master
parent
f2af977ea8
commit
739c5c6c3c
Binary file not shown.
@ -0,0 +1,31 @@
|
||||
HELP.md
|
||||
**/target/
|
||||
!.mvn/wrapper/maven-wrapper.jar
|
||||
!**/src/main/**
|
||||
!**/src/test/**
|
||||
|
||||
### STS ###
|
||||
.apt_generated
|
||||
.classpath
|
||||
.factorypath
|
||||
.project
|
||||
.settings
|
||||
.springBeans
|
||||
.sts4-cache
|
||||
|
||||
### IntelliJ IDEA ###
|
||||
.idea
|
||||
*.iws
|
||||
*.iml
|
||||
*.ipr
|
||||
|
||||
### NetBeans ###
|
||||
/nbproject/private/
|
||||
/nbbuild/
|
||||
/dist/
|
||||
/nbdist/
|
||||
/.nb-gradle/
|
||||
build/
|
||||
|
||||
### VS Code ###
|
||||
.vscode/
|
@ -0,0 +1,5 @@
|
||||
#
|
||||
|
||||
|
||||
|
||||
###
|
@ -0,0 +1,99 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>com.arm.equipment.system</groupId>
|
||||
<artifactId>arm-equipment-system-parent</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
</parent>
|
||||
<packaging>jar</packaging>
|
||||
<artifactId>admin</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<name>admin</name>
|
||||
<description>Demo project for Spring Boot</description>
|
||||
|
||||
<properties>
|
||||
<java.version>1.8</java.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.arm.equipment.system</groupId>
|
||||
<artifactId>data</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-actuator</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.session</groupId>
|
||||
<artifactId>spring-session-data-redis</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-data-redis</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>javax.servlet</groupId>
|
||||
<artifactId>javax.servlet-api</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>mysql</groupId>
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.mybatis.spring.boot</groupId>
|
||||
<artifactId>mybatis-spring-boot-starter</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-lang3</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>fastjson</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.retry</groupId>
|
||||
<artifactId>spring-retry</artifactId>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<finalName>arm-equipment-system-parent-${project.artifactId}</finalName>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
@ -0,0 +1,12 @@
|
||||
package com.arm.equipment.system.admin.controller;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* 接口的基础类
|
||||
* @author admin
|
||||
*/
|
||||
public abstract class BaseController{
|
||||
protected Logger logger = LoggerFactory.getLogger(this.getClass());
|
||||
}
|
@ -0,0 +1,131 @@
|
||||
package com.arm.equipment.system.admin.controller;
|
||||
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.arm.equipment.system.data.exception.AuthException;
|
||||
import com.arm.equipment.system.data.exception.BusinessException;
|
||||
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.Autowired;
|
||||
import org.springframework.dao.QueryTimeoutException;
|
||||
import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.validation.BindException;
|
||||
import org.springframework.validation.FieldError;
|
||||
import org.springframework.web.bind.annotation.ControllerAdvice;
|
||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import org.springframework.web.method.annotation.MethodArgumentTypeMismatchException;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.text.ParseException;
|
||||
|
||||
/**
|
||||
* 统一异常处理
|
||||
*
|
||||
* @author admin
|
||||
*/
|
||||
@ControllerAdvice
|
||||
public class ExceptionController {
|
||||
private final static Logger LOGGER = LoggerFactory.getLogger(ExceptionController.class);
|
||||
@Autowired
|
||||
private RedisTemplate redisTemplate;
|
||||
|
||||
@ExceptionHandler(value = IllegalArgumentException.class)
|
||||
@ResponseBody
|
||||
public RespJSON illegalArgumentException(HttpServletRequest req, Exception e) {
|
||||
logErrDetail(req);
|
||||
return RespJSON.returnCodeWithMessage(ReturnCode.CUSTOM_MESSAGE, "参数错误: " + e.getMessage());
|
||||
}
|
||||
|
||||
@ExceptionHandler(value = MethodArgumentTypeMismatchException.class)
|
||||
@ResponseBody
|
||||
public RespJSON methodArgumentTypeMismatchException(HttpServletRequest req, Exception e) {
|
||||
logErrDetail(req);
|
||||
String field = ((MethodArgumentTypeMismatchException) e).getName();
|
||||
String rejectedValue = ((MethodArgumentTypeMismatchException) e).getValue().toString();
|
||||
String message = "参数:" + field + "注入的值不合法:" + rejectedValue;
|
||||
LOGGER.error("入参错误", e);
|
||||
return RespJSON.returnCodeWithMessage(ReturnCode.CUSTOM_MESSAGE, message);
|
||||
}
|
||||
|
||||
@ExceptionHandler(value = BusinessException.class)
|
||||
@ResponseBody
|
||||
public RespJSON customException(HttpServletRequest req, BusinessException e) {
|
||||
//投票成功返自定义message
|
||||
if (e.getErrorCode() != null && StringUtils.isNotBlank(e.getMessage())) {
|
||||
return RespJSON.returnCustomCodeWithMessage(e.getErrorCode(), e.getMessage());
|
||||
}
|
||||
LOGGER.info("自定义异常: {}", e.getMessage());
|
||||
LOGGER.info("异常请求: {}", req.getRequestURI());
|
||||
LOGGER.info("异常参数: {}", JSON.toJSONString(req.getParameterMap()));
|
||||
return RespJSON.returnCodeWithMessage(ReturnCode.CUSTOM_MESSAGE, e.getMessage());
|
||||
}
|
||||
|
||||
@ExceptionHandler(value = AuthException.class)
|
||||
@ResponseBody
|
||||
public RespJSON authException(HttpServletRequest req, AuthException e) {
|
||||
logErrDetail(req);
|
||||
if (e.getReturnCode() != null) {
|
||||
return RespJSON.returnCode(e.getReturnCode());
|
||||
} else {
|
||||
return RespJSON.returnCode(ReturnCode.CODE_OK, e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@ExceptionHandler(value = BindException.class)
|
||||
@ResponseBody
|
||||
public RespJSON bindException(HttpServletRequest req, Exception e) {
|
||||
logErrDetail(req);
|
||||
FieldError fieldError = ((BindException) e).getBindingResult().getFieldError();
|
||||
String field = fieldError.getField();
|
||||
Object rejectedValue = fieldError.getRejectedValue();
|
||||
String message = "参数:" + field + "注入的值不合法:" + rejectedValue;
|
||||
LOGGER.error("入参错误", e);
|
||||
return RespJSON.returnCodeWithMessage(ReturnCode.CUSTOM_MESSAGE, message);
|
||||
}
|
||||
|
||||
@ExceptionHandler(value = ParseException.class)
|
||||
@ResponseBody
|
||||
public RespJSON parseException(HttpServletRequest req, Exception e) {
|
||||
logErrDetail(req);
|
||||
return RespJSON.returnCode(ReturnCode.PARSE_ERROR);
|
||||
}
|
||||
|
||||
@ExceptionHandler(value = QueryTimeoutException.class)
|
||||
@ResponseBody
|
||||
public RespJSON queryTimeoutException(HttpServletRequest req, Exception e) {
|
||||
logErrDetail(req);
|
||||
LOGGER.error(e.getMessage(), e);
|
||||
((LettuceConnectionFactory) redisTemplate.getConnectionFactory()).resetConnection();
|
||||
((LettuceConnectionFactory) redisTemplate.getConnectionFactory()).afterPropertiesSet();
|
||||
LOGGER.info("reset redis connection");
|
||||
return RespJSON.returnCode(ReturnCode.SYS_ERROR);
|
||||
}
|
||||
|
||||
// @ExceptionHandler(value = MethodNotSupportedException.class)
|
||||
// @ResponseBody
|
||||
// public RespJSON httpRequestMethodNotSupportedException(HttpServletRequest req, Exception e) {
|
||||
// logErrDetail(req);
|
||||
// return RespJSON.genJsonResultWithMsgData(ReturnCode.CUSTOM_MESSAGE, "请求方式不支持!");
|
||||
// }
|
||||
|
||||
@ExceptionHandler(value = Exception.class)
|
||||
@ResponseBody
|
||||
public RespJSON defaultErrorHandler(HttpServletRequest req, Exception e) {
|
||||
logErrDetail(req);
|
||||
LOGGER.error(e.getMessage(), e);
|
||||
return RespJSON.returnCode(ReturnCode.SYS_ERROR);
|
||||
}
|
||||
|
||||
|
||||
private void logErrDetail(HttpServletRequest req) {
|
||||
LOGGER.error("异常请求: " + req.getRequestURI());
|
||||
LOGGER.error("异常参数: " + JSON.toJSONString(req.getParameterMap()));
|
||||
LOGGER.error("异常UA: {}", req.getHeader("user-agent"));
|
||||
LOGGER.error("异常referer: {}", req.getHeader("referer"));
|
||||
}
|
||||
}
|
@ -0,0 +1,132 @@
|
||||
package com.arm.equipment.system.admin.controller.system;
|
||||
|
||||
import com.arm.equipment.system.admin.controller.BaseController;
|
||||
import com.arm.equipment.system.admin.util.CurrentUserUtils;
|
||||
import com.arm.equipment.system.data.domain.PageResult;
|
||||
import com.arm.equipment.system.data.domain.system.SysBaseParam;
|
||||
import com.arm.equipment.system.data.domain.system.SysUser;
|
||||
import com.arm.equipment.system.data.service.system.ISysBaseParamService;
|
||||
import com.arm.equipment.system.data.util.WJAssert;
|
||||
import com.arm.equipment.system.data.vo.RespJSON;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 系统--基础参数
|
||||
*
|
||||
* @author Administrator
|
||||
* @date 2021年10月26日 16:36:52
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/system/sysBaseParam")
|
||||
public class SysBaseParamController extends BaseController {
|
||||
|
||||
@Autowired
|
||||
private ISysBaseParamService sysBaseParamService;
|
||||
|
||||
/**
|
||||
* 保存或更新
|
||||
*
|
||||
* @param sysBaseParamReq sysBaseParamReq
|
||||
* @return RespJSON
|
||||
*/
|
||||
@PostMapping("/save")
|
||||
public RespJSON save(@RequestBody SysBaseParam sysBaseParamReq, @SessionAttribute(CurrentUserUtils.SYSTEM_USER) SysUser loginSysUser) {
|
||||
sysBaseParamService.save(sysBaseParamReq, loginSysUser.getUsername());
|
||||
return RespJSON.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*
|
||||
* @param sysBaseParamReq sysBaseParamReq
|
||||
* @return RespJSON
|
||||
*/
|
||||
@PostMapping("/getPageList")
|
||||
public RespJSON getPageList(@RequestBody SysBaseParam sysBaseParamReq) {
|
||||
int count = sysBaseParamService.getCount(sysBaseParamReq);
|
||||
List<SysBaseParam> list = new ArrayList<>();
|
||||
if (count > 0) {
|
||||
list = sysBaseParamService.getPageList(sysBaseParamReq);
|
||||
}
|
||||
PageResult result = new PageResult(sysBaseParamReq.getPageNo(), sysBaseParamReq.getPageSize(), count, list);
|
||||
return RespJSON.success(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 主键查询
|
||||
*
|
||||
* @param id id
|
||||
* @return RespJSON
|
||||
*/
|
||||
@RequestMapping("/getOneById")
|
||||
public RespJSON getOneById(Long id) {
|
||||
return RespJSON.success(sysBaseParamService.getOneById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 审核
|
||||
*
|
||||
* @param id id
|
||||
* @return RespJSON
|
||||
*/
|
||||
@PostMapping("/audit")
|
||||
@ResponseBody
|
||||
public RespJSON audit(Long id, @SessionAttribute(CurrentUserUtils.SYSTEM_USER) SysUser loginSysUser) {
|
||||
WJAssert.notNull(id, "ID 不合法");
|
||||
sysBaseParamService.audit(id, loginSysUser.getUsername());
|
||||
return RespJSON.success();
|
||||
}
|
||||
|
||||
@PostMapping("/delete")
|
||||
public RespJSON delete(Long id, @SessionAttribute(CurrentUserUtils.SYSTEM_USER) SysUser loginSysUser) {
|
||||
WJAssert.notNull(id, "ID 不合法");
|
||||
sysBaseParamService.delete(id, loginSysUser.getUsername());
|
||||
return RespJSON.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 取消审核
|
||||
*
|
||||
* @param id id
|
||||
* @return RespJSON
|
||||
*/
|
||||
@PostMapping("/unaudit")
|
||||
@ResponseBody
|
||||
public RespJSON unaudit(Long id, @SessionAttribute(CurrentUserUtils.SYSTEM_USER) SysUser loginSysUser) {
|
||||
WJAssert.notNull(id, "ID 不合法");
|
||||
sysBaseParamService.unaudit(id, loginSysUser.getUsername());
|
||||
return RespJSON.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过code查value
|
||||
*
|
||||
* @param unicode
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/selectValueByUnicode")
|
||||
public RespJSON selectValueByUnicode(String unicode) {
|
||||
WJAssert.isMaxLength(unicode, 33, "参数非法");
|
||||
String value = sysBaseParamService.getOneByUniCode(unicode).getValue();
|
||||
return RespJSON.success(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过code设置value
|
||||
*
|
||||
* @param sysBaseParamReq
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/setValueByUnicode")
|
||||
public RespJSON setValueByUnicode(@RequestBody SysBaseParam sysBaseParamReq) {
|
||||
WJAssert.notNull(sysBaseParamReq.getUniCode(), "参数非法");
|
||||
WJAssert.notNull(sysBaseParamReq.getValue(), "参数值非法");
|
||||
SysBaseParam sysBaseParamDB = sysBaseParamService.getOneByUniCode(sysBaseParamReq.getUniCode());
|
||||
sysBaseParamDB.setValue(sysBaseParamReq.getValue());
|
||||
return RespJSON.success(sysBaseParamService.updateSelectiveById(sysBaseParamDB));
|
||||
}
|
||||
}
|
@ -0,0 +1,98 @@
|
||||
package com.arm.equipment.system.admin.controller.system;
|
||||
|
||||
import com.arm.equipment.system.admin.controller.BaseController;
|
||||
import com.arm.equipment.system.admin.util.CurrentUserUtils;
|
||||
import com.arm.equipment.system.data.domain.PageResult;
|
||||
import com.arm.equipment.system.data.domain.system.SysLog;
|
||||
import com.arm.equipment.system.data.domain.system.SysUser;
|
||||
import com.arm.equipment.system.data.service.system.ISysLogService;
|
||||
import com.arm.equipment.system.data.util.WJAssert;
|
||||
import com.arm.equipment.system.data.vo.RespJSON;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 日志表
|
||||
*
|
||||
* @author admin
|
||||
* @date 2022年09月16日 12:41:35
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/system/sysLog")
|
||||
public class SysLogController extends BaseController {
|
||||
|
||||
@Autowired
|
||||
private ISysLogService sysLogService;
|
||||
|
||||
/**
|
||||
* 保存或更新
|
||||
*
|
||||
* @param sysLogReq sysLogReq
|
||||
* @return RespJSON
|
||||
*/
|
||||
@PostMapping("/save")
|
||||
public RespJSON save(@RequestBody SysLog sysLogReq, @SessionAttribute(CurrentUserUtils.SYSTEM_USER) SysUser loginSysUser) {
|
||||
sysLogService.save(sysLogReq, loginSysUser.getUsername());
|
||||
return RespJSON.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*
|
||||
* @param sysLogReq sysLogReq
|
||||
* @return RespJSON
|
||||
*/
|
||||
@PostMapping("/getPageList")
|
||||
public RespJSON getPageList(@RequestBody SysLog sysLogReq) {
|
||||
int count = sysLogService.getCount(sysLogReq);
|
||||
List<SysLog> list = new ArrayList<>();
|
||||
if (count > 0) {
|
||||
list = sysLogService.getPageList(sysLogReq);
|
||||
}
|
||||
PageResult result = new PageResult(sysLogReq.getPageNo(), sysLogReq.getPageSize(), count, list);
|
||||
return RespJSON.success(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 主键查询
|
||||
*
|
||||
* @param id id
|
||||
* @return RespJSON
|
||||
*/
|
||||
@RequestMapping("/getOneById")
|
||||
public RespJSON getOneById(Long id) {
|
||||
return RespJSON.success(sysLogService.getOneById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 审核
|
||||
*
|
||||
* @param id id
|
||||
* @return RespJSON
|
||||
*/
|
||||
@PostMapping("/audit")
|
||||
@ResponseBody
|
||||
public RespJSON audit(Long id, @SessionAttribute(CurrentUserUtils.SYSTEM_USER) SysUser loginSysUser) {
|
||||
WJAssert.notNull(id, "ID 不合法");
|
||||
sysLogService.audit(id, loginSysUser.getUsername());
|
||||
return RespJSON.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 取消审核
|
||||
*
|
||||
* @param id id
|
||||
* @return RespJSON
|
||||
*/
|
||||
@PostMapping("/unaudit")
|
||||
@ResponseBody
|
||||
public RespJSON unaudit(Long id, @SessionAttribute(CurrentUserUtils.SYSTEM_USER) SysUser loginSysUser) {
|
||||
WJAssert.notNull(id, "ID 不合法");
|
||||
sysLogService.unaudit(id, loginSysUser.getUsername());
|
||||
return RespJSON.success();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,97 @@
|
||||
package com.arm.equipment.system.admin.controller.system;
|
||||
|
||||
import com.arm.equipment.system.admin.util.CurrentUserUtils;
|
||||
import com.arm.equipment.system.admin.controller.BaseController;
|
||||
import com.arm.equipment.system.data.domain.PageResult;
|
||||
import com.arm.equipment.system.data.vo.RespJSON;
|
||||
import com.arm.equipment.system.data.domain.system.SysUser;
|
||||
import com.arm.equipment.system.data.domain.system.SysResource;
|
||||
import com.arm.equipment.system.data.service.system.ISysResourceService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* 系统--权限表
|
||||
*
|
||||
* @author admin
|
||||
* @date 2021年10月19日 15:06:30
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/system/sysResource")
|
||||
public class SysResourceController extends BaseController {
|
||||
|
||||
@Autowired
|
||||
private ISysResourceService sysResourceService;
|
||||
|
||||
/**
|
||||
* 保存或更新
|
||||
*
|
||||
* @param sysResourceReq sysResourceReq
|
||||
* @return RespJSON
|
||||
*/
|
||||
@PostMapping("/save")
|
||||
public RespJSON save(@RequestBody SysResource sysResourceReq, @SessionAttribute(CurrentUserUtils.SYSTEM_USER)SysUser loginSysUser) {
|
||||
sysResourceService.save(sysResourceReq, loginSysUser.getUsername());
|
||||
return RespJSON.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*
|
||||
* @param sysResourceReq sysResourceReq
|
||||
* @return RespJSON
|
||||
*/
|
||||
@PostMapping("/getPageList")
|
||||
public RespJSON getPageList(@RequestBody SysResource sysResourceReq) {
|
||||
int count = sysResourceService.getCount(sysResourceReq);
|
||||
List<SysResource> list = new ArrayList<>();
|
||||
if (count > 0) {
|
||||
list = sysResourceService.getPageList(sysResourceReq);
|
||||
}
|
||||
PageResult result = new PageResult(sysResourceReq.getPageNo(), sysResourceReq.getPageSize(), count, list);
|
||||
return RespJSON.success(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 目录树分页查询
|
||||
*
|
||||
* @param sysResourceReq sysResourceReq
|
||||
* @return RespJSON
|
||||
*/
|
||||
@PostMapping("/getPageTreeList")
|
||||
public RespJSON getPageTreeList(@RequestBody SysResource sysResourceReq) {
|
||||
int count = sysResourceService.getCount(sysResourceReq);
|
||||
List<SysResource> list = new ArrayList<>();
|
||||
if (count > 0) {
|
||||
list = sysResourceService.getPageTreeList(sysResourceReq);
|
||||
}
|
||||
PageResult result = new PageResult(sysResourceReq.getPageNo(), sysResourceReq.getPageSize(), count, list);
|
||||
return RespJSON.success(result);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 主键查询
|
||||
*
|
||||
* @param id id
|
||||
* @return RespJSON
|
||||
*/
|
||||
@RequestMapping("/getOneById")
|
||||
public RespJSON getOneById(Long id) {
|
||||
return RespJSON.success(sysResourceService.getOneById(id));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*获取资源树
|
||||
*
|
||||
* @return RespJSON
|
||||
*/
|
||||
@RequestMapping("/getResourceTree")
|
||||
public RespJSON getResourceTree() {
|
||||
return RespJSON.success(sysResourceService.getResourceTree());
|
||||
}
|
||||
}
|
@ -0,0 +1,99 @@
|
||||
package com.arm.equipment.system.admin.controller.system;
|
||||
|
||||
import com.arm.equipment.system.admin.util.CurrentUserUtils;
|
||||
import com.arm.equipment.system.admin.controller.BaseController;
|
||||
import com.arm.equipment.system.data.domain.PageResult;
|
||||
import com.arm.equipment.system.data.domain.system.SysRole;
|
||||
import com.arm.equipment.system.data.domain.system.SysUser;
|
||||
import com.arm.equipment.system.data.enums.dict.EnumStatus;
|
||||
import com.arm.equipment.system.data.service.system.ISysRoleService;
|
||||
import com.arm.equipment.system.data.vo.RespJSON;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 系统--角色表
|
||||
*
|
||||
* @author admin
|
||||
* @date 2021年10月19日 15:06:47
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/system/sysRole")
|
||||
public class SysRoleController extends BaseController {
|
||||
|
||||
@Autowired
|
||||
private ISysRoleService sysRoleService;
|
||||
|
||||
/**
|
||||
* 保存或更新
|
||||
*
|
||||
* @param sysRoleReq sysRoleReq
|
||||
* @return RespJSON
|
||||
*/
|
||||
@PostMapping("/save")
|
||||
public RespJSON save(@RequestBody SysRole sysRoleReq, @SessionAttribute(CurrentUserUtils.SYSTEM_USER) SysUser loginSysUser) {
|
||||
sysRoleService.save(sysRoleReq, loginSysUser.getUsername());
|
||||
return RespJSON.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*
|
||||
* @param sysRoleReq sysRoleReq
|
||||
* @return RespJSON
|
||||
*/
|
||||
@PostMapping("/getPageList")
|
||||
public RespJSON getPageList(@RequestBody SysRole sysRoleReq) {
|
||||
sysRoleReq.setStatus(EnumStatus.NEW.getCode());
|
||||
int count = sysRoleService.getCount(sysRoleReq);
|
||||
List<SysRole> list = new ArrayList<>();
|
||||
if (count > 0) {
|
||||
list = sysRoleService.getPageList(sysRoleReq);
|
||||
}
|
||||
PageResult result = new PageResult(sysRoleReq.getPageNo(), sysRoleReq.getPageSize(), count, list);
|
||||
return RespJSON.success(result);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 删除角色
|
||||
*
|
||||
* @param id
|
||||
* @param loginSysUser
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/delete")
|
||||
public RespJSON delete(Long id, @SessionAttribute(CurrentUserUtils.SYSTEM_USER) SysUser loginSysUser) {
|
||||
sysRoleService.delete(id, loginSysUser.getName());
|
||||
return RespJSON.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 主键查询
|
||||
*
|
||||
* @param id id
|
||||
* @return RespJSON
|
||||
*/
|
||||
@RequestMapping("/getOneById")
|
||||
public RespJSON getOneById(Long id) {
|
||||
|
||||
return RespJSON.success(sysRoleService.getOneById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户角色
|
||||
*
|
||||
* @param loginSysUser
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/getCurrentUserRole")
|
||||
public RespJSON getCurrentUserRole(@SessionAttribute(CurrentUserUtils.SYSTEM_USER) SysUser loginSysUser) {
|
||||
List<SysRole> sysRoleList = sysRoleService.getCurrentUserRole(loginSysUser.getId());
|
||||
return RespJSON.success(sysRoleList);
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,48 @@
|
||||
package com.arm.equipment.system.admin.controller.system;
|
||||
|
||||
import com.arm.equipment.system.admin.util.CurrentUserUtils;
|
||||
import com.arm.equipment.system.admin.controller.BaseController;
|
||||
import com.arm.equipment.system.data.domain.system.SysUser;
|
||||
import com.arm.equipment.system.data.service.system.ISysRoleResourceService;
|
||||
import com.arm.equipment.system.data.vo.RespJSON;
|
||||
import com.arm.equipment.system.data.vo.system.SysRoleResourceVO;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
/**
|
||||
* 系统-角色权限关联表
|
||||
*
|
||||
* @author admin
|
||||
* @date 2021年10月19日 15:06:41
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/system/sysRoleResource")
|
||||
public class SysRoleResourceController extends BaseController {
|
||||
|
||||
@Autowired
|
||||
private ISysRoleResourceService sysRoleResourceService;
|
||||
|
||||
/**
|
||||
* 添加角色按此单
|
||||
* @param roleResourceVO
|
||||
* @param loginSysUser
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/addResource")
|
||||
public RespJSON addResource(@RequestBody SysRoleResourceVO roleResourceVO, @SessionAttribute(CurrentUserUtils.SYSTEM_USER) SysUser loginSysUser) {
|
||||
sysRoleResourceService.addResource(roleResourceVO, loginSysUser.getName());
|
||||
return RespJSON.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据角色ID查询所拥有菜单权限
|
||||
*
|
||||
* @param roleResourceVO
|
||||
* @return RespJSON
|
||||
*/
|
||||
@PostMapping("/getResourcesIdListByRoleId")
|
||||
public RespJSON getResourcesIdListByRoleId(@RequestBody SysRoleResourceVO roleResourceVO) {
|
||||
return RespJSON.success(sysRoleResourceService.getResourcesIdListByRoleId(roleResourceVO.getRoleId()));
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,157 @@
|
||||
package com.arm.equipment.system.admin.controller.system;
|
||||
|
||||
import com.arm.equipment.system.admin.controller.BaseController;
|
||||
import com.arm.equipment.system.admin.util.CurrentUserUtils;
|
||||
import com.arm.equipment.system.data.domain.PageResult;
|
||||
import com.arm.equipment.system.data.domain.system.*;
|
||||
import com.arm.equipment.system.data.service.system.*;
|
||||
import com.arm.equipment.system.data.util.WJAssert;
|
||||
import com.arm.equipment.system.data.vo.RespJSON;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpSession;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 系统--用户表
|
||||
*
|
||||
* @author admin
|
||||
* @date 2021年10月19日 15:07:06
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/system/sysUser")
|
||||
public class SysUserController extends BaseController {
|
||||
|
||||
@Autowired
|
||||
private ISysUserService sysUserService;
|
||||
@Autowired
|
||||
private ISysRoleService sysRoleService;
|
||||
@Autowired
|
||||
private ISysRoleResourceService roleResourceService;
|
||||
|
||||
/**
|
||||
* 保存或更新
|
||||
*
|
||||
* @param sysUserReq sysUserReq
|
||||
* @return RespJSON
|
||||
*/
|
||||
@PostMapping("/save")
|
||||
public RespJSON save(@RequestBody SysUser sysUserReq, @SessionAttribute(CurrentUserUtils.SYSTEM_USER) SysUser loginSysUser) {
|
||||
sysUserService.save(sysUserReq, loginSysUser.getUsername());
|
||||
return RespJSON.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*
|
||||
* @param sysUserReq sysUserReq
|
||||
* @return RespJSON
|
||||
*/
|
||||
@PostMapping("/getPageList")
|
||||
public RespJSON getPageList(@RequestBody SysUser sysUserReq) {
|
||||
int count = sysUserService.getCount(sysUserReq);
|
||||
List<SysUser> list = new ArrayList<>();
|
||||
if (count > 0) {
|
||||
list = sysUserService.getPageList(sysUserReq);
|
||||
}
|
||||
PageResult result = new PageResult(sysUserReq.getPageNo(), sysUserReq.getPageSize(), count, list);
|
||||
return RespJSON.success(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 主键查询
|
||||
*
|
||||
* @param id id
|
||||
* @return RespJSON
|
||||
*/
|
||||
@RequestMapping("/getOneById")
|
||||
public RespJSON getOneById(Long id) {
|
||||
return RespJSON.success(sysUserService.getOneById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 主键查询
|
||||
*
|
||||
* @param id id
|
||||
* @return RespJSON
|
||||
*/
|
||||
@PostMapping("/delete")
|
||||
public RespJSON delete(Long id, @SessionAttribute(CurrentUserUtils.SYSTEM_USER) SysUser loginSysUser) {
|
||||
sysUserService.delete(id, loginSysUser.getUsername());
|
||||
return RespJSON.success();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 登陆
|
||||
* <p>
|
||||
* param username 用户名
|
||||
* param password 密码
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/login")
|
||||
public RespJSON login(@RequestBody SysUser sysUser, HttpSession webSession) {
|
||||
SysUser sysUserDB = sysUserService.login(sysUser, webSession);
|
||||
webSession.setAttribute(CurrentUserUtils.SYSTEM_USER, sysUserDB);
|
||||
return RespJSON.success(webSession.getId());
|
||||
}
|
||||
|
||||
/**
|
||||
* 注销
|
||||
*
|
||||
* @param webSession
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/logout")
|
||||
public RespJSON logout(HttpSession webSession) {
|
||||
webSession.removeAttribute(CurrentUserUtils.SYSTEM_USER);
|
||||
return RespJSON.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前用户信息
|
||||
*
|
||||
* @param loginSysUser
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/getCurrentUser")
|
||||
public RespJSON getCurrentUserAndRole(@SessionAttribute(CurrentUserUtils.SYSTEM_USER) SysUser loginSysUser) {
|
||||
List<SysRole> currentUserRole = sysRoleService.getCurrentUserRole(loginSysUser.getId());
|
||||
|
||||
loginSysUser.setSysRoleList(currentUserRole);
|
||||
List<String> sysResourceIdentityList = new ArrayList<>();
|
||||
List<SysResource> sysResourceList = new ArrayList<>();
|
||||
|
||||
roleResourceService.buildUserResourceListAndIdentityList(currentUserRole, sysResourceList, sysResourceIdentityList);
|
||||
if (CollectionUtils.isEmpty(currentUserRole)) {
|
||||
currentUserRole = new ArrayList<>();
|
||||
SysRole sysRole = new SysRole();
|
||||
sysRole.setName("首页");
|
||||
currentUserRole.add(sysRole);
|
||||
loginSysUser.setSysRoleList(currentUserRole);
|
||||
}
|
||||
loginSysUser.setSysResourceList(sysResourceList);
|
||||
loginSysUser.setSysResourceIdentityList(sysResourceIdentityList);
|
||||
return RespJSON.success(loginSysUser);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改密码
|
||||
*
|
||||
* @param oldPassword
|
||||
* @param newPassword
|
||||
* @param loginSysUser
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/updatePassword")
|
||||
public RespJSON login(String oldPassword, String newPassword, @SessionAttribute(CurrentUserUtils.SYSTEM_USER) SysUser loginSysUser) {
|
||||
WJAssert.isMaxLength(oldPassword, 32, "旧密码错误");
|
||||
WJAssert.isMaxLength(newPassword, 32, "新密码错误");
|
||||
sysUserService.updatePassword(oldPassword, newPassword, loginSysUser.getId());
|
||||
return RespJSON.success();
|
||||
}
|
||||
}
|
@ -0,0 +1,105 @@
|
||||
package com.arm.equipment.system.admin.controller.system;
|
||||
|
||||
import com.arm.equipment.system.admin.util.CurrentUserUtils;
|
||||
import com.arm.equipment.system.admin.controller.BaseController;
|
||||
import com.arm.equipment.system.data.domain.PageResult;
|
||||
import com.arm.equipment.system.data.domain.system.SysUser;
|
||||
import com.arm.equipment.system.data.domain.system.SysUserRole;
|
||||
import com.arm.equipment.system.data.service.system.ISysUserRoleService;
|
||||
import com.arm.equipment.system.data.service.system.ISysUserService;
|
||||
import com.arm.equipment.system.data.vo.RespJSON;
|
||||
import com.arm.equipment.system.data.vo.system.AddRoleVO;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 系统--用户角色关联表
|
||||
*
|
||||
* @author admin
|
||||
* @date 2021年10月19日 15:06:59
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/system/sysUserRole")
|
||||
public class SysUserRoleController extends BaseController {
|
||||
|
||||
@Autowired
|
||||
private ISysUserRoleService sysUserRoleService;
|
||||
@Autowired
|
||||
private ISysUserService sysUserService;
|
||||
|
||||
|
||||
/**
|
||||
* 保存或更新
|
||||
*
|
||||
* @param sysUserRoleReq sysUserRoleReq
|
||||
* @return RespJSON
|
||||
*/
|
||||
@PostMapping("/save")
|
||||
public RespJSON save(@RequestBody SysUserRole sysUserRoleReq, @SessionAttribute(CurrentUserUtils.SYSTEM_USER) SysUser loginSysUser) {
|
||||
sysUserRoleService.save(sysUserRoleReq, loginSysUser.getOperator());
|
||||
return RespJSON.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*
|
||||
* @param sysUserRoleReq sysUserRoleReq
|
||||
* @return RespJSON
|
||||
*/
|
||||
@PostMapping("/getPageList")
|
||||
public RespJSON getPageList(@RequestBody SysUserRole sysUserRoleReq) {
|
||||
int count = sysUserRoleService.getCount(sysUserRoleReq);
|
||||
List<SysUserRole> list = new ArrayList<>();
|
||||
if (count > 0) {
|
||||
list = sysUserRoleService.getPageList(sysUserRoleReq);
|
||||
}
|
||||
PageResult result = new PageResult(sysUserRoleReq.getPageNo(), sysUserRoleReq.getPageSize(), count, list);
|
||||
return RespJSON.success(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 主键查询
|
||||
*
|
||||
* @param id id
|
||||
* @return RespJSON
|
||||
*/
|
||||
@RequestMapping("/getOneById")
|
||||
public RespJSON getOneById(Long id) {
|
||||
return RespJSON.success(sysUserRoleService.getOneById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 为用户分配角色
|
||||
*
|
||||
* @param addRoleVO
|
||||
* @param loginSysUser
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/addRole")
|
||||
public RespJSON addRole(@RequestBody AddRoleVO addRoleVO, @SessionAttribute(CurrentUserUtils.SYSTEM_USER) SysUser loginSysUser) {
|
||||
sysUserRoleService.addRole(addRoleVO, loginSysUser);
|
||||
return RespJSON.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表查询
|
||||
*
|
||||
* @param sysUserRoleReq
|
||||
* @param loginSysUser
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/getList")
|
||||
public RespJSON addRole(@RequestBody SysUserRole sysUserRoleReq, @SessionAttribute(CurrentUserUtils.SYSTEM_USER) SysUser loginSysUser) {
|
||||
List<SysUser> sysUserList = sysUserRoleService.getList(sysUserRoleReq).stream().map(item -> {
|
||||
return sysUserService.getExitOneById(item.getSysUserId());
|
||||
}).collect(Collectors.toList());
|
||||
sysUserList.removeAll(Collections.singleton(null));
|
||||
return RespJSON.success(sysUserList);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,98 @@
|
||||
package com.arm.equipment.system.admin.controller.user;
|
||||
|
||||
import com.arm.equipment.system.admin.controller.BaseController;
|
||||
import com.arm.equipment.system.admin.util.CurrentUserUtils;
|
||||
import com.arm.equipment.system.data.domain.PageResult;
|
||||
import com.arm.equipment.system.data.vo.RespJSON;
|
||||
import com.arm.equipment.system.data.domain.system.SysUser;
|
||||
import com.arm.equipment.system.data.util.WJAssert;
|
||||
import com.arm.equipment.system.data.domain.user.AppUser;
|
||||
import com.arm.equipment.system.data.service.user.IAppUserService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* APP用户
|
||||
*
|
||||
* @author admin
|
||||
* @date 2023年03月13日 22:34:47
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/user/appUser")
|
||||
public class AppUserController extends BaseController {
|
||||
|
||||
@Autowired
|
||||
private IAppUserService appUserService;
|
||||
|
||||
/**
|
||||
* 保存或更新
|
||||
*
|
||||
* @param appUserReq appUserReq
|
||||
* @return RespJSON
|
||||
*/
|
||||
@PostMapping("/save")
|
||||
public RespJSON save(@RequestBody AppUser appUserReq, @SessionAttribute(CurrentUserUtils.SYSTEM_USER)SysUser loginSysUser) {
|
||||
appUserService.save(appUserReq, loginSysUser.getUsername());
|
||||
return RespJSON.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*
|
||||
* @param appUserReq appUserReq
|
||||
* @return RespJSON
|
||||
*/
|
||||
@PostMapping("/getPageList")
|
||||
public RespJSON getPageList(@RequestBody AppUser appUserReq) {
|
||||
int count = appUserService.getCount(appUserReq);
|
||||
List<AppUser> list = new ArrayList<>();
|
||||
if (count > 0) {
|
||||
list = appUserService.getPageList(appUserReq);
|
||||
}
|
||||
PageResult result = new PageResult(appUserReq.getPageNo(), appUserReq.getPageSize(), count, list);
|
||||
return RespJSON.success(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 主键查询
|
||||
*
|
||||
* @param id id
|
||||
* @return RespJSON
|
||||
*/
|
||||
@RequestMapping("/getOneById")
|
||||
public RespJSON getOneById(Long id) {
|
||||
return RespJSON.success(appUserService.getOneById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 审核
|
||||
*
|
||||
* @param id id
|
||||
* @return RespJSON
|
||||
*/
|
||||
@PostMapping("/audit")
|
||||
@ResponseBody
|
||||
public RespJSON audit(Long id, @SessionAttribute(CurrentUserUtils.SYSTEM_USER)SysUser loginSysUser) {
|
||||
WJAssert.notNull(id, "ID 不合法");
|
||||
appUserService.audit(id, loginSysUser.getUsername());
|
||||
return RespJSON.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 取消审核
|
||||
*
|
||||
* @param id id
|
||||
* @return RespJSON
|
||||
*/
|
||||
@PostMapping("/unaudit")
|
||||
@ResponseBody
|
||||
public RespJSON unaudit(Long id, @SessionAttribute(CurrentUserUtils.SYSTEM_USER)SysUser loginSysUser) {
|
||||
WJAssert.notNull(id, "ID 不合法");
|
||||
appUserService.unaudit(id, loginSysUser.getUsername());
|
||||
return RespJSON.success();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,65 @@
|
||||
package com.arm.equipment.system.admin.controller.verifycode;
|
||||
|
||||
|
||||
import com.arm.equipment.system.data.service.common.IVerifyCodeService;
|
||||
import com.arm.equipment.system.data.util.ValidCodeUtil;
|
||||
import com.arm.equipment.system.data.vo.system.VerifyCodeVO;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
import javax.servlet.ServletOutputStream;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.http.HttpSession;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* @author: admin
|
||||
* @time: 2022/9/16 14:35
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/verifycode")
|
||||
public class VerifyCodeController {
|
||||
@Autowired
|
||||
private IVerifyCodeService verifyCodeService;
|
||||
/**
|
||||
* 验证码key开头
|
||||
*/
|
||||
public final static String KEY_TOP = "verifyCode_";
|
||||
|
||||
/**
|
||||
* 生成验证码图片与存入SESSION
|
||||
*
|
||||
* @param response
|
||||
* @param webSession
|
||||
* @return
|
||||
* @throws IOException
|
||||
*/
|
||||
@ResponseBody
|
||||
@GetMapping("/getVerifyCode")
|
||||
public void getVerifyCode(HttpServletResponse response, HttpSession webSession) throws IOException {
|
||||
VerifyCodeVO verifyCode = verifyCodeService.generate(80, 28);
|
||||
String code = verifyCode.getCode();
|
||||
webSession.setAttribute(KEY_TOP + code, verifyCode);
|
||||
response.setContentType(MediaType.IMAGE_JPEG_VALUE);
|
||||
ServletOutputStream outputStream;
|
||||
try {
|
||||
outputStream = response.getOutputStream();
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException("获得响应流失败");
|
||||
}
|
||||
try {
|
||||
BufferedImage image = ValidCodeUtil.generateImg(code);
|
||||
ImageIO.write(image, "png", outputStream);
|
||||
outputStream.flush();
|
||||
outputStream.close();
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException("验证码输出到流失败");
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,98 @@
|
||||
package com.arm.equipment.system.admin.controller.weaponry;
|
||||
|
||||
import com.arm.equipment.system.admin.controller.BaseController;
|
||||
import com.arm.equipment.system.admin.util.CurrentUserUtils;
|
||||
import com.arm.equipment.system.data.domain.PageResult;
|
||||
import com.arm.equipment.system.data.domain.system.SysUser;
|
||||
import com.arm.equipment.system.data.util.WJAssert;
|
||||
import com.arm.equipment.system.data.vo.RespJSON;
|
||||
import com.arm.equipment.system.data.domain.weaponry.Weaponry;
|
||||
import com.arm.equipment.system.data.service.weaponry.IWeaponryService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* 装备武器
|
||||
*
|
||||
* @author admin
|
||||
* @date 2023年03月23日 10:29:48
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/weaponry/weaponry")
|
||||
public class WeaponryController extends BaseController {
|
||||
|
||||
@Autowired
|
||||
private IWeaponryService weaponryService;
|
||||
|
||||
/**
|
||||
* 保存或更新
|
||||
*
|
||||
* @param weaponryReq weaponryReq
|
||||
* @return RespJSON
|
||||
*/
|
||||
@PostMapping("/save")
|
||||
public RespJSON save(@RequestBody Weaponry weaponryReq, @SessionAttribute(CurrentUserUtils.SYSTEM_USER)SysUser loginSysUser) {
|
||||
weaponryService.save(weaponryReq, loginSysUser.getUsername());
|
||||
return RespJSON.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*
|
||||
* @param weaponryReq weaponryReq
|
||||
* @return RespJSON
|
||||
*/
|
||||
@PostMapping("/getPageList")
|
||||
public RespJSON getPageList(@RequestBody Weaponry weaponryReq) {
|
||||
int count = weaponryService.getCount(weaponryReq);
|
||||
List<Weaponry> list = new ArrayList<>();
|
||||
if (count > 0) {
|
||||
list = weaponryService.getPageList(weaponryReq);
|
||||
}
|
||||
PageResult result = new PageResult(weaponryReq.getPageNo(), weaponryReq.getPageSize(), count, list);
|
||||
return RespJSON.success(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 主键查询
|
||||
*
|
||||
* @param id id
|
||||
* @return RespJSON
|
||||
*/
|
||||
@RequestMapping("/getOneById")
|
||||
public RespJSON getOneById(Long id) {
|
||||
return RespJSON.success(weaponryService.getOneById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 审核
|
||||
*
|
||||
* @param id id
|
||||
* @return RespJSON
|
||||
*/
|
||||
@PostMapping("/audit")
|
||||
@ResponseBody
|
||||
public RespJSON audit(Long id, @SessionAttribute(CurrentUserUtils.SYSTEM_USER)SysUser loginSysUser) {
|
||||
WJAssert.notNull(id, "ID 不合法");
|
||||
weaponryService.audit(id, loginSysUser.getUsername());
|
||||
return RespJSON.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 取消审核
|
||||
*
|
||||
* @param id id
|
||||
* @return RespJSON
|
||||
*/
|
||||
@PostMapping("/unaudit")
|
||||
@ResponseBody
|
||||
public RespJSON unaudit(Long id, @SessionAttribute(CurrentUserUtils.SYSTEM_USER)SysUser loginSysUser) {
|
||||
WJAssert.notNull(id, "ID 不合法");
|
||||
weaponryService.unaudit(id, loginSysUser.getUsername());
|
||||
return RespJSON.success();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,98 @@
|
||||
package com.arm.equipment.system.admin.controller.weaponry;
|
||||
|
||||
import com.arm.equipment.system.admin.controller.BaseController;
|
||||
import com.arm.equipment.system.admin.util.CurrentUserUtils;
|
||||
import com.arm.equipment.system.data.domain.PageResult;
|
||||
import com.arm.equipment.system.data.domain.system.SysUser;
|
||||
import com.arm.equipment.system.data.domain.weaponry.WeaponryLendRecord;
|
||||
import com.arm.equipment.system.data.service.weaponry.IWeaponryLendRecordService;
|
||||
import com.arm.equipment.system.data.util.WJAssert;
|
||||
import com.arm.equipment.system.data.vo.RespJSON;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 装备武器借出记录
|
||||
*
|
||||
* @author admin
|
||||
* @date 2023年03月23日 09:20:19
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/weaponry/weaponryLendRecord")
|
||||
public class WeaponryLendRecordController extends BaseController {
|
||||
|
||||
@Autowired
|
||||
private IWeaponryLendRecordService weaponryLendRecordService;
|
||||
|
||||
/**
|
||||
* 保存或更新
|
||||
*
|
||||
* @param weaponryLendRecordReq weaponryLendRecordReq
|
||||
* @return RespJSON
|
||||
*/
|
||||
@PostMapping("/save")
|
||||
public RespJSON save(@RequestBody WeaponryLendRecord weaponryLendRecordReq, @SessionAttribute(CurrentUserUtils.SYSTEM_USER) SysUser loginSysUser) {
|
||||
weaponryLendRecordService.save(weaponryLendRecordReq, loginSysUser.getUsername());
|
||||
return RespJSON.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*
|
||||
* @param weaponryLendRecordReq weaponryLendRecordReq
|
||||
* @return RespJSON
|
||||
*/
|
||||
@PostMapping("/getPageList")
|
||||
public RespJSON getPageList(@RequestBody WeaponryLendRecord weaponryLendRecordReq) {
|
||||
int count = weaponryLendRecordService.getCount(weaponryLendRecordReq);
|
||||
List<WeaponryLendRecord> list = new ArrayList<>();
|
||||
if (count > 0) {
|
||||
list = weaponryLendRecordService.getPageList(weaponryLendRecordReq);
|
||||
}
|
||||
PageResult result = new PageResult(weaponryLendRecordReq.getPageNo(), weaponryLendRecordReq.getPageSize(), count, list);
|
||||
return RespJSON.success(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 主键查询
|
||||
*
|
||||
* @param id id
|
||||
* @return RespJSON
|
||||
*/
|
||||
@RequestMapping("/getOneById")
|
||||
public RespJSON getOneById(Long id) {
|
||||
return RespJSON.success(weaponryLendRecordService.getOneById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 拒绝
|
||||
*
|
||||
* @param id id
|
||||
* @return RespJSON
|
||||
*/
|
||||
@PostMapping("/refuse")
|
||||
@ResponseBody
|
||||
public RespJSON refuse(Long id, @SessionAttribute(CurrentUserUtils.SYSTEM_USER) SysUser loginSysUser) {
|
||||
WJAssert.notNull(id, "ID 不合法");
|
||||
weaponryLendRecordService.refuse(id, loginSysUser.getUsername());
|
||||
return RespJSON.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过
|
||||
*
|
||||
* @param id id
|
||||
* @return RespJSON
|
||||
*/
|
||||
@PostMapping("/adopt")
|
||||
@ResponseBody
|
||||
public RespJSON adopt(Long id, @SessionAttribute(CurrentUserUtils.SYSTEM_USER) SysUser loginSysUser) {
|
||||
WJAssert.notNull(id, "ID 不合法");
|
||||
weaponryLendRecordService.adopt(id, loginSysUser.getUsername());
|
||||
return RespJSON.success();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,98 @@
|
||||
package com.arm.equipment.system.admin.controller.weaponry;
|
||||
|
||||
import com.arm.equipment.system.admin.controller.BaseController;
|
||||
import com.arm.equipment.system.admin.util.CurrentUserUtils;
|
||||
import com.arm.equipment.system.data.domain.PageResult;
|
||||
import com.arm.equipment.system.data.domain.system.SysUser;
|
||||
import com.arm.equipment.system.data.util.WJAssert;
|
||||
import com.arm.equipment.system.data.vo.RespJSON;
|
||||
import com.arm.equipment.system.data.domain.weaponry.WeaponryReturnRecord;
|
||||
import com.arm.equipment.system.data.service.weaponry.IWeaponryReturnRecordService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* 装备武器归还记录
|
||||
*
|
||||
* @author admin
|
||||
* @date 2023年03月23日 09:20:25
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/weaponry/weaponryReturnRecord")
|
||||
public class WeaponryReturnRecordController extends BaseController {
|
||||
|
||||
@Autowired
|
||||
private IWeaponryReturnRecordService weaponryReturnRecordService;
|
||||
|
||||
/**
|
||||
* 保存或更新
|
||||
*
|
||||
* @param weaponryReturnRecordReq weaponryReturnRecordReq
|
||||
* @return RespJSON
|
||||
*/
|
||||
@PostMapping("/save")
|
||||
public RespJSON save(@RequestBody WeaponryReturnRecord weaponryReturnRecordReq, @SessionAttribute(CurrentUserUtils.SYSTEM_USER)SysUser loginSysUser) {
|
||||
weaponryReturnRecordService.save(weaponryReturnRecordReq, loginSysUser.getUsername());
|
||||
return RespJSON.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*
|
||||
* @param weaponryReturnRecordReq weaponryReturnRecordReq
|
||||
* @return RespJSON
|
||||
*/
|
||||
@PostMapping("/getPageList")
|
||||
public RespJSON getPageList(@RequestBody WeaponryReturnRecord weaponryReturnRecordReq) {
|
||||
int count = weaponryReturnRecordService.getCount(weaponryReturnRecordReq);
|
||||
List<WeaponryReturnRecord> list = new ArrayList<>();
|
||||
if (count > 0) {
|
||||
list = weaponryReturnRecordService.getPageList(weaponryReturnRecordReq);
|
||||
}
|
||||
PageResult result = new PageResult(weaponryReturnRecordReq.getPageNo(), weaponryReturnRecordReq.getPageSize(), count, list);
|
||||
return RespJSON.success(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 主键查询
|
||||
*
|
||||
* @param id id
|
||||
* @return RespJSON
|
||||
*/
|
||||
@RequestMapping("/getOneById")
|
||||
public RespJSON getOneById(Long id) {
|
||||
return RespJSON.success(weaponryReturnRecordService.getOneById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 审核
|
||||
*
|
||||
* @param id id
|
||||
* @return RespJSON
|
||||
*/
|
||||
@PostMapping("/audit")
|
||||
@ResponseBody
|
||||
public RespJSON audit(Long id, @SessionAttribute(CurrentUserUtils.SYSTEM_USER)SysUser loginSysUser) {
|
||||
WJAssert.notNull(id, "ID 不合法");
|
||||
weaponryReturnRecordService.audit(id, loginSysUser.getUsername());
|
||||
return RespJSON.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 取消审核
|
||||
*
|
||||
* @param id id
|
||||
* @return RespJSON
|
||||
*/
|
||||
@PostMapping("/unaudit")
|
||||
@ResponseBody
|
||||
public RespJSON unaudit(Long id, @SessionAttribute(CurrentUserUtils.SYSTEM_USER)SysUser loginSysUser) {
|
||||
WJAssert.notNull(id, "ID 不合法");
|
||||
weaponryReturnRecordService.unaudit(id, loginSysUser.getUsername());
|
||||
return RespJSON.success();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,93 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>com.arm.equipment.system</groupId>
|
||||
<artifactId>arm-equipment-system-parent</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
</parent>
|
||||
<artifactId>api</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<name>api</name>
|
||||
<description>接口工程</description>
|
||||
|
||||
<properties>
|
||||
<java.version>1.8</java.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.arm.equipment.system</groupId>
|
||||
<artifactId>data</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-actuator</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.session</groupId>
|
||||
<artifactId>spring-session-data-redis</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-data-redis</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>javax.servlet</groupId>
|
||||
<artifactId>javax.servlet-api</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>mysql</groupId>
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.mybatis.spring.boot</groupId>
|
||||
<artifactId>mybatis-spring-boot-starter</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-lang3</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>fastjson</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<finalName>arm-equipment-system-parent-${project.artifactId}</finalName>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
@ -0,0 +1,16 @@
|
||||
package com.arm.equipment.system.api.controller;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
|
||||
/**
|
||||
* 接口的基础类
|
||||
* @author admin
|
||||
*/
|
||||
public abstract class BaseController{
|
||||
@Autowired
|
||||
protected RedisTemplate redisTemplate;
|
||||
protected Logger logger = LoggerFactory.getLogger(this.getClass());
|
||||
}
|
@ -0,0 +1,155 @@
|
||||
package com.arm.equipment.system.api.controller;
|
||||
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.arm.equipment.system.data.constant.ConstantValues;
|
||||
import com.arm.equipment.system.data.exception.AuthException;
|
||||
import com.arm.equipment.system.data.exception.BusinessException;
|
||||
import com.arm.equipment.system.data.util.EnvUtil;
|
||||
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.beans.factory.annotation.Autowired;
|
||||
import org.springframework.dao.QueryTimeoutException;
|
||||
import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.validation.BindException;
|
||||
import org.springframework.validation.FieldError;
|
||||
import org.springframework.web.bind.annotation.ControllerAdvice;
|
||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import org.springframework.web.method.annotation.MethodArgumentTypeMismatchException;
|
||||
import org.springframework.web.server.ServerWebInputException;
|
||||
import org.springframework.web.server.UnsupportedMediaTypeStatusException;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.text.ParseException;
|
||||
|
||||
/**
|
||||
* 统一异常处理
|
||||
*
|
||||
* @author admin
|
||||
*/
|
||||
@ControllerAdvice
|
||||
public class ExceptionController {
|
||||
private final static Logger LOGGER = LoggerFactory.getLogger(ExceptionController.class);
|
||||
@Autowired
|
||||
private RedisTemplate redisTemplate;
|
||||
|
||||
@ExceptionHandler(value = IllegalArgumentException.class)
|
||||
@ResponseBody
|
||||
public RespJSON illegalArgumentException(HttpServletRequest req, Exception e) {
|
||||
if (EnvUtil.isDev()) {
|
||||
LOGGER.error("异常", e);
|
||||
} else {
|
||||
LOGGER.info("异常: {}", e.getMessage());
|
||||
}
|
||||
logErrDetail(req);
|
||||
return RespJSON.returnCodeWithMessage(ReturnCode.CUSTOM_MESSAGE, "参数错误: " + e.getMessage());
|
||||
}
|
||||
|
||||
@ExceptionHandler(value = MethodArgumentTypeMismatchException.class)
|
||||
@ResponseBody
|
||||
public RespJSON methodArgumentTypeMismatchException(HttpServletRequest req, Exception e) {
|
||||
logErrDetail(req);
|
||||
String field = ((MethodArgumentTypeMismatchException) e).getName();
|
||||
String rejectedValue = ((MethodArgumentTypeMismatchException) e).getValue().toString();
|
||||
String message = "参数:" + field + "注入的值不合法:" + rejectedValue;
|
||||
LOGGER.error("入参错误", e);
|
||||
return RespJSON.returnCodeWithMessage(ReturnCode.CUSTOM_MESSAGE, message);
|
||||
}
|
||||
|
||||
@ExceptionHandler(value = BusinessException.class)
|
||||
@ResponseBody
|
||||
public RespJSON customException(HttpServletRequest req, BusinessException e) {
|
||||
if (EnvUtil.isDev()) {
|
||||
LOGGER.error("自定义异常", e);
|
||||
} else {
|
||||
LOGGER.info("自定义异常: {}", e.getMessage());
|
||||
}
|
||||
logErrDetail(req);
|
||||
return RespJSON.returnCodeWithMessage(ReturnCode.CUSTOM_MESSAGE, e.getMessage());
|
||||
}
|
||||
|
||||
@ExceptionHandler(value = AuthException.class)
|
||||
@ResponseBody
|
||||
public RespJSON authException(HttpServletRequest req, AuthException e) {
|
||||
logErrDetail(req);
|
||||
if (e.getReturnCode() != null) {
|
||||
return RespJSON.returnCode(e.getReturnCode());
|
||||
} else {
|
||||
return RespJSON.returnCode(ReturnCode.CODE_OK, e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@ExceptionHandler(value = BindException.class)
|
||||
@ResponseBody
|
||||
public RespJSON bindException(HttpServletRequest req, Exception e) {
|
||||
logErrDetail(req);
|
||||
FieldError fieldError = ((BindException) e).getBindingResult().getFieldError();
|
||||
String field = fieldError.getField();
|
||||
Object rejectedValue = fieldError.getRejectedValue();
|
||||
String message = "参数:" + field + "注入的值不合法:" + rejectedValue;
|
||||
LOGGER.error("入参错误", e);
|
||||
return RespJSON.returnCodeWithMessage(ReturnCode.CUSTOM_MESSAGE, message);
|
||||
}
|
||||
|
||||
@ExceptionHandler(value = ParseException.class)
|
||||
@ResponseBody
|
||||
public RespJSON parseException(HttpServletRequest req, Exception e) {
|
||||
logErrDetail(req);
|
||||
return RespJSON.returnCode(ReturnCode.PARSE_ERROR);
|
||||
}
|
||||
|
||||
@ExceptionHandler(value = UnsupportedMediaTypeStatusException.class)
|
||||
@ResponseBody
|
||||
public RespJSON unsupportedMediaTypeStatusException(HttpServletRequest req, Exception e) {
|
||||
logErrDetail(req);
|
||||
return RespJSON.returnCustomCodeWithMessage(ReturnCode.SYS_ERROR.getCode(), "错误的请求格式");
|
||||
}
|
||||
|
||||
@ExceptionHandler(value = ServerWebInputException.class)
|
||||
@ResponseBody
|
||||
public RespJSON serverWebInputException(HttpServletRequest req, Exception e) {
|
||||
logErrDetail(req);
|
||||
LOGGER.error(e.getMessage(), e);
|
||||
return RespJSON.returnCodeWithMessage(ReturnCode.CUSTOM_MESSAGE, "请在body中传参");
|
||||
}
|
||||
|
||||
@ExceptionHandler(value = QueryTimeoutException.class)
|
||||
@ResponseBody
|
||||
public RespJSON queryTimeoutException(HttpServletRequest req, Exception e) {
|
||||
logErrDetail(req);
|
||||
LOGGER.error(e.getMessage(), e);
|
||||
((LettuceConnectionFactory)redisTemplate.getConnectionFactory()).initConnection();
|
||||
LOGGER.info("reset redis connection");
|
||||
return RespJSON.returnCode(ReturnCode.SYS_ERROR);
|
||||
}
|
||||
|
||||
@ExceptionHandler(value = Exception.class)
|
||||
@ResponseBody
|
||||
public RespJSON defaultErrorHandler(HttpServletRequest req, Exception e) {
|
||||
logErrDetail(req);
|
||||
LOGGER.error(e.getMessage(), e);
|
||||
return RespJSON.returnCode(ReturnCode.SYS_ERROR);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 打印异常参数等信息
|
||||
* @param req
|
||||
*/
|
||||
private void logErrDetail(HttpServletRequest req) {
|
||||
LOGGER.error("异常请求: {}", req.getRequestURI());
|
||||
LOGGER.error("异常参数: {}", JSON.toJSONString(req.getParameterMap()));
|
||||
Object requestBody = req.getAttribute(ConstantValues.REQUEST_BODY);
|
||||
if (null == requestBody) {
|
||||
requestBody = "";
|
||||
}
|
||||
LOGGER.error("异常参数: {}", requestBody.toString());
|
||||
LOGGER.error("异常UA: {}", req.getHeader("user-agent"));
|
||||
LOGGER.error("异常referer: {}", req.getHeader("referer"));
|
||||
LOGGER.error("异常Content-Type: {}", req.getHeader("Content-Type"));
|
||||
}
|
||||
}
|
@ -0,0 +1,41 @@
|
||||
package com.arm.equipment.system.api.controller.app;
|
||||
|
||||
import com.arm.equipment.system.api.controller.BaseController;
|
||||
import com.arm.equipment.system.data.domain.system.SysBaseParam;
|
||||
import com.arm.equipment.system.data.service.system.ISysBaseParamService;
|
||||
import com.arm.equipment.system.data.vo.RespJSON;
|
||||
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;
|
||||
|
||||
/**
|
||||
* 系统--基础参数
|
||||
*
|
||||
* @author: admin
|
||||
* @time: 2022/9/22 22:03
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/system/sysBaseParam")
|
||||
public class SysBaseParamAction extends BaseController {
|
||||
|
||||
@Autowired
|
||||
private ISysBaseParamService sysBaseParamService;
|
||||
|
||||
/**
|
||||
* 主键查询
|
||||
*
|
||||
* @param uniCode uniCode
|
||||
* @return RespJSON
|
||||
*/
|
||||
@RequestMapping("/getOneUniCode/{uniCode}")
|
||||
public RespJSON getOneUniCode(@PathVariable String uniCode) {
|
||||
SysBaseParam baseParamDB = sysBaseParamService.getOneByUniCode(uniCode);
|
||||
if (baseParamDB != null) {
|
||||
//不返回备注
|
||||
baseParamDB.setDescription(null);
|
||||
}
|
||||
return RespJSON.success(baseParamDB);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,54 @@
|
||||
package com.arm.equipment.system.api.controller.common;
|
||||
|
||||
|
||||
import com.arm.equipment.system.api.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:55
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/common/file")
|
||||
public class UploadAction 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("文件上传错误");
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
package com.arm.equipment.system.api.controller.dict;
|
||||
|
||||
|
||||
import com.arm.equipment.system.data.service.common.IDictService;
|
||||
import com.arm.equipment.system.data.vo.RespJSON;
|
||||
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;
|
||||
|
||||
/**
|
||||
* 字典接口
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/common/dict")
|
||||
public class DictAction {
|
||||
@Autowired
|
||||
private IDictService dictService;
|
||||
|
||||
/**
|
||||
* 统计枚举名称获得枚举的数据
|
||||
*
|
||||
* @param name
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/getDictData/{name}")
|
||||
public RespJSON getDictData(@PathVariable("name") String name) {
|
||||
return RespJSON.success(dictService.getDictData(name));
|
||||
}
|
||||
}
|
@ -0,0 +1,75 @@
|
||||
package com.arm.equipment.system.api.controller.user;
|
||||
|
||||
import com.arm.equipment.system.api.annotation.LoginCheck;
|
||||
import com.arm.equipment.system.api.controller.BaseController;
|
||||
import com.arm.equipment.system.api.util.LoginUtil;
|
||||
import com.arm.equipment.system.data.constant.RedisKeys;
|
||||
import com.arm.equipment.system.data.domain.user.AppUser;
|
||||
import com.arm.equipment.system.data.exception.BusinessException;
|
||||
import com.arm.equipment.system.data.service.user.IAppUserService;
|
||||
import com.arm.equipment.system.data.vo.RespJSON;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* 用户
|
||||
*
|
||||
* @author ousei
|
||||
* @date 2020年11月4日15:13:16
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/user/appUser")
|
||||
public class AppUserAction extends BaseController {
|
||||
@Autowired
|
||||
private IAppUserService appUserService;
|
||||
|
||||
@LoginCheck
|
||||
@PostMapping("/getUserInfo")
|
||||
public RespJSON getBaseUserInfo(@SessionAttribute(value = LoginUtil.LOGIN_USER_SESSION_KEY, required = false) AppUser loginUser, HttpServletRequest request) {
|
||||
AppUser appUserDB = Optional.ofNullable(appUserService.getOneById(loginUser.getId())).orElseThrow(() -> new BusinessException("用户不存在"));
|
||||
LoginUtil.saveInCache(appUserDB, request);
|
||||
return RespJSON.success(appUserDB);
|
||||
}
|
||||
|
||||
/**
|
||||
* 登录
|
||||
* * @return
|
||||
*/
|
||||
@PostMapping("/login")
|
||||
public RespJSON login(@RequestBody AppUser appUser, HttpServletRequest request) {
|
||||
AppUser appUserDB = appUserService.login(appUser);
|
||||
LoginUtil.saveInCache(appUserDB, request);
|
||||
return RespJSON.success(appUserDB);
|
||||
}
|
||||
|
||||
/**
|
||||
* 注册
|
||||
*
|
||||
* @param req
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/save")
|
||||
public RespJSON save(@RequestBody AppUser req) {
|
||||
appUserService.saveUser(req);
|
||||
return RespJSON.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 退出登陆
|
||||
*
|
||||
* @param loginUser
|
||||
* @return
|
||||
*/
|
||||
@LoginCheck
|
||||
@PostMapping("/logout")
|
||||
public RespJSON logout(@SessionAttribute(LoginUtil.LOGIN_USER_SESSION_KEY) AppUser loginUser) {
|
||||
// 删除登陆缓存
|
||||
redisTemplate.delete(RedisKeys.getAppUserSessionKey(loginUser.getToken()));
|
||||
return RespJSON.success();
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,58 @@
|
||||
package com.arm.equipment.system.api.controller.weaponry;
|
||||
|
||||
|
||||
import com.arm.equipment.system.api.controller.BaseController;
|
||||
import com.arm.equipment.system.data.domain.weaponry.WeaponryLendRecord;
|
||||
import com.arm.equipment.system.data.enums.dict.EnumWeaponryLendRecordStatus;
|
||||
import com.arm.equipment.system.data.service.weaponry.IWeaponryLendRecordService;
|
||||
import com.arm.equipment.system.data.util.WJAssert;
|
||||
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.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 装备武器借出表
|
||||
*
|
||||
* @author admin
|
||||
* @date 2023年03月22日 10:57:51
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/weaponry/weaponryLend")
|
||||
public class WeaponryLendRecordAction extends BaseController {
|
||||
|
||||
@Autowired
|
||||
private IWeaponryLendRecordService weaponryLendRecordService;
|
||||
|
||||
/**
|
||||
* 保存或更新
|
||||
*
|
||||
* @param weaponryLendRecord weaponryLendRecord
|
||||
* @return RespJSON
|
||||
*/
|
||||
@PostMapping("/save")
|
||||
public RespJSON save(@RequestBody WeaponryLendRecord weaponryLendRecord) {
|
||||
weaponryLendRecordService.saveLend(weaponryLendRecord);
|
||||
return RespJSON.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*
|
||||
* @param weaponryLendReq weaponryLendReq
|
||||
* @return RespJSON
|
||||
*/
|
||||
@PostMapping("/getPageList")
|
||||
public RespJSON getPageList(@RequestBody WeaponryLendRecord weaponryLendReq) {
|
||||
WJAssert.notNull(weaponryLendReq.getPageNo(), "参数非法");
|
||||
WJAssert.notNull(weaponryLendReq.getPageSize(), "参数非法");
|
||||
weaponryLendReq.setStatus(EnumWeaponryLendRecordStatus.ADOPT.getCode());
|
||||
List<WeaponryLendRecord> pageList = weaponryLendRecordService.getPageList(weaponryLendReq);
|
||||
return RespJSON.success(pageList);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
package com.arm.equipment.system.api.controller.weaponry;
|
||||
|
||||
import com.arm.equipment.system.api.controller.BaseController;
|
||||
import com.arm.equipment.system.data.service.weaponry.IWeaponryReturnRecordService;
|
||||
import com.arm.equipment.system.data.vo.RespJSON;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
/**
|
||||
* 装备武器归还日志
|
||||
*
|
||||
* @author admin
|
||||
* @date 2023年03月22日 10:42:24
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/weaponry/weaponryReturnRecord")
|
||||
public class WeaponryReturnRecordAction extends BaseController {
|
||||
|
||||
@Autowired
|
||||
private IWeaponryReturnRecordService weaponryReturnRecordService;
|
||||
|
||||
/**
|
||||
* 保存归还
|
||||
*
|
||||
* @param lendRecordId
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/save")
|
||||
public RespJSON save( Long lendRecordId) {
|
||||
weaponryReturnRecordService.saveReturn(lendRecordId);
|
||||
return RespJSON.success();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,141 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>com.arm.equipment.system</groupId>
|
||||
<artifactId>arm-equipment-system-parent</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
</parent>
|
||||
<artifactId>data</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<name>data</name>
|
||||
<description>业务公共项目</description>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
<!-- https://mvnrepository.com/artifact/org.mybatis.spring.boot/mybatis-spring-boot-starter -->
|
||||
<dependency>
|
||||
<groupId>org.mybatis.spring.boot</groupId>
|
||||
<artifactId>mybatis-spring-boot-starter</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-aop</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>mysql</groupId>
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-lang3</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>fastjson</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-data-redis</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-pool2</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.bouncycastle</groupId>
|
||||
<artifactId>bcprov-jdk16</artifactId>
|
||||
<version>1.46</version>
|
||||
</dependency>
|
||||
|
||||
<!-- 生成器依赖velocity -->
|
||||
<dependency>
|
||||
<groupId>org.apache.velocity</groupId>
|
||||
<artifactId>velocity</artifactId>
|
||||
<version>1.7</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>easyexcel</artifactId>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>commons-logging</groupId>
|
||||
<artifactId>commons-logging</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
<version>1.1.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.httpcomponents</groupId>
|
||||
<artifactId>httpmime</artifactId>
|
||||
<version>4.5.2</version>
|
||||
</dependency>
|
||||
<!-- https://mvnrepository.com/artifact/javax.validation/validation-api -->
|
||||
<dependency>
|
||||
<groupId>javax.validation</groupId>
|
||||
<artifactId>validation-api</artifactId>
|
||||
<version>2.0.1.Final</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.hibernate</groupId>
|
||||
<artifactId>hibernate-validator</artifactId>
|
||||
<version>5.2.0.Final</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-lang</groupId>
|
||||
<artifactId>commons-lang</artifactId>
|
||||
<version>2.6</version>
|
||||
</dependency>
|
||||
<!--jsoup解析html-->
|
||||
<dependency>
|
||||
<groupId>org.jsoup</groupId>
|
||||
<artifactId>jsoup</artifactId>
|
||||
<version>1.13.1</version>
|
||||
</dependency>
|
||||
<!--拼英工具类-->
|
||||
<dependency>
|
||||
<groupId>com.belerweb</groupId>
|
||||
<artifactId>pinyin4j</artifactId>
|
||||
<version>2.5.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.servlet</groupId>
|
||||
<artifactId>javax.servlet-api</artifactId>
|
||||
<version>4.0.1</version>
|
||||
</dependency>
|
||||
<!-- zxing二维码生成工具类 -->
|
||||
<dependency>
|
||||
<groupId>com.google.zxing</groupId>
|
||||
<artifactId>javase</artifactId>
|
||||
<version>3.0.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.guava</groupId>
|
||||
<artifactId>guava</artifactId>
|
||||
<version>16.0.1</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
</project>
|
@ -0,0 +1,71 @@
|
||||
package com.arm.equipment.system.data.mapper.system;
|
||||
|
||||
import com.arm.equipment.system.data.domain.system.SysBaseParam;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 系统--基础参数
|
||||
*
|
||||
* @author Administrator
|
||||
* @date 2021年10月26日 16:36:52
|
||||
*/
|
||||
public interface ISysBaseParamMapper {
|
||||
|
||||
/**
|
||||
* 插入
|
||||
*
|
||||
* @param sysBaseParam sysBaseParam
|
||||
* @return int
|
||||
*/
|
||||
int insertSelective(SysBaseParam sysBaseParam);
|
||||
|
||||
/**
|
||||
* 更新
|
||||
*
|
||||
* @param setParam setParam
|
||||
* @param whereParam whereParam
|
||||
* @return int
|
||||
*/
|
||||
int updateSelective(SysBaseParam setParam, SysBaseParam whereParam);
|
||||
|
||||
/**
|
||||
* 数量
|
||||
*
|
||||
* @param sysBaseParam sysBaseParam
|
||||
* @return int
|
||||
*/
|
||||
int getCount(SysBaseParam sysBaseParam);
|
||||
|
||||
/**
|
||||
* 单条
|
||||
*
|
||||
* @param sysBaseParam sysBaseParam
|
||||
* @return SysBaseParam
|
||||
*/
|
||||
SysBaseParam getOne(SysBaseParam sysBaseParam);
|
||||
|
||||
/**
|
||||
* 多条
|
||||
*
|
||||
* @param sysBaseParam sysBaseParam
|
||||
* @return List<SysBaseParam>
|
||||
*/
|
||||
List<SysBaseParam> getList(SysBaseParam sysBaseParam);
|
||||
|
||||
/**
|
||||
* 分页
|
||||
*
|
||||
* @param sysBaseParam sysBaseParam
|
||||
* @return List<SysBaseParam>
|
||||
*/
|
||||
List<SysBaseParam> getPageList(SysBaseParam sysBaseParam);
|
||||
|
||||
/**
|
||||
* 根据ID删除
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
int delete(String id);
|
||||
}
|
@ -0,0 +1,64 @@
|
||||
package com.arm.equipment.system.data.mapper.system;
|
||||
|
||||
import com.arm.equipment.system.data.domain.system.SysLog;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 日志表
|
||||
*
|
||||
* @author admin
|
||||
* @date 2022年09月16日 12:41:35
|
||||
*/
|
||||
public interface ISysLogMapper {
|
||||
|
||||
/**
|
||||
* 插入
|
||||
*
|
||||
* @param sysLog sysLog
|
||||
* @return int
|
||||
*/
|
||||
int insertSelective(SysLog sysLog);
|
||||
|
||||
/**
|
||||
* 更新
|
||||
*
|
||||
* @param setParam setParam
|
||||
* @param whereParam whereParam
|
||||
* @return int
|
||||
*/
|
||||
int updateSelective(SysLog setParam, SysLog whereParam);
|
||||
|
||||
/**
|
||||
* 数量
|
||||
*
|
||||
* @param sysLog sysLog
|
||||
* @return int
|
||||
*/
|
||||
int getCount(SysLog sysLog);
|
||||
|
||||
/**
|
||||
* 单条
|
||||
*
|
||||
* @param sysLog sysLog
|
||||
* @return SysLog
|
||||
*/
|
||||
SysLog getOne(SysLog sysLog);
|
||||
|
||||
/**
|
||||
* 多条
|
||||
*
|
||||
* @param sysLog sysLog
|
||||
* @return List<SysLog>
|
||||
*/
|
||||
List<SysLog> getList(SysLog sysLog);
|
||||
|
||||
/**
|
||||
* 分页
|
||||
*
|
||||
* @param sysLog sysLog
|
||||
* @return List<SysLog>
|
||||
*/
|
||||
List<SysLog> getPageList(SysLog sysLog);
|
||||
|
||||
}
|
@ -0,0 +1,63 @@
|
||||
package com.arm.equipment.system.data.mapper.system;
|
||||
|
||||
import com.arm.equipment.system.data.domain.system.SysResource;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 系统--权限表
|
||||
*
|
||||
* @author admin
|
||||
* @date 2021年10月19日 15:06:30
|
||||
*/
|
||||
public interface ISysResourceMapper {
|
||||
|
||||
/**
|
||||
* 插入
|
||||
*
|
||||
* @param sysResource sysResource
|
||||
* @return int
|
||||
*/
|
||||
int insertSelective(SysResource sysResource);
|
||||
|
||||
/**
|
||||
* 更新
|
||||
*
|
||||
* @param setParam setParam
|
||||
* @param whereParam whereParam
|
||||
* @return int
|
||||
*/
|
||||
int updateSelective(SysResource setParam, SysResource whereParam);
|
||||
|
||||
/**
|
||||
* 数量
|
||||
*
|
||||
* @param sysResource sysResource
|
||||
* @return int
|
||||
*/
|
||||
int getCount(SysResource sysResource);
|
||||
|
||||
/**
|
||||
* 单条
|
||||
*
|
||||
* @param sysResource sysResource
|
||||
* @return SysResource
|
||||
*/
|
||||
SysResource getOne(SysResource sysResource);
|
||||
|
||||
/**
|
||||
* 多条
|
||||
*
|
||||
* @param sysResource sysResource
|
||||
* @return List<SysResource>
|
||||
*/
|
||||
List<SysResource> getList(SysResource sysResource);
|
||||
|
||||
/**
|
||||
* 分页
|
||||
*
|
||||
* @param sysResource sysResource
|
||||
* @return List<SysResource>
|
||||
*/
|
||||
List<SysResource> getPageList(SysResource sysResource);
|
||||
}
|
@ -0,0 +1,64 @@
|
||||
package com.arm.equipment.system.data.mapper.system;
|
||||
|
||||
import com.arm.equipment.system.data.domain.system.SysRole;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 系统--角色表
|
||||
*
|
||||
* @author admin
|
||||
* @date 2021年10月19日 15:06:47
|
||||
*/
|
||||
public interface ISysRoleMapper {
|
||||
|
||||
/**
|
||||
* 插入
|
||||
*
|
||||
* @param sysRole sysRole
|
||||
* @return int
|
||||
*/
|
||||
int insertSelective(SysRole sysRole);
|
||||
|
||||
/**
|
||||
* 更新
|
||||
*
|
||||
* @param setParam setParam
|
||||
* @param whereParam whereParam
|
||||
* @return int
|
||||
*/
|
||||
int updateSelective(SysRole setParam, SysRole whereParam);
|
||||
|
||||
/**
|
||||
* 数量
|
||||
*
|
||||
* @param sysRole sysRole
|
||||
* @return int
|
||||
*/
|
||||
int getCount(SysRole sysRole);
|
||||
|
||||
/**
|
||||
* 单条
|
||||
*
|
||||
* @param sysRole sysRole
|
||||
* @return SysRole
|
||||
*/
|
||||
SysRole getOne(SysRole sysRole);
|
||||
|
||||
/**
|
||||
* 多条
|
||||
*
|
||||
* @param sysRole sysRole
|
||||
* @return List<SysRole>
|
||||
*/
|
||||
List<SysRole> getList(SysRole sysRole);
|
||||
|
||||
/**
|
||||
* 分页
|
||||
*
|
||||
* @param sysRole sysRole
|
||||
* @return List<SysRole>
|
||||
*/
|
||||
List<SysRole> getPageList(SysRole sysRole);
|
||||
|
||||
}
|
@ -0,0 +1,82 @@
|
||||
package com.arm.equipment.system.data.mapper.system;
|
||||
|
||||
import com.arm.equipment.system.data.domain.system.SysRoleResource;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 系统-角色权限关联表
|
||||
*
|
||||
* @author admin
|
||||
* @date 2021年10月19日 15:06:41
|
||||
*/
|
||||
public interface ISysRoleResourceMapper {
|
||||
|
||||
/**
|
||||
* 插入
|
||||
*
|
||||
* @param sysRoleResource sysRoleResource
|
||||
* @return int
|
||||
*/
|
||||
int insertSelective(SysRoleResource sysRoleResource);
|
||||
|
||||
/**
|
||||
* 更新
|
||||
*
|
||||
* @param setParam setParam
|
||||
* @param whereParam whereParam
|
||||
* @return int
|
||||
*/
|
||||
int updateSelective(SysRoleResource setParam, SysRoleResource whereParam);
|
||||
|
||||
/**
|
||||
* 数量
|
||||
*
|
||||
* @param sysRoleResource sysRoleResource
|
||||
* @return int
|
||||
*/
|
||||
int getCount(SysRoleResource sysRoleResource);
|
||||
|
||||
/**
|
||||
* 单条
|
||||
*
|
||||
* @param sysRoleResource sysRoleResource
|
||||
* @return SysRoleResource
|
||||
*/
|
||||
SysRoleResource getOne(SysRoleResource sysRoleResource);
|
||||
|
||||
/**
|
||||
* 多条
|
||||
*
|
||||
* @param sysRoleResource sysRoleResource
|
||||
* @return List<SysRoleResource>
|
||||
*/
|
||||
List<SysRoleResource> getList(SysRoleResource sysRoleResource);
|
||||
|
||||
/**
|
||||
* 分页
|
||||
*
|
||||
* @param sysRoleResource sysRoleResource
|
||||
* @return List<SysRoleResource>
|
||||
*/
|
||||
List<SysRoleResource> getPageList(SysRoleResource sysRoleResource);
|
||||
|
||||
/**
|
||||
* 获取权限ID in数据
|
||||
* @param sysUserRoleIdList
|
||||
* @return
|
||||
*/
|
||||
List<SysRoleResource> getListBySysRoleIdIn(List<Long> sysUserRoleIdList);
|
||||
|
||||
/**
|
||||
* 根据权限ID删除
|
||||
* @param roleId
|
||||
*/
|
||||
void deleteByRoleId(Long roleId);
|
||||
|
||||
/**
|
||||
* 批量添加
|
||||
* @param list
|
||||
*/
|
||||
void batchInsert(List<SysRoleResource> list);
|
||||
}
|
@ -0,0 +1,64 @@
|
||||
package com.arm.equipment.system.data.mapper.system;
|
||||
|
||||
import com.arm.equipment.system.data.domain.system.SysUser;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 系统--用户表
|
||||
*
|
||||
* @author admin
|
||||
* @date 2021年10月19日 15:07:06
|
||||
*/
|
||||
public interface ISysUserMapper {
|
||||
|
||||
/**
|
||||
* 插入
|
||||
*
|
||||
* @param sysUser sysUser
|
||||
* @return int
|
||||
*/
|
||||
int insertSelective(SysUser sysUser);
|
||||
|
||||
/**
|
||||
* 更新
|
||||
*
|
||||
* @param setParam setParam
|
||||
* @param whereParam whereParam
|
||||
* @return int
|
||||
*/
|
||||
int updateSelective(SysUser setParam, SysUser whereParam);
|
||||
|
||||
/**
|
||||
* 数量
|
||||
*
|
||||
* @param sysUser sysUser
|
||||
* @return int
|
||||
*/
|
||||
int getCount(SysUser sysUser);
|
||||
|
||||
/**
|
||||
* 单条
|
||||
*
|
||||
* @param sysUser sysUser
|
||||
* @return SysUser
|
||||
*/
|
||||
SysUser getOne(SysUser sysUser);
|
||||
|
||||
/**
|
||||
* 多条
|
||||
*
|
||||
* @param sysUser sysUser
|
||||
* @return List<SysUser>
|
||||
*/
|
||||
List<SysUser> getList(SysUser sysUser);
|
||||
|
||||
/**
|
||||
* 分页
|
||||
*
|
||||
* @param sysUser sysUser
|
||||
* @return List<SysUser>
|
||||
*/
|
||||
List<SysUser> getPageList(SysUser sysUser);
|
||||
|
||||
}
|
@ -0,0 +1,80 @@
|
||||
package com.arm.equipment.system.data.mapper.system;
|
||||
|
||||
import com.arm.equipment.system.data.domain.system.SysUserRole;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 系统--用户角色关联表
|
||||
*
|
||||
* @author admin
|
||||
* @date 2021年10月19日 15:06:59
|
||||
*/
|
||||
public interface ISysUserRoleMapper {
|
||||
|
||||
/**
|
||||
* 插入
|
||||
*
|
||||
* @param sysUserRole sysUserRole
|
||||
* @return int
|
||||
*/
|
||||
int insertSelective(SysUserRole sysUserRole);
|
||||
|
||||
/**
|
||||
* 更新
|
||||
*
|
||||
* @param setParam setParam
|
||||
* @param whereParam whereParam
|
||||
* @return int
|
||||
*/
|
||||
int updateSelective(SysUserRole setParam, SysUserRole whereParam);
|
||||
|
||||
/**
|
||||
* 数量
|
||||
*
|
||||
* @param sysUserRole sysUserRole
|
||||
* @return int
|
||||
*/
|
||||
int getCount(SysUserRole sysUserRole);
|
||||
|
||||
/**
|
||||
* 单条
|
||||
*
|
||||
* @param sysUserRole sysUserRole
|
||||
* @return SysUserRole
|
||||
*/
|
||||
SysUserRole getOne(SysUserRole sysUserRole);
|
||||
|
||||
/**
|
||||
* 多条
|
||||
*
|
||||
* @param sysUserRole sysUserRole
|
||||
* @return List<SysUserRole>
|
||||
*/
|
||||
List<SysUserRole> getList(SysUserRole sysUserRole);
|
||||
|
||||
/**
|
||||
* 分页
|
||||
*
|
||||
* @param sysUserRole sysUserRole
|
||||
* @return List<SysUserRole>
|
||||
*/
|
||||
List<SysUserRole> getPageList(SysUserRole sysUserRole);
|
||||
|
||||
/**
|
||||
* 根据用户ID删除用户角色
|
||||
*
|
||||
* @param userId
|
||||
*/
|
||||
void deleteByUserId(Long userId);
|
||||
|
||||
/**
|
||||
* 为用户批量添加角色
|
||||
*
|
||||
* @param newRole
|
||||
* @param userId
|
||||
* @param operator
|
||||
*/
|
||||
void insertByRoleIdIn(@Param("newRole") List<String> newRole, @Param("userId") Long userId, @Param("operator") String operator);
|
||||
}
|
@ -0,0 +1,64 @@
|
||||
package com.arm.equipment.system.data.mapper.user;
|
||||
|
||||
import com.arm.equipment.system.data.domain.user.AppUser;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* APP用户
|
||||
*
|
||||
* @author admin
|
||||
* @date 2023年03月13日 22:34:47
|
||||
*/
|
||||
public interface IAppUserMapper {
|
||||
|
||||
/**
|
||||
* 插入
|
||||
*
|
||||
* @param appUser appUser
|
||||
* @return int
|
||||
*/
|
||||
int insertSelective(AppUser appUser);
|
||||
|
||||
/**
|
||||
* 更新
|
||||
*
|
||||
* @param setParam setParam
|
||||
* @param whereParam whereParam
|
||||
* @return int
|
||||
*/
|
||||
int updateSelective(AppUser setParam, AppUser whereParam);
|
||||
|
||||
/**
|
||||
* 数量
|
||||
*
|
||||
* @param appUser appUser
|
||||
* @return int
|
||||
*/
|
||||
int getCount(AppUser appUser);
|
||||
|
||||
/**
|
||||
* 单条
|
||||
*
|
||||
* @param appUser appUser
|
||||
* @return AppUser
|
||||
*/
|
||||
AppUser getOne(AppUser appUser);
|
||||
|
||||
/**
|
||||
* 多条
|
||||
*
|
||||
* @param appUser appUser
|
||||
* @return List<AppUser>
|
||||
*/
|
||||
List<AppUser> getList(AppUser appUser);
|
||||
|
||||
/**
|
||||
* 分页
|
||||
*
|
||||
* @param appUser appUser
|
||||
* @return List<AppUser>
|
||||
*/
|
||||
List<AppUser> getPageList(AppUser appUser);
|
||||
|
||||
}
|
@ -0,0 +1,64 @@
|
||||
package com.arm.equipment.system.data.mapper.weaponry;
|
||||
|
||||
import com.arm.equipment.system.data.domain.weaponry.WeaponryLendRecord;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 装备武器借出记录
|
||||
*
|
||||
* @author admin
|
||||
* @date 2023年03月23日 11:02:17
|
||||
*/
|
||||
public interface IWeaponryLendRecordMapper {
|
||||
|
||||
/**
|
||||
* 插入
|
||||
*
|
||||
* @param weaponryLendRecord weaponryLendRecord
|
||||
* @return int
|
||||
*/
|
||||
int insertSelective(WeaponryLendRecord weaponryLendRecord);
|
||||
|
||||
/**
|
||||
* 更新
|
||||
*
|
||||
* @param setParam setParam
|
||||
* @param whereParam whereParam
|
||||
* @return int
|
||||
*/
|
||||
int updateSelective(WeaponryLendRecord setParam, WeaponryLendRecord whereParam);
|
||||
|
||||
/**
|
||||
* 数量
|
||||
*
|
||||
* @param weaponryLendRecord weaponryLendRecord
|
||||
* @return int
|
||||
*/
|
||||
int getCount(WeaponryLendRecord weaponryLendRecord);
|
||||
|
||||
/**
|
||||
* 单条
|
||||
*
|
||||
* @param weaponryLendRecord weaponryLendRecord
|
||||
* @return WeaponryLendRecord
|
||||
*/
|
||||
WeaponryLendRecord getOne(WeaponryLendRecord weaponryLendRecord);
|
||||
|
||||
/**
|
||||
* 多条
|
||||
*
|
||||
* @param weaponryLendRecord weaponryLendRecord
|
||||
* @return List<WeaponryLendRecord>
|
||||
*/
|
||||
List<WeaponryLendRecord> getList(WeaponryLendRecord weaponryLendRecord);
|
||||
|
||||
/**
|
||||
* 分页
|
||||
*
|
||||
* @param weaponryLendRecord weaponryLendRecord
|
||||
* @return List<WeaponryLendRecord>
|
||||
*/
|
||||
List<WeaponryLendRecord> getPageList(WeaponryLendRecord weaponryLendRecord);
|
||||
|
||||
}
|
@ -0,0 +1,64 @@
|
||||
package com.arm.equipment.system.data.mapper.weaponry;
|
||||
|
||||
import com.arm.equipment.system.data.domain.weaponry.Weaponry;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 装备武器
|
||||
*
|
||||
* @author admin
|
||||
* @date 2023年03月23日 10:29:48
|
||||
*/
|
||||
public interface IWeaponryMapper {
|
||||
|
||||
/**
|
||||
* 插入
|
||||
*
|
||||
* @param weaponry weaponry
|
||||
* @return int
|
||||
*/
|
||||
int insertSelective(Weaponry weaponry);
|
||||
|
||||
/**
|
||||
* 更新
|
||||
*
|
||||
* @param setParam setParam
|
||||
* @param whereParam whereParam
|
||||
* @return int
|
||||
*/
|
||||
int updateSelective(Weaponry setParam, Weaponry whereParam);
|
||||
|
||||
/**
|
||||
* 数量
|
||||
*
|
||||
* @param weaponry weaponry
|
||||
* @return int
|
||||
*/
|
||||
int getCount(Weaponry weaponry);
|
||||
|
||||
/**
|
||||
* 单条
|
||||
*
|
||||
* @param weaponry weaponry
|
||||
* @return Weaponry
|
||||
*/
|
||||
Weaponry getOne(Weaponry weaponry);
|
||||
|
||||
/**
|
||||
* 多条
|
||||
*
|
||||
* @param weaponry weaponry
|
||||
* @return List<Weaponry>
|
||||
*/
|
||||
List<Weaponry> getList(Weaponry weaponry);
|
||||
|
||||
/**
|
||||
* 分页
|
||||
*
|
||||
* @param weaponry weaponry
|
||||
* @return List<Weaponry>
|
||||
*/
|
||||
List<Weaponry> getPageList(Weaponry weaponry);
|
||||
|
||||
}
|
@ -0,0 +1,64 @@
|
||||
package com.arm.equipment.system.data.mapper.weaponry;
|
||||
|
||||
import com.arm.equipment.system.data.domain.weaponry.WeaponryReturnRecord;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 装备武器归还记录
|
||||
*
|
||||
* @author admin
|
||||
* @date 2023年03月23日 11:03:25
|
||||
*/
|
||||
public interface IWeaponryReturnRecordMapper {
|
||||
|
||||
/**
|
||||
* 插入
|
||||
*
|
||||
* @param weaponryReturnRecord weaponryReturnRecord
|
||||
* @return int
|
||||
*/
|
||||
int insertSelective(WeaponryReturnRecord weaponryReturnRecord);
|
||||
|
||||
/**
|
||||
* 更新
|
||||
*
|
||||
* @param setParam setParam
|
||||
* @param whereParam whereParam
|
||||
* @return int
|
||||
*/
|
||||
int updateSelective(WeaponryReturnRecord setParam, WeaponryReturnRecord whereParam);
|
||||
|
||||
/**
|
||||
* 数量
|
||||
*
|
||||
* @param weaponryReturnRecord weaponryReturnRecord
|
||||
* @return int
|
||||
*/
|
||||
int getCount(WeaponryReturnRecord weaponryReturnRecord);
|
||||
|
||||
/**
|
||||
* 单条
|
||||
*
|
||||
* @param weaponryReturnRecord weaponryReturnRecord
|
||||
* @return WeaponryReturnRecord
|
||||
*/
|
||||
WeaponryReturnRecord getOne(WeaponryReturnRecord weaponryReturnRecord);
|
||||
|
||||
/**
|
||||
* 多条
|
||||
*
|
||||
* @param weaponryReturnRecord weaponryReturnRecord
|
||||
* @return List<WeaponryReturnRecord>
|
||||
*/
|
||||
List<WeaponryReturnRecord> getList(WeaponryReturnRecord weaponryReturnRecord);
|
||||
|
||||
/**
|
||||
* 分页
|
||||
*
|
||||
* @param weaponryReturnRecord weaponryReturnRecord
|
||||
* @return List<WeaponryReturnRecord>
|
||||
*/
|
||||
List<WeaponryReturnRecord> getPageList(WeaponryReturnRecord weaponryReturnRecord);
|
||||
|
||||
}
|
@ -0,0 +1,62 @@
|
||||
package com.arm.equipment.system.data.mybatis.type;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.ibatis.lang.UsesJava8;
|
||||
import org.apache.ibatis.type.JdbcType;
|
||||
import org.apache.ibatis.type.LocalTimeTypeHandler;
|
||||
|
||||
import java.sql.*;
|
||||
import java.time.LocalTime;
|
||||
|
||||
/**
|
||||
* 继承了LocalTimeTypeHandler这个类, 重写了对localtime的处理
|
||||
* 主要是针对0点返回null的问题
|
||||
* @author
|
||||
*/
|
||||
@UsesJava8
|
||||
public class CustomLocalTimeTypeHandler extends LocalTimeTypeHandler {
|
||||
|
||||
@Override
|
||||
public void setNonNullParameter(PreparedStatement ps, int i, LocalTime parameter, JdbcType jdbcType)
|
||||
throws SQLException {
|
||||
ps.setTime(i, Time.valueOf(parameter));
|
||||
}
|
||||
|
||||
@Override
|
||||
public LocalTime getNullableResult(ResultSet rs, String columnName) throws SQLException {
|
||||
String stringTime = rs.getString(columnName);
|
||||
return getLocalTime(stringTime);
|
||||
}
|
||||
|
||||
@Override
|
||||
public LocalTime getNullableResult(ResultSet rs, int columnIndex) throws SQLException {
|
||||
String stringTime = rs.getString(columnIndex);
|
||||
return getLocalTime(stringTime);
|
||||
}
|
||||
|
||||
@Override
|
||||
public LocalTime getNullableResult(CallableStatement cs, int columnIndex) throws SQLException {
|
||||
String stringTime = cs.getString(columnIndex);
|
||||
return getLocalTime(stringTime);
|
||||
}
|
||||
|
||||
/**
|
||||
* 从字符串中解析时间
|
||||
* 取出每一位设置为localtime的时,分,秒,毫秒
|
||||
* @param stringTime 时间字符串
|
||||
* @return
|
||||
*/
|
||||
private LocalTime getLocalTime(String stringTime) {
|
||||
if (StringUtils.isEmpty(stringTime)) {
|
||||
return null;
|
||||
}
|
||||
String[] timeSplit = stringTime.split(":");
|
||||
if (stringTime.contains(".")) {
|
||||
String[] secondSplit = timeSplit[2].split("\\.");
|
||||
String nano = secondSplit[1].replaceAll("[0]+$", "");
|
||||
return LocalTime.of(Integer.parseInt(timeSplit[0]), Integer.parseInt(timeSplit[1]), Integer.parseInt(secondSplit[0]), Integer.parseInt(nano));
|
||||
} else {
|
||||
return LocalTime.of(Integer.parseInt(timeSplit[0]), Integer.parseInt(timeSplit[1]), Integer.parseInt(timeSplit[2]));
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
package com.arm.equipment.system.data.service.common;
|
||||
|
||||
import com.arm.equipment.system.data.vo.dict.DictVO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 字典业务类
|
||||
*
|
||||
* @author admin
|
||||
*/
|
||||
public interface IDictService {
|
||||
/**
|
||||
* 获取字典数据
|
||||
*
|
||||
* @param name 字典名称
|
||||
* @return 字典数据
|
||||
*/
|
||||
List<DictVO> getDictData(String name);
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
package com.arm.equipment.system.data.service.file;
|
||||
|
||||
|
||||
import com.arm.equipment.system.data.enums.file.EnumUpload;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
/**
|
||||
* 文件业务类
|
||||
*
|
||||
* @author admin
|
||||
*/
|
||||
public interface IFileService {
|
||||
/**
|
||||
* 上传文件
|
||||
*
|
||||
* @param file
|
||||
* @param enumUploadItem
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
String upload(MultipartFile file, EnumUpload enumUploadItem);
|
||||
}
|
@ -0,0 +1,53 @@
|
||||
package com.arm.equipment.system.data.service.file.impl;
|
||||
|
||||
|
||||
import com.arm.equipment.system.data.enums.file.EnumUpload;
|
||||
import com.arm.equipment.system.data.service.file.IFileService;
|
||||
import com.arm.equipment.system.data.util.DateUtils;
|
||||
import com.arm.equipment.system.data.util.UuidUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 上传文件
|
||||
*
|
||||
* @author: xly
|
||||
* @time: 2023/3/10 10:54
|
||||
*/
|
||||
@Component
|
||||
public class FileServiceImpl implements IFileService {
|
||||
private final static Logger LOGGER = LoggerFactory.getLogger(FileServiceImpl.class);
|
||||
@Override
|
||||
public String upload(MultipartFile file, EnumUpload enumUploadItem) {
|
||||
try {
|
||||
String os = System.getProperty("os.name");
|
||||
//Windows操作系统
|
||||
String resourcePath = System.getProperty("user.dir");
|
||||
if (os != null && os.toLowerCase().startsWith("windows")) {
|
||||
resourcePath = resourcePath + "\\";
|
||||
} else {
|
||||
resourcePath = resourcePath + "/";
|
||||
}
|
||||
File pathFile = new File(resourcePath);
|
||||
//判断文件夹是否存在
|
||||
if (!pathFile.exists() && !pathFile.isDirectory()) {
|
||||
pathFile.mkdirs();
|
||||
}
|
||||
String fileName = UuidUtils.uuid() + "." + enumUploadItem.getSuffix();
|
||||
String filePath = resourcePath + fileName;
|
||||
file.transferTo(new File(filePath));
|
||||
return fileName;
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,96 @@
|
||||
package com.arm.equipment.system.data.service.system;
|
||||
|
||||
import com.arm.equipment.system.data.domain.system.SysBaseParam;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 系统--基础参数
|
||||
*
|
||||
* @author Administrator
|
||||
* @date 2021年10月26日 16:36:52
|
||||
*/
|
||||
public interface ISysBaseParamService {
|
||||
/**
|
||||
* 保存或更新
|
||||
* @param req
|
||||
*/
|
||||
void save(SysBaseParam req, String operator);
|
||||
|
||||
/**
|
||||
* 插入
|
||||
*
|
||||
* @param sysBaseParam sysBaseParam
|
||||
* @return int
|
||||
*/
|
||||
int insertSelective(SysBaseParam sysBaseParam);
|
||||
|
||||
/**
|
||||
* 主键更新
|
||||
*
|
||||
* @param sysBaseParam sysBaseParam
|
||||
* @return int
|
||||
*/
|
||||
int updateSelectiveById(SysBaseParam sysBaseParam);
|
||||
|
||||
/**
|
||||
* 数量
|
||||
*
|
||||
* @param sysBaseParam sysBaseParam
|
||||
* @return int
|
||||
*/
|
||||
int getCount(SysBaseParam sysBaseParam);
|
||||
|
||||
/**
|
||||
* unicode查询
|
||||
* @param uniCode
|
||||
* @return
|
||||
*/
|
||||
SysBaseParam getOneByUniCode(String uniCode);
|
||||
|
||||
/**
|
||||
* 主键查询
|
||||
*
|
||||
* @param id id
|
||||
* @return SysBaseParam
|
||||
*/
|
||||
SysBaseParam getOneById(Long id);
|
||||
|
||||
/**
|
||||
* 多条
|
||||
*
|
||||
* @param sysBaseParam sysBaseParam
|
||||
* @return List<SysBaseParam>
|
||||
*/
|
||||
List<SysBaseParam> getList(SysBaseParam sysBaseParam);
|
||||
|
||||
/**
|
||||
* 分页
|
||||
*
|
||||
* @param sysBaseParam sysBaseParam
|
||||
* @return List<SysBaseParam>
|
||||
*/
|
||||
List<SysBaseParam> getPageList(SysBaseParam sysBaseParam);
|
||||
|
||||
/**
|
||||
* 审核
|
||||
* @param id
|
||||
* @param operator
|
||||
*/
|
||||
void audit(Long id, String operator);
|
||||
|
||||
/**
|
||||
* 取消审核
|
||||
* @param id
|
||||
* @param operator
|
||||
*/
|
||||
void unaudit(Long id, String operator);
|
||||
|
||||
/**
|
||||
* 删除
|
||||
* @param id
|
||||
* @param operator
|
||||
*/
|
||||
void delete(Long id, String operator);
|
||||
|
||||
}
|
@ -0,0 +1,88 @@
|
||||
package com.arm.equipment.system.data.service.system;
|
||||
|
||||
import com.arm.equipment.system.data.domain.system.SysLog;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 日志表
|
||||
*
|
||||
* @author admin
|
||||
* @date 2022年09月16日 12:41:35
|
||||
*/
|
||||
public interface ISysLogService {
|
||||
/**
|
||||
* 保存或更新
|
||||
* @param req
|
||||
*/
|
||||
void save(SysLog req, String operator);
|
||||
|
||||
/**
|
||||
* 插入
|
||||
*
|
||||
* @param sysLog sysLog
|
||||
* @return int
|
||||
*/
|
||||
int insertSelective(SysLog sysLog);
|
||||
|
||||
/**
|
||||
* 主键更新
|
||||
*
|
||||
* @param sysLog sysLog
|
||||
* @return int
|
||||
*/
|
||||
int updateSelectiveById(SysLog sysLog);
|
||||
|
||||
/**
|
||||
* 数量
|
||||
*
|
||||
* @param sysLog sysLog
|
||||
* @return int
|
||||
*/
|
||||
int getCount(SysLog sysLog);
|
||||
|
||||
/**
|
||||
* 主键查询
|
||||
*
|
||||
* @param id id
|
||||
* @return SysLog
|
||||
*/
|
||||
SysLog getOneById(Long id);
|
||||
|
||||
/**
|
||||
* 多条
|
||||
*
|
||||
* @param sysLog sysLog
|
||||
* @return List<SysLog>
|
||||
*/
|
||||
List<SysLog> getList(SysLog sysLog);
|
||||
|
||||
/**
|
||||
* 分页
|
||||
*
|
||||
* @param sysLog sysLog
|
||||
* @return List<SysLog>
|
||||
*/
|
||||
List<SysLog> getPageList(SysLog sysLog);
|
||||
|
||||
/**
|
||||
* 审核
|
||||
* @param id
|
||||
* @param operator
|
||||
*/
|
||||
void audit(Long id, String operator);
|
||||
|
||||
/**
|
||||
* 取消审核
|
||||
* @param id
|
||||
* @param operator
|
||||
*/
|
||||
void unaudit(Long id, String operator);
|
||||
|
||||
/**
|
||||
* 删除
|
||||
* @param id
|
||||
* @param operator
|
||||
*/
|
||||
void delete(Long id, String operator);
|
||||
}
|
@ -0,0 +1,107 @@
|
||||
package com.arm.equipment.system.data.service.system;
|
||||
|
||||
import com.arm.equipment.system.data.domain.system.SysResource;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 系统--权限表
|
||||
*
|
||||
* @author admin
|
||||
* @date 2021年10月19日 15:06:30
|
||||
*/
|
||||
public interface ISysResourceService {
|
||||
/**
|
||||
* 保存或更新
|
||||
*
|
||||
* @param req
|
||||
*/
|
||||
void save(SysResource req, String operator);
|
||||
|
||||
/**
|
||||
* 插入
|
||||
*
|
||||
* @param sysResource sysResource
|
||||
* @return int
|
||||
*/
|
||||
int insertSelective(SysResource sysResource);
|
||||
|
||||
/**
|
||||
* 主键更新
|
||||
*
|
||||
* @param sysResource sysResource
|
||||
* @return int
|
||||
*/
|
||||
int updateSelectiveById(SysResource sysResource);
|
||||
|
||||
/**
|
||||
* 数量
|
||||
*
|
||||
* @param sysResource sysResource
|
||||
* @return int
|
||||
*/
|
||||
int getCount(SysResource sysResource);
|
||||
|
||||
/**
|
||||
* 主键查询
|
||||
*
|
||||
* @param id id
|
||||
* @return SysResource
|
||||
*/
|
||||
SysResource getOneById(Long id);
|
||||
|
||||
/**
|
||||
* 多条
|
||||
*
|
||||
* @param sysResource sysResource
|
||||
* @return List<SysResource>
|
||||
*/
|
||||
List<SysResource> getList(SysResource sysResource);
|
||||
|
||||
/**
|
||||
* 分页
|
||||
*
|
||||
* @param sysResource sysResource
|
||||
* @return List<SysResource>
|
||||
*/
|
||||
List<SysResource> getPageList(SysResource sysResource);
|
||||
|
||||
/**
|
||||
* 审核
|
||||
*
|
||||
* @param id
|
||||
* @param operator
|
||||
*/
|
||||
void audit(Long id, String operator);
|
||||
|
||||
/**
|
||||
* 取消审核
|
||||
*
|
||||
* @param id
|
||||
* @param operator
|
||||
*/
|
||||
void unaudit(Long id, String operator);
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*
|
||||
* @param id
|
||||
* @param operator
|
||||
*/
|
||||
void delete(Long id, String operator);
|
||||
|
||||
/**
|
||||
* 获取目录分页数据
|
||||
*
|
||||
* @param sysResource
|
||||
* @return
|
||||
*/
|
||||
List<SysResource> getPageTreeList(SysResource sysResource);
|
||||
|
||||
/**
|
||||
* 获取资源树
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
List<SysResource> getResourceTree();
|
||||
}
|
@ -0,0 +1,120 @@
|
||||
package com.arm.equipment.system.data.service.system;
|
||||
|
||||
import com.arm.equipment.system.data.domain.system.SysResource;
|
||||
import com.arm.equipment.system.data.domain.system.SysRole;
|
||||
import com.arm.equipment.system.data.domain.system.SysRoleResource;
|
||||
import com.arm.equipment.system.data.vo.system.SysRoleResourceVO;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 系统-角色权限关联表
|
||||
*
|
||||
* @author admin
|
||||
* @date 2021年10月19日 15:06:41
|
||||
*/
|
||||
public interface ISysRoleResourceService {
|
||||
/**
|
||||
* 保存或更新
|
||||
*
|
||||
* @param req
|
||||
*/
|
||||
void save(SysRoleResource req, String operator);
|
||||
|
||||
/**
|
||||
* 插入
|
||||
*
|
||||
* @param sysRoleResource sysRoleResource
|
||||
* @return int
|
||||
*/
|
||||
int insertSelective(SysRoleResource sysRoleResource);
|
||||
|
||||
/**
|
||||
* 主键更新
|
||||
*
|
||||
* @param sysRoleResource sysRoleResource
|
||||
* @return int
|
||||
*/
|
||||
int updateSelectiveById(SysRoleResource sysRoleResource);
|
||||
|
||||
/**
|
||||
* 数量
|
||||
*
|
||||
* @param sysRoleResource sysRoleResource
|
||||
* @return int
|
||||
*/
|
||||
int getCount(SysRoleResource sysRoleResource);
|
||||
|
||||
/**
|
||||
* 主键查询
|
||||
*
|
||||
* @param id id
|
||||
* @return SysRoleResource
|
||||
*/
|
||||
SysRoleResource getOneById(Long id);
|
||||
|
||||
/**
|
||||
* 多条
|
||||
*
|
||||
* @param sysRoleResource sysRoleResource
|
||||
* @return List<SysRoleResource>
|
||||
*/
|
||||
List<SysRoleResource> getList(SysRoleResource sysRoleResource);
|
||||
|
||||
/**
|
||||
* 分页
|
||||
*
|
||||
* @param sysRoleResource sysRoleResource
|
||||
* @return List<SysRoleResource>
|
||||
*/
|
||||
List<SysRoleResource> getPageList(SysRoleResource sysRoleResource);
|
||||
|
||||
/**
|
||||
* 审核
|
||||
*
|
||||
* @param id
|
||||
* @param operator
|
||||
*/
|
||||
void audit(Long id, String operator);
|
||||
|
||||
/**
|
||||
* 取消审核
|
||||
*
|
||||
* @param id
|
||||
* @param operator
|
||||
*/
|
||||
void unaudit(Long id, String operator);
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*
|
||||
* @param id
|
||||
* @param operator
|
||||
*/
|
||||
void delete(Long id, String operator);
|
||||
|
||||
/**
|
||||
* 构建用户资源菜单及资源标识
|
||||
*
|
||||
* @param sysUserRoleIdList
|
||||
* @param sysUserResourceList
|
||||
* @param sysResourceIdentityList
|
||||
*/
|
||||
void buildUserResourceListAndIdentityList(List<SysRole> sysUserRoleIdList, List<SysResource> sysUserResourceList,
|
||||
List<String> sysResourceIdentityList);
|
||||
|
||||
/**
|
||||
* 添加角色资源
|
||||
* @param roleResourceVO
|
||||
* @param operator
|
||||
*/
|
||||
void addResource(SysRoleResourceVO roleResourceVO, String operator);
|
||||
|
||||
/**
|
||||
* 获取角色资源
|
||||
* @param roleId
|
||||
* @return
|
||||
*/
|
||||
Map<String, Object> getResourcesIdListByRoleId(Long roleId);
|
||||
}
|
@ -0,0 +1,100 @@
|
||||
package com.arm.equipment.system.data.service.system;
|
||||
|
||||
import com.arm.equipment.system.data.domain.system.SysRole;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 系统--角色表
|
||||
*
|
||||
* @author admin
|
||||
* @date 2021年10月19日 15:06:47
|
||||
*/
|
||||
public interface ISysRoleService {
|
||||
/**
|
||||
* 保存或更新
|
||||
*
|
||||
* @param req
|
||||
*/
|
||||
void save(SysRole req, String operator);
|
||||
|
||||
/**
|
||||
* 插入
|
||||
*
|
||||
* @param sysRole sysRole
|
||||
* @return int
|
||||
*/
|
||||
int insertSelective(SysRole sysRole);
|
||||
|
||||
/**
|
||||
* 主键更新
|
||||
*
|
||||
* @param sysRole sysRole
|
||||
* @return int
|
||||
*/
|
||||
int updateSelectiveById(SysRole sysRole);
|
||||
|
||||
/**
|
||||
* 数量
|
||||
*
|
||||
* @param sysRole sysRole
|
||||
* @return int
|
||||
*/
|
||||
int getCount(SysRole sysRole);
|
||||
|
||||
/**
|
||||
* 主键查询
|
||||
*
|
||||
* @param id id
|
||||
* @return SysRole
|
||||
*/
|
||||
SysRole getOneById(Long id);
|
||||
|
||||
/**
|
||||
* 多条
|
||||
*
|
||||
* @param sysRole sysRole
|
||||
* @return List<SysRole>
|
||||
*/
|
||||
List<SysRole> getList(SysRole sysRole);
|
||||
|
||||
/**
|
||||
* 分页
|
||||
*
|
||||
* @param sysRole sysRole
|
||||
* @return List<SysRole>
|
||||
*/
|
||||
List<SysRole> getPageList(SysRole sysRole);
|
||||
|
||||
/**
|
||||
* 审核
|
||||
*
|
||||
* @param id
|
||||
* @param operator
|
||||
*/
|
||||
void audit(Long id, String operator);
|
||||
|
||||
/**
|
||||
* 取消审核
|
||||
*
|
||||
* @param id
|
||||
* @param operator
|
||||
*/
|
||||
void unaudit(Long id, String operator);
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*
|
||||
* @param id
|
||||
* @param operator
|
||||
*/
|
||||
void delete(Long id, String operator);
|
||||
|
||||
/**
|
||||
* 获取当前登陆用户拥有绝角色
|
||||
*
|
||||
* @param userId
|
||||
* @return
|
||||
*/
|
||||
List<SysRole> getCurrentUserRole(Long userId);
|
||||
}
|
@ -0,0 +1,86 @@
|
||||
package com.arm.equipment.system.data.service.system;
|
||||
|
||||
import com.arm.equipment.system.data.domain.system.SysUser;
|
||||
import com.arm.equipment.system.data.domain.system.SysUserRole;
|
||||
import com.arm.equipment.system.data.vo.system.AddRoleVO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 系统--用户角色关联表
|
||||
*
|
||||
* @author admin
|
||||
* @date 2021年10月19日 15:06:59
|
||||
*/
|
||||
public interface ISysUserRoleService {
|
||||
/**
|
||||
* 保存或更新
|
||||
*
|
||||
* @param req
|
||||
*/
|
||||
void save(SysUserRole req, String operator);
|
||||
|
||||
/**
|
||||
* 插入
|
||||
*
|
||||
* @param sysUserRole sysUserRole
|
||||
* @return int
|
||||
*/
|
||||
int insertSelective(SysUserRole sysUserRole);
|
||||
|
||||
/**
|
||||
* 主键更新
|
||||
*
|
||||
* @param sysUserRole sysUserRole
|
||||
* @return int
|
||||
*/
|
||||
int updateSelectiveById(SysUserRole sysUserRole);
|
||||
|
||||
/**
|
||||
* 数量
|
||||
*
|
||||
* @param sysUserRole sysUserRole
|
||||
* @return int
|
||||
*/
|
||||
int getCount(SysUserRole sysUserRole);
|
||||
|
||||
/**
|
||||
* 主键查询
|
||||
*
|
||||
* @param id id
|
||||
* @return SysUserRole
|
||||
*/
|
||||
SysUserRole getOneById(Long id);
|
||||
|
||||
/**
|
||||
* 多条
|
||||
*
|
||||
* @param sysUserRole sysUserRole
|
||||
* @return List<SysUserRole>
|
||||
*/
|
||||
List<SysUserRole> getList(SysUserRole sysUserRole);
|
||||
|
||||
/**
|
||||
* 分页
|
||||
*
|
||||
* @param sysUserRole sysUserRole
|
||||
* @return List<SysUserRole>
|
||||
*/
|
||||
List<SysUserRole> getPageList(SysUserRole sysUserRole);
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*
|
||||
* @param id
|
||||
* @param operator
|
||||
*/
|
||||
void delete(Long id, String operator);
|
||||
|
||||
/**
|
||||
* 为用户分配角色
|
||||
*
|
||||
* @param addRoleVO
|
||||
* @param currentUser
|
||||
*/
|
||||
void addRole(AddRoleVO addRoleVO, SysUser currentUser);
|
||||
}
|
@ -0,0 +1,115 @@
|
||||
package com.arm.equipment.system.data.service.system;
|
||||
|
||||
import com.arm.equipment.system.data.domain.system.SysUser;
|
||||
|
||||
import javax.servlet.http.HttpSession;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 系统--用户表
|
||||
*
|
||||
* @author admin
|
||||
* @date 2021年10月19日 15:07:06
|
||||
*/
|
||||
public interface ISysUserService {
|
||||
/**
|
||||
* 保存或更新
|
||||
*
|
||||
* @param req
|
||||
*/
|
||||
void save(SysUser req, String operator);
|
||||
|
||||
/**
|
||||
* 插入
|
||||
*
|
||||
* @param sysUser sysUser
|
||||
* @return int
|
||||
*/
|
||||
int insertSelective(SysUser sysUser);
|
||||
|
||||
/**
|
||||
* 主键更新
|
||||
*
|
||||
* @param sysUser sysUser
|
||||
* @return int
|
||||
*/
|
||||
int updateSelectiveById(SysUser sysUser);
|
||||
|
||||
/**
|
||||
* 数量
|
||||
*
|
||||
* @param sysUser sysUser
|
||||
* @return int
|
||||
*/
|
||||
int getCount(SysUser sysUser);
|
||||
|
||||
/**
|
||||
* 主键查询
|
||||
*
|
||||
* @param id id
|
||||
* @return SysUser
|
||||
*/
|
||||
SysUser getOneById(Long id);
|
||||
|
||||
/**
|
||||
* 多条
|
||||
*
|
||||
* @param sysUser sysUser
|
||||
* @return List<SysUser>
|
||||
*/
|
||||
List<SysUser> getList(SysUser sysUser);
|
||||
|
||||
/**
|
||||
* 分页
|
||||
*
|
||||
* @param sysUser sysUser
|
||||
* @return List<SysUser>
|
||||
*/
|
||||
List<SysUser> getPageList(SysUser sysUser);
|
||||
|
||||
/**
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
SysUser getExitOneById(Long id);
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*
|
||||
* @param id
|
||||
* @param operator
|
||||
*/
|
||||
void delete(Long id, String operator);
|
||||
|
||||
/**
|
||||
* 登陆
|
||||
*
|
||||
* @param sysUserReq
|
||||
* @return
|
||||
*/
|
||||
SysUser login(SysUser sysUserReq, HttpSession webSession);
|
||||
|
||||
/**
|
||||
* 接口登陆
|
||||
*
|
||||
* @param username
|
||||
* @param password
|
||||
* @return
|
||||
*/
|
||||
SysUser thirdLogin(String username, String password);
|
||||
|
||||
/**
|
||||
* 修改密码
|
||||
*
|
||||
* @param oldPassword
|
||||
* @param newPassword
|
||||
* @param sysUserId
|
||||
*/
|
||||
void updatePassword(String oldPassword, String newPassword, Long sysUserId);
|
||||
|
||||
/**
|
||||
* 验证用户登陆错误次数
|
||||
* @param username
|
||||
*/
|
||||
void checkLoginErrorNumByUsername(String username);
|
||||
}
|
@ -0,0 +1,147 @@
|
||||
package com.arm.equipment.system.data.service.system.impl;
|
||||
|
||||
import com.arm.equipment.system.data.domain.system.SysBaseParam;
|
||||
import com.arm.equipment.system.data.enums.dict.EnumStatus;
|
||||
import com.arm.equipment.system.data.exception.BusinessException;
|
||||
import com.arm.equipment.system.data.mapper.system.ISysBaseParamMapper;
|
||||
import com.arm.equipment.system.data.service.common.IIdWorkerService;
|
||||
import com.arm.equipment.system.data.service.system.ISysBaseParamService;
|
||||
import com.arm.equipment.system.data.constant.RedisKeys;
|
||||
import com.arm.equipment.system.data.util.WJAssert;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.cache.annotation.CacheEvict;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 系统--基础参数
|
||||
*
|
||||
* @author Administrator
|
||||
* @date 2021年10月26日 16:36:52
|
||||
*/
|
||||
@Service
|
||||
public class SysBaseParamServiceImpl implements ISysBaseParamService {
|
||||
@Autowired
|
||||
private ISysBaseParamMapper sysBaseParamMapper;
|
||||
@Autowired
|
||||
private IIdWorkerService idWorkerService;
|
||||
@Autowired
|
||||
@Lazy
|
||||
private ISysBaseParamService sysBaseParamService;
|
||||
|
||||
@Override
|
||||
public void save(SysBaseParam req, String operator) {
|
||||
req.setOperator(operator);
|
||||
if (null == req.getId()) {
|
||||
insertSelective(req);
|
||||
} else {
|
||||
updateSelectiveById(req);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int insertSelective(SysBaseParam req) {
|
||||
req.setId(idWorkerService.getNextId());
|
||||
req.setStatus(EnumStatus.NEW.getCode());
|
||||
if (null != getOneByUniCode(req.getUniCode())) {
|
||||
throw new BusinessException("已存在同名参数值");
|
||||
}
|
||||
checkStringLength(req, false);
|
||||
return sysBaseParamMapper.insertSelective(req);
|
||||
}
|
||||
|
||||
@Override
|
||||
@CacheEvict(value = RedisKeys.SYS_BASE_PARAM_KEY, key = "#sysBaseParam.uniCode")
|
||||
public int updateSelectiveById(SysBaseParam sysBaseParam) {
|
||||
WJAssert.notNull(sysBaseParam, "入参对象不能为空");
|
||||
WJAssert.notNull(sysBaseParam.getId(), "id参数错误");
|
||||
SysBaseParam where = new SysBaseParam();
|
||||
where.setId(sysBaseParam.getId());
|
||||
return sysBaseParamMapper.updateSelective(sysBaseParam, where);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCount(SysBaseParam sysBaseParam) {
|
||||
checkStringLength(sysBaseParam, true);
|
||||
return sysBaseParamMapper.getCount(sysBaseParam);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SysBaseParam getOneById(Long id) {
|
||||
WJAssert.notNull(id, "id参数错误");
|
||||
SysBaseParam where = new SysBaseParam();
|
||||
where.setId(id);
|
||||
return sysBaseParamMapper.getOne(where);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SysBaseParam> getList(SysBaseParam sysBaseParam) {
|
||||
checkStringLength(sysBaseParam, true);
|
||||
return sysBaseParamMapper.getList(sysBaseParam);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SysBaseParam> getPageList(SysBaseParam sysBaseParam) {
|
||||
checkStringLength(sysBaseParam, true);
|
||||
return sysBaseParamMapper.getPageList(sysBaseParam);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void audit(Long id, String operator) {
|
||||
SysBaseParam req = new SysBaseParam();
|
||||
req.setId(id);
|
||||
req.setOperator(operator);
|
||||
req.setStatus(EnumStatus.AUDIT.getCode());
|
||||
|
||||
SysBaseParam baseParamDB = getOneById(id);
|
||||
req.setUniCode(baseParamDB.getUniCode());
|
||||
sysBaseParamService.updateSelectiveById(req);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unaudit(Long id, String operator) {
|
||||
SysBaseParam req = new SysBaseParam();
|
||||
req.setId(id);
|
||||
req.setOperator(operator);
|
||||
req.setStatus(EnumStatus.NEW.getCode());
|
||||
|
||||
SysBaseParam baseParamDB = getOneById(id);
|
||||
req.setUniCode(baseParamDB.getUniCode());
|
||||
sysBaseParamService.updateSelectiveById(req);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(Long id, String operator) {
|
||||
SysBaseParam req = new SysBaseParam();
|
||||
req.setId(id);
|
||||
req.setOperator(operator);
|
||||
req.setStatus(EnumStatus.DEL.getCode());
|
||||
updateSelectiveById(req);
|
||||
}
|
||||
|
||||
@Cacheable(value = RedisKeys.SYS_BASE_PARAM_KEY, key = "#uniCode")
|
||||
@Override
|
||||
public SysBaseParam getOneByUniCode(String uniCode) {
|
||||
WJAssert.isMaxLength(uniCode, 50, "UNICODE非法");
|
||||
SysBaseParam where = new SysBaseParam();
|
||||
where.setUniCode(uniCode);
|
||||
where.setStatus(EnumStatus.AUDIT.getCode());
|
||||
return sysBaseParamMapper.getOne(where);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 参数校验注解默认使用的方法
|
||||
*/
|
||||
private void checkStringLength(SysBaseParam sysBaseParam, boolean nullAble) {
|
||||
WJAssert.notNull(sysBaseParam, "入参对象不能为空");
|
||||
WJAssert.limitMaxLength(sysBaseParam.getUniCode(), nullAble, 50, "唯一编码不合法!");
|
||||
WJAssert.limitMaxLength(sysBaseParam.getValue(), nullAble, 2000, "值不合法!");
|
||||
WJAssert.limitMaxLength(sysBaseParam.getDescription(), nullAble, 300, "描述不合法!");
|
||||
WJAssert.limitMaxLength(sysBaseParam.getOperator(), nullAble, 100, "操作人不合法!");
|
||||
WJAssert.limitMaxLength(sysBaseParam.getRemark(), true, 255, "备注不合法!");
|
||||
}
|
||||
}
|
@ -0,0 +1,122 @@
|
||||
package com.arm.equipment.system.data.service.system.impl;
|
||||
|
||||
import com.arm.equipment.system.data.enums.dict.EnumStatus;
|
||||
import com.arm.equipment.system.data.util.WJAssert;
|
||||
import com.arm.equipment.system.data.service.common.IIdWorkerService;
|
||||
import com.arm.equipment.system.data.mapper.system.ISysLogMapper;
|
||||
import com.arm.equipment.system.data.domain.system.SysLog;
|
||||
import com.arm.equipment.system.data.service.system.ISysLogService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 日志表
|
||||
*
|
||||
* @author admin
|
||||
* @date 2022年09月16日 12:41:35
|
||||
*/
|
||||
@Service
|
||||
public class SysLogServiceImpl implements ISysLogService {
|
||||
@Autowired
|
||||
private ISysLogMapper sysLogMapper;
|
||||
@Autowired
|
||||
private IIdWorkerService idWorkerService;
|
||||
|
||||
@Override
|
||||
public void save(SysLog req, String operator) {
|
||||
req.setOperator(operator);
|
||||
if (null == req.getId()) {
|
||||
insertSelective(req);
|
||||
} else {
|
||||
updateSelectiveById(req);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int insertSelective(SysLog req) {
|
||||
req.setId(idWorkerService.getNextId());
|
||||
req.setStatus(EnumStatus.NEW.getCode());
|
||||
checkStringLength(req, false);
|
||||
return sysLogMapper.insertSelective(req);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int updateSelectiveById(SysLog sysLog) {
|
||||
WJAssert.notNull(sysLog, "入参对象不能为空");
|
||||
WJAssert.notNull(sysLog.getId(), "id参数错误");
|
||||
SysLog where = new SysLog();
|
||||
where.setId(sysLog.getId());
|
||||
return sysLogMapper.updateSelective(sysLog, where);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCount(SysLog sysLog) {
|
||||
checkStringLength(sysLog, true);
|
||||
return sysLogMapper.getCount(sysLog);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SysLog getOneById(Long id) {
|
||||
WJAssert.notNull(id, "id参数错误");
|
||||
SysLog where = new SysLog();
|
||||
where.setId(id);
|
||||
return sysLogMapper.getOne(where);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SysLog> getList(SysLog sysLog) {
|
||||
checkStringLength(sysLog, true);
|
||||
return sysLogMapper.getList(sysLog);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SysLog> getPageList(SysLog sysLog) {
|
||||
checkStringLength(sysLog, true);
|
||||
return sysLogMapper.getPageList(sysLog);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void audit(Long id, String operator) {
|
||||
SysLog req = new SysLog();
|
||||
req.setId(id);
|
||||
req.setOperator(operator);
|
||||
req.setStatus(EnumStatus.AUDIT.getCode());
|
||||
updateSelectiveById(req);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unaudit(Long id, String operator) {
|
||||
SysLog req = new SysLog();
|
||||
req.setId(id);
|
||||
req.setOperator(operator);
|
||||
req.setStatus(EnumStatus.NEW.getCode());
|
||||
updateSelectiveById(req);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(Long id, String operator) {
|
||||
SysLog req = new SysLog();
|
||||
req.setId(id);
|
||||
req.setOperator(operator);
|
||||
req.setStatus(EnumStatus.DEL.getCode());
|
||||
updateSelectiveById(req);
|
||||
}
|
||||
|
||||
/**
|
||||
* 参数校验注解默认使用的方法
|
||||
*/
|
||||
private void checkStringLength(SysLog sysLog, boolean nullAble) {
|
||||
WJAssert.notNull(sysLog, "入参对象不能为空");
|
||||
WJAssert.limitMaxLength(sysLog.getTitle(), true, 500, "日志标题不合法!");
|
||||
WJAssert.limitMaxLength(sysLog.getRemoteAddr(), true, 255, "操作IP地址不合法!");
|
||||
WJAssert.limitMaxLength(sysLog.getUserAgent(), true, 255, "用户代理不合法!");
|
||||
WJAssert.limitMaxLength(sysLog.getRequestUri(), true, 255, "请求URI不合法!");
|
||||
WJAssert.limitMaxLength(sysLog.getMethod(), true, 10, "操作方式不合法!");
|
||||
WJAssert.limitMaxLength(sysLog.getParams(), true, 1000, "操作提交的数据不合法!");
|
||||
WJAssert.limitMaxLength(sysLog.getException(), true, 1000, "异常信息不合法!");
|
||||
WJAssert.limitMaxLength(sysLog.getOperator(), nullAble, 50, "操作人不合法!");
|
||||
WJAssert.limitMaxLength(sysLog.getRemark(), true, 255, "备注不合法!");
|
||||
}
|
||||
}
|
@ -0,0 +1,146 @@
|
||||
package com.arm.equipment.system.data.service.system.impl;
|
||||
|
||||
import com.arm.equipment.system.data.domain.system.SysRole;
|
||||
import com.arm.equipment.system.data.domain.system.SysUserRole;
|
||||
import com.arm.equipment.system.data.enums.dict.EnumStatus;
|
||||
import com.arm.equipment.system.data.mapper.system.ISysRoleMapper;
|
||||
import com.arm.equipment.system.data.service.common.IIdWorkerService;
|
||||
import com.arm.equipment.system.data.service.system.ISysRoleService;
|
||||
import com.arm.equipment.system.data.service.system.ISysUserRoleService;
|
||||
import com.arm.equipment.system.data.util.WJAssert;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 系统--角色表
|
||||
*
|
||||
* @author admin
|
||||
* @date 2021年10月19日 15:06:47
|
||||
*/
|
||||
@Service
|
||||
public class SysRoleServiceImpl implements ISysRoleService {
|
||||
@Autowired
|
||||
private ISysRoleMapper sysRoleMapper;
|
||||
@Autowired
|
||||
private IIdWorkerService idWorkerService;
|
||||
@Autowired
|
||||
private ISysUserRoleService sysUserRoleService;
|
||||
|
||||
@Override
|
||||
public void save(SysRole req, String operator) {
|
||||
req.setOperator(operator);
|
||||
if (null == req.getId()) {
|
||||
insertSelective(req);
|
||||
} else {
|
||||
updateSelectiveById(req);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int insertSelective(SysRole req) {
|
||||
req.setId(idWorkerService.getNextId());
|
||||
req.setStatus(EnumStatus.NEW.getCode());
|
||||
checkStringLength(req, false);
|
||||
return sysRoleMapper.insertSelective(req);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int updateSelectiveById(SysRole sysRole) {
|
||||
WJAssert.notNull(sysRole, "入参对象不能为空");
|
||||
WJAssert.notNull(sysRole.getId(), "id参数错误");
|
||||
SysRole where = new SysRole();
|
||||
where.setId(sysRole.getId());
|
||||
return sysRoleMapper.updateSelective(sysRole, where);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCount(SysRole sysRole) {
|
||||
checkStringLength(sysRole, true);
|
||||
return sysRoleMapper.getCount(sysRole);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SysRole getOneById(Long id) {
|
||||
WJAssert.notNull(id, "id参数错误");
|
||||
SysRole where = new SysRole();
|
||||
where.setId(id);
|
||||
where.setStatus(EnumStatus.NEW.getCode());
|
||||
return sysRoleMapper.getOne(where);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SysRole> getList(SysRole sysRole) {
|
||||
checkStringLength(sysRole, true);
|
||||
return sysRoleMapper.getList(sysRole);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SysRole> getPageList(SysRole sysRole) {
|
||||
checkStringLength(sysRole, true);
|
||||
return sysRoleMapper.getPageList(sysRole);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void audit(Long id, String operator) {
|
||||
SysRole req = new SysRole();
|
||||
req.setId(id);
|
||||
req.setOperator(operator);
|
||||
req.setStatus(EnumStatus.AUDIT.getCode());
|
||||
updateSelectiveById(req);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unaudit(Long id, String operator) {
|
||||
SysRole req = new SysRole();
|
||||
req.setId(id);
|
||||
req.setOperator(operator);
|
||||
req.setStatus(EnumStatus.NEW.getCode());
|
||||
updateSelectiveById(req);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(Long id, String operator) {
|
||||
SysRole req = new SysRole();
|
||||
req.setId(id);
|
||||
req.setOperator(operator);
|
||||
req.setStatus(EnumStatus.DEL.getCode());
|
||||
updateSelectiveById(req);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前登陆用户拥有绝角色
|
||||
*
|
||||
* @param userId
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List<SysRole> getCurrentUserRole(Long userId) {
|
||||
SysUserRole sysUserRole = new SysUserRole();
|
||||
sysUserRole.setStatus(EnumStatus.NEW.getCode());
|
||||
sysUserRole.setSysUserId(userId);
|
||||
List<SysUserRole> sysUserRoleList = sysUserRoleService.getList(sysUserRole);
|
||||
if (CollectionUtils.isEmpty(sysUserRoleList)) {
|
||||
return null;
|
||||
}
|
||||
List<Long> sysRoleIdList = sysUserRoleList.stream().map(SysUserRole::getSysRoleId).collect(Collectors.toList());
|
||||
SysRole sysRole = new SysRole();
|
||||
sysRole.setSysRoleIdList(sysRoleIdList);
|
||||
List<SysRole> sysRoleList = sysRoleMapper.getList(sysRole);
|
||||
return sysRoleList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 参数校验注解默认使用的方法
|
||||
*/
|
||||
private void checkStringLength(SysRole sysRole, boolean nullAble) {
|
||||
WJAssert.notNull(sysRole, "入参对象不能为空");
|
||||
WJAssert.limitMaxLength(sysRole.getName(), nullAble, 100, "角色名称不合法!");
|
||||
WJAssert.limitMaxLength(sysRole.getDescription(), nullAble, 200, "描述不合法!");
|
||||
WJAssert.limitMaxLength(sysRole.getOperator(), true, 255, "操作人不合法!");
|
||||
WJAssert.limitMaxLength(sysRole.getRemark(), true, 255, "备注不合法!");
|
||||
}
|
||||
}
|
@ -0,0 +1,123 @@
|
||||
package com.arm.equipment.system.data.service.system.impl;
|
||||
|
||||
import com.arm.equipment.system.data.domain.system.SysUser;
|
||||
import com.arm.equipment.system.data.domain.system.SysUserRole;
|
||||
import com.arm.equipment.system.data.enums.dict.EnumStatus;
|
||||
import com.arm.equipment.system.data.exception.BusinessException;
|
||||
import com.arm.equipment.system.data.mapper.system.ISysUserRoleMapper;
|
||||
import com.arm.equipment.system.data.service.common.IIdWorkerService;
|
||||
import com.arm.equipment.system.data.service.system.ISysUserRoleService;
|
||||
import com.arm.equipment.system.data.util.WJAssert;
|
||||
import com.arm.equipment.system.data.vo.system.AddRoleVO;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 系统--用户角色关联表
|
||||
*
|
||||
* @author admin
|
||||
* @date 2021年10月19日 15:06:59
|
||||
*/
|
||||
@Service
|
||||
public class SysUserRoleServiceImpl implements ISysUserRoleService {
|
||||
@Autowired
|
||||
private ISysUserRoleMapper sysUserRoleMapper;
|
||||
@Autowired
|
||||
private IIdWorkerService idWorkerService;
|
||||
|
||||
@Override
|
||||
public void save(SysUserRole req, String operator) {
|
||||
req.setOperator(operator);
|
||||
if (null == req.getId()) {
|
||||
insertSelective(req);
|
||||
} else {
|
||||
updateSelectiveById(req);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int insertSelective(SysUserRole req) {
|
||||
req.setId(idWorkerService.getNextId());
|
||||
req.setStatus(EnumStatus.NEW.getCode());
|
||||
checkStringLength(req, false);
|
||||
return sysUserRoleMapper.insertSelective(req);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int updateSelectiveById(SysUserRole sysUserRole) {
|
||||
WJAssert.notNull(sysUserRole, "入参对象不能为空");
|
||||
WJAssert.notNull(sysUserRole.getId(), "id参数错误");
|
||||
SysUserRole where = new SysUserRole();
|
||||
where.setId(sysUserRole.getId());
|
||||
return sysUserRoleMapper.updateSelective(sysUserRole, where);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCount(SysUserRole sysUserRole) {
|
||||
checkStringLength(sysUserRole, true);
|
||||
return sysUserRoleMapper.getCount(sysUserRole);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SysUserRole getOneById(Long id) {
|
||||
WJAssert.notNull(id, "id参数错误");
|
||||
SysUserRole where = new SysUserRole();
|
||||
where.setId(id);
|
||||
return sysUserRoleMapper.getOne(where);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SysUserRole> getList(SysUserRole sysUserRole) {
|
||||
checkStringLength(sysUserRole, true);
|
||||
return sysUserRoleMapper.getList(sysUserRole);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SysUserRole> getPageList(SysUserRole sysUserRole) {
|
||||
checkStringLength(sysUserRole, true);
|
||||
return sysUserRoleMapper.getPageList(sysUserRole);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(Long id, String operator) {
|
||||
SysUserRole req = new SysUserRole();
|
||||
req.setId(id);
|
||||
req.setOperator(operator);
|
||||
updateSelectiveById(req);
|
||||
}
|
||||
|
||||
/**
|
||||
* 为用户分配角色
|
||||
*
|
||||
* @param addRoleVO
|
||||
* @param currentUser
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void addRole(AddRoleVO addRoleVO, SysUser currentUser) {
|
||||
List<Long> newRoleList = addRoleVO.getNewRole();
|
||||
if (null == addRoleVO.getUserId()) {
|
||||
throw new BusinessException("新增角色ID或用户ID不能为空");
|
||||
}
|
||||
sysUserRoleMapper.deleteByUserId(addRoleVO.getUserId());
|
||||
newRoleList.stream().forEach(item -> {
|
||||
SysUserRole req = new SysUserRole();
|
||||
req.setSysRoleId(item);
|
||||
req.setOperator(currentUser.getName());
|
||||
req.setSysUserId(addRoleVO.getUserId());
|
||||
insertSelective(req);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 参数校验注解默认使用的方法
|
||||
*/
|
||||
private void checkStringLength(SysUserRole sysUserRole, boolean nullAble) {
|
||||
WJAssert.notNull(sysUserRole, "入参对象不能为空");
|
||||
WJAssert.limitMaxLength(sysUserRole.getOperator(), nullAble, 50, "执行者不合法!");
|
||||
WJAssert.limitMaxLength(sysUserRole.getRemark(), true, 255, "备注不合法!");
|
||||
}
|
||||
}
|
@ -0,0 +1,254 @@
|
||||
package com.arm.equipment.system.data.service.system.impl;
|
||||
|
||||
import com.arm.equipment.system.data.constant.RedisKeys;
|
||||
import com.arm.equipment.system.data.domain.system.SysUser;
|
||||
import com.arm.equipment.system.data.enums.dict.EnumStatus;
|
||||
import com.arm.equipment.system.data.exception.BusinessException;
|
||||
import com.arm.equipment.system.data.mapper.system.ISysUserMapper;
|
||||
import com.arm.equipment.system.data.service.common.IIdWorkerService;
|
||||
import com.arm.equipment.system.data.service.system.ISysUserService;
|
||||
import com.arm.equipment.system.data.util.WJAssert;
|
||||
import com.arm.equipment.system.data.util.passwordEncoder.BCryptPasswordEncoderUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.data.redis.core.ValueOperations;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.servlet.http.HttpSession;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 系统--用户表
|
||||
*
|
||||
* @author admin
|
||||
* @date 2021年10月19日 15:07:06
|
||||
*/
|
||||
@Service
|
||||
public class SysUserServiceImpl implements ISysUserService {
|
||||
@Autowired
|
||||
private ISysUserMapper sysUserMapper;
|
||||
@Autowired
|
||||
private IIdWorkerService idWorkerService;
|
||||
@Autowired
|
||||
private BCryptPasswordEncoderUtils bCryptPasswordEncoder;
|
||||
@Autowired
|
||||
private RedisTemplate redisTemplate;
|
||||
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void save(SysUser req, String operator) {
|
||||
req.setOperator(operator);
|
||||
String password = req.getPassword();
|
||||
if (StringUtils.isNotBlank(password)) {
|
||||
req.setPassword(bCryptPasswordEncoder.encode(password));
|
||||
}
|
||||
// 检查用户名
|
||||
if (isUsernameExist(req)) {
|
||||
throw new BusinessException("用户名已存在");
|
||||
}
|
||||
// 检查用户名
|
||||
if (isEmailExist(req)) {
|
||||
throw new BusinessException("邮箱已存在");
|
||||
}
|
||||
// 检查邮箱
|
||||
if (null == req.getId()) {
|
||||
insertSelective(req);
|
||||
} else {
|
||||
updateSelectiveById(req);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int insertSelective(SysUser req) {
|
||||
req.setId(idWorkerService.getNextId());
|
||||
req.setStatus(EnumStatus.NEW.getCode());
|
||||
checkStringLength(req, false);
|
||||
return sysUserMapper.insertSelective(req);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int updateSelectiveById(SysUser sysUser) {
|
||||
WJAssert.notNull(sysUser, "入参对象不能为空");
|
||||
WJAssert.notNull(sysUser.getId(), "id参数错误");
|
||||
SysUser where = new SysUser();
|
||||
where.setId(sysUser.getId());
|
||||
return sysUserMapper.updateSelective(sysUser, where);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCount(SysUser sysUser) {
|
||||
checkStringLength(sysUser, true);
|
||||
return sysUserMapper.getCount(sysUser);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SysUser getOneById(Long id) {
|
||||
WJAssert.notNull(id, "id参数错误");
|
||||
SysUser where = new SysUser();
|
||||
where.setId(id);
|
||||
return sysUserMapper.getOne(where);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SysUser> getList(SysUser sysUser) {
|
||||
checkStringLength(sysUser, true);
|
||||
return sysUserMapper.getList(sysUser);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SysUser> getPageList(SysUser sysUser) {
|
||||
checkStringLength(sysUser, true);
|
||||
return sysUserMapper.getPageList(sysUser)
|
||||
.parallelStream()
|
||||
.peek(item -> {
|
||||
if (StringUtils.isNotBlank(item.getTag())) {
|
||||
item.setTagList(Arrays.asList(item.getTag().split(",")));
|
||||
}
|
||||
}).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public SysUser getExitOneById(Long id) {
|
||||
WJAssert.notNull(id, "id参数错误");
|
||||
SysUser where = new SysUser();
|
||||
where.setStatus(EnumStatus.NEW.getCode());
|
||||
where.setId(id);
|
||||
return sysUserMapper.getOne(where);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(Long id, String operator) {
|
||||
SysUser req = new SysUser();
|
||||
req.setId(id);
|
||||
req.setOperator(operator);
|
||||
req.setStatus(EnumStatus.DEL.getCode());
|
||||
updateSelectiveById(req);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SysUser login(SysUser sysUserReq, HttpSession webSession) {
|
||||
WJAssert.limitMaxLength(sysUserReq.getUsername(), false, 100, "用户名不合法!");
|
||||
WJAssert.limitMaxLength(sysUserReq.getPassword(), false, 100, "密码不合法!");
|
||||
Object code = webSession.getAttribute("verifyCode_" + sysUserReq.getVerifyCode().toUpperCase());
|
||||
//验证码判断
|
||||
if (code == null) {
|
||||
throw new BusinessException("验证码错误");
|
||||
}
|
||||
checkLoginErrorNum(sysUserReq.getUsername());
|
||||
|
||||
SysUser sysUser = new SysUser();
|
||||
sysUser.setUsername(sysUserReq.getUsername());
|
||||
SysUser sysUserDB = sysUserMapper.getOne(sysUser);
|
||||
if (Objects.isNull(sysUserDB) || !bCryptPasswordEncoder.matches(sysUserReq.getPassword(), sysUserDB.getPassword())) {
|
||||
checkLoginErrorNumByUsername(sysUserReq.getUsername());
|
||||
throw new BusinessException("账户不存在或密码错误");
|
||||
}
|
||||
if (Objects.equals(sysUserDB.getStatus(), EnumStatus.DEL.getCode())) {
|
||||
throw new BusinessException("账户已删除");
|
||||
}
|
||||
return sysUserDB;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SysUser thirdLogin(String username, String password) {
|
||||
checkLoginErrorNum(username);
|
||||
|
||||
SysUser sysUser = new SysUser();
|
||||
sysUser.setUsername(username);
|
||||
SysUser sysUserDB = sysUserMapper.getOne(sysUser);
|
||||
if (Objects.isNull(sysUserDB) || !bCryptPasswordEncoder.matches(password, sysUserDB.getPassword())) {
|
||||
checkLoginErrorNumByUsername(username);
|
||||
throw new BusinessException("用户名或密码错误");
|
||||
}
|
||||
if (Objects.equals(sysUserDB.getStatus(), EnumStatus.DEL.getCode())) {
|
||||
throw new BusinessException("账户已删除");
|
||||
}
|
||||
return sysUserDB;
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查错误次数
|
||||
*
|
||||
* @param username
|
||||
*/
|
||||
private void checkLoginErrorNum(String username) {
|
||||
ValueOperations valueOperations = redisTemplate.opsForValue();
|
||||
String key = String.format(RedisKeys.SYS_USER_LOGIN_ERROR_NUM, username);
|
||||
Object errorNumObj = valueOperations.get(key);
|
||||
if (errorNumObj != null && Integer.parseInt(errorNumObj.toString()) > 4) {
|
||||
throw new BusinessException("错误次数过多,请过半小时后再试!");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updatePassword(String oldPassword, String newPassword, Long sysUserId) {
|
||||
SysUser sysUser = new SysUser();
|
||||
sysUser.setId(sysUserId);
|
||||
SysUser sysUserDB = sysUserMapper.getOne(sysUser);
|
||||
if (Objects.isNull(sysUserDB) || !bCryptPasswordEncoder.matches(oldPassword, sysUserDB.getPassword())) {
|
||||
throw new BusinessException("旧密码输入有误!");
|
||||
}
|
||||
sysUserDB.setPassword(bCryptPasswordEncoder.encode(newPassword));
|
||||
updateSelectiveById(sysUserDB);
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证用户登陆错误次数
|
||||
*
|
||||
* @param username
|
||||
*/
|
||||
@Override
|
||||
public void checkLoginErrorNumByUsername(String username) {
|
||||
String key = String.format(RedisKeys.SYS_USER_LOGIN_ERROR_NUM, username);
|
||||
ValueOperations valueOperations = redisTemplate.opsForValue();
|
||||
Object errorNumObj = valueOperations.get(key);
|
||||
int errorNum = 1;
|
||||
if (errorNumObj != null) {
|
||||
errorNum += Integer.parseInt(errorNumObj.toString());
|
||||
}
|
||||
valueOperations.set(key, String.valueOf(errorNum), 30, TimeUnit.MINUTES);
|
||||
if (errorNum > 4) {
|
||||
throw new BusinessException("错误次数过多,请过半小时后再试!");
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isEmailExist(SysUser sysUserReq) {
|
||||
return getOneByEmail(sysUserReq.getEmail()).map(item -> !item.getId().equals(sysUserReq.getId())).orElse(false);
|
||||
}
|
||||
|
||||
private Boolean isUsernameExist(SysUser sysUserReq) {
|
||||
return getOneByUsername(sysUserReq.getUsername()).map(item -> !item.getId().equals(sysUserReq.getId())).orElse(false);
|
||||
}
|
||||
|
||||
private Optional<SysUser> getOneByUsername(String username) {
|
||||
SysUser req = new SysUser();
|
||||
req.setUsername(username);
|
||||
return Optional.ofNullable(sysUserMapper.getOne(req));
|
||||
}
|
||||
|
||||
private Optional<SysUser> getOneByEmail(String email) {
|
||||
SysUser req = new SysUser();
|
||||
req.setEmail(email);
|
||||
return Optional.ofNullable(sysUserMapper.getOne(req));
|
||||
}
|
||||
|
||||
/**
|
||||
* 参数校验注解默认使用的方法
|
||||
*/
|
||||
private void checkStringLength(SysUser sysUser, boolean nullAble) {
|
||||
WJAssert.notNull(sysUser, "入参对象不能为空");
|
||||
WJAssert.limitMaxLength(sysUser.getUsername(), nullAble, 100, "用户名不合法!");
|
||||
WJAssert.limitMaxLength(sysUser.getPassword(), nullAble, 100, "密码不合法!");
|
||||
WJAssert.limitMaxLength(sysUser.getPhone(), true, 20, "手机不合法!");
|
||||
WJAssert.limitMaxLength(sysUser.getName(), true, 50, "姓名不合法!");
|
||||
WJAssert.limitMaxLength(sysUser.getEmail(), true, 100, "邮箱不合法!");
|
||||
WJAssert.limitMaxLength(sysUser.getOperator(), nullAble, 50, "操作人不合法!");
|
||||
WJAssert.limitMaxLength(sysUser.getRemark(), true, 255, "备注不合法!");
|
||||
}
|
||||
}
|
@ -0,0 +1,101 @@
|
||||
package com.arm.equipment.system.data.service.user;
|
||||
|
||||
import com.arm.equipment.system.data.domain.user.AppUser;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* APP用户
|
||||
*
|
||||
* @author admin
|
||||
* @date 2023年03月13日 22:34:47
|
||||
*/
|
||||
public interface IAppUserService {
|
||||
/**
|
||||
* 保存或更新
|
||||
* @param req
|
||||
*/
|
||||
void save(AppUser req, String operator);
|
||||
|
||||
/**
|
||||
* 插入
|
||||
*
|
||||
* @param appUser appUser
|
||||
* @return int
|
||||
*/
|
||||
int insertSelective(AppUser appUser);
|
||||
|
||||
/**
|
||||
* 主键更新
|
||||
*
|
||||
* @param appUser appUser
|
||||
* @return int
|
||||
*/
|
||||
int updateSelectiveById(AppUser appUser);
|
||||
|
||||
/**
|
||||
* 数量
|
||||
*
|
||||
* @param appUser appUser
|
||||
* @return int
|
||||
*/
|
||||
int getCount(AppUser appUser);
|
||||
|
||||
/**
|
||||
* 主键查询
|
||||
*
|
||||
* @param id id
|
||||
* @return AppUser
|
||||
*/
|
||||
AppUser getOneById(Long id);
|
||||
|
||||
/**
|
||||
* 多条
|
||||
*
|
||||
* @param appUser appUser
|
||||
* @return List<AppUser>
|
||||
*/
|
||||
List<AppUser> getList(AppUser appUser);
|
||||
|
||||
/**
|
||||
* 分页
|
||||
*
|
||||
* @param appUser appUser
|
||||
* @return List<AppUser>
|
||||
*/
|
||||
List<AppUser> getPageList(AppUser appUser);
|
||||
|
||||
/**
|
||||
* 审核
|
||||
* @param id
|
||||
* @param operator
|
||||
*/
|
||||
void audit(Long id, String operator);
|
||||
|
||||
/**
|
||||
* 取消审核
|
||||
* @param id
|
||||
* @param operator
|
||||
*/
|
||||
void unaudit(Long id, String operator);
|
||||
|
||||
/**
|
||||
* 删除
|
||||
* @param id
|
||||
* @param operator
|
||||
*/
|
||||
void delete(Long id, String operator);
|
||||
|
||||
/**
|
||||
* 登录
|
||||
* @param req
|
||||
* @return
|
||||
*/
|
||||
AppUser login(AppUser req);
|
||||
|
||||
/**
|
||||
* 注册
|
||||
* @param req
|
||||
*/
|
||||
void saveUser(AppUser req);
|
||||
}
|
@ -0,0 +1,172 @@
|
||||
package com.arm.equipment.system.data.service.user.impl;
|
||||
|
||||
import com.arm.equipment.system.data.exception.BusinessException;
|
||||
import com.arm.equipment.system.data.util.WJAssert;
|
||||
import com.arm.equipment.system.data.enums.dict.EnumStatus;
|
||||
import com.arm.equipment.system.data.service.common.IIdWorkerService;
|
||||
import com.arm.equipment.system.data.mapper.user.IAppUserMapper;
|
||||
import com.arm.equipment.system.data.domain.user.AppUser;
|
||||
import com.arm.equipment.system.data.service.user.IAppUserService;
|
||||
import com.arm.equipment.system.data.util.passwordEncoder.BCryptPasswordEncoderUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* APP用户
|
||||
*
|
||||
* @author admin
|
||||
* @date 2023年03月13日 22:34:47
|
||||
*/
|
||||
@Service
|
||||
public class AppUserServiceImpl implements IAppUserService {
|
||||
@Autowired
|
||||
private IAppUserMapper appUserMapper;
|
||||
@Autowired
|
||||
private IIdWorkerService idWorkerService;
|
||||
@Autowired
|
||||
private BCryptPasswordEncoderUtils bCryptPasswordEncoder;
|
||||
|
||||
@Override
|
||||
public void save(AppUser req, String operator) {
|
||||
req.setOperator(operator);
|
||||
if (null == req.getId()) {
|
||||
insertSelective(req);
|
||||
} else {
|
||||
updateSelectiveById(req);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int insertSelective(AppUser req) {
|
||||
req.setId(idWorkerService.getNextId());
|
||||
req.setStatus(EnumStatus.NEW.getCode());
|
||||
checkStringLength(req, false);
|
||||
return appUserMapper.insertSelective(req);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int updateSelectiveById(AppUser appUser) {
|
||||
WJAssert.notNull(appUser, "入参对象不能为空");
|
||||
WJAssert.notNull(appUser.getId(), "id参数错误");
|
||||
AppUser where = new AppUser();
|
||||
where.setId(appUser.getId());
|
||||
return appUserMapper.updateSelective(appUser, where);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCount(AppUser appUser) {
|
||||
checkStringLength(appUser, true);
|
||||
return appUserMapper.getCount(appUser);
|
||||
}
|
||||
|
||||
|
||||
private boolean getCountByPhone(String phone) {
|
||||
WJAssert.notBlank(phone, "手机号非法");
|
||||
AppUser appUser = new AppUser();
|
||||
appUser.setPhone(phone);
|
||||
return appUserMapper.getCount(appUser) > 0;
|
||||
}
|
||||
|
||||
private boolean getCountByUsername(String username) {
|
||||
WJAssert.notBlank(username, "用户名非法");
|
||||
AppUser appUser = new AppUser();
|
||||
appUser.setUsername(username);
|
||||
return appUserMapper.getCount(appUser) > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AppUser getOneById(Long id) {
|
||||
WJAssert.notNull(id, "id参数错误");
|
||||
AppUser where = new AppUser();
|
||||
where.setId(id);
|
||||
return appUserMapper.getOne(where);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<AppUser> getList(AppUser appUser) {
|
||||
checkStringLength(appUser, true);
|
||||
return appUserMapper.getList(appUser);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<AppUser> getPageList(AppUser appUser) {
|
||||
checkStringLength(appUser, true);
|
||||
return appUserMapper.getPageList(appUser);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void audit(Long id, String operator) {
|
||||
AppUser req = new AppUser();
|
||||
req.setId(id);
|
||||
req.setOperator(operator);
|
||||
req.setStatus(EnumStatus.AUDIT.getCode());
|
||||
updateSelectiveById(req);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unaudit(Long id, String operator) {
|
||||
AppUser req = new AppUser();
|
||||
req.setId(id);
|
||||
req.setOperator(operator);
|
||||
req.setStatus(EnumStatus.NEW.getCode());
|
||||
updateSelectiveById(req);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(Long id, String operator) {
|
||||
AppUser req = new AppUser();
|
||||
req.setId(id);
|
||||
req.setOperator(operator);
|
||||
req.setStatus(EnumStatus.DEL.getCode());
|
||||
updateSelectiveById(req);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AppUser login(AppUser req) {
|
||||
WJAssert.notBlank(req.getUsername(), "账号非法");
|
||||
WJAssert.notBlank(req.getPassword(), "密码非法吗");
|
||||
AppUser where = new AppUser();
|
||||
where.setUsername(req.getUsername());
|
||||
AppUser appUserDB = appUserMapper.getOne(where);
|
||||
if (Objects.isNull(appUserDB) || !bCryptPasswordEncoder.matches(req.getPassword(), appUserDB.getPassword())) {
|
||||
throw new BusinessException("账户不存在或密码错误");
|
||||
}
|
||||
appUserDB.setPassword(null);
|
||||
appUserDB.setLoginTime(new Date());
|
||||
updateSelectiveById(appUserDB);
|
||||
return appUserDB;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveUser(AppUser req) {
|
||||
checkStringLength(req, false);
|
||||
req.setPassword(bCryptPasswordEncoder.encode(req.getPassword()));
|
||||
// 检查用户名
|
||||
if (getCountByPhone(req.getPhone())) {
|
||||
throw new BusinessException("用户名已存在");
|
||||
}
|
||||
// 检查用户名
|
||||
if (getCountByUsername(req.getUsername())) {
|
||||
throw new BusinessException("登录账号已存在");
|
||||
}
|
||||
req.setId(null);
|
||||
req.setLoginTime(new Date());
|
||||
insertSelective(req);
|
||||
}
|
||||
|
||||
/**
|
||||
* 参数校验注解默认使用的方法
|
||||
*/
|
||||
private void checkStringLength(AppUser appUser, boolean nullAble) {
|
||||
WJAssert.notNull(appUser, "入参对象不能为空");
|
||||
WJAssert.limitMaxLength(appUser.getNickname(), nullAble, 50, "用户昵称不合法!");
|
||||
WJAssert.limitMaxLength(appUser.getUsername(), nullAble, 20, "登录账号不合法!");
|
||||
WJAssert.limitMaxLength(appUser.getPassword(), nullAble, 100, "密码不合法!");
|
||||
WJAssert.limitMaxLength(appUser.getPhone(), nullAble, 11, "手机号不合法!");
|
||||
WJAssert.limitMaxLength(appUser.getRemark(), true, 255, "备注不合法!");
|
||||
}
|
||||
}
|
@ -0,0 +1,107 @@
|
||||
package com.arm.equipment.system.data.service.weaponry;
|
||||
|
||||
import com.arm.equipment.system.data.domain.weaponry.WeaponryLendRecord;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 装备武器借出记录
|
||||
*
|
||||
* @author admin
|
||||
* @date 2023年03月23日 09:20:19
|
||||
*/
|
||||
public interface IWeaponryLendRecordService {
|
||||
/**
|
||||
* 保存或更新
|
||||
*
|
||||
* @param req
|
||||
*/
|
||||
void save(WeaponryLendRecord req, String operator);
|
||||
|
||||
/**
|
||||
* 插入
|
||||
*
|
||||
* @param weaponryLendRecord weaponryLendRecord
|
||||
* @return int
|
||||
*/
|
||||
int insertSelective(WeaponryLendRecord weaponryLendRecord);
|
||||
|
||||
/**
|
||||
* 主键更新
|
||||
*
|
||||
* @param weaponryLendRecord weaponryLendRecord
|
||||
* @return int
|
||||
*/
|
||||
int updateSelectiveById(WeaponryLendRecord weaponryLendRecord);
|
||||
|
||||
/**
|
||||
* 数量
|
||||
*
|
||||
* @param weaponryLendRecord weaponryLendRecord
|
||||
* @return int
|
||||
*/
|
||||
int getCount(WeaponryLendRecord weaponryLendRecord);
|
||||
|
||||
/**
|
||||
* 主键查询
|
||||
*
|
||||
* @param id id
|
||||
* @return WeaponryLendRecord
|
||||
*/
|
||||
WeaponryLendRecord getOneById(Long id);
|
||||
|
||||
/**
|
||||
* 多条
|
||||
*
|
||||
* @param weaponryLendRecord weaponryLendRecord
|
||||
* @return List<WeaponryLendRecord>
|
||||
*/
|
||||
List<WeaponryLendRecord> getList(WeaponryLendRecord weaponryLendRecord);
|
||||
|
||||
/**
|
||||
* 分页
|
||||
*
|
||||
* @param weaponryLendRecord weaponryLendRecord
|
||||
* @return List<WeaponryLendRecord>
|
||||
*/
|
||||
List<WeaponryLendRecord> getPageList(WeaponryLendRecord weaponryLendRecord);
|
||||
|
||||
/**
|
||||
* 审核拒绝
|
||||
*
|
||||
* @param id
|
||||
* @param operator
|
||||
*/
|
||||
void refuse(Long id, String operator);
|
||||
|
||||
/**
|
||||
* 审核通过
|
||||
*
|
||||
* @param id
|
||||
* @param operator
|
||||
*/
|
||||
void adopt(Long id, String operator);
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*
|
||||
* @param id
|
||||
* @param operator
|
||||
*/
|
||||
void delete(Long id, String operator);
|
||||
|
||||
/**
|
||||
* 借出
|
||||
*
|
||||
* @param req
|
||||
*/
|
||||
void saveLend(WeaponryLendRecord req);
|
||||
|
||||
/**
|
||||
* 获取未归还得总数
|
||||
*
|
||||
* @param weaponryId
|
||||
* @return
|
||||
*/
|
||||
int getCountByWeaponryId(Long weaponryId);
|
||||
}
|
@ -0,0 +1,99 @@
|
||||
package com.arm.equipment.system.data.service.weaponry;
|
||||
|
||||
import com.arm.equipment.system.data.domain.weaponry.WeaponryReturnRecord;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 装备武器归还记录
|
||||
*
|
||||
* @author admin
|
||||
* @date 2023年03月23日 09:20:25
|
||||
*/
|
||||
public interface IWeaponryReturnRecordService {
|
||||
/**
|
||||
* 保存或更新
|
||||
*
|
||||
* @param req
|
||||
*/
|
||||
void save(WeaponryReturnRecord req, String operator);
|
||||
|
||||
/**
|
||||
* 插入
|
||||
*
|
||||
* @param weaponryReturnRecord weaponryReturnRecord
|
||||
* @return int
|
||||
*/
|
||||
int insertSelective(WeaponryReturnRecord weaponryReturnRecord);
|
||||
|
||||
/**
|
||||
* 主键更新
|
||||
*
|
||||
* @param weaponryReturnRecord weaponryReturnRecord
|
||||
* @return int
|
||||
*/
|
||||
int updateSelectiveById(WeaponryReturnRecord weaponryReturnRecord);
|
||||
|
||||
/**
|
||||
* 数量
|
||||
*
|
||||
* @param weaponryReturnRecord weaponryReturnRecord
|
||||
* @return int
|
||||
*/
|
||||
int getCount(WeaponryReturnRecord weaponryReturnRecord);
|
||||
|
||||
/**
|
||||
* 主键查询
|
||||
*
|
||||
* @param id id
|
||||
* @return WeaponryReturnRecord
|
||||
*/
|
||||
WeaponryReturnRecord getOneById(Long id);
|
||||
|
||||
/**
|
||||
* 多条
|
||||
*
|
||||
* @param weaponryReturnRecord weaponryReturnRecord
|
||||
* @return List<WeaponryReturnRecord>
|
||||
*/
|
||||
List<WeaponryReturnRecord> getList(WeaponryReturnRecord weaponryReturnRecord);
|
||||
|
||||
/**
|
||||
* 分页
|
||||
*
|
||||
* @param weaponryReturnRecord weaponryReturnRecord
|
||||
* @return List<WeaponryReturnRecord>
|
||||
*/
|
||||
List<WeaponryReturnRecord> getPageList(WeaponryReturnRecord weaponryReturnRecord);
|
||||
|
||||
/**
|
||||
* 审核
|
||||
*
|
||||
* @param id
|
||||
* @param operator
|
||||
*/
|
||||
void audit(Long id, String operator);
|
||||
|
||||
/**
|
||||
* 取消审核
|
||||
*
|
||||
* @param id
|
||||
* @param operator
|
||||
*/
|
||||
void unaudit(Long id, String operator);
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*
|
||||
* @param id
|
||||
* @param operator
|
||||
*/
|
||||
void delete(Long id, String operator);
|
||||
|
||||
/**
|
||||
* 保存退还记录
|
||||
*
|
||||
* @param lendRecordId
|
||||
*/
|
||||
void saveReturn(Long lendRecordId);
|
||||
}
|
@ -0,0 +1,88 @@
|
||||
package com.arm.equipment.system.data.service.weaponry;
|
||||
|
||||
import com.arm.equipment.system.data.domain.weaponry.Weaponry;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 装备武器
|
||||
*
|
||||
* @author admin
|
||||
* @date 2023年03月23日 10:29:48
|
||||
*/
|
||||
public interface IWeaponryService {
|
||||
/**
|
||||
* 保存或更新
|
||||
* @param req
|
||||
*/
|
||||
void save(Weaponry req, String operator);
|
||||
|
||||
/**
|
||||
* 插入
|
||||
*
|
||||
* @param weaponry weaponry
|
||||
* @return int
|
||||
*/
|
||||
int insertSelective(Weaponry weaponry);
|
||||
|
||||
/**
|
||||
* 主键更新
|
||||
*
|
||||
* @param weaponry weaponry
|
||||
* @return int
|
||||
*/
|
||||
int updateSelectiveById(Weaponry weaponry);
|
||||
|
||||
/**
|
||||
* 数量
|
||||
*
|
||||
* @param weaponry weaponry
|
||||
* @return int
|
||||
*/
|
||||
int getCount(Weaponry weaponry);
|
||||
|
||||
/**
|
||||
* 主键查询
|
||||
*
|
||||
* @param id id
|
||||
* @return Weaponry
|
||||
*/
|
||||
Weaponry getOneById(Long id);
|
||||
|
||||
/**
|
||||
* 多条
|
||||
*
|
||||
* @param weaponry weaponry
|
||||
* @return List<Weaponry>
|
||||
*/
|
||||
List<Weaponry> getList(Weaponry weaponry);
|
||||
|
||||
/**
|
||||
* 分页
|
||||
*
|
||||
* @param weaponry weaponry
|
||||
* @return List<Weaponry>
|
||||
*/
|
||||
List<Weaponry> getPageList(Weaponry weaponry);
|
||||
|
||||
/**
|
||||
* 审核
|
||||
* @param id
|
||||
* @param operator
|
||||
*/
|
||||
void audit(Long id, String operator);
|
||||
|
||||
/**
|
||||
* 取消审核
|
||||
* @param id
|
||||
* @param operator
|
||||
*/
|
||||
void unaudit(Long id, String operator);
|
||||
|
||||
/**
|
||||
* 删除
|
||||
* @param id
|
||||
* @param operator
|
||||
*/
|
||||
void delete(Long id, String operator);
|
||||
}
|
@ -0,0 +1,181 @@
|
||||
package com.arm.equipment.system.data.service.weaponry.impl;
|
||||
|
||||
import com.arm.equipment.system.data.domain.weaponry.Weaponry;
|
||||
import com.arm.equipment.system.data.domain.weaponry.WeaponryLendRecord;
|
||||
import com.arm.equipment.system.data.enums.dict.EnumStatus;
|
||||
import com.arm.equipment.system.data.enums.dict.EnumWeaponryLendRecordReturnStatus;
|
||||
import com.arm.equipment.system.data.enums.dict.EnumWeaponryLendRecordStatus;
|
||||
import com.arm.equipment.system.data.exception.BusinessException;
|
||||
import com.arm.equipment.system.data.mapper.weaponry.IWeaponryLendRecordMapper;
|
||||
import com.arm.equipment.system.data.service.common.IIdWorkerService;
|
||||
import com.arm.equipment.system.data.service.weaponry.IWeaponryLendRecordService;
|
||||
import com.arm.equipment.system.data.service.weaponry.IWeaponryService;
|
||||
import com.arm.equipment.system.data.util.WJAssert;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 装备武器借出记录
|
||||
*
|
||||
* @author admin
|
||||
* @date 2023年03月23日 09:20:19
|
||||
*/
|
||||
@Service
|
||||
public class WeaponryLendRecordServiceImpl implements IWeaponryLendRecordService {
|
||||
@Autowired
|
||||
private IWeaponryLendRecordMapper weaponryLendRecordMapper;
|
||||
@Autowired
|
||||
private IIdWorkerService idWorkerService;
|
||||
@Autowired
|
||||
private IWeaponryService weaponryService;
|
||||
|
||||
@Override
|
||||
public void save(WeaponryLendRecord req, String operator) {
|
||||
req.setOperator(operator);
|
||||
if (null == req.getId()) {
|
||||
insertSelective(req);
|
||||
} else {
|
||||
updateSelectiveById(req);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int insertSelective(WeaponryLendRecord req) {
|
||||
req.setId(idWorkerService.getNextId());
|
||||
req.setStatus(EnumStatus.NEW.getCode());
|
||||
checkStringLength(req, false);
|
||||
return weaponryLendRecordMapper.insertSelective(req);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int updateSelectiveById(WeaponryLendRecord weaponryLendRecord) {
|
||||
WJAssert.notNull(weaponryLendRecord, "入参对象不能为空");
|
||||
WJAssert.notNull(weaponryLendRecord.getId(), "id参数错误");
|
||||
WeaponryLendRecord where = new WeaponryLendRecord();
|
||||
where.setId(weaponryLendRecord.getId());
|
||||
return weaponryLendRecordMapper.updateSelective(weaponryLendRecord, where);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCount(WeaponryLendRecord weaponryLendRecord) {
|
||||
checkStringLength(weaponryLendRecord, true);
|
||||
return weaponryLendRecordMapper.getCount(weaponryLendRecord);
|
||||
}
|
||||
|
||||
@Override
|
||||
public WeaponryLendRecord getOneById(Long id) {
|
||||
WJAssert.notNull(id, "id参数错误");
|
||||
WeaponryLendRecord where = new WeaponryLendRecord();
|
||||
where.setId(id);
|
||||
return weaponryLendRecordMapper.getOne(where);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<WeaponryLendRecord> getList(WeaponryLendRecord weaponryLendRecord) {
|
||||
checkStringLength(weaponryLendRecord, true);
|
||||
return weaponryLendRecordMapper.getList(weaponryLendRecord);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<WeaponryLendRecord> getPageList(WeaponryLendRecord weaponryLendRecord) {
|
||||
checkStringLength(weaponryLendRecord, true);
|
||||
return weaponryLendRecordMapper.getPageList(weaponryLendRecord)
|
||||
.parallelStream()
|
||||
.peek(item -> {
|
||||
Weaponry weaponryDB = weaponryService.getOneById(item.getWeaponryId());
|
||||
item.setWeaponry(weaponryDB);
|
||||
}).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
/**
|
||||
* 拒绝
|
||||
*
|
||||
* @param id
|
||||
* @param operator
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void refuse(Long id, String operator) {
|
||||
WeaponryLendRecord req = new WeaponryLendRecord();
|
||||
req.setId(id);
|
||||
req.setOperator(operator);
|
||||
req.setStatus(EnumWeaponryLendRecordStatus.REFUSE.getCode());
|
||||
updateSelectiveById(req);
|
||||
|
||||
//拒绝通过 归还锁定库存
|
||||
WeaponryLendRecord weaponryLendRecordDB = getOneById(id);
|
||||
Weaponry weaponryDB = weaponryService.getOneById(weaponryLendRecordDB.getWeaponryId());
|
||||
weaponryDB.setLockInventory(weaponryDB.getLockInventory() - weaponryLendRecordDB.getNum());
|
||||
weaponryService.updateSelectiveById(weaponryDB);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过
|
||||
*
|
||||
* @param id
|
||||
* @param operator
|
||||
*/
|
||||
@Override
|
||||
public void adopt(Long id, String operator) {
|
||||
WeaponryLendRecord req = new WeaponryLendRecord();
|
||||
req.setId(id);
|
||||
req.setOperator(operator);
|
||||
req.setStatus(EnumWeaponryLendRecordStatus.ADOPT.getCode());
|
||||
updateSelectiveById(req);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(Long id, String operator) {
|
||||
WeaponryLendRecord req = new WeaponryLendRecord();
|
||||
req.setId(id);
|
||||
req.setOperator(operator);
|
||||
req.setStatus(EnumStatus.DEL.getCode());
|
||||
updateSelectiveById(req);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void saveLend(WeaponryLendRecord req) {
|
||||
WJAssert.notNull(req.getNum(), "数量非法");
|
||||
WJAssert.notNull(req.getReturnTime(), "归还时间非法");
|
||||
WJAssert.notNull(req.getWeaponryId(), "装备非法");
|
||||
if (req.getNum() < 0) {
|
||||
throw new BusinessException("数量非法");
|
||||
}
|
||||
Weaponry weaponryDB = Optional.ofNullable(weaponryService.getOneById(req.getWeaponryId()))
|
||||
.orElseThrow(() -> new BusinessException("装备不存在"));
|
||||
//剩余库存 = 总库存 - 锁定库存
|
||||
if ((weaponryDB.getTotalInventory() - weaponryDB.getLockInventory()) < req.getNum()) {
|
||||
throw new BusinessException("库存不足");
|
||||
}
|
||||
req.setWeaponryName(weaponryDB.getName());
|
||||
insertSelective(req);
|
||||
|
||||
//增加锁定库存
|
||||
weaponryDB.setLockInventory(weaponryDB.getLockInventory() + req.getNum());
|
||||
weaponryService.updateSelectiveById(weaponryDB);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCountByWeaponryId(Long weaponryId) {
|
||||
WeaponryLendRecord where = new WeaponryLendRecord();
|
||||
where.setWeaponryId(weaponryId);
|
||||
where.setReturnStatus(EnumWeaponryLendRecordReturnStatus.NOT_RETURN.getCode());
|
||||
where.setStatus(EnumWeaponryLendRecordStatus.ADOPT.getCode());
|
||||
return getCount(where);
|
||||
}
|
||||
|
||||
/**
|
||||
* 参数校验注解默认使用的方法
|
||||
*/
|
||||
private void checkStringLength(WeaponryLendRecord weaponryLendRecord, boolean nullAble) {
|
||||
WJAssert.notNull(weaponryLendRecord, "入参对象不能为空");
|
||||
WJAssert.limitMaxLength(weaponryLendRecord.getRemark(), true, 255, "备注不合法!");
|
||||
}
|
||||
}
|
@ -0,0 +1,162 @@
|
||||
package com.arm.equipment.system.data.service.weaponry.impl;
|
||||
|
||||
import com.arm.equipment.system.data.domain.weaponry.Weaponry;
|
||||
import com.arm.equipment.system.data.domain.weaponry.WeaponryLendRecord;
|
||||
import com.arm.equipment.system.data.domain.weaponry.WeaponryReturnRecord;
|
||||
import com.arm.equipment.system.data.enums.dict.EnumStatus;
|
||||
import com.arm.equipment.system.data.enums.dict.EnumWeaponryLendRecordReturnStatus;
|
||||
import com.arm.equipment.system.data.enums.dict.EnumWeaponryLendRecordStatus;
|
||||
import com.arm.equipment.system.data.exception.BusinessException;
|
||||
import com.arm.equipment.system.data.mapper.weaponry.IWeaponryReturnRecordMapper;
|
||||
import com.arm.equipment.system.data.service.common.IIdWorkerService;
|
||||
import com.arm.equipment.system.data.service.weaponry.IWeaponryLendRecordService;
|
||||
import com.arm.equipment.system.data.service.weaponry.IWeaponryReturnRecordService;
|
||||
import com.arm.equipment.system.data.service.weaponry.IWeaponryService;
|
||||
import com.arm.equipment.system.data.util.WJAssert;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 装备武器归还记录
|
||||
*
|
||||
* @author admin
|
||||
* @date 2023年03月23日 09:20:25
|
||||
*/
|
||||
@Service
|
||||
public class WeaponryReturnRecordServiceImpl implements IWeaponryReturnRecordService {
|
||||
@Autowired
|
||||
private IWeaponryReturnRecordMapper weaponryReturnRecordMapper;
|
||||
@Autowired
|
||||
private IIdWorkerService idWorkerService;
|
||||
@Autowired
|
||||
private IWeaponryLendRecordService weaponryLendRecordService;
|
||||
@Autowired
|
||||
private IWeaponryService weaponryService;
|
||||
|
||||
@Override
|
||||
public void save(WeaponryReturnRecord req, String operator) {
|
||||
req.setOperator(operator);
|
||||
if (null == req.getId()) {
|
||||
insertSelective(req);
|
||||
} else {
|
||||
updateSelectiveById(req);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int insertSelective(WeaponryReturnRecord req) {
|
||||
req.setId(idWorkerService.getNextId());
|
||||
req.setStatus(EnumStatus.NEW.getCode());
|
||||
checkStringLength(req, false);
|
||||
return weaponryReturnRecordMapper.insertSelective(req);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int updateSelectiveById(WeaponryReturnRecord weaponryReturnRecord) {
|
||||
WJAssert.notNull(weaponryReturnRecord, "入参对象不能为空");
|
||||
WJAssert.notNull(weaponryReturnRecord.getId(), "id参数错误");
|
||||
WeaponryReturnRecord where = new WeaponryReturnRecord();
|
||||
where.setId(weaponryReturnRecord.getId());
|
||||
return weaponryReturnRecordMapper.updateSelective(weaponryReturnRecord, where);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCount(WeaponryReturnRecord weaponryReturnRecord) {
|
||||
checkStringLength(weaponryReturnRecord, true);
|
||||
return weaponryReturnRecordMapper.getCount(weaponryReturnRecord);
|
||||
}
|
||||
|
||||
@Override
|
||||
public WeaponryReturnRecord getOneById(Long id) {
|
||||
WJAssert.notNull(id, "id参数错误");
|
||||
WeaponryReturnRecord where = new WeaponryReturnRecord();
|
||||
where.setId(id);
|
||||
return weaponryReturnRecordMapper.getOne(where);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<WeaponryReturnRecord> getList(WeaponryReturnRecord weaponryReturnRecord) {
|
||||
checkStringLength(weaponryReturnRecord, true);
|
||||
return weaponryReturnRecordMapper.getList(weaponryReturnRecord);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<WeaponryReturnRecord> getPageList(WeaponryReturnRecord weaponryReturnRecord) {
|
||||
checkStringLength(weaponryReturnRecord, true);
|
||||
return weaponryReturnRecordMapper.getPageList(weaponryReturnRecord)
|
||||
.parallelStream()
|
||||
.peek(item -> {
|
||||
Weaponry weaponryDB = weaponryService.getOneById(item.getWeaponryId());
|
||||
item.setWeaponry(weaponryDB);
|
||||
}).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void audit(Long id, String operator) {
|
||||
WeaponryReturnRecord req = new WeaponryReturnRecord();
|
||||
req.setId(id);
|
||||
req.setOperator(operator);
|
||||
req.setStatus(EnumStatus.AUDIT.getCode());
|
||||
updateSelectiveById(req);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unaudit(Long id, String operator) {
|
||||
WeaponryReturnRecord req = new WeaponryReturnRecord();
|
||||
req.setId(id);
|
||||
req.setOperator(operator);
|
||||
req.setStatus(EnumStatus.NEW.getCode());
|
||||
updateSelectiveById(req);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(Long id, String operator) {
|
||||
WeaponryReturnRecord req = new WeaponryReturnRecord();
|
||||
req.setId(id);
|
||||
req.setOperator(operator);
|
||||
req.setStatus(EnumStatus.DEL.getCode());
|
||||
updateSelectiveById(req);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void saveReturn(Long lendRecordId) {
|
||||
WJAssert.notNull(lendRecordId, "ID非法");
|
||||
WeaponryLendRecord weaponryLendRecordDB = Optional.ofNullable(weaponryLendRecordService.getOneById(lendRecordId))
|
||||
.orElseThrow(() -> new BusinessException("借出记录不存在"));
|
||||
if (!EnumWeaponryLendRecordStatus.ADOPT.getCode().equals(weaponryLendRecordDB.getStatus())
|
||||
|| !EnumWeaponryLendRecordReturnStatus.NOT_RETURN.getCode().equals(weaponryLendRecordDB.getReturnStatus())) {
|
||||
throw new BusinessException("数据非法");
|
||||
}
|
||||
WeaponryReturnRecord req = new WeaponryReturnRecord();
|
||||
req.setWeaponryId(weaponryLendRecordDB.getWeaponryId());
|
||||
req.setLendRecordId(weaponryLendRecordDB.getId());
|
||||
req.setNum(weaponryLendRecordDB.getNum());
|
||||
req.setReturnTime(weaponryLendRecordDB.getReturnTime());
|
||||
req.setWeaponryName(weaponryLendRecordDB.getWeaponryName());
|
||||
insertSelective(req);
|
||||
|
||||
//修改借出归还状态
|
||||
weaponryLendRecordDB.setReturnStatus(EnumWeaponryLendRecordReturnStatus.RETURN.getCode());
|
||||
weaponryLendRecordService.updateSelectiveById(weaponryLendRecordDB);
|
||||
|
||||
//扣除锁定库存
|
||||
Weaponry weaponryDB = Optional.ofNullable(weaponryService.getOneById(weaponryLendRecordDB.getWeaponryId()))
|
||||
.orElseThrow(() -> new BusinessException("武器不存在"));
|
||||
weaponryDB.setLockInventory(weaponryDB.getLockInventory() - weaponryLendRecordDB.getNum());
|
||||
weaponryService.updateSelectiveById(weaponryDB);
|
||||
}
|
||||
|
||||
/**
|
||||
* 参数校验注解默认使用的方法
|
||||
*/
|
||||
private void checkStringLength(WeaponryReturnRecord weaponryReturnRecord, boolean nullAble) {
|
||||
WJAssert.notNull(weaponryReturnRecord, "入参对象不能为空");
|
||||
WJAssert.limitMaxLength(weaponryReturnRecord.getRemark(), true, 255, "备注不合法!");
|
||||
}
|
||||
}
|
@ -0,0 +1,117 @@
|
||||
package com.arm.equipment.system.data.service.weaponry.impl;
|
||||
|
||||
import com.arm.equipment.system.data.enums.dict.EnumStatus;
|
||||
import com.arm.equipment.system.data.util.WJAssert;
|
||||
import com.arm.equipment.system.data.service.common.IIdWorkerService;
|
||||
import com.arm.equipment.system.data.mapper.weaponry.IWeaponryMapper;
|
||||
import com.arm.equipment.system.data.domain.weaponry.Weaponry;
|
||||
import com.arm.equipment.system.data.service.weaponry.IWeaponryService;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 装备武器
|
||||
*
|
||||
* @author admin
|
||||
* @date 2023年03月23日 10:29:48
|
||||
*/
|
||||
@Service
|
||||
public class WeaponryServiceImpl implements IWeaponryService {
|
||||
@Autowired
|
||||
private IWeaponryMapper weaponryMapper;
|
||||
@Autowired
|
||||
private IIdWorkerService idWorkerService;
|
||||
|
||||
@Override
|
||||
public void save(Weaponry req, String operator) {
|
||||
req.setOperator(operator);
|
||||
if (null == req.getId()) {
|
||||
insertSelective(req);
|
||||
} else {
|
||||
updateSelectiveById(req);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int insertSelective(Weaponry req) {
|
||||
req.setId(idWorkerService.getNextId());
|
||||
req.setStatus(EnumStatus.NEW.getCode());
|
||||
checkStringLength(req, false);
|
||||
return weaponryMapper.insertSelective(req);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int updateSelectiveById(Weaponry weaponry) {
|
||||
WJAssert.notNull(weaponry, "入参对象不能为空");
|
||||
WJAssert.notNull(weaponry.getId(), "id参数错误");
|
||||
Weaponry where = new Weaponry();
|
||||
where.setId(weaponry.getId());
|
||||
return weaponryMapper.updateSelective(weaponry, where);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCount(Weaponry weaponry) {
|
||||
checkStringLength(weaponry, true);
|
||||
return weaponryMapper.getCount(weaponry);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Weaponry getOneById(Long id) {
|
||||
WJAssert.notNull(id, "id参数错误");
|
||||
Weaponry where = new Weaponry();
|
||||
where.setId(id);
|
||||
return weaponryMapper.getOne(where);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Weaponry> getList(Weaponry weaponry) {
|
||||
checkStringLength(weaponry, true);
|
||||
return weaponryMapper.getList(weaponry);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Weaponry> getPageList(Weaponry weaponry) {
|
||||
checkStringLength(weaponry, true);
|
||||
return weaponryMapper.getPageList(weaponry);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void audit(Long id, String operator) {
|
||||
Weaponry req = new Weaponry();
|
||||
req.setId(id);
|
||||
req.setOperator(operator);
|
||||
req.setStatus(EnumStatus.AUDIT.getCode());
|
||||
updateSelectiveById(req);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unaudit(Long id, String operator) {
|
||||
Weaponry req = new Weaponry();
|
||||
req.setId(id);
|
||||
req.setOperator(operator);
|
||||
req.setStatus(EnumStatus.NEW.getCode());
|
||||
updateSelectiveById(req);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(Long id, String operator) {
|
||||
Weaponry req = new Weaponry();
|
||||
req.setId(id);
|
||||
req.setOperator(operator);
|
||||
req.setStatus(EnumStatus.DEL.getCode());
|
||||
updateSelectiveById(req);
|
||||
}
|
||||
|
||||
/**
|
||||
* 参数校验注解默认使用的方法
|
||||
*/
|
||||
private void checkStringLength(Weaponry weaponry, boolean nullAble) {
|
||||
WJAssert.notNull(weaponry, "入参对象不能为空");
|
||||
WJAssert.limitMaxLength(weaponry.getName(), nullAble, 50, "武器名称不合法!");
|
||||
WJAssert.limitMaxLength(weaponry.getImgPath(), nullAble, 200, "武器封面不合法!");
|
||||
WJAssert.limitMaxLength(weaponry.getRemark(), true, 255, "备注不合法!");
|
||||
}
|
||||
}
|
@ -0,0 +1,96 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-parent</artifactId>
|
||||
<version>2.7.5</version> <!-- lookup parent from repository -->
|
||||
</parent>
|
||||
<packaging>pom</packaging>
|
||||
<groupId>com.arm.equipment.system</groupId>
|
||||
<artifactId>arm-equipment-system-parent</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<name>arm-equipment-system-parent</name>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||
<java.version>1.8</java.version>
|
||||
</properties>
|
||||
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
<!-- https://mvnrepository.com/artifact/com.alibaba/fastjson -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>fastjson</artifactId>
|
||||
<version>1.2.83</version>
|
||||
</dependency>
|
||||
<!-- https://mvnrepository.com/artifact/org.mybatis.spring.boot/mybatis-spring-boot-starter -->
|
||||
<dependency>
|
||||
<groupId>org.mybatis.spring.boot</groupId>
|
||||
<artifactId>mybatis-spring-boot-starter</artifactId>
|
||||
<version>1.3.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>mysql</groupId>
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
<version>8.0.18</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-lang3</artifactId>
|
||||
<version>3.7</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>javax.servlet</groupId>
|
||||
<artifactId>javax.servlet-api</artifactId>
|
||||
<version>4.0.1</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>spring-snapshots</id>
|
||||
<name>Spring Snapshots</name>
|
||||
<url>https://repo.spring.io/snapshot</url>
|
||||
<snapshots>
|
||||
</snapshots>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>spring-milestones</id>
|
||||
<name>Spring Milestones</name>
|
||||
<url>https://repo.spring.io/milestone</url>
|
||||
<snapshots>
|
||||
<enabled>false</enabled>
|
||||
</snapshots>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<pluginRepositories>
|
||||
<pluginRepository>
|
||||
<id>spring-snapshots</id>
|
||||
<name>Spring Snapshots</name>
|
||||
<url>https://repo.spring.io/snapshot</url>
|
||||
<snapshots>
|
||||
</snapshots>
|
||||
</pluginRepository>
|
||||
<pluginRepository>
|
||||
<id>spring-milestones</id>
|
||||
<name>Spring Milestones</name>
|
||||
<url>https://repo.spring.io/milestone</url>
|
||||
<snapshots>
|
||||
<enabled>false</enabled>
|
||||
</snapshots>
|
||||
</pluginRepository>
|
||||
</pluginRepositories>
|
||||
|
||||
<modules>
|
||||
<module>data</module>
|
||||
<module>admin</module>
|
||||
<module>api</module>
|
||||
</modules>
|
||||
</project>
|
@ -1 +0,0 @@
|
||||
1
|
Loading…
Reference in new issue