소스 검색

用户-类型和角色补充

zdm 6 년 전
부모
커밋
dec8eb043e
1개의 변경된 파일32개의 추가작업 그리고 9개의 파일을 삭제
  1. 32 9
      src/main/java/com.yihu.ehr/basic/user/controller/UserEndPoint.java

+ 32 - 9
src/main/java/com.yihu.ehr/basic/user/controller/UserEndPoint.java

@ -10,17 +10,12 @@ import com.yihu.ehr.basic.org.model.OrgMemberRelation;
import com.yihu.ehr.basic.org.service.OrgMemberRelationService;
import com.yihu.ehr.basic.patient.service.DemographicService;
import com.yihu.ehr.basic.security.service.UserSecurityService;
import com.yihu.ehr.basic.user.dao.XUserTypeRepository;
import com.yihu.ehr.basic.user.dao.XUserTypeRolesRepository;
import com.yihu.ehr.basic.user.entity.Roles;
import com.yihu.ehr.basic.user.entity.UserTypeRoles;
import com.yihu.ehr.basic.user.service.RoleUserService;
import com.yihu.ehr.basic.user.service.RolesService;
import com.yihu.ehr.basic.user.entity.*;
import com.yihu.ehr.basic.user.service.*;
import com.yihu.ehr.commons.constants.BasicServiceApi;
import com.yihu.ehr.constants.ServiceApi;
import com.yihu.ehr.basic.user.entity.Doctors;
import com.yihu.ehr.basic.user.entity.User;
import com.yihu.ehr.basic.user.service.DoctorService;
import com.yihu.ehr.basic.user.service.UserService;
import com.yihu.ehr.constants.ApiVersion;
import com.yihu.ehr.controller.EnvelopRestEndPoint;
import com.yihu.ehr.entity.dict.SystemDictEntry;
@ -30,6 +25,7 @@ import com.yihu.ehr.entity.security.UserSecurity;
import com.yihu.ehr.fastdfs.FastDFSUtil;
import com.yihu.ehr.model.org.MJkzlOrgMemberRelation;
import com.yihu.ehr.model.user.MH5Handshake;
import com.yihu.ehr.model.user.MRoleUser;
import com.yihu.ehr.model.user.MUser;
import com.yihu.ehr.util.datetime.DateUtil;
import com.yihu.ehr.util.id.BizObject;
@ -107,6 +103,10 @@ public class UserEndPoint extends EnvelopRestEndPoint {
    private XUserTypeRolesRepository xUserTypeRolesRepository;
    @Autowired
    private XFileResourceRepository resourceRepository;
    @Autowired
    private XUserTypeRepository xUserTypeRepository;
    @Autowired
    private UserTypeService userTypeService;
    @RequestMapping(value = ServiceApi.Users.Users, method = RequestMethod.GET)
    @ApiOperation(value = "获取用户列表", notes = "根据查询条件获取用户列表在前端表格展示")
@ -1175,7 +1175,7 @@ public class UserEndPoint extends EnvelopRestEndPoint {
                User user = users.get(0);
                String path = getImgPathByFileResource(users.get(0).getImgRemotePath());
                user.setImgRemotePath(path);
                envelop.setObj(users);
                if (users.size() == 1) {
                    List<OrgMemberRelation> memberRelations = orgMemberRelationService.findByField("userId", users.get(0).getId());
                    envelop.setSuccessFlg(true);
@ -1184,6 +1184,29 @@ public class UserEndPoint extends EnvelopRestEndPoint {
                    envelop.setSuccessFlg(false);
                    envelop.setErrorMsg("账号重复,请联系管理员!");
                }
                MUser userModel = convertToModel(user, MUser.class);
                //获取用户类型
                String userType = user.getUserType().toString();
                if (org.apache.commons.lang3.StringUtils.isNotEmpty(userType)) {
                    int userTypeInt = Integer.parseInt(user.getUserType().toString());
                    UserType userTypeObj = xUserTypeRepository.findById(userTypeInt);
                    if(userTypeObj != null){
                        userModel.setUserTypeName(userTypeObj.getName());
                    }
                }
                //获取用户角色
                user.setRole("");
                List<RoleUser> roleUserList = roleUserService.search("userId=" + user.getId());
                if (null != roleUserList && roleUserList.size() > 0) {
                    StringBuffer buffer = new StringBuffer();
                    for (RoleUser m : roleUserList) {
                        buffer.append(m.getRoleId());
                        buffer.append(",");
                    }
                    userModel.setRole(buffer.substring(0, buffer.length() - 1));
                }
                envelop.setObj(userModel);
            } else {
                envelop.setSuccessFlg(false);
                envelop.setErrorMsg("该账号不存在,请确认或联系管理员!");