完善基础代码
This commit is contained in:
parent
04ac64d307
commit
4ada58f55b
14
basic-annotation/pom.xml
Normal file
14
basic-annotation/pom.xml
Normal file
@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>wg-basic</artifactId>
|
||||
<groupId>ink.wgink</groupId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>basic-annotation</artifactId>
|
||||
|
||||
</project>
|
@ -0,0 +1,18 @@
|
||||
package ink.wgink.annotation;
|
||||
|
||||
/**
|
||||
* When you feel like quitting. Think about why you started
|
||||
* 当你想要放弃的时候,想想当初你为何开始
|
||||
*
|
||||
* @ClassName: CheckBooleanAnnotation
|
||||
* @Description: TODO
|
||||
* @Author: WangGeng
|
||||
* @Date: 2019/11/14 14:50
|
||||
* @Version: 1.0
|
||||
**/
|
||||
public @interface CheckBooleanAnnotation {
|
||||
|
||||
String name();
|
||||
|
||||
String[] types() default {};
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
package ink.wgink.annotation;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
/**
|
||||
* When you feel like quitting. Think about why you started
|
||||
* 当你想要放弃的时候,想想当初你为何开始
|
||||
*
|
||||
* @ClassName: CheckEmptyAnnotation
|
||||
* @Description: 校验空
|
||||
* @Author: WangGeng
|
||||
* @Date: 2019/11/14 14:05
|
||||
* @Version: 1.0
|
||||
**/
|
||||
@Documented
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target({ElementType.FIELD})
|
||||
public @interface CheckEmptyAnnotation {
|
||||
|
||||
String name();
|
||||
|
||||
String[] types() default {};
|
||||
|
||||
String verifyType() default "";
|
||||
|
||||
String regex() default "";
|
||||
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
package ink.wgink.annotation;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
/**
|
||||
* When you feel like quitting. Think about why you started
|
||||
* 当你想要放弃的时候,想想当初你为何开始
|
||||
*
|
||||
* @ClassName: CheckListAnnotation
|
||||
* @Description: 校验List
|
||||
* @Author: WangGeng
|
||||
* @Date: 2019/11/15 14:39
|
||||
* @Version: 1.0
|
||||
**/
|
||||
@Documented
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target({ElementType.FIELD})
|
||||
public @interface CheckListAnnotation {
|
||||
|
||||
String name();
|
||||
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
package ink.wgink.annotation;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
/**
|
||||
* When you feel like quitting. Think about why you started
|
||||
* 当你想要放弃的时候,想想当初你为何开始
|
||||
*
|
||||
* @ClassName: CheckNullAnno
|
||||
* @Description: 字段为空校验
|
||||
* @Author: WangGeng
|
||||
* @Date: 2019/11/14 11:31
|
||||
* @Version: 1.0
|
||||
**/
|
||||
@Documented
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target({ElementType.FIELD})
|
||||
public @interface CheckNullAnnotation {
|
||||
|
||||
String name();
|
||||
|
||||
String[] types() default {};
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
package ink.wgink.annotation;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
/**
|
||||
* When you feel like quitting. Think about why you started
|
||||
* 当你想要放弃的时候,想想当初你为何开始
|
||||
*
|
||||
* @ClassName: CheckNumberAnnotation
|
||||
* @Description: 字段为数字校验
|
||||
* @Author: WangGeng
|
||||
* @Date: 2019/11/14 11:31
|
||||
* @Version: 1.0
|
||||
**/
|
||||
@Documented
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target({ElementType.FIELD})
|
||||
public @interface CheckNumberAnnotation {
|
||||
|
||||
String name();
|
||||
|
||||
String[] types() default {};
|
||||
|
||||
double max() default Integer.MAX_VALUE;
|
||||
|
||||
double min() default Integer.MIN_VALUE;
|
||||
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
package ink.wgink.annotation;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
/**
|
||||
* When you feel like quitting. Think about why you started
|
||||
* 当你想要放弃的时候,想想当初你为何开始
|
||||
*
|
||||
* @ClassName: CheckRequestBodyAnnotation
|
||||
* @Description: 校验请求主体
|
||||
* @Author: WangGeng
|
||||
* @Date: 2019/11/14 16:02
|
||||
* @Version: 1.0
|
||||
**/
|
||||
@Documented
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target({ElementType.METHOD})
|
||||
public @interface CheckRequestBodyAnnotation {
|
||||
}
|
@ -11,9 +11,22 @@
|
||||
|
||||
<artifactId>basic-app</artifactId>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>8</maven.compiler.source>
|
||||
<maven.compiler.target>8</maven.compiler.target>
|
||||
</properties>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>ink.wgink</groupId>
|
||||
<artifactId>basic-exception</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ink.wgink</groupId>
|
||||
<artifactId>basic-interface</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ink.wgink</groupId>
|
||||
<artifactId>basic-util</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
@ -1,16 +1,16 @@
|
||||
package ink.wgink.app;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.cm.common.constants.ISystemConstant;
|
||||
import com.cm.common.enums.AppTokenTypeEnum;
|
||||
import com.cm.common.exception.TokenException;
|
||||
import com.cm.common.token.app.entity.AppToken;
|
||||
import com.cm.common.token.app.entity.AppTokenUser;
|
||||
import com.cm.common.utils.AesUtil;
|
||||
import ink.wgink.app.entity.AppToken;
|
||||
import ink.wgink.app.entity.AppTokenUser;
|
||||
import ink.wgink.app.enums.AppTokenTypeEnum;
|
||||
import ink.wgink.exceptions.TokenException;
|
||||
import ink.wgink.interfaces.consts.ISystemConstant;
|
||||
import ink.wgink.util.AesUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.codec.binary.Base64;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
@ -28,9 +28,9 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
* @Date: 2019-08-02 11:08
|
||||
* @Version: 1.0
|
||||
**/
|
||||
@Slf4j
|
||||
public class AppTokenManager {
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(AppTokenManager.class);
|
||||
private static AppTokenManager appTokenManager = AppTokenManagerBuilder.appTokenManager;
|
||||
private static final Map<String, AppToken> tokens = new ConcurrentHashMap();
|
||||
|
||||
@ -59,7 +59,7 @@ public class AppTokenManager {
|
||||
* 添加token
|
||||
*
|
||||
* @param token
|
||||
* @param type
|
||||
* @param appTokenTypeEnum
|
||||
* @param appTokenUser
|
||||
*/
|
||||
public synchronized void addToken(String token, AppTokenTypeEnum appTokenTypeEnum, AppTokenUser appTokenUser) {
|
||||
@ -83,7 +83,7 @@ public class AppTokenManager {
|
||||
try {
|
||||
userInfo = AesUtil.aesCommonDecoder(ISystemConstant.APP_TOKEN_AES_KEY, new String(Base64.decodeBase64(token), "UTF-8"));
|
||||
} catch (Exception e) {
|
||||
LOG.error(e.getMessage(), e);
|
||||
log.error(e.getMessage(), e);
|
||||
throw new TokenException("Token解码异常");
|
||||
}
|
||||
JSONObject userInfoObj = JSONObject.parseObject(userInfo);
|
||||
@ -92,23 +92,23 @@ public class AppTokenManager {
|
||||
}
|
||||
String appTokenSign = userInfoObj.getString(ISystemConstant.APP_TOKEN_SIGN);
|
||||
if (StringUtils.isBlank(appTokenSign)) {
|
||||
LOG.debug("Token标识为空");
|
||||
log.debug("Token标识为空");
|
||||
throw new TokenException("Token非法");
|
||||
}
|
||||
if (!StringUtils.startsWith(appTokenSign, ISystemConstant.APP_TOKEN_VERIFY)) {
|
||||
LOG.debug("Token标识开头错误");
|
||||
log.debug("Token标识开头错误");
|
||||
throw new TokenException("Token非法");
|
||||
}
|
||||
String[] appTokenSignArray = appTokenSign.split("_");
|
||||
if (appTokenSignArray.length != 3) {
|
||||
LOG.debug("Token标识格式长度异常,应为3,这里为:{}", appTokenSignArray.length);
|
||||
log.debug("Token标识格式长度异常,应为3,这里为:{}", appTokenSignArray.length);
|
||||
throw new TokenException("Token非法");
|
||||
}
|
||||
try {
|
||||
new Date(Long.parseLong(appTokenSignArray[2]));
|
||||
} catch (NumberFormatException e) {
|
||||
e.printStackTrace();
|
||||
LOG.debug("Token时间戳异常");
|
||||
log.debug("Token时间戳异常");
|
||||
throw new TokenException("Token非法");
|
||||
}
|
||||
return JSONObject.toJavaObject(userInfoObj, AppTokenUser.class);
|
||||
@ -144,7 +144,7 @@ public class AppTokenManager {
|
||||
for (String tokenKey : clearTokenKeys) {
|
||||
tokens.remove(tokenKey);
|
||||
}
|
||||
LOG.debug("本次共清理超时Token:{}个", clearTokenKeys.size());
|
||||
log.debug("本次共清理超时Token:{}个", clearTokenKeys.size());
|
||||
}
|
||||
|
||||
private static class AppTokenManagerBuilder {
|
||||
|
@ -11,9 +11,4 @@
|
||||
|
||||
<artifactId>basic-exception</artifactId>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>8</maven.compiler.source>
|
||||
<maven.compiler.target>8</maven.compiler.target>
|
||||
</properties>
|
||||
|
||||
</project>
|
@ -18,7 +18,6 @@
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
</dependencies>
|
||||
|
||||
</project>
|
@ -10,5 +10,5 @@ package ink.wgink.interfaces.department;
|
||||
* @Date: 2021/1/24 12:53
|
||||
* @Version: 1.0
|
||||
**/
|
||||
public interface IDepartmentService {
|
||||
public interface IDepartmentBaseService {
|
||||
}
|
@ -0,0 +1,54 @@
|
||||
package ink.wgink.interfaces.user;
|
||||
|
||||
import ink.wgink.pojo.ListPage;
|
||||
import ink.wgink.pojo.dtos.user.UserDTO;
|
||||
import ink.wgink.pojo.result.SuccessResultList;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* When you feel like quitting. Think about why you started
|
||||
* 当你想要放弃的时候,想想当初你为何开始
|
||||
*
|
||||
* @ClassName: IUserService
|
||||
* @Description: 用户
|
||||
* @Author: WangGeng
|
||||
* @Date: 2021/1/24 12:52
|
||||
* @Version: 1.0
|
||||
**/
|
||||
public interface IUserBaseService {
|
||||
|
||||
/**
|
||||
* 用户详情
|
||||
*
|
||||
* @param userId 用户ID
|
||||
* @return
|
||||
*/
|
||||
UserDTO get(String userId);
|
||||
|
||||
/**
|
||||
* 用户详情
|
||||
*
|
||||
* @param username 用户名
|
||||
* @return
|
||||
*/
|
||||
UserDTO getByUsername(String username);
|
||||
|
||||
/**
|
||||
* 用户列表
|
||||
*
|
||||
* @param params
|
||||
* @return
|
||||
*/
|
||||
List<UserDTO> list(Map<String, Object> params);
|
||||
|
||||
/**
|
||||
* 用户分页列表
|
||||
*
|
||||
* @param page
|
||||
* @return
|
||||
*/
|
||||
SuccessResultList<List<UserDTO>> listPage(ListPage page);
|
||||
|
||||
}
|
@ -1,14 +0,0 @@
|
||||
package ink.wgink.interfaces.user;
|
||||
|
||||
/**
|
||||
* When you feel like quitting. Think about why you started
|
||||
* 当你想要放弃的时候,想想当初你为何开始
|
||||
*
|
||||
* @ClassName: IUserService
|
||||
* @Description: 用户
|
||||
* @Author: WangGeng
|
||||
* @Date: 2021/1/24 12:52
|
||||
* @Version: 1.0
|
||||
**/
|
||||
public interface IUserService {
|
||||
}
|
@ -12,6 +12,19 @@
|
||||
<artifactId>basic-pojo</artifactId>
|
||||
|
||||
<dependencies>
|
||||
<!-- tomcat start -->
|
||||
<dependency>
|
||||
<groupId>org.apache.tomcat.embed</groupId>
|
||||
<artifactId>tomcat-embed-core</artifactId>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<!-- tomcat end -->
|
||||
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- spring start -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.security</groupId>
|
||||
|
@ -28,16 +28,16 @@ public class RoleGrantedAuthority implements GrantedAuthority {
|
||||
private List<RoleMenuBO> routeSaveMenu;
|
||||
private List<RoleMenuBO> routeUpdateMenu;
|
||||
private List<RoleMenuBO> routeQueryMenu;
|
||||
private List<com.cm.common.pojo.bos.PermissionBO> permissionInsert;
|
||||
private List<com.cm.common.pojo.bos.PermissionBO> permissionDelete;
|
||||
private List<com.cm.common.pojo.bos.PermissionBO> permissionUpdate;
|
||||
private List<com.cm.common.pojo.bos.PermissionBO> permissionQuery;
|
||||
private List<PermissionBO> permissionInsert;
|
||||
private List<PermissionBO> permissionDelete;
|
||||
private List<PermissionBO> permissionUpdate;
|
||||
private List<PermissionBO> permissionQuery;
|
||||
|
||||
public RoleGrantedAuthority(String role) {
|
||||
this.role = role;
|
||||
}
|
||||
|
||||
public RoleGrantedAuthority(String role, com.cm.common.pojo.bos.RoleBO roleBO) {
|
||||
public RoleGrantedAuthority(String role, RoleBO roleBO) {
|
||||
this.role = role;
|
||||
this.roleId = roleBO.getRoleId();
|
||||
this.roleName = roleBO.getRoleName();
|
||||
@ -181,35 +181,35 @@ public class RoleGrantedAuthority implements GrantedAuthority {
|
||||
this.routeQueryMenu = routeQueryMenu;
|
||||
}
|
||||
|
||||
public List<com.cm.common.pojo.bos.PermissionBO> getPermissionInsert() {
|
||||
public List<PermissionBO> getPermissionInsert() {
|
||||
return permissionInsert;
|
||||
}
|
||||
|
||||
public void setPermissionInsert(List<com.cm.common.pojo.bos.PermissionBO> permissionInsert) {
|
||||
public void setPermissionInsert(List<PermissionBO> permissionInsert) {
|
||||
this.permissionInsert = permissionInsert;
|
||||
}
|
||||
|
||||
public List<com.cm.common.pojo.bos.PermissionBO> getPermissionDelete() {
|
||||
public List<PermissionBO> getPermissionDelete() {
|
||||
return permissionDelete;
|
||||
}
|
||||
|
||||
public void setPermissionDelete(List<com.cm.common.pojo.bos.PermissionBO> permissionDelete) {
|
||||
public void setPermissionDelete(List<PermissionBO> permissionDelete) {
|
||||
this.permissionDelete = permissionDelete;
|
||||
}
|
||||
|
||||
public List<com.cm.common.pojo.bos.PermissionBO> getPermissionUpdate() {
|
||||
public List<PermissionBO> getPermissionUpdate() {
|
||||
return permissionUpdate;
|
||||
}
|
||||
|
||||
public void setPermissionUpdate(List<com.cm.common.pojo.bos.PermissionBO> permissionUpdate) {
|
||||
public void setPermissionUpdate(List<PermissionBO> permissionUpdate) {
|
||||
this.permissionUpdate = permissionUpdate;
|
||||
}
|
||||
|
||||
public List<com.cm.common.pojo.bos.PermissionBO> getPermissionQuery() {
|
||||
public List<PermissionBO> getPermissionQuery() {
|
||||
return permissionQuery;
|
||||
}
|
||||
|
||||
public void setPermissionQuery(List<com.cm.common.pojo.bos.PermissionBO> permissionQuery) {
|
||||
public void setPermissionQuery(List<PermissionBO> permissionQuery) {
|
||||
this.permissionQuery = permissionQuery;
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,39 @@
|
||||
package ink.wgink.pojo.dtos.department;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @ClassName: DepartmentDTO
|
||||
* @Description: 组织部门
|
||||
* @Author: wenc
|
||||
* @Date: 2019/1/8 7:43 PM
|
||||
* @Version: 1.0
|
||||
**/
|
||||
@ApiModel
|
||||
public class DepartmentDTO extends DepartmentSimpleDTO {
|
||||
|
||||
private static final long serialVersionUID = -6682276871851732246L;
|
||||
@ApiModelProperty(name = "subDepartments", value = "组织部门子列表")
|
||||
private List<DepartmentDTO> subDepartments;
|
||||
|
||||
public List<DepartmentDTO> getSubDepartments() {
|
||||
return subDepartments == null ? new ArrayList<>() : subDepartments;
|
||||
}
|
||||
|
||||
public void setSubDepartments(List<DepartmentDTO> subDepartments) {
|
||||
this.subDepartments = subDepartments;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
final StringBuilder sb = new StringBuilder("{");
|
||||
sb.append("\"subDepartments\":")
|
||||
.append(subDepartments);
|
||||
sb.append('}');
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
@ -0,0 +1,471 @@
|
||||
package ink.wgink.pojo.dtos.department;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* When you feel like quitting. Think about why you started
|
||||
* 当你想要放弃的时候,想想当初你为何开始
|
||||
*
|
||||
* @ClassName: DepartmentSimpleDTO
|
||||
* @Description: 组织机构(简单)
|
||||
* @Author: WangGeng
|
||||
* @Date: 2020/4/28 12:11
|
||||
* @Version: 1.0
|
||||
**/
|
||||
public class DepartmentSimpleDTO implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 595737776232939256L;
|
||||
@ApiModelProperty(name = "departmentIntId", value = "组织部门ID")
|
||||
private Long departmentIntId;
|
||||
@ApiModelProperty(name = "departmentId", value = "组织部门ID")
|
||||
private String departmentId;
|
||||
@ApiModelProperty(name = "departmentParentId", value = "组织部门上级ID")
|
||||
private String departmentParentId;
|
||||
@ApiModelProperty(name = "departmentParentName", value = "组织部门上级名称")
|
||||
private String departmentParentName;
|
||||
@ApiModelProperty(name = "departmentName", value = "组织部门名称")
|
||||
private String departmentName;
|
||||
@ApiModelProperty(name = "departmentNameEn", value = "组织部门名称(英文)")
|
||||
private String departmentNameEn;
|
||||
@ApiModelProperty(name = "departmentNameOther", value = "组织部门名称(其他类型)")
|
||||
private String departmentNameOther;
|
||||
@ApiModelProperty(name = "departmentCode", value = "组织部门编码")
|
||||
private String departmentCode;
|
||||
@ApiModelProperty(name = "departmentSummary", value = "组织部门说明")
|
||||
private String departmentSummary;
|
||||
@ApiModelProperty(name = "departmentLogo", value = "组织部门图标ID")
|
||||
private Long departmentLogo;
|
||||
@ApiModelProperty(name = "departmentLogoHover", value = "组织部门图标ID(选中)")
|
||||
private Long departmentLogoHover;
|
||||
@ApiModelProperty(name = "departmentType", value = "组织部门类别,1:机构,2:部门")
|
||||
private Integer departmentType;
|
||||
@ApiModelProperty(name = "departmentState", value = "组织部门状态,0:正常,1:锁定:2:冻结")
|
||||
private Integer departmentState;
|
||||
@ApiModelProperty(name = "departmentFax", value = "组织部门传真")
|
||||
private String departmentFax;
|
||||
@ApiModelProperty(name = "departmentTel", value = "组织部门电话")
|
||||
private String departmentTel;
|
||||
@ApiModelProperty(name = "departmentAddress", value = "组织部门地址")
|
||||
private String departmentAddress;
|
||||
@ApiModelProperty(name = "departmentMaster", value = "组织部门负责人")
|
||||
private String departmentMaster;
|
||||
@ApiModelProperty(name = "departmentMasterName", value = "组织部门负责人名称")
|
||||
private String departmentMasterName;
|
||||
@ApiModelProperty(name = "departmentDuty", value = "组织部门职责")
|
||||
private String departmentDuty;
|
||||
@ApiModelProperty(name = "departmentArea1Id", value = "1级区域ID")
|
||||
private String departmentArea1Id;
|
||||
@ApiModelProperty(name = "departmentArea1Code", value = "1级区域编码")
|
||||
private String departmentArea1Code;
|
||||
@ApiModelProperty(name = "departmentArea1Name", value = "1级区域名称")
|
||||
private String departmentArea1Name;
|
||||
@ApiModelProperty(name = "departmentArea2Id", value = "2级区域ID")
|
||||
private String departmentArea2Id;
|
||||
@ApiModelProperty(name = "departmentArea2Code", value = "2级区域编码")
|
||||
private String departmentArea2Code;
|
||||
@ApiModelProperty(name = "departmentArea2Name", value = "2级区域名称")
|
||||
private String departmentArea2Name;
|
||||
@ApiModelProperty(name = "departmentArea3Id", value = "3级区域ID")
|
||||
private String departmentArea3Id;
|
||||
@ApiModelProperty(name = "departmentArea3Code", value = "3级区域编码")
|
||||
private String departmentArea3Code;
|
||||
@ApiModelProperty(name = "departmentArea3Name", value = "3级区域名称")
|
||||
private String departmentArea3Name;
|
||||
@ApiModelProperty(name = "departmentArea4Id", value = "4级区域ID")
|
||||
private String departmentArea4Id;
|
||||
@ApiModelProperty(name = "departmentArea4Code", value = "4级区域编码")
|
||||
private String departmentArea4Code;
|
||||
@ApiModelProperty(name = "departmentArea4Name", value = "4级区域名称")
|
||||
private String departmentArea4Name;
|
||||
@ApiModelProperty(name = "departmentArea5Id", value = "5级区域ID")
|
||||
private String departmentArea5Id;
|
||||
@ApiModelProperty(name = "departmentArea5Code", value = "5级区域编码")
|
||||
private String departmentArea5Code;
|
||||
@ApiModelProperty(name = "departmentArea5Name", value = "5级区域名称")
|
||||
private String departmentArea5Name;
|
||||
@ApiModelProperty(name = "departmentLongitude", value = "组织部门经度")
|
||||
private String departmentLongitude;
|
||||
@ApiModelProperty(name = "departmentLatitude", value = "组织部门纬度")
|
||||
private String departmentLatitude;
|
||||
@ApiModelProperty(name = "departmentOrder", value = "组织部门排序,默认0")
|
||||
private String departmentOrder;
|
||||
|
||||
public Long getDepartmentIntId() {
|
||||
return departmentIntId;
|
||||
}
|
||||
|
||||
public void setDepartmentIntId(Long departmentIntId) {
|
||||
this.departmentIntId = departmentIntId;
|
||||
}
|
||||
|
||||
public String getDepartmentId() {
|
||||
return departmentId == null ? "" : departmentId;
|
||||
}
|
||||
|
||||
public void setDepartmentId(String departmentId) {
|
||||
this.departmentId = departmentId;
|
||||
}
|
||||
|
||||
public String getDepartmentParentId() {
|
||||
return departmentParentId == null ? "" : departmentParentId;
|
||||
}
|
||||
|
||||
public void setDepartmentParentId(String departmentParentId) {
|
||||
this.departmentParentId = departmentParentId;
|
||||
}
|
||||
|
||||
public String getDepartmentParentName() {
|
||||
return departmentParentName == null ? "" : departmentParentName;
|
||||
}
|
||||
|
||||
public void setDepartmentParentName(String departmentParentName) {
|
||||
this.departmentParentName = departmentParentName;
|
||||
}
|
||||
|
||||
public String getDepartmentName() {
|
||||
return departmentName == null ? "" : departmentName;
|
||||
}
|
||||
|
||||
public void setDepartmentName(String departmentName) {
|
||||
this.departmentName = departmentName;
|
||||
}
|
||||
|
||||
public String getDepartmentNameEn() {
|
||||
return departmentNameEn == null ? "" : departmentNameEn;
|
||||
}
|
||||
|
||||
public void setDepartmentNameEn(String departmentNameEn) {
|
||||
this.departmentNameEn = departmentNameEn;
|
||||
}
|
||||
|
||||
public String getDepartmentNameOther() {
|
||||
return departmentNameOther == null ? "" : departmentNameOther;
|
||||
}
|
||||
|
||||
public void setDepartmentNameOther(String departmentNameOther) {
|
||||
this.departmentNameOther = departmentNameOther;
|
||||
}
|
||||
|
||||
public String getDepartmentCode() {
|
||||
return departmentCode == null ? "" : departmentCode;
|
||||
}
|
||||
|
||||
public void setDepartmentCode(String departmentCode) {
|
||||
this.departmentCode = departmentCode;
|
||||
}
|
||||
|
||||
public String getDepartmentSummary() {
|
||||
return departmentSummary == null ? "" : departmentSummary;
|
||||
}
|
||||
|
||||
public void setDepartmentSummary(String departmentSummary) {
|
||||
this.departmentSummary = departmentSummary;
|
||||
}
|
||||
|
||||
public Long getDepartmentLogo() {
|
||||
return departmentLogo;
|
||||
}
|
||||
|
||||
public void setDepartmentLogo(Long departmentLogo) {
|
||||
this.departmentLogo = departmentLogo;
|
||||
}
|
||||
|
||||
public Long getDepartmentLogoHover() {
|
||||
return departmentLogoHover;
|
||||
}
|
||||
|
||||
public void setDepartmentLogoHover(Long departmentLogoHover) {
|
||||
this.departmentLogoHover = departmentLogoHover;
|
||||
}
|
||||
|
||||
public Integer getDepartmentType() {
|
||||
return departmentType;
|
||||
}
|
||||
|
||||
public void setDepartmentType(Integer departmentType) {
|
||||
this.departmentType = departmentType;
|
||||
}
|
||||
|
||||
public Integer getDepartmentState() {
|
||||
return departmentState;
|
||||
}
|
||||
|
||||
public void setDepartmentState(Integer departmentState) {
|
||||
this.departmentState = departmentState;
|
||||
}
|
||||
|
||||
public String getDepartmentFax() {
|
||||
return departmentFax == null ? "" : departmentFax;
|
||||
}
|
||||
|
||||
public void setDepartmentFax(String departmentFax) {
|
||||
this.departmentFax = departmentFax;
|
||||
}
|
||||
|
||||
public String getDepartmentTel() {
|
||||
return departmentTel == null ? "" : departmentTel;
|
||||
}
|
||||
|
||||
public void setDepartmentTel(String departmentTel) {
|
||||
this.departmentTel = departmentTel;
|
||||
}
|
||||
|
||||
public String getDepartmentAddress() {
|
||||
return departmentAddress == null ? "" : departmentAddress;
|
||||
}
|
||||
|
||||
public void setDepartmentAddress(String departmentAddress) {
|
||||
this.departmentAddress = departmentAddress;
|
||||
}
|
||||
|
||||
public String getDepartmentMaster() {
|
||||
return departmentMaster == null ? "" : departmentMaster;
|
||||
}
|
||||
|
||||
public void setDepartmentMaster(String departmentMaster) {
|
||||
this.departmentMaster = departmentMaster;
|
||||
}
|
||||
|
||||
public String getDepartmentMasterName() {
|
||||
return departmentMasterName == null ? "" : departmentMasterName;
|
||||
}
|
||||
|
||||
public void setDepartmentMasterName(String departmentMasterName) {
|
||||
this.departmentMasterName = departmentMasterName;
|
||||
}
|
||||
|
||||
public String getDepartmentDuty() {
|
||||
return departmentDuty == null ? "" : departmentDuty;
|
||||
}
|
||||
|
||||
public void setDepartmentDuty(String departmentDuty) {
|
||||
this.departmentDuty = departmentDuty;
|
||||
}
|
||||
|
||||
public String getDepartmentArea1Id() {
|
||||
return departmentArea1Id == null ? "" : departmentArea1Id;
|
||||
}
|
||||
|
||||
public void setDepartmentArea1Id(String departmentArea1Id) {
|
||||
this.departmentArea1Id = departmentArea1Id;
|
||||
}
|
||||
|
||||
public String getDepartmentArea1Code() {
|
||||
return departmentArea1Code == null ? "" : departmentArea1Code;
|
||||
}
|
||||
|
||||
public void setDepartmentArea1Code(String departmentArea1Code) {
|
||||
this.departmentArea1Code = departmentArea1Code;
|
||||
}
|
||||
|
||||
public String getDepartmentArea1Name() {
|
||||
return departmentArea1Name == null ? "" : departmentArea1Name;
|
||||
}
|
||||
|
||||
public void setDepartmentArea1Name(String departmentArea1Name) {
|
||||
this.departmentArea1Name = departmentArea1Name;
|
||||
}
|
||||
|
||||
public String getDepartmentArea2Id() {
|
||||
return departmentArea2Id == null ? "" : departmentArea2Id;
|
||||
}
|
||||
|
||||
public void setDepartmentArea2Id(String departmentArea2Id) {
|
||||
this.departmentArea2Id = departmentArea2Id;
|
||||
}
|
||||
|
||||
public String getDepartmentArea2Code() {
|
||||
return departmentArea2Code == null ? "" : departmentArea2Code;
|
||||
}
|
||||
|
||||
public void setDepartmentArea2Code(String departmentArea2Code) {
|
||||
this.departmentArea2Code = departmentArea2Code;
|
||||
}
|
||||
|
||||
public String getDepartmentArea2Name() {
|
||||
return departmentArea2Name == null ? "" : departmentArea2Name;
|
||||
}
|
||||
|
||||
public void setDepartmentArea2Name(String departmentArea2Name) {
|
||||
this.departmentArea2Name = departmentArea2Name;
|
||||
}
|
||||
|
||||
public String getDepartmentArea3Id() {
|
||||
return departmentArea3Id == null ? "" : departmentArea3Id;
|
||||
}
|
||||
|
||||
public void setDepartmentArea3Id(String departmentArea3Id) {
|
||||
this.departmentArea3Id = departmentArea3Id;
|
||||
}
|
||||
|
||||
public String getDepartmentArea3Code() {
|
||||
return departmentArea3Code == null ? "" : departmentArea3Code;
|
||||
}
|
||||
|
||||
public void setDepartmentArea3Code(String departmentArea3Code) {
|
||||
this.departmentArea3Code = departmentArea3Code;
|
||||
}
|
||||
|
||||
public String getDepartmentArea3Name() {
|
||||
return departmentArea3Name == null ? "" : departmentArea3Name;
|
||||
}
|
||||
|
||||
public void setDepartmentArea3Name(String departmentArea3Name) {
|
||||
this.departmentArea3Name = departmentArea3Name;
|
||||
}
|
||||
|
||||
public String getDepartmentArea4Id() {
|
||||
return departmentArea4Id == null ? "" : departmentArea4Id;
|
||||
}
|
||||
|
||||
public void setDepartmentArea4Id(String departmentArea4Id) {
|
||||
this.departmentArea4Id = departmentArea4Id;
|
||||
}
|
||||
|
||||
public String getDepartmentArea4Code() {
|
||||
return departmentArea4Code == null ? "" : departmentArea4Code;
|
||||
}
|
||||
|
||||
public void setDepartmentArea4Code(String departmentArea4Code) {
|
||||
this.departmentArea4Code = departmentArea4Code;
|
||||
}
|
||||
|
||||
public String getDepartmentArea4Name() {
|
||||
return departmentArea4Name == null ? "" : departmentArea4Name;
|
||||
}
|
||||
|
||||
public void setDepartmentArea4Name(String departmentArea4Name) {
|
||||
this.departmentArea4Name = departmentArea4Name;
|
||||
}
|
||||
|
||||
public String getDepartmentArea5Id() {
|
||||
return departmentArea5Id == null ? "" : departmentArea5Id;
|
||||
}
|
||||
|
||||
public void setDepartmentArea5Id(String departmentArea5Id) {
|
||||
this.departmentArea5Id = departmentArea5Id;
|
||||
}
|
||||
|
||||
public String getDepartmentArea5Code() {
|
||||
return departmentArea5Code == null ? "" : departmentArea5Code;
|
||||
}
|
||||
|
||||
public void setDepartmentArea5Code(String departmentArea5Code) {
|
||||
this.departmentArea5Code = departmentArea5Code;
|
||||
}
|
||||
|
||||
public String getDepartmentArea5Name() {
|
||||
return departmentArea5Name == null ? "" : departmentArea5Name;
|
||||
}
|
||||
|
||||
public void setDepartmentArea5Name(String departmentArea5Name) {
|
||||
this.departmentArea5Name = departmentArea5Name;
|
||||
}
|
||||
|
||||
public String getDepartmentLongitude() {
|
||||
return departmentLongitude == null ? "" : departmentLongitude;
|
||||
}
|
||||
|
||||
public void setDepartmentLongitude(String departmentLongitude) {
|
||||
this.departmentLongitude = departmentLongitude;
|
||||
}
|
||||
|
||||
public String getDepartmentLatitude() {
|
||||
return departmentLatitude == null ? "" : departmentLatitude;
|
||||
}
|
||||
|
||||
public void setDepartmentLatitude(String departmentLatitude) {
|
||||
this.departmentLatitude = departmentLatitude;
|
||||
}
|
||||
|
||||
public String getDepartmentOrder() {
|
||||
return departmentOrder == null ? "" : departmentOrder;
|
||||
}
|
||||
|
||||
public void setDepartmentOrder(String departmentOrder) {
|
||||
this.departmentOrder = departmentOrder;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
final StringBuilder sb = new StringBuilder("{");
|
||||
sb.append("\"departmentIntId\":")
|
||||
.append(departmentIntId);
|
||||
sb.append(",\"departmentId\":\"")
|
||||
.append(departmentId).append('\"');
|
||||
sb.append(",\"departmentParentId\":\"")
|
||||
.append(departmentParentId).append('\"');
|
||||
sb.append(",\"departmentParentName\":\"")
|
||||
.append(departmentParentName).append('\"');
|
||||
sb.append(",\"departmentName\":\"")
|
||||
.append(departmentName).append('\"');
|
||||
sb.append(",\"departmentNameEn\":\"")
|
||||
.append(departmentNameEn).append('\"');
|
||||
sb.append(",\"departmentNameOther\":\"")
|
||||
.append(departmentNameOther).append('\"');
|
||||
sb.append(",\"departmentCode\":\"")
|
||||
.append(departmentCode).append('\"');
|
||||
sb.append(",\"departmentSummary\":\"")
|
||||
.append(departmentSummary).append('\"');
|
||||
sb.append(",\"departmentLogo\":")
|
||||
.append(departmentLogo);
|
||||
sb.append(",\"departmentLogoHover\":")
|
||||
.append(departmentLogoHover);
|
||||
sb.append(",\"departmentType\":")
|
||||
.append(departmentType);
|
||||
sb.append(",\"departmentState\":")
|
||||
.append(departmentState);
|
||||
sb.append(",\"departmentFax\":\"")
|
||||
.append(departmentFax).append('\"');
|
||||
sb.append(",\"departmentTel\":\"")
|
||||
.append(departmentTel).append('\"');
|
||||
sb.append(",\"departmentAddress\":\"")
|
||||
.append(departmentAddress).append('\"');
|
||||
sb.append(",\"departmentMaster\":\"")
|
||||
.append(departmentMaster).append('\"');
|
||||
sb.append(",\"departmentMasterName\":\"")
|
||||
.append(departmentMasterName).append('\"');
|
||||
sb.append(",\"departmentDuty\":\"")
|
||||
.append(departmentDuty).append('\"');
|
||||
sb.append(",\"departmentArea1Id\":\"")
|
||||
.append(departmentArea1Id).append('\"');
|
||||
sb.append(",\"departmentArea1Code\":\"")
|
||||
.append(departmentArea1Code).append('\"');
|
||||
sb.append(",\"departmentArea1Name\":\"")
|
||||
.append(departmentArea1Name).append('\"');
|
||||
sb.append(",\"departmentArea2Id\":\"")
|
||||
.append(departmentArea2Id).append('\"');
|
||||
sb.append(",\"departmentArea2Code\":\"")
|
||||
.append(departmentArea2Code).append('\"');
|
||||
sb.append(",\"departmentArea2Name\":\"")
|
||||
.append(departmentArea2Name).append('\"');
|
||||
sb.append(",\"departmentArea3Id\":\"")
|
||||
.append(departmentArea3Id).append('\"');
|
||||
sb.append(",\"departmentArea3Code\":\"")
|
||||
.append(departmentArea3Code).append('\"');
|
||||
sb.append(",\"departmentArea3Name\":\"")
|
||||
.append(departmentArea3Name).append('\"');
|
||||
sb.append(",\"departmentArea4Id\":\"")
|
||||
.append(departmentArea4Id).append('\"');
|
||||
sb.append(",\"departmentArea4Code\":\"")
|
||||
.append(departmentArea4Code).append('\"');
|
||||
sb.append(",\"departmentArea4Name\":\"")
|
||||
.append(departmentArea4Name).append('\"');
|
||||
sb.append(",\"departmentArea5Id\":\"")
|
||||
.append(departmentArea5Id).append('\"');
|
||||
sb.append(",\"departmentArea5Code\":\"")
|
||||
.append(departmentArea5Code).append('\"');
|
||||
sb.append(",\"departmentArea5Name\":\"")
|
||||
.append(departmentArea5Name).append('\"');
|
||||
sb.append(",\"departmentLongitude\":\"")
|
||||
.append(departmentLongitude).append('\"');
|
||||
sb.append(",\"departmentLatitude\":\"")
|
||||
.append(departmentLatitude).append('\"');
|
||||
sb.append(",\"departmentOrder\":\"")
|
||||
.append(departmentOrder).append('\"');
|
||||
sb.append('}');
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
@ -1,9 +1,9 @@
|
||||
package ink.wgink.pojo.dtos;
|
||||
package ink.wgink.pojo.dtos.user;
|
||||
|
||||
import com.cm.common.pojo.bos.DepartmentBO;
|
||||
import com.cm.common.pojo.bos.GroupBO;
|
||||
import com.cm.common.pojo.bos.PositionBO;
|
||||
import com.cm.common.pojo.bos.RoleBO;
|
||||
import ink.wgink.pojo.bos.DepartmentBO;
|
||||
import ink.wgink.pojo.bos.GroupBO;
|
||||
import ink.wgink.pojo.bos.PositionBO;
|
||||
import ink.wgink.pojo.bos.RoleBO;
|
||||
|
||||
import java.util.List;
|
||||
|
274
basic-pojo/src/main/java/ink/wgink/pojo/dtos/user/UserDTO.java
Normal file
274
basic-pojo/src/main/java/ink/wgink/pojo/dtos/user/UserDTO.java
Normal file
@ -0,0 +1,274 @@
|
||||
package ink.wgink.pojo.dtos.user;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author WangGeng
|
||||
*/
|
||||
@ApiModel
|
||||
public class UserDTO implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = -4381097524161926625L;
|
||||
@ApiModelProperty(name = "userId", value = "用户ID")
|
||||
private String userId;
|
||||
@ApiModelProperty(name = "userUsername", value = "用户名")
|
||||
private String userUsername;
|
||||
@ApiModelProperty(name = "userName", value = "用户昵称")
|
||||
private String userName;
|
||||
@ApiModelProperty(name = "userPhone", value = "用户电话")
|
||||
private String userPhone;
|
||||
@ApiModelProperty(name = "userEmail", value = "用户邮件")
|
||||
private String userEmail;
|
||||
@ApiModelProperty(name = "userUKey", value = "UKey")
|
||||
private String userUKey;
|
||||
@ApiModelProperty(name = "userType", value = "用户类型,1:系统用户,2:普通用户")
|
||||
private Integer userType;
|
||||
@ApiModelProperty(name = "userState", value = "用户状态,0:正常,1:冻结")
|
||||
private Integer userState;
|
||||
@ApiModelProperty(name = "userAvatar", value = "用户头像ID")
|
||||
private String userAvatar;
|
||||
@ApiModelProperty(name = "lastLoginAddress", value = "最后登录IP")
|
||||
private String lastLoginAddress;
|
||||
@ApiModelProperty(name = "lastLoginTime", value = "最后登录时间")
|
||||
private String lastLoginTime;
|
||||
@ApiModelProperty(name = "userLongitude", value = "用户经度")
|
||||
private String userLongitude;
|
||||
@ApiModelProperty(name = "userLatitude", value = "用户纬度")
|
||||
private String userLatitude;
|
||||
@ApiModelProperty(name = "departmentIds", value = "组织部门ID")
|
||||
private String departmentIds;
|
||||
@ApiModelProperty(name = "departmentNames", value = "组织部门名称")
|
||||
private String departmentNames;
|
||||
@ApiModelProperty(name = "roleIds", value = "角色ID")
|
||||
private String roleIds;
|
||||
@ApiModelProperty(name = "roleNames", value = "角色名称")
|
||||
private String roleNames;
|
||||
@ApiModelProperty(name = "positionIds", value = "职位ID")
|
||||
private String positionIds;
|
||||
@ApiModelProperty(name = "positionNames", value = "职位名称")
|
||||
private String positionNames;
|
||||
@ApiModelProperty(name = "loginType", value = "登录类型")
|
||||
private Integer loginType;
|
||||
@ApiModelProperty(name = "gmtCreate", value = "创建时间")
|
||||
private String gmtCreate;
|
||||
|
||||
public String getUserId() {
|
||||
return userId == null ? "" : userId.trim();
|
||||
}
|
||||
|
||||
public void setUserId(String userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
public String getUserUsername() {
|
||||
return userUsername == null ? "" : userUsername.trim();
|
||||
}
|
||||
|
||||
public void setUserUsername(String userUsername) {
|
||||
this.userUsername = userUsername;
|
||||
}
|
||||
|
||||
public String getUserName() {
|
||||
return userName == null ? "" : userName.trim();
|
||||
}
|
||||
|
||||
public void setUserName(String userName) {
|
||||
this.userName = userName;
|
||||
}
|
||||
|
||||
public String getUserPhone() {
|
||||
return userPhone == null ? "" : userPhone.trim();
|
||||
}
|
||||
|
||||
public void setUserPhone(String userPhone) {
|
||||
this.userPhone = userPhone;
|
||||
}
|
||||
|
||||
public String getUserEmail() {
|
||||
return userEmail == null ? "" : userEmail.trim();
|
||||
}
|
||||
|
||||
public void setUserEmail(String userEmail) {
|
||||
this.userEmail = userEmail;
|
||||
}
|
||||
|
||||
public String getUserUKey() {
|
||||
return userUKey == null ? "" : userUKey;
|
||||
}
|
||||
|
||||
public void setUserUKey(String userUKey) {
|
||||
this.userUKey = userUKey;
|
||||
}
|
||||
|
||||
public Integer getUserType() {
|
||||
return userType;
|
||||
}
|
||||
|
||||
public void setUserType(Integer userType) {
|
||||
this.userType = userType;
|
||||
}
|
||||
|
||||
public Integer getUserState() {
|
||||
return userState;
|
||||
}
|
||||
|
||||
public void setUserState(Integer userState) {
|
||||
this.userState = userState;
|
||||
}
|
||||
|
||||
public String getUserAvatar() {
|
||||
return userAvatar == null ? "" : userAvatar.trim();
|
||||
}
|
||||
|
||||
public void setUserAvatar(String userAvatar) {
|
||||
this.userAvatar = userAvatar;
|
||||
}
|
||||
|
||||
public String getLastLoginAddress() {
|
||||
return lastLoginAddress == null ? "" : lastLoginAddress.trim();
|
||||
}
|
||||
|
||||
public void setLastLoginAddress(String lastLoginAddress) {
|
||||
this.lastLoginAddress = lastLoginAddress;
|
||||
}
|
||||
|
||||
public String getLastLoginTime() {
|
||||
return lastLoginTime == null ? "" : lastLoginTime.trim();
|
||||
}
|
||||
|
||||
public void setLastLoginTime(String lastLoginTime) {
|
||||
this.lastLoginTime = lastLoginTime;
|
||||
}
|
||||
|
||||
public String getUserLongitude() {
|
||||
return userLongitude == null ? "" : userLongitude.trim();
|
||||
}
|
||||
|
||||
public void setUserLongitude(String userLongitude) {
|
||||
this.userLongitude = userLongitude;
|
||||
}
|
||||
|
||||
public String getUserLatitude() {
|
||||
return userLatitude == null ? "" : userLatitude.trim();
|
||||
}
|
||||
|
||||
public void setUserLatitude(String userLatitude) {
|
||||
this.userLatitude = userLatitude;
|
||||
}
|
||||
|
||||
public String getDepartmentIds() {
|
||||
return departmentIds == null ? "" : departmentIds.trim();
|
||||
}
|
||||
|
||||
public void setDepartmentIds(String departmentIds) {
|
||||
this.departmentIds = departmentIds;
|
||||
}
|
||||
|
||||
public String getDepartmentNames() {
|
||||
return departmentNames == null ? "" : departmentNames.trim();
|
||||
}
|
||||
|
||||
public void setDepartmentNames(String departmentNames) {
|
||||
this.departmentNames = departmentNames;
|
||||
}
|
||||
|
||||
public String getRoleIds() {
|
||||
return roleIds == null ? "" : roleIds.trim();
|
||||
}
|
||||
|
||||
public void setRoleIds(String roleIds) {
|
||||
this.roleIds = roleIds;
|
||||
}
|
||||
|
||||
public String getRoleNames() {
|
||||
return roleNames == null ? "" : roleNames.trim();
|
||||
}
|
||||
|
||||
public void setRoleNames(String roleNames) {
|
||||
this.roleNames = roleNames;
|
||||
}
|
||||
|
||||
public String getPositionIds() {
|
||||
return positionIds == null ? "" : positionIds.trim();
|
||||
}
|
||||
|
||||
public void setPositionIds(String positionIds) {
|
||||
this.positionIds = positionIds;
|
||||
}
|
||||
|
||||
public String getPositionNames() {
|
||||
return positionNames == null ? "" : positionNames.trim();
|
||||
}
|
||||
|
||||
public void setPositionNames(String positionNames) {
|
||||
this.positionNames = positionNames;
|
||||
}
|
||||
|
||||
public Integer getLoginType() {
|
||||
return loginType;
|
||||
}
|
||||
|
||||
public void setLoginType(Integer loginType) {
|
||||
this.loginType = loginType;
|
||||
}
|
||||
|
||||
public String getGmtCreate() {
|
||||
return gmtCreate == null ? "" : gmtCreate.trim();
|
||||
}
|
||||
|
||||
public void setGmtCreate(String gmtCreate) {
|
||||
this.gmtCreate = gmtCreate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
final StringBuilder sb = new StringBuilder("{");
|
||||
sb.append("\"userId\":")
|
||||
.append("\"").append(userId).append("\"");
|
||||
sb.append(",\"userUsername\":")
|
||||
.append("\"").append(userUsername).append("\"");
|
||||
sb.append(",\"userName\":")
|
||||
.append("\"").append(userName).append("\"");
|
||||
sb.append(",\"userPhone\":")
|
||||
.append("\"").append(userPhone).append("\"");
|
||||
sb.append(",\"userEmail\":")
|
||||
.append("\"").append(userEmail).append("\"");
|
||||
sb.append(",\"userUKey\":")
|
||||
.append("\"").append(userUKey).append("\"");
|
||||
sb.append(",\"userType\":")
|
||||
.append(userType);
|
||||
sb.append(",\"userState\":")
|
||||
.append(userState);
|
||||
sb.append(",\"userAvatar\":")
|
||||
.append("\"").append(userAvatar).append("\"");
|
||||
sb.append(",\"lastLoginAddress\":")
|
||||
.append("\"").append(lastLoginAddress).append("\"");
|
||||
sb.append(",\"lastLoginTime\":")
|
||||
.append("\"").append(lastLoginTime).append("\"");
|
||||
sb.append(",\"userLongitude\":")
|
||||
.append("\"").append(userLongitude).append("\"");
|
||||
sb.append(",\"userLatitude\":")
|
||||
.append("\"").append(userLatitude).append("\"");
|
||||
sb.append(",\"departmentIds\":")
|
||||
.append("\"").append(departmentIds).append("\"");
|
||||
sb.append(",\"departmentNames\":")
|
||||
.append("\"").append(departmentNames).append("\"");
|
||||
sb.append(",\"roleIds\":")
|
||||
.append("\"").append(roleIds).append("\"");
|
||||
sb.append(",\"roleNames\":")
|
||||
.append("\"").append(roleNames).append("\"");
|
||||
sb.append(",\"positionIds\":")
|
||||
.append("\"").append(positionIds).append("\"");
|
||||
sb.append(",\"positionNames\":")
|
||||
.append("\"").append(positionNames).append("\"");
|
||||
sb.append(",\"loginType\":")
|
||||
.append(loginType);
|
||||
sb.append(",\"gmtCreate\":")
|
||||
.append("\"").append(gmtCreate).append("\"");
|
||||
sb.append('}');
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
@ -106,7 +106,6 @@
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>fastjson</artifactId>
|
||||
<version>${fastjson.version}</version>
|
||||
</dependency>
|
||||
<!-- fastjson end -->
|
||||
|
||||
|
171
basic-util/src/main/java/ink/wgink/util/AddressUtil.java
Normal file
171
basic-util/src/main/java/ink/wgink/util/AddressUtil.java
Normal file
@ -0,0 +1,171 @@
|
||||
package ink.wgink.util;
|
||||
|
||||
import java.net.InetAddress;
|
||||
import java.net.NetworkInterface;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Enumeration;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* IP和MAC地址工具类
|
||||
*/
|
||||
public class AddressUtil {
|
||||
|
||||
/**
|
||||
* 获取MAC地址,可能会为空
|
||||
*
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
@Deprecated
|
||||
public static final String getMacAddress() throws Exception {
|
||||
InetAddress inetAddress = InetAddress.getLocalHost();
|
||||
byte[] mac = NetworkInterface.getByInetAddress(inetAddress).getHardwareAddress();
|
||||
StringBuilder macAddress = new StringBuilder();
|
||||
for (byte macByte : mac) {
|
||||
if (macAddress.length() > 0) {
|
||||
macAddress.append("-");
|
||||
}
|
||||
int macInt = macByte & 0xff;
|
||||
String str = Integer.toHexString(macInt);
|
||||
macAddress.append(str.length() == 1 ? 0 + str : str);
|
||||
}
|
||||
return macAddress.toString().toUpperCase();
|
||||
}
|
||||
|
||||
/**
|
||||
* 此方法描述的是:获得服务器的IP地址
|
||||
*/
|
||||
public static String getLocalIP() throws Exception {
|
||||
String sIP = "";
|
||||
InetAddress ip = null;
|
||||
boolean bFindIP = false;
|
||||
Enumeration<NetworkInterface> netInterfaces = (Enumeration<NetworkInterface>) NetworkInterface
|
||||
.getNetworkInterfaces();
|
||||
while (netInterfaces.hasMoreElements()) {
|
||||
if (bFindIP) {
|
||||
break;
|
||||
}
|
||||
NetworkInterface ni = (NetworkInterface) netInterfaces
|
||||
.nextElement();
|
||||
|
||||
Enumeration<InetAddress> ips = ni.getInetAddresses();
|
||||
while (ips.hasMoreElements()) {
|
||||
ip = (InetAddress) ips.nextElement();
|
||||
if (!ip.isLoopbackAddress()
|
||||
&& ip.getHostAddress().matches(
|
||||
"(\\d{1,3}\\.){3}\\d{1,3}")) {
|
||||
bFindIP = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (null != ip) {
|
||||
sIP = ip.getHostAddress();
|
||||
}
|
||||
return sIP;
|
||||
}
|
||||
|
||||
/**
|
||||
* 此方法描述的是:获得服务器的IP地址(多网卡)
|
||||
*/
|
||||
public static List<String> getLocalIPS() throws Exception {
|
||||
InetAddress ip = null;
|
||||
List<String> ipList = new ArrayList<String>();
|
||||
Enumeration<NetworkInterface> netInterfaces = (Enumeration<NetworkInterface>) NetworkInterface
|
||||
.getNetworkInterfaces();
|
||||
while (netInterfaces.hasMoreElements()) {
|
||||
NetworkInterface ni = (NetworkInterface) netInterfaces
|
||||
.nextElement();
|
||||
Enumeration<InetAddress> ips = ni.getInetAddresses();
|
||||
while (ips.hasMoreElements()) {
|
||||
ip = (InetAddress) ips.nextElement();
|
||||
if (!ip.isLoopbackAddress()
|
||||
&& ip.getHostAddress().matches(
|
||||
"(\\d{1,3}\\.){3}\\d{1,3}")) {
|
||||
ipList.add(ip.getHostAddress());
|
||||
}
|
||||
}
|
||||
}
|
||||
return ipList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得服务器的MAC地址
|
||||
*/
|
||||
public static String getMacId() throws Exception {
|
||||
String macId = "";
|
||||
InetAddress ip = null;
|
||||
NetworkInterface ni = null;
|
||||
boolean bFindIP = false;
|
||||
Enumeration<NetworkInterface> netInterfaces = (Enumeration<NetworkInterface>) NetworkInterface
|
||||
.getNetworkInterfaces();
|
||||
while (netInterfaces.hasMoreElements()) {
|
||||
if (bFindIP) {
|
||||
break;
|
||||
}
|
||||
ni = (NetworkInterface) netInterfaces
|
||||
.nextElement();
|
||||
Enumeration<InetAddress> ips = ni.getInetAddresses();
|
||||
while (ips.hasMoreElements()) {
|
||||
ip = (InetAddress) ips.nextElement();
|
||||
// 非127.0.0.1
|
||||
if (!ip.isLoopbackAddress()
|
||||
&& ip.getHostAddress().matches(
|
||||
"(\\d{1,3}\\.){3}\\d{1,3}")) {
|
||||
bFindIP = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (null != ip) {
|
||||
macId = getMacFromBytes(ni.getHardwareAddress());
|
||||
}
|
||||
return macId;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得服务器的MAC地址(多网卡)
|
||||
*/
|
||||
public static List<String> getMacIds() throws Exception {
|
||||
InetAddress ip = null;
|
||||
NetworkInterface ni = null;
|
||||
List<String> macList = new ArrayList<String>();
|
||||
Enumeration<NetworkInterface> netInterfaces = (Enumeration<NetworkInterface>) NetworkInterface
|
||||
.getNetworkInterfaces();
|
||||
while (netInterfaces.hasMoreElements()) {
|
||||
ni = (NetworkInterface) netInterfaces
|
||||
.nextElement();
|
||||
// ----------特定情况,可以考虑用ni.getName判断
|
||||
// 遍历所有ip
|
||||
Enumeration<InetAddress> ips = ni.getInetAddresses();
|
||||
while (ips.hasMoreElements()) {
|
||||
ip = (InetAddress) ips.nextElement();
|
||||
if (!ip.isLoopbackAddress() // 非127.0.0.1
|
||||
&& ip.getHostAddress().matches(
|
||||
"(\\d{1,3}\\.){3}\\d{1,3}")) {
|
||||
macList.add(getMacFromBytes(ni.getHardwareAddress()));
|
||||
}
|
||||
}
|
||||
}
|
||||
return macList;
|
||||
}
|
||||
|
||||
private static String getMacFromBytes(byte[] bytes) {
|
||||
StringBuffer mac = new StringBuffer();
|
||||
byte currentByte;
|
||||
boolean first = false;
|
||||
for (byte b : bytes) {
|
||||
if (first) {
|
||||
mac.append("-");
|
||||
}
|
||||
currentByte = (byte) ((b & 240) >> 4);
|
||||
mac.append(Integer.toHexString(currentByte));
|
||||
currentByte = (byte) (b & 15);
|
||||
mac.append(Integer.toHexString(currentByte));
|
||||
first = true;
|
||||
}
|
||||
return mac.toString().toUpperCase();
|
||||
}
|
||||
|
||||
}
|
157
basic-util/src/main/java/ink/wgink/util/AesUtil.java
Normal file
157
basic-util/src/main/java/ink/wgink/util/AesUtil.java
Normal file
@ -0,0 +1,157 @@
|
||||
package ink.wgink.util;
|
||||
|
||||
import org.apache.commons.codec.binary.Base64;
|
||||
import org.apache.commons.codec.binary.StringUtils;
|
||||
|
||||
import javax.crypto.Cipher;
|
||||
import javax.crypto.KeyGenerator;
|
||||
import javax.crypto.SecretKey;
|
||||
import javax.crypto.spec.IvParameterSpec;
|
||||
import javax.crypto.spec.SecretKeySpec;
|
||||
import java.security.SecureRandom;
|
||||
import java.security.Security;
|
||||
|
||||
public class AesUtil {
|
||||
|
||||
private static final String IV_STRING = "16-Bytes--String";
|
||||
/**
|
||||
* PKCS#7
|
||||
*/
|
||||
public static final String PKCS_7 = "PKCS7Padding";
|
||||
/**
|
||||
* PKCS#5
|
||||
*/
|
||||
public static final String PKCS_5 = "PKCS5Padding";
|
||||
|
||||
/**
|
||||
* AES加密
|
||||
*
|
||||
* @param encodeRule
|
||||
* @param content
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public static String aesEncoder(String encodeRule, String content) throws Exception {
|
||||
// 1.构造秘钥生成器
|
||||
KeyGenerator keyGenerator = KeyGenerator.getInstance("AES");
|
||||
// 2.根据编码规则构建秘钥生成器
|
||||
SecureRandom random = SecureRandom.getInstance("SHA1PRNG");
|
||||
random.setSeed(encodeRule.getBytes());
|
||||
keyGenerator.init(128, random);
|
||||
// 3.产生堆成秘钥
|
||||
SecretKey secretKey = keyGenerator.generateKey();
|
||||
// 4.对称秘钥原始数组
|
||||
byte[] secretKeyByte = secretKey.getEncoded();
|
||||
// 5.生成AES秘钥
|
||||
SecretKey key = new SecretKeySpec(secretKeyByte, "AES");
|
||||
// 6.初始化密码器
|
||||
Cipher cipher = Cipher.getInstance("AES");
|
||||
cipher.init(Cipher.ENCRYPT_MODE, key);
|
||||
// 8.获取加密内容字节数组
|
||||
byte[] contentByte = content.getBytes("UTF-8");
|
||||
// 9.加密
|
||||
return new String(Base64.encodeBase64(cipher.doFinal(contentByte)));
|
||||
}
|
||||
|
||||
/**
|
||||
* AES解密
|
||||
*
|
||||
* @param encodeRule
|
||||
* @param content
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public static String aesDecoder(String encodeRule, String content) throws Exception {
|
||||
// 1.构建秘钥生成器
|
||||
KeyGenerator keyGenerator = KeyGenerator.getInstance("AES");
|
||||
// 2.根据编码规则构建秘钥生成器
|
||||
SecureRandom random = SecureRandom.getInstance("SHA1PRNG");
|
||||
random.setSeed(encodeRule.getBytes());
|
||||
keyGenerator.init(128, random);
|
||||
// 3.生成对称解密秘钥
|
||||
SecretKey secretKey = keyGenerator.generateKey();
|
||||
// 4.对称秘钥原始数组
|
||||
byte[] secretKeyByte = secretKey.getEncoded();
|
||||
// 5.生成AES秘钥
|
||||
SecretKey key = new SecretKeySpec(secretKeyByte, "AES");
|
||||
// 6.初始化密码器
|
||||
Cipher cipher = Cipher.getInstance("AES");
|
||||
cipher.init(Cipher.DECRYPT_MODE, key);
|
||||
// 7.要解密内容的字节数组
|
||||
byte[] contentByte = Base64.decodeBase64(content);
|
||||
// 8.解密
|
||||
return new String(cipher.doFinal(contentByte), "UTF-8");
|
||||
}
|
||||
|
||||
/**
|
||||
* 通用aes加密,兼容IOS
|
||||
*
|
||||
* @param key
|
||||
* @param content
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public static String aesCommonEncoder(String key, String content) throws Exception {
|
||||
byte[] encryptedBytes = aesCommonEncodeDetail(key, content, IV_STRING.getBytes(), PKCS_5);
|
||||
return new String(Base64.encodeBase64(encryptedBytes), "UTF-8");
|
||||
}
|
||||
|
||||
/**
|
||||
* 通用aes加密,兼容IOS
|
||||
*
|
||||
* @param key
|
||||
* @param content
|
||||
* @param paddingType
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public static byte[] aesCommonEncodeDetail(String key, String content, byte[] ivBytes, String paddingType) throws Exception {
|
||||
byte[] byteContent = content.getBytes("UTF-8");
|
||||
byte[] enCodeFormat = key.getBytes();
|
||||
SecretKeySpec secretKeySpec = new SecretKeySpec(enCodeFormat, "AES");
|
||||
IvParameterSpec ivParameterSpec = new IvParameterSpec(ivBytes);
|
||||
if (StringUtils.equals(paddingType, PKCS_7)) {
|
||||
Security.addProvider(new org.bouncycastle.jce.provider.BouncyCastleProvider());
|
||||
}
|
||||
Cipher cipher = Cipher.getInstance("AES/CBC/" + paddingType);
|
||||
cipher.init(Cipher.ENCRYPT_MODE, secretKeySpec, ivParameterSpec);
|
||||
return cipher.doFinal(byteContent);
|
||||
}
|
||||
|
||||
/**
|
||||
* aes通用解密,兼容IOS
|
||||
*
|
||||
* @param key
|
||||
* @param content
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public static String aesCommonDecoder(String key, String content) throws Exception {
|
||||
byte[] encryptedBytes = Base64.decodeBase64(content);
|
||||
byte[] keyBytes = key.getBytes();
|
||||
byte[] result = aesCommonDecoderDetail(keyBytes, encryptedBytes, IV_STRING.getBytes(), PKCS_5);
|
||||
return new String(result, "UTF-8");
|
||||
}
|
||||
|
||||
/**
|
||||
* aes cbc 通用解密
|
||||
*
|
||||
* @param keyBytes 秘钥字节数组
|
||||
* @param encryptedBytes 密文字节数组
|
||||
* @param ivBytes 向量字节数组
|
||||
* @param paddingType 填充类型
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public static byte[] aesCommonDecoderDetail(byte[] keyBytes, byte[] encryptedBytes, byte[] ivBytes, String paddingType) throws Exception {
|
||||
SecretKeySpec secretKey = new SecretKeySpec(keyBytes, "AES");
|
||||
IvParameterSpec ivParameterSpec = new IvParameterSpec(ivBytes);
|
||||
Cipher cipher;
|
||||
if (StringUtils.equals(paddingType, PKCS_7)) {
|
||||
Security.addProvider(new org.bouncycastle.jce.provider.BouncyCastleProvider());
|
||||
}
|
||||
cipher = Cipher.getInstance("AES/CBC/" + paddingType);
|
||||
cipher.init(Cipher.DECRYPT_MODE, secretKey, ivParameterSpec);
|
||||
return cipher.doFinal(encryptedBytes);
|
||||
}
|
||||
}
|
26
basic-util/src/main/java/ink/wgink/util/FolderUtil.java
Normal file
26
basic-util/src/main/java/ink/wgink/util/FolderUtil.java
Normal file
@ -0,0 +1,26 @@
|
||||
package ink.wgink.util;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
/**
|
||||
* @ClassName: FolderUtil
|
||||
* @Description: 文件夹工具
|
||||
* @Author: WangGeng
|
||||
* @Date: 2019-05-28 13:46
|
||||
* @Version: 1.0
|
||||
**/
|
||||
public class FolderUtil {
|
||||
|
||||
/**
|
||||
* 创建文件夹
|
||||
*
|
||||
* @param folderPath
|
||||
*/
|
||||
public static void createFolder(String folderPath) {
|
||||
File folder = new File(folderPath);
|
||||
if (folder.exists()) {
|
||||
return;
|
||||
}
|
||||
folder.mkdirs();
|
||||
}
|
||||
}
|
59
basic-util/src/main/java/ink/wgink/util/HtmlHelper.java
Normal file
59
basic-util/src/main/java/ink/wgink/util/HtmlHelper.java
Normal file
@ -0,0 +1,59 @@
|
||||
package ink.wgink.util;
|
||||
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class HtmlHelper {
|
||||
|
||||
/**
|
||||
* 去除script
|
||||
*/
|
||||
private static final Pattern P_SCRIPT = Pattern.compile("<script[^>]*?>[\\s\\S]*?<\\/script>",
|
||||
Pattern.CASE_INSENSITIVE);
|
||||
/**
|
||||
* 去除style的正则表达式
|
||||
*/
|
||||
private static final Pattern P_STYLE = Pattern.compile("<style[^>]*?>[\\s\\S]*?<\\/style>",
|
||||
Pattern.CASE_INSENSITIVE);
|
||||
/**
|
||||
* 定义HTML标签的正则表达式
|
||||
*/
|
||||
private static final Pattern P_HTML = Pattern.compile("<[^>]+>", Pattern.CASE_INSENSITIVE);
|
||||
/**
|
||||
* 定义空格回车换行符
|
||||
*/
|
||||
private static final Pattern P_SPACE = Pattern.compile("\\s*|\t|\r|\n",
|
||||
Pattern.CASE_INSENSITIVE);
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* title HtmlHelper
|
||||
* </p>
|
||||
* <p>
|
||||
* description 获取纯文本
|
||||
* </p>
|
||||
*
|
||||
* @param html
|
||||
* @return
|
||||
* @author WenG
|
||||
* @date 2018年6月14日 下午2:31:32
|
||||
* @modifier WenG
|
||||
* @date 2018年6月14日 下午2:31:32
|
||||
*/
|
||||
public static String getText(String html) {
|
||||
// 过滤script标签
|
||||
Matcher mScript = P_SCRIPT.matcher(html);
|
||||
html = mScript.replaceAll("");
|
||||
// 过滤style标签
|
||||
Matcher mStyle = P_STYLE.matcher(html);
|
||||
html = mStyle.replaceAll("");
|
||||
// 过滤html标签
|
||||
Matcher mHtml = P_HTML.matcher(html);
|
||||
html = mHtml.replaceAll("");
|
||||
// 过滤空格回车标签
|
||||
Matcher mSpace = P_SPACE.matcher(html);
|
||||
html = mSpace.replaceAll("");
|
||||
return html;
|
||||
}
|
||||
|
||||
}
|
36
basic-util/src/main/java/ink/wgink/util/MD5Util.java
Normal file
36
basic-util/src/main/java/ink/wgink/util/MD5Util.java
Normal file
@ -0,0 +1,36 @@
|
||||
package ink.wgink.util;
|
||||
|
||||
import java.nio.charset.Charset;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
|
||||
/**
|
||||
* When you feel like quitting. Think about why you started
|
||||
* 当你想要放弃的时候,想想当初你为何开始
|
||||
*
|
||||
* @ClassName: MD5Util
|
||||
* @Description: MD5处理
|
||||
* @Author: WangGeng
|
||||
* @Date: 2020/6/30 12:20 上午
|
||||
* @Version: 1.0
|
||||
**/
|
||||
public class MD5Util {
|
||||
|
||||
public static String toMD5String(String str) throws NoSuchAlgorithmException {
|
||||
MessageDigest md = MessageDigest.getInstance("MD5");
|
||||
if (md != null && str != null) {
|
||||
byte[] byteData = md.digest(str.getBytes(Charset.forName("UTF-8")));
|
||||
StringBuilder sb = new StringBuilder();
|
||||
byte[] var4 = byteData;
|
||||
int var5 = byteData.length;
|
||||
|
||||
for (int var6 = 0; var6 < var5; ++var6) {
|
||||
byte aByteData = var4[var6];
|
||||
sb.append(Integer.toString((aByteData & 255) + 256, 16).substring(1));
|
||||
}
|
||||
return sb.toString();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
86
basic-util/src/main/java/ink/wgink/util/QRCodeUtil.java
Normal file
86
basic-util/src/main/java/ink/wgink/util/QRCodeUtil.java
Normal file
@ -0,0 +1,86 @@
|
||||
package ink.wgink.util;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Image;
|
||||
import java.awt.RenderingHints;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
|
||||
import com.google.zxing.BarcodeFormat;
|
||||
import com.google.zxing.EncodeHintType;
|
||||
import com.google.zxing.MultiFormatWriter;
|
||||
import com.google.zxing.common.BitMatrix;
|
||||
import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel;
|
||||
|
||||
public class QRCodeUtil {
|
||||
|
||||
public static BufferedImage createQrCode(int width, int height, String content, String logoPath) {
|
||||
Map<EncodeHintType, Object> qrParams = new HashMap<>(3);
|
||||
// 编码
|
||||
qrParams.put(EncodeHintType.CHARACTER_SET, "UTF-8");
|
||||
// 纠错等级
|
||||
qrParams.put(EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.L);
|
||||
// 边框
|
||||
qrParams.put(EncodeHintType.MARGIN, 1);
|
||||
// 生成二维码
|
||||
BufferedImage bufferedImage = null;
|
||||
try {
|
||||
BitMatrix bitMatrix = new MultiFormatWriter().encode(content, BarcodeFormat.QR_CODE,
|
||||
width, height);
|
||||
bufferedImage = getBufferImage(bitMatrix);
|
||||
if (null != logoPath && !logoPath.isEmpty()) {
|
||||
addLogo(bufferedImage, logoPath);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return bufferedImage;
|
||||
}
|
||||
|
||||
private static BufferedImage getBufferImage(BitMatrix bitMatrix) {
|
||||
int bmWidth = bitMatrix.getWidth();
|
||||
int bmHeight = bitMatrix.getHeight();
|
||||
BufferedImage bufferedImage = new BufferedImage(bmWidth, bmHeight,
|
||||
BufferedImage.TYPE_INT_ARGB);
|
||||
for (int x = 0; x < bmWidth; x++) {
|
||||
for (int y = 0; y < bmHeight; y++) {
|
||||
bufferedImage.setRGB(x, y, bitMatrix.get(x, y) ? 0xFF000000 : 0xFFFFFFFF);
|
||||
}
|
||||
}
|
||||
return bufferedImage;
|
||||
}
|
||||
|
||||
private static void addLogo(BufferedImage bufferedImage, String logoPath) throws IOException {
|
||||
Graphics2D graphics2d = bufferedImage.createGraphics();
|
||||
Image logo = ImageIO.read(new File(logoPath));
|
||||
// 设置比例
|
||||
int logoWidth = bufferedImage.getWidth() / 6;
|
||||
int logoHeight = bufferedImage.getHeight() / 6;
|
||||
|
||||
// 填充logo
|
||||
int x = bufferedImage.getWidth() / 2 - logoWidth / 2;
|
||||
int y = bufferedImage.getHeight() / 2 - logoHeight / 2;
|
||||
// 设置抗锯齿
|
||||
graphics2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
|
||||
RenderingHints.VALUE_ANTIALIAS_ON);
|
||||
// 填充填充背景
|
||||
graphics2d.setColor(Color.WHITE);
|
||||
graphics2d.fillRoundRect(x, y, logoWidth, logoHeight, 10, 10);
|
||||
|
||||
// 画边框
|
||||
graphics2d.setColor(new Color(220, 220, 220));
|
||||
graphics2d.drawRoundRect(x, y, logoWidth, logoHeight, 10, 10);
|
||||
|
||||
// 画LOGO
|
||||
graphics2d.drawImage(logo, x + 2, y + 2, logoWidth - 4, logoHeight - 4, null);
|
||||
graphics2d.dispose();
|
||||
logo.flush();
|
||||
}
|
||||
|
||||
}
|
223
basic-util/src/main/java/ink/wgink/util/RegexUtil.java
Normal file
223
basic-util/src/main/java/ink/wgink/util/RegexUtil.java
Normal file
@ -0,0 +1,223 @@
|
||||
package ink.wgink.util;
|
||||
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* When you feel like quitting. Think about why you started
|
||||
* 当你想要放弃的时候,想想当初你为何开始
|
||||
*
|
||||
* @ClassName: RegexUtil
|
||||
* @Description: 正则校验工具类
|
||||
* @Author: WangGeng
|
||||
* @Date: 2019/12/4 18:13
|
||||
* @Version: 1.0
|
||||
**/
|
||||
public class RegexUtil {
|
||||
|
||||
/**
|
||||
* 特殊字符
|
||||
*/
|
||||
public static final String SPECIAL_CHARACTERS = "#?!@$%^&*-_";
|
||||
/**
|
||||
* 密码最小长度
|
||||
*/
|
||||
public static final int PASSWORD_LENGTH_MIN = 6;
|
||||
/**
|
||||
* 密码最大长度
|
||||
*/
|
||||
public static final int PASSWORD_LENGTH_MAX = 16;
|
||||
/**
|
||||
* 手机
|
||||
*/
|
||||
private static final Pattern PATTERN_PHONE = Pattern.compile("^1\\d{10}$");
|
||||
/**
|
||||
* 邮箱
|
||||
*/
|
||||
private static final Pattern PATTERN_EMAIL = Pattern.compile("^([a-zA-Z0-9_\\.\\-])+\\@(([a-zA-Z0-9\\-])+\\.)+([a-zA-Z0-9]{2,4})+$");
|
||||
/**
|
||||
* 邮箱
|
||||
*/
|
||||
private static final Pattern PATTERN_URL = Pattern.compile("(^#)|(^http(s*):\\/\\/[^\\s]+)");
|
||||
/**
|
||||
* 日期格式
|
||||
*/
|
||||
private static final Pattern PATTERN_DATE = Pattern.compile("^(\\d{4})[-\\/](\\d{1}|0\\d{1}|1[0-2])([-\\/](\\d{1}|0\\d{1}|[1-2][0-9]|3[0-1]))*$");
|
||||
/**
|
||||
* 时间戳格式
|
||||
*/
|
||||
private static final Pattern PATTERN_DATETIME = Pattern.compile("^(\\d{4})[-\\/](\\d{1}|0\\d{1}|1[0-2])([-\\/](\\d{1}|0\\d{1}|[1-2][0-9]|3[0-1]))*(\\s+)([0-1][0-9]|(2[0-3])):([0-5][0-9])(:([0-5][0-9]))*$");
|
||||
/**
|
||||
* 身份证
|
||||
*/
|
||||
private static final Pattern PATTERN_IDENTITY = Pattern.compile("(^\\d{15}$)|(^\\d{17}(x|X|\\d)$)");
|
||||
/**
|
||||
* 用户名
|
||||
*/
|
||||
private static final Pattern PATTERN_USERNAME = Pattern.compile("^[a-zA-Z0-9_\\s]+$");
|
||||
/**
|
||||
* 字母
|
||||
*/
|
||||
private static final Pattern PATTERN_LETTER = Pattern.compile("[a-zA-Z]+");
|
||||
/**
|
||||
* 中文
|
||||
*/
|
||||
private static final Pattern PATTERN_CHINESE = Pattern.compile("[\\u4e00-\\u9fa5]+");
|
||||
/**
|
||||
* 数字
|
||||
*/
|
||||
private static final Pattern PATTERN_NUMBER = Pattern.compile("\\d+");
|
||||
/**
|
||||
* 弱密码
|
||||
*/
|
||||
private static final Pattern PASSWORD_WEEK = Pattern.compile(String.format("(?=.*[A-Za-z0-9%s]).{%d,%d}", SPECIAL_CHARACTERS, PASSWORD_LENGTH_MIN, PASSWORD_LENGTH_MAX));
|
||||
/**
|
||||
* 中密码
|
||||
*/
|
||||
private static final Pattern PASSWORD_MIDDLE = Pattern.compile(String.format("((?=.*[A-Za-z])(?=.*[0-9]))|((?=.*[A-Za-z])(?=.*[%s]))|((?=.*[0-9])(?=.*[%s])).{%d,%d}", SPECIAL_CHARACTERS, SPECIAL_CHARACTERS, PASSWORD_LENGTH_MIN, PASSWORD_LENGTH_MAX));
|
||||
/**
|
||||
* 强密码
|
||||
*/
|
||||
private static final Pattern PASSWORD_STRONG = Pattern.compile(String.format("(?=.*[A-Za-z])(?=.*[0-9])(?=.*[%s]).{%d,%d}", SPECIAL_CHARACTERS, PASSWORD_LENGTH_MIN, PASSWORD_LENGTH_MAX));
|
||||
|
||||
/**
|
||||
* 判断弱密码强度
|
||||
*
|
||||
* @param input
|
||||
* @return
|
||||
*/
|
||||
public static boolean isPasswordWeek(String input) {
|
||||
return PASSWORD_WEEK.matcher(input).matches();
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断中密码强度
|
||||
*
|
||||
* @param input
|
||||
* @return
|
||||
*/
|
||||
public static boolean isPasswordMiddle(String input) {
|
||||
return PASSWORD_MIDDLE.matcher(input).matches();
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断强密码强度
|
||||
*
|
||||
* @param input
|
||||
* @return
|
||||
*/
|
||||
public static boolean isPasswordStrong(String input) {
|
||||
return PASSWORD_STRONG.matcher(input).matches();
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断电话
|
||||
*
|
||||
* @param input
|
||||
* @return
|
||||
*/
|
||||
public static boolean isPhone(String input) {
|
||||
return PATTERN_PHONE.matcher(input).matches();
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断邮箱
|
||||
*
|
||||
* @param input
|
||||
* @return
|
||||
*/
|
||||
public static boolean isEmail(String input) {
|
||||
return PATTERN_EMAIL.matcher(input).matches();
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断URL
|
||||
*
|
||||
* @param input
|
||||
* @return
|
||||
*/
|
||||
public static boolean isUrl(String input) {
|
||||
return PATTERN_URL.matcher(input).matches();
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断日期
|
||||
*
|
||||
* @param input
|
||||
* @return
|
||||
*/
|
||||
public static boolean isDate(String input) {
|
||||
return PATTERN_DATE.matcher(input).matches();
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断时间戳
|
||||
*
|
||||
* @param input
|
||||
* @return
|
||||
*/
|
||||
public static boolean isDatetime(String input) {
|
||||
return PATTERN_DATETIME.matcher(input).matches();
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断身份证
|
||||
*
|
||||
* @param input
|
||||
* @return
|
||||
*/
|
||||
public static boolean isIdentity(String input) {
|
||||
return PATTERN_IDENTITY.matcher(input).matches();
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断用户名
|
||||
*
|
||||
* @param input
|
||||
* @return
|
||||
*/
|
||||
public static boolean isUsername(String input) {
|
||||
return PATTERN_USERNAME.matcher(input).matches();
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断是字母
|
||||
*
|
||||
* @param input
|
||||
* @return
|
||||
*/
|
||||
public static boolean isLetter(String input) {
|
||||
return PATTERN_LETTER.matcher(input).matches();
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断是中文
|
||||
*
|
||||
* @param input
|
||||
* @return
|
||||
*/
|
||||
public static boolean isChinese(String input) {
|
||||
return PATTERN_CHINESE.matcher(input).matches();
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断是数字
|
||||
*
|
||||
* @param input
|
||||
* @return
|
||||
*/
|
||||
public static boolean isNumber(String input) {
|
||||
return PATTERN_NUMBER.matcher(input).matches();
|
||||
}
|
||||
|
||||
/**
|
||||
* 自定义判断
|
||||
*
|
||||
* @param customPattern
|
||||
* @param input
|
||||
* @return
|
||||
*/
|
||||
public static boolean isMatch(Pattern customPattern, String input) {
|
||||
return customPattern.matcher(input).matches();
|
||||
}
|
||||
|
||||
}
|
58
basic-util/src/main/java/ink/wgink/util/ResourceUtil.java
Normal file
58
basic-util/src/main/java/ink/wgink/util/ResourceUtil.java
Normal file
@ -0,0 +1,58 @@
|
||||
package ink.wgink.util;
|
||||
|
||||
import org.springframework.core.io.DefaultResourceLoader;
|
||||
import org.springframework.core.io.ResourceLoader;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
/**
|
||||
* @ClassName: ResourceUtil
|
||||
* @Description: 资源工具
|
||||
* @Author: WangGeng
|
||||
* @Date: 2019-05-23 11:04
|
||||
* @Version: 1.0
|
||||
**/
|
||||
public class ResourceUtil {
|
||||
|
||||
/**
|
||||
* 资源输入流
|
||||
*
|
||||
* @param resourcePath
|
||||
* @return
|
||||
* @throws IOException
|
||||
*/
|
||||
public static InputStream getResourceInputStream(String resourcePath) throws IOException {
|
||||
ResourceLoader resourceLoader = new DefaultResourceLoader();
|
||||
return resourceLoader.getResource(resourcePath).getInputStream();
|
||||
}
|
||||
|
||||
/**
|
||||
* 资源文件
|
||||
*
|
||||
* @param resourcePath
|
||||
* @return
|
||||
* @throws IOException
|
||||
*/
|
||||
public static File getResourceFile(String resourcePath) throws IOException {
|
||||
ResourceLoader resourceLoader = new DefaultResourceLoader();
|
||||
return resourceLoader.getResource(resourcePath).getFile();
|
||||
}
|
||||
|
||||
/**
|
||||
* 输入流输出文本
|
||||
*
|
||||
* @param inputStream
|
||||
* @return
|
||||
* @throws IOException
|
||||
*/
|
||||
public static String inputStreamToText(InputStream inputStream) throws IOException {
|
||||
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream, "UTF-8"));
|
||||
StringBuffer resultStr = new StringBuffer();
|
||||
for (String line; (line = bufferedReader.readLine()) != null; ) {
|
||||
resultStr.append(line);
|
||||
}
|
||||
bufferedReader.close();
|
||||
return resultStr.toString();
|
||||
}
|
||||
|
||||
}
|
20
basic-util/src/main/java/ink/wgink/util/UUIDUtil.java
Normal file
20
basic-util/src/main/java/ink/wgink/util/UUIDUtil.java
Normal file
@ -0,0 +1,20 @@
|
||||
package ink.wgink.util;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* UuidUtil
|
||||
*
|
||||
* @author WangGeng
|
||||
*/
|
||||
public class UUIDUtil {
|
||||
|
||||
public static String getUUID() {
|
||||
return UUID.randomUUID().toString().trim();
|
||||
}
|
||||
|
||||
public static String get32UUID() {
|
||||
return getUUID().replaceAll("-", "");
|
||||
}
|
||||
|
||||
}
|
@ -7,6 +7,7 @@ import org.apache.commons.lang3.math.NumberUtils;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.beans.BeanInfo;
|
||||
import java.beans.IntrospectionException;
|
||||
import java.beans.Introspector;
|
||||
import java.beans.PropertyDescriptor;
|
||||
import java.lang.reflect.Field;
|
||||
@ -32,7 +33,7 @@ public class HashMapUtil {
|
||||
*/
|
||||
public static Map<String, Object> requestParamsToMap(HttpServletRequest request) {
|
||||
Enumeration<String> requestNames = request.getParameterNames();
|
||||
Map<String, Object> params = new HashMap<>();
|
||||
Map<String, Object> params = new HashMap<>(0);
|
||||
while (requestNames.hasMoreElements()) {
|
||||
String name = requestNames.nextElement();
|
||||
String value = request.getParameter(name);
|
||||
@ -91,7 +92,7 @@ public class HashMapUtil {
|
||||
* @return
|
||||
*/
|
||||
private static Map<String, String> mapObjToMapString(Object object) {
|
||||
Map<String, String> result = new HashMap<>();
|
||||
Map<String, String> result = new HashMap<>(0);
|
||||
Map<?, ?> map = (Map<?, ?>) object;
|
||||
for (Entry<?, ?> entry : map.entrySet()) {
|
||||
String key = entry.getKey().toString();
|
||||
@ -108,7 +109,7 @@ public class HashMapUtil {
|
||||
* @return
|
||||
*/
|
||||
public static Map<String, Object> mapObjToMap(Object object) {
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
Map<String, Object> result = new HashMap<>(0);
|
||||
Map<?, ?> map = (Map<?, ?>) object;
|
||||
for (Entry<?, ?> entry : map.entrySet()) {
|
||||
String key = entry.getKey().toString();
|
||||
@ -125,22 +126,27 @@ public class HashMapUtil {
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public static Map<String, Object> beanToMap(Object object) throws Exception {
|
||||
Map<String, Object> result = null;
|
||||
BeanInfo beanInfo = Introspector.getBeanInfo(object.getClass());
|
||||
PropertyDescriptor[] properties = beanInfo.getPropertyDescriptors();
|
||||
for (PropertyDescriptor property : properties) {
|
||||
if (null == result) {
|
||||
result = new HashMap<>();
|
||||
public static Map<String, Object> beanToMap(Object object) {
|
||||
try {
|
||||
Map<String, Object> result = null;
|
||||
BeanInfo beanInfo = null;
|
||||
beanInfo = Introspector.getBeanInfo(object.getClass());
|
||||
PropertyDescriptor[] properties = beanInfo.getPropertyDescriptors();
|
||||
for (PropertyDescriptor property : properties) {
|
||||
if (null == result) {
|
||||
result = new HashMap<>(0);
|
||||
}
|
||||
Method method = property.getReadMethod();
|
||||
String name = property.getName();
|
||||
if ("class".equals(name)) {
|
||||
continue;
|
||||
}
|
||||
result.put(name, method.invoke(object));
|
||||
}
|
||||
Method method = property.getReadMethod();
|
||||
String name = property.getName();
|
||||
if ("class".equals(name)) {
|
||||
continue;
|
||||
}
|
||||
result.put(name, method.invoke(object));
|
||||
return result;
|
||||
} catch (IntrospectionException | IllegalAccessException | InvocationTargetException e) {
|
||||
throw new TypeConversionException(e.getMessage(), e);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -150,22 +156,26 @@ public class HashMapUtil {
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public static Map<String, String> beanToMapString(Object object) throws Exception {
|
||||
Map<String, String> result = null;
|
||||
BeanInfo beanInfo = Introspector.getBeanInfo(object.getClass());
|
||||
PropertyDescriptor[] properties = beanInfo.getPropertyDescriptors();
|
||||
for (PropertyDescriptor property : properties) {
|
||||
if (null == result) {
|
||||
result = new HashMap<>();
|
||||
public static Map<String, String> beanToMapString(Object object) {
|
||||
try {
|
||||
Map<String, String> result = null;
|
||||
BeanInfo beanInfo = Introspector.getBeanInfo(object.getClass());
|
||||
PropertyDescriptor[] properties = beanInfo.getPropertyDescriptors();
|
||||
for (PropertyDescriptor property : properties) {
|
||||
if (null == result) {
|
||||
result = new HashMap<>(0);
|
||||
}
|
||||
Method method = property.getReadMethod();
|
||||
String name = property.getName();
|
||||
if ("class".equals(name)) {
|
||||
continue;
|
||||
}
|
||||
result.put(name, method.invoke(object).toString());
|
||||
}
|
||||
Method method = property.getReadMethod();
|
||||
String name = property.getName();
|
||||
if ("class".equals(name)) {
|
||||
continue;
|
||||
}
|
||||
result.put(name, method.invoke(object).toString());
|
||||
return result;
|
||||
} catch (IntrospectionException | IllegalAccessException | InvocationTargetException e) {
|
||||
throw new TypeConversionException(e.getMessage(), e);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -288,4 +298,29 @@ public class HashMapUtil {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 类型转换异常
|
||||
*/
|
||||
public static class TypeConversionException extends RuntimeException {
|
||||
|
||||
public TypeConversionException() {
|
||||
}
|
||||
|
||||
public TypeConversionException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
public TypeConversionException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
|
||||
public TypeConversionException(Throwable cause) {
|
||||
super(cause);
|
||||
}
|
||||
|
||||
public TypeConversionException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
|
||||
super(message, cause, enableSuppression, writableStackTrace);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -27,6 +27,11 @@
|
||||
<artifactId>basic-exception</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ink.wgink</groupId>
|
||||
<artifactId>basic-annotation</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
|
||||
<!-- springboot start -->
|
||||
<dependency>
|
||||
@ -36,6 +41,27 @@
|
||||
</dependency>
|
||||
<!-- springboot end -->
|
||||
|
||||
<!-- durid start -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>druid</artifactId>
|
||||
</dependency>
|
||||
<!-- durid end -->
|
||||
|
||||
<!-- pagerhelper start -->
|
||||
<dependency>
|
||||
<groupId>com.github.pagehelper</groupId>
|
||||
<artifactId>pagehelper</artifactId>
|
||||
</dependency>
|
||||
<!-- pagerhelper end -->
|
||||
|
||||
<!-- easyexcel start -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>easyexcel</artifactId>
|
||||
</dependency>
|
||||
<!-- easyexcel end -->
|
||||
|
||||
</dependencies>
|
||||
|
||||
</project>
|
@ -0,0 +1,88 @@
|
||||
package ink.wgink.common.advice;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import ink.wgink.common.enums.ErrorResultCodeEnum;
|
||||
import ink.wgink.exceptions.*;
|
||||
import ink.wgink.exceptions.base.SystemException;
|
||||
import ink.wgink.pojo.result.ErrorResult;
|
||||
import ink.wgink.util.map.HashMapUtil;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.security.authentication.InsufficientAuthenticationException;
|
||||
import org.springframework.web.bind.annotation.ControllerAdvice;
|
||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.sql.SQLSyntaxErrorException;
|
||||
|
||||
|
||||
/**
|
||||
* @ClassName: ResponseAdvice
|
||||
* @Description: Response结果处理
|
||||
* @Author: WangGeng
|
||||
* @Date: 2019/2/26 5:14 PM
|
||||
* @Version: 1.0
|
||||
**/
|
||||
@ControllerAdvice
|
||||
public class ResponseAdvice {
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(ResponseAdvice.class);
|
||||
|
||||
@ResponseBody
|
||||
@ExceptionHandler({SystemException.class, SQLSyntaxErrorException.class, Exception.class, HashMapUtil.TypeConversionException.class})
|
||||
public void responseException(HttpServletRequest request, HttpServletResponse response, Exception e) throws IOException {
|
||||
if (e instanceof InsufficientAuthenticationException) {
|
||||
throw new InsufficientAuthenticationException(e.getMessage());
|
||||
}
|
||||
if (e instanceof FileException) {
|
||||
LOG.error(e.getMessage());
|
||||
} else {
|
||||
LOG.error(e.getMessage(), e);
|
||||
}
|
||||
ErrorResult result = new ErrorResult(ErrorResultCodeEnum.SYSTEM_ERROR.getValue(), "系统错误");
|
||||
if (e instanceof SaveException) {
|
||||
result.setCode(ErrorResultCodeEnum.SAVE_ERROR.getValue());
|
||||
} else if (e instanceof RemoveException) {
|
||||
result.setCode(ErrorResultCodeEnum.REMOVE_ERROR.getValue());
|
||||
} else if (e instanceof UpdateException) {
|
||||
result.setCode(ErrorResultCodeEnum.UPDATE_ERROR.getValue());
|
||||
} else if (e instanceof SearchException) {
|
||||
result.setCode(ErrorResultCodeEnum.QUERY_ERROR.getValue());
|
||||
} else if (e instanceof ParamsException) {
|
||||
result.setCode(ErrorResultCodeEnum.PARAMS_ERROR.getValue());
|
||||
} else if (e instanceof FileException) {
|
||||
result.setCode(ErrorResultCodeEnum.FILE_ERROR.getValue());
|
||||
} else if (e instanceof AppDeviceException) {
|
||||
result.setCode(ErrorResultCodeEnum.DEVICE_ERROR.getValue());
|
||||
} else if (e instanceof AppVersionException) {
|
||||
result.setCode(ErrorResultCodeEnum.DEVICE_VERSION_ERROR.getValue());
|
||||
} else if (e instanceof AccessTokenException) {
|
||||
response.setStatus(HttpStatus.UNAUTHORIZED.value());
|
||||
}
|
||||
// 自定义提示信息
|
||||
if (e instanceof SystemException) {
|
||||
result.setMsg(e.getMessage());
|
||||
} else {
|
||||
StringBuilder errorMessageSB = new StringBuilder();
|
||||
for (StackTraceElement stackTraceElement : e.getStackTrace()) {
|
||||
errorMessageSB.append(stackTraceElement.toString()).append("\n");
|
||||
}
|
||||
result.setDetail(errorMessageSB.toString());
|
||||
result.setDetail(e.getMessage());
|
||||
}
|
||||
String contentType = request.getContentType();
|
||||
if (contentType != null && contentType.contains(MediaType.APPLICATION_JSON_VALUE)) {
|
||||
response.setContentType(MediaType.APPLICATION_JSON_VALUE);
|
||||
response.setStatus(HttpStatus.BAD_REQUEST.value());
|
||||
response.getWriter().write(JSON.toJSONString(result));
|
||||
} else {
|
||||
request.getSession().setAttribute("errorMessage", JSON.toJSONString(result));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -43,7 +43,7 @@ public class TransactionConfig {
|
||||
/**
|
||||
* 默认其它事务
|
||||
*/
|
||||
private static String[] DEFAULT_OTHER_ARRAY = {"send*", "exec*", "set*", "login*"};
|
||||
private static String[] DEFAULT_OTHER_ARRAY = {"send*", "exec*", "set*", "login*", "register*", "sign*", "rest*", "upload*"};
|
||||
/**
|
||||
* 默认查询事务
|
||||
*/
|
||||
|
42
module-file/pom.xml
Normal file
42
module-file/pom.xml
Normal file
@ -0,0 +1,42 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>wg-basic</artifactId>
|
||||
<groupId>ink.wgink</groupId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>module-file</artifactId>
|
||||
<description>文件模块</description>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>ink.wgink</groupId>
|
||||
<artifactId>basic-app</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ink.wgink</groupId>
|
||||
<artifactId>common</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
|
||||
<!-- sauronsoftware start -->
|
||||
<dependency>
|
||||
<groupId>it.sauronsoftware</groupId>
|
||||
<artifactId>jave</artifactId>
|
||||
</dependency>
|
||||
<!-- sauronsoftware end -->
|
||||
|
||||
<!-- thumbnailator start -->
|
||||
<dependency>
|
||||
<groupId>net.coobird</groupId>
|
||||
<artifactId>thumbnailator</artifactId>
|
||||
</dependency>
|
||||
<!-- thumbnailator end -->
|
||||
</dependencies>
|
||||
|
||||
</project>
|
@ -0,0 +1,14 @@
|
||||
package ink.wgink.module.file.config.properties;
|
||||
|
||||
/**
|
||||
* When you feel like quitting. Think about why you started
|
||||
* 当你想要放弃的时候,想想当初你为何开始
|
||||
*
|
||||
* @ClassName: FileBackendMediaMaxDurationProperties
|
||||
* @Description: APP媒体最大时长
|
||||
* @Author: WangGeng
|
||||
* @Date: 2020/5/31 16:50
|
||||
* @Version: 1.0
|
||||
**/
|
||||
public class FileMediaAppMaxDurationProperties extends com.cm.common.config.properties.FileMediaBaseMaxDurationProperties {
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
package ink.wgink.module.file.config.properties;
|
||||
|
||||
/**
|
||||
* When you feel like quitting. Think about why you started
|
||||
* 当你想要放弃的时候,想想当初你为何开始
|
||||
*
|
||||
* @ClassName: FileBackendMediaMaxDurationProperties
|
||||
* @Description: 后台媒体最大时长
|
||||
* @Author: WangGeng
|
||||
* @Date: 2020/5/31 16:50
|
||||
* @Version: 1.0
|
||||
**/
|
||||
public class FileMediaBackendMaxDurationProperties extends com.cm.common.config.properties.FileMediaBaseMaxDurationProperties {
|
||||
}
|
@ -0,0 +1,44 @@
|
||||
package ink.wgink.module.file.config.properties;
|
||||
|
||||
/**
|
||||
* When you feel like quitting. Think about why you started
|
||||
* 当你想要放弃的时候,想想当初你为何开始
|
||||
*
|
||||
* @ClassName: FileMaxDurationProperties
|
||||
* @Description: 媒体最大长度
|
||||
* @Author: WangGeng
|
||||
* @Date: 2020/5/31 16:49
|
||||
* @Version: 1.0
|
||||
**/
|
||||
public class FileMediaBaseMaxDurationProperties {
|
||||
|
||||
private Long video;
|
||||
private Long audio;
|
||||
|
||||
public Long getVideo() {
|
||||
return video == null ? 0 : video;
|
||||
}
|
||||
|
||||
public void setVideo(Long video) {
|
||||
this.video = video;
|
||||
}
|
||||
|
||||
public Long getAudio() {
|
||||
return audio == null ? 0 : audio;
|
||||
}
|
||||
|
||||
public void setAudio(Long audio) {
|
||||
this.audio = audio;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
final StringBuilder sb = new StringBuilder("{");
|
||||
sb.append("\"video\":")
|
||||
.append(video);
|
||||
sb.append(",\"audio\":")
|
||||
.append(audio);
|
||||
sb.append('}');
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
@ -0,0 +1,55 @@
|
||||
package ink.wgink.module.file.config.properties;
|
||||
|
||||
/**
|
||||
* When you feel like quitting. Think about why you started
|
||||
* 当你想要放弃的时候,想想当初你为何开始
|
||||
*
|
||||
* @ClassName: MediaMaxDurationProperties
|
||||
* @Description: 媒体最大长度
|
||||
* @Author: WangGeng
|
||||
* @Date: 2020/5/31 16:54
|
||||
* @Version: 1.0
|
||||
**/
|
||||
public class FileMediaMaxDurationProperties {
|
||||
|
||||
private FileMediaBackendMaxDurationProperties backend;
|
||||
private com.cm.common.config.properties.FileMediaAppMaxDurationProperties app;
|
||||
private FileMediaWechatMaxDurationProperties wechat;
|
||||
|
||||
public FileMediaBackendMaxDurationProperties getBackend() {
|
||||
return backend;
|
||||
}
|
||||
|
||||
public void setBackend(FileMediaBackendMaxDurationProperties backend) {
|
||||
this.backend = backend;
|
||||
}
|
||||
|
||||
public com.cm.common.config.properties.FileMediaAppMaxDurationProperties getApp() {
|
||||
return app;
|
||||
}
|
||||
|
||||
public void setApp(com.cm.common.config.properties.FileMediaAppMaxDurationProperties app) {
|
||||
this.app = app;
|
||||
}
|
||||
|
||||
public FileMediaWechatMaxDurationProperties getWechat() {
|
||||
return wechat;
|
||||
}
|
||||
|
||||
public void setWechat(FileMediaWechatMaxDurationProperties wechat) {
|
||||
this.wechat = wechat;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
final StringBuilder sb = new StringBuilder("{");
|
||||
sb.append("\"backend\":")
|
||||
.append(backend);
|
||||
sb.append(",\"app\":")
|
||||
.append(app);
|
||||
sb.append(",\"wechat\":")
|
||||
.append(wechat);
|
||||
sb.append('}');
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
package ink.wgink.module.file.config.properties;
|
||||
|
||||
/**
|
||||
* When you feel like quitting. Think about why you started
|
||||
* 当你想要放弃的时候,想想当初你为何开始
|
||||
*
|
||||
* @ClassName: FileBackendMediaMaxDurationProperties
|
||||
* @Description: 微信媒体最大时长
|
||||
* @Author: WangGeng
|
||||
* @Date: 2020/5/31 16:50
|
||||
* @Version: 1.0
|
||||
**/
|
||||
public class FileMediaWechatMaxDurationProperties extends com.cm.common.config.properties.FileMediaBaseMaxDurationProperties {
|
||||
}
|
@ -0,0 +1,112 @@
|
||||
package ink.wgink.module.file.config.properties;
|
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* @ClassName: FileConfig
|
||||
* @Description: 文件配置
|
||||
* @Author: wenc
|
||||
* @Date: 2019/1/3 3:12 PM
|
||||
* @Version: 1.0
|
||||
**/
|
||||
@Component
|
||||
@ConfigurationProperties(prefix = "file")
|
||||
public class FileProperties {
|
||||
|
||||
private String uploadPath;
|
||||
private String imageTypes;
|
||||
private String videoTypes;
|
||||
private String audioTypes;
|
||||
private String fileTypes;
|
||||
private Integer maxFileCount;
|
||||
private Double imageOutputQuality;
|
||||
private FileMediaMaxDurationProperties mediaMaxDuration;
|
||||
|
||||
public String getUploadPath() {
|
||||
return uploadPath;
|
||||
}
|
||||
|
||||
public void setUploadPath(String uploadPath) {
|
||||
this.uploadPath = uploadPath;
|
||||
}
|
||||
|
||||
public String getImageTypes() {
|
||||
return imageTypes == null ? null : imageTypes.trim();
|
||||
}
|
||||
|
||||
public void setImageTypes(String imageTypes) {
|
||||
this.imageTypes = imageTypes;
|
||||
}
|
||||
|
||||
public String getVideoTypes() {
|
||||
return videoTypes == null ? null : videoTypes.replaceAll("\\s", "");
|
||||
}
|
||||
|
||||
public void setVideoTypes(String videoTypes) {
|
||||
this.videoTypes = videoTypes;
|
||||
}
|
||||
|
||||
public String getAudioTypes() {
|
||||
return audioTypes == null ? null : audioTypes.replaceAll("\\s", "");
|
||||
}
|
||||
|
||||
public void setAudioTypes(String audioTypes) {
|
||||
this.audioTypes = audioTypes;
|
||||
}
|
||||
|
||||
public String getFileTypes() {
|
||||
return fileTypes == null ? null : fileTypes.replaceAll("\\s", "");
|
||||
}
|
||||
|
||||
public void setFileTypes(String fileTypes) {
|
||||
this.fileTypes = fileTypes;
|
||||
}
|
||||
|
||||
public Integer getMaxFileCount() {
|
||||
return maxFileCount == null ? 1 : maxFileCount;
|
||||
}
|
||||
|
||||
public void setMaxFileCount(Integer maxFileCount) {
|
||||
this.maxFileCount = maxFileCount;
|
||||
}
|
||||
|
||||
public Double getImageOutputQuality() {
|
||||
return imageOutputQuality == null ? 0.4 : imageOutputQuality;
|
||||
}
|
||||
|
||||
public void setImageOutputQuality(Double imageOutputQuality) {
|
||||
this.imageOutputQuality = imageOutputQuality;
|
||||
}
|
||||
|
||||
public FileMediaMaxDurationProperties getMediaMaxDuration() {
|
||||
return mediaMaxDuration;
|
||||
}
|
||||
|
||||
public void setMediaMaxDuration(FileMediaMaxDurationProperties mediaMaxDuration) {
|
||||
this.mediaMaxDuration = mediaMaxDuration;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
final StringBuilder sb = new StringBuilder("{");
|
||||
sb.append("\"uploadPath\":\"")
|
||||
.append(uploadPath).append('\"');
|
||||
sb.append(",\"imageTypes\":\"")
|
||||
.append(imageTypes).append('\"');
|
||||
sb.append(",\"videoTypes\":\"")
|
||||
.append(videoTypes).append('\"');
|
||||
sb.append(",\"audioTypes\":\"")
|
||||
.append(audioTypes).append('\"');
|
||||
sb.append(",\"fileTypes\":\"")
|
||||
.append(fileTypes).append('\"');
|
||||
sb.append(",\"maxFileCount\":")
|
||||
.append(maxFileCount);
|
||||
sb.append(",\"imageOutputQuality\":")
|
||||
.append(imageOutputQuality);
|
||||
sb.append(",\"mediaMaxDuration\":")
|
||||
.append(mediaMaxDuration);
|
||||
sb.append('}');
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
@ -0,0 +1,103 @@
|
||||
package ink.wgink.module.file.dao;
|
||||
|
||||
|
||||
import ink.wgink.exceptions.RemoveException;
|
||||
import ink.wgink.exceptions.SaveException;
|
||||
import ink.wgink.exceptions.SearchException;
|
||||
import ink.wgink.module.file.pojo.dtos.FileDTO;
|
||||
import ink.wgink.module.file.pojo.dtos.FileInfoDTO;
|
||||
import ink.wgink.pojo.pos.FilePO;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @ClassName: IFileDao
|
||||
* @Description: 文件
|
||||
* @Author: wenc
|
||||
* @Date: 2019/1/3 4:36 PM
|
||||
* @Version: 1.0
|
||||
**/
|
||||
@Repository
|
||||
public interface IFileDao {
|
||||
|
||||
/**
|
||||
* 保存文件
|
||||
*
|
||||
* @param params
|
||||
* @throws SaveException
|
||||
*/
|
||||
void save(Map<String, Object> params) throws SaveException;
|
||||
|
||||
/**
|
||||
* 删除文件
|
||||
*
|
||||
* @param params
|
||||
* @throws RemoveException
|
||||
*/
|
||||
void remove(Map<String, Object> params) throws RemoveException;
|
||||
|
||||
/**
|
||||
* 删除文件(物理删除)
|
||||
*
|
||||
* @param params
|
||||
* @throws RemoveException
|
||||
*/
|
||||
void delete(Map<String, Object> params) throws RemoveException;
|
||||
|
||||
/**
|
||||
* 更新文件描述
|
||||
*
|
||||
* @param fileParams
|
||||
* @throws SearchException
|
||||
*/
|
||||
void updateSummary(Map<String, Object> fileParams) throws SearchException;
|
||||
|
||||
/**
|
||||
* 获取文件详情
|
||||
*
|
||||
* @param params
|
||||
* @return
|
||||
* @throws SearchException
|
||||
*/
|
||||
FilePO getPO(Map<String, Object> params) throws SearchException;
|
||||
|
||||
/**
|
||||
* 获取文件列表
|
||||
*
|
||||
* @param params
|
||||
* @return
|
||||
* @throws SearchException
|
||||
*/
|
||||
List<FileDTO> list(Map<String, Object> params) throws SearchException;
|
||||
|
||||
/**
|
||||
* 获取文件列表
|
||||
*
|
||||
* @param params
|
||||
* @return
|
||||
* @throws SearchException
|
||||
*/
|
||||
List<FileInfoDTO> listInfo(Map<String, Object> params) throws SearchException;
|
||||
|
||||
/**
|
||||
* 获取文件列表(带路径)
|
||||
*
|
||||
* @param params
|
||||
* @return
|
||||
* @throws SearchException
|
||||
*/
|
||||
List<FileInfoDTO> listWithPath(Map<String, Object> params) throws SearchException;
|
||||
|
||||
/**
|
||||
* 文件列表
|
||||
*
|
||||
* @param fileMd5 文件MD5值
|
||||
* @return
|
||||
* @throws SearchException
|
||||
*/
|
||||
List<FileInfoDTO> listByMd5(String fileMd5) throws SearchException;
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
package ink.wgink.module.file.enums;
|
||||
|
||||
/**
|
||||
* @ClassName: UploadTypeEnum
|
||||
* @Description: 上传类型
|
||||
* @Author: WangGeng
|
||||
* @Date: 2019/3/10 10:37 PM
|
||||
* @Version: 1.0
|
||||
**/
|
||||
public enum UploadTypeEnum {
|
||||
|
||||
FILE(1), IMAGE(2), VIDEO(3), AUDIO(4), ERROR_EXCEL(5);
|
||||
private int value;
|
||||
|
||||
UploadTypeEnum(int value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public int getValue() {
|
||||
return value;
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package ink.wgink.pojo.dtos;
|
||||
package ink.wgink.module.file.pojo.dtos;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
@ -0,0 +1,76 @@
|
||||
package ink.wgink.module.file.pojo.dtos;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
/**
|
||||
* When you feel like quitting. Think about why you started
|
||||
* 当你想要放弃的时候,想想当初你为何开始
|
||||
*
|
||||
* @ClassName: FileDTO
|
||||
* @Description: 文件
|
||||
* @Author: WangGeng
|
||||
* @Date: 2020/9/12 17:28
|
||||
* @Version: 1.0
|
||||
**/
|
||||
@ApiModel
|
||||
public class FileInfoDTO extends FileDTO {
|
||||
|
||||
@ApiModelProperty(name = "filePath", value = "文件全路径")
|
||||
private String filePath;
|
||||
@ApiModelProperty(name = "fileUrl", value = "文件链接")
|
||||
private String fileUrl;
|
||||
@ApiModelProperty(name = "fileSummary", value = "文件说明")
|
||||
private String fileSummary;
|
||||
@ApiModelProperty(name = "isBack", value = "是否备份")
|
||||
private Integer isBack;
|
||||
|
||||
public String getFilePath() {
|
||||
return filePath == null ? "" : filePath.trim();
|
||||
}
|
||||
|
||||
public void setFilePath(String filePath) {
|
||||
this.filePath = filePath;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFileUrl() {
|
||||
return fileUrl == null ? "" : fileUrl.trim();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFileUrl(String fileUrl) {
|
||||
this.fileUrl = fileUrl;
|
||||
}
|
||||
|
||||
public String getFileSummary() {
|
||||
return fileSummary == null ? "" : fileSummary.trim();
|
||||
}
|
||||
|
||||
public void setFileSummary(String fileSummary) {
|
||||
this.fileSummary = fileSummary;
|
||||
}
|
||||
|
||||
public Integer getIsBack() {
|
||||
return isBack;
|
||||
}
|
||||
|
||||
public void setIsBack(Integer isBack) {
|
||||
this.isBack = isBack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
final StringBuilder sb = new StringBuilder("{");
|
||||
sb.append("\"filePath\":\"")
|
||||
.append(filePath).append('\"');
|
||||
sb.append(",\"fileUrl\":\"")
|
||||
.append(fileUrl).append('\"');
|
||||
sb.append(",\"fileSummary\":\"")
|
||||
.append(fileSummary).append('\"');
|
||||
sb.append(",\"isBack\":")
|
||||
.append(isBack);
|
||||
sb.append('}');
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
@ -0,0 +1,229 @@
|
||||
package ink.wgink.module.file.service;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import ink.wgink.module.file.enums.UploadTypeEnum;
|
||||
import ink.wgink.module.file.pojo.dtos.FileDTO;
|
||||
import ink.wgink.module.file.pojo.dtos.FileInfoDTO;
|
||||
import ink.wgink.pojo.ListPage;
|
||||
import ink.wgink.pojo.pos.FilePO;
|
||||
import ink.wgink.pojo.result.SuccessResultData;
|
||||
import ink.wgink.pojo.result.SuccessResultList;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @ClassName: IFileService
|
||||
* @Description: 文件处理
|
||||
* @Author: WangGeng
|
||||
* @Date: 2019/3/10 7:05 PM
|
||||
* @Version: 1.0
|
||||
**/
|
||||
public interface IFileService {
|
||||
|
||||
/**
|
||||
* 文件类型
|
||||
*/
|
||||
String UPLOAD_FILE_TYPE = "1";
|
||||
/**
|
||||
* 图片类型
|
||||
*/
|
||||
String UPLOAD_IMAGE_TYPE = "2";
|
||||
/**
|
||||
* 视频类型
|
||||
*/
|
||||
String UPLOAD_VIDEO_TYPE = "3";
|
||||
/**
|
||||
* 音频类型
|
||||
*/
|
||||
String UPLOAD_AUDIO_TYPE = "4";
|
||||
/**
|
||||
* 读取流大小 1M
|
||||
*/
|
||||
int INPUT_STREAM_SIZE = 1048576;
|
||||
|
||||
/**
|
||||
* uEditor action
|
||||
*/
|
||||
String UEDITOR_ACTION = "action";
|
||||
/**
|
||||
* uEditor config
|
||||
*/
|
||||
String UEDITOR_CONFIG = "config";
|
||||
/**
|
||||
* uEditor 图片
|
||||
*/
|
||||
String UEDITOR_UPLOAD_IMAGE = "uploadimage";
|
||||
/**
|
||||
* uEditor 视频
|
||||
*/
|
||||
String UEDITOR_UPLOAD_VIDEO = "uploadvideo";
|
||||
/**
|
||||
* uEditor 文件
|
||||
*/
|
||||
String UEDITOR_UPLOAD_FILE = "uploadfile";
|
||||
/**
|
||||
* uEditor 图片列表
|
||||
*/
|
||||
String UEDITOR_LIST_IMAGE = "listimage";
|
||||
/**
|
||||
* uEditor 文件列表
|
||||
*/
|
||||
String UEDITOR_LIST_FILE = "listfile";
|
||||
|
||||
/**
|
||||
* 文件分页列表
|
||||
*
|
||||
* @param page
|
||||
* @return
|
||||
*/
|
||||
SuccessResultList<List<FileInfoDTO>> listPageInfo(ListPage page);
|
||||
|
||||
/**
|
||||
* 删除记录
|
||||
*
|
||||
* @param ids
|
||||
*/
|
||||
void remove(String ids);
|
||||
|
||||
/**
|
||||
* 删除记录和文件
|
||||
*
|
||||
* @param ids
|
||||
*/
|
||||
void delete(String ids);
|
||||
|
||||
/**
|
||||
* 文件上传
|
||||
*
|
||||
* @param uploadFile
|
||||
* @param uploadTypeEnum
|
||||
* @param params
|
||||
* @return
|
||||
*/
|
||||
SuccessResultData<String> uploadSingle(MultipartFile uploadFile, UploadTypeEnum uploadTypeEnum, Map<String, Object> params);
|
||||
|
||||
/**
|
||||
* 文件上传
|
||||
*
|
||||
* @param token
|
||||
* @param uploadFile
|
||||
* @param uploadTypeEnum
|
||||
* @param params
|
||||
* @return
|
||||
* @throws IOException
|
||||
*/
|
||||
SuccessResultData<String> uploadSingle(String token, MultipartFile uploadFile, UploadTypeEnum uploadTypeEnum, Map<String, Object> params);
|
||||
|
||||
/**
|
||||
* 文件上传
|
||||
*
|
||||
* @param token
|
||||
* @param uploadFile
|
||||
* @param uploadTypeEnum
|
||||
* @param params
|
||||
* @return
|
||||
*/
|
||||
FileDTO uploadSingleForFileDTO(String token, MultipartFile uploadFile, UploadTypeEnum uploadTypeEnum, Map<String, Object> params);
|
||||
|
||||
/**
|
||||
* 文件下载
|
||||
*
|
||||
* @param response
|
||||
* @param params
|
||||
*/
|
||||
void downLoadFile(HttpServletResponse response, Map<String, Object> params);
|
||||
|
||||
/**
|
||||
* 文件下载
|
||||
*
|
||||
* @param request
|
||||
* @param response
|
||||
* @param params
|
||||
*/
|
||||
void downLoadFile(HttpServletRequest request, HttpServletResponse response, Map<String, Object> params);
|
||||
|
||||
/**
|
||||
* 文件下载
|
||||
*
|
||||
* @param request
|
||||
* @param response
|
||||
* @param params
|
||||
* @param canRange 开启断点续传
|
||||
*/
|
||||
void downLoadFile(HttpServletRequest request, HttpServletResponse response, Map<String, Object> params, boolean canRange);
|
||||
|
||||
/**
|
||||
* 百度富文本编辑器
|
||||
*
|
||||
* @param file
|
||||
* @param request
|
||||
* @param params
|
||||
* @return
|
||||
* @throws IOException
|
||||
*/
|
||||
JSONObject uEditor(MultipartFile file, HttpServletRequest request, Map<String, Object> params) throws IOException;
|
||||
|
||||
/**
|
||||
* wangEditor上传文件
|
||||
*
|
||||
* @param image
|
||||
* @param image1
|
||||
* @param params
|
||||
* @return
|
||||
*/
|
||||
JSONObject wangEditorImage(MultipartFile image, UploadTypeEnum image1, Map<String, Object> params);
|
||||
|
||||
/**
|
||||
* 获取文件详情
|
||||
*
|
||||
* @param params
|
||||
* @return
|
||||
*/
|
||||
FilePO getPO(Map<String, Object> params);
|
||||
|
||||
/**
|
||||
* 保存导入Excel异常文件信息
|
||||
*
|
||||
* @param fileName
|
||||
* @param uploadPath
|
||||
* @param fileSize
|
||||
* @param params
|
||||
*/
|
||||
void uploadErrorExcelFileInfo(String fileName, String uploadPath, long fileSize, Map<String, Object> params);
|
||||
|
||||
/**
|
||||
* 获取导入Excel异常文件路径
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
String getUploadExcelErrorPath();
|
||||
|
||||
/**
|
||||
* 通过文件ID获取ID列表
|
||||
*
|
||||
* @param idList
|
||||
* @return
|
||||
*/
|
||||
List<FileDTO> list(List<String> idList);
|
||||
|
||||
/**
|
||||
* 校验视频长度是否符合
|
||||
*
|
||||
* @param uploadFile
|
||||
* @param maxDuration
|
||||
*/
|
||||
void checkVideoDurationAllow(MultipartFile uploadFile, long maxDuration);
|
||||
|
||||
/**
|
||||
* 校验音频长度是否符合
|
||||
*
|
||||
* @param uploadFile
|
||||
* @param maxDuration
|
||||
*/
|
||||
void checkAudioDurationAllow(MultipartFile uploadFile, long maxDuration);
|
||||
}
|
@ -0,0 +1,853 @@
|
||||
package ink.wgink.module.file.service.impl;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import ink.wgink.app.AppTokenManager;
|
||||
import ink.wgink.common.base.DefaultBaseService;
|
||||
import ink.wgink.common.enums.ErrorResultCodeEnum;
|
||||
import ink.wgink.exceptions.FileException;
|
||||
import ink.wgink.exceptions.ParamsException;
|
||||
import ink.wgink.exceptions.SaveException;
|
||||
import ink.wgink.exceptions.SearchException;
|
||||
import ink.wgink.exceptions.base.SystemException;
|
||||
import ink.wgink.module.file.config.properties.FileProperties;
|
||||
import ink.wgink.module.file.dao.IFileDao;
|
||||
import ink.wgink.module.file.enums.UploadTypeEnum;
|
||||
import ink.wgink.module.file.pojo.dtos.FileDTO;
|
||||
import ink.wgink.module.file.pojo.dtos.FileInfoDTO;
|
||||
import ink.wgink.module.file.service.IFileService;
|
||||
import ink.wgink.pojo.ListPage;
|
||||
import ink.wgink.pojo.pos.FilePO;
|
||||
import ink.wgink.pojo.result.SuccessResultData;
|
||||
import ink.wgink.pojo.result.SuccessResultList;
|
||||
import ink.wgink.util.ResourceUtil;
|
||||
import ink.wgink.util.UUIDUtil;
|
||||
import ink.wgink.util.date.DateUtil;
|
||||
import it.sauronsoftware.jave.Encoder;
|
||||
import it.sauronsoftware.jave.EncoderException;
|
||||
import it.sauronsoftware.jave.MultimediaInfo;
|
||||
import net.coobird.thumbnailator.Thumbnails;
|
||||
import org.apache.catalina.connector.ClientAbortException;
|
||||
import org.apache.commons.fileupload.disk.DiskFileItem;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.joda.time.DateTime;
|
||||
import org.joda.time.DateTimeZone;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import org.springframework.web.multipart.commons.CommonsMultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.*;
|
||||
import java.net.URLEncoder;
|
||||
import java.nio.channels.Channels;
|
||||
import java.nio.channels.FileChannel;
|
||||
import java.nio.channels.WritableByteChannel;
|
||||
import java.security.MessageDigest;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @ClassName: FileServiceImpl
|
||||
* @Description: 文件处理
|
||||
* @Author: WangGeng
|
||||
* @Date: 2019/3/10 7:06 PM
|
||||
* @Version: 1.0
|
||||
**/
|
||||
@Service
|
||||
public class FileServiceImpl extends DefaultBaseService implements IFileService {
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(FileServiceImpl.class);
|
||||
private static final char[] HEX_CODE = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};
|
||||
/**
|
||||
* 文件MD5值开头
|
||||
*/
|
||||
public static final String FILE_MD5_PREFIX = "MD5:";
|
||||
/**
|
||||
* 文件引用值开头
|
||||
*/
|
||||
public static final String FILE_REF_PREFIX = "REF:";
|
||||
|
||||
@Autowired
|
||||
private FileProperties fileProperties;
|
||||
@Autowired
|
||||
private IFileDao fileDao;
|
||||
|
||||
private String[] imageTypes;
|
||||
private String[] videoTypes;
|
||||
private String[] audioTypes;
|
||||
private String[] fileTypes;
|
||||
|
||||
public List<FileInfoDTO> listFileInfo(Map<String, Object> params) {
|
||||
return fileDao.listInfo(params);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SuccessResultList<List<FileInfoDTO>> listPageInfo(ListPage page) {
|
||||
PageHelper.startPage(page.getPage(), page.getRows());
|
||||
List<FileInfoDTO> fileInfoDTOs = fileDao.listInfo(page.getParams());
|
||||
PageInfo<FileInfoDTO> pageInfo = new PageInfo<>(fileInfoDTOs);
|
||||
return new SuccessResultList<>(fileInfoDTOs, pageInfo.getPageNum(), pageInfo.getTotal());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove(String ids) {
|
||||
Map<String, Object> params = getHashMap(2);
|
||||
params.put("fileIds", Arrays.asList(ids.split("_")));
|
||||
setUpdateInfo(params);
|
||||
fileDao.remove(params);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(String ids) {
|
||||
Map<String, Object> params = getHashMap(2);
|
||||
params.put("fileIds", Arrays.asList(ids.split("_")));
|
||||
Map<String, Object> fileParams = getHashMap(4);
|
||||
List<FileInfoDTO> fileInfoWithPathDTOs = fileDao.listWithPath(params);
|
||||
// 删除文件
|
||||
for (FileInfoDTO fileInfoDTO : fileInfoWithPathDTOs) {
|
||||
// 如果文件描述为空,可以直接删除源文件
|
||||
if (StringUtils.isBlank(fileInfoDTO.getFileSummary())) {
|
||||
deleteSourceFile(fileInfoDTO.getFilePath());
|
||||
continue;
|
||||
}
|
||||
// 文件描述不为空时,需要判断是否删除的是源文件,源文件在一个系统中只保留一份
|
||||
// 如果是引用文件的数据,不删除源文件
|
||||
if (fileInfoDTO.getFileSummary().startsWith(FILE_REF_PREFIX)) {
|
||||
continue;
|
||||
}
|
||||
// 如果不是MD5源文件,略过
|
||||
if (!fileInfoDTO.getFileSummary().startsWith(FILE_MD5_PREFIX)) {
|
||||
continue;
|
||||
}
|
||||
// 如果删除的是源文件,需要查询系统中是否还存在引用的数据
|
||||
List<FileInfoDTO> fileInfoDTOs = fileDao.listByMd5(FILE_REF_PREFIX + fileInfoDTO.getFileId());
|
||||
// 如果不存在对源文件引用的数据,则直接删除源文件
|
||||
if (fileInfoDTOs.size() == 0) {
|
||||
deleteSourceFile(fileInfoDTO.getFilePath());
|
||||
continue;
|
||||
}
|
||||
fileParams.clear();
|
||||
// 如果存在引用数据,取出第一个修改为源文件,并将其他的引用更新为新的源文件ID
|
||||
FileInfoDTO firstFileInfoDTO = fileInfoDTOs.get(0);
|
||||
fileParams.put("fileSummary", firstFileInfoDTO.getFileSummary());
|
||||
fileParams.put("fileId", firstFileInfoDTO.getFileId());
|
||||
fileDao.updateSummary(fileParams);
|
||||
// 获取其他的ID列表,更新文件引用关系
|
||||
List<String> otherFileIds = new ArrayList<>();
|
||||
for (int i = 1; i < fileInfoDTOs.size(); i++) {
|
||||
otherFileIds.add(fileInfoDTOs.get(i).getFileId());
|
||||
}
|
||||
// 如果不存在其它的引用,略过
|
||||
if (otherFileIds.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
fileParams.remove("fileId");
|
||||
fileParams.put("fileSummary", FILE_REF_PREFIX + firstFileInfoDTO.getFileId());
|
||||
fileParams.put("fileIds", otherFileIds);
|
||||
fileDao.updateSummary(fileParams);
|
||||
}
|
||||
// 删除记录
|
||||
fileDao.delete(params);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除源文件
|
||||
*
|
||||
* @param sourceFilePath 源文件路径
|
||||
*/
|
||||
private void deleteSourceFile(String sourceFilePath) {
|
||||
File file = new File(sourceFilePath);
|
||||
if (file.exists()) {
|
||||
boolean isDelete = file.delete();
|
||||
if (isDelete) {
|
||||
LOG.debug("文件删除成功");
|
||||
} else {
|
||||
LOG.debug("文件删除失败");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public SuccessResultData<String> uploadSingle(MultipartFile uploadFile, UploadTypeEnum uploadTypeEnum, Map<String, Object> params) throws SystemException {
|
||||
uploadFile(null, uploadFile, uploadTypeEnum, params);
|
||||
return new SuccessResultData<>(params.get("fileId").toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public SuccessResultData<String> uploadSingle(String token, MultipartFile uploadFile, UploadTypeEnum uploadTypeEnum, Map<String, Object> params) throws SystemException {
|
||||
uploadFile(token, uploadFile, uploadTypeEnum, params);
|
||||
return new SuccessResultData<>(params.get("fileId").toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public FileDTO uploadSingleForFileDTO(String token, MultipartFile uploadFile, UploadTypeEnum uploadTypeEnum, Map<String, Object> params) throws SystemException {
|
||||
uploadFile(token, uploadFile, uploadTypeEnum, params);
|
||||
FileDTO fileDTO = new FileDTO();
|
||||
fileDTO.setFileId(params.get("fileId").toString());
|
||||
fileDTO.setFileName(params.get("fileName").toString());
|
||||
fileDTO.setFileUrl(params.get("fileUrl").toString());
|
||||
fileDTO.setFileType(params.get("fileType").toString());
|
||||
return fileDTO;
|
||||
}
|
||||
|
||||
/**
|
||||
* 上传文件
|
||||
*
|
||||
* @param token
|
||||
* @param uploadFile
|
||||
* @param uploadTypeEnum
|
||||
* @param params
|
||||
* @throws SystemException
|
||||
*/
|
||||
private void uploadFile(String token, MultipartFile uploadFile, UploadTypeEnum uploadTypeEnum, Map<String, Object> params) throws SystemException {
|
||||
String baseUploadPath = fileProperties.getUploadPath();
|
||||
if (StringUtils.isBlank(baseUploadPath)) {
|
||||
throw new SystemException("上传路径未配置");
|
||||
}
|
||||
String fileName = uploadFile.getOriginalFilename();
|
||||
// 文件大小
|
||||
long fileSize = uploadFile.getSize();
|
||||
// 文件类型
|
||||
String fileType = getFileType(fileName);
|
||||
// 文件保存路径
|
||||
String uploadPath = getUploadPath(baseUploadPath, uploadTypeEnum, fileType);
|
||||
// 文件保存名称
|
||||
String uploadFileName = getUploadFileName(fileType);
|
||||
String fileMd5 = uploadFile(uploadFile, uploadPath, uploadFileName);
|
||||
if (fileMd5 == null) {
|
||||
throw new SaveException("文件上传失败");
|
||||
}
|
||||
// 获取MD5相同的文件
|
||||
List<FileInfoDTO> fileInfoDTOs = fileDao.listByMd5(FILE_MD5_PREFIX + fileMd5);
|
||||
if (fileInfoDTOs.size() > 0) {
|
||||
// 删除新增的文件
|
||||
File uploadedFile = new File(uploadPath + File.separator + uploadFileName);
|
||||
if (uploadedFile.exists()) {
|
||||
uploadedFile.delete();
|
||||
}
|
||||
// 保存记录,但文件信息都是原有的文件
|
||||
params.clear();
|
||||
FileInfoDTO fileInfoDTO = fileInfoDTOs.get(0);
|
||||
params.put("fileSummary", "REF:" + fileInfoDTO.getFileId());
|
||||
saveFile(token, params, fileInfoDTO.getFileName(), fileInfoDTO.getFilePath(), fileInfoDTO.getFileUrl(), fileInfoDTO.getFileType(), fileInfoDTO.getFileSize());
|
||||
return;
|
||||
}
|
||||
params.put("fileSummary", "MD5:" + fileMd5);
|
||||
saveUploadFileInfo(token, fileName, uploadPath, uploadFileName, fileType, fileSize, params);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void uploadErrorExcelFileInfo(String fileName, String uploadPath, long fileSize, Map<String, Object> params) {
|
||||
saveUploadFileInfo(null, fileName, uploadPath, fileName, "xls", fileSize, params);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUploadExcelErrorPath() {
|
||||
String baseUploadPath = fileProperties.getUploadPath();
|
||||
if (StringUtils.isBlank(baseUploadPath)) {
|
||||
throw new SystemException("上传路径未配置");
|
||||
}
|
||||
return getUploadPath(baseUploadPath, UploadTypeEnum.ERROR_EXCEL, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<FileDTO> list(List<String> idList) throws SearchException {
|
||||
Map<String, Object> params = getHashMap(1);
|
||||
params.put("ids", idList);
|
||||
return fileDao.list(params);
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存文件信息
|
||||
*
|
||||
* @param token
|
||||
* @param fileName
|
||||
* @param uploadPath
|
||||
* @param uploadFileName
|
||||
* @param fileType
|
||||
* @param fileSize
|
||||
*/
|
||||
private void saveUploadFileInfo(String token, String fileName, String uploadPath, String uploadFileName, String fileType, long fileSize, Map<String, Object> params) {
|
||||
String fixPath = uploadPath.replace(fileProperties.getUploadPath(), "");
|
||||
if ("\\".equals(File.separator)) {
|
||||
fixPath = fixPath.replace("\\", "/");
|
||||
}
|
||||
if (fixPath.startsWith("/")) {
|
||||
fixPath = fixPath.substring(1, fixPath.length() - 1);
|
||||
}
|
||||
String fileFullPath = String.format("%s%s%s", uploadPath, File.separator, uploadFileName);
|
||||
// 压缩图片
|
||||
if (isImageFile(fileType)) {
|
||||
compressImage(fileFullPath);
|
||||
File photo = new File(fileFullPath);
|
||||
fileSize = photo.length();
|
||||
}
|
||||
saveFile(token, params, fileName, fileFullPath, String.format("files/%s/%s", fixPath, uploadFileName), fileType, fileSize);
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存文件
|
||||
*
|
||||
* @param token token
|
||||
* @param params 参数
|
||||
* @param fileName 文件名
|
||||
* @param fileFullPath 文件全路径
|
||||
* @param fileUrl 文件相对地址
|
||||
* @param fileType 文件类型
|
||||
* @param fileSize 文件大小
|
||||
*/
|
||||
private void saveFile(String token, Map<String, Object> params, String fileName, String fileFullPath, String fileUrl, String fileType, long fileSize) {
|
||||
params.put("fileId", UUIDUtil.getUUID());
|
||||
params.put("fileName", fileName);
|
||||
params.put("filePath", fileFullPath);
|
||||
params.put("fileUrl", fileUrl);
|
||||
params.put("fileType", fileType);
|
||||
params.put("fileSize", fileSize);
|
||||
params.put("isBack", 0);
|
||||
if (StringUtils.isBlank(token)) {
|
||||
setSaveInfo(params);
|
||||
} else {
|
||||
setSaveInfoByUserId(params, AppTokenManager.getInstance().getToken(token).getAppTokenUser().getId());
|
||||
}
|
||||
fileDao.save(params);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void downLoadFile(HttpServletResponse response, Map<String, Object> params) {
|
||||
downLoadFile(null, response, params);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void downLoadFile(HttpServletRequest request, HttpServletResponse response, Map<String, Object> params) {
|
||||
downLoadFile(request, response, params, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void downLoadFile(HttpServletRequest request, HttpServletResponse response, Map<String, Object> params, boolean canRange) {
|
||||
FilePO filePO = fileDao.getPO(params);
|
||||
if (null == filePO) {
|
||||
throw new SearchException("文件获取失败");
|
||||
}
|
||||
try (
|
||||
RandomAccessFile randomAccessFile = new RandomAccessFile(filePO.getFilePath(), "r");
|
||||
FileChannel fileChannel = randomAccessFile.getChannel();
|
||||
OutputStream outputStream = response.getOutputStream();
|
||||
WritableByteChannel writableByteChannel = Channels.newChannel(outputStream);
|
||||
) {
|
||||
boolean isOpen = Boolean.valueOf(params.get("isOpen").toString());
|
||||
response.setHeader("Content-Length", filePO.getFileSize());
|
||||
response.setContentType(getContentType(filePO.getFileType()));
|
||||
if (!isOpen) {
|
||||
response.setHeader("Content-Disposition", "attachment;fileName=" + URLEncoder.encode(filePO.getFileName(), "UTF-8"));
|
||||
} else {
|
||||
response.setHeader("Content-Disposition", "inline;fileName=" + URLEncoder.encode(filePO.getFileName(), "UTF-8"));
|
||||
// 如果是图片资源,开启缓存
|
||||
if (isImageFile(filePO.getFileType())) {
|
||||
// 如果存在校验修改时间且未做修改,返回304,使用本地资源
|
||||
String ifModifiedSince = request.getHeader("If-Modified-Since");
|
||||
if (StringUtils.isNotBlank(ifModifiedSince) && StringUtils.equalsIgnoreCase(ifModifiedSince, filePO.getGmtModified())) {
|
||||
response.setStatus(HttpServletResponse.SC_NOT_MODIFIED);
|
||||
return;
|
||||
}
|
||||
// 缓存有效时间为7天
|
||||
response.setHeader("Expires", DateTime.now().plusDays(7).toDateTime(DateTimeZone.forID("GMT")).toString());
|
||||
// 60秒之内不发送新请求
|
||||
response.setHeader("max-age", "60");
|
||||
response.setHeader("Last-Modified", filePO.getGmtModified());
|
||||
}
|
||||
}
|
||||
String rangeString = null;
|
||||
if (canRange && request != null) {
|
||||
rangeString = request.getHeader("Range");
|
||||
LOG.debug("range: {}", rangeString);
|
||||
}
|
||||
long contentLength = Long.valueOf(filePO.getFileSize());
|
||||
long startRange = 0;
|
||||
long endRange = contentLength - 1;
|
||||
if (!StringUtils.isBlank(rangeString)) {
|
||||
if (!isOpen) {
|
||||
response.setContentType("multipart/byteranges");
|
||||
}
|
||||
String[] rangeArray = rangeString.substring(rangeString.indexOf("=") + 1).split("-");
|
||||
startRange = Long.valueOf(rangeArray[0]);
|
||||
if (rangeArray.length > 1) {
|
||||
endRange = Long.valueOf(rangeArray[1]);
|
||||
}
|
||||
setRangeHeader(startRange, endRange, response, filePO.getFileId(), contentLength);
|
||||
randomAccessFile.seek(startRange);
|
||||
}
|
||||
LOG.debug("startRange: {}, endRange: {}", startRange, endRange);
|
||||
long totalOutputLength = endRange - startRange + 1;
|
||||
fileChannel.transferTo(startRange, totalOutputLength, writableByteChannel);
|
||||
outputStream.flush();
|
||||
} catch (Exception e) {
|
||||
if (e instanceof ClientAbortException) {
|
||||
LOG.debug("客户端断开连接");
|
||||
} else {
|
||||
throw new FileException("文件输出异常", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理视频流问题
|
||||
*
|
||||
* @param startRange
|
||||
* @param endRange
|
||||
* @param response
|
||||
* @param fileId
|
||||
* @param contentLength
|
||||
*/
|
||||
private void setRangeHeader(long startRange, long endRange, HttpServletResponse response, String fileId, long contentLength) {
|
||||
// 这里不设置,会出现第一次加载很慢的情况
|
||||
response.setHeader("Content-Length", String.valueOf(endRange - startRange + 1));
|
||||
response.setHeader("Content-Range", String.format("bytes %d-%d/%d", startRange, endRange, contentLength));
|
||||
response.setHeader("Accept-Ranges", "bytes");
|
||||
response.setHeader("Etag", fileId);
|
||||
response.setStatus(206);
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONObject uEditor(MultipartFile file, HttpServletRequest request, Map<String, Object> params) throws SystemException, IOException {
|
||||
if (params.get(UEDITOR_ACTION) == null || StringUtils.isBlank(params.get(UEDITOR_ACTION).toString())) {
|
||||
throw new ParamsException("参数错误");
|
||||
}
|
||||
String action = params.get(UEDITOR_ACTION).toString();
|
||||
JSONObject result = null;
|
||||
if (UEDITOR_CONFIG.equals(action)) {
|
||||
result = uEditorConfig();
|
||||
}
|
||||
if (UEDITOR_UPLOAD_IMAGE.equals(action) || UEDITOR_UPLOAD_VIDEO.equals(action) || UEDITOR_UPLOAD_FILE.equals(action)) {
|
||||
result = uEditorUpload(file, request, action, params);
|
||||
}
|
||||
if (UEDITOR_LIST_IMAGE.equals(action) || UEDITOR_LIST_FILE.equals(action)) {
|
||||
result = uEditorFileList(request, action, params);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONObject wangEditorImage(MultipartFile image, UploadTypeEnum image1, Map<String, Object> params) {
|
||||
JSONObject result = new JSONObject();
|
||||
try {
|
||||
FileDTO fileDTO = uploadSingleForFileDTO(null, image, UploadTypeEnum.IMAGE, params);
|
||||
result.put("errno", 0);
|
||||
JSONArray fileArray = new JSONArray();
|
||||
fileArray.add(String.format("route/file/downloadfile/true/%s", fileDTO.getFileId()));
|
||||
result.put("data", fileArray);
|
||||
} catch (Exception e) {
|
||||
LOG.error(e.getMessage(), e);
|
||||
result.put("errno", ErrorResultCodeEnum.FILE_ERROR.getValue());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FilePO getPO(Map<String, Object> params) throws SearchException {
|
||||
return fileDao.getPO(params);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void checkVideoDurationAllow(MultipartFile uploadFile, long maxDuration) {
|
||||
if (maxDuration <= 0) {
|
||||
return;
|
||||
}
|
||||
checkDurationAllow(uploadFile, maxDuration, "视频");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void checkAudioDurationAllow(MultipartFile uploadFile, long maxDuration) {
|
||||
if (maxDuration <= 0) {
|
||||
return;
|
||||
}
|
||||
checkDurationAllow(uploadFile, maxDuration, "音频");
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验音、视频长度是否符合
|
||||
*
|
||||
* @param uploadFile
|
||||
* @param maxDuration
|
||||
*/
|
||||
private void checkDurationAllow(MultipartFile uploadFile, long maxDuration, String name) {
|
||||
CommonsMultipartFile commonsMultipartFile = (CommonsMultipartFile) uploadFile;
|
||||
DiskFileItem diskFileItem = (DiskFileItem) commonsMultipartFile.getFileItem();
|
||||
File source = diskFileItem.getStoreLocation();
|
||||
Encoder encoder = new Encoder();
|
||||
MultimediaInfo multimediaInfo;
|
||||
try {
|
||||
multimediaInfo = encoder.getInfo(source);
|
||||
} catch (EncoderException e) {
|
||||
throw new SystemException("文件解析错误");
|
||||
}
|
||||
long fileDuration = multimediaInfo.getDuration() / 1000;
|
||||
if (fileDuration > maxDuration) {
|
||||
throw new FileException(name + "时间超过 " + maxDuration + " 秒");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* uEditor文件列表
|
||||
*
|
||||
* @param action
|
||||
* @param params
|
||||
* @return
|
||||
*/
|
||||
private JSONObject uEditorFileList(HttpServletRequest request, String action, Map<String, Object> params) throws SearchException {
|
||||
LOG.debug("uEditor文件列表");
|
||||
int start = Integer.parseInt(params.get("start").toString());
|
||||
int pageSize = Integer.parseInt(params.get("size").toString());
|
||||
int pageNum = start / pageSize + 1;
|
||||
String downloadFile = "true";
|
||||
if (UEDITOR_LIST_IMAGE.equals(action)) {
|
||||
params.put("fileUrl", "images");
|
||||
} else if (UEDITOR_LIST_FILE.equals(action)) {
|
||||
params.put("fileUrl", "files");
|
||||
downloadFile = "false";
|
||||
}
|
||||
PageHelper.startPage(pageNum, pageSize);
|
||||
List<FileDTO> listFileDTOs = fileDao.list(params);
|
||||
PageInfo<FileDTO> pageInfo = new PageInfo<>(listFileDTOs);
|
||||
List<Map<String, String>> fileList = new ArrayList<>();
|
||||
for (FileDTO fileDTO : listFileDTOs) {
|
||||
Map<String, String> fileMap = new HashMap<>(0);
|
||||
fileMap.put("url", String.format("%s/route/file/downloadfile/%s/%s.%s", request.getContextPath(), downloadFile, fileDTO.getFileId(), fileDTO.getFileType()));
|
||||
fileList.add(fileMap);
|
||||
}
|
||||
JSONObject uEditorListResult = new JSONObject();
|
||||
uEditorListResult.put("state", "SUCCESS");
|
||||
uEditorListResult.put("start", start);
|
||||
uEditorListResult.put("total", pageInfo.getTotal());
|
||||
uEditorListResult.put("list", fileList);
|
||||
return uEditorListResult;
|
||||
}
|
||||
|
||||
/**
|
||||
* uEditor上传文件
|
||||
*
|
||||
* @param file
|
||||
* @param request
|
||||
* @param action
|
||||
* @param params
|
||||
* @return
|
||||
* @throws SystemException
|
||||
*/
|
||||
private JSONObject uEditorUpload(MultipartFile file, HttpServletRequest request, String action, Map<String, Object> params) throws SystemException {
|
||||
LOG.debug("UEditor上传文件");
|
||||
FileDTO fileDTO = null;
|
||||
String downloadFile = "true";
|
||||
if (UEDITOR_UPLOAD_IMAGE.equals(action)) {
|
||||
fileDTO = uploadSingleForFileDTO(null, file, UploadTypeEnum.IMAGE, params);
|
||||
} else if (UEDITOR_UPLOAD_VIDEO.equals(action)) {
|
||||
fileDTO = uploadSingleForFileDTO(null, file, UploadTypeEnum.VIDEO, params);
|
||||
downloadFile = "true";
|
||||
} else if (UEDITOR_UPLOAD_FILE.equals(action)) {
|
||||
fileDTO = uploadSingleForFileDTO(null, file, UploadTypeEnum.FILE, params);
|
||||
downloadFile = "false";
|
||||
}
|
||||
if (fileDTO == null) {
|
||||
throw new SystemException("文件上传失败");
|
||||
}
|
||||
String fileUrl = String.format("route/file/downloadfile/%s/%s.%s", downloadFile, fileDTO.getFileId(), fileDTO.getFileType());
|
||||
JSONObject fileUploadResult = new JSONObject();
|
||||
fileUploadResult.put("state", "SUCCESS");
|
||||
fileUploadResult.put("url", fileUrl);
|
||||
fileUploadResult.put("title", fileDTO.getFileName());
|
||||
fileUploadResult.put("original", fileDTO.getFileName());
|
||||
return fileUploadResult;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取ueditor配置文件
|
||||
*
|
||||
* @return
|
||||
* @throws IOException
|
||||
*/
|
||||
private JSONObject uEditorConfig() throws IOException {
|
||||
LOG.debug("加载UEditor配置文件");
|
||||
String uEditorConfig = ResourceUtil.inputStreamToText(ResourceUtil.getResourceInputStream("classpath:ueditorconfig.json"));
|
||||
return JSONObject.parseObject(uEditorConfig);
|
||||
}
|
||||
|
||||
|
||||
public String[] getImageTypes() {
|
||||
return imageTypes == null ? fileProperties.getImageTypes().split(",") : imageTypes;
|
||||
}
|
||||
|
||||
public void setImageTypes(String[] imageTypes) {
|
||||
this.imageTypes = imageTypes;
|
||||
}
|
||||
|
||||
public String[] getVideoTypes() {
|
||||
return videoTypes == null ? fileProperties.getVideoTypes().split(",") : videoTypes;
|
||||
}
|
||||
|
||||
public void setVideoTypes(String[] videoTypes) {
|
||||
this.videoTypes = videoTypes;
|
||||
}
|
||||
|
||||
public String[] getAudioTypes() {
|
||||
return audioTypes == null ? fileProperties.getAudioTypes().split(",") : audioTypes;
|
||||
}
|
||||
|
||||
public void setAudioTypes(String[] audioTypes) {
|
||||
this.audioTypes = audioTypes;
|
||||
}
|
||||
|
||||
public String[] getFileTypes() {
|
||||
return fileTypes == null ? fileProperties.getFileTypes().split(",") : fileTypes;
|
||||
}
|
||||
|
||||
public void setFileTypes(String[] fileTypes) {
|
||||
this.fileTypes = fileTypes;
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验类型
|
||||
*
|
||||
* @param types
|
||||
* @param fileType
|
||||
* @return
|
||||
*/
|
||||
private boolean isTypeCorrect(String[] types, String fileType) {
|
||||
for (String type : types) {
|
||||
if (StringUtils.equalsIgnoreCase(fileType, type)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取文件类型
|
||||
*
|
||||
* @param fileName
|
||||
* @return
|
||||
*/
|
||||
private String getFileType(String fileName) {
|
||||
String[] names = fileName.split("\\.");
|
||||
if (names != null) {
|
||||
return names[names.length - 1].toLowerCase();
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取上传文件路径
|
||||
*
|
||||
* @param baseUploadPath
|
||||
* @param uploadTypeEnum
|
||||
* @param fileType
|
||||
* @return
|
||||
* @throws FileException
|
||||
*/
|
||||
private String getUploadPath(String baseUploadPath, UploadTypeEnum uploadTypeEnum, String fileType) throws FileException {
|
||||
StringBuilder filePath = new StringBuilder();
|
||||
if (!baseUploadPath.endsWith(File.separator)) {
|
||||
filePath.append(baseUploadPath).append(File.separator);
|
||||
} else {
|
||||
filePath.append(baseUploadPath);
|
||||
}
|
||||
boolean hasFileType = !StringUtils.isBlank(fileType);
|
||||
if (uploadTypeEnum.getValue() == UploadTypeEnum.IMAGE.getValue()) {
|
||||
if (hasFileType && !isTypeCorrect(getImageTypes(), fileType)) {
|
||||
throw new FileException("图片格式不支持上传");
|
||||
}
|
||||
filePath.append("images");
|
||||
} else if (uploadTypeEnum.getValue() == UploadTypeEnum.VIDEO.getValue()) {
|
||||
if (hasFileType && !isTypeCorrect(getVideoTypes(), fileType)) {
|
||||
throw new FileException("视频格式不支持上传");
|
||||
}
|
||||
filePath.append("videos");
|
||||
} else if (uploadTypeEnum.getValue() == UploadTypeEnum.AUDIO.getValue()) {
|
||||
if (hasFileType && !isTypeCorrect(getAudioTypes(), fileType)) {
|
||||
throw new FileException("音频格式不支持上传");
|
||||
}
|
||||
filePath.append("audios");
|
||||
} else if (uploadTypeEnum.getValue() == UploadTypeEnum.ERROR_EXCEL.getValue()) {
|
||||
filePath.append("errorexcels");
|
||||
} else {
|
||||
if (hasFileType && !isTypeCorrect(getFileTypes(), fileType)) {
|
||||
throw new FileException("文件格式不支持上传");
|
||||
}
|
||||
filePath.append("files");
|
||||
}
|
||||
filePath.append(File.separator).append(DateUtil.getDays());
|
||||
return filePath.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取上传文件名称
|
||||
*
|
||||
* @param fileType
|
||||
* @return
|
||||
*/
|
||||
private String getUploadFileName(String fileType) {
|
||||
String uploadFileName = UUIDUtil.get32UUID();
|
||||
if (!StringUtils.isEmpty(fileType)) {
|
||||
uploadFileName += "." + fileType;
|
||||
}
|
||||
return uploadFileName;
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存文件到本地
|
||||
*
|
||||
* @param uploadFile
|
||||
* @param filePath
|
||||
* @param uploadFileName
|
||||
* @return
|
||||
*/
|
||||
private String uploadFile(MultipartFile uploadFile, String filePath, String uploadFileName) throws FileException {
|
||||
String fileMd5;
|
||||
File uploadFolder = new File(filePath);
|
||||
if (!uploadFolder.exists()) {
|
||||
uploadFolder.mkdirs();
|
||||
}
|
||||
InputStream uploadFileInputStream = null;
|
||||
FileOutputStream uploadFileOutputStream = null;
|
||||
try {
|
||||
uploadFileInputStream = uploadFile.getInputStream();
|
||||
uploadFileOutputStream = new FileOutputStream(new File(uploadFolder + "/" + uploadFileName));
|
||||
MessageDigest messageDigest = MessageDigest.getInstance("MD5");
|
||||
for (byte[] buf = new byte[INPUT_STREAM_SIZE]; uploadFileInputStream.read(buf) > -1; ) {
|
||||
uploadFileOutputStream.write(buf, 0, buf.length);
|
||||
messageDigest.update(buf, 0, buf.length);
|
||||
}
|
||||
uploadFileOutputStream.flush();
|
||||
// 计算文件的MD5
|
||||
byte[] data = messageDigest.digest();
|
||||
StringBuilder fileMd5SB = new StringBuilder(data.length * 2);
|
||||
for (byte b : data) {
|
||||
fileMd5SB.append(HEX_CODE[(b >> 4) & 0xF]);
|
||||
fileMd5SB.append(HEX_CODE[(b & 0xF)]);
|
||||
}
|
||||
fileMd5 = fileMd5SB.toString();
|
||||
} catch (Exception e) {
|
||||
LOG.error(e.getMessage(), e);
|
||||
throw new FileException("文件上传失败");
|
||||
} finally {
|
||||
try {
|
||||
if (null != uploadFileOutputStream) {
|
||||
uploadFileOutputStream.close();
|
||||
}
|
||||
if (null != uploadFileInputStream) {
|
||||
uploadFileInputStream.close();
|
||||
}
|
||||
} catch (Exception e1) {
|
||||
LOG.error(e1.getMessage());
|
||||
throw new FileException("文件上传失败");
|
||||
}
|
||||
}
|
||||
return fileMd5;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取ContentType
|
||||
*
|
||||
* @param fileType
|
||||
* @return
|
||||
*/
|
||||
private String getContentType(String fileType) {
|
||||
String contentType;
|
||||
switch (fileType) {
|
||||
case "png":
|
||||
contentType = "image/png";
|
||||
break;
|
||||
case "blob":
|
||||
case "jpg":
|
||||
case "jpeg":
|
||||
contentType = "image/jpeg";
|
||||
break;
|
||||
case "gif":
|
||||
contentType = "image/gif";
|
||||
break;
|
||||
case "mp4":
|
||||
contentType = "video/mp4";
|
||||
break;
|
||||
case "rmvb":
|
||||
contentType = "application/vnd.rn-realmedia-vbr";
|
||||
break;
|
||||
case "mp3":
|
||||
contentType = "audio/mp3";
|
||||
break;
|
||||
case "wmv":
|
||||
contentType = "video/x-ms-wmv";
|
||||
break;
|
||||
case "wav":
|
||||
contentType = "audio/wav";
|
||||
break;
|
||||
case "doc":
|
||||
contentType = "application/msword";
|
||||
break;
|
||||
case "docx":
|
||||
contentType = "application/vnd.openxmlformats-officedocument.wordprocessingml.document";
|
||||
break;
|
||||
case "xls":
|
||||
contentType = "application/vnd.ms-excel";
|
||||
break;
|
||||
case "xlsx":
|
||||
contentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
|
||||
break;
|
||||
case "ppt":
|
||||
contentType = "application/vnd.ms-powerpoint";
|
||||
break;
|
||||
case "pptx":
|
||||
contentType = "application/vnd.openxmlformats-officedocument.presentationml.presentation";
|
||||
break;
|
||||
case "txt":
|
||||
contentType = "text/plain";
|
||||
break;
|
||||
case "apk":
|
||||
contentType = "application/vnd.android.package-archive";
|
||||
break;
|
||||
case "pdf":
|
||||
contentType = "application/pdf";
|
||||
break;
|
||||
default:
|
||||
contentType = "application/octet-stream";
|
||||
}
|
||||
return contentType;
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否是图片文件, GIF图片不压缩
|
||||
*
|
||||
* @param fileType
|
||||
* @return
|
||||
*/
|
||||
private boolean isImageFile(String fileType) {
|
||||
if (StringUtils.equalsIgnoreCase("gif", fileType)) {
|
||||
return false;
|
||||
}
|
||||
String imageTypes = fileProperties.getImageTypes();
|
||||
for (String imageType : imageTypes.split(",")) {
|
||||
if (StringUtils.equalsIgnoreCase(fileType, imageType)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 压缩图片
|
||||
*
|
||||
* @param fileFullPath
|
||||
*/
|
||||
private void compressImage(String fileFullPath) {
|
||||
if (fileFullPath.endsWith(".blob")) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
Thumbnails.of(fileFullPath).scale(1.0f).outputQuality(fileProperties.getImageOutputQuality()).toFile(fileFullPath);
|
||||
} catch (IOException e) {
|
||||
LOG.error(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
31
pom.xml
31
pom.xml
@ -15,6 +15,10 @@
|
||||
<module>service-user</module>
|
||||
<module>basic-app</module>
|
||||
<module>basic-exception</module>
|
||||
<module>basic-annotation</module>
|
||||
<module>service-department</module>
|
||||
<module>service-role</module>
|
||||
<module>module-file</module>
|
||||
</modules>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
@ -55,6 +59,8 @@
|
||||
<jna-platform.version>5.5.0</jna-platform.version>
|
||||
<netty.version>4.1.50.Final</netty.version>
|
||||
<bouncycastle.version>1.56</bouncycastle.version>
|
||||
<tomcat-embed.version>9.0.14</tomcat-embed.version>
|
||||
<lombok.version>1.18.16</lombok.version>
|
||||
</properties>
|
||||
|
||||
<dependencyManagement>
|
||||
@ -353,6 +359,31 @@
|
||||
</dependency>
|
||||
<!-- bouncycastle end -->
|
||||
|
||||
<!-- tomcat start -->
|
||||
<dependency>
|
||||
<groupId>org.apache.tomcat.embed</groupId>
|
||||
<artifactId>tomcat-embed-core</artifactId>
|
||||
<version>${tomcat-embed.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.tomcat.embed</groupId>
|
||||
<artifactId>tomcat-embed-el</artifactId>
|
||||
<version>${tomcat-embed.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.tomcat.embed</groupId>
|
||||
<artifactId>tomcat-embed-websocket</artifactId>
|
||||
<version>${tomcat-embed.version}</version>
|
||||
</dependency>
|
||||
<!-- tomcat end -->
|
||||
|
||||
<!-- lombok start -->
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>${lombok.version}</version>
|
||||
</dependency>
|
||||
<!-- lombok end -->
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
|
23
service-department/pom.xml
Normal file
23
service-department/pom.xml
Normal file
@ -0,0 +1,23 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>wg-basic</artifactId>
|
||||
<groupId>ink.wgink</groupId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>service-department</artifactId>
|
||||
<description>组织机构业务</description>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>ink.wgink</groupId>
|
||||
<artifactId>service-user</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
@ -0,0 +1,205 @@
|
||||
package ink.wgink.service.department.controller.api;
|
||||
|
||||
import ink.wgink.annotation.CheckRequestBodyAnnotation;
|
||||
import ink.wgink.common.base.DefaultBaseController;
|
||||
import ink.wgink.exceptions.ParamsException;
|
||||
import ink.wgink.interfaces.consts.ISystemConstant;
|
||||
import ink.wgink.pojo.ListPage;
|
||||
import ink.wgink.pojo.dtos.ZTreeDTO;
|
||||
import ink.wgink.pojo.dtos.department.DepartmentDTO;
|
||||
import ink.wgink.pojo.result.*;
|
||||
import ink.wgink.service.department.pojo.vos.DepartmentVO;
|
||||
import ink.wgink.service.department.pojo.vos.MergeDepartmentInfoVO;
|
||||
import ink.wgink.service.department.pojo.vos.MergeNewDepartmentInfoVO;
|
||||
import ink.wgink.service.department.pojo.vos.SplitDepartmentVO;
|
||||
import ink.wgink.service.department.service.IDepartmentService;
|
||||
import io.swagger.annotations.*;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URLDecoder;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @ClassName: DepartmentController
|
||||
* @Description: 组织部门
|
||||
* @Author: wenc
|
||||
* @Date: 2019/1/8 7:23 PM
|
||||
* @Version: 1.0
|
||||
**/
|
||||
@Api(tags = ISystemConstant.API_TAGS_SYSTEM_PREFIX + "组织部门")
|
||||
@RestController
|
||||
@RequestMapping(ISystemConstant.API_PREFIX + "/department")
|
||||
public class DepartmentController extends DefaultBaseController {
|
||||
|
||||
@Autowired
|
||||
private IDepartmentService departmentService;
|
||||
|
||||
@ApiOperation(value = "组织部门新增", notes = "组织部门新增接口")
|
||||
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
||||
@PostMapping("save")
|
||||
@CheckRequestBodyAnnotation
|
||||
public SuccessResult save(@RequestBody DepartmentVO departmentVO) throws Exception {
|
||||
departmentService.save(departmentVO);
|
||||
return new SuccessResult();
|
||||
}
|
||||
|
||||
@ApiOperation(value = "组织部门删除", notes = "组织部门删除接口")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "ids", value = "组织部门ID列表,用下划线分隔", paramType = "path", example = "1_2_3")
|
||||
})
|
||||
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
||||
@DeleteMapping("remove/{ids}")
|
||||
public SuccessResult remove(@PathVariable("ids") String ids) {
|
||||
departmentService.remove(Arrays.asList(ids.split("\\_")));
|
||||
return new SuccessResult();
|
||||
}
|
||||
|
||||
@ApiOperation(value = "组织部门修改", notes = "组织部门修改接口")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "departmentId", value = "组织部门ID", paramType = "path")
|
||||
})
|
||||
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
||||
@PutMapping("update/{departmentId}")
|
||||
@CheckRequestBodyAnnotation
|
||||
public SuccessResult update(@PathVariable("departmentId") String departmentId,
|
||||
@RequestBody DepartmentVO departmentVO) {
|
||||
departmentService.update(departmentId, departmentVO);
|
||||
return new SuccessResult();
|
||||
}
|
||||
|
||||
@ApiOperation(value = "重置组织部门编码", notes = "重置组织部门编码接口")
|
||||
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
||||
@PutMapping("restcode")
|
||||
public SuccessResult resetCode() {
|
||||
departmentService.resetCode();
|
||||
return new SuccessResult();
|
||||
}
|
||||
|
||||
|
||||
@ApiOperation(value = "更新合并到新增组织", notes = "更新合并到新增组织接口")
|
||||
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
||||
@PutMapping("updatemergenew")
|
||||
@CheckRequestBodyAnnotation
|
||||
public SuccessResult updateMergeNew(@RequestBody MergeNewDepartmentInfoVO mergeNewDepartmentInfoVO) throws Exception {
|
||||
departmentService.updateMergeNew(mergeNewDepartmentInfoVO);
|
||||
return new SuccessResult();
|
||||
}
|
||||
|
||||
@ApiOperation(value = "更新合并到组织", notes = "更新合并到组织接口")
|
||||
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
||||
@PutMapping("updatemerge/{departmentId}")
|
||||
@CheckRequestBodyAnnotation
|
||||
public SuccessResult updateMerge(@PathVariable("departmentId") String departmentId, @RequestBody MergeDepartmentInfoVO mergeDepartmentInfoVO) {
|
||||
departmentService.updateMerge(departmentId, mergeDepartmentInfoVO);
|
||||
return new SuccessResult();
|
||||
}
|
||||
|
||||
@ApiOperation(value = "更新分割部门", notes = "更新分割部门接口")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "departmentId", value = "部门ID", paramType = "path"),
|
||||
})
|
||||
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
||||
@PutMapping("updatesplit/{departmentId}")
|
||||
@CheckRequestBodyAnnotation
|
||||
public SuccessResult updateSplit(@PathVariable("departmentId") String departmentId, @RequestBody SplitDepartmentVO splitDepartmentVO) {
|
||||
departmentService.updateSplit(departmentId, splitDepartmentVO);
|
||||
return new SuccessResult();
|
||||
}
|
||||
|
||||
@ApiOperation(value = "组织部门列表", notes = "组织部门列表接口")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "departmentParentId", value = "组织部门上级ID", paramType = "path")
|
||||
})
|
||||
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
||||
@GetMapping("list/{departmentParentId}")
|
||||
public List<DepartmentDTO> list(@PathVariable("departmentParentId") String departmentParentId) {
|
||||
Map<String, Object> params = new HashMap<>(0);
|
||||
params.put("departmentParentId", departmentParentId);
|
||||
return departmentService.listAll(params);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "zTree列表", notes = "zTree列表接口")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "id", value = "父ID", paramType = "query", dataType = "String")
|
||||
})
|
||||
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
||||
@GetMapping("listztree")
|
||||
public List<ZTreeDTO> listZTree() {
|
||||
Map<String, Object> params = requestParams();
|
||||
String departmentParentId = "0";
|
||||
if (!StringUtils.isBlank(params.get("id") == null ? null : params.get("id").toString())) {
|
||||
departmentParentId = params.get("id").toString();
|
||||
}
|
||||
return departmentService.listZTree(departmentParentId, params);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "组织部门详情", notes = "组织部门详情接口")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "departmentId", value = "部门ID", paramType = "path")
|
||||
})
|
||||
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
||||
@GetMapping("get/{departmentId}")
|
||||
public DepartmentDTO get(@PathVariable("departmentId") String departmentId) {
|
||||
return departmentService.get(departmentId);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "easyui组织部门列表", notes = "easyui组织部门列表列表接口")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "parentId", value = "上级ID", paramType = "query", dataType = "String"),
|
||||
@ApiImplicitParam(name = "page", value = "当前页码", paramType = "query", dataType = "int", defaultValue = "1"),
|
||||
@ApiImplicitParam(name = "rows", value = "显示数量", paramType = "query", dataType = "int", defaultValue = "20"),
|
||||
@ApiImplicitParam(name = "keywords", value = "关键字", paramType = "query", dataType = "String"),
|
||||
@ApiImplicitParam(name = "startTime", value = "开始时间", paramType = "query", dataType = "String"),
|
||||
@ApiImplicitParam(name = "endTime", value = "结束时间", paramType = "query", dataType = "String")
|
||||
})
|
||||
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
||||
@GetMapping("listpagedepartment")
|
||||
public SuccessResultList<List<DepartmentDTO>> listPageDepartment(ListPage page) {
|
||||
Map<String, Object> params = requestParams();
|
||||
String departmentParentId = "0";
|
||||
if (!StringUtils.isBlank(params.get("parentId") == null ? null : params.get("parentId").toString())) {
|
||||
departmentParentId = params.get("parentId").toString();
|
||||
}
|
||||
page.setParams(params);
|
||||
return departmentService.listPageByParentId(departmentParentId, page);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "保存部门Excel(文件上传)", notes = "保存部门Excel接口(文件上传)")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "excel", value = "文件名称", paramType = "query"),
|
||||
})
|
||||
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
||||
@PostMapping("uploadexcel")
|
||||
public UploadExcelResultDTO uploadExcel(MultipartFile excel) {
|
||||
if (Objects.isNull(excel)) {
|
||||
throw new ParamsException("Excel不能为空");
|
||||
}
|
||||
if (!excel.getOriginalFilename().endsWith(".xls") && !excel.getOriginalFilename().endsWith(".xlsx")) {
|
||||
throw new ParamsException("文件格式为Excel");
|
||||
}
|
||||
return departmentService.uploadExcel(excel);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "获得同一级部门数量(按部门名称)", notes = "获得同一级部门数量(按部门名称)接口")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "departmentParentId", value = "上级部门ID", paramType = "path"),
|
||||
@ApiImplicitParam(name = "departmentName", value = "上级部门ID", paramType = "path"),
|
||||
@ApiImplicitParam(name = "noDepartmentId", value = "不统计的部门ID", paramType = "query"),
|
||||
})
|
||||
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
||||
@GetMapping("countbyparentidandname/{departmentParentId}/{departmentName}")
|
||||
public SuccessResultData<Integer> countByParentIdAndName(@PathVariable("departmentParentId") String departmentParentId,
|
||||
@PathVariable("departmentName") String departmentName,
|
||||
@RequestParam(name = "noDepartmentId", required = false) String noDepartmentId) throws UnsupportedEncodingException {
|
||||
Map<String, Object> params = getParams();
|
||||
params.put("departmentParentId", departmentParentId);
|
||||
params.put("departmentName", URLDecoder.decode(departmentName, "UTF-8"));
|
||||
params.put("noDepartmentId", noDepartmentId);
|
||||
return new SuccessResultData<>(departmentService.count(params));
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,167 @@
|
||||
package ink.wgink.service.department.dao;
|
||||
|
||||
import ink.wgink.exceptions.RemoveException;
|
||||
import ink.wgink.exceptions.SaveException;
|
||||
import ink.wgink.exceptions.SearchException;
|
||||
import ink.wgink.exceptions.UpdateException;
|
||||
import ink.wgink.pojo.dtos.ZTreeDTO;
|
||||
import ink.wgink.pojo.dtos.department.DepartmentDTO;
|
||||
import ink.wgink.pojo.dtos.department.DepartmentSimpleDTO;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* When you feel like quitting. Think about why you started
|
||||
* 当你想要放弃的时候,想想当初你为何开始
|
||||
*
|
||||
* @ClassName: IUserDao
|
||||
* @Description: 用户
|
||||
* @Author: WangGeng
|
||||
* @Date: 2021/1/24 20:23
|
||||
* @Version: 1.0
|
||||
**/
|
||||
@Repository
|
||||
public interface IDepartmentDao {
|
||||
|
||||
/**
|
||||
* 新增组织部门
|
||||
*
|
||||
* @param params
|
||||
* @throws SaveException
|
||||
*/
|
||||
void save(Map<String, Object> params) throws SaveException;
|
||||
|
||||
/**
|
||||
* 删除组织部门
|
||||
*
|
||||
* @param params
|
||||
* @throws RemoveException
|
||||
*/
|
||||
void remove(Map<String, Object> params) throws RemoveException;
|
||||
|
||||
/**
|
||||
* 更新组织部门
|
||||
*
|
||||
* @param params
|
||||
* @throws UpdateException
|
||||
*/
|
||||
void update(Map<String, Object> params) throws UpdateException;
|
||||
|
||||
/**
|
||||
* 组织部门编码更新
|
||||
*
|
||||
* @param params
|
||||
* @throws UpdateException
|
||||
*/
|
||||
void updateCode(Map<String, Object> params) throws UpdateException;
|
||||
|
||||
/**
|
||||
* 更新部门状态
|
||||
*
|
||||
* @param params
|
||||
* @throws UpdateException
|
||||
*/
|
||||
void updateState(Map<String, Object> params) throws UpdateException;
|
||||
|
||||
/**
|
||||
* 组织部门详情
|
||||
*
|
||||
* @param params
|
||||
* @return
|
||||
* @throws SearchException
|
||||
*/
|
||||
DepartmentDTO get(Map<String, Object> params) throws SearchException;
|
||||
|
||||
/**
|
||||
* 组织部门列表
|
||||
*
|
||||
* @param params
|
||||
* @return
|
||||
* @throws SearchException
|
||||
*/
|
||||
List<DepartmentDTO> list(Map<String, Object> params) throws SearchException;
|
||||
|
||||
/**
|
||||
* 统计部门数量
|
||||
*
|
||||
* @param params
|
||||
* @return
|
||||
* @throws SearchException
|
||||
*/
|
||||
Integer count(Map<String, Object> params) throws SearchException;
|
||||
|
||||
/**
|
||||
* 部门ID
|
||||
*
|
||||
* @param params
|
||||
* @return
|
||||
* @throws SearchException
|
||||
*/
|
||||
List<String> listId(Map<String, Object> params) throws SearchException;
|
||||
|
||||
/**
|
||||
* zTree组织部门列表
|
||||
*
|
||||
* @param params
|
||||
* @return
|
||||
* @throws SearchException
|
||||
*/
|
||||
List<ZTreeDTO> listZTree(Map<String, Object> params) throws SearchException;
|
||||
|
||||
/**
|
||||
* zTree组织部门详情
|
||||
*
|
||||
* @param params
|
||||
* @return
|
||||
* @throws SearchException
|
||||
*/
|
||||
ZTreeDTO getZTree(Map<String, Object> params) throws SearchException;
|
||||
|
||||
/**
|
||||
* 组织部门通过ID统计
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
* @throws SearchException
|
||||
*/
|
||||
Integer countByParentId(String id) throws SearchException;
|
||||
|
||||
/**
|
||||
* 最后一个子组织部门
|
||||
*
|
||||
* @param parentId
|
||||
* @return
|
||||
* @throws SearchException
|
||||
*/
|
||||
DepartmentDTO getLastByParentId(String parentId) throws SearchException;
|
||||
|
||||
/**
|
||||
* 获取组织机构通过名称和上级名称
|
||||
*
|
||||
* @param params
|
||||
* @return
|
||||
* @throws SearchException
|
||||
*/
|
||||
DepartmentDTO getByNameAndParentName(Map<String, Object> params) throws SearchException;
|
||||
|
||||
/**
|
||||
* 获取组织机构详情(简单类型)
|
||||
*
|
||||
* @param params
|
||||
* @return
|
||||
* @throws SearchException
|
||||
*/
|
||||
DepartmentSimpleDTO getSimple(Map<String, Object> params) throws SearchException;
|
||||
|
||||
/**
|
||||
* 获取组织机构列表(简单类型)
|
||||
*
|
||||
* @param params
|
||||
* @return
|
||||
* @throws SearchException
|
||||
*/
|
||||
List<DepartmentSimpleDTO> listSimple(Map<String, Object> params) throws SearchException;
|
||||
|
||||
}
|
@ -0,0 +1,96 @@
|
||||
package ink.wgink.service.department.listener.excel;
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
|
||||
/**
|
||||
* When you feel like quitting. Think about why you started
|
||||
* 当你想要放弃的时候,想想当初你为何开始
|
||||
*
|
||||
* @ClassName: DepartmentExcel
|
||||
* @Description: 部门
|
||||
* @Author: WangGeng
|
||||
* @Date: 2020/4/8 15:12
|
||||
* @Version: 1.0
|
||||
**/
|
||||
public class DepartmentExcel {
|
||||
|
||||
@ExcelProperty(index = 0)
|
||||
private Integer departmentId;
|
||||
@ExcelProperty(index = 1)
|
||||
private String departmentName;
|
||||
@ExcelProperty(index = 2)
|
||||
private Integer departmentParentId;
|
||||
@ExcelProperty(index = 3)
|
||||
private String departmentSummary;
|
||||
@ExcelProperty(index = 4)
|
||||
private String departmentTel;
|
||||
@ExcelProperty(index = 5)
|
||||
private Integer departmentType;
|
||||
|
||||
public Integer getDepartmentId() {
|
||||
return departmentId;
|
||||
}
|
||||
|
||||
public void setDepartmentId(Integer departmentId) {
|
||||
this.departmentId = departmentId;
|
||||
}
|
||||
|
||||
public String getDepartmentName() {
|
||||
return departmentName == null ? "" : departmentName.trim();
|
||||
}
|
||||
|
||||
public void setDepartmentName(String departmentName) {
|
||||
this.departmentName = departmentName;
|
||||
}
|
||||
|
||||
public Integer getDepartmentParentId() {
|
||||
return departmentParentId;
|
||||
}
|
||||
|
||||
public void setDepartmentParentId(Integer departmentParentId) {
|
||||
this.departmentParentId = departmentParentId;
|
||||
}
|
||||
|
||||
public String getDepartmentSummary() {
|
||||
return departmentSummary == null ? "" : departmentSummary.trim();
|
||||
}
|
||||
|
||||
public void setDepartmentSummary(String departmentSummary) {
|
||||
this.departmentSummary = departmentSummary;
|
||||
}
|
||||
|
||||
public String getDepartmentTel() {
|
||||
return departmentTel == null ? "" : departmentTel.trim();
|
||||
}
|
||||
|
||||
public void setDepartmentTel(String departmentTel) {
|
||||
this.departmentTel = departmentTel;
|
||||
}
|
||||
|
||||
public Integer getDepartmentType() {
|
||||
return departmentType;
|
||||
}
|
||||
|
||||
public void setDepartmentType(Integer departmentType) {
|
||||
this.departmentType = departmentType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
final StringBuilder sb = new StringBuilder("{");
|
||||
sb.append("\"departmentId\":")
|
||||
.append(departmentId);
|
||||
sb.append(",\"departmentName\":")
|
||||
.append("\"").append(departmentName).append("\"");
|
||||
sb.append(",\"departmentParentId\":")
|
||||
.append(departmentParentId);
|
||||
sb.append(",\"departmentSummary\":")
|
||||
.append("\"").append(departmentSummary).append("\"");
|
||||
sb.append(",\"departmentTel\":")
|
||||
.append("\"").append(departmentTel).append("\"");
|
||||
sb.append(",\"departmentType\":")
|
||||
.append(departmentType);
|
||||
sb.append('}');
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
@ -0,0 +1,108 @@
|
||||
package ink.wgink.service.department.listener.excel;
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
|
||||
/**
|
||||
* When you feel like quitting. Think about why you started
|
||||
* 当你想要放弃的时候,想想当初你为何开始
|
||||
*
|
||||
* @ClassName: DepartmentExcelError
|
||||
* @Description: 部门Excel错误
|
||||
* @Author: WangGeng
|
||||
* @Date: 2020/4/8 15:13
|
||||
* @Version: 1.0
|
||||
**/
|
||||
public class DepartmentExcelError {
|
||||
|
||||
@ExcelProperty(index = 0)
|
||||
private Integer departmentId;
|
||||
@ExcelProperty(index = 1)
|
||||
private String departmentName;
|
||||
@ExcelProperty(index = 2)
|
||||
private Integer departmentParentId;
|
||||
@ExcelProperty(index = 3)
|
||||
private String departmentSummary;
|
||||
@ExcelProperty(index = 4)
|
||||
private String departmentTel;
|
||||
@ExcelProperty(index = 5)
|
||||
private Integer departmentType;
|
||||
@ExcelProperty(index = 6)
|
||||
private String reason;
|
||||
|
||||
public Integer getDepartmentId() {
|
||||
return departmentId;
|
||||
}
|
||||
|
||||
public void setDepartmentId(Integer departmentId) {
|
||||
this.departmentId = departmentId;
|
||||
}
|
||||
|
||||
public String getDepartmentName() {
|
||||
return departmentName == null ? "" : departmentName.trim();
|
||||
}
|
||||
|
||||
public void setDepartmentName(String departmentName) {
|
||||
this.departmentName = departmentName;
|
||||
}
|
||||
|
||||
public Integer getDepartmentParentId() {
|
||||
return departmentParentId;
|
||||
}
|
||||
|
||||
public void setDepartmentParentId(Integer departmentParentId) {
|
||||
this.departmentParentId = departmentParentId;
|
||||
}
|
||||
|
||||
public String getDepartmentSummary() {
|
||||
return departmentSummary == null ? "" : departmentSummary.trim();
|
||||
}
|
||||
|
||||
public void setDepartmentSummary(String departmentSummary) {
|
||||
this.departmentSummary = departmentSummary;
|
||||
}
|
||||
|
||||
public String getDepartmentTel() {
|
||||
return departmentTel == null ? "" : departmentTel.trim();
|
||||
}
|
||||
|
||||
public void setDepartmentTel(String departmentTel) {
|
||||
this.departmentTel = departmentTel;
|
||||
}
|
||||
|
||||
public Integer getDepartmentType() {
|
||||
return departmentType;
|
||||
}
|
||||
|
||||
public void setDepartmentType(Integer departmentType) {
|
||||
this.departmentType = departmentType;
|
||||
}
|
||||
|
||||
public String getReason() {
|
||||
return reason == null ? "" : reason.trim();
|
||||
}
|
||||
|
||||
public void setReason(String reason) {
|
||||
this.reason = reason;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
final StringBuilder sb = new StringBuilder("{");
|
||||
sb.append("\"departmentId\":")
|
||||
.append(departmentId);
|
||||
sb.append(",\"departmentName\":")
|
||||
.append("\"").append(departmentName).append("\"");
|
||||
sb.append(",\"departmentParentId\":")
|
||||
.append(departmentParentId);
|
||||
sb.append(",\"departmentSummary\":")
|
||||
.append("\"").append(departmentSummary).append("\"");
|
||||
sb.append(",\"departmentType\":")
|
||||
.append(departmentType);
|
||||
sb.append(",\"departmentTel\":")
|
||||
.append("\"").append(departmentTel).append("\"");
|
||||
sb.append(",\"reason\":")
|
||||
.append("\"").append(reason).append("\"");
|
||||
sb.append('}');
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
@ -0,0 +1,42 @@
|
||||
package ink.wgink.service.department.listener.excel;
|
||||
|
||||
import com.alibaba.excel.context.AnalysisContext;
|
||||
import com.alibaba.excel.event.AnalysisEventListener;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* When you feel like quitting. Think about why you started
|
||||
* 当你想要放弃的时候,想想当初你为何开始
|
||||
*
|
||||
* @ClassName: DepartmentExcelListener
|
||||
* @Description: 部门Excel监听
|
||||
* @Author: WangGeng
|
||||
* @Date: 2020/4/8 15:13
|
||||
* @Version: 1.0
|
||||
**/
|
||||
public abstract class DepartmentExcelListener extends AnalysisEventListener<DepartmentExcel> {
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(DepartmentExcelListener.class);
|
||||
private List<DepartmentExcel> departmentExcels = new ArrayList<>(0);
|
||||
|
||||
@Override
|
||||
public void invoke(DepartmentExcel departmentExcel, AnalysisContext analysisContext) {
|
||||
departmentExcels.add(departmentExcel);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doAfterAllAnalysed(AnalysisContext analysisContext) {
|
||||
try {
|
||||
listDepartmentExcel(departmentExcels);
|
||||
} catch (Exception e) {
|
||||
LOG.error(e.getMessage());
|
||||
}
|
||||
departmentExcels.clear();
|
||||
}
|
||||
|
||||
public abstract void listDepartmentExcel(List<DepartmentExcel> departmentExcels) throws Exception;
|
||||
}
|
@ -0,0 +1,270 @@
|
||||
package ink.wgink.service.department.pojo.vos;
|
||||
|
||||
import ink.wgink.annotation.CheckEmptyAnnotation;
|
||||
import ink.wgink.annotation.CheckNumberAnnotation;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
/**
|
||||
* @ClassName: DepartmentVO
|
||||
* @Description: 组织部门视图
|
||||
* @Author: WangGeng
|
||||
* @Date: 2019/3/4 4:20 PM
|
||||
* @Version: 1.0
|
||||
**/
|
||||
@ApiModel
|
||||
public class DepartmentVO {
|
||||
|
||||
@ApiModelProperty(name = "departmentParentId", value = "组织部门上级ID")
|
||||
@CheckEmptyAnnotation(name = "组织部门上级ID")
|
||||
private String departmentParentId;
|
||||
@ApiModelProperty(name = "departmentName", value = "组织部门名称")
|
||||
@CheckEmptyAnnotation(name = "组织部门名称")
|
||||
private String departmentName;
|
||||
@ApiModelProperty(name = "departmentNameEn", value = "组织部门名称(英文)")
|
||||
private String departmentNameEn;
|
||||
@ApiModelProperty(name = "departmentNameOther", value = "组织部门名称(其他类型)")
|
||||
private String departmentNameOther;
|
||||
@ApiModelProperty(name = "departmentType", value = "组织部门类型,1:机构,2:部门")
|
||||
@CheckNumberAnnotation(name = "组织部门类型", types = {"1", "2"})
|
||||
private Integer departmentType;
|
||||
@ApiModelProperty(name = "departmentState", value = "组织部门状态,1:正常,2:异常,3:停用")
|
||||
@CheckNumberAnnotation(name = "组织部门状态", types = {"1", "2", "3"})
|
||||
private Integer departmentState;
|
||||
@ApiModelProperty(name = "departmentSummary", value = "组织部门说明")
|
||||
private String departmentSummary;
|
||||
@ApiModelProperty(name = "departmentFax", value = "组织部门传真")
|
||||
private String departmentFax;
|
||||
@ApiModelProperty(name = "departmentTel", value = "组织部门电话")
|
||||
private String departmentTel;
|
||||
@ApiModelProperty(name = "departmentAddress", value = "组织部门地址")
|
||||
private String departmentAddress;
|
||||
@ApiModelProperty(name = "departmentMaster", value = "组织部门负责人")
|
||||
private String departmentMaster;
|
||||
@ApiModelProperty(name = "departmentDuty", value = "组织部门职责")
|
||||
private String departmentDuty;
|
||||
@ApiModelProperty(name = "departmentArea1Id", value = "1级区域ID")
|
||||
private Integer departmentArea1Id;
|
||||
@ApiModelProperty(name = "departmentArea2Id", value = "2级区域ID")
|
||||
private Integer departmentArea2Id;
|
||||
@ApiModelProperty(name = "departmentArea3Id", value = "3级区域ID")
|
||||
private Integer departmentArea3Id;
|
||||
@ApiModelProperty(name = "departmentArea4Id", value = "4级区域ID")
|
||||
private Integer departmentArea4Id;
|
||||
@ApiModelProperty(name = "departmentArea5Id", value = "5级区域ID")
|
||||
private Integer departmentArea5Id;
|
||||
@ApiModelProperty(name = "departmentLongitude", value = "组织部门经度")
|
||||
private String departmentLongitude;
|
||||
@ApiModelProperty(name = "departmentLatitude", value = "组织部门纬度")
|
||||
private String departmentLatitude;
|
||||
@ApiModelProperty(name = "departmentOrder", value = "组织部门排序,默认0")
|
||||
@CheckNumberAnnotation(name = "组织部门排序")
|
||||
private Integer departmentOrder;
|
||||
|
||||
public String getDepartmentParentId() {
|
||||
return departmentParentId == null ? "" : departmentParentId.trim();
|
||||
}
|
||||
|
||||
public void setDepartmentParentId(String departmentParentId) {
|
||||
this.departmentParentId = departmentParentId;
|
||||
}
|
||||
|
||||
public String getDepartmentName() {
|
||||
return departmentName == null ? "" : departmentName.trim();
|
||||
}
|
||||
|
||||
public void setDepartmentName(String departmentName) {
|
||||
this.departmentName = departmentName;
|
||||
}
|
||||
|
||||
public String getDepartmentNameEn() {
|
||||
return departmentNameEn == null ? "" : departmentNameEn.trim();
|
||||
}
|
||||
|
||||
public void setDepartmentNameEn(String departmentNameEn) {
|
||||
this.departmentNameEn = departmentNameEn;
|
||||
}
|
||||
|
||||
public String getDepartmentNameOther() {
|
||||
return departmentNameOther == null ? "" : departmentNameOther.trim();
|
||||
}
|
||||
|
||||
public void setDepartmentNameOther(String departmentNameOther) {
|
||||
this.departmentNameOther = departmentNameOther;
|
||||
}
|
||||
|
||||
public Integer getDepartmentType() {
|
||||
return departmentType;
|
||||
}
|
||||
|
||||
public void setDepartmentType(Integer departmentType) {
|
||||
this.departmentType = departmentType;
|
||||
}
|
||||
|
||||
public Integer getDepartmentState() {
|
||||
return departmentState;
|
||||
}
|
||||
|
||||
public void setDepartmentState(Integer departmentState) {
|
||||
this.departmentState = departmentState;
|
||||
}
|
||||
|
||||
public String getDepartmentSummary() {
|
||||
return departmentSummary == null ? "" : departmentSummary.trim();
|
||||
}
|
||||
|
||||
public void setDepartmentSummary(String departmentSummary) {
|
||||
this.departmentSummary = departmentSummary;
|
||||
}
|
||||
|
||||
public String getDepartmentFax() {
|
||||
return departmentFax == null ? "" : departmentFax.trim();
|
||||
}
|
||||
|
||||
public void setDepartmentFax(String departmentFax) {
|
||||
this.departmentFax = departmentFax;
|
||||
}
|
||||
|
||||
public String getDepartmentTel() {
|
||||
return departmentTel == null ? "" : departmentTel.trim();
|
||||
}
|
||||
|
||||
public void setDepartmentTel(String departmentTel) {
|
||||
this.departmentTel = departmentTel;
|
||||
}
|
||||
|
||||
public String getDepartmentAddress() {
|
||||
return departmentAddress == null ? "" : departmentAddress.trim();
|
||||
}
|
||||
|
||||
public void setDepartmentAddress(String departmentAddress) {
|
||||
this.departmentAddress = departmentAddress;
|
||||
}
|
||||
|
||||
public String getDepartmentMaster() {
|
||||
return departmentMaster == null ? "" : departmentMaster.trim();
|
||||
}
|
||||
|
||||
public void setDepartmentMaster(String departmentMaster) {
|
||||
this.departmentMaster = departmentMaster;
|
||||
}
|
||||
|
||||
public String getDepartmentDuty() {
|
||||
return departmentDuty == null ? "" : departmentDuty.trim();
|
||||
}
|
||||
|
||||
public void setDepartmentDuty(String departmentDuty) {
|
||||
this.departmentDuty = departmentDuty;
|
||||
}
|
||||
|
||||
public Integer getDepartmentArea1Id() {
|
||||
return departmentArea1Id;
|
||||
}
|
||||
|
||||
public void setDepartmentArea1Id(Integer departmentArea1Id) {
|
||||
this.departmentArea1Id = departmentArea1Id;
|
||||
}
|
||||
|
||||
public Integer getDepartmentArea2Id() {
|
||||
return departmentArea2Id;
|
||||
}
|
||||
|
||||
public void setDepartmentArea2Id(Integer departmentArea2Id) {
|
||||
this.departmentArea2Id = departmentArea2Id;
|
||||
}
|
||||
|
||||
public Integer getDepartmentArea3Id() {
|
||||
return departmentArea3Id;
|
||||
}
|
||||
|
||||
public void setDepartmentArea3Id(Integer departmentArea3Id) {
|
||||
this.departmentArea3Id = departmentArea3Id;
|
||||
}
|
||||
|
||||
public Integer getDepartmentArea4Id() {
|
||||
return departmentArea4Id;
|
||||
}
|
||||
|
||||
public void setDepartmentArea4Id(Integer departmentArea4Id) {
|
||||
this.departmentArea4Id = departmentArea4Id;
|
||||
}
|
||||
|
||||
public Integer getDepartmentArea5Id() {
|
||||
return departmentArea5Id;
|
||||
}
|
||||
|
||||
public void setDepartmentArea5Id(Integer departmentArea5Id) {
|
||||
this.departmentArea5Id = departmentArea5Id;
|
||||
}
|
||||
|
||||
public String getDepartmentLongitude() {
|
||||
return departmentLongitude == null ? "" : departmentLongitude.trim();
|
||||
}
|
||||
|
||||
public void setDepartmentLongitude(String departmentLongitude) {
|
||||
this.departmentLongitude = departmentLongitude;
|
||||
}
|
||||
|
||||
public String getDepartmentLatitude() {
|
||||
return departmentLatitude == null ? "" : departmentLatitude.trim();
|
||||
}
|
||||
|
||||
public void setDepartmentLatitude(String departmentLatitude) {
|
||||
this.departmentLatitude = departmentLatitude;
|
||||
}
|
||||
|
||||
public Integer getDepartmentOrder() {
|
||||
return departmentOrder;
|
||||
}
|
||||
|
||||
public void setDepartmentOrder(Integer departmentOrder) {
|
||||
this.departmentOrder = departmentOrder;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
final StringBuilder sb = new StringBuilder("{");
|
||||
sb.append("\"departmentParentId\":\"")
|
||||
.append(departmentParentId).append('\"');
|
||||
sb.append(",\"departmentName\":\"")
|
||||
.append(departmentName).append('\"');
|
||||
sb.append(",\"departmentNameEn\":\"")
|
||||
.append(departmentNameEn).append('\"');
|
||||
sb.append(",\"departmentNameOther\":\"")
|
||||
.append(departmentNameOther).append('\"');
|
||||
sb.append(",\"departmentType\":")
|
||||
.append(departmentType);
|
||||
sb.append(",\"departmentState\":")
|
||||
.append(departmentState);
|
||||
sb.append(",\"departmentSummary\":\"")
|
||||
.append(departmentSummary).append('\"');
|
||||
sb.append(",\"departmentFax\":\"")
|
||||
.append(departmentFax).append('\"');
|
||||
sb.append(",\"departmentTel\":\"")
|
||||
.append(departmentTel).append('\"');
|
||||
sb.append(",\"departmentAddress\":\"")
|
||||
.append(departmentAddress).append('\"');
|
||||
sb.append(",\"departmentMaster\":\"")
|
||||
.append(departmentMaster).append('\"');
|
||||
sb.append(",\"departmentDuty\":\"")
|
||||
.append(departmentDuty).append('\"');
|
||||
sb.append(",\"departmentArea1Id\":\"")
|
||||
.append(departmentArea1Id).append('\"');
|
||||
sb.append(",\"departmentArea2Id\":\"")
|
||||
.append(departmentArea2Id).append('\"');
|
||||
sb.append(",\"departmentArea3Id\":\"")
|
||||
.append(departmentArea3Id).append('\"');
|
||||
sb.append(",\"departmentArea4Id\":\"")
|
||||
.append(departmentArea4Id).append('\"');
|
||||
sb.append(",\"departmentArea5Id\":\"")
|
||||
.append(departmentArea5Id).append('\"');
|
||||
sb.append(",\"departmentLongitude\":\"")
|
||||
.append(departmentLongitude).append('\"');
|
||||
sb.append(",\"departmentLatitude\":\"")
|
||||
.append(departmentLatitude).append('\"');
|
||||
sb.append(",\"departmentOrder\":")
|
||||
.append(departmentOrder);
|
||||
sb.append('}');
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
package ink.wgink.service.department.pojo.vos;
|
||||
|
||||
import ink.wgink.annotation.CheckEmptyAnnotation;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
/**
|
||||
* When you feel like quitting. Think about why you started
|
||||
* 当你想要放弃的时候,想想当初你为何开始
|
||||
*
|
||||
* @ClassName: MergeDepartmentInfoVO
|
||||
* @Description: 合并组织
|
||||
* @Author: WangGeng
|
||||
* @Date: 2020/6/5 15:25
|
||||
* @Version: 1.0
|
||||
**/
|
||||
@ApiModel
|
||||
public class MergeDepartmentInfoVO {
|
||||
|
||||
@ApiModelProperty(name = "mergeDepartmentIds", value = "合并组织ID列表")
|
||||
@CheckEmptyAnnotation(name = "合并组织ID列表")
|
||||
private String mergeDepartmentIds;
|
||||
|
||||
public String getMergeDepartmentIds() {
|
||||
return mergeDepartmentIds == null ? "" : mergeDepartmentIds.trim();
|
||||
}
|
||||
|
||||
public void setMergeDepartmentIds(String mergeDepartmentIds) {
|
||||
this.mergeDepartmentIds = mergeDepartmentIds;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
final StringBuilder sb = new StringBuilder("{");
|
||||
sb.append("\"mergeDepartmentIds\":\"")
|
||||
.append(mergeDepartmentIds).append('\"');
|
||||
sb.append('}');
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
package ink.wgink.service.department.pojo.vos;
|
||||
|
||||
import ink.wgink.annotation.CheckEmptyAnnotation;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
/**
|
||||
* When you feel like quitting. Think about why you started
|
||||
* 当你想要放弃的时候,想想当初你为何开始
|
||||
*
|
||||
* @ClassName: MergeNewDepartmentInfoVO
|
||||
* @Description: 新增合并组织
|
||||
* @Author: WangGeng
|
||||
* @Date: 2020/6/5 15:23
|
||||
* @Version: 1.0
|
||||
**/
|
||||
@ApiModel
|
||||
public class MergeNewDepartmentInfoVO extends DepartmentVO {
|
||||
|
||||
@ApiModelProperty(name = "mergeDepartmentIds", value = "合并组织ID列表")
|
||||
@CheckEmptyAnnotation(name = "合并组织ID列表")
|
||||
private String mergeDepartmentIds;
|
||||
|
||||
public String getMergeDepartmentIds() {
|
||||
return mergeDepartmentIds == null ? "" : mergeDepartmentIds.trim();
|
||||
}
|
||||
|
||||
public void setMergeDepartmentIds(String mergeDepartmentIds) {
|
||||
this.mergeDepartmentIds = mergeDepartmentIds;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
final StringBuilder sb = new StringBuilder("{");
|
||||
sb.append("\"mergeDepartmentIds\":\"")
|
||||
.append(mergeDepartmentIds).append('\"');
|
||||
sb.append('}');
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
package ink.wgink.service.department.pojo.vos;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
/**
|
||||
* When you feel like quitting. Think about why you started
|
||||
* 当你想要放弃的时候,想想当初你为何开始
|
||||
*
|
||||
* @ClassName: SplitDepartmentInfoVO
|
||||
* @Description: 拆分部门信息
|
||||
* @Author: WangGeng
|
||||
* @Date: 2020/6/4 11:52 下午
|
||||
* @Version: 1.0
|
||||
**/
|
||||
@ApiModel
|
||||
public class SplitDepartmentInfoVO extends DepartmentVO {
|
||||
|
||||
@ApiModelProperty(name = "userIds", value = "用户ID列表")
|
||||
private String userIds;
|
||||
|
||||
public String getUserIds() {
|
||||
return userIds == null ? "" : userIds.trim();
|
||||
}
|
||||
|
||||
public void setUserIds(String userIds) {
|
||||
this.userIds = userIds;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
final StringBuilder sb = new StringBuilder("{");
|
||||
sb.append("\"userIds\":")
|
||||
.append("\"").append(userIds).append("\"");
|
||||
sb.append('}');
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
package ink.wgink.service.department.pojo.vos;
|
||||
|
||||
import ink.wgink.annotation.CheckListAnnotation;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* When you feel like quitting. Think about why you started
|
||||
* 当你想要放弃的时候,想想当初你为何开始
|
||||
*
|
||||
* @ClassName: SplitDepartmentVO
|
||||
* @Description: 拆分机构部门
|
||||
* @Author: WangGeng
|
||||
* @Date: 2020/6/4 11:19 下午
|
||||
* @Version: 1.0
|
||||
**/
|
||||
@ApiModel
|
||||
public class SplitDepartmentVO {
|
||||
|
||||
@ApiModelProperty(name = "splitDepartments", value = "拆分的部门列表")
|
||||
@CheckListAnnotation(name = "拆分的部门列表")
|
||||
private List<SplitDepartmentInfoVO> splitDepartments;
|
||||
|
||||
public List<SplitDepartmentInfoVO> getSplitDepartments() {
|
||||
return splitDepartments;
|
||||
}
|
||||
|
||||
public void setSplitDepartments(List<SplitDepartmentInfoVO> splitDepartments) {
|
||||
this.splitDepartments = splitDepartments;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
final StringBuilder sb = new StringBuilder("{");
|
||||
sb.append("\"splitDepartments\":")
|
||||
.append(splitDepartments);
|
||||
sb.append('}');
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
@ -0,0 +1,223 @@
|
||||
package ink.wgink.service.department.service;
|
||||
|
||||
import ink.wgink.interfaces.department.IDepartmentBaseService;
|
||||
import ink.wgink.pojo.ListPage;
|
||||
import ink.wgink.pojo.bos.DepartmentBO;
|
||||
import ink.wgink.pojo.dtos.ZTreeDTO;
|
||||
import ink.wgink.pojo.dtos.department.DepartmentDTO;
|
||||
import ink.wgink.pojo.dtos.department.DepartmentSimpleDTO;
|
||||
import ink.wgink.pojo.result.SuccessResultList;
|
||||
import ink.wgink.pojo.result.UploadExcelResultDTO;
|
||||
import ink.wgink.service.department.pojo.vos.DepartmentVO;
|
||||
import ink.wgink.service.department.pojo.vos.MergeDepartmentInfoVO;
|
||||
import ink.wgink.service.department.pojo.vos.MergeNewDepartmentInfoVO;
|
||||
import ink.wgink.service.department.pojo.vos.SplitDepartmentVO;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* When you feel like quitting. Think about why you started
|
||||
* 当你想要放弃的时候,想想当初你为何开始
|
||||
*
|
||||
* @ClassName: IDepartmentService
|
||||
* @Description: 组织部门
|
||||
* @Author: wanggeng
|
||||
* @Date: 2021/1/27 11:27 上午
|
||||
* @Version: 1.0
|
||||
*/
|
||||
public interface IDepartmentService extends IDepartmentBaseService {
|
||||
|
||||
/**
|
||||
* 新增组织部门
|
||||
*
|
||||
* @param departmentVO
|
||||
* @return
|
||||
*/
|
||||
void save(DepartmentVO departmentVO);
|
||||
|
||||
/**
|
||||
* 保存部门返回ID
|
||||
*
|
||||
* @param departmentVO
|
||||
* @return
|
||||
*/
|
||||
String saveReturnId(DepartmentVO departmentVO);
|
||||
|
||||
/**
|
||||
* 删除组织部门
|
||||
*
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
void remove(List<String> ids);
|
||||
|
||||
/**
|
||||
* 修改组织部门
|
||||
*
|
||||
* @param departmentId
|
||||
* @param departmentVO
|
||||
* @return
|
||||
*/
|
||||
void update(String departmentId, DepartmentVO departmentVO);
|
||||
|
||||
/**
|
||||
* 更新合并到新增组织
|
||||
*
|
||||
* @param mergeNewDepartmentInfoVO
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
void updateMergeNew(MergeNewDepartmentInfoVO mergeNewDepartmentInfoVO);
|
||||
|
||||
/**
|
||||
* 更新合并到组织
|
||||
*
|
||||
* @param departmentId
|
||||
* @param mergeDepartmentInfoVO
|
||||
* @return
|
||||
*/
|
||||
void updateMerge(String departmentId, MergeDepartmentInfoVO mergeDepartmentInfoVO);
|
||||
|
||||
/**
|
||||
* 更新分割部门
|
||||
*
|
||||
* @param departmentId
|
||||
* @param splitDepartmentVO
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
void updateSplit(String departmentId, SplitDepartmentVO splitDepartmentVO);
|
||||
|
||||
/**
|
||||
* 重置组织部门编码
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
void resetCode();
|
||||
|
||||
/**
|
||||
* 部门列表
|
||||
*
|
||||
* @param params
|
||||
* @return
|
||||
*/
|
||||
List<DepartmentDTO> list(Map<String, Object> params);
|
||||
|
||||
/**
|
||||
* 通过ID获取组织部门详情
|
||||
*
|
||||
* @param departmentId
|
||||
* @return
|
||||
*/
|
||||
DepartmentDTO get(String departmentId);
|
||||
|
||||
/**
|
||||
* easyui组织部门
|
||||
*
|
||||
* @param page
|
||||
* @return
|
||||
*/
|
||||
SuccessResultList<List<DepartmentDTO>> listPage(ListPage page);
|
||||
|
||||
/**
|
||||
* easyui组织部门列表
|
||||
*
|
||||
* @param departmentParentId
|
||||
* @param page
|
||||
* @return
|
||||
*/
|
||||
SuccessResultList<List<DepartmentDTO>> listPageByParentId(String departmentParentId, ListPage page);
|
||||
|
||||
/**
|
||||
* 组织部门列表,递归获取全部内容
|
||||
*
|
||||
* @param params
|
||||
* @return
|
||||
*/
|
||||
List<DepartmentDTO> listAll(Map<String, Object> params);
|
||||
|
||||
/**
|
||||
* zTree组织部门
|
||||
*
|
||||
* @param params
|
||||
* @return
|
||||
*/
|
||||
List<ZTreeDTO> listZTree(Map<String, Object> params);
|
||||
|
||||
/**
|
||||
* zTree组织部门
|
||||
*
|
||||
* @param departmentParentId
|
||||
* @param params
|
||||
* @return
|
||||
*/
|
||||
List<ZTreeDTO> listZTree(String departmentParentId, Map<String, Object> params);
|
||||
|
||||
/**
|
||||
* 部门ID列表
|
||||
*
|
||||
* @param params
|
||||
* @return
|
||||
*/
|
||||
List<String> listId(Map<String, Object> params);
|
||||
|
||||
/**
|
||||
* 获取基础部门ID列表
|
||||
*
|
||||
* @param departmentBOs
|
||||
* @return
|
||||
*/
|
||||
List<String> listId(List<DepartmentBO> departmentBOs);
|
||||
|
||||
/**
|
||||
* 获取上级部门
|
||||
*
|
||||
* @param departmentBO1
|
||||
* @param departmentBO2
|
||||
* @return
|
||||
*/
|
||||
DepartmentBO getHigherLevel(DepartmentBO departmentBO1, DepartmentBO departmentBO2);
|
||||
|
||||
/**
|
||||
* 保存部门Excel
|
||||
*
|
||||
* @param excel
|
||||
* @return
|
||||
*/
|
||||
UploadExcelResultDTO uploadExcel(MultipartFile excel);
|
||||
|
||||
/**
|
||||
* 获得同一级部门数量(按部门名称)
|
||||
*
|
||||
* @param params
|
||||
* @return
|
||||
*/
|
||||
Integer count(Map<String, Object> params);
|
||||
|
||||
/**
|
||||
* 通过ID获取组织部门详情(简单格式)
|
||||
*
|
||||
* @param departmentId
|
||||
* @return
|
||||
*/
|
||||
DepartmentSimpleDTO getSimpleById(String departmentId);
|
||||
|
||||
/**
|
||||
* 部门列表
|
||||
*
|
||||
* @param params
|
||||
* @return
|
||||
*/
|
||||
List<DepartmentSimpleDTO> listSimple(Map<String, Object> params);
|
||||
|
||||
/**
|
||||
* 通过上级ID获取组织部门全部列表(简单格式)
|
||||
*
|
||||
* @param departmentParentId
|
||||
* @return
|
||||
*/
|
||||
List<DepartmentSimpleDTO> listSimpleByParentId(String departmentParentId);
|
||||
|
||||
}
|
@ -0,0 +1,451 @@
|
||||
package ink.wgink.service.department.service.impl;
|
||||
|
||||
import com.alibaba.excel.EasyExcel;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import ink.wgink.common.base.DefaultBaseService;
|
||||
import ink.wgink.exceptions.SaveException;
|
||||
import ink.wgink.exceptions.SearchException;
|
||||
import ink.wgink.interfaces.consts.ISystemConstant;
|
||||
import ink.wgink.pojo.ListPage;
|
||||
import ink.wgink.pojo.bos.DepartmentBO;
|
||||
import ink.wgink.pojo.dtos.ZTreeDTO;
|
||||
import ink.wgink.pojo.dtos.department.DepartmentDTO;
|
||||
import ink.wgink.pojo.dtos.department.DepartmentSimpleDTO;
|
||||
import ink.wgink.pojo.result.SuccessResultList;
|
||||
import ink.wgink.pojo.result.UploadExcelResultDTO;
|
||||
import ink.wgink.service.department.dao.IDepartmentDao;
|
||||
import ink.wgink.service.department.listener.excel.DepartmentExcel;
|
||||
import ink.wgink.service.department.listener.excel.DepartmentExcelError;
|
||||
import ink.wgink.service.department.listener.excel.DepartmentExcelListener;
|
||||
import ink.wgink.service.department.pojo.vos.DepartmentVO;
|
||||
import ink.wgink.service.department.pojo.vos.MergeDepartmentInfoVO;
|
||||
import ink.wgink.service.department.pojo.vos.MergeNewDepartmentInfoVO;
|
||||
import ink.wgink.service.department.pojo.vos.SplitDepartmentVO;
|
||||
import ink.wgink.service.department.service.IDepartmentService;
|
||||
import ink.wgink.util.UUIDUtil;
|
||||
import ink.wgink.util.map.HashMapUtil;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* When you feel like quitting. Think about why you started
|
||||
* 当你想要放弃的时候,想想当初你为何开始
|
||||
*
|
||||
* @ClassName: DepartmentServiceImpl
|
||||
* @Description: 组织部门
|
||||
* @Author: wanggeng
|
||||
* @Date: 2021/1/27 3:53 下午
|
||||
* @Version: 1.0
|
||||
*/
|
||||
@Service
|
||||
public class DepartmentServiceImpl extends DefaultBaseService implements IDepartmentService {
|
||||
|
||||
@Autowired
|
||||
private IDepartmentDao departmentDao;
|
||||
|
||||
@Override
|
||||
public void save(DepartmentVO departmentVO) {
|
||||
saveReturnId(departmentVO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String saveReturnId(DepartmentVO departmentVO) {
|
||||
String parentCode = null;
|
||||
String departmentParentId = departmentVO.getDepartmentParentId();
|
||||
if (!ISystemConstant.TREE_ROOT_ID.equals(departmentParentId)) {
|
||||
DepartmentDTO departmentDTO = get(departmentParentId);
|
||||
parentCode = departmentDTO.getDepartmentCode();
|
||||
} else {
|
||||
if (!isAdmin()) {
|
||||
throw new SaveException("非超级管理员无法在根节点添加组织");
|
||||
}
|
||||
}
|
||||
// 同级,同名组织不能添加
|
||||
if (isDepartmentExist(null, departmentVO.getDepartmentParentId(), departmentVO.getDepartmentName())) {
|
||||
throw new SaveException("同级组织名称不能相同");
|
||||
}
|
||||
String departmentId = UUIDUtil.getUUID();
|
||||
String departmentCode = getCode(parentCode, departmentParentId);
|
||||
Map<String, Object> params = HashMapUtil.beanToMap(departmentVO);
|
||||
setArea(departmentVO, params);
|
||||
params.put("departmentCode", departmentCode);
|
||||
params.put("departmentId", departmentId);
|
||||
setSaveInfo(params);
|
||||
departmentDao.save(params);
|
||||
return departmentId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove(List<String> ids) {
|
||||
// 清空组织所在人员组织信息
|
||||
for (String departmentId : ids) {
|
||||
userService.deleteDepartmentUserByDepartmentId(departmentId);
|
||||
}
|
||||
Map<String, Object> params = getHashMap(2);
|
||||
params.put("departmentIds", ids);
|
||||
setUpdateInfo(params);
|
||||
departmentDao.remove(params);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(String departmentId, DepartmentVO departmentVO) {
|
||||
if (isDepartmentExist(departmentId, departmentVO.getDepartmentParentId(), departmentVO.getDepartmentName())) {
|
||||
throw new SaveException("同级组织名称不能相同");
|
||||
}
|
||||
Map<String, Object> params = HashMapUtil.beanToMap(departmentVO);
|
||||
setArea(departmentVO, params);
|
||||
params.put("departmentId", departmentId);
|
||||
setUpdateInfo(params);
|
||||
departmentDao.update(params);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateMergeNew(MergeNewDepartmentInfoVO mergeNewDepartmentInfoVO) {
|
||||
String departmentId = saveReturnId(mergeNewDepartmentInfoVO);
|
||||
String[] mergeDepartmentIdArray = mergeNewDepartmentInfoVO.getMergeDepartmentIds().split("_");
|
||||
mergeByDepartmentId(departmentId, mergeNewDepartmentInfoVO.getDepartmentName(), mergeDepartmentIdArray);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateMerge(String departmentId, MergeDepartmentInfoVO mergeDepartmentInfoVO) {
|
||||
DepartmentSimpleDTO departmentSimpleDTO = getSimpleById(departmentId);
|
||||
if (departmentSimpleDTO == null) {
|
||||
throw new SearchException("部门不存在");
|
||||
}
|
||||
String[] mergeDepartmentIdArray = mergeDepartmentInfoVO.getMergeDepartmentIds().split("_");
|
||||
mergeDepartmentByDepartmentId(departmentId, departmentSimpleDTO.getDepartmentName(), mergeDepartmentIdArray);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateSplit(String departmentId, SplitDepartmentVO splitDepartmentVO) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resetCode() {
|
||||
Map<String, Object> params = getHashMap(2);
|
||||
resetCode("0", "", params);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<DepartmentDTO> list(Map<String, Object> params) {
|
||||
return departmentDao.list(params);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SuccessResultList<List<DepartmentDTO>> listPage(ListPage page) {
|
||||
PageHelper.startPage(page.getPage(), page.getRows());
|
||||
List<DepartmentDTO> departmentDTOs = list(page.getParams());
|
||||
PageInfo<DepartmentDTO> pageInfo = new PageInfo<>(departmentDTOs);
|
||||
return new SuccessResultList<>(departmentDTOs, pageInfo.getPageNum(), pageInfo.getTotal());
|
||||
}
|
||||
|
||||
@Override
|
||||
public SuccessResultList<List<DepartmentDTO>> listPageByParentId(String departmentParentId, ListPage page) {
|
||||
if (StringUtils.equals(ISystemConstant.TREE_ROOT_ID, departmentParentId)) {
|
||||
List<String> listBaseDepartmentIds = listBaseDepartmentIds();
|
||||
if (!Objects.isNull(listBaseDepartmentIds)) {
|
||||
page.getParams().put("departmentIds", listBaseDepartmentIds);
|
||||
} else {
|
||||
page.getParams().put("departmentParentId", departmentParentId);
|
||||
}
|
||||
return listPage(page);
|
||||
}
|
||||
page.getParams().put("departmentParentId", departmentParentId);
|
||||
return listPage(page);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DepartmentDTO get(String departmentId) {
|
||||
Map<String, Object> params = getHashMap(1);
|
||||
params.put("departmentId", departmentId);
|
||||
return departmentDao.get(params);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DepartmentDTO> listAll(Map<String, Object> params) {
|
||||
List<DepartmentDTO> departmentDTOs = list(params);
|
||||
listSub(departmentDTOs, params);
|
||||
return departmentDTOs;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ZTreeDTO> listZTree(Map<String, Object> params) {
|
||||
List<ZTreeDTO> zTreeDepartment = departmentDao.listZTree(params);
|
||||
List<ZTreeDTO> zTreeDTOs = Arrays.asList(new ZTreeDTO[zTreeDepartment.size()]);
|
||||
Collections.copy(zTreeDTOs, zTreeDepartment);
|
||||
for (ZTreeDTO zTreeDTO : zTreeDTOs) {
|
||||
Integer subCount = departmentDao.countByParentId(zTreeDTO.getId());
|
||||
setZTreeInfo(zTreeDTO, subCount);
|
||||
}
|
||||
return zTreeDTOs;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ZTreeDTO> listZTree(String departmentParentId, Map<String, Object> params) {
|
||||
if (StringUtils.equals(ISystemConstant.TREE_ROOT_ID, departmentParentId)) {
|
||||
List<String> listBaseDepartmentIds = listBaseDepartmentIds();
|
||||
if (listBaseDepartmentIds != null && !listBaseDepartmentIds.isEmpty()) {
|
||||
params.put("departmentIds", listBaseDepartmentIds);
|
||||
return listZTree(params);
|
||||
}
|
||||
}
|
||||
params.put("departmentParentId", departmentParentId);
|
||||
return listZTree(params);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> listId(Map<String, Object> params) {
|
||||
List<String> departmentIds = new ArrayList<>();
|
||||
List<DepartmentDTO> departmentDTOs = list(params);
|
||||
for (DepartmentDTO departmentDTO : departmentDTOs) {
|
||||
departmentIds.add(departmentDTO.getDepartmentId());
|
||||
}
|
||||
return departmentIds;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> listId(List<DepartmentBO> departmentBOs) {
|
||||
List<String> departmentIds = new ArrayList<>();
|
||||
if (Objects.isNull(departmentBOs) || departmentBOs.isEmpty()) {
|
||||
return departmentIds;
|
||||
}
|
||||
List<DepartmentBO> departmentList = new ArrayList<>(departmentBOs);
|
||||
List<DepartmentBO> departmentTempList = new ArrayList<>(departmentBOs);
|
||||
for (int i = 0; i < departmentList.size(); i++) {
|
||||
DepartmentBO departmentBO = null;
|
||||
// 找出CODE
|
||||
for (DepartmentBO department : departmentList) {
|
||||
DepartmentBO higherDepartmentBO = getHigherLevel(departmentList.get(i), department);
|
||||
if (higherDepartmentBO != null) {
|
||||
departmentBO = higherDepartmentBO;
|
||||
}
|
||||
}
|
||||
departmentIds.add(departmentBO.getDepartmentId());
|
||||
// 删除包含关系的内容
|
||||
for (int j = 0; j < departmentList.size(); j++) {
|
||||
if (StringUtils.startsWith(departmentList.get(j).getDepartmentCode(), departmentBO.getDepartmentCode())) {
|
||||
departmentList.remove(j);
|
||||
j--;
|
||||
}
|
||||
}
|
||||
for (int j = 0; j < departmentTempList.size(); j++) {
|
||||
if (StringUtils.startsWith(departmentTempList.get(j).getDepartmentCode(), departmentBO.getDepartmentCode())) {
|
||||
departmentTempList.remove(j);
|
||||
j--;
|
||||
}
|
||||
}
|
||||
i = -1;
|
||||
}
|
||||
return departmentIds;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DepartmentBO getHigherLevel(DepartmentBO departmentBO1, DepartmentBO departmentBO2) {
|
||||
if (StringUtils.startsWith(departmentBO1.getDepartmentCode(), departmentBO2.getDepartmentCode())) {
|
||||
return departmentBO2;
|
||||
} else if (StringUtils.startsWith(departmentBO2.getDepartmentCode(), departmentBO1.getDepartmentCode())) {
|
||||
return departmentBO1;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public UploadExcelResultDTO uploadExcel(MultipartFile excel) {
|
||||
// 错误列表
|
||||
List<DepartmentExcelError> departmentExcelErrors = new ArrayList<>(0);
|
||||
long startTime = System.currentTimeMillis();
|
||||
EasyExcel.read(excel.getInputStream(), DepartmentExcel.class, new DepartmentExcelListener() {
|
||||
@Override
|
||||
public void listDepartmentExcel(List<DepartmentExcel> departmentExcels) throws Exception {
|
||||
JSONArray listTreeDepartmentExcelJsonArray = listTreeDepartmentExcelJsonArray(0, departmentExcels, departmentExcelErrors);
|
||||
saveExcel("0", null, listTreeDepartmentExcelJsonArray, departmentExcelErrors);
|
||||
}
|
||||
}).headRowNumber(2).sheet().doRead();
|
||||
long endTime = System.currentTimeMillis();
|
||||
String excelFileId = null;
|
||||
if (departmentExcelErrors.size() > 0) {
|
||||
excelFileId = new AbstractErrorExcelHandler<DepartmentExcelError>(fileService) {
|
||||
@Override
|
||||
public List<List<String>> excelHeaderNames() {
|
||||
return simpleExcelHeader(new String[]{"ID", "组织名称", "上级ID", "组织说明", "组织电话", "类型", "错误原因"});
|
||||
}
|
||||
}.saveErrorExcel(departmentExcelErrors);
|
||||
}
|
||||
return new UploadExcelResultDTO(departmentExcelErrors.size(), endTime - startTime, excelFileId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer count(Map<String, Object> params) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DepartmentSimpleDTO getSimpleById(String departmentId) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DepartmentSimpleDTO> listSimple(Map<String, Object> params) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DepartmentSimpleDTO> listSimpleByParentId(String departmentParentId) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置组织组织地区
|
||||
*
|
||||
* @param departmentVO
|
||||
* @param params
|
||||
*/
|
||||
private void setArea(DepartmentVO departmentVO, Map<String, Object> params) {
|
||||
if (departmentVO.getDepartmentArea1Id() != null) {
|
||||
DataAreaDTO dataAreaDTO = dataAreaService.getAreaById(departmentVO.getDepartmentArea1Id().toString());
|
||||
params.put("departmentArea1Code", dataAreaDTO.getAreaCode());
|
||||
params.put("departmentArea1Name", dataAreaDTO.getAreaName());
|
||||
} else {
|
||||
params.put("departmentArea1Code", "");
|
||||
params.put("departmentArea1Name", "");
|
||||
}
|
||||
if (departmentVO.getDepartmentArea2Id() != null) {
|
||||
DataAreaDTO dataAreaDTO = dataAreaService.getAreaById(departmentVO.getDepartmentArea2Id().toString());
|
||||
params.put("departmentArea2Code", dataAreaDTO.getAreaCode());
|
||||
params.put("departmentArea2Name", dataAreaDTO.getAreaName());
|
||||
} else {
|
||||
params.put("departmentArea2Code", "");
|
||||
params.put("departmentArea2Name", "");
|
||||
}
|
||||
if (departmentVO.getDepartmentArea3Id() != null) {
|
||||
DataAreaDTO dataAreaDTO = dataAreaService.getAreaById(departmentVO.getDepartmentArea3Id().toString());
|
||||
params.put("departmentArea3Code", dataAreaDTO.getAreaCode());
|
||||
params.put("departmentArea3Name", dataAreaDTO.getAreaName());
|
||||
} else {
|
||||
params.put("departmentArea3Code", "");
|
||||
params.put("departmentArea3Name", "");
|
||||
}
|
||||
if (departmentVO.getDepartmentArea4Id() != null) {
|
||||
DataAreaDTO dataAreaDTO = dataAreaService.getAreaById(departmentVO.getDepartmentArea4Id().toString());
|
||||
params.put("departmentArea4Code", dataAreaDTO.getAreaCode());
|
||||
params.put("departmentArea4Name", dataAreaDTO.getAreaName());
|
||||
} else {
|
||||
params.put("departmentArea4Code", "");
|
||||
params.put("departmentArea4Name", "");
|
||||
}
|
||||
if (departmentVO.getDepartmentArea5Id() != null) {
|
||||
DataAreaDTO dataAreaDTO = dataAreaService.getAreaById(departmentVO.getDepartmentArea5Id().toString());
|
||||
params.put("departmentArea5Code", dataAreaDTO.getAreaCode());
|
||||
params.put("departmentArea5Name", dataAreaDTO.getAreaName());
|
||||
} else {
|
||||
params.put("departmentArea5Code", "");
|
||||
params.put("departmentArea5Name", "");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 重置编码
|
||||
*
|
||||
* @param departmentParentId
|
||||
* @param departmentParentCode
|
||||
* @param params
|
||||
*/
|
||||
private void resetCode(String departmentParentId, String departmentParentCode, Map<String, Object> params) {
|
||||
params.clear();
|
||||
params.put("departmentParentId", departmentParentId);
|
||||
List<DepartmentDTO> departmentDTOs = list(params);
|
||||
for (int i = 0; i < departmentDTOs.size(); i++) {
|
||||
params.clear();
|
||||
int index = i + 1;
|
||||
DepartmentDTO departmentDTO = departmentDTOs.get(i);
|
||||
String departmentCode = String.format("%s%04d", departmentParentCode, index);
|
||||
params.put("departmentId", departmentDTO.getDepartmentId());
|
||||
params.put("departmentCode", departmentCode);
|
||||
departmentDao.updateCode(params);
|
||||
resetCode(departmentDTO.getDepartmentId(), departmentCode, params);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 递归查询子部门
|
||||
*
|
||||
* @param departmentDTOs
|
||||
* @param params
|
||||
*/
|
||||
private void listSub(List<DepartmentDTO> departmentDTOs, Map<String, Object> params) throws SearchException {
|
||||
for (DepartmentDTO departmentDTO : departmentDTOs) {
|
||||
params.put("departmentParentId", departmentDTO.getDepartmentId());
|
||||
List<DepartmentDTO> subDepartmentDTOs = list(params);
|
||||
departmentDTO.setSubDepartments(subDepartmentDTOs);
|
||||
listSub(subDepartmentDTOs, params);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 合并组织到指定组织
|
||||
*
|
||||
* @param departmentId
|
||||
* @param mergeDepartmentIdArray
|
||||
*/
|
||||
private void mergeDepartmentByDepartmentId(String departmentId, String departmentName, String[] mergeDepartmentIdArray) {
|
||||
DepartmentDTO departmentDTO = get(departmentId);
|
||||
if (departmentDTO == null) {
|
||||
throw new SearchException("并入部门不存在");
|
||||
}
|
||||
List<String> departmentUserIds = new ArrayList<>();
|
||||
for (String mergeDepartmentId : mergeDepartmentIdArray) {
|
||||
DepartmentDTO mergeDepartmentDTO = get(mergeDepartmentId);
|
||||
if (mergeDepartmentDTO == null) {
|
||||
throw new SearchException("合并部门不存在");
|
||||
}
|
||||
LOG.debug("新增合并日志");
|
||||
saveDepartmentAdjustment(mergeDepartmentId, mergeDepartmentDTO.getDepartmentName(), departmentId, departmentDTO.getDepartmentName(), DepartmentAdjustmentTypeEnum.MERGE);
|
||||
LOG.debug("删除需要合并的组织人员");
|
||||
List<String> oldDepartmentUserIds = removeDepartmentByDepartmentIdReturnDeletedDepartmentUserIds(mergeDepartmentId, mergeDepartmentDTO.getDepartmentName());
|
||||
departmentUserIds.addAll(oldDepartmentUserIds);
|
||||
}
|
||||
LOG.debug("将合并组织的人员添加到新组织");
|
||||
userService.saveDepartmentUserIdByDepartmentId(departmentId, departmentName, departmentUserIds);
|
||||
}
|
||||
|
||||
/**
|
||||
* 组织是否存在
|
||||
*
|
||||
* @param excludeDepartmentId
|
||||
* @param departmentParentId
|
||||
* @param departmentName
|
||||
* @return
|
||||
*/
|
||||
private boolean isDepartmentExist(String excludeDepartmentId, String departmentParentId, String departmentName) {
|
||||
Map<String, Object> params = getHashMap(3);
|
||||
params.put("excludeDepartmentId", excludeDepartmentId);
|
||||
params.put("departmentParentId", departmentParentId);
|
||||
params.put("departmentName", departmentName.trim());
|
||||
DepartmentDTO departmentDTO = departmentDao.get(params);
|
||||
if (departmentDTO == null) {
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取code
|
||||
*
|
||||
* @param parentCode
|
||||
* @param parentId
|
||||
* @return
|
||||
*/
|
||||
private String getCode(String parentCode, String parentId) {
|
||||
DepartmentDTO departmentDTO = departmentDao.getLastByParentId(parentId);
|
||||
String code = departmentDTO != null ? departmentDTO.getDepartmentCode() : "0000";
|
||||
return super.getNewCode(code, parentCode);
|
||||
}
|
||||
}
|
@ -0,0 +1,865 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="ink.wgink.service.department.dao.IDepartmentDao">
|
||||
|
||||
<cache/>
|
||||
|
||||
<resultMap id="departmentDTO" type="ink.wgink.pojo.dtos.department.DepartmentDTO">
|
||||
<id property="departmentId" column="department_id"/>
|
||||
<result property="departmentParentId" column="department_parent_id"/>
|
||||
<result property="departmentParentName" column="department_parent_name"/>
|
||||
<result property="departmentName" column="department_name"/>
|
||||
<result property="departmentSummary" column="department_summary"/>
|
||||
<result property="departmentCode" column="department_code"/>
|
||||
<result property="departmentNameEn" column="department_name_en"/>
|
||||
<result property="departmentNameOther" column="department_name_other"/>
|
||||
<result property="departmentSummary" column="department_summary"/>
|
||||
<result property="departmentLogo" column="department_logo"/>
|
||||
<result property="departmentLogoHover" column="department_logo_hover"/>
|
||||
<result property="departmentType" column="department_type"/>
|
||||
<result property="departmentState" column="department_state"/>
|
||||
<result property="departmentFax" column="department_fax"/>
|
||||
<result property="departmentTel" column="department_tel"/>
|
||||
<result property="departmentAddress" column="department_address"/>
|
||||
<result property="departmentMaster" column="department_master"/>
|
||||
<result property="departmentMasterName" column="department_master_name"/>
|
||||
<result property="departmentDuty" column="department_duty"/>
|
||||
<result property="departmentArea1Id" column="department_area1_id"/>
|
||||
<result property="departmentArea1Code" column="department_area1_code"/>
|
||||
<result property="departmentArea1Name" column="department_area1_name"/>
|
||||
<result property="departmentArea2Id" column="department_area2_id"/>
|
||||
<result property="departmentArea2Code" column="department_area2_code"/>
|
||||
<result property="departmentArea2Name" column="department_area2_name"/>
|
||||
<result property="departmentArea3Id" column="department_area3_id"/>
|
||||
<result property="departmentArea3Code" column="department_area3_code"/>
|
||||
<result property="departmentArea3Name" column="department_area3_name"/>
|
||||
<result property="departmentArea4Id" column="department_area4_id"/>
|
||||
<result property="departmentArea4Code" column="department_area4_code"/>
|
||||
<result property="departmentArea4Name" column="department_area4_name"/>
|
||||
<result property="departmentArea5Id" column="department_area5_id"/>
|
||||
<result property="departmentArea5Code" column="department_area5_code"/>
|
||||
<result property="departmentArea5Name" column="department_area5_name"/>
|
||||
<result property="departmentLongitude" column="department_longitude"/>
|
||||
<result property="departmentLatitude" column="department_latitude"/>
|
||||
<result property="departmentOrder" column="department_order"/>
|
||||
</resultMap>
|
||||
|
||||
<resultMap id="departmentSimpleDTO" type="ink.wgink.pojo.dtos.department.DepartmentSimpleDTO">
|
||||
<id property="departmentId" column="department_id"/>
|
||||
<result property="departmentIntId" column="department_int_id"/>
|
||||
<result property="departmentParentId" column="department_parent_id"/>
|
||||
<result property="departmentParentName" column="department_parent_name"/>
|
||||
<result property="departmentName" column="department_name"/>
|
||||
<result property="departmentSummary" column="department_summary"/>
|
||||
<result property="departmentCode" column="department_code"/>
|
||||
<result property="departmentNameEn" column="department_name_en"/>
|
||||
<result property="departmentNameOther" column="department_name_other"/>
|
||||
<result property="departmentSummary" column="department_summary"/>
|
||||
<result property="departmentLogo" column="department_logo"/>
|
||||
<result property="departmentLogoHover" column="department_logo_hover"/>
|
||||
<result property="departmentType" column="department_type"/>
|
||||
<result property="departmentState" column="department_state"/>
|
||||
<result property="departmentFax" column="department_fax"/>
|
||||
<result property="departmentTel" column="department_tel"/>
|
||||
<result property="departmentAddress" column="department_address"/>
|
||||
<result property="departmentMaster" column="department_master"/>
|
||||
<result property="departmentMasterName" column="department_master_name"/>
|
||||
<result property="departmentDuty" column="department_duty"/>
|
||||
<result property="departmentArea1Id" column="department_area1_id"/>
|
||||
<result property="departmentArea1Code" column="department_area1_code"/>
|
||||
<result property="departmentArea1Name" column="department_area1_name"/>
|
||||
<result property="departmentArea2Id" column="department_area2_id"/>
|
||||
<result property="departmentArea2Code" column="department_area2_code"/>
|
||||
<result property="departmentArea2Name" column="department_area2_name"/>
|
||||
<result property="departmentArea3Id" column="department_area3_id"/>
|
||||
<result property="departmentArea3Code" column="department_area3_code"/>
|
||||
<result property="departmentArea3Name" column="department_area3_name"/>
|
||||
<result property="departmentArea4Id" column="department_area4_id"/>
|
||||
<result property="departmentArea4Code" column="department_area4_code"/>
|
||||
<result property="departmentArea4Name" column="department_area4_name"/>
|
||||
<result property="departmentArea5Id" column="department_area5_id"/>
|
||||
<result property="departmentArea5Code" column="department_area5_code"/>
|
||||
<result property="departmentArea5Name" column="department_area5_name"/>
|
||||
<result property="departmentLongitude" column="department_longitude"/>
|
||||
<result property="departmentLatitude" column="department_latitude"/>
|
||||
<result property="departmentOrder" column="department_order"/>
|
||||
</resultMap>
|
||||
|
||||
<resultMap id="departmentZTreeDTO" type="ink.wgink.pojo.dtos.ZTreeDTO">
|
||||
<id property="id" column="department_id"/>
|
||||
<result property="pId" column="department_parent_id"/>
|
||||
<result property="name" column="department_name"/>
|
||||
</resultMap>
|
||||
|
||||
<!-- 新增组织部门 -->
|
||||
<insert id="save" parameterType="map" flushCache="true">
|
||||
INSERT INTO sys_department(
|
||||
department_id,
|
||||
department_parent_id,
|
||||
department_name,
|
||||
department_name_en,
|
||||
department_name_other,
|
||||
department_summary,
|
||||
department_code,
|
||||
department_logo,
|
||||
department_logo_hover,
|
||||
department_type,
|
||||
department_state,
|
||||
department_fax,
|
||||
department_tel,
|
||||
department_address,
|
||||
department_master,
|
||||
department_duty,
|
||||
department_area1_id,
|
||||
department_area1_code,
|
||||
department_area1_name,
|
||||
department_area2_id,
|
||||
department_area2_code,
|
||||
department_area2_name,
|
||||
department_area3_id,
|
||||
department_area3_code,
|
||||
department_area3_name,
|
||||
department_area4_id,
|
||||
department_area4_code,
|
||||
department_area4_name,
|
||||
department_area5_id,
|
||||
department_area5_code,
|
||||
department_area5_name,
|
||||
department_longitude,
|
||||
department_latitude,
|
||||
department_order,
|
||||
creator,
|
||||
gmt_create,
|
||||
modifier,
|
||||
gmt_modified,
|
||||
is_delete
|
||||
) VALUES(
|
||||
#{departmentId},
|
||||
#{departmentParentId},
|
||||
#{departmentName},
|
||||
#{departmentNameEn},
|
||||
#{departmentNameOther},
|
||||
#{departmentSummary},
|
||||
#{departmentCode},
|
||||
#{departmentLogo},
|
||||
#{departmentLogoHover},
|
||||
#{departmentType},
|
||||
#{departmentState},
|
||||
#{departmentFax},
|
||||
#{departmentTel},
|
||||
#{departmentAddress},
|
||||
#{departmentMaster},
|
||||
#{departmentDuty},
|
||||
#{departmentArea1Id},
|
||||
#{departmentArea1Code},
|
||||
#{departmentArea1Name},
|
||||
#{departmentArea2Id},
|
||||
#{departmentArea2Code},
|
||||
#{departmentArea2Name},
|
||||
#{departmentArea3Id},
|
||||
#{departmentArea3Code},
|
||||
#{departmentArea3Name},
|
||||
#{departmentArea4Id},
|
||||
#{departmentArea4Code},
|
||||
#{departmentArea4Name},
|
||||
#{departmentArea5Id},
|
||||
#{departmentArea5Code},
|
||||
#{departmentArea5Name},
|
||||
#{departmentLongitude},
|
||||
#{departmentLatitude},
|
||||
#{departmentOrder},
|
||||
#{creator},
|
||||
#{gmtCreate},
|
||||
#{modifier},
|
||||
#{gmtModified},
|
||||
#{isDelete}
|
||||
)
|
||||
</insert>
|
||||
|
||||
<!-- 删除组织部门 -->
|
||||
<update id="remove" parameterType="map" flushCache="true">
|
||||
UPDATE
|
||||
sys_department
|
||||
SET
|
||||
is_delete = 1,
|
||||
modifier = #{modifier},
|
||||
gmt_modified = #{gmtModified}
|
||||
WHERE
|
||||
department_id IN
|
||||
<foreach collection="departmentIds" index="index" open="(" separator="," close=")">
|
||||
#{departmentIds[${index}]}
|
||||
</foreach>
|
||||
</update>
|
||||
|
||||
<!-- 修改组织部门 -->
|
||||
<update id="update" parameterType="map" flushCache="true">
|
||||
UPDATE
|
||||
sys_department
|
||||
SET
|
||||
<if test="departmentName != null">
|
||||
department_name = #{departmentName},
|
||||
</if>
|
||||
<if test="departmentNameEn != null">
|
||||
department_name_en = #{departmentNameEn},
|
||||
</if>
|
||||
<if test="departmentNameOther != null">
|
||||
department_name_other = #{departmentNameOther},
|
||||
</if>
|
||||
<if test="departmentSummary != null">
|
||||
department_summary = #{departmentSummary},
|
||||
</if>
|
||||
<if test="departmentCode != null and departmentCode != ''">
|
||||
department_code = #{departmentCode},
|
||||
</if>
|
||||
<if test="departmentLogo != null and departmentLogo != ''">
|
||||
department_logo = #{departmentLogo},
|
||||
</if>
|
||||
<if test="departmentLogoHover != null">
|
||||
department_logo_hover = #{departmentLogoHover},
|
||||
</if>
|
||||
<if test="departmentType != null">
|
||||
department_type = #{departmentType},
|
||||
</if>
|
||||
<if test="departmentState != null">
|
||||
department_state = #{departmentState},
|
||||
</if>
|
||||
<if test="departmentFax != null">
|
||||
department_fax = #{departmentFax},
|
||||
</if>
|
||||
<if test="departmentTel != null">
|
||||
department_tel = #{departmentTel},
|
||||
</if>
|
||||
<if test="departmentAddress != null">
|
||||
department_address = #{departmentAddress},
|
||||
</if>
|
||||
<if test="departmentMaster != null">
|
||||
department_master = #{departmentMaster},
|
||||
</if>
|
||||
<if test="departmentDuty != null">
|
||||
department_duty = #{departmentDuty},
|
||||
</if>
|
||||
department_area1_id = #{departmentArea1Id},
|
||||
<if test="departmentArea1Code != null">
|
||||
department_area1_code = #{departmentArea1Code},
|
||||
</if>
|
||||
<if test="departmentArea1Name != null">
|
||||
department_area1_name = #{departmentArea1Name},
|
||||
</if>
|
||||
department_area2_id = #{departmentArea2Id},
|
||||
<if test="departmentArea2Code != null">
|
||||
department_area2_code = #{departmentArea2Code},
|
||||
</if>
|
||||
<if test="departmentArea2Name != null">
|
||||
department_area2_name = #{departmentArea2Name},
|
||||
</if>
|
||||
department_area3_id = #{departmentArea3Id},
|
||||
<if test="departmentArea3Code != null">
|
||||
department_area3_code = #{departmentArea3Code},
|
||||
</if>
|
||||
<if test="departmentArea3Name != null">
|
||||
department_area3_name = #{departmentArea3Name},
|
||||
</if>
|
||||
department_area4_id = #{departmentArea4Id},
|
||||
<if test="departmentArea4Code != null">
|
||||
department_area4_code = #{departmentArea4Code},
|
||||
</if>
|
||||
<if test="departmentArea4Name != null">
|
||||
department_area4_name = #{departmentArea4Name},
|
||||
</if>
|
||||
department_area5_id = #{departmentArea5Id},
|
||||
<if test="departmentArea5Code != null">
|
||||
department_area5_code = #{departmentArea5Code},
|
||||
</if>
|
||||
<if test="departmentArea5Name != null">
|
||||
department_area5_name = #{departmentArea5Name},
|
||||
</if>
|
||||
<if test="departmentLongitude != null">
|
||||
department_longitude = #{departmentLongitude},
|
||||
</if>
|
||||
<if test="departmentLatitude != null">
|
||||
department_latitude = #{departmentLatitude},
|
||||
</if>
|
||||
<if test="departmentOrder != null">
|
||||
department_order = #{departmentOrder},
|
||||
</if>
|
||||
modifier = #{modifier},
|
||||
gmt_modified = #{gmtModified}
|
||||
WHERE
|
||||
department_id = #{departmentId}
|
||||
</update>
|
||||
|
||||
<!-- 组织部门编码更新 -->
|
||||
<update id="updateCode" parameterType="map" flushCache="true">
|
||||
UPDATE
|
||||
sys_department
|
||||
SET
|
||||
department_code = #{departmentCode}
|
||||
WHERE
|
||||
department_id = #{departmentId}
|
||||
</update>
|
||||
|
||||
<!-- 更新部门状态 -->
|
||||
<update id="updateState" parameterType="map" flushCache="true">
|
||||
UPDATE
|
||||
sys_department
|
||||
SET
|
||||
department_state = #{departmentState}
|
||||
WHERE
|
||||
department_id = #{departmentId}
|
||||
</update>
|
||||
|
||||
<!-- ztree列表 -->
|
||||
<select id="listZTree" parameterType="map" resultMap="departmentZTreeDTO" useCache="true">
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
sys_department
|
||||
WHERE
|
||||
is_delete = 0
|
||||
<if test="departmentParentId != null and departmentParentId != ''">
|
||||
AND
|
||||
department_parent_id = #{departmentParentId}
|
||||
</if>
|
||||
<if test="departmentIds != null and departmentIds.size > 0">
|
||||
AND
|
||||
department_id IN
|
||||
<foreach collection="departmentIds" index="index" open="(" separator="," close=")">
|
||||
#{departmentIds[${index}]}
|
||||
</foreach>
|
||||
</if>
|
||||
ORDER BY
|
||||
department_order
|
||||
</select>
|
||||
|
||||
<!-- ztree详情 -->
|
||||
<select id="getZTree" parameterType="map" resultMap="departmentZTreeDTO" useCache="false">
|
||||
SELECT
|
||||
department_id,
|
||||
department_parent_id,
|
||||
department_name,
|
||||
department_name_en,
|
||||
department_name_other,
|
||||
department_summary,
|
||||
department_code,
|
||||
department_logo,
|
||||
department_logo_hover,
|
||||
department_type,
|
||||
department_state,
|
||||
department_fax,
|
||||
department_tel,
|
||||
department_address,
|
||||
department_master,
|
||||
department_duty,
|
||||
department_longitude,
|
||||
department_latitude,
|
||||
department_order,
|
||||
creator,
|
||||
gmt_create,
|
||||
modifier,
|
||||
gmt_modified,
|
||||
is_delete
|
||||
FROM
|
||||
sys_department
|
||||
WHERE
|
||||
is_delete = 0
|
||||
<if test="departmentId != null and departmentId != ''">
|
||||
AND
|
||||
department_id = #{departmentId}
|
||||
</if>
|
||||
<if test="departmentState != null">
|
||||
AND
|
||||
department_state = #{departmentState}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<!-- 组织部门列表 -->
|
||||
<select id="list" parameterType="map" resultMap="departmentDTO" useCache="false">
|
||||
SELECT
|
||||
department_id,
|
||||
department_parent_id,
|
||||
department_name,
|
||||
department_name_en,
|
||||
department_name_other,
|
||||
department_summary,
|
||||
department_code,
|
||||
department_logo,
|
||||
department_logo_hover,
|
||||
department_type,
|
||||
department_state,
|
||||
department_fax,
|
||||
department_tel,
|
||||
department_address,
|
||||
department_master,
|
||||
department_duty,
|
||||
department_area1_id,
|
||||
department_area1_code,
|
||||
department_area1_name,
|
||||
department_area2_id,
|
||||
department_area2_code,
|
||||
department_area2_name,
|
||||
department_area3_id,
|
||||
department_area3_code,
|
||||
department_area3_name,
|
||||
department_area4_id,
|
||||
department_area4_code,
|
||||
department_area4_name,
|
||||
department_area5_id,
|
||||
department_area5_code,
|
||||
department_area5_name,
|
||||
department_longitude,
|
||||
department_latitude,
|
||||
department_order,
|
||||
creator,
|
||||
gmt_create,
|
||||
modifier,
|
||||
gmt_modified,
|
||||
is_delete
|
||||
FROM
|
||||
sys_department
|
||||
WHERE
|
||||
is_delete = 0
|
||||
<if test="departmentParentId != null and departmentParentId != ''">
|
||||
AND
|
||||
department_parent_id = #{departmentParentId}
|
||||
</if>
|
||||
<if test="departmentCode != null and departmentCode != ''">
|
||||
AND
|
||||
department_code LIKE CONCAT(#{departmentCode}, '%')
|
||||
</if>
|
||||
<if test="departmentIds != null and departmentIds.size > 0">
|
||||
AND
|
||||
department_id IN
|
||||
<foreach collection="departmentIds" index="index" open="(" separator="," close=")">
|
||||
#{departmentIds[${index}]}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="departmentName != null and departmentName != ''">
|
||||
AND
|
||||
department_name = #{departmentName}
|
||||
</if>
|
||||
<if test="departmentState != null">
|
||||
AND
|
||||
department_state = #{departmentState}
|
||||
</if>
|
||||
<if test="keywords != null and keywords != ''">
|
||||
AND
|
||||
department_name LIKE CONCAT('%', #{keywords}, '%')
|
||||
</if>
|
||||
<if test="startTime != null and startTime != ''">
|
||||
AND
|
||||
gmt_create <![CDATA[ >= ]]> #{startTime}
|
||||
</if>
|
||||
<if test="startTime != null and startTime != ''">
|
||||
AND
|
||||
gmt_create <![CDATA[ <= ]]> #{endTime}
|
||||
</if>
|
||||
<choose>
|
||||
<when test="sort != null and (sort == 'departmentName' or sort == 'departmentNameEn' or sort == 'departmentNameOther' or sort == 'departmentCode' or sort == 'departmentType' or sort == 'departmentState')">
|
||||
ORDER BY
|
||||
<if test="sort == 'departmentName'">
|
||||
department_name ${order}
|
||||
</if>
|
||||
<if test="sort == 'departmentNameEn'">
|
||||
department_name_en ${order}
|
||||
</if>
|
||||
<if test="sort == 'departmentNameOther'">
|
||||
department_name_other ${order}
|
||||
</if>
|
||||
<if test="sort == 'departmentCode'">
|
||||
department_code ${order}
|
||||
</if>
|
||||
<if test="sort == 'departmentType'">
|
||||
department_type ${order}
|
||||
</if>
|
||||
<if test="sort == 'departmentState'">
|
||||
department_state ${order}
|
||||
</if>
|
||||
</when>
|
||||
<otherwise>
|
||||
ORDER BY
|
||||
department_order ASC
|
||||
</otherwise>
|
||||
</choose>
|
||||
</select>
|
||||
|
||||
<!-- 组织部门详情 -->
|
||||
<select id="get" parameterType="map" resultMap="departmentDTO" useCache="false">
|
||||
SELECT
|
||||
t1.*,
|
||||
jt1.department_name department_parent_name,
|
||||
jt2.user_name department_master_name
|
||||
FROM
|
||||
sys_department t1
|
||||
LEFT JOIN
|
||||
sys_department jt1
|
||||
ON
|
||||
t1.department_parent_id = jt1.department_id
|
||||
AND
|
||||
jt1.is_delete = 0
|
||||
LEFT JOIN
|
||||
sys_user jt2
|
||||
ON
|
||||
t1.department_master = jt2.user_id
|
||||
AND
|
||||
jt2.is_delete = 0
|
||||
WHERE
|
||||
t1.is_delete = 0
|
||||
<if test="departmentId != null and departmentId != ''">
|
||||
AND
|
||||
t1.department_id = #{departmentId}
|
||||
</if>
|
||||
<if test="departmentParentId != null and departmentParentId != ''">
|
||||
AND
|
||||
t1.department_parent_id = #{departmentParentId}
|
||||
</if>
|
||||
<if test="excludeDepartmentId != null and excludeDepartmentId != ''">
|
||||
AND
|
||||
t1.department_id != #{excludeDepartmentId}
|
||||
</if>
|
||||
<if test="departmentName != null and departmentName != ''">
|
||||
AND
|
||||
t1.department_name = #{departmentName}
|
||||
</if>
|
||||
<if test="departmentState != null">
|
||||
AND
|
||||
t1.department_state = #{departmentState}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<!-- 获取组织机构通过名称和上级名称 -->
|
||||
<select id="getByNameAndParentName" parameterType="map" resultMap="departmentDTO" useCache="false">
|
||||
SELECT
|
||||
t1.*,
|
||||
jt1.department_name department_parent_name,
|
||||
jt2.user_name department_master_name
|
||||
FROM
|
||||
sys_department t1
|
||||
LEFT JOIN
|
||||
sys_department jt1
|
||||
ON
|
||||
t1.department_parent_id = jt1.department_id
|
||||
AND
|
||||
jt1.is_delete = 0
|
||||
LEFT JOIN
|
||||
sys_user jt2
|
||||
ON
|
||||
t1.department_master = jt2.user_id
|
||||
AND
|
||||
jt2.is_delete = 0
|
||||
WHERE
|
||||
t1.is_delete = 0
|
||||
AND
|
||||
t1.department_name = #{departmentName}
|
||||
<if test="departmentParentName != null and departmentParentName != ''">
|
||||
AND
|
||||
jt1.department_name = #{departmentParentName}
|
||||
</if>
|
||||
<if test="departmentParentName == null or departmentParentName == ''">
|
||||
AND
|
||||
jt1.department_name IS NULL
|
||||
</if>
|
||||
<if test="departmentState != null">
|
||||
AND
|
||||
t1.department_state = #{departmentState}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<!-- 子节点数量 -->
|
||||
<select id="countByParentId" parameterType="String" resultType="Integer" useCache="false">
|
||||
SELECT
|
||||
COUNT(*)
|
||||
FROM
|
||||
sys_department
|
||||
WHERE
|
||||
is_delete = 0
|
||||
AND
|
||||
department_parent_id = #{_parameter}
|
||||
</select>
|
||||
|
||||
<!-- 获取最后一个子组织部门,实际数据,包含已删除,方式编码重复 -->
|
||||
<select id="getLastByParentId" parameterType="String" resultMap="departmentDTO" useCache="false">
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
sys_department
|
||||
WHERE
|
||||
department_parent_id = #{_parameter}
|
||||
ORDER BY
|
||||
department_code DESC
|
||||
LIMIT 0, 1
|
||||
</select>
|
||||
|
||||
<!-- 获取组织机构详情(简单类型) -->
|
||||
<select id="getSimple" parameterType="map" resultMap="departmentSimpleDTO" useCache="false">
|
||||
SELECT
|
||||
id department_int_id,
|
||||
department_id,
|
||||
department_parent_id,
|
||||
department_name,
|
||||
department_name_en,
|
||||
department_name_other,
|
||||
department_summary,
|
||||
department_code,
|
||||
department_logo,
|
||||
department_logo_hover,
|
||||
department_type,
|
||||
department_state,
|
||||
department_fax,
|
||||
department_tel,
|
||||
department_address,
|
||||
department_master,
|
||||
department_duty,
|
||||
department_area1_id,
|
||||
department_area1_code,
|
||||
department_area1_name,
|
||||
department_area2_id,
|
||||
department_area2_code,
|
||||
department_area2_name,
|
||||
department_area3_id,
|
||||
department_area3_code,
|
||||
department_area3_name,
|
||||
department_area4_id,
|
||||
department_area4_code,
|
||||
department_area4_name,
|
||||
department_area5_id,
|
||||
department_area5_code,
|
||||
department_area5_name,
|
||||
department_longitude,
|
||||
department_latitude,
|
||||
department_order
|
||||
FROM
|
||||
sys_department
|
||||
WHERE
|
||||
is_delete = 0
|
||||
<if test="departmentId != null and departmentId != ''">
|
||||
AND
|
||||
department_id = #{departmentId}
|
||||
</if>
|
||||
<if test="departmentIntId != null">
|
||||
AND
|
||||
id = #{departmentIntId}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<!-- 获取组织机构列表(简单类型) -->
|
||||
<select id="listSimple" parameterType="map" resultMap="departmentSimpleDTO" useCache="false">
|
||||
SELECT
|
||||
id department_int_id,
|
||||
department_id,
|
||||
department_parent_id,
|
||||
department_name,
|
||||
department_name_en,
|
||||
department_name_other,
|
||||
department_summary,
|
||||
department_code,
|
||||
department_logo,
|
||||
department_logo_hover,
|
||||
department_type,
|
||||
department_state,
|
||||
department_fax,
|
||||
department_tel,
|
||||
department_address,
|
||||
department_master,
|
||||
department_duty,
|
||||
department_area1_id,
|
||||
department_area1_code,
|
||||
department_area1_name,
|
||||
department_area2_id,
|
||||
department_area2_code,
|
||||
department_area2_name,
|
||||
department_area3_id,
|
||||
department_area3_code,
|
||||
department_area3_name,
|
||||
department_area4_id,
|
||||
department_area4_code,
|
||||
department_area4_name,
|
||||
department_area5_id,
|
||||
department_area5_code,
|
||||
department_area5_name,
|
||||
department_longitude,
|
||||
department_latitude,
|
||||
department_order
|
||||
FROM
|
||||
sys_department
|
||||
WHERE
|
||||
is_delete = 0
|
||||
<if test="departmentParentId != null and departmentParentId != ''">
|
||||
AND
|
||||
department_parent_id = #{departmentParentId}
|
||||
</if>
|
||||
<if test="departmentCode != null and departmentCode != ''">
|
||||
AND
|
||||
department_code LIKE CONCAT(#{departmentCode}, '%')
|
||||
</if>
|
||||
<if test="departmentIds != null and departmentIds.size > 0">
|
||||
AND
|
||||
department_id IN
|
||||
<foreach collection="departmentIds" index="index" open="(" separator="," close=")">
|
||||
#{departmentIds[${index}]}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="departmentName != null and departmentName != ''">
|
||||
AND
|
||||
department_name = #{departmentName}
|
||||
</if>
|
||||
<if test="keywords != null and keywords != ''">
|
||||
AND
|
||||
department_name LIKE CONCAT('%', #{keywords}, '%')
|
||||
</if>
|
||||
<if test="departmentState != null">
|
||||
AND
|
||||
department_state = #{departmentState}
|
||||
</if>
|
||||
<if test="startTime != null and startTime != ''">
|
||||
AND
|
||||
gmt_create <![CDATA[ >= ]]> #{startTime}
|
||||
</if>
|
||||
<if test="startTime != null and startTime != ''">
|
||||
AND
|
||||
gmt_create <![CDATA[ <= ]]> #{endTime}
|
||||
</if>
|
||||
<if test="addDate != null and addDate != ''">
|
||||
AND
|
||||
gmt_create <![CDATA[ >= ]]> #{addDate}
|
||||
</if>
|
||||
<if test="updateDate != null and updateDate != ''">
|
||||
AND
|
||||
gmt_modified <![CDATA[ >= ]]> #{updateDate}
|
||||
</if>
|
||||
<if test="orderByCode != null">
|
||||
ORDER BY
|
||||
department_code
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<!-- 统计部门数量 -->
|
||||
<select id="count" parameterType="map" resultType="java.lang.Integer" useCache="true">
|
||||
SELECT
|
||||
COUNT(*)
|
||||
FROM
|
||||
sys_department
|
||||
WHERE
|
||||
is_delete = 0
|
||||
<if test="departmentId != null and departmentId != ''">
|
||||
AND
|
||||
department_id = #{departmentId}
|
||||
</if>
|
||||
<if test="departmentParentId != null and departmentParentId != ''">
|
||||
AND
|
||||
department_parent_id = #{departmentParentId}
|
||||
</if>
|
||||
<if test="departmentName != null and departmentName != ''">
|
||||
AND
|
||||
department_name = #{departmentName}
|
||||
</if>
|
||||
<if test="noDepartmentId != null and noDepartmentId != ''">
|
||||
AND
|
||||
department_id != #{noDepartmentId}
|
||||
</if>
|
||||
<if test="departmentType != null">
|
||||
AND
|
||||
department_type = #{departmentType}
|
||||
</if>
|
||||
<if test="departmentState != null">
|
||||
AND
|
||||
department_state = #{departmentState}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<!-- 部门ID列表 -->
|
||||
<select id="listId" parameterType="map" resultType="java.lang.String" useCache="true">
|
||||
SELECT
|
||||
department_id
|
||||
FROM
|
||||
sys_department
|
||||
WHERE
|
||||
is_delete = 0
|
||||
<if test="area1 != null">
|
||||
AND (
|
||||
department_area1_id = #{area1}
|
||||
<if test="local != null">
|
||||
AND ((
|
||||
department_area2_id IS NULL
|
||||
OR
|
||||
department_area2_id = ''
|
||||
)
|
||||
AND (
|
||||
department_area3_id IS NULL
|
||||
OR
|
||||
department_area3_id = ''
|
||||
)
|
||||
AND (
|
||||
department_area4_id IS NULL
|
||||
OR
|
||||
department_area4_id = ''
|
||||
)
|
||||
AND (
|
||||
department_area5_id IS NULL
|
||||
OR
|
||||
department_area5_id = ''
|
||||
)
|
||||
)
|
||||
</if>
|
||||
)
|
||||
</if>
|
||||
<if test="area2 != null">
|
||||
AND (
|
||||
department_area2_id = #{area2}
|
||||
<if test="local != null">
|
||||
AND ((
|
||||
department_area3_id IS NULL
|
||||
OR
|
||||
department_area3_id = ''
|
||||
)
|
||||
AND (
|
||||
department_area4_id IS NULL
|
||||
OR
|
||||
department_area4_id = ''
|
||||
)
|
||||
AND (
|
||||
department_area5_id IS NULL
|
||||
OR
|
||||
department_area5_id = ''
|
||||
)
|
||||
)
|
||||
</if>
|
||||
)
|
||||
</if>
|
||||
<if test="area3 != null">
|
||||
AND (
|
||||
department_area3_id = #{area3}
|
||||
<if test="local != null">
|
||||
AND ((
|
||||
department_area4_id IS NULL
|
||||
OR
|
||||
department_area4_id = ''
|
||||
)
|
||||
AND (
|
||||
department_area5_id IS NULL
|
||||
OR
|
||||
department_area5_id = ''
|
||||
)
|
||||
)
|
||||
</if>
|
||||
)
|
||||
</if>
|
||||
<if test="area4 != null">
|
||||
AND (
|
||||
department_area4_id = #{area4}
|
||||
<if test="local != null">
|
||||
AND ((
|
||||
department_area5_id IS NULL
|
||||
OR
|
||||
department_area5_id = ''
|
||||
)
|
||||
)
|
||||
</if>
|
||||
)
|
||||
</if>
|
||||
<if test="area5 != null">
|
||||
AND
|
||||
department_area5_id = #{area5}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
</mapper>
|
24
service-role/pom.xml
Normal file
24
service-role/pom.xml
Normal file
@ -0,0 +1,24 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>wg-basic</artifactId>
|
||||
<groupId>ink.wgink</groupId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>service-role</artifactId>
|
||||
<description>角色业务</description>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>ink.wgink</groupId>
|
||||
<artifactId>service-user</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
|
||||
</project>
|
@ -0,0 +1,22 @@
|
||||
package ink.wgink.service.role.controller.api;
|
||||
|
||||
import ink.wgink.common.base.DefaultBaseController;
|
||||
import ink.wgink.interfaces.consts.ISystemConstant;
|
||||
import io.swagger.annotations.Api;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* @ClassName: RoleController
|
||||
* @Description: 角色
|
||||
* @Author: wenc
|
||||
* @Date: 2019/1/6 3:03 PM
|
||||
* @Version: 1.0
|
||||
* @MenuUrl: admin/role/goroles
|
||||
**/
|
||||
@Api(tags = ISystemConstant.API_TAGS_SYSTEM_PREFIX + "角色信息管理接口")
|
||||
@RestController
|
||||
@RequestMapping(ISystemConstant.API_PREFIX + "/role")
|
||||
public class RoleController extends DefaultBaseController {
|
||||
|
||||
}
|
@ -10,11 +10,12 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>service-user</artifactId>
|
||||
<description>用户业务</description>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>ink.wgink</groupId>
|
||||
<artifactId>common</artifactId>
|
||||
<artifactId>module-file</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
@ -1,10 +1,24 @@
|
||||
package ink.wgink.service.user.controller.api;
|
||||
|
||||
import ink.wgink.common.base.DefaultBaseController;
|
||||
import ink.wgink.exceptions.ParamsException;
|
||||
import ink.wgink.interfaces.consts.ISystemConstant;
|
||||
import io.swagger.annotations.Api;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import ink.wgink.pojo.ListPage;
|
||||
import ink.wgink.pojo.dtos.user.UserDTO;
|
||||
import ink.wgink.pojo.result.ErrorResult;
|
||||
import ink.wgink.pojo.result.SuccessResult;
|
||||
import ink.wgink.pojo.result.SuccessResultList;
|
||||
import ink.wgink.service.user.pojo.vos.UserVO;
|
||||
import ink.wgink.service.user.service.IUserService;
|
||||
import ink.wgink.util.RegexUtil;
|
||||
import io.swagger.annotations.*;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* When you feel like quitting. Think about why you started
|
||||
@ -16,11 +30,83 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
* @Date: 2021/1/24 17:10
|
||||
* @Version: 1.0
|
||||
**/
|
||||
@Api(tags = ISystemConstant.API_TAGS_SYSTEM_PREFIX + "用户信息管理")
|
||||
@Api(tags = ISystemConstant.API_TAGS_SYSTEM_PREFIX + "用户")
|
||||
@RestController
|
||||
@RequestMapping(ISystemConstant.API_PREFIX + "/user")
|
||||
public class UserController extends DefaultBaseController {
|
||||
|
||||
@Autowired
|
||||
private IUserService userService;
|
||||
|
||||
@ApiOperation(value = "用户新增", notes = "用户新增接口")
|
||||
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
||||
@PostMapping("save")
|
||||
public SuccessResult save(@RequestBody UserVO userVO) {
|
||||
checkParams(userVO);
|
||||
userService.save(userVO);
|
||||
return new SuccessResult();
|
||||
}
|
||||
|
||||
@ApiOperation(value = "用户删除", notes = "用户删除接口")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "ids", value = "用户ID列表,用下划线分隔", paramType = "path")
|
||||
})
|
||||
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
||||
@DeleteMapping("remove/{ids}")
|
||||
public SuccessResult remove(@PathVariable("ids") String ids) {
|
||||
userService.remove(Arrays.asList(ids.split("\\_")));
|
||||
return new SuccessResult();
|
||||
}
|
||||
|
||||
@ApiOperation(value = "用户修改", notes = "用户修改接口")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "userId", value = "用户ID", paramType = "path"),
|
||||
})
|
||||
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
||||
@PutMapping("update/{userId}")
|
||||
public SuccessResult update(@PathVariable("userId") String userId, @RequestBody UserVO userVO) {
|
||||
checkParams(userVO);
|
||||
userService.update(userId, userVO);
|
||||
return new SuccessResult();
|
||||
}
|
||||
|
||||
/**
|
||||
* 参数校验
|
||||
*
|
||||
* @param userVO
|
||||
* @throws ParamsException
|
||||
*/
|
||||
private void checkParams(UserVO userVO) throws ParamsException {
|
||||
if (!StringUtils.isBlank(userVO.getUserPhone()) && !RegexUtil.isPhone(userVO.getUserPhone())) {
|
||||
throw new ParamsException("手机号码格式错误");
|
||||
}
|
||||
if (!StringUtils.isBlank(userVO.getUserEmail()) && !RegexUtil.isEmail(userVO.getUserEmail())) {
|
||||
throw new ParamsException("用户邮箱格式错误");
|
||||
}
|
||||
}
|
||||
|
||||
@ApiOperation(value = "用户列表", notes = "用户列表接口")
|
||||
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
||||
@GetMapping("list")
|
||||
public List<UserDTO> list() {
|
||||
Map<String, Object> params = requestParams();
|
||||
return userService.list(params);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "用户分页列表", notes = "用户分页列表接口")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "page", value = "当前页码", paramType = "query", dataType = "int", defaultValue = "1"),
|
||||
@ApiImplicitParam(name = "rows", value = "显示数量", paramType = "query", dataType = "int", defaultValue = "20"),
|
||||
@ApiImplicitParam(name = "keywords", value = "关键字", paramType = "query", dataType = "String"),
|
||||
@ApiImplicitParam(name = "startTime", value = "开始时间", paramType = "query", dataType = "String"),
|
||||
@ApiImplicitParam(name = "endTime", value = "结束时间", paramType = "query", dataType = "String")
|
||||
})
|
||||
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
||||
@GetMapping("listpage")
|
||||
public SuccessResultList<List<UserDTO>> listPage(ListPage page) {
|
||||
Map<String, Object> params = requestParams();
|
||||
page.setParams(params);
|
||||
return userService.listPage(page);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,7 +1,16 @@
|
||||
package ink.wgink.service.user.dao;
|
||||
|
||||
import ink.wgink.exceptions.RemoveException;
|
||||
import ink.wgink.exceptions.SaveException;
|
||||
import ink.wgink.exceptions.SearchException;
|
||||
import ink.wgink.exceptions.UpdateException;
|
||||
import ink.wgink.pojo.dtos.user.UserDTO;
|
||||
import ink.wgink.service.user.pojo.pos.UserPO;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* When you feel like quitting. Think about why you started
|
||||
* 当你想要放弃的时候,想想当初你为何开始
|
||||
@ -14,4 +23,81 @@ import org.springframework.stereotype.Repository;
|
||||
**/
|
||||
@Repository
|
||||
public interface IUserDao {
|
||||
|
||||
/**
|
||||
* 新增
|
||||
*
|
||||
* @param params
|
||||
* @throws SaveException
|
||||
*/
|
||||
void save(Map<String, Object> params) throws SaveException;
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*
|
||||
* @param params
|
||||
* @throws RemoveException
|
||||
*/
|
||||
void remove(Map<String, Object> params) throws RemoveException;
|
||||
|
||||
/**
|
||||
* 修改
|
||||
*
|
||||
* @param params
|
||||
* @throws UpdateException
|
||||
*/
|
||||
void update(Map<String, Object> params) throws UpdateException;
|
||||
|
||||
/**
|
||||
* 修改密码
|
||||
*
|
||||
* @param params
|
||||
* @throws UpdateException
|
||||
*/
|
||||
void updatePassword(Map<String, Object> params) throws UpdateException;
|
||||
|
||||
/**
|
||||
* 修改用户名
|
||||
*
|
||||
* @param params
|
||||
* @throws UpdateException
|
||||
*/
|
||||
void updateUsername(Map<String, Object> params) throws UpdateException;
|
||||
|
||||
/**
|
||||
* 详情
|
||||
*
|
||||
* @param params
|
||||
* @return
|
||||
* @throws SaveException
|
||||
*/
|
||||
UserPO getPO(Map<String, Object> params) throws SearchException;
|
||||
|
||||
/**
|
||||
* 详情
|
||||
*
|
||||
* @param params
|
||||
* @return
|
||||
* @throws SearchException
|
||||
*/
|
||||
UserDTO get(Map<String, Object> params) throws SearchException;
|
||||
|
||||
/**
|
||||
* 列表
|
||||
*
|
||||
* @param params
|
||||
* @return
|
||||
* @throws SearchException
|
||||
*/
|
||||
List<UserDTO> list(Map<String, Object> params) throws SearchException;
|
||||
|
||||
/**
|
||||
* 总数
|
||||
*
|
||||
* @param params
|
||||
* @return
|
||||
* @throws SearchException
|
||||
*/
|
||||
Integer count(Map<String, Object> params) throws SearchException;
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,194 @@
|
||||
package ink.wgink.service.user.pojo.pos;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* When you feel like quitting. Think about why you started
|
||||
* 当你想要放弃的时候,想想当初你为何开始
|
||||
*
|
||||
* @ClassName: UserPO
|
||||
* @Description: 用户
|
||||
* @Author: wanggeng
|
||||
* @Date: 2021/1/27 10:15 上午
|
||||
* @Version: 1.0
|
||||
*/
|
||||
@ApiModel
|
||||
public class UserPO implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = -9198716902763162718L;
|
||||
private String userId;
|
||||
private String userUsername;
|
||||
private String userPassword;
|
||||
private String userName;
|
||||
private String userPhone;
|
||||
private String userEmail;
|
||||
private String userUKey;
|
||||
private Integer userType;
|
||||
private Integer userState;
|
||||
private String userAvatar;
|
||||
private String lastLoginAddress;
|
||||
private String lastLoginTime;
|
||||
private String userLongitude;
|
||||
private String userLatitude;
|
||||
private Integer loginType;
|
||||
|
||||
public String getUserId() {
|
||||
return userId == null ? "" : userId;
|
||||
}
|
||||
|
||||
public void setUserId(String userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
public String getUserUsername() {
|
||||
return userUsername == null ? "" : userUsername;
|
||||
}
|
||||
|
||||
public void setUserUsername(String userUsername) {
|
||||
this.userUsername = userUsername;
|
||||
}
|
||||
|
||||
public String getUserPassword() {
|
||||
return userPassword == null ? "" : userPassword;
|
||||
}
|
||||
|
||||
public void setUserPassword(String userPassword) {
|
||||
this.userPassword = userPassword;
|
||||
}
|
||||
|
||||
public String getUserName() {
|
||||
return userName == null ? "" : userName;
|
||||
}
|
||||
|
||||
public void setUserName(String userName) {
|
||||
this.userName = userName;
|
||||
}
|
||||
|
||||
public String getUserPhone() {
|
||||
return userPhone == null ? "" : userPhone;
|
||||
}
|
||||
|
||||
public void setUserPhone(String userPhone) {
|
||||
this.userPhone = userPhone;
|
||||
}
|
||||
|
||||
public String getUserEmail() {
|
||||
return userEmail == null ? "" : userEmail;
|
||||
}
|
||||
|
||||
public void setUserEmail(String userEmail) {
|
||||
this.userEmail = userEmail;
|
||||
}
|
||||
|
||||
public String getUserUKey() {
|
||||
return userUKey == null ? "" : userUKey;
|
||||
}
|
||||
|
||||
public void setUserUKey(String userUKey) {
|
||||
this.userUKey = userUKey;
|
||||
}
|
||||
|
||||
public Integer getUserType() {
|
||||
return userType == null ? 0 : userType;
|
||||
}
|
||||
|
||||
public void setUserType(Integer userType) {
|
||||
this.userType = userType;
|
||||
}
|
||||
|
||||
public Integer getUserState() {
|
||||
return userState == null ? 0 : userState;
|
||||
}
|
||||
|
||||
public void setUserState(Integer userState) {
|
||||
this.userState = userState;
|
||||
}
|
||||
|
||||
public String getUserAvatar() {
|
||||
return userAvatar == null ? "" : userAvatar;
|
||||
}
|
||||
|
||||
public void setUserAvatar(String userAvatar) {
|
||||
this.userAvatar = userAvatar;
|
||||
}
|
||||
|
||||
public String getLastLoginAddress() {
|
||||
return lastLoginAddress == null ? "" : lastLoginAddress;
|
||||
}
|
||||
|
||||
public void setLastLoginAddress(String lastLoginAddress) {
|
||||
this.lastLoginAddress = lastLoginAddress;
|
||||
}
|
||||
|
||||
public String getLastLoginTime() {
|
||||
return lastLoginTime == null ? "" : lastLoginTime;
|
||||
}
|
||||
|
||||
public void setLastLoginTime(String lastLoginTime) {
|
||||
this.lastLoginTime = lastLoginTime;
|
||||
}
|
||||
|
||||
public String getUserLongitude() {
|
||||
return userLongitude == null ? "" : userLongitude;
|
||||
}
|
||||
|
||||
public void setUserLongitude(String userLongitude) {
|
||||
this.userLongitude = userLongitude;
|
||||
}
|
||||
|
||||
public String getUserLatitude() {
|
||||
return userLatitude == null ? "" : userLatitude;
|
||||
}
|
||||
|
||||
public void setUserLatitude(String userLatitude) {
|
||||
this.userLatitude = userLatitude;
|
||||
}
|
||||
|
||||
public Integer getLoginType() {
|
||||
return loginType == null ? 0 : loginType;
|
||||
}
|
||||
|
||||
public void setLoginType(Integer loginType) {
|
||||
this.loginType = loginType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
final StringBuilder sb = new StringBuilder("{");
|
||||
sb.append("\"userId\":\"")
|
||||
.append(userId).append('\"');
|
||||
sb.append(",\"userUsername\":\"")
|
||||
.append(userUsername).append('\"');
|
||||
sb.append(",\"userPassword\":\"")
|
||||
.append(userPassword).append('\"');
|
||||
sb.append(",\"userName\":\"")
|
||||
.append(userName).append('\"');
|
||||
sb.append(",\"userPhone\":\"")
|
||||
.append(userPhone).append('\"');
|
||||
sb.append(",\"userEmail\":\"")
|
||||
.append(userEmail).append('\"');
|
||||
sb.append(",\"userUKey\":\"")
|
||||
.append(userUKey).append('\"');
|
||||
sb.append(",\"userType\":")
|
||||
.append(userType);
|
||||
sb.append(",\"userState\":")
|
||||
.append(userState);
|
||||
sb.append(",\"userAvatar\":\"")
|
||||
.append(userAvatar).append('\"');
|
||||
sb.append(",\"lastLoginAddress\":\"")
|
||||
.append(lastLoginAddress).append('\"');
|
||||
sb.append(",\"lastLoginTime\":\"")
|
||||
.append(lastLoginTime).append('\"');
|
||||
sb.append(",\"userLongitude\":\"")
|
||||
.append(userLongitude).append('\"');
|
||||
sb.append(",\"userLatitude\":\"")
|
||||
.append(userLatitude).append('\"');
|
||||
sb.append(",\"loginType\":")
|
||||
.append(loginType);
|
||||
sb.append('}');
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
@ -0,0 +1,126 @@
|
||||
package ink.wgink.service.user.pojo.vos;
|
||||
|
||||
import ink.wgink.annotation.CheckEmptyAnnotation;
|
||||
import ink.wgink.annotation.CheckNumberAnnotation;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
/**
|
||||
* @ClassName: UserVO
|
||||
* @Description: 用户视图对象
|
||||
* @Author: WangGeng
|
||||
* @Date: 2019/3/3 9:49 PM
|
||||
* @Version: 1.0
|
||||
**/
|
||||
@ApiModel
|
||||
public class UserVO {
|
||||
|
||||
@ApiModelProperty(name = "userUsername", value = "用户名")
|
||||
@CheckEmptyAnnotation(name = "用户名")
|
||||
private String userUsername;
|
||||
@ApiModelProperty(name = "userPassword", value = "密码")
|
||||
@CheckEmptyAnnotation(name = "密码")
|
||||
private String userPassword;
|
||||
@ApiModelProperty(name = "userName", value = "昵称")
|
||||
@CheckEmptyAnnotation(name = "昵称")
|
||||
private String userName;
|
||||
@ApiModelProperty(name = "userType", value = "用户类型,1:系统用户,2:普通该用户")
|
||||
@CheckNumberAnnotation(name = "用户类型", types = {"1", "2"})
|
||||
private Integer userType;
|
||||
@ApiModelProperty(name = "userState", value = "用户状态,0:正常,1:冻结,2:锁定")
|
||||
@CheckNumberAnnotation(name = "用户状态", types = {"0", "1", "2"})
|
||||
private Integer userState;
|
||||
@ApiModelProperty(name = "userPhone", value = "用户电话")
|
||||
private String userPhone;
|
||||
@ApiModelProperty(name = "userEmail", value = "用户邮件")
|
||||
private String userEmail;
|
||||
@ApiModelProperty(name = "userAvatar", value = "用户头像ID")
|
||||
private String userAvatar;
|
||||
|
||||
public String getUserUsername() {
|
||||
return userUsername == null ? "" : userUsername.trim();
|
||||
}
|
||||
|
||||
public void setUserUsername(String userUsername) {
|
||||
this.userUsername = userUsername;
|
||||
}
|
||||
|
||||
public String getUserPassword() {
|
||||
return userPassword;
|
||||
}
|
||||
|
||||
public void setUserPassword(String userPassword) {
|
||||
this.userPassword = userPassword;
|
||||
}
|
||||
|
||||
public String getUserName() {
|
||||
return userName == null ? "" : userName.trim();
|
||||
}
|
||||
|
||||
public void setUserName(String userName) {
|
||||
this.userName = userName;
|
||||
}
|
||||
|
||||
public Integer getUserType() {
|
||||
return userType;
|
||||
}
|
||||
|
||||
public void setUserType(Integer userType) {
|
||||
this.userType = userType;
|
||||
}
|
||||
|
||||
public Integer getUserState() {
|
||||
return userState;
|
||||
}
|
||||
|
||||
public void setUserState(Integer userState) {
|
||||
this.userState = userState;
|
||||
}
|
||||
|
||||
public String getUserPhone() {
|
||||
return userPhone == null ? "" : userPhone.trim();
|
||||
}
|
||||
|
||||
public void setUserPhone(String userPhone) {
|
||||
this.userPhone = userPhone;
|
||||
}
|
||||
|
||||
public String getUserEmail() {
|
||||
return userEmail == null ? "" : userEmail.trim();
|
||||
}
|
||||
|
||||
public void setUserEmail(String userEmail) {
|
||||
this.userEmail = userEmail;
|
||||
}
|
||||
|
||||
public String getUserAvatar() {
|
||||
return userAvatar == null ? "" : userAvatar.trim();
|
||||
}
|
||||
|
||||
public void setUserAvatar(String userAvatar) {
|
||||
this.userAvatar = userAvatar;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
final StringBuilder sb = new StringBuilder("{");
|
||||
sb.append("\"userUsername\":\"")
|
||||
.append(userUsername).append('\"');
|
||||
sb.append(",\"userPassword\":\"")
|
||||
.append(userPassword).append('\"');
|
||||
sb.append(",\"userName\":\"")
|
||||
.append(userName).append('\"');
|
||||
sb.append(",\"userType\":")
|
||||
.append(userType);
|
||||
sb.append(",\"userState\":")
|
||||
.append(userState);
|
||||
sb.append(",\"userPhone\":\"")
|
||||
.append(userPhone).append('\"');
|
||||
sb.append(",\"userEmail\":\"")
|
||||
.append(userEmail).append('\"');
|
||||
sb.append(",\"userAvatar\":\"")
|
||||
.append(userAvatar).append('\"');
|
||||
sb.append('}');
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
@ -0,0 +1,57 @@
|
||||
package ink.wgink.service.user.service;
|
||||
|
||||
import ink.wgink.exceptions.RemoveException;
|
||||
import ink.wgink.exceptions.SaveException;
|
||||
import ink.wgink.exceptions.SearchException;
|
||||
import ink.wgink.interfaces.user.IUserBaseService;
|
||||
import ink.wgink.pojo.result.SuccessResult;
|
||||
import ink.wgink.service.user.pojo.vos.UserVO;
|
||||
import ink.wgink.util.map.HashMapUtil;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* When you feel like quitting. Think about why you started
|
||||
* 当你想要放弃的时候,想想当初你为何开始
|
||||
*
|
||||
* @ClassName: IUserService
|
||||
* @Description: 用户
|
||||
* @Author: wanggeng
|
||||
* @Date: 2021/1/25 3:06 下午
|
||||
* @Version: 1.0
|
||||
*/
|
||||
public interface IUserService extends IUserBaseService {
|
||||
|
||||
/**
|
||||
* 保存用户
|
||||
*
|
||||
* @param userVO
|
||||
* @return
|
||||
*/
|
||||
void save(UserVO userVO);
|
||||
|
||||
/**
|
||||
* 注册用户
|
||||
*
|
||||
* @param userVO
|
||||
* @return
|
||||
*/
|
||||
void register(UserVO userVO);
|
||||
|
||||
/**
|
||||
* 删除用户
|
||||
*
|
||||
* @param ids id数组
|
||||
* @return
|
||||
*/
|
||||
void remove(List<String> ids);
|
||||
|
||||
/**
|
||||
* 修改用户
|
||||
*
|
||||
* @param userId
|
||||
* @param userVO
|
||||
* @return
|
||||
*/
|
||||
void update(String userId, UserVO userVO);
|
||||
}
|
@ -1,22 +0,0 @@
|
||||
package ink.wgink.service.user.service;
|
||||
|
||||
import ink.wgink.common.base.DefaultBaseService;
|
||||
import ink.wgink.interfaces.user.IUserService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* When you feel like quitting. Think about why you started
|
||||
* 当你想要放弃的时候,想想当初你为何开始
|
||||
*
|
||||
* @ClassName: UserServiceImpl
|
||||
* @Description: 用户
|
||||
* @Author: WangGeng
|
||||
* @Date: 2021/1/24 20:25
|
||||
* @Version: 1.0
|
||||
**/
|
||||
@Service
|
||||
public class UserServiceImpl extends DefaultBaseService implements IUserService {
|
||||
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,120 @@
|
||||
package ink.wgink.service.user.service.impl;
|
||||
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import ink.wgink.common.base.DefaultBaseService;
|
||||
import ink.wgink.exceptions.SearchException;
|
||||
import ink.wgink.pojo.ListPage;
|
||||
import ink.wgink.pojo.dtos.user.UserDTO;
|
||||
import ink.wgink.pojo.result.SuccessResultList;
|
||||
import ink.wgink.service.user.dao.IUserDao;
|
||||
import ink.wgink.service.user.pojo.vos.UserVO;
|
||||
import ink.wgink.service.user.service.IUserService;
|
||||
import ink.wgink.util.UUIDUtil;
|
||||
import ink.wgink.util.map.HashMapUtil;
|
||||
import org.apache.commons.codec.digest.DigestUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.crypto.password.PasswordEncoder;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* When you feel like quitting. Think about why you started
|
||||
* 当你想要放弃的时候,想想当初你为何开始
|
||||
*
|
||||
* @ClassName: UserServiceImpl
|
||||
* @Description: 用户
|
||||
* @Author: WangGeng
|
||||
* @Date: 2021/1/24 20:25
|
||||
* @Version: 1.0
|
||||
**/
|
||||
@Service
|
||||
public class UserServiceImpl extends DefaultBaseService implements IUserService {
|
||||
|
||||
@Autowired
|
||||
private IUserDao userDao;
|
||||
@Autowired
|
||||
private PasswordEncoder passwordEncoder;
|
||||
|
||||
@Override
|
||||
public synchronized void save(UserVO userVO) {
|
||||
saveUser(userVO, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void register(UserVO userVO) {
|
||||
saveUser(userVO, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存用户
|
||||
*
|
||||
* @param userVO
|
||||
* @param isRegister 是否注册
|
||||
*/
|
||||
private void saveUser(UserVO userVO, boolean isRegister) {
|
||||
UserDTO userDTO = get(userVO.getUserUsername());
|
||||
if (userDTO != null) {
|
||||
throw new SearchException("用户已经存在");
|
||||
}
|
||||
userVO.setUserPassword(passwordEncoder.encode(DigestUtils.md5Hex(DigestUtils.md5Hex(DigestUtils.md5Hex(userVO.getUserPassword())))));
|
||||
String userId = UUIDUtil.getUUID();
|
||||
Map<String, Object> params = HashMapUtil.beanToMap(userVO);
|
||||
params.put("userId", userId);
|
||||
if (isRegister) {
|
||||
setSaveInfoByUserId(params, userId);
|
||||
} else {
|
||||
setSaveInfo(params);
|
||||
}
|
||||
userDao.save(params);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove(List<String> ids) {
|
||||
Map<String, Object> params = getHashMap(2);
|
||||
params.put("ids", ids);
|
||||
setUpdateInfo(params);
|
||||
userDao.remove(params);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(String userId, UserVO userVO) {
|
||||
if (!StringUtils.isBlank(userVO.getUserPassword())) {
|
||||
userVO.setUserPassword(passwordEncoder.encode(DigestUtils.md5Hex(DigestUtils.md5Hex(DigestUtils.md5Hex(userVO.getUserPassword())))));
|
||||
}
|
||||
Map<String, Object> params = HashMapUtil.beanToMap(userVO);
|
||||
setUpdateInfo(params);
|
||||
userDao.update(params);
|
||||
}
|
||||
|
||||
@Override
|
||||
public UserDTO get(String userId) {
|
||||
Map<String, Object> params = getHashMap(2);
|
||||
params.put("userId", userId);
|
||||
return userDao.get(params);
|
||||
}
|
||||
|
||||
@Override
|
||||
public UserDTO getByUsername(String username) {
|
||||
Map<String, Object> params = getHashMap(2);
|
||||
params.put("userUsername", username);
|
||||
return userDao.get(params);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<UserDTO> list(Map<String, Object> params) {
|
||||
return userDao.list(params);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SuccessResultList<List<UserDTO>> listPage(ListPage page) {
|
||||
PageHelper.startPage(page.getPage(), page.getRows());
|
||||
List<UserDTO> userDTOs = list(page.getParams());
|
||||
PageInfo<UserDTO> pageInfo = new PageInfo<>(userDTOs);
|
||||
return new SuccessResultList<>(userDTOs, pageInfo.getPageNum(), pageInfo.getTotal());
|
||||
}
|
||||
|
||||
}
|
366
service-user/src/main/resources/mybatis/mapper/user-mapper.xml
Normal file
366
service-user/src/main/resources/mybatis/mapper/user-mapper.xml
Normal file
@ -0,0 +1,366 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="ink.wgink.service.user.dao.IUserDao">
|
||||
<cache/>
|
||||
|
||||
<resultMap id="userPO" type="ink.wgink.service.user.pojo.pos.UserPO">
|
||||
<id property="userId" column="user_id"/>
|
||||
<result property="userUsername" column="user_username"/>
|
||||
<result property="userPassword" column="user_password"/>
|
||||
<result property="userName" column="user_name"/>
|
||||
<result property="userPhone" column="user_phone"/>
|
||||
<result property="userEmail" column="user_email"/>
|
||||
<result property="userUKey" column="user_ukey"/>
|
||||
<result property="userAvatar" column="user_avatar"/>
|
||||
<result property="userType" column="user_type"/>
|
||||
<result property="userState" column="user_state"/>
|
||||
<result property="lastLoginAddress" column="last_login_address"/>
|
||||
<result property="lastLoginTime" column="last_login_time"/>
|
||||
<result property="userLongitude" column="user_longitude"/>
|
||||
<result property="userLatitude" column="user_latitude"/>
|
||||
<result property="loginType" column="login_type"/>
|
||||
</resultMap>
|
||||
|
||||
<resultMap id="userDTO" type="ink.wgink.pojo.dtos.user.UserDTO">
|
||||
<id property="userId" column="user_id"/>
|
||||
<result property="userUsername" column="user_username"/>
|
||||
<result property="userName" column="user_name"/>
|
||||
<result property="userPhone" column="user_phone"/>
|
||||
<result property="userEmail" column="user_email"/>
|
||||
<result property="userUKey" column="user_ukey"/>
|
||||
<result property="userAvatar" column="user_avatar"/>
|
||||
<result property="userType" column="user_type"/>
|
||||
<result property="userState" column="user_state"/>
|
||||
<result property="lastLoginAddress" column="last_login_address"/>
|
||||
<result property="lastLoginTime" column="last_login_time"/>
|
||||
<result property="userLongitude" column="user_longitude"/>
|
||||
<result property="userLatitude" column="user_latitude"/>
|
||||
<result property="departmentIds" column="department_ids"/>
|
||||
<result property="departmentNames" column="department_names"/>
|
||||
<result property="roleIds" column="role_ids"/>
|
||||
<result property="roleNames" column="role_names"/>
|
||||
<result property="positionIds" column="position_ids"/>
|
||||
<result property="positionNames" column="position_names"/>
|
||||
<result property="loginType" column="login_type"/>
|
||||
<result property="gmtCreate" column="gmt_create"/>
|
||||
</resultMap>
|
||||
|
||||
<!-- 保存用户 -->
|
||||
<insert id="save" parameterType="map" flushCache="true">
|
||||
INSERT INTO sys_user(
|
||||
user_id,
|
||||
user_username,
|
||||
user_password,
|
||||
user_name,
|
||||
user_phone,
|
||||
user_email,
|
||||
user_type,
|
||||
user_state,
|
||||
user_avatar,
|
||||
creator,
|
||||
gmt_create,
|
||||
modifier,
|
||||
gmt_modified,
|
||||
is_delete
|
||||
) VALUES(
|
||||
#{userId},
|
||||
#{userUsername},
|
||||
#{userPassword},
|
||||
#{userName},
|
||||
#{userPhone},
|
||||
#{userEmail},
|
||||
#{userType},
|
||||
#{userState},
|
||||
#{userAvatar},
|
||||
#{creator},
|
||||
#{gmtCreate},
|
||||
#{modifier},
|
||||
#{gmtModified},
|
||||
#{isDelete}
|
||||
)
|
||||
</insert>
|
||||
|
||||
<!-- 删除用户 -->
|
||||
<update id="remove" parameterType="map" flushCache="true">
|
||||
UPDATE
|
||||
sys_user
|
||||
SET
|
||||
is_delete = 1,
|
||||
modifier = #{modifier},
|
||||
gmt_modified = #{gmtModified}
|
||||
WHERE
|
||||
user_id IN
|
||||
<foreach collection="userIds" index="index" open="(" separator="," close=")">
|
||||
#{userIds[${index}]}
|
||||
</foreach>
|
||||
</update>
|
||||
|
||||
<!-- 修改菜单 -->
|
||||
<update id="update" parameterType="map" flushCache="true">
|
||||
UPDATE
|
||||
sys_user
|
||||
SET
|
||||
<if test="userPassword != null and userPassword != ''">
|
||||
user_password = #{userPassword},
|
||||
</if>
|
||||
<if test="userName != null and userName != ''">
|
||||
user_name = #{userName},
|
||||
</if>
|
||||
<if test="userPhone != null and userPhone != ''">
|
||||
user_phone = #{userPhone},
|
||||
</if>
|
||||
<if test="userEmail != null and userEmail != ''">
|
||||
user_email = #{userEmail},
|
||||
</if>
|
||||
<if test="userType != null">
|
||||
user_type = #{userType},
|
||||
</if>
|
||||
<if test="userState != null">
|
||||
user_state = #{userState},
|
||||
</if>
|
||||
<if test="userAvatar != null and userAvatar != ''">
|
||||
user_avatar = #{userAvatar},
|
||||
</if>
|
||||
<if test="lastLoginAddress != null and lastLoginAddress != ''">
|
||||
last_login_address = #{lastLoginAddress},
|
||||
</if>
|
||||
<if test="lastLoginTime != null and lastLoginTime != ''">
|
||||
last_login_time = #{lastLoginTime},
|
||||
</if>
|
||||
<if test="gmtPasswordModified != null and gmtPasswordModified != ''">
|
||||
gmt_password_modified = #{gmtPasswordModified},
|
||||
</if>
|
||||
<if test="userUKey != null and userUKey != ''">
|
||||
user_ukey = #{userUKey},
|
||||
</if>
|
||||
<if test="userUKeyElectronicSecretKey != null and userUKeyElectronicSecretKey != ''">
|
||||
user_ukey_electronic_secret_key = #{userUKeyElectronicSecretKey},
|
||||
</if>
|
||||
<if test="loginType != null">
|
||||
login_type = #{loginType},
|
||||
</if>
|
||||
modifier = #{modifier},
|
||||
gmt_modified = #{gmtModified}
|
||||
WHERE
|
||||
user_id = #{userId}
|
||||
</update>
|
||||
|
||||
<!-- 更新用户密码 -->
|
||||
<update id="updatePassword" parameterType="map" flushCache="true">
|
||||
UPDATE
|
||||
sys_user
|
||||
SET
|
||||
user_password = #{userPassword}
|
||||
WHERE
|
||||
user_id = #{userId}
|
||||
</update>
|
||||
|
||||
<!-- 更新用户名 -->
|
||||
<update id="updateUsername" parameterType="map" flushCache="true">
|
||||
UPDATE
|
||||
sys_user
|
||||
SET
|
||||
user_username = #{userUsername}
|
||||
WHERE
|
||||
user_id = #{userId}
|
||||
</update>
|
||||
|
||||
<!-- 获取用户 -->
|
||||
<select id="getPO" parameterType="map" resultMap="userPO" useCache="true">
|
||||
SELECT
|
||||
user_id,
|
||||
user_password,
|
||||
user_username,
|
||||
user_name,
|
||||
user_phone,
|
||||
user_email,
|
||||
user_ukey,
|
||||
user_ukey_electronic_secret_key,
|
||||
user_type,
|
||||
user_state,
|
||||
user_avatar,
|
||||
user_longitude,
|
||||
user_latitude,
|
||||
last_login_address,
|
||||
LEFT(last_login_time, 19) last_login_time,
|
||||
login_type,
|
||||
gmt_password_modified,
|
||||
remarks,
|
||||
LEFT(gmt_create, 19) gmt_create
|
||||
FROM
|
||||
sys_user
|
||||
WHERE
|
||||
is_delete = 0
|
||||
<if test="userId != null and userId != ''">
|
||||
AND
|
||||
user_id = #{userId}
|
||||
</if>
|
||||
<if test="userUsername != null and userUsername != ''">
|
||||
AND
|
||||
user_username = #{userUsername}
|
||||
</if>
|
||||
<if test="userUKey != null and userUKey != ''">
|
||||
AND
|
||||
user_ukey = #{userUKey}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<!-- 获取用户 -->
|
||||
<select id="get" parameterType="map" resultMap="userDTO" useCache="true">
|
||||
SELECT
|
||||
user_id,
|
||||
user_password,
|
||||
user_username,
|
||||
user_name,
|
||||
user_phone,
|
||||
user_email,
|
||||
user_ukey,
|
||||
user_ukey_electronic_secret_key,
|
||||
user_type,
|
||||
user_state,
|
||||
user_avatar,
|
||||
user_longitude,
|
||||
user_latitude,
|
||||
last_login_address,
|
||||
LEFT(last_login_time, 19) last_login_time,
|
||||
login_type,
|
||||
gmt_password_modified,
|
||||
remarks,
|
||||
LEFT(gmt_create, 19) gmt_create
|
||||
FROM
|
||||
sys_user
|
||||
WHERE
|
||||
is_delete = 0
|
||||
<if test="userId != null and userId != ''">
|
||||
AND
|
||||
user_id = #{userId}
|
||||
</if>
|
||||
<if test="userUsername != null and userUsername != ''">
|
||||
AND
|
||||
user_username = #{userUsername}
|
||||
</if>
|
||||
<if test="userUKey != null and userUKey != ''">
|
||||
AND
|
||||
user_ukey = #{userUKey}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<!-- 用户列表 -->
|
||||
<select id="list" parameterType="map" resultMap="userDTO" useCache="true">
|
||||
SELECT
|
||||
user_id,
|
||||
user_password,
|
||||
user_username,
|
||||
user_name,
|
||||
user_phone,
|
||||
user_email,
|
||||
user_ukey,
|
||||
user_ukey_electronic_secret_key,
|
||||
user_type,
|
||||
user_state,
|
||||
user_avatar,
|
||||
user_longitude,
|
||||
user_latitude,
|
||||
last_login_address,
|
||||
LEFT(last_login_time, 19) last_login_time,
|
||||
login_type,
|
||||
gmt_password_modified,
|
||||
remarks,
|
||||
LEFT(gmt_create, 19) gmt_create
|
||||
FROM
|
||||
sys_user
|
||||
WHERE
|
||||
is_delete = 0
|
||||
AND
|
||||
user_username != 'admin'
|
||||
<if test="userIds != null and userIds.size > 0">
|
||||
AND
|
||||
user_id IN
|
||||
<foreach collection="userIds" index="index" open="(" separator="," close=")">
|
||||
#{userIds[${index}]}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="keywords != null and keywords != ''">
|
||||
AND (
|
||||
user_username LIKE CONCAT('%', #{keywords}, '%')
|
||||
OR
|
||||
user_name LIKE CONCAT('%', #{keywords}, '%')
|
||||
OR
|
||||
user_phone LIKE CONCAT('%', #{keywords}, '%')
|
||||
OR
|
||||
user_email LIKE CONCAT('%', #{keywords}, '%')
|
||||
)
|
||||
</if>
|
||||
<choose>
|
||||
<when test="sort != null and (sort == 'userUsername' or sort == 'userName' or sort == 'userPhone' or sort == 'userEmail' or sort == 'userState' or sort == 'lastLoginAddress' or sort == 'lastLoginTime')">
|
||||
ORDER BY
|
||||
<if test="sort == 'userUsername'">
|
||||
user_username ${order}
|
||||
</if>
|
||||
<if test="sort == 'userName'">
|
||||
user_name ${order}
|
||||
</if>
|
||||
<if test="sort == 'userPhone'">
|
||||
user_phone ${order}
|
||||
</if>
|
||||
<if test="sort == 'userEmail'">
|
||||
user_email ${order}
|
||||
</if>
|
||||
<if test="sort == 'userState'">
|
||||
user_state ${order}
|
||||
</if>
|
||||
<if test="sort == 'lastLoginAddress'">
|
||||
last_login_address ${order}
|
||||
</if>
|
||||
<if test="sort == 'lastLoginTime'">
|
||||
last_login_time ${order}
|
||||
</if>
|
||||
</when>
|
||||
</choose>
|
||||
</select>
|
||||
|
||||
<!-- 统计用户数量 -->
|
||||
<select id="count" parameterType="map" resultType="java.lang.Integer" useCache="true">
|
||||
SELECT
|
||||
count(*)
|
||||
FROM
|
||||
sys_user
|
||||
WHERE
|
||||
is_delete = 0
|
||||
AND
|
||||
user_username != 'admin'
|
||||
<if test="startDay != null and startDay != ''">
|
||||
AND
|
||||
LEFT(gmt_create, 10) <![CDATA[ >= ]]> #{startDay}
|
||||
</if>
|
||||
<if test="endDay != null and endDay != ''">
|
||||
AND
|
||||
LEFT(gmt_create, 10) <![CDATA[ <= ]]> #{endDay}
|
||||
</if>
|
||||
<if test="today != null and today != ''">
|
||||
AND
|
||||
LEFT(gmt_create, 10) = #{today}
|
||||
</if>
|
||||
<if test="userType != null">
|
||||
AND
|
||||
user_type = #{userType}
|
||||
</if>
|
||||
<if test="userState != null">
|
||||
AND
|
||||
user_state = #{userState}
|
||||
</if>
|
||||
<if test="errorUserType != null">
|
||||
AND
|
||||
(user_type <![CDATA[<>]]> 1 AND user_type <![CDATA[<>]]> 2 OR user_type IS NULL)
|
||||
</if>
|
||||
<if test="loginType != null">
|
||||
AND
|
||||
login_type = #{loginType}
|
||||
</if>
|
||||
<if test="errorLoginType != null">
|
||||
AND
|
||||
(login_type <![CDATA[<>]]> 1 AND login_type <![CDATA[<>]]> 2 AND login_type <![CDATA[<>]]> 3 OR login_type IS NULL)
|
||||
</if>
|
||||
</select>
|
||||
|
||||
</mapper>
|
Loading…
Reference in New Issue
Block a user