master
熊正 2 years ago
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,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 20211026 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();
}
/**
* codevalue
*
* @param unicode
* @return
*/
@PostMapping("/selectValueByUnicode")
public RespJSON selectValueByUnicode(String unicode) {
WJAssert.isMaxLength(unicode, 33, "参数非法");
String value = sysBaseParamService.getOneByUniCode(unicode).getValue();
return RespJSON.success(value);
}
/**
* codevalue
*
* @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 20220916 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 20211019 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 20211019 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 20211019 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 20211019 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 20211019 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 20230313 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 20230323 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 20230323 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 20230323 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 202011415: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,76 @@
package com.arm.equipment.system.api.controller.weaponry;
import com.arm.equipment.system.api.controller.BaseController;
import com.arm.equipment.system.data.domain.weaponry.Weaponry;
import com.arm.equipment.system.data.enums.dict.EnumStatus;
import com.arm.equipment.system.data.enums.dict.EnumYesNo;
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 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;
import java.util.stream.Collectors;
/**
*
*
* @author admin
* @date 20230322 10:39:04
*/
@RestController
@RequestMapping("/weaponry/weaponry")
public class WeaponryAction extends BaseController {
@Autowired
private IWeaponryService weaponryService;
@Autowired
private IWeaponryLendRecordService weaponryLendRecordService;
/**
*
*
* @param weaponryReq weaponryReq
* @return RespJSON
*/
@PostMapping("/getPageList")
public RespJSON getPageList(@RequestBody Weaponry weaponryReq) {
WJAssert.notNull(weaponryReq.getPageNo(), "参数非法");
WJAssert.notNull(weaponryReq.getPageSize(), "参数非法");
weaponryReq.setStatus(EnumStatus.AUDIT.getCode());
List<Weaponry> list = weaponryService.getPageList(weaponryReq)
.parallelStream()
.peek(item -> {
item.setIsLend(EnumYesNo.NO.getCode());
//判断是否已借出
int count = weaponryLendRecordService.getCountByWeaponryId(item.getId());
if (count > 0) {
item.setIsLend(EnumYesNo.YES.getCode());
}
}).collect(Collectors.toList());
return RespJSON.success(list);
}
/**
* 1
*
* @param weaponryReq weaponryReq
* @return RespJSON
*/
@PostMapping("/getLocationWarningPageList")
public RespJSON getLocationWarningPageList(@RequestBody Weaponry weaponryReq) {
WJAssert.notNull(weaponryReq.getPageNo(), "参数非法");
WJAssert.notNull(weaponryReq.getPageSize(), "参数非法");
weaponryReq.setStatus(EnumStatus.AUDIT.getCode());
weaponryReq.setLockInventoryStart(1);
List<Weaponry> list = weaponryService.getPageList(weaponryReq);
return RespJSON.success(list);
}
}

@ -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 20230322 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 20230322 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 20211026 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 20220916 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 20211019 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 20211019 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 20211019 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 20211019 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 20211019 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 20230313 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 20230323 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 20230323 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 20230323 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
* 0null
* @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,15 @@
package com.arm.equipment.system.data.service.common;
/**
* id
*/
public interface IIdWorkerService {
/**
* id
* long9223372036854775807
*
* @return
*/
long getNextId();
}

@ -0,0 +1,36 @@
package com.arm.equipment.system.data.service.common;
import com.arm.equipment.system.data.vo.system.VerifyCodeVO;
import java.io.IOException;
import java.io.OutputStream;
/**
*
*
* @author Ousei
* @date 202071715:27:07
*/
public interface IVerifyCodeService {
/**
* codeos
*
* @param width
* @param height
* @param os
* @return
* @throws IOException
*/
String generate(int width, int height, OutputStream os) throws IOException;
/**
*
*
* @param width
* @param height
* @return
* @throws IOException
*/
VerifyCodeVO generate(int width, int height) throws IOException;
}

@ -0,0 +1,65 @@
package com.arm.equipment.system.data.service.common.impl;
import com.arm.equipment.system.data.exception.BusinessException;
import com.arm.equipment.system.data.service.common.IDictService;
import com.arm.equipment.system.data.vo.dict.DictVO;
import org.springframework.stereotype.Service;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List;
/**
*
*
* @author admin
*/
@Service
public class DictServiceImpl implements IDictService {
/**
*
*/
String DICT_BASE_PACKAGE = "com.arm.equipment.system.data.enums.dict";
@Override
public List<DictVO> getDictData(String name) {
return getEnumDict(name);
}
/**
*
*
* @param name , DICT_BASE_PACKAGE
* @return
*/
private List<DictVO> getEnumDict(String name) {
String className = DICT_BASE_PACKAGE + "." + name;
Method method;
try {
method = Class.forName(className).getMethod("values");
} catch (NoSuchMethodException e) {
throw new BusinessException("枚举类反射异常不存在的方法method=values");
} catch (ClassNotFoundException e) {
throw new BusinessException(String.format("枚举类反射异常不存在的枚举类className=%s", className));
}
try {
Object invoke = method.invoke(null);
Object[] list = (Object[]) invoke;
List<DictVO> voList = new ArrayList<>();
for (Object o : list) {
Object enumCode = o.getClass().getMethod("getCode").invoke(o);
String enumText = o.getClass().getMethod("getText").invoke(o).toString();
DictVO vo = new DictVO(enumCode.toString(), enumText);
voList.add(vo);
}
return voList;
} catch (IllegalAccessException | InvocationTargetException e) {
throw new BusinessException(String.format("枚举类反射异常:方法[%s]执行失败!", method.getName()));
} catch (NoSuchMethodException e) {
throw new BusinessException(String.format("枚举类反射异常:方法[%s]不存在!", method.getName()));
}
}
}

@ -0,0 +1,159 @@
package com.arm.equipment.system.data.service.common.impl;
import com.arm.equipment.system.data.service.common.IIdWorkerService;
import com.arm.equipment.system.data.constant.RedisKeys;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
import javax.annotation.PostConstruct;
/**
* Twitter_Snowflake<br>
* SnowFlake(-):<br>
* 0 - 0000000000 0000000000 0000000000 0000000000 0 - 00000 - 00000 - 000000000000 <br>
* 1longJava01id0<br>
* 41()41 - )
* id使IdWorkerstartTime41使69T = (1L << 41) / (1000L * 60 * 60 * 24 * 365) = 69<br>
* 1010245datacenterId5workerId<br>
* 1212()4096ID<br>
* 64Long<br>
* SnowFlakeID(IDID)SnowFlake26ID
*/
@Service
public class IdWorkerServiceImpl implements IIdWorkerService {
private final static Logger logger = LoggerFactory.getLogger(IdWorkerServiceImpl.class);
@Autowired
private RedisTemplate redisTemplate;
/**
* (Thu Mar 05 2020 11:57:29 GMT+0800)
*/
private final long twepoch = 1583380649557L;
/**
* id
*/
private final static long WORKER_ID_BITS = 5L;
/**
* id
*/
private final long datacenterIdBits = 5L;
/**
* id31 ()
*/
private final static long MAX_WORKER_ID = -1L ^ (-1L << WORKER_ID_BITS);
/**
* id31
*/
private final long maxDatacenterId = -1L ^ (-1L << datacenterIdBits);
/**
* id
*/
private final long sequenceBits = 12L;
/**
* ID12
*/
private final long workerIdShift = sequenceBits;
/**
* id17(12+5)
*/
private final long datacenterIdShift = sequenceBits + WORKER_ID_BITS;
/**
* 22(5+5+12)
*/
private final long timestampLeftShift = sequenceBits + WORKER_ID_BITS + datacenterIdBits;
/**
* 4095 (0b111111111111=0xfff=4095)
*/
private final long sequenceMask = -1L ^ (-1L << sequenceBits);
/**
* ID(0~31)
*/
private Long workerId = (long) (Math.random() * 32);
/**
* ID(0~31)
*/
private static long datacenterId = 0;
/**
* (0~4095)
*/
private long sequence = 0L;
/**
* ID
*/
private long lastTimestamp = -1L;
/**
* worker id
* 1.redis
* 2.32(0~31)
*/
@PostConstruct
public void init() {
Long increment = redisTemplate.opsForValue().increment(RedisKeys.SNOW_FLAKE_WORKER_ID);
workerId = increment % 32;
logger.info("当前机器 workerId: {}", workerId);
}
/**
* ID (线)
*
* @return SnowflakeId
*/
@Override
public synchronized long getNextId() {
long timestamp = timeGen();
//如果当前时间小于上一次ID生成的时间戳说明系统时钟回退过这个时候应当抛出异常
if (timestamp < lastTimestamp) {
throw new RuntimeException(String.format("Clock moved backwards. Refusing to generate id for %d milliseconds", lastTimestamp - timestamp));
}
//如果是同一时间生成的,则进行毫秒内序列
if (lastTimestamp == timestamp) {
sequence = (sequence + 1) & sequenceMask;
//毫秒内序列溢出
if (sequence == 0) {
//阻塞到下一个毫秒,获得新的时间戳
timestamp = tilNextMillis(lastTimestamp);
}
}
//时间戳改变,毫秒内序列重置
else {
sequence = 0L;
}
//上次生成ID的时间截
lastTimestamp = timestamp;
//移位并通过或运算拼到一起组成64位的ID
long id = ((timestamp - twepoch) << timestampLeftShift)
| (datacenterId << datacenterIdShift)
| (workerId << workerIdShift)
| sequence;
return id;
}
/**
*
*
* @param lastTimestamp ID
* @return
*/
private long tilNextMillis(long lastTimestamp) {
long timestamp = timeGen();
while (timestamp <= lastTimestamp) {
timestamp = timeGen();
}
return timestamp;
}
/**
*
*
* @return ()
*/
private static long timeGen() {
return System.currentTimeMillis();
}
}

@ -0,0 +1,110 @@
package com.arm.equipment.system.data.service.common.impl;
import com.arm.equipment.system.data.service.common.IVerifyCodeService;
import com.arm.equipment.system.data.util.RandomUtils;
import com.arm.equipment.system.data.vo.system.VerifyCodeVO;
import org.springframework.stereotype.Service;
import javax.imageio.ImageIO;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.Random;
@Service
public class VerifyCodeServiceImpl implements IVerifyCodeService {
private static final String[] FONT_TYPES = {"\u5b8b\u4f53", "\u65b0\u5b8b\u4f53", "\u9ed1\u4f53", "\u6977\u4f53", "\u96b6\u4e66"};
private static final int VALICATE_CODE_LENGTH = 4;
/**
* 线
*
* @param graphics
* @param width
* @param height
*/
private static void fillBackground(Graphics graphics, int width, int height) {
// 填充背景
graphics.setColor(Color.WHITE);
//设置矩形坐标x y 为0
graphics.fillRect(0, 0, width, height);
// 加入干扰线条
for (int i = 0; i < 8; i++) {
//设置随机颜色算法参数
graphics.setColor(RandomUtils.randomColor(40, 150));
Random random = new Random();
int x = random.nextInt(width);
int y = random.nextInt(height);
int x1 = random.nextInt(width);
int y1 = random.nextInt(height);
graphics.drawLine(x, y, x1, y1);
}
}
/**
*
*
* @param width
* @param height
* @param os
* @return
* @throws IOException
*/
@Override
public String generate(int width, int height, OutputStream os) throws IOException {
BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
Graphics graphics = image.getGraphics();
fillBackground(graphics, width, height);
String randomStr = RandomUtils.randomString(VALICATE_CODE_LENGTH);
createCharacter(graphics, randomStr);
graphics.dispose();
//设置JPEG格式
ImageIO.write(image, "JPEG", os);
return randomStr;
}
/**
*
*
* @param width
* @param height
* @return
*/
@Override
public VerifyCodeVO generate(int width, int height) {
VerifyCodeVO verifyCode = null;
//将流的初始化放到这里就不需要手动关闭流
try (ByteArrayOutputStream baos = new ByteArrayOutputStream()) {
String code = generate(width, height, baos);
verifyCode = new VerifyCodeVO();
verifyCode.setCode(code);
verifyCode.setImgBytes(baos.toByteArray());
} catch (IOException e) {
verifyCode = null;
}
return verifyCode;
}
/**
*
*
* @param g
* @param randomStr
*/
private void createCharacter(Graphics g, String randomStr) {
char[] charArray = randomStr.toCharArray();
for (int i = 0; i < charArray.length; i++) {
//设置RGB颜色算法参数
g.setColor(new Color(50 + RandomUtils.nextInt(100),
50 + RandomUtils.nextInt(100), 50 + RandomUtils.nextInt(100)));
//设置字体大小,类型
g.setFont(new Font(FONT_TYPES[RandomUtils.nextInt(FONT_TYPES.length)], Font.BOLD, 26));
//设置x y 坐标
g.drawString(String.valueOf(charArray[i]), 15 * i + 5, 19 + RandomUtils.nextInt(8));
}
}
}

@ -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 20211026 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 20220916 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 20211019 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 20211019 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 20211019 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 20211019 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 20211019 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 20211026 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 20220916 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,201 @@
package com.arm.equipment.system.data.service.system.impl;
import com.arm.equipment.system.data.domain.system.SysResource;
import com.arm.equipment.system.data.enums.dict.EnumStatus;
import com.arm.equipment.system.data.enums.dict.EnumSysResourceType;
import com.arm.equipment.system.data.exception.BusinessException;
import com.arm.equipment.system.data.mapper.system.ISysResourceMapper;
import com.arm.equipment.system.data.service.common.IIdWorkerService;
import com.arm.equipment.system.data.service.system.ISysResourceService;
import com.arm.equipment.system.data.util.WJAssert;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;
/**
* --
*
* @author admin
* @date 20211020 08:59:10
*/
@Service
public class SysResourceServiceImpl implements ISysResourceService {
@Autowired
private ISysResourceMapper sysResourceMapper;
@Autowired
private IIdWorkerService idWorkerService;
@Override
public void save(SysResource req, String operator) {
req.setOperator(operator);
if (StringUtils.isNotBlank(req.getIdentity())) {
SysResource where = new SysResource();
where.setIdentity(req.getIdentity());
SysResource resourceDB = sysResourceMapper.getOne(where);
if (resourceDB != null && !resourceDB.getId().equals(req.getId())) {
throw new BusinessException("标识已存在!");
}
}
if (null == req.getId()) {
insertSelective(req);
} else {
updateSelectiveById(req);
}
}
@Override
public int insertSelective(SysResource req) {
req.setId(idWorkerService.getNextId());
req.setStatus(EnumStatus.NEW.getCode());
checkStringLength(req, false);
return sysResourceMapper.insertSelective(req);
}
@Override
public int updateSelectiveById(SysResource sysResource) {
WJAssert.notNull(sysResource, "入参对象不能为空");
WJAssert.notNull(sysResource.getId(), "id参数错误");
SysResource where = new SysResource();
where.setId(sysResource.getId());
return sysResourceMapper.updateSelective(sysResource, where);
}
@Override
public int getCount(SysResource sysResource) {
checkStringLength(sysResource, true);
return sysResourceMapper.getCount(sysResource);
}
@Override
public SysResource getOneById(Long id) {
WJAssert.notNull(id, "id参数错误");
SysResource where = new SysResource();
where.setId(id);
return sysResourceMapper.getOne(where);
}
@Override
public List<SysResource> getList(SysResource sysResource) {
checkStringLength(sysResource, true);
return sysResourceMapper.getList(sysResource);
}
@Override
public List<SysResource> getPageList(SysResource sysResource) {
checkStringLength(sysResource, true);
return sysResourceMapper.getPageList(sysResource);
}
@Override
public void audit(Long id, String operator) {
SysResource req = new SysResource();
req.setId(id);
req.setOperator(operator);
req.setStatus(EnumStatus.AUDIT.getCode());
updateSelectiveById(req);
}
@Override
public void unaudit(Long id, String operator) {
SysResource req = new SysResource();
req.setId(id);
req.setOperator(operator);
req.setStatus(EnumStatus.NEW.getCode());
updateSelectiveById(req);
}
@Override
public void delete(Long id, String operator) {
SysResource req = new SysResource();
req.setId(id);
req.setOperator(operator);
req.setStatus(EnumStatus.DEL.getCode());
updateSelectiveById(req);
}
/**
*
*
* @param sysResource
* @return
*/
@Override
public List<SysResource> getPageTreeList(SysResource sysResource) {
SysResource where = new SysResource();
sysResource.setStatus(EnumStatus.NEW.getCode());
List<SysResource> listDB = sysResourceMapper.getList(where);
return sysResourceMapper.getPageList(sysResource)
.stream().peek(item -> {
item.setLabel(item.getName());
item.setChildren(getChildrenTree(listDB, item.getId().toString()));
}).collect(Collectors.toList());
}
/**
*
*
*
* @return
*/
@Override
public List<SysResource> getResourceTree() {
SysResource sysResource = new SysResource();
sysResource.setStatus(EnumStatus.NEW.getCode());
List<SysResource> listDB = sysResourceMapper.getList(sysResource);
List<SysResource> catalogueList = listDB.stream().filter(item -> {
return item.getType().equals(EnumSysResourceType.CATALOGUE.getCode());
}).sorted(Comparator.comparing(SysResource::getSort)).collect(Collectors.toList());
return catalogueList.stream()
.peek(item -> {
item.setLabel(item.getName());
item.setIcon("el-icon-folder-opened");
item.setChildren(getChildrenTree(listDB, item.getId().toString()));
}).collect(Collectors.toList());
}
/**
* ->->
*
* @param listDB
* @param parentId
* @return
*/
private List<SysResource> getChildrenTree(List<SysResource> listDB, String parentId) {
return listDB.stream()
.filter(item -> {
return parentId.equals(item.getParentId()) && EnumSysResourceType.MENU.getCode().equals(item.getType());
}).peek(item -> {
item.setLabel(item.getName());
item.setIcon("el-icon-document");
List<SysResource> btnList = listDB.stream()
.filter(btnItem -> {
return btnItem.getParentId().equals(item.getId().toString()) && EnumSysResourceType.BUTTON.getCode().equals(btnItem.getType());
}).peek(btnItem -> {
btnItem.setLabel(btnItem.getName());
}).sorted(Comparator.comparing(SysResource::getSort)).collect(Collectors.toList());
item.setChildren(btnList);
}).sorted(Comparator.comparing(SysResource::getSort)).collect(Collectors.toList());
}
/**
* 使
*/
private void checkStringLength(SysResource sysResource, boolean nullAble) {
WJAssert.notNull(sysResource, "入参对象不能为空");
WJAssert.limitMaxLength(sysResource.getName(), nullAble, 100, "菜单名称不合法!");
WJAssert.limitMaxLength(sysResource.getUrl(), true, 200, "链接地址不合法!");
WJAssert.limitMaxLength(sysResource.getParentId(), true, 32, "父菜单ID不合法!");
WJAssert.limitMaxLength(sysResource.getIcon(), true, 200, "图标不合法!");
WJAssert.limitMaxLength(sysResource.getIdentity(), nullAble, 255, "权限标识不合法!");
WJAssert.limitMaxLength(sysResource.getOperator(), true, 50, "操作人不合法!");
WJAssert.limitMaxLength(sysResource.getRemark(), true, 255, "备注不合法!");
WJAssert.limitMaxLength(sysResource.getRootPath(), true, 255, "根路径,用.分隔不合法!");
}
}

@ -0,0 +1,311 @@
package com.arm.equipment.system.data.service.system.impl;
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.enums.dict.EnumStatus;
import com.arm.equipment.system.data.enums.dict.EnumSysResourceType;
import com.arm.equipment.system.data.exception.BusinessException;
import com.arm.equipment.system.data.mapper.system.ISysRoleResourceMapper;
import com.arm.equipment.system.data.service.common.IIdWorkerService;
import com.arm.equipment.system.data.service.system.ISysResourceService;
import com.arm.equipment.system.data.service.system.ISysRoleResourceService;
import com.arm.equipment.system.data.service.system.ISysRoleService;
import com.arm.equipment.system.data.util.WJAssert;
import com.arm.equipment.system.data.vo.system.SysRoleResourceVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import java.util.*;
import java.util.stream.Collectors;
/**
* -
*
* @author admin
* @date 20211019 15:06:41
*/
@Service
public class SysRoleResourceServiceImpl implements ISysRoleResourceService {
@Autowired
private ISysRoleResourceMapper sysRoleResourceMapper;
@Autowired
private IIdWorkerService idWorkerService;
@Autowired
private ISysResourceService sysResourceService;
@Autowired
private ISysRoleService sysRoleService;
@Override
public void save(SysRoleResource req, String operator) {
req.setOperator(operator);
if (null == req.getId()) {
insertSelective(req);
} else {
updateSelectiveById(req);
}
}
@Override
public int insertSelective(SysRoleResource req) {
req.setId(idWorkerService.getNextId());
req.setStatus(EnumStatus.NEW.getCode());
checkStringLength(req, false);
return sysRoleResourceMapper.insertSelective(req);
}
@Override
public int updateSelectiveById(SysRoleResource sysRoleResource) {
WJAssert.notNull(sysRoleResource, "入参对象不能为空");
WJAssert.notNull(sysRoleResource.getId(), "id参数错误");
SysRoleResource where = new SysRoleResource();
where.setId(sysRoleResource.getId());
return sysRoleResourceMapper.updateSelective(sysRoleResource, where);
}
@Override
public int getCount(SysRoleResource sysRoleResource) {
checkStringLength(sysRoleResource, true);
return sysRoleResourceMapper.getCount(sysRoleResource);
}
@Override
public SysRoleResource getOneById(Long id) {
WJAssert.notNull(id, "id参数错误");
SysRoleResource where = new SysRoleResource();
where.setId(id);
return sysRoleResourceMapper.getOne(where);
}
@Override
public List<SysRoleResource> getList(SysRoleResource sysRoleResource) {
checkStringLength(sysRoleResource, true);
return sysRoleResourceMapper.getList(sysRoleResource);
}
@Override
public List<SysRoleResource> getPageList(SysRoleResource sysRoleResource) {
checkStringLength(sysRoleResource, true);
return sysRoleResourceMapper.getPageList(sysRoleResource);
}
@Override
public void audit(Long id, String operator) {
SysRoleResource req = new SysRoleResource();
req.setId(id);
req.setOperator(operator);
req.setStatus(EnumStatus.AUDIT.getCode());
updateSelectiveById(req);
}
@Override
public void unaudit(Long id, String operator) {
SysRoleResource req = new SysRoleResource();
req.setId(id);
req.setOperator(operator);
req.setStatus(EnumStatus.NEW.getCode());
updateSelectiveById(req);
}
@Override
public void delete(Long id, String operator) {
SysRoleResource req = new SysRoleResource();
req.setId(id);
req.setOperator(operator);
req.setStatus(EnumStatus.DEL.getCode());
updateSelectiveById(req);
}
/**
*
*
* @param sysUserRoleIdList
* @param sysUserResourceList
* @param sysResourceIdentityList
*/
@Override
public void buildUserResourceListAndIdentityList(List<SysRole> sysUserRoleIdList, List<SysResource> sysUserResourceList,
List<String> sysResourceIdentityList) {
if (CollectionUtils.isEmpty(sysUserRoleIdList)) {
return;
}
List<Long> roleIds = sysUserRoleIdList.stream().map(SysRole::getId).collect(Collectors.toList());
List<SysRoleResource> list = sysRoleResourceMapper.getListBySysRoleIdIn(roleIds);
if (CollectionUtils.isEmpty(list)) {
return;
}
List<Long> resourceIdList = list.stream().map(SysRoleResource::getSysResourceId).distinct().collect(Collectors.toList());
SysResource sysResourceWhere = new SysResource();
sysResourceWhere.setStatus(EnumStatus.NEW.getCode());
sysResourceWhere.setIdsList(resourceIdList);
List<SysResource> sysResourcesList = sysResourceService.getList(sysResourceWhere);
if (CollectionUtils.isEmpty(sysResourcesList)) {
return;
}
//用户所拥有资源标识
List<String> resourceIdentityList = sysResourcesList.stream().map(SysResource::getIdentity).collect(Collectors.toList());
//目录资源集合
List<SysResource> allCatalogueResourceList = sysResourcesList.stream().filter(item -> {
return EnumSysResourceType.CATALOGUE.getCode().equals(item.getType());
}).sorted(Comparator.comparing(SysResource::getSort)).collect(Collectors.toList());
//菜单资源集合
List<SysResource> allMenuResourceList = sysResourcesList.stream().filter(item -> {
return EnumSysResourceType.MENU.getCode().equals(item.getType());
}).collect(Collectors.toList());
//用户所拥有目录菜单资源盖楼
List<SysResource> userResourceList = allCatalogueResourceList.stream()
.peek(item -> {
List<SysResource> childrenList = allMenuResourceList.stream().filter(childrenItem -> {
return item.getId().toString().equals(childrenItem.getParentId());
}).sorted(Comparator.comparing(SysResource::getSort)).collect(Collectors.toList());
item.setChildren(childrenList);
}).collect(Collectors.toList());
sysUserResourceList.addAll(userResourceList);
sysResourceIdentityList.addAll(resourceIdentityList);
}
/**
*
*
* @param roleResourceVO
* @param operator
*/
@Override
@Transactional(rollbackFor = Exception.class)
public void addResource(SysRoleResourceVO roleResourceVO, String operator) {
List<Long> newResourcesList = roleResourceVO.getResourcesIds();
if (null == roleResourceVO.getRoleId()) {
return;
}
SysRole sysRoleDB = sysRoleService.getOneById(roleResourceVO.getRoleId());
if (sysRoleDB == null) {
throw new BusinessException("不存的角色!");
}
sysRoleResourceMapper.deleteByRoleId(roleResourceVO.getRoleId());
if (CollectionUtils.isEmpty(newResourcesList)) {
return;
}
List<SysRoleResource> list = newResourcesList.parallelStream().map(item -> {
SysRoleResource req = new SysRoleResource();
req.setOperator(operator);
req.setSysResourceId(item);
req.setSysRoleId(roleResourceVO.getRoleId());
req.setId(idWorkerService.getNextId());
req.setStatus(EnumStatus.NEW.getCode());
return req;
}).collect(Collectors.toList());
sysRoleResourceMapper.batchInsert(list);
}
/**
* el-tree
* 1.
* 2.
* 3.ID
* 4.使ID
* 5.
*
* @param roleId
* @return
*/
@Override
public Map<String, Object> getResourcesIdListByRoleId(Long roleId) {
Map<String, Object> resultMap = new HashMap<>(2);
resultMap.put("checkedTreeList", new ArrayList<>());
resultMap.put("treeList", new ArrayList<>());
List<Long> resultList = new ArrayList<>();
SysRoleResource req = new SysRoleResource();
req.setSysRoleId(roleId);
List<Long> resourceIdList = getList(req).stream().map(SysRoleResource::getSysResourceId).collect(Collectors.toList());
if (CollectionUtils.isEmpty(resourceIdList)) {
return resultMap;
}
SysResource sysResourceWhere = new SysResource();
sysResourceWhere.setStatus(EnumStatus.NEW.getCode());
sysResourceWhere.setIdsList(resourceIdList);
List<SysResource> sysResourcesList = sysResourceService.getList(sysResourceWhere);
if (CollectionUtils.isEmpty(sysResourcesList)) {
return resultMap;
}
//用户所拥有目录资源集合
List<Long> allCatalogueResourceIdList = sysResourcesList.stream().filter(item -> {
return EnumSysResourceType.CATALOGUE.getCode().equals(item.getType());
}).map(SysResource::getId).collect(Collectors.toList());
//用户所拥有菜单资源集合
List<SysResource> allMenuResourceIdList = sysResourcesList.stream().filter(item -> {
return EnumSysResourceType.MENU.getCode().equals(item.getType());
}).collect(Collectors.toList());
//用户所拥有按钮资源集合
List<SysResource> allButtonResourceIdList = sysResourcesList.stream().filter(item -> {
return EnumSysResourceType.BUTTON.getCode().equals(item.getType());
}).collect(Collectors.toList());
SysResource srWhere = new SysResource();
srWhere.setStatus(EnumStatus.NEW.getCode());
List<SysResource> resourceAllListDB = sysResourceService.getList(srWhere);
//过滤后的结果菜单
List<SysResource> menuResourceIdListResult = allMenuResourceIdList.stream()
.filter(item -> {
return isHasAllChildren(allButtonResourceIdList, resourceAllListDB, EnumSysResourceType.BUTTON.getCode(), item.getId());
}).collect(Collectors.toList());
//过滤后的结果目录
List<Long> catalogueResourceIdListResult = allCatalogueResourceIdList.stream()
.filter(item -> {
return isHasAllChildren(menuResourceIdListResult, resourceAllListDB, EnumSysResourceType.MENU.getCode(), item);
}).collect(Collectors.toList());
List<Long> buttonIdList = allButtonResourceIdList.stream().map(SysResource::getId).collect(Collectors.toList());
List<Long> menuIdList = menuResourceIdListResult.stream().map(SysResource::getId).collect(Collectors.toList());
resultList.addAll(catalogueResourceIdListResult);
resultList.addAll(menuIdList);
resultList.addAll(buttonIdList);
resultMap.put("checkedTreeList", resultList);
resultMap.put("treeList", resourceIdList);
return resultMap;
}
/**
*
*
* @param resourceIdList
* @param type
* @param resourceId
* @return
*/
private boolean isHasAllChildren(List<SysResource> resourceIdList, List<SysResource> resourceAllListDB, Integer type, Long resourceId) {
//得到当前类型的所有对应子节点
List<Long> idList = resourceIdList
.stream()
.filter(item -> item.getParentId().equals(resourceId.toString()))
.map(SysResource::getId).collect(Collectors.toList());
List<Long> idListDB = resourceAllListDB
.stream()
.filter(item -> item.getParentId().equals(resourceId.toString()) && item.getType().equals(type))
.map(SysResource::getId).collect(Collectors.toList());
if (CollectionUtils.isEmpty(idListDB)) {
return true;
}
return idList.size() == idListDB.size();
}
/**
* 使
*/
private void checkStringLength(SysRoleResource sysRoleResource, boolean nullAble) {
WJAssert.notNull(sysRoleResource, "入参对象不能为空");
WJAssert.limitMaxLength(sysRoleResource.getOperator(), true, 255, "操作人不合法!");
WJAssert.limitMaxLength(sysRoleResource.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 20211019 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 20211019 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 20211019 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 20230313 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 20230313 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 20230323 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 20230323 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 20230323 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 20230323 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 20230323 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 20230323 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>
Loading…
Cancel
Save