Commit 19e69558068025b02e6680add1b6c3d70d302e1c
1 parent
10b9ff1fd3
Exists in
master
and in
1 other branch
platform permission
Showing 8 changed files with 272 additions and 186 deletions
- platform-biz-service/src/main/java/com/lyms/platform/permission/model/Organization.java
- platform-biz-service/src/main/java/com/lyms/platform/permission/model/Users.java
- platform-common/src/main/java/com/lyms/platform/common/utils/ResultUtils.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/DepartmentsController.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/OrganizationController.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/PermissionsController.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/RolesController.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/UsersController.java
platform-biz-service/src/main/java/com/lyms/platform/permission/model/Organization.java
View file @
19e6955
| ... | ... | @@ -2,177 +2,177 @@ |
| 2 | 2 | |
| 3 | 3 | import java.util.Date; |
| 4 | 4 | |
| 5 | -public class Organization {private Integer id;private String name;private Integer type;private Integer level;private Integer areaManage;private Integer provinceId;private Integer cityId;private Integer areaId;private String address;private String description;private Integer publishId;private String publishName;private Integer yn;private Date modified;private Date created;private String shortCode; | |
| 5 | +public class Organization { | |
| 6 | + private Integer id; | |
| 7 | + private String name; | |
| 8 | + private Integer type; | |
| 9 | + private Integer level; | |
| 10 | + private Integer areaManage; | |
| 11 | + private Integer provinceId; | |
| 12 | + private Integer cityId; | |
| 13 | + private Integer areaId; | |
| 14 | + private String address; | |
| 15 | + private String description; | |
| 16 | + private Integer publishId; | |
| 17 | + private String publishName; | |
| 18 | + private Integer yn; | |
| 19 | + private Date modified; | |
| 20 | + private Date created; | |
| 21 | + private String shortCode; | |
| 6 | 22 | |
| 7 | -public Integer getId() { | |
| 23 | + public Integer getId() { | |
| 8 | 24 | return id; |
| 9 | 25 | } |
| 10 | 26 | |
| 11 | 27 | |
| 12 | - | |
| 13 | 28 | public void setId(Integer id) { |
| 14 | 29 | this.id = id; |
| 15 | 30 | |
| 16 | 31 | } |
| 17 | 32 | |
| 18 | -public String getName() { | |
| 33 | + public String getName() { | |
| 19 | 34 | return name; |
| 20 | 35 | } |
| 21 | 36 | |
| 22 | 37 | |
| 23 | - | |
| 24 | 38 | public void setName(String name) { |
| 25 | 39 | this.name = name; |
| 26 | 40 | |
| 27 | 41 | } |
| 28 | 42 | |
| 29 | -public Integer getType() { | |
| 43 | + public Integer getType() { | |
| 30 | 44 | return type; |
| 31 | 45 | } |
| 32 | 46 | |
| 33 | 47 | |
| 34 | - | |
| 35 | 48 | public void setType(Integer type) { |
| 36 | 49 | this.type = type; |
| 37 | 50 | |
| 38 | 51 | } |
| 39 | 52 | |
| 40 | -public Integer getLevel() { | |
| 53 | + public Integer getLevel() { | |
| 41 | 54 | return level; |
| 42 | 55 | } |
| 43 | 56 | |
| 44 | 57 | |
| 45 | - | |
| 46 | 58 | public void setLevel(Integer level) { |
| 47 | 59 | this.level = level; |
| 48 | 60 | |
| 49 | 61 | } |
| 50 | 62 | |
| 51 | -public Integer getAreaManage() { | |
| 63 | + public Integer getAreaManage() { | |
| 52 | 64 | return areaManage; |
| 53 | 65 | } |
| 54 | 66 | |
| 55 | 67 | |
| 56 | - | |
| 57 | 68 | public void setAreaManage(Integer areaManage) { |
| 58 | 69 | this.areaManage = areaManage; |
| 59 | 70 | |
| 60 | 71 | } |
| 61 | 72 | |
| 62 | -public Integer getProvinceId() { | |
| 73 | + public Integer getProvinceId() { | |
| 63 | 74 | return provinceId; |
| 64 | 75 | } |
| 65 | 76 | |
| 66 | 77 | |
| 67 | - | |
| 68 | 78 | public void setProvinceId(Integer provinceId) { |
| 69 | 79 | this.provinceId = provinceId; |
| 70 | 80 | |
| 71 | 81 | } |
| 72 | 82 | |
| 73 | -public Integer getCityId() { | |
| 83 | + public Integer getCityId() { | |
| 74 | 84 | return cityId; |
| 75 | 85 | } |
| 76 | 86 | |
| 77 | 87 | |
| 78 | - | |
| 79 | 88 | public void setCityId(Integer cityId) { |
| 80 | 89 | this.cityId = cityId; |
| 81 | 90 | |
| 82 | 91 | } |
| 83 | 92 | |
| 84 | -public Integer getAreaId() { | |
| 93 | + public Integer getAreaId() { | |
| 85 | 94 | return areaId; |
| 86 | 95 | } |
| 87 | 96 | |
| 88 | 97 | |
| 89 | - | |
| 90 | 98 | public void setAreaId(Integer areaId) { |
| 91 | 99 | this.areaId = areaId; |
| 92 | 100 | |
| 93 | 101 | } |
| 94 | 102 | |
| 95 | -public String getAddress() { | |
| 103 | + public String getAddress() { | |
| 96 | 104 | return address; |
| 97 | 105 | } |
| 98 | 106 | |
| 99 | 107 | |
| 100 | - | |
| 101 | 108 | public void setAddress(String address) { |
| 102 | 109 | this.address = address; |
| 103 | 110 | |
| 104 | 111 | } |
| 105 | 112 | |
| 106 | -public String getDescription() { | |
| 113 | + public String getDescription() { | |
| 107 | 114 | return description; |
| 108 | 115 | } |
| 109 | 116 | |
| 110 | 117 | |
| 111 | - | |
| 112 | 118 | public void setDescription(String description) { |
| 113 | 119 | this.description = description; |
| 114 | 120 | |
| 115 | 121 | } |
| 116 | 122 | |
| 117 | -public Integer getPublishId() { | |
| 123 | + public Integer getPublishId() { | |
| 118 | 124 | return publishId; |
| 119 | 125 | } |
| 120 | 126 | |
| 121 | 127 | |
| 122 | - | |
| 123 | 128 | public void setPublishId(Integer publishId) { |
| 124 | 129 | this.publishId = publishId; |
| 125 | 130 | |
| 126 | 131 | } |
| 127 | 132 | |
| 128 | -public String getPublishName() { | |
| 133 | + public String getPublishName() { | |
| 129 | 134 | return publishName; |
| 130 | 135 | } |
| 131 | 136 | |
| 132 | 137 | |
| 133 | - | |
| 134 | 138 | public void setPublishName(String publishName) { |
| 135 | 139 | this.publishName = publishName; |
| 136 | 140 | |
| 137 | 141 | } |
| 138 | 142 | |
| 139 | -public Integer getYn() { | |
| 143 | + public Integer getYn() { | |
| 140 | 144 | return yn; |
| 141 | 145 | } |
| 142 | 146 | |
| 143 | 147 | |
| 144 | - | |
| 145 | 148 | public void setYn(Integer yn) { |
| 146 | 149 | this.yn = yn; |
| 147 | 150 | |
| 148 | 151 | } |
| 149 | 152 | |
| 150 | -public Date getModified() { | |
| 153 | + public Date getModified() { | |
| 151 | 154 | return modified; |
| 152 | 155 | } |
| 153 | 156 | |
| 154 | 157 | |
| 155 | - | |
| 156 | 158 | public void setModified(Date modified) { |
| 157 | 159 | this.modified = modified; |
| 158 | 160 | |
| 159 | 161 | } |
| 160 | 162 | |
| 161 | -public Date getCreated() { | |
| 163 | + public Date getCreated() { | |
| 162 | 164 | return created; |
| 163 | 165 | } |
| 164 | 166 | |
| 165 | 167 | |
| 166 | - | |
| 167 | 168 | public void setCreated(Date created) { |
| 168 | 169 | this.created = created; |
| 169 | 170 | |
| 170 | 171 | } |
| 171 | 172 | |
| 172 | -public String getShortcode() { | |
| 173 | + public String getShortcode() { | |
| 173 | 174 | return shortCode; |
| 174 | 175 | } |
| 175 | - | |
| 176 | 176 | |
| 177 | 177 | |
| 178 | 178 | public void setShortcode(String shortCode) { |
platform-biz-service/src/main/java/com/lyms/platform/permission/model/Users.java
View file @
19e6955
| ... | ... | @@ -2,177 +2,177 @@ |
| 2 | 2 | |
| 3 | 3 | import java.util.Date; |
| 4 | 4 | |
| 5 | -public class Users {private Integer id;private Integer type;private Integer orgId;private Integer deptId;private String name;private String account;private String pwd;private String phone;private Integer publishId;private String publishName;private Integer yn;private Integer enable;private Date modified;private Date created;private String remarks;private Date lastLoginTime; | |
| 5 | +public class Users { | |
| 6 | + private Integer id; | |
| 7 | + private Integer type; | |
| 8 | + private Integer orgId; | |
| 9 | + private Integer deptId; | |
| 10 | + private String name; | |
| 11 | + private String account; | |
| 12 | + private String pwd; | |
| 13 | + private String phone; | |
| 14 | + private Integer publishId; | |
| 15 | + private String publishName; | |
| 16 | + private Integer yn; | |
| 17 | + private Integer enable; | |
| 18 | + private Date modified; | |
| 19 | + private Date created; | |
| 20 | + private String remarks; | |
| 21 | + private Date lastLoginTime; | |
| 6 | 22 | |
| 7 | -public Integer getId() { | |
| 23 | + public Integer getId() { | |
| 8 | 24 | return id; |
| 9 | 25 | } |
| 10 | 26 | |
| 11 | 27 | |
| 12 | - | |
| 13 | 28 | public void setId(Integer id) { |
| 14 | 29 | this.id = id; |
| 15 | 30 | |
| 16 | 31 | } |
| 17 | 32 | |
| 18 | -public Integer getType() { | |
| 33 | + public Integer getType() { | |
| 19 | 34 | return type; |
| 20 | 35 | } |
| 21 | 36 | |
| 22 | 37 | |
| 23 | - | |
| 24 | 38 | public void setType(Integer type) { |
| 25 | 39 | this.type = type; |
| 26 | 40 | |
| 27 | 41 | } |
| 28 | 42 | |
| 29 | -public Integer getOrgId() { | |
| 43 | + public Integer getOrgId() { | |
| 30 | 44 | return orgId; |
| 31 | 45 | } |
| 32 | 46 | |
| 33 | 47 | |
| 34 | - | |
| 35 | 48 | public void setOrgId(Integer orgId) { |
| 36 | 49 | this.orgId = orgId; |
| 37 | 50 | |
| 38 | 51 | } |
| 39 | 52 | |
| 40 | -public Integer getDeptId() { | |
| 53 | + public Integer getDeptId() { | |
| 41 | 54 | return deptId; |
| 42 | 55 | } |
| 43 | 56 | |
| 44 | 57 | |
| 45 | - | |
| 46 | 58 | public void setDeptId(Integer deptId) { |
| 47 | 59 | this.deptId = deptId; |
| 48 | 60 | |
| 49 | 61 | } |
| 50 | 62 | |
| 51 | -public String getName() { | |
| 63 | + public String getName() { | |
| 52 | 64 | return name; |
| 53 | 65 | } |
| 54 | 66 | |
| 55 | 67 | |
| 56 | - | |
| 57 | 68 | public void setName(String name) { |
| 58 | 69 | this.name = name; |
| 59 | 70 | |
| 60 | 71 | } |
| 61 | 72 | |
| 62 | -public String getAccount() { | |
| 73 | + public String getAccount() { | |
| 63 | 74 | return account; |
| 64 | 75 | } |
| 65 | 76 | |
| 66 | 77 | |
| 67 | - | |
| 68 | 78 | public void setAccount(String account) { |
| 69 | 79 | this.account = account; |
| 70 | 80 | |
| 71 | 81 | } |
| 72 | 82 | |
| 73 | -public String getPwd() { | |
| 83 | + public String getPwd() { | |
| 74 | 84 | return pwd; |
| 75 | 85 | } |
| 76 | 86 | |
| 77 | 87 | |
| 78 | - | |
| 79 | 88 | public void setPwd(String pwd) { |
| 80 | 89 | this.pwd = pwd; |
| 81 | 90 | |
| 82 | 91 | } |
| 83 | 92 | |
| 84 | -public String getPhone() { | |
| 93 | + public String getPhone() { | |
| 85 | 94 | return phone; |
| 86 | 95 | } |
| 87 | 96 | |
| 88 | 97 | |
| 89 | - | |
| 90 | 98 | public void setPhone(String phone) { |
| 91 | 99 | this.phone = phone; |
| 92 | 100 | |
| 93 | 101 | } |
| 94 | 102 | |
| 95 | -public Integer getPublishId() { | |
| 103 | + public Integer getPublishId() { | |
| 96 | 104 | return publishId; |
| 97 | 105 | } |
| 98 | 106 | |
| 99 | 107 | |
| 100 | - | |
| 101 | 108 | public void setPublishId(Integer publishId) { |
| 102 | 109 | this.publishId = publishId; |
| 103 | 110 | |
| 104 | 111 | } |
| 105 | 112 | |
| 106 | -public String getPublishName() { | |
| 113 | + public String getPublishName() { | |
| 107 | 114 | return publishName; |
| 108 | 115 | } |
| 109 | 116 | |
| 110 | 117 | |
| 111 | - | |
| 112 | 118 | public void setPublishName(String publishName) { |
| 113 | 119 | this.publishName = publishName; |
| 114 | 120 | |
| 115 | 121 | } |
| 116 | 122 | |
| 117 | -public Integer getYn() { | |
| 123 | + public Integer getYn() { | |
| 118 | 124 | return yn; |
| 119 | 125 | } |
| 120 | 126 | |
| 121 | 127 | |
| 122 | - | |
| 123 | 128 | public void setYn(Integer yn) { |
| 124 | 129 | this.yn = yn; |
| 125 | 130 | |
| 126 | 131 | } |
| 127 | 132 | |
| 128 | -public Integer getEnable() { | |
| 133 | + public Integer getEnable() { | |
| 129 | 134 | return enable; |
| 130 | 135 | } |
| 131 | 136 | |
| 132 | 137 | |
| 133 | - | |
| 134 | 138 | public void setEnable(Integer enable) { |
| 135 | 139 | this.enable = enable; |
| 136 | 140 | |
| 137 | 141 | } |
| 138 | 142 | |
| 139 | -public Date getModified() { | |
| 143 | + public Date getModified() { | |
| 140 | 144 | return modified; |
| 141 | 145 | } |
| 142 | 146 | |
| 143 | 147 | |
| 144 | - | |
| 145 | 148 | public void setModified(Date modified) { |
| 146 | 149 | this.modified = modified; |
| 147 | 150 | |
| 148 | 151 | } |
| 149 | 152 | |
| 150 | -public Date getCreated() { | |
| 153 | + public Date getCreated() { | |
| 151 | 154 | return created; |
| 152 | 155 | } |
| 153 | 156 | |
| 154 | 157 | |
| 155 | - | |
| 156 | 158 | public void setCreated(Date created) { |
| 157 | 159 | this.created = created; |
| 158 | 160 | |
| 159 | 161 | } |
| 160 | 162 | |
| 161 | -public String getRemarks() { | |
| 163 | + public String getRemarks() { | |
| 162 | 164 | return remarks; |
| 163 | 165 | } |
| 164 | 166 | |
| 165 | 167 | |
| 166 | - | |
| 167 | 168 | public void setRemarks(String remarks) { |
| 168 | 169 | this.remarks = remarks; |
| 169 | 170 | |
| 170 | 171 | } |
| 171 | 172 | |
| 172 | -public Date getLastLoginTime() { | |
| 173 | + public Date getLastLoginTime() { | |
| 173 | 174 | return lastLoginTime; |
| 174 | 175 | } |
| 175 | - | |
| 176 | 176 | |
| 177 | 177 | |
| 178 | 178 | public void setLastLoginTime(Date lastLoginTime) { |
platform-common/src/main/java/com/lyms/platform/common/utils/ResultUtils.java
View file @
19e6955
| ... | ... | @@ -15,6 +15,19 @@ |
| 15 | 15 | public static final String ERROR_CODE="errorcode"; |
| 16 | 16 | public static final String ERROR_MSG="errormsg"; |
| 17 | 17 | |
| 18 | + | |
| 19 | + /** | |
| 20 | + * 返回成功数据 | |
| 21 | + */ | |
| 22 | + public static void buildSuccessResultAndWrite(HttpServletResponse httpServletResponse, Object data){ | |
| 23 | + Map<String,Object> result= new HashMap<String, Object>(); | |
| 24 | + result.put(ERROR_CODE, ErrorCodeConstants.SUCCESS); | |
| 25 | + result.put(ERROR_MSG,"成功"); | |
| 26 | + result.put("list", data); | |
| 27 | + writeJson(httpServletResponse, JsonUtil.obj2JsonString(result)); | |
| 28 | + } | |
| 29 | + | |
| 30 | + | |
| 18 | 31 | /** |
| 19 | 32 | * 返回自定义消息 |
| 20 | 33 | */ |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/DepartmentsController.java
View file @
19e6955
| ... | ... | @@ -5,27 +5,24 @@ |
| 5 | 5 | import com.lyms.platform.common.base.BaseController; |
| 6 | 6 | import com.lyms.platform.common.base.ContextHolder; |
| 7 | 7 | import com.lyms.platform.common.base.PlatformContext; |
| 8 | +import com.lyms.platform.common.constants.ErrorCodeConstants; | |
| 8 | 9 | import com.lyms.platform.common.enums.YnEnums; |
| 10 | +import com.lyms.platform.common.result.BaseListResponse; | |
| 9 | 11 | import com.lyms.platform.common.utils.ResultUtils; |
| 10 | -import com.lyms.platform.permission.model.Departments; | |
| 11 | -import com.lyms.platform.permission.model.DepartmentsQuery; | |
| 12 | -import com.lyms.platform.permission.model.Users; | |
| 12 | +import com.lyms.platform.permission.model.*; | |
| 13 | 13 | import com.lyms.platform.permission.service.*; |
| 14 | 14 | import org.springframework.beans.factory.annotation.Autowired; |
| 15 | 15 | import org.springframework.stereotype.Controller; |
| 16 | -import org.springframework.web.bind.annotation.PathVariable; | |
| 17 | -import org.springframework.web.bind.annotation.RequestMapping; | |
| 18 | -import org.springframework.web.bind.annotation.RequestMethod; | |
| 19 | -import org.springframework.web.bind.annotation.RequestParam; | |
| 16 | +import org.springframework.web.bind.annotation.*; | |
| 20 | 17 | |
| 21 | 18 | import javax.servlet.http.HttpServletResponse; |
| 22 | 19 | import java.util.Date; |
| 20 | +import java.util.List; | |
| 23 | 21 | |
| 24 | 22 | /** |
| 25 | 23 | * Created by zhang.rui on 2015/9/28 0028. |
| 26 | 24 | */ |
| 27 | 25 | @Controller |
| 28 | -@RequestMapping("/v1") | |
| 29 | 26 | public class DepartmentsController extends BaseController { |
| 30 | 27 | @Autowired |
| 31 | 28 | private DepartmentsService departmentsService; |
| 32 | 29 | |
| 33 | 30 | |
| 34 | 31 | |
| 35 | 32 | |
| ... | ... | @@ -70,29 +67,28 @@ |
| 70 | 67 | /** |
| 71 | 68 | * 修改部门 |
| 72 | 69 | */ |
| 73 | - @RequestMapping(value = "/departments", method = RequestMethod.PUT) | |
| 70 | + @RequestMapping(value = "/departments/{id}", method = RequestMethod.PUT) | |
| 74 | 71 | @TokenRequired |
| 75 | 72 | public void addDepartments(HttpServletResponse response, |
| 76 | - @RequestParam(value = "id") Integer id, | |
| 73 | + @PathVariable(value = "id") Integer id, | |
| 77 | 74 | @RequestParam(value = "pid") Integer pid, |
| 78 | 75 | @RequestParam(value = "name") String name, |
| 79 | 76 | @RequestParam(value = "orgId") Integer orgId, |
| 80 | 77 | @RequestParam(value = "description") String description, |
| 81 | 78 | @RequestParam(value = "shortCode") String shortCode) { |
| 82 | 79 | |
| 83 | - if (null == name || null == orgId) { | |
| 80 | + if (null == name || null == id) { | |
| 84 | 81 | ResultUtils.buildParameterErrorResultAndWrite(response); |
| 85 | 82 | return; |
| 86 | 83 | } |
| 87 | - DepartmentsQuery departmentsQuery = new DepartmentsQuery(); | |
| 88 | - departmentsQuery.setName(name); | |
| 89 | - if(0 == departmentsService.queryDepartmentsCount(departmentsQuery)) { | |
| 84 | + | |
| 85 | + Departments departments = departmentsService.getDepartments(id); | |
| 86 | + if(null == departments) { | |
| 90 | 87 | ResultUtils.buildParameterErrorResultAndWrite(response,"该部门不存在"); |
| 91 | 88 | return; |
| 92 | 89 | } |
| 93 | 90 | |
| 94 | 91 | |
| 95 | - Departments departments = new Departments(); | |
| 96 | 92 | pid = pid == null ? 0 : pid; |
| 97 | 93 | departments.setParentId(pid); |
| 98 | 94 | departments.setName(name); |
| ... | ... | @@ -157,6 +153,34 @@ |
| 157 | 153 | |
| 158 | 154 | } |
| 159 | 155 | |
| 156 | + /** | |
| 157 | + * 获取列表 | |
| 158 | + */ | |
| 159 | + @RequestMapping(value = "/departments", method = RequestMethod.GET) | |
| 160 | + @ResponseBody | |
| 161 | + @TokenRequired | |
| 162 | + public void getPermissions(HttpServletResponse response, | |
| 163 | + @RequestParam(value = "keyword", required = false) String keyword, | |
| 164 | + @RequestParam(value = "page", required = false) Integer page, | |
| 165 | + @RequestParam(value = "limit", required = false) Integer limit, | |
| 166 | + @RequestParam(value = "orgId", required = false) Integer orgId) { | |
| 167 | + | |
| 168 | + limit = limit == null ? 10 : limit; | |
| 169 | + page = page == null ? 1 : page; | |
| 170 | + | |
| 171 | + | |
| 172 | + DepartmentsQuery departmentsQuery = new DepartmentsQuery(); | |
| 173 | + departmentsQuery.setNeed("true"); | |
| 174 | + departmentsQuery.setSort("id desc"); | |
| 175 | + departmentsQuery.setOrgId(orgId); | |
| 176 | + departmentsQuery.setPage(page); | |
| 177 | + departmentsQuery.setName(keyword); | |
| 178 | + departmentsQuery.setLimit(limit); | |
| 179 | + //TODO 这里查询未完成 模糊查询 | |
| 180 | + | |
| 181 | + List<Departments> departmentses = departmentsService.queryDepartments(departmentsQuery); | |
| 182 | + ResultUtils.buildSuccessResultAndWrite(response, departmentses); | |
| 183 | + } | |
| 160 | 184 | |
| 161 | 185 | |
| 162 | 186 | } |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/OrganizationController.java
View file @
19e6955
| ... | ... | @@ -7,6 +7,8 @@ |
| 7 | 7 | import com.lyms.platform.common.base.PlatformContext; |
| 8 | 8 | import com.lyms.platform.common.constants.ErrorCodeConstants; |
| 9 | 9 | import com.lyms.platform.common.enums.YnEnums; |
| 10 | +import com.lyms.platform.common.result.BaseListResponse; | |
| 11 | +import com.lyms.platform.common.result.BaseResponse; | |
| 10 | 12 | import com.lyms.platform.common.utils.ResultUtils; |
| 11 | 13 | import com.lyms.platform.permission.model.Organization; |
| 12 | 14 | import com.lyms.platform.permission.model.OrganizationQuery; |
| 13 | 15 | |
| 14 | 16 | |
| ... | ... | @@ -15,19 +17,16 @@ |
| 15 | 17 | import org.apache.commons.lang.StringUtils; |
| 16 | 18 | import org.springframework.beans.factory.annotation.Autowired; |
| 17 | 19 | import org.springframework.stereotype.Controller; |
| 18 | -import org.springframework.web.bind.annotation.PathVariable; | |
| 19 | -import org.springframework.web.bind.annotation.RequestMapping; | |
| 20 | -import org.springframework.web.bind.annotation.RequestMethod; | |
| 21 | -import org.springframework.web.bind.annotation.RequestParam; | |
| 20 | +import org.springframework.web.bind.annotation.*; | |
| 22 | 21 | |
| 23 | 22 | import javax.servlet.http.HttpServletResponse; |
| 24 | 23 | import java.util.Date; |
| 24 | +import java.util.List; | |
| 25 | 25 | |
| 26 | 26 | /** |
| 27 | 27 | * Created by zhang.rui on 2015/9/28 0028. |
| 28 | 28 | */ |
| 29 | 29 | @Controller |
| 30 | -@RequestMapping("/v1") | |
| 31 | 30 | public class OrganizationController extends BaseController { |
| 32 | 31 | @Autowired |
| 33 | 32 | private UsersService usersService; |
| 34 | 33 | |
| ... | ... | @@ -66,20 +65,20 @@ |
| 66 | 65 | /** |
| 67 | 66 | * 修改机构 |
| 68 | 67 | */ |
| 69 | - @RequestMapping(value = "/organization", method = RequestMethod.PUT) | |
| 68 | + @RequestMapping(value = "/organization/{id}", method = RequestMethod.PUT) | |
| 70 | 69 | @TokenRequired |
| 71 | 70 | public void updateOrganization(HttpServletResponse response, |
| 72 | - @RequestParam(value = "id") Integer id, | |
| 73 | - @RequestParam(value = "name") String name, | |
| 74 | - @RequestParam(value = "type") Integer type, | |
| 75 | - @RequestParam(value = "level") Integer level, | |
| 76 | - @RequestParam(value = "areaManage") Integer areaManage, | |
| 77 | - @RequestParam(value = "provinceId") Integer provinceId, | |
| 78 | - @RequestParam(value = "cityId") Integer cityId, | |
| 79 | - @RequestParam(value = "areaId") Integer areaId, | |
| 80 | - @RequestParam(value = "address") String address, | |
| 81 | - @RequestParam(value = "description") String description, | |
| 82 | - @RequestParam(value = "shortCode") String shortCode) { | |
| 71 | + @PathVariable(value = "id") Integer id, | |
| 72 | + @RequestParam(value = "name", required = false) String name, | |
| 73 | + @RequestParam(value = "type", required = false) Integer type, | |
| 74 | + @RequestParam(value = "level", required = false) Integer level, | |
| 75 | + @RequestParam(value = "areaManage", required = false) Integer areaManage, | |
| 76 | + @RequestParam(value = "provinceId", required = false) Integer provinceId, | |
| 77 | + @RequestParam(value = "cityId", required = false) Integer cityId, | |
| 78 | + @RequestParam(value = "areaId", required = false) Integer areaId, | |
| 79 | + @RequestParam(value = "address", required = false) String address, | |
| 80 | + @RequestParam(value = "description", required = false) String description, | |
| 81 | + @RequestParam(value = "shortCode", required = false) String shortCode) { | |
| 83 | 82 | |
| 84 | 83 | |
| 85 | 84 | if (type == null || StringUtils.isBlank(name) ) { |
| 86 | 85 | |
| 87 | 86 | |
| ... | ... | @@ -178,13 +177,28 @@ |
| 178 | 177 | * 获取列表 |
| 179 | 178 | */ |
| 180 | 179 | @RequestMapping(value = "/organization", method = RequestMethod.GET) |
| 180 | + @ResponseBody | |
| 181 | 181 | @TokenRequired |
| 182 | - public void getPermissions(HttpServletResponse response, | |
| 183 | - @RequestParam(value = "type") Integer type, | |
| 184 | - @RequestParam(value = "page") Integer page, | |
| 185 | - @RequestParam(value = "limit") Integer limit, | |
| 186 | - @RequestParam(value = "id", required = false) Integer id) { | |
| 182 | + public void getOrganization(HttpServletResponse response, | |
| 183 | + @RequestParam(value = "keyword", required = false) String keyword, | |
| 184 | + @RequestParam(value = "page", required = false) Integer page, | |
| 185 | + @RequestParam(value = "limit", required = false) Integer limit, | |
| 186 | + @RequestParam(value = "areaId", required = false) Integer areaId) { | |
| 187 | 187 | |
| 188 | + limit = limit == null ? 10 : limit; | |
| 189 | + page = page == null ? 1 : page; | |
| 190 | + | |
| 191 | + | |
| 192 | + OrganizationQuery organizationQuery = new OrganizationQuery(); | |
| 193 | + organizationQuery.setNeed("true"); | |
| 194 | + organizationQuery.setSort("id desc"); | |
| 195 | + organizationQuery.setName(keyword); | |
| 196 | + organizationQuery.setPage(page); | |
| 197 | + organizationQuery.setLimit(limit); | |
| 198 | + //TODO 这里查询未完成 模糊查询 | |
| 199 | + | |
| 200 | + List<Organization> organizations = organizationService.queryOrganization(organizationQuery); | |
| 201 | + ResultUtils.buildSuccessResultAndWrite(response, organizations); | |
| 188 | 202 | } |
| 189 | 203 | |
| 190 | 204 |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/PermissionsController.java
View file @
19e6955
platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/RolesController.java
View file @
19e6955
| ... | ... | @@ -8,6 +8,7 @@ |
| 8 | 8 | import com.lyms.platform.common.constants.ConstantInterface; |
| 9 | 9 | import com.lyms.platform.common.enums.YnEnums; |
| 10 | 10 | import com.lyms.platform.common.exception.BusinessException; |
| 11 | +import com.lyms.platform.common.result.BaseListResponse; | |
| 11 | 12 | import com.lyms.platform.common.utils.JsonUtil; |
| 12 | 13 | import com.lyms.platform.common.utils.ResultUtils; |
| 13 | 14 | import com.lyms.platform.permission.model.*; |
| ... | ... | @@ -15,10 +16,7 @@ |
| 15 | 16 | import org.apache.commons.lang.StringUtils; |
| 16 | 17 | import org.springframework.beans.factory.annotation.Autowired; |
| 17 | 18 | import org.springframework.stereotype.Controller; |
| 18 | -import org.springframework.web.bind.annotation.PathVariable; | |
| 19 | -import org.springframework.web.bind.annotation.RequestMapping; | |
| 20 | -import org.springframework.web.bind.annotation.RequestMethod; | |
| 21 | -import org.springframework.web.bind.annotation.RequestParam; | |
| 19 | +import org.springframework.web.bind.annotation.*; | |
| 22 | 20 | |
| 23 | 21 | import javax.servlet.http.HttpServletResponse; |
| 24 | 22 | import java.util.*; |
| ... | ... | @@ -27,7 +25,6 @@ |
| 27 | 25 | * Created by Administrator on 2015/9/29 0029. |
| 28 | 26 | */ |
| 29 | 27 | @Controller |
| 30 | -@RequestMapping("/v1") | |
| 31 | 28 | public class RolesController extends BaseController { |
| 32 | 29 | |
| 33 | 30 | @Autowired |
| 34 | 31 | |
| ... | ... | @@ -142,12 +139,12 @@ |
| 142 | 139 | @RequestMapping(value = "/roles/{id}",method = RequestMethod.PUT) |
| 143 | 140 | @TokenRequired |
| 144 | 141 | public void updateRoles(HttpServletResponse response ,@PathVariable Integer id, |
| 145 | - @RequestParam(value = "name")String name, | |
| 146 | - @RequestParam(value = "enable")Integer enable, | |
| 147 | - @RequestParam(value = "remarks")String remarks, | |
| 148 | - @RequestParam(value = "shortCode")String shortCode) { | |
| 142 | + @RequestParam(value = "name",required = false)String name, | |
| 143 | + @RequestParam(value = "enable",required = false)Integer enable, | |
| 144 | + @RequestParam(value = "remarks",required = false)String remarks, | |
| 145 | + @RequestParam(value = "shortCode",required = false)String shortCode) { | |
| 149 | 146 | |
| 150 | - if ( StringUtils.isBlank(name) || null != id ) { | |
| 147 | + if ( StringUtils.isBlank(name) || null == id ) { | |
| 151 | 148 | ResultUtils.buildParameterErrorResultAndWrite(response); |
| 152 | 149 | return; |
| 153 | 150 | } |
| 154 | 151 | |
| 155 | 152 | |
| 156 | 153 | |
| ... | ... | @@ -238,18 +235,32 @@ |
| 238 | 235 | } |
| 239 | 236 | |
| 240 | 237 | /** |
| 241 | - * 获取角色信息 | |
| 238 | + * 获取列表 | |
| 242 | 239 | */ |
| 243 | - @RequestMapping(value = "/roles",method = RequestMethod.GET) | |
| 240 | + @RequestMapping(value = "/roles", method = RequestMethod.GET) | |
| 241 | + @ResponseBody | |
| 244 | 242 | @TokenRequired |
| 245 | - public void getRoles(HttpServletResponse response , | |
| 246 | - @RequestParam(value = "page")Integer page, | |
| 247 | - @RequestParam(value = "limit")Integer limit, | |
| 248 | - @RequestParam(value = "id",required = false)Integer id, | |
| 249 | - @RequestParam(value = "type",required = false)Integer type, | |
| 250 | - @RequestParam(value = "parentId",required = false)Integer parentId, | |
| 251 | - @RequestParam(value = "title",required = false)String title) { | |
| 243 | + public void getPermissions(HttpServletResponse response, | |
| 244 | + @RequestParam(value = "keyword",required = false) String keyword, | |
| 245 | + @RequestParam(value = "type",required = false) Integer type, | |
| 246 | + @RequestParam(value = "page",required = false) Integer page, | |
| 247 | + @RequestParam(value = "limit",required = false) Integer limit, | |
| 248 | + @RequestParam(value = "orgId", required = false) Integer orgId) { | |
| 252 | 249 | |
| 250 | + limit = limit == null ? 10 : limit; | |
| 251 | + page = page == null ? 1 : page; | |
| 252 | + | |
| 253 | + RolesQuery rolesQuery = new RolesQuery(); | |
| 254 | + rolesQuery.setNeed("true"); | |
| 255 | + rolesQuery.setSort("id desc"); | |
| 256 | + rolesQuery.setType(type); | |
| 257 | + rolesQuery.setName(keyword); | |
| 258 | + rolesQuery.setPage(page); | |
| 259 | + rolesQuery.setLimit(limit); | |
| 260 | + //TODO 这里查询未完成 模糊查询 | |
| 261 | + | |
| 262 | + List<Roles> roles = rolesService.queryRoles(rolesQuery); | |
| 263 | + ResultUtils.buildSuccessResultAndWrite(response, roles); | |
| 253 | 264 | } |
| 254 | 265 | } |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/UsersController.java
View file @
19e6955
| ... | ... | @@ -17,10 +17,7 @@ |
| 17 | 17 | import org.springframework.beans.factory.annotation.Autowired; |
| 18 | 18 | import org.springframework.http.MediaType; |
| 19 | 19 | import org.springframework.stereotype.Controller; |
| 20 | -import org.springframework.web.bind.annotation.PathVariable; | |
| 21 | -import org.springframework.web.bind.annotation.RequestMapping; | |
| 22 | -import org.springframework.web.bind.annotation.RequestMethod; | |
| 23 | -import org.springframework.web.bind.annotation.RequestParam; | |
| 20 | +import org.springframework.web.bind.annotation.*; | |
| 24 | 21 | |
| 25 | 22 | import javax.servlet.http.HttpServletResponse; |
| 26 | 23 | import java.text.MessageFormat; |
| ... | ... | @@ -30,7 +27,6 @@ |
| 30 | 27 | * Created by Administrator on 2015/9/25 0025. |
| 31 | 28 | */ |
| 32 | 29 | @Controller |
| 33 | -@RequestMapping("/v1") | |
| 34 | 30 | public class UsersController extends BaseController { |
| 35 | 31 | |
| 36 | 32 | @Autowired |
| 37 | 33 | |
| ... | ... | @@ -50,7 +46,48 @@ |
| 50 | 46 | |
| 51 | 47 | private static final String LYMS = "龙源美生"; |
| 52 | 48 | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 53 | 57 | /** |
| 58 | + * 获取列表 | |
| 59 | + */ | |
| 60 | + @RequestMapping(value = "/users", method = RequestMethod.GET) | |
| 61 | + @ResponseBody | |
| 62 | + @TokenRequired | |
| 63 | + public void getPermissions(HttpServletResponse response, | |
| 64 | + @RequestParam(value = "type") Integer type, | |
| 65 | + @RequestParam(value = "keyword", required = false) String keyword, | |
| 66 | + @RequestParam(value = "rolesId", required = false) Integer rolesId, | |
| 67 | + @RequestParam(value = "page", required = false) Integer page, | |
| 68 | + @RequestParam(value = "limit", required = false) Integer limit, | |
| 69 | + @RequestParam(value = "orgId", required = false) Integer orgId) { | |
| 70 | + | |
| 71 | + limit = limit == null ? 10 : limit; | |
| 72 | + page = page == null ? 1 : page; | |
| 73 | + | |
| 74 | + UsersQuery usersQuery = new UsersQuery(); | |
| 75 | + usersQuery.setNeed("true"); | |
| 76 | + usersQuery.setSort("id desc"); | |
| 77 | + usersQuery.setName(keyword); | |
| 78 | + usersQuery.setType(type); | |
| 79 | + usersQuery.setPage(page); | |
| 80 | + usersQuery.setLimit(limit); | |
| 81 | + //TODO 这里查询未完成 模糊查询 | |
| 82 | + | |
| 83 | + List<Users> users = usersService.queryUsers(usersQuery); | |
| 84 | + ResultUtils.buildSuccessResultAndWrite(response, users); | |
| 85 | + } | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + /** | |
| 54 | 91 | * AMS 用户请求登录,获取token |
| 55 | 92 | */ |
| 56 | 93 | @RequestMapping(value = "/tokens", method = RequestMethod.POST) |
| ... | ... | @@ -131,6 +168,8 @@ |
| 131 | 168 | String code = NumberUtils.getRandomString(6); |
| 132 | 169 | //设置缓存10分钟验证码 |
| 133 | 170 | RedisUtils.setObj(countKey, code, TimeConstants.TEN_MINUTE); |
| 171 | + | |
| 172 | + System.out.println(phone + "----" + code); | |
| 134 | 173 | //发送短信 |
| 135 | 174 | MessageUtil.send(phone, ConstantInterface.SHORT_MESSAGE_PRE + MessageFormat.format("验证码{0},您正在登录区域平台,若非本人操作,请勿泄露。", code)); |
| 136 | 175 | |
| ... | ... | @@ -203,6 +242,10 @@ |
| 203 | 242 | return; |
| 204 | 243 | } |
| 205 | 244 | |
| 245 | + if(!usersList.get(0).getType().equals(0)) { | |
| 246 | + ResultUtils.buildParameterErrorResultAndWrite(response, "用户错误"); | |
| 247 | + } | |
| 248 | + | |
| 206 | 249 | //将已有映射设为失效 |
| 207 | 250 | UserOrganizationMapsQuery userOrganizationMapsQuery = new UserOrganizationMapsQuery(); |
| 208 | 251 | userOrganizationMapsQuery.setUserId(userId); |
| 209 | 252 | |
| 210 | 253 | |
| ... | ... | @@ -328,28 +371,23 @@ |
| 328 | 371 | /** |
| 329 | 372 | * 用户修改 |
| 330 | 373 | */ |
| 331 | - @RequestMapping(value = "/users", method = RequestMethod.PUT) | |
| 374 | + @RequestMapping(value = "/users/{id}", method = RequestMethod.PUT) | |
| 332 | 375 | @TokenRequired |
| 333 | 376 | public void updateUsers(HttpServletResponse response, |
| 334 | - @RequestParam(value = "id") Integer id, | |
| 335 | - @RequestParam(value = "deptId") Integer deptId, | |
| 336 | - @RequestParam(value = "orgId") Integer orgId, | |
| 337 | - @RequestParam(value = "name") String name, | |
| 338 | - @RequestParam(value = "account")String account, | |
| 339 | - @RequestParam(value = "phone") String phone, | |
| 340 | - @RequestParam(value = "enable") Integer enable, | |
| 341 | - @RequestParam(value = "remarks") String remarks, | |
| 342 | - @RequestParam(value = "roleIds") String roleIds) { | |
| 377 | + @PathVariable(value = "id") Integer id, | |
| 378 | + @RequestParam(value = "deptId",required = false) Integer deptId, | |
| 379 | + @RequestParam(value = "orgId",required = false) Integer orgId, | |
| 380 | + @RequestParam(value = "name",required = false) String name, | |
| 381 | + @RequestParam(value = "account",required = false)String account, | |
| 382 | + @RequestParam(value = "phone",required = false) String phone, | |
| 383 | + @RequestParam(value = "enable",required = false) Integer enable, | |
| 384 | + @RequestParam(value = "remarks",required = false) String remarks, | |
| 385 | + @RequestParam(value = "roleIds",required = false) String roleIds) { | |
| 343 | 386 | |
| 344 | 387 | PlatformContext mommyBobyContext = ContextHolder.getContext(); |
| 345 | 388 | String token = mommyBobyContext.getToken(); |
| 346 | 389 | |
| 347 | - if ( StringUtils.isBlank(roleIds) || deptId == null || | |
| 348 | - StringUtils.isBlank(name) /*|| StringUtils.isBlank(account) || | |
| 349 | - StringUtils.isBlank(pwd) */ || StringUtils.isBlank(phone)) { | |
| 350 | - ResultUtils.buildParameterErrorResultAndWrite(response); | |
| 351 | - return; | |
| 352 | - } | |
| 390 | + | |
| 353 | 391 | //获取登录用户ID |
| 354 | 392 | Integer userId = Integer.valueOf(tokenService.getUserId(token)); |
| 355 | 393 | if (userId != null) { |
| ... | ... | @@ -367,7 +405,7 @@ |
| 367 | 405 | return; |
| 368 | 406 | } |
| 369 | 407 | |
| 370 | - Users users = new Users(); | |
| 408 | + Users users = usersList.get(0); | |
| 371 | 409 | users.setId(id); |
| 372 | 410 | users.setDeptId(deptId); |
| 373 | 411 | users.setOrgId(orgId); |
| 374 | 412 | |
| 375 | 413 | |
| ... | ... | @@ -385,30 +423,33 @@ |
| 385 | 423 | |
| 386 | 424 | |
| 387 | 425 | //如有角色,则对用户角色中间表先删除后新增 |
| 388 | - Integer _userId = usersList.get(0).getId(); | |
| 389 | - UserRoleMapsQuery userRoleMapsQuery = new UserRoleMapsQuery(); | |
| 390 | - userRoleMapsQuery.setUserId(_userId); | |
| 391 | - List<UserRoleMaps> roleMapsList = userRoleMapsService.queryUserRoleMaps(userRoleMapsQuery); | |
| 392 | - for (UserRoleMaps userRoleMaps : roleMapsList) { | |
| 393 | - userRoleMaps.setYn(YnEnums.NO.getId()); | |
| 394 | - userRoleMapsService.updateUserRoleMaps(userRoleMaps); | |
| 395 | - } | |
| 426 | + if(null != roleIds) { | |
| 396 | 427 | |
| 397 | - | |
| 398 | - UserRoleMaps userRoleMaps = new UserRoleMaps(); | |
| 399 | - String[] roleArrayIds = roleIds.split(","); | |
| 400 | - List<Users> user = usersService.queryUsers(usersQuery); | |
| 401 | - for (String tmp : roleArrayIds) { | |
| 402 | - Roles roles = rolesService.getRoles(Integer.valueOf(tmp)); | |
| 403 | - if (roles == null || roles.getYn() == YnEnums.NO.getId()) { | |
| 404 | - continue; | |
| 428 | + Integer _userId = usersList.get(0).getId(); | |
| 429 | + UserRoleMapsQuery userRoleMapsQuery = new UserRoleMapsQuery(); | |
| 430 | + userRoleMapsQuery.setUserId(_userId); | |
| 431 | + List<UserRoleMaps> roleMapsList = userRoleMapsService.queryUserRoleMaps(userRoleMapsQuery); | |
| 432 | + for (UserRoleMaps userRoleMaps : roleMapsList) { | |
| 433 | + userRoleMaps.setYn(YnEnums.NO.getId()); | |
| 434 | + userRoleMapsService.updateUserRoleMaps(userRoleMaps); | |
| 405 | 435 | } |
| 406 | 436 | |
| 407 | - if (user.get(0).getId() != null) { | |
| 408 | - userRoleMaps.setRoleId(Integer.valueOf(Integer.valueOf(tmp))); | |
| 409 | - userRoleMaps.setUserId(user.get(0).getId()); | |
| 410 | - userRoleMaps.setYn(YnEnums.YES.getId()); | |
| 411 | - userRoleMapsService.addUserRoleMaps(userRoleMaps); | |
| 437 | + | |
| 438 | + UserRoleMaps userRoleMaps = new UserRoleMaps(); | |
| 439 | + String[] roleArrayIds = roleIds.split(","); | |
| 440 | + List<Users> user = usersService.queryUsers(usersQuery); | |
| 441 | + for (String tmp : roleArrayIds) { | |
| 442 | + Roles roles = rolesService.getRoles(Integer.valueOf(tmp)); | |
| 443 | + if (roles == null || roles.getYn() == YnEnums.NO.getId()) { | |
| 444 | + continue; | |
| 445 | + } | |
| 446 | + | |
| 447 | + if (user.get(0).getId() != null) { | |
| 448 | + userRoleMaps.setRoleId(Integer.valueOf(Integer.valueOf(tmp))); | |
| 449 | + userRoleMaps.setUserId(user.get(0).getId()); | |
| 450 | + userRoleMaps.setYn(YnEnums.YES.getId()); | |
| 451 | + userRoleMapsService.addUserRoleMaps(userRoleMaps); | |
| 452 | + } | |
| 412 | 453 | } |
| 413 | 454 | } |
| 414 | 455 | ResultUtils.buildSuccessResultAndWrite(response); |
| ... | ... | @@ -453,7 +494,7 @@ |
| 453 | 494 | @RequestMapping(value = "/users/{id}", method = RequestMethod.DELETE) |
| 454 | 495 | @TokenRequired |
| 455 | 496 | public void deleteUsers(HttpServletResponse response,@PathVariable Integer id) { |
| 456 | - if (null != id) { | |
| 497 | + if (null == id) { | |
| 457 | 498 | ResultUtils.buildIdIsNull(response); |
| 458 | 499 | return; |
| 459 | 500 | } |
| 460 | 501 | |
| ... | ... | @@ -493,23 +534,7 @@ |
| 493 | 534 | ResultUtils.buildSuccessResultAndWrite(response); |
| 494 | 535 | } |
| 495 | 536 | |
| 496 | - /** | |
| 497 | - * 获取用户信息 | |
| 498 | - */ | |
| 499 | - @RequestMapping(value = "/users", method = RequestMethod.GET) | |
| 500 | - @TokenRequired | |
| 501 | - public void getUsers(HttpServletResponse response, Integer page, Integer limit, | |
| 502 | - @RequestParam(value = "id", required = false) Integer id, | |
| 503 | - @RequestParam(value = "type", required = false) Integer type, | |
| 504 | - @RequestParam(value = "parentId", required = false) Integer parentId, | |
| 505 | - @RequestParam(value = "username", required = false) String username) { | |
| 506 | 537 | |
| 507 | - | |
| 508 | - | |
| 509 | - | |
| 510 | - | |
| 511 | - | |
| 512 | - } | |
| 513 | 538 | |
| 514 | 539 | /** |
| 515 | 540 | * 修改用户密码 |