Commit 21f1179a2fd44051c62824d38dd86cf6a79c8ab3

Authored by jiangjiazhi
1 parent ecb99dac5a

增加

Showing 5 changed files with 75 additions and 3 deletions

platform-biz-service/src/main/java/com/lyms/platform/permission/model/OrganizationQuery.java View file @ 21f1179
... ... @@ -4,6 +4,7 @@
4 4 import com.lyms.platform.common.dao.BaseQuery;
5 5  
6 6 import java.util.Date;
  7 +import java.util.List;
7 8  
8 9  
9 10 public class OrganizationQuery extends BaseQuery {
... ... @@ -27,6 +28,15 @@
27 28 private String keyword;
28 29 private String foreignId;
29 30  
  31 + private List<Integer> typeList;
  32 +
  33 + public List<Integer> getTypeList() {
  34 + return typeList;
  35 + }
  36 +
  37 + public void setTypeList(List<Integer> typeList) {
  38 + this.typeList = typeList;
  39 + }
30 40  
31 41 public String getStreetId() {
32 42 return streetId;
platform-biz-service/src/main/resources/mainOrm/Organization.xml View file @ 21f1179
... ... @@ -171,6 +171,12 @@
171 171 <if test="keyword != null and keyword != ''">
172 172 and name like CONCAT(#{keyword}, '%')
173 173 </if>
  174 + <if test="typeList != null">
  175 + and type in
  176 + <foreach collection="typeList" index="index" item="item" open="(" separator="," close=")">
  177 + #{item}
  178 + </foreach>
  179 + </if>
174 180 </where>
175 181 </sql>
176 182  
platform-operate-api/src/main/java/com/lyms/platform/operate/web/Test.java View file @ 21f1179
  1 +package com.lyms.platform.operate.web;
  2 +
  3 +
  4 +import org.springframework.util.StopWatch;
  5 +
  6 +/**
  7 + * Created by Administrator on 2016/5/3 0003.
  8 + */
  9 +public class Test {
  10 + public static void main(String[] args){
  11 + StopWatch stopWatch= new StopWatch("doctor-api-patient");
  12 + stopWatch.start("query patients");
  13 + add();
  14 + stopWatch.stop();
  15 + stopWatch.start("query patients1");
  16 + add();
  17 + stopWatch.stop();
  18 + stopWatch.start("query patients2");
  19 + add();
  20 + stopWatch.stop();
  21 + System.out.print(stopWatch);
  22 + }
  23 + private static void add(){
  24 + int a=0;
  25 + for(int i =0;i<100000;i++){
  26 + a +=i;
  27 + }
  28 + System.out.println(a);
  29 + }
  30 +}
platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/DepartmentsController.java View file @ 21f1179
... ... @@ -7,9 +7,11 @@
7 7 import com.lyms.platform.common.constants.ErrorCodeConstants;
8 8 import com.lyms.platform.common.enums.YnEnums;
9 9 import com.lyms.platform.common.utils.ResultUtils;
  10 +import com.lyms.platform.operate.web.facade.AutoMatchFacade;
10 11 import com.lyms.platform.operate.web.result.FrontEndResult;
11 12 import com.lyms.platform.permission.model.*;
12 13 import com.lyms.platform.permission.service.*;
  14 +import org.apache.commons.lang.StringUtils;
13 15 import org.springframework.beans.factory.annotation.Autowired;
14 16 import org.springframework.stereotype.Controller;
15 17 import org.springframework.web.bind.annotation.*;
... ... @@ -38,6 +40,8 @@
38 40 private RolePermissionMapsService rolePermissionMapsService;
39 41 @Autowired
40 42 private OrganizationService organizationService;
  43 + @Autowired
  44 + private AutoMatchFacade autoMatchFacade;
41 45  
42 46  
43 47  
... ... @@ -163,7 +167,7 @@
163 167 @RequestMapping(value = "/departments", method = RequestMethod.GET)
164 168 @ResponseBody
165 169 @TokenRequired
166   - public FrontEndResult getPermissions(HttpServletResponse response,
  170 + public FrontEndResult getPermissions(HttpServletRequest request,
167 171 @RequestParam(value = "keyword", required = false) String keyword,
168 172 @RequestParam(value = "page", required = false) Integer page,
169 173 @RequestParam(value = "limit", required = false) Integer limit,
170 174  
... ... @@ -172,12 +176,18 @@
172 176 limit = limit == null ? 10 : limit;
173 177 page = page == null ? 1 : page;
174 178  
175   -
  179 + LoginContext loginState = (LoginContext) request.getAttribute("loginContext");
176 180 DepartmentsQuery departmentsQuery = new DepartmentsQuery();
177 181 departmentsQuery.setNeed("true");
178 182 departmentsQuery.setSort("id desc");
179 183 departmentsQuery.setYn(YnEnums.YES.getId());
180   - departmentsQuery.setOrgId(orgId);
  184 + Integer orgId1 = autoMatchFacade.matchOrgId(loginState.getId());
  185 + if(null!=orgId){
  186 + departmentsQuery.setOrgId(orgId);
  187 + }else{
  188 + departmentsQuery.setOrgId(orgId1);
  189 + }
  190 +
181 191 departmentsQuery.setPage(page);
182 192 departmentsQuery.setKeyword(keyword);
183 193 departmentsQuery.setLimit(limit);
platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/AutoMatchFacade.java View file @ 21f1179
... ... @@ -48,6 +48,22 @@
48 48 return null;
49 49 }
50 50  
  51 + public Integer matchOrgId(int userId){
  52 + UsersQuery usersQuery = new UsersQuery();
  53 + usersQuery.setId(userId);
  54 +
  55 + usersQuery.setYn(1);
  56 + List<Users> list = usersService.queryUsers(usersQuery);
  57 + if (CollectionUtils.isNotEmpty(list)) {
  58 + //用户角色
  59 + if (list.get(0).getType() == 1) {
  60 + Organization organization = organizationService.getOrganization(list.get(0).getOrgId());
  61 + return organization.getId();
  62 + }
  63 + }
  64 + return null;
  65 + }
  66 +
51 67  
52 68 public List<CommunityConfig> findCommunity(String areaId) {
53 69 CommunityQuery communityQuery = new CommunityQuery();