提交代码

main
姜玉琦 2024-03-13 21:17:09 +08:00
parent 0f35fb536e
commit a341eb2d5a
27 changed files with 186 additions and 913 deletions

View File

@ -219,7 +219,6 @@
<module>yanzhu-flowable</module>
<module>yanzhu-manage</module>
<module>yanzhu-mapper</module>
<module>yanzhu-wechat</module>
</modules>
<packaging>pom</packaging>

View File

@ -19,7 +19,7 @@ server:
port: 8080
servlet:
# 应用的访问路径
context-path: /prjapi
context-path: /yanZhuProject
tomcat:
# tomcat的URI编码
uri-encoding: UTF-8

View File

@ -105,6 +105,19 @@ public class TokenService
}
}
/**
*
*/
public void delLoginUser(HttpServletRequest request)
{
String token = getToken(request);
if (StringUtils.isNotEmpty(token))
{
String userKey = getTokenKey(token);
redisCache.deleteObject(userKey);
}
}
/**
*
*
@ -153,6 +166,26 @@ public class TokenService
redisCache.setCacheObject(userKey, loginUser, expireTime, TimeUnit.MINUTES);
}
/**
*
*
* @param token token
*/
public void refreshMobileToken(String token)
{
Claims claims = parseToken(token);
// 解析对应的权限以及用户信息
String uuid = (String) claims.get(Constants.LOGIN_USER_KEY);
String userKey = getTokenKey(uuid);
LoginUser user = redisCache.getCacheObject(userKey);
user.setLoginTime(System.currentTimeMillis());
int mobileExpireTime = expireTime * 3650 * 60 ;
user.setExpireTime(user.getLoginTime() + mobileExpireTime * MILLIS_MINUTE);
// 根据uuid将loginUser缓存
redisCache.setCacheObject(userKey, user, mobileExpireTime, TimeUnit.MINUTES);
}
/**
*
*

View File

@ -50,6 +50,10 @@
<groupId>com.yanzhu</groupId>
<artifactId>yanzhu-framework</artifactId>
</dependency>
<dependency>
<groupId>com.yanzhu</groupId>
<artifactId>yanzhu-flowable</artifactId>
</dependency>
</dependencies>

View File

@ -276,7 +276,7 @@ public class WxFlowableController extends BaseController {
}
/**
*
*
* @param flowTaskEntity
* @return
*/

View File

@ -1,12 +1,16 @@
package com.yanzhu.wechat.controller;
import com.yanzhu.common.annotation.Anonymous;
import com.yanzhu.common.annotation.Log;
import com.yanzhu.common.annotation.RateLimiter;
import com.yanzhu.common.constant.Constants;
import com.yanzhu.common.core.controller.BaseController;
import com.yanzhu.common.core.domain.AjaxResult;
import com.yanzhu.common.core.domain.model.LoginBody;
import com.yanzhu.common.core.redis.RedisCache;
import com.yanzhu.common.enums.BusinessType;
import com.yanzhu.common.enums.LimitType;
import com.yanzhu.common.enums.OperatorType;
import com.yanzhu.framework.web.service.SysLoginService;
import com.yanzhu.framework.web.service.TokenService;
import com.yanzhu.system.domain.vo.UpdatePwdVo;
@ -15,6 +19,7 @@ import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import java.util.Map;
@ -49,12 +54,15 @@ public class WxLoginController extends BaseController {
*/
@ApiOperation(value = "账号密码登录")
@RateLimiter(count = 10, limitType = LimitType.IP)
@Anonymous
@PostMapping("/login")
public AjaxResult login(@RequestBody LoginBody loginBody)
{
AjaxResult ajax = AjaxResult.success();
// 生成令牌
String token = loginService.login(loginBody.getUsername(), loginBody.getPassword(), loginBody.getCode(),loginBody.getUuid());
// 移动端这里刷新token有效期为长期
tokenService.refreshMobileToken(token);
ajax.put(Constants.TOKEN, token);
return ajax;
}
@ -66,6 +74,7 @@ public class WxLoginController extends BaseController {
*/
@ApiOperation(value = "修改密码")
@RateLimiter(count = 10, limitType = LimitType.IP)
@Log(title = "用户修改密码", businessType = BusinessType.UPDATE, operatorType = OperatorType.MOBILE)
@PostMapping("/updatePwd")
public AjaxResult updatePwd(@RequestBody @Valid UpdatePwdVo updatePwdVo)
{
@ -73,4 +82,19 @@ public class WxLoginController extends BaseController {
return success();
}
/**
* 退
*
* @return
*/
@ApiOperation(value = "退出登录")
@RateLimiter(count = 10, limitType = LimitType.IP)
@Log(title = "用户退出登录", businessType = BusinessType.UPDATE, operatorType = OperatorType.MOBILE)
@PostMapping("/loginOut")
public AjaxResult loginOut(HttpServletRequest request)
{
tokenService.delLoginUser(request);
return success();
}
}

View File

@ -10,10 +10,13 @@ import com.yanzhu.common.core.domain.entity.SysRole;
import com.yanzhu.common.core.domain.entity.SysUser;
import com.yanzhu.common.core.page.TableDataInfo;
import com.yanzhu.common.core.redis.RedisCache;
import com.yanzhu.common.enums.ShiFouEnum;
import com.yanzhu.common.utils.DictUtils;
import com.yanzhu.common.utils.SecurityUtils;
import com.yanzhu.common.utils.StringUtils;
import com.yanzhu.project.domain.ProProjectInfo;
import com.yanzhu.project.service.IProProjectApplyService;
import com.yanzhu.project.service.IProProjectInfoService;
import com.yanzhu.sur.domain.SurMenuConfig;
import com.yanzhu.sur.service.ISurMenuConfigService;
import com.yanzhu.system.service.ISysDeptService;
@ -56,6 +59,9 @@ public class WxPublicsController extends BaseController
@Autowired
private IBaseAssetsTypeService baseAssetsTypeService;
@Autowired
private IProProjectInfoService proProjectInfoService;
@Autowired
private IProProjectApplyService proProjectApplyService;
@ -71,14 +77,14 @@ public class WxPublicsController extends BaseController
/**
*
*/
@GetMapping("/findAllByCategory/{category}")
@GetMapping("/v1/findAllByCategory/{category}")
public AjaxResult findAllByCategory(@PathVariable String category)
{
SysUser sysUser = super.getLoginUser().getUser();
String key = "YANZHU.BASE.ASSETSTYPE.findAllByCategory." + sysUser.getParDeptId() + "." + category;
Object object = redisCache.getCacheObject(key);
if (object != null) {
return success(object);
//return success(object);
}
List<BaseAssetsType> list = baseAssetsTypeService.findAllByCategory(category);
redisCache.setCacheObject(key, list, Constants.BASE_DATA_EXPIRATION, TimeUnit.MINUTES);
@ -124,7 +130,7 @@ public class WxPublicsController extends BaseController
}
/**
*
*
*/
@GetMapping("/v1/selectRoleMenuList")
public AjaxResult selectRoleMenuList(SurMenuConfig surMenuConfig)
@ -143,4 +149,39 @@ public class WxPublicsController extends BaseController
return success(list);
}
/**
*
*/
@GetMapping("/v1/findMyDeptList")
public AjaxResult findMyDeptList(){
Long parDeptId = super.getLoginUser().getUser().getParDeptId();
String key = "YANZHU.DEPT.V1.findMyDeptList." + parDeptId;
Object object = redisCache.getCacheObject(key);
if (object != null) {
return success(object);
}
List<SysDept> list = deptService.findChildList(parDeptId);
redisCache.setCacheObject(key, list, Constants.CAPTCHA_EXPIRATION, TimeUnit.MINUTES);
return success(list);
}
/**
*
*/
@GetMapping("/v1/findMyProjectList")
public AjaxResult findMyProjectList(){
Long parDeptId = super.getLoginUser().getUser().getParDeptId();
String key = "YANZHU.PROJ.V1.findMyProjectList." + parDeptId;
Object object = redisCache.getCacheObject(key);
if (object != null) {
return success(object);
}
ProProjectInfo proProjectInfo = new ProProjectInfo();
proProjectInfo.setDeptId(parDeptId);
proProjectInfo.setIsDel(ShiFouEnum.FOU.getCode());
List<ProProjectInfo> list = proProjectInfoService.selectProProjectInfoList(proProjectInfo);
redisCache.setCacheObject(key, list, Constants.CAPTCHA_EXPIRATION, TimeUnit.MINUTES);
return success(list);
}
}

View File

@ -53,6 +53,10 @@ public class ProProjectApplyDetail extends BaseEntity
@Excel(name = "资产单位")
private String assetsUnit;
/** 规格型号 */
@Excel(name = "规格型号")
private String assetsVersion;
/** 数量 */
@Excel(name = "数量")
private Long number;
@ -164,7 +168,15 @@ public class ProProjectApplyDetail extends BaseEntity
this.number = number;
}
public Long getNumber()
public String getAssetsVersion() {
return assetsVersion;
}
public void setAssetsVersion(String assetsVersion) {
this.assetsVersion = assetsVersion;
}
public Long getNumber()
{
return number;
}
@ -226,6 +238,7 @@ public class ProProjectApplyDetail extends BaseEntity
.append("assetsId", getAssetsId())
.append("assetsName", getAssetsName())
.append("assetsUnit", getAssetsUnit())
.append("assetsVersion", getAssetsVersion())
.append("number", getNumber())
.append("useTime", getUseTime())
.append("useReason", getUseReason())

View File

@ -148,12 +148,17 @@ public class ProProjectApplyServiceImpl implements IProProjectApplyService
proProjectApplyDetail.setSuperTypeKey(proProjectApply.getApplyType());
proProjectApplyDetail.setSuperTypeName(superTypeName);
//资产
BaseAssetsType baseAssetsType = baseAssetsTypeMapper.selectBaseAssetsTypeById(proProjectApplyDetail.getAssetsId());
proProjectApplyDetail.setAssetsName(baseAssetsType.getName());
//资产类型
BaseAssetsType parentAssetsType = baseAssetsTypeMapper.selectBaseAssetsTypeById(baseAssetsType.getParentId());
proProjectApplyDetail.setTypeId(parentAssetsType.getId());
proProjectApplyDetail.setTypeName(parentAssetsType.getName());
if(StringUtils.isEmpty(proProjectApplyDetail.getAssetsName())){
BaseAssetsType baseAssetsType = baseAssetsTypeMapper.selectBaseAssetsTypeById(proProjectApplyDetail.getAssetsId());
proProjectApplyDetail.setAssetsName(baseAssetsType.getName());
//为空时,重新查询并赋值
if(proProjectApplyDetail.getTypeId()==null || StringUtils.isEmpty(proProjectApplyDetail.getTypeName())){
//资产类型
BaseAssetsType parentAssetsType = baseAssetsTypeMapper.selectBaseAssetsTypeById(baseAssetsType.getParentId());
proProjectApplyDetail.setTypeId(parentAssetsType.getId());
proProjectApplyDetail.setTypeName(parentAssetsType.getName());
}
}
proProjectApplyDetail.setIsDel(ShiFouEnum.FOU.getCode());
list.add(proProjectApplyDetail);
}

View File

@ -115,4 +115,5 @@ public interface SysDeptMapper
* @return
*/
public int deleteDeptById(Long deptId);
}

View File

@ -121,4 +121,12 @@ public interface ISysDeptService
* @return
*/
public int deleteDeptById(Long deptId);
/**
*
*
* @param deptId ID
* @return
*/
public List<SysDept> findChildList(Long deptId);
}

View File

@ -1,7 +1,10 @@
package com.yanzhu.system.service;
import java.util.List;
import java.util.Map;
import com.yanzhu.common.core.domain.entity.SysUser;
import com.yanzhu.system.domain.vo.UpdatePwdVo;
/**
*
@ -203,4 +206,12 @@ public interface ISysUserService
* @return
*/
public String importUser(List<SysUser> userList, Boolean isUpdateSupport, String operName);
/**
*
*
* @param updatePwdVo
* @return
*/
public void updatePwd(UpdatePwdVo updatePwdVo);
}

View File

@ -335,4 +335,16 @@ public class SysDeptServiceImpl implements ISysDeptService
{
return getChildList(list, t).size() > 0;
}
/**
*
*
* @param deptId ID
* @return
*/
public List<SysDept> findChildList(Long deptId) {
SysDept sysDept = new SysDept();
sysDept.setParentId(deptId);
return deptMapper.selectDeptList(sysDept);
}
}

View File

@ -2,8 +2,11 @@ package com.yanzhu.system.service.impl;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
import javax.validation.Validator;
import com.yanzhu.system.domain.vo.UpdatePwdVo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@ -541,4 +544,23 @@ public class SysUserServiceImpl implements ISysUserService
}
return successMsg.toString();
}
/**
*
*
* @param updatePwdVo
* @return
*/
@Override
public void updatePwd(UpdatePwdVo updatePwdVo){
if(!SecurityUtils.matchesPassword(updatePwdVo.getOldPsw(),updatePwdVo.getCfmPsw())) {
throw new ServiceException("旧密码错误,请重新输入!");
}
if(!Objects.equals(updatePwdVo.getNewPsw(),updatePwdVo.getCfmPsw())){
throw new ServiceException("两次密码不一致,请重新输入!");
}
SysUser sysUser = SecurityUtils.getLoginUser().getUser();
sysUser.setPassword(SecurityUtils.encryptPassword(updatePwdVo.getCfmPsw()));
userMapper.updateUser(sysUser);
}
}

View File

@ -1,89 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>yanzhu</artifactId>
<groupId>com.yanzhu</groupId>
<version>3.8.7</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>yanzhu-wechat</artifactId>
<properties>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
</properties>
<dependencies>
<!-- Mysql驱动包 -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
<!-- 核心模块-->
<dependency>
<groupId>com.yanzhu</groupId>
<artifactId>yanzhu-framework</artifactId>
</dependency>
<!-- 系统模块-->
<dependency>
<groupId>com.yanzhu</groupId>
<artifactId>yanzhu-flowable</artifactId>
</dependency>
<!-- 系统模块-->
<dependency>
<groupId>com.yanzhu</groupId>
<artifactId>yanzhu-system</artifactId>
</dependency>
<!-- 系统模块-->
<dependency>
<groupId>com.yanzhu</groupId>
<artifactId>yanzhu-mapper</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>2.1.1.RELEASE</version>
<configuration>
<fork>true</fork> <!-- 如果没有该配置devtools不会生效 -->
</configuration>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>3.1.0</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
<warName>${project.artifactId}</warName>
</configuration>
</plugin>
</plugins>
<finalName>${project.artifactId}</finalName>
</build>
</project>

View File

@ -1,30 +0,0 @@
package com.yanzhu;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
/**
*
*
* @author yanZhu
*/
@SpringBootApplication(exclude = { DataSourceAutoConfiguration.class })
public class WxYanZhuApplication
{
public static void main(String[] args)
{
// System.setProperty("spring.devtools.restart.enabled", "false");
SpringApplication.run(WxYanZhuApplication.class, args);
System.out.println("(♥◠‿◠)ノ゙ 研筑临时项目小程序服务启动成功 ლ(´ڡ`ლ)゙ \n" +
" .-------. ____ __ \n" +
" | _ _ \\ \\ \\ / / \n" +
" | ( ' ) | \\ _. / ' \n" +
" |(_ o _) / _( )_ .' \n" +
" | (_,_).' __ ___(_ o _)' \n" +
" | |\\ \\ | || |(_,_)' \n" +
" | | \\ `' /| `-' / \n" +
" | | \\ / \\ / \n" +
" ''-' `'-' `-..-' ");
}
}

View File

@ -1,18 +0,0 @@
package com.yanzhu;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
/**
* web
*
* @author yanZhu
*/
public class WxYanzhuServletInitializer extends SpringBootServletInitializer
{
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application)
{
return application.sources(WxYanZhuApplication.class);
}
}

View File

@ -1,95 +0,0 @@
package com.yanzhu.wechat.common;
import com.google.code.kaptcha.Producer;
import com.yanzhu.common.config.YanZhuConfig;
import com.yanzhu.common.constant.CacheConstants;
import com.yanzhu.common.constant.Constants;
import com.yanzhu.common.core.domain.AjaxResult;
import com.yanzhu.common.core.redis.RedisCache;
import com.yanzhu.common.utils.sign.Base64;
import com.yanzhu.common.utils.uuid.IdUtils;
import com.yanzhu.system.service.ISysConfigService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.FastByteArrayOutputStream;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import javax.imageio.ImageIO;
import javax.servlet.http.HttpServletResponse;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.util.concurrent.TimeUnit;
/**
*
*
* @author yanZhu
*/
@RestController
public class CaptchaController
{
@Resource(name = "captchaProducer")
private Producer captchaProducer;
@Resource(name = "captchaProducerMath")
private Producer captchaProducerMath;
@Autowired
private RedisCache redisCache;
@Autowired
private ISysConfigService configService;
/**
*
*/
@GetMapping("/captchaImage")
public AjaxResult getCode(HttpServletResponse response) throws IOException
{
AjaxResult ajax = AjaxResult.success();
boolean captchaEnabled = configService.selectCaptchaEnabled();
ajax.put("captchaEnabled", captchaEnabled);
if (!captchaEnabled)
{
return ajax;
}
// 保存验证码信息
String uuid = IdUtils.simpleUUID();
String verifyKey = CacheConstants.CAPTCHA_CODE_KEY + uuid;
String capStr = null, code = null;
BufferedImage image = null;
// 生成验证码
String captchaType = YanZhuConfig.getCaptchaType();
if ("math".equals(captchaType))
{
String capText = captchaProducerMath.createText();
capStr = capText.substring(0, capText.lastIndexOf("@"));
code = capText.substring(capText.lastIndexOf("@") + 1);
image = captchaProducerMath.createImage(capStr);
}
else if ("char".equals(captchaType))
{
capStr = code = captchaProducer.createText();
image = captchaProducer.createImage(capStr);
}
redisCache.setCacheObject(verifyKey, code, Constants.CAPTCHA_EXPIRATION, TimeUnit.MINUTES);
// 转换流信息写出
FastByteArrayOutputStream os = new FastByteArrayOutputStream();
try
{
ImageIO.write(image, "jpg", os);
}
catch (IOException e)
{
return AjaxResult.error(e.getMessage());
}
ajax.put("uuid", uuid);
ajax.put("img", Base64.encode(os.toByteArray()));
return ajax;
}
}

View File

