diff --git a/pom.xml b/pom.xml index f078503..05cfadf 100644 --- a/pom.xml +++ b/pom.xml @@ -219,7 +219,6 @@ yanzhu-flowable yanzhu-manage yanzhu-mapper - yanzhu-wechat pom diff --git a/yanzhu-admin/src/main/resources/application-druid.yml b/yanzhu-admin/src/main/resources/application-druid.yml index 6221291..91dbbb1 100644 --- a/yanzhu-admin/src/main/resources/application-druid.yml +++ b/yanzhu-admin/src/main/resources/application-druid.yml @@ -19,7 +19,7 @@ server: port: 8080 servlet: # 应用的访问路径 - context-path: /prjapi + context-path: /yanZhuProject tomcat: # tomcat的URI编码 uri-encoding: UTF-8 diff --git a/yanzhu-framework/src/main/java/com/yanzhu/framework/web/service/TokenService.java b/yanzhu-framework/src/main/java/com/yanzhu/framework/web/service/TokenService.java index 348d100..4021af1 100644 --- a/yanzhu-framework/src/main/java/com/yanzhu/framework/web/service/TokenService.java +++ b/yanzhu-framework/src/main/java/com/yanzhu/framework/web/service/TokenService.java @@ -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); + } + + /** * 设置用户代理信息 * diff --git a/yanzhu-manage/pom.xml b/yanzhu-manage/pom.xml index bbbbe36..c4e81f5 100644 --- a/yanzhu-manage/pom.xml +++ b/yanzhu-manage/pom.xml @@ -50,6 +50,10 @@ com.yanzhu yanzhu-framework + + com.yanzhu + yanzhu-flowable + diff --git a/yanzhu-manage/src/main/java/com/yanzhu/wechat/controller/WxFlowableController.java b/yanzhu-manage/src/main/java/com/yanzhu/wechat/controller/WxFlowableController.java index de2c3d0..6972981 100644 --- a/yanzhu-manage/src/main/java/com/yanzhu/wechat/controller/WxFlowableController.java +++ b/yanzhu-manage/src/main/java/com/yanzhu/wechat/controller/WxFlowableController.java @@ -276,7 +276,7 @@ public class WxFlowableController extends BaseController { } /** - * 根据条件统计所有流任务 + * 根据条件统计所有流程任务 * @param flowTaskEntity * @return */ diff --git a/yanzhu-manage/src/main/java/com/yanzhu/wechat/controller/WxLoginController.java b/yanzhu-manage/src/main/java/com/yanzhu/wechat/controller/WxLoginController.java index a832c61..59f4fe8 100644 --- a/yanzhu-manage/src/main/java/com/yanzhu/wechat/controller/WxLoginController.java +++ b/yanzhu-manage/src/main/java/com/yanzhu/wechat/controller/WxLoginController.java @@ -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(); + } + } diff --git a/yanzhu-manage/src/main/java/com/yanzhu/wechat/controller/WxPublicsController.java b/yanzhu-manage/src/main/java/com/yanzhu/wechat/controller/WxPublicsController.java index 3729604..4066517 100644 --- a/yanzhu-manage/src/main/java/com/yanzhu/wechat/controller/WxPublicsController.java +++ b/yanzhu-manage/src/main/java/com/yanzhu/wechat/controller/WxPublicsController.java @@ -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 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 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 list = proProjectInfoService.selectProProjectInfoList(proProjectInfo); + redisCache.setCacheObject(key, list, Constants.CAPTCHA_EXPIRATION, TimeUnit.MINUTES); + return success(list); + } + } diff --git a/yanzhu-mapper/src/main/java/com/yanzhu/project/domain/ProProjectApplyDetail.java b/yanzhu-mapper/src/main/java/com/yanzhu/project/domain/ProProjectApplyDetail.java index 2ea7693..a5c6bb8 100644 --- a/yanzhu-mapper/src/main/java/com/yanzhu/project/domain/ProProjectApplyDetail.java +++ b/yanzhu-mapper/src/main/java/com/yanzhu/project/domain/ProProjectApplyDetail.java @@ -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()) diff --git a/yanzhu-mapper/src/main/java/com/yanzhu/project/service/impl/ProProjectApplyServiceImpl.java b/yanzhu-mapper/src/main/java/com/yanzhu/project/service/impl/ProProjectApplyServiceImpl.java index 04a4efc..b900652 100644 --- a/yanzhu-mapper/src/main/java/com/yanzhu/project/service/impl/ProProjectApplyServiceImpl.java +++ b/yanzhu-mapper/src/main/java/com/yanzhu/project/service/impl/ProProjectApplyServiceImpl.java @@ -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); } diff --git a/yanzhu-system/src/main/java/com/yanzhu/system/mapper/SysDeptMapper.java b/yanzhu-system/src/main/java/com/yanzhu/system/mapper/SysDeptMapper.java index ce98706..2bfd815 100644 --- a/yanzhu-system/src/main/java/com/yanzhu/system/mapper/SysDeptMapper.java +++ b/yanzhu-system/src/main/java/com/yanzhu/system/mapper/SysDeptMapper.java @@ -115,4 +115,5 @@ public interface SysDeptMapper * @return 结果 */ public int deleteDeptById(Long deptId); + } diff --git a/yanzhu-system/src/main/java/com/yanzhu/system/service/ISysDeptService.java b/yanzhu-system/src/main/java/com/yanzhu/system/service/ISysDeptService.java index aa17311..114f1b4 100644 --- a/yanzhu-system/src/main/java/com/yanzhu/system/service/ISysDeptService.java +++ b/yanzhu-system/src/main/java/com/yanzhu/system/service/ISysDeptService.java @@ -121,4 +121,12 @@ public interface ISysDeptService * @return 结果 */ public int deleteDeptById(Long deptId); + + /** + * 查询子部门列表 + * + * @param deptId 部门ID + * @return 结果 + */ + public List findChildList(Long deptId); } diff --git a/yanzhu-system/src/main/java/com/yanzhu/system/service/ISysUserService.java b/yanzhu-system/src/main/java/com/yanzhu/system/service/ISysUserService.java index 6972888..ad9bf1f 100644 --- a/yanzhu-system/src/main/java/com/yanzhu/system/service/ISysUserService.java +++ b/yanzhu-system/src/main/java/com/yanzhu/system/service/ISysUserService.java @@ -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 userList, Boolean isUpdateSupport, String operName); + + /** + * 用户修改密码 + * + * @param updatePwdVo 密码信息 + * @return 结果 + */ + public void updatePwd(UpdatePwdVo updatePwdVo); } diff --git a/yanzhu-system/src/main/java/com/yanzhu/system/service/impl/SysDeptServiceImpl.java b/yanzhu-system/src/main/java/com/yanzhu/system/service/impl/SysDeptServiceImpl.java index d634a74..f4c7faf 100644 --- a/yanzhu-system/src/main/java/com/yanzhu/system/service/impl/SysDeptServiceImpl.java +++ b/yanzhu-system/src/main/java/com/yanzhu/system/service/impl/SysDeptServiceImpl.java @@ -335,4 +335,16 @@ public class SysDeptServiceImpl implements ISysDeptService { return getChildList(list, t).size() > 0; } + + /** + * 查询子部门列表 + * + * @param deptId 部门ID + * @return 结果 + */ + public List findChildList(Long deptId) { + SysDept sysDept = new SysDept(); + sysDept.setParentId(deptId); + return deptMapper.selectDeptList(sysDept); + } } diff --git a/yanzhu-system/src/main/java/com/yanzhu/system/service/impl/SysUserServiceImpl.java b/yanzhu-system/src/main/java/com/yanzhu/system/service/impl/SysUserServiceImpl.java index 5975fbd..a41ae64 100644 --- a/yanzhu-system/src/main/java/com/yanzhu/system/service/impl/SysUserServiceImpl.java +++ b/yanzhu-system/src/main/java/com/yanzhu/system/service/impl/SysUserServiceImpl.java @@ -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); + } } diff --git a/yanzhu-wechat/pom.xml b/yanzhu-wechat/pom.xml deleted file mode 100644 index 07a95bf..0000000 --- a/yanzhu-wechat/pom.xml +++ /dev/null @@ -1,89 +0,0 @@ - - - - yanzhu - com.yanzhu - 3.8.7 - - 4.0.0 - - yanzhu-wechat - - - 17 - 17 - - - - - - - mysql - mysql-connector-java - - - - - com.yanzhu - yanzhu-framework - - - - - com.yanzhu - yanzhu-flowable - - - - - com.yanzhu - yanzhu-system - - - - - com.yanzhu - yanzhu-mapper - - - - org.projectlombok - lombok - true - - - - - - - - org.springframework.boot - spring-boot-maven-plugin - 2.1.1.RELEASE - - true - - - - - repackage - - - - - - org.apache.maven.plugins - maven-war-plugin - 3.1.0 - - false - ${project.artifactId} - - - - ${project.artifactId} - - - \ No newline at end of file diff --git a/yanzhu-wechat/src/main/java/com/yanzhu/WxYanZhuApplication.java b/yanzhu-wechat/src/main/java/com/yanzhu/WxYanZhuApplication.java deleted file mode 100644 index 97ae438..0000000 --- a/yanzhu-wechat/src/main/java/com/yanzhu/WxYanZhuApplication.java +++ /dev/null @@ -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" + - " ''-' `'-' `-..-' "); - } -} diff --git a/yanzhu-wechat/src/main/java/com/yanzhu/WxYanzhuServletInitializer.java b/yanzhu-wechat/src/main/java/com/yanzhu/WxYanzhuServletInitializer.java deleted file mode 100644 index 13f3f9e..0000000 --- a/yanzhu-wechat/src/main/java/com/yanzhu/WxYanzhuServletInitializer.java +++ /dev/null @@ -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); - } -} diff --git a/yanzhu-wechat/src/main/java/com/yanzhu/wechat/common/CaptchaController.java b/yanzhu-wechat/src/main/java/com/yanzhu/wechat/common/CaptchaController.java deleted file mode 100644 index 127c917..0000000 --- a/yanzhu-wechat/src/main/java/com/yanzhu/wechat/common/CaptchaController.java +++ /dev/null @@ -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; - } -} diff --git a/yanzhu-wechat/src/main/java/com/yanzhu/wechat/common/CommonController.java b/yanzhu-wechat/src/main/java/com/yanzhu/wechat/common/CommonController.java deleted file mode 100644 index 45af46b..0000000 --- a/yanzhu-wechat/src/main/java/com/yanzhu/wechat/common/CommonController.java +++ /dev/null @@ -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 files) throws Exception - { - try - { - // 上传文件路径 - String filePath = YanZhuConfig.getUploadPath(); - List urls = new ArrayList(); - List fileNames = new ArrayList(); - List newFileNames = new ArrayList(); - List originalFilenames = new ArrayList(); - 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); - } - } -} diff --git a/yanzhu-wechat/src/main/resources/META-INF/spring-devtools.properties b/yanzhu-wechat/src/main/resources/META-INF/spring-devtools.properties deleted file mode 100644 index 37e7b58..0000000 --- a/yanzhu-wechat/src/main/resources/META-INF/spring-devtools.properties +++ /dev/null @@ -1 +0,0 @@ -restart.include.json=/com.alibaba.fastjson2.*.jar \ No newline at end of file diff --git a/yanzhu-wechat/src/main/resources/application-druid.yml b/yanzhu-wechat/src/main/resources/application-druid.yml deleted file mode 100644 index 5a79fe1..0000000 --- a/yanzhu-wechat/src/main/resources/application-druid.yml +++ /dev/null @@ -1,117 +0,0 @@ -# 项目相关配置 -yanzhu: - # 名称 - name: ProjectName - # 版本 - version: 3.8.7 - # 版权年份 - copyrightYear: 2023 - # 文件路径 示例( Windows配置D:/yanZhu/uploadPath,Linux配置 /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 \ No newline at end of file diff --git a/yanzhu-wechat/src/main/resources/application-prod.yml b/yanzhu-wechat/src/main/resources/application-prod.yml deleted file mode 100644 index 727946e..0000000 --- a/yanzhu-wechat/src/main/resources/application-prod.yml +++ /dev/null @@ -1,117 +0,0 @@ -# 项目相关配置 -yanZhu: - # 名称 - name: ProjectName - # 版本 - version: 3.8.7 - # 版权年份 - copyrightYear: 2023 - # 文件路径 示例( Windows配置D:/yanZhu/uploadPath,Linux配置 /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 \ No newline at end of file diff --git a/yanzhu-wechat/src/main/resources/application.yml b/yanzhu-wechat/src/main/resources/application.yml deleted file mode 100644 index 5b42bfb..0000000 --- a/yanzhu-wechat/src/main/resources/application.yml +++ /dev/null @@ -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 \ No newline at end of file diff --git a/yanzhu-wechat/src/main/resources/banner.txt b/yanzhu-wechat/src/main/resources/banner.txt deleted file mode 100644 index d9aa928..0000000 --- a/yanzhu-wechat/src/main/resources/banner.txt +++ /dev/null @@ -1,24 +0,0 @@ -Application Version: ${yanzhu.version} -Spring Boot Version: ${spring-boot.version} -//////////////////////////////////////////////////////////////////// -// _ooOoo_ // -// o8888888o // -// 88" . "88 // -// (| ^_^ |) // -// O\ = /O // -// ____/`---'\____ // -// .' \\| |// `. // -// / \\||| : |||// \ // -// / _||||| -:- |||||- \ // -// | | \\\ - /// | | // -// | \_| ''\---/'' | | // -// \ .-\__ `-` ___/-. / // -// ___`. .' /--.--\ `. . ___ // -// ."" '< `.___\_<|>_/___.' >'"". // -// | | : `- \`.;`\ _ /`;.`/ - ` : | | // -// \ \ `-. \_ __\ /__ _/ .-` / / // -// ========`-.____`-.___\_____/___.-`____.-'======== // -// `=---=' // -// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ // -// 佛祖保佑 永不宕机 永无BUG // -//////////////////////////////////////////////////////////////////// \ No newline at end of file diff --git a/yanzhu-wechat/src/main/resources/i18n/messages.properties b/yanzhu-wechat/src/main/resources/i18n/messages.properties deleted file mode 100644 index 93de005..0000000 --- a/yanzhu-wechat/src/main/resources/i18n/messages.properties +++ /dev/null @@ -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=上传的文件大小超出限制的文件大小!
允许的文件最大大小是:{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}] diff --git a/yanzhu-wechat/src/main/resources/logback.xml b/yanzhu-wechat/src/main/resources/logback.xml deleted file mode 100644 index 30b7042..0000000 --- a/yanzhu-wechat/src/main/resources/logback.xml +++ /dev/null @@ -1,106 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - ${CONSOLE_LOG_PATTERN} - - - - - - ${log.path}/sys-info.log - - - - ${log.path}/sys-info.%d{yyyy-MM-dd}.log - - 60 - - - ${log.pattern} - - - - INFO - - ACCEPT - - DENY - - - - - ${log.path}/sys-error.log - - - - ${log.path}/sys-error.%d{yyyy-MM-dd}.log - - 60 - - - ${log.pattern} - - - - ERROR - - ACCEPT - - DENY - - - - - - ${log.path}/sys-user.log - - - ${log.path}/sys-user.%d{yyyy-MM-dd}.log - - 60 - - - ${log.pattern} - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/yanzhu-wechat/src/main/resources/mybatis/mybatis-config.xml b/yanzhu-wechat/src/main/resources/mybatis/mybatis-config.xml deleted file mode 100644 index ac47c03..0000000 --- a/yanzhu-wechat/src/main/resources/mybatis/mybatis-config.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - - - - - - - - - - - -