Commit 89c76ecea2888e80eb04e4c34a4ace3fcc31bbc3

Authored by hanshaofeng
1 parent 311c49a259

permission2

Showing 5 changed files with 65 additions and 4 deletions

platform-biz-service/src/main/java/com/lyms/platform/permission/service/OrganizationService.java View file @ 89c76ec
... ... @@ -27,5 +27,7 @@
27 27 * 维护用户机构权限为最新状态,机构新增、修改、删除时执行;用户新增、修改、删除时执行
28 28 */
29 29 public void rebuildDataPermissions(Integer userId);
  30 +
  31 + public void rebuildDefaultRoles();
30 32 }
platform-biz-service/src/main/java/com/lyms/platform/permission/service/impl/OrganizationServiceImpl.java View file @ 89c76ec
... ... @@ -61,6 +61,16 @@
61 61 return obj.getId();
62 62 }
63 63  
  64 + @Override
  65 + public void rebuildDefaultRoles() {
  66 + OrganizationQuery query = new OrganizationQuery();
  67 + query.setYn(1);
  68 + List<Organization> list = masterOrganizationMapper.queryOrganization(query);
  69 + for (Organization obj:list) {
  70 + addDefaultRoles(obj);
  71 + }
  72 + }
  73 +
64 74 private void addDefaultRoles(Organization obj) {
65 75 List<Roles> rolesList = new ArrayList<>();
66 76 rolesList.add(rolesService.getRoles(87));
... ... @@ -80,7 +90,7 @@
80 90 roles.setOrgId(obj.getId());
81 91 roles.setModified(new Date());
82 92 roles.setCreated(roles.getModified());
83   - roles.setRemarks(obj.getName());
  93 + roles.setRemarks(obj.getName()+"_"+mapsQuery.getRoleId());
84 94 rolesService.addRoles(roles);
85 95 for (RolePermissionMaps maps:mapsList) {
86 96 maps.setId(null);
platform-biz-service/src/main/resources/mainOrm/master/MasterRoles.xml View file @ 89c76ec
... ... @@ -145,7 +145,7 @@
145 145  
146 146  
147 147 <select id="queryRoles" resultMap="RolesResultMap" parameterType="com.lyms.platform.permission.model.RolesQuery">
148   - select id,type,name,publish_id,publish_name,yn,enable,modified,created,remarks,shortCode,permissiontype
  148 + select id,type,name,publish_id,publish_name,yn,enable,modified,created,remarks,shortCode,permissiontype,orgid
149 149 from roles
150 150 <include refid="RolesCondition"/>
151 151 <include refid="orderAndLimit"/>
platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/TestController.java View file @ 89c76ec
... ... @@ -9,6 +9,7 @@
9 9 import com.lyms.platform.common.utils.DateUtil;
10 10 import com.lyms.platform.common.utils.JsonUtil;
11 11 import com.lyms.platform.operate.web.service.SyncDataTaskService;
  12 +import com.lyms.platform.permission.service.OrganizationService;
12 13 import com.lyms.platform.pojo.AssayConfig;
13 14 import com.lyms.platform.pojo.Patients;
14 15 import com.lyms.platform.query.PatientsQuery;
15 16  
... ... @@ -47,9 +48,11 @@
47 48 @Autowired
48 49 private SyncDataTaskService syncDataTaskService;
49 50 @Autowired
50   - private SieveService sieveService
51   - ;
  51 + private SieveService sieveService;
52 52  
  53 + @Autowired
  54 + private OrganizationService organizationService;
  55 +
53 56 /**
54 57 * 获取科室
55 58 */
... ... @@ -275,6 +278,13 @@
275 278 }
276 279  
277 280 return "update finish";
  281 + }
  282 +
  283 + @RequestMapping(value = "/rebuildDefaultRoles", method = RequestMethod.GET)
  284 + @ResponseBody
  285 + public String rebuildDefaultRoles() {
  286 + organizationService.rebuildDefaultRoles();
  287 + return "sieveOrder finish";
278 288 }
279 289  
280 290 }
platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/UsersController.java View file @ 89c76ec
... ... @@ -76,6 +76,45 @@
76 76 private static final String replacePwd = "[$#&/]-+";
77 77  
78 78  
  79 + public String rebuildUserRoles(@RequestParam(value = "hospitalId")Integer hospitalId) {
  80 + StringBuffer sb = new StringBuffer();
  81 + Organization organization = organizationService.getOrganization(hospitalId);
  82 + if (organization != null) {
  83 + RolesQuery rolesQuery = new RolesQuery();
  84 + rolesQuery.setYn(YnEnums.YES.getId());
  85 + List<Integer> orgids = new ArrayList<>();
  86 + orgids.add(hospitalId);
  87 + rolesQuery.setOrgIds(orgids);
  88 + List<Roles> rolesList = rolesService.queryRoles(rolesQuery);
  89 + if (rolesList == null || rolesList.size() == 0) {
  90 + sb.append("机构下权限不存在:"+hospitalId);
  91 + } else {
  92 + Map<Integer,Roles> rolesMap = new HashMap<>();
  93 + for (Roles r:rolesList) {
  94 + rolesMap.put(Integer.valueOf(r.getRemarks().split("_")[1 ]), r);
  95 + }
  96 + UsersQuery usersQuery = new UsersQuery();
  97 + usersQuery.setOrgId(hospitalId);
  98 + List<Users> list = usersService.queryUsers(usersQuery);
  99 + UserRoleMapsQuery mapsQuery = new UserRoleMapsQuery();
  100 + mapsQuery.setYn(YnEnums.YES.getId());
  101 + for (Users users : list) {
  102 + mapsQuery.setUserId(users.getId());
  103 + List<UserRoleMaps> mapsList = userRoleMapsService.queryUserRoleMaps(mapsQuery);
  104 + for (UserRoleMaps maps : mapsList) {
  105 +
  106 + }
  107 + }
  108 + }
  109 +
  110 +
  111 +
  112 + } else {
  113 + sb.append("机构不存在:"+hospitalId);
  114 + }
  115 + return sb.toString();
  116 + }
  117 +
79 118 /**
80 119 * 获取管理员列表
81 120 */