|
|
@@ -1,56 +1,36 @@
|
|
|
-package com.java110.api.listener.user;
|
|
|
+package com.java110.user.cmd.user;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
-import com.java110.api.bmo.user.IUserBMO;
|
|
|
-import com.java110.api.listener.AbstractServiceApiPlusListener;
|
|
|
-import com.java110.core.annotation.Java110Listener;
|
|
|
+import com.java110.core.annotation.Java110Cmd;
|
|
|
+import com.java110.core.annotation.Java110Transactional;
|
|
|
import com.java110.core.context.DataFlowContext;
|
|
|
-import com.java110.core.event.service.api.ServiceDataFlowEvent;
|
|
|
-import com.java110.core.factory.DataFlowFactory;
|
|
|
+import com.java110.core.context.ICmdDataFlowContext;
|
|
|
+import com.java110.core.event.cmd.Cmd;
|
|
|
+import com.java110.core.event.cmd.CmdEvent;
|
|
|
import com.java110.core.factory.GenerateCodeFactory;
|
|
|
+import com.java110.dto.file.FileDto;
|
|
|
+import com.java110.dto.file.FileRelDto;
|
|
|
import com.java110.dto.org.OrgStaffRelDto;
|
|
|
import com.java110.dto.user.UserDto;
|
|
|
import com.java110.intf.common.IFileInnerServiceSMO;
|
|
|
import com.java110.intf.common.IFileRelInnerServiceSMO;
|
|
|
-import com.java110.dto.file.FileDto;
|
|
|
-import com.java110.dto.file.FileRelDto;
|
|
|
-import com.java110.entity.center.AppService;
|
|
|
+import com.java110.intf.store.IOrgStaffRelV1InnerServiceSMO;
|
|
|
import com.java110.intf.user.IOrgStaffRelInnerServiceSMO;
|
|
|
import com.java110.intf.user.IUserInnerServiceSMO;
|
|
|
+import com.java110.intf.user.IUserV1InnerServiceSMO;
|
|
|
import com.java110.po.file.FileRelPo;
|
|
|
import com.java110.po.org.OrgStaffRelPo;
|
|
|
import com.java110.po.user.UserPo;
|
|
|
-import com.java110.utils.constant.BusinessTypeConstant;
|
|
|
-import com.java110.utils.constant.CommonConstant;
|
|
|
-import com.java110.utils.constant.ServiceCodeConstant;
|
|
|
-import com.java110.utils.exception.ListenerExecuteException;
|
|
|
+import com.java110.utils.exception.CmdException;
|
|
|
import com.java110.utils.util.Assert;
|
|
|
import com.java110.utils.util.BeanConvertUtil;
|
|
|
-import com.java110.vo.ResultVo;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
-import org.slf4j.Logger;
|
|
|
-import com.java110.core.log.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.http.HttpEntity;
|
|
|
-import org.springframework.http.HttpHeaders;
|
|
|
-import org.springframework.http.HttpMethod;
|
|
|
-import org.springframework.http.HttpStatus;
|
|
|
-import org.springframework.http.ResponseEntity;
|
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
-/**
|
|
|
- * 修改员工 2018年12月6日
|
|
|
- * Created by wuxw on 2018/5/18.
|
|
|
- */
|
|
|
-@Java110Listener("modifyStaffServiceListener")
|
|
|
-public class ModifyStaffServiceListener extends AbstractServiceApiPlusListener {
|
|
|
-
|
|
|
- private final static Logger logger = LoggerFactory.getLogger(ModifyStaffServiceListener.class);
|
|
|
-
|
|
|
- @Autowired
|
|
|
- private IUserBMO userBMOImpl;
|
|
|
-
|
|
|
+@Java110Cmd(serviceCode = "user.staff.modify")
|
|
|
+public class UserStaffModifyCmd extends Cmd {
|
|
|
@Autowired
|
|
|
private IFileInnerServiceSMO fileInnerServiceSMOImpl;
|
|
|
|
|
|
@@ -61,35 +41,25 @@ public class ModifyStaffServiceListener extends AbstractServiceApiPlusListener {
|
|
|
private IUserInnerServiceSMO userInnerServiceSMOImpl;
|
|
|
|
|
|
@Autowired
|
|
|
- private IOrgStaffRelInnerServiceSMO orgStaffRelInnerServiceSMOImpl;
|
|
|
+ private IUserV1InnerServiceSMO userV1InnerServiceSMOImpl;
|
|
|
|
|
|
- @Override
|
|
|
- public String getServiceCode() {
|
|
|
- return ServiceCodeConstant.SERVICE_CODE_USER_STAFF_MODIFY;
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public HttpMethod getHttpMethod() {
|
|
|
- return HttpMethod.POST;
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- @Override
|
|
|
- public int getOrder() {
|
|
|
- return 0;
|
|
|
- }
|
|
|
+ @Autowired
|
|
|
+ private IOrgStaffRelInnerServiceSMO orgStaffRelInnerServiceSMOImpl;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private IOrgStaffRelV1InnerServiceSMO orgStaffRelV1InnerServiceSMOImpl;
|
|
|
|
|
|
@Override
|
|
|
- protected void validate(ServiceDataFlowEvent event, JSONObject reqJson) {
|
|
|
- Assert.jsonObjectHaveKey(reqJson, "userId", "请求参数中未包含userId 节点,请确认");
|
|
|
+ public void validate(CmdEvent event, ICmdDataFlowContext context, JSONObject reqJson) throws CmdException {
|
|
|
+ Assert.jsonObjectHaveKey(reqJson, "staffId", "请求参数中未包含员工 节点,请确认");
|
|
|
//校验json 格式中是否包含 name,email,levelCd,tel
|
|
|
Assert.jsonObjectHaveKey(reqJson, "name", "请求参数中未包含name 节点,请确认");
|
|
|
Assert.jsonObjectHaveKey(reqJson, "tel", "请求参数中未包含tel 节点,请确认");
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- protected void doSoService(ServiceDataFlowEvent event, DataFlowContext context, JSONObject reqJson) {
|
|
|
+ @Java110Transactional
|
|
|
+ public void doCmd(CmdEvent event, ICmdDataFlowContext context, JSONObject reqJson) throws CmdException {
|
|
|
if (reqJson.containsKey("photo") && !StringUtils.isEmpty(reqJson.getString("photo"))) {
|
|
|
FileDto fileDto = new FileDto();
|
|
|
fileDto.setFileId(GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_file_id));
|
|
|
@@ -112,22 +82,28 @@ public class ModifyStaffServiceListener extends AbstractServiceApiPlusListener {
|
|
|
businessUnit.put("fileRealName", fileDto.getFileId());
|
|
|
businessUnit.put("fileSaveName", fileName);
|
|
|
FileRelPo fileRelPo = BeanConvertUtil.covertBean(businessUnit, FileRelPo.class);
|
|
|
- super.insert(context, fileRelPo, BusinessTypeConstant.BUSINESS_TYPE_SAVE_FILE_REL);
|
|
|
+ int flag = fileRelInnerServiceSMOImpl.saveFileRel(fileRelPo);
|
|
|
+ if (flag < 1) {
|
|
|
+ throw new CmdException("保存图片异常");
|
|
|
+ }
|
|
|
} else {
|
|
|
JSONObject businessUnit = new JSONObject();
|
|
|
businessUnit.putAll(BeanConvertUtil.beanCovertMap(fileRelDtos.get(0)));
|
|
|
businessUnit.put("fileRealName", fileDto.getFileId());
|
|
|
businessUnit.put("fileSaveName", fileName);
|
|
|
FileRelPo fileRelPo = BeanConvertUtil.covertBean(businessUnit, FileRelPo.class);
|
|
|
- super.update(context, fileRelPo, BusinessTypeConstant.BUSINESS_TYPE_UPDATE_FILE_REL);
|
|
|
+ int flag = fileRelInnerServiceSMOImpl.updateFileRel(fileRelPo);
|
|
|
+ if (flag < 1) {
|
|
|
+ throw new CmdException("保存图片异常");
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
- modifyStaff(reqJson, context);
|
|
|
- }
|
|
|
+ modifyStaff(reqJson);
|
|
|
|
|
|
+ }
|
|
|
|
|
|
- private void modifyStaff(JSONObject paramObj, DataFlowContext dataFlowContext) {
|
|
|
- UserPo userPo = BeanConvertUtil.covertBean(builderStaffInfo(paramObj, dataFlowContext), UserPo.class);
|
|
|
+ private void modifyStaff(JSONObject paramObj) {
|
|
|
+ UserPo userPo = BeanConvertUtil.covertBean(paramObj, UserPo.class);
|
|
|
//根据手机号查询用户
|
|
|
UserDto userDto = new UserDto();
|
|
|
userDto.setTel(userPo.getTel());
|
|
|
@@ -140,54 +116,28 @@ public class ModifyStaffServiceListener extends AbstractServiceApiPlusListener {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- super.update(dataFlowContext, userPo, BusinessTypeConstant.BUSINESS_TYPE_MODIFY_USER_INFO);
|
|
|
+ int flag = userV1InnerServiceSMOImpl.updateUser(userPo);
|
|
|
+
|
|
|
+ if (flag < 1) {
|
|
|
+ throw new CmdException("保存用户异常");
|
|
|
+ }
|
|
|
OrgStaffRelDto orgStaffRelDto = new OrgStaffRelDto();
|
|
|
orgStaffRelDto.setStaffId(userPo.getUserId());
|
|
|
List<OrgStaffRelDto> orgStaffRelDtoList = orgStaffRelInnerServiceSMOImpl.queryOrgInfoByStaffIds(orgStaffRelDto);
|
|
|
- if (orgStaffRelDtoList.size() != 1) {
|
|
|
- ResponseEntity<String> responseEntity = ResultVo.createResponseEntity(ResultVo.CODE_BUSINESS_VERIFICATION, "当前用户在添加是没有初始化工作岗位职称!");
|
|
|
- dataFlowContext.setResponseEntity(responseEntity);
|
|
|
+
|
|
|
+ if (orgStaffRelDtoList == null || orgStaffRelDtoList.size() < 1) {
|
|
|
return;
|
|
|
}
|
|
|
OrgStaffRelPo orgStaffRelPo = new OrgStaffRelPo();
|
|
|
orgStaffRelPo.setRelCd(paramObj.getString("relCd"));
|
|
|
orgStaffRelPo.setRelId(orgStaffRelDtoList.get(0).getRelId());
|
|
|
orgStaffRelPo.setOrgId(paramObj.getString("orgId"));
|
|
|
- super.update(dataFlowContext, orgStaffRelPo, BusinessTypeConstant.BUSINESS_TYPE_UPDATE_ORG_STAFF_REL);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 构建员工信息
|
|
|
- *
|
|
|
- * @param paramObj
|
|
|
- * @param dataFlowContext
|
|
|
- * @return
|
|
|
- */
|
|
|
- private JSONObject builderStaffInfo(JSONObject paramObj, DataFlowContext dataFlowContext) {
|
|
|
-
|
|
|
- //首先根据员工ID查询员工信息,根据员工信息修改相应的数据
|
|
|
- ResponseEntity responseEntity = null;
|
|
|
- AppService appService = DataFlowFactory.getService(dataFlowContext.getAppId(), ServiceCodeConstant.SERVICE_CODE_QUERY_USER_USERINFO);
|
|
|
- if (appService == null) {
|
|
|
- throw new ListenerExecuteException(1999, "当前没有权限访问" + ServiceCodeConstant.SERVICE_CODE_QUERY_USER_USERINFO);
|
|
|
|
|
|
+ flag = orgStaffRelV1InnerServiceSMOImpl.updateOrgStaffRel(orgStaffRelPo);
|
|
|
+ if (flag < 1) {
|
|
|
+ throw new CmdException("保存员工 失败");
|
|
|
}
|
|
|
- String requestUrl = appService.getUrl() + "?userId=" + paramObj.getString("userId");
|
|
|
- HttpHeaders header = new HttpHeaders();
|
|
|
- header.add(CommonConstant.HTTP_SERVICE.toLowerCase(), ServiceCodeConstant.SERVICE_CODE_QUERY_USER_USERINFO);
|
|
|
- dataFlowContext.getRequestHeaders().put("REQUEST_URL", requestUrl);
|
|
|
- HttpEntity<String> httpEntity = new HttpEntity<String>("", header);
|
|
|
- doRequest(dataFlowContext, appService, httpEntity);
|
|
|
- responseEntity = dataFlowContext.getResponseEntity();
|
|
|
-
|
|
|
- if (responseEntity.getStatusCode() != HttpStatus.OK) {
|
|
|
- dataFlowContext.setResponseEntity(responseEntity);
|
|
|
- }
|
|
|
-
|
|
|
- JSONObject userInfo = JSONObject.parseObject(responseEntity.getBody().toString());
|
|
|
- userInfo.putAll(paramObj);
|
|
|
-
|
|
|
- return userInfo;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
}
|