| | |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.java110.core.annotation.Java110Cmd; |
| | | import com.java110.core.context.Environment; |
| | | import com.java110.core.context.ICmdDataFlowContext; |
| | | import com.java110.core.event.cmd.AbstractServiceCmdListener; |
| | | import com.java110.core.event.cmd.Cmd; |
| | | import com.java110.core.event.cmd.CmdEvent; |
| | | import com.java110.core.factory.AuthenticationFactory; |
| | | import com.java110.core.factory.GenerateCodeFactory; |
| | |
| | | import java.util.List; |
| | | |
| | | @Java110Cmd(serviceCode = "user.resetStaffPwd") |
| | | public class ResetStaffPwdCmd extends AbstractServiceCmdListener { |
| | | public class ResetStaffPwdCmd extends Cmd { |
| | | |
| | | @Autowired |
| | | private IStoreUserV1InnerServiceSMO storeUserV1InnerServiceSMOImpl; |
| | |
| | | @Override |
| | | public void validate(CmdEvent event, ICmdDataFlowContext cmdDataFlowContext, JSONObject reqJson) { |
| | | |
| | | Environment.isDevEnv(); |
| | | |
| | | if(reqJson.containsKey("storeId") && StoreDto.STORE_ADMIN.equals(reqJson.getString("storeId"))){ |
| | | return ; |
| | | } |
| | | |
| | | if (!reqJson.containsKey("staffId")) { |
| | | reqJson.put("staffId", reqJson.getString("userId")); |
| | | } |
| | | |
| | | Assert.jsonObjectHaveKey(reqJson, "staffId", "请求参数中未包含staffId 节点,请确认"); |
| | | |
| | | StoreUserDto storeUserDt = new StoreUserDto(); |
| | | storeUserDt.setUserId(reqJson.getString("userId")); |
| | | List<StoreUserDto> storeUserDts = storeUserV1InnerServiceSMOImpl.queryStoreUsers(storeUserDt); |
| | | Assert.listOnlyOne(storeUserDts, "查询员工商户错误!"); |
| | | |
| | | //首先判断是否为 运营或者开发 |
| | | //查询store 信息 |
| | | StoreDto storeDto = new StoreDto(); |
| | | storeDto.setStoreId(reqJson.getString("storeId")); |
| | | if (!reqJson.containsKey("storeId")) { |
| | | storeDto.setStoreId(storeUserDts.get(0).getStoreId()); |
| | | } else { |
| | | storeDto.setStoreId(reqJson.getString("storeId")); |
| | | } |
| | | List<StoreDto> storeDtos = storeV1InnerServiceSMOImpl.queryStores(storeDto); |
| | | |
| | | Assert.listOnlyOne(storeDtos, "商户不存在"); |
| | |
| | | |
| | | //校验 staff 和 store 之间是否有 关系 防止 攻击 |
| | | StoreUserDto storeUserDto = new StoreUserDto(); |
| | | storeUserDto.setUserId(reqJson.getString("staffId")); |
| | | storeUserDto.setUserId(reqJson.getString("userId")); |
| | | storeUserDto.setStoreId(reqJson.getString("storeId")); |
| | | List<StoreUserDto> storeUserDtos = storeUserV1InnerServiceSMOImpl.queryStoreUsers(storeUserDto); |
| | | |
| | |
| | | modifyStaff(reqJson, cmdDataFlowContext); |
| | | JSONObject paramOut = new JSONObject(); |
| | | paramOut.put("pwd", reqJson.getString("pwd")); |
| | | paramOut.put("code",0); |
| | | paramOut.put("msg","成功"); |
| | | ResponseEntity<String> responseEntity = new ResponseEntity<>(paramOut.toJSONString(), HttpStatus.OK); |
| | | cmdDataFlowContext.setResponseEntity(responseEntity); |
| | | |
| | |
| | | |
| | | JSONObject userInfo = JSONObject.parseObject(JSONObject.toJSONString(userDtos.get(0))); |
| | | String pwd = GenerateCodeFactory.getRandomCode(6); |
| | | userInfo.putAll(paramObj); |
| | | //userInfo.putAll(paramObj); |
| | | userInfo.put("password", AuthenticationFactory.passwdMd5(pwd)); |
| | | paramObj.put("pwd", pwd); |
| | | |