@ -1,164 +0,0 @@
package com.yanzhu.wechat.common;
import com.yanzhu.common.config.YanZhuConfig;
import com.yanzhu.common.constant.Constants;
import com.yanzhu.common.core.domain.AjaxResult;
import com.yanzhu.common.utils.StringUtils;
import com.yanzhu.common.utils.file.FileUploadUtils;
import com.yanzhu.common.utils.file.FileUtils;
import com.yanzhu.framework.config.ServerConfig;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
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.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.List;
/**
*
*
* @author yanZhu
*/
@RestController
@RequestMapping("/wxApi/common")
public class CommonController
{
private static final Logger log = LoggerFactory.getLogger(CommonController.class);
@Autowired
private ServerConfig serverConfig;
private static final String FILE_DELIMETER = ",";
/**
*
*
* @param fileName
* @param delete
*/
@GetMapping("/download")
public void fileDownload(String fileName, Boolean delete, HttpServletResponse response, HttpServletRequest request)
{
try
{
if (!FileUtils.checkAllowDownload(fileName))
{
throw new Exception(StringUtils.format("文件名称({})非法,不允许下载。 ", fileName));
}
String realFileName = System.currentTimeMillis() + fileName.substring(fileName.indexOf("_") + 1);
String filePath = YanZhuConfig.getDownloadPath() + fileName;
response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE);
FileUtils.setAttachmentResponseHeader(response, realFileName);
FileUtils.writeBytes(filePath, response.getOutputStream());
if (delete)
{
FileUtils.deleteFile(filePath);
}
}
catch (Exception e)
{
log.error("下载文件失败", e);
}
}
/**
*
*/
@PostMapping("/upload")
public AjaxResult uploadFile(MultipartFile file) throws Exception
{
try
{
// 上传文件路径
String filePath = YanZhuConfig.getUploadPath();
// 上传并返回新文件名称
String fileName = FileUploadUtils.upload(filePath, file);
String url = serverConfig.getUrl() + fileName;
AjaxResult ajax = AjaxResult.success();
ajax.put("url", url);
ajax.put("fileName", fileName);
ajax.put("newFileName", FileUtils.getName(fileName));
ajax.put("originalFilename", file.getOriginalFilename());
return ajax;
}
catch (Exception e)
{
return AjaxResult.error(e.getMessage());
}
}
/**
*
*/
@PostMapping("/uploads")
public AjaxResult uploadFiles(List<MultipartFile> files) throws Exception
{
try
{
// 上传文件路径
String filePath = YanZhuConfig.getUploadPath();
List<String> urls = new ArrayList<String>();
List<String> fileNames = new ArrayList<String>();
List<String> newFileNames = new ArrayList<String>();
List<String> originalFilenames = new ArrayList<String>();
for (MultipartFile file : files)
{
// 上传并返回新文件名称
String fileName = FileUploadUtils.upload(filePath, file);
String url = serverConfig.getUrl() + fileName;
urls.add(url);
fileNames.add(fileName);
newFileNames.add(FileUtils.getName(fileName));
originalFilenames.add(file.getOriginalFilename());
}
AjaxResult ajax = AjaxResult.success();
ajax.put("urls", StringUtils.join(urls, FILE_DELIMETER));
ajax.put("fileNames", StringUtils.join(fileNames, FILE_DELIMETER));
ajax.put("newFileNames", StringUtils.join(newFileNames, FILE_DELIMETER));
ajax.put("originalFilenames", StringUtils.join(originalFilenames, FILE_DELIMETER));
return ajax;
}
catch (Exception e)
{
return AjaxResult.error(e.getMessage());
}
}
/**
*
*/
@GetMapping("/download/resource")
public void resourceDownload(String resource, HttpServletRequest request, HttpServletResponse response)
throws Exception
{
try
{
if (!FileUtils.checkAllowDownload(resource))
{
throw new Exception(StringUtils.format("资源文件({})非法,不允许下载。 ", resource));
}
// 本地资源路径
String localPath = YanZhuConfig.getProfile();
// 数据库资源地址
String downloadPath = localPath + StringUtils.substringAfter(resource, Constants.RESOURCE_PREFIX);
// 下载名称
String downloadName = StringUtils.substringAfterLast(downloadPath, "/");
response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE);
FileUtils.setAttachmentResponseHeader(response, downloadName);
FileUtils.writeBytes(downloadPath, response.getOutputStream());
}
catch (Exception e)
{
log.error("下载文件失败", e);
}
}
}

View File

@ -1 +0,0 @@
restart.include.json=/com.alibaba.fastjson2.*.jar

View File

@ -1,117 +0,0 @@
# 项目相关配置
yanzhu:
# 名称
name: ProjectName
# 版本
version: 3.8.7
# 版权年份
copyrightYear: 2023
# 文件路径 示例( Windows配置D:/yanZhu/uploadPathLinux配置 /home/yanZhu/uploadPath
profile: D:/data/yanzhu
# 获取ip地址开关
addressEnabled: false
# 验证码类型 math 数字计算 char 字符验证
captchaType: math
# 开发环境配置
server:
# 服务器的HTTP端口默认为8080
port: 8089
servlet:
# 应用的访问路径
context-path: /yanZhuProject
tomcat:
# tomcat的URI编码
uri-encoding: UTF-8
# 连接数满后的排队数默认为100
accept-count: 1000
threads:
# tomcat最大线程数默认为200
max: 800
# Tomcat启动初始化的线程数默认值10
min-spare: 100
# 数据源配置
spring:
datasource:
type: com.alibaba.druid.pool.DruidDataSource
driverClassName: com.mysql.cj.jdbc.Driver
druid:
# 主库数据源
master:
url: jdbc:mysql://cd-cynosdbmysql-grp-9rqrhxsm.sql.tencentcdb.com:27981/yanzhu_project?useSSL=false&characterEncoding=UTF-8&serverTimezone=GMT%2B8
username: root
password: Sxyanzhu@cf
# 从库数据源
slave:
# 从数据源开关/默认关闭
enabled: false
url:
username:
password:
# 初始连接数
initialSize: 5
# 最小连接池数量
minIdle: 10
# 最大连接池数量
maxActive: 20
# 配置获取连接等待超时的时间
maxWait: 60000
# 配置连接超时时间
connectTimeout: 30000
# 配置网络超时时间
socketTimeout: 60000
# 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒
timeBetweenEvictionRunsMillis: 60000
# 配置一个连接在池中最小生存的时间,单位是毫秒
minEvictableIdleTimeMillis: 300000
# 配置一个连接在池中最大生存的时间,单位是毫秒
maxEvictableIdleTimeMillis: 900000
# 配置检测连接是否有效
validationQuery: SELECT 1 FROM DUAL
testWhileIdle: true
testOnBorrow: false
testOnReturn: false
webStatFilter:
enabled: true
statViewServlet:
enabled: true
# 设置白名单,不填则允许所有访问
allow:
url-pattern: /druid/*
# 控制台管理用户名和密码
login-username: yanzhu
login-password: Sxyanzhu@yanzhu+mz
filter:
stat:
enabled: true
# 慢SQL记录
log-slow-sql: true
slow-sql-millis: 1000
merge-sql: true
wall:
config:
multi-statement-allow: true
# redis 配置
redis:
# 地址
host: 127.0.0.1
# 端口默认为6379
port: 6379
# 数据库索引
database: 0
# 密码
password: 123456
# 连接超时时间
timeout: 10s
lettuce:
pool:
# 连接池中的最小空闲连接
min-idle: 0
# 连接池中的最大空闲连接
max-idle: 8
# 连接池的最大数据库连接数
max-active: 8
# #连接池最大阻塞等待时间(使用负值表示没有限制)
max-wait: -1ms

View File

@ -1,117 +0,0 @@
# 项目相关配置
yanZhu:
# 名称
name: ProjectName
# 版本
version: 3.8.7
# 版权年份
copyrightYear: 2023
# 文件路径 示例( Windows配置D:/yanZhu/uploadPathLinux配置 /home/yanZhu/uploadPath
profile: /data/yanzhu
# 获取ip地址开关
addressEnabled: false
# 验证码类型 math 数字计算 char 字符验证
captchaType: math
# 开发环境配置
server:
# 服务器的HTTP端口默认为8080
port: 8089
servlet:
# 应用的访问路径
context-path: /yanZhuProject
tomcat:
# tomcat的URI编码
uri-encoding: UTF-8
# 连接数满后的排队数默认为100
accept-count: 1000
threads:
# tomcat最大线程数默认为200
max: 800
# Tomcat启动初始化的线程数默认值10
min-spare: 100
# 数据源配置
spring:
datasource:
type: com.alibaba.druid.pool.DruidDataSource
driverClassName: com.mysql.cj.jdbc.Driver
druid:
# 主库数据源
master:
url: jdbc:mysql://cd-cynosdbmysql-grp-9rqrhxsm.sql.tencentcdb.com:27981/yanzhu_project?useSSL=false&characterEncoding=UTF-8&serverTimezone=GMT%2B8
username: root
password: Sxyanzhu@cf
# 从库数据源
slave:
# 从数据源开关/默认关闭
enabled: false
url:
username:
password:
# 初始连接数
initialSize: 5
# 最小连接池数量
minIdle: 10
# 最大连接池数量
maxActive: 20
# 配置获取连接等待超时的时间
maxWait: 60000
# 配置连接超时时间
connectTimeout: 30000
# 配置网络超时时间
socketTimeout: 60000
# 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒
timeBetweenEvictionRunsMillis: 60000
# 配置一个连接在池中最小生存的时间,单位是毫秒
minEvictableIdleTimeMillis: 300000
# 配置一个连接在池中最大生存的时间,单位是毫秒
maxEvictableIdleTimeMillis: 900000
# 配置检测连接是否有效
validationQuery: SELECT 1 FROM DUAL
testWhileIdle: true
testOnBorrow: false
testOnReturn: false
webStatFilter:
enabled: true
statViewServlet:
enabled: true
# 设置白名单,不填则允许所有访问
allow:
url-pattern: /druid/*
# 控制台管理用户名和密码
login-username: yanzhu
login-password: Sxyanzhu@yanzhu+mz
filter:
stat:
enabled: true
# 慢SQL记录
log-slow-sql: true
slow-sql-millis: 1000
merge-sql: true
wall:
config:
multi-statement-allow: true
# redis 配置
redis:
# 地址
host: 127.0.0.1
# 端口默认为6379
port: 6379
# 数据库索引
database: 0
# 密码
password: 123456
# 连接超时时间
timeout: 10s
lettuce:
pool:
# 连接池中的最小空闲连接
min-idle: 0
# 连接池中的最大空闲连接
max-idle: 8
# 连接池的最大数据库连接数
max-active: 8
# #连接池最大阻塞等待时间(使用负值表示没有限制)
max-wait: -1ms

View File

@ -1,81 +0,0 @@
# 日志配置
logging:
level:
com.yanzhu: debug
org.springframework: warn
# 用户配置
user:
password:
# 密码最大错误次数
maxRetryCount: 5
# 密码锁定时间默认10分钟
lockTime: 10
# Spring配置
spring:
# 资源信息
messages:
# 国际化资源文件路径
basename: i18n/messages
profiles:
active: druid
# 文件上传
servlet:
multipart:
# 单个文件大小
max-file-size: 10MB
# 设置总上传的文件大小
max-request-size: 20MB
# 服务模块
devtools:
restart:
# 热部署开关
enabled: true
# token配置
token:
# 令牌自定义标识
header: Authorization
# 令牌密钥
secret: abcdefghijklmnopqrstuvwxyz
# 令牌有效期默认30分钟
expireTime: 365000
# MyBatis配置
mybatis:
# 搜索指定包别名
typeAliasesPackage: com.yanzhu.**.domain
# 配置mapper的扫描找到所有的mapper.xml映射文件
mapperLocations: classpath*:mapper/**/*Mapper.xml
# 加载全局的配置文件
configLocation: classpath:mybatis/mybatis-config.xml
# PageHelper分页插件
pagehelper:
helperDialect: mysql
supportMethodsArguments: true
params: count=countSql
# Swagger配置
swagger:
# 是否开启swagger
enabled: true
# 请求前缀
pathMapping: /dev-api
# 防止XSS攻击
xss:
# 过滤开关
enabled: true
# 排除链接(多个用逗号分隔)
excludes: /system/notice,/flowable/definition/save
# 匹配链接
urlPatterns: /*
# flowable相关表
flowable:
# true 会对数据库中所有表进行更新操作。如果表不存在,则自动创建(建议开发时使用)
database-schema-update: false
# 关闭定时任务JOB
async-executor-activate: false

View File

@ -1,24 +0,0 @@
Application Version: ${yanzhu.version}
Spring Boot Version: ${spring-boot.version}
////////////////////////////////////////////////////////////////////
// _ooOoo_ //
// o8888888o //
// 88" . "88 //
// (| ^_^ |) //
// O\ = /O //
// ____/`---'\____ //
// .' \\| |// `. //
// / \\||| : |||// \ //
// / _||||| -:- |||||- \ //
// | | \\\ - /// | | //
// | \_| ''\---/'' | | //
// \ .-\__ `-` ___/-. / //
// ___`. .' /--.--\ `. . ___ //
// ."" '< `.___\_<|>_/___.' >'"". //
// | | : `- \`.;`\ _ /`;.`/ - ` : | | //
// \ \ `-. \_ __\ /__ _/ .-` / / //
// ========`-.____`-.___\_____/___.-`____.-'======== //
// `=---=' //
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ //
// 佛祖保佑 永不宕机 永无BUG //
////////////////////////////////////////////////////////////////////

View File

@ -1,38 +0,0 @@
#错误消息
not.null=* 必须填写
user.jcaptcha.error=验证码错误
user.jcaptcha.expire=验证码已失效
user.not.exists=用户不存在/密码错误
user.password.not.match=用户不存在/密码错误
user.password.retry.limit.count=密码输入错误{0}次
user.password.retry.limit.exceed=密码输入错误{0}次,帐户锁定{1}分钟
user.password.delete=对不起,您的账号已被删除
user.blocked=用户已封禁,请联系管理员
role.blocked=角色已封禁,请联系管理员
login.blocked=很遗憾访问IP已被列入系统黑名单
user.logout.success=退出成功
length.not.valid=长度必须在{min}到{max}个字符之间
user.username.not.valid=* 2到20个汉字、字母、数字或下划线组成且必须以非数字开头
user.password.not.valid=* 5-50个字符
user.email.not.valid=邮箱格式错误
user.mobile.phone.number.not.valid=手机号格式错误
user.login.success=登录成功
user.register.success=注册成功
user.notfound=请重新登录
user.forcelogout=管理员强制退出,请重新登录
user.unknown.error=未知错误,请重新登录
##文件上传消息
upload.exceed.maxSize=上传的文件大小超出限制的文件大小!<br/>允许的文件最大大小是:{0}MB
upload.filename.exceed.length=上传的文件名最长{0}个字符
##权限
no.permission=您没有数据的权限,请联系管理员添加权限 [{0}]
no.create.permission=您没有创建数据的权限,请联系管理员添加权限 [{0}]
no.update.permission=您没有修改数据的权限,请联系管理员添加权限 [{0}]
no.delete.permission=您没有删除数据的权限,请联系管理员添加权限 [{0}]
no.export.permission=您没有导出数据的权限,请联系管理员添加权限 [{0}]
no.view.permission=您没有查看数据的权限,请联系管理员添加权限 [{0}]

View File

@ -1,106 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<!-- 日志存放路径 -->
<property name="log.path" value="/Users/2y/zhj/logs" />
<!-- 彩色日志 -->
<conversionRule conversionWord="clr" converterClass="org.springframework.boot.logging.logback.ColorConverter"/>
<conversionRule conversionWord="wex"
converterClass="org.springframework.boot.logging.logback.WhitespaceThrowableProxyConverter"/>
<conversionRule conversionWord="wEx"
converterClass="org.springframework.boot.logging.logback.ExtendedWhitespaceThrowableProxyConverter"/>
<!-- &lt;!&ndash; 日志输出格式 &ndash;&gt;-->
<!-- <property name="log.pattern" value="%d{HH:mm:ss.SSS} [%thread] %-5level %logger{20} - [%method,%line] - %msg%n" />-->
<!-- Console 设置默认输出格式 -->
<property name="CONSOLE_LOG_PATTERN"
value="${CONSOLE_LOG_PATTERN:-%clr(%d{yyyy-MM-dd HH:mm:ss.SSS}){faint} %clr(${LOG_LEVEL_PATTERN:-%5p}) %clr(${PID:- }){magenta} %clr(---){faint} %clr([%15.15t]){faint} %clr(%-40.40logger{39}){cyan} %clr(:){faint} %m%n${LOG_EXCEPTION_CONVERSION_WORD:-%wEx}}"/>
<!-- 控制台输出 -->
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<!--格式化输出:%d表示日期%thread表示线程名%-5level级别从左显示5个字符宽度%msg日志消息%n是换行符 -->
<!-- <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50}:%L - %msg%n</pattern>-->
<pattern>${CONSOLE_LOG_PATTERN}</pattern>
</encoder>
</appender>
<!-- 系统日志输出 -->
<appender name="file_info" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${log.path}/sys-info.log</file>
<!-- 循环政策:基于时间创建日志文件 -->
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- 日志文件名格式 -->
<fileNamePattern>${log.path}/sys-info.%d{yyyy-MM-dd}.log</fileNamePattern>
<!-- 日志最大的历史 60天 -->
<maxHistory>60</maxHistory>
</rollingPolicy>
<encoder>
<pattern>${log.pattern}</pattern>
</encoder>
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<!-- 过滤的级别 -->
<level>INFO</level>
<!-- 匹配时的操作:接收(记录) -->
<onMatch>ACCEPT</onMatch>
<!-- 不匹配时的操作:拒绝(不记录) -->
<onMismatch>DENY</onMismatch>
</filter>
</appender>
<appender name="file_error" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${log.path}/sys-error.log</file>
<!-- 循环政策:基于时间创建日志文件 -->
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- 日志文件名格式 -->
<fileNamePattern>${log.path}/sys-error.%d{yyyy-MM-dd}.log</fileNamePattern>
<!-- 日志最大的历史 60天 -->
<maxHistory>60</maxHistory>
</rollingPolicy>
<encoder>
<pattern>${log.pattern}</pattern>
</encoder>
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<!-- 过滤的级别 -->
<level>ERROR</level>
<!-- 匹配时的操作:接收(记录) -->
<onMatch>ACCEPT</onMatch>
<!-- 不匹配时的操作:拒绝(不记录) -->
<onMismatch>DENY</onMismatch>
</filter>
</appender>
<!-- 用户访问日志输出 -->
<appender name="sys-user" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${log.path}/sys-user.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- 按天回滚 daily -->
<fileNamePattern>${log.path}/sys-user.%d{yyyy-MM-dd}.log</fileNamePattern>
<!-- 日志最大的历史 60天 -->
<maxHistory>60</maxHistory>
</rollingPolicy>
<encoder>
<pattern>${log.pattern}</pattern>
</encoder>
</appender>
<!-- 系统模块日志级别控制 -->
<logger name="com.yanzhu" level="info" />
<!-- Spring日志级别控制 -->
<logger name="org.springframework" level="warn" />
<root level="info">
<appender-ref ref="console" />
</root>
<!--系统操作日志-->
<root level="info">
<appender-ref ref="file_info" />
<appender-ref ref="file_error" />
</root>
<!--系统用户操作日志-->
<logger name="sys-user" level="info">
<appender-ref ref="sys-user"/>
</logger>
</configuration>

View File

@ -1,20 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE configuration
PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-config.dtd">
<configuration>
<!-- 全局参数 -->
<settings>
<!-- 使全局的映射器启用或禁用缓存 -->
<setting name="cacheEnabled" value="true" />
<!-- 允许JDBC 支持自动生成主键 -->
<setting name="useGeneratedKeys" value="true" />
<!-- 配置默认的执行器.SIMPLE就是普通执行器;REUSE执行器会重用预处理语句(prepared statements);BATCH执行器将重用语句并执行批量更新 -->
<setting name="defaultExecutorType" value="SIMPLE" />
<!-- 指定 MyBatis 所用日志的具体实现 -->
<setting name="logImpl" value="SLF4J" />
<!-- 使用驼峰命名法转换字段 -->
<!-- <setting name="mapUnderscoreToCamelCase" value="true"/> -->
</settings>
</configuration>