Compare commits
2 Commits
61cf3929ad
...
cf9eb6a75a
| Author | SHA1 | Date |
|---|---|---|
|
|
cf9eb6a75a | |
|
|
07e797d498 |
12
pom.xml
12
pom.xml
|
|
@ -38,16 +38,6 @@
|
|||
<tomcat.version>9.0.102</tomcat.version>
|
||||
<logback.version>1.2.13</logback.version>
|
||||
<spring-framework.version>5.3.39</spring-framework.version>
|
||||
<lombok.version>1.18.36</lombok.version>
|
||||
<mybatis-plus-boot-starter.version>3.5.1</mybatis-plus-boot-starter.version>
|
||||
<mybatis-plus-join-boot-starter.version>1.5.0</mybatis-plus-join-boot-starter.version>
|
||||
<artemis-http-client.version>1.1.3</artemis-http-client.version>
|
||||
<mybatis-plus-annotation.version>3.5.3.1</mybatis-plus-annotation.version>
|
||||
<mybatis-plus-core.version>3.5.3.1</mybatis-plus-core.version>
|
||||
<mybatis-plus-extension.version>3.5.3.1</mybatis-plus-extension.version>
|
||||
<hutool-all.version>5.1.0</hutool-all.version>
|
||||
<jna.version>5.15.0</jna.version>
|
||||
<org.eclipse.paho.client.mqttv3.version>1.2.5</org.eclipse.paho.client.mqttv3.version>
|
||||
</properties>
|
||||
|
||||
<!-- 依赖声明 -->
|
||||
|
|
@ -366,7 +356,7 @@
|
|||
<!-- 环境标识,需要与配置文件的名称相对应 -->
|
||||
<profiles.active>test</profiles.active>
|
||||
<nacos.username>nacos</nacos.username>
|
||||
<nacos.password>nacos123456</nacos.password>
|
||||
<nacos.password>jRrQh3w6A123</nacos.password>
|
||||
</properties>
|
||||
<activation>
|
||||
<!-- 默认环境 -->
|
||||
|
|
|
|||
|
|
@ -10,7 +10,6 @@
|
|||
|
||||
<modules>
|
||||
<module>tcctyn-api-system</module>
|
||||
<module>tcctyn-api-iot</module>
|
||||
</modules>
|
||||
|
||||
<artifactId>tcctyn-api</artifactId>
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ import org.springframework.web.bind.annotation.PostMapping;
|
|||
import org.springframework.web.bind.annotation.RequestPart;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import com.tcctyn.common.core.constant.ServiceNameConstants;
|
||||
import com.tcctyn.common.core.web.domain.R;
|
||||
import com.tcctyn.common.core.domain.R;
|
||||
import com.tcctyn.system.api.domain.SysFile;
|
||||
import com.tcctyn.system.api.factory.RemoteFileFallbackFactory;
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ import org.springframework.web.bind.annotation.RequestBody;
|
|||
import org.springframework.web.bind.annotation.RequestHeader;
|
||||
import com.tcctyn.common.core.constant.SecurityConstants;
|
||||
import com.tcctyn.common.core.constant.ServiceNameConstants;
|
||||
import com.tcctyn.common.core.web.domain.R;
|
||||
import com.tcctyn.common.core.domain.R;
|
||||
import com.tcctyn.system.api.domain.SysLogininfor;
|
||||
import com.tcctyn.system.api.domain.SysOperLog;
|
||||
import com.tcctyn.system.api.factory.RemoteLogFallbackFactory;
|
||||
|
|
|
|||
|
|
@ -1,16 +1,18 @@
|
|||
package com.tcctyn.system.api;
|
||||
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestHeader;
|
||||
import com.tcctyn.common.core.constant.SecurityConstants;
|
||||
import com.tcctyn.common.core.constant.ServiceNameConstants;
|
||||
import com.tcctyn.common.core.web.domain.R;
|
||||
import com.tcctyn.system.api.domain.SysDept;
|
||||
import com.tcctyn.common.core.domain.R;
|
||||
import com.tcctyn.system.api.domain.SysUser;
|
||||
import com.tcctyn.system.api.factory.RemoteUserFallbackFactory;
|
||||
import com.tcctyn.system.api.model.LoginUser;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 用户服务
|
||||
|
|
@ -27,7 +29,7 @@ public interface RemoteUserService
|
|||
* @param source 请求来源
|
||||
* @return 结果
|
||||
*/
|
||||
@GetMapping("/system/user/info/{username}")
|
||||
@GetMapping("/user/info/{username}")
|
||||
public R<LoginUser> getUserInfo(@PathVariable("username") String username, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
|
||||
|
||||
/**
|
||||
|
|
@ -37,7 +39,7 @@ public interface RemoteUserService
|
|||
* @param source 请求来源
|
||||
* @return 结果
|
||||
*/
|
||||
@PostMapping("/system/user/register")
|
||||
@PostMapping("/user/register")
|
||||
public R<Boolean> registerUserInfo(@RequestBody SysUser sysUser, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
|
||||
|
||||
/**
|
||||
|
|
@ -47,47 +49,6 @@ public interface RemoteUserService
|
|||
* @param source 请求来源
|
||||
* @return 结果
|
||||
*/
|
||||
@PutMapping("/system/user/recordlogin")
|
||||
@PutMapping("/user/recordlogin")
|
||||
public R<Boolean> recordUserLogin(@RequestBody SysUser sysUser, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
|
||||
|
||||
/**
|
||||
* 通过用户ID查询用户
|
||||
*
|
||||
* @return 结果
|
||||
*/
|
||||
@PostMapping("/system/user/selectUserById/{userId}")
|
||||
public R<SysUser> selectUserById(@PathVariable("userId") Long userId);
|
||||
|
||||
/**
|
||||
* 通过条件查询查询用户列表
|
||||
*
|
||||
* @param sysUser 用户信息
|
||||
* @return 结果
|
||||
*/
|
||||
@PostMapping("/system/user/selectUserList")
|
||||
public R<List<SysUser>> selectUserList(@RequestBody SysUser sysUser);
|
||||
|
||||
/**
|
||||
* 获取用户列表用于前端选择器
|
||||
* @param regionId 归属地区id
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/system/user/userNames/{regionId}")
|
||||
public R<List<SysUser>> selectUserByRegionIdList(@PathVariable("regionId") Long regionId) ;
|
||||
/**
|
||||
* 通过用户ID查询用户
|
||||
*
|
||||
* @return 结果
|
||||
*/
|
||||
@PostMapping("/system/dept/selectDeptById/{deptId}")
|
||||
public R<SysDept> selectDeptById(@PathVariable("deptId") Long deptId);
|
||||
|
||||
/**
|
||||
* 通过条件查询查询用户列表
|
||||
*
|
||||
* @return 结果
|
||||
*/
|
||||
@PostMapping("/system/dept/selectDeptList")
|
||||
public R<List<SysDept>> selectDeptList(@RequestBody SysDept sysDept);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import org.slf4j.LoggerFactory;
|
|||
import org.springframework.cloud.openfeign.FallbackFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import com.tcctyn.common.core.web.domain.R;
|
||||
import com.tcctyn.common.core.domain.R;
|
||||
import com.tcctyn.system.api.RemoteFileService;
|
||||
import com.tcctyn.system.api.domain.SysFile;
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import org.slf4j.Logger;
|
|||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.cloud.openfeign.FallbackFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
import com.tcctyn.common.core.web.domain.R;
|
||||
import com.tcctyn.common.core.domain.R;
|
||||
import com.tcctyn.system.api.RemoteLogService;
|
||||
import com.tcctyn.system.api.domain.SysLogininfor;
|
||||
import com.tcctyn.system.api.domain.SysOperLog;
|
||||
|
|
|
|||
|
|
@ -1,17 +1,14 @@
|
|||
package com.tcctyn.system.api.factory;
|
||||
|
||||
import com.tcctyn.system.api.domain.SysDept;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.cloud.openfeign.FallbackFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
import com.tcctyn.common.core.web.domain.R;
|
||||
import com.tcctyn.common.core.domain.R;
|
||||
import com.tcctyn.system.api.RemoteUserService;
|
||||
import com.tcctyn.system.api.domain.SysUser;
|
||||
import com.tcctyn.system.api.model.LoginUser;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 用户服务降级处理
|
||||
*
|
||||
|
|
@ -45,31 +42,6 @@ public class RemoteUserFallbackFactory implements FallbackFactory<RemoteUserServ
|
|||
{
|
||||
return R.fail("记录用户登录信息失败:" + throwable.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public R<SysUser> selectUserById(Long userId) {
|
||||
return R.fail("获取用户信息失败:" + throwable.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public R<List<SysUser>> selectUserList(SysUser sysUser) {
|
||||
return R.fail("获取用户信息列表失败:" + throwable.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public R<List<SysUser>> selectUserByRegionIdList(Long regionId) {
|
||||
return R.fail("获取用户区域id失败:" + throwable.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public R<SysDept> selectDeptById(Long deptId) {
|
||||
return R.fail("获取部门信息失败:" + throwable.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public R<List<SysDept>> selectDeptList(SysDept sysDept) {
|
||||
return R.fail("获取部门信息列表失败:" + throwable.getMessage());
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ import org.springframework.web.bind.annotation.RestController;
|
|||
import com.tcctyn.auth.form.LoginBody;
|
||||
import com.tcctyn.auth.form.RegisterBody;
|
||||
import com.tcctyn.auth.service.SysLoginService;
|
||||
import com.tcctyn.common.core.web.domain.R;
|
||||
import com.tcctyn.common.core.domain.R;
|
||||
import com.tcctyn.common.core.utils.JwtUtils;
|
||||
import com.tcctyn.common.core.utils.StringUtils;
|
||||
import com.tcctyn.common.security.auth.AuthUtil;
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ import com.tcctyn.common.core.constant.CacheConstants;
|
|||
import com.tcctyn.common.core.constant.Constants;
|
||||
import com.tcctyn.common.core.constant.SecurityConstants;
|
||||
import com.tcctyn.common.core.constant.UserConstants;
|
||||
import com.tcctyn.common.core.web.domain.R;
|
||||
import com.tcctyn.common.core.domain.R;
|
||||
import com.tcctyn.common.core.enums.UserStatus;
|
||||
import com.tcctyn.common.core.exception.ServiceException;
|
||||
import com.tcctyn.common.core.text.Convert;
|
||||
|
|
|
|||
|
|
@ -111,33 +111,6 @@
|
|||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>mybatis-plus-annotation</artifactId>
|
||||
<version>${mybatis-plus-annotation.version}</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.eclipse.paho</groupId>
|
||||
<artifactId>org.eclipse.paho.client.mqttv3</artifactId>
|
||||
<version>${org.eclipse.paho.client.mqttv3.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.data</groupId>
|
||||
<artifactId>spring-data-redis</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.security</groupId>
|
||||
<artifactId>spring-security-core</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>cn.hutool</groupId>
|
||||
<artifactId>hutool-all</artifactId>
|
||||
<version>${hutool-all.version}</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
|
|
|
|||
|
|
@ -1,14 +1,13 @@
|
|||
package com.tcctyn.common.core.annotation;
|
||||
|
||||
import com.tcctyn.common.core.utils.poi.ExcelHandlerAdapter;
|
||||
import org.apache.poi.ss.usermodel.HorizontalAlignment;
|
||||
import org.apache.poi.ss.usermodel.IndexedColors;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
import java.math.BigDecimal;
|
||||
import org.apache.poi.ss.usermodel.HorizontalAlignment;
|
||||
import org.apache.poi.ss.usermodel.IndexedColors;
|
||||
import com.tcctyn.common.core.utils.poi.ExcelHandlerAdapter;
|
||||
|
||||
/**
|
||||
* 自定义导出Excel数据注解
|
||||
|
|
@ -34,11 +33,6 @@ public @interface Excel
|
|||
*/
|
||||
public String dateFormat() default "";
|
||||
|
||||
/**
|
||||
* 如果是字典类型,请设置字典的type值 (如: sys_user_sex)
|
||||
*/
|
||||
public String dictType() default "";
|
||||
|
||||
/**
|
||||
* 读取内容转表达式 (如: 0=男,1=女,2=未知)
|
||||
*/
|
||||
|
|
@ -84,16 +78,16 @@ public @interface Excel
|
|||
*/
|
||||
public String prompt() default "";
|
||||
|
||||
/**
|
||||
* 是否允许内容换行
|
||||
*/
|
||||
public boolean wrapText() default false;
|
||||
|
||||
/**
|
||||
* 设置只能选择不能输入的列内容.
|
||||
*/
|
||||
public String[] combo() default {};
|
||||
|
||||
/**
|
||||
* 是否从字典读数据到combo,默认不读取,如读取需要设置dictType注解.
|
||||
*/
|
||||
public boolean comboReadDict() default false;
|
||||
|
||||
/**
|
||||
* 是否需要纵向合并单元格,应对需求:含有list集合单元格)
|
||||
*/
|
||||
|
|
@ -115,7 +109,7 @@ public @interface Excel
|
|||
public boolean isStatistics() default false;
|
||||
|
||||
/**
|
||||
* 导出类型(0数字 1字符串 2图片)
|
||||
* 导出类型(0数字 1字符串)
|
||||
*/
|
||||
public ColumnType cellType() default ColumnType.STRING;
|
||||
|
||||
|
|
|
|||
|
|
@ -14,5 +14,5 @@ import java.lang.annotation.Target;
|
|||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface Excels
|
||||
{
|
||||
public Excel[] value();
|
||||
}
|
||||
Excel[] value();
|
||||
}
|
||||
|
|
@ -1,47 +1,12 @@
|
|||
package com.tcctyn.common.core.constant;
|
||||
|
||||
/**
|
||||
* 缓存的key 常量
|
||||
* 缓存常量信息
|
||||
*
|
||||
* @author tcctyn
|
||||
*/
|
||||
public class CacheConstants
|
||||
{
|
||||
/**
|
||||
* 登录用户 redis key
|
||||
*/
|
||||
public static final String LOGIN_TOKEN_KEY = "login_tokens:";
|
||||
|
||||
/**
|
||||
* 验证码 redis key
|
||||
*/
|
||||
public static final String CAPTCHA_CODE_KEY = "captcha_codes:";
|
||||
|
||||
/**
|
||||
* 参数管理 cache key
|
||||
*/
|
||||
public static final String SYS_CONFIG_KEY = "sys_config:";
|
||||
|
||||
/**
|
||||
* 字典管理 cache key
|
||||
*/
|
||||
public static final String SYS_DICT_KEY = "sys_dict:";
|
||||
|
||||
/**
|
||||
* 防重提交 redis key
|
||||
*/
|
||||
public static final String REPEAT_SUBMIT_KEY = "repeat_submit:";
|
||||
|
||||
/**
|
||||
* 限流 redis key
|
||||
*/
|
||||
public static final String RATE_LIMIT_KEY = "rate_limit:";
|
||||
|
||||
/**
|
||||
* 登录账户密码错误次数 redis key
|
||||
*/
|
||||
public static final String PWD_ERR_CNT_KEY = "pwd_err_cnt:";
|
||||
|
||||
/**
|
||||
* 缓存有效期,默认720(分钟)
|
||||
*/
|
||||
|
|
@ -62,6 +27,30 @@ public class CacheConstants
|
|||
*/
|
||||
public final static long PASSWORD_LOCK_TIME = 10;
|
||||
|
||||
/**
|
||||
* 权限缓存前缀
|
||||
*/
|
||||
public final static String LOGIN_TOKEN_KEY = "login_tokens:";
|
||||
|
||||
/**
|
||||
* 验证码 redis key
|
||||
*/
|
||||
public static final String CAPTCHA_CODE_KEY = "captcha_codes:";
|
||||
|
||||
/**
|
||||
* 参数管理 cache key
|
||||
*/
|
||||
public static final String SYS_CONFIG_KEY = "sys_config:";
|
||||
|
||||
/**
|
||||
* 字典管理 cache key
|
||||
*/
|
||||
public static final String SYS_DICT_KEY = "sys_dict:";
|
||||
|
||||
/**
|
||||
* 登录账户密码错误次数 redis key
|
||||
*/
|
||||
public static final String PWD_ERR_CNT_KEY = "pwd_err_cnt:";
|
||||
|
||||
/**
|
||||
* 登录IP黑名单 cache key
|
||||
|
|
|
|||
|
|
@ -1,12 +1,8 @@
|
|||
package com.tcctyn.common.core.constant;
|
||||
|
||||
import io.jsonwebtoken.Claims;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* 通用常量信息
|
||||
*
|
||||
*
|
||||
* @author tcctyn
|
||||
*/
|
||||
public class Constants
|
||||
|
|
@ -21,16 +17,26 @@ public class Constants
|
|||
*/
|
||||
public static final String GBK = "GBK";
|
||||
|
||||
/**
|
||||
* 系统语言
|
||||
*/
|
||||
public static final Locale DEFAULT_LOCALE = Locale.SIMPLIFIED_CHINESE;
|
||||
|
||||
/**
|
||||
* www主域
|
||||
*/
|
||||
public static final String WWW = "www.";
|
||||
|
||||
/**
|
||||
* RMI 远程方法调用
|
||||
*/
|
||||
public static final String LOOKUP_RMI = "rmi:";
|
||||
|
||||
/**
|
||||
* LDAP 远程方法调用
|
||||
*/
|
||||
public static final String LOOKUP_LDAP = "ldap:";
|
||||
|
||||
/**
|
||||
* LDAPS 远程方法调用
|
||||
*/
|
||||
public static final String LOOKUP_LDAPS = "ldaps:";
|
||||
|
||||
/**
|
||||
* http请求
|
||||
*/
|
||||
|
|
@ -42,14 +48,24 @@ public class Constants
|
|||
public static final String HTTPS = "https://";
|
||||
|
||||
/**
|
||||
* 通用成功标识
|
||||
* 成功标记
|
||||
*/
|
||||
public static final String SUCCESS = "0";
|
||||
public static final Integer SUCCESS = 200;
|
||||
|
||||
/**
|
||||
* 通用失败标识
|
||||
* 失败标记
|
||||
*/
|
||||
public static final String FAIL = "1";
|
||||
public static final Integer FAIL = 500;
|
||||
|
||||
/**
|
||||
* 登录成功状态
|
||||
*/
|
||||
public static final String LOGIN_SUCCESS_STATUS = "0";
|
||||
|
||||
/**
|
||||
* 登录失败状态
|
||||
*/
|
||||
public static final String LOGIN_FAIL_STATUS = "1";
|
||||
|
||||
/**
|
||||
* 登录成功
|
||||
|
|
@ -72,91 +88,35 @@ public class Constants
|
|||
public static final String LOGIN_FAIL = "Error";
|
||||
|
||||
/**
|
||||
* 所有权限标识
|
||||
* 当前记录起始索引
|
||||
*/
|
||||
public static final String ALL_PERMISSION = "*:*:*";
|
||||
public static final String PAGE_NUM = "pageNum";
|
||||
|
||||
/**
|
||||
* 管理员角色权限标识
|
||||
* 每页显示记录数
|
||||
*/
|
||||
public static final String SUPER_ADMIN = "admin";
|
||||
public static final String PAGE_SIZE = "pageSize";
|
||||
|
||||
/**
|
||||
* 角色权限分隔符
|
||||
* 排序列
|
||||
*/
|
||||
public static final String ROLE_DELIMETER = ",";
|
||||
public static final String ORDER_BY_COLUMN = "orderByColumn";
|
||||
|
||||
/**
|
||||
* 权限标识分隔符
|
||||
* 排序的方向 "desc" 或者 "asc".
|
||||
*/
|
||||
public static final String PERMISSION_DELIMETER = ",";
|
||||
|
||||
public static final String IS_ASC = "isAsc";
|
||||
|
||||
/**
|
||||
* 验证码有效期(分钟)
|
||||
*/
|
||||
public static final long CAPTCHA_EXPIRATION = 2;
|
||||
|
||||
/**
|
||||
* 令牌
|
||||
*/
|
||||
public static final String TOKEN = "token";
|
||||
|
||||
/**
|
||||
* 令牌前缀
|
||||
*/
|
||||
public static final String TOKEN_PREFIX = "Bearer ";
|
||||
|
||||
/**
|
||||
* 令牌前缀
|
||||
*/
|
||||
public static final String LOGIN_USER_KEY = "login_user_key";
|
||||
|
||||
/**
|
||||
* 用户ID
|
||||
*/
|
||||
public static final String JWT_USERID = "userid";
|
||||
|
||||
/**
|
||||
* 用户名称
|
||||
*/
|
||||
public static final String JWT_USERNAME = Claims.SUBJECT;
|
||||
|
||||
/**
|
||||
* 用户头像
|
||||
*/
|
||||
public static final String JWT_AVATAR = "avatar";
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
public static final String JWT_CREATED = "created";
|
||||
|
||||
/**
|
||||
* 用户权限
|
||||
*/
|
||||
public static final String JWT_AUTHORITIES = "authorities";
|
||||
|
||||
/**
|
||||
* 资源映射路径 前缀
|
||||
*/
|
||||
public static final String RESOURCE_PREFIX = "/profile";
|
||||
|
||||
/**
|
||||
* RMI 远程方法调用
|
||||
*/
|
||||
public static final String LOOKUP_RMI = "rmi:";
|
||||
|
||||
/**
|
||||
* LDAP 远程方法调用
|
||||
*/
|
||||
public static final String LOOKUP_LDAP = "ldap:";
|
||||
|
||||
/**
|
||||
* LDAPS 远程方法调用
|
||||
*/
|
||||
public static final String LOOKUP_LDAPS = "ldaps:";
|
||||
|
||||
/**
|
||||
* 自动识别json对象白名单配置(仅允许解析的包名,范围越小越安全)
|
||||
*/
|
||||
|
|
@ -165,21 +125,11 @@ public class Constants
|
|||
/**
|
||||
* 定时任务白名单配置(仅允许访问的包名,如其他需要可以自行添加)
|
||||
*/
|
||||
public static final String[] JOB_WHITELIST_STR = { "com.tcctyn.quartz.task" };
|
||||
|
||||
/**
|
||||
* 登录成功状态
|
||||
*/
|
||||
public static final String LOGIN_SUCCESS_STATUS = "0";
|
||||
|
||||
/**
|
||||
* 登录失败状态
|
||||
*/
|
||||
public static final String LOGIN_FAIL_STATUS = "1";
|
||||
public static final String[] JOB_WHITELIST_STR = { "com.tcctyn.job.task" };
|
||||
|
||||
/**
|
||||
* 定时任务违规的字符
|
||||
*/
|
||||
public static final String[] JOB_ERROR_STR = { "java.net.URL", "javax.naming.InitialContext", "org.yaml.snakeyaml",
|
||||
"org.springframework", "org.apache", "com.tcctyn.common.utils.file", "com.tcctyn.common.config", "com.tcctyn.generator" };
|
||||
"org.springframework", "org.apache", "com.tcctyn.common.core.utils.file" };
|
||||
}
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ public class GenConstants
|
|||
public static final String[] BASE_ENTITY = { "createBy", "createTime", "updateBy", "updateTime", "remark" };
|
||||
|
||||
/** Tree基类字段 */
|
||||
public static final String[] TREE_ENTITY = { "parentName", "parentId", "orderNum", "ancestors", "children" };
|
||||
public static final String[] TREE_ENTITY = { "parentName", "parentId", "orderNum", "ancestors" };
|
||||
|
||||
/** 文本框 */
|
||||
public static final String HTML_INPUT = "input";
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ package com.tcctyn.common.core.constant;
|
|||
|
||||
/**
|
||||
* 用户常量信息
|
||||
*
|
||||
*
|
||||
* @author tcctyn
|
||||
*/
|
||||
public class UserConstants
|
||||
|
|
|
|||
|
|
@ -1,8 +1,7 @@
|
|||
package com.tcctyn.common.core.web.domain;
|
||||
|
||||
import com.tcctyn.common.core.constant.HttpStatus;
|
||||
package com.tcctyn.common.core.domain;
|
||||
|
||||
import java.io.Serializable;
|
||||
import com.tcctyn.common.core.constant.Constants;
|
||||
|
||||
/**
|
||||
* 响应信息主体
|
||||
|
|
@ -14,10 +13,10 @@ public class R<T> implements Serializable
|
|||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 成功 */
|
||||
public static final int SUCCESS = HttpStatus.SUCCESS;
|
||||
public static final int SUCCESS = Constants.SUCCESS;
|
||||
|
||||
/** 失败 */
|
||||
public static final int FAIL = HttpStatus.ERROR;
|
||||
public static final int FAIL = Constants.FAIL;
|
||||
|
||||
private int code;
|
||||
|
||||
|
|
@ -27,12 +26,12 @@ public class R<T> implements Serializable
|
|||
|
||||
public static <T> R<T> ok()
|
||||
{
|
||||
return restResult(null, SUCCESS, "操作成功");
|
||||
return restResult(null, SUCCESS, null);
|
||||
}
|
||||
|
||||
public static <T> R<T> ok(T data)
|
||||
{
|
||||
return restResult(data, SUCCESS, "操作成功");
|
||||
return restResult(data, SUCCESS, null);
|
||||
}
|
||||
|
||||
public static <T> R<T> ok(T data, String msg)
|
||||
|
|
@ -42,7 +41,7 @@ public class R<T> implements Serializable
|
|||
|
||||
public static <T> R<T> fail()
|
||||
{
|
||||
return restResult(null, FAIL, "操作失败");
|
||||
return restResult(null, FAIL, null);
|
||||
}
|
||||
|
||||
public static <T> R<T> fail(String msg)
|
||||
|
|
@ -52,7 +51,7 @@ public class R<T> implements Serializable
|
|||
|
||||
public static <T> R<T> fail(T data)
|
||||
{
|
||||
return restResult(data, FAIL, "操作失败");
|
||||
return restResult(data, FAIL, null);
|
||||
}
|
||||
|
||||
public static <T> R<T> fail(T data, String msg)
|
||||
|
|
@ -1,8 +1,5 @@
|
|||
package com.tcctyn.common.core.exception.base;
|
||||
|
||||
import com.tcctyn.common.core.utils.MessageUtils;
|
||||
import com.tcctyn.common.core.utils.StringUtils;
|
||||
|
||||
/**
|
||||
* 基础异常
|
||||
*
|
||||
|
|
@ -60,21 +57,6 @@ public class BaseException extends RuntimeException
|
|||
this(null, null, null, defaultMessage);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMessage()
|
||||
{
|
||||
String message = null;
|
||||
if (!StringUtils.isEmpty(code))
|
||||
{
|
||||
message = MessageUtils.message(code, args);
|
||||
}
|
||||
if (message == null)
|
||||
{
|
||||
message = defaultMessage;
|
||||
}
|
||||
return message;
|
||||
}
|
||||
|
||||
public String getModule()
|
||||
{
|
||||
return module;
|
||||
|
|
|
|||
|
|
@ -11,9 +11,9 @@ public class FileException extends BaseException
|
|||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public FileException(String code, Object[] args)
|
||||
public FileException(String code, Object[] args, String msg)
|
||||
{
|
||||
super("file", code, args, null);
|
||||
super("file", code, args, msg);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,6 +11,6 @@ public class FileNameLengthLimitExceededException extends FileException
|
|||
|
||||
public FileNameLengthLimitExceededException(int defaultFileNameLength)
|
||||
{
|
||||
super("upload.filename.exceed.length", new Object[] { defaultFileNameLength });
|
||||
super("upload.filename.exceed.length", new Object[] { defaultFileNameLength }, "the filename is too long");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,6 +11,6 @@ public class FileSizeLimitExceededException extends FileException
|
|||
|
||||
public FileSizeLimitExceededException(long defaultMaxSize)
|
||||
{
|
||||
super("upload.exceed.maxSize", new Object[] { defaultMaxSize });
|
||||
super("upload.exceed.maxSize", new Object[] { defaultMaxSize }, "the filesize is too large");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ public class InvalidExtensionException extends FileUploadException
|
|||
|
||||
public InvalidExtensionException(String[] allowedExtension, String extension, String filename)
|
||||
{
|
||||
super("文件[" + filename + "]后缀[" + extension + "]不正确,请上传" + Arrays.toString(allowedExtension) + "格式");
|
||||
super("filename : [" + filename + "], extension : [" + extension + "], allowed extension : [" + Arrays.toString(allowedExtension) + "]");
|
||||
this.allowedExtension = allowedExtension;
|
||||
this.extension = extension;
|
||||
this.filename = filename;
|
||||
|
|
@ -67,7 +67,7 @@ public class InvalidExtensionException extends FileUploadException
|
|||
super(allowedExtension, extension, filename);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static class InvalidVideoExtensionException extends InvalidExtensionException
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
|
|
|||
|
|
@ -1,9 +1,8 @@
|
|||
package com.tcctyn.common.core.text;
|
||||
|
||||
import com.tcctyn.common.core.utils.StringUtils;
|
||||
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import com.tcctyn.common.core.utils.StringUtils;
|
||||
|
||||
/**
|
||||
* 字符集工具类
|
||||
|
|
|
|||
|
|
@ -1,8 +1,5 @@
|
|||
package com.tcctyn.common.core.text;
|
||||
|
||||
import com.tcctyn.common.core.utils.StringUtils;
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.BigInteger;
|
||||
import java.math.RoundingMode;
|
||||
|
|
@ -10,10 +7,11 @@ import java.nio.ByteBuffer;
|
|||
import java.nio.charset.Charset;
|
||||
import java.text.NumberFormat;
|
||||
import java.util.Set;
|
||||
import com.tcctyn.common.core.utils.StringUtils;
|
||||
|
||||
/**
|
||||
* 类型转换器
|
||||
*
|
||||
*
|
||||
* @author tcctyn
|
||||
*/
|
||||
public class Convert
|
||||
|
|
@ -22,7 +20,7 @@ public class Convert
|
|||
* 转换为字符串<br>
|
||||
* 如果给定的值为null,或者转换失败,返回默认值<br>
|
||||
* 转换失败不会报错
|
||||
*
|
||||
*
|
||||
* @param value 被转换的值
|
||||
* @param defaultValue 转换错误时的默认值
|
||||
* @return 结果
|
||||
|
|
@ -44,7 +42,7 @@ public class Convert
|
|||
* 转换为字符串<br>
|
||||
* 如果给定的值为<code>null</code>,或者转换失败,返回默认值<code>null</code><br>
|
||||
* 转换失败不会报错
|
||||
*
|
||||
*
|
||||
* @param value 被转换的值
|
||||
* @return 结果
|
||||
*/
|
||||
|
|
@ -57,7 +55,7 @@ public class Convert
|
|||
* 转换为字符<br>
|
||||
* 如果给定的值为null,或者转换失败,返回默认值<br>
|
||||
* 转换失败不会报错
|
||||
*
|
||||
*
|
||||
* @param value 被转换的值
|
||||
* @param defaultValue 转换错误时的默认值
|
||||
* @return 结果
|
||||
|
|
@ -81,7 +79,7 @@ public class Convert
|
|||
* 转换为字符<br>
|
||||
* 如果给定的值为<code>null</code>,或者转换失败,返回默认值<code>null</code><br>
|
||||
* 转换失败不会报错
|
||||
*
|
||||
*
|
||||
* @param value 被转换的值
|
||||
* @return 结果
|
||||
*/
|
||||
|
|
@ -94,7 +92,7 @@ public class Convert
|
|||
* 转换为byte<br>
|
||||
* 如果给定的值为<code>null</code>,或者转换失败,返回默认值<br>
|
||||
* 转换失败不会报错
|
||||
*
|
||||
*
|
||||
* @param value 被转换的值
|
||||
* @param defaultValue 转换错误时的默认值
|
||||
* @return 结果
|
||||
|
|
@ -132,7 +130,7 @@ public class Convert
|
|||
* 转换为byte<br>
|
||||
* 如果给定的值为<code>null</code>,或者转换失败,返回默认值<code>null</code><br>
|
||||
* 转换失败不会报错
|
||||
*
|
||||
*
|
||||
* @param value 被转换的值
|
||||
* @return 结果
|
||||
*/
|
||||
|
|
@ -145,7 +143,7 @@ public class Convert
|
|||
* 转换为Short<br>
|
||||
* 如果给定的值为<code>null</code>,或者转换失败,返回默认值<br>
|
||||
* 转换失败不会报错
|
||||
*
|
||||
*
|
||||
* @param value 被转换的值
|
||||
* @param defaultValue 转换错误时的默认值
|
||||
* @return 结果
|
||||
|
|
@ -183,7 +181,7 @@ public class Convert
|
|||
* 转换为Short<br>
|
||||
* 如果给定的值为<code>null</code>,或者转换失败,返回默认值<code>null</code><br>
|
||||
* 转换失败不会报错
|
||||
*
|
||||
*
|
||||
* @param value 被转换的值
|
||||
* @return 结果
|
||||
*/
|
||||
|
|
@ -196,7 +194,7 @@ public class Convert
|
|||
* 转换为Number<br>
|
||||
* 如果给定的值为空,或者转换失败,返回默认值<br>
|
||||
* 转换失败不会报错
|
||||
*
|
||||
*
|
||||
* @param value 被转换的值
|
||||
* @param defaultValue 转换错误时的默认值
|
||||
* @return 结果
|
||||
|
|
@ -230,7 +228,7 @@ public class Convert
|
|||
* 转换为Number<br>
|
||||
* 如果给定的值为空,或者转换失败,返回默认值<code>null</code><br>
|
||||
* 转换失败不会报错
|
||||
*
|
||||
*
|
||||
* @param value 被转换的值
|
||||
* @return 结果
|
||||
*/
|
||||
|
|
@ -243,7 +241,7 @@ public class Convert
|
|||
* 转换为int<br>
|
||||
* 如果给定的值为空,或者转换失败,返回默认值<br>
|
||||
* 转换失败不会报错
|
||||
*
|
||||
*
|
||||
* @param value 被转换的值
|
||||
* @param defaultValue 转换错误时的默认值
|
||||
* @return 结果
|
||||
|
|
@ -281,7 +279,7 @@ public class Convert
|
|||
* 转换为int<br>
|
||||
* 如果给定的值为<code>null</code>,或者转换失败,返回默认值<code>null</code><br>
|
||||
* 转换失败不会报错
|
||||
*
|
||||
*
|
||||
* @param value 被转换的值
|
||||
* @return 结果
|
||||
*/
|
||||
|
|
@ -292,7 +290,7 @@ public class Convert
|
|||
|
||||
/**
|
||||
* 转换为Integer数组<br>
|
||||
*
|
||||
*
|
||||
* @param str 被转换的值
|
||||
* @return 结果
|
||||
*/
|
||||
|
|
@ -303,7 +301,7 @@ public class Convert
|
|||
|
||||
/**
|
||||
* 转换为Long数组<br>
|
||||
*
|
||||
*
|
||||
* @param str 被转换的值
|
||||
* @return 结果
|
||||
*/
|
||||
|
|
@ -314,9 +312,9 @@ public class Convert
|
|||
|
||||
/**
|
||||
* 转换为Integer数组<br>
|
||||
*
|
||||
*
|
||||
* @param split 分隔符
|
||||
* @param split 被转换的值
|
||||
* @param str 被转换的值
|
||||
* @return 结果
|
||||
*/
|
||||
public static Integer[] toIntArray(String split, String str)
|
||||
|
|
@ -337,7 +335,7 @@ public class Convert
|
|||
|
||||
/**
|
||||
* 转换为Long数组<br>
|
||||
*
|
||||
*
|
||||
* @param split 分隔符
|
||||
* @param str 被转换的值
|
||||
* @return 结果
|
||||
|
|
@ -360,7 +358,7 @@ public class Convert
|
|||
|
||||
/**
|
||||
* 转换为String数组<br>
|
||||
*
|
||||
*
|
||||
* @param str 被转换的值
|
||||
* @return 结果
|
||||
*/
|
||||
|
|
@ -375,9 +373,9 @@ public class Convert
|
|||
|
||||
/**
|
||||
* 转换为String数组<br>
|
||||
*
|
||||
*
|
||||
* @param split 分隔符
|
||||
* @param split 被转换的值
|
||||
* @param str 被转换的值
|
||||
* @return 结果
|
||||
*/
|
||||
public static String[] toStrArray(String split, String str)
|
||||
|
|
@ -389,7 +387,7 @@ public class Convert
|
|||
* 转换为long<br>
|
||||
* 如果给定的值为空,或者转换失败,返回默认值<br>
|
||||
* 转换失败不会报错
|
||||
*
|
||||
*
|
||||
* @param value 被转换的值
|
||||
* @param defaultValue 转换错误时的默认值
|
||||
* @return 结果
|
||||
|
|
@ -428,7 +426,7 @@ public class Convert
|
|||
* 转换为long<br>
|
||||
* 如果给定的值为<code>null</code>,或者转换失败,返回默认值<code>null</code><br>
|
||||
* 转换失败不会报错
|
||||
*
|
||||
*
|
||||
* @param value 被转换的值
|
||||
* @return 结果
|
||||
*/
|
||||
|
|
@ -441,7 +439,7 @@ public class Convert
|
|||
* 转换为double<br>
|
||||
* 如果给定的值为空,或者转换失败,返回默认值<br>
|
||||
* 转换失败不会报错
|
||||
*
|
||||
*
|
||||
* @param value 被转换的值
|
||||
* @param defaultValue 转换错误时的默认值
|
||||
* @return 结果
|
||||
|
|
@ -480,7 +478,7 @@ public class Convert
|
|||
* 转换为double<br>
|
||||
* 如果给定的值为空,或者转换失败,返回默认值<code>null</code><br>
|
||||
* 转换失败不会报错
|
||||
*
|
||||
*
|
||||
* @param value 被转换的值
|
||||
* @return 结果
|
||||
*/
|
||||
|
|
@ -493,7 +491,7 @@ public class Convert
|
|||
* 转换为Float<br>
|
||||
* 如果给定的值为空,或者转换失败,返回默认值<br>
|
||||
* 转换失败不会报错
|
||||
*
|
||||
*
|
||||
* @param value 被转换的值
|
||||
* @param defaultValue 转换错误时的默认值
|
||||
* @return 结果
|
||||
|
|
@ -531,7 +529,7 @@ public class Convert
|
|||
* 转换为Float<br>
|
||||
* 如果给定的值为空,或者转换失败,返回默认值<code>null</code><br>
|
||||
* 转换失败不会报错
|
||||
*
|
||||
*
|
||||
* @param value 被转换的值
|
||||
* @return 结果
|
||||
*/
|
||||
|
|
@ -542,7 +540,7 @@ public class Convert
|
|||
|
||||
/**
|
||||
* 转换为boolean<br>
|
||||
* String支持的值为:true、false、yes、ok、no,1,0 如果给定的值为空,或者转换失败,返回默认值<br>
|
||||
* String支持的值为:true、false、yes、ok、no、1、0、是、否, 如果给定的值为空,或者转换失败,返回默认值<br>
|
||||
* 转换失败不会报错
|
||||
*
|
||||
* @param value 被转换的值
|
||||
|
|
@ -571,10 +569,12 @@ public class Convert
|
|||
case "yes":
|
||||
case "ok":
|
||||
case "1":
|
||||
case "是":
|
||||
return true;
|
||||
case "false":
|
||||
case "no":
|
||||
case "0":
|
||||
case "否":
|
||||
return false;
|
||||
default:
|
||||
return defaultValue;
|
||||
|
|
@ -585,7 +585,7 @@ public class Convert
|
|||
* 转换为boolean<br>
|
||||
* 如果给定的值为空,或者转换失败,返回默认值<code>null</code><br>
|
||||
* 转换失败不会报错
|
||||
*
|
||||
*
|
||||
* @param value 被转换的值
|
||||
* @return 结果
|
||||
*/
|
||||
|
|
@ -597,7 +597,7 @@ public class Convert
|
|||
/**
|
||||
* 转换为Enum对象<br>
|
||||
* 如果给定的值为空,或者转换失败,返回默认值<br>
|
||||
*
|
||||
*
|
||||
* @param clazz Enum的Class
|
||||
* @param value 值
|
||||
* @param defaultValue 默认值
|
||||
|
|
@ -633,7 +633,7 @@ public class Convert
|
|||
/**
|
||||
* 转换为Enum对象<br>
|
||||
* 如果给定的值为空,或者转换失败,返回默认值<code>null</code><br>
|
||||
*
|
||||
*
|
||||
* @param clazz Enum的Class
|
||||
* @param value 值
|
||||
* @return Enum
|
||||
|
|
@ -647,7 +647,7 @@ public class Convert
|
|||
* 转换为BigInteger<br>
|
||||
* 如果给定的值为空,或者转换失败,返回默认值<br>
|
||||
* 转换失败不会报错
|
||||
*
|
||||
*
|
||||
* @param value 被转换的值
|
||||
* @param defaultValue 转换错误时的默认值
|
||||
* @return 结果
|
||||
|
|
@ -685,7 +685,7 @@ public class Convert
|
|||
* 转换为BigInteger<br>
|
||||
* 如果给定的值为空,或者转换失败,返回默认值<code>null</code><br>
|
||||
* 转换失败不会报错
|
||||
*
|
||||
*
|
||||
* @param value 被转换的值
|
||||
* @return 结果
|
||||
*/
|
||||
|
|
@ -698,7 +698,7 @@ public class Convert
|
|||
* 转换为BigDecimal<br>
|
||||
* 如果给定的值为空,或者转换失败,返回默认值<br>
|
||||
* 转换失败不会报错
|
||||
*
|
||||
*
|
||||
* @param value 被转换的值
|
||||
* @param defaultValue 转换错误时的默认值
|
||||
* @return 结果
|
||||
|
|
@ -744,7 +744,7 @@ public class Convert
|
|||
* 转换为BigDecimal<br>
|
||||
* 如果给定的值为空,或者转换失败,返回默认值<br>
|
||||
* 转换失败不会报错
|
||||
*
|
||||
*
|
||||
* @param value 被转换的值
|
||||
* @return 结果
|
||||
*/
|
||||
|
|
@ -756,7 +756,7 @@ public class Convert
|
|||
/**
|
||||
* 将对象转为字符串<br>
|
||||
* 1、Byte数组和ByteBuffer会被转换为对应字符串的数组 2、对象数组会调用Arrays.toString方法
|
||||
*
|
||||
*
|
||||
* @param obj 对象
|
||||
* @return 字符串
|
||||
*/
|
||||
|
|
@ -768,7 +768,7 @@ public class Convert
|
|||
/**
|
||||
* 将对象转为字符串<br>
|
||||
* 1、Byte数组和ByteBuffer会被转换为对应字符串的数组 2、对象数组会调用Arrays.toString方法
|
||||
*
|
||||
*
|
||||
* @param obj 对象
|
||||
* @param charsetName 字符集
|
||||
* @return 字符串
|
||||
|
|
@ -781,7 +781,7 @@ public class Convert
|
|||
/**
|
||||
* 将对象转为字符串<br>
|
||||
* 1、Byte数组和ByteBuffer会被转换为对应字符串的数组 2、对象数组会调用Arrays.toString方法
|
||||
*
|
||||
*
|
||||
* @param obj 对象
|
||||
* @param charset 字符集
|
||||
* @return 字符串
|
||||
|
|
@ -797,14 +797,23 @@ public class Convert
|
|||
{
|
||||
return (String) obj;
|
||||
}
|
||||
else if (obj instanceof byte[])
|
||||
else if (obj instanceof byte[] || obj instanceof Byte[])
|
||||
{
|
||||
return str((byte[]) obj, charset);
|
||||
}
|
||||
else if (obj instanceof Byte[])
|
||||
{
|
||||
byte[] bytes = ArrayUtils.toPrimitive((Byte[]) obj);
|
||||
return str(bytes, charset);
|
||||
if (obj instanceof byte[])
|
||||
{
|
||||
return str((byte[]) obj, charset);
|
||||
}
|
||||
else
|
||||
{
|
||||
Byte[] bytes = (Byte[]) obj;
|
||||
int length = bytes.length;
|
||||
byte[] dest = new byte[length];
|
||||
for (int i = 0; i < length; i++)
|
||||
{
|
||||
dest[i] = bytes[i];
|
||||
}
|
||||
return str(dest, charset);
|
||||
}
|
||||
}
|
||||
else if (obj instanceof ByteBuffer)
|
||||
{
|
||||
|
|
@ -815,7 +824,7 @@ public class Convert
|
|||
|
||||
/**
|
||||
* 将byte数组转为字符串
|
||||
*
|
||||
*
|
||||
* @param bytes byte数组
|
||||
* @param charset 字符集
|
||||
* @return 字符串
|
||||
|
|
@ -827,7 +836,7 @@ public class Convert
|
|||
|
||||
/**
|
||||
* 解码字节码
|
||||
*
|
||||
*
|
||||
* @param data 字符串
|
||||
* @param charset 字符集,如果此字段为空,则解码的结果取决于平台
|
||||
* @return 解码后的字符串
|
||||
|
|
@ -848,7 +857,7 @@ public class Convert
|
|||
|
||||
/**
|
||||
* 将编码的byteBuffer数据转换为字符串
|
||||
*
|
||||
*
|
||||
* @param data 数据
|
||||
* @param charset 字符集,如果为空使用当前系统字符集
|
||||
* @return 字符串
|
||||
|
|
@ -865,7 +874,7 @@ public class Convert
|
|||
|
||||
/**
|
||||
* 将编码的byteBuffer数据转换为字符串
|
||||
*
|
||||
*
|
||||
* @param data 数据
|
||||
* @param charset 字符集,如果为空使用当前系统字符集
|
||||
* @return 字符串
|
||||
|
|
@ -882,7 +891,7 @@ public class Convert
|
|||
// ----------------------------------------------------------------------- 全角半角转换
|
||||
/**
|
||||
* 半角转全角
|
||||
*
|
||||
*
|
||||
* @param input String.
|
||||
* @return 全角字符串.
|
||||
*/
|
||||
|
|
@ -893,7 +902,7 @@ public class Convert
|
|||
|
||||
/**
|
||||
* 半角转全角
|
||||
*
|
||||
*
|
||||
* @param input String
|
||||
* @param notConvertSet 不替换的字符集合
|
||||
* @return 全角字符串.
|
||||
|
|
@ -924,7 +933,7 @@ public class Convert
|
|||
|
||||
/**
|
||||
* 全角转半角
|
||||
*
|
||||
*
|
||||
* @param input String.
|
||||
* @return 半角字符串
|
||||
*/
|
||||
|
|
@ -935,7 +944,7 @@ public class Convert
|
|||
|
||||
/**
|
||||
* 替换全角为半角
|
||||
*
|
||||
*
|
||||
* @param text 文本
|
||||
* @param notConvertSet 不替换的字符集合
|
||||
* @return 替换后的字符
|
||||
|
|
@ -960,14 +969,12 @@ public class Convert
|
|||
c[i] = (char) (c[i] - 65248);
|
||||
}
|
||||
}
|
||||
String returnString = new String(c);
|
||||
|
||||
return returnString;
|
||||
return new String(c);
|
||||
}
|
||||
|
||||
/**
|
||||
* 数字金额大写转换 先写个完整的然后将如零拾替换成零
|
||||
*
|
||||
*
|
||||
* @param n 数字
|
||||
* @return 中文大写数字
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -1,28 +1,29 @@
|
|||
package com.tcctyn.common.core.utils;
|
||||
|
||||
import org.apache.commons.lang3.time.DateFormatUtils;
|
||||
|
||||
import java.lang.management.ManagementFactory;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.*;
|
||||
import java.util.Calendar;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalTime;
|
||||
import java.time.ZoneId;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.util.Date;
|
||||
import org.apache.commons.lang3.time.DateFormatUtils;
|
||||
|
||||
/**
|
||||
* 时间工具类
|
||||
*
|
||||
* @author tcctyn
|
||||
*/
|
||||
public class DateUtils extends org.apache.commons.lang3.time.DateUtils {
|
||||
public class DateUtils extends org.apache.commons.lang3.time.DateUtils
|
||||
{
|
||||
public static String YYYY = "yyyy";
|
||||
|
||||
public static String YYYY_MM = "yyyy-MM";
|
||||
|
||||
public static String YYYY_MM_DD = "yyyy-MM-dd";
|
||||
|
||||
public static final String YYYYMMDD = "yyyyMMdd";
|
||||
|
||||
public static String YYYYMMDDHHMMSS = "yyyyMMddHHmmss";
|
||||
|
||||
public static String YYYY_MM_DD_HH_MM_SS = "yyyy-MM-dd HH:mm:ss";
|
||||
|
|
@ -37,7 +38,8 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils {
|
|||
*
|
||||
* @return Date() 当前日期
|
||||
*/
|
||||
public static Date getNowDate() {
|
||||
public static Date getNowDate()
|
||||
{
|
||||
return new Date();
|
||||
}
|
||||
|
||||
|
|
@ -46,43 +48,44 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils {
|
|||
*
|
||||
* @return String
|
||||
*/
|
||||
public static String getDate() {
|
||||
public static String getDate()
|
||||
{
|
||||
return dateTimeNow(YYYY_MM_DD);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前日期
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
public static String getDate(String dateType) {
|
||||
return dateTimeNow(dateType);
|
||||
}
|
||||
|
||||
public static final String getTime() {
|
||||
public static final String getTime()
|
||||
{
|
||||
return dateTimeNow(YYYY_MM_DD_HH_MM_SS);
|
||||
}
|
||||
|
||||
public static final String dateTimeNow() {
|
||||
public static final String dateTimeNow()
|
||||
{
|
||||
return dateTimeNow(YYYYMMDDHHMMSS);
|
||||
}
|
||||
|
||||
public static final String dateTimeNow(final String format) {
|
||||
public static final String dateTimeNow(final String format)
|
||||
{
|
||||
return parseDateToStr(format, new Date());
|
||||
}
|
||||
|
||||
public static final String dateTime(final Date date) {
|
||||
public static final String dateTime(final Date date)
|
||||
{
|
||||
return parseDateToStr(YYYY_MM_DD, date);
|
||||
}
|
||||
|
||||
public static final String parseDateToStr(final String format, final Date date) {
|
||||
public static final String parseDateToStr(final String format, final Date date)
|
||||
{
|
||||
return new SimpleDateFormat(format).format(date);
|
||||
}
|
||||
|
||||
public static final Date dateTime(final String format, final String ts) {
|
||||
try {
|
||||
public static final Date dateTime(final String format, final String ts)
|
||||
{
|
||||
try
|
||||
{
|
||||
return new SimpleDateFormat(format).parse(ts);
|
||||
} catch (ParseException e) {
|
||||
}
|
||||
catch (ParseException e)
|
||||
{
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
|
@ -90,7 +93,8 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils {
|
|||
/**
|
||||
* 日期路径 即年/月/日 如2018/08/08
|
||||
*/
|
||||
public static final String datePath() {
|
||||
public static final String datePath()
|
||||
{
|
||||
Date now = new Date();
|
||||
return DateFormatUtils.format(now, "yyyy/MM/dd");
|
||||
}
|
||||
|
|
@ -98,7 +102,8 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils {
|
|||
/**
|
||||
* 日期路径 即年/月/日 如20180808
|
||||
*/
|
||||
public static final String dateTime() {
|
||||
public static final String dateTime()
|
||||
{
|
||||
Date now = new Date();
|
||||
return DateFormatUtils.format(now, "yyyyMMdd");
|
||||
}
|
||||
|
|
@ -106,13 +111,18 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils {
|
|||
/**
|
||||
* 日期型字符串转化为日期 格式
|
||||
*/
|
||||
public static Date parseDate(Object str) {
|
||||
if (str == null) {
|
||||
public static Date parseDate(Object str)
|
||||
{
|
||||
if (str == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
try
|
||||
{
|
||||
return parseDate(str.toString(), parsePatterns);
|
||||
} catch (ParseException e) {
|
||||
}
|
||||
catch (ParseException e)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
@ -120,26 +130,21 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils {
|
|||
/**
|
||||
* 获取服务器启动时间
|
||||
*/
|
||||
public static Date getServerStartDate() {
|
||||
public static Date getServerStartDate()
|
||||
{
|
||||
long time = ManagementFactory.getRuntimeMXBean().getStartTime();
|
||||
return new Date(time);
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算相差天数
|
||||
*/
|
||||
public static int differentDaysByMillisecond(Date date1, Date date2) {
|
||||
return Math.abs((int) ((date2.getTime() - date1.getTime()) / (1000 * 3600 * 24)));
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算时间差
|
||||
*
|
||||
* @param endDate 最后时间
|
||||
* @param endDate 最后时间
|
||||
* @param startTime 开始时间
|
||||
* @return 时间差(天/小时/分钟)
|
||||
*/
|
||||
public static String timeDistance(Date endDate, Date startTime) {
|
||||
public static String timeDistance(Date endDate, Date startTime)
|
||||
{
|
||||
long nd = 1000 * 24 * 60 * 60;
|
||||
long nh = 1000 * 60 * 60;
|
||||
long nm = 1000 * 60;
|
||||
|
|
@ -160,7 +165,8 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils {
|
|||
/**
|
||||
* 增加 LocalDateTime ==> Date
|
||||
*/
|
||||
public static Date toDate(LocalDateTime temporalAccessor) {
|
||||
public static Date toDate(LocalDateTime temporalAccessor)
|
||||
{
|
||||
ZonedDateTime zdt = temporalAccessor.atZone(ZoneId.systemDefault());
|
||||
return Date.from(zdt.toInstant());
|
||||
}
|
||||
|
|
@ -168,59 +174,10 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils {
|
|||
/**
|
||||
* 增加 LocalDate ==> Date
|
||||
*/
|
||||
public static Date toDate(LocalDate temporalAccessor) {
|
||||
public static Date toDate(LocalDate temporalAccessor)
|
||||
{
|
||||
LocalDateTime localDateTime = LocalDateTime.of(temporalAccessor, LocalTime.of(0, 0, 0));
|
||||
ZonedDateTime zdt = localDateTime.atZone(ZoneId.systemDefault());
|
||||
return Date.from(zdt.toInstant());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前周的周一日期
|
||||
*
|
||||
* @param date 当前日期
|
||||
* @return 周一的日期
|
||||
*/
|
||||
public static Date getThisWeekMonday(Date date) {
|
||||
Calendar cal = Calendar.getInstance();
|
||||
cal.setTime(date);
|
||||
cal.setFirstDayOfWeek(Calendar.MONDAY);
|
||||
cal.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY); // 设置为周一
|
||||
return cal.getTime();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前周的周日日期
|
||||
*
|
||||
* @param date 当前日期
|
||||
* @return 周日的日期
|
||||
*/
|
||||
public static Date getThisWeekSunday(Date date) {
|
||||
Calendar cal = Calendar.getInstance();
|
||||
cal.setTime(date);
|
||||
cal.setFirstDayOfWeek(Calendar.MONDAY);
|
||||
cal.set(Calendar.DAY_OF_WEEK, Calendar.SUNDAY); // 设置为周日
|
||||
return cal.getTime();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取星期
|
||||
*
|
||||
* @param date 日期
|
||||
*/
|
||||
public static int getWeek(Date date) {
|
||||
Calendar cal = Calendar.getInstance();
|
||||
cal.setTime(date);
|
||||
int dayOfWeek = cal.get(Calendar.DAY_OF_WEEK);
|
||||
dayOfWeek -= 1;
|
||||
if (dayOfWeek == 0) {
|
||||
dayOfWeek = 7;
|
||||
}
|
||||
return dayOfWeek;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
String date = DateUtils.getDate(DateUtils.YYYYMMDD);
|
||||
System.out.println(date);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,9 +1,8 @@
|
|||
package com.tcctyn.common.core.utils;
|
||||
|
||||
import org.apache.commons.lang3.exception.ExceptionUtils;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
import org.apache.commons.lang3.exception.ExceptionUtils;
|
||||
|
||||
/**
|
||||
* 错误信息处理类。
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
package com.tcctyn.common.core.utils;
|
||||
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.tcctyn.common.core.utils.sql.SqlUtil;
|
||||
import com.tcctyn.common.core.web.page.PageDomain;
|
||||
import com.tcctyn.common.core.web.page.TableSupport;
|
||||
import com.tcctyn.common.core.utils.sql.SqlUtil;
|
||||
|
||||
/**
|
||||
* 分页工具类
|
||||
|
|
|
|||
|
|
@ -1,9 +1,17 @@
|
|||
package com.tcctyn.common.core.utils;
|
||||
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.tcctyn.common.core.constant.Constants;
|
||||
import com.tcctyn.common.core.web.domain.R;
|
||||
import com.tcctyn.common.core.text.Convert;
|
||||
import java.io.IOException;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URLDecoder;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.Collections;
|
||||
import java.util.Enumeration;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import javax.servlet.ServletRequest;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.http.HttpSession;
|
||||
import org.springframework.core.io.buffer.DataBuffer;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpStatus;
|
||||
|
|
@ -13,24 +21,15 @@ import org.springframework.util.LinkedCaseInsensitiveMap;
|
|||
import org.springframework.web.context.request.RequestAttributes;
|
||||
import org.springframework.web.context.request.RequestContextHolder;
|
||||
import org.springframework.web.context.request.ServletRequestAttributes;
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.tcctyn.common.core.constant.Constants;
|
||||
import com.tcctyn.common.core.domain.R;
|
||||
import com.tcctyn.common.core.text.Convert;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
import javax.servlet.ServletRequest;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.http.HttpSession;
|
||||
import java.io.IOException;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URLDecoder;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.Collections;
|
||||
import java.util.Enumeration;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 客户端工具类
|
||||
*
|
||||
*
|
||||
* @author tcctyn
|
||||
*/
|
||||
public class ServletUtils
|
||||
|
|
@ -190,7 +189,7 @@ public class ServletUtils
|
|||
|
||||
/**
|
||||
* 将字符串渲染到客户端
|
||||
*
|
||||
*
|
||||
* @param response 渲染对象
|
||||
* @param string 待渲染的字符串
|
||||
*/
|
||||
|
|
@ -211,7 +210,7 @@ public class ServletUtils
|
|||
|
||||
/**
|
||||
* 是否是Ajax异步请求
|
||||
*
|
||||
*
|
||||
* @param request
|
||||
*/
|
||||
public static boolean isAjaxRequest(HttpServletRequest request)
|
||||
|
|
@ -240,7 +239,7 @@ public class ServletUtils
|
|||
|
||||
/**
|
||||
* 内容编码
|
||||
*
|
||||
*
|
||||
* @param str 内容
|
||||
* @return 编码后的内容
|
||||
*/
|
||||
|
|
@ -258,7 +257,7 @@ public class ServletUtils
|
|||
|
||||
/**
|
||||
* 内容解码
|
||||
*
|
||||
*
|
||||
* @param str 内容
|
||||
* @return 解码后的内容
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -1,16 +1,15 @@
|
|||
package com.tcctyn.common.core.utils;
|
||||
|
||||
import com.tcctyn.common.core.constant.Constants;
|
||||
import com.tcctyn.common.core.text.StrFormatter;
|
||||
import org.springframework.util.AntPathMatcher;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import org.springframework.util.AntPathMatcher;
|
||||
import com.tcctyn.common.core.constant.Constants;
|
||||
import com.tcctyn.common.core.text.StrFormatter;
|
||||
|
||||
/**
|
||||
* 字符串工具类
|
||||
*
|
||||
*
|
||||
* @author tcctyn
|
||||
*/
|
||||
public class StringUtils extends org.apache.commons.lang3.StringUtils
|
||||
|
|
@ -26,7 +25,7 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils
|
|||
|
||||
/**
|
||||
* 获取参数不为空值
|
||||
*
|
||||
*
|
||||
* @param value defaultValue 要判断的value
|
||||
* @return value 返回值
|
||||
*/
|
||||
|
|
@ -37,7 +36,7 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils
|
|||
|
||||
/**
|
||||
* * 判断一个Collection是否为空, 包含List,Set,Queue
|
||||
*
|
||||
*
|
||||
* @param coll 要判断的Collection
|
||||
* @return true:为空 false:非空
|
||||
*/
|
||||
|
|
@ -48,7 +47,7 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils
|
|||
|
||||
/**
|
||||
* * 判断一个Collection是否非空,包含List,Set,Queue
|
||||
*
|
||||
*
|
||||
* @param coll 要判断的Collection
|
||||
* @return true:非空 false:空
|
||||
*/
|
||||
|
|
@ -59,7 +58,7 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils
|
|||
|
||||
/**
|
||||
* * 判断一个对象数组是否为空
|
||||
*
|
||||
*
|
||||
* @param objects 要判断的对象数组
|
||||
** @return true:为空 false:非空
|
||||
*/
|
||||
|
|
@ -70,7 +69,7 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils
|
|||
|
||||
/**
|
||||
* * 判断一个对象数组是否非空
|
||||
*
|
||||
*
|
||||
* @param objects 要判断的对象数组
|
||||
* @return true:非空 false:空
|
||||
*/
|
||||
|
|
@ -81,7 +80,7 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils
|
|||
|
||||
/**
|
||||
* * 判断一个Map是否为空
|
||||
*
|
||||
*
|
||||
* @param map 要判断的Map
|
||||
* @return true:为空 false:非空
|
||||
*/
|
||||
|
|
@ -92,7 +91,7 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils
|
|||
|
||||
/**
|
||||
* * 判断一个Map是否为空
|
||||
*
|
||||
*
|
||||
* @param map 要判断的Map
|
||||
* @return true:非空 false:空
|
||||
*/
|
||||
|
|
@ -103,7 +102,7 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils
|
|||
|
||||
/**
|
||||
* * 判断一个字符串是否为空串
|
||||
*
|
||||
*
|
||||
* @param str String
|
||||
* @return true:为空 false:非空
|
||||
*/
|
||||
|
|
@ -114,7 +113,7 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils
|
|||
|
||||
/**
|
||||
* * 判断一个字符串是否为非空串
|
||||
*
|
||||
*
|
||||
* @param str String
|
||||
* @return true:非空串 false:空串
|
||||
*/
|
||||
|
|
@ -125,7 +124,7 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils
|
|||
|
||||
/**
|
||||
* * 判断一个对象是否为空
|
||||
*
|
||||
*
|
||||
* @param object Object
|
||||
* @return true:为空 false:非空
|
||||
*/
|
||||
|
|
@ -136,7 +135,7 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils
|
|||
|
||||
/**
|
||||
* * 判断一个对象是否非空
|
||||
*
|
||||
*
|
||||
* @param object Object
|
||||
* @return true:非空 false:空
|
||||
*/
|
||||
|
|
@ -147,7 +146,7 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils
|
|||
|
||||
/**
|
||||
* * 判断一个对象是否是数组类型(Java基本型别的数组)
|
||||
*
|
||||
*
|
||||
* @param object 对象
|
||||
* @return true:是数组 false:不是数组
|
||||
*/
|
||||
|
|
@ -209,7 +208,7 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils
|
|||
|
||||
/**
|
||||
* 截取字符串
|
||||
*
|
||||
*
|
||||
* @param str 字符串
|
||||
* @param start 开始
|
||||
* @return 结果
|
||||
|
|
@ -240,7 +239,7 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils
|
|||
|
||||
/**
|
||||
* 截取字符串
|
||||
*
|
||||
*
|
||||
* @param str 字符串
|
||||
* @param start 开始
|
||||
* @param end 结束
|
||||
|
|
@ -286,7 +285,7 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils
|
|||
|
||||
/**
|
||||
* 在字符串中查找第一个出现的 `open` 和最后一个出现的 `close` 之间的子字符串
|
||||
*
|
||||
*
|
||||
* @param str 要截取的字符串
|
||||
* @param open 起始字符串
|
||||
* @param close 结束字符串
|
||||
|
|
@ -312,7 +311,7 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils
|
|||
|
||||
/**
|
||||
* 判断是否为空,并且不是空白字符
|
||||
*
|
||||
*
|
||||
* @param str 要判断的value
|
||||
* @return 结果
|
||||
*/
|
||||
|
|
@ -342,7 +341,7 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils
|
|||
* 通常使用:format("this is {} for {}", "a", "b") -> this is a for b<br>
|
||||
* 转义{}: format("this is \\{} for {}", "a", "b") -> this is \{} for a<br>
|
||||
* 转义\: format("this is \\\\{} for {}", "a", "b") -> this is \a for b<br>
|
||||
*
|
||||
*
|
||||
* @param template 文本模板,被替换的部分用 {} 表示
|
||||
* @param params 参数值
|
||||
* @return 格式化后的文本
|
||||
|
|
@ -358,7 +357,7 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils
|
|||
|
||||
/**
|
||||
* 是否为http(s)://开头
|
||||
*
|
||||
*
|
||||
* @param link 链接
|
||||
* @return 结果
|
||||
*/
|
||||
|
|
@ -444,7 +443,7 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils
|
|||
|
||||
/**
|
||||
* 是否包含字符串
|
||||
*
|
||||
*
|
||||
* @param str 验证字符串
|
||||
* @param strs 字符串组
|
||||
* @return 包含返回true
|
||||
|
|
@ -466,7 +465,7 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils
|
|||
|
||||
/**
|
||||
* 将下划线大写方式命名的字符串转换为驼峰式。如果转换前的下划线大写方式命名的字符串为空,则返回空字符串。 例如:HELLO_WORLD->HelloWorld
|
||||
*
|
||||
*
|
||||
* @param name 转换前的下划线大写方式命名的字符串
|
||||
* @return 转换后的驼峰式命名的字符串
|
||||
*/
|
||||
|
|
@ -540,7 +539,7 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils
|
|||
|
||||
/**
|
||||
* 查找指定字符串是否匹配指定字符串列表中的任意一个字符串
|
||||
*
|
||||
*
|
||||
* @param str 指定字符串
|
||||
* @param strs 需要检查的字符串数组
|
||||
* @return 是否匹配
|
||||
|
|
@ -562,11 +561,11 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils
|
|||
}
|
||||
|
||||
/**
|
||||
* 判断url是否与规则配置:
|
||||
* ? 表示单个字符;
|
||||
* * 表示一层路径内的任意字符串,不可跨层级;
|
||||
* 判断url是否与规则配置:
|
||||
* ? 表示单个字符;
|
||||
* * 表示一层路径内的任意字符串,不可跨层级;
|
||||
* ** 表示任意层路径;
|
||||
*
|
||||
*
|
||||
* @param pattern 匹配规则
|
||||
* @param url 需要匹配的url
|
||||
* @return
|
||||
|
|
@ -585,7 +584,7 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils
|
|||
|
||||
/**
|
||||
* 数字左边补齐0,使之达到指定长度。注意,如果数字转换为字符串后,长度大于size,则只保留 最后size个字符。
|
||||
*
|
||||
*
|
||||
* @param num 数字对象
|
||||
* @param size 字符串指定长度
|
||||
* @return 返回数字的字符串格式,该字符串为指定长度。
|
||||
|
|
@ -597,7 +596,7 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils
|
|||
|
||||
/**
|
||||
* 字符串左补齐。如果原始字符串s长度大于size,则只保留最后size个字符。
|
||||
*
|
||||
*
|
||||
* @param s 原始字符串
|
||||
* @param size 字符串指定长度
|
||||
* @param c 用于补齐的字符
|
||||
|
|
|
|||
|
|
@ -1,55 +1,53 @@
|
|||
package com.tcctyn.common.core.utils.bean;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static cn.hutool.core.bean.BeanUtil.toBean;
|
||||
|
||||
/**
|
||||
* Bean 工具类
|
||||
*
|
||||
*
|
||||
* @author tcctyn
|
||||
*/
|
||||
public class BeanUtils extends org.springframework.beans.BeanUtils {
|
||||
/**
|
||||
* Bean方法名中属性名开始的下标
|
||||
*/
|
||||
public class BeanUtils extends org.springframework.beans.BeanUtils
|
||||
{
|
||||
/** Bean方法名中属性名开始的下标 */
|
||||
private static final int BEAN_METHOD_PROP_INDEX = 3;
|
||||
|
||||
/**
|
||||
* 匹配getter方法的正则表达式
|
||||
*/
|
||||
/** * 匹配getter方法的正则表达式 */
|
||||
private static final Pattern GET_PATTERN = Pattern.compile("get(\\p{javaUpperCase}\\w*)");
|
||||
|
||||
/**
|
||||
* 匹配setter方法的正则表达式
|
||||
*/
|
||||
/** * 匹配setter方法的正则表达式 */
|
||||
private static final Pattern SET_PATTERN = Pattern.compile("set(\\p{javaUpperCase}\\w*)");
|
||||
|
||||
/**
|
||||
* Bean属性复制工具方法。
|
||||
*
|
||||
* @param src 源对象
|
||||
*
|
||||
* @param dest 目标对象
|
||||
* @param src 源对象
|
||||
*/
|
||||
public static void copyBeanProp(Object src, Object dest) {
|
||||
try {
|
||||
public static void copyBeanProp(Object dest, Object src)
|
||||
{
|
||||
try
|
||||
{
|
||||
copyProperties(src, dest);
|
||||
} catch (Exception e) {
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取对象的setter方法。
|
||||
*
|
||||
*
|
||||
* @param obj 对象
|
||||
* @return 对象的setter方法列表
|
||||
*/
|
||||
public static List<Method> getSetterMethods(Object obj) {
|
||||
public static List<Method> getSetterMethods(Object obj)
|
||||
{
|
||||
// setter方法列表
|
||||
List<Method> setterMethods = new ArrayList<Method>();
|
||||
|
||||
|
|
@ -58,9 +56,11 @@ public class BeanUtils extends org.springframework.beans.BeanUtils {
|
|||
|
||||
// 查找setter方法
|
||||
|
||||
for (Method method : methods) {
|
||||
for (Method method : methods)
|
||||
{
|
||||
Matcher m = SET_PATTERN.matcher(method.getName());
|
||||
if (m.matches() && (method.getParameterTypes().length == 1)) {
|
||||
if (m.matches() && (method.getParameterTypes().length == 1))
|
||||
{
|
||||
setterMethods.add(method);
|
||||
}
|
||||
}
|
||||
|
|
@ -70,20 +70,23 @@ public class BeanUtils extends org.springframework.beans.BeanUtils {
|
|||
|
||||
/**
|
||||
* 获取对象的getter方法。
|
||||
*
|
||||
*
|
||||
* @param obj 对象
|
||||
* @return 对象的getter方法列表
|
||||
*/
|
||||
|
||||
public static List<Method> getGetterMethods(Object obj) {
|
||||
public static List<Method> getGetterMethods(Object obj)
|
||||
{
|
||||
// getter方法列表
|
||||
List<Method> getterMethods = new ArrayList<Method>();
|
||||
// 获取所有方法
|
||||
Method[] methods = obj.getClass().getMethods();
|
||||
// 查找getter方法
|
||||
for (Method method : methods) {
|
||||
for (Method method : methods)
|
||||
{
|
||||
Matcher m = GET_PATTERN.matcher(method.getName());
|
||||
if (m.matches() && (method.getParameterTypes().length == 0)) {
|
||||
if (m.matches() && (method.getParameterTypes().length == 0))
|
||||
{
|
||||
getterMethods.add(method);
|
||||
}
|
||||
}
|
||||
|
|
@ -94,29 +97,14 @@ public class BeanUtils extends org.springframework.beans.BeanUtils {
|
|||
/**
|
||||
* 检查Bean方法名中的属性名是否相等。<br>
|
||||
* 如getName()和setName()属性名一样,getName()和setAge()属性名不一样。
|
||||
*
|
||||
*
|
||||
* @param m1 方法名1
|
||||
* @param m2 方法名2
|
||||
* @return 属性名一样返回true,否则返回false
|
||||
*/
|
||||
|
||||
public static boolean isMethodPropEquals(String m1, String m2) {
|
||||
public static boolean isMethodPropEquals(String m1, String m2)
|
||||
{
|
||||
return m1.substring(BEAN_METHOD_PROP_INDEX).equals(m2.substring(BEAN_METHOD_PROP_INDEX));
|
||||
}
|
||||
|
||||
/**
|
||||
* List 对象复制工具方法。
|
||||
*
|
||||
* @param sourceList
|
||||
* @param destinationClass
|
||||
* @return
|
||||
*/
|
||||
public static <T, E> List<T> copyList(Collection<E> sourceList, Class<T> destinationClass) {
|
||||
if (sourceList == null || sourceList.isEmpty() || destinationClass == null) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
return sourceList.parallelStream()
|
||||
.filter(Objects::nonNull)
|
||||
.map(source -> toBean(source, destinationClass)).collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
package com.tcctyn.common.core.utils.bean;
|
||||
|
||||
import java.util.Set;
|
||||
import javax.validation.ConstraintViolation;
|
||||
import javax.validation.ConstraintViolationException;
|
||||
import javax.validation.Validator;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* bean对象属性验证
|
||||
|
|
|
|||
|
|
@ -1,11 +1,10 @@
|
|||
package com.tcctyn.common.core.utils.file;
|
||||
|
||||
import org.apache.commons.io.FilenameUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Objects;
|
||||
import org.apache.commons.io.FilenameUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
/**
|
||||
* 文件类型工具类
|
||||
|
|
@ -18,7 +17,7 @@ public class FileTypeUtils
|
|||
* 获取文件类型
|
||||
* <p>
|
||||
* 例如: tcctyn.txt, 返回: txt
|
||||
*
|
||||
*
|
||||
* @param file 文件名
|
||||
* @return 后缀(不含".")
|
||||
*/
|
||||
|
|
@ -51,7 +50,7 @@ public class FileTypeUtils
|
|||
|
||||
/**
|
||||
* 获取文件名的后缀
|
||||
*
|
||||
*
|
||||
* @param file 表单文件
|
||||
* @return 后缀名
|
||||
*/
|
||||
|
|
@ -67,7 +66,7 @@ public class FileTypeUtils
|
|||
|
||||
/**
|
||||
* 获取文件类型
|
||||
*
|
||||
*
|
||||
* @param photoByte 文件字节码
|
||||
* @return 后缀(不含".")
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -1,18 +1,17 @@
|
|||
package com.tcctyn.common.core.utils.file;
|
||||
|
||||
import com.tcctyn.common.core.config.TcctynConfig;
|
||||
import com.tcctyn.common.core.utils.DateUtils;
|
||||
import com.tcctyn.common.core.utils.StringUtils;
|
||||
import com.tcctyn.common.core.utils.uuid.IdUtils;
|
||||
import org.apache.commons.io.FilenameUtils;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.*;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URLEncoder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
import com.tcctyn.common.core.utils.StringUtils;
|
||||
|
||||
/**
|
||||
* 文件处理工具类
|
||||
|
|
@ -21,6 +20,12 @@ import java.nio.charset.StandardCharsets;
|
|||
*/
|
||||
public class FileUtils
|
||||
{
|
||||
/** 字符常量:斜杠 {@code '/'} */
|
||||
public static final char SLASH = '/';
|
||||
|
||||
/** 字符常量:反斜杠 {@code '\\'} */
|
||||
public static final char BACKSLASH = '\\';
|
||||
|
||||
public static String FILENAME_PATTERN = "[a-zA-Z0-9_\\-\\|\\.\\u4e00-\\u9fa5]+";
|
||||
|
||||
/**
|
||||
|
|
@ -54,50 +59,31 @@ public class FileUtils
|
|||
}
|
||||
finally
|
||||
{
|
||||
IOUtils.close(os);
|
||||
IOUtils.close(fis);
|
||||
if (os != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
os.close();
|
||||
}
|
||||
catch (IOException e1)
|
||||
{
|
||||
e1.printStackTrace();
|
||||
}
|
||||
}
|
||||
if (fis != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
fis.close();
|
||||
}
|
||||
catch (IOException e1)
|
||||
{
|
||||
e1.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 写数据到文件中
|
||||
*
|
||||
* @param data 数据
|
||||
* @return 目标文件
|
||||
* @throws IOException IO异常
|
||||
*/
|
||||
public static String writeImportBytes(byte[] data) throws IOException
|
||||
{
|
||||
return writeBytes(data, TcctynConfig.getImportPath());
|
||||
}
|
||||
|
||||
/**
|
||||
* 写数据到文件中
|
||||
*
|
||||
* @param data 数据
|
||||
* @param uploadDir 目标文件
|
||||
* @return 目标文件
|
||||
* @throws IOException IO异常
|
||||
*/
|
||||
public static String writeBytes(byte[] data, String uploadDir) throws IOException
|
||||
{
|
||||
FileOutputStream fos = null;
|
||||
String pathName = "";
|
||||
try
|
||||
{
|
||||
String extension = getFileExtendName(data);
|
||||
pathName = DateUtils.datePath() + "/" + IdUtils.fastUUID() + "." + extension;
|
||||
File file = FileUploadUtils.getAbsoluteFile(uploadDir, pathName);
|
||||
fos = new FileOutputStream(file);
|
||||
fos.write(data);
|
||||
}
|
||||
finally
|
||||
{
|
||||
IOUtils.close(fos);
|
||||
}
|
||||
return FileUploadUtils.getPathFileName(uploadDir, pathName);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除文件
|
||||
*
|
||||
|
|
@ -140,15 +126,8 @@ public class FileUtils
|
|||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// 检查允许下载的文件规则
|
||||
if (ArrayUtils.contains(MimeTypeUtils.DEFAULT_ALLOWED_EXTENSION, FileTypeUtils.getFileType(resource)))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
// 不在允许下载的文件规则
|
||||
return false;
|
||||
// 判断是否在允许下载的文件规则内
|
||||
return ArrayUtils.contains(MimeTypeUtils.DEFAULT_ALLOWED_EXTENSION, FileTypeUtils.getFileType(resource));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -186,11 +165,63 @@ public class FileUtils
|
|||
return filename;
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回文件名
|
||||
*
|
||||
* @param filePath 文件
|
||||
* @return 文件名
|
||||
*/
|
||||
public static String getName(String filePath)
|
||||
{
|
||||
if (null == filePath)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
int len = filePath.length();
|
||||
if (0 == len)
|
||||
{
|
||||
return filePath;
|
||||
}
|
||||
if (isFileSeparator(filePath.charAt(len - 1)))
|
||||
{
|
||||
// 以分隔符结尾的去掉结尾分隔符
|
||||
len--;
|
||||
}
|
||||
|
||||
int begin = 0;
|
||||
char c;
|
||||
for (int i = len - 1; i > -1; i--)
|
||||
{
|
||||
c = filePath.charAt(i);
|
||||
if (isFileSeparator(c))
|
||||
{
|
||||
// 查找最后一个路径分隔符(/或者\)
|
||||
begin = i + 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return filePath.substring(begin, len);
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否为Windows或者Linux(Unix)文件分隔符<br>
|
||||
* Windows平台下分隔符为\,Linux(Unix)为/
|
||||
*
|
||||
* @param c 字符
|
||||
* @return 是否为Windows或者Linux(Unix)文件分隔符
|
||||
*/
|
||||
public static boolean isFileSeparator(char c)
|
||||
{
|
||||
return SLASH == c || BACKSLASH == c;
|
||||
}
|
||||
|
||||
/**
|
||||
* 下载文件名重新编码
|
||||
*
|
||||
* @param response 响应对象
|
||||
* @param realFileName 真实文件名
|
||||
* @return
|
||||
*/
|
||||
public static void setAttachmentResponseHeader(HttpServletResponse response, String realFileName) throws UnsupportedEncodingException
|
||||
{
|
||||
|
|
@ -204,7 +235,6 @@ public class FileUtils
|
|||
.append("utf-8''")
|
||||
.append(percentEncodedFileName);
|
||||
|
||||
response.addHeader("Access-Control-Expose-Headers", "Content-Disposition,download-filename");
|
||||
response.setHeader("Content-disposition", contentDispositionValue.toString());
|
||||
response.setHeader("download-filename", percentEncodedFileName);
|
||||
}
|
||||
|
|
@ -220,67 +250,4 @@ public class FileUtils
|
|||
String encode = URLEncoder.encode(s, StandardCharsets.UTF_8.toString());
|
||||
return encode.replaceAll("\\+", "%20");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取图像后缀
|
||||
*
|
||||
* @param photoByte 图像数据
|
||||
* @return 后缀名
|
||||
*/
|
||||
public static String getFileExtendName(byte[] photoByte)
|
||||
{
|
||||
String strFileExtendName = "jpg";
|
||||
if ((photoByte[0] == 71) && (photoByte[1] == 73) && (photoByte[2] == 70) && (photoByte[3] == 56)
|
||||
&& ((photoByte[4] == 55) || (photoByte[4] == 57)) && (photoByte[5] == 97))
|
||||
{
|
||||
strFileExtendName = "gif";
|
||||
}
|
||||
else if ((photoByte[6] == 74) && (photoByte[7] == 70) && (photoByte[8] == 73) && (photoByte[9] == 70))
|
||||
{
|
||||
strFileExtendName = "jpg";
|
||||
}
|
||||
else if ((photoByte[0] == 66) && (photoByte[1] == 77))
|
||||
{
|
||||
strFileExtendName = "bmp";
|
||||
}
|
||||
else if ((photoByte[1] == 80) && (photoByte[2] == 78) && (photoByte[3] == 71))
|
||||
{
|
||||
strFileExtendName = "png";
|
||||
}
|
||||
return strFileExtendName;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取文件名称 /profile/upload/2022/04/16/tcctyn.png -- tcctyn.png
|
||||
*
|
||||
* @param fileName 路径名称
|
||||
* @return 没有文件路径的名称
|
||||
*/
|
||||
public static String getName(String fileName)
|
||||
{
|
||||
if (fileName == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
int lastUnixPos = fileName.lastIndexOf('/');
|
||||
int lastWindowsPos = fileName.lastIndexOf('\\');
|
||||
int index = Math.max(lastUnixPos, lastWindowsPos);
|
||||
return fileName.substring(index + 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取不带后缀文件名称 /profile/upload/2022/04/16/tcctyn.png -- tcctyn
|
||||
*
|
||||
* @param fileName 路径名称
|
||||
* @return 没有文件路径和后缀的名称
|
||||
*/
|
||||
public static String getNameNotSuffix(String fileName)
|
||||
{
|
||||
if (fileName == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
String baseName = FilenameUtils.getBaseName(fileName);
|
||||
return baseName;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,18 +1,13 @@
|
|||
package com.tcctyn.common.core.utils.file;
|
||||
|
||||
import com.tcctyn.common.core.config.TcctynConfig;
|
||||
import com.tcctyn.common.core.constant.Constants;
|
||||
import com.tcctyn.common.core.utils.StringUtils;
|
||||
import org.apache.poi.util.IOUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.InputStream;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import java.util.Arrays;
|
||||
import org.apache.poi.util.IOUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* 图片处理工具类
|
||||
|
|
@ -67,28 +62,18 @@ public class ImageUtils
|
|||
InputStream in = null;
|
||||
try
|
||||
{
|
||||
if (url.startsWith("http"))
|
||||
{
|
||||
// 网络地址
|
||||
URL urlObj = new URL(url);
|
||||
URLConnection urlConnection = urlObj.openConnection();
|
||||
urlConnection.setConnectTimeout(30 * 1000);
|
||||
urlConnection.setReadTimeout(60 * 1000);
|
||||
urlConnection.setDoInput(true);
|
||||
in = urlConnection.getInputStream();
|
||||
}
|
||||
else
|
||||
{
|
||||
// 本机地址
|
||||
String localPath = TcctynConfig.getProfile();
|
||||
String downloadPath = localPath + StringUtils.substringAfter(url, Constants.RESOURCE_PREFIX);
|
||||
in = new FileInputStream(downloadPath);
|
||||
}
|
||||
// 网络地址
|
||||
URL urlObj = new URL(url);
|
||||
URLConnection urlConnection = urlObj.openConnection();
|
||||
urlConnection.setConnectTimeout(30 * 1000);
|
||||
urlConnection.setReadTimeout(60 * 1000);
|
||||
urlConnection.setDoInput(true);
|
||||
in = urlConnection.getInputStream();
|
||||
return IOUtils.toByteArray(in);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
log.error("获取文件路径异常 {}", e);
|
||||
log.error("访问文件异常 {}", e);
|
||||
return null;
|
||||
}
|
||||
finally
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ public class MimeTypeUtils
|
|||
public static final String IMAGE_BMP = "image/bmp";
|
||||
|
||||
public static final String IMAGE_GIF = "image/gif";
|
||||
|
||||
|
||||
public static final String[] IMAGE_EXTENSION = { "bmp", "gif", "jpg", "jpeg", "png" };
|
||||
|
||||
public static final String[] FLASH_EXTENSION = { "swf", "flv" };
|
||||
|
|
|
|||
|
|
@ -1,6 +1,10 @@
|
|||
package com.tcctyn.common.core.utils.html;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ConcurrentMap;
|
||||
import java.util.regex.Matcher;
|
||||
|
|
|
|||
|
|
@ -1,11 +1,10 @@
|
|||
package com.tcctyn.common.core.utils.ip;
|
||||
|
||||
import com.tcctyn.common.core.utils.ServletUtils;
|
||||
import com.tcctyn.common.core.utils.StringUtils;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.net.InetAddress;
|
||||
import java.net.UnknownHostException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import com.tcctyn.common.core.utils.ServletUtils;
|
||||
import com.tcctyn.common.core.utils.StringUtils;
|
||||
|
||||
/**
|
||||
* 获取IP方法
|
||||
|
|
|
|||
|
|
@ -1,37 +1,7 @@
|
|||
package com.tcctyn.common.core.utils.poi;
|
||||
|
||||
import com.tcctyn.common.core.annotation.Excel;
|
||||
import com.tcctyn.common.core.annotation.Excel.ColumnType;
|
||||
import com.tcctyn.common.core.annotation.Excel.Type;
|
||||
import com.tcctyn.common.core.annotation.Excels;
|
||||
import com.tcctyn.common.core.config.TcctynConfig;
|
||||
import com.tcctyn.common.core.web.domain.AjaxResult;
|
||||
import com.tcctyn.common.core.exception.UtilException;
|
||||
import com.tcctyn.common.core.text.Convert;
|
||||
import com.tcctyn.common.core.utils.DateUtils;
|
||||
import com.tcctyn.common.core.utils.DictUtils;
|
||||
import com.tcctyn.common.core.utils.StringUtils;
|
||||
import com.tcctyn.common.core.utils.file.FileTypeUtils;
|
||||
import com.tcctyn.common.core.utils.file.FileUtils;
|
||||
import com.tcctyn.common.core.utils.file.ImageUtils;
|
||||
import com.tcctyn.common.core.utils.reflect.ReflectUtils;
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
import org.apache.commons.lang3.RegExUtils;
|
||||
import org.apache.commons.lang3.reflect.FieldUtils;
|
||||
import org.apache.poi.hssf.usermodel.*;
|
||||
import org.apache.poi.ooxml.POIXMLDocumentPart;
|
||||
import org.apache.poi.ss.usermodel.*;
|
||||
import org.apache.poi.ss.util.CellRangeAddress;
|
||||
import org.apache.poi.ss.util.CellRangeAddressList;
|
||||
import org.apache.poi.util.IOUtils;
|
||||
import org.apache.poi.xssf.streaming.SXSSFWorkbook;
|
||||
import org.apache.poi.xssf.usermodel.*;
|
||||
import org.openxmlformats.schemas.drawingml.x2006.spreadsheetDrawing.CTMarker;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.*;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.ParameterizedType;
|
||||
|
|
@ -39,12 +9,64 @@ import java.math.BigDecimal;
|
|||
import java.text.DecimalFormat;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Comparator;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
import org.apache.commons.lang3.RegExUtils;
|
||||
import org.apache.commons.lang3.reflect.FieldUtils;
|
||||
import org.apache.poi.ss.usermodel.BorderStyle;
|
||||
import org.apache.poi.ss.usermodel.Cell;
|
||||
import org.apache.poi.ss.usermodel.CellStyle;
|
||||
import org.apache.poi.ss.usermodel.CellType;
|
||||
import org.apache.poi.ss.usermodel.ClientAnchor;
|
||||
import org.apache.poi.ss.usermodel.DataFormat;
|
||||
import org.apache.poi.ss.usermodel.DataValidation;
|
||||
import org.apache.poi.ss.usermodel.DataValidationConstraint;
|
||||
import org.apache.poi.ss.usermodel.DataValidationHelper;
|
||||
import org.apache.poi.ss.usermodel.DateUtil;
|
||||
import org.apache.poi.ss.usermodel.Drawing;
|
||||
import org.apache.poi.ss.usermodel.FillPatternType;
|
||||
import org.apache.poi.ss.usermodel.Font;
|
||||
import org.apache.poi.ss.usermodel.HorizontalAlignment;
|
||||
import org.apache.poi.ss.usermodel.IndexedColors;
|
||||
import org.apache.poi.ss.usermodel.Name;
|
||||
import org.apache.poi.ss.usermodel.Row;
|
||||
import org.apache.poi.ss.usermodel.Sheet;
|
||||
import org.apache.poi.ss.usermodel.VerticalAlignment;
|
||||
import org.apache.poi.ss.usermodel.Workbook;
|
||||
import org.apache.poi.ss.usermodel.WorkbookFactory;
|
||||
import org.apache.poi.ss.util.CellRangeAddress;
|
||||
import org.apache.poi.ss.util.CellRangeAddressList;
|
||||
import org.apache.poi.util.IOUtils;
|
||||
import org.apache.poi.xssf.streaming.SXSSFWorkbook;
|
||||
import org.apache.poi.xssf.usermodel.XSSFClientAnchor;
|
||||
import org.apache.poi.xssf.usermodel.XSSFDataValidation;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import com.tcctyn.common.core.annotation.Excel;
|
||||
import com.tcctyn.common.core.annotation.Excel.ColumnType;
|
||||
import com.tcctyn.common.core.annotation.Excel.Type;
|
||||
import com.tcctyn.common.core.annotation.Excels;
|
||||
import com.tcctyn.common.core.exception.UtilException;
|
||||
import com.tcctyn.common.core.text.Convert;
|
||||
import com.tcctyn.common.core.utils.DateUtils;
|
||||
import com.tcctyn.common.core.utils.StringUtils;
|
||||
import com.tcctyn.common.core.utils.file.FileTypeUtils;
|
||||
import com.tcctyn.common.core.utils.file.ImageUtils;
|
||||
import com.tcctyn.common.core.utils.reflect.ReflectUtils;
|
||||
|
||||
/**
|
||||
* Excel相关处理
|
||||
*
|
||||
*
|
||||
* @author tcctyn
|
||||
*/
|
||||
public class ExcelUtil<T>
|
||||
|
|
@ -55,11 +77,6 @@ public class ExcelUtil<T>
|
|||
|
||||
public static final String[] FORMULA_STR = { "=", "-", "+", "@" };
|
||||
|
||||
/**
|
||||
* 用于dictType属性数据存储,避免重复查缓存
|
||||
*/
|
||||
public Map<String, String> sysDictMap = new HashMap<String, String>();
|
||||
|
||||
/**
|
||||
* Excel sheet最大行数,默认65536
|
||||
*/
|
||||
|
|
@ -150,6 +167,11 @@ public class ExcelUtil<T>
|
|||
*/
|
||||
public Class<T> clazz;
|
||||
|
||||
/**
|
||||
* 需要显示列属性
|
||||
*/
|
||||
public String[] includeFields;
|
||||
|
||||
/**
|
||||
* 需要排除列属性
|
||||
*/
|
||||
|
|
@ -160,11 +182,20 @@ public class ExcelUtil<T>
|
|||
this.clazz = clazz;
|
||||
}
|
||||
|
||||
/**
|
||||
* 仅在Excel中显示列属性
|
||||
*
|
||||
* @param fields 列属性名 示例[单个"name"/多个"id","name"]
|
||||
*/
|
||||
public void showColumn(String... fields)
|
||||
{
|
||||
this.includeFields = fields;
|
||||
}
|
||||
|
||||
/**
|
||||
* 隐藏Excel中列属性
|
||||
*
|
||||
* @param fields 列属性名 示例[单个"name"/多个"id","name"]
|
||||
* @throws Exception
|
||||
*/
|
||||
public void hideColumn(String... fields)
|
||||
{
|
||||
|
|
@ -194,8 +225,6 @@ public class ExcelUtil<T>
|
|||
{
|
||||
if (StringUtils.isNotEmpty(title))
|
||||
{
|
||||
subMergedFirstRowNum++;
|
||||
subMergedLastRowNum++;
|
||||
int titleLastCol = this.fields.size() - 1;
|
||||
if (isSubList())
|
||||
{
|
||||
|
|
@ -206,7 +235,7 @@ public class ExcelUtil<T>
|
|||
Cell titleCell = titleRow.createCell(0);
|
||||
titleCell.setCellStyle(styles.get("title"));
|
||||
titleCell.setCellValue(title);
|
||||
sheet.addMergedRegion(new CellRangeAddress(titleRow.getRowNum(), titleRow.getRowNum(), titleRow.getRowNum(), titleLastCol));
|
||||
sheet.addMergedRegion(new CellRangeAddress(titleRow.getRowNum(), titleRow.getRowNum(), 0, titleLastCol));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -217,23 +246,31 @@ public class ExcelUtil<T>
|
|||
{
|
||||
if (isSubList())
|
||||
{
|
||||
subMergedFirstRowNum++;
|
||||
subMergedLastRowNum++;
|
||||
Row subRow = sheet.createRow(rownum);
|
||||
int excelNum = 0;
|
||||
int column = 0;
|
||||
int subFieldSize = subFields != null ? subFields.size() : 0;
|
||||
for (Object[] objects : fields)
|
||||
{
|
||||
Field field = (Field) objects[0];
|
||||
Excel attr = (Excel) objects[1];
|
||||
Cell headCell1 = subRow.createCell(excelNum);
|
||||
headCell1.setCellValue(attr.name());
|
||||
headCell1.setCellStyle(styles.get(StringUtils.format("header_{}_{}", attr.headerColor(), attr.headerBackgroundColor())));
|
||||
excelNum++;
|
||||
}
|
||||
int headFirstRow = excelNum - 1;
|
||||
int headLastRow = headFirstRow + subFields.size() - 1;
|
||||
if (headLastRow > headFirstRow)
|
||||
{
|
||||
sheet.addMergedRegion(new CellRangeAddress(rownum, rownum, headFirstRow, headLastRow));
|
||||
if (Collection.class.isAssignableFrom(field.getType()))
|
||||
{
|
||||
Cell cell = subRow.createCell(column);
|
||||
cell.setCellValue(attr.name());
|
||||
cell.setCellStyle(styles.get(StringUtils.format("header_{}_{}", attr.headerColor(), attr.headerBackgroundColor())));
|
||||
if (subFieldSize > 1)
|
||||
{
|
||||
CellRangeAddress cellAddress = new CellRangeAddress(rownum, rownum, column, column + subFieldSize - 1);
|
||||
sheet.addMergedRegion(cellAddress);
|
||||
}
|
||||
column += subFieldSize;
|
||||
}
|
||||
else
|
||||
{
|
||||
Cell cell = subRow.createCell(column++);
|
||||
cell.setCellValue(attr.name());
|
||||
cell.setCellStyle(styles.get(StringUtils.format("header_{}_{}", attr.headerColor(), attr.headerBackgroundColor())));
|
||||
}
|
||||
}
|
||||
rownum++;
|
||||
}
|
||||
|
|
@ -246,11 +283,23 @@ public class ExcelUtil<T>
|
|||
* @return 转换后集合
|
||||
*/
|
||||
public List<T> importExcel(InputStream is)
|
||||
{
|
||||
return importExcel(is, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* 对excel表单默认第一个索引名转换成list
|
||||
*
|
||||
* @param is 输入流
|
||||
* @param titleNum 标题占用行数
|
||||
* @return 转换后集合
|
||||
*/
|
||||
public List<T> importExcel(InputStream is, int titleNum)
|
||||
{
|
||||
List<T> list = null;
|
||||
try
|
||||
{
|
||||
list = importExcel(is, 0);
|
||||
list = importExcel(StringUtils.EMPTY, is, titleNum);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
|
@ -264,18 +313,6 @@ public class ExcelUtil<T>
|
|||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
* 对excel表单默认第一个索引名转换成list
|
||||
*
|
||||
* @param is 输入流
|
||||
* @param titleNum 标题占用行数
|
||||
* @return 转换后集合
|
||||
*/
|
||||
public List<T> importExcel(InputStream is, int titleNum) throws Exception
|
||||
{
|
||||
return importExcel(StringUtils.EMPTY, is, titleNum);
|
||||
}
|
||||
|
||||
/**
|
||||
* 对excel表单指定表格索引名转换成list
|
||||
*
|
||||
|
|
@ -295,16 +332,7 @@ public class ExcelUtil<T>
|
|||
{
|
||||
throw new IOException("文件sheet不存在");
|
||||
}
|
||||
boolean isXSSFWorkbook = !(wb instanceof HSSFWorkbook);
|
||||
Map<String, PictureData> pictures;
|
||||
if (isXSSFWorkbook)
|
||||
{
|
||||
pictures = getSheetPictures07((XSSFSheet) sheet, (XSSFWorkbook) wb);
|
||||
}
|
||||
else
|
||||
{
|
||||
pictures = getSheetPictures03((HSSFSheet) sheet, (HSSFWorkbook) wb);
|
||||
}
|
||||
|
||||
// 获取最后一个非空行的行下标,比如总行数为n,则返回的为n-1
|
||||
int rows = sheet.getLastRowNum();
|
||||
if (rows > 0)
|
||||
|
|
@ -362,7 +390,7 @@ public class ExcelUtil<T>
|
|||
if (String.class == fieldType)
|
||||
{
|
||||
String s = Convert.toStr(val);
|
||||
if (StringUtils.endsWith(s, ".0"))
|
||||
if (s.matches("^\\d+\\.0$"))
|
||||
{
|
||||
val = StringUtils.substringBefore(s, ".0");
|
||||
}
|
||||
|
|
@ -425,32 +453,10 @@ public class ExcelUtil<T>
|
|||
{
|
||||
val = reverseByExp(Convert.toStr(val), attr.readConverterExp(), attr.separator());
|
||||
}
|
||||
else if (StringUtils.isNotEmpty(attr.dictType()))
|
||||
{
|
||||
if (!sysDictMap.containsKey(attr.dictType() + val))
|
||||
{
|
||||
String dictValue = reverseDictByExp(Convert.toStr(val), attr.dictType(), attr.separator());
|
||||
sysDictMap.put(attr.dictType() + val, dictValue);
|
||||
}
|
||||
val = sysDictMap.get(attr.dictType() + val);
|
||||
}
|
||||
else if (!attr.handler().equals(ExcelHandlerAdapter.class))
|
||||
{
|
||||
val = dataFormatHandlerAdapter(val, attr, null);
|
||||
}
|
||||
else if (ColumnType.IMAGE == attr.cellType() && StringUtils.isNotEmpty(pictures))
|
||||
{
|
||||
PictureData image = pictures.get(row.getRowNum() + "_" + entry.getKey());
|
||||
if (image == null)
|
||||
{
|
||||
val = "";
|
||||
}
|
||||
else
|
||||
{
|
||||
byte[] data = image.getData();
|
||||
val = FileUtils.writeImportBytes(data);
|
||||
}
|
||||
}
|
||||
ReflectUtils.invokeSetter(entity, propertyName, val);
|
||||
}
|
||||
}
|
||||
|
|
@ -462,33 +468,7 @@ public class ExcelUtil<T>
|
|||
|
||||
/**
|
||||
* 对list数据源将其里面的数据导入到excel表单
|
||||
*
|
||||
* @param list 导出数据集合
|
||||
* @param sheetName 工作表的名称
|
||||
* @return 结果
|
||||
*/
|
||||
public AjaxResult exportExcel(List<T> list, String sheetName)
|
||||
{
|
||||
return exportExcel(list, sheetName, StringUtils.EMPTY);
|
||||
}
|
||||
|
||||
/**
|
||||
* 对list数据源将其里面的数据导入到excel表单
|
||||
*
|
||||
* @param list 导出数据集合
|
||||
* @param sheetName 工作表的名称
|
||||
* @param title 标题
|
||||
* @return 结果
|
||||
*/
|
||||
public AjaxResult exportExcel(List<T> list, String sheetName, String title)
|
||||
{
|
||||
this.init(list, sheetName, title, Type.EXPORT);
|
||||
return exportExcel();
|
||||
}
|
||||
|
||||
/**
|
||||
* 对list数据源将其里面的数据导入到excel表单
|
||||
*
|
||||
*
|
||||
* @param response 返回数据
|
||||
* @param list 导出数据集合
|
||||
* @param sheetName 工作表的名称
|
||||
|
|
@ -501,7 +481,7 @@ public class ExcelUtil<T>
|
|||
|
||||
/**
|
||||
* 对list数据源将其里面的数据导入到excel表单
|
||||
*
|
||||
*
|
||||
* @param response 返回数据
|
||||
* @param list 导出数据集合
|
||||
* @param sheetName 工作表的名称
|
||||
|
|
@ -518,31 +498,7 @@ public class ExcelUtil<T>
|
|||
|
||||
/**
|
||||
* 对list数据源将其里面的数据导入到excel表单
|
||||
*
|
||||
* @param sheetName 工作表的名称
|
||||
* @return 结果
|
||||
*/
|
||||
public AjaxResult importTemplateExcel(String sheetName)
|
||||
{
|
||||
return importTemplateExcel(sheetName, StringUtils.EMPTY);
|
||||
}
|
||||
|
||||
/**
|
||||
* 对list数据源将其里面的数据导入到excel表单
|
||||
*
|
||||
* @param sheetName 工作表的名称
|
||||
* @param title 标题
|
||||
* @return 结果
|
||||
*/
|
||||
public AjaxResult importTemplateExcel(String sheetName, String title)
|
||||
{
|
||||
this.init(null, sheetName, title, Type.IMPORT);
|
||||
return exportExcel();
|
||||
}
|
||||
|
||||
/**
|
||||
* 对list数据源将其里面的数据导入到excel表单
|
||||
*
|
||||
*
|
||||
* @param sheetName 工作表的名称
|
||||
* @return 结果
|
||||
*/
|
||||
|
|
@ -553,7 +509,7 @@ public class ExcelUtil<T>
|
|||
|
||||
/**
|
||||
* 对list数据源将其里面的数据导入到excel表单
|
||||
*
|
||||
*
|
||||
* @param sheetName 工作表的名称
|
||||
* @param title 标题
|
||||
* @return 结果
|
||||
|
|
@ -588,34 +544,6 @@ public class ExcelUtil<T>
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 对list数据源将其里面的数据导入到excel表单
|
||||
*
|
||||
* @return 结果
|
||||
*/
|
||||
public AjaxResult exportExcel()
|
||||
{
|
||||
OutputStream out = null;
|
||||
try
|
||||
{
|
||||
writeSheet();
|
||||
String filename = encodingFilename(sheetName);
|
||||
out = new FileOutputStream(getAbsoluteFile(filename));
|
||||
wb.write(out);
|
||||
return AjaxResult.success(filename);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
log.error("导出Excel异常{}", e.getMessage());
|
||||
throw new UtilException("导出Excel失败,请联系网站管理员!");
|
||||
}
|
||||
finally
|
||||
{
|
||||
IOUtils.closeQuietly(wb);
|
||||
IOUtils.closeQuietly(out);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建写入数据到Sheet
|
||||
*/
|
||||
|
|
@ -667,64 +595,91 @@ public class ExcelUtil<T>
|
|||
{
|
||||
int startNo = index * sheetSize;
|
||||
int endNo = Math.min(startNo + sheetSize, list.size());
|
||||
int rowNo = (1 + rownum) - startNo;
|
||||
int currentRowNum = rownum + 1; // 从标题行后开始
|
||||
|
||||
for (int i = startNo; i < endNo; i++)
|
||||
{
|
||||
rowNo = isSubList() ? (i > 1 ? rowNo + 1 : rowNo + i) : i + 1 + rownum - startNo;
|
||||
row = sheet.createRow(rowNo);
|
||||
// 得到导出对象.
|
||||
row = sheet.createRow(currentRowNum);
|
||||
T vo = (T) list.get(i);
|
||||
Collection<?> subList = null;
|
||||
if (isSubList())
|
||||
{
|
||||
if (isSubListValue(vo))
|
||||
{
|
||||
subList = getListCellValue(vo);
|
||||
subMergedLastRowNum = subMergedLastRowNum + subList.size();
|
||||
}
|
||||
else
|
||||
{
|
||||
subMergedFirstRowNum++;
|
||||
subMergedLastRowNum++;
|
||||
}
|
||||
}
|
||||
int column = 0;
|
||||
int maxSubListSize = getCurrentMaxSubListSize(vo);
|
||||
for (Object[] os : fields)
|
||||
{
|
||||
Field field = (Field) os[0];
|
||||
Excel excel = (Excel) os[1];
|
||||
if (Collection.class.isAssignableFrom(field.getType()) && StringUtils.isNotNull(subList))
|
||||
if (Collection.class.isAssignableFrom(field.getType()))
|
||||
{
|
||||
boolean subFirst = false;
|
||||
for (Object obj : subList)
|
||||
try
|
||||
{
|
||||
if (subFirst)
|
||||
Collection<?> subList = (Collection<?>) getTargetValue(vo, field, excel);
|
||||
if (subList != null && !subList.isEmpty())
|
||||
{
|
||||
rowNo++;
|
||||
row = sheet.createRow(rowNo);
|
||||
}
|
||||
List<Field> subFields = FieldUtils.getFieldsListWithAnnotation(obj.getClass(), Excel.class);
|
||||
int subIndex = 0;
|
||||
for (Field subField : subFields)
|
||||
{
|
||||
if (subField.isAnnotationPresent(Excel.class))
|
||||
int subIndex = 0;
|
||||
for (Object subVo : subList)
|
||||
{
|
||||
subField.setAccessible(true);
|
||||
Excel attr = subField.getAnnotation(Excel.class);
|
||||
this.addCell(attr, row, (T) obj, subField, column + subIndex);
|
||||
Row subRow = sheet.getRow(currentRowNum + subIndex);
|
||||
if (subRow == null)
|
||||
{
|
||||
subRow = sheet.createRow(currentRowNum + subIndex);
|
||||
}
|
||||
|
||||
int subColumn = column;
|
||||
for (Field subField : subFields)
|
||||
{
|
||||
Excel subExcel = subField.getAnnotation(Excel.class);
|
||||
addCell(subExcel, subRow, (T) subVo, subField, subColumn++);
|
||||
}
|
||||
subIndex++;
|
||||
}
|
||||
subIndex++;
|
||||
column += subFields.size();
|
||||
}
|
||||
subFirst = true;
|
||||
}
|
||||
this.subMergedFirstRowNum = this.subMergedFirstRowNum + subList.size();
|
||||
catch (Exception e)
|
||||
{
|
||||
log.error("填充集合数据失败", e);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.addCell(excel, row, vo, field, column++);
|
||||
// 创建单元格并设置值
|
||||
addCell(excel, row, vo, field, column);
|
||||
if (maxSubListSize > 1 && excel.needMerge())
|
||||
{
|
||||
sheet.addMergedRegion(new CellRangeAddress(currentRowNum, currentRowNum + maxSubListSize - 1, column, column));
|
||||
}
|
||||
column++;
|
||||
}
|
||||
}
|
||||
currentRowNum += maxSubListSize;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取子列表最大数
|
||||
*/
|
||||
private int getCurrentMaxSubListSize(T vo)
|
||||
{
|
||||
int maxSubListSize = 1;
|
||||
for (Object[] os : fields)
|
||||
{
|
||||
Field field = (Field) os[0];
|
||||
if (Collection.class.isAssignableFrom(field.getType()))
|
||||
{
|
||||
try
|
||||
{
|
||||
Collection<?> subList = (Collection<?>) getTargetValue(vo, field, (Excel) os[1]);
|
||||
if (subList != null && !subList.isEmpty())
|
||||
{
|
||||
maxSubListSize = Math.max(maxSubListSize, subList.size());
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
log.error("获取集合大小失败", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
return maxSubListSize;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -859,7 +814,7 @@ public class ExcelUtil<T>
|
|||
*/
|
||||
public void annotationDataStyles(Map<String, CellStyle> styles, Field field, Excel excel)
|
||||
{
|
||||
String key = StringUtils.format("data_{}_{}_{}_{}", excel.align(), excel.color(), excel.backgroundColor(), excel.cellType());
|
||||
String key = StringUtils.format("data_{}_{}_{}_{}_{}", excel.align(), excel.color(), excel.backgroundColor(), excel.cellType(), excel.wrapText());
|
||||
if (!styles.containsKey(key))
|
||||
{
|
||||
CellStyle style = wb.createCellStyle();
|
||||
|
|
@ -875,6 +830,7 @@ public class ExcelUtil<T>
|
|||
style.setBottomBorderColor(IndexedColors.GREY_50_PERCENT.getIndex());
|
||||
style.setFillPattern(FillPatternType.SOLID_FOREGROUND);
|
||||
style.setFillForegroundColor(excel.backgroundColor().getIndex());
|
||||
style.setWrapText(excel.wrapText());
|
||||
Font dataFont = wb.createFont();
|
||||
dataFont.setFontName("Arial");
|
||||
dataFont.setFontHeightInPoints((short) 10);
|
||||
|
|
@ -903,7 +859,7 @@ public class ExcelUtil<T>
|
|||
if (isSubList())
|
||||
{
|
||||
// 填充默认样式,防止合并单元格样式失效
|
||||
sheet.setDefaultColumnStyle(column, styles.get(StringUtils.format("data_{}_{}_{}_{}", attr.align(), attr.color(), attr.backgroundColor(), attr.cellType())));
|
||||
sheet.setDefaultColumnStyle(column, styles.get(StringUtils.format("data_{}_{}_{}_{}_{}", attr.align(), attr.color(), attr.backgroundColor(), attr.cellType(), attr.wrapText())));
|
||||
if (attr.needMerge())
|
||||
{
|
||||
sheet.addMergedRegion(new CellRangeAddress(rownum - 1, rownum, column, column));
|
||||
|
|
@ -998,28 +954,17 @@ public class ExcelUtil<T>
|
|||
// 设置列宽
|
||||
sheet.setColumnWidth(column, (int) ((attr.width() + 0.72) * 256));
|
||||
}
|
||||
if (StringUtils.isNotEmpty(attr.prompt()) || attr.combo().length > 0 || attr.comboReadDict())
|
||||
if (StringUtils.isNotEmpty(attr.prompt()) || attr.combo().length > 0)
|
||||
{
|
||||
String[] comboArray = attr.combo();
|
||||
if (attr.comboReadDict())
|
||||
{
|
||||
if (!sysDictMap.containsKey("combo_" + attr.dictType()))
|
||||
{
|
||||
String labels = DictUtils.getDictLabels(attr.dictType());
|
||||
sysDictMap.put("combo_" + attr.dictType(), labels);
|
||||
}
|
||||
String val = sysDictMap.get("combo_" + attr.dictType());
|
||||
comboArray = StringUtils.split(val, DictUtils.SEPARATOR);
|
||||
}
|
||||
if (comboArray.length > 15 || StringUtils.join(comboArray).length() > 255)
|
||||
if (attr.combo().length > 15 || StringUtils.join(attr.combo()).length() > 255)
|
||||
{
|
||||
// 如果下拉数大于15或字符串长度大于255,则使用一个新sheet存储,避免生成的模板下拉值获取不到
|
||||
setXSSFValidationWithHidden(sheet, comboArray, attr.prompt(), 1, 100, column, column);
|
||||
setXSSFValidationWithHidden(sheet, attr.combo(), attr.prompt(), 1, 100, column, column);
|
||||
}
|
||||
else
|
||||
{
|
||||
// 提示信息或只能选择不能输入的列内容.
|
||||
setPromptOrValidation(sheet, comboArray, attr.prompt(), 1, 100, column, column);
|
||||
setPromptOrValidation(sheet, attr.combo(), attr.prompt(), 1, 100, column, column);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1041,34 +986,27 @@ public class ExcelUtil<T>
|
|||
cell = row.createCell(column);
|
||||
if (isSubListValue(vo) && getListCellValue(vo).size() > 1 && attr.needMerge())
|
||||
{
|
||||
CellRangeAddress cellAddress = new CellRangeAddress(subMergedFirstRowNum, subMergedLastRowNum, column, column);
|
||||
sheet.addMergedRegion(cellAddress);
|
||||
if (subMergedLastRowNum >= subMergedFirstRowNum)
|
||||
{
|
||||
sheet.addMergedRegion(new CellRangeAddress(subMergedFirstRowNum, subMergedLastRowNum, column, column));
|
||||
}
|
||||
}
|
||||
cell.setCellStyle(styles.get(StringUtils.format("data_{}_{}_{}_{}", attr.align(), attr.color(), attr.backgroundColor(), attr.cellType())));
|
||||
cell.setCellStyle(styles.get(StringUtils.format("data_{}_{}_{}_{}_{}", attr.align(), attr.color(), attr.backgroundColor(), attr.cellType(), attr.wrapText())));
|
||||
|
||||
// 用于读取对象中的属性
|
||||
Object value = getTargetValue(vo, field, attr);
|
||||
String dateFormat = attr.dateFormat();
|
||||
String readConverterExp = attr.readConverterExp();
|
||||
String separator = attr.separator();
|
||||
String dictType = attr.dictType();
|
||||
if (StringUtils.isNotEmpty(dateFormat) && StringUtils.isNotNull(value))
|
||||
{
|
||||
cell.getCellStyle().setDataFormat(this.wb.getCreationHelper().createDataFormat().getFormat(dateFormat));
|
||||
cell.setCellValue(parseDateToStr(dateFormat, value));
|
||||
}
|
||||
else if (StringUtils.isNotEmpty(readConverterExp) && StringUtils.isNotNull(value))
|
||||
{
|
||||
cell.setCellValue(convertByExp(Convert.toStr(value), readConverterExp, separator));
|
||||
}
|
||||
else if (StringUtils.isNotEmpty(dictType) && StringUtils.isNotNull(value))
|
||||
{
|
||||
if (!sysDictMap.containsKey(dictType + value))
|
||||
{
|
||||
String lable = convertDictByExp(Convert.toStr(value), dictType, separator);
|
||||
sysDictMap.put(dictType + value, lable);
|
||||
}
|
||||
cell.setCellValue(sysDictMap.get(dictType + value));
|
||||
}
|
||||
else if (value instanceof BigDecimal && -1 != attr.scale())
|
||||
{
|
||||
cell.setCellValue((((BigDecimal) value).setScale(attr.scale(), attr.roundingMode())).doubleValue());
|
||||
|
|
@ -1255,35 +1193,9 @@ public class ExcelUtil<T>
|
|||
return StringUtils.stripEnd(propertyString.toString(), separator);
|
||||
}
|
||||
|
||||
/**
|
||||
* 解析字典值
|
||||
*
|
||||
* @param dictValue 字典值
|
||||
* @param dictType 字典类型
|
||||
* @param separator 分隔符
|
||||
* @return 字典标签
|
||||
*/
|
||||
public static String convertDictByExp(String dictValue, String dictType, String separator)
|
||||
{
|
||||
return DictUtils.getDictLabel(dictType, dictValue, separator);
|
||||
}
|
||||
|
||||
/**
|
||||
* 反向解析值字典值
|
||||
*
|
||||
* @param dictLabel 字典标签
|
||||
* @param dictType 字典类型
|
||||
* @param separator 分隔符
|
||||
* @return 字典值
|
||||
*/
|
||||
public static String reverseDictByExp(String dictLabel, String dictType, String separator)
|
||||
{
|
||||
return DictUtils.getDictValue(dictType, dictLabel, separator);
|
||||
}
|
||||
|
||||
/**
|
||||
* 数据处理器
|
||||
*
|
||||
*
|
||||
* @param value 数据值
|
||||
* @param excel 数据注解
|
||||
* @return
|
||||
|
|
@ -1349,34 +1261,9 @@ public class ExcelUtil<T>
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 编码文件名
|
||||
*/
|
||||
public String encodingFilename(String filename)
|
||||
{
|
||||
filename = UUID.randomUUID() + "_" + filename + ".xlsx";
|
||||
return filename;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取下载路径
|
||||
*
|
||||
* @param filename 文件名称
|
||||
*/
|
||||
public String getAbsoluteFile(String filename)
|
||||
{
|
||||
String downloadPath = TcctynConfig.getDownloadPath() + filename;
|
||||
File desc = new File(downloadPath);
|
||||
if (!desc.getParentFile().exists())
|
||||
{
|
||||
desc.getParentFile().mkdirs();
|
||||
}
|
||||
return downloadPath;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取bean中的属性值
|
||||
*
|
||||
*
|
||||
* @param vo 实体对象
|
||||
* @param field 字段
|
||||
* @param excel 注解
|
||||
|
|
@ -1385,6 +1272,7 @@ public class ExcelUtil<T>
|
|||
*/
|
||||
private Object getTargetValue(T vo, Field field, Excel excel) throws Exception
|
||||
{
|
||||
field.setAccessible(true);
|
||||
Object o = field.get(vo);
|
||||
if (StringUtils.isNotEmpty(excel.targetAttr()))
|
||||
{
|
||||
|
|
@ -1407,7 +1295,7 @@ public class ExcelUtil<T>
|
|||
|
||||
/**
|
||||
* 以类的属性的get方法方法形式获取值
|
||||
*
|
||||
*
|
||||
* @param o
|
||||
* @param name
|
||||
* @return value
|
||||
|
|
@ -1444,46 +1332,83 @@ public class ExcelUtil<T>
|
|||
List<Field> tempFields = new ArrayList<>();
|
||||
tempFields.addAll(Arrays.asList(clazz.getSuperclass().getDeclaredFields()));
|
||||
tempFields.addAll(Arrays.asList(clazz.getDeclaredFields()));
|
||||
for (Field field : tempFields)
|
||||
if (StringUtils.isNotEmpty(includeFields))
|
||||
{
|
||||
if (!ArrayUtils.contains(this.excludeFields, field.getName()))
|
||||
for (Field field : tempFields)
|
||||
{
|
||||
// 单注解
|
||||
if (field.isAnnotationPresent(Excel.class))
|
||||
if (ArrayUtils.contains(this.includeFields, field.getName()) || field.isAnnotationPresent(Excels.class))
|
||||
{
|
||||
Excel attr = field.getAnnotation(Excel.class);
|
||||
if (attr != null && (attr.type() == Type.ALL || attr.type() == type))
|
||||
addField(fields, field);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (StringUtils.isNotEmpty(excludeFields))
|
||||
{
|
||||
for (Field field : tempFields)
|
||||
{
|
||||
if (!ArrayUtils.contains(this.excludeFields, field.getName()))
|
||||
{
|
||||
addField(fields, field);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (Field field : tempFields)
|
||||
{
|
||||
addField(fields, field);
|
||||
}
|
||||
}
|
||||
return fields;
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加字段信息
|
||||
*/
|
||||
public void addField(List<Object[]> fields, Field field)
|
||||
{
|
||||
// 单注解
|
||||
if (field.isAnnotationPresent(Excel.class))
|
||||
{
|
||||
Excel attr = field.getAnnotation(Excel.class);
|
||||
if (attr != null && (attr.type() == Type.ALL || attr.type() == type))
|
||||
{
|
||||
fields.add(new Object[] { field, attr });
|
||||
}
|
||||
if (Collection.class.isAssignableFrom(field.getType()))
|
||||
{
|
||||
subMethod = getSubMethod(field.getName(), clazz);
|
||||
ParameterizedType pt = (ParameterizedType) field.getGenericType();
|
||||
Class<?> subClass = (Class<?>) pt.getActualTypeArguments()[0];
|
||||
this.subFields = FieldUtils.getFieldsListWithAnnotation(subClass, Excel.class);
|
||||
}
|
||||
}
|
||||
|
||||
// 多注解
|
||||
if (field.isAnnotationPresent(Excels.class))
|
||||
{
|
||||
Excels attrs = field.getAnnotation(Excels.class);
|
||||
Excel[] excels = attrs.value();
|
||||
for (Excel attr : excels)
|
||||
{
|
||||
if (StringUtils.isNotEmpty(includeFields))
|
||||
{
|
||||
if (ArrayUtils.contains(this.includeFields, field.getName() + "." + attr.targetAttr())
|
||||
&& (attr != null && (attr.type() == Type.ALL || attr.type() == type)))
|
||||
{
|
||||
field.setAccessible(true);
|
||||
fields.add(new Object[] { field, attr });
|
||||
}
|
||||
if (Collection.class.isAssignableFrom(field.getType()))
|
||||
{
|
||||
subMethod = getSubMethod(field.getName(), clazz);
|
||||
ParameterizedType pt = (ParameterizedType) field.getGenericType();
|
||||
Class<?> subClass = (Class<?>) pt.getActualTypeArguments()[0];
|
||||
this.subFields = FieldUtils.getFieldsListWithAnnotation(subClass, Excel.class);
|
||||
}
|
||||
}
|
||||
|
||||
// 多注解
|
||||
if (field.isAnnotationPresent(Excels.class))
|
||||
else
|
||||
{
|
||||
Excels attrs = field.getAnnotation(Excels.class);
|
||||
Excel[] excels = attrs.value();
|
||||
for (Excel attr : excels)
|
||||
if (!ArrayUtils.contains(this.excludeFields, field.getName() + "." + attr.targetAttr())
|
||||
&& (attr != null && (attr.type() == Type.ALL || attr.type() == type)))
|
||||
{
|
||||
if (!ArrayUtils.contains(this.excludeFields, field.getName() + "." + attr.targetAttr())
|
||||
&& (attr != null && (attr.type() == Type.ALL || attr.type() == type)))
|
||||
{
|
||||
field.setAccessible(true);
|
||||
fields.add(new Object[] { field, attr });
|
||||
}
|
||||
fields.add(new Object[] { field, attr });
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return fields;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -1611,71 +1536,6 @@ public class ExcelUtil<T>
|
|||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取Excel2003图片
|
||||
*
|
||||
* @param sheet 当前sheet对象
|
||||
* @param workbook 工作簿对象
|
||||
* @return Map key:图片单元格索引(1_1)String,value:图片流PictureData
|
||||
*/
|
||||
public static Map<String, PictureData> getSheetPictures03(HSSFSheet sheet, HSSFWorkbook workbook)
|
||||
{
|
||||
Map<String, PictureData> sheetIndexPicMap = new HashMap<String, PictureData>();
|
||||
List<HSSFPictureData> pictures = workbook.getAllPictures();
|
||||
if (!pictures.isEmpty())
|
||||
{
|
||||
for (HSSFShape shape : sheet.getDrawingPatriarch().getChildren())
|
||||
{
|
||||
HSSFClientAnchor anchor = (HSSFClientAnchor) shape.getAnchor();
|
||||
if (shape instanceof HSSFPicture)
|
||||
{
|
||||
HSSFPicture pic = (HSSFPicture) shape;
|
||||
int pictureIndex = pic.getPictureIndex() - 1;
|
||||
HSSFPictureData picData = pictures.get(pictureIndex);
|
||||
String picIndex = anchor.getRow1() + "_" + anchor.getCol1();
|
||||
sheetIndexPicMap.put(picIndex, picData);
|
||||
}
|
||||
}
|
||||
return sheetIndexPicMap;
|
||||
}
|
||||
else
|
||||
{
|
||||
return sheetIndexPicMap;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取Excel2007图片
|
||||
*
|
||||
* @param sheet 当前sheet对象
|
||||
* @param workbook 工作簿对象
|
||||
* @return Map key:图片单元格索引(1_1)String,value:图片流PictureData
|
||||
*/
|
||||
public static Map<String, PictureData> getSheetPictures07(XSSFSheet sheet, XSSFWorkbook workbook)
|
||||
{
|
||||
Map<String, PictureData> sheetIndexPicMap = new HashMap<String, PictureData>();
|
||||
for (POIXMLDocumentPart dr : sheet.getRelations())
|
||||
{
|
||||
if (dr instanceof XSSFDrawing)
|
||||
{
|
||||
XSSFDrawing drawing = (XSSFDrawing) dr;
|
||||
List<XSSFShape> shapes = drawing.getShapes();
|
||||
for (XSSFShape shape : shapes)
|
||||
{
|
||||
if (shape instanceof XSSFPicture)
|
||||
{
|
||||
XSSFPicture pic = (XSSFPicture) shape;
|
||||
XSSFClientAnchor anchor = pic.getPreferredSize();
|
||||
CTMarker ctMarker = anchor.getFrom();
|
||||
String picIndex = ctMarker.getRow() + "_" + ctMarker.getCol();
|
||||
sheetIndexPicMap.put(picIndex, pic.getPictureData());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return sheetIndexPicMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* 格式化不同类型的日期对象
|
||||
*
|
||||
|
|
|
|||
|
|
@ -1,15 +1,19 @@
|
|||
package com.tcctyn.common.core.utils.reflect;
|
||||
|
||||
import com.tcctyn.common.core.text.Convert;
|
||||
import com.tcctyn.common.core.utils.DateUtils;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.lang.reflect.ParameterizedType;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.Date;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.lang3.Validate;
|
||||
import org.apache.poi.ss.usermodel.DateUtil;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.lang.reflect.*;
|
||||
import java.util.Date;
|
||||
import com.tcctyn.common.core.text.Convert;
|
||||
import com.tcctyn.common.core.utils.DateUtils;
|
||||
|
||||
/**
|
||||
* 反射工具类. 提供调用getter/setter方法, 访问私有变量, 调用私有方法, 获取泛型类型Class, 被AOP过的真实类等工具函数.
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ public class SqlUtil
|
|||
/**
|
||||
* 定义常用的 sql关键字
|
||||
*/
|
||||
public static String SQL_REGEX = "and |extractvalue|updatexml|exec |insert |select |delete |update |drop |count |chr |mid |master |truncate |char |declare |or |+|user()";
|
||||
public static String SQL_REGEX = "\u000B|and |extractvalue|updatexml|sleep|exec |insert |select |delete |update |drop |count |chr |mid |master |truncate |char |declare |or |union |like |+|/*|user()";
|
||||
|
||||
/**
|
||||
* 仅支持字母、数字、下划线、空格、逗号、小数点(支持多个字段排序)
|
||||
|
|
|
|||
|
|
@ -1,10 +1,9 @@
|
|||
package com.tcctyn.common.core.utils.uuid;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import com.tcctyn.common.core.utils.DateUtils;
|
||||
import com.tcctyn.common.core.utils.StringUtils;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
/**
|
||||
* @author tcctyn 序列生成类
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -1,12 +1,11 @@
|
|||
package com.tcctyn.common.core.utils.uuid;
|
||||
|
||||
import com.tcctyn.common.core.exception.UtilException;
|
||||
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.security.SecureRandom;
|
||||
import java.util.Random;
|
||||
import java.util.concurrent.ThreadLocalRandom;
|
||||
import com.tcctyn.common.core.exception.UtilException;
|
||||
|
||||
/**
|
||||
* 提供通用唯一识别码(universally unique identifier)(UUID)实现
|
||||
|
|
@ -67,7 +66,7 @@ public final class UUID implements java.io.Serializable, Comparable<UUID>
|
|||
}
|
||||
|
||||
/**
|
||||
* 获取类型 4(伪随机生成的)UUID 的静态工厂。
|
||||
* 获取类型 4(伪随机生成的)UUID 的静态工厂。
|
||||
*
|
||||
* @return 随机生成的 {@code UUID}
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -1,44 +1,45 @@
|
|||
package com.tcctyn.common.core.web.controller;
|
||||
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.tcctyn.common.core.constant.HttpStatus;
|
||||
import com.tcctyn.common.core.web.domain.AjaxResult;
|
||||
import com.tcctyn.common.core.web.domain.model.LoginUser;
|
||||
import com.tcctyn.common.core.web.page.PageDomain;
|
||||
import com.tcctyn.common.core.web.page.TableDataInfo;
|
||||
import com.tcctyn.common.core.web.page.TableSupport;
|
||||
import com.tcctyn.common.core.utils.DateUtils;
|
||||
import com.tcctyn.common.core.utils.PageUtils;
|
||||
import com.tcctyn.common.core.utils.SecurityUtils;
|
||||
import com.tcctyn.common.core.utils.StringUtils;
|
||||
import com.tcctyn.common.core.utils.sql.SqlUtil;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.web.bind.WebDataBinder;
|
||||
import org.springframework.web.bind.annotation.InitBinder;
|
||||
|
||||
import java.beans.PropertyEditorSupport;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.web.bind.WebDataBinder;
|
||||
import org.springframework.web.bind.annotation.InitBinder;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.tcctyn.common.core.constant.HttpStatus;
|
||||
import com.tcctyn.common.core.utils.DateUtils;
|
||||
import com.tcctyn.common.core.utils.PageUtils;
|
||||
import com.tcctyn.common.core.utils.StringUtils;
|
||||
import com.tcctyn.common.core.utils.sql.SqlUtil;
|
||||
import com.tcctyn.common.core.web.domain.AjaxResult;
|
||||
import com.tcctyn.common.core.web.page.PageDomain;
|
||||
import com.tcctyn.common.core.web.page.TableDataInfo;
|
||||
import com.tcctyn.common.core.web.page.TableSupport;
|
||||
|
||||
/**
|
||||
* web层通用数据处理
|
||||
*
|
||||
*
|
||||
* @author tcctyn
|
||||
*/
|
||||
public class BaseController {
|
||||
public class BaseController
|
||||
{
|
||||
protected final Logger logger = LoggerFactory.getLogger(this.getClass());
|
||||
|
||||
/**
|
||||
* 将前台传递过来的日期格式的字符串,自动转化为Date类型
|
||||
*/
|
||||
@InitBinder
|
||||
public void initBinder(WebDataBinder binder) {
|
||||
public void initBinder(WebDataBinder binder)
|
||||
{
|
||||
// Date 类型转换
|
||||
binder.registerCustomEditor(Date.class, new PropertyEditorSupport() {
|
||||
binder.registerCustomEditor(Date.class, new PropertyEditorSupport()
|
||||
{
|
||||
@Override
|
||||
public void setAsText(String text) {
|
||||
public void setAsText(String text)
|
||||
{
|
||||
setValue(DateUtils.parseDate(text));
|
||||
}
|
||||
});
|
||||
|
|
@ -47,16 +48,19 @@ public class BaseController {
|
|||
/**
|
||||
* 设置请求分页数据
|
||||
*/
|
||||
protected void startPage() {
|
||||
protected void startPage()
|
||||
{
|
||||
PageUtils.startPage();
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置请求排序数据
|
||||
*/
|
||||
protected void startOrderBy() {
|
||||
protected void startOrderBy()
|
||||
{
|
||||
PageDomain pageDomain = TableSupport.buildPageRequest();
|
||||
if (StringUtils.isNotEmpty(pageDomain.getOrderBy())) {
|
||||
if (StringUtils.isNotEmpty(pageDomain.getOrderBy()))
|
||||
{
|
||||
String orderBy = SqlUtil.escapeOrderBySql(pageDomain.getOrderBy());
|
||||
PageHelper.orderBy(orderBy);
|
||||
}
|
||||
|
|
@ -65,132 +69,92 @@ public class BaseController {
|
|||
/**
|
||||
* 清理分页的线程变量
|
||||
*/
|
||||
protected void clearPage() {
|
||||
protected void clearPage()
|
||||
{
|
||||
PageUtils.clearPage();
|
||||
}
|
||||
|
||||
/**
|
||||
* 响应请求分页数据
|
||||
*/
|
||||
@SuppressWarnings({"rawtypes", "unchecked"})
|
||||
protected TableDataInfo getDataTable(List<?> list) {
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
protected TableDataInfo getDataTable(List<?> list)
|
||||
{
|
||||
TableDataInfo rspData = new TableDataInfo();
|
||||
rspData.setCode(HttpStatus.SUCCESS);
|
||||
rspData.setMsg("查询成功");
|
||||
rspData.setRows(list);
|
||||
rspData.setMsg("查询成功");
|
||||
rspData.setTotal(new PageInfo(list).getTotal());
|
||||
return rspData;
|
||||
}
|
||||
|
||||
/**
|
||||
* 涉及到DO转VO的使用下面这个方法
|
||||
* @Param dolist 数据库查询出来的list
|
||||
* @Param volist 前台展示的list
|
||||
*/
|
||||
protected TableDataInfo getDataTable(List<?> dolist, List<?> voList) {
|
||||
TableDataInfo rspData = new TableDataInfo();
|
||||
rspData.setCode(HttpStatus.SUCCESS);
|
||||
rspData.setMsg("查询成功");
|
||||
rspData.setRows(voList);
|
||||
rspData.setTotal(new PageInfo(dolist).getTotal());
|
||||
return rspData;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 返回成功
|
||||
*/
|
||||
public AjaxResult success() {
|
||||
public AjaxResult success()
|
||||
{
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回失败消息
|
||||
*/
|
||||
public AjaxResult error() {
|
||||
return AjaxResult.error();
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回成功消息
|
||||
*/
|
||||
public AjaxResult success(String message) {
|
||||
public AjaxResult success(String message)
|
||||
{
|
||||
return AjaxResult.success(message);
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回成功消息
|
||||
*/
|
||||
public AjaxResult success(Object data) {
|
||||
public AjaxResult success(Object data)
|
||||
{
|
||||
return AjaxResult.success(data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回失败消息
|
||||
*/
|
||||
public AjaxResult error(String message) {
|
||||
public AjaxResult error()
|
||||
{
|
||||
return AjaxResult.error();
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回失败消息
|
||||
*/
|
||||
public AjaxResult error(String message)
|
||||
{
|
||||
return AjaxResult.error(message);
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回警告消息
|
||||
*/
|
||||
public AjaxResult warn(String message) {
|
||||
public AjaxResult warn(String message)
|
||||
{
|
||||
return AjaxResult.warn(message);
|
||||
}
|
||||
|
||||
/**
|
||||
* 响应返回结果
|
||||
*
|
||||
*
|
||||
* @param rows 影响行数
|
||||
* @return 操作结果
|
||||
*/
|
||||
protected AjaxResult toAjax(int rows) {
|
||||
protected AjaxResult toAjax(int rows)
|
||||
{
|
||||
return rows > 0 ? AjaxResult.success() : AjaxResult.error();
|
||||
}
|
||||
|
||||
/**
|
||||
* 响应返回结果
|
||||
*
|
||||
*
|
||||
* @param result 结果
|
||||
* @return 操作结果
|
||||
*/
|
||||
protected AjaxResult toAjax(boolean result) {
|
||||
protected AjaxResult toAjax(boolean result)
|
||||
{
|
||||
return result ? success() : error();
|
||||
}
|
||||
|
||||
/**
|
||||
* 页面跳转
|
||||
*/
|
||||
public String redirect(String url) {
|
||||
return StringUtils.format("redirect:{}", url);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户缓存信息
|
||||
*/
|
||||
public LoginUser getLoginUser() {
|
||||
return SecurityUtils.getLoginUser();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取登录用户id
|
||||
*/
|
||||
public Long getUserId() {
|
||||
return getLoginUser().getUserId();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取登录部门id
|
||||
*/
|
||||
public Long getDeptId() {
|
||||
return getLoginUser().getDeptId();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取登录用户名
|
||||
*/
|
||||
public String getUsername() {
|
||||
return getLoginUser().getUsername();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,10 +1,9 @@
|
|||
package com.tcctyn.common.core.web.domain;
|
||||
|
||||
import com.tcctyn.common.core.constant.HttpStatus;
|
||||
import com.tcctyn.common.core.utils.StringUtils;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Objects;
|
||||
import com.tcctyn.common.core.constant.HttpStatus;
|
||||
import com.tcctyn.common.core.utils.StringUtils;
|
||||
|
||||
/**
|
||||
* 操作消息提醒
|
||||
|
|
@ -204,9 +203,9 @@ public class AjaxResult extends HashMap<String, Object>
|
|||
/**
|
||||
* 方便链式调用
|
||||
*
|
||||
* @param key 键
|
||||
* @param value 值
|
||||
* @return 数据对象
|
||||
* @param key
|
||||
* @param value
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public AjaxResult put(String key, Object value)
|
||||
|
|
|
|||
|
|
@ -1,14 +1,12 @@
|
|||
package com.tcctyn.common.core.web.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
|
||||
/**
|
||||
* Entity基类
|
||||
|
|
@ -21,7 +19,6 @@ public class BaseEntity implements Serializable
|
|||
|
||||
/** 搜索值 */
|
||||
@JsonIgnore
|
||||
@TableField(exist = false)
|
||||
private String searchValue;
|
||||
|
||||
/** 创建者 */
|
||||
|
|
@ -39,12 +36,10 @@ public class BaseEntity implements Serializable
|
|||
private Date updateTime;
|
||||
|
||||
/** 备注 */
|
||||
@TableField(exist = false)
|
||||
private String remark;
|
||||
|
||||
/** 请求参数 */
|
||||
@JsonInclude(JsonInclude.Include.NON_EMPTY)
|
||||
@TableField(exist = false)
|
||||
private Map<String, Object> params;
|
||||
|
||||
public String getSearchValue()
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ public class TableDataInfo implements Serializable
|
|||
* @param list 列表数据
|
||||
* @param total 总记录数
|
||||
*/
|
||||
public TableDataInfo(List<?> list, int total)
|
||||
public TableDataInfo(List<?> list, long total)
|
||||
{
|
||||
this.rows = list;
|
||||
this.total = total;
|
||||
|
|
@ -82,4 +82,4 @@ public class TableDataInfo implements Serializable
|
|||
{
|
||||
this.msg = msg;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,11 +1,10 @@
|
|||
package com.tcctyn.common.core.xss;
|
||||
|
||||
import com.tcctyn.common.core.utils.StringUtils;
|
||||
|
||||
import javax.validation.ConstraintValidator;
|
||||
import javax.validation.ConstraintValidatorContext;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import javax.validation.ConstraintValidator;
|
||||
import javax.validation.ConstraintValidatorContext;
|
||||
import com.tcctyn.common.core.utils.StringUtils;
|
||||
|
||||
/**
|
||||
* 自定义xss校验注解实现
|
||||
|
|
|
|||
|
|
@ -85,24 +85,9 @@
|
|||
<dependency>
|
||||
<groupId>com.hikvision.ga</groupId>
|
||||
<artifactId>artemis-http-client</artifactId>
|
||||
<version>${artemis-http-client.version}</version>
|
||||
<version>1.1.3</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
<!-- mybatis-plus 增强CRUD -->
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>mybatis-plus-boot-starter</artifactId>
|
||||
<version>${mybatis-plus-boot-starter.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.github.yulichang</groupId>
|
||||
<artifactId>mybatis-plus-join-boot-starter</artifactId>
|
||||
<version>${mybatis-plus-join-boot-starter.version}</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
|
|
|||
|
|
@ -4,12 +4,10 @@ import com.tcctyn.common.security.annotation.EnableCustomConfig;
|
|||
import com.tcctyn.common.security.annotation.EnableRyFeignClients;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
|
||||
@EnableCustomConfig
|
||||
@EnableRyFeignClients
|
||||
@SpringBootApplication
|
||||
@ComponentScan(basePackages = {"com.tcctyn.iot.**", "com.tcctyn.common.**"})
|
||||
public class TcctynIotApplication {
|
||||
|
||||
public static void main(String[] args)
|
||||
|
|
|
|||
|
|
@ -23,29 +23,3 @@ spring:
|
|||
import:
|
||||
# - optional:nacos:application-@profiles.active@.yml
|
||||
- optional:nacos:${spring.application.name}-@profiles.active@.yml
|
||||
|
||||
|
||||
|
||||
# 海康运营管理中心接口配置
|
||||
artemis:
|
||||
path: /artemis
|
||||
host: 116.53.205.228:14443
|
||||
app-key: 21887937
|
||||
app-secret: hwOzOEqxuPDz5frAnEXb
|
||||
|
||||
# 测试使用,为了系统安全,通常生产环境不建议开启swagger。
|
||||
springdoc:
|
||||
swagger-ui:
|
||||
path: /swagger-ui.html
|
||||
disable-swagger-default-url: true
|
||||
# 关键修复配置 ↓
|
||||
url: /v3/api-docs # 改用YAML格式
|
||||
config-url: /v3/api-docs/swagger-config
|
||||
api-docs:
|
||||
path: /v3/api-docs
|
||||
enabled: true
|
||||
# 必须配置扫描 ↓
|
||||
paths-to-match: /**
|
||||
packages-to-scan: com.tcctyn.iot.hk.controller
|
||||
cache:
|
||||
disabled: true # 开发时禁用缓存
|
||||
|
|
@ -4,6 +4,7 @@ import com.tcctyn.common.security.annotation.EnableCustomConfig;
|
|||
import com.tcctyn.common.security.annotation.EnableRyFeignClients;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
|
||||
|
||||
/**
|
||||
* 系统模块
|
||||
|
|
|
|||
|
|
@ -1,5 +1,17 @@
|
|||
package com.tcctyn.system.controller;
|
||||
|
||||
import java.util.List;
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import com.tcctyn.common.core.constant.UserConstants;
|
||||
import com.tcctyn.common.core.utils.StringUtils;
|
||||
import com.tcctyn.common.core.web.controller.BaseController;
|
||||
|
|
@ -10,12 +22,6 @@ import com.tcctyn.common.security.annotation.RequiresPermissions;
|
|||
import com.tcctyn.common.security.utils.SecurityUtils;
|
||||
import com.tcctyn.system.api.domain.SysDept;
|
||||
import com.tcctyn.system.service.ISysDeptService;
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 部门信息
|
||||
|
|
@ -124,24 +130,4 @@ public class SysDeptController extends BaseController
|
|||
deptService.checkDeptDataScope(deptId);
|
||||
return toAjax(deptService.deleteDeptById(deptId));
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 根据条件查询用户列表
|
||||
*/
|
||||
@PostMapping("/selectDeptList")
|
||||
public List<SysDept> selectUserList(SysDept sysDept) {
|
||||
return deptService.selectDeptList(sysDept);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 根据条件查询用户列表
|
||||
*/
|
||||
@PostMapping("/selectDeptById/{deptId}")
|
||||
public SysDept selectDeptById(@PathVariable("deptId") Long deptId) {
|
||||
return deptService.selectDeptById(deptId);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
package com.tcctyn.system.controller;
|
||||
|
||||
import com.tcctyn.common.core.web.domain.R;
|
||||
import com.tcctyn.common.core.domain.R;
|
||||
import com.tcctyn.common.core.utils.file.FileUtils;
|
||||
import com.tcctyn.system.api.domain.SysFile;
|
||||
import com.tcctyn.system.service.ISysFileService;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,17 @@
|
|||
package com.tcctyn.system.controller;
|
||||
|
||||
import com.tcctyn.common.core.web.domain.R;
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import com.tcctyn.common.core.domain.R;
|
||||
import com.tcctyn.common.core.utils.StringUtils;
|
||||
import com.tcctyn.common.core.utils.file.FileTypeUtils;
|
||||
import com.tcctyn.common.core.utils.file.MimeTypeUtils;
|
||||
|
|
@ -15,13 +26,6 @@ import com.tcctyn.system.api.domain.SysFile;
|
|||
import com.tcctyn.system.api.domain.SysUser;
|
||||
import com.tcctyn.system.api.model.LoginUser;
|
||||
import com.tcctyn.system.service.ISysUserService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 个人信息 业务处理
|
||||
|
|
@ -33,7 +37,6 @@ import java.util.Map;
|
|||
public class SysProfileController extends BaseController
|
||||
{
|
||||
@Autowired
|
||||
@Lazy
|
||||
private ISysUserService userService;
|
||||
|
||||
@Autowired
|
||||
|
|
|
|||
|
|
@ -1,5 +1,17 @@
|
|||
package com.tcctyn.system.controller;
|
||||
|
||||
import java.util.List;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import com.tcctyn.common.core.utils.poi.ExcelUtil;
|
||||
import com.tcctyn.common.core.web.controller.BaseController;
|
||||
import com.tcctyn.common.core.web.domain.AjaxResult;
|
||||
|
|
@ -15,12 +27,6 @@ import com.tcctyn.system.domain.SysUserRole;
|
|||
import com.tcctyn.system.service.ISysDeptService;
|
||||
import com.tcctyn.system.service.ISysRoleService;
|
||||
import com.tcctyn.system.service.ISysUserService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 角色信息
|
||||
|
|
|
|||
|
|
@ -1,6 +1,23 @@
|
|||
package com.tcctyn.system.controller;
|
||||
|
||||
import com.tcctyn.common.core.web.domain.R;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import com.tcctyn.common.core.domain.R;
|
||||
import com.tcctyn.common.core.utils.StringUtils;
|
||||
import com.tcctyn.common.core.utils.poi.ExcelUtil;
|
||||
import com.tcctyn.common.core.web.controller.BaseController;
|
||||
|
|
@ -16,18 +33,12 @@ import com.tcctyn.system.api.domain.SysDept;
|
|||
import com.tcctyn.system.api.domain.SysRole;
|
||||
import com.tcctyn.system.api.domain.SysUser;
|
||||
import com.tcctyn.system.api.model.LoginUser;
|
||||
import com.tcctyn.system.service.*;
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
import com.tcctyn.system.service.ISysConfigService;
|
||||
import com.tcctyn.system.service.ISysDeptService;
|
||||
import com.tcctyn.system.service.ISysPermissionService;
|
||||
import com.tcctyn.system.service.ISysPostService;
|
||||
import com.tcctyn.system.service.ISysRoleService;
|
||||
import com.tcctyn.system.service.ISysUserService;
|
||||
|
||||
/**
|
||||
* 用户信息
|
||||
|
|
@ -337,32 +348,4 @@ public class SysUserController extends BaseController
|
|||
{
|
||||
return success(deptService.selectDeptTreeList(dept));
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据条件查询用户列表
|
||||
*/
|
||||
@PostMapping("/selectUserList")
|
||||
public List<SysUser> selectUserList(SysUser user) {
|
||||
return userService.selectUserList(user);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 根据条件查询用户列表
|
||||
*/
|
||||
@PostMapping("/selectUserById/{userId}")
|
||||
public SysUser selectUserById(@PathVariable("userId") Long userId) {
|
||||
return userService.selectUserById(userId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户列表用于前端选择器
|
||||
* @param regionId 归属地区id
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/userNames/{regionId}")
|
||||
public List<SysUser> getOrdinaryUser(@PathVariable("regionId") Long regionId) {
|
||||
return userService.getOrdinaryUser(regionId);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,9 +1,8 @@
|
|||
package com.tcctyn.system.mapper;
|
||||
|
||||
import com.tcctyn.system.api.domain.SysUser;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import com.tcctyn.system.api.domain.SysUser;
|
||||
|
||||
/**
|
||||
* 用户表 数据层
|
||||
|
|
@ -125,10 +124,4 @@ public interface SysUserMapper
|
|||
* @return 结果
|
||||
*/
|
||||
public SysUser checkEmailUnique(String email);
|
||||
|
||||
/**
|
||||
* 获取用户信息用于前端选择
|
||||
* @return
|
||||
*/
|
||||
public List<SysUser> selectOrdinaryUser(Long regionId);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,7 @@
|
|||
package com.tcctyn.system.service;
|
||||
|
||||
import com.tcctyn.system.api.domain.SysUser;
|
||||
|
||||
import java.util.List;
|
||||
import com.tcctyn.system.api.domain.SysUser;
|
||||
|
||||
/**
|
||||
* 用户 业务层
|
||||
|
|
@ -204,6 +203,4 @@ public interface ISysUserService
|
|||
* @return 结果
|
||||
*/
|
||||
public String importUser(List<SysUser> userList, Boolean isUpdateSupport, String operName);
|
||||
|
||||
List<SysUser> getOrdinaryUser(Long regionId);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,15 @@
|
|||
package com.tcctyn.system.service.impl;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import javax.validation.Validator;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import com.tcctyn.common.core.constant.UserConstants;
|
||||
import com.tcctyn.common.core.exception.ServiceException;
|
||||
import com.tcctyn.common.core.utils.SpringUtils;
|
||||
|
|
@ -12,21 +22,14 @@ import com.tcctyn.system.api.domain.SysUser;
|
|||
import com.tcctyn.system.domain.SysPost;
|
||||
import com.tcctyn.system.domain.SysUserPost;
|
||||
import com.tcctyn.system.domain.SysUserRole;
|
||||
import com.tcctyn.system.mapper.*;
|
||||
import com.tcctyn.system.mapper.SysPostMapper;
|
||||
import com.tcctyn.system.mapper.SysRoleMapper;
|
||||
import com.tcctyn.system.mapper.SysUserMapper;
|
||||
import com.tcctyn.system.mapper.SysUserPostMapper;
|
||||
import com.tcctyn.system.mapper.SysUserRoleMapper;
|
||||
import com.tcctyn.system.service.ISysConfigService;
|
||||
import com.tcctyn.system.service.ISysDeptService;
|
||||
import com.tcctyn.system.service.ISysUserService;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import javax.validation.Validator;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 用户 业务层处理
|
||||
|
|
@ -34,7 +37,7 @@ import java.util.stream.Collectors;
|
|||
* @author tcctyn
|
||||
*/
|
||||
@Service
|
||||
public abstract class SysUserServiceImpl implements ISysUserService
|
||||
public class SysUserServiceImpl implements ISysUserService
|
||||
{
|
||||
private static final Logger log = LoggerFactory.getLogger(SysUserServiceImpl.class);
|
||||
|
||||
|
|
@ -544,13 +547,5 @@ public abstract class SysUserServiceImpl implements ISysUserService
|
|||
}
|
||||
return successMsg.toString();
|
||||
}
|
||||
/**
|
||||
* 获取用户信息用于前端选择器
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List<SysUser> getOrdinaryUser(Long regionId) {
|
||||
return userMapper.selectOrdinaryUser(regionId);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -216,15 +216,5 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
#{userId}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
<!-- 查询用户信息用于前端选择器 -->
|
||||
<select id="selectOrdinaryUser" parameterType="Long" resultMap="SysUserResult">
|
||||
select u.user_id, u.region_id, u.user_name, u.nick_name
|
||||
from sys_user u where u.del_flag = '0' and u.user_name != 'admin'
|
||||
<if test="region_id != null">
|
||||
AND u.region_id = #{region_id}
|
||||
</if>
|
||||
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
Loading…
Reference in New Issue