Compare commits
1 Commits
master
...
xiongzheng
| Author | SHA1 | Date |
|---|---|---|
|
|
d0a6ddde3f | 3 years ago |
0
src/arm-equipment-system-parent/arm-equipment-system-parent/admin/src/main/java/com/arm/equipment/system/admin/controller/weaponry/WeaponryLendRecordController.java → src/arm-equipment-system-parent/admin/src/main/java/com/arm/equipment/system/admin/controller/weaponry/WeaponryLendRecordController.java
0
src/arm-equipment-system-parent/arm-equipment-system-parent/admin/src/main/java/com/arm/equipment/system/admin/controller/weaponry/WeaponryLendRecordController.java → src/arm-equipment-system-parent/admin/src/main/java/com/arm/equipment/system/admin/controller/weaponry/WeaponryLendRecordController.java
0
src/arm-equipment-system-parent/arm-equipment-system-parent/admin/src/main/java/com/arm/equipment/system/admin/controller/weaponry/WeaponryReturnRecordController.java → src/arm-equipment-system-parent/admin/src/main/java/com/arm/equipment/system/admin/controller/weaponry/WeaponryReturnRecordController.java
0
src/arm-equipment-system-parent/arm-equipment-system-parent/admin/src/main/java/com/arm/equipment/system/admin/controller/weaponry/WeaponryReturnRecordController.java → src/arm-equipment-system-parent/admin/src/main/java/com/arm/equipment/system/admin/controller/weaponry/WeaponryReturnRecordController.java
@ -1,39 +0,0 @@
|
||||
package com.arm.equipment.system.admin.app;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.web.servlet.ServletListenerRegistrationBean;
|
||||
import org.springframework.cache.annotation.EnableCaching;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.scheduling.annotation.EnableAsync;
|
||||
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||
import org.springframework.session.data.redis.config.annotation.web.http.EnableRedisHttpSession;
|
||||
import org.springframework.transaction.annotation.EnableTransactionManagement;
|
||||
import org.springframework.web.util.IntrospectorCleanupListener;
|
||||
|
||||
/**
|
||||
* 工程启动配置
|
||||
*
|
||||
* @author admin
|
||||
*/
|
||||
@SpringBootApplication
|
||||
@ComponentScan("com.arm.equipment.system")
|
||||
@EnableTransactionManagement
|
||||
@EnableRedisHttpSession(maxInactiveIntervalInSeconds = 86400)
|
||||
@EnableAsync
|
||||
@EnableCaching
|
||||
@EnableScheduling
|
||||
public class AdminApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(AdminApplication.class, args);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public ServletListenerRegistrationBean introspectorCleanupListener() {
|
||||
ServletListenerRegistrationBean listenerRegistration = new ServletListenerRegistrationBean();
|
||||
listenerRegistration.setListener(new IntrospectorCleanupListener());
|
||||
return listenerRegistration;
|
||||
}
|
||||
}
|
||||
@ -1,38 +0,0 @@
|
||||
package com.arm.equipment.system.admin.app;
|
||||
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.cors.CorsConfiguration;
|
||||
import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
|
||||
import org.springframework.web.filter.CorsFilter;
|
||||
|
||||
/**
|
||||
* CORS配置
|
||||
*/
|
||||
@Configuration
|
||||
public class AdminCorsConfiguration {
|
||||
|
||||
@Bean
|
||||
public CorsFilter corsFilter() {
|
||||
// 添加CORS配置信息
|
||||
CorsConfiguration config = new CorsConfiguration();
|
||||
// 放行哪些原始域
|
||||
config.addAllowedOriginPattern("*");
|
||||
// 是否发送Cookie信息
|
||||
config.setAllowCredentials(true);
|
||||
// 放行哪些原始域(请求方式)
|
||||
config.addAllowedMethod("*");
|
||||
// 放行哪些原始域(头部信息)
|
||||
config.addAllowedHeader("*");
|
||||
// 暴露哪些头部信息(因为跨域访问默认不能获取全部头部信息)
|
||||
// config.addExposedHeader("*");
|
||||
|
||||
//2.添加映射路径
|
||||
UrlBasedCorsConfigurationSource configSource = new UrlBasedCorsConfigurationSource();
|
||||
configSource.registerCorsConfiguration("/**", config);
|
||||
|
||||
//3.返回新的CorsFilter.
|
||||
return new CorsFilter(configSource);
|
||||
}
|
||||
}
|
||||
@ -1,17 +0,0 @@
|
||||
package com.arm.equipment.system.admin.app;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.data.redis.connection.RedisConnectionFactory;
|
||||
import org.springframework.data.redis.listener.RedisMessageListenerContainer;
|
||||
|
||||
@Configuration
|
||||
public class RedisListenerConfiguration {
|
||||
|
||||
@Bean
|
||||
RedisMessageListenerContainer redisMessageListenerContainer(RedisConnectionFactory lettuceConnectionFactory) {
|
||||
RedisMessageListenerContainer container = new RedisMessageListenerContainer();
|
||||
container.setConnectionFactory(lettuceConnectionFactory);
|
||||
return container;
|
||||
}
|
||||
}
|
||||
@ -1,29 +0,0 @@
|
||||
package com.arm.equipment.system.admin.app;
|
||||
|
||||
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.scheduling.annotation.SchedulingConfigurer;
|
||||
import org.springframework.scheduling.config.ScheduledTaskRegistrar;
|
||||
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
|
||||
/**
|
||||
* 定时任务配置
|
||||
* @author admin
|
||||
*/
|
||||
@Configuration
|
||||
public class SchedulerConfiguration implements SchedulingConfigurer {
|
||||
@Override
|
||||
public void configureTasks(ScheduledTaskRegistrar taskRegistrar) {
|
||||
taskRegistrar.setScheduler(taskExecutor());
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建线程池
|
||||
* @return
|
||||
*/
|
||||
public ScheduledExecutorService taskExecutor() {
|
||||
return Executors.newScheduledThreadPool(Runtime.getRuntime().availableProcessors() + 1);
|
||||
}
|
||||
}
|
||||
@ -1,33 +0,0 @@
|
||||
package com.arm.equipment.system.admin.controller.common;
|
||||
|
||||
import com.arm.equipment.system.data.service.common.IDictService;
|
||||
import com.arm.equipment.system.data.vo.RespJSON;
|
||||
import com.arm.equipment.system.data.vo.dict.DictVO;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 字典接口
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/common/dict")
|
||||
public class DictController {
|
||||
@Autowired
|
||||
private IDictService dictService;
|
||||
|
||||
/**
|
||||
* 统计枚举名称获得枚举的数据
|
||||
*
|
||||
* @param name 枚举名称, 枚举文件必须在com.arm.equipment.system.data.enums.dict包下
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/getDictDataByName/{name}")
|
||||
public RespJSON getDictDataByName(@PathVariable String name) {
|
||||
List<DictVO> dictData = dictService.getDictData(name);
|
||||
return RespJSON.success(dictData);
|
||||
}
|
||||
}
|
||||
@ -1,53 +0,0 @@
|
||||
package com.arm.equipment.system.admin.controller.file;
|
||||
|
||||
import com.arm.equipment.system.admin.controller.BaseController;
|
||||
import com.arm.equipment.system.data.enums.file.EnumUpload;
|
||||
import com.arm.equipment.system.data.exception.BusinessException;
|
||||
import com.arm.equipment.system.data.service.file.IFileService;
|
||||
import com.arm.equipment.system.data.util.StringUtils;
|
||||
import com.arm.equipment.system.data.vo.RespJSON;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
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;
|
||||
|
||||
/**
|
||||
* 公共文件上传接口
|
||||
*
|
||||
* @author: xly
|
||||
* @time: 2023/3/10 10:56
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/file/upload")
|
||||
public class UploadController extends BaseController {
|
||||
@Autowired
|
||||
private IFileService fileService;
|
||||
|
||||
/**
|
||||
* 文件上传接口
|
||||
*
|
||||
* @param file
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/upload")
|
||||
public RespJSON upload(String uploadItem, @RequestParam("file") MultipartFile file) {
|
||||
if (null == file) {
|
||||
throw new BusinessException("文件不合法");
|
||||
}
|
||||
EnumUpload enumUploadItem = EnumUpload.RES_PHOTO_LIB;
|
||||
if (StringUtils.isNotBlank(uploadItem)) {
|
||||
enumUploadItem = EnumUpload.getEnum(uploadItem);
|
||||
}
|
||||
if (enumUploadItem == null) {
|
||||
throw new BusinessException("上传文件类目不正确");
|
||||
}
|
||||
try {
|
||||
return RespJSON.success(fileService.upload(file, enumUploadItem));
|
||||
} catch (Exception e) {
|
||||
logger.error("文件上传错误", e);
|
||||
throw new BusinessException("文件上传错误");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,91 +0,0 @@
|
||||
package com.arm.equipment.system.admin.filter;
|
||||
|
||||
import javax.servlet.ReadListener;
|
||||
import javax.servlet.ServletInputStream;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletRequestWrapper;
|
||||
import java.io.*;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
/**
|
||||
* request封装
|
||||
*/
|
||||
public class BodyReaderHttpServletRequestWrapper extends HttpServletRequestWrapper {
|
||||
|
||||
private final byte[] body;
|
||||
private String bodyStr;
|
||||
|
||||
public BodyReaderHttpServletRequestWrapper(HttpServletRequest request) throws IOException {
|
||||
super(request);
|
||||
String bodyString = getBodyString(request);
|
||||
body = bodyString.getBytes(StandardCharsets.UTF_8);
|
||||
bodyStr = bodyString;
|
||||
}
|
||||
|
||||
public String getBodyStr() {
|
||||
return bodyStr;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ServletInputStream getInputStream() throws IOException {
|
||||
final ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(body);
|
||||
|
||||
return new ServletInputStream() {
|
||||
@Override
|
||||
public int read() throws IOException {
|
||||
return byteArrayInputStream.read();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFinished() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isReady() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setReadListener(ReadListener readListener) {
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
public String getBodyString(HttpServletRequest request) throws IOException {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
InputStream inputStream = null;
|
||||
BufferedReader reader = null;
|
||||
try {
|
||||
inputStream = request.getInputStream();
|
||||
reader = new BufferedReader(
|
||||
new InputStreamReader(inputStream, Charset.forName("UTF-8")));
|
||||
|
||||
char[] bodyCharBuffer = new char[1024];
|
||||
int len = 0;
|
||||
while ((len = reader.read(bodyCharBuffer)) != -1) {
|
||||
sb.append(new String(bodyCharBuffer, 0, len));
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
if (inputStream != null) {
|
||||
try {
|
||||
inputStream.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
if (reader != null) {
|
||||
try {
|
||||
reader.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
@ -1,81 +0,0 @@
|
||||
package com.arm.equipment.system.admin.filter;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.google.common.base.Throwables;
|
||||
import com.arm.equipment.system.admin.util.CurrentUserUtils;
|
||||
import com.arm.equipment.system.data.domain.system.SysUser;
|
||||
import com.arm.equipment.system.data.vo.RespJSON;
|
||||
import com.arm.equipment.system.data.vo.ReturnCode;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.core.annotation.Order;
|
||||
import org.springframework.web.servlet.HandlerInterceptor;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author: admin
|
||||
* @time: 2022/9/16 11:20
|
||||
*/
|
||||
@Order(1001)
|
||||
@Configuration
|
||||
public class LoginPermissionsFilter implements HandlerInterceptor {
|
||||
private final static Logger logger = LoggerFactory.getLogger(LoginPermissionsFilter.class);
|
||||
@Value("${domain.admin}")
|
||||
private String adminDomain;
|
||||
|
||||
private static final List<String> IGNORE_URL_LIST = Arrays.asList("/login", "/file/upload", "/common/dict", "/verifycode/getVerifyCode");
|
||||
|
||||
private final String RETURN_INFO = JSON.toJSONString(RespJSON.returnCode(ReturnCode.NOT_LOGIN_ERROR));
|
||||
|
||||
@Override
|
||||
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
|
||||
// 将 options 请求放过
|
||||
String method = request.getMethod();
|
||||
if ("options".equalsIgnoreCase(method)) {
|
||||
return true;
|
||||
}
|
||||
String uri = request.getRequestURI();
|
||||
for (String ignoreUrl : IGNORE_URL_LIST) {
|
||||
if (StringUtils.contains(uri, ignoreUrl)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
SysUser sysUser = (SysUser) request.getSession().getAttribute(CurrentUserUtils.SYSTEM_USER);
|
||||
if (null != sysUser) {
|
||||
return true;
|
||||
}
|
||||
returnNoLogin(response, request);
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
private void returnNoLogin(HttpServletResponse response, HttpServletRequest request) {
|
||||
String origin = adminDomain;
|
||||
String originHeader = request.getHeader("Origin");
|
||||
if (StringUtils.isNotEmpty(originHeader)) {
|
||||
origin = originHeader;
|
||||
}
|
||||
response.setCharacterEncoding("UTF-8");
|
||||
response.setHeader("Content-Type", "application/json; charset=utf-8");
|
||||
response.setHeader("Access-Control-Allow-Credentials", "true");
|
||||
response.setHeader("Access-Control-Allow-Origin", origin);
|
||||
PrintWriter writer = null;
|
||||
try {
|
||||
writer = response.getWriter();
|
||||
writer.write(RETURN_INFO);
|
||||
} catch (IOException e) {
|
||||
logger.error(Throwables.getStackTraceAsString(e));
|
||||
} finally {
|
||||
writer.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,37 +0,0 @@
|
||||
package com.arm.equipment.system.admin.filter;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.servlet.*;
|
||||
import javax.servlet.annotation.WebFilter;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* 记录用户请求参数
|
||||
*/
|
||||
@Component
|
||||
@WebFilter(filterName = "httpServletRequestWrapperFilter", urlPatterns = {"/"})
|
||||
public class RequestBodyFilter implements Filter {
|
||||
|
||||
@Override
|
||||
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
|
||||
ServletRequest requestWrapper = null;
|
||||
if (request instanceof HttpServletRequest) {
|
||||
HttpServletRequest httpRequest = (HttpServletRequest) request;
|
||||
//遇到post方法才对request进行包装
|
||||
String methodType = httpRequest.getMethod();
|
||||
String contentType = ((HttpServletRequest) request).getHeader("Content-Type");
|
||||
if (StringUtils.isNotEmpty(contentType) && contentType.contains("application/json") && "POST".equals(methodType)) {
|
||||
requestWrapper = new BodyReaderHttpServletRequestWrapper((HttpServletRequest) request);
|
||||
}
|
||||
}
|
||||
if (null == requestWrapper) {
|
||||
chain.doFilter(request, response);
|
||||
} else {
|
||||
chain.doFilter(requestWrapper, response);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,101 +0,0 @@
|
||||
package com.arm.equipment.system.admin.filter;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.arm.equipment.system.admin.util.CurrentUserUtils;
|
||||
import com.arm.equipment.system.data.domain.system.SysLog;
|
||||
import com.arm.equipment.system.data.domain.system.SysUser;
|
||||
import com.arm.equipment.system.data.enums.dict.EnumSysLogType;
|
||||
import com.arm.equipment.system.data.service.system.ISysLogService;
|
||||
import com.arm.equipment.system.data.util.IPUtil;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.core.annotation.Order;
|
||||
import org.springframework.web.servlet.HandlerInterceptor;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.Enumeration;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.LinkedBlockingQueue;
|
||||
import java.util.concurrent.ThreadPoolExecutor;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* 系统日志filter, 记录所有请求
|
||||
*/
|
||||
@Order(1002)
|
||||
@Configuration
|
||||
public class SysLogFilter implements HandlerInterceptor {
|
||||
private final static Logger logger = LoggerFactory.getLogger(SysLogFilter.class);
|
||||
@Autowired
|
||||
private ISysLogService sysLogService;
|
||||
/**
|
||||
* 50个线程, 无界队列, 超过异常
|
||||
*/
|
||||
private final static ThreadPoolExecutor THREAD_POOL_EXECUTOR = new ThreadPoolExecutor(50, 50, 120, TimeUnit.SECONDS, new LinkedBlockingQueue<>(), new ThreadPoolExecutor.AbortPolicy());
|
||||
/**
|
||||
* 登录路径
|
||||
*/
|
||||
private final static String LOGIN_PATH = "/system/sysUser/login";
|
||||
|
||||
@Override
|
||||
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
|
||||
THREAD_POOL_EXECUTOR.submit(() -> {
|
||||
String userAgent = request.getHeader("User-Agent");
|
||||
SysLog sysLog = new SysLog();
|
||||
sysLog.setType(EnumSysLogType.LOG.getCode());
|
||||
// todo 尽量设置访问链接的菜单
|
||||
sysLog.setTitle(" ");
|
||||
sysLog.setRemoteAddr(IPUtil.getRemoteAddress(request));
|
||||
|
||||
sysLog.setUserAgent(userAgent);
|
||||
sysLog.setRequestUri(buildUri(request));
|
||||
sysLog.setMethod(request.getMethod());
|
||||
String requestBody = getRequestBody(((BodyReaderHttpServletRequestWrapper) request).getBodyStr());
|
||||
sysLog.setParams(requestBody);
|
||||
//登录接口日志特殊处理 不显示密码
|
||||
if (sysLog.getRequestUri().contains(LOGIN_PATH)) {
|
||||
JSONObject loginInfoJson = JSONObject.parseObject(requestBody);
|
||||
loginInfoJson.put("password", "");
|
||||
sysLog.setParams(loginInfoJson.toJSONString());
|
||||
}
|
||||
SysUser sysUser = (SysUser) request.getSession().getAttribute(CurrentUserUtils.SYSTEM_USER);
|
||||
if (null != sysUser) {
|
||||
sysLogService.save(sysLog, sysUser.getUsername());
|
||||
} else {
|
||||
sysLogService.save(sysLog, "SYSTEM");
|
||||
}
|
||||
});
|
||||
return true;
|
||||
}
|
||||
|
||||
private Map<String, String> getAllHeader(HttpServletRequest request) {
|
||||
Enumeration<String> headerNames = request.getHeaderNames();
|
||||
Map<String, String> map = new HashMap<>();
|
||||
while (headerNames.hasMoreElements()) {
|
||||
String key = headerNames.nextElement();
|
||||
map.put(key, request.getHeader(key));
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
private String getRequestBody(String requestBody) {
|
||||
if (StringUtils.isEmpty(requestBody)) {
|
||||
return null;
|
||||
}
|
||||
return requestBody;
|
||||
}
|
||||
|
||||
private String buildUri(HttpServletRequest request) {
|
||||
String path = request.getRequestURL().toString();
|
||||
String query = request.getQueryString();
|
||||
if (StringUtils.isEmpty(query)) {
|
||||
return path;
|
||||
}
|
||||
return path + "?" + query;
|
||||
}
|
||||
}
|
||||
@ -1,13 +0,0 @@
|
||||
package com.arm.equipment.system.admin.util;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author: admin
|
||||
* @time: 2022/9/16 11:20
|
||||
*/
|
||||
public class CurrentUserUtils {
|
||||
|
||||
public static final String SYSTEM_USER = "system_user";
|
||||
|
||||
}
|
||||
@ -1,34 +0,0 @@
|
||||
env: dev
|
||||
spring:
|
||||
datasource:
|
||||
url: jdbc:mysql://127.0.0.1:3306/arm-equipment-system?useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai&zeroDateTimeBehavior=convertToNull
|
||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
username: root
|
||||
password:
|
||||
type: com.zaxxer.hikari.HikariDataSource
|
||||
hikari:
|
||||
auto-commit: true
|
||||
connection-timeout: 30000
|
||||
idle-timeout: 600000
|
||||
max-lifetime: 1800000
|
||||
minimum-idle: 1
|
||||
maximum-pool-size: 10
|
||||
pool-name: hikaricp
|
||||
validation-timeout: 5000
|
||||
redis:
|
||||
host: 127.0.0.1
|
||||
port: 6379
|
||||
password:
|
||||
database: 0
|
||||
timeout: 5000ms
|
||||
lettuce:
|
||||
pool:
|
||||
max-idle: 100
|
||||
min-idle: 1
|
||||
max-active: 1000
|
||||
web:
|
||||
resources:
|
||||
static-locations: file:admin/src/main/resources/static
|
||||
# 域名配置
|
||||
domain:
|
||||
admin: http://localhost:9527
|
||||
@ -1,25 +0,0 @@
|
||||
git:
|
||||
version: "@git.commit.id.abbrev@"
|
||||
commitTime: "@git.commit.time@"
|
||||
server:
|
||||
port: 18081
|
||||
compression:
|
||||
enabled: true
|
||||
mime-types: application/javascript,text/css,application/json,application/xml,text/html,text/xml,text/plain
|
||||
spring:
|
||||
jackson:
|
||||
serialization:
|
||||
write-dates-as-timestamps: true
|
||||
output:
|
||||
ansi:
|
||||
enabled: always
|
||||
webflux:
|
||||
static-path-pattern: /**
|
||||
session:
|
||||
store-type: redis
|
||||
timeout: 86400
|
||||
profiles:
|
||||
active: dev
|
||||
servlet:
|
||||
multipart:
|
||||
max-file-size: 1024MB
|
||||
@ -1,44 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<configuration>
|
||||
<include resource="org/springframework/boot/logging/logback/base.xml"/>
|
||||
<substitutionProperty name="log.base" value="logs/app" />
|
||||
|
||||
<springProfile name="dev">
|
||||
<logger name="com.arm.equipment.system" level="debug" additivity="false">
|
||||
<appender-ref ref="CONSOLE" />
|
||||
</logger>
|
||||
<logger name="io.swagger.models.parameters.AbstractSerializableParameter" level="error" additivity="false">
|
||||
<appender-ref ref="CONSOLE" />
|
||||
</logger>
|
||||
<root level="info">
|
||||
<appender-ref ref="CONSOLE" />
|
||||
</root>
|
||||
</springProfile>
|
||||
|
||||
<springProfile name="prod,test">
|
||||
<appender name="logfile" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<File>${log.base}.log</File>
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||
<cleanHistoryOnStart>true</cleanHistoryOnStart>
|
||||
<maxHistory>30</maxHistory>
|
||||
<FileNamePattern>
|
||||
${log.base}.%d{yyyy-MM-dd}.log
|
||||
</FileNamePattern>
|
||||
</rollingPolicy>
|
||||
<layout class="ch.qos.logback.classic.PatternLayout">
|
||||
<pattern>
|
||||
%date [%thread] %-5level %logger{80} - %msg%n
|
||||
</pattern>
|
||||
</layout>
|
||||
</appender>
|
||||
<logger name="io.swagger.models.parameters.AbstractSerializableParameter" level="error" additivity="false">
|
||||
<appender-ref ref="CONSOLE" />
|
||||
<appender-ref ref="logfile" />
|
||||
</logger>
|
||||
<root level="info">
|
||||
<appender-ref ref="CONSOLE" />
|
||||
<appender-ref ref="logfile" />
|
||||
</root>
|
||||
</springProfile>
|
||||
</configuration>
|
||||
|
||||
@ -1,38 +0,0 @@
|
||||
package com.arm.equipment.system.admin;
|
||||
|
||||
import com.arm.equipment.system.admin.app.AdminApplication;
|
||||
import com.arm.equipment.system.data.service.common.IIdWorkerService;
|
||||
import com.arm.equipment.system.data.util.passwordEncoder.BCryptPasswordEncoderUtils;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.ActiveProfiles;
|
||||
import org.springframework.test.context.junit.jupiter.SpringExtension;
|
||||
|
||||
|
||||
@ExtendWith(SpringExtension.class)
|
||||
@SpringBootTest(classes = AdminApplication.class)
|
||||
@ActiveProfiles(profiles = "dev")
|
||||
public class AdminApplicationTests {
|
||||
|
||||
@Autowired
|
||||
private BCryptPasswordEncoderUtils bCryptPasswordEncoder;
|
||||
|
||||
@Test
|
||||
public void test() {
|
||||
System.out.println(bCryptPasswordEncoder.encode("123123"));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Autowired
|
||||
IIdWorkerService idWorkerService;
|
||||
|
||||
@Test
|
||||
public void aa(){
|
||||
for (int i = 0; i < 30; i++) {
|
||||
System.out.println(idWorkerService.getNextId());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,141 +0,0 @@
|
||||
package com.arm.equipment.system.admin;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.arm.equipment.system.admin.app.AdminApplication;
|
||||
import com.arm.equipment.system.data.domain.system.SysResource;
|
||||
import com.arm.equipment.system.data.service.system.ISysResourceService;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.ActiveProfiles;
|
||||
import org.springframework.test.context.junit.jupiter.SpringExtension;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@ExtendWith(SpringExtension.class)
|
||||
@SpringBootTest(classes = AdminApplication.class)
|
||||
@ActiveProfiles(profiles = "dev")
|
||||
public class SysResourceTests {
|
||||
@Autowired
|
||||
private ISysResourceService sysResourceService;
|
||||
|
||||
/**
|
||||
* 公共按钮map
|
||||
*/
|
||||
private final static Map<String, String> MAP = ImmutableMap.<String, String>builder()
|
||||
.put("list", "查询")
|
||||
.put("add", "添加")
|
||||
.put("edit", "编辑")
|
||||
.put("delete", "删除")
|
||||
.put("audit", "审核")
|
||||
.put("unAudit", "取消审核")
|
||||
.put("publish", "发布")
|
||||
.put("unPublish", "取消发布")
|
||||
.put("archives", "归档")
|
||||
.put("unArchives", "取消归档")
|
||||
.put("setPosition", "调整位置")
|
||||
.put("exportToExcel", "导出Excel")
|
||||
.put("recommend", "推荐")
|
||||
.put("unRecommend", "取消推荐")
|
||||
.put("used", "标记使用")
|
||||
.put("clueFee", "线索费")
|
||||
.put("show", "显示")
|
||||
.put("unShow", "取消显示")
|
||||
.put("send", "发放红包")
|
||||
.put("refuse", "拒绝")
|
||||
.put("top", "置顶")
|
||||
.put("unTop", "取消置顶")
|
||||
.put("handle", "处理")
|
||||
.put("onShelves", "上架")
|
||||
.put("offShell", "下架")
|
||||
.put("push", "推送")
|
||||
.put("recruit", "招聘管理")
|
||||
.put("download", "下载简历模板")
|
||||
.put("recruitmentDeliverInfoList", "查看职位投递信息")
|
||||
.put("updateStatus", "操作提醒状态")
|
||||
.put("option", "直播间设置")
|
||||
.put("startLuckyBag", "直播间开启福袋")
|
||||
.put("closeLuckyBag", "直播间关闭福袋")
|
||||
.put("modifyLuckyBag", "直播间修改福袋")
|
||||
.put("startRedPacket", "直播间开启红包")
|
||||
.put("modifyRedPacket", "直播间修改红包")
|
||||
.put("interaction", "直播间互动")
|
||||
.put("data", "直播间数据")
|
||||
.put("split", "直播间拆条")
|
||||
.put("startLive", "直播间开始直播")
|
||||
.put("stopLive", "直播间结束直播")
|
||||
.put("modifyLive", "直播间修改直播")
|
||||
.put("addLine", "直播间新增线路")
|
||||
.put("breakLine", "直播间断开线路")
|
||||
.put("restoreLine", "直播间恢复线路")
|
||||
.put("modifyLine", "直播间修改线路")
|
||||
.put("deleteLine", "直播间删除线路")
|
||||
.put("addVote", "直播间添加投票")
|
||||
.put("modifyVote", "直播间修改投票")
|
||||
.put("deleteVote", "直播间删除投票")
|
||||
.put("deleteComment", "直播间删除评论")
|
||||
.put("cancelTopComment", "直播间取消置顶评论")
|
||||
.put("topComment", "直播间置顶评论")
|
||||
.put("addDraw", "直播间创建抽奖")
|
||||
.put("addCoupon", "直播间创建优惠券")
|
||||
.put("startCoupon", "直播间开启优惠券")
|
||||
.put("closeCoupon", "直播间关闭优惠券")
|
||||
.put("modifyCoupon", "直播间修改优惠券")
|
||||
.put("updateBrowseMultiple", "浏览倍率")
|
||||
.put("sliderManage", "轮播管理")
|
||||
.put("navManage", "导航栏管理")
|
||||
.put("start", "导播台开启")
|
||||
.put("stop", "导播台关闭")
|
||||
.put("detail", "导播台详情")
|
||||
.put("canPublish", "可发布文章")
|
||||
.put("sign", "标记")
|
||||
.build();
|
||||
/**父级菜单查询条件 这里是根据路径找到对象 根据需求更换*/
|
||||
private final static String URL_WHERE = "/live/liveStudioGiftsList";
|
||||
/**按钮标识前缀 根据需求更换*/
|
||||
private final static String SUFFIX_IDENTITY = "live_studio_gifts"+"_";
|
||||
/**按钮名称前缀 根据需求更换*/
|
||||
private final static String SUFFIX_NAME = "直播间礼物";
|
||||
/**需要生成的按钮权限 已公共map中的为准 有其他公共权限可以自行添加到map 一般如果存在多个按钮 list按钮权限最好生成 根据需求更换*/
|
||||
private final static List<String> COMMON_ROLE = Arrays.asList("list", "add","edit","delete","audit","unAudit");
|
||||
// "startRedPacket", "modifyRedPacket", "interaction", "data", "split", "startLive", "stopLive", "modifyLive",
|
||||
// "addLine", "breakLine", "restoreLine", "modifyLine", "deleteLine", "addVote", "modifyVote", "deleteVote",
|
||||
// "deleteComment", "cancelTopComment", "topComment", "addDraw", "addCoupon", "startCoupon", "closeCoupon");
|
||||
/**
|
||||
* 公共添加
|
||||
*/
|
||||
@Test
|
||||
public void commonSave() {
|
||||
SysResource where = new SysResource();
|
||||
where.setUrl(URL_WHERE);
|
||||
List<SysResource> sysResourcesListDB = sysResourceService.getList(where);
|
||||
COMMON_ROLE.forEach(item -> {
|
||||
buildSave(sysResourcesListDB.get(0).getId().toString(), SUFFIX_IDENTITY + item, SUFFIX_NAME + MAP.get(item));
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 单个添加
|
||||
*/
|
||||
// @Test
|
||||
// public void save() {
|
||||
// SysResource where = new SysResource();
|
||||
// where.setUrl(URL_WHERE);
|
||||
// List<SysResource> sysResourcesListDB = sysResourceService.getList(where);
|
||||
// buildSave(sysResourcesListDB.get(0).getId(), SUFFIX_IDENTITY + "generalize", SUFFIX_NAME + "微兔眼爆料跟踪信息");
|
||||
// }
|
||||
|
||||
private void buildSave(String parentId, String identity, String name) {
|
||||
SysResource req = new SysResource();
|
||||
req.setIdentity(identity);
|
||||
req.setName(name);
|
||||
req.setParentId(parentId);
|
||||
req.setType(2);
|
||||
req.setSort(1);
|
||||
req.setIsShow(1);
|
||||
sysResourceService.save(req, "admin");
|
||||
}
|
||||
}
|
||||
@ -1,13 +0,0 @@
|
||||
package com.arm.equipment.system.api.annotation;
|
||||
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
|
||||
/**
|
||||
* 判断接口是否必须要登录才能使用
|
||||
* @author admin
|
||||
*/
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface LoginCheck {
|
||||
}
|
||||
@ -1,35 +0,0 @@
|
||||
package com.arm.equipment.system.api.app;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.web.servlet.ServletListenerRegistrationBean;
|
||||
import org.springframework.cache.annotation.EnableCaching;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.session.data.redis.config.annotation.web.http.EnableRedisHttpSession;
|
||||
import org.springframework.transaction.annotation.EnableTransactionManagement;
|
||||
import org.springframework.web.util.IntrospectorCleanupListener;
|
||||
|
||||
/**
|
||||
* 工程启动配置
|
||||
*
|
||||
* @author admin
|
||||
*/
|
||||
@SpringBootApplication
|
||||
@ComponentScan("com.arm.equipment.system")
|
||||
@EnableTransactionManagement
|
||||
@EnableRedisHttpSession
|
||||
@EnableCaching
|
||||
public class ApiApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(ApiApplication.class, args);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public ServletListenerRegistrationBean introspectorCleanupListener() {
|
||||
ServletListenerRegistrationBean listenerRegistration = new ServletListenerRegistrationBean();
|
||||
listenerRegistration.setListener(new IntrospectorCleanupListener());
|
||||
return listenerRegistration;
|
||||
}
|
||||
}
|
||||
@ -1,38 +0,0 @@
|
||||
package com.arm.equipment.system.api.app;
|
||||
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.cors.CorsConfiguration;
|
||||
import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
|
||||
import org.springframework.web.filter.CorsFilter;
|
||||
|
||||
/**
|
||||
* CORS配置
|
||||
*/
|
||||
@Configuration
|
||||
public class ApiCorsConfiguration {
|
||||
|
||||
@Bean
|
||||
public CorsFilter corsFilter() {
|
||||
// 添加CORS配置信息
|
||||
CorsConfiguration config = new CorsConfiguration();
|
||||
// 放行哪些原始域
|
||||
config.addAllowedOriginPattern("*");
|
||||
// 是否发送Cookie信息
|
||||
config.setAllowCredentials(true);
|
||||
// 放行哪些原始域(请求方式)
|
||||
config.addAllowedMethod("*");
|
||||
// 放行哪些原始域(头部信息)
|
||||
config.addAllowedHeader("*");
|
||||
// 暴露哪些头部信息(因为跨域访问默认不能获取全部头部信息)
|
||||
// config.addExposedHeader("*");
|
||||
|
||||
//2.添加映射路径
|
||||
UrlBasedCorsConfigurationSource configSource = new UrlBasedCorsConfigurationSource();
|
||||
configSource.registerCorsConfiguration("/**", config);
|
||||
|
||||
//3.返回新的CorsFilter.
|
||||
return new CorsFilter(configSource);
|
||||
}
|
||||
}
|
||||
@ -1,91 +0,0 @@
|
||||
package com.arm.equipment.system.api.filter;
|
||||
|
||||
import javax.servlet.ReadListener;
|
||||
import javax.servlet.ServletInputStream;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletRequestWrapper;
|
||||
import java.io.*;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
/**
|
||||
* request封装
|
||||
*/
|
||||
public class BodyReaderHttpServletRequestWrapper extends HttpServletRequestWrapper {
|
||||
|
||||
private final byte[] body;
|
||||
private String bodyStr;
|
||||
|
||||
public BodyReaderHttpServletRequestWrapper(HttpServletRequest request) throws IOException {
|
||||
super(request);
|
||||
String bodyString = getBodyString(request);
|
||||
body = bodyString.getBytes(StandardCharsets.UTF_8);
|
||||
bodyStr = bodyString;
|
||||
}
|
||||
|
||||
public String getBodyStr() {
|
||||
return bodyStr;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ServletInputStream getInputStream() throws IOException {
|
||||
final ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(body);
|
||||
|
||||
return new ServletInputStream() {
|
||||
@Override
|
||||
public int read() throws IOException {
|
||||
return byteArrayInputStream.read();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFinished() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isReady() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setReadListener(ReadListener readListener) {
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
public String getBodyString(HttpServletRequest request) throws IOException {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
InputStream inputStream = null;
|
||||
BufferedReader reader = null;
|
||||
try {
|
||||
inputStream = request.getInputStream();
|
||||
reader = new BufferedReader(
|
||||
new InputStreamReader(inputStream, Charset.forName("UTF-8")));
|
||||
|
||||
char[] bodyCharBuffer = new char[1024];
|
||||
int len = 0;
|
||||
while ((len = reader.read(bodyCharBuffer)) != -1) {
|
||||
sb.append(new String(bodyCharBuffer, 0, len));
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
if (inputStream != null) {
|
||||
try {
|
||||
inputStream.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
if (reader != null) {
|
||||
try {
|
||||
reader.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
@ -1,93 +0,0 @@
|
||||
package com.arm.equipment.system.api.filter;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.arm.equipment.system.api.annotation.LoginCheck;
|
||||
import com.arm.equipment.system.api.util.LoginUtil;
|
||||
import com.google.common.base.Throwables;
|
||||
import com.arm.equipment.system.data.domain.user.AppUser;
|
||||
import com.arm.equipment.system.data.util.StringUtils;
|
||||
import com.arm.equipment.system.data.vo.RespJSON;
|
||||
import com.arm.equipment.system.data.vo.ReturnCode;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.core.annotation.Order;
|
||||
import org.springframework.web.method.HandlerMethod;
|
||||
import org.springframework.web.servlet.HandlerInterceptor;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.http.HttpSession;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
|
||||
/**
|
||||
* 登录过滤器
|
||||
* 用于将登录信息放到session中
|
||||
**/
|
||||
@Order(1004)
|
||||
@Configuration
|
||||
public class LoginFilter implements HandlerInterceptor {
|
||||
private final static Logger logger = LoggerFactory.getLogger(LoginFilter.class);
|
||||
private final String NO_LOGIN_RETURN_INFO = JSON.toJSONString(RespJSON.returnCode(ReturnCode.NOT_LOGIN_ERROR));
|
||||
|
||||
@Override
|
||||
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
|
||||
// 将 options 请求放过
|
||||
String method = request.getMethod();
|
||||
if ("options".equalsIgnoreCase(method)) {
|
||||
return true;
|
||||
}
|
||||
HandlerMethod handlerMethod = (HandlerMethod) handler;
|
||||
LoginCheck loginCheckAnnotation = handlerMethod.getMethodAnnotation(LoginCheck.class);
|
||||
String userTokenHeader = request.getHeader("User-Token");
|
||||
AppUser loginUser;
|
||||
// 不需要登录的接口直接放过
|
||||
if (null == loginCheckAnnotation) {
|
||||
if (StringUtils.isEmpty(userTokenHeader)) {
|
||||
return true;
|
||||
}
|
||||
// 没有获取到用户信息 直接报错
|
||||
loginUser = LoginUtil.getLoginUser(userTokenHeader);
|
||||
|
||||
} else {
|
||||
// 请求头没有token 直接报错
|
||||
if (StringUtils.isEmpty(userTokenHeader)) {
|
||||
returnNoLogin(response);
|
||||
return false;
|
||||
}
|
||||
// 没有获取到用户信息 直接报错
|
||||
loginUser = LoginUtil.getLoginUser(userTokenHeader);
|
||||
if (null == loginUser) {
|
||||
returnNoLogin(response);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// 用户信息保存到session
|
||||
AppUser finalLoginUser = loginUser;
|
||||
HttpSession session = request.getSession();
|
||||
session.setAttribute(LoginUtil.LOGIN_USER_SESSION_KEY, finalLoginUser);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 未登录时的返回内容
|
||||
*
|
||||
* @param response
|
||||
* @return
|
||||
*/
|
||||
private void returnNoLogin(HttpServletResponse response) {
|
||||
response.setCharacterEncoding("UTF-8");
|
||||
response.setHeader("Content-Type", "application/json; charset=utf-8");
|
||||
PrintWriter writer = null;
|
||||
try {
|
||||
writer = response.getWriter();
|
||||
writer.write(NO_LOGIN_RETURN_INFO);
|
||||
} catch (IOException e) {
|
||||
logger.error(Throwables.getStackTraceAsString(e));
|
||||
} finally {
|
||||
writer.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,37 +0,0 @@
|
||||
package com.arm.equipment.system.api.filter;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.servlet.*;
|
||||
import javax.servlet.annotation.WebFilter;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* 记录用户请求参数
|
||||
*/
|
||||
@Component
|
||||
@WebFilter(filterName = "httpServletRequestWrapperFilter", urlPatterns = {"/"})
|
||||
public class RequestBodyFilter implements Filter {
|
||||
|
||||
@Override
|
||||
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
|
||||
ServletRequest requestWrapper = null;
|
||||
if (request instanceof HttpServletRequest) {
|
||||
HttpServletRequest httpRequest = (HttpServletRequest) request;
|
||||
//遇到post方法才对request进行包装
|
||||
String methodType = httpRequest.getMethod();
|
||||
String contentType = ((HttpServletRequest) request).getHeader("Content-Type");
|
||||
if (StringUtils.isNotEmpty(contentType) && contentType.contains("application/json") && "POST".equals(methodType)) {
|
||||
requestWrapper = new BodyReaderHttpServletRequestWrapper((HttpServletRequest) request);
|
||||
}
|
||||
}
|
||||
if (null == requestWrapper) {
|
||||
chain.doFilter(request, response);
|
||||
} else {
|
||||
chain.doFilter(requestWrapper, response);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,121 +0,0 @@
|
||||
package com.arm.equipment.system.api.util;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.arm.equipment.system.data.constant.RedisKeys;
|
||||
import com.arm.equipment.system.data.domain.user.AppUser;
|
||||
import com.arm.equipment.system.data.util.UuidUtils;
|
||||
import com.arm.equipment.system.data.util.WJAssert;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.data.redis.core.SetOperations;
|
||||
import org.springframework.data.redis.core.ValueOperations;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpSession;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.LinkedBlockingQueue;
|
||||
import java.util.concurrent.ThreadPoolExecutor;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* 登录用户的工具类
|
||||
*/
|
||||
@Component
|
||||
public class LoginUtil {
|
||||
private final static Logger logger = LoggerFactory.getLogger(LoginUtil.class);
|
||||
private static RedisTemplate redisTemplate;
|
||||
private static ValueOperations<String, String> valueOps;
|
||||
/**
|
||||
* 登录用户在session中的key
|
||||
*/
|
||||
public static final String LOGIN_USER_SESSION_KEY = "appUserSessionKey";
|
||||
/**
|
||||
* 50个线程, 无界队列, 超过异常
|
||||
*/
|
||||
private final static ThreadPoolExecutor THREAD_POOL_EXECUTOR = new ThreadPoolExecutor(50, 50, 120, TimeUnit.SECONDS, new LinkedBlockingQueue<>(), new ThreadPoolExecutor.AbortPolicy());
|
||||
|
||||
public static AppUser getLoginUser(String token) {
|
||||
WJAssert.isMaxLength(token, 500, "token非法");
|
||||
String key = RedisKeys.getAppUserSessionKey(token);
|
||||
String s = valueOps.get(key);
|
||||
if (StringUtils.isEmpty(s)) {
|
||||
return null;
|
||||
}
|
||||
return JSONObject.parseObject(s, AppUser.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户登录状态保存到redis
|
||||
* 不会重新设置token
|
||||
*
|
||||
* @param appUser
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
public static AppUser refreshCache(AppUser appUser, HttpServletRequest request) {
|
||||
String key = RedisKeys.getAppUserSessionKey(appUser.getToken());
|
||||
valueOps.set(key, JSON.toJSONString(appUser), 1, TimeUnit.DAYS);
|
||||
HttpSession session = request.getSession();
|
||||
if (null == session) {
|
||||
logger.info("session 是空的");
|
||||
return null;
|
||||
}
|
||||
session.setAttribute(LoginUtil.LOGIN_USER_SESSION_KEY, appUser);
|
||||
return appUser;
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户登录状态保存到redis
|
||||
* 会重新设置token
|
||||
*
|
||||
* @param appUser
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
public static AppUser saveInCache(AppUser appUser, HttpServletRequest request) {
|
||||
appUser.setToken(UuidUtils.uuid());
|
||||
refreshCache(appUser, request);
|
||||
// 保存token和用户的关系, 是个 set
|
||||
String appUsernameByTokenSetKey = RedisKeys.getAppUsernameByTokenSetKey(appUser.getUsername());
|
||||
SetOperations<String, String> setOps = redisTemplate.opsForSet();
|
||||
setOps.add(appUsernameByTokenSetKey, appUser.getToken());
|
||||
// 清除set中的过期token, 避免set过大
|
||||
clearUserTokenSet(appUsernameByTokenSetKey);
|
||||
return appUser;
|
||||
}
|
||||
|
||||
/**
|
||||
* 清除用户的登录token set避免过大
|
||||
*
|
||||
* @param appUsernameByTokenSetKey
|
||||
*/
|
||||
private static void clearUserTokenSet(String appUsernameByTokenSetKey) {
|
||||
THREAD_POOL_EXECUTOR.submit(() -> {
|
||||
SetOperations<String, String> setOps = redisTemplate.opsForSet();
|
||||
Set<String> tokenSet = setOps.members(appUsernameByTokenSetKey);
|
||||
if (CollectionUtils.isEmpty(tokenSet)) {
|
||||
return;
|
||||
}
|
||||
tokenSet.forEach(token -> {
|
||||
String appUserSessionKey = RedisKeys.getAppUserSessionKey(token);
|
||||
Long expire = redisTemplate.getExpire(appUserSessionKey);
|
||||
if (null == expire || expire < 0) {
|
||||
logger.info("删除过期key {}", token);
|
||||
setOps.remove(appUsernameByTokenSetKey, token);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@Autowired
|
||||
public void setRedisTemplate(RedisTemplate redisTemplate) {
|
||||
LoginUtil.redisTemplate = redisTemplate;
|
||||
LoginUtil.valueOps = redisTemplate.opsForValue();
|
||||
}
|
||||
}
|
||||
@ -1,24 +0,0 @@
|
||||
package com.arm.equipment.system.api.vo.user;
|
||||
|
||||
public class RefreshTokenVO {
|
||||
/** 手机号 */
|
||||
private String data;
|
||||
/** 平台 */
|
||||
private Integer platform;
|
||||
|
||||
public Integer getPlatform() {
|
||||
return platform;
|
||||
}
|
||||
|
||||
public void setPlatform(Integer platform) {
|
||||
this.platform = platform;
|
||||
}
|
||||
|
||||
public String getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
public void setData(String data) {
|
||||
this.data = data;
|
||||
}
|
||||
}
|
||||
@ -1,72 +0,0 @@
|
||||
package com.arm.equipment.system.api.vo.user;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
*
|
||||
* 编辑用户信息VO
|
||||
* @author: xly
|
||||
* @time: 2022/9/19 12:00
|
||||
*/
|
||||
public class UpdateUserVO {
|
||||
/** 生日 */
|
||||
private Date birthday;
|
||||
/** 昵称 */
|
||||
private String nickname;
|
||||
/** 性别 1 男 2 女 */
|
||||
private Integer genderCode;
|
||||
/** 所在地址 */
|
||||
private String address;
|
||||
/** 学历 */
|
||||
private String education;
|
||||
/**头像 */
|
||||
private String avatarPath;
|
||||
|
||||
public String getAvatarPath() {
|
||||
return avatarPath;
|
||||
}
|
||||
|
||||
public void setAvatarPath(String avatarPath) {
|
||||
this.avatarPath = avatarPath;
|
||||
}
|
||||
|
||||
public Date getBirthday() {
|
||||
return birthday;
|
||||
}
|
||||
|
||||
public void setBirthday(Date birthday) {
|
||||
this.birthday = birthday;
|
||||
}
|
||||
|
||||
public String getNickname() {
|
||||
return nickname;
|
||||
}
|
||||
|
||||
public void setNickname(String nickname) {
|
||||
this.nickname = nickname;
|
||||
}
|
||||
|
||||
public Integer getGenderCode() {
|
||||
return genderCode;
|
||||
}
|
||||
|
||||
public void setGenderCode(Integer genderCode) {
|
||||
this.genderCode = genderCode;
|
||||
}
|
||||
|
||||
public String getAddress() {
|
||||
return address;
|
||||
}
|
||||
|
||||
public void setAddress(String address) {
|
||||
this.address = address;
|
||||
}
|
||||
|
||||
public String getEducation() {
|
||||
return education;
|
||||
}
|
||||
|
||||
public void setEducation(String education) {
|
||||
this.education = education;
|
||||
}
|
||||
}
|
||||
@ -1,34 +0,0 @@
|
||||
package com.arm.equipment.system.api.vo.user;
|
||||
|
||||
/**
|
||||
* 用户中心VO
|
||||
* @author: xly
|
||||
* @time: 2021/11/19 17:41
|
||||
*/
|
||||
public class UserCenterVO {
|
||||
/**
|
||||
* 用户ID
|
||||
*/
|
||||
private String userId;
|
||||
/**
|
||||
* 由于微兔眼小程序只统计爆料评论的总数 所以这里由此类型
|
||||
* 请求类型 type (0 智能农机云 1 微兔眼小程序)
|
||||
*/
|
||||
private Integer type;
|
||||
|
||||
public String getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
public void setUserId(String userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
public Integer getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(Integer type) {
|
||||
this.type = type;
|
||||
}
|
||||
}
|
||||
@ -1,110 +0,0 @@
|
||||
package com.arm.equipment.system.api.vo.user;
|
||||
|
||||
/**
|
||||
* 用户登录信息VO
|
||||
*
|
||||
* @author ousei
|
||||
* @date 2020年11月4日15:17:48
|
||||
*/
|
||||
public class UserLoginVO {
|
||||
/** 手机号 */
|
||||
private String username;
|
||||
/** 验证码 */
|
||||
private String verifyCode;
|
||||
/** 设备TOKEN */
|
||||
private String deviceToken;
|
||||
/** unionid */
|
||||
private String unionid;
|
||||
/** 登录的类型 */
|
||||
private Integer loginType;
|
||||
/**用户密码*/
|
||||
private String password;
|
||||
/**平台*/
|
||||
private Integer platform;
|
||||
/**邀请码*/
|
||||
private String invcode;
|
||||
/**微信code**/
|
||||
private String code;
|
||||
/**一键登录手机号token*/
|
||||
private String usernameToken;
|
||||
|
||||
public String getUsernameToken() {
|
||||
return usernameToken;
|
||||
}
|
||||
|
||||
public void setUsernameToken(String usernameToken) {
|
||||
this.usernameToken = usernameToken;
|
||||
}
|
||||
|
||||
public String getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public void setCode(String code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public Integer getPlatform() {
|
||||
return platform;
|
||||
}
|
||||
|
||||
public void setPlatform(Integer platform) {
|
||||
this.platform = platform;
|
||||
}
|
||||
|
||||
public String getInvcode() {
|
||||
return invcode;
|
||||
}
|
||||
|
||||
public void setInvcode(String invcode) {
|
||||
this.invcode = invcode;
|
||||
}
|
||||
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
public void setPassword(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
public Integer getLoginType() {
|
||||
return loginType;
|
||||
}
|
||||
|
||||
public void setLoginType(Integer loginType) {
|
||||
this.loginType = loginType;
|
||||
}
|
||||
|
||||
public String getUnionid() {
|
||||
return unionid;
|
||||
}
|
||||
|
||||
public void setUnionid(String unionid) {
|
||||
this.unionid = unionid;
|
||||
}
|
||||
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
public String getVerifyCode() {
|
||||
return verifyCode;
|
||||
}
|
||||
|
||||
public void setVerifyCode(String verifyCode) {
|
||||
this.verifyCode = verifyCode;
|
||||
}
|
||||
|
||||
public String getDeviceToken() {
|
||||
return deviceToken;
|
||||
}
|
||||
|
||||
public void setDeviceToken(String deviceToken) {
|
||||
this.deviceToken = deviceToken;
|
||||
}
|
||||
}
|
||||
@ -1,31 +0,0 @@
|
||||
env: dev
|
||||
spring:
|
||||
datasource:
|
||||
url: jdbc:mysql://127.0.0.1:3306/arm-equipment-system?useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai&zeroDateTimeBehavior=convertToNull
|
||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
username: root
|
||||
password:
|
||||
type: com.zaxxer.hikari.HikariDataSource
|
||||
hikari:
|
||||
auto-commit: true
|
||||
connection-timeout: 30000
|
||||
idle-timeout: 600000
|
||||
max-lifetime: 1800000
|
||||
minimum-idle: 1
|
||||
maximum-pool-size: 10
|
||||
pool-name: hikaricp
|
||||
validation-timeout: 5000
|
||||
redis:
|
||||
host: 127.0.0.1
|
||||
port: 6379
|
||||
password:
|
||||
database: 0
|
||||
timeout: 5000ms
|
||||
lettuce:
|
||||
pool:
|
||||
max-idle: 100
|
||||
min-idle: 1
|
||||
max-active: 1000
|
||||
web:
|
||||
resources:
|
||||
static-locations: file:admin/src/main/resources/static
|
||||
@ -1,21 +0,0 @@
|
||||
git:
|
||||
version: "@git.commit.id.abbrev@"
|
||||
commitTime: "@git.commit.time@"
|
||||
server:
|
||||
port: 8088
|
||||
compression:
|
||||
enabled: true
|
||||
mime-types: application/javascript,text/css,application/json,application/xml,text/html,text/xml,text/plain
|
||||
spring:
|
||||
jackson:
|
||||
serialization:
|
||||
write-dates-as-timestamps: true
|
||||
output:
|
||||
ansi:
|
||||
enabled: always
|
||||
webflux:
|
||||
static-path-pattern: /**
|
||||
session:
|
||||
store-type: redis
|
||||
profiles:
|
||||
active: dev
|
||||
@ -1,41 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<configuration>
|
||||
<include resource="org/springframework/boot/logging/logback/base.xml"/>
|
||||
<substitutionProperty name="log.base" value="logs/app" />
|
||||
|
||||
<springProfile name="dev">
|
||||
<logger name="com.arm.equipment.system" level="debug" additivity="false">
|
||||
<appender-ref ref="CONSOLE" />
|
||||
</logger>
|
||||
<root level="info">
|
||||
<appender-ref ref="CONSOLE" />
|
||||
</root>
|
||||
</springProfile>
|
||||
|
||||
<springProfile name="prod,test">
|
||||
<appender name="logfile" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<File>${log.base}.log</File>
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||
<cleanHistoryOnStart>true</cleanHistoryOnStart>
|
||||
<maxHistory>30</maxHistory>
|
||||
<FileNamePattern>
|
||||
${log.base}.%d{yyyy-MM-dd}.log
|
||||
</FileNamePattern>
|
||||
</rollingPolicy>
|
||||
<layout class="ch.qos.logback.classic.PatternLayout">
|
||||
<pattern>
|
||||
%date [%thread] %-5level %logger{80} - %msg%n
|
||||
</pattern>
|
||||
</layout>
|
||||
</appender>
|
||||
<logger name="io.swagger.models.parameters.AbstractSerializableParameter" level="error" additivity="false">
|
||||
<appender-ref ref="CONSOLE" />
|
||||
<appender-ref ref="logfile" />
|
||||
</logger>
|
||||
<root level="info">
|
||||
<appender-ref ref="CONSOLE" />
|
||||
<appender-ref ref="logfile" />
|
||||
</root>
|
||||
</springProfile>
|
||||
</configuration>
|
||||
|
||||
@ -1,22 +0,0 @@
|
||||
package com.arm.equipment.system.api;
|
||||
|
||||
import com.arm.equipment.system.api.app.ApiApplication;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.ActiveProfiles;
|
||||
import org.springframework.test.context.junit.jupiter.SpringExtension;
|
||||
|
||||
@ExtendWith(SpringExtension.class)
|
||||
@SpringBootTest(classes = ApiApplication.class)
|
||||
@ActiveProfiles(profiles = "dev")
|
||||
public class ApiApplicationTests {
|
||||
private final static Logger LOGGER = LoggerFactory.getLogger(ApiApplicationTests.class);
|
||||
|
||||
@Test
|
||||
public void test() {
|
||||
|
||||
}
|
||||
}
|
||||
@ -1,25 +0,0 @@
|
||||
package com.arm.equipment.system.data.app;
|
||||
|
||||
import com.arm.equipment.system.data.util.passwordEncoder.BCryptPasswordEncoderUtils;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author: admin
|
||||
* @time: 2022/9/16 11:20
|
||||
*/
|
||||
@Configuration
|
||||
public class BCryptConfiguration {
|
||||
|
||||
/**
|
||||
* BCrypt密码校验
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Bean
|
||||
public BCryptPasswordEncoderUtils bCryptPasswordEncoder() {
|
||||
return new BCryptPasswordEncoderUtils(5, null);
|
||||
}
|
||||
}
|
||||
@ -1,17 +0,0 @@
|
||||
package com.arm.equipment.system.data.app;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.transaction.annotation.EnableTransactionManagement;
|
||||
|
||||
@SpringBootApplication
|
||||
@EnableTransactionManagement
|
||||
@ComponentScan("com.arm.equipment.system")
|
||||
public class DataApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(DataApplication.class, args);
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,52 +0,0 @@
|
||||
package com.arm.equipment.system.data.app;
|
||||
|
||||
import com.arm.equipment.system.data.exception.BusinessException;
|
||||
import com.zaxxer.hikari.HikariDataSource;
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
import org.apache.ibatis.mapping.VendorDatabaseIdProvider;
|
||||
import org.apache.ibatis.session.SqlSessionFactory;
|
||||
import org.mybatis.spring.SqlSessionFactoryBean;
|
||||
import org.mybatis.spring.annotation.MapperScan;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
|
||||
import org.springframework.core.io.support.ResourcePatternResolver;
|
||||
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
|
||||
|
||||
/**
|
||||
* mybatis配置
|
||||
* @author admin
|
||||
*/
|
||||
@MapperScan("com.arm.equipment.system.data.mapper")
|
||||
@Configuration
|
||||
public class MyBatisConfiguration {
|
||||
|
||||
@Bean(name = "sessionFactory")
|
||||
public SqlSessionFactory sessionFactory(HikariDataSource dataSource) {
|
||||
SqlSessionFactoryBean bean = new SqlSessionFactoryBean();
|
||||
bean.setDataSource(dataSource);
|
||||
bean.setDatabaseIdProvider(new VendorDatabaseIdProvider());
|
||||
bean.setTypeHandlersPackage("com.arm.equipment.system.data.mybatis.type");
|
||||
|
||||
//添加XML目录
|
||||
ResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
|
||||
try {
|
||||
//设置xml扫描路径
|
||||
Resource[] baseMapperResource = resolver.getResources("classpath*:/mybatis/base-mapper.xml");
|
||||
Resource[] resources = resolver.getResources("classpath*:/mybatis/**/*.xml");
|
||||
bean.setMapperLocations(ArrayUtils.addAll(resources, resources));
|
||||
return bean.getObject();
|
||||
} catch (Exception e) {
|
||||
throw new BusinessException("sessionFactory init fail",e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 配置事务管理器
|
||||
*/
|
||||
@Bean(name = "transactionManager")
|
||||
public DataSourceTransactionManager transactionManager(HikariDataSource dataSource) {
|
||||
return new DataSourceTransactionManager(dataSource);
|
||||
}
|
||||
}
|
||||
@ -1,174 +0,0 @@
|
||||
package com.arm.equipment.system.data.app;
|
||||
|
||||
import com.arm.equipment.system.data.constant.RedisKeys;
|
||||
import org.apache.commons.pool2.impl.GenericObjectPoolConfig;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.boot.autoconfigure.data.redis.RedisProperties;
|
||||
import org.springframework.boot.context.event.ApplicationStartedEvent;
|
||||
import org.springframework.context.ApplicationEvent;
|
||||
import org.springframework.context.ApplicationListener;
|
||||
import org.springframework.context.Lifecycle;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Primary;
|
||||
import org.springframework.context.event.ContextClosedEvent;
|
||||
import org.springframework.data.redis.cache.RedisCacheConfiguration;
|
||||
import org.springframework.data.redis.cache.RedisCacheManager;
|
||||
import org.springframework.data.redis.cache.RedisCacheWriter;
|
||||
import org.springframework.data.redis.connection.RedisConnectionFactory;
|
||||
import org.springframework.data.redis.connection.RedisStandaloneConfiguration;
|
||||
import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory;
|
||||
import org.springframework.data.redis.connection.lettuce.LettucePoolingClientConfiguration;
|
||||
import org.springframework.data.redis.connection.stream.MapRecord;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer;
|
||||
import org.springframework.data.redis.serializer.RedisSerializationContext;
|
||||
import org.springframework.data.redis.serializer.RedisSerializer;
|
||||
import org.springframework.data.redis.serializer.StringRedisSerializer;
|
||||
import org.springframework.data.redis.stream.StreamMessageListenerContainer;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.LinkedBlockingQueue;
|
||||
import java.util.concurrent.ThreadPoolExecutor;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* redis 配置
|
||||
*
|
||||
* @author admin
|
||||
*/
|
||||
@Configuration
|
||||
public class RedisConfiguration implements ApplicationListener<ApplicationEvent> {
|
||||
@Autowired
|
||||
private RedisProperties redisProperties;
|
||||
/**
|
||||
* 100个线程, 无界队列, 超过异常
|
||||
*/
|
||||
private final static ThreadPoolExecutor THREAD_POOL_EXECUTOR = new ThreadPoolExecutor(100, 100, 120, TimeUnit.SECONDS, new LinkedBlockingQueue<>(), new ThreadPoolExecutor.AbortPolicy());
|
||||
|
||||
/**
|
||||
* lettuce对象连接池
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Bean
|
||||
public LettuceConnectionFactory lettuceConnectionFactory() {
|
||||
RedisStandaloneConfiguration configuration = new RedisStandaloneConfiguration();
|
||||
configuration.setHostName(redisProperties.getHost());
|
||||
configuration.setDatabase(redisProperties.getDatabase());
|
||||
configuration.setPort(redisProperties.getPort());
|
||||
configuration.setPassword(redisProperties.getPassword());
|
||||
//连接池配置
|
||||
GenericObjectPoolConfig poolConfig = new GenericObjectPoolConfig();
|
||||
RedisProperties.Pool pool = redisProperties.getLettuce().getPool();
|
||||
poolConfig.setMaxIdle(20);
|
||||
poolConfig.setMinIdle(1);
|
||||
poolConfig.setMaxTotal(100);
|
||||
poolConfig.setMaxWaitMillis(3000);
|
||||
poolConfig.setTimeBetweenEvictionRunsMillis(20000);
|
||||
poolConfig.setTestWhileIdle(true);
|
||||
LettucePoolingClientConfiguration clientConfiguration = LettucePoolingClientConfiguration.builder()
|
||||
.commandTimeout(Duration.ofSeconds(10))
|
||||
.poolConfig(poolConfig).build();
|
||||
return new LettuceConnectionFactory(configuration, clientConfiguration);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public RedisTemplate getTemplate(@Qualifier(value = "redisTemplate") RedisTemplate template) {
|
||||
template.setConnectionFactory(lettuceConnectionFactory());
|
||||
template.setDefaultSerializer(new StringRedisSerializer());
|
||||
template.setKeySerializer(new StringRedisSerializer());
|
||||
template.setValueSerializer(new StringRedisSerializer());
|
||||
template.setHashKeySerializer(new GenericJackson2JsonRedisSerializer());
|
||||
template.setHashValueSerializer(new GenericJackson2JsonRedisSerializer());
|
||||
return template;
|
||||
}
|
||||
|
||||
/**
|
||||
* 缓存管理器
|
||||
* 1.默认缓存为1天
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Bean
|
||||
@Primary
|
||||
public RedisCacheManager cacheManager() {
|
||||
RedisCacheWriter redisCacheWriter = RedisCacheWriter.nonLockingRedisCacheWriter(lettuceConnectionFactory());
|
||||
GenericJackson2JsonRedisSerializer genericJackson2JsonRedisSerializer = new GenericJackson2JsonRedisSerializer();
|
||||
RedisCacheConfiguration redisCacheConfiguration = RedisCacheConfiguration.defaultCacheConfig()
|
||||
.serializeKeysWith(RedisSerializationContext.SerializationPair.fromSerializer(RedisSerializer.string()))
|
||||
.serializeValuesWith(RedisSerializationContext.SerializationPair.fromSerializer(genericJackson2JsonRedisSerializer))
|
||||
.entryTtl(Duration.ofDays(1));
|
||||
RedisCacheManager redisCacheManager = RedisCacheManager.builder(redisCacheWriter)
|
||||
.cacheDefaults(redisCacheConfiguration)
|
||||
.withInitialCacheConfigurations(getRedisCacheConfigurationMap()).build();
|
||||
return redisCacheManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* 为指定 key 设置过期时间
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
private Map<String, RedisCacheConfiguration> getRedisCacheConfigurationMap() {
|
||||
Map<String, RedisCacheConfiguration> redisCacheConfigurationMap = new HashMap<>();
|
||||
redisCacheConfigurationMap.put(RedisKeys.WECHAT_ACCESS_TOKEN, getRedisCacheConfigurationWithTtl(600));
|
||||
// 直播间统计ID集合 默认保存七天
|
||||
return redisCacheConfigurationMap;
|
||||
}
|
||||
|
||||
private RedisCacheConfiguration getRedisCacheConfigurationWithTtl(Integer seconds) {
|
||||
GenericJackson2JsonRedisSerializer genericJackson2JsonRedisSerializer = new GenericJackson2JsonRedisSerializer();
|
||||
return RedisCacheConfiguration.defaultCacheConfig()
|
||||
.serializeKeysWith(RedisSerializationContext.SerializationPair.fromSerializer(RedisSerializer.string()))
|
||||
.serializeValuesWith(RedisSerializationContext.SerializationPair.fromSerializer(genericJackson2JsonRedisSerializer))
|
||||
.computePrefixWith(name -> name + ":").entryTtl(Duration.ofSeconds(seconds));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 流监听容器, 这里只是创建, 需要在下面启动
|
||||
*
|
||||
* @param redisConnectionFactory
|
||||
* @return
|
||||
*/
|
||||
@Bean
|
||||
public StreamMessageListenerContainer<String, MapRecord<String, String, String>> streamMessageListenerContainer(RedisConnectionFactory redisConnectionFactory) {
|
||||
// 创建配置对象
|
||||
StreamMessageListenerContainer.StreamMessageListenerContainerOptions<String, MapRecord<String, String, String>> listenerContainerOptions = StreamMessageListenerContainer.StreamMessageListenerContainerOptions
|
||||
.builder()
|
||||
// 一次性最多拉取多少条消息
|
||||
.batchSize(100)
|
||||
.executor(THREAD_POOL_EXECUTOR)
|
||||
.build();
|
||||
// 根据配置对象创建监听容器
|
||||
|
||||
StreamMessageListenerContainer<String, MapRecord<String, String, String>> listenerContainer = StreamMessageListenerContainer.create(redisConnectionFactory, listenerContainerOptions);
|
||||
return listenerContainer;
|
||||
}
|
||||
|
||||
/**
|
||||
* 1.spring启动后启动redis监听容器
|
||||
* 2.spring结束后关闭redis监听容器
|
||||
*
|
||||
* @param applicationEvent
|
||||
*/
|
||||
@Override
|
||||
public void onApplicationEvent(ApplicationEvent applicationEvent) {
|
||||
if (applicationEvent instanceof ApplicationStartedEvent) {
|
||||
// 启动redis stream 监听
|
||||
((ApplicationStartedEvent) applicationEvent).getApplicationContext()
|
||||
.getBeanProvider(StreamMessageListenerContainer.class)
|
||||
.ifAvailable(Lifecycle::start);
|
||||
}
|
||||
if (applicationEvent instanceof ContextClosedEvent) {
|
||||
// 启动redis stream 监听
|
||||
((ContextClosedEvent) applicationEvent).getApplicationContext()
|
||||
.getBeanProvider(StreamMessageListenerContainer.class)
|
||||
.ifAvailable(Lifecycle::stop);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,47 +0,0 @@
|
||||
package com.arm.equipment.system.data.app;
|
||||
|
||||
import com.alibaba.fastjson.serializer.SerializerFeature;
|
||||
import com.alibaba.fastjson.support.config.FastJsonConfig;
|
||||
import com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.http.client.SimpleClientHttpRequestFactory;
|
||||
import org.springframework.http.converter.FormHttpMessageConverter;
|
||||
import org.springframework.http.converter.StringHttpMessageConverter;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Configuration
|
||||
public class RestTemplateConfiguration {
|
||||
@Bean(name = "restTemplate")
|
||||
public RestTemplate getRestTemplate() {
|
||||
List messageConverters = new ArrayList<>();
|
||||
messageConverters.add(new FormHttpMessageConverter());
|
||||
messageConverters.add(getFastJsonHttpMessageConverter());
|
||||
messageConverters.add(new StringHttpMessageConverter());
|
||||
RestTemplate restTemplate = new RestTemplate(getHttpRequestFactory());
|
||||
restTemplate.setMessageConverters(messageConverters);
|
||||
return restTemplate;
|
||||
}
|
||||
|
||||
private FastJsonHttpMessageConverter getFastJsonHttpMessageConverter() {
|
||||
FastJsonHttpMessageConverter fastJsonHttpMessageConverter = new FastJsonHttpMessageConverter();
|
||||
fastJsonHttpMessageConverter.setFastJsonConfig(getFastJsonConfig());
|
||||
return fastJsonHttpMessageConverter;
|
||||
}
|
||||
|
||||
private FastJsonConfig getFastJsonConfig() {
|
||||
FastJsonConfig fastJsonConfig = new FastJsonConfig();
|
||||
fastJsonConfig.setSerializerFeatures(SerializerFeature.WriteDateUseDateFormat);
|
||||
return fastJsonConfig;
|
||||
}
|
||||
|
||||
private SimpleClientHttpRequestFactory getHttpRequestFactory() {
|
||||
SimpleClientHttpRequestFactory simpleClientHttpRequestFactory = new SimpleClientHttpRequestFactory();
|
||||
simpleClientHttpRequestFactory.setConnectTimeout(120000);
|
||||
simpleClientHttpRequestFactory.setReadTimeout(120000);
|
||||
return simpleClientHttpRequestFactory;
|
||||
}
|
||||
}
|
||||
@ -1,13 +0,0 @@
|
||||
package com.arm.equipment.system.data.constant;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 全局变量存放处
|
||||
* @author wyd
|
||||
*/
|
||||
public class ConstantValues {
|
||||
/** request请求中的参数 */
|
||||
public final static String REQUEST_BODY = "WJ-Request-Body";
|
||||
}
|
||||
@ -1,29 +0,0 @@
|
||||
package com.arm.equipment.system.data.constant;
|
||||
|
||||
/**
|
||||
* redisKey集合
|
||||
*/
|
||||
public class RedisKeys {
|
||||
public final static String SYS_BASE_PARAM_KEY = "sysBaseParamKey";
|
||||
/** * 微信accesstoken*/
|
||||
public final static String WECHAT_ACCESS_TOKEN = "wechatAccessToken";
|
||||
/*** id worker service中的worker id*/
|
||||
public static final String SNOW_FLAKE_WORKER_ID = "snow:flake_worker:id";
|
||||
/**系统用户登陆错误次数*/
|
||||
public static final String SYS_USER_LOGIN_ERROR_NUM = "sys:user:login:error:num:%s";
|
||||
/**
|
||||
* token和用户的对应关系
|
||||
* <p>
|
||||
* 数据结构: SET
|
||||
*
|
||||
* @param token
|
||||
* @return
|
||||
*/
|
||||
public static String getAppUsernameByTokenSetKey(String token) {
|
||||
return String.format("app:user:token:%s", token);
|
||||
}
|
||||
|
||||
public static String getAppUserSessionKey(String token) {
|
||||
return String.format("app:user:session:%s", token);
|
||||
}
|
||||
}
|
||||
@ -1,65 +0,0 @@
|
||||
package com.arm.equipment.system.data.domain;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 数据库实体基类
|
||||
* @author admin
|
||||
*/
|
||||
public class BaseDomain extends BasePage {
|
||||
/** 主键 */
|
||||
private Long id;
|
||||
/** 创建时间 */
|
||||
private Date createTime;
|
||||
/** 更新时间 */
|
||||
private Date updateTime;
|
||||
/** 更新时间结束 */
|
||||
private Date updateTimeEnd;
|
||||
/** 操作人*/
|
||||
private String operator;
|
||||
/** 备注 */
|
||||
private String remark;
|
||||
|
||||
public String getOperator() {
|
||||
return operator;
|
||||
}
|
||||
|
||||
public void setOperator(String operator) {
|
||||
this.operator = operator;
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Date getCreateTime() { return createTime; }
|
||||
|
||||
public void setCreateTime(Date createTime) { this.createTime = createTime; }
|
||||
|
||||
public Date getUpdateTime() { return updateTime; }
|
||||
|
||||
public void setUpdateTime(Date updateTime) { this.updateTime = updateTime; }
|
||||
|
||||
public Date getUpdateTimeEnd() { return updateTimeEnd; }
|
||||
|
||||
public void setUpdateTimeEnd(Date updateTimeEnd) { this.updateTimeEnd = updateTimeEnd; }
|
||||
|
||||
public String getRemark() { return remark; }
|
||||
|
||||
public void setRemark(String remark) { this.remark = remark; }
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "BaseDomain{" +
|
||||
"id=" + id +
|
||||
", createTime=" + createTime +
|
||||
", updateTime=" + updateTime +
|
||||
", updateTimeEnd=" + updateTimeEnd +
|
||||
", remark='" + remark + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@ -1,94 +0,0 @@
|
||||
package com.arm.equipment.system.data.domain;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* @author admin
|
||||
*/
|
||||
public class PageResult {
|
||||
/** 页数 */
|
||||
private int pageNo;
|
||||
/** 总页数 */
|
||||
private int pageCount;
|
||||
/** 总条数 */
|
||||
private int total;
|
||||
/** 数据 */
|
||||
private Collection<?> rows;
|
||||
/** 页大小 */
|
||||
private int pageSize;
|
||||
|
||||
public PageResult() {
|
||||
}
|
||||
|
||||
public PageResult(int pageNo, int pageSize, int total, Collection<?> rows) {
|
||||
this.pageNo = pageNo;
|
||||
this.total = total;
|
||||
this.rows = rows;
|
||||
this.pageSize = pageSize;
|
||||
this.pageCount = calcPageCount(total);
|
||||
|
||||
}
|
||||
|
||||
private int calcPageCount(int count) {
|
||||
if (pageSize == 0) {
|
||||
return 0;
|
||||
}
|
||||
if (count % pageSize == 0) {
|
||||
return count / pageSize;
|
||||
} else {
|
||||
return count / pageSize + 1;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public static int getPageCount(int count, int pageSize) {
|
||||
if (pageSize == 0) {
|
||||
return 0;
|
||||
}
|
||||
if (count % pageSize == 0) {
|
||||
return count / pageSize;
|
||||
} else {
|
||||
return count / pageSize + 1;
|
||||
}
|
||||
}
|
||||
|
||||
public int getPageSize() {
|
||||
return pageSize;
|
||||
}
|
||||
|
||||
public void setPageSize(int pageSize) {
|
||||
this.pageSize = pageSize;
|
||||
}
|
||||
|
||||
public int getPageNo() {
|
||||
return pageNo;
|
||||
}
|
||||
|
||||
public void setPageNo(int pageNo) {
|
||||
this.pageNo = pageNo;
|
||||
}
|
||||
|
||||
public int getPageCount() {
|
||||
return pageCount;
|
||||
}
|
||||
|
||||
public void setPageCount(int pageCount) {
|
||||
this.pageCount = pageCount;
|
||||
}
|
||||
|
||||
public int getTotal() {
|
||||
return total;
|
||||
}
|
||||
|
||||
public void setTotal(int total) {
|
||||
this.total = total;
|
||||
}
|
||||
|
||||
public Collection<?> getRows() {
|
||||
return rows;
|
||||
}
|
||||
|
||||
public void setRows(Collection<?> rows) {
|
||||
this.rows = rows;
|
||||
}
|
||||
}
|
||||
@ -1,67 +0,0 @@
|
||||
package com.arm.equipment.system.data.domain.system;
|
||||
|
||||
import com.arm.equipment.system.data.domain.BaseDomain;
|
||||
|
||||
/**
|
||||
* 系统--基础参数
|
||||
*
|
||||
* @author Administrator
|
||||
* @date 2021年10月26日 16:36:52
|
||||
*/
|
||||
public class SysBaseParam extends BaseDomain {
|
||||
/** 唯一编码 */
|
||||
private String uniCode;
|
||||
/** 值 */
|
||||
private String value;
|
||||
/** 描述 */
|
||||
private String description;
|
||||
/** 操作人 */
|
||||
private String operator;
|
||||
/** 数据状态 */
|
||||
private Integer status;
|
||||
|
||||
public String getUniCode() {
|
||||
return uniCode;
|
||||
}
|
||||
|
||||
public void setUniCode(String uniCode) {
|
||||
this.uniCode = uniCode;
|
||||
}
|
||||
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
|
||||
public String getOperator() {
|
||||
return operator;
|
||||
}
|
||||
|
||||
public void setOperator(String operator) {
|
||||
this.operator = operator;
|
||||
}
|
||||
|
||||
|
||||
public Integer getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(Integer status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,166 +0,0 @@
|
||||
package com.arm.equipment.system.data.domain.system;
|
||||
|
||||
import com.arm.equipment.system.data.domain.BaseDomain;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 系统--权限表
|
||||
*
|
||||
* @author admin
|
||||
* @date 2021年10月20日 08:59:10
|
||||
*/
|
||||
public class SysResource extends BaseDomain {
|
||||
/** 菜单名称 */
|
||||
private String name;
|
||||
/** 链接地址 */
|
||||
private String url;
|
||||
/** 父菜单ID */
|
||||
private String parentId;
|
||||
/** 图标 */
|
||||
private String icon;
|
||||
/** 排序 */
|
||||
private Integer sort;
|
||||
/** 菜单类型 */
|
||||
private Integer type;
|
||||
/** 权限标识 */
|
||||
private String identity;
|
||||
/** 是否显示 */
|
||||
private Integer isShow;
|
||||
/** 状态 */
|
||||
private Integer status;
|
||||
/** 操作人 */
|
||||
private String operator;
|
||||
/** 根路径,用.分隔 */
|
||||
private String rootPath;
|
||||
|
||||
/********VO******/
|
||||
/**子集集合*/
|
||||
private List<SysResource> children;
|
||||
/**标签*/
|
||||
private String label;
|
||||
/**ID集合*/
|
||||
private List<Long> idsList;
|
||||
|
||||
public List<Long> getIdsList() {
|
||||
return idsList;
|
||||
}
|
||||
|
||||
public void setIdsList(List<Long> idsList) {
|
||||
this.idsList = idsList;
|
||||
}
|
||||
|
||||
public String getLabel() {
|
||||
return label;
|
||||
}
|
||||
|
||||
public void setLabel(String label) {
|
||||
this.label = label;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
|
||||
public void setUrl(String url) {
|
||||
this.url = url;
|
||||
}
|
||||
|
||||
|
||||
public String getParentId() {
|
||||
return parentId;
|
||||
}
|
||||
|
||||
public void setParentId(String parentId) {
|
||||
this.parentId = parentId;
|
||||
}
|
||||
|
||||
|
||||
public String getIcon() {
|
||||
return icon;
|
||||
}
|
||||
|
||||
public void setIcon(String icon) {
|
||||
this.icon = icon;
|
||||
}
|
||||
|
||||
|
||||
public Integer getSort() {
|
||||
return sort;
|
||||
}
|
||||
|
||||
public void setSort(Integer sort) {
|
||||
this.sort = sort;
|
||||
}
|
||||
|
||||
|
||||
public Integer getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(Integer type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
|
||||
public String getIdentity() {
|
||||
return identity;
|
||||
}
|
||||
|
||||
public void setIdentity(String identity) {
|
||||
this.identity = identity;
|
||||
}
|
||||
|
||||
|
||||
public Integer getIsShow() {
|
||||
return isShow;
|
||||
}
|
||||
|
||||
public void setIsShow(Integer isShow) {
|
||||
this.isShow = isShow;
|
||||
}
|
||||
|
||||
|
||||
public Integer getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(Integer status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
|
||||
public String getOperator() {
|
||||
return operator;
|
||||
}
|
||||
|
||||
public void setOperator(String operator) {
|
||||
this.operator = operator;
|
||||
}
|
||||
|
||||
|
||||
public String getRootPath() {
|
||||
return rootPath;
|
||||
}
|
||||
|
||||
public void setRootPath(String rootPath) {
|
||||
this.rootPath = rootPath;
|
||||
}
|
||||
|
||||
public List<SysResource> getChildren() {
|
||||
return children;
|
||||
}
|
||||
|
||||
public void setChildren(List<SysResource> children) {
|
||||
this.children = children;
|
||||
}
|
||||
}
|
||||
@ -1,69 +0,0 @@
|
||||
package com.arm.equipment.system.data.domain.system;
|
||||
|
||||
import com.arm.equipment.system.data.domain.BaseDomain;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 系统--角色表
|
||||
*
|
||||
* @author admin
|
||||
* @date 2021年10月19日 15:06:47
|
||||
*/
|
||||
public class SysRole extends BaseDomain {
|
||||
/** 角色名称 */
|
||||
private String name;
|
||||
/** 描述 */
|
||||
private String description;
|
||||
/** 状态 */
|
||||
private Integer status;
|
||||
/** 操作人 */
|
||||
private String operator;
|
||||
|
||||
/****** VO ***/
|
||||
/**角色ID集合*/
|
||||
private List<Long> sysRoleIdList;
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
|
||||
public Integer getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(Integer status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
|
||||
public String getOperator() {
|
||||
return operator;
|
||||
}
|
||||
|
||||
public void setOperator(String operator) {
|
||||
this.operator = operator;
|
||||
}
|
||||
|
||||
public List<Long> getSysRoleIdList() {
|
||||
return sysRoleIdList;
|
||||
}
|
||||
|
||||
public void setSysRoleIdList(List<Long> sysRoleIdList) {
|
||||
this.sysRoleIdList = sysRoleIdList;
|
||||
}
|
||||
}
|
||||
@ -1,70 +0,0 @@
|
||||
package com.arm.equipment.system.data.domain.system;
|
||||
|
||||
import com.arm.equipment.system.data.domain.BaseDomain;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 系统-角色权限关联表
|
||||
*
|
||||
* @author admin
|
||||
* @date 2021年10月19日 15:06:41
|
||||
*/
|
||||
public class SysRoleResource extends BaseDomain {
|
||||
/** 角色ID */
|
||||
private Long sysRoleId;
|
||||
/** 权限ID */
|
||||
private Long sysResourceId;
|
||||
/** 状态 */
|
||||
private Integer status;
|
||||
/** 操作人 */
|
||||
private String operator;
|
||||
|
||||
/****** VO ***/
|
||||
/**添加新权限(修改权限)*/
|
||||
private List<String> newResources;
|
||||
|
||||
public List<String> getNewResources() {
|
||||
return newResources;
|
||||
}
|
||||
|
||||
public void setNewResources(List<String> newResources) {
|
||||
this.newResources = newResources;
|
||||
}
|
||||
|
||||
public Long getSysRoleId() {
|
||||
return sysRoleId;
|
||||
}
|
||||
|
||||
public void setSysRoleId(Long sysRoleId) {
|
||||
this.sysRoleId = sysRoleId;
|
||||
}
|
||||
|
||||
|
||||
public Long getSysResourceId() {
|
||||
return sysResourceId;
|
||||
}
|
||||
|
||||
public void setSysResourceId(Long sysResourceId) {
|
||||
this.sysResourceId = sysResourceId;
|
||||
}
|
||||
|
||||
|
||||
public Integer getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(Integer status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
|
||||
public String getOperator() {
|
||||
return operator;
|
||||
}
|
||||
|
||||
public void setOperator(String operator) {
|
||||
this.operator = operator;
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,172 +0,0 @@
|
||||
package com.arm.equipment.system.data.domain.system;
|
||||
|
||||
import com.arm.equipment.system.data.domain.BaseDomain;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 系统--用户表
|
||||
*
|
||||
* @author admin
|
||||
* @date 2021年10月19日 15:07:06
|
||||
*/
|
||||
public class SysUser extends BaseDomain {
|
||||
/** 用户名 */
|
||||
private String username;
|
||||
/** 密码 */
|
||||
private String password;
|
||||
/** 手机 */
|
||||
private String phone;
|
||||
/** 姓名 */
|
||||
private String name;
|
||||
/** 邮箱 */
|
||||
private String email;
|
||||
/**
|
||||
* 用户标签
|
||||
* @see
|
||||
* */
|
||||
private String tag;
|
||||
/** 状态 */
|
||||
private Integer status;
|
||||
/**是否需要二次登陆*/
|
||||
private Integer isSecondLanding;
|
||||
|
||||
/******VO****/
|
||||
/**
|
||||
* 验证码
|
||||
*/
|
||||
private String verifyCode;
|
||||
/**
|
||||
* 角色信息
|
||||
*/
|
||||
private List<SysRole> sysRoleList;
|
||||
/**
|
||||
* 用户菜单标识信息
|
||||
*/
|
||||
private List<String> sysResourceIdentityList;
|
||||
/**
|
||||
* 用户菜单列表
|
||||
*/
|
||||
private List<SysResource> sysResourceList;
|
||||
/**标签集合*/
|
||||
private List<String> tagList;
|
||||
/**二次登陆验证码*/
|
||||
private String twoVerifyCode;
|
||||
|
||||
public String getTwoVerifyCode() {
|
||||
return twoVerifyCode;
|
||||
}
|
||||
|
||||
public void setTwoVerifyCode(String twoVerifyCode) {
|
||||
this.twoVerifyCode = twoVerifyCode;
|
||||
}
|
||||
|
||||
public Integer getIsSecondLanding() {
|
||||
return isSecondLanding;
|
||||
}
|
||||
|
||||
public void setIsSecondLanding(Integer isSecondLanding) {
|
||||
this.isSecondLanding = isSecondLanding;
|
||||
}
|
||||
|
||||
public List<String> getTagList() {
|
||||
return tagList;
|
||||
}
|
||||
|
||||
public void setTagList(List<String> tagList) {
|
||||
this.tagList = tagList;
|
||||
}
|
||||
|
||||
public String getVerifyCode() {
|
||||
return verifyCode;
|
||||
}
|
||||
|
||||
public void setVerifyCode(String verifyCode) {
|
||||
this.verifyCode = verifyCode;
|
||||
}
|
||||
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
public void setPassword(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
|
||||
public String getPhone() {
|
||||
return phone;
|
||||
}
|
||||
|
||||
public void setPhone(String phone) {
|
||||
this.phone = phone;
|
||||
}
|
||||
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
|
||||
public String getEmail() {
|
||||
return email;
|
||||
}
|
||||
|
||||
public void setEmail(String email) {
|
||||
this.email = email;
|
||||
}
|
||||
|
||||
|
||||
public Integer getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(Integer status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public List<SysRole> getSysRoleList() {
|
||||
return sysRoleList;
|
||||
}
|
||||
|
||||
public void setSysRoleList(List<SysRole> sysRoleList) {
|
||||
this.sysRoleList = sysRoleList;
|
||||
}
|
||||
|
||||
public List<String> getSysResourceIdentityList() {
|
||||
return sysResourceIdentityList;
|
||||
}
|
||||
|
||||
public void setSysResourceIdentityList(List<String> sysResourceIdentityList) {
|
||||
this.sysResourceIdentityList = sysResourceIdentityList;
|
||||
}
|
||||
|
||||
public List<SysResource> getSysResourceList() {
|
||||
return sysResourceList;
|
||||
}
|
||||
|
||||
public void setSysResourceList(List<SysResource> sysResourceList) {
|
||||
this.sysResourceList = sysResourceList;
|
||||
}
|
||||
|
||||
public String getTag() {
|
||||
return tag;
|
||||
}
|
||||
|
||||
public void setTag(String tag) {
|
||||
this.tag = tag;
|
||||
}
|
||||
}
|
||||
@ -1,56 +0,0 @@
|
||||
package com.arm.equipment.system.data.domain.system;
|
||||
|
||||
import com.arm.equipment.system.data.domain.BaseDomain;
|
||||
|
||||
/**
|
||||
* 系统--用户角色关联表
|
||||
*
|
||||
* @author admin
|
||||
* @date 2021年10月19日 15:06:59
|
||||
*/
|
||||
public class SysUserRole extends BaseDomain {
|
||||
/** 角色ID */
|
||||
private Long sysRoleId;
|
||||
/** 用户ID */
|
||||
private Long sysUserId;
|
||||
/** 状态 */
|
||||
private Integer status;
|
||||
/** 执行者 */
|
||||
private String operator;
|
||||
|
||||
public Long getSysRoleId() {
|
||||
return sysRoleId;
|
||||
}
|
||||
|
||||
public void setSysRoleId(Long sysRoleId) {
|
||||
this.sysRoleId = sysRoleId;
|
||||
}
|
||||
|
||||
|
||||
public Long getSysUserId() {
|
||||
return sysUserId;
|
||||
}
|
||||
|
||||
public void setSysUserId(Long sysUserId) {
|
||||
this.sysUserId = sysUserId;
|
||||
}
|
||||
|
||||
|
||||
public Integer getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(Integer status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
|
||||
public String getOperator() {
|
||||
return operator;
|
||||
}
|
||||
|
||||
public void setOperator(String operator) {
|
||||
this.operator = operator;
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,89 +0,0 @@
|
||||
package com.arm.equipment.system.data.domain.user;
|
||||
|
||||
import com.arm.equipment.system.data.domain.BaseDomain;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* APP用户
|
||||
*
|
||||
* @author admin
|
||||
* @date 2023年03月13日 22:34:47
|
||||
*/
|
||||
public class AppUser extends BaseDomain {
|
||||
/** 用户昵称 */
|
||||
private String nickname;
|
||||
/** 登录账号 */
|
||||
private String username;
|
||||
/** 密码 */
|
||||
private String password;
|
||||
/** 手机号 */
|
||||
private String phone;
|
||||
/** 数据状态 */
|
||||
private Integer status;
|
||||
/** 登录时间 */
|
||||
private Date loginTime;
|
||||
|
||||
private String token;
|
||||
|
||||
public String getToken() {
|
||||
return token;
|
||||
}
|
||||
|
||||
public void setToken(String token) {
|
||||
this.token = token;
|
||||
}
|
||||
public String getNickname() {
|
||||
return nickname;
|
||||
}
|
||||
|
||||
public void setNickname(String nickname) {
|
||||
this.nickname = nickname;
|
||||
}
|
||||
|
||||
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
public void setPassword(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
|
||||
public String getPhone() {
|
||||
return phone;
|
||||
}
|
||||
|
||||
public void setPhone(String phone) {
|
||||
this.phone = phone;
|
||||
}
|
||||
|
||||
|
||||
public Integer getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(Integer status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
|
||||
public Date getLoginTime() {
|
||||
return loginTime;
|
||||
}
|
||||
|
||||
public void setLoginTime(Date loginTime) {
|
||||
this.loginTime = loginTime;
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,91 +0,0 @@
|
||||
package com.arm.equipment.system.data.domain.weaponry;
|
||||
|
||||
import com.arm.equipment.system.data.domain.BaseDomain;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 装备武器归还记录
|
||||
*
|
||||
* @author admin
|
||||
* @date 2023年03月23日 11:03:25
|
||||
*/
|
||||
public class WeaponryReturnRecord extends BaseDomain {
|
||||
/** 武器ID */
|
||||
private Long weaponryId;
|
||||
/** 武器名称 */
|
||||
private String weaponryName;
|
||||
/** 记录ID */
|
||||
private Long lendRecordId;
|
||||
/** 借出数量 */
|
||||
private Integer num;
|
||||
/** 归还时间 */
|
||||
private Date returnTime;
|
||||
/** 数据状态 */
|
||||
private Integer status;
|
||||
|
||||
/****************VO**************/
|
||||
private Weaponry weaponry;
|
||||
|
||||
public Weaponry getWeaponry() {
|
||||
return weaponry;
|
||||
}
|
||||
|
||||
public void setWeaponry(Weaponry weaponry) {
|
||||
this.weaponry = weaponry;
|
||||
}
|
||||
|
||||
public Long getWeaponryId() {
|
||||
return weaponryId;
|
||||
}
|
||||
|
||||
public void setWeaponryId(Long weaponryId) {
|
||||
this.weaponryId = weaponryId;
|
||||
}
|
||||
|
||||
|
||||
public String getWeaponryName() {
|
||||
return weaponryName;
|
||||
}
|
||||
|
||||
public void setWeaponryName(String weaponryName) {
|
||||
this.weaponryName = weaponryName;
|
||||
}
|
||||
|
||||
|
||||
public Long getLendRecordId() {
|
||||
return lendRecordId;
|
||||
}
|
||||
|
||||
public void setLendRecordId(Long lendRecordId) {
|
||||
this.lendRecordId = lendRecordId;
|
||||
}
|
||||
|
||||
|
||||
public Integer getNum() {
|
||||
return num;
|
||||
}
|
||||
|
||||
public void setNum(Integer num) {
|
||||
this.num = num;
|
||||
}
|
||||
|
||||
|
||||
public Date getReturnTime() {
|
||||
return returnTime;
|
||||
}
|
||||
|
||||
public void setReturnTime(Date returnTime) {
|
||||
this.returnTime = returnTime;
|
||||
}
|
||||
|
||||
|
||||
public Integer getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(Integer status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,37 +0,0 @@
|
||||
package com.arm.equipment.system.data.enums.dict;
|
||||
|
||||
/***
|
||||
*
|
||||
* 资源文件类型
|
||||
* @author: admin
|
||||
* @time: 2021/11/17 17:35
|
||||
*/
|
||||
public enum EnumFileResourceType {
|
||||
/** */
|
||||
IMG(1, "图片"),
|
||||
VIDEO(2, "视频"),
|
||||
;
|
||||
|
||||
private Integer code;
|
||||
private String text;
|
||||
|
||||
EnumFileResourceType(Integer code, String text) {
|
||||
this.code = code;
|
||||
this.text = text;
|
||||
}
|
||||
|
||||
public Integer getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public void setCode(Integer code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public String getText() {
|
||||
return text;
|
||||
}
|
||||
|
||||
public void setText(String text) {
|
||||
this.text = text;
|
||||
}}
|
||||
@ -1,51 +0,0 @@
|
||||
package com.arm.equipment.system.data.enums.dict;
|
||||
|
||||
import com.arm.equipment.system.data.exception.BusinessException;
|
||||
|
||||
/**
|
||||
* 数据状态枚举
|
||||
* @author admin
|
||||
*/
|
||||
public enum EnumGender {
|
||||
/** 审核 */
|
||||
MALE(1, "男"),
|
||||
|
||||
/** The release. */
|
||||
FEMALE(2, "女"),
|
||||
;
|
||||
|
||||
private Integer code;
|
||||
private String text;
|
||||
|
||||
EnumGender(Integer code, String text) {
|
||||
this.code = code;
|
||||
this.text = text;
|
||||
}
|
||||
|
||||
public static EnumGender getByCode(Integer code) {
|
||||
if (null == code) {
|
||||
return null;
|
||||
}
|
||||
for (EnumGender type : EnumGender.values()) {
|
||||
if (type.getCode().equals(code)) {
|
||||
return type;
|
||||
}
|
||||
}
|
||||
throw new BusinessException("内容类型非法");
|
||||
}
|
||||
|
||||
public Integer getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public void setCode(Integer code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public String getText() {
|
||||
return text;
|
||||
}
|
||||
|
||||
public void setText(String text) {
|
||||
this.text = text;
|
||||
}}
|
||||
@ -1,51 +0,0 @@
|
||||
package com.arm.equipment.system.data.enums.dict;
|
||||
|
||||
/**
|
||||
* 排序类型
|
||||
*
|
||||
* @author: xly
|
||||
* @time: 2022/9/16 18:30
|
||||
*/
|
||||
public enum EnumSortType {
|
||||
ASC(1, "升序"),
|
||||
DESC(2, "降序"),
|
||||
;
|
||||
|
||||
private Integer code;
|
||||
private String text;
|
||||
|
||||
EnumSortType(Integer code, String text) {
|
||||
this.code = code;
|
||||
this.text = text;
|
||||
}
|
||||
|
||||
public Integer getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public void setCode(Integer code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public String getText() {
|
||||
return text;
|
||||
}
|
||||
|
||||
public void setText(String text) {
|
||||
this.text = text;
|
||||
}
|
||||
|
||||
|
||||
public static EnumSortType getByCode(Integer code) {
|
||||
if (code == null) {
|
||||
return null;
|
||||
}
|
||||
EnumSortType[] values = EnumSortType.values();
|
||||
for (EnumSortType v : values) {
|
||||
if (v.getCode().equals(code)) {
|
||||
return v;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@ -1,56 +0,0 @@
|
||||
package com.arm.equipment.system.data.enums.dict;
|
||||
|
||||
/**
|
||||
* 数据状态枚举
|
||||
*
|
||||
* @author admin
|
||||
*/
|
||||
public enum EnumStatus {
|
||||
/**
|
||||
* The new.
|
||||
*/
|
||||
NEW(0, "新增"),
|
||||
|
||||
AUDIT(1, "已审核"),
|
||||
|
||||
DEL(-9, "已删除");
|
||||
|
||||
private Integer code;
|
||||
private String text;
|
||||
EnumStatus(Integer code, String text) {
|
||||
this.code = code;
|
||||
this.text = text;
|
||||
}
|
||||
|
||||
public Integer getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public void setCode(Integer code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public String getText() {
|
||||
return text;
|
||||
}
|
||||
|
||||
public void setText(String text) {
|
||||
this.text = text;
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过code获得该枚举类型
|
||||
*
|
||||
* @param code
|
||||
* @return
|
||||
*/
|
||||
public static EnumStatus getByCode(Integer code) {
|
||||
EnumStatus[] values = EnumStatus.values();
|
||||
for (EnumStatus type : values) {
|
||||
if (type.code.equals(code)) {
|
||||
return type;
|
||||
}
|
||||
}
|
||||
return NEW;
|
||||
}
|
||||
}
|
||||
@ -1,56 +0,0 @@
|
||||
package com.arm.equipment.system.data.enums.dict;
|
||||
|
||||
/**
|
||||
* 数据状态枚举
|
||||
*
|
||||
* @author admin
|
||||
*/
|
||||
public enum EnumSysLogType {
|
||||
/**
|
||||
* The new.
|
||||
*/
|
||||
LOG(1, "普通日志"),
|
||||
|
||||
EXCEPTION_LOG(2, "异常日志"),
|
||||
;
|
||||
|
||||
private Integer code;
|
||||
private String text;
|
||||
|
||||
EnumSysLogType(Integer code, String text) {
|
||||
this.code = code;
|
||||
this.text = text;
|
||||
}
|
||||
|
||||
public Integer getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public void setCode(Integer code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public String getText() {
|
||||
return text;
|
||||
}
|
||||
|
||||
public void setText(String text) {
|
||||
this.text = text;
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过code获得该枚举类型
|
||||
*
|
||||
* @param code
|
||||
* @return
|
||||
*/
|
||||
public static EnumSysLogType getByCode(Integer code) {
|
||||
EnumSysLogType[] values = EnumSysLogType.values();
|
||||
for (EnumSysLogType type : values) {
|
||||
if (type.code.equals(code)) {
|
||||
return type;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@ -1,41 +0,0 @@
|
||||
package com.arm.equipment.system.data.enums.dict;
|
||||
|
||||
/**
|
||||
* 系统资源菜单类型
|
||||
*
|
||||
* @author: admin
|
||||
* @time: 2021/10/19 18:02
|
||||
*/
|
||||
public enum EnumSysResourceType {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
CATALOGUE(0, "目录"),
|
||||
MENU(1, "菜单"),
|
||||
BUTTON(2, "按钮"),
|
||||
;
|
||||
|
||||
private Integer code;
|
||||
private String text;
|
||||
|
||||
EnumSysResourceType(Integer code, String text) {
|
||||
this.code = code;
|
||||
this.text = text;
|
||||
}
|
||||
|
||||
public Integer getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public void setCode(Integer code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public String getText() {
|
||||
return text;
|
||||
}
|
||||
|
||||
public void setText(String text) {
|
||||
this.text = text;
|
||||
}
|
||||
}
|
||||
@ -1,50 +0,0 @@
|
||||
package com.arm.equipment.system.data.enums.dict;
|
||||
|
||||
/**
|
||||
* @author: xly
|
||||
* @time: 2023/3/23 9:02
|
||||
*/
|
||||
public enum EnumWeaponryLendRecordReturnStatus {
|
||||
NOT_RETURN(0, "未归还"),
|
||||
RETURN(1, "已经归还"),
|
||||
;
|
||||
private Integer code;
|
||||
private String text;
|
||||
|
||||
EnumWeaponryLendRecordReturnStatus(Integer code, String text) {
|
||||
this.code = code;
|
||||
this.text = text;
|
||||
}
|
||||
|
||||
public Integer getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public void setCode(Integer code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public String getText() {
|
||||
return text;
|
||||
}
|
||||
|
||||
public void setText(String text) {
|
||||
this.text = text;
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过code获得该枚举类型
|
||||
*
|
||||
* @param code
|
||||
* @return
|
||||
*/
|
||||
public static EnumSysLogType getByCode(Integer code) {
|
||||
EnumSysLogType[] values = EnumSysLogType.values();
|
||||
for (EnumSysLogType type : values) {
|
||||
if (type.getCode().equals(code)) {
|
||||
return type;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@ -1,51 +0,0 @@
|
||||
package com.arm.equipment.system.data.enums.dict;
|
||||
|
||||
/**
|
||||
* @author: xly
|
||||
* @time: 2023/3/23 9:02
|
||||
*/
|
||||
public enum EnumWeaponryLendRecordStatus {
|
||||
NEW(0, "新增"),
|
||||
ADOPT(1, "通过"),
|
||||
REFUSE(2, "拒绝"),
|
||||
;
|
||||
private Integer code;
|
||||
private String text;
|
||||
|
||||
EnumWeaponryLendRecordStatus(Integer code, String text) {
|
||||
this.code = code;
|
||||
this.text = text;
|
||||
}
|
||||
|
||||
public Integer getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public void setCode(Integer code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public String getText() {
|
||||
return text;
|
||||
}
|
||||
|
||||
public void setText(String text) {
|
||||
this.text = text;
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过code获得该枚举类型
|
||||
*
|
||||
* @param code
|
||||
* @return
|
||||
*/
|
||||
public static EnumSysLogType getByCode(Integer code) {
|
||||
EnumSysLogType[] values = EnumSysLogType.values();
|
||||
for (EnumSysLogType type : values) {
|
||||
if (type.getCode().equals(code)) {
|
||||
return type;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@ -1,36 +0,0 @@
|
||||
package com.arm.equipment.system.data.enums.dict;
|
||||
|
||||
/**
|
||||
* yes no枚举
|
||||
* @author admin
|
||||
*/
|
||||
public enum EnumYesNo {
|
||||
/** */
|
||||
NO(0, "否"),
|
||||
|
||||
YES(1, "是")
|
||||
;
|
||||
|
||||
private Integer code;
|
||||
private String text;
|
||||
|
||||
EnumYesNo(Integer code, String text) {
|
||||
this.code = code;
|
||||
this.text = text;
|
||||
}
|
||||
|
||||
public Integer getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public void setCode(Integer code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public String getText() {
|
||||
return text;
|
||||
}
|
||||
|
||||
public void setText(String text) {
|
||||
this.text = text;
|
||||
}}
|
||||
@ -1,62 +0,0 @@
|
||||
package com.arm.equipment.system.data.exception;
|
||||
|
||||
import com.arm.equipment.system.data.vo.ReturnCode;
|
||||
|
||||
/**
|
||||
* @author 向帅 用户登录异常
|
||||
* @Date 2019/7/27 17:11
|
||||
**/
|
||||
public class AuthException extends RuntimeException {
|
||||
|
||||
private static final long serialVersionUID = -7429924842303522242L;
|
||||
|
||||
String message;
|
||||
|
||||
ReturnCode returnCode;
|
||||
|
||||
public AuthException() {
|
||||
super();
|
||||
}
|
||||
|
||||
public AuthException(String message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public AuthException(ReturnCode returnCode) {
|
||||
this.returnCode = returnCode;
|
||||
}
|
||||
|
||||
public AuthException(String message, ReturnCode returnCode) {
|
||||
this.message = message;
|
||||
this.returnCode = returnCode;
|
||||
}
|
||||
|
||||
public AuthException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
|
||||
public AuthException(Throwable cause) {
|
||||
super(cause);
|
||||
}
|
||||
|
||||
protected AuthException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
|
||||
super(message, cause, enableSuppression, writableStackTrace);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
public void setMessage(String message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public ReturnCode getReturnCode() {
|
||||
return returnCode;
|
||||
}
|
||||
|
||||
public void setReturnCode(ReturnCode returnCode) {
|
||||
this.returnCode = returnCode;
|
||||
}
|
||||
}
|
||||
@ -1,33 +0,0 @@
|
||||
package com.arm.equipment.system.data.util;
|
||||
|
||||
import org.springframework.beans.BeanWrapper;
|
||||
import org.springframework.beans.BeanWrapperImpl;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author admin
|
||||
*/
|
||||
public class BeanUtil {
|
||||
|
||||
/**
|
||||
* 获得对象里是null的属性
|
||||
* @param source
|
||||
* @return
|
||||
*/
|
||||
public static String[] getNullPropertyNames (Object source) {
|
||||
final BeanWrapper src = new BeanWrapperImpl(source);
|
||||
java.beans.PropertyDescriptor[] pds = src.getPropertyDescriptors();
|
||||
|
||||
Set<String> emptyNames = new HashSet<String>();
|
||||
for(java.beans.PropertyDescriptor pd : pds) {
|
||||
Object srcValue = src.getPropertyValue(pd.getName());
|
||||
if (srcValue == null){
|
||||
emptyNames.add(pd.getName());
|
||||
}
|
||||
}
|
||||
String[] result = new String[emptyNames.size()];
|
||||
return emptyNames.toArray(result);
|
||||
}
|
||||
}
|
||||
@ -1,32 +0,0 @@
|
||||
package com.arm.equipment.system.data.util;
|
||||
|
||||
import com.alibaba.excel.context.AnalysisContext;
|
||||
import com.alibaba.excel.event.AnalysisEventListener;
|
||||
import com.alibaba.excel.metadata.BaseRowModel;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class EasyExcelListener<T extends BaseRowModel> extends AnalysisEventListener<T> {
|
||||
|
||||
private final static Logger logger = LoggerFactory.getLogger(EasyExcelListener.class);
|
||||
|
||||
private final List<T> rows = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
public void invoke(T object, AnalysisContext context) {
|
||||
rows.add(object);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doAfterAllAnalysed(AnalysisContext context) {
|
||||
logger.info("read {} rows %n", rows.size());
|
||||
}
|
||||
|
||||
public List<T> getRows() {
|
||||
logger.info("read {} rows %n", rows);
|
||||
return rows;
|
||||
}
|
||||
}
|
||||
@ -1,60 +0,0 @@
|
||||
package com.arm.equipment.system.data.util;
|
||||
|
||||
import org.springframework.context.EnvironmentAware;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* 判断当前系统运行环境
|
||||
*/
|
||||
@Component
|
||||
public class EnvUtil implements EnvironmentAware {
|
||||
/** 系统环境 */
|
||||
private static Environment environment;
|
||||
|
||||
/**
|
||||
* 判断是否开发环境
|
||||
* @return
|
||||
*/
|
||||
public static boolean isDev() {
|
||||
return isEnv("dev");
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断是否测试环境
|
||||
* @return
|
||||
*/
|
||||
public static boolean isTest() {
|
||||
return isEnv("test");
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断是否生产环境
|
||||
* @return
|
||||
*/
|
||||
public static boolean isProd() {
|
||||
return isEnv("prod");
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断是否激活某个profile
|
||||
* @param env
|
||||
* @return
|
||||
*/
|
||||
private static boolean isEnv(String env) {
|
||||
return environment.getProperty("env").equalsIgnoreCase(env);
|
||||
}
|
||||
|
||||
public static String getEnv() {
|
||||
return environment.getProperty("env");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setEnvironment(Environment environment) {
|
||||
EnvUtil.environment = environment;
|
||||
}
|
||||
|
||||
public static boolean isESEnable() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue