Commit 291020e0856e031912de88f2d1ef822ab70af5e3
1 parent
b51ec03a05
Exists in
master
添加用户基本信息
Showing 22 changed files with 1084 additions and 181 deletions
- center.manager/src/main/java/com/lyms/cm/controller/sys/SysRolesController.java
- center.manager/src/main/java/com/lyms/cm/controller/sys/SysUsersController.java
- center.manager/src/main/java/com/lyms/cm/dao/sys/SysRolesMapper.java
- center.manager/src/main/java/com/lyms/cm/dao/sys/SysRolesMapper.xml
- center.manager/src/main/java/com/lyms/cm/dao/sys/SysUsersMapper.java
- center.manager/src/main/java/com/lyms/cm/dao/sys/SysUsersMapper.xml
- center.manager/src/main/java/com/lyms/cm/entity/sys/SysRoles.java
- center.manager/src/main/java/com/lyms/cm/entity/sys/SysUsers.java
- center.manager/src/main/java/com/lyms/cm/enums/UserStatusEnum.java
- center.manager/src/main/java/com/lyms/cm/enums/UserTypeEnum.java
- center.manager/src/main/java/com/lyms/cm/enums/UserValidityEnum.java
- center.manager/src/main/java/com/lyms/cm/enums/package-info.java
- center.manager/src/main/java/com/lyms/cm/service/sys/ISysRolesService.java
- center.manager/src/main/java/com/lyms/cm/service/sys/ISysUsersService.java
- center.manager/src/main/java/com/lyms/cm/service/sys/impl/SysRolesServiceImpl.java
- center.manager/src/main/java/com/lyms/cm/service/sys/impl/SysUsersServiceImpl.java
- center.manager/src/main/resources/app-context.xml
- center.manager/src/main/resources/app-mvc.xml
- center.manager/src/main/webapp/WEB-INF/web.xml
- center.manager/src/test/java/center/manager/test/user/UserTest.java
- center.manager/src/test/java/center/manager/test/user/package-info.java
- core.sdk/src/main/java/com/lyms/web/controller/BaseController.java
center.manager/src/main/java/com/lyms/cm/controller/sys/SysRolesController.java
View file @
291020e
| 1 | +package com.lyms.cm.controller.sys; | |
| 2 | + | |
| 3 | +import org.springframework.stereotype.Controller; | |
| 4 | +import org.springframework.web.bind.annotation.RequestMapping; | |
| 5 | +import com.lyms.web.controller.BaseController; | |
| 6 | + | |
| 7 | +/** | |
| 8 | + * <p> | |
| 9 | + * 角色表 前端控制器 | |
| 10 | + * </p> | |
| 11 | + * | |
| 12 | + * @author maliang | |
| 13 | + * @since 2017-03-02 | |
| 14 | + */ | |
| 15 | +@Controller | |
| 16 | +@RequestMapping("/sysRoles") | |
| 17 | +public class SysRolesController extends BaseController { | |
| 18 | + | |
| 19 | +} |
center.manager/src/main/java/com/lyms/cm/controller/sys/SysUsersController.java
View file @
291020e
| 1 | 1 | package com.lyms.cm.controller.sys; |
| 2 | 2 | |
| 3 | - | |
| 4 | 3 | import org.springframework.stereotype.Controller; |
| 5 | 4 | import org.springframework.web.bind.annotation.RequestMapping; |
| 5 | + | |
| 6 | 6 | import com.lyms.web.controller.BaseController; |
| 7 | 7 | |
| 8 | 8 | /** |
| 9 | 9 | * <p> |
| 10 | - * 用户表 前端控制器 | |
| 10 | + * 用户表 前端控制器 | |
| 11 | 11 | * </p> |
| 12 | 12 | * |
| 13 | 13 | * @author maliang |
| ... | ... | @@ -16,6 +16,6 @@ |
| 16 | 16 | @Controller |
| 17 | 17 | @RequestMapping("/sysUsers") |
| 18 | 18 | public class SysUsersController extends BaseController { |
| 19 | - | |
| 19 | + | |
| 20 | 20 | } |
center.manager/src/main/java/com/lyms/cm/dao/sys/SysRolesMapper.java
View file @
291020e
| 1 | +package com.lyms.cm.dao.sys; | |
| 2 | + | |
| 3 | + | |
| 4 | +import com.baomidou.mybatisplus.mapper.BaseMapper; | |
| 5 | +import com.lyms.cm.entity.sys.SysRoles; | |
| 6 | + | |
| 7 | +import org.springframework.stereotype.Repository; | |
| 8 | +/** | |
| 9 | + * <p> | |
| 10 | + * Mapper接口 | |
| 11 | + * </p> | |
| 12 | + * | |
| 13 | + * @author maliang | |
| 14 | + * @since 2017-03-02 | |
| 15 | + */ | |
| 16 | +@Repository | |
| 17 | +public interface SysRolesMapper extends BaseMapper<SysRoles> { | |
| 18 | + | |
| 19 | +} |
center.manager/src/main/java/com/lyms/cm/dao/sys/SysRolesMapper.xml
View file @
291020e
center.manager/src/main/java/com/lyms/cm/dao/sys/SysUsersMapper.java
View file @
291020e
center.manager/src/main/java/com/lyms/cm/dao/sys/SysUsersMapper.xml
View file @
291020e
| 1 | 1 | <?xml version="1.0" encoding="UTF-8"?> |
| 2 | 2 | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| 3 | -<mapper namespace="com.lyms.cm.entity.sys.dao.SysUsersMapper"> | |
| 3 | +<mapper namespace="com.lyms.cm.dao.sys.SysUsersMapper"> | |
| 4 | 4 | |
| 5 | 5 | |
| 6 | 6 | </mapper> |
center.manager/src/main/java/com/lyms/cm/entity/sys/SysRoles.java
View file @
291020e
| 1 | +package com.lyms.cm.entity.sys; | |
| 2 | + | |
| 3 | + | |
| 4 | +import com.baomidou.mybatisplus.annotations.TableName; | |
| 5 | +import com.baomidou.mybatisplus.annotations.TableField; | |
| 6 | +import java.io.Serializable; | |
| 7 | +import java.util.Date; | |
| 8 | + | |
| 9 | +/** | |
| 10 | + * <p> | |
| 11 | + * 角色表 | |
| 12 | + * </p> | |
| 13 | + * | |
| 14 | + * @author maliang | |
| 15 | + * @since 2017-03-02 | |
| 16 | + */ | |
| 17 | +@TableName("SYS_ROLES") | |
| 18 | +public class SysRoles implements Serializable { | |
| 19 | + | |
| 20 | + private static final long serialVersionUID = 1L; | |
| 21 | + | |
| 22 | + /** | |
| 23 | + * | |
| 24 | + */ | |
| 25 | + @TableField(value="ID") | |
| 26 | + private String id; | |
| 27 | + /** | |
| 28 | + * 0:管理员角色,1:用户角色 | |
| 29 | + */ | |
| 30 | + @TableField(value="TYPE") | |
| 31 | + private Integer type; | |
| 32 | + /** | |
| 33 | + * 角色名称 | |
| 34 | + */ | |
| 35 | + @TableField(value="NAME") | |
| 36 | + private String name; | |
| 37 | + /** | |
| 38 | + * | |
| 39 | + */ | |
| 40 | + @TableField(value="PUBLISH_ID") | |
| 41 | + private String publishId; | |
| 42 | + /** | |
| 43 | + * 1:启用,2:停用 | |
| 44 | + */ | |
| 45 | + @TableField(value="ENABLE") | |
| 46 | + private Integer enable; | |
| 47 | + /** | |
| 48 | + * 1:有效,2:无效 | |
| 49 | + */ | |
| 50 | + @TableField(value="YN") | |
| 51 | + private Integer yn; | |
| 52 | + /** | |
| 53 | + * 备注 | |
| 54 | + */ | |
| 55 | + @TableField(value="REMARKS") | |
| 56 | + private String remarks; | |
| 57 | + /** | |
| 58 | + * 简码 | |
| 59 | + */ | |
| 60 | + @TableField(value="SHORT_CODE") | |
| 61 | + private String shortCode; | |
| 62 | + /** | |
| 63 | + * 机构id | |
| 64 | + */ | |
| 65 | + @TableField(value="ORG_ID") | |
| 66 | + private String orgId; | |
| 67 | + /** | |
| 68 | + * | |
| 69 | + */ | |
| 70 | + @TableField(value="CREATED") | |
| 71 | + private Date created; | |
| 72 | + /** | |
| 73 | + * | |
| 74 | + */ | |
| 75 | + @TableField(value="MODIFIED") | |
| 76 | + private Date modified; | |
| 77 | + | |
| 78 | + | |
| 79 | + public String getId() { | |
| 80 | + return id; | |
| 81 | + } | |
| 82 | + | |
| 83 | + public void setId(String id) { | |
| 84 | + this.id = id; | |
| 85 | + } | |
| 86 | + | |
| 87 | + public Integer getType() { | |
| 88 | + return type; | |
| 89 | + } | |
| 90 | + | |
| 91 | + public void setType(Integer type) { | |
| 92 | + this.type = type; | |
| 93 | + } | |
| 94 | + | |
| 95 | + public String getName() { | |
| 96 | + return name; | |
| 97 | + } | |
| 98 | + | |
| 99 | + public void setName(String name) { | |
| 100 | + this.name = name; | |
| 101 | + } | |
| 102 | + | |
| 103 | + public String getPublishId() { | |
| 104 | + return publishId; | |
| 105 | + } | |
| 106 | + | |
| 107 | + public void setPublishId(String publishId) { | |
| 108 | + this.publishId = publishId; | |
| 109 | + } | |
| 110 | + | |
| 111 | + public Integer getEnable() { | |
| 112 | + return enable; | |
| 113 | + } | |
| 114 | + | |
| 115 | + public void setEnable(Integer enable) { | |
| 116 | + this.enable = enable; | |
| 117 | + } | |
| 118 | + | |
| 119 | + public Integer getYn() { | |
| 120 | + return yn; | |
| 121 | + } | |
| 122 | + | |
| 123 | + public void setYn(Integer yn) { | |
| 124 | + this.yn = yn; | |
| 125 | + } | |
| 126 | + | |
| 127 | + public String getRemarks() { | |
| 128 | + return remarks; | |
| 129 | + } | |
| 130 | + | |
| 131 | + public void setRemarks(String remarks) { | |
| 132 | + this.remarks = remarks; | |
| 133 | + } | |
| 134 | + | |
| 135 | + public String getShortCode() { | |
| 136 | + return shortCode; | |
| 137 | + } | |
| 138 | + | |
| 139 | + public void setShortCode(String shortCode) { | |
| 140 | + this.shortCode = shortCode; | |
| 141 | + } | |
| 142 | + | |
| 143 | + public String getOrgId() { | |
| 144 | + return orgId; | |
| 145 | + } | |
| 146 | + | |
| 147 | + public void setOrgId(String orgId) { | |
| 148 | + this.orgId = orgId; | |
| 149 | + } | |
| 150 | + | |
| 151 | + public Date getCreated() { | |
| 152 | + return created; | |
| 153 | + } | |
| 154 | + | |
| 155 | + public void setCreated(Date created) { | |
| 156 | + this.created = created; | |
| 157 | + } | |
| 158 | + | |
| 159 | + public Date getModified() { | |
| 160 | + return modified; | |
| 161 | + } | |
| 162 | + | |
| 163 | + public void setModified(Date modified) { | |
| 164 | + this.modified = modified; | |
| 165 | + } | |
| 166 | + | |
| 167 | +} |
center.manager/src/main/java/com/lyms/cm/entity/sys/SysUsers.java
View file @
291020e
| 1 | +package com.lyms.cm.entity.sys; | |
| 2 | + | |
| 3 | +import java.io.Serializable; | |
| 4 | +import java.util.Date; | |
| 5 | + | |
| 6 | +import com.baomidou.mybatisplus.annotations.TableField; | |
| 7 | +import com.baomidou.mybatisplus.annotations.TableName; | |
| 8 | +import com.lyms.cm.enums.UserStatusEnum; | |
| 9 | +import com.lyms.cm.enums.UserTypeEnum; | |
| 10 | +import com.lyms.cm.enums.UserValidityEnum; | |
| 11 | + | |
| 12 | +/** | |
| 13 | + * <p> | |
| 14 | + * 用户表 | |
| 15 | + * </p> | |
| 16 | + * | |
| 17 | + * @author maliang | |
| 18 | + * @since 2017-03-02 | |
| 19 | + */ | |
| 20 | +@TableName("SYS_USERS") | |
| 21 | +public class SysUsers implements Serializable { | |
| 22 | + | |
| 23 | + private static final long serialVersionUID = 1L; | |
| 24 | + | |
| 25 | + // 初始默认值 | |
| 26 | + public SysUsers() { | |
| 27 | + // this.setType(UserTypeEnum.USER.getType()); | |
| 28 | + // this.setEnable(UserStatusEnum.ENABLED.getStatus()); | |
| 29 | + // this.setCreated(new Date()); | |
| 30 | + } | |
| 31 | + | |
| 32 | + /** | |
| 33 | + * | |
| 34 | + */ | |
| 35 | + @TableField(value = "ID") | |
| 36 | + private String id; | |
| 37 | + /** | |
| 38 | + * 0:管理员,1:用户 | |
| 39 | + * <p> | |
| 40 | + * {@link UserTypeEnum#MANAGER} OR {@link UserTypeEnum#USER} | |
| 41 | + */ | |
| 42 | + @TableField(value = "TYPE") | |
| 43 | + private Integer type = UserTypeEnum.USER.getType(); | |
| 44 | + /** | |
| 45 | + * 机构id | |
| 46 | + */ | |
| 47 | + @TableField(value = "ORG_ID") | |
| 48 | + private String orgId; | |
| 49 | + /** | |
| 50 | + * 部门id | |
| 51 | + */ | |
| 52 | + @TableField(value = "DEPT_ID") | |
| 53 | + private String deptId; | |
| 54 | + /** | |
| 55 | + * 名称 | |
| 56 | + */ | |
| 57 | + @TableField(value = "NAME") | |
| 58 | + private String name; | |
| 59 | + /** | |
| 60 | + * 帐号 | |
| 61 | + */ | |
| 62 | + @TableField(value = "ACCOUNT") | |
| 63 | + private String account; | |
| 64 | + /** | |
| 65 | + * 名字 | |
| 66 | + */ | |
| 67 | + @TableField(value = "PWD") | |
| 68 | + private String pwd; | |
| 69 | + /** | |
| 70 | + * 手机号 | |
| 71 | + */ | |
| 72 | + @TableField(value = "PHONE") | |
| 73 | + private String phone; | |
| 74 | + /** | |
| 75 | + * 发布者id | |
| 76 | + */ | |
| 77 | + @TableField(value = "PUBLISH_ID") | |
| 78 | + private Integer publishId; | |
| 79 | + /** | |
| 80 | + * 1:有效,2:无效 | |
| 81 | + * <p> | |
| 82 | + * {@link UserValidityEnum#VALIDITY} OR {@link UserValidityEnum#UNVALIDITY} | |
| 83 | + */ | |
| 84 | + @TableField(value = "YN") | |
| 85 | + private Integer yn = UserValidityEnum.VALIDITY.getValidity(); | |
| 86 | + /** | |
| 87 | + * 1:启用,2:停用 | |
| 88 | + * <p> | |
| 89 | + * {@link UserStatusEnum#ENABLED} OR {@link UserStatusEnum#DISENABLED} | |
| 90 | + */ | |
| 91 | + @TableField(value = "ENABLE") | |
| 92 | + private Integer enable = UserStatusEnum.ENABLED.getStatus(); | |
| 93 | + /** | |
| 94 | + * 最后修改时间 | |
| 95 | + */ | |
| 96 | + @TableField(value = "MODIFIED") | |
| 97 | + private Date modified; | |
| 98 | + /** | |
| 99 | + * 创建时间 | |
| 100 | + */ | |
| 101 | + @TableField(value = "CREATED") | |
| 102 | + private Date created; | |
| 103 | + /** | |
| 104 | + * 备注 | |
| 105 | + */ | |
| 106 | + @TableField(value = "REMARKS") | |
| 107 | + private String remarks; | |
| 108 | + /** | |
| 109 | + * 最后登录时间 | |
| 110 | + */ | |
| 111 | + @TableField(value = "LAST_LOGIN_TIME") | |
| 112 | + private Date lastLoginTime; | |
| 113 | + /** | |
| 114 | + * 导入数据的源id | |
| 115 | + */ | |
| 116 | + @TableField(value = "FOREIGN_ID") | |
| 117 | + private String foreignId; | |
| 118 | + /** | |
| 119 | + * 医院的帐号 | |
| 120 | + */ | |
| 121 | + @TableField(value = "OTHER_ACCOUNT") | |
| 122 | + private String otherAccount; | |
| 123 | + /** | |
| 124 | + * | |
| 125 | + */ | |
| 126 | + @TableField(value = "EMPLOYEE_ID") | |
| 127 | + private String employeeId; | |
| 128 | + /** | |
| 129 | + * | |
| 130 | + */ | |
| 131 | + @TableField(value = "EXPIR_TIME") | |
| 132 | + private Date expirTime; | |
| 133 | + /** | |
| 134 | + * | |
| 135 | + */ | |
| 136 | + @TableField(value = "LEVEL") | |
| 137 | + private Integer level; | |
| 138 | + /** | |
| 139 | + * | |
| 140 | + */ | |
| 141 | + @TableField(value = "AVATAR") | |
| 142 | + private String avatar; | |
| 143 | + /** | |
| 144 | + * | |
| 145 | + */ | |
| 146 | + @TableField(value = "WORK_TIME") | |
| 147 | + private String workTime; | |
| 148 | + /** | |
| 149 | + * | |
| 150 | + */ | |
| 151 | + @TableField(value = "GOOD_AT") | |
| 152 | + private String goodAt; | |
| 153 | + | |
| 154 | + public String getId() { | |
| 155 | + return id; | |
| 156 | + } | |
| 157 | + | |
| 158 | + public void setId(String id) { | |
| 159 | + this.id = id; | |
| 160 | + } | |
| 161 | + | |
| 162 | + public Integer getType() { | |
| 163 | + return type; | |
| 164 | + } | |
| 165 | + | |
| 166 | + public void setType(Integer type) { | |
| 167 | + this.type = type; | |
| 168 | + } | |
| 169 | + | |
| 170 | + public String getOrgId() { | |
| 171 | + return orgId; | |
| 172 | + } | |
| 173 | + | |
| 174 | + public void setOrgId(String orgId) { | |
| 175 | + this.orgId = orgId; | |
| 176 | + } | |
| 177 | + | |
| 178 | + public String getDeptId() { | |
| 179 | + return deptId; | |
| 180 | + } | |
| 181 | + | |
| 182 | + public void setDeptId(String deptId) { | |
| 183 | + this.deptId = deptId; | |
| 184 | + } | |
| 185 | + | |
| 186 | + public String getName() { | |
| 187 | + return name; | |
| 188 | + } | |
| 189 | + | |
| 190 | + public void setName(String name) { | |
| 191 | + this.name = name; | |
| 192 | + } | |
| 193 | + | |
| 194 | + public String getAccount() { | |
| 195 | + return account; | |
| 196 | + } | |
| 197 | + | |
| 198 | + public void setAccount(String account) { | |
| 199 | + this.account = account; | |
| 200 | + } | |
| 201 | + | |
| 202 | + public String getPwd() { | |
| 203 | + return pwd; | |
| 204 | + } | |
| 205 | + | |
| 206 | + public void setPwd(String pwd) { | |
| 207 | + this.pwd = pwd; | |
| 208 | + } | |
| 209 | + | |
| 210 | + public String getPhone() { | |
| 211 | + return phone; | |
| 212 | + } | |
| 213 | + | |
| 214 | + public void setPhone(String phone) { | |
| 215 | + this.phone = phone; | |
| 216 | + } | |
| 217 | + | |
| 218 | + public Integer getPublishId() { | |
| 219 | + return publishId; | |
| 220 | + } | |
| 221 | + | |
| 222 | + public void setPublishId(Integer publishId) { | |
| 223 | + this.publishId = publishId; | |
| 224 | + } | |
| 225 | + | |
| 226 | + public Integer getYn() { | |
| 227 | + return yn; | |
| 228 | + } | |
| 229 | + | |
| 230 | + public void setYn(Integer yn) { | |
| 231 | + this.yn = yn; | |
| 232 | + } | |
| 233 | + | |
| 234 | + public Integer getEnable() { | |
| 235 | + return enable; | |
| 236 | + } | |
| 237 | + | |
| 238 | + public void setEnable(Integer enable) { | |
| 239 | + this.enable = enable; | |
| 240 | + } | |
| 241 | + | |
| 242 | + public Date getModified() { | |
| 243 | + return modified; | |
| 244 | + } | |
| 245 | + | |
| 246 | + public void setModified(Date modified) { | |
| 247 | + this.modified = modified; | |
| 248 | + } | |
| 249 | + | |
| 250 | + public Date getCreated() { | |
| 251 | + return created; | |
| 252 | + } | |
| 253 | + | |
| 254 | + public void setCreated(Date created) { | |
| 255 | + this.created = created; | |
| 256 | + } | |
| 257 | + | |
| 258 | + public String getRemarks() { | |
| 259 | + return remarks; | |
| 260 | + } | |
| 261 | + | |
| 262 | + public void setRemarks(String remarks) { | |
| 263 | + this.remarks = remarks; | |
| 264 | + } | |
| 265 | + | |
| 266 | + public Date getLastLoginTime() { | |
| 267 | + return lastLoginTime; | |
| 268 | + } | |
| 269 | + | |
| 270 | + public void setLastLoginTime(Date lastLoginTime) { | |
| 271 | + this.lastLoginTime = lastLoginTime; | |
| 272 | + } | |
| 273 | + | |
| 274 | + public String getForeignId() { | |
| 275 | + return foreignId; | |
| 276 | + } | |
| 277 | + | |
| 278 | + public void setForeignId(String foreignId) { | |
| 279 | + this.foreignId = foreignId; | |
| 280 | + } | |
| 281 | + | |
| 282 | + public String getOtherAccount() { | |
| 283 | + return otherAccount; | |
| 284 | + } | |
| 285 | + | |
| 286 | + public void setOtherAccount(String otherAccount) { | |
| 287 | + this.otherAccount = otherAccount; | |
| 288 | + } | |
| 289 | + | |
| 290 | + public String getEmployeeId() { | |
| 291 | + return employeeId; | |
| 292 | + } | |
| 293 | + | |
| 294 | + public void setEmployeeId(String employeeId) { | |
| 295 | + this.employeeId = employeeId; | |
| 296 | + } | |
| 297 | + | |
| 298 | + public Date getExpirTime() { | |
| 299 | + return expirTime; | |
| 300 | + } | |
| 301 | + | |
| 302 | + public void setExpirTime(Date expirTime) { | |
| 303 | + this.expirTime = expirTime; | |
| 304 | + } | |
| 305 | + | |
| 306 | + public Integer getLevel() { | |
| 307 | + return level; | |
| 308 | + } | |
| 309 | + | |
| 310 | + public void setLevel(Integer level) { | |
| 311 | + this.level = level; | |
| 312 | + } | |
| 313 | + | |
| 314 | + public String getAvatar() { | |
| 315 | + return avatar; | |
| 316 | + } | |
| 317 | + | |
| 318 | + public void setAvatar(String avatar) { | |
| 319 | + this.avatar = avatar; | |
| 320 | + } | |
| 321 | + | |
| 322 | + public String getWorkTime() { | |
| 323 | + return workTime; | |
| 324 | + } | |
| 325 | + | |
| 326 | + public void setWorkTime(String workTime) { | |
| 327 | + this.workTime = workTime; | |
| 328 | + } | |
| 329 | + | |
| 330 | + public String getGoodAt() { | |
| 331 | + return goodAt; | |
| 332 | + } | |
| 333 | + | |
| 334 | + public void setGoodAt(String goodAt) { | |
| 335 | + this.goodAt = goodAt; | |
| 336 | + } | |
| 337 | + | |
| 338 | + public boolean isEnabled() { | |
| 339 | + return UserStatusEnum.isEnabled(this.getEnable()); | |
| 340 | + } | |
| 341 | + | |
| 342 | +} |
center.manager/src/main/java/com/lyms/cm/enums/UserStatusEnum.java
View file @
291020e
| 1 | +package com.lyms.cm.enums; | |
| 2 | + | |
| 3 | +/** | |
| 4 | + * 用户状态标识 | |
| 5 | + * | |
| 6 | + * @author maliang | |
| 7 | + * | |
| 8 | + */ | |
| 9 | +public enum UserStatusEnum { | |
| 10 | + | |
| 11 | + // 启用 | |
| 12 | + ENABLED(1), | |
| 13 | + // 禁用 | |
| 14 | + DISENABLED(2); | |
| 15 | + | |
| 16 | + private int status; | |
| 17 | + | |
| 18 | + private UserStatusEnum(int status) { | |
| 19 | + this.status = status; | |
| 20 | + } | |
| 21 | + | |
| 22 | + public int getStatus() { | |
| 23 | + return this.status; | |
| 24 | + } | |
| 25 | + | |
| 26 | + public static boolean isEnabled(Integer status) { | |
| 27 | + return status != null && ENABLED.getStatus() == status; | |
| 28 | + } | |
| 29 | + | |
| 30 | + public static boolean isDisEnabled(Integer status) { | |
| 31 | + return status != null && DISENABLED.getStatus() == status; | |
| 32 | + } | |
| 33 | + | |
| 34 | +} |
center.manager/src/main/java/com/lyms/cm/enums/UserTypeEnum.java
View file @
291020e
| 1 | +package com.lyms.cm.enums; | |
| 2 | + | |
| 3 | +/** | |
| 4 | + * 用户类型 | |
| 5 | + * | |
| 6 | + * @author maliang | |
| 7 | + * | |
| 8 | + */ | |
| 9 | +public enum UserTypeEnum { | |
| 10 | + | |
| 11 | + // 管理员 | |
| 12 | + MANAGER(0), | |
| 13 | + // 用户 | |
| 14 | + USER(1); | |
| 15 | + | |
| 16 | + private int type; | |
| 17 | + | |
| 18 | + private UserTypeEnum(int type) { | |
| 19 | + this.type = type; | |
| 20 | + } | |
| 21 | + | |
| 22 | + /** | |
| 23 | + * 获取类型 | |
| 24 | + * | |
| 25 | + * @return | |
| 26 | + */ | |
| 27 | + public int getType() { | |
| 28 | + return this.type; | |
| 29 | + } | |
| 30 | + | |
| 31 | +} |
center.manager/src/main/java/com/lyms/cm/enums/UserValidityEnum.java
View file @
291020e
| 1 | +package com.lyms.cm.enums; | |
| 2 | + | |
| 3 | +/** | |
| 4 | + * 用户是否有效 | |
| 5 | + * | |
| 6 | + * @author maliang | |
| 7 | + * | |
| 8 | + */ | |
| 9 | +public enum UserValidityEnum { | |
| 10 | + | |
| 11 | + // 有效 | |
| 12 | + VALIDITY(1), | |
| 13 | + // 无效 | |
| 14 | + UNVALIDITY(2); | |
| 15 | + | |
| 16 | + private int validity; | |
| 17 | + | |
| 18 | + private UserValidityEnum(int validity) { | |
| 19 | + this.validity = validity; | |
| 20 | + } | |
| 21 | + | |
| 22 | + public int getValidity() { | |
| 23 | + return this.validity; | |
| 24 | + } | |
| 25 | + | |
| 26 | +} |
center.manager/src/main/java/com/lyms/cm/enums/package-info.java
View file @
291020e
center.manager/src/main/java/com/lyms/cm/service/sys/ISysRolesService.java
View file @
291020e
| 1 | +package com.lyms.cm.service.sys; | |
| 2 | + | |
| 3 | +import com.lyms.cm.entity.sys.SysRoles; | |
| 4 | +import com.lyms.web.service.BaseService; | |
| 5 | + | |
| 6 | +/** | |
| 7 | + * <p> | |
| 8 | + * 服务类 | |
| 9 | + * </p> | |
| 10 | + * | |
| 11 | + * @author maliang | |
| 12 | + * @since 2017-03-02 | |
| 13 | + */ | |
| 14 | +public interface ISysRolesService extends BaseService<SysRoles> { | |
| 15 | + | |
| 16 | +} |
center.manager/src/main/java/com/lyms/cm/service/sys/ISysUsersService.java
View file @
291020e
| 1 | +package com.lyms.cm.service.sys; | |
| 2 | + | |
| 3 | +import com.lyms.cm.entity.sys.SysUsers; | |
| 4 | +import com.lyms.exception.SystemException; | |
| 5 | +import com.lyms.web.service.BaseService; | |
| 6 | + | |
| 7 | +/** | |
| 8 | + * <p> | |
| 9 | + * 用户服务类 | |
| 10 | + * </p> | |
| 11 | + * | |
| 12 | + * @author maliang | |
| 13 | + * @since 2017-03-02 | |
| 14 | + */ | |
| 15 | +public interface ISysUsersService extends BaseService<SysUsers> { | |
| 16 | + | |
| 17 | + /** | |
| 18 | + * 添加用户 | |
| 19 | + * | |
| 20 | + * @param user | |
| 21 | + * @return | |
| 22 | + * @author maliang | |
| 23 | + */ | |
| 24 | + public boolean addUser(SysUsers user) throws SystemException; | |
| 25 | + | |
| 26 | + /** | |
| 27 | + * 修改用户信息 | |
| 28 | + * | |
| 29 | + * @param user | |
| 30 | + * @return | |
| 31 | + * @author maliang | |
| 32 | + */ | |
| 33 | + public boolean updateUser(SysUsers user) throws SystemException; | |
| 34 | + | |
| 35 | + /** | |
| 36 | + * 根据ID获取用户信息 | |
| 37 | + * | |
| 38 | + * @param userId | |
| 39 | + * @return | |
| 40 | + * @author maliang | |
| 41 | + */ | |
| 42 | + public SysUsers getUserById(String userId) throws SystemException; | |
| 43 | + | |
| 44 | + /** | |
| 45 | + * 启用/停用 | |
| 46 | + * <p> | |
| 47 | + * 根据用户ID操作 | |
| 48 | + * <p> | |
| 49 | + * | |
| 50 | + * @param userId | |
| 51 | + * @return | |
| 52 | + * @author maliang | |
| 53 | + */ | |
| 54 | + public boolean enabled(String userId) throws SystemException; | |
| 55 | + | |
| 56 | +} |
center.manager/src/main/java/com/lyms/cm/service/sys/impl/SysRolesServiceImpl.java
View file @
291020e
| 1 | +package com.lyms.cm.service.sys.impl; | |
| 2 | + | |
| 3 | +import org.springframework.stereotype.Service; | |
| 4 | + | |
| 5 | +import com.baomidou.mybatisplus.service.impl.ServiceImpl; | |
| 6 | +import com.lyms.cm.dao.sys.SysRolesMapper; | |
| 7 | +import com.lyms.cm.entity.sys.SysRoles; | |
| 8 | +import com.lyms.cm.service.sys.ISysRolesService; | |
| 9 | + | |
| 10 | +/** | |
| 11 | + * <p> | |
| 12 | + * 角色表 服务实现类 | |
| 13 | + * </p> | |
| 14 | + * | |
| 15 | + * @author maliang | |
| 16 | + * @since 2017-03-02 | |
| 17 | + */ | |
| 18 | +@Service | |
| 19 | +public class SysRolesServiceImpl extends ServiceImpl<SysRolesMapper, SysRoles> implements ISysRolesService { | |
| 20 | + | |
| 21 | +} |
center.manager/src/main/java/com/lyms/cm/service/sys/impl/SysUsersServiceImpl.java
View file @
291020e
| 1 | +package com.lyms.cm.service.sys.impl; | |
| 2 | + | |
| 3 | +import org.apache.commons.lang3.StringUtils; | |
| 4 | +import org.springframework.beans.factory.annotation.Autowired; | |
| 5 | +import org.springframework.stereotype.Service; | |
| 6 | +import org.springframework.transaction.annotation.Transactional; | |
| 7 | + | |
| 8 | +import com.baomidou.mybatisplus.service.impl.ServiceImpl; | |
| 9 | +import com.lyms.cm.dao.sys.SysUsersMapper; | |
| 10 | +import com.lyms.cm.entity.sys.SysUsers; | |
| 11 | +import com.lyms.cm.enums.UserStatusEnum; | |
| 12 | +import com.lyms.cm.service.sys.ISysUsersService; | |
| 13 | + | |
| 14 | +/** | |
| 15 | + * <p> | |
| 16 | + * 用户表 服务实现类 | |
| 17 | + * </p> | |
| 18 | + * | |
| 19 | + * @author maliang | |
| 20 | + * @since 2017-03-02 | |
| 21 | + */ | |
| 22 | +@Service | |
| 23 | +public class SysUsersServiceImpl extends ServiceImpl<SysUsersMapper, SysUsers> implements ISysUsersService { | |
| 24 | + | |
| 25 | + @Autowired | |
| 26 | + private SysUsersMapper userMapper; | |
| 27 | + | |
| 28 | + // 模块基础操作信息 | |
| 29 | + private boolean empty(SysUsers user) { | |
| 30 | + return user == null; | |
| 31 | + } | |
| 32 | + | |
| 33 | + @Override | |
| 34 | + @Transactional | |
| 35 | + public boolean addUser(SysUsers user) { | |
| 36 | + if (empty(user)) | |
| 37 | + return false; | |
| 38 | + | |
| 39 | + Integer tag = userMapper.insert(user); | |
| 40 | + return tag != null && tag >= 1; | |
| 41 | + } | |
| 42 | + | |
| 43 | + @Override | |
| 44 | + @Transactional | |
| 45 | + public boolean updateUser(SysUsers user) { | |
| 46 | + if (empty(user)) | |
| 47 | + return false; | |
| 48 | + Integer tag = userMapper.updateById(user); | |
| 49 | + return tag != null && tag >= 1; | |
| 50 | + } | |
| 51 | + | |
| 52 | + @Override | |
| 53 | + public SysUsers getUserById(String userId) { | |
| 54 | + if (StringUtils.isBlank(userId)) | |
| 55 | + return null; | |
| 56 | + return userMapper.selectById(userId); | |
| 57 | + } | |
| 58 | + | |
| 59 | + @Override | |
| 60 | + @Transactional | |
| 61 | + public boolean enabled(String userId) { | |
| 62 | + // TODO 编写SQL 修改 | |
| 63 | + SysUsers user = this.getUserById(userId); | |
| 64 | + if (empty(user)) | |
| 65 | + return false; | |
| 66 | + | |
| 67 | + // 判断当前用户的启用,禁用情况 | |
| 68 | + if (user.isEnabled()) { | |
| 69 | + user.setEnable(UserStatusEnum.DISENABLED.getStatus()); | |
| 70 | + } else { | |
| 71 | + user.setEnable(UserStatusEnum.ENABLED.getStatus()); | |
| 72 | + } | |
| 73 | + return this.updateUser(user); | |
| 74 | + } | |
| 75 | + | |
| 76 | +} |
center.manager/src/main/resources/app-context.xml
View file @
291020e
| ... | ... | @@ -13,100 +13,15 @@ |
| 13 | 13 | http://www.springframework.org/schema/mvc |
| 14 | 14 | http://www.springframework.org/schema/mvc/spring-mvc.xsd"> |
| 15 | 15 | |
| 16 | - <bean id="placeholder" class="com.lyms.spring.PropertiesUtil"> | |
| 17 | - <property name="locations"> | |
| 18 | - <list> | |
| 19 | - <value>classpath:jdbc.properties</value> | |
| 20 | - </list> | |
| 21 | - </property> | |
| 22 | - </bean> | |
| 23 | - | |
| 16 | + <context:annotation-config /> | |
| 24 | 17 | <!-- 扫描控制器 禁用use-default-filters 不重复扫描@Service,@Repository等..否则将导致事务失效 --> |
| 25 | 18 | <context:component-scan base-package="com.lyms.cm"></context:component-scan> |
| 26 | - | |
| 27 | - <!-- <mvc:default-servlet-handler /> --> | |
| 28 | - | |
| 29 | - <!-- 配置静态资源,直接映射到对应的文件夹,DispatcherServlet 不处理 --> | |
| 30 | - <mvc:resources mapping="/static/**" location="/WEB-INF/static/" cache-period="31926534"> | |
| 31 | - <mvc:resource-chain resource-cache="false" auto-registration="false"> | |
| 32 | - <mvc:resolvers> | |
| 33 | - <bean class="org.springframework.web.servlet.resource.GzipResourceResolver"/> | |
| 34 | - <bean class="org.springframework.web.servlet.resource.PathResourceResolver"/> | |
| 35 | - </mvc:resolvers> | |
| 36 | - </mvc:resource-chain> | |
| 37 | - </mvc:resources> | |
| 38 | - <mvc:resources mapping="/error/**" location="/error/" /> | |
| 39 | - | |
| 40 | - <!-- 定义视图解析器 --> | |
| 41 | - <bean id="velocityConfig" | |
| 42 | - class="org.springframework.web.servlet.view.velocity.VelocityConfigurer"> | |
| 43 | - <property name="resourceLoaderPath" value="/WEB-INF/views/" /> | |
| 44 | - <property name="configLocation" value="classpath:velocity.properties" /> | |
| 45 | - </bean> | |
| 19 | + <context:property-placeholder location="classpath:jdbc.properties"/> | |
| 46 | 20 | |
| 47 | - <bean id= "viewResolver" class= "org.springframework.web.servlet.view.velocity.VelocityLayoutViewResolver"> | |
| 48 | - <property name="toolboxConfigLocation" value="/WEB-INF/toolbox.xml" /> | |
| 49 | - <property name="layoutUrl" value="layout/empty.html" /> | |
| 50 | - <property name="suffix" value=".html" /> | |
| 51 | - <property name="cache" value="false" /> | |
| 52 | - <property name="contentType" value="text/html;charset=UTF-8" /> | |
| 53 | - <property name="dateToolAttribute" value="date" /><!--日期函数名称--> | |
| 54 | - <property name="numberToolAttribute" value="number" /><!--数字函数名称--> | |
| 55 | - <!-- <property name="viewClass" value="com.lyms.velocity.VelocityToolboxViewExt"/> --> | |
| 56 | - <property name="exposeSpringMacroHelpers" value="true" /> | |
| 57 | - <property name="exposeRequestAttributes" value="true" /> | |
| 58 | - <property name="exposeSessionAttributes" value="true" /> | |
| 59 | - <property name="redirectContextRelative" value="true" /> | |
| 60 | - <property name="requestContextAttribute" value="request" /> | |
| 61 | - <property name="redirectHttp10Compatible" value="true" /> | |
| 62 | - </bean> | |
| 63 | - | |
| 64 | - <bean id="ExceptionHandler" class="com.lyms.spring.exception.ExceptionHandler" /> | |
| 65 | - | |
| 66 | - <mvc:annotation-driven> | |
| 67 | - <!-- 编码转换 --> | |
| 68 | - <mvc:message-converters> | |
| 69 | - <bean id="fastJsonHttpMessageConverter" | |
| 70 | - class="com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter"> | |
| 71 | - <property name="supportedMediaTypes"> | |
| 72 | - <list> | |
| 73 | - <value>application/json;charset=UTF-8</value> | |
| 74 | - </list> | |
| 75 | - </property> | |
| 76 | - <!-- | 这个地方能自己配置一些东西,比如时间的格式化,null输出""等等 | <property name="serializerFeature"></property> | |
| 77 | - | --> | |
| 78 | - </bean> | |
| 79 | - <bean class="org.springframework.http.converter.StringHttpMessageConverter"> | |
| 80 | - <property name="supportedMediaTypes"> | |
| 81 | - <list> | |
| 82 | - <value>text/plain;charset=UTF-8</value> | |
| 83 | - <value>text/html;charset=UTF-8</value> | |
| 84 | - <value>application/json;charset=UTF-8</value> | |
| 85 | - </list> | |
| 86 | - </property> | |
| 87 | - </bean> | |
| 88 | - </mvc:message-converters> | |
| 89 | - </mvc:annotation-driven> | |
| 90 | - | |
| 91 | - <bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver"> | |
| 92 | - <property name="defaultEncoding" value="utf-8" /> | |
| 93 | - <!-- 文件大小最大值 --> | |
| 94 | - <property name="maxUploadSize" value="10485760000" /> | |
| 95 | - <!-- 内存中的最大值 --> | |
| 96 | - <property name="maxInMemorySize" value="40960" /> | |
| 97 | - </bean> | |
| 98 | - | |
| 99 | - <aop:aspectj-autoproxy/> | |
| 100 | - <bean class = "com.lyms.aop.SysLogAop"/> | |
| 101 | - | |
| 102 | - <!-- 配置基础拦截器 --> | |
| 103 | - <mvc:interceptors> | |
| 104 | - <bean class="com.lyms.spring.interceptor.BaseInterceptor"/> | |
| 105 | - </mvc:interceptors> | |
| 106 | - | |
| 107 | - <bean class="com.lyms.web.listener.StartupListener"/> | |
| 21 | + <bean class="com.lyms.web.listener.StartupListener"/> | |
| 108 | 22 | <bean class="com.lyms.context.AppContext"/> |
| 109 | - | |
| 23 | + | |
| 110 | 24 | <import resource="xml/app-*.xml" /> |
| 25 | + | |
| 111 | 26 | </beans> |
center.manager/src/main/resources/app-mvc.xml
View file @
291020e
| 1 | +<beans xmlns="http://www.springframework.org/schema/beans" | |
| 2 | + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p" | |
| 3 | + xmlns:aop="http://www.springframework.org/schema/aop" | |
| 4 | + xmlns:context="http://www.springframework.org/schema/context" | |
| 5 | + xmlns:mvc="http://www.springframework.org/schema/mvc" | |
| 6 | + xsi:schemaLocation=" | |
| 7 | + http://www.springframework.org/schema/beans | |
| 8 | + http://www.springframework.org/schema/beans/spring-beans.xsd | |
| 9 | + http://www.springframework.org/schema/context | |
| 10 | + http://www.springframework.org/schema/context/spring-context.xsd | |
| 11 | + http://www.springframework.org/schema/aop | |
| 12 | + http://www.springframework.org/schema/aop/spring-aop.xsd | |
| 13 | + http://www.springframework.org/schema/mvc | |
| 14 | + http://www.springframework.org/schema/mvc/spring-mvc.xsd"> | |
| 15 | + | |
| 16 | + | |
| 17 | + <context:annotation-config /> | |
| 18 | + <bean id="placeholder" class="com.lyms.spring.PropertiesUtil"> | |
| 19 | + <property name="locations"> | |
| 20 | + <list> | |
| 21 | + <value>classpath:jdbc.properties</value> | |
| 22 | + </list> | |
| 23 | + </property> | |
| 24 | + </bean> | |
| 25 | + | |
| 26 | + <!-- 扫描控制器 禁用use-default-filters 不重复扫描@Service,@Repository等..否则将导致事务失效 --> | |
| 27 | + <context:component-scan base-package="com.lyms.cm.controller"></context:component-scan> | |
| 28 | + | |
| 29 | + <!-- <mvc:default-servlet-handler /> --> | |
| 30 | + | |
| 31 | + <!-- 配置静态资源,直接映射到对应的文件夹,DispatcherServlet 不处理 --> | |
| 32 | + <mvc:resources mapping="/static/**" location="/WEB-INF/static/" cache-period="31926534"> | |
| 33 | + <mvc:resource-chain resource-cache="false" auto-registration="false"> | |
| 34 | + <mvc:resolvers> | |
| 35 | + <bean class="org.springframework.web.servlet.resource.GzipResourceResolver"/> | |
| 36 | + <bean class="org.springframework.web.servlet.resource.PathResourceResolver"/> | |
| 37 | + </mvc:resolvers> | |
| 38 | + </mvc:resource-chain> | |
| 39 | + </mvc:resources> | |
| 40 | + <mvc:resources mapping="/error/**" location="/error/" /> | |
| 41 | + | |
| 42 | + <!-- 定义视图解析器 --> | |
| 43 | + <bean id="velocityConfig" | |
| 44 | + class="org.springframework.web.servlet.view.velocity.VelocityConfigurer"> | |
| 45 | + <property name="resourceLoaderPath" value="/WEB-INF/views/" /> | |
| 46 | + <property name="configLocation" value="classpath:velocity.properties" /> | |
| 47 | + </bean> | |
| 48 | + | |
| 49 | + <bean id= "viewResolver" class= "org.springframework.web.servlet.view.velocity.VelocityLayoutViewResolver"> | |
| 50 | + <property name="toolboxConfigLocation" value="/WEB-INF/toolbox.xml" /> | |
| 51 | + <property name="layoutUrl" value="layout/empty.html" /> | |
| 52 | + <property name="suffix" value=".html" /> | |
| 53 | + <property name="cache" value="false" /> | |
| 54 | + <property name="contentType" value="text/html;charset=UTF-8" /> | |
| 55 | + <property name="dateToolAttribute" value="date" /><!--日期函数名称--> | |
| 56 | + <property name="numberToolAttribute" value="number" /><!--数字函数名称--> | |
| 57 | + <!-- <property name="viewClass" value="com.lyms.velocity.VelocityToolboxViewExt"/> --> | |
| 58 | + <property name="exposeSpringMacroHelpers" value="true" /> | |
| 59 | + <property name="exposeRequestAttributes" value="true" /> | |
| 60 | + <property name="exposeSessionAttributes" value="true" /> | |
| 61 | + <property name="redirectContextRelative" value="true" /> | |
| 62 | + <property name="requestContextAttribute" value="request" /> | |
| 63 | + <property name="redirectHttp10Compatible" value="true" /> | |
| 64 | + </bean> | |
| 65 | + | |
| 66 | + <bean id="ExceptionHandler" class="com.lyms.spring.exception.ExceptionHandler" /> | |
| 67 | + | |
| 68 | + <mvc:annotation-driven> | |
| 69 | + <!-- 编码转换 --> | |
| 70 | + <mvc:message-converters> | |
| 71 | + <bean id="fastJsonHttpMessageConverter" | |
| 72 | + class="com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter"> | |
| 73 | + <property name="supportedMediaTypes"> | |
| 74 | + <list> | |
| 75 | + <value>application/json;charset=UTF-8</value> | |
| 76 | + </list> | |
| 77 | + </property> | |
| 78 | + <!-- | 这个地方能自己配置一些东西,比如时间的格式化,null输出""等等 | <property name="serializerFeature"></property> | |
| 79 | + | --> | |
| 80 | + </bean> | |
| 81 | + <bean class="org.springframework.http.converter.StringHttpMessageConverter"> | |
| 82 | + <property name="supportedMediaTypes"> | |
| 83 | + <list> | |
| 84 | + <value>text/plain;charset=UTF-8</value> | |
| 85 | + <value>text/html;charset=UTF-8</value> | |
| 86 | + <value>application/json;charset=UTF-8</value> | |
| 87 | + </list> | |
| 88 | + </property> | |
| 89 | + </bean> | |
| 90 | + </mvc:message-converters> | |
| 91 | + </mvc:annotation-driven> | |
| 92 | + | |
| 93 | + <bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver"> | |
| 94 | + <property name="defaultEncoding" value="utf-8" /> | |
| 95 | + <!-- 文件大小最大值 --> | |
| 96 | + <property name="maxUploadSize" value="10485760000" /> | |
| 97 | + <!-- 内存中的最大值 --> | |
| 98 | + <property name="maxInMemorySize" value="40960" /> | |
| 99 | + </bean> | |
| 100 | + | |
| 101 | + <aop:aspectj-autoproxy/> | |
| 102 | + <bean class = "com.lyms.aop.SysLogAop"/> | |
| 103 | + | |
| 104 | + <!-- 配置基础拦截器 --> | |
| 105 | + <mvc:interceptors> | |
| 106 | + <bean class="com.lyms.spring.interceptor.BaseInterceptor"/> | |
| 107 | + </mvc:interceptors> | |
| 108 | + <!--<bean class="com.lyms.web.listener.StartupListener"/> | |
| 109 | + <bean class="com.lyms.context.AppContext"/> | |
| 110 | + | |
| 111 | + <import resource="xml/app-*.xml" /> --> | |
| 112 | +</beans> |
center.manager/src/main/webapp/WEB-INF/web.xml
View file @
291020e
| ... | ... | @@ -4,7 +4,20 @@ |
| 4 | 4 | xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" |
| 5 | 5 | metadata-complete="true" version="3.0"> |
| 6 | 6 | |
| 7 | + <!-- application 跟 servlet xml 文件区分 --> | |
| 8 | + <context-param> | |
| 9 | + <param-name>contextConfigLocation</param-name> | |
| 10 | + <param-value> | |
| 11 | + classpath:app-context.xml | |
| 12 | + </param-value> | |
| 13 | + </context-param> | |
| 14 | + | |
| 15 | + | |
| 7 | 16 | <listener> |
| 17 | + <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> | |
| 18 | + </listener> | |
| 19 | + | |
| 20 | + <listener> | |
| 8 | 21 | <listener-class>org.springframework.web.context.request.RequestContextListener</listener-class> |
| 9 | 22 | </listener> |
| 10 | 23 | <filter> |
| ... | ... | @@ -43,7 +56,7 @@ |
| 43 | 56 | <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> |
| 44 | 57 | <init-param> |
| 45 | 58 | <param-name>contextConfigLocation</param-name> |
| 46 | - <param-value>classpath:app-context.xml</param-value> | |
| 59 | + <param-value>classpath:app-mvc.xml</param-value> | |
| 47 | 60 | </init-param> |
| 48 | 61 | <load-on-startup>1</load-on-startup> |
| 49 | 62 | </servlet> |
center.manager/src/test/java/center/manager/test/user/UserTest.java
View file @
291020e
| 1 | +package center.manager.test.user; | |
| 2 | + | |
| 3 | +import java.util.UUID; | |
| 4 | + | |
| 5 | +import org.junit.Assert; | |
| 6 | +import org.junit.Before; | |
| 7 | +import org.junit.Test; | |
| 8 | +import org.junit.runner.RunWith; | |
| 9 | +import org.springframework.beans.factory.annotation.Autowired; | |
| 10 | +import org.springframework.test.context.ContextConfiguration; | |
| 11 | +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; | |
| 12 | +import org.springframework.transaction.annotation.Transactional; | |
| 13 | + | |
| 14 | +import com.lyms.cm.entity.sys.SysUsers; | |
| 15 | +import com.lyms.cm.service.sys.ISysUsersService; | |
| 16 | + | |
| 17 | +@Transactional | |
| 18 | +@RunWith(SpringJUnit4ClassRunner.class) | |
| 19 | +@ContextConfiguration(locations = { "classpath:app-context.xml" }) | |
| 20 | +public class UserTest { | |
| 21 | + | |
| 22 | + @Autowired | |
| 23 | + private ISysUsersService userService; | |
| 24 | + | |
| 25 | + SysUsers user = null; | |
| 26 | + | |
| 27 | + @Before | |
| 28 | + public void init() { | |
| 29 | + user = new SysUsers(); | |
| 30 | + user.setId(UUID.randomUUID().toString().replaceAll("-", "")); | |
| 31 | + user.setName("欧阳拉闸"); | |
| 32 | + user.setPhone("18682531229"); | |
| 33 | + } | |
| 34 | + | |
| 35 | + @Test | |
| 36 | + public void addUserTest() { | |
| 37 | + boolean tag = userService.addUser(user); | |
| 38 | + Assert.assertTrue("添加成功", tag); | |
| 39 | + } | |
| 40 | + | |
| 41 | +} |
center.manager/src/test/java/center/manager/test/user/package-info.java
View file @
291020e
core.sdk/src/main/java/com/lyms/web/controller/BaseController.java
View file @
291020e
| ... | ... | @@ -12,7 +12,6 @@ |
| 12 | 12 | |
| 13 | 13 | import org.slf4j.Logger; |
| 14 | 14 | import org.slf4j.LoggerFactory; |
| 15 | -import org.springframework.beans.factory.annotation.Autowired; | |
| 16 | 15 | import org.springframework.beans.propertyeditors.CustomDateEditor; |
| 17 | 16 | import org.springframework.util.StringUtils; |
| 18 | 17 | import org.springframework.web.bind.ServletRequestDataBinder; |
| 19 | 18 | |
| 20 | 19 | |
| 21 | 20 | |
| 22 | 21 | |
| 23 | 22 | |
| ... | ... | @@ -30,29 +29,29 @@ |
| 30 | 29 | import com.lyms.web.entity.MobileInfo; |
| 31 | 30 | |
| 32 | 31 | public class BaseController { |
| 33 | - | |
| 34 | - protected Logger logger = LoggerFactory.getLogger(this.getClass()); | |
| 35 | 32 | |
| 36 | - @Autowired | |
| 33 | + protected Logger logger = LoggerFactory.getLogger(this.getClass()); | |
| 34 | + | |
| 35 | + // @Autowired | |
| 37 | 36 | protected HttpServletRequest request; |
| 38 | 37 | |
| 39 | - @Autowired | |
| 38 | + // @Autowired | |
| 40 | 39 | protected HttpServletResponse response; |
| 41 | - | |
| 40 | + | |
| 42 | 41 | @InitBinder |
| 43 | 42 | public void initBinder(ServletRequestDataBinder binder) { |
| 44 | - /** | |
| 45 | - * 自动转换日期类型的字段格式 | |
| 46 | - */ | |
| 47 | - binder.registerCustomEditor(Date.class, new CustomDateEditor(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"), true)); | |
| 43 | + /** | |
| 44 | + * 自动转换日期类型的字段格式 | |
| 45 | + */ | |
| 46 | + binder.registerCustomEditor(Date.class, | |
| 47 | + new CustomDateEditor(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"), true)); | |
| 48 | 48 | |
| 49 | - /** | |
| 50 | - * 防止XSS攻击 | |
| 51 | - */ | |
| 52 | - binder.registerCustomEditor(String.class, new StringEscapeEditor(true, false)); | |
| 53 | - } | |
| 54 | - | |
| 55 | - | |
| 49 | + /** | |
| 50 | + * 防止XSS攻击 | |
| 51 | + */ | |
| 52 | + binder.registerCustomEditor(String.class, new StringEscapeEditor(true, false)); | |
| 53 | + } | |
| 54 | + | |
| 56 | 55 | /** |
| 57 | 56 | * 是否为 post 请求 |
| 58 | 57 | */ |
| 59 | 58 | |
| 60 | 59 | |
| ... | ... | @@ -66,16 +65,16 @@ |
| 66 | 65 | protected boolean isGet() { |
| 67 | 66 | return HttpUtils.isGet(request); |
| 68 | 67 | } |
| 69 | - | |
| 70 | 68 | |
| 71 | 69 | /** |
| 72 | - * @param name 获取parameter | |
| 70 | + * @param name | |
| 71 | + * 获取parameter | |
| 73 | 72 | * @return |
| 74 | 73 | */ |
| 75 | 74 | protected String getParameter(String name) { |
| 76 | 75 | return request.getParameter(name); |
| 77 | 76 | } |
| 78 | - | |
| 77 | + | |
| 79 | 78 | /** |
| 80 | 79 | * 重定向至地址 url |
| 81 | 80 | * |
| ... | ... | @@ -88,7 +87,7 @@ |
| 88 | 87 | rto.append(url); |
| 89 | 88 | return rto.toString(); |
| 90 | 89 | } |
| 91 | - | |
| 90 | + | |
| 92 | 91 | /** |
| 93 | 92 | * <p> |
| 94 | 93 | * 获取分页对象 |
| ... | ... | @@ -119,7 +118,6 @@ |
| 119 | 118 | } |
| 120 | 119 | return new Page<T>(_index, _size); |
| 121 | 120 | } |
| 122 | - | |
| 123 | 121 | |
| 124 | 122 | /** |
| 125 | 123 | * |
| 126 | 124 | |
| ... | ... | @@ -130,11 +128,11 @@ |
| 130 | 128 | * @return |
| 131 | 129 | */ |
| 132 | 130 | protected String toJson(Object object) { |
| 133 | - //return JSON.toJSONString(object, SerializerFeature.BrowserCompatible); | |
| 131 | + // return JSON.toJSONString(object, | |
| 132 | + // SerializerFeature.BrowserCompatible); | |
| 134 | 133 | return JSON.toJSONString(object, SerializerFeature.WriteMapNullValue); |
| 135 | 134 | } |
| 136 | - | |
| 137 | - | |
| 135 | + | |
| 138 | 136 | /** |
| 139 | 137 | * |
| 140 | 138 | * 返回 JSON 格式对象 |
| ... | ... | @@ -151,7 +149,7 @@ |
| 151 | 149 | } |
| 152 | 150 | return JSON.toJSONStringWithDateFormat(object, format, SerializerFeature.WriteDateUseDateFormat); |
| 153 | 151 | } |
| 154 | - | |
| 152 | + | |
| 155 | 153 | /** |
| 156 | 154 | * <p> |
| 157 | 155 | * 转换为 bootstrap-table 需要的分页格式 JSON |
| 158 | 156 | |
| ... | ... | @@ -167,9 +165,7 @@ |
| 167 | 165 | gridData.put("rows", page.getRecords()); |
| 168 | 166 | return gridData; |
| 169 | 167 | } |
| 170 | - | |
| 171 | 168 | |
| 172 | - | |
| 173 | 169 | /** |
| 174 | 170 | * <li>@Description:构建分页参数 |
| 175 | 171 | * <li>@param request |
| ... | ... | @@ -203,7 +199,7 @@ |
| 203 | 199 | ajaxResult.setMessage(operationName + (result > 0 ? "成功" : "失败")); |
| 204 | 200 | return ajaxResult; |
| 205 | 201 | } |
| 206 | - | |
| 202 | + | |
| 207 | 203 | /** |
| 208 | 204 | * <li>@Description:处理json数据(方法描述) |
| 209 | 205 | * <li>@param ajaxResult ajaxResult对象 |
| ... | ... | @@ -219,9 +215,8 @@ |
| 219 | 215 | ajaxResult.setMessage(operationName + (result ? "成功" : "失败")); |
| 220 | 216 | return ajaxResult; |
| 221 | 217 | } |
| 222 | - | |
| 223 | - | |
| 224 | - /** | |
| 218 | + | |
| 219 | + /** | |
| 225 | 220 | * <li>@Description:将JSON.toJSONString(data)输出 |
| 226 | 221 | * <li>@param data |
| 227 | 222 | * <li>@param response |
| 228 | 223 | |
| 229 | 224 | |
| 230 | 225 | |
| 231 | 226 | |
| 232 | 227 | |
| 233 | 228 | |
| ... | ... | @@ -229,38 +224,39 @@ |
| 229 | 224 | * <li>创建时间:2016年9月20日 |
| 230 | 225 | * <li>修改人: |
| 231 | 226 | * <li>修改时间: |
| 232 | - */ | |
| 233 | - protected void writeJson(Object data,HttpServletResponse response){ | |
| 234 | - writeJsonText(JSON.toJSONString(data),response); | |
| 227 | + */ | |
| 228 | + protected void writeJson(Object data, HttpServletResponse response) { | |
| 229 | + writeJsonText(JSON.toJSONString(data), response); | |
| 235 | 230 | } |
| 236 | - | |
| 237 | - /** | |
| 231 | + | |
| 232 | + /** | |
| 238 | 233 | * <li>@Description:原样输出text(ContentType="application/json; charset=utf-8") |
| 239 | - * <li>@param text | |
| 234 | + * <li>@param text | |
| 240 | 235 | * <li>@param response |
| 241 | 236 | * <li>创建人:方承 |
| 242 | 237 | * <li>创建时间:2016年9月20日 |
| 243 | 238 | * <li>修改人: |
| 244 | 239 | * <li>修改时间: |
| 245 | - */ | |
| 246 | - protected void writeJsonText(String text,HttpServletResponse response){ | |
| 247 | - PrintWriter pw = null; | |
| 240 | + */ | |
| 241 | + protected void writeJsonText(String text, HttpServletResponse response) { | |
| 242 | + PrintWriter pw = null; | |
| 248 | 243 | try { |
| 249 | - response.setCharacterEncoding("UTF-8"); | |
| 250 | - response.setContentType("application/json; charset=utf-8"); | |
| 244 | + response.setCharacterEncoding("UTF-8"); | |
| 245 | + response.setContentType("application/json; charset=utf-8"); | |
| 251 | 246 | pw = response.getWriter(); |
| 252 | 247 | pw.write(text); |
| 253 | 248 | pw.flush(); |
| 254 | 249 | } catch (IOException e) { |
| 255 | 250 | e.printStackTrace(); |
| 256 | - }finally { | |
| 257 | - if(pw != null){ | |
| 251 | + } finally { | |
| 252 | + if (pw != null) { | |
| 258 | 253 | pw.flush(); |
| 259 | 254 | pw.close(); |
| 260 | 255 | } |
| 261 | 256 | } |
| 262 | 257 | } |
| 263 | - /** | |
| 258 | + | |
| 259 | + /** | |
| 264 | 260 | * <li>@Description:输出类型:text/html |
| 265 | 261 | * <li>@param text |
| 266 | 262 | * <li>@param response |
| 267 | 263 | |
| 268 | 264 | |
| 269 | 265 | |
| ... | ... | @@ -268,56 +264,56 @@ |
| 268 | 264 | * <li>创建时间:2016年9月20日 |
| 269 | 265 | * <li>修改人: |
| 270 | 266 | * <li>修改时间: |
| 271 | - */ | |
| 272 | - protected void writeText(String text,HttpServletResponse response){ | |
| 273 | - PrintWriter pw = null; | |
| 267 | + */ | |
| 268 | + protected void writeText(String text, HttpServletResponse response) { | |
| 269 | + PrintWriter pw = null; | |
| 274 | 270 | try { |
| 275 | - response.setCharacterEncoding("UTF-8"); | |
| 276 | - response.setContentType("text/html; charset=utf-8"); | |
| 271 | + response.setCharacterEncoding("UTF-8"); | |
| 272 | + response.setContentType("text/html; charset=utf-8"); | |
| 277 | 273 | pw = response.getWriter(); |
| 278 | 274 | pw.write(text); |
| 279 | 275 | pw.flush(); |
| 280 | 276 | } catch (IOException e) { |
| 281 | 277 | e.printStackTrace(); |
| 282 | - }finally { | |
| 283 | - if(pw != null){ | |
| 278 | + } finally { | |
| 279 | + if (pw != null) { | |
| 284 | 280 | pw.flush(); |
| 285 | 281 | pw.close(); |
| 286 | 282 | } |
| 287 | 283 | } |
| 288 | 284 | } |
| 289 | - | |
| 290 | - /** | |
| 291 | - * <li>@Description:获取移动端请求头信息 | |
| 292 | - * <li>@param request | |
| 293 | - * <li>@return | |
| 294 | - * <li>@throws BusinessException | |
| 295 | - * <li>创建人:方承 | |
| 296 | - * <li>创建时间:2016年10月28日 | |
| 297 | - * <li>修改人: | |
| 298 | - * <li>修改时间: | |
| 299 | - */ | |
| 300 | - protected MobileInfo getMobileInfo(HttpServletRequest request) throws BusinessException { | |
| 301 | - String appVersion = request.getHeader("appVersion"); | |
| 302 | - String systemVersion = request.getHeader("appSystemVersion"); | |
| 303 | - String deviceId = request.getHeader("appDeviceId"); | |
| 304 | - Integer width = null; | |
| 305 | - Integer height = null; | |
| 306 | - int night = 0; | |
| 307 | - try { | |
| 308 | - width = Integer.parseInt(request.getHeader("appDeviceWidth")); | |
| 309 | - height = Integer.parseInt(request.getHeader("appDeviceHeight")); | |
| 310 | - if (request.getHeader("nightMode") != null) { | |
| 311 | - night = Integer.parseInt(request.getHeader("nightMode")); | |
| 312 | - } | |
| 313 | - } catch (NumberFormatException e) { | |
| 314 | - throw new BusinessException("移动端请求头不符合约定"); | |
| 315 | - } | |
| 316 | - if (StrUtils.isEmpty(appVersion) || width == null || height == null) { | |
| 317 | - throw new BusinessException("移动端请求头不符合约定"); | |
| 318 | - } | |
| 319 | - return new MobileInfo(appVersion, systemVersion, deviceId, width, height, night != 0); | |
| 320 | - } | |
| 285 | + | |
| 286 | + /** | |
| 287 | + * <li>@Description:获取移动端请求头信息 | |
| 288 | + * <li>@param request | |
| 289 | + * <li>@return | |
| 290 | + * <li>@throws BusinessException | |
| 291 | + * <li>创建人:方承 | |
| 292 | + * <li>创建时间:2016年10月28日 | |
| 293 | + * <li>修改人: | |
| 294 | + * <li>修改时间: | |
| 295 | + */ | |
| 296 | + protected MobileInfo getMobileInfo(HttpServletRequest request) throws BusinessException { | |
| 297 | + String appVersion = request.getHeader("appVersion"); | |
| 298 | + String systemVersion = request.getHeader("appSystemVersion"); | |
| 299 | + String deviceId = request.getHeader("appDeviceId"); | |
| 300 | + Integer width = null; | |
| 301 | + Integer height = null; | |
| 302 | + int night = 0; | |
| 303 | + try { | |
| 304 | + width = Integer.parseInt(request.getHeader("appDeviceWidth")); | |
| 305 | + height = Integer.parseInt(request.getHeader("appDeviceHeight")); | |
| 306 | + if (request.getHeader("nightMode") != null) { | |
| 307 | + night = Integer.parseInt(request.getHeader("nightMode")); | |
| 308 | + } | |
| 309 | + } catch (NumberFormatException e) { | |
| 310 | + throw new BusinessException("移动端请求头不符合约定"); | |
| 311 | + } | |
| 312 | + if (StrUtils.isEmpty(appVersion) || width == null || height == null) { | |
| 313 | + throw new BusinessException("移动端请求头不符合约定"); | |
| 314 | + } | |
| 315 | + return new MobileInfo(appVersion, systemVersion, deviceId, width, height, night != 0); | |
| 316 | + } | |
| 321 | 317 | |
| 322 | 318 | } |