commit 0c9d340a05734caecf2777ec33bf18e0b5b2e217 Author: 清晨 <136767481@qq.com> Date: Tue Apr 8 16:37:17 2025 +0800 提交 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..46e3350 --- /dev/null +++ b/.gitignore @@ -0,0 +1,51 @@ +###################################################################### +# Build Tools + +.gradle +/build/ +!gradle/wrapper/gradle-wrapper.jar + +target/ +!.mvn/wrapper/maven-wrapper.jar + +###################################################################### +# IDE + +### STS ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans + +### IntelliJ IDEA ### +.idea/ +.idea +*.iws +*.iml +*.ipr + +### NetBeans ### +nbproject/private/ +build/* +nbbuild/ +dist/ +nbdist/ +.nb-gradle/ + +###################################################################### +# Others +*.log +*.xml.versionsBackup +*.swp + +!*/build/*.java +!*/build/*.html +!*/build/*.xml + + +###################################################################### +.vscode/ +.target/ + diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..8564f29 --- /dev/null +++ b/LICENSE @@ -0,0 +1,20 @@ +The MIT License (MIT) + +Copyright (c) 2018 RuoYi + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software is furnished to do so, +subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..162d3db --- /dev/null +++ b/README.md @@ -0,0 +1 @@ +## 平台简介 diff --git a/hf.fo b/hf.fo new file mode 100644 index 0000000..50695ae --- /dev/null +++ b/hf.fo @@ -0,0 +1,5 @@ +BODY CONTENTBODY CONTENTBODY CONTENTBODY CONTENT + + + + \ No newline at end of file diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..48e341a --- /dev/null +++ b/package-lock.json @@ -0,0 +1,3 @@ +{ + "lockfileVersion": 1 +} diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..d9876e7 --- /dev/null +++ b/pom.xml @@ -0,0 +1,336 @@ + + + 4.0.0 + + com.ruoyi + ruoyi + 3.7.0 + + ruoyi + http://www.ruoyi.vip + 若依S管理系统 + + + 3.7.0 + UTF-8 + UTF-8 + 1.8 + 3.1.1 + 1.2.6 + 1.21 + 3.0.0 + 2.3.2 + 3.4.2 + 1.3.1 + 1.2.78 + 5.8.0 + 5.8.0 + 2.11.0 + 1.4 + 3.2.2 + 4.1.2 + 1.7 + 0.9.1 + 1.1.55.RELEASE + 1.9 + + + + + + + + + org.springframework.boot + spring-boot-dependencies + 2.5.5 + pom + import + + + + + com.alibaba + druid-spring-boot-starter + ${druid.version} + + + + + eu.bitwalker + UserAgentUtils + ${bitwalker.version} + + + + + com.baomidou + mybatis-plus-boot-starter + ${mybatis-plus-boot-starter.version} + + + com.baomidou + mybatis-plus-extension + ${mybatis-plus-boot-starter.version} + + + + + com.github.pagehelper + pagehelper-spring-boot-starter + ${pagehelper.boot.version} + + + + + com.github.oshi + oshi-core + ${oshi.version} + + + + net.java.dev.jna + jna + ${jna.version} + + + + net.java.dev.jna + jna-platform + ${jna.version} + + + + + io.springfox + springfox-boot-starter + ${swagger.version} + + + io.swagger + swagger-models + + + + + + + commons-io + commons-io + ${commons.io.version} + + + org.apache.commons + commons-text + ${commons-text.version} + + + com.ibeetl + beetl-framework-starter + ${beetl.version} + + + + + commons-fileupload + commons-fileupload + ${commons.fileupload.version} + + + + + org.apache.poi + poi-ooxml + ${poi.version} + + + + + org.apache.velocity + velocity + ${velocity.version} + + + commons-collections + commons-collections + + + + + + + commons-collections + commons-collections + ${commons.collections.version} + + + + + com.alibaba + fastjson + ${fastjson.version} + + + + + io.jsonwebtoken + jjwt + ${jwt.version} + + + + + com.github.penggle + kaptcha + ${kaptcha.version} + + + + + com.ruoyi + ruoyi-quartz + ${ruoyi.version} + + + + + com.ruoyi + ruoyi-generator + ${ruoyi.version} + + + + + com.ruoyi + ruoyi-framework + ${ruoyi.version} + + + + + com.ruoyi + ruoyi-system + ${ruoyi.version} + + + + + com.ruoyi + ruoyi-common + ${ruoyi.version} + + + + + com.ruoyi + ruoyi-tenant + ${ruoyi.version} + + + + com.ruoyi + ruoyi-data-rule + ${ruoyi.version} + + + + com.ruoyi + ruoyi-oss + ${ruoyi.version} + + + + com.ruoyi + ruoyi-biz + ${ruoyi.version} + + + + + + com.lkl.laop.sdk + lkl-laop-java-sdk + 1.0.5 + + + + + + ruoyi-main + ruoyi-base-support + ruoyi-extend + + pom + + + + + + + + + + src/main/java + + **/*.xml + + + + src/main/resources + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.1 + + ${java.version} + ${java.version} + ${project.build.sourceEncoding} + + + + + + + + public + aliyun nexus + http://maven.aliyun.com/nexus/content/groups/public/ + + true + + + + + + + + + + + + + + + + + + + public + aliyun nexus + http://maven.aliyun.com/nexus/content/groups/public/ + + true + + + false + + + + + diff --git a/ruoyi-base-support/pom.xml b/ruoyi-base-support/pom.xml new file mode 100644 index 0000000..28f3e9a --- /dev/null +++ b/ruoyi-base-support/pom.xml @@ -0,0 +1,33 @@ + + + 4.0.0 + + com.ruoyi + ruoyi + 3.7.0 + + + ruoyi-base-support + pom + + ruoyi-biz + ruoyi-common + ruoyi-data-rule + ruoyi-framework + ruoyi-generator + ruoyi-oss + ruoyi-quartz + ruoyi-system + ruoyi-tenant + ruoyi-admin + + + + 8 + 8 + UTF-8 + + + \ No newline at end of file diff --git a/ruoyi-base-support/ruoyi-admin/pom.xml b/ruoyi-base-support/ruoyi-admin/pom.xml new file mode 100644 index 0000000..f557a17 --- /dev/null +++ b/ruoyi-base-support/ruoyi-admin/pom.xml @@ -0,0 +1,70 @@ + + + 4.0.0 + + com.ruoyi + ruoyi-base-support + 3.7.0 + + + ruoyi-admin + + + 8 + 8 + UTF-8 + + + + + + + + io.springfox + springfox-boot-starter + + + + + io.swagger + swagger-models + 1.6.2 + + + + + mysql + mysql-connector-java + + + + + com.ruoyi + ruoyi-framework + + + + + + + + com.ruoyi + ruoyi-generator + + + com.ruoyi + ruoyi-oss + + + + com.ruoyi + ruoyi-biz + + + + \ No newline at end of file diff --git a/ruoyi-base-support/ruoyi-admin/src/main/java/com/ruoyi/web/controller/common/CaptchaController.java b/ruoyi-base-support/ruoyi-admin/src/main/java/com/ruoyi/web/controller/common/CaptchaController.java new file mode 100644 index 0000000..a558c5f --- /dev/null +++ b/ruoyi-base-support/ruoyi-admin/src/main/java/com/ruoyi/web/controller/common/CaptchaController.java @@ -0,0 +1,90 @@ +package com.ruoyi.web.controller.common; + +import com.google.code.kaptcha.Producer; +import com.ruoyi.common.constant.Constants; +import com.ruoyi.common.core.domain.AjaxResultMap; +import com.ruoyi.common.core.redis.RedisService; +import com.ruoyi.common.utils.sign.Base64; +import com.ruoyi.common.utils.uuid.IdUtils; +import com.ruoyi.system.service.ISysConfigService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +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 ruoyi + */ +@RestController +public class CaptchaController { + @Resource(name = "captchaProducer") + private Producer captchaProducer; + + @Resource(name = "captchaProducerMath") + private Producer captchaProducerMath; + + @Autowired + private RedisService redisCache; + + // 验证码类型 + @Value("${ruoyi.captchaType}") + private String captchaType; + + @Autowired + private ISysConfigService configService; + + /** + * 生成验证码 + */ + @GetMapping("/captchaImage") + public AjaxResultMap getCode(HttpServletResponse response) throws IOException { + AjaxResultMap ajax = AjaxResultMap.success(); + boolean captchaOnOff = configService.selectCaptchaOnOff(); + ajax.put("captchaOnOff", captchaOnOff); + if (!captchaOnOff) { + return ajax; + } + + // 保存验证码信息 + String uuid = IdUtils.simpleUUID(); + String verifyKey = Constants.CAPTCHA_CODE_KEY + uuid; + + String capStr = null, code = null; + BufferedImage image = null; + + // 生成验证码 + if ("math".equals(captchaType)) { + String capText = captchaProducerMath.createText(); + capStr = capText.substring(0, capText.lastIndexOf("@")); + code = capText.substring(capText.lastIndexOf("@") + 1); + System.out.println(capStr); + 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 AjaxResultMap.error(e.getMessage()); + } + + ajax.put("uuid", uuid); + ajax.put("img", Base64.encode(os.toByteArray())); + return ajax; + } +} diff --git a/ruoyi-base-support/ruoyi-admin/src/main/java/com/ruoyi/web/controller/common/CommonController.java b/ruoyi-base-support/ruoyi-admin/src/main/java/com/ruoyi/web/controller/common/CommonController.java new file mode 100644 index 0000000..0b8aea5 --- /dev/null +++ b/ruoyi-base-support/ruoyi-admin/src/main/java/com/ruoyi/web/controller/common/CommonController.java @@ -0,0 +1,142 @@ +package com.ruoyi.web.controller.common; + +import com.ruoyi.common.config.RuoYiConfig; +import com.ruoyi.common.constant.Constants; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.domain.AjaxResultMap; +import com.ruoyi.common.exception.file.FileNameLengthLimitExceededException; +import com.ruoyi.common.utils.StringUtils; +import com.ruoyi.common.utils.file.FileUploadUtils; +import com.ruoyi.common.utils.file.FileUtils; +import com.ruoyi.framework.config.ServerConfig; +import com.ruoyi.oss.utils.AttachmentHelper; +import org.apache.commons.fileupload.FileUploadBase; +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.*; +import org.springframework.web.multipart.MultipartFile; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; + +/** + * 通用请求处理 + * + * @author ruoyi + */ +@RestController +public class CommonController +{ + private static final Logger log = LoggerFactory.getLogger(CommonController.class); + + @Autowired + private ServerConfig serverConfig; + @Autowired + private AttachmentHelper attachmentHelper; + + /** + * 通用下载请求 + * + * @param fileName 文件名称 + * @param delete 是否删除 + */ + @GetMapping("common/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 = RuoYiConfig.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("/common/upload") + public AjaxResultMap uploadFile(MultipartFile file) throws Exception + { + try + { + // 上传文件路径 + String filePath = RuoYiConfig.getUploadPath(); + // 上传并返回新文件名称 + String fileName = FileUploadUtils.upload(filePath, file); + String url = serverConfig.getUrl() + fileName; + AjaxResultMap ajax = AjaxResultMap.success(); + ajax.put("fileName", fileName); + ajax.put("url", url); + return ajax; + } + catch (Exception e) + { + return AjaxResultMap.error(e.getMessage()); + } + } + + /** + * 本地资源通用下载 + */ + @GetMapping("/common/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 = RuoYiConfig.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); + } + } + + @RequestMapping(value = "/common/ossUpload", method = RequestMethod.POST) + public AjaxResult upload(HttpServletRequest request, MultipartFile file, @RequestParam(required = false, defaultValue = "") String dir) { + try { + return AjaxResult.success((Object) attachmentHelper.upload(request, file, dir)); + } catch (IOException e) { + return AjaxResult.error("上传失败"); + } catch (FileUploadBase.FileSizeLimitExceededException e) { + return AjaxResult.error("上传失败"); + } catch (FileNameLengthLimitExceededException e) { + return AjaxResult.error("上传失败"); + } catch (com.ruoyi.oss.exception.FileNameLengthLimitExceededException e) { + return AjaxResult.error("上传失败"); + } catch (com.ruoyi.oss.exception.InvalidExtensionException e) { + return AjaxResult.error("上传失败"); + } + } + +} diff --git a/ruoyi-base-support/ruoyi-admin/src/main/java/com/ruoyi/web/controller/monitor/CacheController.java b/ruoyi-base-support/ruoyi-admin/src/main/java/com/ruoyi/web/controller/monitor/CacheController.java new file mode 100644 index 0000000..dcc1efd --- /dev/null +++ b/ruoyi-base-support/ruoyi-admin/src/main/java/com/ruoyi/web/controller/monitor/CacheController.java @@ -0,0 +1,50 @@ +package com.ruoyi.web.controller.monitor; + +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.utils.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.redis.core.RedisCallback; +import org.springframework.data.redis.core.RedisTemplate; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.util.*; + +/** + * 缓存监控 + * + * @author ruoyi + */ +@RestController +@RequestMapping("/monitor/cache") +public class CacheController +{ + @Autowired + private RedisTemplate redisTemplate; + + @PreAuthorize("@ss.hasPermi('monitor:cache:list')") + @GetMapping() + public AjaxResult getInfo() throws Exception + { + Properties info = (Properties) redisTemplate.execute((RedisCallback) connection -> connection.info()); + Properties commandStats = (Properties) redisTemplate.execute((RedisCallback) connection -> connection.info("commandstats")); + Object dbSize = redisTemplate.execute((RedisCallback) connection -> connection.dbSize()); + + Map result = new HashMap<>(3); + result.put("info", info); + result.put("dbSize", dbSize); + + List> pieList = new ArrayList<>(); + commandStats.stringPropertyNames().forEach(key -> { + Map data = new HashMap<>(2); + String property = commandStats.getProperty(key); + data.put("name", StringUtils.removeStart(key, "cmdstat_")); + data.put("value", StringUtils.substringBetween(property, "calls=", ",usec")); + pieList.add(data); + }); + result.put("commandStats", pieList); + return AjaxResult.success(result); + } +} diff --git a/ruoyi-base-support/ruoyi-admin/src/main/java/com/ruoyi/web/controller/monitor/ServerController.java b/ruoyi-base-support/ruoyi-admin/src/main/java/com/ruoyi/web/controller/monitor/ServerController.java new file mode 100644 index 0000000..6a8bab1 --- /dev/null +++ b/ruoyi-base-support/ruoyi-admin/src/main/java/com/ruoyi/web/controller/monitor/ServerController.java @@ -0,0 +1,27 @@ +package com.ruoyi.web.controller.monitor; + +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.framework.web.domain.Server; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * 服务器监控 + * + * @author ruoyi + */ +@RestController +@RequestMapping("/monitor/server") +public class ServerController +{ + @PreAuthorize("@ss.hasPermi('monitor:server:list')") + @GetMapping() + public AjaxResult getInfo() throws Exception + { + Server server = new Server(); + server.copyTo(); + return AjaxResult.success(server); + } +} diff --git a/ruoyi-base-support/ruoyi-admin/src/main/java/com/ruoyi/web/controller/monitor/SysLogininforController.java b/ruoyi-base-support/ruoyi-admin/src/main/java/com/ruoyi/web/controller/monitor/SysLogininforController.java new file mode 100644 index 0000000..8bd22f9 --- /dev/null +++ b/ruoyi-base-support/ruoyi-admin/src/main/java/com/ruoyi/web/controller/monitor/SysLogininforController.java @@ -0,0 +1,64 @@ +package com.ruoyi.web.controller.monitor; + +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.page.TableDataInfo; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.common.utils.poi.ExcelUtil; +import com.ruoyi.system.domain.SysLogininfor; +import com.ruoyi.system.service.ISysLogininforService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +/** + * 系统访问记录 + * + * @author ruoyi + */ +@RestController +@RequestMapping("/monitor/logininfor") +public class SysLogininforController extends BaseController +{ + @Autowired + private ISysLogininforService logininforService; + + @PreAuthorize("@ss.hasPermi('monitor:logininfor:list')") + @GetMapping("/list") + public TableDataInfo list(SysLogininfor logininfor) + { + startPage(); + List list = logininforService.selectLogininforList(logininfor); + return getDataTable(list); + } + + @Log(title = "登录日志", businessType = BusinessType.EXPORT) + @PreAuthorize("@ss.hasPermi('monitor:logininfor:export')") + @GetMapping("/export") + public AjaxResult export(SysLogininfor logininfor) + { + List list = logininforService.selectLogininforList(logininfor); + ExcelUtil util = new ExcelUtil(SysLogininfor.class); + return util.exportExcel(list, "登录日志"); + } + + @PreAuthorize("@ss.hasPermi('monitor:logininfor:remove')") + @Log(title = "登录日志", businessType = BusinessType.DELETE) + @DeleteMapping("/{infoIds}") + public AjaxResult remove(@PathVariable Long[] infoIds) + { + return toAjax(logininforService.deleteLogininforByIds(infoIds)); + } + + @PreAuthorize("@ss.hasPermi('monitor:logininfor:remove')") + @Log(title = "登录日志", businessType = BusinessType.CLEAN) + @DeleteMapping("/clean") + public AjaxResult clean() + { + logininforService.cleanLogininfor(); + return AjaxResult.success(); + } +} diff --git a/ruoyi-base-support/ruoyi-admin/src/main/java/com/ruoyi/web/controller/monitor/SysOperlogController.java b/ruoyi-base-support/ruoyi-admin/src/main/java/com/ruoyi/web/controller/monitor/SysOperlogController.java new file mode 100644 index 0000000..ad8f0d5 --- /dev/null +++ b/ruoyi-base-support/ruoyi-admin/src/main/java/com/ruoyi/web/controller/monitor/SysOperlogController.java @@ -0,0 +1,64 @@ +package com.ruoyi.web.controller.monitor; + +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.page.TableDataInfo; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.common.utils.poi.ExcelUtil; +import com.ruoyi.system.domain.SysOperLog; +import com.ruoyi.system.service.ISysOperLogService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +/** + * 操作日志记录 + * + * @author ruoyi + */ +@RestController +@RequestMapping("/monitor/operlog") +public class SysOperlogController extends BaseController +{ + @Autowired + private ISysOperLogService operLogService; + + @PreAuthorize("@ss.hasPermi('monitor:operlog:list')") + @GetMapping("/list") + public TableDataInfo list(SysOperLog operLog) + { + startPage(); + List list = operLogService.selectOperLogList(operLog); + return getDataTable(list); + } + + @Log(title = "操作日志", businessType = BusinessType.EXPORT) + @PreAuthorize("@ss.hasPermi('monitor:operlog:export')") + @GetMapping("/export") + public AjaxResult export(SysOperLog operLog) + { + List list = operLogService.selectOperLogList(operLog); + ExcelUtil util = new ExcelUtil(SysOperLog.class); + return util.exportExcel(list, "操作日志"); + } + + @Log(title = "操作日志", businessType = BusinessType.DELETE) + @PreAuthorize("@ss.hasPermi('monitor:operlog:remove')") + @DeleteMapping("/{operIds}") + public AjaxResult remove(@PathVariable Long[] operIds) + { + return toAjax(operLogService.deleteOperLogByIds(operIds)); + } + + @Log(title = "操作日志", businessType = BusinessType.CLEAN) + @PreAuthorize("@ss.hasPermi('monitor:operlog:remove')") + @DeleteMapping("/clean") + public AjaxResult clean() + { + operLogService.cleanOperLog(); + return AjaxResult.success(); + } +} diff --git a/ruoyi-base-support/ruoyi-admin/src/main/java/com/ruoyi/web/controller/monitor/SysUserOnlineController.java b/ruoyi-base-support/ruoyi-admin/src/main/java/com/ruoyi/web/controller/monitor/SysUserOnlineController.java new file mode 100644 index 0000000..59d3f13 --- /dev/null +++ b/ruoyi-base-support/ruoyi-admin/src/main/java/com/ruoyi/web/controller/monitor/SysUserOnlineController.java @@ -0,0 +1,89 @@ +package com.ruoyi.web.controller.monitor; + +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.constant.Constants; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.domain.model.LoginUser; +import com.ruoyi.common.core.page.TableDataInfo; +import com.ruoyi.common.core.redis.RedisService; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.common.utils.StringUtils; +import com.ruoyi.system.domain.SysUserOnline; +import com.ruoyi.system.service.ISysUserOnlineService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.*; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.List; + +/** + * 在线用户监控 + * + * @author ruoyi + */ +@RestController +@RequestMapping("/monitor/online") +public class SysUserOnlineController extends BaseController +{ + @Autowired + private ISysUserOnlineService userOnlineService; + + @Autowired + private RedisService redisCache; + + @PreAuthorize("@ss.hasPermi('monitor:online:list')") + @GetMapping("/list") + public TableDataInfo list(String ipaddr, String userName) + { + Collection keys = redisCache.keys(Constants.LOGIN_TOKEN_KEY + "*"); + List userOnlineList = new ArrayList(); + for (String key : keys) + { + LoginUser user = redisCache.getCacheObject(key); + if (StringUtils.isNotEmpty(ipaddr) && StringUtils.isNotEmpty(userName)) + { + if (StringUtils.equals(ipaddr, user.getIpaddr()) && StringUtils.equals(userName, user.getUsername())) + { + userOnlineList.add(userOnlineService.selectOnlineByInfo(ipaddr, userName, user)); + } + } + else if (StringUtils.isNotEmpty(ipaddr)) + { + if (StringUtils.equals(ipaddr, user.getIpaddr())) + { + userOnlineList.add(userOnlineService.selectOnlineByIpaddr(ipaddr, user)); + } + } + else if (StringUtils.isNotEmpty(userName) && StringUtils.isNotNull(user.getUser())) + { + if (StringUtils.equals(userName, user.getUsername())) + { + userOnlineList.add(userOnlineService.selectOnlineByUserName(userName, user)); + } + } + else + { + userOnlineList.add(userOnlineService.loginUserToUserOnline(user)); + } + } + Collections.reverse(userOnlineList); + userOnlineList.removeAll(Collections.singleton(null)); + return getDataTable(userOnlineList); + } + + /** + * 强退用户 + */ + @PreAuthorize("@ss.hasPermi('monitor:online:forceLogout')") + @Log(title = "在线用户", businessType = BusinessType.FORCE) + @DeleteMapping("/{tokenId}") + public AjaxResult forceLogout(@PathVariable String tokenId) + { + redisCache.deleteObject(Constants.LOGIN_TOKEN_KEY + tokenId); + return AjaxResult.success(); + } +} diff --git a/ruoyi-base-support/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysConfigController.java b/ruoyi-base-support/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysConfigController.java new file mode 100644 index 0000000..d2aad97 --- /dev/null +++ b/ruoyi-base-support/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysConfigController.java @@ -0,0 +1,130 @@ +package com.ruoyi.web.controller.system; + +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.annotation.RepeatSubmit; +import com.ruoyi.common.constant.UserConstants; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.domain.AjaxResultMap; +import com.ruoyi.common.core.page.TableDataInfo; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.common.utils.poi.ExcelUtil; +import com.ruoyi.system.domain.SysConfig; +import com.ruoyi.system.service.ISysConfigService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +/** + * 参数配置 信息操作处理 + * + * @author ruoyi + */ +@RestController +@RequestMapping("/system/config") +public class SysConfigController extends BaseController +{ + @Autowired + private ISysConfigService configService; + + /** + * 获取参数配置列表 + */ + @PreAuthorize("@ss.hasPermi('system:config:list')") + @GetMapping("/list") + public TableDataInfo list(SysConfig config) + { + startPage(); + List list = configService.selectConfigList(config); + return getDataTable(list); + } + + @Log(title = "参数管理", businessType = BusinessType.EXPORT) + @PreAuthorize("@ss.hasPermi('system:config:export')") + @GetMapping("/export") + public AjaxResult export(SysConfig config) + { + List list = configService.selectConfigList(config); + ExcelUtil util = new ExcelUtil(SysConfig.class); + return util.exportExcel(list, "参数数据"); + } + + /** + * 根据参数编号获取详细信息 + */ + @PreAuthorize("@ss.hasPermi('system:config:query')") + @GetMapping(value = "/{configId}") + public AjaxResult getInfo(@PathVariable Long configId) + { + return AjaxResult.success(configService.selectConfigById(configId)); + } + + /** + * 根据参数键名查询参数值 + */ + @GetMapping(value = "/configKey/{configKey}") + public AjaxResultMap getConfigKey(@PathVariable String configKey) + { + return AjaxResultMap.success(configService.selectConfigByKey(configKey)); + } + + /** + * 新增参数配置 + */ + @PreAuthorize("@ss.hasPermi('system:config:add')") + @Log(title = "参数管理", businessType = BusinessType.INSERT) + @PostMapping + @RepeatSubmit + public AjaxResult add(@Validated @RequestBody SysConfig config) + { + if (UserConstants.NOT_UNIQUE.equals(configService.checkConfigKeyUnique(config))) + { + return AjaxResult.error("新增参数'" + config.getConfigName() + "'失败,参数键名已存在"); + } + config.setCreateBy(getUsername()); + return toAjax(configService.insertConfig(config)); + } + + /** + * 修改参数配置 + */ + @PreAuthorize("@ss.hasPermi('system:config:edit')") + @Log(title = "参数管理", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@Validated @RequestBody SysConfig config) + { + if (UserConstants.NOT_UNIQUE.equals(configService.checkConfigKeyUnique(config))) + { + return AjaxResult.error("修改参数'" + config.getConfigName() + "'失败,参数键名已存在"); + } + config.setUpdateBy(getUsername()); + return toAjax(configService.updateConfig(config)); + } + + /** + * 删除参数配置 + */ + @PreAuthorize("@ss.hasPermi('system:config:remove')") + @Log(title = "参数管理", businessType = BusinessType.DELETE) + @DeleteMapping("/{configIds}") + public AjaxResult remove(@PathVariable Long[] configIds) + { + configService.deleteConfigByIds(configIds); + return success(); + } + + /** + * 刷新参数缓存 + */ + @PreAuthorize("@ss.hasPermi('system:config:remove')") + @Log(title = "参数管理", businessType = BusinessType.CLEAN) + @DeleteMapping("/refreshCache") + public AjaxResult refreshCache() + { + configService.resetConfigCache(); + return AjaxResult.success(); + } +} diff --git a/ruoyi-base-support/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysDataRuleController.java b/ruoyi-base-support/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysDataRuleController.java new file mode 100644 index 0000000..9fb0df7 --- /dev/null +++ b/ruoyi-base-support/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysDataRuleController.java @@ -0,0 +1,196 @@ +package com.ruoyi.web.controller.system; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.domain.AjaxResultMap; +import com.ruoyi.common.core.domain.entity.SysDataRule; +import com.ruoyi.common.core.page.TableDataInfo; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.common.utils.StringUtils; +import com.ruoyi.common.utils.poi.ExcelUtil; +import com.ruoyi.datarule.handler.DataRuleHandler; +import com.ruoyi.system.domain.SysRoleDataRule; +import com.ruoyi.system.service.ISysDataRuleService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.*; + +import javax.servlet.http.HttpServletRequest; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +/** + * 参数配置 信息操作处理 + * + * @author ruoyi + */ +@RestController +@RequestMapping("/system/dataRule") +public class SysDataRuleController extends BaseController { + @Autowired + private ISysDataRuleService sysDataRuleService; + + //所有数据更新都需要刷新数据权限 + @Autowired + private DataRuleHandler dataRuleHandler; + + /** + * 获取参数配置列表 + */ + @PreAuthorize("@ss.hasPermi('system:dataRule:list')") + @GetMapping("/list") + public TableDataInfo list(HttpServletRequest request) { + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.orderByDesc("create_time"); + String tenantId = request.getParameter("tenantId"); + if (!StringUtils.isEmpty(tenantId)) { + queryWrapper.eq("tenant_id", tenantId); + } + String contact = request.getParameter("contact"); + if (!StringUtils.isEmpty(contact)) { + queryWrapper.like("contact", contact); + } + String phone = request.getParameter("phone"); + if (!StringUtils.isEmpty(phone)) { + queryWrapper.eq("phone", phone); + } + String name = request.getParameter("name"); + if (!StringUtils.isEmpty(name)) { + queryWrapper.like("name", name); + } + + Page page = sysDataRuleService.page(getPage(), queryWrapper); + return getDataTable(page); + } + + @GetMapping(value = "roleDataRuleList") + @PreAuthorize("@ss.hasPermi('system:dataRule:list')") + public TableDataInfo roleDataRuleList(HttpServletRequest request) throws IOException { + //加入条件 + QueryWrapper roleDataRuleEntityWrapper = new QueryWrapper<>(); + String roleId = request.getParameter("roleId"); + roleDataRuleEntityWrapper.eq("role_id", roleId); + // 预处理 + List list = sysDataRuleService.roleDataList(roleDataRuleEntityWrapper); + + QueryWrapper entityWrapper = new QueryWrapper<>(); + entityWrapper.orderByDesc( "create_time"); + String resourceCode = request.getParameter("resourceCode"); + if (!StringUtils.isEmpty(resourceCode)) { + entityWrapper.eq("resource_code", resourceCode); + } + String scopeName = request.getParameter("scopeName"); + if (!StringUtils.isEmpty(scopeName)) { + entityWrapper.eq("scope_name", scopeName); + } + // 预处理 + Page pageBean = sysDataRuleService.page(getPage(), entityWrapper); + pageBean.getRecords().forEach(item -> { + list.forEach(roleDataRule -> { + if (item.getId().equals(roleDataRule.getScopeId())) { + item.setSelect(true); + } + }); + }); + return getDataTable(pageBean); + } + @PostMapping("updateRules") + @Log(title = "数据规则", businessType = BusinessType.UPDATE) + @PreAuthorize("@ss.hasPermi('system:dataRule:update')") + public AjaxResult update(@RequestBody SysRoleDataRule sysRoleDataRule) { + QueryWrapper roleDataRuleEntityWrapper = new QueryWrapper<>(); + roleDataRuleEntityWrapper.eq("role_id", sysRoleDataRule.getRoleId()); + sysDataRuleService.removeRoleDataRule(roleDataRuleEntityWrapper); + if (StringUtils.isEmpty(sysRoleDataRule.getIds())) { + dataRuleHandler.refreshRole(); + return AjaxResult.success("更新成功"); + } + String[] ids = sysRoleDataRule.getIds().split(","); + List idList = Arrays.asList(ids); + List roleDataRuleList = new ArrayList<>(); + idList.forEach(item -> { + SysRoleDataRule roleDataRule = new SysRoleDataRule(); + roleDataRule.setRoleId(sysRoleDataRule.getRoleId()); + roleDataRule.setScopeId(item); + roleDataRuleList.add(roleDataRule); + }); + sysDataRuleService.insertBatchRoleDataRule(roleDataRuleList); + dataRuleHandler.refreshRole(); + return AjaxResult.success("更新成功"); + } + + /** + * 导出数据规则列表 + */ + @PreAuthorize("@ss.hasPermi('system:dataRule:export')") + @Log(title = "数据规则", businessType = BusinessType.EXPORT) + @GetMapping("/export") + public AjaxResult export(HttpServletRequest request) { + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.orderByDesc("a.create_time"); + String tenantId = request.getParameter("tenantId"); + if (!StringUtils.isEmpty(tenantId)) { + queryWrapper.eq("a.tenant_id", tenantId); + } + String contact = request.getParameter("contact"); + if (!StringUtils.isEmpty(contact)) { + queryWrapper.like("contact", contact); + } + String phone = request.getParameter("phone"); + if (!StringUtils.isEmpty(phone)) { + queryWrapper.eq("phone", phone); + } + String name = request.getParameter("name"); + if (!StringUtils.isEmpty(name)) { + queryWrapper.like("name", name); + } + + List list = sysDataRuleService.list(queryWrapper); + ExcelUtil util = new ExcelUtil<>(SysDataRule.class); + return util.exportExcel(list, "数据规则数据"); + } + + /** + * 获取数据规则详细信息 + */ + @PreAuthorize("@ss.hasPermi('system:dataRule:query')") + @GetMapping(value = "/{id}") + public AjaxResultMap getInfo(@PathVariable("id") Long id) { + return AjaxResultMap.success(sysDataRuleService.getById(id)); + } + + /** + * 新增数据规则 + */ + @PreAuthorize("@ss.hasPermi('system:dataRule:add')") + @Log(title = "数据规则", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody SysDataRule sysDataRule) { + return toAjax(sysDataRuleService.save(sysDataRule)); + } + + /** + * 修改数据规则 + */ + @PreAuthorize("@ss.hasPermi('system:dataRule:edit')") + @Log(title = "数据规则", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody SysDataRule sysDataRule) { + return toAjax(sysDataRuleService.updateById(sysDataRule)); + } + + /** + * 删除数据规则 + */ + @PreAuthorize("@ss.hasPermi('system:dataRule:remove')") + @Log(title = "数据规则", businessType = BusinessType.DELETE) + @DeleteMapping("/{infoIds}") + public AjaxResult remove(@PathVariable Long[] infoIds) { + return toAjax(sysDataRuleService.removeByIds(Arrays.asList(infoIds))); + } +} diff --git a/ruoyi-base-support/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysDeptController.java b/ruoyi-base-support/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysDeptController.java new file mode 100644 index 0000000..a956cfa --- /dev/null +++ b/ruoyi-base-support/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysDeptController.java @@ -0,0 +1,166 @@ +package com.ruoyi.web.controller.system; + +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.constant.UserConstants; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.domain.AjaxResultMap; +import com.ruoyi.common.core.domain.entity.SysDept; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.common.utils.SecurityUtils; +import com.ruoyi.common.utils.StringUtils; +import com.ruoyi.system.service.ISysDeptService; +import org.apache.commons.lang3.ArrayUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; + +import java.util.Iterator; +import java.util.List; + +/** + * 部门信息 + * + * @author ruoyi + */ +@RestController +@RequestMapping("/system/dept") +public class SysDeptController extends BaseController +{ + @Autowired + private ISysDeptService deptService; + + /** + * 获取部门列表 + */ + @PreAuthorize("@ss.hasPermi('system:dept:list')") + @GetMapping("/list") + public AjaxResultMap list(SysDept dept) + { + dept.setTenantId(SecurityUtils.getLoginUser().getTenantId()); + List depts = deptService.selectDeptList(dept); + return AjaxResultMap.success(depts); + } + + /** + * 查询部门列表(排除节点) + */ + @PreAuthorize("@ss.hasPermi('system:dept:list')") + @GetMapping("/list/exclude/{deptId}") + public AjaxResult excludeChild(@PathVariable(value = "deptId", required = false) String deptId) + { + SysDept dept = new SysDept(); + dept.setTenantId(SecurityUtils.getLoginUser().getTenantId()); + List depts = deptService.selectDeptList(dept); + Iterator it = depts.iterator(); + while (it.hasNext()) + { + SysDept d = (SysDept) it.next(); + if (d.getDeptId().equals(deptId) + || ArrayUtils.contains(StringUtils.split(d.getAncestors(), ","), deptId + "")) + { + it.remove(); + } + } + return AjaxResult.success(depts); + } + + /** + * 根据部门编号获取详细信息 + */ + @PreAuthorize("@ss.hasPermi('system:dept:query')") + @GetMapping(value = "/{deptId}") + public AjaxResult getInfo(@PathVariable String deptId) + { + deptService.checkDeptDataScope(deptId); + return AjaxResult.success(deptService.selectDeptById(deptId)); + } + + /** + * 获取部门下拉树列表 + */ + @GetMapping("/treeselect") + public AjaxResultMap treeselect(SysDept dept) + { + dept.setTenantId(SecurityUtils.getLoginUser().getTenantId()); + List depts = deptService.selectDeptList(dept); + return AjaxResultMap.success(deptService.buildDeptTreeSelect(depts)); + } + + /** + * 加载对应角色部门列表树 + */ + @GetMapping(value = "/roleDeptTreeselect/{roleId}") + public AjaxResultMap roleDeptTreeselect(@PathVariable("roleId") Long roleId) + { + SysDept dept = new SysDept(); + dept.setTenantId(SecurityUtils.getLoginUser().getTenantId()); + List depts = deptService.selectDeptList(dept); + AjaxResultMap ajax = AjaxResultMap.success(); + ajax.put("checkedKeys", deptService.selectDeptListByRoleId(roleId)); + ajax.put("depts", deptService.buildDeptTreeSelect(depts)); + return ajax; + } + + /** + * 新增部门 + */ + @PreAuthorize("@ss.hasPermi('system:dept:add')") + @Log(title = "部门管理", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@Validated @RequestBody SysDept dept) + { + if (UserConstants.NOT_UNIQUE.equals(deptService.checkDeptNameUnique(dept))) + { + return AjaxResult.error("新增部门'" + dept.getDeptName() + "'失败,部门名称已存在"); + } + dept.setTenantId(SecurityUtils.getLoginUser().getTenantId()); + dept.setCreateBy(getUsername()); + return toAjax(deptService.insertDept(dept)); + } + + /** + * 修改部门 + */ + @PreAuthorize("@ss.hasPermi('system:dept:edit')") + @Log(title = "部门管理", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@Validated @RequestBody SysDept dept) + { + if (UserConstants.NOT_UNIQUE.equals(deptService.checkDeptNameUnique(dept))) + { + return AjaxResult.error("修改部门'" + dept.getDeptName() + "'失败,部门名称已存在"); + } + else if (dept.getParentId().equals(dept.getDeptId())) + { + return AjaxResult.error("修改部门'" + dept.getDeptName() + "'失败,上级部门不能是自己"); + } + else if (StringUtils.equals(UserConstants.DEPT_DISABLE, dept.getStatus()) + && deptService.selectNormalChildrenDeptById(dept.getDeptId()) > 0) + { + return AjaxResult.error("该部门包含未停用的子部门!"); + } + dept.setUpdateBy(getUsername()); + return toAjax(deptService.updateDept(dept)); + } + + /** + * 删除部门 + */ + @PreAuthorize("@ss.hasPermi('system:dept:remove')") + @Log(title = "部门管理", businessType = BusinessType.DELETE) + @DeleteMapping("/{deptId}") + public AjaxResult remove(@PathVariable String deptId) + { + if (deptService.hasChildByDeptId(deptId)) + { + return AjaxResult.error("存在下级部门,不允许删除"); + } + if (deptService.checkDeptExistUser(deptId)) + { + return AjaxResult.error("部门存在用户,不允许删除"); + } + return toAjax(deptService.deleteDeptById(deptId)); + } +} diff --git a/ruoyi-base-support/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysDictDataController.java b/ruoyi-base-support/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysDictDataController.java new file mode 100644 index 0000000..2f33f0f --- /dev/null +++ b/ruoyi-base-support/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysDictDataController.java @@ -0,0 +1,128 @@ +package com.ruoyi.web.controller.system; + +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.domain.AjaxResultMap; +import com.ruoyi.common.core.domain.entity.SysDictData; +import com.ruoyi.common.core.page.TableDataInfo; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.common.utils.StringUtils; +import com.ruoyi.common.utils.poi.ExcelUtil; +import com.ruoyi.system.service.ISysDictDataService; +import com.ruoyi.system.service.ISysDictTypeService; +import com.sun.jna.platform.unix.solaris.LibKstat; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; + +import java.util.ArrayList; +import java.util.List; + +/** + * 数据字典信息 + * + * @author ruoyi + */ +@RestController +@RequestMapping("/system/dict/data") +public class SysDictDataController extends BaseController +{ + @Autowired + private ISysDictDataService dictDataService; + + @Autowired + private ISysDictTypeService dictTypeService; + + @PreAuthorize("@ss.hasPermi('system:dict:list')") + @GetMapping("/list") + public TableDataInfo list(SysDictData dictData) + { + startPage(); + List list = dictDataService.selectDictDataList(dictData); + return getDataTable(list); + } + + @Log(title = "字典数据", businessType = BusinessType.EXPORT) + @PreAuthorize("@ss.hasPermi('system:dict:export')") + @GetMapping("/export") + public AjaxResult export(SysDictData dictData) + { + List list = dictDataService.selectDictDataList(dictData); + ExcelUtil util = new ExcelUtil(SysDictData.class); + return util.exportExcel(list, "字典数据"); + } + + /** + * 查询字典数据详细 + */ + @PreAuthorize("@ss.hasPermi('system:dict:query')") + @GetMapping(value = "/{dictCode}") + public AjaxResult getInfo(@PathVariable Long dictCode) + { + return AjaxResult.success(dictDataService.selectDictDataById(dictCode)); + } + + /** + * 根据字典类型查询字典数据信息 + */ + @GetMapping(value = "/type/{dictType}") + public AjaxResultMap dictType(@PathVariable String dictType) + { + List data = dictTypeService.selectDictDataByType(dictType); + if (StringUtils.isNull(data)) + { + data = new ArrayList(); + } + return AjaxResultMap.success(data); + } + + /** + * 新增字典类型 + */ + @PreAuthorize("@ss.hasPermi('system:dict:add')") + @Log(title = "字典数据", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@Validated @RequestBody SysDictData dict) + { + dict.setCreateBy(getUsername()); + return toAjax(dictDataService.insertDictData(dict)); + } + + /** + * 修改保存字典类型 + */ + @PreAuthorize("@ss.hasPermi('system:dict:edit')") + @Log(title = "字典数据", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@Validated @RequestBody SysDictData dict) + { + dict.setUpdateBy(getUsername()); + return toAjax(dictDataService.updateDictData(dict)); + } + + /** + * 删除字典类型 + */ + @PreAuthorize("@ss.hasPermi('system:dict:remove')") + @Log(title = "字典类型", businessType = BusinessType.DELETE) + @DeleteMapping("/{dictCodes}") + public AjaxResult remove(@PathVariable Long[] dictCodes) + { + dictDataService.deleteDictDataByIds(dictCodes); + return success(); + } + + /** + * 根据code查询 + */ + @PostMapping("/dictOne/{code}") + public AjaxResult dictOne(@PathVariable("code") String code) + { + SysDictData sysDictData = new SysDictData(); + sysDictData.setCode(code); + List list = dictDataService.selectDictDataList(sysDictData); + return AjaxResult.success(list.isEmpty()?null:list.get(0)); + } +} diff --git a/ruoyi-base-support/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysDictTypeController.java b/ruoyi-base-support/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysDictTypeController.java new file mode 100644 index 0000000..2d3670a --- /dev/null +++ b/ruoyi-base-support/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysDictTypeController.java @@ -0,0 +1,147 @@ +package com.ruoyi.web.controller.system; + +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.constant.UserConstants; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.domain.entity.SysDictData; +import com.ruoyi.common.core.domain.entity.SysDictType; +import com.ruoyi.common.core.page.TableDataInfo; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.common.utils.poi.ExcelUtil; +import com.ruoyi.system.service.ISysDictDataService; +import com.ruoyi.system.service.ISysDictTypeService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; + +import javax.validation.Valid; +import javax.validation.constraints.NotBlank; +import java.util.List; + +/** + * 数据字典信息 + * + * @author ruoyi + */ +@RestController +@RequestMapping("/system/dict/type") +@Api(tags = "数据字典信息") +public class SysDictTypeController extends BaseController +{ + @Autowired + private ISysDictTypeService dictTypeService; + + @PreAuthorize("@ss.hasPermi('system:dict:list')") + @GetMapping("/list") + public TableDataInfo list(SysDictType dictType) + { + startPage(); + List list = dictTypeService.selectDictTypeList(dictType); + return getDataTable(list); + } + + @Log(title = "字典类型", businessType = BusinessType.EXPORT) + @PreAuthorize("@ss.hasPermi('system:dict:export')") + @GetMapping("/export") + public AjaxResult export(SysDictType dictType) + { + List list = dictTypeService.selectDictTypeList(dictType); + ExcelUtil util = new ExcelUtil(SysDictType.class); + return util.exportExcel(list, "字典类型"); + } + + /** + * 查询字典类型详细 + */ + @PreAuthorize("@ss.hasPermi('system:dict:query')") + @GetMapping(value = "/{dictId}") + public AjaxResult getInfo(@PathVariable Long dictId) + { + return AjaxResult.success(dictTypeService.selectDictTypeById(dictId)); + } + + /** + * 新增字典类型 + */ + @PreAuthorize("@ss.hasPermi('system:dict:add')") + @Log(title = "字典类型", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@Validated @RequestBody SysDictType dict) + { + if (UserConstants.NOT_UNIQUE.equals(dictTypeService.checkDictTypeUnique(dict))) + { + return AjaxResult.error("新增字典'" + dict.getDictName() + "'失败,字典类型已存在"); + } + dict.setCreateBy(getUsername()); + return toAjax(dictTypeService.insertDictType(dict)); + } + + /** + * 修改字典类型 + */ + @PreAuthorize("@ss.hasPermi('system:dict:edit')") + @Log(title = "字典类型", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@Validated @RequestBody SysDictType dict) + { + if (UserConstants.NOT_UNIQUE.equals(dictTypeService.checkDictTypeUnique(dict))) + { + return AjaxResult.error("修改字典'" + dict.getDictName() + "'失败,字典类型已存在"); + } + dict.setUpdateBy(getUsername()); + return toAjax(dictTypeService.updateDictType(dict)); + } + + /** + * 删除字典类型 + */ + @PreAuthorize("@ss.hasPermi('system:dict:remove')") + @Log(title = "字典类型", businessType = BusinessType.DELETE) + @DeleteMapping("/{dictIds}") + public AjaxResult remove(@PathVariable Long[] dictIds) + { + dictTypeService.deleteDictTypeByIds(dictIds); + return success(); + } + + /** + * 刷新字典缓存 + */ + @PreAuthorize("@ss.hasPermi('system:dict:remove')") + @Log(title = "字典类型", businessType = BusinessType.CLEAN) + @DeleteMapping("/refreshCache") + public AjaxResult refreshCache() + { + dictTypeService.resetDictCache(); + return AjaxResult.success(); + } + + /** + * 获取字典选择框列表 + */ + @GetMapping("/optionselect") + public AjaxResult optionselect() + { + List dictTypes = dictTypeService.selectDictTypeAll(); + return AjaxResult.success(dictTypes); + } + + @Autowired + private ISysDictDataService iSysDictDataService; + + /** + * 字典表下级加密(AES) + * @param code + * @return + */ + @RequestMapping(value = "/md5FineList", method = RequestMethod.POST) + @ApiOperation(value = "字典表下级") + public AjaxResult md5FineList(@RequestParam("code") @Valid @NotBlank(message = "code值不能为空") String code) { + return AjaxResult.success(null,iSysDictDataService.md5FineList(code)); + } + +} diff --git a/ruoyi-base-support/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysIndexController.java b/ruoyi-base-support/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysIndexController.java new file mode 100644 index 0000000..e79be55 --- /dev/null +++ b/ruoyi-base-support/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysIndexController.java @@ -0,0 +1,29 @@ +package com.ruoyi.web.controller.system; + +import com.ruoyi.common.config.RuoYiConfig; +import com.ruoyi.common.utils.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * 首页 + * + * @author ruoyi + */ +@RestController +public class SysIndexController +{ + /** 系统基础配置 */ + @Autowired + private RuoYiConfig ruoyiConfig; + + /** + * 访问首页,提示语 + */ + @RequestMapping("/") + public String index() + { + return StringUtils.format("欢迎使用{}后台管理框架,当前版本:v{},请通过前端地址访问。", ruoyiConfig.getName(), ruoyiConfig.getVersion()); + } +} diff --git a/ruoyi-base-support/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysLoginController.java b/ruoyi-base-support/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysLoginController.java new file mode 100644 index 0000000..88e4d4d --- /dev/null +++ b/ruoyi-base-support/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysLoginController.java @@ -0,0 +1,87 @@ +package com.ruoyi.web.controller.system; + +import com.ruoyi.common.constant.Constants; +import com.ruoyi.common.core.domain.AjaxResultMap; +import com.ruoyi.common.core.domain.entity.SysMenu; +import com.ruoyi.common.core.domain.entity.SysUser; +import com.ruoyi.common.core.domain.model.LoginBody; +import com.ruoyi.common.utils.SecurityUtils; +import com.ruoyi.framework.web.service.SysLoginService; +import com.ruoyi.framework.web.service.SysPermissionService; +import com.ruoyi.system.service.ISysMenuService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RestController; + +import java.util.List; +import java.util.Set; + +/** + * 登录验证 + * + * @author ruoyi + */ +@RestController +public class SysLoginController +{ + @Autowired + private SysLoginService loginService; + + @Autowired + private ISysMenuService menuService; + + @Autowired + private SysPermissionService permissionService; + + /** + * 登录方法 + * + * @param loginBody 登录信息 + * @return 结果 + */ + @PostMapping("/login") + public AjaxResultMap login(@RequestBody LoginBody loginBody) + { + AjaxResultMap ajax = AjaxResultMap.success(); + // 生成令牌 + String token = loginService.login(loginBody.getLoginType(),loginBody.getUsername(), loginBody.getPassword(), loginBody.getCode(), + loginBody.getUuid()); + ajax.put(Constants.TOKEN, token); + return ajax; + } + + /** + * 获取用户信息 + * + * @return 用户信息 + */ + @GetMapping("getInfo") + public AjaxResultMap getInfo() + { + SysUser user = SecurityUtils.getLoginUser().getUser(); + // 角色集合 + Set roles = permissionService.getRolePermission(user); + // 权限集合 + Set permissions = permissionService.getMenuPermission(user); + AjaxResultMap ajax = AjaxResultMap.success(); + ajax.put("user", user); + ajax.put("roles", roles); + ajax.put("permissions", permissions); + return ajax; + } + + /** + * 获取路由信息 + * + * @return 路由信息 + */ + @GetMapping("getRouters") + public AjaxResultMap getRouters() + { + Long userId = SecurityUtils.getUserId(); + List menus = menuService.selectMenuTreeByUserId(userId); + return AjaxResultMap.success(menuService.buildMenus(menus)); + } +} diff --git a/ruoyi-base-support/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysMenuController.java b/ruoyi-base-support/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysMenuController.java new file mode 100644 index 0000000..f074b4b --- /dev/null +++ b/ruoyi-base-support/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysMenuController.java @@ -0,0 +1,140 @@ +package com.ruoyi.web.controller.system; + +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.constant.UserConstants; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.domain.AjaxResultMap; +import com.ruoyi.common.core.domain.entity.SysMenu; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.common.utils.StringUtils; +import com.ruoyi.system.service.ISysMenuService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +/** + * 菜单信息 + * + * @author ruoyi + */ +@RestController +@RequestMapping("/system/menu") +public class SysMenuController extends BaseController +{ + @Autowired + private ISysMenuService menuService; + + /** + * 获取菜单列表 + */ + @PreAuthorize("@ss.hasPermi('system:menu:list')") + @GetMapping("/list") + public AjaxResultMap list(SysMenu menu) + { + List menus = menuService.selectMenuList(menu, getUserId()); + return AjaxResultMap.success(menus); + } + + /** + * 根据菜单编号获取详细信息 + */ + @PreAuthorize("@ss.hasPermi('system:menu:query')") + @GetMapping(value = "/{menuId}") + public AjaxResult getInfo(@PathVariable Long menuId) + { + return AjaxResult.success(menuService.selectMenuById(menuId)); + } + + /** + * 获取菜单下拉树列表 + */ + @GetMapping("/treeselect") + public AjaxResult treeselect(SysMenu menu) + { + List menus = menuService.selectMenuList(menu, getUserId()); + return AjaxResult.success(menuService.buildMenuTreeSelect(menus)); + } + + /** + * 加载对应角色菜单列表树 + */ + @GetMapping(value = "/roleMenuTreeselect/{roleId}") + public AjaxResultMap roleMenuTreeselect(@PathVariable("roleId") Long roleId) + { + List menus = menuService.selectMenuList(getUserId()); + AjaxResultMap ajax = AjaxResultMap.success(); + ajax.put("checkedKeys", menuService.selectMenuListByRoleId(roleId)); + ajax.put("menus", menuService.buildMenuTreeSelect(menus)); + return ajax; + } + + /** + * 新增菜单 + */ + @PreAuthorize("@ss.hasPermi('system:menu:add')") + @Log(title = "菜单管理", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@Validated @RequestBody SysMenu menu) + { + if (UserConstants.NOT_UNIQUE.equals(menuService.checkMenuNameUnique(menu))) + { + return AjaxResult.error("新增菜单'" + menu.getMenuName() + "'失败,菜单名称已存在"); + } + else if (UserConstants.YES_FRAME.equals(menu.getIsFrame()) && !StringUtils.ishttp(menu.getPath())) + { + return AjaxResult.error("新增菜单'" + menu.getMenuName() + "'失败,地址必须以http(s)://开头"); + } + menu.setCreateBy(getUsername()); + return toAjax(menuService.insertMenu(menu)); + } + + /** + * 修改菜单 + */ + @PreAuthorize("@ss.hasPermi('system:menu:edit')") + @Log(title = "菜单管理", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@Validated @RequestBody SysMenu menu) + { + if (UserConstants.NOT_UNIQUE.equals(menuService.checkMenuNameUnique(menu))) + { + return AjaxResult.error("修改菜单'" + menu.getMenuName() + "'失败,菜单名称已存在"); + } + else if (UserConstants.YES_FRAME.equals(menu.getIsFrame()) && !StringUtils.ishttp(menu.getPath())) + { + return AjaxResult.error("修改菜单'" + menu.getMenuName() + "'失败,地址必须以http(s)://开头"); + } + else if (menu.getMenuId().equals(menu.getParentId())) + { + return AjaxResult.error("修改菜单'" + menu.getMenuName() + "'失败,上级菜单不能选择自己"); + } + menu.setUpdateBy(getUsername()); + return toAjax(menuService.updateMenu(menu)); + } + + /** + * 删除菜单 + */ + @PreAuthorize("@ss.hasPermi('system:menu:remove')") + @Log(title = "菜单管理", businessType = BusinessType.DELETE) + @DeleteMapping("/{menuId}") + public AjaxResult remove(@PathVariable("menuId") Long menuId) + { + if (menuService.hasChildByMenuId(menuId)) + { +// return AjaxResult.error("存在子菜单,不允许删除"); + + //删除子菜单 + menuService.deleteChildByMenuId(menuId); + } + if (menuService.checkMenuExistRole(menuId)) + { + return AjaxResult.error("菜单已分配,不允许删除"); + } + return toAjax(menuService.deleteMenuById(menuId)); + } +} \ No newline at end of file diff --git a/ruoyi-base-support/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysNoticeController.java b/ruoyi-base-support/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysNoticeController.java new file mode 100644 index 0000000..173a591 --- /dev/null +++ b/ruoyi-base-support/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysNoticeController.java @@ -0,0 +1,85 @@ +package com.ruoyi.web.controller.system; + +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.page.TableDataInfo; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.system.domain.SysNotice; +import com.ruoyi.system.service.ISysNoticeService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +/** + * 公告 信息操作处理 + * + * @author ruoyi + */ +@RestController +@RequestMapping("/system/notice") +public class SysNoticeController extends BaseController +{ + @Autowired + private ISysNoticeService noticeService; + + /** + * 获取通知公告列表 + */ + @PreAuthorize("@ss.hasPermi('system:notice:list')") + @GetMapping("/list") + public TableDataInfo list(SysNotice notice) + { + startPage(); + List list = noticeService.selectNoticeList(notice); + return getDataTable(list); + } + + /** + * 根据通知公告编号获取详细信息 + */ + @PreAuthorize("@ss.hasPermi('system:notice:query')") + @GetMapping(value = "/{noticeId}") + public AjaxResult getInfo(@PathVariable Long noticeId) + { + return AjaxResult.success(noticeService.selectNoticeById(noticeId)); + } + + /** + * 新增通知公告 + */ + @PreAuthorize("@ss.hasPermi('system:notice:add')") + @Log(title = "通知公告", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@Validated @RequestBody SysNotice notice) + { + notice.setCreateBy(getUsername()); + return toAjax(noticeService.insertNotice(notice)); + } + + /** + * 修改通知公告 + */ + @PreAuthorize("@ss.hasPermi('system:notice:edit')") + @Log(title = "通知公告", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@Validated @RequestBody SysNotice notice) + { + notice.setUpdateBy(getUsername()); + return toAjax(noticeService.updateNotice(notice)); + } + + /** + * 删除通知公告 + */ + @PreAuthorize("@ss.hasPermi('system:notice:remove')") + @Log(title = "通知公告", businessType = BusinessType.DELETE) + @DeleteMapping("/{noticeIds}") + public AjaxResult remove(@PathVariable Long[] noticeIds) + { + return toAjax(noticeService.deleteNoticeByIds(noticeIds)); + } +} diff --git a/ruoyi-base-support/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysPostController.java b/ruoyi-base-support/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysPostController.java new file mode 100644 index 0000000..310ef8d --- /dev/null +++ b/ruoyi-base-support/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysPostController.java @@ -0,0 +1,123 @@ +package com.ruoyi.web.controller.system; + +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.constant.UserConstants; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.page.TableDataInfo; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.common.utils.poi.ExcelUtil; +import com.ruoyi.system.domain.SysPost; +import com.ruoyi.system.service.ISysPostService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +/** + * 岗位信息操作处理 + * + * @author ruoyi + */ +@RestController +@RequestMapping("/system/post") +public class SysPostController extends BaseController +{ + @Autowired + private ISysPostService postService; + + /** + * 获取岗位列表 + */ + @PreAuthorize("@ss.hasPermi('system:post:list')") + @GetMapping("/list") + public TableDataInfo list(SysPost post) + { + startPage(); + List list = postService.selectPostList(post); + return getDataTable(list); + } + + @Log(title = "岗位管理", businessType = BusinessType.EXPORT) + @PreAuthorize("@ss.hasPermi('system:post:export')") + @GetMapping("/export") + public AjaxResult export(SysPost post) + { + List list = postService.selectPostList(post); + ExcelUtil util = new ExcelUtil(SysPost.class); + return util.exportExcel(list, "岗位数据"); + } + + /** + * 根据岗位编号获取详细信息 + */ + @PreAuthorize("@ss.hasPermi('system:post:query')") + @GetMapping(value = "/{postId}") + public AjaxResult getInfo(@PathVariable Long postId) + { + return AjaxResult.success(postService.selectPostById(postId)); + } + + /** + * 新增岗位 + */ + @PreAuthorize("@ss.hasPermi('system:post:add')") + @Log(title = "岗位管理", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@Validated @RequestBody SysPost post) + { + if (UserConstants.NOT_UNIQUE.equals(postService.checkPostNameUnique(post))) + { + return AjaxResult.error("新增岗位'" + post.getPostName() + "'失败,岗位名称已存在"); + } + else if (UserConstants.NOT_UNIQUE.equals(postService.checkPostCodeUnique(post))) + { + return AjaxResult.error("新增岗位'" + post.getPostName() + "'失败,岗位编码已存在"); + } + post.setCreateBy(getUsername()); + return toAjax(postService.insertPost(post)); + } + + /** + * 修改岗位 + */ + @PreAuthorize("@ss.hasPermi('system:post:edit')") + @Log(title = "岗位管理", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@Validated @RequestBody SysPost post) + { + if (UserConstants.NOT_UNIQUE.equals(postService.checkPostNameUnique(post))) + { + return AjaxResult.error("修改岗位'" + post.getPostName() + "'失败,岗位名称已存在"); + } + else if (UserConstants.NOT_UNIQUE.equals(postService.checkPostCodeUnique(post))) + { + return AjaxResult.error("修改岗位'" + post.getPostName() + "'失败,岗位编码已存在"); + } + post.setUpdateBy(getUsername()); + return toAjax(postService.updatePost(post)); + } + + /** + * 删除岗位 + */ + @PreAuthorize("@ss.hasPermi('system:post:remove')") + @Log(title = "岗位管理", businessType = BusinessType.DELETE) + @DeleteMapping("/{postIds}") + public AjaxResult remove(@PathVariable Long[] postIds) + { + return toAjax(postService.deletePostByIds(postIds)); + } + + /** + * 获取岗位选择框列表 + */ + @GetMapping("/optionselect") + public AjaxResult optionselect() + { + List posts = postService.selectPostAll(); + return AjaxResult.success(posts); + } +} diff --git a/ruoyi-base-support/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysProfileController.java b/ruoyi-base-support/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysProfileController.java new file mode 100644 index 0000000..21a482f --- /dev/null +++ b/ruoyi-base-support/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysProfileController.java @@ -0,0 +1,137 @@ +package com.ruoyi.web.controller.system; + +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.config.RuoYiConfig; +import com.ruoyi.common.constant.UserConstants; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.domain.AjaxResultMap; +import com.ruoyi.common.core.domain.entity.SysUser; +import com.ruoyi.common.core.domain.model.LoginUser; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.common.utils.SecurityUtils; +import com.ruoyi.common.utils.StringUtils; +import com.ruoyi.common.utils.file.FileUploadUtils; +import com.ruoyi.framework.web.service.TokenService; +import com.ruoyi.system.service.ISysUserService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartFile; + +import java.io.IOException; + +/** + * 个人信息 业务处理 + * + * @author ruoyi + */ +@RestController +@RequestMapping("/system/user/profile") +public class SysProfileController extends BaseController +{ + @Autowired + private ISysUserService userService; + + @Autowired + private TokenService tokenService; + + /** + * 个人信息 + */ + @GetMapping + public AjaxResultMap profile() + { + LoginUser loginUser = getLoginUser(); + SysUser user = loginUser.getUser(); + AjaxResultMap ajax = AjaxResultMap.success(user); + ajax.put("roleGroup", userService.selectUserRoleGroup(loginUser.getUsername())); + ajax.put("postGroup", userService.selectUserPostGroup(loginUser.getUsername())); + return ajax; + } + + /** + * 修改用户 + */ + @Log(title = "个人信息", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult updateProfile(@RequestBody SysUser user) + { + if (StringUtils.isNotEmpty(user.getPhonenumber()) + && UserConstants.NOT_UNIQUE.equals(userService.checkPhoneUnique(user))) + { + return AjaxResult.error("修改用户'" + user.getUserName() + "'失败,手机号码已存在"); + } + if (StringUtils.isNotEmpty(user.getEmail()) + && UserConstants.NOT_UNIQUE.equals(userService.checkEmailUnique(user))) + { + return AjaxResult.error("修改用户'" + user.getUserName() + "'失败,邮箱账号已存在"); + } + LoginUser loginUser = getLoginUser(); + SysUser sysUser = loginUser.getUser(); + user.setUserId(sysUser.getUserId()); + user.setPassword(null); + if (userService.updateUserProfile(user) > 0) + { + // 更新缓存用户信息 + sysUser.setNickName(user.getNickName()); + sysUser.setPhonenumber(user.getPhonenumber()); + sysUser.setEmail(user.getEmail()); + sysUser.setSex(user.getSex()); + tokenService.setLoginUser(loginUser); + return AjaxResult.success(); + } + return AjaxResult.error("修改个人信息异常,请联系管理员"); + } + + /** + * 重置密码 + */ + @Log(title = "个人信息", businessType = BusinessType.UPDATE) + @PutMapping("/updatePwd") + public AjaxResult updatePwd(String oldPassword, String newPassword) + { + LoginUser loginUser = getLoginUser(); + String userName = loginUser.getUsername(); + String password = loginUser.getPassword(); + if (!SecurityUtils.matchesPassword(oldPassword, password)) + { + return AjaxResult.error("修改密码失败,旧密码错误"); + } + if (SecurityUtils.matchesPassword(newPassword, password)) + { + return AjaxResult.error("新密码不能与旧密码相同"); + } + if (userService.resetUserPwd(userName, SecurityUtils.encryptPassword(newPassword)) > 0) + { + // 更新缓存用户密码 + loginUser.getUser().setPassword(SecurityUtils.encryptPassword(newPassword)); + tokenService.setLoginUser(loginUser); + return AjaxResult.success(); + } + return AjaxResult.error("修改密码异常,请联系管理员"); + } + + /** + * 头像上传 + */ + @Log(title = "用户头像", businessType = BusinessType.UPDATE) + @PostMapping("/avatar") + public AjaxResultMap avatar(@RequestParam("avatarfile") MultipartFile file) throws IOException + { + if (!file.isEmpty()) + { + LoginUser loginUser = getLoginUser(); + String avatar = FileUploadUtils.upload(RuoYiConfig.getAvatarPath(), file); + if (userService.updateUserAvatar(loginUser.getUsername(), avatar)) + { + AjaxResultMap ajax = AjaxResultMap.success(); + ajax.put("imgUrl", avatar); + // 更新缓存用户头像 + loginUser.getUser().setAvatar(avatar); + tokenService.setLoginUser(loginUser); + return ajax; + } + } + return AjaxResultMap.error("上传图片异常,请联系管理员"); + } +} diff --git a/ruoyi-base-support/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysRegisterController.java b/ruoyi-base-support/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysRegisterController.java new file mode 100644 index 0000000..afd9f93 --- /dev/null +++ b/ruoyi-base-support/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysRegisterController.java @@ -0,0 +1,38 @@ +package com.ruoyi.web.controller.system; + +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.domain.model.RegisterBody; +import com.ruoyi.common.utils.StringUtils; +import com.ruoyi.framework.web.service.SysRegisterService; +import com.ruoyi.system.service.ISysConfigService; +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.RestController; + +/** + * 注册验证 + * + * @author ruoyi + */ +@RestController +public class SysRegisterController extends BaseController +{ + @Autowired + private SysRegisterService registerService; + + @Autowired + private ISysConfigService configService; + + @PostMapping("/register") + public AjaxResult register(@RequestBody RegisterBody user) + { + if (!("true".equals(configService.selectConfigByKey("sys.account.registerUser")))) + { + return error("当前系统没有开启注册功能!"); + } + String msg = registerService.register(user); + return StringUtils.isEmpty(msg) ? success() : error(msg); + } +} diff --git a/ruoyi-base-support/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysRoleController.java b/ruoyi-base-support/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysRoleController.java new file mode 100644 index 0000000..13ed637 --- /dev/null +++ b/ruoyi-base-support/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysRoleController.java @@ -0,0 +1,234 @@ +package com.ruoyi.web.controller.system; + +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.constant.UserConstants; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.domain.entity.SysRole; +import com.ruoyi.common.core.domain.entity.SysUser; +import com.ruoyi.common.core.domain.model.LoginUser; +import com.ruoyi.common.core.page.TableDataInfo; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.common.utils.StringUtils; +import com.ruoyi.common.utils.poi.ExcelUtil; +import com.ruoyi.framework.web.service.SysPermissionService; +import com.ruoyi.framework.web.service.TokenService; +import com.ruoyi.system.domain.SysUserRole; +import com.ruoyi.system.service.ISysRoleService; +import com.ruoyi.system.service.ISysUserService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +/** + * 角色信息 + * + * @author ruoyi + */ +@RestController +@RequestMapping("/system/role") +public class SysRoleController extends BaseController +{ + @Autowired + private ISysRoleService roleService; + + @Autowired + private TokenService tokenService; + + @Autowired + private SysPermissionService permissionService; + + @Autowired + private ISysUserService userService; + + @PreAuthorize("@ss.hasPermi('system:role:list')") + @GetMapping("/list") + public TableDataInfo list(SysRole role) + { + startPage(); + List list = roleService.selectRoleList(role); + return getDataTable(list); + } + + @Log(title = "角色管理", businessType = BusinessType.EXPORT) + @PreAuthorize("@ss.hasPermi('system:role:export')") + @GetMapping("/export") + public AjaxResult export(SysRole role) + { + List list = roleService.selectRoleList(role); + ExcelUtil util = new ExcelUtil(SysRole.class); + return util.exportExcel(list, "角色数据"); + } + + /** + * 根据角色编号获取详细信息 + */ + @PreAuthorize("@ss.hasPermi('system:role:query')") + @GetMapping(value = "/{roleId}") + public AjaxResult getInfo(@PathVariable Long roleId) + { + roleService.checkRoleDataScope(roleId); + return AjaxResult.success(roleService.selectRoleById(roleId)); + } + + /** + * 新增角色 + */ + @PreAuthorize("@ss.hasPermi('system:role:add')") + @Log(title = "角色管理", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@Validated @RequestBody SysRole role) + { + if (UserConstants.NOT_UNIQUE.equals(roleService.checkRoleNameUnique(role))) + { + return AjaxResult.error("新增角色'" + role.getRoleName() + "'失败,角色名称已存在"); + } + else if (UserConstants.NOT_UNIQUE.equals(roleService.checkRoleKeyUnique(role))) + { + return AjaxResult.error("新增角色'" + role.getRoleName() + "'失败,角色权限已存在"); + } + role.setCreateBy(getUsername()); + return toAjax(roleService.insertRole(role)); + + } + + /** + * 修改保存角色 + */ + @PreAuthorize("@ss.hasPermi('system:role:edit')") + @Log(title = "角色管理", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@Validated @RequestBody SysRole role) + { + roleService.checkRoleAllowed(role); + if (UserConstants.NOT_UNIQUE.equals(roleService.checkRoleNameUnique(role))) + { + return AjaxResult.error("修改角色'" + role.getRoleName() + "'失败,角色名称已存在"); + } + else if (UserConstants.NOT_UNIQUE.equals(roleService.checkRoleKeyUnique(role))) + { + return AjaxResult.error("修改角色'" + role.getRoleName() + "'失败,角色权限已存在"); + } + role.setUpdateBy(getUsername()); + + if (roleService.updateRole(role) > 0) + { + // 更新缓存用户权限 + LoginUser loginUser = getLoginUser(); + if (StringUtils.isNotNull(loginUser.getUser()) && !loginUser.getUser().isAdmin()) + { + loginUser.setPermissions(permissionService.getMenuPermission(loginUser.getUser())); + loginUser.setUser(userService.selectUserByUserName(loginUser.getUser().getUserName())); + tokenService.setLoginUser(loginUser); + } + return AjaxResult.success(); + } + return AjaxResult.error("修改角色'" + role.getRoleName() + "'失败,请联系管理员"); + } + + /** + * 修改保存数据权限 + */ + @PreAuthorize("@ss.hasPermi('system:role:edit')") + @Log(title = "角色管理", businessType = BusinessType.UPDATE) + @PutMapping("/dataScope") + public AjaxResult dataScope(@RequestBody SysRole role) + { + roleService.checkRoleAllowed(role); + return toAjax(roleService.authDataScope(role)); + } + + /** + * 状态修改 + */ + @PreAuthorize("@ss.hasPermi('system:role:edit')") + @Log(title = "角色管理", businessType = BusinessType.UPDATE) + @PutMapping("/changeStatus") + public AjaxResult changeStatus(@RequestBody SysRole role) + { + roleService.checkRoleAllowed(role); + role.setUpdateBy(getUsername()); + return toAjax(roleService.updateRoleStatus(role)); + } + + /** + * 删除角色 + */ + @PreAuthorize("@ss.hasPermi('system:role:remove')") + @Log(title = "角色管理", businessType = BusinessType.DELETE) + @DeleteMapping("/{roleIds}") + public AjaxResult remove(@PathVariable Long[] roleIds) + { + return toAjax(roleService.deleteRoleByIds(roleIds)); + } + + /** + * 获取角色选择框列表 + */ + @PreAuthorize("@ss.hasPermi('system:role:query')") + @GetMapping("/optionselect") + public AjaxResult optionselect() + { + return AjaxResult.success(roleService.selectRoleAll()); + } + + /** + * 查询已分配用户角色列表 + */ + @PreAuthorize("@ss.hasPermi('system:role:list')") + @GetMapping("/authUser/allocatedList") + public TableDataInfo allocatedList(SysUser user) + { + startPage(); + List list = userService.selectAllocatedList(user); + return getDataTable(list); + } + + /** + * 查询未分配用户角色列表 + */ + @PreAuthorize("@ss.hasPermi('system:role:list')") + @GetMapping("/authUser/unallocatedList") + public TableDataInfo unallocatedList(SysUser user) + { + startPage(); + List list = userService.selectUnallocatedList(user); + return getDataTable(list); + } + + /** + * 取消授权用户 + */ + @PreAuthorize("@ss.hasPermi('system:role:edit')") + @Log(title = "角色管理", businessType = BusinessType.GRANT) + @PutMapping("/authUser/cancel") + public AjaxResult cancelAuthUser(@RequestBody SysUserRole userRole) + { + return toAjax(roleService.deleteAuthUser(userRole)); + } + + /** + * 批量取消授权用户 + */ + @PreAuthorize("@ss.hasPermi('system:role:edit')") + @Log(title = "角色管理", businessType = BusinessType.GRANT) + @PutMapping("/authUser/cancelAll") + public AjaxResult cancelAuthUserAll(Long roleId, Long[] userIds) + { + return toAjax(roleService.deleteAuthUsers(roleId, userIds)); + } + + /** + * 批量选择用户授权 + */ + @PreAuthorize("@ss.hasPermi('system:role:edit')") + @Log(title = "角色管理", businessType = BusinessType.GRANT) + @PutMapping("/authUser/selectAll") + public AjaxResult selectAuthUserAll(Long roleId, Long[] userIds) + { + return toAjax(roleService.insertAuthUsers(roleId, userIds)); + } +} diff --git a/ruoyi-base-support/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysTenantController.java b/ruoyi-base-support/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysTenantController.java new file mode 100644 index 0000000..ae945d4 --- /dev/null +++ b/ruoyi-base-support/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysTenantController.java @@ -0,0 +1,131 @@ +package com.ruoyi.web.controller.system; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.domain.entity.SysTenant; +import com.ruoyi.common.core.page.TableDataInfo; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.common.utils.StringUtils; +import com.ruoyi.common.utils.poi.ExcelUtil; +import com.ruoyi.system.service.ISysTenantService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.*; + +import javax.servlet.http.HttpServletRequest; +import java.util.Arrays; +import java.util.List; + +/** + * 参数配置 信息操作处理 + * + * @author ruoyi + */ +@RestController +@RequestMapping("/system/tenant") +public class SysTenantController extends BaseController { + @Autowired + private ISysTenantService sysTenantService; + + /** + * 获取参数配置列表 + */ + @PreAuthorize("@ss.hasPermi('system:tenant:list')") + @GetMapping("/list") + public TableDataInfo list(HttpServletRequest request) { + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.orderByDesc("a.create_time"); + String tenantId = request.getParameter("tenantId"); + if (!StringUtils.isEmpty(tenantId)) { + queryWrapper.eq("a.tenant_id", tenantId); + } + String contact = request.getParameter("contact"); + if (!StringUtils.isEmpty(contact)) { + queryWrapper.like("contact", contact); + } + String phone = request.getParameter("phone"); + if (!StringUtils.isEmpty(phone)) { + queryWrapper.eq("phone", phone); + } + String name = request.getParameter("name"); + if (!StringUtils.isEmpty(name)) { + queryWrapper.like("name", name); + } + + Page page = sysTenantService.page(getPage(), queryWrapper); + return getDataTable(page); + } + + /** + * 导出租户管理列表 + */ + @PreAuthorize("@ss.hasPermi('system:tenant:export')") + @Log(title = "租户管理", businessType = BusinessType.EXPORT) + @GetMapping("/export") + public AjaxResult export(HttpServletRequest request) { + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.orderByDesc("a.create_time"); + String tenantId = request.getParameter("tenantId"); + if (!StringUtils.isEmpty(tenantId)) { + queryWrapper.eq("a.tenant_id", tenantId); + } + String contact = request.getParameter("contact"); + if (!StringUtils.isEmpty(contact)) { + queryWrapper.like("contact", contact); + } + String phone = request.getParameter("phone"); + if (!StringUtils.isEmpty(phone)) { + queryWrapper.eq("phone", phone); + } + String name = request.getParameter("name"); + if (!StringUtils.isEmpty(name)) { + queryWrapper.like("name", name); + } + + List list = sysTenantService.list(queryWrapper); + ExcelUtil util = new ExcelUtil<>(SysTenant.class); + return util.exportExcel(list, "租户管理数据"); + } + + /** + * 获取租户管理详细信息 + */ + @PreAuthorize("@ss.hasPermi('system:tenant:query')") + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") Long id) { + return AjaxResult.success(sysTenantService.getById(id)); + } + + /** + * 新增租户管理 + */ + @PreAuthorize("@ss.hasPermi('system:tenant:add')") + @Log(title = "租户管理", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody SysTenant sysTenant) { + return toAjax(sysTenantService.save(sysTenant)); + } + + /** + * 修改租户管理 + */ + @PreAuthorize("@ss.hasPermi('system:tenant:edit')") + @Log(title = "租户管理", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody SysTenant sysTenant) { + return toAjax(sysTenantService.updateById(sysTenant)); + } + + /** + * 删除租户管理 + */ + @PreAuthorize("@ss.hasPermi('system:tenant:remove')") + @Log(title = "租户管理", businessType = BusinessType.DELETE) + @DeleteMapping("/{infoIds}") + public AjaxResult remove(@PathVariable Long[] infoIds) { + return toAjax(sysTenantService.removeByIds(Arrays.asList(infoIds))); + } +} diff --git a/ruoyi-base-support/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysUserController.java b/ruoyi-base-support/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysUserController.java new file mode 100644 index 0000000..2beebda --- /dev/null +++ b/ruoyi-base-support/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysUserController.java @@ -0,0 +1,228 @@ +package com.ruoyi.web.controller.system; + +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.constant.UserConstants; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.domain.AjaxResultMap; +import com.ruoyi.common.core.domain.entity.SysRole; +import com.ruoyi.common.core.domain.entity.SysUser; +import com.ruoyi.common.core.page.TableDataInfo; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.common.utils.SecurityUtils; +import com.ruoyi.common.utils.StringUtils; +import com.ruoyi.common.utils.poi.ExcelUtil; +import com.ruoyi.system.service.ISysPostService; +import com.ruoyi.system.service.ISysRoleService; +import com.ruoyi.system.service.ISysUserService; +import org.apache.commons.lang3.ArrayUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartFile; + +import java.util.List; +import java.util.stream.Collectors; + +/** + * 用户信息 + * + * @author ruoyi + */ +@RestController +@RequestMapping("/system/user") +public class SysUserController extends BaseController +{ + @Autowired + private ISysUserService userService; + + @Autowired + private ISysRoleService roleService; + + @Autowired + private ISysPostService postService; + + /** + * 获取用户列表 + */ + @PreAuthorize("@ss.hasPermi('system:user:list')") + @GetMapping("/list") + public TableDataInfo list(SysUser user) + { + startPage(); + user.setTenantId(SecurityUtils.getLoginUser().getTenantId()); + List list = userService.selectUserList(user); + return getDataTable(list); + } + + @Log(title = "用户管理", businessType = BusinessType.EXPORT) + @PreAuthorize("@ss.hasPermi('system:user:export')") + @GetMapping("/export") + public AjaxResult export(SysUser user) + { + List list = userService.selectUserList(user); + ExcelUtil util = new ExcelUtil(SysUser.class); + return util.exportExcel(list, "用户数据"); + } + + @Log(title = "用户管理", businessType = BusinessType.IMPORT) + @PreAuthorize("@ss.hasPermi('system:user:import')") + @PostMapping("/importData") + public AjaxResult importData(MultipartFile file, boolean updateSupport) throws Exception + { + ExcelUtil util = new ExcelUtil(SysUser.class); + List userList = util.importExcel(file.getInputStream()); + String operName = getUsername(); + String message = userService.importUser(userList, updateSupport, operName); + return AjaxResult.success(message); + } + + @GetMapping("/importTemplate") + public AjaxResult importTemplate() + { + ExcelUtil util = new ExcelUtil(SysUser.class); + return util.importTemplateExcel("用户数据"); + } + + /** + * 根据用户编号获取详细信息 + */ + @PreAuthorize("@ss.hasPermi('system:user:query')") + @GetMapping(value = { "/", "/{userId}" }) + public AjaxResultMap getInfo(@PathVariable(value = "userId", required = false) Long userId) + { + userService.checkUserDataScope(userId); + AjaxResultMap ajax = AjaxResultMap.success(); + List roles = roleService.selectRoleAll(); + ajax.put("roles", SysUser.isAdmin(userId) ? roles : roles.stream().filter(r -> !r.isAdmin()).collect(Collectors.toList())); + ajax.put("posts", postService.selectPostAll()); + if (StringUtils.isNotNull(userId)) + { + ajax.put(AjaxResultMap.DATA_TAG, userService.selectUserById(userId)); + ajax.put("postIds", postService.selectPostListByUserId(userId)); + ajax.put("roleIds", roleService.selectRoleListByUserId(userId)); + } + return ajax; + } + + /** + * 新增用户 + */ + @PreAuthorize("@ss.hasPermi('system:user:add')") + @Log(title = "用户管理", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@Validated @RequestBody SysUser user) + { + if (UserConstants.NOT_UNIQUE.equals(userService.checkUserNameUnique(user.getUserName()))) + { + return AjaxResult.error("新增用户'" + user.getUserName() + "'失败,登录账号已存在"); + } + else if (StringUtils.isNotEmpty(user.getPhonenumber()) + && UserConstants.NOT_UNIQUE.equals(userService.checkPhoneUnique(user))) + { + return AjaxResult.error("新增用户'" + user.getUserName() + "'失败,手机号码已存在"); + } + else if (StringUtils.isNotEmpty(user.getEmail()) + && UserConstants.NOT_UNIQUE.equals(userService.checkEmailUnique(user))) + { + return AjaxResult.error("新增用户'" + user.getUserName() + "'失败,邮箱账号已存在"); + } + user.setTenantId(SecurityUtils.getLoginUser().getTenantId()); + user.setCreateBy(getUsername()); + user.setPassword(SecurityUtils.encryptPassword(user.getPassword())); + return toAjax(userService.insertUser(user)); + } + + /** + * 修改用户 + */ + @PreAuthorize("@ss.hasPermi('system:user:edit')") + @Log(title = "用户管理", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@Validated @RequestBody SysUser user) + { + userService.checkUserAllowed(user); + if (StringUtils.isNotEmpty(user.getPhonenumber()) + && UserConstants.NOT_UNIQUE.equals(userService.checkPhoneUnique(user))) + { + return AjaxResult.error("修改用户'" + user.getUserName() + "'失败,手机号码已存在"); + } + else if (StringUtils.isNotEmpty(user.getEmail()) + && UserConstants.NOT_UNIQUE.equals(userService.checkEmailUnique(user))) + { + return AjaxResult.error("修改用户'" + user.getUserName() + "'失败,邮箱账号已存在"); + } + user.setUpdateBy(getUsername()); + return toAjax(userService.updateUser(user)); + } + + /** + * 删除用户 + */ + @PreAuthorize("@ss.hasPermi('system:user:remove')") + @Log(title = "用户管理", businessType = BusinessType.DELETE) + @DeleteMapping("/{userIds}") + public AjaxResult remove(@PathVariable Long[] userIds) + { + if (ArrayUtils.contains(userIds, getUserId())) + { + return error("当前用户不能删除"); + } + return toAjax(userService.deleteUserByIds(userIds)); + } + + /** + * 重置密码 + */ + @PreAuthorize("@ss.hasPermi('system:user:resetPwd')") + @Log(title = "用户管理", businessType = BusinessType.UPDATE) + @PutMapping("/resetPwd") + public AjaxResult resetPwd(@RequestBody SysUser user) + { + userService.checkUserAllowed(user); + user.setPassword(SecurityUtils.encryptPassword(user.getPassword())); + user.setUpdateBy(getUsername()); + return toAjax(userService.resetPwd(user)); + } + + /** + * 状态修改 + */ + @PreAuthorize("@ss.hasPermi('system:user:edit')") + @Log(title = "用户管理", businessType = BusinessType.UPDATE) + @PutMapping("/changeStatus") + public AjaxResult changeStatus(@RequestBody SysUser user) + { + userService.checkUserAllowed(user); + user.setUpdateBy(getUsername()); + return toAjax(userService.updateUserStatus(user)); + } + + /** + * 根据用户编号获取授权角色 + */ + @PreAuthorize("@ss.hasPermi('system:user:query')") + @GetMapping("/authRole/{userId}") + public AjaxResultMap authRole(@PathVariable("userId") Long userId) + { + AjaxResultMap ajax = AjaxResultMap.success(); + SysUser user = userService.selectUserById(userId); + List roles = roleService.selectRolesByUserId(userId); + ajax.put("user", user); + ajax.put("roles", SysUser.isAdmin(userId) ? roles : roles.stream().filter(r -> !r.isAdmin()).collect(Collectors.toList())); + return ajax; + } + + /** + * 用户授权角色 + */ + @PreAuthorize("@ss.hasPermi('system:user:edit')") + @Log(title = "用户管理", businessType = BusinessType.GRANT) + @PutMapping("/authRole") + public AjaxResult insertAuthRole(Long userId, Long[] roleIds) + { + userService.insertUserAuth(userId, roleIds); + return success(); + } +} diff --git a/ruoyi-base-support/ruoyi-admin/src/main/java/com/ruoyi/web/controller/tool/SwaggerController.java b/ruoyi-base-support/ruoyi-admin/src/main/java/com/ruoyi/web/controller/tool/SwaggerController.java new file mode 100644 index 0000000..a4bf1d4 --- /dev/null +++ b/ruoyi-base-support/ruoyi-admin/src/main/java/com/ruoyi/web/controller/tool/SwaggerController.java @@ -0,0 +1,24 @@ +package com.ruoyi.web.controller.tool; + +import com.ruoyi.common.core.controller.BaseController; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; + +/** + * swagger 接口 + * + * @author ruoyi + */ +@Controller +@RequestMapping("/tool/swagger") +public class SwaggerController extends BaseController +{ + @PreAuthorize("@ss.hasPermi('tool:swagger:view')") + @GetMapping() + public String index() + { + return redirect("/swagger-ui.html"); + } +} diff --git a/ruoyi-base-support/ruoyi-admin/src/main/java/com/ruoyi/web/controller/tool/TestController.java b/ruoyi-base-support/ruoyi-admin/src/main/java/com/ruoyi/web/controller/tool/TestController.java new file mode 100644 index 0000000..d1df717 --- /dev/null +++ b/ruoyi-base-support/ruoyi-admin/src/main/java/com/ruoyi/web/controller/tool/TestController.java @@ -0,0 +1,170 @@ +package com.ruoyi.web.controller.tool; + +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.utils.StringUtils; +import io.swagger.annotations.*; +import org.springframework.web.bind.annotation.*; + +import java.util.ArrayList; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; + +/** + * swagger 用户测试方法 + * + * @author ruoyi + */ +/*@Api("用户信息管理") +@RestController +@RequestMapping("/test/user")*/ +public class TestController extends BaseController +{ + private final static Map users = new LinkedHashMap(); + { + users.put(1, new UserEntity(1, "admin", "admin123", "15888888888")); + users.put(2, new UserEntity(2, "ry", "admin123", "15666666666")); + } + + @ApiOperation("获取用户列表") + @GetMapping("/list") + public AjaxResult userList() + { + List userList = new ArrayList(users.values()); + return AjaxResult.success(userList); + } + + @ApiOperation("获取用户详细") + @ApiImplicitParam(name = "userId", value = "用户ID", required = true, dataType = "int", paramType = "path", dataTypeClass = Integer.class) + @GetMapping("/{userId}") + public AjaxResult getUser(@PathVariable Integer userId) + { + if (!users.isEmpty() && users.containsKey(userId)) + { + return AjaxResult.success(users.get(userId)); + } + else + { + return error("用户不存在"); + } + } + + @ApiOperation("新增用户") + @ApiImplicitParams({ + @ApiImplicitParam(name = "userId", value = "用户id", dataType = "Integer", dataTypeClass = Integer.class), + @ApiImplicitParam(name = "username", value = "用户名称", dataType = "String", dataTypeClass = String.class), + @ApiImplicitParam(name = "password", value = "用户密码", dataType = "String", dataTypeClass = String.class), + @ApiImplicitParam(name = "mobile", value = "用户手机", dataType = "String", dataTypeClass = String.class) + }) + @PostMapping("/save") + public AjaxResult save(UserEntity user) + { + if (StringUtils.isNull(user) || StringUtils.isNull(user.getUserId())) + { + return error("用户ID不能为空"); + } + return AjaxResult.success(users.put(user.getUserId(), user)); + } + + @ApiOperation("更新用户") + @PutMapping("/update") + public AjaxResult update(@RequestBody UserEntity user) + { + if (StringUtils.isNull(user) || StringUtils.isNull(user.getUserId())) + { + return error("用户ID不能为空"); + } + if (users.isEmpty() || !users.containsKey(user.getUserId())) + { + return error("用户不存在"); + } + users.remove(user.getUserId()); + return AjaxResult.success(users.put(user.getUserId(), user)); + } + + @ApiOperation("删除用户信息") + @ApiImplicitParam(name = "userId", value = "用户ID", required = true, dataType = "int", paramType = "path", dataTypeClass = Integer.class) + @DeleteMapping("/{userId}") + public AjaxResult delete(@PathVariable Integer userId) + { + if (!users.isEmpty() && users.containsKey(userId)) + { + users.remove(userId); + return success(); + } + else + { + return error("用户不存在"); + } + } +} + +@ApiModel(value = "UserEntity", description = "用户实体") +class UserEntity +{ + @ApiModelProperty("用户ID") + private Integer userId; + + @ApiModelProperty("用户名称") + private String username; + + @ApiModelProperty("用户密码") + private String password; + + @ApiModelProperty("用户手机") + private String mobile; + + public UserEntity() + { + + } + + public UserEntity(Integer userId, String username, String password, String mobile) + { + this.userId = userId; + this.username = username; + this.password = password; + this.mobile = mobile; + } + + public Integer getUserId() + { + return userId; + } + + public void setUserId(Integer userId) + { + this.userId = userId; + } + + public String getUsername() + { + return username; + } + + public void setUsername(String username) + { + this.username = username; + } + + public String getPassword() + { + return password; + } + + public void setPassword(String password) + { + this.password = password; + } + + public String getMobile() + { + return mobile; + } + + public void setMobile(String mobile) + { + this.mobile = mobile; + } +} diff --git a/ruoyi-base-support/ruoyi-admin/src/main/java/com/ruoyi/web/core/config/SwaggerConfig.java b/ruoyi-base-support/ruoyi-admin/src/main/java/com/ruoyi/web/core/config/SwaggerConfig.java new file mode 100644 index 0000000..60f97d8 --- /dev/null +++ b/ruoyi-base-support/ruoyi-admin/src/main/java/com/ruoyi/web/core/config/SwaggerConfig.java @@ -0,0 +1,121 @@ +package com.ruoyi.web.core.config; + +import com.ruoyi.common.config.RuoYiConfig; +import io.swagger.annotations.ApiOperation; +import io.swagger.models.auth.In; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import springfox.documentation.builders.ApiInfoBuilder; +import springfox.documentation.builders.PathSelectors; +import springfox.documentation.builders.RequestHandlerSelectors; +import springfox.documentation.service.*; +import springfox.documentation.spi.DocumentationType; +import springfox.documentation.spi.service.contexts.SecurityContext; +import springfox.documentation.spring.web.plugins.Docket; + +import java.util.ArrayList; +import java.util.List; + +/** + * Swagger2的接口配置 + * + * @author ruoyi + */ +@Configuration +public class SwaggerConfig +{ + /** 系统基础配置 */ + @Autowired + private RuoYiConfig ruoyiConfig; + + /** 是否开启swagger */ + @Value("${swagger.enabled}") + private boolean enabled; + + /** 设置请求的统一前缀 */ + @Value("${swagger.pathMapping}") + private String pathMapping; + + /** + * 创建API + */ + @Bean + public Docket createRestApi() + { + return new Docket(DocumentationType.OAS_30) + // 是否启用Swagger + .enable(enabled) + // 用来创建该API的基本信息,展示在文档的页面中(自定义展示的信息) + .apiInfo(apiInfo()) + // 设置哪些接口暴露给Swagger展示 + .select() + // 扫描所有有注解的api,用这种方式更灵活 + .apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class)) + // 扫描指定包中的swagger注解 + // .apis(RequestHandlerSelectors.basePackage("com.ruoyi.project.tool.swagger")) + // 扫描所有 .apis(RequestHandlerSelectors.any()) + .paths(PathSelectors.any()) + .build() + /* 设置安全模式,swagger可以设置访问token */ + .securitySchemes(securitySchemes()) + .securityContexts(securityContexts()) + .pathMapping(pathMapping); + } + + /** + * 安全模式,这里指定token通过Authorization头请求头传递 + */ + private List securitySchemes() + { + List apiKeyList = new ArrayList(); + apiKeyList.add(new ApiKey("Authorization", "Authorization", In.HEADER.toValue())); + return apiKeyList; + } + + /** + * 安全上下文 + */ + private List securityContexts() + { + List securityContexts = new ArrayList<>(); + securityContexts.add( + SecurityContext.builder() + .securityReferences(defaultAuth()) + .operationSelector(o -> o.requestMappingPattern().matches("/.*")) + .build()); + return securityContexts; + } + + /** + * 默认的安全上引用 + */ + private List defaultAuth() + { + AuthorizationScope authorizationScope = new AuthorizationScope("global", "accessEverything"); + AuthorizationScope[] authorizationScopes = new AuthorizationScope[1]; + authorizationScopes[0] = authorizationScope; + List securityReferences = new ArrayList<>(); + securityReferences.add(new SecurityReference("Authorization", authorizationScopes)); + return securityReferences; + } + + /** + * 添加摘要信息 + */ + private ApiInfo apiInfo() + { + // 用ApiInfoBuilder进行定制 + return new ApiInfoBuilder() + // 设置标题 + .title("标题:若依管理系统_接口文档") + // 描述 + .description("描述:用于管理集团旗下公司的人员信息,具体包括XXX,XXX模块...") + // 作者信息 + .contact(new Contact(ruoyiConfig.getName(), null, null)) + // 版本 + .version("版本号:" + ruoyiConfig.getVersion()) + .build(); + } +} diff --git a/ruoyi-base-support/ruoyi-biz/pom.xml b/ruoyi-base-support/ruoyi-biz/pom.xml new file mode 100644 index 0000000..a61fd1e --- /dev/null +++ b/ruoyi-base-support/ruoyi-biz/pom.xml @@ -0,0 +1,57 @@ + + + + ruoyi-base-support + com.ruoyi + 3.7.0 + + 4.0.0 + + ruoyi-biz + + + 13 + 13 + + + + + org.springframework.boot + spring-boot-devtools + true + + + + + io.springfox + springfox-boot-starter + + + + + io.swagger + swagger-models + 1.6.2 + + + + + mysql + mysql-connector-java + + + + + com.ruoyi + ruoyi-framework + + + + com.ruoyi + ruoyi-common + + + + diff --git a/ruoyi-base-support/ruoyi-biz/src/main/java/com/ruoyi/web/demo/expandtable/controller/ExpandTableController.java b/ruoyi-base-support/ruoyi-biz/src/main/java/com/ruoyi/web/demo/expandtable/controller/ExpandTableController.java new file mode 100644 index 0000000..9cea8f2 --- /dev/null +++ b/ruoyi-base-support/ruoyi-biz/src/main/java/com/ruoyi/web/demo/expandtable/controller/ExpandTableController.java @@ -0,0 +1,119 @@ +package com.ruoyi.web.demo.expandtable.controller; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.page.TableDataInfo; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.common.utils.StringUtils; +import com.ruoyi.common.utils.poi.ExcelUtil; +import com.ruoyi.web.demo.expandtable.entity.ExpandTable; +import com.ruoyi.web.demo.expandtable.service.IExpandTableService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.*; + +import javax.servlet.http.HttpServletRequest; +import java.util.Arrays; +import java.util.List; + +/** + * 参数配置 信息操作处理 + * + * @author ruoyi + */ +@RestController +@RequestMapping("/demo/expandTable") +public class ExpandTableController extends BaseController { + @Autowired + private IExpandTableService expandTableService; + + /** + * 获取参数配置列表 + */ + @PreAuthorize("@ss.hasPermi('demo:expandTable:list')") + @GetMapping("/list") + public TableDataInfo list(HttpServletRequest request) { + //加入条件 + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.orderByDesc("create_time"); + + String title = request.getParameter("name"); + if (!StringUtils.isEmpty(title)) { + queryWrapper.like("title", title); + } + + Page page = expandTableService.page(getPage(), queryWrapper); + return getDataTable(page); + } + + /** + * 导出展开表格列表 + */ + @PreAuthorize("@ss.hasPermi('demo:expandTable:export')") + @Log(title = "展开表格", businessType = BusinessType.EXPORT) + @GetMapping("/export") + public AjaxResult export(HttpServletRequest request) { + //加入条件 + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.orderByDesc("create_time"); + + String title = request.getParameter("title"); + if (!StringUtils.isEmpty(title)) { + queryWrapper.eq("title", title); + } + String level = request.getParameter("level"); + if (!StringUtils.isEmpty(title)) { + queryWrapper.eq("level", level); + } + String type = request.getParameter("type"); + if (!StringUtils.isEmpty(type)) { + queryWrapper.eq("type", type); + } + + List list = expandTableService.list(queryWrapper); + ExcelUtil util = new ExcelUtil<>(ExpandTable.class); + return util.exportExcel(list, "展开表格数据"); + } + + /** + * 获取展开表格详细信息 + */ + @PreAuthorize("@ss.hasPermi('demo:expandTable:query')") + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") Long id) { + return AjaxResult.success(expandTableService.getById(id)); + } + + /** + * 新增展开表格 + */ + @PreAuthorize("@ss.hasPermi('demo:expandTable:add')") + @Log(title = "展开表格", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody ExpandTable expandTable) { + return toAjax(expandTableService.save(expandTable)); + } + + /** + * 修改展开表格 + */ + @PreAuthorize("@ss.hasPermi('demo:expandTable:edit')") + @Log(title = "展开表格", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody ExpandTable expandTable) { + return toAjax(expandTableService.updateById(expandTable)); + } + + /** + * 删除展开表格 + */ + @PreAuthorize("@ss.hasPermi('demo:expandTable:remove')") + @Log(title = "展开表格", businessType = BusinessType.DELETE) + @DeleteMapping("/{infoIds}") + public AjaxResult remove(@PathVariable Long[] infoIds) { + return toAjax(expandTableService.removeByIds(Arrays.asList(infoIds))); + } +} diff --git a/ruoyi-base-support/ruoyi-biz/src/main/java/com/ruoyi/web/demo/expandtable/entity/ExpandTable.java b/ruoyi-base-support/ruoyi-biz/src/main/java/com/ruoyi/web/demo/expandtable/entity/ExpandTable.java new file mode 100644 index 0000000..feae3fb --- /dev/null +++ b/ruoyi-base-support/ruoyi-biz/src/main/java/com/ruoyi/web/demo/expandtable/entity/ExpandTable.java @@ -0,0 +1,45 @@ +package com.ruoyi.web.demo.expandtable.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import com.ruoyi.common.core.domain.BaseEntity; +import lombok.Data; + +/** + * All rights Reserved, Designed By www.sunseagear.com + * + * @version V1.0 + * @package test.expandtable + * @title: 商品信息控制器 + * @description: 商品信息控制器 + * @author: admin + * @date: 2019-11-13 15:02:00 + * @copyright: www.sunseagear.com Inc. All rights reserved. + */ + +@Data +@TableName("demo_expand_table") +@SuppressWarnings("serial") +public class ExpandTable extends BaseEntity { + + + @TableId(value = "id", type = IdType.AUTO) + private String id; //id + @TableField(value = "name") + private String name; //商品名称 + @TableField(value = "shop") + private String shop; //所属店铺 + @TableField(value = "category") + private String category; //商品分类 + @TableField(value = "address") + private String address; //店铺地址 + @TableField(value = "description") + private String description; //商品描述 + @TableField(value = "tag") + private String tag; //标签 + @TableField(value = "image") + private String image; //图片 + +} diff --git a/ruoyi-base-support/ruoyi-biz/src/main/java/com/ruoyi/web/demo/expandtable/mapper/ExpandTableMapper.java b/ruoyi-base-support/ruoyi-biz/src/main/java/com/ruoyi/web/demo/expandtable/mapper/ExpandTableMapper.java new file mode 100644 index 0000000..3f36bbc --- /dev/null +++ b/ruoyi-base-support/ruoyi-biz/src/main/java/com/ruoyi/web/demo/expandtable/mapper/ExpandTableMapper.java @@ -0,0 +1,21 @@ +package com.ruoyi.web.demo.expandtable.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.ruoyi.web.demo.expandtable.entity.ExpandTable; +import org.apache.ibatis.annotations.Mapper; + +/** + * All rights Reserved, Designed By www.sunseagear.com + * + * @version V1.0 + * @package test.expandtable + * @title: 商品信息控制器 + * @description: 商品信息控制器 + * @author: admin + * @date: 2019-11-13 15:02:01 + * @copyright: www.sunseagear.com Inc. All rights reserved. + */ +@Mapper +public interface ExpandTableMapper extends BaseMapper { + +} diff --git a/ruoyi-base-support/ruoyi-biz/src/main/java/com/ruoyi/web/demo/expandtable/mapper/xml/ExpandTableMapper.xml b/ruoyi-base-support/ruoyi-biz/src/main/java/com/ruoyi/web/demo/expandtable/mapper/xml/ExpandTableMapper.xml new file mode 100644 index 0000000..8344b37 --- /dev/null +++ b/ruoyi-base-support/ruoyi-biz/src/main/java/com/ruoyi/web/demo/expandtable/mapper/xml/ExpandTableMapper.xml @@ -0,0 +1,23 @@ + + + + + + a.id, + a.name, + a.shop, + a.category, + a.address, + a.description, + a.tag, + a.create_time, + a.update_by, + a.update_date, + a.remarks, + a.del_flag, + a.create_by + + + + + diff --git a/ruoyi-base-support/ruoyi-biz/src/main/java/com/ruoyi/web/demo/expandtable/service/IExpandTableService.java b/ruoyi-base-support/ruoyi-biz/src/main/java/com/ruoyi/web/demo/expandtable/service/IExpandTableService.java new file mode 100644 index 0000000..dbc74ed --- /dev/null +++ b/ruoyi-base-support/ruoyi-biz/src/main/java/com/ruoyi/web/demo/expandtable/service/IExpandTableService.java @@ -0,0 +1,19 @@ +package com.ruoyi.web.demo.expandtable.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.ruoyi.web.demo.expandtable.entity.ExpandTable; + +/** + * All rights Reserved, Designed By www.sunseagear.com + * + * @version V1.0 + * @package test.expandtable + * @title: 商品信息控制器 + * @description: 商品信息控制器 + * @author: admin + * @date: 2019-11-13 15:02:02 + * @copyright: www.sunseagear.com Inc. All rights reserved. + */ +public interface IExpandTableService extends IService { + +} diff --git a/ruoyi-base-support/ruoyi-biz/src/main/java/com/ruoyi/web/demo/expandtable/service/impl/ExpandTableServiceImpl.java b/ruoyi-base-support/ruoyi-biz/src/main/java/com/ruoyi/web/demo/expandtable/service/impl/ExpandTableServiceImpl.java new file mode 100644 index 0000000..76621a5 --- /dev/null +++ b/ruoyi-base-support/ruoyi-biz/src/main/java/com/ruoyi/web/demo/expandtable/service/impl/ExpandTableServiceImpl.java @@ -0,0 +1,26 @@ +package com.ruoyi.web.demo.expandtable.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.ruoyi.web.demo.expandtable.entity.ExpandTable; +import com.ruoyi.web.demo.expandtable.mapper.ExpandTableMapper; +import com.ruoyi.web.demo.expandtable.service.IExpandTableService; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + + +/** + * All rights Reserved, Designed By www.sunseagear.com + * + * @version V1.0 + * @package test.expandtable + * @title: 商品信息控制器 + * @description: 商品信息控制器 + * @author: admin + * @date: 2019-11-13 15:02:03 + * @copyright: www.sunseagear.com Inc. All rights reserved. + */ +@Transactional +@Service("expandTableService") +public class ExpandTableServiceImpl extends ServiceImpl implements IExpandTableService { + +} diff --git a/ruoyi-base-support/ruoyi-biz/src/main/java/com/ruoyi/web/demo/table/controller/TableController.java b/ruoyi-base-support/ruoyi-biz/src/main/java/com/ruoyi/web/demo/table/controller/TableController.java new file mode 100644 index 0000000..c0d7db7 --- /dev/null +++ b/ruoyi-base-support/ruoyi-biz/src/main/java/com/ruoyi/web/demo/table/controller/TableController.java @@ -0,0 +1,127 @@ +package com.ruoyi.web.demo.table.controller; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.page.TableDataInfo; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.common.utils.StringUtils; +import com.ruoyi.common.utils.poi.ExcelUtil; +import com.ruoyi.web.demo.table.entity.Table; +import com.ruoyi.web.demo.table.service.ITableService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.*; + +import javax.servlet.http.HttpServletRequest; +import java.util.Arrays; +import java.util.List; + +/** + * 参数配置 信息操作处理 + * + * @author ruoyi + */ +@RestController +@RequestMapping("/demo/table") +public class TableController extends BaseController { + @Autowired + private ITableService tableService; + + /** + * 获取参数配置列表 + */ + @PreAuthorize("@ss.hasPermi('demo:table:list')") + @GetMapping("/list") + public TableDataInfo list(HttpServletRequest request) { + //加入条件 + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.orderByDesc("create_time"); + + String title = request.getParameter("title"); + if (!StringUtils.isEmpty(title)) { + queryWrapper.eq("title", title); + } + String level = request.getParameter("level"); + if (!StringUtils.isEmpty(title)) { + queryWrapper.eq("level", level); + } + String type = request.getParameter("type"); + if (!StringUtils.isEmpty(type)) { + queryWrapper.eq("type", type); + } + + Page
page = tableService.page(getPage(), queryWrapper); + return getDataTable(page); + } + + /** + * 导出综合表格列表 + */ + @PreAuthorize("@ss.hasPermi('demo:table:export')") + @Log(title = "综合表格", businessType = BusinessType.EXPORT) + @GetMapping("/export") + public AjaxResult export(HttpServletRequest request) { + //加入条件 + QueryWrapper
queryWrapper = new QueryWrapper<>(); + queryWrapper.orderByDesc("create_time"); + + String title = request.getParameter("title"); + if (!StringUtils.isEmpty(title)) { + queryWrapper.eq("title", title); + } + String level = request.getParameter("level"); + if (!StringUtils.isEmpty(title)) { + queryWrapper.eq("level", level); + } + String type = request.getParameter("type"); + if (!StringUtils.isEmpty(type)) { + queryWrapper.eq("type", type); + } + + List
list = tableService.list(queryWrapper); + ExcelUtil
util = new ExcelUtil<>(Table.class); + return util.exportExcel(list, "综合表格数据"); + } + + /** + * 获取综合表格详细信息 + */ + @PreAuthorize("@ss.hasPermi('demo:table:query')") + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") Long id) { + return AjaxResult.success(tableService.getById(id)); + } + + /** + * 新增综合表格 + */ + @PreAuthorize("@ss.hasPermi('demo:table:add')") + @Log(title = "综合表格", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody Table table) { + return toAjax(tableService.save(table)); + } + + /** + * 修改综合表格 + */ + @PreAuthorize("@ss.hasPermi('demo:table:edit')") + @Log(title = "综合表格", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody Table table) { + return toAjax(tableService.updateById(table)); + } + + /** + * 删除综合表格 + */ + @PreAuthorize("@ss.hasPermi('demo:table:remove')") + @Log(title = "综合表格", businessType = BusinessType.DELETE) + @DeleteMapping("/{infoIds}") + public AjaxResult remove(@PathVariable Long[] infoIds) { + return toAjax(tableService.removeByIds(Arrays.asList(infoIds))); + } +} diff --git a/ruoyi-base-support/ruoyi-biz/src/main/java/com/ruoyi/web/demo/table/entity/Table.java b/ruoyi-base-support/ruoyi-biz/src/main/java/com/ruoyi/web/demo/table/entity/Table.java new file mode 100644 index 0000000..6f39219 --- /dev/null +++ b/ruoyi-base-support/ruoyi-biz/src/main/java/com/ruoyi/web/demo/table/entity/Table.java @@ -0,0 +1,60 @@ +package com.ruoyi.web.demo.table.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import com.ruoyi.common.core.domain.BaseEntity; +import com.ruoyi.common.core.domain.entity.SysUser; +import lombok.Data; + +import java.util.Date; + +/** + * All rights Reserved, Designed By www.sunseagear.com + * + * @version V1.0 + * @package com.sunseagear.bbs.modules.sys.entity + * @title: 操作日志实体 + * @description: 操作日志实体 * @date: 2018-09-30 15:53:25 + * @copyright: 2018 www.sunseagear.com Inc. All rights reserved. + */ + +@Data +@TableName("demo_table") +@SuppressWarnings("serial") +public class Table extends BaseEntity { + + @TableId(value = "id", type = IdType.AUTO) + private Long id; //id + + @TableField(value = "title") + private String title; //标题 + + @TableField(value = "content") + private String content; //内容 + + @TableField(value = "author") + private String author; //作者 + + @TableField(value = "type") + private String type; //类型 + + @TableField(value = "status") + private String status; //状态 + + @TableField(value = "level") + private Integer level; //重要程度 + + @TableField(value = "tag") + private String tag; //标签 + + @TableField(value = "readings") + private Integer readings; //阅读数 + + @TableField(value = "publish_date") + private Date publishDate; //发布时间 + + @TableField(exist = false) + private SysUser user; //发布时间 +} diff --git a/ruoyi-base-support/ruoyi-biz/src/main/java/com/ruoyi/web/demo/table/mapper/TableMapper.java b/ruoyi-base-support/ruoyi-biz/src/main/java/com/ruoyi/web/demo/table/mapper/TableMapper.java new file mode 100644 index 0000000..642862c --- /dev/null +++ b/ruoyi-base-support/ruoyi-biz/src/main/java/com/ruoyi/web/demo/table/mapper/TableMapper.java @@ -0,0 +1,19 @@ +package com.ruoyi.web.demo.table.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.ruoyi.web.demo.table.entity.Table; +import org.apache.ibatis.annotations.Mapper; + +/** + * All rights Reserved, Designed By www.sunseagear.com + * + * @version V1.0 + * @package com.sunseagear.wind.modules.sys.mapper + * @title: 操作日志数据库控制层接口 + * @description: 操作日志数据库控制层接口 * @date: 2018-09-30 15:53:25 + * @copyright: 2018 www.sunseagear.com Inc. All rights reserved. + */ +@Mapper +public interface TableMapper extends BaseMapper
{ + +} diff --git a/ruoyi-base-support/ruoyi-biz/src/main/java/com/ruoyi/web/demo/table/mapper/xml/TableMapper.xml b/ruoyi-base-support/ruoyi-biz/src/main/java/com/ruoyi/web/demo/table/mapper/xml/TableMapper.xml new file mode 100644 index 0000000..81e299a --- /dev/null +++ b/ruoyi-base-support/ruoyi-biz/src/main/java/com/ruoyi/web/demo/table/mapper/xml/TableMapper.xml @@ -0,0 +1,26 @@ + + + + + + a.*, + b.realname as "user.realname", + b.username as "user.username" + + + left join sys_user b on b.id = a.author + + + diff --git a/ruoyi-base-support/ruoyi-biz/src/main/java/com/ruoyi/web/demo/table/service/ITableService.java b/ruoyi-base-support/ruoyi-biz/src/main/java/com/ruoyi/web/demo/table/service/ITableService.java new file mode 100644 index 0000000..510de81 --- /dev/null +++ b/ruoyi-base-support/ruoyi-biz/src/main/java/com/ruoyi/web/demo/table/service/ITableService.java @@ -0,0 +1,18 @@ +package com.ruoyi.web.demo.table.service; + + +import com.baomidou.mybatisplus.extension.service.IService; +import com.ruoyi.web.demo.table.entity.Table; + +/** + * All rights Reserved, Designed By www.sunseagear.com + * + * @version V1.0 + * @package com.sunseagear.wind.modules.sys.service + * @title: 操作日志服务接口 + * @description: 操作日志服务接口 * @date: 2018-09-30 15:53:25 + * @copyright: 2018 www.sunseagear.com Inc. All rights reserved. + */ +public interface ITableService extends IService
{ + +} diff --git a/ruoyi-base-support/ruoyi-biz/src/main/java/com/ruoyi/web/demo/table/service/impl/TableServiceImpl.java b/ruoyi-base-support/ruoyi-biz/src/main/java/com/ruoyi/web/demo/table/service/impl/TableServiceImpl.java new file mode 100644 index 0000000..309d5a5 --- /dev/null +++ b/ruoyi-base-support/ruoyi-biz/src/main/java/com/ruoyi/web/demo/table/service/impl/TableServiceImpl.java @@ -0,0 +1,24 @@ +package com.ruoyi.web.demo.table.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.ruoyi.web.demo.table.entity.Table; +import com.ruoyi.web.demo.table.mapper.TableMapper; +import com.ruoyi.web.demo.table.service.ITableService; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + + +/** + * All rights Reserved, Designed By www.sunseagear.com + * + * @version V1.0 + * @package com.sunseagear.wind.modules.sys.service.impl + * @title: 操作日志服务实现 + * @description: 操作日志服务实现 * @date: 2018-09-30 15:53:25 + * @copyright: 2018 www.sunseagear.com Inc. All rights reserved. + */ +@Transactional +@Service("tableService") +public class TableServiceImpl extends ServiceImpl implements ITableService { + +} diff --git a/ruoyi-base-support/ruoyi-biz/src/main/java/com/ruoyi/web/demo/treeandtable/controller/TreeAndTableController.java b/ruoyi-base-support/ruoyi-biz/src/main/java/com/ruoyi/web/demo/treeandtable/controller/TreeAndTableController.java new file mode 100644 index 0000000..332d072 --- /dev/null +++ b/ruoyi-base-support/ruoyi-biz/src/main/java/com/ruoyi/web/demo/treeandtable/controller/TreeAndTableController.java @@ -0,0 +1,125 @@ +package com.ruoyi.web.demo.treeandtable.controller; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.page.TableDataInfo; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.common.utils.StringUtils; +import com.ruoyi.common.utils.poi.ExcelUtil; +import com.ruoyi.web.demo.treeandtable.entity.TreeAndTable; +import com.ruoyi.web.demo.treeandtable.service.ITreeAndTableService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.*; + +import javax.servlet.http.HttpServletRequest; +import java.io.IOException; +import java.util.Arrays; +import java.util.List; + + +/** + * All rights Reserved, Designed By www.sunseagear.com + * + * @version V1.0 + * @package test.treeandtable + * @title: 左树右表控制器 + * @description: 左树右表控制器 + * @author: admin + * @date: 2019-11-13 21:24:49 + * @copyright: www.sunseagear.com Inc. All rights reserved. + */ + +@RestController +@RequestMapping("/demo/treeandtable") +public class TreeAndTableController extends BaseController { + + @Autowired + private ITreeAndTableService treeAndTableService; + + /** + * 根据页码和每页记录数,以及查询条件动态加载数据 + * + * @param request + * @throws IOException + */ + @PreAuthorize("@ss.hasPermi('demo:treeandtable:list')") + @GetMapping("/list") + public TableDataInfo list(HttpServletRequest request) throws IOException { + //加入条件 + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.orderByDesc("create_time"); + String name = request.getParameter("name"); + if (!StringUtils.isEmpty(name)) { + queryWrapper.eq("name", name); + } + String type = request.getParameter("type"); + if (!StringUtils.isEmpty(type)) { + queryWrapper.eq("type", type); + } + String areaId = request.getParameter("areaId"); + if (!StringUtils.isEmpty(areaId)) { + queryWrapper.eq("area_id", areaId); + } + // 预处理 + Page pageBean = treeAndTableService.page(getPage(), queryWrapper); + return getDataTable(pageBean); + } + + @PreAuthorize("@ss.hasPermi('demo:treeandtable:export')") + @Log(title = "左树右表", businessType = BusinessType.EXPORT) + @GetMapping("/export") + public AjaxResult export(HttpServletRequest request) throws IOException { + //加入条件 + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.orderByDesc("create_time"); + String name = request.getParameter("name"); + if (!StringUtils.isEmpty(name)) { + queryWrapper.eq("name", name); + } + String type = request.getParameter("type"); + if (!StringUtils.isEmpty(type)) { + queryWrapper.eq("type", type); + } + String areaId = request.getParameter("areaId"); + if (!StringUtils.isEmpty(areaId)) { + queryWrapper.apply("area_id", areaId); + } + List list = treeAndTableService.list(queryWrapper); + ExcelUtil util = new ExcelUtil<>(TreeAndTable.class); + return util.exportExcel(list, "左树右表数据"); + } + + @PreAuthorize("@ss.hasPermi('demo:treeandtable:add')") + @Log(title = "左树右表", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody TreeAndTable entity) { + return toAjax(treeAndTableService.save(entity)); + } + + @PreAuthorize("@ss.hasPermi('demo:treeandtable:edit')") + @Log(title = "左树右表", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult update(@RequestBody TreeAndTable entity) { + return toAjax(treeAndTableService.updateById(entity)); + } + + /** + * 获取左树右表详细信息 + */ + @PreAuthorize("@ss.hasPermi('demo:treeandtable:query')") + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") Long id) { + return AjaxResult.success(treeAndTableService.getById(id)); + } + + @PreAuthorize("@ss.hasPermi('demo:treeandtable:remove')") + @Log(title = "左树右表", businessType = BusinessType.DELETE) + @DeleteMapping("/{infoIds}") + public AjaxResult batchDelete(@PathVariable String[] infoIds) { + return toAjax(treeAndTableService.removeByIds(Arrays.asList(infoIds))); + } +} diff --git a/ruoyi-base-support/ruoyi-biz/src/main/java/com/ruoyi/web/demo/treeandtable/entity/TreeAndTable.java b/ruoyi-base-support/ruoyi-biz/src/main/java/com/ruoyi/web/demo/treeandtable/entity/TreeAndTable.java new file mode 100644 index 0000000..f4f8ec0 --- /dev/null +++ b/ruoyi-base-support/ruoyi-biz/src/main/java/com/ruoyi/web/demo/treeandtable/entity/TreeAndTable.java @@ -0,0 +1,39 @@ +package com.ruoyi.web.demo.treeandtable.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import com.ruoyi.common.core.domain.BaseEntity; +import lombok.Data; + +/** + * All rights Reserved, Designed By www.sunseagear.com + * + * @version V1.0 + * @package test.treeandtable + * @title: 左树右表控制器 + * @description: 左树右表控制器 + * @author: admin + * @date: 2019-11-13 21:24:49 + * @copyright: www.sunseagear.com Inc. All rights reserved. + */ + +@Data +@TableName("demo_tree_and_table") +@SuppressWarnings("serial") +public class TreeAndTable extends BaseEntity { + + + @TableId(value = "id", type = IdType.AUTO) + private String id; //id + @TableField(value = "name") + private String name; //部门名称 + @TableField(value = "type") + private String type; //类型 + @TableField(value = "tag") + private String tag; //标签 + @TableField(value = "area_id") + private String areaId; //区域 + +} diff --git a/ruoyi-base-support/ruoyi-biz/src/main/java/com/ruoyi/web/demo/treeandtable/mapper/TreeAndTableMapper.java b/ruoyi-base-support/ruoyi-biz/src/main/java/com/ruoyi/web/demo/treeandtable/mapper/TreeAndTableMapper.java new file mode 100644 index 0000000..924cc14 --- /dev/null +++ b/ruoyi-base-support/ruoyi-biz/src/main/java/com/ruoyi/web/demo/treeandtable/mapper/TreeAndTableMapper.java @@ -0,0 +1,21 @@ +package com.ruoyi.web.demo.treeandtable.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.ruoyi.web.demo.treeandtable.entity.TreeAndTable; +import org.apache.ibatis.annotations.Mapper; + +/** + * All rights Reserved, Designed By www.sunseagear.com + * + * @version V1.0 + * @package test.treeandtable + * @title: 左树右表控制器 + * @description: 左树右表控制器 + * @author: admin + * @date: 2019-11-13 21:24:50 + * @copyright: www.sunseagear.com Inc. All rights reserved. + */ +@Mapper +public interface TreeAndTableMapper extends BaseMapper { + +} diff --git a/ruoyi-base-support/ruoyi-biz/src/main/java/com/ruoyi/web/demo/treeandtable/mapper/xml/TreeAndTableMapper.xml b/ruoyi-base-support/ruoyi-biz/src/main/java/com/ruoyi/web/demo/treeandtable/mapper/xml/TreeAndTableMapper.xml new file mode 100644 index 0000000..fd2f8cd --- /dev/null +++ b/ruoyi-base-support/ruoyi-biz/src/main/java/com/ruoyi/web/demo/treeandtable/mapper/xml/TreeAndTableMapper.xml @@ -0,0 +1,21 @@ + + + + + + a.id, + a.name, + a.type, + a.tag, + a.area_id, + a.create_time, + a.update_by, + a.update_date, + a.remarks, + a.del_flag, + a.create_by + + + + + diff --git a/ruoyi-base-support/ruoyi-biz/src/main/java/com/ruoyi/web/demo/treeandtable/service/ITreeAndTableService.java b/ruoyi-base-support/ruoyi-biz/src/main/java/com/ruoyi/web/demo/treeandtable/service/ITreeAndTableService.java new file mode 100644 index 0000000..a91e5bf --- /dev/null +++ b/ruoyi-base-support/ruoyi-biz/src/main/java/com/ruoyi/web/demo/treeandtable/service/ITreeAndTableService.java @@ -0,0 +1,19 @@ +package com.ruoyi.web.demo.treeandtable.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.ruoyi.web.demo.treeandtable.entity.TreeAndTable; + +/** + * All rights Reserved, Designed By www.sunseagear.com + * + * @version V1.0 + * @package test.treeandtable + * @title: 左树右表控制器 + * @description: 左树右表控制器 + * @author: admin + * @date: 2019-11-13 21:24:52 + * @copyright: www.sunseagear.com Inc. All rights reserved. + */ +public interface ITreeAndTableService extends IService { + +} diff --git a/ruoyi-base-support/ruoyi-biz/src/main/java/com/ruoyi/web/demo/treeandtable/service/impl/TreeAndTableServiceImpl.java b/ruoyi-base-support/ruoyi-biz/src/main/java/com/ruoyi/web/demo/treeandtable/service/impl/TreeAndTableServiceImpl.java new file mode 100644 index 0000000..bbdc4c4 --- /dev/null +++ b/ruoyi-base-support/ruoyi-biz/src/main/java/com/ruoyi/web/demo/treeandtable/service/impl/TreeAndTableServiceImpl.java @@ -0,0 +1,26 @@ +package com.ruoyi.web.demo.treeandtable.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.ruoyi.web.demo.treeandtable.entity.TreeAndTable; +import com.ruoyi.web.demo.treeandtable.mapper.TreeAndTableMapper; +import com.ruoyi.web.demo.treeandtable.service.ITreeAndTableService; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + + +/** + * All rights Reserved, Designed By www.sunseagear.com + * + * @version V1.0 + * @package test.treeandtable + * @title: 左树右表控制器 + * @description: 左树右表控制器 + * @author: admin + * @date: 2019-11-13 21:24:52 + * @copyright: www.sunseagear.com Inc. All rights reserved. + */ +@Transactional +@Service("treeAndTableService") +public class TreeAndTableServiceImpl extends ServiceImpl implements ITreeAndTableService { + +} diff --git a/ruoyi-base-support/ruoyi-biz/src/main/java/com/ruoyi/web/demo/treetable/controller/TreeTableController.java b/ruoyi-base-support/ruoyi-biz/src/main/java/com/ruoyi/web/demo/treetable/controller/TreeTableController.java new file mode 100644 index 0000000..4159fc7 --- /dev/null +++ b/ruoyi-base-support/ruoyi-biz/src/main/java/com/ruoyi/web/demo/treetable/controller/TreeTableController.java @@ -0,0 +1,105 @@ +package com.ruoyi.web.demo.treetable.controller; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.common.utils.StringUtils; +import com.ruoyi.web.demo.treetable.entity.TreeTable; +import com.ruoyi.web.demo.treetable.service.ITreeTableService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.*; + +import javax.servlet.http.HttpServletRequest; +import java.io.IOException; +import java.util.Arrays; +import java.util.List; + + +/** + * All rights Reserved, Designed By www.sunseagear.com + * + * @version V1.0 + * @package test.treetable + * @title: 树形结构表控制器 + * @description: 树形结构表控制器 + * @author: admin + * @date: 2019-11-13 21:38:32 + * @copyright: www.sunseagear.com Inc. All rights reserved. + */ + +@RestController +@RequestMapping("demo/treeTable") +public class TreeTableController extends BaseController { + + @Autowired + private ITreeTableService treeTableService; + + /** + * 根据页码和每页记录数,以及查询条件动态加载数据 + * + * @param request + * @throws IOException + */ + @PreAuthorize("@ss.hasPermi('demo:treetable:list')") + @GetMapping("/list") + public AjaxResult list(HttpServletRequest request) throws IOException { + //加入条件 + QueryWrapper entityWrapper = new QueryWrapper<>(); + entityWrapper.orderByDesc( "create_time"); + String name = request.getParameter("name"); + if (!StringUtils.isEmpty(name)) { + entityWrapper.like("name", name); + } + + // 预处理 + List treeNodeList = treeTableService.list(entityWrapper); + return AjaxResult.success(treeNodeList); + } + + + /** + * 获取树形表格详细信息 + */ + @PreAuthorize("@ss.hasPermi('demo:treeTable:query')") + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") String id) + { + return AjaxResult.success(treeTableService.getById(id)); + } + + /** + * 新增树形表格 + */ + @PreAuthorize("@ss.hasPermi('demo:treeTable:add')") + @Log(title = "树形表格", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody TreeTable treeTable) + { + return toAjax(treeTableService.save(treeTable)); + } + + /** + * 修改树形表格 + */ + @PreAuthorize("@ss.hasPermi('demo:treeTable:edit')") + @Log(title = "树形表格", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody TreeTable treeTable) + { + return toAjax(treeTableService.updateById(treeTable)); + } + + /** + * 删除树形表格 + */ + @PreAuthorize("@ss.hasPermi('demo:treeTable:remove')") + @Log(title = "树形表格", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}") + public AjaxResult remove(@PathVariable String[] ids) + { + return toAjax(treeTableService.removeByIds(Arrays.asList(ids))); + } +} diff --git a/ruoyi-base-support/ruoyi-biz/src/main/java/com/ruoyi/web/demo/treetable/entity/TreeTable.java b/ruoyi-base-support/ruoyi-biz/src/main/java/com/ruoyi/web/demo/treetable/entity/TreeTable.java new file mode 100644 index 0000000..d3c75ab --- /dev/null +++ b/ruoyi-base-support/ruoyi-biz/src/main/java/com/ruoyi/web/demo/treetable/entity/TreeTable.java @@ -0,0 +1,36 @@ +package com.ruoyi.web.demo.treetable.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import com.ruoyi.common.core.domain.TreeEntity; +import lombok.Data; + +/** + * All rights Reserved, Designed By www.sunseagear.com + * + * @version V1.0 + * @package test.treetable + * @title: 树形结构表控制器 + * @description: 树形结构表控制器 + * @author: admin + * @date: 2019-11-13 21:38:33 + * @copyright: www.sunseagear.com Inc. All rights reserved. + */ + +@Data +@TableName("demo_tree_table") +@SuppressWarnings("serial") +public class TreeTable extends TreeEntity { + + @TableId(value = "id", type = IdType.AUTO) + private String id; //id + + @TableField(value = "name") + private String name; //地理编码 + @TableField(value = "geocoding") + private String geocoding; //地理编码 + @TableField(value = "postal_code") + private String postalCode; //邮政编码 +} diff --git a/ruoyi-base-support/ruoyi-biz/src/main/java/com/ruoyi/web/demo/treetable/mapper/TreeTableMapper.java b/ruoyi-base-support/ruoyi-biz/src/main/java/com/ruoyi/web/demo/treetable/mapper/TreeTableMapper.java new file mode 100644 index 0000000..1e22780 --- /dev/null +++ b/ruoyi-base-support/ruoyi-biz/src/main/java/com/ruoyi/web/demo/treetable/mapper/TreeTableMapper.java @@ -0,0 +1,21 @@ +package com.ruoyi.web.demo.treetable.mapper; + +import com.ruoyi.common.core.mapper.BaseTreeMapper; +import com.ruoyi.web.demo.treetable.entity.TreeTable; +import org.apache.ibatis.annotations.Mapper; + +/** + * All rights Reserved, Designed By www.sunseagear.com + * + * @version V1.0 + * @package test.treetable + * @title: 树形结构表控制器 + * @description: 树形结构表控制器 + * @author: admin + * @date: 2019-11-13 21:38:33 + * @copyright: www.sunseagear.com Inc. All rights reserved. + */ +@Mapper +public interface TreeTableMapper extends BaseTreeMapper { + +} diff --git a/ruoyi-base-support/ruoyi-biz/src/main/java/com/ruoyi/web/demo/treetable/mapper/xml/TreeTableMapper.xml b/ruoyi-base-support/ruoyi-biz/src/main/java/com/ruoyi/web/demo/treetable/mapper/xml/TreeTableMapper.xml new file mode 100644 index 0000000..cf62f8c --- /dev/null +++ b/ruoyi-base-support/ruoyi-biz/src/main/java/com/ruoyi/web/demo/treetable/mapper/xml/TreeTableMapper.xml @@ -0,0 +1,50 @@ + + + + + + a.*, + (select count(*) from demo_tree_table s + WHERE s.parent_id=a.id) as + hasChildren + + + + + + + + + + + update demo_tree_table set ancestors= CONCAT(#{newParentIds},substring(ancestors, length(#{oldParentIds})+1,length(ancestors)+1)) + where ancestors like concat(#{oldParentIds}, '%') + + + + + delete from demo_tree_table + where ancestors like concat(#{parentIds}, '%') + + + diff --git a/ruoyi-base-support/ruoyi-biz/src/main/java/com/ruoyi/web/demo/treetable/service/ITreeTableService.java b/ruoyi-base-support/ruoyi-biz/src/main/java/com/ruoyi/web/demo/treetable/service/ITreeTableService.java new file mode 100644 index 0000000..15d3f48 --- /dev/null +++ b/ruoyi-base-support/ruoyi-biz/src/main/java/com/ruoyi/web/demo/treetable/service/ITreeTableService.java @@ -0,0 +1,19 @@ +package com.ruoyi.web.demo.treetable.service; + +import com.ruoyi.common.core.service.ITreeCommonService; +import com.ruoyi.web.demo.treetable.entity.TreeTable; + +/** + * All rights Reserved, Designed By www.sunseagear.com + * + * @version V1.0 + * @package test.treetable + * @title: 树形结构表控制器 + * @description: 树形结构表控制器 + * @author: admin + * @date: 2019-11-13 21:38:34 + * @copyright: www.sunseagear.com Inc. All rightss reserved. + */ +public interface ITreeTableService extends ITreeCommonService { + +} diff --git a/ruoyi-base-support/ruoyi-biz/src/main/java/com/ruoyi/web/demo/treetable/service/impl/TreeTableServiceImpl.java b/ruoyi-base-support/ruoyi-biz/src/main/java/com/ruoyi/web/demo/treetable/service/impl/TreeTableServiceImpl.java new file mode 100644 index 0000000..5e70287 --- /dev/null +++ b/ruoyi-base-support/ruoyi-biz/src/main/java/com/ruoyi/web/demo/treetable/service/impl/TreeTableServiceImpl.java @@ -0,0 +1,26 @@ +package com.ruoyi.web.demo.treetable.service.impl; + +import com.ruoyi.common.core.service.impl.TreeCommonServiceImpl; +import com.ruoyi.web.demo.treetable.entity.TreeTable; +import com.ruoyi.web.demo.treetable.mapper.TreeTableMapper; +import com.ruoyi.web.demo.treetable.service.ITreeTableService; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + + +/** + * All rights Reserved, Designed By www.sunseagear.com + * + * @version V1.0 + * @package test.treetable + * @title: 树形结构表控制器 + * @description: 树形结构表控制器 + * @author: admin + * @date: 2019-11-13 21:38:34 + * @copyright: www.sunseagear.com Inc. All rights reserved. + */ +@Transactional +@Service("treeTableService") +public class TreeTableServiceImpl extends TreeCommonServiceImpl implements ITreeTableService { + +} diff --git a/ruoyi-base-support/ruoyi-biz/src/main/java/com/ruoyi/web/demo/twotable/controller/CarController.java b/ruoyi-base-support/ruoyi-biz/src/main/java/com/ruoyi/web/demo/twotable/controller/CarController.java new file mode 100644 index 0000000..f2d1caa --- /dev/null +++ b/ruoyi-base-support/ruoyi-biz/src/main/java/com/ruoyi/web/demo/twotable/controller/CarController.java @@ -0,0 +1,90 @@ +package com.ruoyi.web.demo.twotable.controller; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.page.TableDataInfo; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.common.utils.StringUtils; +import com.ruoyi.web.demo.twotable.entity.Car; +import com.ruoyi.web.demo.twotable.service.ICarService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.*; + +import javax.servlet.http.HttpServletRequest; +import java.io.IOException; +import java.util.Arrays; + +@RestController +@RequestMapping("/demo/twotable/car") +public class CarController extends BaseController { + + @Autowired + private ICarService carService; + + + /** + * 根据页码和每页记录数,以及查询条件动态加载数据 + * + * @param request + * @throws IOException + */ + @PreAuthorize("@ss.hasPermi('demo:twotable:car:list')") + @GetMapping("/list") + public TableDataInfo list(HttpServletRequest request) throws IOException { + //加入条件 + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.orderByDesc( "create_time"); + String keyword = request.getParameter("keyword"); + if (!StringUtils.isEmpty(keyword)) { + queryWrapper.like("name", keyword).or().like("code", keyword); + } + // 预处理 + Page page = carService.page(getPage(), queryWrapper); + return getDataTable(page); + } + + /** + * 获取车辆品牌详细信息 + */ + @PreAuthorize("@ss.hasPermi('demo:twotable:car:query')") + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") Long id) { + return AjaxResult.success(carService.getById(id)); + } + + /** + * 新增车辆品牌 + */ + @PreAuthorize("@ss.hasPermi('demo:twotable:car:add')") + @Log(title = "车辆品牌", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody Car car) { + return toAjax(carService.save(car)); + } + + /** + * 修改车辆品牌 + */ + @PreAuthorize("@ss.hasPermi('demo:twotable:car:edit')") + @Log(title = "车辆品牌", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody Car car) { + return toAjax(carService.updateById(car)); + } + + /** + * 删除车辆品牌 + */ + @PreAuthorize("@ss.hasPermi('demo:twotable:car:remove')") + @Log(title = "车辆品牌", businessType = BusinessType.DELETE) + @DeleteMapping("/{infoIds}") + public AjaxResult remove(@PathVariable Long[] infoIds) { + return toAjax(carService.removeByIds(Arrays.asList(infoIds))); + } + + +} diff --git a/ruoyi-base-support/ruoyi-biz/src/main/java/com/ruoyi/web/demo/twotable/controller/CarModelController.java b/ruoyi-base-support/ruoyi-biz/src/main/java/com/ruoyi/web/demo/twotable/controller/CarModelController.java new file mode 100644 index 0000000..78ba6f5 --- /dev/null +++ b/ruoyi-base-support/ruoyi-biz/src/main/java/com/ruoyi/web/demo/twotable/controller/CarModelController.java @@ -0,0 +1,103 @@ +package com.ruoyi.web.demo.twotable.controller; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.page.TableDataInfo; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.common.utils.StringUtils; +import com.ruoyi.web.demo.twotable.entity.CarModel; +import com.ruoyi.web.demo.twotable.service.ICarModelService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.*; + +import javax.servlet.http.HttpServletRequest; +import java.io.IOException; +import java.util.Arrays; + +/** + * All rights Reserved, Designed By www.sunseagear.com + * + * @version V1.0 + * @package com.sunseagear.wind.modules.sys.controller + * @title: 消息模版控制器 + * @description: 消息模版控制器 * @date: 2018-09-03 15:10:10 + * @copyright: 2018 www.sunseagear.com Inc. All rights reserved. + */ + +@RestController +@RequestMapping("/demo/twotable/carmodel") +public class CarModelController extends BaseController { + + @Autowired + private ICarModelService carModelService; + + + /** + * 根据页码和每页记录数,以及查询条件动态加载数据 + * + * @param request + * @throws IOException + */ + @PreAuthorize("@ss.hasPermi('demo:twotable:car:list')") + @GetMapping("/list") + public TableDataInfo list(HttpServletRequest request) throws IOException { + //加入条件 + QueryWrapper entityWrapper = new QueryWrapper<>(); + entityWrapper.orderByAsc( "sort"); + String keyword = request.getParameter("keyword"); + String carId = request.getParameter("carId"); + if (!StringUtils.isEmpty(carId) && !StringUtils.isEmpty(keyword)) { + entityWrapper.eq("car_id", carId).and(i -> i.like("label", keyword).or().like("value", keyword)); + } else if (!StringUtils.isEmpty(carId)) { + entityWrapper.eq("car_id", carId); + } + + // 预处理 + Page page = carModelService.page(getPage(), entityWrapper); + return getDataTable(page); + } + + /** + * 获取车辆型号详细信息 + */ + @PreAuthorize("@ss.hasPermi('demo:twotable:car:query')") + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") Long id) { + return AjaxResult.success(carModelService.getById(id)); + } + + /** + * 新增车辆型号 + */ + @PreAuthorize("@ss.hasPermi('demo:twotable:car:add')") + @Log(title = "车辆型号", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody CarModel carModel) { + return toAjax(carModelService.save(carModel)); + } + + /** + * 修改车辆型号 + */ + @PreAuthorize("@ss.hasPermi('demo:twotable:car:edit')") + @Log(title = "车辆型号", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody CarModel carModel) { + return toAjax(carModelService.updateById(carModel)); + } + + /** + * 删除车辆型号 + */ + @PreAuthorize("@ss.hasPermi('demo:twotable:car:remove')") + @Log(title = "车辆型号", businessType = BusinessType.DELETE) + @DeleteMapping("/{infoIds}") + public AjaxResult remove(@PathVariable Long[] infoIds) { + return toAjax(carModelService.removeByIds(Arrays.asList(infoIds))); + } + +} diff --git a/ruoyi-base-support/ruoyi-biz/src/main/java/com/ruoyi/web/demo/twotable/entity/Car.java b/ruoyi-base-support/ruoyi-biz/src/main/java/com/ruoyi/web/demo/twotable/entity/Car.java new file mode 100644 index 0000000..5b05eb7 --- /dev/null +++ b/ruoyi-base-support/ruoyi-biz/src/main/java/com/ruoyi/web/demo/twotable/entity/Car.java @@ -0,0 +1,88 @@ +package com.ruoyi.web.demo.twotable.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import com.ruoyi.common.core.domain.BaseEntity; + +@TableName("demo_car") +@SuppressWarnings("serial") +public class Car extends BaseEntity { + + /** + * 主键 + */ + @TableId(value = "id", type = IdType.AUTO) + private String id; + /** + * 汽车品牌 + */ + @TableField(value = "name") + private String name; + + /** + * 品牌编码 + */ + @TableField(value = "code") + private String code; + + + /** + * 获取 code + * + * @return: String 分组编码 + */ + public String getCode() { + return this.code; + } + + /** + * 设置 code + * + * @param: code + * 分组编码 + */ + public void setCode(String code) { + this.code = code; + } + + /** + * 获取 id + * + * @return: String 主键 + */ + public String getId() { + return this.id; + } + + /** + * 设置 id + * + * @param: id + * 主键 + */ + public void setId(String id) { + this.id = id; + } + + /** + * 获取 name + * + * @return: String 分组名称 + */ + public String getName() { + return this.name; + } + + /** + * 设置 name + * + * @param: name + * 分组名称 + */ + public void setName(String name) { + this.name = name; + } + +} diff --git a/ruoyi-base-support/ruoyi-biz/src/main/java/com/ruoyi/web/demo/twotable/entity/CarModel.java b/ruoyi-base-support/ruoyi-biz/src/main/java/com/ruoyi/web/demo/twotable/entity/CarModel.java new file mode 100644 index 0000000..32c4e89 --- /dev/null +++ b/ruoyi-base-support/ruoyi-biz/src/main/java/com/ruoyi/web/demo/twotable/entity/CarModel.java @@ -0,0 +1,75 @@ +package com.ruoyi.web.demo.twotable.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import com.ruoyi.common.core.domain.BaseEntity; + +@TableName("demo_car_model") +@SuppressWarnings("serial") +public class CarModel extends BaseEntity { + + @TableId(value = "id", type = IdType.AUTO) + private String id; + @TableField(value = "car_id") + private String carId; + @TableField(value = "name") + private String name; + @TableField(value = "value") + private String value; + + @TableField(value = "sort") + private Integer sort; + @TableField(exist = false) + private String code; + + public String getCarId() { + return this.carId; + } + + public void setCarId(String carId) { + this.carId = carId; + } + + public String getId() { + return this.id; + } + + public void setId(String id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getValue() { + return this.value; + } + + public void setValue(String value) { + this.value = value; + } + + public Integer getSort() { + return this.sort; + } + + public void setSort(Integer sort) { + this.sort = sort; + } + + public String getCode() { + return code; + } + + public void setCode(String code) { + this.code = code; + } + +} diff --git a/ruoyi-base-support/ruoyi-biz/src/main/java/com/ruoyi/web/demo/twotable/mapper/CarMapper.java b/ruoyi-base-support/ruoyi-biz/src/main/java/com/ruoyi/web/demo/twotable/mapper/CarMapper.java new file mode 100644 index 0000000..4739c03 --- /dev/null +++ b/ruoyi-base-support/ruoyi-biz/src/main/java/com/ruoyi/web/demo/twotable/mapper/CarMapper.java @@ -0,0 +1,10 @@ +package com.ruoyi.web.demo.twotable.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.ruoyi.web.demo.twotable.entity.Car; +import org.apache.ibatis.annotations.Mapper; + +@Mapper +public interface CarMapper extends BaseMapper { + +} diff --git a/ruoyi-base-support/ruoyi-biz/src/main/java/com/ruoyi/web/demo/twotable/mapper/CarModelMapper.java b/ruoyi-base-support/ruoyi-biz/src/main/java/com/ruoyi/web/demo/twotable/mapper/CarModelMapper.java new file mode 100644 index 0000000..84be242 --- /dev/null +++ b/ruoyi-base-support/ruoyi-biz/src/main/java/com/ruoyi/web/demo/twotable/mapper/CarModelMapper.java @@ -0,0 +1,12 @@ +package com.ruoyi.web.demo.twotable.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.ruoyi.web.demo.twotable.entity.CarModel; +import org.apache.ibatis.annotations.Mapper; + +import java.util.List; + +@Mapper +public interface CarModelMapper extends BaseMapper { + List selectDictList(); +} diff --git a/ruoyi-base-support/ruoyi-biz/src/main/java/com/ruoyi/web/demo/twotable/mapper/xml/CarModelMapper.xml b/ruoyi-base-support/ruoyi-biz/src/main/java/com/ruoyi/web/demo/twotable/mapper/xml/CarModelMapper.xml new file mode 100644 index 0000000..e3bdbc7 --- /dev/null +++ b/ruoyi-base-support/ruoyi-biz/src/main/java/com/ruoyi/web/demo/twotable/mapper/xml/CarModelMapper.xml @@ -0,0 +1,19 @@ + + + + + d.id, + d.car_id, + d.name, + d.value, + d.sort, + d.remarks, + g.code + + + diff --git a/ruoyi-base-support/ruoyi-biz/src/main/java/com/ruoyi/web/demo/twotable/service/ICarModelService.java b/ruoyi-base-support/ruoyi-biz/src/main/java/com/ruoyi/web/demo/twotable/service/ICarModelService.java new file mode 100644 index 0000000..3bf511d --- /dev/null +++ b/ruoyi-base-support/ruoyi-biz/src/main/java/com/ruoyi/web/demo/twotable/service/ICarModelService.java @@ -0,0 +1,18 @@ +package com.ruoyi.web.demo.twotable.service; + + +import com.baomidou.mybatisplus.extension.service.IService; +import com.ruoyi.web.demo.twotable.entity.CarModel; + +import java.util.List; + +/** + * @author jwcg + * @version V1.0 + * @Title: + * @Description: + * @date 2017-02-09 09:05:29 + */ +public interface ICarModelService extends IService { + List selectDictList(); +} diff --git a/ruoyi-base-support/ruoyi-biz/src/main/java/com/ruoyi/web/demo/twotable/service/ICarService.java b/ruoyi-base-support/ruoyi-biz/src/main/java/com/ruoyi/web/demo/twotable/service/ICarService.java new file mode 100644 index 0000000..454f273 --- /dev/null +++ b/ruoyi-base-support/ruoyi-biz/src/main/java/com/ruoyi/web/demo/twotable/service/ICarService.java @@ -0,0 +1,15 @@ +package com.ruoyi.web.demo.twotable.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.ruoyi.web.demo.twotable.entity.Car; + +/** + * @author jwcg + * @version V1.0 + * @Title: + * @Description: + * @date 2017-02-09 09:05:51 + */ +public interface ICarService extends IService { + +} diff --git a/ruoyi-base-support/ruoyi-biz/src/main/java/com/ruoyi/web/demo/twotable/service/impl/CarModelServiceImpl.java b/ruoyi-base-support/ruoyi-biz/src/main/java/com/ruoyi/web/demo/twotable/service/impl/CarModelServiceImpl.java new file mode 100644 index 0000000..ef71ef3 --- /dev/null +++ b/ruoyi-base-support/ruoyi-biz/src/main/java/com/ruoyi/web/demo/twotable/service/impl/CarModelServiceImpl.java @@ -0,0 +1,21 @@ +package com.ruoyi.web.demo.twotable.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.ruoyi.web.demo.twotable.entity.CarModel; +import com.ruoyi.web.demo.twotable.mapper.CarModelMapper; +import com.ruoyi.web.demo.twotable.service.ICarModelService; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.List; + +@Transactional +@Service("carModelService") +public class CarModelServiceImpl extends ServiceImpl implements ICarModelService { + + @Override + public List selectDictList() { + return baseMapper.selectDictList(); + } + +} diff --git a/ruoyi-base-support/ruoyi-biz/src/main/java/com/ruoyi/web/demo/twotable/service/impl/CarServiceImpl.java b/ruoyi-base-support/ruoyi-biz/src/main/java/com/ruoyi/web/demo/twotable/service/impl/CarServiceImpl.java new file mode 100644 index 0000000..e86bca0 --- /dev/null +++ b/ruoyi-base-support/ruoyi-biz/src/main/java/com/ruoyi/web/demo/twotable/service/impl/CarServiceImpl.java @@ -0,0 +1,36 @@ +package com.ruoyi.web.demo.twotable.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.ruoyi.web.demo.twotable.entity.Car; +import com.ruoyi.web.demo.twotable.entity.CarModel; +import com.ruoyi.web.demo.twotable.mapper.CarMapper; +import com.ruoyi.web.demo.twotable.service.ICarModelService; +import com.ruoyi.web.demo.twotable.service.ICarService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.io.Serializable; +import java.util.Collection; + +@Transactional +@Service("carService") +public class CarServiceImpl extends ServiceImpl implements ICarService { + @Autowired + private ICarModelService carModelService; + + @Override + public boolean removeById(Serializable id) { + carModelService.remove(new QueryWrapper().eq("car_id",id)); + return super.removeById(id); + } + + @Override + public boolean removeByIds(Collection idList) { + idList.forEach(id ->{ + removeById(id); + }); + return true; + } +} diff --git a/ruoyi-base-support/ruoyi-common/pom.xml b/ruoyi-base-support/ruoyi-common/pom.xml new file mode 100644 index 0000000..583f81c --- /dev/null +++ b/ruoyi-base-support/ruoyi-common/pom.xml @@ -0,0 +1,261 @@ + + + + ruoyi-base-support + com.ruoyi + 3.7.0 + + 4.0.0 + + ruoyi-common + + + common通用工具 + + + + + + + org.springframework + spring-context-support + + + + + org.springframework + spring-web + + + + + org.springframework.boot + spring-boot-starter-security + + + + + com.github.pagehelper + pagehelper-spring-boot-starter + + + + + com.baomidou + mybatis-plus-boot-starter + + + com.baomidou + mybatis-plus-extension + + + + + javax.validation + validation-api + + + + + org.apache.commons + commons-lang3 + + + + + com.fasterxml.jackson.core + jackson-databind + + + + + com.alibaba + fastjson + + + + + commons-io + commons-io + + + + + commons-fileupload + commons-fileupload + + + + + org.apache.poi + poi-ooxml + + + + + org.yaml + snakeyaml + + + + + io.jsonwebtoken + jjwt + + + + + org.springframework.boot + spring-boot-starter-data-redis + + + + + org.apache.commons + commons-pool2 + + + + + eu.bitwalker + UserAgentUtils + + + + + javax.servlet + javax.servlet-api + + + javax.xml.bind + jaxb-api + 2.3.0 + + + com.sun.xml.bind + jaxb-impl + 2.3.0 + + + com.sun.xml.bind + jaxb-core + 2.3.0 + + + javax.activation + activation + 1.1.1 + + + org.projectlombok + lombok + + + + cn.hutool + hutool-all + 5.3.7 + + + + com.documents4j + documents4j-local + 1.0.3 + + + com.documents4j + documents4j-transformer-msoffice-word + 1.0.3 + + + + com.deepoove + poi-tl + 1.8.0 + + + + + org.jodconverter + jodconverter-core + 4.1.0 + + + org.jodconverter + jodconverter-local + 4.1.0 + + + org.jodconverter + jodconverter-spring-boot-starter + 4.1.0 + + + org.libreoffice + juh + 5.4.2 + + + org.libreoffice + jurt + 5.4.2 + + + org.libreoffice + ridl + 5.4.2 + + + org.libreoffice + unoil + 5.4.2 + + + com.google.code.gson + gson + 2.8.2 + + + + com.tencentcloudapi + tencentcloud-sdk-java + 3.1.1065 + + + + com.aspose + aspose-words + 15.8.0-jdk16 + + + + + io.goeasy + goeasy-sdk + 0.4.2 + + + com.qcloud + cos-sts_api + 3.1.0 + compile + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.6.1 + + 1.8 + 1.8 + + + + + + diff --git a/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/annotation/CreateBy.java b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/annotation/CreateBy.java new file mode 100644 index 0000000..c0cdb71 --- /dev/null +++ b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/annotation/CreateBy.java @@ -0,0 +1,17 @@ +package com.ruoyi.common.annotation; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * 自动设置创建人 + */ +@Retention(RetentionPolicy.RUNTIME) +@Target({ElementType.FIELD}) +public @interface CreateBy { + String value() default ""; +} + + diff --git a/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/annotation/CreateTime.java b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/annotation/CreateTime.java new file mode 100644 index 0000000..ee987be --- /dev/null +++ b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/annotation/CreateTime.java @@ -0,0 +1,16 @@ +package com.ruoyi.common.annotation; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * 自动设置创建时间 + */ +@Retention(RetentionPolicy.RUNTIME) +@Target({ElementType.FIELD}) +public @interface CreateTime { + String value() default ""; +} + diff --git a/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/annotation/DataScope.java b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/annotation/DataScope.java new file mode 100644 index 0000000..5dd8c34 --- /dev/null +++ b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/annotation/DataScope.java @@ -0,0 +1,24 @@ +package com.ruoyi.common.annotation; + +import java.lang.annotation.*; + +/** + * 数据权限过滤注解 + * + * @author ruoyi + */ +@Target(ElementType.METHOD) +@Retention(RetentionPolicy.RUNTIME) +@Documented +public @interface DataScope +{ + /** + * 部门表的别名 + */ + public String deptAlias() default ""; + + /** + * 用户表的别名 + */ + public String userAlias() default ""; +} diff --git a/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/annotation/DataSource.java b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/annotation/DataSource.java new file mode 100644 index 0000000..5287cd2 --- /dev/null +++ b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/annotation/DataSource.java @@ -0,0 +1,24 @@ +package com.ruoyi.common.annotation; + +import com.ruoyi.common.enums.DataSourceType; + +import java.lang.annotation.*; + +/** + * 自定义多数据源切换注解 + * + * 优先级:先方法,后类,如果方法覆盖了类上的数据源类型,以方法的为准,否则以类上的为准 + * + * @author ruoyi + */ +@Target({ ElementType.METHOD, ElementType.TYPE }) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Inherited +public @interface DataSource +{ + /** + * 切换数据源名称 + */ + public DataSourceType value() default DataSourceType.MASTER; +} diff --git a/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/annotation/Excel.java b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/annotation/Excel.java new file mode 100644 index 0000000..bdba091 --- /dev/null +++ b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/annotation/Excel.java @@ -0,0 +1,177 @@ +package com.ruoyi.common.annotation; + +import com.ruoyi.common.utils.poi.ExcelHandlerAdapter; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; +import java.math.BigDecimal; + +/** + * 自定义导出Excel数据注解 + * + * @author ruoyi + */ +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.FIELD) +public @interface Excel +{ + /** + * 导出时在excel中排序 + */ + public int sort() default Integer.MAX_VALUE; + + /** + * 导出到Excel中的名字. + */ + public String name() default ""; + + /** + * 日期格式, 如: yyyy-MM-dd + */ + public String dateFormat() default ""; + + /** + * 如果是字典类型,请设置字典的type值 (如: sys_user_sex) + */ + public String dictType() default ""; + + /** + * 读取内容转表达式 (如: 0=男,1=女,2=未知) + */ + public String readConverterExp() default ""; + + /** + * 分隔符,读取字符串组内容 + */ + public String separator() default ","; + + /** + * BigDecimal 精度 默认:-1(默认不开启BigDecimal格式化) + */ + public int scale() default -1; + + /** + * BigDecimal 舍入规则 默认:BigDecimal.ROUND_HALF_EVEN + */ + public int roundingMode() default BigDecimal.ROUND_HALF_EVEN; + + /** + * 导出类型(0数字 1字符串) + */ + public ColumnType cellType() default ColumnType.STRING; + + /** + * 导出时在excel中每个列的高度 单位为字符 + */ + public double height() default 14; + + /** + * 导出时在excel中每个列的宽 单位为字符 + */ + public double width() default 16; + + /** + * 文字后缀,如% 90 变成90% + */ + public String suffix() default ""; + + /** + * 当值为空时,字段的默认值 + */ + public String defaultValue() default ""; + + /** + * 提示信息 + */ + public String prompt() default ""; + + /** + * 设置只能选择不能输入的列内容. + */ + public String[] combo() default {}; + + /** + * 是否导出数据,应对需求:有时我们需要导出一份模板,这是标题需要但内容需要用户手工填写. + */ + public boolean isExport() default true; + + /** + * 另一个类中的属性名称,支持多级获取,以小数点隔开 + */ + public String targetAttr() default ""; + + /** + * 是否自动统计数据,在最后追加一行统计数据总和 + */ + public boolean isStatistics() default false; + + /** + * 导出字段对齐方式(0:默认;1:靠左;2:居中;3:靠右) + */ + public Align align() default Align.AUTO; + + /** + * 自定义数据处理器 + */ + public Class handler() default ExcelHandlerAdapter.class; + + /** + * 自定义数据处理器参数 + */ + public String[] args() default {}; + + public enum Align + { + AUTO(0), LEFT(1), CENTER(2), RIGHT(3); + private final int value; + + Align(int value) + { + this.value = value; + } + + public int value() + { + return this.value; + } + } + + /** + * 字段类型(0:导出导入;1:仅导出;2:仅导入) + */ + Type type() default Type.ALL; + + public enum Type + { + ALL(0), EXPORT(1), IMPORT(2); + private final int value; + + Type(int value) + { + this.value = value; + } + + public int value() + { + return this.value; + } + } + + public enum ColumnType + { + NUMERIC(0), STRING(1), IMAGE(2); + private final int value; + + ColumnType(int value) + { + this.value = value; + } + + public int value() + { + return this.value; + } + } +} \ No newline at end of file diff --git a/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/annotation/Excels.java b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/annotation/Excels.java new file mode 100644 index 0000000..1f1cc81 --- /dev/null +++ b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/annotation/Excels.java @@ -0,0 +1,18 @@ +package com.ruoyi.common.annotation; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * Excel注解集 + * + * @author ruoyi + */ +@Target(ElementType.FIELD) +@Retention(RetentionPolicy.RUNTIME) +public @interface Excels +{ + public Excel[] value(); +} diff --git a/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/annotation/Log.java b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/annotation/Log.java new file mode 100644 index 0000000..22d7e85 --- /dev/null +++ b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/annotation/Log.java @@ -0,0 +1,43 @@ +package com.ruoyi.common.annotation; + +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.common.enums.OperatorType; + +import java.lang.annotation.*; + +/** + * 自定义操作日志记录注解 + * + * @author ruoyi + * + */ +@Target({ ElementType.PARAMETER, ElementType.METHOD }) +@Retention(RetentionPolicy.RUNTIME) +@Documented +public @interface Log +{ + /** + * 模块 + */ + public String title() default ""; + + /** + * 功能 + */ + public BusinessType businessType() default BusinessType.OTHER; + + /** + * 操作人类别 + */ + public OperatorType operatorType() default OperatorType.MANAGE; + + /** + * 是否保存请求的参数 + */ + public boolean isSaveRequestData() default true; + + /** + * 是否保存响应的参数 + */ + public boolean isSaveResponseData() default true; +} diff --git a/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/annotation/RateLimiter.java b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/annotation/RateLimiter.java new file mode 100644 index 0000000..b3b4a1e --- /dev/null +++ b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/annotation/RateLimiter.java @@ -0,0 +1,37 @@ +package com.ruoyi.common.annotation; + +import com.ruoyi.common.constant.Constants; +import com.ruoyi.common.enums.LimitType; + +import java.lang.annotation.*; + +/** + * 限流注解 + * + * @author ruoyi + */ +@Target(ElementType.METHOD) +@Retention(RetentionPolicy.RUNTIME) +@Documented +public @interface RateLimiter +{ + /** + * 限流key + */ + public String key() default Constants.RATE_LIMIT_KEY; + + /** + * 限流时间,单位秒 + */ + public int time() default 60; + + /** + * 限流次数 + */ + public int count() default 100; + + /** + * 限流类型 + */ + public LimitType limitType() default LimitType.DEFAULT; +} diff --git a/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/annotation/RepeatSubmit.java b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/annotation/RepeatSubmit.java new file mode 100644 index 0000000..4247593 --- /dev/null +++ b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/annotation/RepeatSubmit.java @@ -0,0 +1,26 @@ +package com.ruoyi.common.annotation; + +import java.lang.annotation.*; + +/** + * 自定义注解防止表单重复提交 + * + * @author ruoyi + * + */ +@Inherited +@Target(ElementType.METHOD) +@Retention(RetentionPolicy.RUNTIME) +@Documented +public @interface RepeatSubmit +{ + /** + * 间隔时间(ms),小于此时间视为重复提交 + */ + public int interval() default 5000; + + /** + * 提示消息 + */ + public String message() default "不允许重复提交,请稍后再试"; +} diff --git a/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/annotation/UpdateBy.java b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/annotation/UpdateBy.java new file mode 100644 index 0000000..0d559ca --- /dev/null +++ b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/annotation/UpdateBy.java @@ -0,0 +1,16 @@ +package com.ruoyi.common.annotation; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * 自动设置修改人 + */ +@Retention(RetentionPolicy.RUNTIME) +@Target({ElementType.FIELD}) +public @interface UpdateBy { + String value() default ""; +} + diff --git a/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/annotation/UpdateTime.java b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/annotation/UpdateTime.java new file mode 100644 index 0000000..9ed936f --- /dev/null +++ b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/annotation/UpdateTime.java @@ -0,0 +1,16 @@ +package com.ruoyi.common.annotation; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * 自动设置修改时间 + */ +@Retention(RetentionPolicy.RUNTIME) +@Target({ElementType.FIELD}) +public @interface UpdateTime { + String value() default ""; +} + diff --git a/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/config/RuoYiConfig.java b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/config/RuoYiConfig.java new file mode 100644 index 0000000..faf25be --- /dev/null +++ b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/config/RuoYiConfig.java @@ -0,0 +1,124 @@ +package com.ruoyi.common.config; + +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.stereotype.Component; + +/** + * 读取项目相关配置 + * + * @author ruoyi + */ +@Component +@ConfigurationProperties(prefix = "ruoyi") +public class RuoYiConfig +{ + /** 项目名称 */ + private String name; + + /** 版本 */ + private String version; + + /** 版权年份 */ + private String copyrightYear; + + /** 实例演示开关 */ + private boolean demoEnabled; + + /** 上传路径 */ + private static String profile; + + /** 获取地址开关 */ + private static boolean addressEnabled; + + public String getName() + { + return name; + } + + public void setName(String name) + { + this.name = name; + } + + public String getVersion() + { + return version; + } + + public void setVersion(String version) + { + this.version = version; + } + + public String getCopyrightYear() + { + return copyrightYear; + } + + public void setCopyrightYear(String copyrightYear) + { + this.copyrightYear = copyrightYear; + } + + public boolean isDemoEnabled() + { + return demoEnabled; + } + + public void setDemoEnabled(boolean demoEnabled) + { + this.demoEnabled = demoEnabled; + } + + public static String getProfile() + { + return profile; + } + + public void setProfile(String profile) + { + RuoYiConfig.profile = profile; + } + + public static boolean isAddressEnabled() + { + return addressEnabled; + } + + public void setAddressEnabled(boolean addressEnabled) + { + RuoYiConfig.addressEnabled = addressEnabled; + } + + /** + * 获取导入上传路径 + */ + public static String getImportPath() + { + return getProfile() + "/import"; + } + + /** + * 获取头像上传路径 + */ + public static String getAvatarPath() + { + return getProfile() + "/avatar"; + } + + /** + * 获取下载路径 + */ + public static String getDownloadPath() + { + return getProfile() + "/download/"; + } + + /** + * 获取上传路径 + */ + public static String getUploadPath() + { + return getProfile() + "/upload"; + } +} diff --git a/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/constant/Constants.java b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/constant/Constants.java new file mode 100644 index 0000000..d36253c --- /dev/null +++ b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/constant/Constants.java @@ -0,0 +1,151 @@ +package com.ruoyi.common.constant; + +import io.jsonwebtoken.Claims; + +/** + * 通用常量信息 + * + * @author ruoyi + */ +public class Constants +{ + /** + * UTF-8 字符集 + */ + public static final String UTF8 = "UTF-8"; + + /** + * GBK 字符集 + */ + public static final String GBK = "GBK"; + + /** + * http请求 + */ + public static final String HTTP = "http://"; + + /** + * https请求 + */ + public static final String HTTPS = "https://"; + + /** + * 通用成功标识 + */ + public static final String SUCCESS = "0"; + + /** + * 通用失败标识 + */ + public static final String FAIL = "1"; + + /** + * 登录成功 + */ + public static final String LOGIN_SUCCESS = "Success"; + + /** + * 注销 + */ + public static final String LOGOUT = "Logout"; + + /** + * 注册 + */ + public static final String REGISTER = "Register"; + + /** + * 登录失败 + */ + public static final String LOGIN_FAIL = "Error"; + + /** + * 验证码 redis key + */ + public static final String CAPTCHA_CODE_KEY = "captcha_codes:"; + + /** + * 登录用户 redis key + */ + public static final String LOGIN_TOKEN_KEY = "login_tokens:"; + + /** + * 防重提交 redis key + */ + public static final String REPEAT_SUBMIT_KEY = "repeat_submit:"; + + /** + * 限流 redis key + */ + public static final String RATE_LIMIT_KEY = "rate_limit:"; + + /** + * 验证码有效期(分钟) + */ + public static final Integer CAPTCHA_EXPIRATION = 2; + + /** + * 令牌 + */ + public static final String TOKEN = "token"; + + /** + * 令牌前缀 + */ + public static final String TOKEN_PREFIX = "Bearer "; + + /** + * 令牌前缀 + */ + public static final String LOGIN_USER_KEY = "login_user_key"; + + /** + * 用户ID + */ + public static final String JWT_USERID = "userid"; + + /** + * 用户名称 + */ + public static final String JWT_USERNAME = Claims.SUBJECT; + + /** + * 用户头像 + */ + public static final String JWT_AVATAR = "avatar"; + + /** + * 创建时间 + */ + public static final String JWT_CREATED = "created"; + + /** + * 用户权限 + */ + public static final String JWT_AUTHORITIES = "authorities"; + + /** + * 参数管理 cache key + */ + public static final String SYS_CONFIG_KEY = "sys_config:"; + + /** + * 字典管理 cache key + */ + public static final String SYS_DICT_KEY = "sys_dict:"; + + /** + * 资源映射路径 前缀 + */ + public static final String RESOURCE_PREFIX = "/profile"; + + /** + * RMI 远程方法调用 + */ + public static final String LOOKUP_RMI = "rmi://"; + + /** + * LDAP 远程方法调用 + */ + public static final String LOOKUP_LDAP = "ldap://"; +} diff --git a/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/constant/GenConstants.java b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/constant/GenConstants.java new file mode 100644 index 0000000..44abbe8 --- /dev/null +++ b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/constant/GenConstants.java @@ -0,0 +1,117 @@ +package com.ruoyi.common.constant; + +/** + * 代码生成通用常量 + * + * @author ruoyi + */ +public class GenConstants +{ + /** 单表(增删改查) */ + public static final String TPL_CRUD = "crud"; + + /** 树表(增删改查) */ + public static final String TPL_TREE = "tree"; + + /** 主子表(增删改查) */ + public static final String TPL_SUB = "sub"; + + /** 树编码字段 */ + public static final String TREE_CODE = "treeCode"; + + /** 树父编码字段 */ + public static final String TREE_PARENT_CODE = "treeParentCode"; + + /** 树名称字段 */ + public static final String TREE_NAME = "treeName"; + + /** 上级菜单ID字段 */ + public static final String PARENT_MENU_ID = "parentMenuId"; + + /** 上级菜单名称字段 */ + public static final String PARENT_MENU_NAME = "parentMenuName"; + + /** 数据库字符串类型 */ + public static final String[] COLUMNTYPE_STR = { "char", "varchar", "nvarchar", "varchar2" }; + + /** 数据库文本类型 */ + public static final String[] COLUMNTYPE_TEXT = { "tinytext", "text", "mediumtext", "longtext" }; + + /** 数据库时间类型 */ + public static final String[] COLUMNTYPE_TIME = { "datetime", "time", "date", "timestamp" }; + + /** 数据库数字类型 */ + public static final String[] COLUMNTYPE_NUMBER = { "tinyint", "smallint", "mediumint", "int", "number", "integer", + "bit", "bigint", "float", "double", "decimal" }; + + /** 数据库数字类型 */ + public static final String[] COLUMNTYPE_INT = { "tinyint", "smallint", "mediumint", "int", "number", "integer"}; + + /** 页面不需要编辑字段 */ + public static final String[] COLUMNNAME_NOT_EDIT = { "id", "create_by", "create_time", "del_flag" }; + + /** 页面不需要显示的列表字段 */ + public static final String[] COLUMNNAME_NOT_LIST = { "id", "create_by", "create_time", "del_flag", "update_by", + "update_time" }; + + /** 页面不需要查询字段 */ + public static final String[] COLUMNNAME_NOT_QUERY = { "id", "create_by", "create_time", "del_flag", "update_by", + "update_time", "remark" }; + + /** Entity基类字段 */ + public static final String[] BASE_ENTITY = { "createBy", "createTime", "updateBy", "updateTime", "remark" }; + + /** Tree基类字段 */ + public static final String[] TREE_ENTITY = { "parentName", "parentId", "orderNum", "ancestors", "children" }; + + /** 文本框 */ + public static final String HTML_INPUT = "input"; + + /** 文本域 */ + public static final String HTML_TEXTAREA = "textarea"; + + /** 下拉框 */ + public static final String HTML_SELECT = "select"; + + /** 单选框 */ + public static final String HTML_RADIO = "radio"; + + /** 复选框 */ + public static final String HTML_CHECKBOX = "checkbox"; + + /** 日期控件 */ + public static final String HTML_DATETIME = "datetime"; + + /** 图片上传控件 */ + public static final String HTML_IMAGE_UPLOAD = "imageUpload"; + + /** 文件上传控件 */ + public static final String HTML_FILE_UPLOAD = "fileUpload"; + + /** 富文本控件 */ + public static final String HTML_EDITOR = "editor"; + + /** 字符串类型 */ + public static final String TYPE_STRING = "String"; + + /** 整型 */ + public static final String TYPE_INTEGER = "Integer"; + + /** 长整型 */ + public static final String TYPE_LONG = "Long"; + + /** 浮点型 */ + public static final String TYPE_DOUBLE = "Double"; + + /** 高精度计算类型 */ + public static final String TYPE_BIGDECIMAL = "BigDecimal"; + + /** 时间类型 */ + public static final String TYPE_DATE = "Date"; + + /** 模糊查询 */ + public static final String QUERY_LIKE = "LIKE"; + + /** 需要 */ + public static final String REQUIRE = "1"; +} diff --git a/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/constant/HttpStatus.java b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/constant/HttpStatus.java new file mode 100644 index 0000000..d60afee --- /dev/null +++ b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/constant/HttpStatus.java @@ -0,0 +1,89 @@ +package com.ruoyi.common.constant; + +/** + * 返回状态码 + * + * @author ruoyi + */ +public class HttpStatus +{ + /** + * 操作成功 + */ + public static final int SUCCESS = 200; + + /** + * 对象创建成功 + */ + public static final int CREATED = 201; + + /** + * 请求已经被接受 + */ + public static final int ACCEPTED = 202; + + /** + * 操作已经执行成功,但是没有返回数据 + */ + public static final int NO_CONTENT = 204; + + /** + * 资源已被移除 + */ + public static final int MOVED_PERM = 301; + + /** + * 重定向 + */ + public static final int SEE_OTHER = 303; + + /** + * 资源没有被修改 + */ + public static final int NOT_MODIFIED = 304; + + /** + * 参数列表错误(缺少,格式不匹配) + */ + public static final int BAD_REQUEST = 400; + + /** + * 未授权 + */ + public static final int UNAUTHORIZED = 401; + + /** + * 访问受限,授权过期 + */ + public static final int FORBIDDEN = 403; + + /** + * 资源,服务未找到 + */ + public static final int NOT_FOUND = 404; + + /** + * 不允许的http方法 + */ + public static final int BAD_METHOD = 405; + + /** + * 资源冲突,或者资源被锁 + */ + public static final int CONFLICT = 409; + + /** + * 不支持的数据,媒体类型 + */ + public static final int UNSUPPORTED_TYPE = 415; + + /** + * 系统内部错误 + */ + public static final int ERROR = 500; + + /** + * 接口未实现 + */ + public static final int NOT_IMPLEMENTED = 501; +} diff --git a/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/constant/ScheduleConstants.java b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/constant/ScheduleConstants.java new file mode 100644 index 0000000..62ad815 --- /dev/null +++ b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/constant/ScheduleConstants.java @@ -0,0 +1,50 @@ +package com.ruoyi.common.constant; + +/** + * 任务调度通用常量 + * + * @author ruoyi + */ +public class ScheduleConstants +{ + public static final String TASK_CLASS_NAME = "TASK_CLASS_NAME"; + + /** 执行目标key */ + public static final String TASK_PROPERTIES = "TASK_PROPERTIES"; + + /** 默认 */ + public static final String MISFIRE_DEFAULT = "0"; + + /** 立即触发执行 */ + public static final String MISFIRE_IGNORE_MISFIRES = "1"; + + /** 触发一次执行 */ + public static final String MISFIRE_FIRE_AND_PROCEED = "2"; + + /** 不触发立即执行 */ + public static final String MISFIRE_DO_NOTHING = "3"; + + public enum Status + { + /** + * 正常 + */ + NORMAL("0"), + /** + * 暂停 + */ + PAUSE("1"); + + private String value; + + private Status(String value) + { + this.value = value; + } + + public String getValue() + { + return value; + } + } +} diff --git a/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/constant/UserConstants.java b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/constant/UserConstants.java new file mode 100644 index 0000000..4ed6009 --- /dev/null +++ b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/constant/UserConstants.java @@ -0,0 +1,78 @@ +package com.ruoyi.common.constant; + +/** + * 用户常量信息 + * + * @author ruoyi + */ +public class UserConstants +{ + /** + * 平台内系统用户的唯一标志 + */ + public static final String SYS_USER = "SYS_USER"; + + /** 正常状态 */ + public static final String NORMAL = "0"; + + /** 异常状态 */ + public static final String EXCEPTION = "1"; + + /** 用户封禁状态 */ + public static final String USER_DISABLE = "1"; + + /** 角色封禁状态 */ + public static final String ROLE_DISABLE = "1"; + + /** 部门正常状态 */ + public static final String DEPT_NORMAL = "0"; + + /** 部门停用状态 */ + public static final String DEPT_DISABLE = "1"; + + /** 字典正常状态 */ + public static final String DICT_NORMAL = "0"; + + /** 是否为系统默认(是) */ + public static final String YES = "Y"; + + /** 是否菜单外链(是) */ + public static final String YES_FRAME = "0"; + + /** 是否菜单外链(否) */ + public static final String NO_FRAME = "1"; + + /** 菜单类型(目录) */ + public static final String TYPE_DIR = "M"; + + /** 菜单类型(菜单) */ + public static final String TYPE_MENU = "C"; + + /** 菜单类型(按钮) */ + public static final String TYPE_BUTTON = "F"; + + /** Layout组件标识 */ + public final static String LAYOUT = "Layout"; + + /** ParentView组件标识 */ + public final static String PARENT_VIEW = "ParentView"; + + /** InnerLink组件标识 */ + public final static String INNER_LINK = "InnerLink"; + + /** 校验返回结果码 */ + public final static String UNIQUE = "0"; + public final static String NOT_UNIQUE = "1"; + + /** + * 用户名长度限制 + */ + public static final int USERNAME_MIN_LENGTH = 2; + public static final int USERNAME_MAX_LENGTH = 20; + + /** + * 密码长度限制 + */ + public static final int PASSWORD_MIN_LENGTH = 5; + public static final int PASSWORD_MAX_LENGTH = 20; +} diff --git a/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/core/controller/BaseController.java b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/core/controller/BaseController.java new file mode 100644 index 0000000..76c19bc --- /dev/null +++ b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/core/controller/BaseController.java @@ -0,0 +1,209 @@ +package com.ruoyi.common.core.controller; + +import java.beans.PropertyEditorSupport; +import java.util.Date; +import java.util.List; + +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.ruoyi.common.core.domain.AjaxResult; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.web.bind.WebDataBinder; +import org.springframework.web.bind.annotation.InitBinder; +import com.github.pagehelper.PageHelper; +import com.github.pagehelper.PageInfo; +import com.ruoyi.common.constant.HttpStatus; +import com.ruoyi.common.core.domain.model.LoginUser; +import com.ruoyi.common.core.page.PageDomain; +import com.ruoyi.common.core.page.TableDataInfo; +import com.ruoyi.common.core.page.TableSupport; +import com.ruoyi.common.utils.DateUtils; +import com.ruoyi.common.utils.SecurityUtils; +import com.ruoyi.common.utils.StringUtils; +import com.ruoyi.common.utils.sql.SqlUtil; + +/** + * web层通用数据处理 + * + * @author ruoyi + */ +public class BaseController +{ + protected final Logger logger = LoggerFactory.getLogger(this.getClass()); + + /** + * 将前台传递过来的日期格式的字符串,自动转化为Date类型 + */ + @InitBinder + public void initBinder(WebDataBinder binder) + { + // Date 类型转换 + binder.registerCustomEditor(Date.class, new PropertyEditorSupport() + { + @Override + public void setAsText(String text) + { + setValue(DateUtils.parseDate(text)); + } + }); + } + + /** + * 设置请求分页数据 + */ + protected void startPage() + { + PageDomain pageDomain = TableSupport.buildPageRequest(); + Integer pageNum = pageDomain.getPageNum(); + Integer pageSize = pageDomain.getPageSize(); + if (StringUtils.isNotNull(pageNum) && StringUtils.isNotNull(pageSize)) + { + String orderBy = SqlUtil.escapeOrderBySql(pageDomain.getOrderBy()); + Boolean reasonable = pageDomain.getReasonable(); + PageHelper.startPage(pageNum, pageSize, orderBy).setReasonable(reasonable); + } + } + + /** + * 设置请求排序数据 + */ + protected void startOrderBy() + { + PageDomain pageDomain = TableSupport.buildPageRequest(); + if (StringUtils.isNotEmpty(pageDomain.getOrderBy())) + { + String orderBy = SqlUtil.escapeOrderBySql(pageDomain.getOrderBy()); + PageHelper.orderBy(orderBy); + } + } + + /** + * 响应请求分页数据 + */ + @SuppressWarnings({ "rawtypes", "unchecked" }) + protected TableDataInfo getDataTable(List list) + { + TableDataInfo rspData = new TableDataInfo(); + rspData.setCode(HttpStatus.SUCCESS); + rspData.setMsg("查询成功"); + rspData.setRows(list); + Long total = new PageInfo(list).getTotal(); + rspData.setTotal(total.intValue()); + return rspData; + } + protected TableDataInfo getDataTable(Page page) + { + TableDataInfo rspData = new TableDataInfo(); + rspData.setCode(HttpStatus.SUCCESS); + rspData.setMsg("查询成功"); + rspData.setRows(page.getRecords()); + Long total = new PageInfo(page.getRecords()).getTotal(); + rspData.setTotal(total.intValue()); + return rspData; + } + + /** + * 返回成功 + */ + public AjaxResult success() + { + return AjaxResult.success(); + } + + /** + * 返回失败消息 + */ + public AjaxResult error() + { + return AjaxResult.error(); + } + + /** + * 返回成功消息 + */ + public AjaxResult success(String message) + { + return AjaxResult.success(message); + } + + /** + * 返回失败消息 + */ + public AjaxResult error(String message) + { + return AjaxResult.error(message); + } + + /** + * 响应返回结果 + * + * @param rows 影响行数 + * @return 操作结果 + */ + protected AjaxResult toAjax(int rows) + { + return rows > 0 ? AjaxResult.success() : AjaxResult.error(); + } + + /** + * 响应返回结果 + * + * @param result 结果 + * @return 操作结果 + */ + protected AjaxResult toAjax(boolean result) + { + return result ? success() : error(); + } + + /** + * 页面跳转 + */ + public String redirect(String url) + { + return StringUtils.format("redirect:{}", url); + } + + /** + * 获取用户缓存信息 + */ + public LoginUser getLoginUser() + { + return SecurityUtils.getLoginUser(); + } + + /** + * 获取登录用户id + */ + public Long getUserId() + { + return getLoginUser().getUserId(); + } + + /** + * 获取登录部门id + */ + public String getDeptId() + { + return getLoginUser().getDeptId(); + } + + /** + * 获取登录用户名 + */ + public String getUsername() + { + return getLoginUser().getUsername(); + } + + /** + * 获取登录用户名 + */ + public Page getPage() { + PageDomain pageDomain = TableSupport.buildPageRequest(); + Integer pageNum = pageDomain.getPageNum(); + Integer pageSize = pageDomain.getPageSize(); + return new Page(pageNum, pageSize); + } + +} diff --git a/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/AjaxResult.java b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/AjaxResult.java new file mode 100644 index 0000000..cce5155 --- /dev/null +++ b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/AjaxResult.java @@ -0,0 +1,160 @@ +package com.ruoyi.common.core.domain; + +import java.util.Date; +import java.util.HashMap; + +import com.fasterxml.jackson.annotation.JsonFormat; +import com.ruoyi.common.constant.HttpStatus; +import com.ruoyi.common.utils.StringUtils; +import lombok.Data; + +/** + * 操作消息提醒 + * + * @author ruoyi + */ +@Data +public class AjaxResult +{ + private static final long serialVersionUID = 1L; + + /** + * 响应状态码 + */ + private Integer code; + + /** + * 响应信息 + */ + private String msg; + + /** + * 响应对象 + */ + private T data; + + private Date currentTime = new Date(); + + /** + * 初始化一个新创建的 AjaxResult 对象,使其表示一个空消息。 + */ + public AjaxResult() + { + } + + /** + * 初始化一个新创建的 AjaxResult 对象 + * + * @param code 状态码 + * @param msg 返回内容 + */ + public AjaxResult(int code, String msg) + { + this.code = code; + this.msg = msg; + this.currentTime = new Date(); + } + + /** + * 初始化一个新创建的 AjaxResult 对象 + * + * @param code 状态码 + * @param msg 返回内容 + * @param data 数据对象 + */ + public AjaxResult(int code, String msg, T data) + { + this.code = code; + this.msg = msg; + this.data = data; + this.currentTime = new Date(); + } + + /** + * 返回成功消息 + * + * @return 成功消息 + */ + public static AjaxResult success() + { + return AjaxResult.success("操作成功"); + } + + /** + * 返回成功数据 + * + * @return 成功消息 + */ + public static AjaxResult success(Object data) + { + return AjaxResult.success("操作成功", data); + } + + /** + * 返回成功消息 + * + * @param msg 返回内容 + * @return 成功消息 + */ + public static AjaxResult success(String msg) + { + return AjaxResult.success(msg, null); + } + + /** + * 返回成功消息 + * + * @param msg 返回内容 + * @param data 数据对象 + * @return 成功消息 + */ + public static AjaxResult success(String msg, Object data) + { + return new AjaxResult(HttpStatus.SUCCESS, msg, data); + } + + /** + * 返回错误消息 + * + * @return + */ + public static AjaxResult error() + { + return AjaxResult.error("操作失败"); + } + + /** + * 返回错误消息 + * + * @param msg 返回内容 + * @return 警告消息 + */ + public static AjaxResult error(String msg) + { + return AjaxResult.error(msg, null); + } + + /** + * 返回错误消息 + * + * @param msg 返回内容 + * @param data 数据对象 + * @return 警告消息 + */ + public static AjaxResult error(String msg, Object data) + { + return new AjaxResult(HttpStatus.ERROR, msg, data); + } + + /** + * 返回错误消息 + * + * @param code 状态码 + * @param msg 返回内容 + * @return 警告消息 + */ + public static AjaxResult error(int code, String msg) + { + return new AjaxResult(code, msg, null); + } +} \ No newline at end of file diff --git a/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/AjaxResultMap.java b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/AjaxResultMap.java new file mode 100644 index 0000000..3a6ad24 --- /dev/null +++ b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/AjaxResultMap.java @@ -0,0 +1,149 @@ +package com.ruoyi.common.core.domain; + +import com.ruoyi.common.constant.HttpStatus; +import com.ruoyi.common.utils.StringUtils; + +import java.util.HashMap; + +/** + * 操作消息提醒 + * + * @author ruoyi + */ +public class AjaxResultMap extends HashMap +{ + private static final long serialVersionUID = 1L; + + /** 状态码 */ + public static final String CODE_TAG = "code"; + + /** 返回内容 */ + public static final String MSG_TAG = "msg"; + + /** 数据对象 */ + public static final String DATA_TAG = "data"; + + /** + * 初始化一个新创建的 AjaxResult 对象,使其表示一个空消息。 + */ + public AjaxResultMap() + { + } + + /** + * 初始化一个新创建的 AjaxResult 对象 + * + * @param code 状态码 + * @param msg 返回内容 + */ + public AjaxResultMap(int code, String msg) + { + super.put(CODE_TAG, code); + super.put(MSG_TAG, msg); + } + + /** + * 初始化一个新创建的 AjaxResult 对象 + * + * @param code 状态码 + * @param msg 返回内容 + * @param data 数据对象 + */ + public AjaxResultMap(int code, String msg, T data) + { + super.put(CODE_TAG, code); + super.put(MSG_TAG, msg); + if (StringUtils.isNotNull(data)) + { + super.put(DATA_TAG, data); + } + } + + /** + * 返回成功消息 + * + * @return 成功消息 + */ + public static AjaxResultMap success() + { + return AjaxResultMap.success("操作成功"); + } + + /** + * 返回成功数据 + * + * @return 成功消息 + */ + public static AjaxResultMap success(Object data) + { + return AjaxResultMap.success("操作成功", data); + } + + /** + * 返回成功消息 + * + * @param msg 返回内容 + * @return 成功消息 + */ + public static AjaxResultMap success(String msg) + { + return AjaxResultMap.success(msg, null); + } + + /** + * 返回成功消息 + * + * @param msg 返回内容 + * @param data 数据对象 + * @return 成功消息 + */ + public static AjaxResultMap success(String msg, Object data) + { + return new AjaxResultMap(HttpStatus.SUCCESS, msg, data); + } + + /** + * 返回错误消息 + * + * @return + */ + public static AjaxResultMap error() + { + return AjaxResultMap.error("操作失败"); + } + + /** + * 返回错误消息 + * + * @param msg 返回内容 + * @return 警告消息 + */ + public static AjaxResultMap error(String msg) + { + return AjaxResultMap.error(msg, null); + } + + /** + * 返回错误消息 + * + * @param msg 返回内容 + * @param data 数据对象 + * @return 警告消息 + */ + public static AjaxResultMap error(String msg, Object data) + { + return new AjaxResultMap(HttpStatus.ERROR, msg, data); + } + + /** + * 返回错误消息 + * + * @param code 状态码 + * @param msg 返回内容 + * @return 警告消息 + */ + public static AjaxResultMap error(int code, String msg) + { + return new AjaxResultMap(code, msg, null); + } +} \ No newline at end of file diff --git a/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/BaseEntity.java b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/BaseEntity.java new file mode 100644 index 0000000..c538b10 --- /dev/null +++ b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/BaseEntity.java @@ -0,0 +1,80 @@ +package com.ruoyi.common.core.domain; + +import java.io.Serializable; +import java.util.Date; +import java.util.HashMap; +import java.util.Map; + +import com.baomidou.mybatisplus.annotation.TableField; +import com.fasterxml.jackson.annotation.JsonFormat; +import com.ruoyi.common.annotation.CreateBy; +import com.ruoyi.common.annotation.CreateTime; +import com.ruoyi.common.annotation.UpdateBy; +import com.ruoyi.common.annotation.UpdateTime; +import com.ruoyi.common.utils.SecurityUtils; +import lombok.Data; +import lombok.experimental.Accessors; + +/** + * Entity基类 + * + * @author ruoyi + */ +@Data +@Accessors(chain = true) +public class BaseEntity implements Serializable +{ + private static final long serialVersionUID = 1L; + + /** 搜索值 */ + @TableField(exist = false) + private String searchValue; + + /** 创建者 */ + @CreateBy + private String createBy; + + /** 创建时间 */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @CreateTime + private Date createTime; + + /** 更新者 */ + @UpdateBy + private String updateBy; + + /** 更新时间 */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @UpdateTime + private Date updateTime; + + /** 备注 */ + @TableField(exist = false) + private String remark; + + /** 请求参数 */ + @TableField(exist = false) + private Map params; + + + + public Map getParams() + { + if (params == null) + { + params = new HashMap<>(); + } + return params; + } + + public void setCreateData() + { + this.createBy = SecurityUtils.getUserId().toString(); + this.createTime = new Date(); + } + public void setUpdateData() + { + this.updateBy = SecurityUtils.getUserId().toString(); + this.updateTime = new Date(); + } +} diff --git a/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/TreeEntity.java b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/TreeEntity.java new file mode 100644 index 0000000..b176238 --- /dev/null +++ b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/TreeEntity.java @@ -0,0 +1,37 @@ +package com.ruoyi.common.core.domain; + +import com.baomidou.mybatisplus.annotation.TableField; +import com.ruoyi.common.utils.StringUtils; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.util.ArrayList; +import java.util.List; + +/** + * Tree基类 + * + * @author ruoyi + */ +@EqualsAndHashCode(callSuper = true) +@Data +public abstract class TreeEntity extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + + /** 父部门ID */ + protected String parentId = "0"; + + /** 祖级列表 */ + protected String ancestors = "0,"; + + public abstract String getId(); + + public String makeSelfAsNewParentIds() { + if (StringUtils.isEmpty(getAncestors())) { + return getId() + ","; + } + return getAncestors() + getId() + ","; + } +} diff --git a/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/TreeSelect.java b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/TreeSelect.java new file mode 100644 index 0000000..9cda3cf --- /dev/null +++ b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/TreeSelect.java @@ -0,0 +1,79 @@ +package com.ruoyi.common.core.domain; + +import java.io.Serializable; +import java.util.List; +import java.util.stream.Collectors; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.ruoyi.common.core.domain.entity.SysDept; +import com.ruoyi.common.core.domain.entity.SysMenu; +import lombok.Data; + +/** + * Treeselect树结构实体类 + * + * @author ruoyi + */ +@Data +public class TreeSelect implements Serializable +{ + private static final long serialVersionUID = 1L; + + /** 节点ID */ + private String id; + + /** 节点名称 */ + private String label; + + /** 子节点 */ + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private List children; + + public TreeSelect() + { + + } + + public TreeSelect(SysDept dept) + { + this.id = dept.getDeptId(); + this.label = dept.getDeptName(); + this.children = dept.getChildren().stream().map(TreeSelect::new).collect(Collectors.toList()); + } + + public TreeSelect(SysMenu menu) + { + this.id = menu.getMenuId().toString(); + this.label = menu.getMenuName(); + this.children = menu.getChildren().stream().map(TreeSelect::new).collect(Collectors.toList()); + } + + public String getId() + { + return id; + } + + public void setId(String id) + { + this.id = id; + } + + public String getLabel() + { + return label; + } + + public void setLabel(String label) + { + this.label = label; + } + + public List getChildren() + { + return children; + } + + public void setChildren(List children) + { + this.children = children; + } +} diff --git a/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SysDataRule.java b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SysDataRule.java new file mode 100644 index 0000000..4b3f872 --- /dev/null +++ b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SysDataRule.java @@ -0,0 +1,55 @@ +package com.ruoyi.common.core.domain.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import com.ruoyi.common.core.domain.BaseEntity; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * All rights Reserved, Designed By www.sunseagear.com + * + * @version V1.0 + * @package sys + * @title: 数据权限表控制器 + * @description: 数据权限表控制器 + * @author: 未知 + * @date: 2019-11-29 06:05:01 + * @copyright: www.sunseagear.com Inc. All rights reserved. + */ + +@EqualsAndHashCode(callSuper = true) +@Data +@TableName("sys_data_rule") +@SuppressWarnings("serial") +public class SysDataRule extends BaseEntity { + + + @TableId(value = "id", type = IdType.AUTO) + private String id; //id + @TableField(value = "resource_code") + private String resourceCode; //资源编号 + @TableField(value = "scope_name") + private String scopeName; //数据权限名称 + @TableField(value = "scope_field") + private String scopeField; //数据权限字段 + @TableField(value = "scope_class") + private String scopeClass; //数据权限类名 + @TableField(value = "scope_column") + private String scopeColumn; //数据权限字段 + @TableField(value = "table_name") + private String tableName; //数据权限关联表名 + @TableField(value = "scope_type") + private String scopeType; //数据权限类型 + @TableField(value = "scope_value") + private String scopeValue; //数据权限值域 + @TableField(value = "user_column") + private String userColumn; //用户表对应字段 + @TableField(value = "user_entity_field") + private String userEntityField; //用户实体类对应字段 + + @TableField(exist = false) + private boolean select; //是否选择 +} diff --git a/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SysDept.java b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SysDept.java new file mode 100644 index 0000000..692bb77 --- /dev/null +++ b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SysDept.java @@ -0,0 +1,112 @@ +package com.ruoyi.common.core.domain.entity; + +import com.ruoyi.common.core.domain.TreeEntity; +import lombok.Data; +import lombok.EqualsAndHashCode; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; + +import javax.validation.constraints.Email; +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.Size; +import java.util.ArrayList; +import java.util.List; + +/** + * 部门表 sys_dept + * + * @author ruoyi + */ +@EqualsAndHashCode(callSuper = true) +@Data +public class SysDept extends TreeEntity +{ + private static final long serialVersionUID = 1L; + + /** 部门ID */ + private String deptId; + + /** 部门名称 */ + private String deptName; + + /** 显示顺序 */ + private String orderNum; + + /** 负责人 */ + private String leader; + + /** 联系电话 */ + private String phone; + + /** 邮箱 */ + private String email; + + /** 部门状态:0正常,1停用 */ + private String status; + + /** 删除标志(0代表存在 2代表删除) */ + private String delFlag; + + /** 父部门名称 */ + private String parentName; + + /** 租户ID */ + private String tenantId; + + /** 子部门 */ + private List children = new ArrayList(); + + @NotBlank(message = "部门名称不能为空") + @Size(min = 0, max = 30, message = "部门名称长度不能超过30个字符") + public String getDeptName() + { + return deptName; + } + + + @NotBlank(message = "显示顺序不能为空") + public String getOrderNum() + { + return orderNum; + } + + + @Size(min = 0, max = 11, message = "联系电话长度不能超过11个字符") + public String getPhone() + { + return phone; + } + + + @Email(message = "邮箱格式不正确") + @Size(min = 0, max = 50, message = "邮箱长度不能超过50个字符") + public String getEmail() + { + return email; + } + + @Override + public String toString() { + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) + .append("deptId", getDeptId()) + .append("parentId", getParentId()) + .append("ancestors", getAncestors()) + .append("deptName", getDeptName()) + .append("orderNum", getOrderNum()) + .append("leader", getLeader()) + .append("phone", getPhone()) + .append("email", getEmail()) + .append("status", getStatus()) + .append("delFlag", getDelFlag()) + .append("createBy", getCreateBy()) + .append("createTime", getCreateTime()) + .append("updateBy", getUpdateBy()) + .append("updateTime", getUpdateTime()) + .toString(); + } + + @Override + public String getId() { + return getDeptId(); + } +} diff --git a/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SysDictData.java b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SysDictData.java new file mode 100644 index 0000000..6a37a2a --- /dev/null +++ b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SysDictData.java @@ -0,0 +1,200 @@ +package com.ruoyi.common.core.domain.entity; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.Size; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.annotation.Excel.ColumnType; +import com.ruoyi.common.constant.UserConstants; +import com.ruoyi.common.core.domain.BaseEntity; + +import java.util.List; + +/** + * 字典数据表 sys_dict_data + * + * @author ruoyi + */ +public class SysDictData extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** 字典编码 */ + @Excel(name = "字典编码", cellType = ColumnType.NUMERIC) + private Long dictCode; + + /** 字典排序 */ + @Excel(name = "字典排序", cellType = ColumnType.NUMERIC) + private Long dictSort; + + /** 字典标签 */ + @Excel(name = "字典标签") + private String dictLabel; + + /** 字典键值 */ + @Excel(name = "字典键值") + private String dictValue; + + /** 字典类型 */ + @Excel(name = "字典类型") + private String dictType; + + /** 样式属性(其他样式扩展) */ + private String cssClass; + + /** 表格字典样式 */ + private String listClass; + + /** 是否默认(Y是 N否) */ + @Excel(name = "是否默认", readConverterExp = "Y=是,N=否") + private String isDefault; + + /** 状态(0正常 1停用) */ + @Excel(name = "状态", readConverterExp = "0=正常,1=停用") + private String status; + + /**字典编码唯一*/ + private String code; + + /**图片*/ + private String images; + + public String getCode() { + return code; + } + + public void setCode(String code) { + this.code = code; + } + + public String getImages() { + return images; + } + + public void setImages(String images) { + this.images = images; + } + + public Long getDictCode() + { + return dictCode; + } + + public void setDictCode(Long dictCode) + { + this.dictCode = dictCode; + } + + public Long getDictSort() + { + return dictSort; + } + + public void setDictSort(Long dictSort) + { + this.dictSort = dictSort; + } + + @NotBlank(message = "字典标签不能为空") + @Size(min = 0, max = 1000, message = "字典标签长度不能超过1000个字符") + public String getDictLabel() + { + return dictLabel; + } + + public void setDictLabel(String dictLabel) + { + this.dictLabel = dictLabel; + } + + @NotBlank(message = "字典键值不能为空") + @Size(min = 0, max = 1000, message = "字典键值长度不能超过1000个字符") + public String getDictValue() + { + return dictValue; + } + + public void setDictValue(String dictValue) + { + this.dictValue = dictValue; + } + + @NotBlank(message = "字典类型不能为空") + @Size(min = 0, max = 1000, message = "字典类型长度不能超过1000个字符") + public String getDictType() + { + return dictType; + } + + public void setDictType(String dictType) + { + this.dictType = dictType; + } + + @Size(min = 0, max = 100, message = "样式属性长度不能超过100个字符") + public String getCssClass() + { + return cssClass; + } + + public void setCssClass(String cssClass) + { + this.cssClass = cssClass; + } + + public String getListClass() + { + return listClass; + } + + public void setListClass(String listClass) + { + this.listClass = listClass; + } + + public boolean getDefault() + { + return UserConstants.YES.equals(this.isDefault) ? true : false; + } + + public String getIsDefault() + { + return isDefault; + } + + public void setIsDefault(String isDefault) + { + this.isDefault = isDefault; + } + + public String getStatus() + { + return status; + } + + public void setStatus(String status) + { + this.status = status; + } + + @Override + public String toString() { + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) + .append("dictCode", getDictCode()) + .append("dictSort", getDictSort()) + .append("dictLabel", getDictLabel()) + .append("dictValue", getDictValue()) + .append("dictType", getDictType()) + .append("cssClass", getCssClass()) + .append("listClass", getListClass()) + .append("isDefault", getIsDefault()) + .append("status", getStatus()) + .append("createBy", getCreateBy()) + .append("createTime", getCreateTime()) + .append("updateBy", getUpdateBy()) + .append("updateTime", getUpdateTime()) + .append("remark", getRemark()) + .toString(); + } +} diff --git a/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SysDictType.java b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SysDictType.java new file mode 100644 index 0000000..d2c4249 --- /dev/null +++ b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SysDictType.java @@ -0,0 +1,94 @@ +package com.ruoyi.common.core.domain.entity; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.Size; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.annotation.Excel.ColumnType; +import com.ruoyi.common.core.domain.BaseEntity; + +/** + * 字典类型表 sys_dict_type + * + * @author ruoyi + */ +public class SysDictType extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** 字典主键 */ + @Excel(name = "字典主键", cellType = ColumnType.NUMERIC) + private Long dictId; + + /** 字典名称 */ + @Excel(name = "字典名称") + private String dictName; + + /** 字典类型 */ + @Excel(name = "字典类型") + private String dictType; + + /** 状态(0正常 1停用) */ + @Excel(name = "状态", readConverterExp = "0=正常,1=停用") + private String status; + + public Long getDictId() + { + return dictId; + } + + public void setDictId(Long dictId) + { + this.dictId = dictId; + } + + @NotBlank(message = "字典名称不能为空") + @Size(min = 0, max = 100, message = "字典类型名称长度不能超过100个字符") + public String getDictName() + { + return dictName; + } + + public void setDictName(String dictName) + { + this.dictName = dictName; + } + + @NotBlank(message = "字典类型不能为空") + @Size(min = 0, max = 100, message = "字典类型类型长度不能超过100个字符") + public String getDictType() + { + return dictType; + } + + public void setDictType(String dictType) + { + this.dictType = dictType; + } + + public String getStatus() + { + return status; + } + + public void setStatus(String status) + { + this.status = status; + } + + @Override + public String toString() { + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) + .append("dictId", getDictId()) + .append("dictName", getDictName()) + .append("dictType", getDictType()) + .append("status", getStatus()) + .append("createBy", getCreateBy()) + .append("createTime", getCreateTime()) + .append("updateBy", getUpdateBy()) + .append("updateTime", getUpdateTime()) + .append("remark", getRemark()) + .toString(); + } +} diff --git a/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SysMenu.java b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SysMenu.java new file mode 100644 index 0000000..1572159 --- /dev/null +++ b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SysMenu.java @@ -0,0 +1,267 @@ +package com.ruoyi.common.core.domain.entity; + +import com.fasterxml.jackson.annotation.JsonFormat; +import com.ruoyi.common.core.domain.BaseEntity; +import lombok.Data; +import lombok.EqualsAndHashCode; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.Size; +import java.util.ArrayList; +import java.util.List; + +/** + * 菜单权限表 sys_menu + * + * @author ruoyi + */ +@EqualsAndHashCode(callSuper = true) +@Data +public class SysMenu extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** 菜单ID */ + private Long menuId; + + /** 菜单名称 */ + private String menuName; + + /** 父菜单名称 */ + private String parentName; + + /** 父菜单ID */ + private Long parentId; + + /** 显示顺序 */ + private String orderNum; + + /** 路由地址 */ + private String path; + + /** 组件路径 */ + private String component; + + /** 路由参数 */ + private String query; + + /** 是否为外链(0是 1否) */ + private String isFrame; + + /** 是否缓存(0缓存 1不缓存) */ + private String isCache; + + /** 类型(M目录 C菜单 F按钮) */ + private String menuType; + + /** 显示状态(0显示 1隐藏) */ + private String visible; + + /** 菜单状态(0显示 1隐藏) */ + private String status; + + /** 权限字符串 */ + private String perms; + + /** 菜单图标 */ + private String icon; + + private String tenantId; + + /** 子菜单 */ + private List children = new ArrayList(); + + @JsonFormat(shape = JsonFormat.Shape.STRING) + public Long getMenuId() + { + return menuId; + } + + public void setMenuId(Long menuId) + { + this.menuId = menuId; + } + + @NotBlank(message = "菜单名称不能为空") + @Size(min = 0, max = 50, message = "菜单名称长度不能超过50个字符") + public String getMenuName() + { + return menuName; + } + + public void setMenuName(String menuName) + { + this.menuName = menuName; + } + + public String getParentName() + { + return parentName; + } + + public void setParentName(String parentName) + { + this.parentName = parentName; + } + + public Long getParentId() + { + return parentId; + } + + public void setParentId(Long parentId) + { + this.parentId = parentId; + } + + @NotBlank(message = "显示顺序不能为空") + public String getOrderNum() + { + return orderNum; + } + + public void setOrderNum(String orderNum) + { + this.orderNum = orderNum; + } + + @Size(min = 0, max = 200, message = "路由地址不能超过200个字符") + public String getPath() + { + return path; + } + + public void setPath(String path) + { + this.path = path; + } + + @Size(min = 0, max = 200, message = "组件路径不能超过255个字符") + public String getComponent() + { + return component; + } + + public void setComponent(String component) + { + this.component = component; + } + + public String getQuery() + { + return query; + } + + public void setQuery(String query) + { + this.query = query; + } + + public String getIsFrame() + { + return isFrame; + } + + public void setIsFrame(String isFrame) + { + this.isFrame = isFrame; + } + + public String getIsCache() + { + return isCache; + } + + public void setIsCache(String isCache) + { + this.isCache = isCache; + } + + @NotBlank(message = "菜单类型不能为空") + public String getMenuType() + { + return menuType; + } + + public void setMenuType(String menuType) + { + this.menuType = menuType; + } + + public String getVisible() + { + return visible; + } + + public void setVisible(String visible) + { + this.visible = visible; + } + + public String getStatus() + { + return status; + } + + public void setStatus(String status) + { + this.status = status; + } + + @Size(min = 0, max = 100, message = "权限标识长度不能超过100个字符") + public String getPerms() + { + return perms; + } + + public void setPerms(String perms) + { + this.perms = perms; + } + + public String getIcon() + { + return icon; + } + + public void setIcon(String icon) + { + this.icon = icon; + } + + public List getChildren() + { + return children; + } + + public void setChildren(List children) + { + this.children = children; + } + + @Override + public String toString() { + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) + .append("menuId", getMenuId()) + .append("menuName", getMenuName()) + .append("parentId", getParentId()) + .append("orderNum", getOrderNum()) + .append("path", getPath()) + .append("component", getComponent()) + .append("isFrame", getIsFrame()) + .append("IsCache", getIsCache()) + .append("menuType", getMenuType()) + .append("visible", getVisible()) + .append("status ", getStatus()) + .append("perms", getPerms()) + .append("icon", getIcon()) + .append("createBy", getCreateBy()) + .append("createTime", getCreateTime()) + .append("updateBy", getUpdateBy()) + .append("updateTime", getUpdateTime()) + .append("remark", getRemark()) + .toString(); + } +} diff --git a/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SysRole.java b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SysRole.java new file mode 100644 index 0000000..05baf22 --- /dev/null +++ b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SysRole.java @@ -0,0 +1,235 @@ +package com.ruoyi.common.core.domain.entity; + +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.annotation.Excel.ColumnType; +import com.ruoyi.common.core.domain.BaseEntity; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.Size; + +/** + * 角色表 sys_role + * + * @author ruoyi + */ +@EqualsAndHashCode(callSuper = true) +@Data +@Accessors(chain = true) +public class SysRole extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** 角色ID */ + @Excel(name = "角色序号", cellType = ColumnType.NUMERIC) + private Long roleId; + + /** 角色名称 */ + @Excel(name = "角色名称") + private String roleName; + + /** 角色权限 */ + @Excel(name = "角色权限") + private String roleKey; + + /** 角色排序 */ + @Excel(name = "角色排序") + private String roleSort; + + /** 数据范围(1:所有数据权限;2:自定义数据权限;3:本部门数据权限;4:本部门及以下数据权限;5:仅本人数据权限) */ + @Excel(name = "数据范围", readConverterExp = "1=所有数据权限,2=自定义数据权限,3=本部门数据权限,4=本部门及以下数据权限,5=仅本人数据权限") + private String dataScope; + + /** 菜单树选择项是否关联显示( 0:父子不互相关联显示 1:父子互相关联显示) */ + private boolean menuCheckStrictly; + + /** 部门树选择项是否关联显示(0:父子不互相关联显示 1:父子互相关联显示 ) */ + private boolean deptCheckStrictly; + + /** 角色状态(0正常 1停用) */ + @Excel(name = "角色状态", readConverterExp = "0=正常,1=停用") + private String status; + + /** 删除标志(0代表存在 2代表删除) */ + private String delFlag; + + /** 用户是否存在此角色标识 默认不存在 */ + private boolean flag = false; + + private String tenantId; + + /** 菜单组 */ + private Long[] menuIds; + + /** 部门组(数据权限) */ + private Long[] deptIds; + + public SysRole() + { + + } + + public SysRole(Long roleId) + { + this.roleId = roleId; + } + + public Long getRoleId() + { + return roleId; + } + + public void setRoleId(Long roleId) + { + this.roleId = roleId; + } + + public boolean isAdmin() + { + return isAdmin(this.roleId); + } + + public static boolean isAdmin(Long roleId) + { + return roleId != null && 1L == roleId; + } + + @NotBlank(message = "角色名称不能为空") + @Size(min = 0, max = 30, message = "角色名称长度不能超过30个字符") + public String getRoleName() + { + return roleName; + } + + public void setRoleName(String roleName) + { + this.roleName = roleName; + } + + @NotBlank(message = "权限字符不能为空") + @Size(min = 0, max = 100, message = "权限字符长度不能超过100个字符") + public String getRoleKey() + { + return roleKey; + } + + public void setRoleKey(String roleKey) + { + this.roleKey = roleKey; + } + + @NotBlank(message = "显示顺序不能为空") + public String getRoleSort() + { + return roleSort; + } + + public void setRoleSort(String roleSort) + { + this.roleSort = roleSort; + } + + public String getDataScope() + { + return dataScope; + } + + public void setDataScope(String dataScope) + { + this.dataScope = dataScope; + } + + public boolean isMenuCheckStrictly() + { + return menuCheckStrictly; + } + + public void setMenuCheckStrictly(boolean menuCheckStrictly) + { + this.menuCheckStrictly = menuCheckStrictly; + } + + public boolean isDeptCheckStrictly() + { + return deptCheckStrictly; + } + + public void setDeptCheckStrictly(boolean deptCheckStrictly) + { + this.deptCheckStrictly = deptCheckStrictly; + } + + public String getStatus() + { + return status; + } + + public void setStatus(String status) + { + this.status = status; + } + + public String getDelFlag() + { + return delFlag; + } + + public void setDelFlag(String delFlag) + { + this.delFlag = delFlag; + } + + public boolean isFlag() + { + return flag; + } + + public void setFlag(boolean flag) + { + this.flag = flag; + } + + public Long[] getMenuIds() + { + return menuIds; + } + + public void setMenuIds(Long[] menuIds) + { + this.menuIds = menuIds; + } + + public Long[] getDeptIds() + { + return deptIds; + } + + public void setDeptIds(Long[] deptIds) + { + this.deptIds = deptIds; + } + + @Override + public String toString() { + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) + .append("roleId", getRoleId()) + .append("roleName", getRoleName()) + .append("roleKey", getRoleKey()) + .append("roleSort", getRoleSort()) + .append("dataScope", getDataScope()) + .append("menuCheckStrictly", isMenuCheckStrictly()) + .append("deptCheckStrictly", isDeptCheckStrictly()) + .append("status", getStatus()) + .append("delFlag", getDelFlag()) + .append("createBy", getCreateBy()) + .append("createTime", getCreateTime()) + .append("updateBy", getUpdateBy()) + .append("updateTime", getUpdateTime()) + .append("remark", getRemark()) + .toString(); + } +} diff --git a/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SysTenant.java b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SysTenant.java new file mode 100644 index 0000000..32f9407 --- /dev/null +++ b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SysTenant.java @@ -0,0 +1,44 @@ +package com.ruoyi.common.core.domain.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import com.ruoyi.common.core.domain.BaseEntity; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * All rights Reserved, Designed By www.sunseagear.com + * + * @version V1.0 + * @package sys + * @title: 租户管理控制器 + * @description: 租户管理控制器 + * @author: 未知 + * @date: 2019-11-28 06:24:52 + * @copyright: www.sunseagear.com Inc. All rights reserved. + */ + +@EqualsAndHashCode(callSuper = true) +@Data +@TableName("sys_tenant") +public class SysTenant extends BaseEntity { + + private static final long serialVersionUID = 1L; + + @TableId(value = "id", type = IdType.AUTO) + private Long id; //id + @TableField(value = "contact") + private String contact; //联系人 + @TableField(value = "phone") + private String phone; //电话 + @TableField(value = "name") + private String name; //租户名称 + @TableField(value = "tenant_id") + private String tenantId; + @TableField(value = "user_id") + private Long userId; + @TableField(exist = false) + private String userName; +} diff --git a/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SysUser.java b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SysUser.java new file mode 100644 index 0000000..ba54e16 --- /dev/null +++ b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SysUser.java @@ -0,0 +1,211 @@ +package com.ruoyi.common.core.domain.entity; + +import java.util.Date; +import java.util.List; +import javax.validation.constraints.Email; +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.Size; + +import lombok.Data; +import lombok.EqualsAndHashCode; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.annotation.Excel.ColumnType; +import com.ruoyi.common.annotation.Excel.Type; +import com.ruoyi.common.annotation.Excels; +import com.ruoyi.common.core.domain.BaseEntity; + +/** + * 用户对象 sys_user + * + * @author ruoyi + */ +@EqualsAndHashCode(callSuper = true) +@Data +public class SysUser extends BaseEntity { + private static final long serialVersionUID = 1L; + + /** + * 用户ID + */ + @Excel(name = "用户序号", cellType = ColumnType.NUMERIC, prompt = "用户编号") + private Long userId; + + private String userType; + + /** + * 部门ID + */ + @Excel(name = "部门编号", type = Type.IMPORT) + private String deptId; + + /** + * 用户账号 + */ + @Excel(name = "登录名称") + @NotBlank(message = "用户账号不能为空") + @Size(min = 0, max = 30, message = "用户账号长度不能超过30个字符") + private String userName; + + /** + * 用户昵称 + */ + @Excel(name = "用户名称") + @Size(min = 0, max = 30, message = "用户昵称长度不能超过30个字符") + private String nickName; + + /** + * 用户邮箱 + */ + @Excel(name = "用户邮箱") + private String email; + + /** + * 手机号码 + */ + @Excel(name = "手机号码") + private String phonenumber; + + /** + * 用户性别 + */ + @Excel(name = "用户性别", readConverterExp = "0=男,1=女,2=未知") + private String sex; + + /** + * 用户头像 + */ + private String avatar; + + /** + * 密码 + */ + private String password; + + /** + * 盐加密 + */ + private String salt; + + /** + * 帐号状态(0正常 1停用) + */ + @Excel(name = "帐号状态", readConverterExp = "0=正常,1=停用") + private String status; + + /** + * 删除标志(0代表存在 2代表删除) + */ + private String delFlag; + + /** + * 最后登录IP + */ + @Excel(name = "最后登录IP", type = Type.EXPORT) + private String loginIp; + + /** + * 最后登录时间 + */ + @Excel(name = "最后登录时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss", type = Type.EXPORT) + private Date loginDate; + + /** + * 部门对象 + */ + @Excels({ + @Excel(name = "部门名称", targetAttr = "deptName", type = Type.EXPORT), + @Excel(name = "部门负责人", targetAttr = "leader", type = Type.EXPORT) + }) + private SysDept dept; + + /** + * 角色对象 + */ + private List roles; + + /** + * 角色组 + */ + private Long[] roleIds; + + /** + * 岗位组 + */ + private Long[] postIds; + + /** + * 角色ID + */ + private Long roleId; + + /** + * 租户ID + */ + private String tenantId; + + + public SysUser() { + + } + + public SysUser(Long userId) { + this.userId = userId; + } + + + public boolean isAdmin() { + return isAdmin(this.userId); + } + + public static boolean isAdmin(Long userId) { + return userId != null && 1L == userId; + } + + @Email(message = "邮箱格式不正确") + @Size(min = 0, max = 50, message = "邮箱长度不能超过50个字符") + public String getEmail() { + return email; + } + + + @Size(min = 0, max = 11, message = "手机号码长度不能超过11个字符") + public String getPhonenumber() { + return phonenumber; + } + + @JsonIgnore + @JsonProperty + public String getPassword() { + return password; + } + + @Override + public String toString() { + return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE) + .append("userId", getUserId()) + .append("deptId", getDeptId()) + .append("userName", getUserName()) + .append("nickName", getNickName()) + .append("email", getEmail()) + .append("phonenumber", getPhonenumber()) + .append("sex", getSex()) + .append("avatar", getAvatar()) + .append("password", getPassword()) + .append("salt", getSalt()) + .append("status", getStatus()) + .append("delFlag", getDelFlag()) + .append("loginIp", getLoginIp()) + .append("loginDate", getLoginDate()) + .append("createBy", getCreateBy()) + .append("createTime", getCreateTime()) + .append("updateBy", getUpdateBy()) + .append("updateTime", getUpdateTime()) + .append("remark", getRemark()) + .append("dept", getDept()) + .toString(); + } +} diff --git a/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/model/LoginBody.java b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/model/LoginBody.java new file mode 100644 index 0000000..42761be --- /dev/null +++ b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/model/LoginBody.java @@ -0,0 +1,82 @@ +package com.ruoyi.common.core.domain.model; + +/** + * 用户登录对象 + * + * @author ruoyi + */ +public class LoginBody +{ + /** + * 登入端口 + */ + private String loginType = "00"; + + /** + * 用户名 + */ + private String username; + + /** + * 用户密码 + */ + private String password; + + /** + * 验证码 + */ + private String code; + + /** + * 唯一标识 + */ + private String uuid = ""; + + public String getUsername() + { + return username; + } + + public void setUsername(String username) + { + this.username = username; + } + + public String getPassword() + { + return password; + } + + public void setPassword(String password) + { + this.password = password; + } + + public String getCode() + { + return code; + } + + public void setCode(String code) + { + this.code = code; + } + + public String getUuid() + { + return uuid; + } + + public void setUuid(String uuid) + { + this.uuid = uuid; + } + + public String getLoginType() { + return loginType; + } + + public void setLoginType(String loginType) { + this.loginType = loginType; + } +} diff --git a/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/model/LoginUser.java b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/model/LoginUser.java new file mode 100644 index 0000000..9ddeb8b --- /dev/null +++ b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/model/LoginUser.java @@ -0,0 +1,151 @@ +package com.ruoyi.common.core.domain.model; + +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.ruoyi.common.core.domain.entity.SysUser; +import lombok.Data; +import org.springframework.security.core.GrantedAuthority; +import org.springframework.security.core.userdetails.UserDetails; + +import java.util.Collection; +import java.util.Set; + +/** + * 登录用户身份权限 + * + * @author ruoyi + */ +@Data +public class LoginUser implements UserDetails { + private static final long serialVersionUID = 1L; + + /** + * 用户ID + */ + private Long userId; + + /** + * 部门ID + */ + private String deptId; + + /** + * 用户唯一标识 + */ + private String token; + + /** + * 登录时间 + */ + private Long loginTime; + + /** + * 过期时间 + */ + private Long expireTime; + + /** + * 登录IP地址 + */ + private String ipaddr; + + /** + * 登录地点 + */ + private String loginLocation; + + /** + * 浏览器类型 + */ + private String browser; + + /** + * 操作系统 + */ + private String os; + + /** + * 权限列表 + */ + private Set permissions; + + /** + * 租户ID + */ + private String tenantId; + + /** + * 用户信息 + */ + private SysUser user; + + public LoginUser() { + } + + public LoginUser(SysUser user, Set permissions) { + this.user = user; + this.permissions = permissions; + this.userId = user.getUserId(); + this.deptId = user.getDeptId(); + this.tenantId = user.getTenantId(); + + } + + @JsonIgnore + @Override + public String getPassword() { + return user.getPassword(); + } + + @Override + public String getUsername() { + return user.getUserName(); + } + + /** + * 账户是否未过期,过期无法验证 + */ + @JsonIgnore + @Override + public boolean isAccountNonExpired() { + return true; + } + + /** + * 指定用户是否解锁,锁定的用户无法进行身份验证 + * + * @return + */ + @JsonIgnore + @Override + public boolean isAccountNonLocked() { + return true; + } + + /** + * 指示是否已过期的用户的凭据(密码),过期的凭据防止认证 + * + * @return + */ + @JsonIgnore + @Override + public boolean isCredentialsNonExpired() { + return true; + } + + /** + * 是否可用 ,禁用的用户不能身份验证 + * + * @return + */ + @JsonIgnore + @Override + public boolean isEnabled() { + return true; + } + + + @Override + public Collection getAuthorities() { + return null; + } +} diff --git a/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/model/RegisterBody.java b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/model/RegisterBody.java new file mode 100644 index 0000000..868a1fc --- /dev/null +++ b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/model/RegisterBody.java @@ -0,0 +1,11 @@ +package com.ruoyi.common.core.domain.model; + +/** + * 用户注册对象 + * + * @author ruoyi + */ +public class RegisterBody extends LoginBody +{ + +} diff --git a/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/core/mapper/BaseTreeMapper.java b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/core/mapper/BaseTreeMapper.java new file mode 100644 index 0000000..bd17ac8 --- /dev/null +++ b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/core/mapper/BaseTreeMapper.java @@ -0,0 +1,47 @@ +package com.ruoyi.common.core.mapper; + +import com.baomidou.mybatisplus.core.conditions.Wrapper; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import org.apache.ibatis.annotations.Param; + +import java.io.Serializable; +import java.util.List; + +public interface BaseTreeMapper extends BaseMapper { + /** + * @param id + * @return + * @title: selectByPrimaryKey + * @description: 查找主键 + * @return: Menu + */ + T selectByTreeId(Serializable id); + + /** + * @param wrapper + * @return + * @title: selectTreeList + * @description: 查找列表 + * @return: List + */ + List selectTreeList(@Param("ew") Wrapper wrapper); + + /** + * @param newParentIds + * @param oldParentIds + * @title: updateSunTreeParentId + * @description: 更新ParentIds + * @return: void + */ + void updateSunTreeParentIds(@Param("newParentIds") String newParentIds, @Param("oldParentIds") String oldParentIds); + + /** + * @param parentIds + * @return + * @title: selectTreeList + * @description: 查找列表 + * @return: List + */ + void deleteSunTree(String parentIds); + +} diff --git a/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/core/page/PageDomain.java b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/core/page/PageDomain.java new file mode 100644 index 0000000..1314b29 --- /dev/null +++ b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/core/page/PageDomain.java @@ -0,0 +1,101 @@ +package com.ruoyi.common.core.page; + +import com.ruoyi.common.utils.StringUtils; + +/** + * 分页数据 + * + * @author ruoyi + */ +public class PageDomain { + /** + * 当前记录起始索引 + */ + private Integer pageNum; + + /** + * 每页显示记录数 + */ + private Integer pageSize; + + /** + * 排序列 + */ + private String orderByColumn; + + /** + * 排序的方向desc或者asc + */ + private String isAsc = "asc"; + + /** + * 分页参数合理化 + */ + private Boolean reasonable = true; + + public String getOrderBy() { + if (StringUtils.isEmpty(orderByColumn)) { + return ""; + } + return StringUtils.toUnderScoreCase(orderByColumn) + " " + isAsc; + } + + public Integer getPageNum() { + return pageNum; + } + + public void setPageNum(Integer pageNum) { +// if (pageNum == null) { +// this.pageNum = 10; +// return; +// } + this.pageNum = pageNum; + } + + public Integer getPageSize() { + return pageSize; + } + + public void setPageSize(Integer pageSize) { +// if (pageSize == null) { +// this.pageSize = 1; +// return; +// } + this.pageSize = pageSize; + } + + public String getOrderByColumn() { + return orderByColumn; + } + + public void setOrderByColumn(String orderByColumn) { + this.orderByColumn = orderByColumn; + } + + public String getIsAsc() { + return isAsc; + } + + public void setIsAsc(String isAsc) { + if (StringUtils.isNotEmpty(isAsc)) { + // 兼容前端排序类型 + if ("ascending".equals(isAsc)) { + isAsc = "asc"; + } else if ("descending".equals(isAsc)) { + isAsc = "desc"; + } + this.isAsc = isAsc; + } + } + + public Boolean getReasonable() { + if (StringUtils.isNull(reasonable)) { + return Boolean.TRUE; + } + return reasonable; + } + + public void setReasonable(Boolean reasonable) { + this.reasonable = reasonable; + } +} diff --git a/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/core/page/TableDataInfo.java b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/core/page/TableDataInfo.java new file mode 100644 index 0000000..1b24371 --- /dev/null +++ b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/core/page/TableDataInfo.java @@ -0,0 +1,85 @@ +package com.ruoyi.common.core.page; + +import java.io.Serializable; +import java.util.List; + +/** + * 表格分页数据对象 + * + * @author ruoyi + */ +public class TableDataInfo implements Serializable +{ + private static final long serialVersionUID = 1L; + + /** 总记录数 */ + private Integer total; + + /** 列表数据 */ + private List rows; + + /** 消息状态码 */ + private int code; + + /** 消息内容 */ + private String msg; + + /** + * 表格数据对象 + */ + public TableDataInfo() + { + } + + /** + * 分页 + * + * @param list 列表数据 + * @param total 总记录数 + */ + public TableDataInfo(List list, Integer total) + { + this.rows = list; + this.total = total; + } + + public long getTotal() + { + return total; + } + + public void setTotal(Integer total) + { + this.total = total; + } + + public List getRows() + { + return rows; + } + + public void setRows(List rows) + { + this.rows = rows; + } + + public int getCode() + { + return code; + } + + public void setCode(int code) + { + this.code = code; + } + + public String getMsg() + { + return msg; + } + + public void setMsg(String msg) + { + this.msg = msg; + } +} diff --git a/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/core/page/TableSupport.java b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/core/page/TableSupport.java new file mode 100644 index 0000000..5f30168 --- /dev/null +++ b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/core/page/TableSupport.java @@ -0,0 +1,55 @@ +package com.ruoyi.common.core.page; + +import com.ruoyi.common.utils.ServletUtils; + +/** + * 表格数据处理 + * + * @author ruoyi + */ +public class TableSupport +{ + /** + * 当前记录起始索引 + */ + public static final String PAGE_NUM = "pageNum"; + + /** + * 每页显示记录数 + */ + public static final String PAGE_SIZE = "pageSize"; + + /** + * 排序列 + */ + public static final String ORDER_BY_COLUMN = "orderByColumn"; + + /** + * 排序的方向 "desc" 或者 "asc". + */ + public static final String IS_ASC = "isAsc"; + + /** + * 分页参数合理化 + */ + public static final String REASONABLE = "reasonable"; + + /** + * 封装分页对象 + */ + public static PageDomain getPageDomain() + { + PageDomain pageDomain = new PageDomain(); + pageDomain.setPageNum(ServletUtils.getParameterToInt(PAGE_NUM)); + pageDomain.setPageSize(ServletUtils.getParameterToInt(PAGE_SIZE)); + pageDomain.setOrderByColumn(ServletUtils.getParameter(ORDER_BY_COLUMN)); + pageDomain.setIsAsc(ServletUtils.getParameter(IS_ASC)); + pageDomain.setReasonable(ServletUtils.getParameterToBool(REASONABLE)); + return pageDomain; + } + + public static PageDomain buildPageRequest() + { + return getPageDomain(); + } +} diff --git a/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/core/redis/RedisCache.java b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/core/redis/RedisCache.java new file mode 100644 index 0000000..76ee260 --- /dev/null +++ b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/core/redis/RedisCache.java @@ -0,0 +1,231 @@ +package com.ruoyi.common.core.redis; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.redis.core.BoundSetOperations; +import org.springframework.data.redis.core.HashOperations; +import org.springframework.data.redis.core.RedisTemplate; +import org.springframework.data.redis.core.ValueOperations; +import org.springframework.stereotype.Component; + +import java.util.*; +import java.util.concurrent.TimeUnit; + +/** + * spring redis 工具类 + * + * @author ruoyi + **/ +@SuppressWarnings(value = { "unchecked", "rawtypes" }) +@Component +public class RedisCache +{ + @Autowired + public RedisTemplate redisTemplate; + + /** + * 缓存基本的对象,Integer、String、实体类等 + * + * @param key 缓存的键值 + * @param value 缓存的值 + */ + public void setCacheObject(final String key, final T value) + { + redisTemplate.opsForValue().set(key, value); + } + + /** + * 缓存基本的对象,Integer、String、实体类等 + * + * @param key 缓存的键值 + * @param value 缓存的值 + * @param timeout 时间 + * @param timeUnit 时间颗粒度 + */ + public void setCacheObject(final String key, final T value, final Integer timeout, final TimeUnit timeUnit) + { + redisTemplate.opsForValue().set(key, value, timeout, timeUnit); + } + + /** + * 设置有效时间 + * + * @param key Redis键 + * @param timeout 超时时间 + * @return true=设置成功;false=设置失败 + */ + public boolean expire(final String key, final long timeout) + { + return expire(key, timeout, TimeUnit.SECONDS); + } + + /** + * 设置有效时间 + * + * @param key Redis键 + * @param timeout 超时时间 + * @param unit 时间单位 + * @return true=设置成功;false=设置失败 + */ + public boolean expire(final String key, final long timeout, final TimeUnit unit) + { + return redisTemplate.expire(key, timeout, unit); + } + + /** + * 获得缓存的基本对象。 + * + * @param key 缓存键值 + * @return 缓存键值对应的数据 + */ + public T getCacheObject(final String key) + { + ValueOperations operation = redisTemplate.opsForValue(); + return operation.get(key); + } + + /** + * 删除单个对象 + * + * @param key + */ + public boolean deleteObject(final String key) + { + return redisTemplate.delete(key); + } + + /** + * 删除集合对象 + * + * @param collection 多个对象 + * @return + */ + public long deleteObject(final Collection collection) + { + return redisTemplate.delete(collection); + } + + /** + * 缓存List数据 + * + * @param key 缓存的键值 + * @param dataList 待缓存的List数据 + * @return 缓存的对象 + */ + public long setCacheList(final String key, final List dataList) + { + Long count = redisTemplate.opsForList().rightPushAll(key, dataList); + return count == null ? 0 : count; + } + + /** + * 获得缓存的list对象 + * + * @param key 缓存的键值 + * @return 缓存键值对应的数据 + */ + public List getCacheList(final String key) + { + return redisTemplate.opsForList().range(key, 0, -1); + } + + /** + * 缓存Set + * + * @param key 缓存键值 + * @param dataSet 缓存的数据 + * @return 缓存数据的对象 + */ + public BoundSetOperations setCacheSet(final String key, final Set dataSet) + { + BoundSetOperations setOperation = redisTemplate.boundSetOps(key); + Iterator it = dataSet.iterator(); + while (it.hasNext()) + { + setOperation.add(it.next()); + } + return setOperation; + } + + /** + * 获得缓存的set + * + * @param key + * @return + */ + public Set getCacheSet(final String key) + { + return redisTemplate.opsForSet().members(key); + } + + /** + * 缓存Map + * + * @param key + * @param dataMap + */ + public void setCacheMap(final String key, final Map dataMap) + { + if (dataMap != null) { + redisTemplate.opsForHash().putAll(key, dataMap); + } + } + + /** + * 获得缓存的Map + * + * @param key + * @return + */ + public Map getCacheMap(final String key) + { + return redisTemplate.opsForHash().entries(key); + } + + /** + * 往Hash中存入数据 + * + * @param key Redis键 + * @param hKey Hash键 + * @param value 值 + */ + public void setCacheMapValue(final String key, final String hKey, final T value) + { + redisTemplate.opsForHash().put(key, hKey, value); + } + + /** + * 获取Hash中的数据 + * + * @param key Redis键 + * @param hKey Hash键 + * @return Hash中的对象 + */ + public T getCacheMapValue(final String key, final String hKey) + { + HashOperations opsForHash = redisTemplate.opsForHash(); + return opsForHash.get(key, hKey); + } + + /** + * 获取多个Hash中的数据 + * + * @param key Redis键 + * @param hKeys Hash键集合 + * @return Hash对象集合 + */ + public List getMultiCacheMapValue(final String key, final Collection hKeys) + { + return redisTemplate.opsForHash().multiGet(key, hKeys); + } + + /** + * 获得缓存的基本对象列表 + * + * @param pattern 字符串前缀 + * @return 对象列表 + */ + public Collection keys(final String pattern) + { + return redisTemplate.keys(pattern); + } +} diff --git a/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/core/redis/RedisService.java b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/core/redis/RedisService.java new file mode 100644 index 0000000..1cfda52 --- /dev/null +++ b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/core/redis/RedisService.java @@ -0,0 +1,231 @@ +package com.ruoyi.common.core.redis; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.redis.core.BoundSetOperations; +import org.springframework.data.redis.core.HashOperations; +import org.springframework.data.redis.core.RedisTemplate; +import org.springframework.data.redis.core.ValueOperations; +import org.springframework.stereotype.Component; + +import java.util.*; +import java.util.concurrent.TimeUnit; + +/** + * spring redis 工具类 + * + * @author ruoyi + **/ +@SuppressWarnings(value = { "unchecked", "rawtypes" }) +@Component +public class RedisService +{ + @Autowired + public RedisTemplate redisTemplate; + + /** + * 缓存基本的对象,Integer、String、实体类等 + * + * @param key 缓存的键值 + * @param value 缓存的值 + */ + public void setCacheObject(final String key, final T value) + { + redisTemplate.opsForValue().set(key, value); + } + + /** + * 缓存基本的对象,Integer、String、实体类等 + * + * @param key 缓存的键值 + * @param value 缓存的值 + * @param timeout 时间 + * @param timeUnit 时间颗粒度 + */ + public void setCacheObject(final String key, final T value, final Integer timeout, final TimeUnit timeUnit) + { + redisTemplate.opsForValue().set(key, value, timeout, timeUnit); + } + + /** + * 设置有效时间 + * + * @param key Redis键 + * @param timeout 超时时间 + * @return true=设置成功;false=设置失败 + */ + public boolean expire(final String key, final long timeout) + { + return expire(key, timeout, TimeUnit.SECONDS); + } + + /** + * 设置有效时间 + * + * @param key Redis键 + * @param timeout 超时时间 + * @param unit 时间单位 + * @return true=设置成功;false=设置失败 + */ + public boolean expire(final String key, final long timeout, final TimeUnit unit) + { + return redisTemplate.expire(key, timeout, unit); + } + + /** + * 获得缓存的基本对象。 + * + * @param key 缓存键值 + * @return 缓存键值对应的数据 + */ + public T getCacheObject(final String key) + { + ValueOperations operation = redisTemplate.opsForValue(); + return operation.get(key); + } + + /** + * 删除单个对象 + * + * @param key + */ + public boolean deleteObject(final String key) + { + return redisTemplate.delete(key); + } + + /** + * 删除集合对象 + * + * @param collection 多个对象 + * @return + */ + public long deleteObject(final Collection collection) + { + return redisTemplate.delete(collection); + } + + /** + * 缓存List数据 + * + * @param key 缓存的键值 + * @param dataList 待缓存的List数据 + * @return 缓存的对象 + */ + public long setCacheList(final String key, final List dataList) + { + Long count = redisTemplate.opsForList().rightPushAll(key, dataList); + return count == null ? 0 : count; + } + + /** + * 获得缓存的list对象 + * + * @param key 缓存的键值 + * @return 缓存键值对应的数据 + */ + public List getCacheList(final String key) + { + return redisTemplate.opsForList().range(key, 0, -1); + } + + /** + * 缓存Set + * + * @param key 缓存键值 + * @param dataSet 缓存的数据 + * @return 缓存数据的对象 + */ + public BoundSetOperations setCacheSet(final String key, final Set dataSet) + { + BoundSetOperations setOperation = redisTemplate.boundSetOps(key); + Iterator it = dataSet.iterator(); + while (it.hasNext()) + { + setOperation.add(it.next()); + } + return setOperation; + } + + /** + * 获得缓存的set + * + * @param key + * @return + */ + public Set getCacheSet(final String key) + { + return redisTemplate.opsForSet().members(key); + } + + /** + * 缓存Map + * + * @param key + * @param dataMap + */ + public void setCacheMap(final String key, final Map dataMap) + { + if (dataMap != null) { + redisTemplate.opsForHash().putAll(key, dataMap); + } + } + + /** + * 获得缓存的Map + * + * @param key + * @return + */ + public Map getCacheMap(final String key) + { + return redisTemplate.opsForHash().entries(key); + } + + /** + * 往Hash中存入数据 + * + * @param key Redis键 + * @param hKey Hash键 + * @param value 值 + */ + public void setCacheMapValue(final String key, final String hKey, final T value) + { + redisTemplate.opsForHash().put(key, hKey, value); + } + + /** + * 获取Hash中的数据 + * + * @param key Redis键 + * @param hKey Hash键 + * @return Hash中的对象 + */ + public T getCacheMapValue(final String key, final String hKey) + { + HashOperations opsForHash = redisTemplate.opsForHash(); + return opsForHash.get(key, hKey); + } + + /** + * 获取多个Hash中的数据 + * + * @param key Redis键 + * @param hKeys Hash键集合 + * @return Hash对象集合 + */ + public List getMultiCacheMapValue(final String key, final Collection hKeys) + { + return redisTemplate.opsForHash().multiGet(key, hKeys); + } + + /** + * 获得缓存的基本对象列表 + * + * @param pattern 字符串前缀 + * @return 对象列表 + */ + public Collection keys(final String pattern) + { + return redisTemplate.keys(pattern); + } +} diff --git a/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/core/service/ITreeCommonService.java b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/core/service/ITreeCommonService.java new file mode 100644 index 0000000..fae1a23 --- /dev/null +++ b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/core/service/ITreeCommonService.java @@ -0,0 +1,13 @@ +package com.ruoyi.common.core.service; + +import com.baomidou.mybatisplus.core.conditions.Wrapper; +import com.baomidou.mybatisplus.extension.service.IService; +import com.ruoyi.common.core.domain.TreeEntity; + +import java.util.List; + +public interface ITreeCommonService + extends IService { + public List selectTreeList(Wrapper wrapper); + +} diff --git a/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/core/service/impl/TreeCommonServiceImpl.java b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/core/service/impl/TreeCommonServiceImpl.java new file mode 100644 index 0000000..79d2fe0 --- /dev/null +++ b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/core/service/impl/TreeCommonServiceImpl.java @@ -0,0 +1,83 @@ +package com.ruoyi.common.core.service.impl; + +import com.baomidou.mybatisplus.core.conditions.Wrapper; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.ruoyi.common.core.domain.TreeEntity; +import com.ruoyi.common.core.mapper.BaseTreeMapper; +import com.ruoyi.common.core.service.ITreeCommonService; +import com.ruoyi.common.utils.StringUtils; +import org.springframework.transaction.annotation.Transactional; + +import java.io.Serializable; +import java.util.Collection; +import java.util.List; + +@Transactional +public class TreeCommonServiceImpl, T extends TreeEntity> + extends ServiceImpl implements ITreeCommonService { + + @Override + public T getById(Serializable id) { + return baseMapper.selectByTreeId(id); + } + + @Override + public List selectTreeList(Wrapper wrapper) { + List content = baseMapper.selectTreeList(wrapper); + return content; + } + + + @Override + public boolean save(T entity) { + if (!StringUtils.isEmpty(entity.getParentId()) && !"0".equals(entity.getParentId())) { + T parent = getById(entity.getParentId()); + entity.setParentId(parent.getId()); + entity.setAncestors(parent.makeSelfAsNewParentIds()); + } else { + entity.setParentId(null); + } + return super.save(entity); + } + + @Override + public boolean updateById(T entity) { + if (!StringUtils.isEmpty(entity.getParentId()) && !"0".equals(entity.getParentId())) { + T parent = getById(entity.getParentId()); + updateSelftAndChild(entity, parent.getId(), parent.makeSelfAsNewParentIds()); + } else { + entity.setParentId(null); + updateSelftAndChild(entity, "0", "0,"); + } + return true; + } + + + private void updateSelftAndChild(T entity, String newParentId, String newParentIds) { + T oldEntity = getById(entity.getId()); + String oldChildrenParentIds = oldEntity.makeSelfAsNewParentIds(); + entity.setParentId(newParentId); + entity.setAncestors(newParentIds); + super.updateById(entity); + String newChildrenParentIds = entity.makeSelfAsNewParentIds(); + baseMapper.updateSunTreeParentIds(newChildrenParentIds, oldChildrenParentIds); + } + + + @Override + public boolean removeById(Serializable id) { + T entity = getById(id); + baseMapper.deleteSunTree(entity.makeSelfAsNewParentIds()); + return super.removeById(id); + } + + @Override + public boolean removeByIds(Collection idList) { + for (Serializable treeId: idList) { + removeById(treeId); + } + return true; + } + + +} diff --git a/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/core/text/CharsetKit.java b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/core/text/CharsetKit.java new file mode 100644 index 0000000..656b3aa --- /dev/null +++ b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/core/text/CharsetKit.java @@ -0,0 +1,87 @@ +package com.ruoyi.common.core.text; + +import com.ruoyi.common.utils.StringUtils; + +import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; + +/** + * 字符集工具类 + * + * @author ruoyi + */ +public class CharsetKit +{ + /** ISO-8859-1 */ + public static final String ISO_8859_1 = "ISO-8859-1"; + /** UTF-8 */ + public static final String UTF_8 = "UTF-8"; + /** GBK */ + public static final String GBK = "GBK"; + + /** ISO-8859-1 */ + public static final Charset CHARSET_ISO_8859_1 = Charset.forName(ISO_8859_1); + /** UTF-8 */ + public static final Charset CHARSET_UTF_8 = Charset.forName(UTF_8); + /** GBK */ + public static final Charset CHARSET_GBK = Charset.forName(GBK); + + /** + * 转换为Charset对象 + * + * @param charset 字符集,为空则返回默认字符集 + * @return Charset + */ + public static Charset charset(String charset) + { + return StringUtils.isEmpty(charset) ? Charset.defaultCharset() : Charset.forName(charset); + } + + /** + * 转换字符串的字符集编码 + * + * @param source 字符串 + * @param srcCharset 源字符集,默认ISO-8859-1 + * @param destCharset 目标字符集,默认UTF-8 + * @return 转换后的字符集 + */ + public static String convert(String source, String srcCharset, String destCharset) + { + return convert(source, Charset.forName(srcCharset), Charset.forName(destCharset)); + } + + /** + * 转换字符串的字符集编码 + * + * @param source 字符串 + * @param srcCharset 源字符集,默认ISO-8859-1 + * @param destCharset 目标字符集,默认UTF-8 + * @return 转换后的字符集 + */ + public static String convert(String source, Charset srcCharset, Charset destCharset) + { + if (null == srcCharset) + { + srcCharset = StandardCharsets.ISO_8859_1; + } + + if (null == destCharset) + { + destCharset = StandardCharsets.UTF_8; + } + + if (StringUtils.isEmpty(source) || srcCharset.equals(destCharset)) + { + return source; + } + return new String(source.getBytes(srcCharset), destCharset); + } + + /** + * @return 系统字符集编码 + */ + public static String systemCharset() + { + return Charset.defaultCharset().name(); + } +} diff --git a/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/core/text/Convert.java b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/core/text/Convert.java new file mode 100644 index 0000000..c21cbce --- /dev/null +++ b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/core/text/Convert.java @@ -0,0 +1,1006 @@ +package com.ruoyi.common.core.text; + +import com.ruoyi.common.utils.StringUtils; +import org.apache.commons.lang3.ArrayUtils; + +import java.math.BigDecimal; +import java.math.BigInteger; +import java.nio.ByteBuffer; +import java.nio.charset.Charset; +import java.text.NumberFormat; +import java.util.Set; + +/** + * 类型转换器 + * + * @author ruoyi + */ +public class Convert +{ + /** + * 转换为字符串
+ * 如果给定的值为null,或者转换失败,返回默认值
+ * 转换失败不会报错 + * + * @param value 被转换的值 + * @param defaultValue 转换错误时的默认值 + * @return 结果 + */ + public static String toStr(Object value, String defaultValue) + { + if (null == value) + { + return defaultValue; + } + if (value instanceof String) + { + return (String) value; + } + return value.toString(); + } + + /** + * 转换为字符串
+ * 如果给定的值为null,或者转换失败,返回默认值null
+ * 转换失败不会报错 + * + * @param value 被转换的值 + * @return 结果 + */ + public static String toStr(Object value) + { + return toStr(value, null); + } + + /** + * 转换为字符
+ * 如果给定的值为null,或者转换失败,返回默认值
+ * 转换失败不会报错 + * + * @param value 被转换的值 + * @param defaultValue 转换错误时的默认值 + * @return 结果 + */ + public static Character toChar(Object value, Character defaultValue) + { + if (null == value) + { + return defaultValue; + } + if (value instanceof Character) + { + return (Character) value; + } + + final String valueStr = toStr(value, null); + return StringUtils.isEmpty(valueStr) ? defaultValue : valueStr.charAt(0); + } + + /** + * 转换为字符
+ * 如果给定的值为null,或者转换失败,返回默认值null
+ * 转换失败不会报错 + * + * @param value 被转换的值 + * @return 结果 + */ + public static Character toChar(Object value) + { + return toChar(value, null); + } + + /** + * 转换为byte
+ * 如果给定的值为null,或者转换失败,返回默认值
+ * 转换失败不会报错 + * + * @param value 被转换的值 + * @param defaultValue 转换错误时的默认值 + * @return 结果 + */ + public static Byte toByte(Object value, Byte defaultValue) + { + if (value == null) + { + return defaultValue; + } + if (value instanceof Byte) + { + return (Byte) value; + } + if (value instanceof Number) + { + return ((Number) value).byteValue(); + } + final String valueStr = toStr(value, null); + if (StringUtils.isEmpty(valueStr)) + { + return defaultValue; + } + try + { + return Byte.parseByte(valueStr); + } + catch (Exception e) + { + return defaultValue; + } + } + + /** + * 转换为byte
+ * 如果给定的值为null,或者转换失败,返回默认值null
+ * 转换失败不会报错 + * + * @param value 被转换的值 + * @return 结果 + */ + public static Byte toByte(Object value) + { + return toByte(value, null); + } + + /** + * 转换为Short
+ * 如果给定的值为null,或者转换失败,返回默认值
+ * 转换失败不会报错 + * + * @param value 被转换的值 + * @param defaultValue 转换错误时的默认值 + * @return 结果 + */ + public static Short toShort(Object value, Short defaultValue) + { + if (value == null) + { + return defaultValue; + } + if (value instanceof Short) + { + return (Short) value; + } + if (value instanceof Number) + { + return ((Number) value).shortValue(); + } + final String valueStr = toStr(value, null); + if (StringUtils.isEmpty(valueStr)) + { + return defaultValue; + } + try + { + return Short.parseShort(valueStr.trim()); + } + catch (Exception e) + { + return defaultValue; + } + } + + /** + * 转换为Short
+ * 如果给定的值为null,或者转换失败,返回默认值null
+ * 转换失败不会报错 + * + * @param value 被转换的值 + * @return 结果 + */ + public static Short toShort(Object value) + { + return toShort(value, null); + } + + /** + * 转换为Number
+ * 如果给定的值为空,或者转换失败,返回默认值
+ * 转换失败不会报错 + * + * @param value 被转换的值 + * @param defaultValue 转换错误时的默认值 + * @return 结果 + */ + public static Number toNumber(Object value, Number defaultValue) + { + if (value == null) + { + return defaultValue; + } + if (value instanceof Number) + { + return (Number) value; + } + final String valueStr = toStr(value, null); + if (StringUtils.isEmpty(valueStr)) + { + return defaultValue; + } + try + { + return NumberFormat.getInstance().parse(valueStr); + } + catch (Exception e) + { + return defaultValue; + } + } + + /** + * 转换为Number
+ * 如果给定的值为空,或者转换失败,返回默认值null
+ * 转换失败不会报错 + * + * @param value 被转换的值 + * @return 结果 + */ + public static Number toNumber(Object value) + { + return toNumber(value, null); + } + + /** + * 转换为int
+ * 如果给定的值为空,或者转换失败,返回默认值
+ * 转换失败不会报错 + * + * @param value 被转换的值 + * @param defaultValue 转换错误时的默认值 + * @return 结果 + */ + public static Integer toInt(Object value, Integer defaultValue) + { + if (value == null) + { + return defaultValue; + } + if (value instanceof Integer) + { + return (Integer) value; + } + if (value instanceof Number) + { + return ((Number) value).intValue(); + } + final String valueStr = toStr(value, null); + if (StringUtils.isEmpty(valueStr)) + { + return defaultValue; + } + try + { + return Integer.parseInt(valueStr.trim()); + } + catch (Exception e) + { + return defaultValue; + } + } + + /** + * 转换为int
+ * 如果给定的值为null,或者转换失败,返回默认值null
+ * 转换失败不会报错 + * + * @param value 被转换的值 + * @return 结果 + */ + public static Integer toInt(Object value) + { + return toInt(value, null); + } + + /** + * 转换为Integer数组
+ * + * @param str 被转换的值 + * @return 结果 + */ + public static Integer[] toIntArray(String str) + { + return toIntArray(",", str); + } + + /** + * 转换为Long数组
+ * + * @param str 被转换的值 + * @return 结果 + */ + public static Long[] toLongArray(String str) + { + return toLongArray(",", str); + } + + /** + * 转换为Integer数组
+ * + * @param split 分隔符 + * @param split 被转换的值 + * @return 结果 + */ + public static Integer[] toIntArray(String split, String str) + { + if (StringUtils.isEmpty(str)) + { + return new Integer[] {}; + } + String[] arr = str.split(split); + final Integer[] ints = new Integer[arr.length]; + for (int i = 0; i < arr.length; i++) + { + final Integer v = toInt(arr[i], 0); + ints[i] = v; + } + return ints; + } + + /** + * 转换为Long数组
+ * + * @param split 分隔符 + * @param str 被转换的值 + * @return 结果 + */ + public static Long[] toLongArray(String split, String str) + { + if (StringUtils.isEmpty(str)) + { + return new Long[] {}; + } + String[] arr = str.split(split); + final Long[] longs = new Long[arr.length]; + for (int i = 0; i < arr.length; i++) + { + final Long v = toLong(arr[i], null); + longs[i] = v; + } + return longs; + } + + /** + * 转换为String数组
+ * + * @param str 被转换的值 + * @return 结果 + */ + public static String[] toStrArray(String str) + { + return toStrArray(",", str); + } + + /** + * 转换为String数组
+ * + * @param split 分隔符 + * @param split 被转换的值 + * @return 结果 + */ + public static String[] toStrArray(String split, String str) + { + return str.split(split); + } + + /** + * 转换为long
+ * 如果给定的值为空,或者转换失败,返回默认值
+ * 转换失败不会报错 + * + * @param value 被转换的值 + * @param defaultValue 转换错误时的默认值 + * @return 结果 + */ + public static Long toLong(Object value, Long defaultValue) + { + if (value == null) + { + return defaultValue; + } + if (value instanceof Long) + { + return (Long) value; + } + if (value instanceof Number) + { + return ((Number) value).longValue(); + } + final String valueStr = toStr(value, null); + if (StringUtils.isEmpty(valueStr)) + { + return defaultValue; + } + try + { + // 支持科学计数法 + return new BigDecimal(valueStr.trim()).longValue(); + } + catch (Exception e) + { + return defaultValue; + } + } + + /** + * 转换为long
+ * 如果给定的值为null,或者转换失败,返回默认值null
+ * 转换失败不会报错 + * + * @param value 被转换的值 + * @return 结果 + */ + public static Long toLong(Object value) + { + return toLong(value, null); + } + + /** + * 转换为double
+ * 如果给定的值为空,或者转换失败,返回默认值
+ * 转换失败不会报错 + * + * @param value 被转换的值 + * @param defaultValue 转换错误时的默认值 + * @return 结果 + */ + public static Double toDouble(Object value, Double defaultValue) + { + if (value == null) + { + return defaultValue; + } + if (value instanceof Double) + { + return (Double) value; + } + if (value instanceof Number) + { + return ((Number) value).doubleValue(); + } + final String valueStr = toStr(value, null); + if (StringUtils.isEmpty(valueStr)) + { + return defaultValue; + } + try + { + // 支持科学计数法 + return new BigDecimal(valueStr.trim()).doubleValue(); + } + catch (Exception e) + { + return defaultValue; + } + } + + /** + * 转换为double
+ * 如果给定的值为空,或者转换失败,返回默认值null
+ * 转换失败不会报错 + * + * @param value 被转换的值 + * @return 结果 + */ + public static Double toDouble(Object value) + { + return toDouble(value, null); + } + + /** + * 转换为Float
+ * 如果给定的值为空,或者转换失败,返回默认值
+ * 转换失败不会报错 + * + * @param value 被转换的值 + * @param defaultValue 转换错误时的默认值 + * @return 结果 + */ + public static Float toFloat(Object value, Float defaultValue) + { + if (value == null) + { + return defaultValue; + } + if (value instanceof Float) + { + return (Float) value; + } + if (value instanceof Number) + { + return ((Number) value).floatValue(); + } + final String valueStr = toStr(value, null); + if (StringUtils.isEmpty(valueStr)) + { + return defaultValue; + } + try + { + return Float.parseFloat(valueStr.trim()); + } + catch (Exception e) + { + return defaultValue; + } + } + + /** + * 转换为Float
+ * 如果给定的值为空,或者转换失败,返回默认值null
+ * 转换失败不会报错 + * + * @param value 被转换的值 + * @return 结果 + */ + public static Float toFloat(Object value) + { + return toFloat(value, null); + } + + /** + * 转换为boolean
+ * String支持的值为:true、false、yes、ok、no,1,0 如果给定的值为空,或者转换失败,返回默认值
+ * 转换失败不会报错 + * + * @param value 被转换的值 + * @param defaultValue 转换错误时的默认值 + * @return 结果 + */ + public static Boolean toBool(Object value, Boolean defaultValue) + { + if (value == null) + { + return defaultValue; + } + if (value instanceof Boolean) + { + return (Boolean) value; + } + String valueStr = toStr(value, null); + if (StringUtils.isEmpty(valueStr)) + { + return defaultValue; + } + valueStr = valueStr.trim().toLowerCase(); + switch (valueStr) + { + case "true": + return true; + case "false": + return false; + case "yes": + return true; + case "ok": + return true; + case "no": + return false; + case "1": + return true; + case "0": + return false; + default: + return defaultValue; + } + } + + /** + * 转换为boolean
+ * 如果给定的值为空,或者转换失败,返回默认值null
+ * 转换失败不会报错 + * + * @param value 被转换的值 + * @return 结果 + */ + public static Boolean toBool(Object value) + { + return toBool(value, null); + } + + /** + * 转换为Enum对象
+ * 如果给定的值为空,或者转换失败,返回默认值
+ * + * @param clazz Enum的Class + * @param value 值 + * @param defaultValue 默认值 + * @return Enum + */ + public static > E toEnum(Class clazz, Object value, E defaultValue) + { + if (value == null) + { + return defaultValue; + } + if (clazz.isAssignableFrom(value.getClass())) + { + @SuppressWarnings("unchecked") + E myE = (E) value; + return myE; + } + final String valueStr = toStr(value, null); + if (StringUtils.isEmpty(valueStr)) + { + return defaultValue; + } + try + { + return Enum.valueOf(clazz, valueStr); + } + catch (Exception e) + { + return defaultValue; + } + } + + /** + * 转换为Enum对象
+ * 如果给定的值为空,或者转换失败,返回默认值null
+ * + * @param clazz Enum的Class + * @param value 值 + * @return Enum + */ + public static > E toEnum(Class clazz, Object value) + { + return toEnum(clazz, value, null); + } + + /** + * 转换为BigInteger
+ * 如果给定的值为空,或者转换失败,返回默认值
+ * 转换失败不会报错 + * + * @param value 被转换的值 + * @param defaultValue 转换错误时的默认值 + * @return 结果 + */ + public static BigInteger toBigInteger(Object value, BigInteger defaultValue) + { + if (value == null) + { + return defaultValue; + } + if (value instanceof BigInteger) + { + return (BigInteger) value; + } + if (value instanceof Long) + { + return BigInteger.valueOf((Long) value); + } + final String valueStr = toStr(value, null); + if (StringUtils.isEmpty(valueStr)) + { + return defaultValue; + } + try + { + return new BigInteger(valueStr); + } + catch (Exception e) + { + return defaultValue; + } + } + + /** + * 转换为BigInteger
+ * 如果给定的值为空,或者转换失败,返回默认值null
+ * 转换失败不会报错 + * + * @param value 被转换的值 + * @return 结果 + */ + public static BigInteger toBigInteger(Object value) + { + return toBigInteger(value, null); + } + + /** + * 转换为BigDecimal
+ * 如果给定的值为空,或者转换失败,返回默认值
+ * 转换失败不会报错 + * + * @param value 被转换的值 + * @param defaultValue 转换错误时的默认值 + * @return 结果 + */ + public static BigDecimal toBigDecimal(Object value, BigDecimal defaultValue) + { + if (value == null) + { + return defaultValue; + } + if (value instanceof BigDecimal) + { + return (BigDecimal) value; + } + if (value instanceof Long) + { + return new BigDecimal((Long) value); + } + if (value instanceof Double) + { + return new BigDecimal((Double) value); + } + if (value instanceof Integer) + { + return new BigDecimal((Integer) value); + } + final String valueStr = toStr(value, null); + if (StringUtils.isEmpty(valueStr)) + { + return defaultValue; + } + try + { + return new BigDecimal(valueStr); + } + catch (Exception e) + { + return defaultValue; + } + } + + /** + * 转换为BigDecimal
+ * 如果给定的值为空,或者转换失败,返回默认值
+ * 转换失败不会报错 + * + * @param value 被转换的值 + * @return 结果 + */ + public static BigDecimal toBigDecimal(Object value) + { + return toBigDecimal(value, null); + } + + /** + * 将对象转为字符串
+ * 1、Byte数组和ByteBuffer会被转换为对应字符串的数组 2、对象数组会调用Arrays.toString方法 + * + * @param obj 对象 + * @return 字符串 + */ + public static String utf8Str(Object obj) + { + return str(obj, CharsetKit.CHARSET_UTF_8); + } + + /** + * 将对象转为字符串
+ * 1、Byte数组和ByteBuffer会被转换为对应字符串的数组 2、对象数组会调用Arrays.toString方法 + * + * @param obj 对象 + * @param charsetName 字符集 + * @return 字符串 + */ + public static String str(Object obj, String charsetName) + { + return str(obj, Charset.forName(charsetName)); + } + + /** + * 将对象转为字符串
+ * 1、Byte数组和ByteBuffer会被转换为对应字符串的数组 2、对象数组会调用Arrays.toString方法 + * + * @param obj 对象 + * @param charset 字符集 + * @return 字符串 + */ + public static String str(Object obj, Charset charset) + { + if (null == obj) + { + return null; + } + + if (obj instanceof String) + { + return (String) obj; + } + else if (obj instanceof byte[]) + { + return str((byte[]) obj, charset); + } + else if (obj instanceof Byte[]) + { + byte[] bytes = ArrayUtils.toPrimitive((Byte[]) obj); + return str(bytes, charset); + } + else if (obj instanceof ByteBuffer) + { + return str((ByteBuffer) obj, charset); + } + return obj.toString(); + } + + /** + * 将byte数组转为字符串 + * + * @param bytes byte数组 + * @param charset 字符集 + * @return 字符串 + */ + public static String str(byte[] bytes, String charset) + { + return str(bytes, StringUtils.isEmpty(charset) ? Charset.defaultCharset() : Charset.forName(charset)); + } + + /** + * 解码字节码 + * + * @param data 字符串 + * @param charset 字符集,如果此字段为空,则解码的结果取决于平台 + * @return 解码后的字符串 + */ + public static String str(byte[] data, Charset charset) + { + if (data == null) + { + return null; + } + + if (null == charset) + { + return new String(data); + } + return new String(data, charset); + } + + /** + * 将编码的byteBuffer数据转换为字符串 + * + * @param data 数据 + * @param charset 字符集,如果为空使用当前系统字符集 + * @return 字符串 + */ + public static String str(ByteBuffer data, String charset) + { + if (data == null) + { + return null; + } + + return str(data, Charset.forName(charset)); + } + + /** + * 将编码的byteBuffer数据转换为字符串 + * + * @param data 数据 + * @param charset 字符集,如果为空使用当前系统字符集 + * @return 字符串 + */ + public static String str(ByteBuffer data, Charset charset) + { + if (null == charset) + { + charset = Charset.defaultCharset(); + } + return charset.decode(data).toString(); + } + + // ----------------------------------------------------------------------- 全角半角转换 + /** + * 半角转全角 + * + * @param input String. + * @return 全角字符串. + */ + public static String toSBC(String input) + { + return toSBC(input, null); + } + + /** + * 半角转全角 + * + * @param input String + * @param notConvertSet 不替换的字符集合 + * @return 全角字符串. + */ + public static String toSBC(String input, Set notConvertSet) + { + char[] c = input.toCharArray(); + for (int i = 0; i < c.length; i++) + { + if (null != notConvertSet && notConvertSet.contains(c[i])) + { + // 跳过不替换的字符 + continue; + } + + if (c[i] == ' ') + { + c[i] = '\u3000'; + } + else if (c[i] < '\177') + { + c[i] = (char) (c[i] + 65248); + + } + } + return new String(c); + } + + /** + * 全角转半角 + * + * @param input String. + * @return 半角字符串 + */ + public static String toDBC(String input) + { + return toDBC(input, null); + } + + /** + * 替换全角为半角 + * + * @param text 文本 + * @param notConvertSet 不替换的字符集合 + * @return 替换后的字符 + */ + public static String toDBC(String text, Set notConvertSet) + { + char[] c = text.toCharArray(); + for (int i = 0; i < c.length; i++) + { + if (null != notConvertSet && notConvertSet.contains(c[i])) + { + // 跳过不替换的字符 + continue; + } + + if (c[i] == '\u3000') + { + c[i] = ' '; + } + else if (c[i] > '\uFF00' && c[i] < '\uFF5F') + { + c[i] = (char) (c[i] - 65248); + } + } + String returnString = new String(c); + + return returnString; + } + + /** + * 数字金额大写转换 先写个完整的然后将如零拾替换成零 + * + * @param n 数字 + * @return 中文大写数字 + */ + public static String digitUppercase(double n) + { + String[] fraction = { "角", "分" }; + String[] digit = { "零", "壹", "贰", "叁", "肆", "伍", "陆", "柒", "捌", "玖" }; + String[][] unit = { { "元", "万", "亿" }, { "", "拾", "佰", "仟" } }; + + String head = n < 0 ? "负" : ""; + n = Math.abs(n); + + String s = ""; + for (int i = 0; i < fraction.length; i++) + { + s += (digit[(int) (Math.floor(n * 10 * Math.pow(10, i)) % 10)] + fraction[i]).replaceAll("(零.)+", ""); + } + if (s.length() < 1) + { + s = "整"; + } + int integerPart = (int) Math.floor(n); + + for (int i = 0; i < unit[0].length && integerPart > 0; i++) + { + String p = ""; + for (int j = 0; j < unit[1].length && n > 0; j++) + { + p = digit[integerPart % 10] + unit[1][j] + p; + integerPart = integerPart / 10; + } + s = p.replaceAll("(零.)*零$", "").replaceAll("^$", "零") + unit[0][i] + s; + } + return head + s.replaceAll("(零.)*零元", "元").replaceFirst("(零.)+", "").replaceAll("(零.)+", "零").replaceAll("^整$", "零元整"); + } +} diff --git a/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/core/text/StrFormatter.java b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/core/text/StrFormatter.java new file mode 100644 index 0000000..c78ac77 --- /dev/null +++ b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/core/text/StrFormatter.java @@ -0,0 +1,92 @@ +package com.ruoyi.common.core.text; + +import com.ruoyi.common.utils.StringUtils; + +/** + * 字符串格式化 + * + * @author ruoyi + */ +public class StrFormatter +{ + public static final String EMPTY_JSON = "{}"; + public static final char C_BACKSLASH = '\\'; + public static final char C_DELIM_START = '{'; + public static final char C_DELIM_END = '}'; + + /** + * 格式化字符串
+ * 此方法只是简单将占位符 {} 按照顺序替换为参数
+ * 如果想输出 {} 使用 \\转义 { 即可,如果想输出 {} 之前的 \ 使用双转义符 \\\\ 即可
+ * 例:
+ * 通常使用:format("this is {} for {}", "a", "b") -> this is a for b
+ * 转义{}: format("this is \\{} for {}", "a", "b") -> this is \{} for a
+ * 转义\: format("this is \\\\{} for {}", "a", "b") -> this is \a for b
+ * + * @param strPattern 字符串模板 + * @param argArray 参数列表 + * @return 结果 + */ + public static String format(final String strPattern, final Object... argArray) + { + if (StringUtils.isEmpty(strPattern) || StringUtils.isEmpty(argArray)) + { + return strPattern; + } + final int strPatternLength = strPattern.length(); + + // 初始化定义好的长度以获得更好的性能 + StringBuilder sbuf = new StringBuilder(strPatternLength + 50); + + int handledPosition = 0; + int delimIndex;// 占位符所在位置 + for (int argIndex = 0; argIndex < argArray.length; argIndex++) + { + delimIndex = strPattern.indexOf(EMPTY_JSON, handledPosition); + if (delimIndex == -1) + { + if (handledPosition == 0) + { + return strPattern; + } + else + { // 字符串模板剩余部分不再包含占位符,加入剩余部分后返回结果 + sbuf.append(strPattern, handledPosition, strPatternLength); + return sbuf.toString(); + } + } + else + { + if (delimIndex > 0 && strPattern.charAt(delimIndex - 1) == C_BACKSLASH) + { + if (delimIndex > 1 && strPattern.charAt(delimIndex - 2) == C_BACKSLASH) + { + // 转义符之前还有一个转义符,占位符依旧有效 + sbuf.append(strPattern, handledPosition, delimIndex - 1); + sbuf.append(Convert.utf8Str(argArray[argIndex])); + handledPosition = delimIndex + 2; + } + else + { + // 占位符被转义 + argIndex--; + sbuf.append(strPattern, handledPosition, delimIndex - 1); + sbuf.append(C_DELIM_START); + handledPosition = delimIndex + 1; + } + } + else + { + // 正常占位符 + sbuf.append(strPattern, handledPosition, delimIndex); + sbuf.append(Convert.utf8Str(argArray[argIndex])); + handledPosition = delimIndex + 2; + } + } + } + // 加入最后一个占位符后所有的字符 + sbuf.append(strPattern, handledPosition, strPattern.length()); + + return sbuf.toString(); + } +} diff --git a/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/cos/PostObjectDemo.java b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/cos/PostObjectDemo.java new file mode 100644 index 0000000..ce2e252 --- /dev/null +++ b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/cos/PostObjectDemo.java @@ -0,0 +1,135 @@ +package com.ruoyi.common.cos; + + +import com.ruoyi.common.cos.auth.COSSigner; +import com.ruoyi.common.cos.utils.VersionInfoUtils; +import org.apache.commons.codec.binary.Base64; + +import java.io.*; +import java.net.HttpURLConnection; +import java.net.URL; +import java.text.SimpleDateFormat; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class PostObjectDemo { + public static void main(String[] args) throws Exception { + PostObjectUploadDemo(); + } + + private static void PostObjectUploadDemo() throws Exception { + String bucketName = "ddht-1324395003"; + String endpoint = "cos.ap-shanghai.myqcloud.com"; + String key = "images/test.png"; + String filename = "test.png"; + String inputFilePath = "C:\\Users\\admin\\Desktop\\1721376479165.jpg"; + String contentType = "image/jpeg"; + String secretId = "AKIDSBQuX5mAZvHa2jNwSzWE0lNvNuMjA9gC"; + String seretKey = "VXZWQPYaedvMC6vovAU3gJ1ogXXdvO1n"; + long startTimestamp = System.currentTimeMillis() / 1000; + long endTimestamp = startTimestamp + 30 * 60; + String endTimestampStr = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"). + format(endTimestamp * 1000); + String keyTime = startTimestamp + ";" + endTimestamp; + String boundary = "----WebKitFormBoundaryZBPbaoYE2gqeB21N"; + // 设置表单的body字段值 + Map formFields = new HashMap<>(); + formFields.put("q-sign-algorithm", "sha1"); + formFields.put("key", key); + formFields.put("q-ak", secretId); + formFields.put("q-key-time", keyTime); + // 构造policy,参考文档: https://cloud.tencent.com/document/product/436/14690 + String policy = "{\n" + + " \"expiration\": \"" + endTimestampStr + "\",\n" + + " \"conditions\": [\n" + + " { \"bucket\": \"" + bucketName + "\" },\n" + + " { \"q-sign-algorithm\": \"sha1\" },\n" + + " { \"q-ak\": \"" + secretId + "\" },\n" + + " { \"q-sign-time\":\"" + keyTime + "\" }\n" + + " ]\n" + + "}"; + // policy需要base64后算放入表单中 + String encodedPolicy = new String(Base64.encodeBase64(policy.getBytes())); + // 设置policy + formFields.put("policy", encodedPolicy); + // 根据编码后的policy和secretKey计算签名 + COSSigner cosSigner = new COSSigner(); + String signature = cosSigner.buildPostObjectSignature(seretKey, + keyTime, policy); + // 设置签名 + formFields.put("q-signature", signature); + // 根据以上表单参数,构造最开始的body部分 + String formBody = buildPostObjectBody(boundary, formFields, + filename, contentType); + HttpURLConnection conn = null; + try { + String urlStr = "http://" + bucketName + "." + endpoint; + URL url = new URL(urlStr); + conn = (HttpURLConnection) url.openConnection(); + conn.setRequestMethod("POST"); + conn.setRequestProperty("User-Agent", VersionInfoUtils.getUserAgent()); + conn.setRequestProperty("Content-Type", "multipart/form-data; boundary=" + boundary); + conn.setDoOutput(true); + conn.setDoInput(true); + OutputStream out = new DataOutputStream(conn.getOutputStream()); + // 写入表单的最开始部分 + out.write(formBody.getBytes()); + // 将文件内容写入到输出流中 + File file = new File(inputFilePath); + DataInputStream in = new DataInputStream(new FileInputStream(file)); + int readBytes; + byte[] bytes = new byte[4096]; + while ((readBytes = in.read(bytes)) != -1) { + out.write(bytes, 0, readBytes); + } + in.close(); + // 添加最后一个分割符,行首和行尾都是-- + byte[] endData = ("\r\n--" + boundary + "--\r\n").getBytes(); + out.write(endData); + out.flush(); + out.close(); + // 读取响应头部 + for (Map.Entry> entries : conn.getHeaderFields().entrySet()) { + String values = ""; + for (String value : entries.getValue()) { + values += value + ","; + } + if(entries.getKey() == null) { + System.out.println("reponse line:" + values ); + } else { + System.out.println(entries.getKey() + ":" + values ); + } + } + } catch (Exception e) { + e.printStackTrace(); + throw e; + } finally { + if (conn != null) { + conn.disconnect(); + } + } + } + + public static String buildPostObjectBody(String boundary, Map formFields, + String filename, String contentType) { + StringBuffer stringBuffer = new StringBuffer(); + for(Map.Entry entry: formFields.entrySet()) { + // 添加boundary行,行首以--开头 + stringBuffer.append("--").append(boundary).append("\r\n"); + // 字段名 + stringBuffer.append("Content-Disposition: form-data; name=\"" + + entry.getKey() + "\"\r\n\r\n"); + // 字段值 + stringBuffer.append(entry.getValue() + "\r\n"); + } + // 添加boundary行,行首以--开头 + stringBuffer.append("--").append(boundary).append("\r\n"); + // 文件名 + stringBuffer.append("Content-Disposition: form-data; name=\"file\"; " + + "filename=\"" + filename + "\"\r\n"); + // 文件类型 + stringBuffer.append("Content-Type: " + contentType + "\r\n\r\n"); + return stringBuffer.toString(); + } +} diff --git a/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/cos/TxApiHttpUtils.java b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/cos/TxApiHttpUtils.java new file mode 100644 index 0000000..e03b794 --- /dev/null +++ b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/cos/TxApiHttpUtils.java @@ -0,0 +1,172 @@ +package com.ruoyi.common.cos; + +import com.alibaba.fastjson.JSONObject; +import okhttp3.*; + +import javax.crypto.Mac; +import javax.crypto.spec.SecretKeySpec; +import java.io.IOException; +import java.nio.charset.StandardCharsets; +import java.security.InvalidKeyException; +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.TimeZone; + +public class TxApiHttpUtils { + public static void main(String[] args) throws IOException, NoSuchAlgorithmException, InvalidKeyException { + /*String secretId = "AKIDBG9FF8rkglmaSDnBMRdmtBSr7OVYP3Me"; + String secretKey = "IUVOQPIFY2fH0njq3BEGD5vkV9hEj9Vz"; + String token = ""; + String service = "tms"; + String version = "2020-12-29"; + String action = "TextModeration"; + String body = "{\"Content\":\"5L2g5aW9\"}"; + String region = "ap-shanghai"; + String resp = doRequest(secretId, secretKey, service, version, action, body, region, token); + System.out.println(resp);*/ + + System.out.printf(checkContext("你好").toString()); + } + + public static JSONObject checkContext(String content) { + String secretId = "AKIDBG9FF8rkglmaSDnBMRdmtBSr7OVYP3Me"; + String secretKey = "IUVOQPIFY2fH0njq3BEGD5vkV9hEj9Vz"; + String token = ""; + String service = "tms"; + String version = "2020-12-29"; + String action = "TextModeration"; + String body = "{\"Content\":\"5L2g5aW9\"}"; + String region = "ap-shanghai"; + String resp = null; + try { + resp = doRequest(secretId, secretKey, service, version, action, body, region, token); + return JSONObject.parseObject(resp); + } catch (IOException e) { + throw new RuntimeException(e); + } catch (NoSuchAlgorithmException e) { + throw new RuntimeException(e); + } catch (InvalidKeyException e) { + throw new RuntimeException(e); + } + } + + // singleton client for connection reuse and better performance + private static final OkHttpClient client = new OkHttpClient(); + + public static String doRequest( + String secretId, String secretKey, + String service, String version, String action, + String body, String region, String token + ) throws IOException, NoSuchAlgorithmException, InvalidKeyException { + + Request request = buildRequest(secretId, secretKey, service, version, action, body, region, token); + + System.out.println(request.method() + " " + request.url()); + System.out.println(request.headers()); + System.out.println(body); + + Response response = client.newCall(request).execute(); + return response.body().string(); + } + + public static Request buildRequest( + String secretId, String secretKey, + String service, String version, String action, + String body, String region, String token + ) throws NoSuchAlgorithmException, InvalidKeyException { + String host = "tms.ap-shanghai.tencentcloudapi.com"; + String endpoint = "https://" + host; + String contentType = "application/json; charset=utf-8"; + String timestamp = String.valueOf(System.currentTimeMillis() / 1000); + String auth = getAuth(secretId, secretKey, host, contentType, timestamp, body); + return new Request.Builder() + .header("Host", host) + .header("X-TC-Timestamp", timestamp) + .header("X-TC-Version", version) + .header("X-TC-Action", action) + .header("X-TC-Region", region) + .header("X-TC-Token", token) + .header("X-TC-RequestClient", "SDK_JAVA_BAREBONE") + .header("Authorization", auth) + .url(endpoint) + .post(RequestBody.create(MediaType.parse(contentType), body)) + .build(); + } + + private static String getAuth( + String secretId, String secretKey, String host, String contentType, + String timestamp, String body + ) throws NoSuchAlgorithmException, InvalidKeyException { + String canonicalUri = "/"; + String canonicalQueryString = ""; + String canonicalHeaders = "content-type:" + contentType + "\nhost:" + host + "\n"; + String signedHeaders = "content-type;host"; + + String hashedRequestPayload = sha256Hex(body.getBytes(StandardCharsets.UTF_8)); + String canonicalRequest = "POST" + + "\n" + + canonicalUri + + "\n" + + canonicalQueryString + + "\n" + + canonicalHeaders + + "\n" + + signedHeaders + + "\n" + + hashedRequestPayload; + + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + sdf.setTimeZone(TimeZone.getTimeZone("UTC")); + String date = sdf.format(new Date(Long.valueOf(timestamp + "000"))); + String service = host.split("\\.")[0]; + String credentialScope = date + "/" + service + "/" + "tc3_request"; + String hashedCanonicalRequest = + sha256Hex(canonicalRequest.getBytes(StandardCharsets.UTF_8)); + String stringToSign = + "TC3-HMAC-SHA256\n" + timestamp + "\n" + credentialScope + "\n" + hashedCanonicalRequest; + + byte[] secretDate = hmac256(("TC3" + secretKey).getBytes(StandardCharsets.UTF_8), date); + byte[] secretService = hmac256(secretDate, service); + byte[] secretSigning = hmac256(secretService, "tc3_request"); + String signature = + printHexBinary(hmac256(secretSigning, stringToSign)).toLowerCase(); + return "TC3-HMAC-SHA256 " + + "Credential=" + + secretId + + "/" + + credentialScope + + ", " + + "SignedHeaders=" + + signedHeaders + + ", " + + "Signature=" + + signature; + } + + public static String sha256Hex(byte[] b) throws NoSuchAlgorithmException { + MessageDigest md; + md = MessageDigest.getInstance("SHA-256"); + byte[] d = md.digest(b); + return printHexBinary(d).toLowerCase(); + } + + private static final char[] hexCode = "0123456789ABCDEF".toCharArray(); + + public static String printHexBinary(byte[] data) { + StringBuilder r = new StringBuilder(data.length * 2); + for (byte b : data) { + r.append(hexCode[(b >> 4) & 0xF]); + r.append(hexCode[(b & 0xF)]); + } + return r.toString(); + } + + public static byte[] hmac256(byte[] key, String msg) throws NoSuchAlgorithmException, InvalidKeyException { + Mac mac = Mac.getInstance("HmacSHA256"); + SecretKeySpec secretKeySpec = new SecretKeySpec(key, mac.getAlgorithm()); + mac.init(secretKeySpec); + return mac.doFinal(msg.getBytes(StandardCharsets.UTF_8)); + } +} \ No newline at end of file diff --git a/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/cos/TxApiSdkUtils.java b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/cos/TxApiSdkUtils.java new file mode 100644 index 0000000..fc20599 --- /dev/null +++ b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/cos/TxApiSdkUtils.java @@ -0,0 +1,251 @@ +package com.ruoyi.common.cos; + +import cn.hutool.core.codec.Base64; +import com.alibaba.fastjson.JSONObject; +import com.tencent.cloud.CosStsClient; +import com.tencent.cloud.Policy; +import com.tencent.cloud.Response; +import com.tencent.cloud.Statement; +import com.tencent.cloud.cos.util.Jackson; +import com.tencentcloudapi.common.AbstractModel; +import com.tencentcloudapi.common.Credential; +import com.tencentcloudapi.common.profile.ClientProfile; +import com.tencentcloudapi.common.profile.HttpProfile; + +import com.tencentcloudapi.common.exception.TencentCloudSDKException; +import com.tencentcloudapi.ims.v20201229.ImsClient; +import com.tencentcloudapi.ims.v20201229.models.ImageModerationRequest; +import com.tencentcloudapi.ims.v20201229.models.ImageModerationResponse; +import com.tencentcloudapi.sms.v20210111.SmsClient; +import com.tencentcloudapi.sms.v20210111.models.SendSmsRequest; +import com.tencentcloudapi.sms.v20210111.models.SendSmsResponse; +import com.tencentcloudapi.tms.v20201229.TmsClient; +import com.tencentcloudapi.tms.v20201229.models.TextModerationRequest; +import com.tencentcloudapi.tms.v20201229.models.TextModerationResponse; + +import java.util.TreeMap; + + +public class TxApiSdkUtils +{ + public static void main(String [] args) { + +// System.out.printf(checkContext("你好").toString()); +// System.out.printf(checkImages("https://xgtpt.oss-cn-hangzhou.aliyuncs.com/image/1708593052292148w_181&h_180.png").toString()); + +// sendSmsMsg("18225698628","256896"); + + + } + + + /** + * 获取上传临时密钥 + */ + public void getCredential() { + TreeMap config = new TreeMap(); + try { + //这里的 SecretId 和 SecretKey 代表了用于申请临时密钥的永久身份(主账号、子账号等),子账号需要具有操作存储桶的权限。 + String secretId = System.getenv("AKIDMcmoeNr64nIpicWBYeU6TaR8h280uyAF");//用户的 SecretId,建议使用子账号密钥,授权遵循最小权限指引,降低使用风险。子账号密钥获取可参见 https://cloud.tencent.com/document/product/598/37140 + String secretKey = System.getenv("yg8JEzVmriLjtqZ3KURUIrDRQ9euxmbI");//用户的 SecretKey,建议使用子账号密钥,授权遵循最小权限指引,降低使用风险。子账号密钥获取可参见 https://cloud.tencent.com/document/product/598/37140 + // 替换为您的云 api 密钥 SecretId + config.put("secretId", secretId); + // 替换为您的云 api 密钥 SecretKey + config.put("secretKey", secretKey); + + // 初始化 policy + Policy policy = new Policy(); + + // 设置域名: + // 如果您使用了腾讯云 cvm,可以设置内部域名 + //config.put("host", "sts.internal.tencentcloudapi.com"); + + // 临时密钥有效时长,单位是秒,默认 1800 秒,目前主账号最长 2 小时(即 7200 秒),子账号最长 36 小时(即 129600)秒 + config.put("durationSeconds", 1800); + // 换成您的 bucket + config.put("bucket", "examplebucket-1250000000"); + // 换成 bucket 所在地区 + config.put("region", "ap-shanghai"); + + // 开始构建一条 statement + Statement statement = new Statement(); + // 声明设置的结果是允许操作 + statement.setEffect("allow"); + /** + * 密钥的权限列表。必须在这里指定本次临时密钥所需要的权限。 + * 权限列表请参见 https://cloud.tencent.com/document/product/436/31923 + * 规则为 {project}:{interfaceName} + * project : 产品缩写 cos相关授权为值为cos,数据万象(数据处理)相关授权值为ci + * 授权所有接口用*表示,例如 cos:*,ci:* + * 添加一批操作权限 : + */ + statement.addActions(new String[]{ + "cos:PutObject", + // 表单上传、小程序上传 + "cos:PostObject", + // 分块上传 + "cos:InitiateMultipartUpload", + "cos:ListMultipartUploads", + "cos:ListParts", + "cos:UploadPart", + "cos:CompleteMultipartUpload", + // 处理相关接口一般为数据万象产品 权限中以ci开头 + // 创建媒体处理任务 + "ci:CreateMediaJobs", + // 文件压缩 + "ci:CreateFileProcessJobs" + }); + + /** + * 这里改成允许的路径前缀,可以根据自己网站的用户登录态判断允许上传的具体路径 + * 资源表达式规则分对象存储(cos)和数据万象(ci)两种 + * 数据处理、审核相关接口需要授予ci资源权限 + * cos : qcs::cos:{region}:uid/{appid}:{bucket}/{path} + * ci : qcs::ci:{region}:uid/{appid}:bucket/{bucket}/{path} + * 列举几种典型的{path}授权场景: + * 1、允许访问所有对象:"*" + * 2、允许访问指定的对象:"a/a1.txt", "b/b1.txt" + * 3、允许访问指定前缀的对象:"a*", "a/*", "b/*" + * 如果填写了“*”,将允许用户访问所有资源;除非业务需要,否则请按照最小权限原则授予用户相应的访问权限范围。 + * + * 示例:授权examplebucket-1250000000 bucket目录下的所有资源给cos和ci 授权两条Resource + */ + statement.addResources(new String[]{ + "qcs::cos:ap-chongqing:uid/1250000000:examplebucket-1250000000/*", + "qcs::ci:ap-chongqing:uid/1250000000:bucket/examplebucket-1250000000/*"}); + + // 把一条 statement 添加到 policy + // 可以添加多条 + policy.addStatement(statement); + // 将 Policy 示例转化成 String,可以使用任何 json 转化方式,这里是本 SDK 自带的推荐方式 + config.put("policy", Jackson.toJsonPrettyString(policy)); + + Response response = CosStsClient.getCredential(config); + System.out.println(response.credentials.tmpSecretId); + System.out.println(response.credentials.tmpSecretKey); + System.out.println(response.credentials.sessionToken); + } catch (Exception e) { + e.printStackTrace(); + throw new IllegalArgumentException("no valid secret !"); + } + } + + /** + * 腾讯云文件安全检测 + * @param content + * @return + */ + public static JSONObject checkContext(String content){ + try{ + // 实例化一个认证对象,入参需要传入腾讯云账户 SecretId 和 SecretKey,此处还需注意密钥对的保密 + // 代码泄露可能会导致 SecretId 和 SecretKey 泄露,并威胁账号下所有资源的安全性。以下代码示例仅供参考,建议采用更安全的方式来使用密钥,请参见:https://cloud.tencent.com/document/product/1278/85305 + // 密钥可前往官网控制台 https://console.cloud.tencent.com/cam/capi 进行获取 + Credential cred = new Credential("AKIDMcmoeNr64nIpicWBYeU6TaR8h280uyAF", "yg8JEzVmriLjtqZ3KURUIrDRQ9euxmbI"); + // 实例化一个http选项,可选的,没有特殊需求可以跳过 + HttpProfile httpProfile = new HttpProfile(); + httpProfile.setEndpoint("tms.ap-shanghai.tencentcloudapi.com"); + // 实例化一个client选项,可选的,没有特殊需求可以跳过 + ClientProfile clientProfile = new ClientProfile(); + clientProfile.setHttpProfile(httpProfile); + // 实例化要请求产品的client对象,clientProfile是可选的 + TmsClient client = new TmsClient(cred, "ap-shanghai", clientProfile); + // 实例化一个请求对象,每个接口都会对应一个request对象 + TextModerationRequest req = new TextModerationRequest(); + + String str = Base64.encode(content); +// System.out.printf(str); + req.setContent(str); + // 返回的resp是一个TextModerationResponse的实例,与请求对象对应 + TextModerationResponse resp = client.TextModeration(req); + // 输出json格式的字符串回包 + + String res = (AbstractModel.toJsonString(resp)); + System.out.println(res); + return JSONObject.parseObject(res); + } catch (TencentCloudSDKException e) { + System.out.println(e.toString()); + return null; + } + } + + + /** + * 腾讯云图片安全检测 + * @param imgUrl + * @return + */ + public static JSONObject checkImages(String imgUrl){ + try{ + // 实例化一个认证对象,入参需要传入腾讯云账户 SecretId 和 SecretKey,此处还需注意密钥对的保密 + // 代码泄露可能会导致 SecretId 和 SecretKey 泄露,并威胁账号下所有资源的安全性。以下代码示例仅供参考,建议采用更安全的方式来使用密钥,请参见:https://cloud.tencent.com/document/product/1278/85305 + // 密钥可前往官网控制台 https://console.cloud.tencent.com/cam/capi 进行获取 + Credential cred = new Credential("AKIDMcmoeNr64nIpicWBYeU6TaR8h280uyAF", "yg8JEzVmriLjtqZ3KURUIrDRQ9euxmbI"); + // 实例化一个http选项,可选的,没有特殊需求可以跳过 + HttpProfile httpProfile = new HttpProfile(); + httpProfile.setEndpoint("ims.ap-shanghai.tencentcloudapi.com"); + // 实例化一个client选项,可选的,没有特殊需求可以跳过 + ClientProfile clientProfile = new ClientProfile(); + clientProfile.setHttpProfile(httpProfile); + // 实例化要请求产品的client对象,clientProfile是可选的 + ImsClient client = new ImsClient(cred, "ap-shanghai", clientProfile); + // 实例化一个请求对象,每个接口都会对应一个request对象jkighjkhgkhgkhgjhghkjj + ImageModerationRequest req = new ImageModerationRequest(); + req.setFileUrl(imgUrl); + // 返回的resp是一个ImageModerationResponse的实例,与请求对象对应 + ImageModerationResponse resp = client.ImageModeration(req); + // 输出json格式的字符串回包 + String res = (AbstractModel.toJsonString(resp)); + System.out.println(res); + return JSONObject.parseObject(res); + } catch (TencentCloudSDKException e) { + System.out.println(e.toString()); + return null; + } + } + + + /** + * 腾讯云发送短信 + * @param phoneNumber + * @param code + * @return + */ + public static JSONObject sendSmsMsg(String phoneNumber, String code){ + try{ + // 实例化一个认证对象,入参需要传入腾讯云账户 SecretId 和 SecretKey,此处还需注意密钥对的保密 + // 代码泄露可能会导致 SecretId 和 SecretKey 泄露,并威胁账号下所有资源的安全性。以下代码示例仅供参考,建议采用更安全的方式来使用密钥,请参见:https://cloud.tencent.com/document/product/1278/85305 + // 密钥可前往官网控制台 https://console.cloud.tencent.com/cam/capi 进行获取 + Credential cred = new Credential("AKIDMcmoeNr64nIpicWBYeU6TaR8h280uyAF", "yg8JEzVmriLjtqZ3KURUIrDRQ9euxmbI"); + // 实例化一个http选项,可选的,没有特殊需求可以跳过 + HttpProfile httpProfile = new HttpProfile(); + httpProfile.setEndpoint("sms.tencentcloudapi.com"); + // 实例化一个client选项,可选的,没有特殊需求可以跳过 + ClientProfile clientProfile = new ClientProfile(); + clientProfile.setHttpProfile(httpProfile); + // 实例化要请求产品的client对象,clientProfile是可选的 + SmsClient client = new SmsClient(cred, "ap-nanjing", clientProfile); + // 实例化一个请求对象,每个接口都会对应一个request对象 + SendSmsRequest req = new SendSmsRequest(); + + String[] phoneNumberSet1 = {phoneNumber}; + req.setPhoneNumberSet(phoneNumberSet1); + + req.setSmsSdkAppId("1400926380"); + req.setTemplateId("2222045"); + req.setSignName("合肥小图科技"); + + String[] templateParamSet1 = {code}; + req.setTemplateParamSet(templateParamSet1); + + // 返回的resp是一个SendSmsResponse的实例,与请求对象对应 + SendSmsResponse resp = client.SendSms(req); + // 输出json格式的字符串回包 + String res = (AbstractModel.toJsonString(resp)); + return JSONObject.parseObject(res); + } catch (TencentCloudSDKException e) { + System.out.println(e.toString()); + return null; + } + } + +} \ No newline at end of file diff --git a/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/cos/auth/COSSigner.java b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/cos/auth/COSSigner.java new file mode 100644 index 0000000..93dc6d2 --- /dev/null +++ b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/cos/auth/COSSigner.java @@ -0,0 +1,104 @@ +package com.ruoyi.common.cos.auth; + +/* + * Copyright 2010-2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + + * According to cos feature, we modify some class,comment, field name, etc. + */ + + +import org.apache.commons.codec.digest.DigestUtils; +import org.apache.commons.codec.digest.HmacUtils; + +import java.util.Date; +import java.util.HashSet; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +public class COSSigner { + private static Set needSignedHeaderSet = new HashSet<>(); + private Boolean isCIWorkflowRequest = false; + // Time offset between local and server + private int localTimeDelta = 0; + + static { + needSignedHeaderSet.add("cache-control"); + needSignedHeaderSet.add("content-disposition"); + needSignedHeaderSet.add("content-encoding"); + needSignedHeaderSet.add("content-length"); + needSignedHeaderSet.add("content-md5"); + needSignedHeaderSet.add("content-type"); + needSignedHeaderSet.add("expect"); + needSignedHeaderSet.add("expires"); + needSignedHeaderSet.add("host"); + needSignedHeaderSet.add("if-match"); + needSignedHeaderSet.add("if-modified-since"); + needSignedHeaderSet.add("if-none-match"); + needSignedHeaderSet.add("if-unmodified-since"); + needSignedHeaderSet.add("origin"); + needSignedHeaderSet.add("range"); + needSignedHeaderSet.add("transfer-encoding"); + } + + public String buildPostObjectSignature(String secretKey, String keyTime, String policy) { + String signKey = HmacUtils.hmacSha1Hex(secretKey, keyTime); + String stringToSign = DigestUtils.sha1Hex(policy); + return HmacUtils.hmacSha1Hex(signKey, stringToSign); + } + + public boolean needSignedHeader(String header) { + return needSignedHeaderSet.contains(header) || header.startsWith("x-cos-"); + } + + + private String buildSignMemberStr(Map signHeaders) { + StringBuilder strBuilder = new StringBuilder(); + boolean seenOne = false; + for (String key : signHeaders.keySet()) { + if (!seenOne) { + seenOne = true; + } else { + strBuilder.append(";"); + } + strBuilder.append(key); + } + return strBuilder.toString(); + } + + private String formatMapToStr(Map kVMap) { + StringBuilder strBuilder = new StringBuilder(); + boolean seeOne = false; + for (Entry entry : kVMap.entrySet()) { + String key = entry.getKey(); + String value = entry.getValue(); + if (!seeOne) { + seeOne = true; + } else { + strBuilder.append("&"); + } + strBuilder.append(key).append("=").append(value); + } + return strBuilder.toString(); + } + + private String buildTimeStr(Date startTime, Date endTime) { + StringBuilder strBuilder = new StringBuilder(); + long startTimestamp = startTime.getTime() / 1000 + localTimeDelta; + long endTimestamp = endTime.getTime() / 1000 + localTimeDelta; + strBuilder.append(startTimestamp).append(";").append(endTimestamp); + return strBuilder.toString(); + } + +} diff --git a/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/cos/utils/VersionInfoUtils.java b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/cos/utils/VersionInfoUtils.java new file mode 100644 index 0000000..4c95432 --- /dev/null +++ b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/cos/utils/VersionInfoUtils.java @@ -0,0 +1,126 @@ +package com.ruoyi.common.cos.utils; + +/* + * Copyright 2010-2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + + * According to cos feature, we modify some class,comment, field name, etc. + */ + + + +import java.io.InputStream; +import java.util.Properties; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class VersionInfoUtils { + /** The COS SDK version info file with SDK versioning info */ + static final String VERSION_INFO_FILE = "/versionInfo.properties"; + + /** SDK version info */ + private static volatile String version; + + /** SDK platform info */ + private static volatile String platform; + + /** User Agent info */ + private static volatile String userAgent; + + /** Shared logger for any issues while loading version information */ + private static final Logger log = LoggerFactory.getLogger(VersionInfoUtils.class); + + /** + * Returns the current version for the COS SDK in which this class is running. Version + * information is obtained from from the versionInfo.properties file which the COS Java SDK + * build process generates. + * + * @return The current version for the COS SDK, if known, otherwise returns a string indicating + * that the version information is not available. + */ + public static String getVersion() { + if (version == null) { + synchronized (VersionInfoUtils.class) { + if (version == null) { + initializeVersion(); + } + } + } + return version; + } + + /** + * Returns the current platform for the COS SDK in which this class is running. Version + * information is obtained from from the versionInfo.properties file which the COS Java SDK + * build process generates. + * + * @return The current platform for the COS SDK, if known, otherwise returns a string indicating + * that the platform information is not available. + */ + public static String getPlatform() { + if (platform == null) { + synchronized (VersionInfoUtils.class) { + if (platform == null) { + initializeVersion(); + } + } + } + return platform; + } + + /** + * @return Returns the User Agent string to be used when communicating with the COS services. + * The User Agent encapsulates SDK, Java, OS and region information. + */ + public static String getUserAgent() { + if (userAgent == null) { + synchronized(VersionInfoUtils.class) { + if (userAgent == null) { + userAgent = String.format("cos-java-sdk-v%s/%s/jdk-%s/%s", + getVersion(), + System.getProperty("os.name"), + System.getProperty("java.version"), + System.getProperty("java.vm.name")); + } + } + } + return userAgent; + } + + /** + * Loads the versionInfo.properties file from the COS Java SDK and stores the information so + * that the file doesn't have to be read the next time the data is needed. + */ + private static void initializeVersion() { + InputStream inputStream = VersionInfoUtils.class.getResourceAsStream(VERSION_INFO_FILE); + Properties versionInfoProperties = new Properties(); + try { + if (inputStream == null) { + throw new Exception(VERSION_INFO_FILE + " not found on classpath"); + } + + versionInfoProperties.load(inputStream); + version = versionInfoProperties.getProperty("version"); + } catch (Exception e) { + log.info("Unable to load version information for the running SDK: " + e.getMessage()); + version = "unknown-version"; + platform = "java"; + } finally { + try { + inputStream.close(); + } catch (Exception e) { + } + } + } +} diff --git a/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/enums/BusinessStatus.java b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/enums/BusinessStatus.java new file mode 100644 index 0000000..10b7306 --- /dev/null +++ b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/enums/BusinessStatus.java @@ -0,0 +1,20 @@ +package com.ruoyi.common.enums; + +/** + * 操作状态 + * + * @author ruoyi + * + */ +public enum BusinessStatus +{ + /** + * 成功 + */ + SUCCESS, + + /** + * 失败 + */ + FAIL, +} diff --git a/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/enums/BusinessType.java b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/enums/BusinessType.java new file mode 100644 index 0000000..2e17c4a --- /dev/null +++ b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/enums/BusinessType.java @@ -0,0 +1,59 @@ +package com.ruoyi.common.enums; + +/** + * 业务操作类型 + * + * @author ruoyi + */ +public enum BusinessType +{ + /** + * 其它 + */ + OTHER, + + /** + * 新增 + */ + INSERT, + + /** + * 修改 + */ + UPDATE, + + /** + * 删除 + */ + DELETE, + + /** + * 授权 + */ + GRANT, + + /** + * 导出 + */ + EXPORT, + + /** + * 导入 + */ + IMPORT, + + /** + * 强退 + */ + FORCE, + + /** + * 生成代码 + */ + GENCODE, + + /** + * 清空数据 + */ + CLEAN, +} diff --git a/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/enums/DataSourceType.java b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/enums/DataSourceType.java new file mode 100644 index 0000000..0d945be --- /dev/null +++ b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/enums/DataSourceType.java @@ -0,0 +1,19 @@ +package com.ruoyi.common.enums; + +/** + * 数据源 + * + * @author ruoyi + */ +public enum DataSourceType +{ + /** + * 主库 + */ + MASTER, + + /** + * 从库 + */ + SLAVE +} diff --git a/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/enums/HttpMethod.java b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/enums/HttpMethod.java new file mode 100644 index 0000000..be6f739 --- /dev/null +++ b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/enums/HttpMethod.java @@ -0,0 +1,36 @@ +package com.ruoyi.common.enums; + +import java.util.HashMap; +import java.util.Map; +import org.springframework.lang.Nullable; + +/** + * 请求方式 + * + * @author ruoyi + */ +public enum HttpMethod +{ + GET, HEAD, POST, PUT, PATCH, DELETE, OPTIONS, TRACE; + + private static final Map mappings = new HashMap<>(16); + + static + { + for (HttpMethod httpMethod : values()) + { + mappings.put(httpMethod.name(), httpMethod); + } + } + + @Nullable + public static HttpMethod resolve(@Nullable String method) + { + return (method != null ? mappings.get(method) : null); + } + + public boolean matches(String method) + { + return (this == resolve(method)); + } +} diff --git a/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/enums/LimitType.java b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/enums/LimitType.java new file mode 100644 index 0000000..c609fd8 --- /dev/null +++ b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/enums/LimitType.java @@ -0,0 +1,20 @@ +package com.ruoyi.common.enums; + +/** + * 限流类型 + * + * @author ruoyi + */ + +public enum LimitType +{ + /** + * 默认策略全局限流 + */ + DEFAULT, + + /** + * 根据请求者IP进行限流 + */ + IP +} diff --git a/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/enums/OperatorType.java b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/enums/OperatorType.java new file mode 100644 index 0000000..bdd143c --- /dev/null +++ b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/enums/OperatorType.java @@ -0,0 +1,24 @@ +package com.ruoyi.common.enums; + +/** + * 操作人类别 + * + * @author ruoyi + */ +public enum OperatorType +{ + /** + * 其它 + */ + OTHER, + + /** + * 后台用户 + */ + MANAGE, + + /** + * 手机端用户 + */ + MOBILE +} diff --git a/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/enums/UserStatus.java b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/enums/UserStatus.java new file mode 100644 index 0000000..d7ff44a --- /dev/null +++ b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/enums/UserStatus.java @@ -0,0 +1,30 @@ +package com.ruoyi.common.enums; + +/** + * 用户状态 + * + * @author ruoyi + */ +public enum UserStatus +{ + OK("0", "正常"), DISABLE("1", "停用"), DELETED("2", "删除"); + + private final String code; + private final String info; + + UserStatus(String code, String info) + { + this.code = code; + this.info = info; + } + + public String getCode() + { + return code; + } + + public String getInfo() + { + return info; + } +} diff --git a/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/exception/CustomException.java b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/exception/CustomException.java new file mode 100644 index 0000000..1a51de4 --- /dev/null +++ b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/exception/CustomException.java @@ -0,0 +1,53 @@ + +package com.ruoyi.common.exception; + +import com.ruoyi.common.exception.enums.abs.AbstractBaseExceptionEnum; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.util.ArrayList; +import java.util.List; + +/** + * 业务异常 + * + * @author xuyuxiang + * @date 2020/4/8 15:54 + */ +@EqualsAndHashCode(callSuper = true) +@Data +public class CustomException extends RuntimeException { + + private Integer code; + + private String errorMessage; + + + private List objectList = new ArrayList(); + + public CustomException(Integer code, String errorMessage) { + super(errorMessage); + this.code = code; + this.errorMessage = errorMessage; + } + + public CustomException(String errorMessage) { + super(errorMessage); + this.code = 500; + this.errorMessage = errorMessage; + } + + public CustomException(AbstractBaseExceptionEnum exception) { + super(exception.getMessage()); + this.code = exception.getCode(); + this.errorMessage = exception.getMessage(); + } + + public CustomException(AbstractBaseExceptionEnum exception, List objectList) { + super(exception.getMessage()); + this.code = exception.getCode(); + this.errorMessage = exception.getMessage(); + this.objectList = objectList; + } + +} diff --git a/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/exception/DemoModeException.java b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/exception/DemoModeException.java new file mode 100644 index 0000000..f6ad2ab --- /dev/null +++ b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/exception/DemoModeException.java @@ -0,0 +1,15 @@ +package com.ruoyi.common.exception; + +/** + * 演示模式异常 + * + * @author ruoyi + */ +public class DemoModeException extends RuntimeException +{ + private static final long serialVersionUID = 1L; + + public DemoModeException() + { + } +} diff --git a/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/exception/GlobalException.java b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/exception/GlobalException.java new file mode 100644 index 0000000..0bb6768 --- /dev/null +++ b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/exception/GlobalException.java @@ -0,0 +1,59 @@ +package com.ruoyi.common.exception; + +/** + * 全局异常 + * + * @author ruoyi + */ +public class GlobalException extends RuntimeException +{ + + private static final long serialVersionUID = 1L; + + /** + * 错误提示 + */ + private String message; + + /** + * 错误明细,内部调试错误 + * + * 和 {@link CommonResult#getDetailMessage()} 一致的设计 + */ + private String detailMessage; + + /** + * 空构造方法,避免反序列化问题 + */ + public GlobalException() + { + } + + public GlobalException(String message) + { + this.message = message; + } + + public String getDetailMessage() + { + return detailMessage; + } + + public GlobalException setDetailMessage(String detailMessage) + { + this.detailMessage = detailMessage; + return this; + } + + @Override + public String getMessage() + { + return message; + } + + public GlobalException setMessage(String message) + { + this.message = message; + return this; + } +} \ No newline at end of file diff --git a/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/exception/ServiceException.java b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/exception/ServiceException.java new file mode 100644 index 0000000..ac53760 --- /dev/null +++ b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/exception/ServiceException.java @@ -0,0 +1,84 @@ +package com.ruoyi.common.exception; + +import com.ruoyi.common.exception.enums.abs.AbstractBaseExceptionEnum; + +/** + * 业务异常 + * + * @author ruoyi + */ +public final class ServiceException extends RuntimeException +{ + private static final long serialVersionUID = 1L; + + /** + * 错误码 + */ + private Integer code; + + /** + * 错误提示 + */ + private String message; + + /** + * 错误明细,内部调试错误 + * + * 和 {@link CommonResult#getDetailMessage()} 一致的设计 + */ + private String detailMessage; + + /** + * 空构造方法,避免反序列化问题 + */ + public ServiceException() + { + } + + public ServiceException(String message) + { + this.message = message; + } + + public ServiceException(String message, Integer code) + { + this.message = message; + this.code = code; + } + + public String getDetailMessage() + { + return detailMessage; + } + + @Override + public String getMessage() + { + return message; + } + + public Integer getCode() + { + return code; + } + + public ServiceException setMessage(String message) + { + + this.message = message; + return this; + } + + public ServiceException setDetailMessage(String detailMessage) + { + this.detailMessage = detailMessage; + return this; + } + + + public ServiceException(AbstractBaseExceptionEnum exception) { + super(exception.getMessage()); + this.code = exception.getCode(); + this.message = exception.getMessage(); + } +} \ No newline at end of file diff --git a/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/exception/UtilException.java b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/exception/UtilException.java new file mode 100644 index 0000000..980fa46 --- /dev/null +++ b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/exception/UtilException.java @@ -0,0 +1,26 @@ +package com.ruoyi.common.exception; + +/** + * 工具类异常 + * + * @author ruoyi + */ +public class UtilException extends RuntimeException +{ + private static final long serialVersionUID = 8247610319171014183L; + + public UtilException(Throwable e) + { + super(e.getMessage(), e); + } + + public UtilException(String message) + { + super(message); + } + + public UtilException(String message, Throwable throwable) + { + super(message, throwable); + } +} diff --git a/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/exception/base/BaseException.java b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/exception/base/BaseException.java new file mode 100644 index 0000000..b55d72e --- /dev/null +++ b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/exception/base/BaseException.java @@ -0,0 +1,97 @@ +package com.ruoyi.common.exception.base; + +import com.ruoyi.common.utils.MessageUtils; +import com.ruoyi.common.utils.StringUtils; + +/** + * 基础异常 + * + * @author ruoyi + */ +public class BaseException extends RuntimeException +{ + private static final long serialVersionUID = 1L; + + /** + * 所属模块 + */ + private String module; + + /** + * 错误码 + */ + private String code; + + /** + * 错误码对应的参数 + */ + private Object[] args; + + /** + * 错误消息 + */ + private String defaultMessage; + + public BaseException(String module, String code, Object[] args, String defaultMessage) + { + this.module = module; + this.code = code; + this.args = args; + this.defaultMessage = defaultMessage; + } + + public BaseException(String module, String code, Object[] args) + { + this(module, code, args, null); + } + + public BaseException(String module, String defaultMessage) + { + this(module, null, null, defaultMessage); + } + + public BaseException(String code, Object[] args) + { + this(null, code, args, null); + } + + public BaseException(String defaultMessage) + { + this(null, null, null, defaultMessage); + } + + @Override + public String getMessage() + { + String message = null; + if (!StringUtils.isEmpty(code)) + { + message = MessageUtils.message(code, args); + } + if (message == null) + { + message = defaultMessage; + } + return message; + } + + public String getModule() + { + return module; + } + + public String getCode() + { + return code; + } + + public Object[] getArgs() + { + return args; + } + + public String getDefaultMessage() + { + return defaultMessage; + } +} diff --git a/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/exception/enums/AuthExceptionEnum.java b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/exception/enums/AuthExceptionEnum.java new file mode 100644 index 0000000..45eb4b8 --- /dev/null +++ b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/exception/enums/AuthExceptionEnum.java @@ -0,0 +1,109 @@ +/* +Copyright [2020] [https://www.stylefeng.cn] + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +Guns采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点: + +1.请不要删除和修改根目录下的LICENSE文件。 +2.请不要删除和修改Guns源码头部的版权声明。 +3.请保留源码和相关描述文件的项目出处,作者声明等。 +4.分发源码时候,请注明软件出处 https://gitee.com/stylefeng/guns-separation +5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://gitee.com/stylefeng/guns-separation +6.若您的项目无法满足以上几点,可申请商业授权,获取Guns商业授权许可,请在官网购买授权,地址为 https://www.stylefeng.cn + */ +package com.ruoyi.common.exception.enums; + + +import com.ruoyi.common.exception.enums.abs.AbstractBaseExceptionEnum; + +/** + * 认证相关的异常的枚举 + *

+ * 认证和鉴权的区别: + *

+ * 认证可以证明你能登录系统,认证的过程是校验token的过程 + * 鉴权可以证明你有系统的哪些权限,鉴权的过程是校验角色是否包含某些接口的权限 + * + * @author stylefeng + * @date 2019/7/18 22:22 + */ +public enum AuthExceptionEnum implements AbstractBaseExceptionEnum { + + /** + * 账号或密码为空 + */ + ACCOUNT_PWD_EMPTY(1, "账号或密码为空"), + + /** + * 账号密码错误 + */ + ACCOUNT_PWD_ERROR(2, "账号或密码错误"), + + /** + * 验证码错误 + */ + VALID_CODE_ERROR(3, "验证码错误,请检查captcha参数"), + + /** + * 请求token为空 + */ + REQUEST_TOKEN_EMPTY(700, "请求token为空"), + + /** + * token格式不正确,token请以Bearer开头 + */ + NOT_VALID_TOKEN_TYPE(700, "token格式不正确,token请以Bearer开头,并且Bearer后边带一个空格"), + + /** + * 请求token错误 + */ + REQUEST_TOKEN_ERROR(700, "请求token错误"), + + /** + * 账号被冻结 + */ + ACCOUNT_FREEZE_ERROR(7, "账号被冻结,请联系管理员"), + + /** + * 登录已过期 + */ + LOGIN_EXPIRED(8, "登录已过期,请重新登录"), + + /** + * 无登录用户 + */ + NO_LOGIN_USER(9, "无登录用户"); + + + + private final Integer code; + + private final String message; + + AuthExceptionEnum(Integer code, String message) { + this.code = code; + this.message = message; + } + + @Override + public Integer getCode() { + return code; + } + + @Override + public String getMessage() { + return message; + } + +} diff --git a/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/exception/enums/CoreExceptionEnum.java b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/exception/enums/CoreExceptionEnum.java new file mode 100644 index 0000000..268471f --- /dev/null +++ b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/exception/enums/CoreExceptionEnum.java @@ -0,0 +1,138 @@ +package com.ruoyi.common.exception.enums; + + +import com.ruoyi.common.exception.enums.abs.AbstractBaseExceptionEnum; + +/** + * @author liwenlong + * @date 2021/11/1 19:34 + */ + + +public enum CoreExceptionEnum implements AbstractBaseExceptionEnum { + + + /** + * 用户相关 + */ + REGISTER_FAIL( "注册失败"), + PWD_ERROR( "密码错误"), + ACCOUNT_NOT_EXIST( "账号不存在"), + ACCOUNT_DISABLE( "账号被冻结"), + + PHONE_NOT_EXIST( "手机号不存在"), + + MOBILE_BIND_MAKE( "请使用绑定的手机号码"), + ACCOUNT_HAS_EXIST( "账号已存在,请重新输入"), + + PHONE_HAS_EXIST( "手机号已存在,请重新输入"), + + + + /** + * 邀请码 + */ + REFEREE_CODE_ERROR( "邀请码错误"), + + + FIGURE_CODE_ERROR( "图形验证码错误"), + + FIGURE_CODE_NOT_EXIST( "请先获取图形验证码"), + + + /** + * 短信 + */ + SMS_SEND_FAIL( "短信发送失败"), + + + /** + * 参数 + */ + ERROR_PARAM("参数错误"), + NOT_NULL_PARAM("参数不能为空"), + ERROR_DATA("数据错误"), + + ERROR_FIELD_NAME("字段名称错误"), + + /** + * 余额 + */ + + PRICE_ZERO(210, "支付金额为零"), + BALANCE_INSUFFICIENT (220, "余额不足"), + + INTEGRAL_INSUFFICIENT (230, "积分不足"), + + PAY_BALANCE_ERROR (240, "支付价格错误"), + + EDIT_BALANCE_ERROR (250, "余额修改错误"), + + + /** + * 字典 + */ + NO_DICTIONARIES( "未配置字典值"), + DICTIONARIES_ERROR( "字典值格式错误"), + + + /** + * 渲染 + */ + WRITE_ERROR( "渲染界面错误"), + + RESOURCES_NOT_EXIST("资源不存在"), + IO_ERROR("流读取异常"), + + INVLIDE_DATE_STRING(400, "输入日期格式不对"), + FILE_READING_ERROR(400, "FILE_READING_ERROR!"), + FILE_NOT_FOUND(400, "FILE_NOT_FOUND!"), + PAGE_NULL(404, "请求页面不存在"), + REMOTE_SERVICE_NULL(404, "远程服务不存在"), + + + ERROR_TOKEN(520,"token异常"), + INPUT_PWD(530, "请输入支付密码"), + NO_PWD(540, "密码为空"), + UPDATE_PWD_ERROR("编辑密码错误"), + UPDATE_MOBILE_ERROR("编辑手机号错误"), + UPDATE_DATA(570, "数据更新错误"), + INSERT_DATA(580, "数据保存错误"), + ERROR_DICT_LACK(590,"字典表配置缺失"), + + + ENCRYPT_ERROR(600, "加解密错误"), + + + NO_CURRENT_USER(700, "当前没有登录的用户"), + FIELD_VALIDATE_ERROR(700, "数据库字段与实体字段不一致!"), + INIT_TABLE_EMPTY_PARAMS(701, "初始化数据库,存在为空的字段"), + + + ASYNC_ERROR(5000, "数据在被别人修改,请稍后重试"), + + ; + + private Integer code; + private String message; + + private CoreExceptionEnum(int code, String message) { + this.code = code; + this.message = message; + } + + private CoreExceptionEnum(String message) { + this.code = 500; + this.message = message; + } + + @Override + public Integer getCode() { + return this.code; + } + + @Override + public String getMessage() { + return this.message; + } +} diff --git a/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/exception/enums/ParamExceptionEnum.java b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/exception/enums/ParamExceptionEnum.java new file mode 100644 index 0000000..d77528a --- /dev/null +++ b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/exception/enums/ParamExceptionEnum.java @@ -0,0 +1,61 @@ +/* +Copyright [2020] [https://www.stylefeng.cn] + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +Guns采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点: + +1.请不要删除和修改根目录下的LICENSE文件。 +2.请不要删除和修改Guns源码头部的版权声明。 +3.请保留源码和相关描述文件的项目出处,作者声明等。 +4.分发源码时候,请注明软件出处 https://gitee.com/stylefeng/guns-separation +5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://gitee.com/stylefeng/guns-separation +6.若您的项目无法满足以上几点,可申请商业授权,获取Guns商业授权许可,请在官网购买授权,地址为 https://www.stylefeng.cn + */ +package com.ruoyi.common.exception.enums; + + +import com.ruoyi.common.exception.enums.abs.AbstractBaseExceptionEnum; + +/** + * 参数校验异常枚举 + * + * @author xuyuxiang + * @date 2020/3/25 20:11 + */ +public enum ParamExceptionEnum implements AbstractBaseExceptionEnum { + + /** + * 参数错误 + */ + PARAM_ERROR(1, "参数错误"); + + private final Integer code; + + private final String message; + + ParamExceptionEnum(Integer code, String message) { + this.code = code; + this.message = message; + } + + @Override + public Integer getCode() { + return code; + } + + @Override + public String getMessage() { + return message; + } +} diff --git a/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/exception/enums/PermissionExceptionEnum.java b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/exception/enums/PermissionExceptionEnum.java new file mode 100644 index 0000000..52def99 --- /dev/null +++ b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/exception/enums/PermissionExceptionEnum.java @@ -0,0 +1,92 @@ +/* +Copyright [2020] [https://www.stylefeng.cn] + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +Guns采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点: + +1.请不要删除和修改根目录下的LICENSE文件。 +2.请不要删除和修改Guns源码头部的版权声明。 +3.请保留源码和相关描述文件的项目出处,作者声明等。 +4.分发源码时候,请注明软件出处 https://gitee.com/stylefeng/guns-separation +5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://gitee.com/stylefeng/guns-separation +6.若您的项目无法满足以上几点,可申请商业授权,获取Guns商业授权许可,请在官网购买授权,地址为 https://www.stylefeng.cn + */ +package com.ruoyi.common.exception.enums; + + +import com.ruoyi.common.exception.enums.abs.AbstractBaseExceptionEnum; + +/** + * 授权和鉴权异常的枚举 + *

+ * 认证和鉴权的区别: + *

+ * 认证可以证明你能登录系统,认证的过程是校验token的过程 + * 鉴权可以证明你有系统的哪些权限,鉴权的过程是校验角色是否包含某些接口的权限 + * + * @author xuyuxiang + * @date 2020/3/12 10:14 + */ +public enum PermissionExceptionEnum implements AbstractBaseExceptionEnum { + + /** + * 资源路径不存在 + */ + URL_NOT_EXIST(1, "资源路径不存在,请检查请求地址"), + + /** + * 没有权限访问资源 + */ + NO_PERMISSION(2, "没有权限访问资源,请联系管理员"), + + /** + * 没有权限操作该数据 + */ + NO_PERMISSION_OPERATE(3, "没有权限操作该数据,请联系管理员"), + + /** + * 手机号已存在 + */ + MOBILE_REPEAT(4, "手机号已存在"), + + /** + * 账号已存在 + */ + ACCOUNT_REPEAT(5, "账号已存在"), + + /** + * 请指定接收数据的操作员 + */ + NO_CHOOSE_OPERATOR(7, "请指定接收数据的操作员"); + + private final Integer code; + + private final String message; + + PermissionExceptionEnum(Integer code, String message) { + this.code = code; + this.message = message; + } + + @Override + public Integer getCode() { + return code; + } + + @Override + public String getMessage() { + return message; + } + +} diff --git a/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/exception/enums/RequestMethodExceptionEnum.java b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/exception/enums/RequestMethodExceptionEnum.java new file mode 100644 index 0000000..bee388d --- /dev/null +++ b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/exception/enums/RequestMethodExceptionEnum.java @@ -0,0 +1,67 @@ +/* +Copyright [2020] [https://www.stylefeng.cn] + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +Guns采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点: + +1.请不要删除和修改根目录下的LICENSE文件。 +2.请不要删除和修改Guns源码头部的版权声明。 +3.请保留源码和相关描述文件的项目出处,作者声明等。 +4.分发源码时候,请注明软件出处 https://gitee.com/stylefeng/guns-separation +5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://gitee.com/stylefeng/guns-separation +6.若您的项目无法满足以上几点,可申请商业授权,获取Guns商业授权许可,请在官网购买授权,地址为 https://www.stylefeng.cn + */ +package com.ruoyi.common.exception.enums; + + +import com.ruoyi.common.exception.enums.abs.AbstractBaseExceptionEnum; + +/** + * 请求方法相关异常枚举 + * + * @author xuyuxiang + * @date 2020/3/11 15:33 + */ +public enum RequestMethodExceptionEnum implements AbstractBaseExceptionEnum { + + /** + * 不支持该请求方法,请求方法应为POST + */ + REQUEST_METHOD_IS_POST(1, "不支持该请求方法,请求方法应为POST"), + + /** + * 不支持该请求方法,请求方法应为GET + */ + REQUEST_METHOD_IS_GET(2, "不支持该请求方法,请求方法应为GET"); + + private final Integer code; + + private final String message; + + RequestMethodExceptionEnum(Integer code, String message) { + this.code = code; + this.message = message; + } + + @Override + public Integer getCode() { + return code; + } + + @Override + public String getMessage() { + return message; + } + +} diff --git a/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/exception/enums/RequestTypeExceptionEnum.java b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/exception/enums/RequestTypeExceptionEnum.java new file mode 100644 index 0000000..702fcda --- /dev/null +++ b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/exception/enums/RequestTypeExceptionEnum.java @@ -0,0 +1,67 @@ +/* +Copyright [2020] [https://www.stylefeng.cn] + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +Guns采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点: + +1.请不要删除和修改根目录下的LICENSE文件。 +2.请不要删除和修改Guns源码头部的版权声明。 +3.请保留源码和相关描述文件的项目出处,作者声明等。 +4.分发源码时候,请注明软件出处 https://gitee.com/stylefeng/guns-separation +5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://gitee.com/stylefeng/guns-separation +6.若您的项目无法满足以上几点,可申请商业授权,获取Guns商业授权许可,请在官网购买授权,地址为 https://www.stylefeng.cn + */ +package com.ruoyi.common.exception.enums; + + +import com.ruoyi.common.exception.enums.abs.AbstractBaseExceptionEnum; + +/** + * 请求类型相关异常枚举 + * + * @author xuyuxiang + * @date 2020/4/2 15:42 + */ +public enum RequestTypeExceptionEnum implements AbstractBaseExceptionEnum { + + /** + * 参数传递格式不支持 + */ + REQUEST_TYPE_IS_JSON(1, "参数传递格式不支持,请使用JSON格式传参"), + + /** + * 请求JSON参数格式不正确 + */ + REQUEST_JSON_ERROR(2, "请求JSON参数格式不正确,请检查参数格式"); + + private final Integer code; + + private final String message; + + RequestTypeExceptionEnum(Integer code, String message) { + this.code = code; + this.message = message; + } + + @Override + public Integer getCode() { + return code; + } + + @Override + public String getMessage() { + return message; + } + +} diff --git a/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/exception/enums/RestExceptionEnum.java b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/exception/enums/RestExceptionEnum.java new file mode 100644 index 0000000..8ebdbe5 --- /dev/null +++ b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/exception/enums/RestExceptionEnum.java @@ -0,0 +1,65 @@ +/** + * Copyright 2018-2020 stylefeng & fengshuonan (https://gitee.com/stylefeng) + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.ruoyi.common.exception.enums; + + +import com.ruoyi.common.exception.enums.abs.AbstractBaseExceptionEnum; + +/** + * rest异常 + * + * @author administrator + * @date 2016年11月12日 下午5:04:51 + */ +public enum RestExceptionEnum implements AbstractBaseExceptionEnum { + + + /** + * token异常 + */ + TOKEN_EXPIRED(700, "token过期"), + TOKEN_ERROR(700, "token验证失败"), + + AUTH_EXCEPTION(700, "token过期"); + + + RestExceptionEnum(int code, String message) { + this.code = code; + this.message = message; + } + + private Integer code; + + private String message; + + @Override + public Integer getCode() { + return code; + } + + public void setCode(Integer code) { + this.code = code; + } + + @Override + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } +} diff --git a/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/exception/enums/ServerExceptionEnum.java b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/exception/enums/ServerExceptionEnum.java new file mode 100644 index 0000000..ce9491d --- /dev/null +++ b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/exception/enums/ServerExceptionEnum.java @@ -0,0 +1,82 @@ +/* +Copyright [2020] [https://www.stylefeng.cn] + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +Guns采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点: + +1.请不要删除和修改根目录下的LICENSE文件。 +2.请不要删除和修改Guns源码头部的版权声明。 +3.请保留源码和相关描述文件的项目出处,作者声明等。 +4.分发源码时候,请注明软件出处 https://gitee.com/stylefeng/guns-separation +5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://gitee.com/stylefeng/guns-separation +6.若您的项目无法满足以上几点,可申请商业授权,获取Guns商业授权许可,请在官网购买授权,地址为 https://www.stylefeng.cn + */ +package com.ruoyi.common.exception.enums; + + +import com.ruoyi.common.exception.enums.abs.AbstractBaseExceptionEnum; + +/** + * 服务器内部相关异常枚举 + * + * @author xuyuxiang + * @date 2020/3/18 19:19 + */ +public enum ServerExceptionEnum implements AbstractBaseExceptionEnum { + + /** + * 当前请求参数为空或数据缺失 + */ + REQUEST_EMPTY(1, "当前请求参数为空或数据缺失,请联系管理员"), + + /** + * 加载中,请稍后…… + */ + SERVER_ERROR(2, "程序异常,请联系管理员"), + + /** + * 常量获取存在空值 + */ + CONSTANT_EMPTY(3, "常量获取存在空值,请检查sys_config中是否配置"), + /** + * + */ + COMMON_EXCEPTION(4, "编译异常"), + + + /** + * 请勿重复提交 + */ + NO_REPEAT_REQUEST(5, "请勿重复提交"); + + private final Integer code; + + private final String message; + + ServerExceptionEnum(Integer code, String message) { + this.code = code; + this.message = message; + } + + @Override + public Integer getCode() { + return code; + } + + @Override + public String getMessage() { + return message; + } + +} diff --git a/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/exception/enums/StatusExceptionEnum.java b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/exception/enums/StatusExceptionEnum.java new file mode 100644 index 0000000..f0ba013 --- /dev/null +++ b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/exception/enums/StatusExceptionEnum.java @@ -0,0 +1,81 @@ +/* +Copyright [2020] [https://www.stylefeng.cn] + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +Guns采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点: + +1.请不要删除和修改根目录下的LICENSE文件。 +2.请不要删除和修改Guns源码头部的版权声明。 +3.请保留源码和相关描述文件的项目出处,作者声明等。 +4.分发源码时候,请注明软件出处 https://gitee.com/stylefeng/guns-separation +5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://gitee.com/stylefeng/guns-separation +6.若您的项目无法满足以上几点,可申请商业授权,获取Guns商业授权许可,请在官网购买授权,地址为 https://www.stylefeng.cn + */ +package com.ruoyi.common.exception.enums; + + +import com.ruoyi.common.exception.enums.abs.AbstractBaseExceptionEnum; + +/** + * 状态枚举 + * + * @author stylefeng + * @date 2020/4/30 22:45 + */ +public enum StatusExceptionEnum implements AbstractBaseExceptionEnum { + + /** + * 请求状态值为空 + */ + REQUEST_EMPTY(1, "请求状态值为空"), + + /** + * 请求状值为非正确状态值 + */ + NOT_WRITE_STATUS(2, "请求状态值不合法"), + + /** + * 更新状态失败,试图更新被删除的记录 + */ + UPDATE_STATUS_ERROR(3, "更新状态失败,您试图更新被删除的记录"), + + /** + * 操作失败 + */ + OPERATOR_FAIL(500, "操作失败"),; + + private final Integer code; + + private final String message; + + StatusExceptionEnum(Integer code, String message) { + this.code = code; + this.message = message; + } + + @Override + public Integer getCode() { + return code; + } + + @Override + public String getMessage() { + return message; + } + + public static void main(String[] args) { + System.out.println(StatusExceptionEnum.NOT_WRITE_STATUS.getCode()); + } + +} diff --git a/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/exception/enums/WrapperExceptionEnum.java b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/exception/enums/WrapperExceptionEnum.java new file mode 100644 index 0000000..4d383f2 --- /dev/null +++ b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/exception/enums/WrapperExceptionEnum.java @@ -0,0 +1,72 @@ +/* +Copyright [2020] [https://www.stylefeng.cn] + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +Guns采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点: + +1.请不要删除和修改根目录下的LICENSE文件。 +2.请不要删除和修改Guns源码头部的版权声明。 +3.请保留源码和相关描述文件的项目出处,作者声明等。 +4.分发源码时候,请注明软件出处 https://gitee.com/stylefeng/guns-separation +5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://gitee.com/stylefeng/guns-separation +6.若您的项目无法满足以上几点,可申请商业授权,获取Guns商业授权许可,请在官网购买授权,地址为 https://www.stylefeng.cn + */ +package com.ruoyi.common.exception.enums; + + +import com.ruoyi.common.exception.enums.abs.AbstractBaseExceptionEnum; + +/** + * 对象包装异常 + * + * @author fengshuonan + * @date 2020/7/24 14:36 + */ +public enum WrapperExceptionEnum implements AbstractBaseExceptionEnum { + + /** + * 被包装的值不能是基本类型 + */ + BASIC_TYPE_ERROR(1, "被包装的值不能是基本类型"), + + /** + * 获取转化字段的值异常 + */ + TRANSFER_FILED_VALUE_ERROR(2, "获取转化字段的值异常"), + + /** + * 字段包装转化异常 + */ + TRANSFER_ERROR(3, "字段包装转化异常"); + + private final Integer code; + + private final String message; + + WrapperExceptionEnum(Integer code, String message) { + this.code = code; + this.message = message; + } + + @Override + public Integer getCode() { + return code; + } + + @Override + public String getMessage() { + return message; + } + +} diff --git a/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/exception/enums/abs/AbstractBaseExceptionEnum.java b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/exception/enums/abs/AbstractBaseExceptionEnum.java new file mode 100644 index 0000000..fba3a60 --- /dev/null +++ b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/exception/enums/abs/AbstractBaseExceptionEnum.java @@ -0,0 +1,53 @@ +/* +Copyright [2020] [https://www.stylefeng.cn] + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +Guns采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点: + +1.请不要删除和修改根目录下的LICENSE文件。 +2.请不要删除和修改Guns源码头部的版权声明。 +3.请保留源码和相关描述文件的项目出处,作者声明等。 +4.分发源码时候,请注明软件出处 https://gitee.com/stylefeng/guns-separation +5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://gitee.com/stylefeng/guns-separation +6.若您的项目无法满足以上几点,可申请商业授权,获取Guns商业授权许可,请在官网购买授权,地址为 https://www.stylefeng.cn + */ +package com.ruoyi.common.exception.enums.abs; + +/** + * 异常枚举格式规范 + * + * @author stylefeng + * @date 2017/12/17 22:22 + */ +public interface AbstractBaseExceptionEnum { + + /** + * 获取异常的状态码 + * + * @return 状态码 + * @author stylefeng + * @date 2020/7/9 14:28 + */ + Integer getCode(); + + /** + * 获取异常的提示信息 + * + * @return 提示信息 + * @author stylefeng + * @date 2020/7/9 14:28 + */ + String getMessage(); + +} diff --git a/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/exception/file/FileException.java b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/exception/file/FileException.java new file mode 100644 index 0000000..871f09b --- /dev/null +++ b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/exception/file/FileException.java @@ -0,0 +1,19 @@ +package com.ruoyi.common.exception.file; + +import com.ruoyi.common.exception.base.BaseException; + +/** + * 文件信息异常类 + * + * @author ruoyi + */ +public class FileException extends BaseException +{ + private static final long serialVersionUID = 1L; + + public FileException(String code, Object[] args) + { + super("file", code, args, null); + } + +} diff --git a/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/exception/file/FileNameLengthLimitExceededException.java b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/exception/file/FileNameLengthLimitExceededException.java new file mode 100644 index 0000000..70e0ec9 --- /dev/null +++ b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/exception/file/FileNameLengthLimitExceededException.java @@ -0,0 +1,16 @@ +package com.ruoyi.common.exception.file; + +/** + * 文件名称超长限制异常类 + * + * @author ruoyi + */ +public class FileNameLengthLimitExceededException extends FileException +{ + private static final long serialVersionUID = 1L; + + public FileNameLengthLimitExceededException(int defaultFileNameLength) + { + super("upload.filename.exceed.length", new Object[] { defaultFileNameLength }); + } +} diff --git a/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/exception/file/FileSizeLimitExceededException.java b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/exception/file/FileSizeLimitExceededException.java new file mode 100644 index 0000000..ec6ab05 --- /dev/null +++ b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/exception/file/FileSizeLimitExceededException.java @@ -0,0 +1,16 @@ +package com.ruoyi.common.exception.file; + +/** + * 文件名大小限制异常类 + * + * @author ruoyi + */ +public class FileSizeLimitExceededException extends FileException +{ + private static final long serialVersionUID = 1L; + + public FileSizeLimitExceededException(long defaultMaxSize) + { + super("upload.exceed.maxSize", new Object[] { defaultMaxSize }); + } +} diff --git a/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/exception/file/InvalidExtensionException.java b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/exception/file/InvalidExtensionException.java new file mode 100644 index 0000000..f1c8e83 --- /dev/null +++ b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/exception/file/InvalidExtensionException.java @@ -0,0 +1,81 @@ +package com.ruoyi.common.exception.file; + +import java.util.Arrays; +import org.apache.commons.fileupload.FileUploadException; + +/** + * 文件上传 误异常类 + * + * @author ruoyi + */ +public class InvalidExtensionException extends FileUploadException +{ + private static final long serialVersionUID = 1L; + + private String[] allowedExtension; + private String extension; + private String filename; + + public InvalidExtensionException(String[] allowedExtension, String extension, String filename) + { + super("filename : [" + filename + "], extension : [" + extension + "], allowed extension : [" + Arrays.toString(allowedExtension) + "]"); + this.allowedExtension = allowedExtension; + this.extension = extension; + this.filename = filename; + } + + public String[] getAllowedExtension() + { + return allowedExtension; + } + + public String getExtension() + { + return extension; + } + + public String getFilename() + { + return filename; + } + + public static class InvalidImageExtensionException extends InvalidExtensionException + { + private static final long serialVersionUID = 1L; + + public InvalidImageExtensionException(String[] allowedExtension, String extension, String filename) + { + super(allowedExtension, extension, filename); + } + } + + public static class InvalidFlashExtensionException extends InvalidExtensionException + { + private static final long serialVersionUID = 1L; + + public InvalidFlashExtensionException(String[] allowedExtension, String extension, String filename) + { + super(allowedExtension, extension, filename); + } + } + + public static class InvalidMediaExtensionException extends InvalidExtensionException + { + private static final long serialVersionUID = 1L; + + public InvalidMediaExtensionException(String[] allowedExtension, String extension, String filename) + { + super(allowedExtension, extension, filename); + } + } + + public static class InvalidVideoExtensionException extends InvalidExtensionException + { + private static final long serialVersionUID = 1L; + + public InvalidVideoExtensionException(String[] allowedExtension, String extension, String filename) + { + super(allowedExtension, extension, filename); + } + } +} diff --git a/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/exception/job/TaskException.java b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/exception/job/TaskException.java new file mode 100644 index 0000000..a567b40 --- /dev/null +++ b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/exception/job/TaskException.java @@ -0,0 +1,34 @@ +package com.ruoyi.common.exception.job; + +/** + * 计划策略异常 + * + * @author ruoyi + */ +public class TaskException extends Exception +{ + private static final long serialVersionUID = 1L; + + private Code code; + + public TaskException(String msg, Code code) + { + this(msg, code, null); + } + + public TaskException(String msg, Code code, Exception nestedEx) + { + super(msg, nestedEx); + this.code = code; + } + + public Code getCode() + { + return code; + } + + public enum Code + { + TASK_EXISTS, NO_TASK_EXISTS, TASK_ALREADY_STARTED, UNKNOWN, CONFIG_ERROR, TASK_NODE_NOT_AVAILABLE + } +} \ No newline at end of file diff --git a/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/exception/user/CaptchaException.java b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/exception/user/CaptchaException.java new file mode 100644 index 0000000..389dbc7 --- /dev/null +++ b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/exception/user/CaptchaException.java @@ -0,0 +1,16 @@ +package com.ruoyi.common.exception.user; + +/** + * 验证码错误异常类 + * + * @author ruoyi + */ +public class CaptchaException extends UserException +{ + private static final long serialVersionUID = 1L; + + public CaptchaException() + { + super("user.jcaptcha.error", null); + } +} diff --git a/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/exception/user/CaptchaExpireException.java b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/exception/user/CaptchaExpireException.java new file mode 100644 index 0000000..85f9486 --- /dev/null +++ b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/exception/user/CaptchaExpireException.java @@ -0,0 +1,16 @@ +package com.ruoyi.common.exception.user; + +/** + * 验证码失效异常类 + * + * @author ruoyi + */ +public class CaptchaExpireException extends UserException +{ + private static final long serialVersionUID = 1L; + + public CaptchaExpireException() + { + super("user.jcaptcha.expire", null); + } +} diff --git a/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/exception/user/UserException.java b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/exception/user/UserException.java new file mode 100644 index 0000000..c292d70 --- /dev/null +++ b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/exception/user/UserException.java @@ -0,0 +1,18 @@ +package com.ruoyi.common.exception.user; + +import com.ruoyi.common.exception.base.BaseException; + +/** + * 用户信息异常类 + * + * @author ruoyi + */ +public class UserException extends BaseException +{ + private static final long serialVersionUID = 1L; + + public UserException(String code, Object[] args) + { + super("user", code, args, null); + } +} diff --git a/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/exception/user/UserPasswordNotMatchException.java b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/exception/user/UserPasswordNotMatchException.java new file mode 100644 index 0000000..a7f3e5f --- /dev/null +++ b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/exception/user/UserPasswordNotMatchException.java @@ -0,0 +1,16 @@ +package com.ruoyi.common.exception.user; + +/** + * 用户密码不正确或不符合规范异常类 + * + * @author ruoyi + */ +public class UserPasswordNotMatchException extends UserException +{ + private static final long serialVersionUID = 1L; + + public UserPasswordNotMatchException() + { + super("user.password.not.match", null); + } +} diff --git a/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/filter/CustomInterceptor.java b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/filter/CustomInterceptor.java new file mode 100644 index 0000000..530cd05 --- /dev/null +++ b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/filter/CustomInterceptor.java @@ -0,0 +1,113 @@ +package com.ruoyi.common.filter; + +import com.ruoyi.common.annotation.CreateBy; +import com.ruoyi.common.annotation.CreateTime; +import com.ruoyi.common.annotation.UpdateBy; +import com.ruoyi.common.annotation.UpdateTime; +import com.ruoyi.common.core.domain.BaseEntity; +import com.ruoyi.common.utils.SecurityUtils; +import org.apache.ibatis.binding.MapperMethod; +import org.apache.ibatis.executor.Executor; +import org.apache.ibatis.mapping.MappedStatement; +import org.apache.ibatis.mapping.SqlCommandType; +import org.apache.ibatis.plugin.Interceptor; +import org.apache.ibatis.plugin.Intercepts; +import org.apache.ibatis.plugin.Invocation; +import org.apache.ibatis.plugin.Signature; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Component; + +import java.lang.reflect.Field; +import java.sql.Timestamp; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +/** + * 自定义 Mybatis 插件,自动设置 createTime 和 updatTime 的值。 + * 拦截 update 操作(添加和修改) + */ +@Component +@Intercepts({@Signature(type = Executor.class, method = "update", args = {MappedStatement.class, Object.class})}) +public class CustomInterceptor implements Interceptor { + private static final Logger logger = LoggerFactory.getLogger(CustomInterceptor.class); + + @Override + public Object intercept(Invocation invocation) throws Throwable { + MappedStatement mappedStatement = (MappedStatement) invocation.getArgs()[0]; + + // 获取 SQL 命令 + SqlCommandType sqlCommandType = mappedStatement.getSqlCommandType(); + //只判断新增和修改 + if (SqlCommandType.INSERT.equals(sqlCommandType) || SqlCommandType.UPDATE.equals(sqlCommandType)) { + // 获取参数 + Object parameter = invocation.getArgs()[1]; + //批量操作时 + if (parameter instanceof MapperMethod.ParamMap) { + MapperMethod.ParamMap map = (MapperMethod.ParamMap) parameter; + if (map.containsKey("list")) { + Object obj = map.get("list"); + List list = (List) obj; + if (list != null) { + for (Object o : list) { + setParameter(o, sqlCommandType); + } + } + } + } else { + setParameter(parameter, sqlCommandType); + } + } + return invocation.proceed(); + } + + public void setParameter(Object parameter, SqlCommandType sqlCommandType) throws Throwable { + Class aClass = parameter.getClass(); + Field[] declaredFields; + //如果常用字段提取了公共类 BaseEntity + //判断BaseEntity是否是父类 + if (BaseEntity.class.isAssignableFrom(aClass)) { + // 获取父类私有成员变量 + declaredFields = aClass.getSuperclass().getDeclaredFields(); + } else { + // 获取私有成员变量 + declaredFields = aClass.getDeclaredFields(); + } + for (Field field : declaredFields) { + if (SqlCommandType.INSERT.equals(sqlCommandType)) { // insert 语句插入 createBy + if (field.getAnnotation(CreateBy.class) != null) { + field.setAccessible(true); + + try { + field.set(parameter, SecurityUtils.getUserId().toString()); + }catch (Exception e){ + field.set(parameter, "0"); + continue; + } + } + + if (field.getAnnotation(CreateTime.class) != null) { // insert 语句插入 createTime + field.setAccessible(true); + field.set(parameter, new Timestamp(System.currentTimeMillis())); + } + } + + if (SqlCommandType.UPDATE.equals(sqlCommandType)) { + if (field.getAnnotation(UpdateTime.class) != null) { // update 语句插入 updateTime + field.setAccessible(true); + field.set(parameter, new Timestamp(System.currentTimeMillis())); + } + if (field.getAnnotation(UpdateBy.class) != null) { // update 语句插入 updateBy + field.setAccessible(true); + + try { + field.set(parameter, SecurityUtils.getUserId().toString()); + }catch (Exception e){ + continue; + } + } + } + } + } +} + diff --git a/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/filter/RepeatableFilter.java b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/filter/RepeatableFilter.java new file mode 100644 index 0000000..a1bcfe2 --- /dev/null +++ b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/filter/RepeatableFilter.java @@ -0,0 +1,52 @@ +package com.ruoyi.common.filter; + +import java.io.IOException; +import javax.servlet.Filter; +import javax.servlet.FilterChain; +import javax.servlet.FilterConfig; +import javax.servlet.ServletException; +import javax.servlet.ServletRequest; +import javax.servlet.ServletResponse; +import javax.servlet.http.HttpServletRequest; +import org.springframework.http.MediaType; +import com.ruoyi.common.utils.StringUtils; + +/** + * Repeatable 过滤器 + * + * @author ruoyi + */ +public class RepeatableFilter implements Filter +{ + @Override + public void init(FilterConfig filterConfig) throws ServletException + { + + } + + @Override + public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) + throws IOException, ServletException + { + ServletRequest requestWrapper = null; + if (request instanceof HttpServletRequest + && StringUtils.startsWithIgnoreCase(request.getContentType(), MediaType.APPLICATION_JSON_VALUE)) + { + requestWrapper = new RepeatedlyRequestWrapper((HttpServletRequest) request, response); + } + if (null == requestWrapper) + { + chain.doFilter(request, response); + } + else + { + chain.doFilter(requestWrapper, response); + } + } + + @Override + public void destroy() + { + + } +} diff --git a/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/filter/RepeatedlyRequestWrapper.java b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/filter/RepeatedlyRequestWrapper.java new file mode 100644 index 0000000..614c24c --- /dev/null +++ b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/filter/RepeatedlyRequestWrapper.java @@ -0,0 +1,75 @@ +package com.ruoyi.common.filter; + +import java.io.BufferedReader; +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.io.InputStreamReader; +import javax.servlet.ReadListener; +import javax.servlet.ServletInputStream; +import javax.servlet.ServletResponse; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletRequestWrapper; +import com.ruoyi.common.utils.http.HttpHelper; + +/** + * 构建可重复读取inputStream的request + * + * @author ruoyi + */ +public class RepeatedlyRequestWrapper extends HttpServletRequestWrapper +{ + private final byte[] body; + + public RepeatedlyRequestWrapper(HttpServletRequest request, ServletResponse response) throws IOException + { + super(request); + request.setCharacterEncoding("UTF-8"); + response.setCharacterEncoding("UTF-8"); + + body = HttpHelper.getBodyString(request).getBytes("UTF-8"); + } + + @Override + public BufferedReader getReader() throws IOException + { + return new BufferedReader(new InputStreamReader(getInputStream())); + } + + @Override + public ServletInputStream getInputStream() throws IOException + { + final ByteArrayInputStream bais = new ByteArrayInputStream(body); + return new ServletInputStream() + { + @Override + public int read() throws IOException + { + return bais.read(); + } + + @Override + public int available() throws IOException + { + return body.length; + } + + @Override + public boolean isFinished() + { + return false; + } + + @Override + public boolean isReady() + { + return false; + } + + @Override + public void setReadListener(ReadListener readListener) + { + + } + }; + } +} diff --git a/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/filter/XssFilter.java b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/filter/XssFilter.java new file mode 100644 index 0000000..99323ed --- /dev/null +++ b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/filter/XssFilter.java @@ -0,0 +1,74 @@ +package com.ruoyi.common.filter; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import javax.servlet.Filter; +import javax.servlet.FilterChain; +import javax.servlet.FilterConfig; +import javax.servlet.ServletException; +import javax.servlet.ServletRequest; +import javax.servlet.ServletResponse; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import com.ruoyi.common.utils.StringUtils; + +/** + * 防止XSS攻击的过滤器 + * + * @author ruoyi + */ +public class XssFilter implements Filter +{ + /** + * 排除链接 + */ + public List excludes = new ArrayList<>(); + + @Override + public void init(FilterConfig filterConfig) throws ServletException + { + String tempExcludes = filterConfig.getInitParameter("excludes"); + if (StringUtils.isNotEmpty(tempExcludes)) + { + String[] url = tempExcludes.split(","); + for (int i = 0; url != null && i < url.length; i++) + { + excludes.add(url[i]); + } + } + } + + @Override + public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) + throws IOException, ServletException + { + HttpServletRequest req = (HttpServletRequest) request; + HttpServletResponse resp = (HttpServletResponse) response; + if (handleExcludeURL(req, resp)) + { + chain.doFilter(request, response); + return; + } + XssHttpServletRequestWrapper xssRequest = new XssHttpServletRequestWrapper((HttpServletRequest) request); + chain.doFilter(xssRequest, response); + } + + private boolean handleExcludeURL(HttpServletRequest request, HttpServletResponse response) + { + String url = request.getServletPath(); + String method = request.getMethod(); + // GET DELETE 不过滤 + if (method == null || method.matches("GET") || method.matches("DELETE")) + { + return true; + } + return StringUtils.matches(url, excludes); + } + + @Override + public void destroy() + { + + } +} \ No newline at end of file diff --git a/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/filter/XssHttpServletRequestWrapper.java b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/filter/XssHttpServletRequestWrapper.java new file mode 100644 index 0000000..b1eeb65 --- /dev/null +++ b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/filter/XssHttpServletRequestWrapper.java @@ -0,0 +1,111 @@ +package com.ruoyi.common.filter; + +import java.io.ByteArrayInputStream; +import java.io.IOException; +import javax.servlet.ReadListener; +import javax.servlet.ServletInputStream; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletRequestWrapper; +import org.apache.commons.io.IOUtils; +import org.springframework.http.HttpHeaders; +import org.springframework.http.MediaType; +import com.ruoyi.common.utils.StringUtils; +import com.ruoyi.common.utils.html.EscapeUtil; + +/** + * XSS过滤处理 + * + * @author ruoyi + */ +public class XssHttpServletRequestWrapper extends HttpServletRequestWrapper +{ + /** + * @param request + */ + public XssHttpServletRequestWrapper(HttpServletRequest request) + { + super(request); + } + + @Override + public String[] getParameterValues(String name) + { + String[] values = super.getParameterValues(name); + if (values != null) + { + int length = values.length; + String[] escapseValues = new String[length]; + for (int i = 0; i < length; i++) + { + // 防xss攻击和过滤前后空格 + escapseValues[i] = EscapeUtil.clean(values[i]).trim(); + } + return escapseValues; + } + return super.getParameterValues(name); + } + + @Override + public ServletInputStream getInputStream() throws IOException + { + // 非json类型,直接返回 + if (!isJsonRequest()) + { + return super.getInputStream(); + } + + // 为空,直接返回 + String json = IOUtils.toString(super.getInputStream(), "utf-8"); + if (StringUtils.isEmpty(json)) + { + return super.getInputStream(); + } + + // xss过滤 + json = EscapeUtil.clean(json).trim(); + byte[] jsonBytes = json.getBytes("utf-8"); + final ByteArrayInputStream bis = new ByteArrayInputStream(jsonBytes); + return new ServletInputStream() + { + @Override + public boolean isFinished() + { + return true; + } + + @Override + public boolean isReady() + { + return true; + } + + @Override + public int available() throws IOException + { + return jsonBytes.length; + } + + @Override + public void setReadListener(ReadListener readListener) + { + } + + @Override + public int read() throws IOException + { + return bis.read(); + } + }; + } + + /** + * 是否是Json请求 + * + * @param request + */ + public boolean isJsonRequest() + { + String header = super.getHeader(HttpHeaders.CONTENT_TYPE); + return StringUtils.startsWithIgnoreCase(header, MediaType.APPLICATION_JSON_VALUE); + } +} \ No newline at end of file diff --git a/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/page/ManualPagination.java b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/page/ManualPagination.java new file mode 100644 index 0000000..dedb26b --- /dev/null +++ b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/page/ManualPagination.java @@ -0,0 +1,28 @@ + +package com.ruoyi.common.page; + +import com.ruoyi.common.core.page.PageDomain; +import com.ruoyi.common.core.page.TableSupport; + +import java.util.List; + +/** + * 手动分页 + */ +public class ManualPagination { + + public static List getPage(List dataList) { + + PageDomain pageDomain = TableSupport.buildPageRequest(); + Integer pageNum = pageDomain.getPageNum(); + Integer pageSize = pageDomain.getPageSize(); + int startIndex = (pageNum - 1) * pageSize; + int endIndex = Math.min(startIndex + pageSize, dataList.size()); + List pageData = dataList.subList(startIndex, endIndex); + return pageData; + } + + public static void main(String[] args) { + + } +} diff --git a/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/page/PageResult.java b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/page/PageResult.java new file mode 100644 index 0000000..049772d --- /dev/null +++ b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/page/PageResult.java @@ -0,0 +1,119 @@ +/* +Copyright [2020] [https://www.stylefeng.cn] + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +Guns采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点: + +1.请不要删除和修改根目录下的LICENSE文件。 +2.请不要删除和修改Guns源码头部的版权声明。 +3.请保留源码和相关描述文件的项目出处,作者声明等。 +4.分发源码时候,请注明软件出处 https://gitee.com/stylefeng/guns-separation +5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://gitee.com/stylefeng/guns-separation +6.若您的项目无法满足以上几点,可申请商业授权,获取Guns商业授权许可,请在官网购买授权,地址为 https://www.stylefeng.cn + */ +package com.ruoyi.common.page; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import cn.hutool.core.convert.Convert; +import cn.hutool.core.util.PageUtil; +import lombok.Data; + +import java.io.Serializable; +import java.util.List; + +/** + * 分页结果集 + * + * @author xuyuxiang + * @date 2020/3/30 15:44 + */ +@Data +public class PageResult implements Serializable { + + private static final long serialVersionUID = -1L; + + /** + * 默认分页彩虹展示数量 + */ + public static final int RAINBOW_NUM = 5; + + /** + * 第几页 + */ + private Integer pageNo = 1; + + /** + * 每页条数 + */ + private Integer pageSize = 20; + + /** + * 总页数 + */ + private Integer totalPage = 0; + + /** + * 总记录数 + */ + private Integer totalRows = 0; + + /** + * 结果集 + */ + private List rows; + + /** + * 分页彩虹 + */ + private int[] rainbow; + + public PageResult() { + } + + /** + * 将mybatis-plus的page转成自定义的PageResult,扩展了totalPage总页数,和rainBow彩虹条 + * + * @author xuyuxiang + * @date 2020/4/8 19:20 + */ + public PageResult(IPage page) { + this.setRows(page.getRecords()); + this.setTotalRows(Convert.toInt(page.getTotal())); + this.setPageNo(Convert.toInt(page.getCurrent())); + this.setPageSize(Convert.toInt(page.getSize())); + this.setTotalPage(PageUtil.totalPage(Convert.toInt(page.getTotal()), + Convert.toInt(page.getSize()))); + this.setRainbow(PageUtil.rainbow(Convert.toInt(page.getCurrent()), + Convert.toInt(this.getTotalPage()), RAINBOW_NUM)); + } + + /** + * 将mybatis-plus的page转成自定义的PageResult,扩展了totalPage总页数,和rainBow彩虹条 + * 可单独设置rows + * + * @author xuyuxiang + * @date 2020/4/14 20:55 + */ + public PageResult(Page page, List t) { + this.setRows(t); + this.setTotalRows(Convert.toInt(page.getTotal())); + this.setPageNo(Convert.toInt(page.getCurrent())); + this.setPageSize(Convert.toInt(page.getSize())); + this.setTotalPage(PageUtil.totalPage(Convert.toInt(page.getTotal()), + Convert.toInt(page.getSize()))); + this.setRainbow(PageUtil.rainbow(Convert.toInt(page.getCurrent()), + Convert.toInt(this.getTotalPage()), RAINBOW_NUM)); + } +} diff --git a/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/page/PageUtil.java b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/page/PageUtil.java new file mode 100644 index 0000000..93031ce --- /dev/null +++ b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/page/PageUtil.java @@ -0,0 +1,30 @@ +package com.ruoyi.common.page; + + +import com.github.pagehelper.PageInfo; +import com.ruoyi.common.constant.HttpStatus; +import com.ruoyi.common.core.page.TableDataInfo; + +import java.util.List; + +public class PageUtil { + + /** + * + * @param list 返回数据 + * @param totalList 计算总数据量的数据 + * @return + */ + public static TableDataInfo getTableDataInfo(List list, List totalList){ + TableDataInfo rspData = new TableDataInfo(); + rspData.setCode(HttpStatus.SUCCESS); + rspData.setRows(list); + rspData.setMsg("查询成功"); + if(totalList==null){ + rspData.setTotal(Integer.valueOf(new PageInfo(list).getTotal() + "")); + }else { + rspData.setTotal(Integer.valueOf(new PageInfo(totalList).getTotal()+"")); + } + return rspData; + } +} diff --git a/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/utils/AESUtil.java b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/utils/AESUtil.java new file mode 100644 index 0000000..5945753 --- /dev/null +++ b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/utils/AESUtil.java @@ -0,0 +1,234 @@ +package com.ruoyi.common.utils; + +import org.apache.commons.lang3.RandomStringUtils; +import org.apache.commons.lang3.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.util.Base64Utils; + +import javax.crypto.Cipher; +import javax.crypto.spec.IvParameterSpec; +import javax.crypto.spec.SecretKeySpec; + +/** + * AES加密工具类 + * + * @author ACGkaka + * @since 2021-06-18 19:11:03 + */ +public class AESUtil { + /** + * 日志相关 + */ + private static final Logger LOGGER = LoggerFactory.getLogger(AESUtil.class); + /** + * 编码 + */ + private static final String ENCODING = "UTF-8"; + /** + * 算法定义 + */ + private static final String AES_ALGORITHM = "AES"; + /** + * 指定填充方式 + */ + private static final String CIPHER_PADDING = "AES/ECB/PKCS5Padding"; + private static final String CIPHER_CBC_PADDING = "AES/CBC/PKCS5Padding"; + /** + * 偏移量(CBC中使用,增强加密算法强度) + */ + private static final String IV_SEED = "1234567812345678"; + + /** + * AES加密 + * @param content 待加密内容 + * @param aesKey 密码 + * @return + */ + public static String encrypt(String content, String aesKey){ + if(StringUtils.isBlank(content)){ + LOGGER.info("AES encrypt: the content is null!"); + return null; + } + //判断秘钥是否为16位 + if(StringUtils.isNotBlank(aesKey) && aesKey.length() == 16){ + try { + //对密码进行编码 + byte[] bytes = aesKey.getBytes(ENCODING); + //设置加密算法,生成秘钥 + SecretKeySpec skeySpec = new SecretKeySpec(bytes, AES_ALGORITHM); + // "算法/模式/补码方式" + Cipher cipher = Cipher.getInstance(CIPHER_PADDING); + //选择加密 + cipher.init(Cipher.ENCRYPT_MODE, skeySpec); + //根据待加密内容生成字节数组 + byte[] encrypted = cipher.doFinal(content.getBytes(ENCODING)); + //返回base64字符串 + return Base64Utils.encodeToString(encrypted); + } catch (Exception e) { + LOGGER.info("AES encrypt exception:" + e.getMessage()); + throw new RuntimeException(e); + } + + }else { + LOGGER.info("AES encrypt: the aesKey is null or error!"); + return null; + } + } + + /** + * 解密 + * + * @param content 待解密内容 + * @param aesKey 密码 + * @return + */ + public static String decrypt(String content, String aesKey){ + if(StringUtils.isBlank(content)){ + LOGGER.info("AES decrypt: the content is null!"); + return null; + } + //判断秘钥是否为16位 + if(StringUtils.isNotBlank(aesKey) && aesKey.length() == 16){ + try { + //对密码进行编码 + byte[] bytes = aesKey.getBytes(ENCODING); + //设置解密算法,生成秘钥 + SecretKeySpec skeySpec = new SecretKeySpec(bytes, AES_ALGORITHM); + // "算法/模式/补码方式" + Cipher cipher = Cipher.getInstance(CIPHER_PADDING); + //选择解密 + cipher.init(Cipher.DECRYPT_MODE, skeySpec); + + //先进行Base64解码 + byte[] decodeBase64 = Base64Utils.decodeFromString(content); + + //根据待解密内容进行解密 + byte[] decrypted = cipher.doFinal(decodeBase64); + + //将字节数组转成字符串 + return new String(decrypted, ENCODING); + } catch (Exception e) { + LOGGER.info("AES decrypt exception:" + e.getMessage()); + throw new RuntimeException(e); + } + + }else { + LOGGER.info("AES decrypt: the aesKey is null or error!"); + return null; + } + } + + /** + * AES_CBC加密 + * + * @param content 待加密内容 + * @param aesKey 密码 + * @return + */ + public static String encryptCBC(String content, String aesKey){ + if(StringUtils.isBlank(content)){ + LOGGER.info("AES_CBC encrypt: the content is null!"); + return null; + } + //判断秘钥是否为16位 + if(StringUtils.isNotBlank(aesKey) && aesKey.length() == 16){ + try { + //对密码进行编码 + byte[] bytes = aesKey.getBytes(ENCODING); + //设置加密算法,生成秘钥 + SecretKeySpec skeySpec = new SecretKeySpec(bytes, AES_ALGORITHM); + // "算法/模式/补码方式" + Cipher cipher = Cipher.getInstance(CIPHER_CBC_PADDING); + //偏移 + IvParameterSpec iv = new IvParameterSpec(IV_SEED.getBytes(ENCODING)); + //选择加密 + cipher.init(Cipher.ENCRYPT_MODE, skeySpec, iv); + //根据待加密内容生成字节数组 + byte[] encrypted = cipher.doFinal(content.getBytes(ENCODING)); + //返回base64字符串 + return Base64Utils.encodeToString(encrypted); + } catch (Exception e) { + LOGGER.info("AES_CBC encrypt exception:" + e.getMessage()); + throw new RuntimeException(e); + } + + }else { + LOGGER.info("AES_CBC encrypt: the aesKey is null or error!"); + return null; + } + } + + /** + * AES_CBC解密 + * + * @param content 待解密内容 + * @param aesKey 密码 + * @return + */ + public static String decryptCBC(String content, String aesKey){ + if(StringUtils.isBlank(content)){ + LOGGER.info("AES_CBC decrypt: the content is null!"); + return null; + } + //判断秘钥是否为16位 + if(StringUtils.isNotBlank(aesKey) && aesKey.length() == 16){ + try { + //对密码进行编码 + byte[] bytes = aesKey.getBytes(ENCODING); + //设置解密算法,生成秘钥 + SecretKeySpec skeySpec = new SecretKeySpec(bytes, AES_ALGORITHM); + //偏移 + IvParameterSpec iv = new IvParameterSpec(IV_SEED.getBytes(ENCODING)); + // "算法/模式/补码方式" + Cipher cipher = Cipher.getInstance(CIPHER_CBC_PADDING); + //选择解密 + cipher.init(Cipher.DECRYPT_MODE, skeySpec, iv); + + //先进行Base64解码 + byte[] decodeBase64 = Base64Utils.decodeFromString(content); + + //根据待解密内容进行解密 + byte[] decrypted = cipher.doFinal(decodeBase64); + //将字节数组转成字符串 + return new String(decrypted, ENCODING); + } catch (Exception e) { + LOGGER.info("AES_CBC decrypt exception:" + e.getMessage()); + throw new RuntimeException(e); + } + + }else { + LOGGER.info("AES_CBC decrypt: the aesKey is null or error!"); + return null; + } + } + + public static void main(String[] args) { + // AES支持三种长度的密钥:128位、192位、256位。 + // 代码中这种就是128位的加密密钥,16字节 * 8位/字节 = 128位。 + String random = RandomStringUtils.random(16, "abcdefghijklmnopqrstuvwxyz1234567890"); + System.out.println("随机key:" + random); + System.out.println(); + + System.out.println("---------加密---------"); + String aesResult = encrypt("测试AES加密12", "huitu@77387.uurh"); + System.out.println("aes加密结果:" + aesResult); + System.out.println(); + + System.out.println("---------解密---------"); + String decrypt = decrypt(aesResult, "huitu@77387.uurh"); + System.out.println("aes解密结果:" + decrypt); + System.out.println(); + + + System.out.println("--------AES_CBC加密解密---------"); + String cbcResult = encryptCBC("测试AES加密12456", random); + System.out.println("aes_cbc加密结果:" + cbcResult); + System.out.println(); + + System.out.println("---------解密CBC---------"); + String cbcDecrypt = decryptCBC(cbcResult, random); + System.out.println("aes解密结果:" + cbcDecrypt); + System.out.println(); + } +} diff --git a/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/utils/Arith.java b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/utils/Arith.java new file mode 100644 index 0000000..b6326c2 --- /dev/null +++ b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/utils/Arith.java @@ -0,0 +1,114 @@ +package com.ruoyi.common.utils; + +import java.math.BigDecimal; +import java.math.RoundingMode; + +/** + * 精确的浮点数运算 + * + * @author ruoyi + */ +public class Arith +{ + + /** 默认除法运算精度 */ + private static final int DEF_DIV_SCALE = 10; + + /** 这个类不能实例化 */ + private Arith() + { + } + + /** + * 提供精确的加法运算。 + * @param v1 被加数 + * @param v2 加数 + * @return 两个参数的和 + */ + public static double add(double v1, double v2) + { + BigDecimal b1 = new BigDecimal(Double.toString(v1)); + BigDecimal b2 = new BigDecimal(Double.toString(v2)); + return b1.add(b2).doubleValue(); + } + + /** + * 提供精确的减法运算。 + * @param v1 被减数 + * @param v2 减数 + * @return 两个参数的差 + */ + public static double sub(double v1, double v2) + { + BigDecimal b1 = new BigDecimal(Double.toString(v1)); + BigDecimal b2 = new BigDecimal(Double.toString(v2)); + return b1.subtract(b2).doubleValue(); + } + + /** + * 提供精确的乘法运算。 + * @param v1 被乘数 + * @param v2 乘数 + * @return 两个参数的积 + */ + public static double mul(double v1, double v2) + { + BigDecimal b1 = new BigDecimal(Double.toString(v1)); + BigDecimal b2 = new BigDecimal(Double.toString(v2)); + return b1.multiply(b2).doubleValue(); + } + + /** + * 提供(相对)精确的除法运算,当发生除不尽的情况时,精确到 + * 小数点以后10位,以后的数字四舍五入。 + * @param v1 被除数 + * @param v2 除数 + * @return 两个参数的商 + */ + public static double div(double v1, double v2) + { + return div(v1, v2, DEF_DIV_SCALE); + } + + /** + * 提供(相对)精确的除法运算。当发生除不尽的情况时,由scale参数指 + * 定精度,以后的数字四舍五入。 + * @param v1 被除数 + * @param v2 除数 + * @param scale 表示表示需要精确到小数点以后几位。 + * @return 两个参数的商 + */ + public static double div(double v1, double v2, int scale) + { + if (scale < 0) + { + throw new IllegalArgumentException( + "The scale must be a positive integer or zero"); + } + BigDecimal b1 = new BigDecimal(Double.toString(v1)); + BigDecimal b2 = new BigDecimal(Double.toString(v2)); + if (b1.compareTo(BigDecimal.ZERO) == 0) + { + return BigDecimal.ZERO.doubleValue(); + } + return b1.divide(b2, scale, RoundingMode.HALF_UP).doubleValue(); + } + + /** + * 提供精确的小数位四舍五入处理。 + * @param v 需要四舍五入的数字 + * @param scale 小数点后保留几位 + * @return 四舍五入后的结果 + */ + public static double round(double v, int scale) + { + if (scale < 0) + { + throw new IllegalArgumentException( + "The scale must be a positive integer or zero"); + } + BigDecimal b = new BigDecimal(Double.toString(v)); + BigDecimal one = BigDecimal.ONE; + return b.divide(one, scale, RoundingMode.HALF_UP).doubleValue(); + } +} diff --git a/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/utils/DateUtils.java b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/utils/DateUtils.java new file mode 100644 index 0000000..536cb3c --- /dev/null +++ b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/utils/DateUtils.java @@ -0,0 +1,155 @@ +package com.ruoyi.common.utils; + +import java.lang.management.ManagementFactory; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.Date; +import org.apache.commons.lang3.time.DateFormatUtils; + +/** + * 时间工具类 + * + * @author ruoyi + */ +public class DateUtils extends org.apache.commons.lang3.time.DateUtils +{ + public static String YYYY = "yyyy"; + + public static String YYYY_MM = "yyyy-MM"; + + public static String YYYY_MM_DD = "yyyy-MM-dd"; + + public static String YYYYMMDDHHMMSS = "yyyyMMddHHmmss"; + + public static String YYYY_MM_DD_HH_MM_SS = "yyyy-MM-dd HH:mm:ss"; + + private static String[] parsePatterns = { + "yyyy-MM-dd", "yyyy-MM-dd HH:mm:ss", "yyyy-MM-dd HH:mm", "yyyy-MM", + "yyyy/MM/dd", "yyyy/MM/dd HH:mm:ss", "yyyy/MM/dd HH:mm", "yyyy/MM", + "yyyy.MM.dd", "yyyy.MM.dd HH:mm:ss", "yyyy.MM.dd HH:mm", "yyyy.MM"}; + + /** + * 获取当前Date型日期 + * + * @return Date() 当前日期 + */ + public static Date getNowDate() + { + return new Date(); + } + + /** + * 获取当前日期, 默认格式为yyyy-MM-dd + * + * @return String + */ + public static String getDate() + { + return dateTimeNow(YYYY_MM_DD); + } + + public static final String getTime() + { + return dateTimeNow(YYYY_MM_DD_HH_MM_SS); + } + + public static final String dateTimeNow() + { + return dateTimeNow(YYYYMMDDHHMMSS); + } + + public static final String dateTimeNow(final String format) + { + return parseDateToStr(format, new Date()); + } + + public static final String dateTime(final Date date) + { + return parseDateToStr(YYYY_MM_DD, date); + } + + public static final String parseDateToStr(final String format, final Date date) + { + return new SimpleDateFormat(format).format(date); + } + + public static final Date dateTime(final String format, final String ts) + { + try + { + return new SimpleDateFormat(format).parse(ts); + } + catch (ParseException e) + { + throw new RuntimeException(e); + } + } + + /** + * 日期路径 即年/月/日 如2018/08/08 + */ + public static final String datePath() + { + Date now = new Date(); + return DateFormatUtils.format(now, "yyyy/MM/dd"); + } + + /** + * 日期路径 即年/月/日 如20180808 + */ + public static final String dateTime() + { + Date now = new Date(); + return DateFormatUtils.format(now, "yyyyMMdd"); + } + + /** + * 日期型字符串转化为日期 格式 + */ + public static Date parseDate(Object str) + { + if (str == null) + { + return null; + } + try + { + return parseDate(str.toString(), parsePatterns); + } + catch (ParseException e) + { + return null; + } + } + + /** + * 获取服务器启动时间 + */ + public static Date getServerStartDate() + { + long time = ManagementFactory.getRuntimeMXBean().getStartTime(); + return new Date(time); + } + + /** + * 计算两个时间差 + */ + public static String getDatePoor(Date endDate, Date nowDate) + { + long nd = 1000 * 24 * 60 * 60; + long nh = 1000 * 60 * 60; + long nm = 1000 * 60; + // long ns = 1000; + // 获得两个时间的毫秒时间差异 + long diff = endDate.getTime() - nowDate.getTime(); + // 计算差多少天 + long day = diff / nd; + // 计算差多少小时 + long hour = diff % nd / nh; + // 计算差多少分钟 + long min = diff % nd % nh / nm; + // 计算差多少秒//输出结果 + // long sec = diff % nd % nh % nm / ns; + return day + "天" + hour + "小时" + min + "分钟"; + } +} diff --git a/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/utils/DictUtils.java b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/utils/DictUtils.java new file mode 100644 index 0000000..4c90a6c --- /dev/null +++ b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/utils/DictUtils.java @@ -0,0 +1,183 @@ +package com.ruoyi.common.utils; + +import java.util.Collection; +import java.util.List; +import com.ruoyi.common.constant.Constants; +import com.ruoyi.common.core.domain.entity.SysDictData; +import com.ruoyi.common.core.redis.RedisService; +import com.ruoyi.common.utils.spring.SpringUtils; + +/** + * 字典工具类 + * + * @author ruoyi + */ +public class DictUtils +{ + /** + * 分隔符 + */ + public static final String SEPARATOR = ","; + + /** + * 设置字典缓存 + * + * @param key 参数键 + * @param dictDatas 字典数据列表 + */ + public static void setDictCache(String key, List dictDatas) + { + SpringUtils.getBean(RedisService.class).setCacheObject(getCacheKey(key), dictDatas); + } + + /** + * 获取字典缓存 + * + * @param key 参数键 + * @return dictDatas 字典数据列表 + */ + public static List getDictCache(String key) + { + Object cacheObj = SpringUtils.getBean(RedisService.class).getCacheObject(getCacheKey(key)); + if (StringUtils.isNotNull(cacheObj)) + { + List dictDatas = StringUtils.cast(cacheObj); + return dictDatas; + } + return null; + } + + /** + * 根据字典类型和字典值获取字典标签 + * + * @param dictType 字典类型 + * @param dictValue 字典值 + * @return 字典标签 + */ + public static String getDictLabel(String dictType, String dictValue) + { + return getDictLabel(dictType, dictValue, SEPARATOR); + } + + /** + * 根据字典类型和字典标签获取字典值 + * + * @param dictType 字典类型 + * @param dictLabel 字典标签 + * @return 字典值 + */ + public static String getDictValue(String dictType, String dictLabel) + { + return getDictValue(dictType, dictLabel, SEPARATOR); + } + + /** + * 根据字典类型和字典值获取字典标签 + * + * @param dictType 字典类型 + * @param dictValue 字典值 + * @param separator 分隔符 + * @return 字典标签 + */ + public static String getDictLabel(String dictType, String dictValue, String separator) + { + StringBuilder propertyString = new StringBuilder(); + List datas = getDictCache(dictType); + + if (StringUtils.containsAny(separator, dictValue) && StringUtils.isNotEmpty(datas)) + { + for (SysDictData dict : datas) + { + for (String value : dictValue.split(separator)) + { + if (value.equals(dict.getDictValue())) + { + propertyString.append(dict.getDictLabel() + separator); + break; + } + } + } + } + else + { + for (SysDictData dict : datas) + { + if (dictValue.equals(dict.getDictValue())) + { + return dict.getDictLabel(); + } + } + } + return StringUtils.stripEnd(propertyString.toString(), separator); + } + + /** + * 根据字典类型和字典标签获取字典值 + * + * @param dictType 字典类型 + * @param dictLabel 字典标签 + * @param separator 分隔符 + * @return 字典值 + */ + public static String getDictValue(String dictType, String dictLabel, String separator) + { + StringBuilder propertyString = new StringBuilder(); + List datas = getDictCache(dictType); + + if (StringUtils.containsAny(separator, dictLabel) && StringUtils.isNotEmpty(datas)) + { + for (SysDictData dict : datas) + { + for (String label : dictLabel.split(separator)) + { + if (label.equals(dict.getDictLabel())) + { + propertyString.append(dict.getDictValue() + separator); + break; + } + } + } + } + else + { + for (SysDictData dict : datas) + { + if (dictLabel.equals(dict.getDictLabel())) + { + return dict.getDictValue(); + } + } + } + return StringUtils.stripEnd(propertyString.toString(), separator); + } + + /** + * 删除指定字典缓存 + * + * @param key 字典键 + */ + public static void removeDictCache(String key) + { + SpringUtils.getBean(RedisService.class).deleteObject(getCacheKey(key)); + } + + /** + * 清空字典缓存 + */ + public static void clearDictCache() + { + Collection keys = SpringUtils.getBean(RedisService.class).keys(Constants.SYS_DICT_KEY + "*"); + SpringUtils.getBean(RedisService.class).deleteObject(keys); + } + + /** + * 设置cache key + * + * @param configKey 参数键 + * @return 缓存键key + */ + public static String getCacheKey(String configKey) + { + return Constants.SYS_DICT_KEY + configKey; + } +} diff --git a/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/utils/ExceptionUtil.java b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/utils/ExceptionUtil.java new file mode 100644 index 0000000..ae81a69 --- /dev/null +++ b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/utils/ExceptionUtil.java @@ -0,0 +1,40 @@ +package com.ruoyi.common.utils; + +import java.io.PrintWriter; +import java.io.StringWriter; +import org.apache.commons.lang3.exception.ExceptionUtils; + +/** + * 错误信息处理类。 + * + * @author ruoyi + */ +public class ExceptionUtil +{ + /** + * 获取exception的详细错误信息。 + */ + public static String getExceptionMessage(Throwable e) + { + StringWriter sw = new StringWriter(); + e.printStackTrace(new PrintWriter(sw, true)); + String str = sw.toString(); + return str; + } + + public static String getRootErrorMessage(Exception e) + { + Throwable root = ExceptionUtils.getRootCause(e); + root = (root == null ? e : root); + if (root == null) + { + return ""; + } + String msg = root.getMessage(); + if (msg == null) + { + return "null"; + } + return StringUtils.defaultString(msg); + } +} diff --git a/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/utils/ImageMerge.java b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/utils/ImageMerge.java new file mode 100644 index 0000000..41266f1 --- /dev/null +++ b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/utils/ImageMerge.java @@ -0,0 +1,61 @@ +package com.ruoyi.common.utils; + +import javax.imageio.ImageIO; +import java.awt.*; +import java.awt.image.BufferedImage; +import java.io.File; +import java.util.ArrayList; +import java.util.List; + +public class ImageMerge { + public static void main(String[] args) throws Exception { + // 加载第一张图片 + BufferedImage image1 = ImageIO.read(new File("G:\\download\\output.png")); + // 加载第二张图片 + BufferedImage image2 = ImageIO.read(new File("G:\\download\\output2.png")); + + List list = new ArrayList<>(); + list.add("G:\\download\\output.png"); + list.add("G:\\download\\output2.png"); + list.add("G:\\download\\output3.png"); + + mergeImages(list,null); + } + + + public static void mergeImages(List imagePathList,String outputPath) throws Exception { + // 加载第一张图片 + BufferedImage image1 = ImageIO.read(new File(imagePathList.get(0))); + + Integer height = image1.getHeight(); + Integer width = image1.getWidth(); + + for (int i = 0; i < imagePathList.size(); i++) { + if (i == 0) { + continue; + } + BufferedImage image = ImageIO.read(new File(imagePathList.get(i))); + height = height + image.getHeight(); + } + // 创建一个新的图片用于合并 + BufferedImage combinedImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB); + // 合并第一张图片 + Integer heightTemp = 0; + Graphics2D g = null; + for (int i = 0; i < imagePathList.size(); i++) { + BufferedImage image = ImageIO.read(new File(imagePathList.get(i))); + g = combinedImage.createGraphics(); + if (i == 0) { + g.drawImage(image, 0, heightTemp, null); + + } else { + g.drawImage(image, 0, heightTemp, null); + } + heightTemp = heightTemp + image.getHeight(); + // 释放图形上下文 + g.dispose(); + } + // 保存合并后的图片 + ImageIO.write(combinedImage, "PNG", new File(outputPath)); + } +} \ No newline at end of file diff --git a/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/utils/ImageRotator.java b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/utils/ImageRotator.java new file mode 100644 index 0000000..c21e947 --- /dev/null +++ b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/utils/ImageRotator.java @@ -0,0 +1,74 @@ +package com.ruoyi.common.utils; + +import com.ruoyi.common.utils.uuid.UUID; + +import javax.imageio.ImageIO; +import java.awt.*; +import java.awt.geom.AffineTransform; +import java.awt.image.BufferedImage; +import java.io.File; +import java.io.IOException; + +public class ImageRotator { + public static String rotate90DegreesCounterClockwise(String image, String path) { + // 读取原始图片 + BufferedImage originalImage = null; + try { + originalImage = ImageIO.read(new File(image)); + } catch (IOException e) { + throw new RuntimeException(e); + } + + // 创建一个旋转后的图片,宽度和高度交换 + BufferedImage rotatedImage = new BufferedImage(originalImage.getHeight(), originalImage.getWidth(), BufferedImage.TYPE_INT_ARGB); + + // 创建Graphics2D对象,用于绘制旋转后的图片 + Graphics2D g2d = rotatedImage.createGraphics(); + + // 逆时针旋转90度 + AffineTransform at = new AffineTransform(); + at.translate(originalImage.getHeight(), 0); + at.rotate(Math.toRadians(90)); + + g2d.setTransform(at); + g2d.drawImage(originalImage, 0, 0, null); + g2d.dispose(); + + String outPath = path + UUID.randomUUID() + ".png"; + // 保存旋转后的图片 + try { + ImageIO.write(rotatedImage, "PNG", new File(outPath)); + } catch (IOException e) { + throw new RuntimeException(e); + } + return outPath; + } + + public static void main(String[] args) throws IOException { + String path = "G:\\download\\"; + // 读取原始图片 + BufferedImage originalImage = ImageIO.read(new File(path + "input.jpg")); + + // 创建一个旋转后的图片,宽度和高度交换 + BufferedImage rotatedImage = new BufferedImage(originalImage.getHeight(), originalImage.getWidth(), BufferedImage.TYPE_INT_ARGB); + + // 创建Graphics2D对象,用于绘制旋转后的图片 + Graphics2D g2d = rotatedImage.createGraphics(); + + // 逆时针旋转90度 + AffineTransform at = new AffineTransform(); + at.translate(originalImage.getHeight(), 0); + at.rotate(Math.toRadians(90)); + + g2d.setTransform(at); + g2d.drawImage(originalImage, 0, 0, null); + g2d.dispose(); + + // 保存旋转后的图片 + ImageIO.write(rotatedImage, "PNG", new File(path + "out.jpg")); + + System.out.println("图片旋转完成。"); + } + + +} \ No newline at end of file diff --git a/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/utils/LogUtils.java b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/utils/LogUtils.java new file mode 100644 index 0000000..0de30c6 --- /dev/null +++ b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/utils/LogUtils.java @@ -0,0 +1,18 @@ +package com.ruoyi.common.utils; + +/** + * 处理并记录日志文件 + * + * @author ruoyi + */ +public class LogUtils +{ + public static String getBlock(Object msg) + { + if (msg == null) + { + msg = ""; + } + return "[" + msg.toString() + "]"; + } +} diff --git a/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/utils/MessageUtils.java b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/utils/MessageUtils.java new file mode 100644 index 0000000..7dac75a --- /dev/null +++ b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/utils/MessageUtils.java @@ -0,0 +1,26 @@ +package com.ruoyi.common.utils; + +import org.springframework.context.MessageSource; +import org.springframework.context.i18n.LocaleContextHolder; +import com.ruoyi.common.utils.spring.SpringUtils; + +/** + * 获取i18n资源文件 + * + * @author ruoyi + */ +public class MessageUtils +{ + /** + * 根据消息键和参数 获取消息 委托给spring messageSource + * + * @param code 消息键 + * @param args 参数 + * @return 获取国际化翻译值 + */ + public static String message(String code, Object... args) + { + MessageSource messageSource = SpringUtils.getBean(MessageSource.class); + return messageSource.getMessage(code, args, LocaleContextHolder.getLocale()); + } +} diff --git a/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/utils/ObjectSwitchHelper.java b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/utils/ObjectSwitchHelper.java new file mode 100644 index 0000000..43f10d6 --- /dev/null +++ b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/utils/ObjectSwitchHelper.java @@ -0,0 +1,158 @@ +package com.ruoyi.common.utils; + +/** + * 加载基础 + */ +public abstract class ObjectSwitchHelper { + + public void setString(String key, String value) { + set(key, value); + } + + public void setInt(String key, int value) { + setString(key, String.valueOf(value)); + } + + public void setBoolean(String key, Boolean value) { + setString(key, String.valueOf(value)); + } + + public void setByte(String key, byte[] value) { + setString(key, String.valueOf(value)); + } + + public void setShort(String key, short value) { + + setString(key, String.valueOf(value)); + } + + public void setLong(String key, long value) { + + setString(key, String.valueOf(value)); + } + + public void setFloat(String key, float value) { + setString(key, String.valueOf(value)); + } + + public void setDouble(String key, double value) { + setString(key, String.valueOf(value)); + } + + public String getString(String key) { + if (get(key) == null) { + return ""; + } + return String.valueOf(get(key)); + } + + public int getInt(String key) { + return Integer.valueOf(getString(key)); + } + + public boolean getBoolean(String key) { + return Boolean.valueOf(getString(key)); + } + + public byte[] getByte(String key) { + return getString(key).getBytes(); + } + + public short getShort(String key) { + return Short.valueOf(getString(key, "")); + } + + public long getLong(String key) { + return Long.valueOf(getString(key)); + } + + public float getFloat(String key) { + return Float.valueOf(getString(key)); + } + + public double getDouble(String key) { + return Double.valueOf(getString(key)); + } + + public String getString(String key, String defaultValue) { + return get(key) != null && !StringUtils.isEmpty((String) get(key)) ? String.valueOf(get(key)) : defaultValue; + } + + public int getInt(String key, int defaultValue) { + try { + return Integer.valueOf(getString(key, "")); + } catch (Exception e) { + + } + return defaultValue; + } + + public boolean getBoolean(String key, Boolean defaultValue) { + try { + return Boolean.valueOf(getString(key, "")); + } catch (Exception e) { + + } + return defaultValue; + } + + public byte[] getByte(String key, byte[] defaultValue) { + try { + return getString(key, "").getBytes(); + } catch (Exception e) { + + } + return defaultValue; + } + + public short getShort(String key, Short defaultValue) { + try { + return Short.valueOf(getString(key, "")); + } catch (Exception e) { + + } + return defaultValue; + } + + public long getLong(String key, Long defaultValue) { + + try { + return Long.valueOf(getString(key, "")); + } catch (Exception e) { + + } + return defaultValue; + } + + public float getFloat(String key, Float defaultValue) { + + try { + return Float.valueOf(getString(key, "")); + } catch (Exception e) { + + } + return defaultValue; + } + + public double getDouble(String key, Double defaultValue) { + try { + return Double.valueOf(getString(key, "")); + } catch (Exception e) { + + } + return defaultValue; + } + + public void remove(String... keys) { + for (String key : keys) { + remove(key); + } + } + + public abstract Object get(String key); + + public abstract void set(String key, Object value); + + public abstract boolean remove(String key); + +} diff --git a/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/utils/PdfUtil.java b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/utils/PdfUtil.java new file mode 100644 index 0000000..711f936 --- /dev/null +++ b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/utils/PdfUtil.java @@ -0,0 +1,74 @@ +package com.ruoyi.common.utils; + + +import com.aspose.words.Document; +import com.aspose.words.FontSettings; +import com.aspose.words.License; +import com.aspose.words.SaveFormat; + +import java.io.*; + +public class PdfUtil { + + + public static boolean getLicense(String licensePath) { + boolean result = false; + InputStream is = null; + try { + is = new FileInputStream(licensePath); + License aposeLic = new License(); + aposeLic.setLicense(is); + result = true; + } catch (Exception e) { + e.printStackTrace(); + } finally { + if (is != null) { + try { + is.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + } + return result; + } + + public static void main(String[] args) { + String osName = System.getProperty("os.name"); + System.out.println(osName); + } + + public static boolean doc2pdf(String inPath, String outPath, String licensePath) { + if (!getLicense(licensePath)) { // 验证License 若不验证则转化出的pdf文档会有水印产生 + return false; + } + FileOutputStream os = null; + try { + long old = System.currentTimeMillis(); + File file = new File(outPath); // 新建一个空白pdf文档 + os = new FileOutputStream(file); + Document doc = new Document(inPath); // Address是将要被转化的word文档 + String osName = System.getProperty("os.name"); + if (osName != null && osName.trim().toLowerCase().contains("linux")) { + FontSettings.setFontsFolder("/usr/share/fonts/chinese" + File.separator, true);//此处处理乱码和小方块 + } + doc.save(os, SaveFormat.PDF);// 全面支持DOC, DOCX, OOXML, RTF HTML, OpenDocument, PDF, + // EPUB, XPS, SWF 相互转换 + long now = System.currentTimeMillis(); + System.out.println("pdf转换成功,共耗时:" + ((now - old) / 1000.0) + "秒"); // 转化用时 + } catch (Exception e) { + e.printStackTrace(); + return false; + } finally { + if (os != null) { + try { + os.flush(); + os.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + } + return true; + } +} diff --git a/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/utils/PropertiesUtil.java b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/utils/PropertiesUtil.java new file mode 100644 index 0000000..e8ddfce --- /dev/null +++ b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/utils/PropertiesUtil.java @@ -0,0 +1,172 @@ +package com.ruoyi.common.utils; + +import com.ruoyi.common.utils.file.FileUtils; +import org.apache.commons.io.IOUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.*; +import java.util.Map; +import java.util.Properties; + +/** + * Properties文件工具类 + * + * @version 2017-01-19 + */ +public class PropertiesUtil extends ObjectSwitchHelper { + /** + * 日志对象 + */ + protected Logger logger = LoggerFactory.getLogger(getClass()); + private Properties properties; + private String[] resourcesPaths; + private String properiesName = ""; + + public PropertiesUtil() { + + } + + public static PropertiesUtil create(String... resourcesPaths) { + PropertiesUtil propertiesUtil = new PropertiesUtil(resourcesPaths); + return propertiesUtil; + } + + public PropertiesUtil(String... resourcesPaths) { + load(resourcesPaths); + } + + public void load(String... resourcesPaths) { + this.resourcesPaths = resourcesPaths; + properties = new Properties(); + for (String location : resourcesPaths) { + logger.debug("Loading properties file from:" + location); + InputStream is = null; + try { + is = PropertiesUtil.class.getClassLoader().getResourceAsStream(location); + properties.load(is); + } catch (IOException ex) { + logger.info("Could not load properties from path:" + location + ", " + ex.getMessage()); + } catch (Exception ex) { + logger.info("Could not load properties from path:" + location + ", " + ex.getMessage()); + } finally { + IOUtils.closeQuietly(is); + } + } + } + + /** + * 更新与删除时指定文件名称 + * + * @param properiesName + */ + public void setOptProperiesName(String properiesName) { + this.properiesName = properiesName; + } + + @Override + public Object get(String key) { + if (properties.containsKey(key)) { + return properties.getProperty(key); + } + return ""; + } + + public String getAbsolutePath(String filename) { + if (!FileUtils.isAbsolutePath(filename)) { + filename = PropertiesUtil.class.getClassLoader().getResource(filename).getPath(); + } + return filename; + } + + @Override + public void set(String key, Object value) { + if (StringUtils.isEmpty(this.properiesName)) { + this.properiesName = this.resourcesPaths[0]; + } + InputStream is = null; + OutputStream os = null; + Properties p = new Properties(); + try { + FileUtils.createFile(getAbsolutePath(this.properiesName)); + is = new FileInputStream(getAbsolutePath(this.properiesName)); + p.load(is); + os = new FileOutputStream(getAbsolutePath(this.properiesName)); + p.setProperty(key, value + ""); + p.store(os, "====配置更新===="); + os.flush(); + os.close(); + } catch (Exception e) { + e.printStackTrace(); + } finally { + IOUtils.closeQuietly(is); + IOUtils.closeQuietly(os); + } + this.properiesName = ""; + } + + public void set(Map dataMap) { + if (StringUtils.isEmpty(this.properiesName)) { + this.properiesName = this.resourcesPaths[0]; + } + InputStream is = null; + OutputStream os = null; + Properties p = new Properties(); + try { + FileUtils.createFile(getAbsolutePath(this.properiesName)); + is = new FileInputStream(getAbsolutePath(this.properiesName)); + p.load(is); + os = new FileOutputStream(getAbsolutePath(this.properiesName)); + for (Map.Entry entry : dataMap.entrySet()) { + p.setProperty(entry.getKey(), entry.getValue() + ""); + } + p.store(os, "====配置更新===="); + os.flush(); + os.close(); + } catch (Exception e) { + e.printStackTrace(); + } finally { + IOUtils.closeQuietly(is); + IOUtils.closeQuietly(os); + } + this.properiesName = ""; + } + + @Override + public boolean remove(String key) { + if (StringUtils.isEmpty(this.properiesName)) { + this.properiesName = this.resourcesPaths[0]; + } + InputStream is = null; + OutputStream os = null; + Properties p = new Properties(); + try { + is = new FileInputStream(getAbsolutePath(this.properiesName)); + p.load(is); + os = new FileOutputStream(getAbsolutePath(this.properiesName)); + p.remove(key); + p.store(os, ""); + os.flush(); + os.close(); + } catch (Exception e) { + e.printStackTrace(); + } finally { + IOUtils.closeQuietly(is); + IOUtils.closeQuietly(os); + } + this.properiesName = ""; + return false; + } + + public static void main(String[] args) { + String properiesName = "generation/generation_config.properties"; + PropertiesUtil propertiesUtil = new PropertiesUtil(properiesName); + String sdfsdf = propertiesUtil.getString("project_path"); + System.out.println(sdfsdf); + // 指定更新与删除时指定文件名称 + // propertiesUtil.setOptProperiesName("generation/generation_config.properties"); + // propertiesUtil.set("project_path", "sdfsdfsd"); + + } + +} diff --git a/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/utils/SecurityUtils.java b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/utils/SecurityUtils.java new file mode 100644 index 0000000..23c2caf --- /dev/null +++ b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/utils/SecurityUtils.java @@ -0,0 +1,123 @@ +package com.ruoyi.common.utils; + +import com.ruoyi.common.core.domain.entity.SysRole; +import org.springframework.security.core.Authentication; +import org.springframework.security.core.context.SecurityContextHolder; +import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; +import com.ruoyi.common.constant.HttpStatus; +import com.ruoyi.common.core.domain.model.LoginUser; +import com.ruoyi.common.exception.ServiceException; + +import java.util.Arrays; +import java.util.List; + +/** + * 安全服务工具类 + * + * @author ruoyi + */ +public class SecurityUtils { + /** + * 用户ID + **/ + public static Long getUserId() { + try { + return getLoginUser().getUserId(); + } catch (Exception e) { + return 0L; +// throw new ServiceException("获取用户ID异常", HttpStatus.UNAUTHORIZED); + } + } + + /** + * 获取部门ID + **/ + public static String getDeptId() { + try { + return getLoginUser().getDeptId(); + } catch (Exception e) { + throw new ServiceException("获取部门ID异常", HttpStatus.UNAUTHORIZED); + } + } + + /** + * 获取用户账户 + **/ + public static String getUsername() { + try { + return getLoginUser().getUsername(); + } catch (Exception e) { + throw new ServiceException("获取用户账户异常", HttpStatus.UNAUTHORIZED); + } + } + + /** + * 获取用户 + **/ + public static LoginUser getLoginUser() { + try { + if (getAuthentication() == null || getAuthentication().getPrincipal() instanceof String) { + return null; + } + return (LoginUser) getAuthentication().getPrincipal(); + } catch (Exception e) { + throw new ServiceException("获取用户信息异常", HttpStatus.UNAUTHORIZED); + } + } + + /** + * 获取Authentication + */ + public static Authentication getAuthentication() { + return SecurityContextHolder.getContext().getAuthentication(); + } + + /** + * 生成BCryptPasswordEncoder密码 + * + * @param password 密码 + * @return 加密字符串 + */ + public static String encryptPassword(String password) { + BCryptPasswordEncoder passwordEncoder = new BCryptPasswordEncoder(); + return passwordEncoder.encode(password); + } + + /** + * 判断密码是否相同 + * + * @param rawPassword 真实密码 + * @param encodedPassword 加密后字符 + * @return 结果 + */ + public static boolean matchesPassword(String rawPassword, String encodedPassword) { + BCryptPasswordEncoder passwordEncoder = new BCryptPasswordEncoder(); + return passwordEncoder.matches(rawPassword, encodedPassword); + } + + /** + * 是否为管理员 + * + * @param userId 用户ID + * @return 结果 + */ + public static boolean isAdmin(Long userId) { + return userId != null && 1L == userId; + } + + + /** + * 判断当前用户角色 + * + * @param roleKeys + * @return 结果 + */ + public static boolean hasRoleKey(String... roleKeys) { + + //当前登入角色 + List roles = SecurityUtils.getLoginUser().getUser().getRoles(); + + return roles.stream().anyMatch(s->Arrays.asList(roleKeys).contains(s.getRoleKey())); + } + +} diff --git a/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/utils/ServletUtils.java b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/utils/ServletUtils.java new file mode 100644 index 0000000..03576c5 --- /dev/null +++ b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/utils/ServletUtils.java @@ -0,0 +1,152 @@ +package com.ruoyi.common.utils; + +import java.io.IOException; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpSession; +import org.springframework.web.context.request.RequestAttributes; +import org.springframework.web.context.request.RequestContextHolder; +import org.springframework.web.context.request.ServletRequestAttributes; +import com.ruoyi.common.core.text.Convert; + +/** + * 客户端工具类 + * + * @author ruoyi + */ +public class ServletUtils +{ + /** + * 获取String参数 + */ + public static String getParameter(String name) + { + return getRequest().getParameter(name); + } + + /** + * 获取String参数 + */ + public static String getParameter(String name, String defaultValue) + { + return Convert.toStr(getRequest().getParameter(name), defaultValue); + } + + /** + * 获取Integer参数 + */ + public static Integer getParameterToInt(String name) + { + return Convert.toInt(getRequest().getParameter(name)); + } + + /** + * 获取Integer参数 + */ + public static Integer getParameterToInt(String name, Integer defaultValue) + { + return Convert.toInt(getRequest().getParameter(name), defaultValue); + } + + /** + * 获取Boolean参数 + */ + public static Boolean getParameterToBool(String name) + { + return Convert.toBool(getRequest().getParameter(name)); + } + + /** + * 获取Boolean参数 + */ + public static Boolean getParameterToBool(String name, Boolean defaultValue) + { + return Convert.toBool(getRequest().getParameter(name), defaultValue); + } + + /** + * 获取request + */ + public static HttpServletRequest getRequest() + { + return getRequestAttributes().getRequest(); + } + + /** + * 获取response + */ + public static HttpServletResponse getResponse() + { + return getRequestAttributes().getResponse(); + } + + /** + * 获取session + */ + public static HttpSession getSession() + { + return getRequest().getSession(); + } + + public static ServletRequestAttributes getRequestAttributes() + { + RequestAttributes attributes = RequestContextHolder.getRequestAttributes(); + return (ServletRequestAttributes) attributes; + } + + /** + * 将字符串渲染到客户端 + * + * @param response 渲染对象 + * @param string 待渲染的字符串 + * @return null + */ + public static String renderString(HttpServletResponse response, String string) + { + try + { + response.setStatus(200); + response.setContentType("application/json"); + response.setCharacterEncoding("utf-8"); + response.getWriter().print(string); + } + catch (IOException e) + { + e.printStackTrace(); + } + return null; + } + + /** + * 是否是Ajax异步请求 + * + * @param request + */ + public static boolean isAjaxRequest(HttpServletRequest request) + { + String accept = request.getHeader("accept"); + if (accept != null && accept.indexOf("application/json") != -1) + { + return true; + } + + String xRequestedWith = request.getHeader("X-Requested-With"); + if (xRequestedWith != null && xRequestedWith.indexOf("XMLHttpRequest") != -1) + { + return true; + } + + String uri = request.getRequestURI(); + if (StringUtils.inStringIgnoreCase(uri, ".json", ".xml")) + { + return true; + } + + String ajax = request.getParameter("__ajax"); + if (StringUtils.inStringIgnoreCase(ajax, "json", "xml")) + { + return true; + } + return false; + } +} diff --git a/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/utils/StringUtils.java b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/utils/StringUtils.java new file mode 100644 index 0000000..70c818d --- /dev/null +++ b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/utils/StringUtils.java @@ -0,0 +1,560 @@ +package com.ruoyi.common.utils; + +import java.util.*; + +import org.springframework.util.AntPathMatcher; +import com.ruoyi.common.constant.Constants; +import com.ruoyi.common.core.text.StrFormatter; + +/** + * 字符串工具类 + * + * @author ruoyi + */ +public class StringUtils extends org.apache.commons.lang3.StringUtils +{ + /** 空字符串 */ + private static final String NULLSTR = ""; + + /** 下划线 */ + private static final char SEPARATOR = '_'; + + /** + * 获取参数不为空值 + * + * @param value defaultValue 要判断的value + * @return value 返回值 + */ + public static T nvl(T value, T defaultValue) + { + return value != null ? value : defaultValue; + } + + /** + * * 判断一个Collection是否为空, 包含List,Set,Queue + * + * @param coll 要判断的Collection + * @return true:为空 false:非空 + */ + public static boolean isEmpty(Collection coll) + { + return isNull(coll) || coll.isEmpty(); + } + + /** + * * 判断一个Collection是否非空,包含List,Set,Queue + * + * @param coll 要判断的Collection + * @return true:非空 false:空 + */ + public static boolean isNotEmpty(Collection coll) + { + return !isEmpty(coll); + } + + /** + * * 判断一个对象数组是否为空 + * + * @param objects 要判断的对象数组 + ** @return true:为空 false:非空 + */ + public static boolean isEmpty(Object[] objects) + { + return isNull(objects) || (objects.length == 0); + } + + /** + * * 判断一个对象数组是否非空 + * + * @param objects 要判断的对象数组 + * @return true:非空 false:空 + */ + public static boolean isNotEmpty(Object[] objects) + { + return !isEmpty(objects); + } + + /** + * * 判断一个Map是否为空 + * + * @param map 要判断的Map + * @return true:为空 false:非空 + */ + public static boolean isEmpty(Map map) + { + return isNull(map) || map.isEmpty(); + } + + /** + * * 判断一个Map是否为空 + * + * @param map 要判断的Map + * @return true:非空 false:空 + */ + public static boolean isNotEmpty(Map map) + { + return !isEmpty(map); + } + + /** + * * 判断一个字符串是否为空串 + * + * @param str String + * @return true:为空 false:非空 + */ + public static boolean isEmpty(String str) + { + return isNull(str) || NULLSTR.equals(str.trim()); + } + + /** + * * 判断一个字符串是否为非空串 + * + * @param str String + * @return true:非空串 false:空串 + */ + public static boolean isNotEmpty(String str) + { + return !isEmpty(str); + } + + /** + * * 判断一个对象是否为空 + * + * @param object Object + * @return true:为空 false:非空 + */ + public static boolean isNull(Object object) + { + return object == null; + } + + /** + * * 判断一个对象是否非空 + * + * @param object Object + * @return true:非空 false:空 + */ + public static boolean isNotNull(Object object) + { + return !isNull(object); + } + + /** + * * 判断一个对象是否是数组类型(Java基本型别的数组) + * + * @param object 对象 + * @return true:是数组 false:不是数组 + */ + public static boolean isArray(Object object) + { + return isNotNull(object) && object.getClass().isArray(); + } + + /** + * 去空格 + */ + public static String trim(String str) + { + return (str == null ? "" : str.trim()); + } + + /** + * 截取字符串 + * + * @param str 字符串 + * @param start 开始 + * @return 结果 + */ + public static String substring(final String str, int start) + { + if (str == null) + { + return NULLSTR; + } + + if (start < 0) + { + start = str.length() + start; + } + + if (start < 0) + { + start = 0; + } + if (start > str.length()) + { + return NULLSTR; + } + + return str.substring(start); + } + + /** + * 截取字符串 + * + * @param str 字符串 + * @param start 开始 + * @param end 结束 + * @return 结果 + */ + public static String substring(final String str, int start, int end) + { + if (str == null) + { + return NULLSTR; + } + + if (end < 0) + { + end = str.length() + end; + } + if (start < 0) + { + start = str.length() + start; + } + + if (end > str.length()) + { + end = str.length(); + } + + if (start > end) + { + return NULLSTR; + } + + if (start < 0) + { + start = 0; + } + if (end < 0) + { + end = 0; + } + + return str.substring(start, end); + } + + /** + * 格式化文本, {} 表示占位符
+ * 此方法只是简单将占位符 {} 按照顺序替换为参数
+ * 如果想输出 {} 使用 \\转义 { 即可,如果想输出 {} 之前的 \ 使用双转义符 \\\\ 即可
+ * 例:
+ * 通常使用:format("this is {} for {}", "a", "b") -> this is a for b
+ * 转义{}: format("this is \\{} for {}", "a", "b") -> this is \{} for a
+ * 转义\: format("this is \\\\{} for {}", "a", "b") -> this is \a for b
+ * + * @param template 文本模板,被替换的部分用 {} 表示 + * @param params 参数值 + * @return 格式化后的文本 + */ + public static String format(String template, Object... params) + { + if (isEmpty(params) || isEmpty(template)) + { + return template; + } + return StrFormatter.format(template, params); + } + + /** + * 是否为http(s)://开头 + * + * @param link 链接 + * @return 结果 + */ + public static boolean ishttp(String link) + { + return StringUtils.startsWithAny(link, Constants.HTTP, Constants.HTTPS); + } + + /** + * 字符串转set + * + * @param str 字符串 + * @param sep 分隔符 + * @return set集合 + */ + public static final Set str2Set(String str, String sep) + { + return new HashSet(str2List(str, sep, true, false)); + } + + /** + * 字符串转list + * + * @param str 字符串 + * @param sep 分隔符 + * @param filterBlank 过滤纯空白 + * @param trim 去掉首尾空白 + * @return list集合 + */ + public static final List str2List(String str, String sep, boolean filterBlank, boolean trim) + { + List list = new ArrayList(); + if (StringUtils.isEmpty(str)) + { + return list; + } + + // 过滤空白字符串 + if (filterBlank && StringUtils.isBlank(str)) + { + return list; + } + String[] split = str.split(sep); + for (String string : split) + { + if (filterBlank && StringUtils.isBlank(string)) + { + continue; + } + if (trim) + { + string = string.trim(); + } + list.add(string); + } + + return list; + } + + /** + * 查找指定字符串是否包含指定字符串列表中的任意一个字符串同时串忽略大小写 + * + * @param cs 指定字符串 + * @param searchCharSequences 需要检查的字符串数组 + * @return 是否包含任意一个字符串 + */ + public static boolean containsAnyIgnoreCase(CharSequence cs, CharSequence... searchCharSequences) + { + if (isEmpty(cs) || isEmpty(searchCharSequences)) + { + return false; + } + for (CharSequence testStr : searchCharSequences) + { + if (containsIgnoreCase(cs, testStr)) + { + return true; + } + } + return false; + } + + /** + * 驼峰转下划线命名 + */ + public static String toUnderScoreCase(String str) + { + if (str == null) + { + return null; + } + StringBuilder sb = new StringBuilder(); + // 前置字符是否大写 + boolean preCharIsUpperCase = true; + // 当前字符是否大写 + boolean curreCharIsUpperCase = true; + // 下一字符是否大写 + boolean nexteCharIsUpperCase = true; + for (int i = 0; i < str.length(); i++) + { + char c = str.charAt(i); + if (i > 0) + { + preCharIsUpperCase = Character.isUpperCase(str.charAt(i - 1)); + } + else + { + preCharIsUpperCase = false; + } + + curreCharIsUpperCase = Character.isUpperCase(c); + + if (i < (str.length() - 1)) + { + nexteCharIsUpperCase = Character.isUpperCase(str.charAt(i + 1)); + } + + if (preCharIsUpperCase && curreCharIsUpperCase && !nexteCharIsUpperCase) + { + sb.append(SEPARATOR); + } + else if ((i != 0 && !preCharIsUpperCase) && curreCharIsUpperCase) + { + sb.append(SEPARATOR); + } + sb.append(Character.toLowerCase(c)); + } + + return sb.toString(); + } + + /** + * 是否包含字符串 + * + * @param str 验证字符串 + * @param strs 字符串组 + * @return 包含返回true + */ + public static boolean inStringIgnoreCase(String str, String... strs) + { + if (str != null && strs != null) + { + for (String s : strs) + { + if (str.equalsIgnoreCase(trim(s))) + { + return true; + } + } + } + return false; + } + + /** + * 将下划线大写方式命名的字符串转换为驼峰式。如果转换前的下划线大写方式命名的字符串为空,则返回空字符串。 例如:HELLO_WORLD->HelloWorld + * + * @param name 转换前的下划线大写方式命名的字符串 + * @return 转换后的驼峰式命名的字符串 + */ + public static String convertToCamelCase(String name) + { + StringBuilder result = new StringBuilder(); + // 快速检查 + if (name == null || name.isEmpty()) + { + // 没必要转换 + return ""; + } + else if (!name.contains("_")) + { + // 不含下划线,仅将首字母大写 + return name.substring(0, 1).toUpperCase() + name.substring(1); + } + // 用下划线将原始字符串分割 + String[] camels = name.split("_"); + for (String camel : camels) + { + // 跳过原始字符串中开头、结尾的下换线或双重下划线 + if (camel.isEmpty()) + { + continue; + } + // 首字母大写 + result.append(camel.substring(0, 1).toUpperCase()); + result.append(camel.substring(1).toLowerCase()); + } + return result.toString(); + } + + /** + * 驼峰式命名法 例如:user_name->userName + */ + public static String toCamelCase(String s) + { + if (s == null) + { + return null; + } + s = s.toLowerCase(); + StringBuilder sb = new StringBuilder(s.length()); + boolean upperCase = false; + for (int i = 0; i < s.length(); i++) + { + char c = s.charAt(i); + + if (c == SEPARATOR) + { + upperCase = true; + } + else if (upperCase) + { + sb.append(Character.toUpperCase(c)); + upperCase = false; + } + else + { + sb.append(c); + } + } + return sb.toString(); + } + + /** + * 查找指定字符串是否匹配指定字符串列表中的任意一个字符串 + * + * @param str 指定字符串 + * @param strs 需要检查的字符串数组 + * @return 是否匹配 + */ + public static boolean matches(String str, List strs) + { + if (isEmpty(str) || isEmpty(strs)) + { + return false; + } + for (String pattern : strs) + { + if (isMatch(pattern, str)) + { + return true; + } + } + return false; + } + + /** + * 判断url是否与规则配置: + * ? 表示单个字符; + * * 表示一层路径内的任意字符串,不可跨层级; + * ** 表示任意层路径; + * + * @param pattern 匹配规则 + * @param url 需要匹配的url + * @return + */ + public static boolean isMatch(String pattern, String url) + { + AntPathMatcher matcher = new AntPathMatcher(); + return matcher.match(pattern, url); + } + + /* + * 生成随机字符串 + */ + public static String randomNumber(int length) { //length表示生成字符串的长度 + String base = "0123456789"; + Random random = new Random(); + StringBuffer sb = new StringBuffer(); + for (int i = 0; i < length; i++) { + int number = random.nextInt(base.length()); + sb.append(base.charAt(number)); + } + return sb.toString(); + } + + @SuppressWarnings("unchecked") + public static T cast(Object obj) + { + return (T) obj; + } + + /** + * 去掉前面的下划线 + * + * @param filename + * @return + */ + public static String trimDiagonal(String filename) { + if (filename.startsWith("/")) { + filename = filename.substring(1, filename.length()); + //下一次 + return trimDiagonal(filename); + } else { + return filename; + } + } +} diff --git a/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/utils/Threads.java b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/utils/Threads.java new file mode 100644 index 0000000..1934195 --- /dev/null +++ b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/utils/Threads.java @@ -0,0 +1,99 @@ +package com.ruoyi.common.utils; + +import java.util.concurrent.CancellationException; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Future; +import java.util.concurrent.TimeUnit; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * 线程相关工具类. + * + * @author ruoyi + */ +public class Threads +{ + private static final Logger logger = LoggerFactory.getLogger(Threads.class); + + /** + * sleep等待,单位为毫秒 + */ + public static void sleep(long milliseconds) + { + try + { + Thread.sleep(milliseconds); + } + catch (InterruptedException e) + { + return; + } + } + + /** + * 停止线程池 + * 先使用shutdown, 停止接收新任务并尝试完成所有已存在任务. + * 如果超时, 则调用shutdownNow, 取消在workQueue中Pending的任务,并中断所有阻塞函数. + * 如果仍人超時,則強制退出. + * 另对在shutdown时线程本身被调用中断做了处理. + */ + public static void shutdownAndAwaitTermination(ExecutorService pool) + { + if (pool != null && !pool.isShutdown()) + { + pool.shutdown(); + try + { + if (!pool.awaitTermination(120, TimeUnit.SECONDS)) + { + pool.shutdownNow(); + if (!pool.awaitTermination(120, TimeUnit.SECONDS)) + { + logger.info("Pool did not terminate"); + } + } + } + catch (InterruptedException ie) + { + pool.shutdownNow(); + Thread.currentThread().interrupt(); + } + } + } + + /** + * 打印线程异常信息 + */ + public static void printException(Runnable r, Throwable t) + { + if (t == null && r instanceof Future) + { + try + { + Future future = (Future) r; + if (future.isDone()) + { + future.get(); + } + } + catch (CancellationException ce) + { + t = ce; + } + catch (ExecutionException ee) + { + t = ee.getCause(); + } + catch (InterruptedException ie) + { + Thread.currentThread().interrupt(); + } + } + if (t != null) + { + logger.error(t.getMessage(), t); + } + } +} diff --git a/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/utils/VerifyCodeUtils.java b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/utils/VerifyCodeUtils.java new file mode 100644 index 0000000..5fdf3a9 --- /dev/null +++ b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/utils/VerifyCodeUtils.java @@ -0,0 +1,228 @@ +package com.ruoyi.common.utils; + +import java.awt.Color; +import java.awt.Font; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.RenderingHints; +import java.awt.geom.AffineTransform; +import java.awt.image.BufferedImage; +import java.io.IOException; +import java.io.OutputStream; +import java.security.SecureRandom; +import java.util.Arrays; +import java.util.Random; +import javax.imageio.ImageIO; + +/** + * 验证码工具类 + * + * @author ruoyi + */ +public class VerifyCodeUtils +{ + // 使用到Algerian字体,系统里没有的话需要安装字体,字体只显示大写,去掉了1,0,i,o几个容易混淆的字符 + public static final String VERIFY_CODES = "123456789ABCDEFGHJKLMNPQRSTUVWXYZ"; + + private static Random random = new SecureRandom(); + + /** + * 使用系统默认字符源生成验证码 + * + * @param verifySize 验证码长度 + * @return + */ + public static String generateVerifyCode(int verifySize) + { + return generateVerifyCode(verifySize, VERIFY_CODES); + } + + /** + * 使用指定源生成验证码 + * + * @param verifySize 验证码长度 + * @param sources 验证码字符源 + * @return + */ + public static String generateVerifyCode(int verifySize, String sources) + { + if (sources == null || sources.length() == 0) + { + sources = VERIFY_CODES; + } + int codesLen = sources.length(); + Random rand = new Random(System.currentTimeMillis()); + StringBuilder verifyCode = new StringBuilder(verifySize); + for (int i = 0; i < verifySize; i++) + { + verifyCode.append(sources.charAt(rand.nextInt(codesLen - 1))); + } + return verifyCode.toString(); + } + + /** + * 输出指定验证码图片流 + * + * @param w + * @param h + * @param os + * @param code + * @throws IOException + */ + public static void outputImage(int w, int h, OutputStream os, String code) throws IOException + { + int verifySize = code.length(); + BufferedImage image = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB); + Random rand = new Random(); + Graphics2D g2 = image.createGraphics(); + g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); + Color[] colors = new Color[5]; + Color[] colorSpaces = new Color[] { Color.WHITE, Color.CYAN, Color.GRAY, Color.LIGHT_GRAY, Color.MAGENTA, + Color.ORANGE, Color.PINK, Color.YELLOW }; + float[] fractions = new float[colors.length]; + for (int i = 0; i < colors.length; i++) + { + colors[i] = colorSpaces[rand.nextInt(colorSpaces.length)]; + fractions[i] = rand.nextFloat(); + } + Arrays.sort(fractions); + + g2.setColor(Color.GRAY);// 设置边框色 + g2.fillRect(0, 0, w, h); + + Color c = getRandColor(200, 250); + g2.setColor(c);// 设置背景色 + g2.fillRect(0, 2, w, h - 4); + + // 绘制干扰线 + Random random = new Random(); + g2.setColor(getRandColor(160, 200));// 设置线条的颜色 + for (int i = 0; i < 20; i++) + { + int x = random.nextInt(w - 1); + int y = random.nextInt(h - 1); + int xl = random.nextInt(6) + 1; + int yl = random.nextInt(12) + 1; + g2.drawLine(x, y, x + xl + 40, y + yl + 20); + } + + // 添加噪点 + float yawpRate = 0.05f;// 噪声率 + int area = (int) (yawpRate * w * h); + for (int i = 0; i < area; i++) + { + int x = random.nextInt(w); + int y = random.nextInt(h); + int rgb = getRandomIntColor(); + image.setRGB(x, y, rgb); + } + + shear(g2, w, h, c);// 使图片扭曲 + + g2.setColor(getRandColor(100, 160)); + int fontSize = h - 4; + Font font = new Font("Algerian", Font.ITALIC, fontSize); + g2.setFont(font); + char[] chars = code.toCharArray(); + for (int i = 0; i < verifySize; i++) + { + AffineTransform affine = new AffineTransform(); + affine.setToRotation(Math.PI / 4 * rand.nextDouble() * (rand.nextBoolean() ? 1 : -1), + (w / verifySize) * i + fontSize / 2, h / 2); + g2.setTransform(affine); + g2.drawChars(chars, i, 1, ((w - 10) / verifySize) * i + 5, h / 2 + fontSize / 2 - 10); + } + + g2.dispose(); + ImageIO.write(image, "jpg", os); + } + + private static Color getRandColor(int fc, int bc) + { + if (fc > 255) { + fc = 255; + } + if (bc > 255) { + bc = 255; + } + int r = fc + random.nextInt(bc - fc); + int g = fc + random.nextInt(bc - fc); + int b = fc + random.nextInt(bc - fc); + return new Color(r, g, b); + } + + private static int getRandomIntColor() + { + int[] rgb = getRandomRgb(); + int color = 0; + for (int c : rgb) + { + color = color << 8; + color = color | c; + } + return color; + } + + private static int[] getRandomRgb() + { + int[] rgb = new int[3]; + for (int i = 0; i < 3; i++) + { + rgb[i] = random.nextInt(255); + } + return rgb; + } + + private static void shear(Graphics g, int w1, int h1, Color color) + { + shearX(g, w1, h1, color); + shearY(g, w1, h1, color); + } + + private static void shearX(Graphics g, int w1, int h1, Color color) + { + + int period = random.nextInt(2); + + boolean borderGap = true; + int frames = 1; + int phase = random.nextInt(2); + + for (int i = 0; i < h1; i++) + { + double d = (double) (period >> 1) + * Math.sin((double) i / (double) period + (6.2831853071795862D * (double) phase) / (double) frames); + g.copyArea(0, i, w1, 1, (int) d, 0); + if (borderGap) + { + g.setColor(color); + g.drawLine((int) d, i, 0, i); + g.drawLine((int) d + w1, i, w1, i); + } + } + + } + + private static void shearY(Graphics g, int w1, int h1, Color color) + { + + int period = random.nextInt(40) + 10; // 50; + + boolean borderGap = true; + int frames = 20; + int phase = 7; + for (int i = 0; i < w1; i++) + { + double d = (double) (period >> 1) + * Math.sin((double) i / (double) period + (6.2831853071795862D * (double) phase) / (double) frames); + g.copyArea(i, 0, 1, h1, 0, (int) d); + if (borderGap) + { + g.setColor(color); + g.drawLine(i, (int) d, i, 0); + g.drawLine(i, (int) d + h1, i, h1); + } + + } + } +} \ No newline at end of file diff --git a/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/utils/bean/BeanUtils.java b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/utils/bean/BeanUtils.java new file mode 100644 index 0000000..cdbe8b7 --- /dev/null +++ b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/utils/bean/BeanUtils.java @@ -0,0 +1,196 @@ +package com.ruoyi.common.utils.bean; + +import org.springframework.cglib.beans.BeanCopier; +import org.springframework.lang.Nullable; + +import java.beans.BeanInfo; +import java.beans.IntrospectionException; +import java.beans.Introspector; +import java.beans.PropertyDescriptor; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * Bean 工具类 + * + * @author ruoyi + */ +public class BeanUtils extends org.springframework.beans.BeanUtils +{ + /** Bean方法名中属性名开始的下标 */ + private static final int BEAN_METHOD_PROP_INDEX = 3; + + /** * 匹配getter方法的正则表达式 */ + private static final Pattern GET_PATTERN = Pattern.compile("get(\\p{javaUpperCase}\\w*)"); + + /** * 匹配setter方法的正则表达式 */ + private static final Pattern SET_PATTERN = Pattern.compile("set(\\p{javaUpperCase}\\w*)"); + + /** + * Bean属性复制工具方法。 + * + * @param dest 目标对象 + * @param src 源对象 + */ + public static void copyBeanProp(Object dest, Object src) + { + try + { + copyProperties(src, dest); + } + catch (Exception e) + { + e.printStackTrace(); + } + } + + /** + * 获取对象的setter方法。 + * + * @param obj 对象 + * @return 对象的setter方法列表 + */ + public static List getSetterMethods(Object obj) + { + // setter方法列表 + List setterMethods = new ArrayList(); + + // 获取所有方法 + Method[] methods = obj.getClass().getMethods(); + + // 查找setter方法 + + for (Method method : methods) + { + Matcher m = SET_PATTERN.matcher(method.getName()); + if (m.matches() && (method.getParameterTypes().length == 1)) + { + setterMethods.add(method); + } + } + // 返回setter方法列表 + return setterMethods; + } + + /** + * 获取对象的getter方法。 + * + * @param obj 对象 + * @return 对象的getter方法列表 + */ + + public static List getGetterMethods(Object obj) + { + // getter方法列表 + List getterMethods = new ArrayList(); + // 获取所有方法 + Method[] methods = obj.getClass().getMethods(); + // 查找getter方法 + for (Method method : methods) + { + Matcher m = GET_PATTERN.matcher(method.getName()); + if (m.matches() && (method.getParameterTypes().length == 0)) + { + getterMethods.add(method); + } + } + // 返回getter方法列表 + return getterMethods; + } + + /** + * 检查Bean方法名中的属性名是否相等。
+ * 如getName()和setName()属性名一样,getName()和setAge()属性名不一样。 + * + * @param m1 方法名1 + * @param m2 方法名2 + * @return 属性名一样返回true,否则返回false + */ + + public static boolean isMethodPropEquals(String m1, String m2) + { + return m1.substring(BEAN_METHOD_PROP_INDEX).equals(m2.substring(BEAN_METHOD_PROP_INDEX)); + } + + /** + * 将一个 JavaBean 对象转化为一个 Map + * + * @param bean 要转化的JavaBean 对象 + * @return 转化出来的 Map 对象 + * @throws IntrospectionException 如果分析类属性失败 + * @throws IllegalAccessException 如果实例化 JavaBean 失败 + * @throws InvocationTargetException 如果调用属性的 setter 方法失败 + */ + public static Map convertBean(Object bean) + throws IntrospectionException, IllegalAccessException, InvocationTargetException { + Class type = bean.getClass(); + Map returnMap = new HashMap(); + BeanInfo beanInfo = Introspector.getBeanInfo(type); + + PropertyDescriptor[] propertyDescriptors = beanInfo.getPropertyDescriptors(); + for (int i = 0; i < propertyDescriptors.length; i++) { + PropertyDescriptor descriptor = propertyDescriptors[i]; + String propertyName = descriptor.getName(); + if (!"class".equals(propertyName)) { + Method readMethod = descriptor.getReadMethod(); + Object result = readMethod.invoke(bean, new Object[0]); + if (result != null) { + returnMap.put(propertyName, result); + } else { + returnMap.put(propertyName, ""); + } + } + } + return returnMap; + } + + /** + * 深复制 + * + *

+ * 支持 map bean + *

+ * + * @param source 源对象 + * @param 泛型标记 + * @return T + */ + @SuppressWarnings("unchecked") + @Nullable + public static T clone(@Nullable T source) { + if (source == null) { + return null; + } + return (T) copy(source, source.getClass()); + } + @Nullable + public static T copy(@Nullable Object source, Class clazz) { + if (source == null) { + return null; + } + return copy(source, source.getClass(), clazz); + } + + @Nullable + public static T copy(@Nullable Object source, Class sourceClazz, Class targetClazz) { + if (source == null) { + return null; + } + BeanCopier copier = BeanCopier.create(sourceClazz, targetClazz, false); + T to = newInstance(targetClazz); + copier.copy(source, to, null); + return to; + } + public static T newInstance(Class clazz) { + return (T) instantiateClass(clazz); + } + + + +} diff --git a/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/utils/file/FileTypeUtils.java b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/utils/file/FileTypeUtils.java new file mode 100644 index 0000000..68130b9 --- /dev/null +++ b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/utils/file/FileTypeUtils.java @@ -0,0 +1,76 @@ +package com.ruoyi.common.utils.file; + +import java.io.File; +import org.apache.commons.lang3.StringUtils; + +/** + * 文件类型工具类 + * + * @author ruoyi + */ +public class FileTypeUtils +{ + /** + * 获取文件类型 + *

+ * 例如: ruoyi.txt, 返回: txt + * + * @param file 文件名 + * @return 后缀(不含".") + */ + public static String getFileType(File file) + { + if (null == file) + { + return StringUtils.EMPTY; + } + return getFileType(file.getName()); + } + + /** + * 获取文件类型 + *

+ * 例如: ruoyi.txt, 返回: txt + * + * @param fileName 文件名 + * @return 后缀(不含".") + */ + public static String getFileType(String fileName) + { + int separatorIndex = fileName.lastIndexOf("."); + if (separatorIndex < 0) + { + return ""; + } + return fileName.substring(separatorIndex + 1).toLowerCase(); + } + + /** + * 获取文件类型 + * + * @param photoByte 文件字节码 + * @return 后缀(不含".") + */ + public static String getFileExtendName(byte[] photoByte) + { + String strFileExtendName = "JPG"; + if ((photoByte[0] == 71) && (photoByte[1] == 73) && (photoByte[2] == 70) && (photoByte[3] == 56) + && ((photoByte[4] == 55) || (photoByte[4] == 57)) && (photoByte[5] == 97)) + { + strFileExtendName = "GIF"; + } + else if ((photoByte[6] == 74) && (photoByte[7] == 70) && (photoByte[8] == 73) && (photoByte[9] == 70)) + { + strFileExtendName = "JPG"; + } + else if ((photoByte[0] == 66) && (photoByte[1] == 77)) + { + strFileExtendName = "BMP"; + } + else if ((photoByte[1] == 80) && (photoByte[2] == 78) && (photoByte[3] == 71)) + { + strFileExtendName = "PNG"; + } + return strFileExtendName; + } +} \ No newline at end of file diff --git a/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/utils/file/FileUploadUtils.java b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/utils/file/FileUploadUtils.java new file mode 100644 index 0000000..eb12806 --- /dev/null +++ b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/utils/file/FileUploadUtils.java @@ -0,0 +1,235 @@ +package com.ruoyi.common.utils.file; + +import java.io.File; +import java.io.IOException; +import org.apache.commons.io.FilenameUtils; +import org.springframework.web.multipart.MultipartFile; +import com.ruoyi.common.config.RuoYiConfig; +import com.ruoyi.common.constant.Constants; +import com.ruoyi.common.exception.file.FileNameLengthLimitExceededException; +import com.ruoyi.common.exception.file.FileSizeLimitExceededException; +import com.ruoyi.common.exception.file.InvalidExtensionException; +import com.ruoyi.common.utils.DateUtils; +import com.ruoyi.common.utils.StringUtils; +import com.ruoyi.common.utils.uuid.IdUtils; + +/** + * 文件上传工具类 + * + * @author ruoyi + */ +public class FileUploadUtils +{ + /** + * 默认大小 50M + */ + public static final long DEFAULT_MAX_SIZE = 50 * 1024 * 1024; + + /** + * 默认的文件名最大长度 100 + */ + public static final int DEFAULT_FILE_NAME_LENGTH = 100; + + /** + * 默认上传的地址 + */ + private static String defaultBaseDir = RuoYiConfig.getProfile(); + + public static void setDefaultBaseDir(String defaultBaseDir) + { + FileUploadUtils.defaultBaseDir = defaultBaseDir; + } + + public static String getDefaultBaseDir() + { + return defaultBaseDir; + } + + /** + * 以默认配置进行文件上传 + * + * @param file 上传的文件 + * @return 文件名称 + * @throws Exception + */ + public static final String upload(MultipartFile file) throws IOException + { + try + { + return upload(getDefaultBaseDir(), file, MimeTypeUtils.DEFAULT_ALLOWED_EXTENSION); + } + catch (Exception e) + { + throw new IOException(e.getMessage(), e); + } + } + + /** + * 根据文件路径上传 + * + * @param baseDir 相对应用的基目录 + * @param file 上传的文件 + * @return 文件名称 + * @throws IOException + */ + public static final String upload(String baseDir, MultipartFile file) throws IOException + { + try + { + return upload(baseDir, file, MimeTypeUtils.DEFAULT_ALLOWED_EXTENSION); + } + catch (Exception e) + { + throw new IOException(e.getMessage(), e); + } + } + + /** + * 文件上传 + * + * @param baseDir 相对应用的基目录 + * @param file 上传的文件 + * @param allowedExtension 上传文件类型 + * @return 返回上传成功的文件名 + * @throws FileSizeLimitExceededException 如果超出最大大小 + * @throws FileNameLengthLimitExceededException 文件名太长 + * @throws IOException 比如读写文件出错时 + * @throws InvalidExtensionException 文件校验异常 + */ + public static final String upload(String baseDir, MultipartFile file, String[] allowedExtension) + throws FileSizeLimitExceededException, IOException, FileNameLengthLimitExceededException, + InvalidExtensionException + { + int fileNamelength = file.getOriginalFilename().length(); + if (fileNamelength > FileUploadUtils.DEFAULT_FILE_NAME_LENGTH) + { + throw new FileNameLengthLimitExceededException(FileUploadUtils.DEFAULT_FILE_NAME_LENGTH); + } + + assertAllowed(file, allowedExtension); + + String fileName = extractFilename(file); + + File desc = getAbsoluteFile(baseDir, fileName); + file.transferTo(desc); + String pathFileName = getPathFileName(baseDir, fileName); + return pathFileName; + } + + /** + * 编码文件名 + */ + public static final String extractFilename(MultipartFile file) + { + String fileName = file.getOriginalFilename(); + String extension = getExtension(file); + fileName = DateUtils.datePath() + "/" + IdUtils.fastUUID() + "." + extension; + return fileName; + } + + public static final File getAbsoluteFile(String uploadDir, String fileName) throws IOException + { + File desc = new File(uploadDir + File.separator + fileName); + + if (!desc.exists()) + { + if (!desc.getParentFile().exists()) + { + desc.getParentFile().mkdirs(); + } + } + return desc; + } + + public static final String getPathFileName(String uploadDir, String fileName) throws IOException + { + int dirLastIndex = RuoYiConfig.getProfile().length() + 1; + String currentDir = StringUtils.substring(uploadDir, dirLastIndex); + String pathFileName = Constants.RESOURCE_PREFIX + "/" + currentDir + "/" + fileName; + return pathFileName; + } + + /** + * 文件大小校验 + * + * @param file 上传的文件 + * @return + * @throws FileSizeLimitExceededException 如果超出最大大小 + * @throws InvalidExtensionException + */ + public static final void assertAllowed(MultipartFile file, String[] allowedExtension) + throws FileSizeLimitExceededException, InvalidExtensionException + { + long size = file.getSize(); + if (DEFAULT_MAX_SIZE != -1 && size > DEFAULT_MAX_SIZE) + { + throw new FileSizeLimitExceededException(DEFAULT_MAX_SIZE / 1024 / 1024); + } + + String fileName = file.getOriginalFilename(); + String extension = getExtension(file); + if (allowedExtension != null && !isAllowedExtension(extension, allowedExtension)) + { + if (allowedExtension == MimeTypeUtils.IMAGE_EXTENSION) + { + throw new InvalidExtensionException.InvalidImageExtensionException(allowedExtension, extension, + fileName); + } + else if (allowedExtension == MimeTypeUtils.FLASH_EXTENSION) + { + throw new InvalidExtensionException.InvalidFlashExtensionException(allowedExtension, extension, + fileName); + } + else if (allowedExtension == MimeTypeUtils.MEDIA_EXTENSION) + { + throw new InvalidExtensionException.InvalidMediaExtensionException(allowedExtension, extension, + fileName); + } + else if (allowedExtension == MimeTypeUtils.VIDEO_EXTENSION) + { + throw new InvalidExtensionException.InvalidVideoExtensionException(allowedExtension, extension, + fileName); + } + else + { + throw new InvalidExtensionException(allowedExtension, extension, fileName); + } + } + + } + + /** + * 判断MIME类型是否是允许的MIME类型 + * + * @param extension + * @param allowedExtension + * @return + */ + public static final boolean isAllowedExtension(String extension, String[] allowedExtension) + { + for (String str : allowedExtension) + { + if (str.equalsIgnoreCase(extension)) + { + return true; + } + } + return false; + } + + /** + * 获取文件名的后缀 + * + * @param file 表单文件 + * @return 后缀名 + */ + public static final String getExtension(MultipartFile file) + { + String extension = FilenameUtils.getExtension(file.getOriginalFilename()); + if (StringUtils.isEmpty(extension)) + { + extension = MimeTypeUtils.getExtension(file.getContentType()); + } + return extension; + } +} diff --git a/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/utils/file/FileUtils.java b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/utils/file/FileUtils.java new file mode 100644 index 0000000..789573d --- /dev/null +++ b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/utils/file/FileUtils.java @@ -0,0 +1,316 @@ +package com.ruoyi.common.utils.file; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.OutputStream; +import java.io.UnsupportedEncodingException; +import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import org.apache.commons.io.IOUtils; +import org.apache.commons.lang3.ArrayUtils; +import com.ruoyi.common.config.RuoYiConfig; +import com.ruoyi.common.utils.DateUtils; +import com.ruoyi.common.utils.StringUtils; +import com.ruoyi.common.utils.uuid.IdUtils; + +/** + * 文件处理工具类 + * + * @author ruoyi + */ +public class FileUtils +{ + public static String FILENAME_PATTERN = "[a-zA-Z0-9_\\-\\|\\.\\u4e00-\\u9fa5]+"; + + /** + * 输出指定文件的byte数组 + * + * @param filePath 文件路径 + * @param os 输出流 + * @return + */ + public static void writeBytes(String filePath, OutputStream os) throws IOException + { + FileInputStream fis = null; + try + { + File file = new File(filePath); + if (!file.exists()) + { + throw new FileNotFoundException(filePath); + } + fis = new FileInputStream(file); + byte[] b = new byte[1024]; + int length; + while ((length = fis.read(b)) > 0) + { + os.write(b, 0, length); + } + } + catch (IOException e) + { + throw e; + } + finally + { + IOUtils.close(os); + IOUtils.close(fis); + } + } + + /** + * 写数据到文件中 + * + * @param data 数据 + * @return 目标文件 + * @throws IOException IO异常 + */ + public static String writeImportBytes(byte[] data) throws IOException + { + return writeBytes(data, RuoYiConfig.getImportPath()); + } + + /** + * 写数据到文件中 + * + * @param data 数据 + * @param uploadDir 目标文件 + * @return 目标文件 + * @throws IOException IO异常 + */ + public static String writeBytes(byte[] data, String uploadDir) throws IOException + { + FileOutputStream fos = null; + String pathName = ""; + try + { + String extension = getFileExtendName(data); + pathName = DateUtils.datePath() + "/" + IdUtils.fastUUID() + "." + extension; + File file = FileUploadUtils.getAbsoluteFile(uploadDir, pathName); + fos = new FileOutputStream(file); + fos.write(data); + } + finally + { + IOUtils.close(fos); + } + return FileUploadUtils.getPathFileName(uploadDir, pathName); + } + + /** + * 删除文件 + * + * @param filePath 文件 + * @return + */ + public static boolean deleteFile(String filePath) + { + boolean flag = false; + File file = new File(filePath); + // 路径为文件且不为空则进行删除 + if (file.isFile() && file.exists()) + { + file.delete(); + flag = true; + } + return flag; + } + + /** + * 文件名称验证 + * + * @param filename 文件名称 + * @return true 正常 false 非法 + */ + public static boolean isValidFilename(String filename) + { + return filename.matches(FILENAME_PATTERN); + } + + /** + * 检查文件是否可下载 + * + * @param resource 需要下载的文件 + * @return true 正常 false 非法 + */ + public static boolean checkAllowDownload(String resource) + { + // 禁止目录上跳级别 + if (StringUtils.contains(resource, "..")) + { + return false; + } + + // 检查允许下载的文件规则 + if (ArrayUtils.contains(MimeTypeUtils.DEFAULT_ALLOWED_EXTENSION, FileTypeUtils.getFileType(resource))) + { + return true; + } + + // 不在允许下载的文件规则 + return false; + } + + /** + * 下载文件名重新编码 + * + * @param request 请求对象 + * @param fileName 文件名 + * @return 编码后的文件名 + */ + public static String setFileDownloadHeader(HttpServletRequest request, String fileName) throws UnsupportedEncodingException + { + final String agent = request.getHeader("USER-AGENT"); + String filename = fileName; + if (agent.contains("MSIE")) + { + // IE浏览器 + filename = URLEncoder.encode(filename, "utf-8"); + filename = filename.replace("+", " "); + } + else if (agent.contains("Firefox")) + { + // 火狐浏览器 + filename = new String(fileName.getBytes(), "ISO8859-1"); + } + else if (agent.contains("Chrome")) + { + // google浏览器 + filename = URLEncoder.encode(filename, "utf-8"); + } + else + { + // 其它浏览器 + filename = URLEncoder.encode(filename, "utf-8"); + } + return filename; + } + + /** + * 下载文件名重新编码 + * + * @param response 响应对象 + * @param realFileName 真实文件名 + * @return + */ + public static void setAttachmentResponseHeader(HttpServletResponse response, String realFileName) throws UnsupportedEncodingException + { + String percentEncodedFileName = percentEncode(realFileName); + + StringBuilder contentDispositionValue = new StringBuilder(); + contentDispositionValue.append("attachment; filename=") + .append(percentEncodedFileName) + .append(";") + .append("filename*=") + .append("utf-8''") + .append(percentEncodedFileName); + + response.setHeader("Content-disposition", contentDispositionValue.toString()); + response.setHeader("download-filename", percentEncodedFileName); + } + + /** + * 百分号编码工具方法 + * + * @param s 需要百分号编码的字符串 + * @return 百分号编码后的字符串 + */ + public static String percentEncode(String s) throws UnsupportedEncodingException + { + String encode = URLEncoder.encode(s, StandardCharsets.UTF_8.toString()); + return encode.replaceAll("\\+", "%20"); + } + + /** + * 获取图像后缀 + * + * @param photoByte 图像数据 + * @return 后缀名 + */ + public static String getFileExtendName(byte[] photoByte) + { + String strFileExtendName = "jpg"; + if ((photoByte[0] == 71) && (photoByte[1] == 73) && (photoByte[2] == 70) && (photoByte[3] == 56) + && ((photoByte[4] == 55) || (photoByte[4] == 57)) && (photoByte[5] == 97)) + { + strFileExtendName = "gif"; + } + else if ((photoByte[6] == 74) && (photoByte[7] == 70) && (photoByte[8] == 73) && (photoByte[9] == 70)) + { + strFileExtendName = "jpg"; + } + else if ((photoByte[0] == 66) && (photoByte[1] == 77)) + { + strFileExtendName = "bmp"; + } + else if ((photoByte[1] == 80) && (photoByte[2] == 78) && (photoByte[3] == 71)) + { + strFileExtendName = "png"; + } + return strFileExtendName; + } + + public static boolean isAbsolutePath(String path) { + if (path.startsWith("/") || path.indexOf(":") > 0) { + return true; + } + return false; + } + + // 创建单个文件 + public static boolean createFile(String filePath) { + File file = new File(filePath); + if (file.exists()) {// 判断文件是否存在 + //System.out.println("目标文件已存在" + filePath); + return false; + } + if (filePath.endsWith(File.separator)) {// 判断文件是否为目录 + //System.out.println("目标文件不能为目录!"); + return false; + } + if (!file.getParentFile().exists()) {// 判断目标文件所在的目录是否存在 + // 如果目标文件所在的文件夹不存在,则创建父文件夹 + //System.out.println("目标文件所在目录不存在,准备创建它!"); + if (!file.getParentFile().mkdirs()) {// 判断创建目录是否成功 + //System.out.println("创建目标文件所在的目录失败!"); + return false; + } + } + try { + if (file.createNewFile()) {// 创建目标文件 + //System.out.println("创建文件成功:" + filePath); + return true; + } else { + //System.out.println("创建文件失败!"); + return false; + } + } catch (IOException e) {// 捕获异常 + e.printStackTrace(); + //System.out.println("创建文件失败!" + e.getMessage()); + return false; + } + } + + + /** + * @param filename + * @return + * @title: getExtensionName + * @description: Java文件操作 获取文件扩展名 + * @return: String + */ + public static String getExtensionName(String filename) { + if ((filename != null) && (filename.length() > 0)) { + int dot = filename.lastIndexOf('.'); + if ((dot > -1) && (dot < (filename.length() - 1))) { + return filename.substring(dot + 1); + } + } + return filename; + } +} diff --git a/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/utils/file/ImageUtils.java b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/utils/file/ImageUtils.java new file mode 100644 index 0000000..0b7b5aa --- /dev/null +++ b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/utils/file/ImageUtils.java @@ -0,0 +1,101 @@ +package com.ruoyi.common.utils.file; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.FileInputStream; +import java.io.InputStream; +import java.net.URL; +import java.net.URLConnection; +import java.util.Arrays; +import org.apache.poi.util.IOUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import com.ruoyi.common.config.RuoYiConfig; +import com.ruoyi.common.constant.Constants; +import com.ruoyi.common.utils.StringUtils; + +/** + * 图片处理工具类 + * + * @author ruoyi + */ +public class ImageUtils +{ + private static final Logger log = LoggerFactory.getLogger(ImageUtils.class); + + public static byte[] getImage(String imagePath) + { + InputStream is = getFile(imagePath); + try + { + return IOUtils.toByteArray(is); + } + catch (Exception e) + { + log.error("图片加载异常 {}", e); + return null; + } + finally + { + IOUtils.closeQuietly(is); + } + } + + public static InputStream getFile(String imagePath) + { + try + { + byte[] result = readFile(imagePath); + result = Arrays.copyOf(result, result.length); + return new ByteArrayInputStream(result); + } + catch (Exception e) + { + log.error("获取图片异常 {}", e); + } + return null; + } + + /** + * 读取文件为字节数据 + * + * @param key 地址 + * @return 字节数据 + */ + public static byte[] readFile(String url) + { + InputStream in = null; + ByteArrayOutputStream baos = null; + try + { + if (url.startsWith("http")) + { + // 网络地址 + URL urlObj = new URL(url); + URLConnection urlConnection = urlObj.openConnection(); + urlConnection.setConnectTimeout(30 * 1000); + urlConnection.setReadTimeout(60 * 1000); + urlConnection.setDoInput(true); + in = urlConnection.getInputStream(); + } + else + { + // 本机地址 + String localPath = RuoYiConfig.getProfile(); + String downloadPath = localPath + StringUtils.substringAfter(url, Constants.RESOURCE_PREFIX); + in = new FileInputStream(downloadPath); + } + return IOUtils.toByteArray(in); + } + catch (Exception e) + { + log.error("获取文件路径异常 {}", e); + return null; + } + finally + { + IOUtils.closeQuietly(in); + IOUtils.closeQuietly(baos); + } + } +} diff --git a/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/utils/file/MimeTypeUtils.java b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/utils/file/MimeTypeUtils.java new file mode 100644 index 0000000..f968f1a --- /dev/null +++ b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/utils/file/MimeTypeUtils.java @@ -0,0 +1,59 @@ +package com.ruoyi.common.utils.file; + +/** + * 媒体类型工具类 + * + * @author ruoyi + */ +public class MimeTypeUtils +{ + public static final String IMAGE_PNG = "image/png"; + + public static final String IMAGE_JPG = "image/jpg"; + + public static final String IMAGE_JPEG = "image/jpeg"; + + public static final String IMAGE_BMP = "image/bmp"; + + public static final String IMAGE_GIF = "image/gif"; + + public static final String[] IMAGE_EXTENSION = { "bmp", "gif", "jpg", "jpeg", "png" }; + + public static final String[] FLASH_EXTENSION = { "swf", "flv" }; + + public static final String[] MEDIA_EXTENSION = { "swf", "flv", "mp3", "wav", "wma", "wmv", "mid", "avi", "mpg", + "asf", "rm", "rmvb" }; + + public static final String[] VIDEO_EXTENSION = { "mp4", "avi", "rmvb" }; + + public static final String[] DEFAULT_ALLOWED_EXTENSION = { + // 图片 + "bmp", "gif", "jpg", "jpeg", "png", + // word excel powerpoint + "doc", "docx", "xls", "xlsx", "ppt", "pptx", "html", "htm", "txt", + // 压缩文件 + "rar", "zip", "gz", "bz2", + // 视频格式 + "mp4", "avi", "rmvb", + // pdf + "pdf" }; + + public static String getExtension(String prefix) + { + switch (prefix) + { + case IMAGE_PNG: + return "png"; + case IMAGE_JPG: + return "jpg"; + case IMAGE_JPEG: + return "jpeg"; + case IMAGE_BMP: + return "bmp"; + case IMAGE_GIF: + return "gif"; + default: + return ""; + } + } +} diff --git a/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/utils/goeasy/GoEasyUtils.java b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/utils/goeasy/GoEasyUtils.java new file mode 100644 index 0000000..6b1274f --- /dev/null +++ b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/utils/goeasy/GoEasyUtils.java @@ -0,0 +1,56 @@ +package com.ruoyi.common.utils.goeasy; + +import cn.hutool.http.HttpUtil; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import io.goeasy.GoEasy; +import io.goeasy.publish.GoEasyError; +import io.goeasy.publish.PublishListener; + +public class GoEasyUtils { + + static String regionHost = "https://rest-hz.goeasy.io"; + + static String appkey = "BC-d4519ea15c3f4d67a0d923dc980cbdac"; + + public static void main(String[] args) { + //sendGoeasy("689191586282475520",1,""); + + + String channel = ""; + + String str = "https://rest-hz.goeasy.io/v2/pubsub/presence/herenow?appkey="+appkey+"&channel="+channel+"&limit=10"; + + HttpUtil.get(str); + + + } + + + /** + * 发送消息 + * @param userId + * @param code + * @param data + */ + public static void sendGoeasy(String userId,Integer code,String data){ + + GoEasyVo goEasyVo = new GoEasyVo(); + goEasyVo.setCode(code); + goEasyVo.setData(data); + JSONObject jsonObject = JSONObject.parseObject(JSON.toJSONString(goEasyVo)); + + //新加坡rest-host:rest-singapore.goeasy.io + GoEasy goEasy = new GoEasy(regionHost, appkey); + goEasy.publish(userId, String.valueOf(jsonObject),new PublishListener(){ + @Override + public void onSuccess() { + System.out.println("Publish success."); + } + @Override + public void onFailed(GoEasyError error) { + System.out.println("Failed to Publish message, error:" + error.getCode() + " , " + error.getContent()); + } + }); + } +} diff --git a/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/utils/goeasy/GoEasyVo.java b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/utils/goeasy/GoEasyVo.java new file mode 100644 index 0000000..54a4328 --- /dev/null +++ b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/utils/goeasy/GoEasyVo.java @@ -0,0 +1,18 @@ +package com.ruoyi.common.utils.goeasy; + +import lombok.Data; + +@Data +public class GoEasyVo { + + /** + * 编码 + */ + private Integer code; + + /** + * 内容 + */ + private String data; + +} diff --git a/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/utils/html/EscapeUtil.java b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/utils/html/EscapeUtil.java new file mode 100644 index 0000000..7f74ac2 --- /dev/null +++ b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/utils/html/EscapeUtil.java @@ -0,0 +1,155 @@ +package com.ruoyi.common.utils.html; + +import com.ruoyi.common.utils.StringUtils; + +/** + * 转义和反转义工具类 + * + * @author ruoyi + */ +public class EscapeUtil +{ + public static final String RE_HTML_MARK = "(<[^<]*?>)|(<[\\s]*?/[^<]*?>)|(<[^<]*?/[\\s]*?>)"; + + private static final char[][] TEXT = new char[64][]; + + static + { + for (int i = 0; i < 64; i++) + { + TEXT[i] = new char[] { (char) i }; + } + + // special HTML characters + TEXT['\''] = "'".toCharArray(); // 单引号 + TEXT['"'] = """.toCharArray(); // 双引号 + TEXT['&'] = "&".toCharArray(); // &符 + TEXT['<'] = "<".toCharArray(); // 小于号 + TEXT['>'] = ">".toCharArray(); // 大于号 + } + + /** + * 转义文本中的HTML字符为安全的字符 + * + * @param text 被转义的文本 + * @return 转义后的文本 + */ + public static String escape(String text) + { + return encode(text); + } + + /** + * 还原被转义的HTML特殊字符 + * + * @param content 包含转义符的HTML内容 + * @return 转换后的字符串 + */ + public static String unescape(String content) + { + return decode(content); + } + + /** + * 清除所有HTML标签,但是不删除标签内的内容 + * + * @param content 文本 + * @return 清除标签后的文本 + */ + public static String clean(String content) + { + return new HTMLFilter().filter(content); + } + + /** + * Escape编码 + * + * @param text 被编码的文本 + * @return 编码后的字符 + */ + private static String encode(String text) + { + int len; + if ((text == null) || ((len = text.length()) == 0)) + { + return StringUtils.EMPTY; + } + StringBuilder buffer = new StringBuilder(len + (len >> 2)); + char c; + for (int i = 0; i < len; i++) + { + c = text.charAt(i); + if (c < 64) + { + buffer.append(TEXT[c]); + } + else + { + buffer.append(c); + } + } + return buffer.toString(); + } + + /** + * Escape解码 + * + * @param content 被转义的内容 + * @return 解码后的字符串 + */ + public static String decode(String content) + { + if (StringUtils.isEmpty(content)) + { + return content; + } + + StringBuilder tmp = new StringBuilder(content.length()); + int lastPos = 0, pos = 0; + char ch; + while (lastPos < content.length()) + { + pos = content.indexOf("%", lastPos); + if (pos == lastPos) + { + if (content.charAt(pos + 1) == 'u') + { + ch = (char) Integer.parseInt(content.substring(pos + 2, pos + 6), 16); + tmp.append(ch); + lastPos = pos + 6; + } + else + { + ch = (char) Integer.parseInt(content.substring(pos + 1, pos + 3), 16); + tmp.append(ch); + lastPos = pos + 3; + } + } + else + { + if (pos == -1) + { + tmp.append(content.substring(lastPos)); + lastPos = content.length(); + } + else + { + tmp.append(content.substring(lastPos, pos)); + lastPos = pos; + } + } + } + return tmp.toString(); + } + + public static void main(String[] args) + { + String html = ""; + // String html = "ipt>alert(\"XSS\")ipt>"; + // String html = "<123"; + // String html = "123>"; + System.out.println(EscapeUtil.clean(html)); + System.out.println(EscapeUtil.escape(html)); + System.out.println(EscapeUtil.unescape(html)); + } +} diff --git a/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/utils/html/HTMLFilter.java b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/utils/html/HTMLFilter.java new file mode 100644 index 0000000..75ce718 --- /dev/null +++ b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/utils/html/HTMLFilter.java @@ -0,0 +1,570 @@ +package com.ruoyi.common.utils.html; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ConcurrentMap; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * HTML过滤器,用于去除XSS漏洞隐患。 + * + * @author ruoyi + */ +public final class HTMLFilter +{ + /** + * regex flag union representing /si modifiers in php + **/ + private static final int REGEX_FLAGS_SI = Pattern.CASE_INSENSITIVE | Pattern.DOTALL; + private static final Pattern P_COMMENTS = Pattern.compile("", Pattern.DOTALL); + private static final Pattern P_COMMENT = Pattern.compile("^!--(.*)--$", REGEX_FLAGS_SI); + private static final Pattern P_TAGS = Pattern.compile("<(.*?)>", Pattern.DOTALL); + private static final Pattern P_END_TAG = Pattern.compile("^/([a-z0-9]+)", REGEX_FLAGS_SI); + private static final Pattern P_START_TAG = Pattern.compile("^([a-z0-9]+)(.*?)(/?)$", REGEX_FLAGS_SI); + private static final Pattern P_QUOTED_ATTRIBUTES = Pattern.compile("([a-z0-9]+)=([\"'])(.*?)\\2", REGEX_FLAGS_SI); + private static final Pattern P_UNQUOTED_ATTRIBUTES = Pattern.compile("([a-z0-9]+)(=)([^\"\\s']+)", REGEX_FLAGS_SI); + private static final Pattern P_PROTOCOL = Pattern.compile("^([^:]+):", REGEX_FLAGS_SI); + private static final Pattern P_ENTITY = Pattern.compile("&#(\\d+);?"); + private static final Pattern P_ENTITY_UNICODE = Pattern.compile("&#x([0-9a-f]+);?"); + private static final Pattern P_ENCODE = Pattern.compile("%([0-9a-f]{2});?"); + private static final Pattern P_VALID_ENTITIES = Pattern.compile("&([^&;]*)(?=(;|&|$))"); + private static final Pattern P_VALID_QUOTES = Pattern.compile("(>|^)([^<]+?)(<|$)", Pattern.DOTALL); + private static final Pattern P_END_ARROW = Pattern.compile("^>"); + private static final Pattern P_BODY_TO_END = Pattern.compile("<([^>]*?)(?=<|$)"); + private static final Pattern P_XML_CONTENT = Pattern.compile("(^|>)([^<]*?)(?=>)"); + private static final Pattern P_STRAY_LEFT_ARROW = Pattern.compile("<([^>]*?)(?=<|$)"); + private static final Pattern P_STRAY_RIGHT_ARROW = Pattern.compile("(^|>)([^<]*?)(?=>)"); + private static final Pattern P_AMP = Pattern.compile("&"); + private static final Pattern P_QUOTE = Pattern.compile("\""); + private static final Pattern P_LEFT_ARROW = Pattern.compile("<"); + private static final Pattern P_RIGHT_ARROW = Pattern.compile(">"); + private static final Pattern P_BOTH_ARROWS = Pattern.compile("<>"); + + // @xxx could grow large... maybe use sesat's ReferenceMap + private static final ConcurrentMap P_REMOVE_PAIR_BLANKS = new ConcurrentHashMap<>(); + private static final ConcurrentMap P_REMOVE_SELF_BLANKS = new ConcurrentHashMap<>(); + + /** + * set of allowed html elements, along with allowed attributes for each element + **/ + private final Map> vAllowed; + /** + * counts of open tags for each (allowable) html element + **/ + private final Map vTagCounts = new HashMap<>(); + + /** + * html elements which must always be self-closing (e.g. "") + **/ + private final String[] vSelfClosingTags; + /** + * html elements which must always have separate opening and closing tags (e.g. "") + **/ + private final String[] vNeedClosingTags; + /** + * set of disallowed html elements + **/ + private final String[] vDisallowed; + /** + * attributes which should be checked for valid protocols + **/ + private final String[] vProtocolAtts; + /** + * allowed protocols + **/ + private final String[] vAllowedProtocols; + /** + * tags which should be removed if they contain no content (e.g. "" or "") + **/ + private final String[] vRemoveBlanks; + /** + * entities allowed within html markup + **/ + private final String[] vAllowedEntities; + /** + * flag determining whether comments are allowed in input String. + */ + private final boolean stripComment; + private final boolean encodeQuotes; + /** + * flag determining whether to try to make tags when presented with "unbalanced" angle brackets (e.g. "" + * becomes " text "). If set to false, unbalanced angle brackets will be html escaped. + */ + private final boolean alwaysMakeTags; + + /** + * Default constructor. + */ + public HTMLFilter() + { + vAllowed = new HashMap<>(); + + final ArrayList a_atts = new ArrayList<>(); + a_atts.add("href"); + a_atts.add("target"); + vAllowed.put("a", a_atts); + + final ArrayList img_atts = new ArrayList<>(); + img_atts.add("src"); + img_atts.add("width"); + img_atts.add("height"); + img_atts.add("alt"); + vAllowed.put("img", img_atts); + + final ArrayList no_atts = new ArrayList<>(); + vAllowed.put("b", no_atts); + vAllowed.put("strong", no_atts); + vAllowed.put("i", no_atts); + vAllowed.put("em", no_atts); + + vSelfClosingTags = new String[] { "img" }; + vNeedClosingTags = new String[] { "a", "b", "strong", "i", "em" }; + vDisallowed = new String[] {}; + vAllowedProtocols = new String[] { "http", "mailto", "https" }; // no ftp. + vProtocolAtts = new String[] { "src", "href" }; + vRemoveBlanks = new String[] { "a", "b", "strong", "i", "em" }; + vAllowedEntities = new String[] { "amp", "gt", "lt", "quot" }; + stripComment = true; + encodeQuotes = true; + alwaysMakeTags = false; + } + + /** + * Map-parameter configurable constructor. + * + * @param conf map containing configuration. keys match field names. + */ + @SuppressWarnings("unchecked") + public HTMLFilter(final Map conf) + { + + assert conf.containsKey("vAllowed") : "configuration requires vAllowed"; + assert conf.containsKey("vSelfClosingTags") : "configuration requires vSelfClosingTags"; + assert conf.containsKey("vNeedClosingTags") : "configuration requires vNeedClosingTags"; + assert conf.containsKey("vDisallowed") : "configuration requires vDisallowed"; + assert conf.containsKey("vAllowedProtocols") : "configuration requires vAllowedProtocols"; + assert conf.containsKey("vProtocolAtts") : "configuration requires vProtocolAtts"; + assert conf.containsKey("vRemoveBlanks") : "configuration requires vRemoveBlanks"; + assert conf.containsKey("vAllowedEntities") : "configuration requires vAllowedEntities"; + + vAllowed = Collections.unmodifiableMap((HashMap>) conf.get("vAllowed")); + vSelfClosingTags = (String[]) conf.get("vSelfClosingTags"); + vNeedClosingTags = (String[]) conf.get("vNeedClosingTags"); + vDisallowed = (String[]) conf.get("vDisallowed"); + vAllowedProtocols = (String[]) conf.get("vAllowedProtocols"); + vProtocolAtts = (String[]) conf.get("vProtocolAtts"); + vRemoveBlanks = (String[]) conf.get("vRemoveBlanks"); + vAllowedEntities = (String[]) conf.get("vAllowedEntities"); + stripComment = conf.containsKey("stripComment") ? (Boolean) conf.get("stripComment") : true; + encodeQuotes = conf.containsKey("encodeQuotes") ? (Boolean) conf.get("encodeQuotes") : true; + alwaysMakeTags = conf.containsKey("alwaysMakeTags") ? (Boolean) conf.get("alwaysMakeTags") : true; + } + + private void reset() + { + vTagCounts.clear(); + } + + // --------------------------------------------------------------- + // my versions of some PHP library functions + public static String chr(final int decimal) + { + return String.valueOf((char) decimal); + } + + public static String htmlSpecialChars(final String s) + { + String result = s; + result = regexReplace(P_AMP, "&", result); + result = regexReplace(P_QUOTE, """, result); + result = regexReplace(P_LEFT_ARROW, "<", result); + result = regexReplace(P_RIGHT_ARROW, ">", result); + return result; + } + + // --------------------------------------------------------------- + + /** + * given a user submitted input String, filter out any invalid or restricted html. + * + * @param input text (i.e. submitted by a user) than may contain html + * @return "clean" version of input, with only valid, whitelisted html elements allowed + */ + public String filter(final String input) + { + reset(); + String s = input; + + s = escapeComments(s); + + s = balanceHTML(s); + + s = checkTags(s); + + s = processRemoveBlanks(s); + + // s = validateEntities(s); + + return s; + } + + public boolean isAlwaysMakeTags() + { + return alwaysMakeTags; + } + + public boolean isStripComments() + { + return stripComment; + } + + private String escapeComments(final String s) + { + final Matcher m = P_COMMENTS.matcher(s); + final StringBuffer buf = new StringBuffer(); + if (m.find()) + { + final String match = m.group(1); // (.*?) + m.appendReplacement(buf, Matcher.quoteReplacement("")); + } + m.appendTail(buf); + + return buf.toString(); + } + + private String balanceHTML(String s) + { + if (alwaysMakeTags) + { + // + // try and form html + // + s = regexReplace(P_END_ARROW, "", s); + // 不追加结束标签 + s = regexReplace(P_BODY_TO_END, "<$1>", s); + s = regexReplace(P_XML_CONTENT, "$1<$2", s); + + } + else + { + // + // escape stray brackets + // + s = regexReplace(P_STRAY_LEFT_ARROW, "<$1", s); + s = regexReplace(P_STRAY_RIGHT_ARROW, "$1$2><", s); + + // + // the last regexp causes '<>' entities to appear + // (we need to do a lookahead assertion so that the last bracket can + // be used in the next pass of the regexp) + // + s = regexReplace(P_BOTH_ARROWS, "", s); + } + + return s; + } + + private String checkTags(String s) + { + Matcher m = P_TAGS.matcher(s); + + final StringBuffer buf = new StringBuffer(); + while (m.find()) + { + String replaceStr = m.group(1); + replaceStr = processTag(replaceStr); + m.appendReplacement(buf, Matcher.quoteReplacement(replaceStr)); + } + m.appendTail(buf); + + // these get tallied in processTag + // (remember to reset before subsequent calls to filter method) + final StringBuilder sBuilder = new StringBuilder(buf.toString()); + for (String key : vTagCounts.keySet()) + { + for (int ii = 0; ii < vTagCounts.get(key); ii++) + { + sBuilder.append(""); + } + } + s = sBuilder.toString(); + + return s; + } + + private String processRemoveBlanks(final String s) + { + String result = s; + for (String tag : vRemoveBlanks) + { + if (!P_REMOVE_PAIR_BLANKS.containsKey(tag)) + { + P_REMOVE_PAIR_BLANKS.putIfAbsent(tag, Pattern.compile("<" + tag + "(\\s[^>]*)?>")); + } + result = regexReplace(P_REMOVE_PAIR_BLANKS.get(tag), "", result); + if (!P_REMOVE_SELF_BLANKS.containsKey(tag)) + { + P_REMOVE_SELF_BLANKS.putIfAbsent(tag, Pattern.compile("<" + tag + "(\\s[^>]*)?/>")); + } + result = regexReplace(P_REMOVE_SELF_BLANKS.get(tag), "", result); + } + + return result; + } + + private static String regexReplace(final Pattern regex_pattern, final String replacement, final String s) + { + Matcher m = regex_pattern.matcher(s); + return m.replaceAll(replacement); + } + + private String processTag(final String s) + { + // ending tags + Matcher m = P_END_TAG.matcher(s); + if (m.find()) + { + final String name = m.group(1).toLowerCase(); + if (allowed(name)) + { + if (false == inArray(name, vSelfClosingTags)) + { + if (vTagCounts.containsKey(name)) + { + vTagCounts.put(name, vTagCounts.get(name) - 1); + return ""; + } + } + } + } + + // starting tags + m = P_START_TAG.matcher(s); + if (m.find()) + { + final String name = m.group(1).toLowerCase(); + final String body = m.group(2); + String ending = m.group(3); + + // debug( "in a starting tag, name='" + name + "'; body='" + body + "'; ending='" + ending + "'" ); + if (allowed(name)) + { + final StringBuilder params = new StringBuilder(); + + final Matcher m2 = P_QUOTED_ATTRIBUTES.matcher(body); + final Matcher m3 = P_UNQUOTED_ATTRIBUTES.matcher(body); + final List paramNames = new ArrayList<>(); + final List paramValues = new ArrayList<>(); + while (m2.find()) + { + paramNames.add(m2.group(1)); // ([a-z0-9]+) + paramValues.add(m2.group(3)); // (.*?) + } + while (m3.find()) + { + paramNames.add(m3.group(1)); // ([a-z0-9]+) + paramValues.add(m3.group(3)); // ([^\"\\s']+) + } + + String paramName, paramValue; + for (int ii = 0; ii < paramNames.size(); ii++) + { + paramName = paramNames.get(ii).toLowerCase(); + paramValue = paramValues.get(ii); + + // debug( "paramName='" + paramName + "'" ); + // debug( "paramValue='" + paramValue + "'" ); + // debug( "allowed? " + vAllowed.get( name ).contains( paramName ) ); + + if (allowedAttribute(name, paramName)) + { + if (inArray(paramName, vProtocolAtts)) + { + paramValue = processParamProtocol(paramValue); + } + params.append(' ').append(paramName).append("=\\\"").append(paramValue).append("\""); + } + } + + if (inArray(name, vSelfClosingTags)) + { + ending = " /"; + } + + if (inArray(name, vNeedClosingTags)) + { + ending = ""; + } + + if (ending == null || ending.length() < 1) + { + if (vTagCounts.containsKey(name)) + { + vTagCounts.put(name, vTagCounts.get(name) + 1); + } + else + { + vTagCounts.put(name, 1); + } + } + else + { + ending = " /"; + } + return "<" + name + params + ending + ">"; + } + else + { + return ""; + } + } + + // comments + m = P_COMMENT.matcher(s); + if (!stripComment && m.find()) + { + return "<" + m.group() + ">"; + } + + return ""; + } + + private String processParamProtocol(String s) + { + s = decodeEntities(s); + final Matcher m = P_PROTOCOL.matcher(s); + if (m.find()) + { + final String protocol = m.group(1); + if (!inArray(protocol, vAllowedProtocols)) + { + // bad protocol, turn into local anchor link instead + s = "#" + s.substring(protocol.length() + 1); + if (s.startsWith("#//")) + { + s = "#" + s.substring(3); + } + } + } + + return s; + } + + private String decodeEntities(String s) + { + StringBuffer buf = new StringBuffer(); + + Matcher m = P_ENTITY.matcher(s); + while (m.find()) + { + final String match = m.group(1); + final int decimal = Integer.decode(match).intValue(); + m.appendReplacement(buf, Matcher.quoteReplacement(chr(decimal))); + } + m.appendTail(buf); + s = buf.toString(); + + buf = new StringBuffer(); + m = P_ENTITY_UNICODE.matcher(s); + while (m.find()) + { + final String match = m.group(1); + final int decimal = Integer.valueOf(match, 16).intValue(); + m.appendReplacement(buf, Matcher.quoteReplacement(chr(decimal))); + } + m.appendTail(buf); + s = buf.toString(); + + buf = new StringBuffer(); + m = P_ENCODE.matcher(s); + while (m.find()) + { + final String match = m.group(1); + final int decimal = Integer.valueOf(match, 16).intValue(); + m.appendReplacement(buf, Matcher.quoteReplacement(chr(decimal))); + } + m.appendTail(buf); + s = buf.toString(); + + s = validateEntities(s); + return s; + } + + private String validateEntities(final String s) + { + StringBuffer buf = new StringBuffer(); + + // validate entities throughout the string + Matcher m = P_VALID_ENTITIES.matcher(s); + while (m.find()) + { + final String one = m.group(1); // ([^&;]*) + final String two = m.group(2); // (?=(;|&|$)) + m.appendReplacement(buf, Matcher.quoteReplacement(checkEntity(one, two))); + } + m.appendTail(buf); + + return encodeQuotes(buf.toString()); + } + + private String encodeQuotes(final String s) + { + if (encodeQuotes) + { + StringBuffer buf = new StringBuffer(); + Matcher m = P_VALID_QUOTES.matcher(s); + while (m.find()) + { + final String one = m.group(1); // (>|^) + final String two = m.group(2); // ([^<]+?) + final String three = m.group(3); // (<|$) + // 不替换双引号为",防止json格式无效 regexReplace(P_QUOTE, """, two) + m.appendReplacement(buf, Matcher.quoteReplacement(one + two + three)); + } + m.appendTail(buf); + return buf.toString(); + } + else + { + return s; + } + } + + private String checkEntity(final String preamble, final String term) + { + + return ";".equals(term) && isValidEntity(preamble) ? '&' + preamble : "&" + preamble; + } + + private boolean isValidEntity(final String entity) + { + return inArray(entity, vAllowedEntities); + } + + private static boolean inArray(final String s, final String[] array) + { + for (String item : array) + { + if (item != null && item.equals(s)) + { + return true; + } + } + return false; + } + + private boolean allowed(final String name) + { + return (vAllowed.isEmpty() || vAllowed.containsKey(name)) && !inArray(name, vDisallowed); + } + + private boolean allowedAttribute(final String name, final String paramName) + { + return allowed(name) && (vAllowed.isEmpty() || vAllowed.get(name).contains(paramName)); + } +} \ No newline at end of file diff --git a/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/utils/http/HttpHelper.java b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/utils/http/HttpHelper.java new file mode 100644 index 0000000..dac60ad --- /dev/null +++ b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/utils/http/HttpHelper.java @@ -0,0 +1,55 @@ +package com.ruoyi.common.utils.http; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.nio.charset.Charset; +import javax.servlet.ServletRequest; +import org.apache.commons.lang3.exception.ExceptionUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * 通用http工具封装 + * + * @author ruoyi + */ +public class HttpHelper +{ + private static final Logger LOGGER = LoggerFactory.getLogger(HttpHelper.class); + + public static String getBodyString(ServletRequest request) + { + StringBuilder sb = new StringBuilder(); + BufferedReader reader = null; + try (InputStream inputStream = request.getInputStream()) + { + reader = new BufferedReader(new InputStreamReader(inputStream, Charset.forName("UTF-8"))); + String line = ""; + while ((line = reader.readLine()) != null) + { + sb.append(line); + } + } + catch (IOException e) + { + LOGGER.warn("getBodyString出现问题!"); + } + finally + { + if (reader != null) + { + try + { + reader.close(); + } + catch (IOException e) + { + LOGGER.error(ExceptionUtils.getMessage(e)); + } + } + } + return sb.toString(); + } +} diff --git a/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/utils/http/HttpUtils.java b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/utils/http/HttpUtils.java new file mode 100644 index 0000000..9aee92e --- /dev/null +++ b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/utils/http/HttpUtils.java @@ -0,0 +1,262 @@ +package com.ruoyi.common.utils.http; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.PrintWriter; +import java.net.ConnectException; +import java.net.SocketTimeoutException; +import java.net.URL; +import java.net.URLConnection; +import java.security.cert.X509Certificate; +import javax.net.ssl.HostnameVerifier; +import javax.net.ssl.HttpsURLConnection; +import javax.net.ssl.SSLContext; +import javax.net.ssl.SSLSession; +import javax.net.ssl.TrustManager; +import javax.net.ssl.X509TrustManager; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import com.ruoyi.common.constant.Constants; + +/** + * 通用http发送方法 + * + * @author ruoyi + */ +public class HttpUtils +{ + private static final Logger log = LoggerFactory.getLogger(HttpUtils.class); + + /** + * 向指定 URL 发送GET方法的请求 + * + * @param url 发送请求的 URL + * @param param 请求参数,请求参数应该是 name1=value1&name2=value2 的形式。 + * @return 所代表远程资源的响应结果 + */ + public static String sendGet(String url, String param) + { + return sendGet(url, param, Constants.UTF8); + } + + /** + * 向指定 URL 发送GET方法的请求 + * + * @param url 发送请求的 URL + * @param param 请求参数,请求参数应该是 name1=value1&name2=value2 的形式。 + * @param contentType 编码类型 + * @return 所代表远程资源的响应结果 + */ + public static String sendGet(String url, String param, String contentType) + { + StringBuilder result = new StringBuilder(); + BufferedReader in = null; + try + { + String urlNameString = url + "?" + param; + log.info("sendGet - {}", urlNameString); + URL realUrl = new URL(urlNameString); + URLConnection connection = realUrl.openConnection(); + connection.setRequestProperty("accept", "*/*"); + connection.setRequestProperty("connection", "Keep-Alive"); + connection.setRequestProperty("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)"); + connection.connect(); + in = new BufferedReader(new InputStreamReader(connection.getInputStream(), contentType)); + String line; + while ((line = in.readLine()) != null) + { + result.append(line); + } + log.info("recv - {}", result); + } + catch (ConnectException e) + { + log.error("调用HttpUtils.sendGet ConnectException, url=" + url + ",param=" + param, e); + } + catch (SocketTimeoutException e) + { + log.error("调用HttpUtils.sendGet SocketTimeoutException, url=" + url + ",param=" + param, e); + } + catch (IOException e) + { + log.error("调用HttpUtils.sendGet IOException, url=" + url + ",param=" + param, e); + } + catch (Exception e) + { + log.error("调用HttpsUtil.sendGet Exception, url=" + url + ",param=" + param, e); + } + finally + { + try + { + if (in != null) + { + in.close(); + } + } + catch (Exception ex) + { + log.error("调用in.close Exception, url=" + url + ",param=" + param, ex); + } + } + return result.toString(); + } + + /** + * 向指定 URL 发送POST方法的请求 + * + * @param url 发送请求的 URL + * @param param 请求参数,请求参数应该是 name1=value1&name2=value2 的形式。 + * @return 所代表远程资源的响应结果 + */ + public static String sendPost(String url, String param) + { + PrintWriter out = null; + BufferedReader in = null; + StringBuilder result = new StringBuilder(); + try + { + String urlNameString = url; + log.info("sendPost - {}", urlNameString); + URL realUrl = new URL(urlNameString); + URLConnection conn = realUrl.openConnection(); + conn.setRequestProperty("accept", "*/*"); + conn.setRequestProperty("connection", "Keep-Alive"); + conn.setRequestProperty("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)"); + conn.setRequestProperty("Accept-Charset", "utf-8"); + conn.setRequestProperty("contentType", "utf-8"); + conn.setDoOutput(true); + conn.setDoInput(true); + out = new PrintWriter(conn.getOutputStream()); + out.print(param); + out.flush(); + in = new BufferedReader(new InputStreamReader(conn.getInputStream(), "utf-8")); + String line; + while ((line = in.readLine()) != null) + { + result.append(line); + } + log.info("recv - {}", result); + } + catch (ConnectException e) + { + log.error("调用HttpUtils.sendPost ConnectException, url=" + url + ",param=" + param, e); + } + catch (SocketTimeoutException e) + { + log.error("调用HttpUtils.sendPost SocketTimeoutException, url=" + url + ",param=" + param, e); + } + catch (IOException e) + { + log.error("调用HttpUtils.sendPost IOException, url=" + url + ",param=" + param, e); + } + catch (Exception e) + { + log.error("调用HttpsUtil.sendPost Exception, url=" + url + ",param=" + param, e); + } + finally + { + try + { + if (out != null) + { + out.close(); + } + if (in != null) + { + in.close(); + } + } + catch (IOException ex) + { + log.error("调用in.close Exception, url=" + url + ",param=" + param, ex); + } + } + return result.toString(); + } + + public static String sendSSLPost(String url, String param) + { + StringBuilder result = new StringBuilder(); + String urlNameString = url + "?" + param; + try + { + log.info("sendSSLPost - {}", urlNameString); + SSLContext sc = SSLContext.getInstance("SSL"); + sc.init(null, new TrustManager[] { new TrustAnyTrustManager() }, new java.security.SecureRandom()); + URL console = new URL(urlNameString); + HttpsURLConnection conn = (HttpsURLConnection) console.openConnection(); + conn.setRequestProperty("accept", "*/*"); + conn.setRequestProperty("connection", "Keep-Alive"); + conn.setRequestProperty("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)"); + conn.setRequestProperty("Accept-Charset", "utf-8"); + conn.setRequestProperty("contentType", "utf-8"); + conn.setDoOutput(true); + conn.setDoInput(true); + + conn.setSSLSocketFactory(sc.getSocketFactory()); + conn.setHostnameVerifier(new TrustAnyHostnameVerifier()); + conn.connect(); + InputStream is = conn.getInputStream(); + BufferedReader br = new BufferedReader(new InputStreamReader(is)); + String ret = ""; + while ((ret = br.readLine()) != null) + { + if (ret != null && !"".equals(ret.trim())) + { + result.append(new String(ret.getBytes("ISO-8859-1"), "utf-8")); + } + } + log.info("recv - {}", result); + conn.disconnect(); + br.close(); + } + catch (ConnectException e) + { + log.error("调用HttpUtils.sendSSLPost ConnectException, url=" + url + ",param=" + param, e); + } + catch (SocketTimeoutException e) + { + log.error("调用HttpUtils.sendSSLPost SocketTimeoutException, url=" + url + ",param=" + param, e); + } + catch (IOException e) + { + log.error("调用HttpUtils.sendSSLPost IOException, url=" + url + ",param=" + param, e); + } + catch (Exception e) + { + log.error("调用HttpsUtil.sendSSLPost Exception, url=" + url + ",param=" + param, e); + } + return result.toString(); + } + + private static class TrustAnyTrustManager implements X509TrustManager + { + @Override + public void checkClientTrusted(X509Certificate[] chain, String authType) + { + } + + @Override + public void checkServerTrusted(X509Certificate[] chain, String authType) + { + } + + @Override + public X509Certificate[] getAcceptedIssuers() + { + return new X509Certificate[] {}; + } + } + + private static class TrustAnyHostnameVerifier implements HostnameVerifier + { + @Override + public boolean verify(String hostname, SSLSession session) + { + return true; + } + } +} \ No newline at end of file diff --git a/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/utils/ip/AddressUtils.java b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/utils/ip/AddressUtils.java new file mode 100644 index 0000000..01c24fc --- /dev/null +++ b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/utils/ip/AddressUtils.java @@ -0,0 +1,56 @@ +package com.ruoyi.common.utils.ip; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import com.alibaba.fastjson.JSONObject; +import com.ruoyi.common.config.RuoYiConfig; +import com.ruoyi.common.constant.Constants; +import com.ruoyi.common.utils.StringUtils; +import com.ruoyi.common.utils.http.HttpUtils; + +/** + * 获取地址类 + * + * @author ruoyi + */ +public class AddressUtils +{ + private static final Logger log = LoggerFactory.getLogger(AddressUtils.class); + + // IP地址查询 + public static final String IP_URL = "http://whois.pconline.com.cn/ipJson.jsp"; + + // 未知地址 + public static final String UNKNOWN = "XX XX"; + + public static String getRealAddressByIP(String ip) + { + String address = UNKNOWN; + // 内网不查询 + if (IpUtils.internalIp(ip)) + { + return "内网IP"; + } + if (RuoYiConfig.isAddressEnabled()) + { + try + { + String rspStr = HttpUtils.sendGet(IP_URL, "ip=" + ip + "&json=true", Constants.GBK); + if (StringUtils.isEmpty(rspStr)) + { + log.error("获取地理位置异常 {}", ip); + return UNKNOWN; + } + JSONObject obj = JSONObject.parseObject(rspStr); + String region = obj.getString("pro"); + String city = obj.getString("city"); + return String.format("%s %s", region, city); + } + catch (Exception e) + { + log.error("获取地理位置异常 {}", ip); + } + } + return address; + } +} diff --git a/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/utils/ip/IpUtils.java b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/utils/ip/IpUtils.java new file mode 100644 index 0000000..1b3f42b --- /dev/null +++ b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/utils/ip/IpUtils.java @@ -0,0 +1,195 @@ +package com.ruoyi.common.utils.ip; + +import java.net.InetAddress; +import java.net.UnknownHostException; +import javax.servlet.http.HttpServletRequest; +import com.ruoyi.common.utils.StringUtils; +import com.ruoyi.common.utils.html.EscapeUtil; + +/** + * 获取IP方法 + * + * @author ruoyi + */ +public class IpUtils +{ + public static String getIpAddr(HttpServletRequest request) + { + if (request == null) + { + return "unknown"; + } + String ip = request.getHeader("x-forwarded-for"); + if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) + { + ip = request.getHeader("Proxy-Client-IP"); + } + if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) + { + ip = request.getHeader("X-Forwarded-For"); + } + if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) + { + ip = request.getHeader("WL-Proxy-Client-IP"); + } + if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) + { + ip = request.getHeader("X-Real-IP"); + } + + if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) + { + ip = request.getRemoteAddr(); + } + return "0:0:0:0:0:0:0:1".equals(ip) ? "127.0.0.1" : EscapeUtil.clean(ip); + } + + public static boolean internalIp(String ip) + { + byte[] addr = textToNumericFormatV4(ip); + return internalIp(addr) || "127.0.0.1".equals(ip); + } + + private static boolean internalIp(byte[] addr) + { + if (StringUtils.isNull(addr) || addr.length < 2) + { + return true; + } + final byte b0 = addr[0]; + final byte b1 = addr[1]; + // 10.x.x.x/8 + final byte SECTION_1 = 0x0A; + // 172.16.x.x/12 + final byte SECTION_2 = (byte) 0xAC; + final byte SECTION_3 = (byte) 0x10; + final byte SECTION_4 = (byte) 0x1F; + // 192.168.x.x/16 + final byte SECTION_5 = (byte) 0xC0; + final byte SECTION_6 = (byte) 0xA8; + switch (b0) + { + case SECTION_1: + return true; + case SECTION_2: + if (b1 >= SECTION_3 && b1 <= SECTION_4) + { + return true; + } + case SECTION_5: + switch (b1) + { + case SECTION_6: + return true; + } + default: + return false; + } + } + + /** + * 将IPv4地址转换成字节 + * + * @param text IPv4地址 + * @return byte 字节 + */ + public static byte[] textToNumericFormatV4(String text) + { + if (text.length() == 0) + { + return null; + } + + byte[] bytes = new byte[4]; + String[] elements = text.split("\\.", -1); + try + { + long l; + int i; + switch (elements.length) + { + case 1: + l = Long.parseLong(elements[0]); + if ((l < 0L) || (l > 4294967295L)) { + return null; + } + bytes[0] = (byte) (int) (l >> 24 & 0xFF); + bytes[1] = (byte) (int) ((l & 0xFFFFFF) >> 16 & 0xFF); + bytes[2] = (byte) (int) ((l & 0xFFFF) >> 8 & 0xFF); + bytes[3] = (byte) (int) (l & 0xFF); + break; + case 2: + l = Integer.parseInt(elements[0]); + if ((l < 0L) || (l > 255L)) { + return null; + } + bytes[0] = (byte) (int) (l & 0xFF); + l = Integer.parseInt(elements[1]); + if ((l < 0L) || (l > 16777215L)) { + return null; + } + bytes[1] = (byte) (int) (l >> 16 & 0xFF); + bytes[2] = (byte) (int) ((l & 0xFFFF) >> 8 & 0xFF); + bytes[3] = (byte) (int) (l & 0xFF); + break; + case 3: + for (i = 0; i < 2; ++i) + { + l = Integer.parseInt(elements[i]); + if ((l < 0L) || (l > 255L)) { + return null; + } + bytes[i] = (byte) (int) (l & 0xFF); + } + l = Integer.parseInt(elements[2]); + if ((l < 0L) || (l > 65535L)) { + return null; + } + bytes[2] = (byte) (int) (l >> 8 & 0xFF); + bytes[3] = (byte) (int) (l & 0xFF); + break; + case 4: + for (i = 0; i < 4; ++i) + { + l = Integer.parseInt(elements[i]); + if ((l < 0L) || (l > 255L)) { + return null; + } + bytes[i] = (byte) (int) (l & 0xFF); + } + break; + default: + return null; + } + } + catch (NumberFormatException e) + { + return null; + } + return bytes; + } + + public static String getHostIp() + { + try + { + return InetAddress.getLocalHost().getHostAddress(); + } + catch (UnknownHostException e) + { + } + return "127.0.0.1"; + } + + public static String getHostName() + { + try + { + return InetAddress.getLocalHost().getHostName(); + } + catch (UnknownHostException e) + { + } + return "未知"; + } +} \ No newline at end of file diff --git a/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/utils/poi/ExcelHandlerAdapter.java b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/utils/poi/ExcelHandlerAdapter.java new file mode 100644 index 0000000..5ea74c1 --- /dev/null +++ b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/utils/poi/ExcelHandlerAdapter.java @@ -0,0 +1,19 @@ +package com.ruoyi.common.utils.poi; + +/** + * Excel数据格式处理适配器 + * + * @author ruoyi + */ +public interface ExcelHandlerAdapter +{ + /** + * 格式化 + * + * @param value 单元格数据值 + * @param args excel注解args参数组 + * + * @return 处理后的值 + */ + Object format(Object value, String[] args); +} diff --git a/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/utils/poi/ExcelUtil.java b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/utils/poi/ExcelUtil.java new file mode 100644 index 0000000..9ded3a5 --- /dev/null +++ b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/utils/poi/ExcelUtil.java @@ -0,0 +1,1394 @@ +package com.ruoyi.common.utils.poi; + +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.lang.reflect.Field; +import java.lang.reflect.Method; +import java.math.BigDecimal; +import java.text.DecimalFormat; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Comparator; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.UUID; +import java.util.stream.Collectors; +import javax.servlet.http.HttpServletResponse; +import org.apache.poi.hssf.usermodel.HSSFClientAnchor; +import org.apache.poi.hssf.usermodel.HSSFPicture; +import org.apache.poi.hssf.usermodel.HSSFPictureData; +import org.apache.poi.hssf.usermodel.HSSFShape; +import org.apache.poi.hssf.usermodel.HSSFSheet; +import org.apache.poi.hssf.usermodel.HSSFWorkbook; +import org.apache.poi.ooxml.POIXMLDocumentPart; +import org.apache.poi.ss.usermodel.BorderStyle; +import org.apache.poi.ss.usermodel.Cell; +import org.apache.poi.ss.usermodel.CellStyle; +import org.apache.poi.ss.usermodel.CellType; +import org.apache.poi.ss.usermodel.ClientAnchor; +import org.apache.poi.ss.usermodel.DataValidation; +import org.apache.poi.ss.usermodel.DataValidationConstraint; +import org.apache.poi.ss.usermodel.DataValidationHelper; +import org.apache.poi.ss.usermodel.DateUtil; +import org.apache.poi.ss.usermodel.Drawing; +import org.apache.poi.ss.usermodel.FillPatternType; +import org.apache.poi.ss.usermodel.Font; +import org.apache.poi.ss.usermodel.HorizontalAlignment; +import org.apache.poi.ss.usermodel.IndexedColors; +import org.apache.poi.ss.usermodel.PictureData; +import org.apache.poi.ss.usermodel.Row; +import org.apache.poi.ss.usermodel.Sheet; +import org.apache.poi.ss.usermodel.VerticalAlignment; +import org.apache.poi.ss.usermodel.Workbook; +import org.apache.poi.ss.usermodel.WorkbookFactory; +import org.apache.poi.ss.util.CellRangeAddress; +import org.apache.poi.ss.util.CellRangeAddressList; +import org.apache.poi.util.IOUtils; +import org.apache.poi.xssf.streaming.SXSSFWorkbook; +import org.apache.poi.xssf.usermodel.XSSFClientAnchor; +import org.apache.poi.xssf.usermodel.XSSFDataValidation; +import org.apache.poi.xssf.usermodel.XSSFDrawing; +import org.apache.poi.xssf.usermodel.XSSFPicture; +import org.apache.poi.xssf.usermodel.XSSFShape; +import org.apache.poi.xssf.usermodel.XSSFSheet; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; +import org.openxmlformats.schemas.drawingml.x2006.spreadsheetDrawing.CTMarker; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.annotation.Excel.ColumnType; +import com.ruoyi.common.annotation.Excel.Type; +import com.ruoyi.common.annotation.Excels; +import com.ruoyi.common.config.RuoYiConfig; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.text.Convert; +import com.ruoyi.common.exception.UtilException; +import com.ruoyi.common.utils.DateUtils; +import com.ruoyi.common.utils.DictUtils; +import com.ruoyi.common.utils.StringUtils; +import com.ruoyi.common.utils.file.FileTypeUtils; +import com.ruoyi.common.utils.file.FileUtils; +import com.ruoyi.common.utils.file.ImageUtils; +import com.ruoyi.common.utils.reflect.ReflectUtils; + +/** + * Excel相关处理 + * + * @author ruoyi + */ +public class ExcelUtil +{ + private static final Logger log = LoggerFactory.getLogger(ExcelUtil.class); + + /** + * Excel sheet最大行数,默认65536 + */ + public static final int sheetSize = 65536; + + /** + * 工作表名称 + */ + private String sheetName; + + /** + * 导出类型(EXPORT:导出数据;IMPORT:导入模板) + */ + private Type type; + + /** + * 工作薄对象 + */ + private Workbook wb; + + /** + * 工作表对象 + */ + private Sheet sheet; + + /** + * 样式列表 + */ + private Map styles; + + /** + * 导入导出数据列表 + */ + private List list; + + /** + * 注解列表 + */ + private List fields; + + /** + * 当前行号 + */ + private int rownum; + + /** + * 标题 + */ + private String title; + + /** + * 最大高度 + */ + private short maxHeight; + + /** + * 统计列表 + */ + private Map statistics = new HashMap(); + + /** + * 数字格式 + */ + private static final DecimalFormat DOUBLE_FORMAT = new DecimalFormat("######0.00"); + + /** + * 实体对象 + */ + public Class clazz; + + public ExcelUtil(Class clazz) + { + this.clazz = clazz; + } + + public void init(List list, String sheetName, String title, Type type) + { + if (list == null) + { + list = new ArrayList(); + } + this.list = list; + this.sheetName = sheetName; + this.type = type; + this.title = title; + createExcelField(); + createWorkbook(); + createTitle(); + } + + /** + * 创建excel第一行标题 + */ + public void createTitle() + { + if (StringUtils.isNotEmpty(title)) + { + Row titleRow = sheet.createRow(rownum == 0 ? rownum++ : 0); + titleRow.setHeightInPoints(30); + Cell titleCell = titleRow.createCell(0); + titleCell.setCellStyle(styles.get("title")); + titleCell.setCellValue(title); + sheet.addMergedRegion(new CellRangeAddress(titleRow.getRowNum(), titleRow.getRowNum(), titleRow.getRowNum(), + this.fields.size() - 1)); + } + } + + /** + * 对excel表单默认第一个索引名转换成list + * + * @param is 输入流 + * @return 转换后集合 + */ + public List importExcel(InputStream is) throws Exception + { + return importExcel(is, 0); + } + + /** + * 对excel表单默认第一个索引名转换成list + * + * @param is 输入流 + * @param titleNum 标题占用行数 + * @return 转换后集合 + */ + public List importExcel(InputStream is, int titleNum) throws Exception + { + return importExcel(StringUtils.EMPTY, is, titleNum); + } + + /** + * 对excel表单指定表格索引名转换成list + * + * @param sheetName 表格索引名 + * @param titleNum 标题占用行数 + * @param is 输入流 + * @return 转换后集合 + */ + public List importExcel(String sheetName, InputStream is, int titleNum) throws Exception + { + this.type = Type.IMPORT; + this.wb = WorkbookFactory.create(is); + List list = new ArrayList(); + // 如果指定sheet名,则取指定sheet中的内容 否则默认指向第1个sheet + Sheet sheet = StringUtils.isNotEmpty(sheetName) ? wb.getSheet(sheetName) : wb.getSheetAt(0); + if (sheet == null) + { + throw new IOException("文件sheet不存在"); + } + boolean isXSSFWorkbook = !(wb instanceof HSSFWorkbook); + Map pictures; + if (isXSSFWorkbook) + { + pictures = getSheetPictures07((XSSFSheet) sheet, (XSSFWorkbook) wb); + } + else + { + pictures = getSheetPictures03((HSSFSheet) sheet, (HSSFWorkbook) wb); + } + // 获取最后一个非空行的行下标,比如总行数为n,则返回的为n-1 + int rows = sheet.getLastRowNum(); + + if (rows > 0) + { + // 定义一个map用于存放excel列的序号和field. + Map cellMap = new HashMap(); + // 获取表头 + Row heard = sheet.getRow(titleNum); + for (int i = 0; i < heard.getPhysicalNumberOfCells(); i++) + { + Cell cell = heard.getCell(i); + if (StringUtils.isNotNull(cell)) + { + String value = this.getCellValue(heard, i).toString(); + cellMap.put(value, i); + } + else + { + cellMap.put(null, i); + } + } + // 有数据时才处理 得到类的所有field. + Field[] allFields = clazz.getDeclaredFields(); + // 定义一个map用于存放列的序号和field. + Map fieldsMap = new HashMap(); + for (int col = 0; col < allFields.length; col++) + { + Field field = allFields[col]; + Excel attr = field.getAnnotation(Excel.class); + if (attr != null && (attr.type() == Type.ALL || attr.type() == type)) + { + // 设置类的私有字段属性可访问. + field.setAccessible(true); + Integer column = cellMap.get(attr.name()); + if (column != null) + { + fieldsMap.put(column, field); + } + } + } + for (int i = titleNum + 1; i <= rows; i++) + { + // 从第2行开始取数据,默认第一行是表头. + Row row = sheet.getRow(i); + // 判断当前行是否是空行 + if (isRowEmpty(row)) + { + continue; + } + T entity = null; + for (Map.Entry entry : fieldsMap.entrySet()) + { + Object val = this.getCellValue(row, entry.getKey()); + + // 如果不存在实例则新建. + entity = (entity == null ? clazz.newInstance() : entity); + // 从map中得到对应列的field. + Field field = fieldsMap.get(entry.getKey()); + // 取得类型,并根据对象类型设置值. + Class fieldType = field.getType(); + if (String.class == fieldType) + { + String s = Convert.toStr(val); + if (StringUtils.endsWith(s, ".0")) + { + val = StringUtils.substringBefore(s, ".0"); + } + else + { + String dateFormat = field.getAnnotation(Excel.class).dateFormat(); + if (StringUtils.isNotEmpty(dateFormat)) + { + val = DateUtils.parseDateToStr(dateFormat, (Date) val); + } + else + { + val = Convert.toStr(val); + } + } + } + else if ((Integer.TYPE == fieldType || Integer.class == fieldType) && StringUtils.isNumeric(Convert.toStr(val))) + { + val = Convert.toInt(val); + } + else if (Long.TYPE == fieldType || Long.class == fieldType) + { + val = Convert.toLong(val); + } + else if (Double.TYPE == fieldType || Double.class == fieldType) + { + val = Convert.toDouble(val); + } + else if (Float.TYPE == fieldType || Float.class == fieldType) + { + val = Convert.toFloat(val); + } + else if (BigDecimal.class == fieldType) + { + val = Convert.toBigDecimal(val); + } + else if (Date.class == fieldType) + { + if (val instanceof String) + { + val = DateUtils.parseDate(val); + } + else if (val instanceof Double) + { + val = DateUtil.getJavaDate((Double) val); + } + } + else if (Boolean.TYPE == fieldType || Boolean.class == fieldType) + { + val = Convert.toBool(val, false); + } + if (StringUtils.isNotNull(fieldType)) + { + Excel attr = field.getAnnotation(Excel.class); + String propertyName = field.getName(); + if (StringUtils.isNotEmpty(attr.targetAttr())) + { + propertyName = field.getName() + "." + attr.targetAttr(); + } + else if (StringUtils.isNotEmpty(attr.readConverterExp())) + { + val = reverseByExp(Convert.toStr(val), attr.readConverterExp(), attr.separator()); + } + else if (StringUtils.isNotEmpty(attr.dictType())) + { + val = reverseDictByExp(Convert.toStr(val), attr.dictType(), attr.separator()); + } + else if (!attr.handler().equals(ExcelHandlerAdapter.class)) + { + val = dataFormatHandlerAdapter(val, attr); + } + else if (ColumnType.IMAGE == attr.cellType() && StringUtils.isNotEmpty(pictures)) + { + PictureData image = pictures.get(row.getRowNum() + "_" + entry.getKey()); + if (image == null) + { + val = ""; + } + else + { + byte[] data = image.getData(); + val = FileUtils.writeImportBytes(data); + } + } + ReflectUtils.invokeSetter(entity, propertyName, val); + } + } + list.add(entity); + } + } + return list; + } + + /** + * 对list数据源将其里面的数据导入到excel表单 + * + * @param list 导出数据集合 + * @param sheetName 工作表的名称 + * @return 结果 + */ + public AjaxResult exportExcel(List list, String sheetName) + { + return exportExcel(list, sheetName, StringUtils.EMPTY); + } + + /** + * 对list数据源将其里面的数据导入到excel表单 + * + * @param list 导出数据集合 + * @param sheetName 工作表的名称 + * @param title 标题 + * @return 结果 + */ + public AjaxResult exportExcel(List list, String sheetName, String title) + { + this.init(list, sheetName, title, Type.EXPORT); + return exportExcel(); + } + + /** + * 对list数据源将其里面的数据导入到excel表单 + * + * @param response 返回数据 + * @param list 导出数据集合 + * @param sheetName 工作表的名称 + * @return 结果 + * @throws IOException + */ + public void exportExcel(HttpServletResponse response, List list, String sheetName)throws IOException + { + exportExcel(response, list, sheetName, StringUtils.EMPTY); + } + + /** + * 对list数据源将其里面的数据导入到excel表单 + * + * @param response 返回数据 + * @param list 导出数据集合 + * @param sheetName 工作表的名称 + * @param title 标题 + * @return 结果 + * @throws IOException + */ + public void exportExcel(HttpServletResponse response, List list, String sheetName, String title) throws IOException + { + response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); + response.setCharacterEncoding("utf-8"); + this.init(list, sheetName, title, Type.EXPORT); + exportExcel(response.getOutputStream()); + } + + /** + * 对list数据源将其里面的数据导入到excel表单 + * + * @param sheetName 工作表的名称 + * @return 结果 + */ + public AjaxResult importTemplateExcel(String sheetName) + { + return importTemplateExcel(sheetName, StringUtils.EMPTY); + } + + /** + * 对list数据源将其里面的数据导入到excel表单 + * + * @param sheetName 工作表的名称 + * @param title 标题 + * @return 结果 + */ + public AjaxResult importTemplateExcel(String sheetName, String title) + { + this.init(null, sheetName, title, Type.IMPORT); + return exportExcel(); + } + + /** + * 对list数据源将其里面的数据导入到excel表单 + * + * @param sheetName 工作表的名称 + * @return 结果 + */ + public void importTemplateExcel(HttpServletResponse response, String sheetName) throws IOException + { + importTemplateExcel(response, sheetName); + } + + /** + * 对list数据源将其里面的数据导入到excel表单 + * + * @param sheetName 工作表的名称 + * @param title 标题 + * @return 结果 + */ + public void importTemplateExcel(HttpServletResponse response, String sheetName, String title) throws IOException + { + response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); + response.setCharacterEncoding("utf-8"); + this.init(null, sheetName, title, Type.IMPORT); + exportExcel(response.getOutputStream()); + } + + /** + * 对list数据源将其里面的数据导入到excel表单 + * + * @return 结果 + */ + public void exportExcel(OutputStream out) + { + try + { + writeSheet(); + wb.write(out); + } + catch (Exception e) + { + log.error("导出Excel异常{}", e.getMessage()); + } + finally + { + IOUtils.closeQuietly(wb); + IOUtils.closeQuietly(out); + } + } + + /** + * 对list数据源将其里面的数据导入到excel表单 + * + * @return 结果 + */ + public AjaxResult exportExcel() + { + OutputStream out = null; + try + { + writeSheet(); + String filename = encodingFilename(sheetName); + out = new FileOutputStream(getAbsoluteFile(filename)); + wb.write(out); + return AjaxResult.success(filename); + } + catch (Exception e) + { + log.error("导出Excel异常{}", e.getMessage()); + throw new UtilException("导出Excel失败,请联系网站管理员!"); + } + finally + { + IOUtils.closeQuietly(wb); + IOUtils.closeQuietly(out); + } + } + + /** + * 创建写入数据到Sheet + */ + public void writeSheet() + { + // 取出一共有多少个sheet. + int sheetNo = Math.max(1, (int) Math.ceil(list.size() * 1.0 / sheetSize)); + for (int index = 0; index < sheetNo; index++) + { + createSheet(sheetNo, index); + + // 产生一行 + Row row = sheet.createRow(rownum); + int column = 0; + // 写入各个字段的列头名称 + for (Object[] os : fields) + { + Excel excel = (Excel) os[1]; + this.createCell(excel, row, column++); + } + if (Type.EXPORT.equals(type)) + { + fillExcelData(index, row); + addStatisticsRow(); + } + } + } + + /** + * 填充excel数据 + * + * @param index 序号 + * @param row 单元格行 + */ + public void fillExcelData(int index, Row row) + { + int startNo = index * sheetSize; + int endNo = Math.min(startNo + sheetSize, list.size()); + for (int i = startNo; i < endNo; i++) + { + row = sheet.createRow(i + 1 + rownum - startNo); + // 得到导出对象. + T vo = (T) list.get(i); + int column = 0; + for (Object[] os : fields) + { + Field field = (Field) os[0]; + Excel excel = (Excel) os[1]; + // 设置实体类私有属性可访问 + field.setAccessible(true); + this.addCell(excel, row, vo, field, column++); + } + } + } + + /** + * 创建表格样式 + * + * @param wb 工作薄对象 + * @return 样式列表 + */ + private Map createStyles(Workbook wb) + { + // 写入各条记录,每条记录对应excel表中的一行 + Map styles = new HashMap(); + CellStyle style = wb.createCellStyle(); + style.setAlignment(HorizontalAlignment.CENTER); + style.setVerticalAlignment(VerticalAlignment.CENTER); + Font titleFont = wb.createFont(); + titleFont.setFontName("Arial"); + titleFont.setFontHeightInPoints((short) 16); + titleFont.setBold(true); + style.setFont(titleFont); + styles.put("title", style); + + style = wb.createCellStyle(); + style.setAlignment(HorizontalAlignment.CENTER); + style.setVerticalAlignment(VerticalAlignment.CENTER); + style.setBorderRight(BorderStyle.THIN); + style.setRightBorderColor(IndexedColors.GREY_50_PERCENT.getIndex()); + style.setBorderLeft(BorderStyle.THIN); + style.setLeftBorderColor(IndexedColors.GREY_50_PERCENT.getIndex()); + style.setBorderTop(BorderStyle.THIN); + style.setTopBorderColor(IndexedColors.GREY_50_PERCENT.getIndex()); + style.setBorderBottom(BorderStyle.THIN); + style.setBottomBorderColor(IndexedColors.GREY_50_PERCENT.getIndex()); + Font dataFont = wb.createFont(); + dataFont.setFontName("Arial"); + dataFont.setFontHeightInPoints((short) 10); + style.setFont(dataFont); + styles.put("data", style); + + style = wb.createCellStyle(); + style.cloneStyleFrom(styles.get("data")); + style.setAlignment(HorizontalAlignment.CENTER); + style.setVerticalAlignment(VerticalAlignment.CENTER); + style.setFillForegroundColor(IndexedColors.GREY_50_PERCENT.getIndex()); + style.setFillPattern(FillPatternType.SOLID_FOREGROUND); + Font headerFont = wb.createFont(); + headerFont.setFontName("Arial"); + headerFont.setFontHeightInPoints((short) 10); + headerFont.setBold(true); + headerFont.setColor(IndexedColors.WHITE.getIndex()); + style.setFont(headerFont); + styles.put("header", style); + + style = wb.createCellStyle(); + style.setAlignment(HorizontalAlignment.CENTER); + style.setVerticalAlignment(VerticalAlignment.CENTER); + Font totalFont = wb.createFont(); + totalFont.setFontName("Arial"); + totalFont.setFontHeightInPoints((short) 10); + style.setFont(totalFont); + styles.put("total", style); + + style = wb.createCellStyle(); + style.cloneStyleFrom(styles.get("data")); + style.setAlignment(HorizontalAlignment.LEFT); + styles.put("data1", style); + + style = wb.createCellStyle(); + style.cloneStyleFrom(styles.get("data")); + style.setAlignment(HorizontalAlignment.CENTER); + styles.put("data2", style); + + style = wb.createCellStyle(); + style.cloneStyleFrom(styles.get("data")); + style.setAlignment(HorizontalAlignment.RIGHT); + styles.put("data3", style); + + return styles; + } + + /** + * 创建单元格 + */ + public Cell createCell(Excel attr, Row row, int column) + { + // 创建列 + Cell cell = row.createCell(column); + // 写入列信息 + cell.setCellValue(attr.name()); + setDataValidation(attr, row, column); + cell.setCellStyle(styles.get("header")); + return cell; + } + + /** + * 设置单元格信息 + * + * @param value 单元格值 + * @param attr 注解相关 + * @param cell 单元格信息 + */ + public void setCellVo(Object value, Excel attr, Cell cell) + { + if (ColumnType.STRING == attr.cellType()) + { + cell.setCellValue(StringUtils.isNull(value) ? attr.defaultValue() : value + attr.suffix()); + } + else if (ColumnType.NUMERIC == attr.cellType()) + { + if (StringUtils.isNotNull(value)) + { + cell.setCellValue(StringUtils.contains(Convert.toStr(value), ".") ? Convert.toDouble(value) : Convert.toInt(value)); + } + } + else if (ColumnType.IMAGE == attr.cellType()) + { + ClientAnchor anchor = new XSSFClientAnchor(0, 0, 0, 0, (short) cell.getColumnIndex(), cell.getRow().getRowNum(), (short) (cell.getColumnIndex() + 1), cell.getRow().getRowNum() + 1); + String imagePath = Convert.toStr(value); + if (StringUtils.isNotEmpty(imagePath)) + { + byte[] data = ImageUtils.getImage(imagePath); + getDrawingPatriarch(cell.getSheet()).createPicture(anchor, + cell.getSheet().getWorkbook().addPicture(data, getImageType(data))); + } + } + } + + /** + * 获取画布 + */ + public static Drawing getDrawingPatriarch(Sheet sheet) + { + if (sheet.getDrawingPatriarch() == null) + { + sheet.createDrawingPatriarch(); + } + return sheet.getDrawingPatriarch(); + } + + /** + * 获取图片类型,设置图片插入类型 + */ + public int getImageType(byte[] value) + { + String type = FileTypeUtils.getFileExtendName(value); + if ("JPG".equalsIgnoreCase(type)) + { + return Workbook.PICTURE_TYPE_JPEG; + } + else if ("PNG".equalsIgnoreCase(type)) + { + return Workbook.PICTURE_TYPE_PNG; + } + return Workbook.PICTURE_TYPE_JPEG; + } + + /** + * 创建表格样式 + */ + public void setDataValidation(Excel attr, Row row, int column) + { + if (attr.name().indexOf("注:") >= 0) + { + sheet.setColumnWidth(column, 6000); + } + else + { + // 设置列宽 + sheet.setColumnWidth(column, (int) ((attr.width() + 0.72) * 256)); + } + // 如果设置了提示信息则鼠标放上去提示. + if (StringUtils.isNotEmpty(attr.prompt())) + { + // 这里默认设了2-101列提示. + setXSSFPrompt(sheet, "", attr.prompt(), 1, 100, column, column); + } + // 如果设置了combo属性则本列只能选择不能输入 + if (attr.combo().length > 0) + { + // 这里默认设了2-101列只能选择不能输入. + setXSSFValidation(sheet, attr.combo(), 1, 100, column, column); + } + } + + /** + * 添加单元格 + */ + public Cell addCell(Excel attr, Row row, T vo, Field field, int column) + { + Cell cell = null; + try + { + // 设置行高 + row.setHeight(maxHeight); + // 根据Excel中设置情况决定是否导出,有些情况需要保持为空,希望用户填写这一列. + if (attr.isExport()) + { + // 创建cell + cell = row.createCell(column); + int align = attr.align().value(); + cell.setCellStyle(styles.get("data" + (align >= 1 && align <= 3 ? align : ""))); + + // 用于读取对象中的属性 + Object value = getTargetValue(vo, field, attr); + String dateFormat = attr.dateFormat(); + String readConverterExp = attr.readConverterExp(); + String separator = attr.separator(); + String dictType = attr.dictType(); + if (StringUtils.isNotEmpty(dateFormat) && StringUtils.isNotNull(value)) + { + cell.setCellValue(DateUtils.parseDateToStr(dateFormat, (Date) value)); + } + else if (StringUtils.isNotEmpty(readConverterExp) && StringUtils.isNotNull(value)) + { + cell.setCellValue(convertByExp(Convert.toStr(value), readConverterExp, separator)); + } + else if (StringUtils.isNotEmpty(dictType) && StringUtils.isNotNull(value)) + { + cell.setCellValue(convertDictByExp(Convert.toStr(value), dictType, separator)); + } + else if (value instanceof BigDecimal && -1 != attr.scale()) + { + cell.setCellValue((((BigDecimal) value).setScale(attr.scale(), attr.roundingMode())).toString()); + } + else if (!attr.handler().equals(ExcelHandlerAdapter.class)) + { + cell.setCellValue(dataFormatHandlerAdapter(value, attr)); + } + else + { + // 设置列类型 + setCellVo(value, attr, cell); + } + addStatisticsData(column, Convert.toStr(value), attr); + } + } + catch (Exception e) + { + log.error("导出Excel失败{}", e); + } + return cell; + } + + /** + * 设置 POI XSSFSheet 单元格提示 + * + * @param sheet 表单 + * @param promptTitle 提示标题 + * @param promptContent 提示内容 + * @param firstRow 开始行 + * @param endRow 结束行 + * @param firstCol 开始列 + * @param endCol 结束列 + */ + public void setXSSFPrompt(Sheet sheet, String promptTitle, String promptContent, int firstRow, int endRow, + int firstCol, int endCol) + { + DataValidationHelper helper = sheet.getDataValidationHelper(); + DataValidationConstraint constraint = helper.createCustomConstraint("DD1"); + CellRangeAddressList regions = new CellRangeAddressList(firstRow, endRow, firstCol, endCol); + DataValidation dataValidation = helper.createValidation(constraint, regions); + dataValidation.createPromptBox(promptTitle, promptContent); + dataValidation.setShowPromptBox(true); + sheet.addValidationData(dataValidation); + } + + /** + * 设置某些列的值只能输入预制的数据,显示下拉框. + * + * @param sheet 要设置的sheet. + * @param textlist 下拉框显示的内容 + * @param firstRow 开始行 + * @param endRow 结束行 + * @param firstCol 开始列 + * @param endCol 结束列 + * @return 设置好的sheet. + */ + public void setXSSFValidation(Sheet sheet, String[] textlist, int firstRow, int endRow, int firstCol, int endCol) + { + DataValidationHelper helper = sheet.getDataValidationHelper(); + // 加载下拉列表内容 + DataValidationConstraint constraint = helper.createExplicitListConstraint(textlist); + // 设置数据有效性加载在哪个单元格上,四个参数分别是:起始行、终止行、起始列、终止列 + CellRangeAddressList regions = new CellRangeAddressList(firstRow, endRow, firstCol, endCol); + // 数据有效性对象 + DataValidation dataValidation = helper.createValidation(constraint, regions); + // 处理Excel兼容性问题 + if (dataValidation instanceof XSSFDataValidation) + { + dataValidation.setSuppressDropDownArrow(true); + dataValidation.setShowErrorBox(true); + } + else + { + dataValidation.setSuppressDropDownArrow(false); + } + + sheet.addValidationData(dataValidation); + } + + /** + * 解析导出值 0=男,1=女,2=未知 + * + * @param propertyValue 参数值 + * @param converterExp 翻译注解 + * @param separator 分隔符 + * @return 解析后值 + */ + public static String convertByExp(String propertyValue, String converterExp, String separator) + { + StringBuilder propertyString = new StringBuilder(); + String[] convertSource = converterExp.split(","); + for (String item : convertSource) + { + String[] itemArray = item.split("="); + if (StringUtils.containsAny(separator, propertyValue)) + { + for (String value : propertyValue.split(separator)) + { + if (itemArray[0].equals(value)) + { + propertyString.append(itemArray[1] + separator); + break; + } + } + } + else + { + if (itemArray[0].equals(propertyValue)) + { + return itemArray[1]; + } + } + } + return StringUtils.stripEnd(propertyString.toString(), separator); + } + + /** + * 反向解析值 男=0,女=1,未知=2 + * + * @param propertyValue 参数值 + * @param converterExp 翻译注解 + * @param separator 分隔符 + * @return 解析后值 + */ + public static String reverseByExp(String propertyValue, String converterExp, String separator) + { + StringBuilder propertyString = new StringBuilder(); + String[] convertSource = converterExp.split(","); + for (String item : convertSource) + { + String[] itemArray = item.split("="); + if (StringUtils.containsAny(separator, propertyValue)) + { + for (String value : propertyValue.split(separator)) + { + if (itemArray[1].equals(value)) + { + propertyString.append(itemArray[0] + separator); + break; + } + } + } + else + { + if (itemArray[1].equals(propertyValue)) + { + return itemArray[0]; + } + } + } + return StringUtils.stripEnd(propertyString.toString(), separator); + } + + /** + * 解析字典值 + * + * @param dictValue 字典值 + * @param dictType 字典类型 + * @param separator 分隔符 + * @return 字典标签 + */ + public static String convertDictByExp(String dictValue, String dictType, String separator) + { + return DictUtils.getDictLabel(dictType, dictValue, separator); + } + + /** + * 反向解析值字典值 + * + * @param dictLabel 字典标签 + * @param dictType 字典类型 + * @param separator 分隔符 + * @return 字典值 + */ + public static String reverseDictByExp(String dictLabel, String dictType, String separator) + { + return DictUtils.getDictValue(dictType, dictLabel, separator); + } + + /** + * 数据处理器 + * + * @param value 数据值 + * @param excel 数据注解 + * @return + */ + public String dataFormatHandlerAdapter(Object value, Excel excel) + { + try + { + Object instance = excel.handler().newInstance(); + Method formatMethod = excel.handler().getMethod("format", new Class[] { Object.class, String[].class }); + value = formatMethod.invoke(instance, value, excel.args()); + } + catch (Exception e) + { + log.error("不能格式化数据 " + excel.handler(), e.getMessage()); + } + return Convert.toStr(value); + } + + /** + * 合计统计信息 + */ + private void addStatisticsData(Integer index, String text, Excel entity) + { + if (entity != null && entity.isStatistics()) + { + Double temp = 0D; + if (!statistics.containsKey(index)) + { + statistics.put(index, temp); + } + try + { + temp = Double.valueOf(text); + } + catch (NumberFormatException e) + { + } + statistics.put(index, statistics.get(index) + temp); + } + } + + /** + * 创建统计行 + */ + public void addStatisticsRow() + { + if (statistics.size() > 0) + { + Row row = sheet.createRow(sheet.getLastRowNum() + 1); + Set keys = statistics.keySet(); + Cell cell = row.createCell(0); + cell.setCellStyle(styles.get("total")); + cell.setCellValue("合计"); + + for (Integer key : keys) + { + cell = row.createCell(key); + cell.setCellStyle(styles.get("total")); + cell.setCellValue(DOUBLE_FORMAT.format(statistics.get(key))); + } + statistics.clear(); + } + } + + /** + * 编码文件名 + */ + public String encodingFilename(String filename) + { + filename = UUID.randomUUID().toString() + "_" + filename + ".xlsx"; + return filename; + } + + /** + * 获取下载路径 + * + * @param filename 文件名称 + */ + public String getAbsoluteFile(String filename) + { + String downloadPath = RuoYiConfig.getDownloadPath() + filename; + File desc = new File(downloadPath); + if (!desc.getParentFile().exists()) + { + desc.getParentFile().mkdirs(); + } + return downloadPath; + } + + /** + * 获取bean中的属性值 + * + * @param vo 实体对象 + * @param field 字段 + * @param excel 注解 + * @return 最终的属性值 + * @throws Exception + */ + private Object getTargetValue(T vo, Field field, Excel excel) throws Exception + { + Object o = field.get(vo); + if (StringUtils.isNotEmpty(excel.targetAttr())) + { + String target = excel.targetAttr(); + if (target.indexOf(".") > -1) + { + String[] targets = target.split("[.]"); + for (String name : targets) + { + o = getValue(o, name); + } + } + else + { + o = getValue(o, target); + } + } + return o; + } + + /** + * 以类的属性的get方法方法形式获取值 + * + * @param o + * @param name + * @return value + * @throws Exception + */ + private Object getValue(Object o, String name) throws Exception + { + if (StringUtils.isNotNull(o) && StringUtils.isNotEmpty(name)) + { + Class clazz = o.getClass(); + Field field = clazz.getDeclaredField(name); + field.setAccessible(true); + o = field.get(o); + } + return o; + } + + /** + * 得到所有定义字段 + */ + private void createExcelField() + { + this.fields = new ArrayList(); + List tempFields = new ArrayList<>(); + tempFields.addAll(Arrays.asList(clazz.getSuperclass().getDeclaredFields())); + tempFields.addAll(Arrays.asList(clazz.getDeclaredFields())); + for (Field field : tempFields) + { + // 单注解 + if (field.isAnnotationPresent(Excel.class)) + { + putToField(field, field.getAnnotation(Excel.class)); + } + + // 多注解 + if (field.isAnnotationPresent(Excels.class)) + { + Excels attrs = field.getAnnotation(Excels.class); + Excel[] excels = attrs.value(); + for (Excel excel : excels) + { + putToField(field, excel); + } + } + } + this.fields = this.fields.stream().sorted(Comparator.comparing(objects -> ((Excel) objects[1]).sort())).collect(Collectors.toList()); + this.maxHeight = getRowHeight(); + } + + /** + * 根据注解获取最大行高 + */ + public short getRowHeight() + { + double maxHeight = 0; + for (Object[] os : this.fields) + { + Excel excel = (Excel) os[1]; + maxHeight = maxHeight > excel.height() ? maxHeight : excel.height(); + } + return (short) (maxHeight * 20); + } + + /** + * 放到字段集合中 + */ + private void putToField(Field field, Excel attr) + { + if (attr != null && (attr.type() == Type.ALL || attr.type() == type)) + { + this.fields.add(new Object[] { field, attr }); + } + } + + /** + * 创建一个工作簿 + */ + public void createWorkbook() + { + this.wb = new SXSSFWorkbook(500); + this.sheet = wb.createSheet(); + wb.setSheetName(0, sheetName); + this.styles = createStyles(wb); + } + + /** + * 创建工作表 + * + * @param sheetNo sheet数量 + * @param index 序号 + */ + public void createSheet(int sheetNo, int index) + { + // 设置工作表的名称. + if (sheetNo > 1 && index > 0) + { + this.sheet = wb.createSheet(); + this.createTitle(); + wb.setSheetName(index, sheetName + index); + } + } + + /** + * 获取单元格值 + * + * @param row 获取的行 + * @param column 获取单元格列号 + * @return 单元格值 + */ + public Object getCellValue(Row row, int column) + { + if (row == null) + { + return row; + } + Object val = ""; + try + { + Cell cell = row.getCell(column); + if (StringUtils.isNotNull(cell)) + { + if (cell.getCellType() == CellType.NUMERIC || cell.getCellType() == CellType.FORMULA) + { + val = cell.getNumericCellValue(); + if (DateUtil.isCellDateFormatted(cell)) + { + val = DateUtil.getJavaDate((Double) val); // POI Excel 日期格式转换 + } + else + { + if ((Double) val % 1 != 0) + { + val = new BigDecimal(val.toString()); + } + else + { + val = new DecimalFormat("0").format(val); + } + } + } + else if (cell.getCellType() == CellType.STRING) + { + val = cell.getStringCellValue(); + } + else if (cell.getCellType() == CellType.BOOLEAN) + { + val = cell.getBooleanCellValue(); + } + else if (cell.getCellType() == CellType.ERROR) + { + val = cell.getErrorCellValue(); + } + + } + } + catch (Exception e) + { + return val; + } + return val; + } + + /** + * 判断是否是空行 + * + * @param row 判断的行 + * @return + */ + private boolean isRowEmpty(Row row) + { + if (row == null) + { + return true; + } + for (int i = row.getFirstCellNum(); i < row.getLastCellNum(); i++) + { + Cell cell = row.getCell(i); + if (cell != null && cell.getCellType() != CellType.BLANK) + { + return false; + } + } + return true; + } + + /** + * 获取Excel2003图片 + * + * @param sheet 当前sheet对象 + * @param workbook 工作簿对象 + * @return Map key:图片单元格索引(1_1)String,value:图片流PictureData + */ + public static Map getSheetPictures03(HSSFSheet sheet, HSSFWorkbook workbook) + { + Map sheetIndexPicMap = new HashMap(); + List pictures = workbook.getAllPictures(); + if (!pictures.isEmpty()) + { + for (HSSFShape shape : sheet.getDrawingPatriarch().getChildren()) + { + HSSFClientAnchor anchor = (HSSFClientAnchor) shape.getAnchor(); + if (shape instanceof HSSFPicture) + { + HSSFPicture pic = (HSSFPicture) shape; + int pictureIndex = pic.getPictureIndex() - 1; + HSSFPictureData picData = pictures.get(pictureIndex); + String picIndex = String.valueOf(anchor.getRow1()) + "_" + String.valueOf(anchor.getCol1()); + sheetIndexPicMap.put(picIndex, picData); + } + } + return sheetIndexPicMap; + } + else + { + return sheetIndexPicMap; + } + } + + /** + * 获取Excel2007图片 + * + * @param sheet 当前sheet对象 + * @param workbook 工作簿对象 + * @return Map key:图片单元格索引(1_1)String,value:图片流PictureData + */ + public static Map getSheetPictures07(XSSFSheet sheet, XSSFWorkbook workbook) + { + Map sheetIndexPicMap = new HashMap(); + for (POIXMLDocumentPart dr : sheet.getRelations()) + { + if (dr instanceof XSSFDrawing) + { + XSSFDrawing drawing = (XSSFDrawing) dr; + List shapes = drawing.getShapes(); + for (XSSFShape shape : shapes) + { + if (shape instanceof XSSFPicture) + { + XSSFPicture pic = (XSSFPicture) shape; + XSSFClientAnchor anchor = pic.getPreferredSize(); + CTMarker ctMarker = anchor.getFrom(); + String picIndex = ctMarker.getRow() + "_" + ctMarker.getCol(); + sheetIndexPicMap.put(picIndex, pic.getPictureData()); + } + } + } + } + return sheetIndexPicMap; + } +} diff --git a/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/utils/reflect/ReflectUtils.java b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/utils/reflect/ReflectUtils.java new file mode 100644 index 0000000..b19953e --- /dev/null +++ b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/utils/reflect/ReflectUtils.java @@ -0,0 +1,410 @@ +package com.ruoyi.common.utils.reflect; + +import java.lang.reflect.Field; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.lang.reflect.Modifier; +import java.lang.reflect.ParameterizedType; +import java.lang.reflect.Type; +import java.util.Date; +import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.Validate; +import org.apache.poi.ss.usermodel.DateUtil; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import com.ruoyi.common.core.text.Convert; +import com.ruoyi.common.utils.DateUtils; + +/** + * 反射工具类. 提供调用getter/setter方法, 访问私有变量, 调用私有方法, 获取泛型类型Class, 被AOP过的真实类等工具函数. + * + * @author ruoyi + */ +@SuppressWarnings("rawtypes") +public class ReflectUtils +{ + private static final String SETTER_PREFIX = "set"; + + private static final String GETTER_PREFIX = "get"; + + private static final String CGLIB_CLASS_SEPARATOR = "$$"; + + private static Logger logger = LoggerFactory.getLogger(ReflectUtils.class); + + /** + * 调用Getter方法. + * 支持多级,如:对象名.对象名.方法 + */ + @SuppressWarnings("unchecked") + public static E invokeGetter(Object obj, String propertyName) + { + Object object = obj; + for (String name : StringUtils.split(propertyName, ".")) + { + String getterMethodName = GETTER_PREFIX + StringUtils.capitalize(name); + object = invokeMethod(object, getterMethodName, new Class[] {}, new Object[] {}); + } + return (E) object; + } + + /** + * 调用Setter方法, 仅匹配方法名。 + * 支持多级,如:对象名.对象名.方法 + */ + public static void invokeSetter(Object obj, String propertyName, E value) + { + Object object = obj; + String[] names = StringUtils.split(propertyName, "."); + for (int i = 0; i < names.length; i++) + { + if (i < names.length - 1) + { + String getterMethodName = GETTER_PREFIX + StringUtils.capitalize(names[i]); + object = invokeMethod(object, getterMethodName, new Class[] {}, new Object[] {}); + } + else + { + String setterMethodName = SETTER_PREFIX + StringUtils.capitalize(names[i]); + invokeMethodByName(object, setterMethodName, new Object[] { value }); + } + } + } + + /** + * 直接读取对象属性值, 无视private/protected修饰符, 不经过getter函数. + */ + @SuppressWarnings("unchecked") + public static E getFieldValue(final Object obj, final String fieldName) + { + Field field = getAccessibleField(obj, fieldName); + if (field == null) + { + logger.debug("在 [" + obj.getClass() + "] 中,没有找到 [" + fieldName + "] 字段 "); + return null; + } + E result = null; + try + { + result = (E) field.get(obj); + } + catch (IllegalAccessException e) + { + logger.error("不可能抛出的异常{}", e.getMessage()); + } + return result; + } + + /** + * 直接设置对象属性值, 无视private/protected修饰符, 不经过setter函数. + */ + public static void setFieldValue(final Object obj, final String fieldName, final E value) + { + Field field = getAccessibleField(obj, fieldName); + if (field == null) + { + // throw new IllegalArgumentException("在 [" + obj.getClass() + "] 中,没有找到 [" + fieldName + "] 字段 "); + logger.debug("在 [" + obj.getClass() + "] 中,没有找到 [" + fieldName + "] 字段 "); + return; + } + try + { + field.set(obj, value); + } + catch (IllegalAccessException e) + { + logger.error("不可能抛出的异常: {}", e.getMessage()); + } + } + + /** + * 直接调用对象方法, 无视private/protected修饰符. + * 用于一次性调用的情况,否则应使用getAccessibleMethod()函数获得Method后反复调用. + * 同时匹配方法名+参数类型, + */ + @SuppressWarnings("unchecked") + public static E invokeMethod(final Object obj, final String methodName, final Class[] parameterTypes, + final Object[] args) + { + if (obj == null || methodName == null) + { + return null; + } + Method method = getAccessibleMethod(obj, methodName, parameterTypes); + if (method == null) + { + logger.debug("在 [" + obj.getClass() + "] 中,没有找到 [" + methodName + "] 方法 "); + return null; + } + try + { + return (E) method.invoke(obj, args); + } + catch (Exception e) + { + String msg = "method: " + method + ", obj: " + obj + ", args: " + args + ""; + throw convertReflectionExceptionToUnchecked(msg, e); + } + } + + /** + * 直接调用对象方法, 无视private/protected修饰符, + * 用于一次性调用的情况,否则应使用getAccessibleMethodByName()函数获得Method后反复调用. + * 只匹配函数名,如果有多个同名函数调用第一个。 + */ + @SuppressWarnings("unchecked") + public static E invokeMethodByName(final Object obj, final String methodName, final Object[] args) + { + Method method = getAccessibleMethodByName(obj, methodName, args.length); + if (method == null) + { + // 如果为空不报错,直接返回空。 + logger.debug("在 [" + obj.getClass() + "] 中,没有找到 [" + methodName + "] 方法 "); + return null; + } + try + { + // 类型转换(将参数数据类型转换为目标方法参数类型) + Class[] cs = method.getParameterTypes(); + for (int i = 0; i < cs.length; i++) + { + if (args[i] != null && !args[i].getClass().equals(cs[i])) + { + if (cs[i] == String.class) + { + args[i] = Convert.toStr(args[i]); + if (StringUtils.endsWith((String) args[i], ".0")) + { + args[i] = StringUtils.substringBefore((String) args[i], ".0"); + } + } + else if (cs[i] == Integer.class) + { + args[i] = Convert.toInt(args[i]); + } + else if (cs[i] == Long.class) + { + args[i] = Convert.toLong(args[i]); + } + else if (cs[i] == Double.class) + { + args[i] = Convert.toDouble(args[i]); + } + else if (cs[i] == Float.class) + { + args[i] = Convert.toFloat(args[i]); + } + else if (cs[i] == Date.class) + { + if (args[i] instanceof String) + { + args[i] = DateUtils.parseDate(args[i]); + } + else + { + args[i] = DateUtil.getJavaDate((Double) args[i]); + } + } + else if (cs[i] == boolean.class || cs[i] == Boolean.class) + { + args[i] = Convert.toBool(args[i]); + } + } + } + return (E) method.invoke(obj, args); + } + catch (Exception e) + { + String msg = "method: " + method + ", obj: " + obj + ", args: " + args + ""; + throw convertReflectionExceptionToUnchecked(msg, e); + } + } + + /** + * 循环向上转型, 获取对象的DeclaredField, 并强制设置为可访问. + * 如向上转型到Object仍无法找到, 返回null. + */ + public static Field getAccessibleField(final Object obj, final String fieldName) + { + // 为空不报错。直接返回 null + if (obj == null) + { + return null; + } + Validate.notBlank(fieldName, "fieldName can't be blank"); + for (Class superClass = obj.getClass(); superClass != Object.class; superClass = superClass.getSuperclass()) + { + try + { + Field field = superClass.getDeclaredField(fieldName); + makeAccessible(field); + return field; + } + catch (NoSuchFieldException e) + { + continue; + } + } + return null; + } + + /** + * 循环向上转型, 获取对象的DeclaredMethod,并强制设置为可访问. + * 如向上转型到Object仍无法找到, 返回null. + * 匹配函数名+参数类型。 + * 用于方法需要被多次调用的情况. 先使用本函数先取得Method,然后调用Method.invoke(Object obj, Object... args) + */ + public static Method getAccessibleMethod(final Object obj, final String methodName, + final Class... parameterTypes) + { + // 为空不报错。直接返回 null + if (obj == null) + { + return null; + } + Validate.notBlank(methodName, "methodName can't be blank"); + for (Class searchType = obj.getClass(); searchType != Object.class; searchType = searchType.getSuperclass()) + { + try + { + Method method = searchType.getDeclaredMethod(methodName, parameterTypes); + makeAccessible(method); + return method; + } + catch (NoSuchMethodException e) + { + continue; + } + } + return null; + } + + /** + * 循环向上转型, 获取对象的DeclaredMethod,并强制设置为可访问. + * 如向上转型到Object仍无法找到, 返回null. + * 只匹配函数名。 + * 用于方法需要被多次调用的情况. 先使用本函数先取得Method,然后调用Method.invoke(Object obj, Object... args) + */ + public static Method getAccessibleMethodByName(final Object obj, final String methodName, int argsNum) + { + // 为空不报错。直接返回 null + if (obj == null) + { + return null; + } + Validate.notBlank(methodName, "methodName can't be blank"); + for (Class searchType = obj.getClass(); searchType != Object.class; searchType = searchType.getSuperclass()) + { + Method[] methods = searchType.getDeclaredMethods(); + for (Method method : methods) + { + if (method.getName().equals(methodName) && method.getParameterTypes().length == argsNum) + { + makeAccessible(method); + return method; + } + } + } + return null; + } + + /** + * 改变private/protected的方法为public,尽量不调用实际改动的语句,避免JDK的SecurityManager抱怨。 + */ + public static void makeAccessible(Method method) + { + if ((!Modifier.isPublic(method.getModifiers()) || !Modifier.isPublic(method.getDeclaringClass().getModifiers())) + && !method.isAccessible()) + { + method.setAccessible(true); + } + } + + /** + * 改变private/protected的成员变量为public,尽量不调用实际改动的语句,避免JDK的SecurityManager抱怨。 + */ + public static void makeAccessible(Field field) + { + if ((!Modifier.isPublic(field.getModifiers()) || !Modifier.isPublic(field.getDeclaringClass().getModifiers()) + || Modifier.isFinal(field.getModifiers())) && !field.isAccessible()) + { + field.setAccessible(true); + } + } + + /** + * 通过反射, 获得Class定义中声明的泛型参数的类型, 注意泛型必须定义在父类处 + * 如无法找到, 返回Object.class. + */ + @SuppressWarnings("unchecked") + public static Class getClassGenricType(final Class clazz) + { + return getClassGenricType(clazz, 0); + } + + /** + * 通过反射, 获得Class定义中声明的父类的泛型参数的类型. + * 如无法找到, 返回Object.class. + */ + public static Class getClassGenricType(final Class clazz, final int index) + { + Type genType = clazz.getGenericSuperclass(); + + if (!(genType instanceof ParameterizedType)) + { + logger.debug(clazz.getSimpleName() + "'s superclass not ParameterizedType"); + return Object.class; + } + + Type[] params = ((ParameterizedType) genType).getActualTypeArguments(); + + if (index >= params.length || index < 0) + { + logger.debug("Index: " + index + ", Size of " + clazz.getSimpleName() + "'s Parameterized Type: " + + params.length); + return Object.class; + } + if (!(params[index] instanceof Class)) + { + logger.debug(clazz.getSimpleName() + " not set the actual class on superclass generic parameter"); + return Object.class; + } + + return (Class) params[index]; + } + + public static Class getUserClass(Object instance) + { + if (instance == null) + { + throw new RuntimeException("Instance must not be null"); + } + Class clazz = instance.getClass(); + if (clazz != null && clazz.getName().contains(CGLIB_CLASS_SEPARATOR)) + { + Class superClass = clazz.getSuperclass(); + if (superClass != null && !Object.class.equals(superClass)) + { + return superClass; + } + } + return clazz; + + } + + /** + * 将反射时的checked exception转换为unchecked exception. + */ + public static RuntimeException convertReflectionExceptionToUnchecked(String msg, Exception e) + { + if (e instanceof IllegalAccessException || e instanceof IllegalArgumentException + || e instanceof NoSuchMethodException) + { + return new IllegalArgumentException(msg, e); + } + else if (e instanceof InvocationTargetException) + { + return new RuntimeException(msg, ((InvocationTargetException) e).getTargetException()); + } + return new RuntimeException(msg, e); + } +} diff --git a/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/utils/sign/Base64.java b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/utils/sign/Base64.java new file mode 100644 index 0000000..9b37e04 --- /dev/null +++ b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/utils/sign/Base64.java @@ -0,0 +1,291 @@ +package com.ruoyi.common.utils.sign; + +/** + * Base64工具类 + * + * @author ruoyi + */ +public final class Base64 +{ + static private final int BASELENGTH = 128; + static private final int LOOKUPLENGTH = 64; + static private final int TWENTYFOURBITGROUP = 24; + static private final int EIGHTBIT = 8; + static private final int SIXTEENBIT = 16; + static private final int FOURBYTE = 4; + static private final int SIGN = -128; + static private final char PAD = '='; + static final private byte[] base64Alphabet = new byte[BASELENGTH]; + static final private char[] lookUpBase64Alphabet = new char[LOOKUPLENGTH]; + + static + { + for (int i = 0; i < BASELENGTH; ++i) + { + base64Alphabet[i] = -1; + } + for (int i = 'Z'; i >= 'A'; i--) + { + base64Alphabet[i] = (byte) (i - 'A'); + } + for (int i = 'z'; i >= 'a'; i--) + { + base64Alphabet[i] = (byte) (i - 'a' + 26); + } + + for (int i = '9'; i >= '0'; i--) + { + base64Alphabet[i] = (byte) (i - '0' + 52); + } + + base64Alphabet['+'] = 62; + base64Alphabet['/'] = 63; + + for (int i = 0; i <= 25; i++) + { + lookUpBase64Alphabet[i] = (char) ('A' + i); + } + + for (int i = 26, j = 0; i <= 51; i++, j++) + { + lookUpBase64Alphabet[i] = (char) ('a' + j); + } + + for (int i = 52, j = 0; i <= 61; i++, j++) + { + lookUpBase64Alphabet[i] = (char) ('0' + j); + } + lookUpBase64Alphabet[62] = (char) '+'; + lookUpBase64Alphabet[63] = (char) '/'; + } + + private static boolean isWhiteSpace(char octect) + { + return (octect == 0x20 || octect == 0xd || octect == 0xa || octect == 0x9); + } + + private static boolean isPad(char octect) + { + return (octect == PAD); + } + + private static boolean isData(char octect) + { + return (octect < BASELENGTH && base64Alphabet[octect] != -1); + } + + /** + * Encodes hex octects into Base64 + * + * @param binaryData Array containing binaryData + * @return Encoded Base64 array + */ + public static String encode(byte[] binaryData) + { + if (binaryData == null) + { + return null; + } + + int lengthDataBits = binaryData.length * EIGHTBIT; + if (lengthDataBits == 0) + { + return ""; + } + + int fewerThan24bits = lengthDataBits % TWENTYFOURBITGROUP; + int numberTriplets = lengthDataBits / TWENTYFOURBITGROUP; + int numberQuartet = fewerThan24bits != 0 ? numberTriplets + 1 : numberTriplets; + char[] encodedData = null; + + encodedData = new char[numberQuartet * 4]; + + byte k = 0, l = 0, b1 = 0, b2 = 0, b3 = 0; + + int encodedIndex = 0; + int dataIndex = 0; + + for (int i = 0; i < numberTriplets; i++) + { + b1 = binaryData[dataIndex++]; + b2 = binaryData[dataIndex++]; + b3 = binaryData[dataIndex++]; + + l = (byte) (b2 & 0x0f); + k = (byte) (b1 & 0x03); + + byte val1 = ((b1 & SIGN) == 0) ? (byte) (b1 >> 2) : (byte) ((b1) >> 2 ^ 0xc0); + byte val2 = ((b2 & SIGN) == 0) ? (byte) (b2 >> 4) : (byte) ((b2) >> 4 ^ 0xf0); + byte val3 = ((b3 & SIGN) == 0) ? (byte) (b3 >> 6) : (byte) ((b3) >> 6 ^ 0xfc); + + encodedData[encodedIndex++] = lookUpBase64Alphabet[val1]; + encodedData[encodedIndex++] = lookUpBase64Alphabet[val2 | (k << 4)]; + encodedData[encodedIndex++] = lookUpBase64Alphabet[(l << 2) | val3]; + encodedData[encodedIndex++] = lookUpBase64Alphabet[b3 & 0x3f]; + } + + // form integral number of 6-bit groups + if (fewerThan24bits == EIGHTBIT) + { + b1 = binaryData[dataIndex]; + k = (byte) (b1 & 0x03); + byte val1 = ((b1 & SIGN) == 0) ? (byte) (b1 >> 2) : (byte) ((b1) >> 2 ^ 0xc0); + encodedData[encodedIndex++] = lookUpBase64Alphabet[val1]; + encodedData[encodedIndex++] = lookUpBase64Alphabet[k << 4]; + encodedData[encodedIndex++] = PAD; + encodedData[encodedIndex++] = PAD; + } + else if (fewerThan24bits == SIXTEENBIT) + { + b1 = binaryData[dataIndex]; + b2 = binaryData[dataIndex + 1]; + l = (byte) (b2 & 0x0f); + k = (byte) (b1 & 0x03); + + byte val1 = ((b1 & SIGN) == 0) ? (byte) (b1 >> 2) : (byte) ((b1) >> 2 ^ 0xc0); + byte val2 = ((b2 & SIGN) == 0) ? (byte) (b2 >> 4) : (byte) ((b2) >> 4 ^ 0xf0); + + encodedData[encodedIndex++] = lookUpBase64Alphabet[val1]; + encodedData[encodedIndex++] = lookUpBase64Alphabet[val2 | (k << 4)]; + encodedData[encodedIndex++] = lookUpBase64Alphabet[l << 2]; + encodedData[encodedIndex++] = PAD; + } + return new String(encodedData); + } + + /** + * Decodes Base64 data into octects + * + * @param encoded string containing Base64 data + * @return Array containind decoded data. + */ + public static byte[] decode(String encoded) + { + if (encoded == null) + { + return null; + } + + char[] base64Data = encoded.toCharArray(); + // remove white spaces + int len = removeWhiteSpace(base64Data); + + if (len % FOURBYTE != 0) + { + return null;// should be divisible by four + } + + int numberQuadruple = (len / FOURBYTE); + + if (numberQuadruple == 0) + { + return new byte[0]; + } + + byte[] decodedData = null; + byte b1 = 0, b2 = 0, b3 = 0, b4 = 0; + char d1 = 0, d2 = 0, d3 = 0, d4 = 0; + + int i = 0; + int encodedIndex = 0; + int dataIndex = 0; + decodedData = new byte[(numberQuadruple) * 3]; + + for (; i < numberQuadruple - 1; i++) + { + + if (!isData((d1 = base64Data[dataIndex++])) || !isData((d2 = base64Data[dataIndex++])) + || !isData((d3 = base64Data[dataIndex++])) || !isData((d4 = base64Data[dataIndex++]))) + { + return null; + } // if found "no data" just return null + + b1 = base64Alphabet[d1]; + b2 = base64Alphabet[d2]; + b3 = base64Alphabet[d3]; + b4 = base64Alphabet[d4]; + + decodedData[encodedIndex++] = (byte) (b1 << 2 | b2 >> 4); + decodedData[encodedIndex++] = (byte) (((b2 & 0xf) << 4) | ((b3 >> 2) & 0xf)); + decodedData[encodedIndex++] = (byte) (b3 << 6 | b4); + } + + if (!isData((d1 = base64Data[dataIndex++])) || !isData((d2 = base64Data[dataIndex++]))) + { + return null;// if found "no data" just return null + } + + b1 = base64Alphabet[d1]; + b2 = base64Alphabet[d2]; + + d3 = base64Data[dataIndex++]; + d4 = base64Data[dataIndex++]; + if (!isData((d3)) || !isData((d4))) + {// Check if they are PAD characters + if (isPad(d3) && isPad(d4)) + { + if ((b2 & 0xf) != 0)// last 4 bits should be zero + { + return null; + } + byte[] tmp = new byte[i * 3 + 1]; + System.arraycopy(decodedData, 0, tmp, 0, i * 3); + tmp[encodedIndex] = (byte) (b1 << 2 | b2 >> 4); + return tmp; + } + else if (!isPad(d3) && isPad(d4)) + { + b3 = base64Alphabet[d3]; + if ((b3 & 0x3) != 0)// last 2 bits should be zero + { + return null; + } + byte[] tmp = new byte[i * 3 + 2]; + System.arraycopy(decodedData, 0, tmp, 0, i * 3); + tmp[encodedIndex++] = (byte) (b1 << 2 | b2 >> 4); + tmp[encodedIndex] = (byte) (((b2 & 0xf) << 4) | ((b3 >> 2) & 0xf)); + return tmp; + } + else + { + return null; + } + } + else + { // No PAD e.g 3cQl + b3 = base64Alphabet[d3]; + b4 = base64Alphabet[d4]; + decodedData[encodedIndex++] = (byte) (b1 << 2 | b2 >> 4); + decodedData[encodedIndex++] = (byte) (((b2 & 0xf) << 4) | ((b3 >> 2) & 0xf)); + decodedData[encodedIndex++] = (byte) (b3 << 6 | b4); + + } + return decodedData; + } + + /** + * remove WhiteSpace from MIME containing encoded Base64 data. + * + * @param data the byte array of base64 data (with WS) + * @return the new length + */ + private static int removeWhiteSpace(char[] data) + { + if (data == null) + { + return 0; + } + + // count characters that's not whitespace + int newSize = 0; + int len = data.length; + for (int i = 0; i < len; i++) + { + if (!isWhiteSpace(data[i])) + { + data[newSize++] = data[i]; + } + } + return newSize; + } +} diff --git a/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/utils/sign/Md5Utils.java b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/utils/sign/Md5Utils.java new file mode 100644 index 0000000..430922a --- /dev/null +++ b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/utils/sign/Md5Utils.java @@ -0,0 +1,66 @@ +package com.ruoyi.common.utils.sign; + +import java.security.MessageDigest; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Md5加密方法 + * + * @author ruoyi + */ +public class Md5Utils +{ + private static final Logger log = LoggerFactory.getLogger(Md5Utils.class); + + private static byte[] md5(String s) + { + MessageDigest algorithm; + try + { + algorithm = MessageDigest.getInstance("MD5"); + algorithm.reset(); + algorithm.update(s.getBytes("UTF-8")); + byte[] messageDigest = algorithm.digest(); + return messageDigest; + } + catch (Exception e) + { + log.error("MD5 Error...", e); + } + return null; + } + + private static final String toHex(byte[] hash) + { + if (hash == null) + { + return null; + } + StringBuffer buf = new StringBuffer(hash.length * 2); + int i; + + for (i = 0; i < hash.length; i++) + { + if ((hash[i] & 0xff) < 0x10) + { + buf.append("0"); + } + buf.append(Long.toString(hash[i] & 0xff, 16)); + } + return buf.toString(); + } + + public static String hash(String s) + { + try + { + return new String(toHex(md5(s)).getBytes("UTF-8"), "UTF-8"); + } + catch (Exception e) + { + log.error("not supported charset...{}", e); + return s; + } + } +} diff --git a/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/utils/spring/SpringUtils.java b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/utils/spring/SpringUtils.java new file mode 100644 index 0000000..a5d5275 --- /dev/null +++ b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/utils/spring/SpringUtils.java @@ -0,0 +1,146 @@ +package com.ruoyi.common.utils.spring; + +import org.springframework.aop.framework.AopContext; +import org.springframework.beans.BeansException; +import org.springframework.beans.factory.NoSuchBeanDefinitionException; +import org.springframework.beans.factory.config.BeanFactoryPostProcessor; +import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; +import org.springframework.context.ApplicationContext; +import org.springframework.context.ApplicationContextAware; +import org.springframework.stereotype.Component; +import com.ruoyi.common.utils.StringUtils; + +/** + * spring工具类 方便在非spring管理环境中获取bean + * + * @author ruoyi + */ +@Component +public final class SpringUtils implements BeanFactoryPostProcessor, ApplicationContextAware +{ + /** Spring应用上下文环境 */ + private static ConfigurableListableBeanFactory beanFactory; + + private static ApplicationContext applicationContext; + + @Override + public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException + { + SpringUtils.beanFactory = beanFactory; + } + + @Override + public void setApplicationContext(ApplicationContext applicationContext) throws BeansException + { + SpringUtils.applicationContext = applicationContext; + } + + /** + * 获取对象 + * + * @param name + * @return Object 一个以所给名字注册的bean的实例 + * @throws BeansException + * + */ + @SuppressWarnings("unchecked") + public static T getBean(String name) throws BeansException + { + return (T) beanFactory.getBean(name); + } + + /** + * 获取类型为requiredType的对象 + * + * @param clz + * @return + * @throws BeansException + * + */ + public static T getBean(Class clz) throws BeansException + { + T result = (T) beanFactory.getBean(clz); + return result; + } + + /** + * 如果BeanFactory包含一个与所给名称匹配的bean定义,则返回true + * + * @param name + * @return boolean + */ + public static boolean containsBean(String name) + { + return beanFactory.containsBean(name); + } + + /** + * 判断以给定名字注册的bean定义是一个singleton还是一个prototype。 如果与给定名字相应的bean定义没有被找到,将会抛出一个异常(NoSuchBeanDefinitionException) + * + * @param name + * @return boolean + * @throws NoSuchBeanDefinitionException + * + */ + public static boolean isSingleton(String name) throws NoSuchBeanDefinitionException + { + return beanFactory.isSingleton(name); + } + + /** + * @param name + * @return Class 注册对象的类型 + * @throws NoSuchBeanDefinitionException + * + */ + public static Class getType(String name) throws NoSuchBeanDefinitionException + { + return beanFactory.getType(name); + } + + /** + * 如果给定的bean名字在bean定义中有别名,则返回这些别名 + * + * @param name + * @return + * @throws NoSuchBeanDefinitionException + * + */ + public static String[] getAliases(String name) throws NoSuchBeanDefinitionException + { + return beanFactory.getAliases(name); + } + + /** + * 获取aop代理对象 + * + * @param invoker + * @return + */ + @SuppressWarnings("unchecked") + public static T getAopProxy(T invoker) + { + return (T) AopContext.currentProxy(); + } + + /** + * 获取当前的环境配置,无配置返回null + * + * @return 当前的环境配置 + */ + public static String[] getActiveProfiles() + { + return applicationContext.getEnvironment().getActiveProfiles(); + } + + /** + * 获取当前的环境配置,当有多个环境配置时,只获取第一个 + * + * @return 当前的环境配置 + */ + public static String getActiveProfile() + { + final String[] activeProfiles = getActiveProfiles(); + return StringUtils.isNotEmpty(activeProfiles) ? activeProfiles[0] : null; + } +} diff --git a/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/utils/sql/SqlUtil.java b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/utils/sql/SqlUtil.java new file mode 100644 index 0000000..a198946 --- /dev/null +++ b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/utils/sql/SqlUtil.java @@ -0,0 +1,37 @@ +package com.ruoyi.common.utils.sql; + +import com.ruoyi.common.exception.UtilException; +import com.ruoyi.common.utils.StringUtils; + +/** + * sql操作工具类 + * + * @author ruoyi + */ +public class SqlUtil +{ + /** + * 仅支持字母、数字、下划线、空格、逗号、小数点(支持多个字段排序) + */ + public static String SQL_PATTERN = "[a-zA-Z0-9_\\ \\,\\.]+"; + + /** + * 检查字符,防止注入绕过 + */ + public static String escapeOrderBySql(String value) + { + if (StringUtils.isNotEmpty(value) && !isValidOrderBySql(value)) + { + throw new UtilException("参数不符合规范,不能进行查询"); + } + return value; + } + + /** + * 验证 order by 语法是否符合规范 + */ + public static boolean isValidOrderBySql(String value) + { + return value.matches(SQL_PATTERN); + } +} diff --git a/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/utils/uuid/IdUtils.java b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/utils/uuid/IdUtils.java new file mode 100644 index 0000000..2c84427 --- /dev/null +++ b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/utils/uuid/IdUtils.java @@ -0,0 +1,49 @@ +package com.ruoyi.common.utils.uuid; + +/** + * ID生成器工具类 + * + * @author ruoyi + */ +public class IdUtils +{ + /** + * 获取随机UUID + * + * @return 随机UUID + */ + public static String randomUUID() + { + return UUID.randomUUID().toString(); + } + + /** + * 简化的UUID,去掉了横线 + * + * @return 简化的UUID,去掉了横线 + */ + public static String simpleUUID() + { + return UUID.randomUUID().toString(true); + } + + /** + * 获取随机UUID,使用性能更好的ThreadLocalRandom生成UUID + * + * @return 随机UUID + */ + public static String fastUUID() + { + return UUID.fastUUID().toString(); + } + + /** + * 简化的UUID,去掉了横线,使用性能更好的ThreadLocalRandom生成UUID + * + * @return 简化的UUID,去掉了横线 + */ + public static String fastSimpleUUID() + { + return UUID.fastUUID().toString(true); + } +} diff --git a/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/utils/uuid/UUID.java b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/utils/uuid/UUID.java new file mode 100644 index 0000000..062d633 --- /dev/null +++ b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/utils/uuid/UUID.java @@ -0,0 +1,484 @@ +package com.ruoyi.common.utils.uuid; + +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; +import java.security.SecureRandom; +import java.util.Random; +import java.util.concurrent.ThreadLocalRandom; +import com.ruoyi.common.exception.UtilException; + +/** + * 提供通用唯一识别码(universally unique identifier)(UUID)实现 + * + * @author ruoyi + */ +public final class UUID implements java.io.Serializable, Comparable +{ + private static final long serialVersionUID = -1185015143654744140L; + + /** + * SecureRandom 的单例 + * + */ + private static class Holder + { + static final SecureRandom numberGenerator = getSecureRandom(); + } + + /** 此UUID的最高64有效位 */ + private final long mostSigBits; + + /** 此UUID的最低64有效位 */ + private final long leastSigBits; + + /** + * 私有构造 + * + * @param data 数据 + */ + private UUID(byte[] data) + { + long msb = 0; + long lsb = 0; + assert data.length == 16 : "data must be 16 bytes in length"; + for (int i = 0; i < 8; i++) + { + msb = (msb << 8) | (data[i] & 0xff); + } + for (int i = 8; i < 16; i++) + { + lsb = (lsb << 8) | (data[i] & 0xff); + } + this.mostSigBits = msb; + this.leastSigBits = lsb; + } + + /** + * 使用指定的数据构造新的 UUID。 + * + * @param mostSigBits 用于 {@code UUID} 的最高有效 64 位 + * @param leastSigBits 用于 {@code UUID} 的最低有效 64 位 + */ + public UUID(long mostSigBits, long leastSigBits) + { + this.mostSigBits = mostSigBits; + this.leastSigBits = leastSigBits; + } + + /** + * 获取类型 4(伪随机生成的)UUID 的静态工厂。 使用加密的本地线程伪随机数生成器生成该 UUID。 + * + * @return 随机生成的 {@code UUID} + */ + public static UUID fastUUID() + { + return randomUUID(false); + } + + /** + * 获取类型 4(伪随机生成的)UUID 的静态工厂。 使用加密的强伪随机数生成器生成该 UUID。 + * + * @return 随机生成的 {@code UUID} + */ + public static UUID randomUUID() + { + return randomUUID(true); + } + + /** + * 获取类型 4(伪随机生成的)UUID 的静态工厂。 使用加密的强伪随机数生成器生成该 UUID。 + * + * @param isSecure 是否使用{@link SecureRandom}如果是可以获得更安全的随机码,否则可以得到更好的性能 + * @return 随机生成的 {@code UUID} + */ + public static UUID randomUUID(boolean isSecure) + { + final Random ng = isSecure ? Holder.numberGenerator : getRandom(); + + byte[] randomBytes = new byte[16]; + ng.nextBytes(randomBytes); + randomBytes[6] &= 0x0f; /* clear version */ + randomBytes[6] |= 0x40; /* set to version 4 */ + randomBytes[8] &= 0x3f; /* clear variant */ + randomBytes[8] |= 0x80; /* set to IETF variant */ + return new UUID(randomBytes); + } + + /** + * 根据指定的字节数组获取类型 3(基于名称的)UUID 的静态工厂。 + * + * @param name 用于构造 UUID 的字节数组。 + * + * @return 根据指定数组生成的 {@code UUID} + */ + public static UUID nameUUIDFromBytes(byte[] name) + { + MessageDigest md; + try + { + md = MessageDigest.getInstance("MD5"); + } + catch (NoSuchAlgorithmException nsae) + { + throw new InternalError("MD5 not supported"); + } + byte[] md5Bytes = md.digest(name); + md5Bytes[6] &= 0x0f; /* clear version */ + md5Bytes[6] |= 0x30; /* set to version 3 */ + md5Bytes[8] &= 0x3f; /* clear variant */ + md5Bytes[8] |= 0x80; /* set to IETF variant */ + return new UUID(md5Bytes); + } + + /** + * 根据 {@link #toString()} 方法中描述的字符串标准表示形式创建{@code UUID}。 + * + * @param name 指定 {@code UUID} 字符串 + * @return 具有指定值的 {@code UUID} + * @throws IllegalArgumentException 如果 name 与 {@link #toString} 中描述的字符串表示形式不符抛出此异常 + * + */ + public static UUID fromString(String name) + { + String[] components = name.split("-"); + if (components.length != 5) + { + throw new IllegalArgumentException("Invalid UUID string: " + name); + } + for (int i = 0; i < 5; i++) + { + components[i] = "0x" + components[i]; + } + + long mostSigBits = Long.decode(components[0]).longValue(); + mostSigBits <<= 16; + mostSigBits |= Long.decode(components[1]).longValue(); + mostSigBits <<= 16; + mostSigBits |= Long.decode(components[2]).longValue(); + + long leastSigBits = Long.decode(components[3]).longValue(); + leastSigBits <<= 48; + leastSigBits |= Long.decode(components[4]).longValue(); + + return new UUID(mostSigBits, leastSigBits); + } + + /** + * 返回此 UUID 的 128 位值中的最低有效 64 位。 + * + * @return 此 UUID 的 128 位值中的最低有效 64 位。 + */ + public long getLeastSignificantBits() + { + return leastSigBits; + } + + /** + * 返回此 UUID 的 128 位值中的最高有效 64 位。 + * + * @return 此 UUID 的 128 位值中最高有效 64 位。 + */ + public long getMostSignificantBits() + { + return mostSigBits; + } + + /** + * 与此 {@code UUID} 相关联的版本号. 版本号描述此 {@code UUID} 是如何生成的。 + *

+ * 版本号具有以下含意: + *

    + *
  • 1 基于时间的 UUID + *
  • 2 DCE 安全 UUID + *
  • 3 基于名称的 UUID + *
  • 4 随机生成的 UUID + *
+ * + * @return 此 {@code UUID} 的版本号 + */ + public int version() + { + // Version is bits masked by 0x000000000000F000 in MS long + return (int) ((mostSigBits >> 12) & 0x0f); + } + + /** + * 与此 {@code UUID} 相关联的变体号。变体号描述 {@code UUID} 的布局。 + *

+ * 变体号具有以下含意: + *

    + *
  • 0 为 NCS 向后兼容保留 + *
  • 2 IETF RFC 4122(Leach-Salz), 用于此类 + *
  • 6 保留,微软向后兼容 + *
  • 7 保留供以后定义使用 + *
+ * + * @return 此 {@code UUID} 相关联的变体号 + */ + public int variant() + { + // This field is composed of a varying number of bits. + // 0 - - Reserved for NCS backward compatibility + // 1 0 - The IETF aka Leach-Salz variant (used by this class) + // 1 1 0 Reserved, Microsoft backward compatibility + // 1 1 1 Reserved for future definition. + return (int) ((leastSigBits >>> (64 - (leastSigBits >>> 62))) & (leastSigBits >> 63)); + } + + /** + * 与此 UUID 相关联的时间戳值。 + * + *

+ * 60 位的时间戳值根据此 {@code UUID} 的 time_low、time_mid 和 time_hi 字段构造。
+ * 所得到的时间戳以 100 毫微秒为单位,从 UTC(通用协调时间) 1582 年 10 月 15 日零时开始。 + * + *

+ * 时间戳值仅在在基于时间的 UUID(其 version 类型为 1)中才有意义。
+ * 如果此 {@code UUID} 不是基于时间的 UUID,则此方法抛出 UnsupportedOperationException。 + * + * @throws UnsupportedOperationException 如果此 {@code UUID} 不是 version 为 1 的 UUID。 + */ + public long timestamp() throws UnsupportedOperationException + { + checkTimeBase(); + return (mostSigBits & 0x0FFFL) << 48// + | ((mostSigBits >> 16) & 0x0FFFFL) << 32// + | mostSigBits >>> 32; + } + + /** + * 与此 UUID 相关联的时钟序列值。 + * + *

+ * 14 位的时钟序列值根据此 UUID 的 clock_seq 字段构造。clock_seq 字段用于保证在基于时间的 UUID 中的时间唯一性。 + *

+ * {@code clockSequence} 值仅在基于时间的 UUID(其 version 类型为 1)中才有意义。 如果此 UUID 不是基于时间的 UUID,则此方法抛出 + * UnsupportedOperationException。 + * + * @return 此 {@code UUID} 的时钟序列 + * + * @throws UnsupportedOperationException 如果此 UUID 的 version 不为 1 + */ + public int clockSequence() throws UnsupportedOperationException + { + checkTimeBase(); + return (int) ((leastSigBits & 0x3FFF000000000000L) >>> 48); + } + + /** + * 与此 UUID 相关的节点值。 + * + *

+ * 48 位的节点值根据此 UUID 的 node 字段构造。此字段旨在用于保存机器的 IEEE 802 地址,该地址用于生成此 UUID 以保证空间唯一性。 + *

+ * 节点值仅在基于时间的 UUID(其 version 类型为 1)中才有意义。
+ * 如果此 UUID 不是基于时间的 UUID,则此方法抛出 UnsupportedOperationException。 + * + * @return 此 {@code UUID} 的节点值 + * + * @throws UnsupportedOperationException 如果此 UUID 的 version 不为 1 + */ + public long node() throws UnsupportedOperationException + { + checkTimeBase(); + return leastSigBits & 0x0000FFFFFFFFFFFFL; + } + + /** + * 返回此{@code UUID} 的字符串表现形式。 + * + *

+ * UUID 的字符串表示形式由此 BNF 描述: + * + *

+     * {@code
+     * UUID                   = ----
+     * time_low               = 4*
+     * time_mid               = 2*
+     * time_high_and_version  = 2*
+     * variant_and_sequence   = 2*
+     * node                   = 6*
+     * hexOctet               = 
+     * hexDigit               = [0-9a-fA-F]
+     * }
+     * 
+ * + * + * + * @return 此{@code UUID} 的字符串表现形式 + * @see #toString(boolean) + */ + @Override + public String toString() + { + return toString(false); + } + + /** + * 返回此{@code UUID} 的字符串表现形式。 + * + *

+ * UUID 的字符串表示形式由此 BNF 描述: + * + *

+     * {@code
+     * UUID                   = ----
+     * time_low               = 4*
+     * time_mid               = 2*
+     * time_high_and_version  = 2*
+     * variant_and_sequence   = 2*
+     * node                   = 6*
+     * hexOctet               = 
+     * hexDigit               = [0-9a-fA-F]
+     * }
+     * 
+ * + * + * + * @param isSimple 是否简单模式,简单模式为不带'-'的UUID字符串 + * @return 此{@code UUID} 的字符串表现形式 + */ + public String toString(boolean isSimple) + { + final StringBuilder builder = new StringBuilder(isSimple ? 32 : 36); + // time_low + builder.append(digits(mostSigBits >> 32, 8)); + if (false == isSimple) + { + builder.append('-'); + } + // time_mid + builder.append(digits(mostSigBits >> 16, 4)); + if (false == isSimple) + { + builder.append('-'); + } + // time_high_and_version + builder.append(digits(mostSigBits, 4)); + if (false == isSimple) + { + builder.append('-'); + } + // variant_and_sequence + builder.append(digits(leastSigBits >> 48, 4)); + if (false == isSimple) + { + builder.append('-'); + } + // node + builder.append(digits(leastSigBits, 12)); + + return builder.toString(); + } + + /** + * 返回此 UUID 的哈希码。 + * + * @return UUID 的哈希码值。 + */ + @Override + public int hashCode() + { + long hilo = mostSigBits ^ leastSigBits; + return ((int) (hilo >> 32)) ^ (int) hilo; + } + + /** + * 将此对象与指定对象比较。 + *

+ * 当且仅当参数不为 {@code null}、而是一个 UUID 对象、具有与此 UUID 相同的 varriant、包含相同的值(每一位均相同)时,结果才为 {@code true}。 + * + * @param obj 要与之比较的对象 + * + * @return 如果对象相同,则返回 {@code true};否则返回 {@code false} + */ + @Override + public boolean equals(Object obj) + { + if ((null == obj) || (obj.getClass() != UUID.class)) + { + return false; + } + UUID id = (UUID) obj; + return (mostSigBits == id.mostSigBits && leastSigBits == id.leastSigBits); + } + + // Comparison Operations + + /** + * 将此 UUID 与指定的 UUID 比较。 + * + *

+ * 如果两个 UUID 不同,且第一个 UUID 的最高有效字段大于第二个 UUID 的对应字段,则第一个 UUID 大于第二个 UUID。 + * + * @param val 与此 UUID 比较的 UUID + * + * @return 在此 UUID 小于、等于或大于 val 时,分别返回 -1、0 或 1。 + * + */ + @Override + public int compareTo(UUID val) + { + // The ordering is intentionally set up so that the UUIDs + // can simply be numerically compared as two numbers + return (this.mostSigBits < val.mostSigBits ? -1 : // + (this.mostSigBits > val.mostSigBits ? 1 : // + (this.leastSigBits < val.leastSigBits ? -1 : // + (this.leastSigBits > val.leastSigBits ? 1 : // + 0)))); + } + + // ------------------------------------------------------------------------------------------------------------------- + // Private method start + /** + * 返回指定数字对应的hex值 + * + * @param val 值 + * @param digits 位 + * @return 值 + */ + private static String digits(long val, int digits) + { + long hi = 1L << (digits * 4); + return Long.toHexString(hi | (val & (hi - 1))).substring(1); + } + + /** + * 检查是否为time-based版本UUID + */ + private void checkTimeBase() + { + if (version() != 1) + { + throw new UnsupportedOperationException("Not a time-based UUID"); + } + } + + /** + * 获取{@link SecureRandom},类提供加密的强随机数生成器 (RNG) + * + * @return {@link SecureRandom} + */ + public static SecureRandom getSecureRandom() + { + try + { + return SecureRandom.getInstance("SHA1PRNG"); + } + catch (NoSuchAlgorithmException e) + { + throw new UtilException(e); + } + } + + /** + * 获取随机数生成器对象
+ * ThreadLocalRandom是JDK 7之后提供并发产生随机数,能够解决多个线程发生的竞争争夺。 + * + * @return {@link ThreadLocalRandom} + */ + public static ThreadLocalRandom getRandom() + { + return ThreadLocalRandom.current(); + } +} diff --git a/ruoyi-base-support/ruoyi-data-rule/pom.xml b/ruoyi-base-support/ruoyi-data-rule/pom.xml new file mode 100644 index 0000000..c7e4dd2 --- /dev/null +++ b/ruoyi-base-support/ruoyi-data-rule/pom.xml @@ -0,0 +1,48 @@ + + + + ruoyi-base-support + com.ruoyi + 3.7.0 + + 4.0.0 + + ruoyi-data-rule + + + 17 + 17 + + + + org.springframework.boot + spring-boot-starter-web + + + com.baomidou + mybatis-plus-boot-starter + + + com.alibaba + druid-spring-boot-starter + + + com.ibeetl + beetl-framework-starter + + + org.apache.commons + commons-text + + + org.projectlombok + lombok + + + com.ruoyi + ruoyi-common + + + diff --git a/ruoyi-base-support/ruoyi-data-rule/src/main/java/com/ruoyi/datarule/config/DataScopeConfiguration.java b/ruoyi-base-support/ruoyi-data-rule/src/main/java/com/ruoyi/datarule/config/DataScopeConfiguration.java new file mode 100644 index 0000000..d7d508c --- /dev/null +++ b/ruoyi-base-support/ruoyi-data-rule/src/main/java/com/ruoyi/datarule/config/DataScopeConfiguration.java @@ -0,0 +1,43 @@ +package com.ruoyi.datarule.config; + +import com.ruoyi.datarule.handler.DataRuleHandler; +import com.ruoyi.datarule.handler.DataRuleSqlHandler; +import com.ruoyi.datarule.interceptor.DataRuleInterceptor; +import lombok.AllArgsConstructor; +import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.jdbc.core.JdbcTemplate; + + +@Configuration +@AllArgsConstructor +public class DataScopeConfiguration { + + private JdbcTemplate jdbcTemplate; + + @Bean + @ConditionalOnMissingBean(DataRuleHandler.class) + public DataRuleHandler dataRuleHandler() { + DataRuleHandler dataRuleHandler = new DataRuleHandler(jdbcTemplate); + dataRuleHandler.init(); + return dataRuleHandler; + } + + + @Bean + @ConditionalOnBean(DataRuleHandler.class) + @ConditionalOnMissingBean(DataRuleSqlHandler.class) + public DataRuleSqlHandler dataScopeHandler(DataRuleHandler dataRuleHandler) { + return new DataRuleSqlHandler(dataRuleHandler); + } + + @Bean + @ConditionalOnBean({DataRuleSqlHandler.class, DataRuleHandler.class}) + @ConditionalOnMissingBean(DataRuleInterceptor.class) + public DataRuleInterceptor interceptor(DataRuleSqlHandler dataRuleSqlHandler, DataRuleHandler dataRuleHandler) { + return new DataRuleInterceptor(dataRuleSqlHandler, dataRuleHandler); + } + +} diff --git a/ruoyi-base-support/ruoyi-data-rule/src/main/java/com/ruoyi/datarule/constant/DataScopeConstant.java b/ruoyi-base-support/ruoyi-data-rule/src/main/java/com/ruoyi/datarule/constant/DataScopeConstant.java new file mode 100644 index 0000000..b2e1c4c --- /dev/null +++ b/ruoyi-base-support/ruoyi-data-rule/src/main/java/com/ruoyi/datarule/constant/DataScopeConstant.java @@ -0,0 +1,9 @@ +package com.ruoyi.datarule.constant; + +public interface DataScopeConstant { + + String DEFAULT_FIELD = "deptId"; + String DEFAULT_COLUMN = "dept_id"; + String DEFAULT_TABLE = "sys_dept"; + +} diff --git a/ruoyi-base-support/ruoyi-data-rule/src/main/java/com/ruoyi/datarule/handler/DataRuleHandler.java b/ruoyi-base-support/ruoyi-data-rule/src/main/java/com/ruoyi/datarule/handler/DataRuleHandler.java new file mode 100644 index 0000000..50559ad --- /dev/null +++ b/ruoyi-base-support/ruoyi-data-rule/src/main/java/com/ruoyi/datarule/handler/DataRuleHandler.java @@ -0,0 +1,159 @@ +package com.ruoyi.datarule.handler; + +import com.ruoyi.common.core.domain.entity.SysRole; +import com.ruoyi.common.core.domain.entity.SysUser; +import com.ruoyi.common.utils.StringUtils; +import com.ruoyi.common.utils.bean.BeanUtils; +import com.ruoyi.datarule.model.DataRuleModel; +import com.ruoyi.datarule.model.RoleDataRuleModel; +import com.ruoyi.datarule.model.TreeEntityModel; +import lombok.RequiredArgsConstructor; +import org.springframework.jdbc.core.BeanPropertyRowMapper; +import org.springframework.jdbc.core.JdbcTemplate; + +import java.beans.IntrospectionException; +import java.lang.reflect.InvocationTargetException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +@RequiredArgsConstructor +public class DataRuleHandler { + + + HashMap> roleDataRuleModelHashMap = new HashMap<>(); + HashMap dataRuleModelHashMap = new HashMap<>(); + HashMap> userModelHashMap = new HashMap<>(); + HashMap> treeEntityModelMap = new HashMap<>(); + + private final JdbcTemplate jdbcTemplate; + + public void init() { + List list = jdbcTemplate.query("select * from sys_data_rule where del_flag = ?", new Object[]{0}, new BeanPropertyRowMapper<>(DataRuleModel.class)); + list.forEach(item -> { + dataRuleModelHashMap.put(item.getScopeClass(), item); + if (StringUtils.isEmpty(item.getTableName())) { + return; + } + List treeEntityModelList = jdbcTemplate.query(String.format("select * from %s where del_flag = ?", item.getTableName()), new Object[]{0}, new BeanPropertyRowMapper<>(TreeEntityModel.class)); + treeEntityModelMap.put(item.getTableName(), treeEntityModelList); + }); + + refreshRole(); + } + + public DataRuleModel getDataRuleModel(String mapperId) { + if (dataRuleModelHashMap.containsKey(mapperId)) { + return dataRuleModelHashMap.get(mapperId); + } + return null; + } + + public List getChildren(String tableName, String id) { + if (!treeEntityModelMap.containsKey(tableName)) { + List treeEntityModelList = jdbcTemplate.query(String.format("select * from %s where del_flag = ?", tableName), new Object[]{0}, new BeanPropertyRowMapper<>(TreeEntityModel.class)); + treeEntityModelMap.put(tableName, treeEntityModelList); + } + List idList = new ArrayList<>(); + List treeEntityModelList = treeEntityModelMap.get(tableName); + treeEntityModelList.forEach(item -> { + if (item.getId().equals(id) || (!StringUtils.isEmpty(item.getAncestors()) && item.getAncestors().contains(id + ","))) { + idList.add(item.getId()); + } + }); + return idList; + } + + + public void refreshTreeEntity(String tableName) { + List treeEntityModelList = jdbcTemplate.query(String.format("select * from %s where del_flag = ?", tableName), new Object[]{0}, new BeanPropertyRowMapper<>(TreeEntityModel.class)); + treeEntityModelMap.put(tableName, treeEntityModelList); + } + + public void refreshRole() { + List roleDataRuleModelList = jdbcTemplate.query("select * from sys_role_data_rule", new Object[]{}, new BeanPropertyRowMapper<>(RoleDataRuleModel.class)); + roleDataRuleModelHashMap.clear(); + roleDataRuleModelList.forEach(item -> { + if (!roleDataRuleModelHashMap.containsKey(item.getRoleId())) { + roleDataRuleModelHashMap.put(item.getRoleId(), new ArrayList<>()); + } + roleDataRuleModelHashMap.get(item.getRoleId()).add(item.getDataRuleId()); + }); + } + + public void refreshDataRule(String id) { + DataRuleModel dataRuleModel = jdbcTemplate.queryForObject("select * from sys_data_rule where id = ?", new Object[]{id}, new BeanPropertyRowMapper<>(DataRuleModel.class)); + for (Map.Entry entry : dataRuleModelHashMap.entrySet()) { + if (entry.getValue().getId().equals(id)) { + dataRuleModelHashMap.remove(entry.getKey()); + break; + } + } + dataRuleModelHashMap.put(dataRuleModel.getScopeClass(), dataRuleModel); + if (StringUtils.isEmpty(dataRuleModel.getTableName())) { + return; + } + List treeEntityModelList = jdbcTemplate.query(String.format("select * from %s where del_flag = ?", dataRuleModel.getTableName()), new Object[]{0}, new BeanPropertyRowMapper<>(TreeEntityModel.class)); + treeEntityModelMap.put(dataRuleModel.getTableName(), treeEntityModelList); + + } + + public void deleteDataRule(String id) { + for (Map.Entry entry : dataRuleModelHashMap.entrySet()) { + if (entry.getValue().getId().equals(id)) { + dataRuleModelHashMap.remove(entry.getKey()); + break; + } + } + } + + public DataRuleModel getDataRule(String mapperId, List roleList) { + for (SysRole sysRole : roleList) { + String roleId = sysRole.getRoleId().toString(); + DataRuleModel dataRuleModel = getDataRuleModel(mapperId); + if (dataRuleModel == null) { + return null; + } + if (!roleDataRuleModelHashMap.containsKey(roleId)) { + //如果找不到,刷新角色权限 + refreshRole(); + //如果还不找不到,返回null + if (!roleDataRuleModelHashMap.containsKey(roleId)) { + continue; + } + } + boolean isMatch = roleDataRuleModelHashMap.get(roleId).stream().anyMatch(dataRuleModel.getId()::contains); + if (isMatch) { + return dataRuleModel; + } + } + + return null; + + } + + public void refreshUser(String id) { + SysUser userModel = jdbcTemplate.queryForObject("select * from sys_user where user_id = ?", new Object[]{id}, new BeanPropertyRowMapper<>(SysUser.class)); + try { + Map map = BeanUtils.convertBean(userModel); + userModelHashMap.put(id, map); + } catch (IntrospectionException e) { + e.printStackTrace(); + } catch (IllegalAccessException e) { + e.printStackTrace(); + } catch (InvocationTargetException e) { + e.printStackTrace(); + } + } + + public Map getUser(Long id) { + if (!userModelHashMap.containsKey(id)) { + refreshUser("" + id); + } + if (userModelHashMap.containsKey(id)) { + return userModelHashMap.get(id); + } + return null; + } +} diff --git a/ruoyi-base-support/ruoyi-data-rule/src/main/java/com/ruoyi/datarule/handler/DataRuleSqlHandler.java b/ruoyi-base-support/ruoyi-data-rule/src/main/java/com/ruoyi/datarule/handler/DataRuleSqlHandler.java new file mode 100644 index 0000000..f76f3d3 --- /dev/null +++ b/ruoyi-base-support/ruoyi-data-rule/src/main/java/com/ruoyi/datarule/handler/DataRuleSqlHandler.java @@ -0,0 +1,129 @@ +package com.ruoyi.datarule.handler; + +import com.alibaba.druid.DbType; +import com.alibaba.druid.sql.SQLUtils; +import com.alibaba.druid.sql.ast.SQLLimit; +import com.alibaba.druid.sql.ast.statement.SQLSelectQueryBlock; +import com.alibaba.druid.sql.ast.statement.SQLSelectStatement; +import com.alibaba.druid.util.JdbcConstants; +import com.ruoyi.common.core.domain.model.LoginUser; +import com.ruoyi.common.utils.StringUtils; +import com.ruoyi.datarule.model.DataRuleModel; +import lombok.RequiredArgsConstructor; +import org.apache.commons.text.StringEscapeUtils; +import org.beetl.core.Configuration; +import org.beetl.core.GroupTemplate; +import org.beetl.core.Template; +import org.beetl.core.resource.StringTemplateResourceLoader; +import org.beetl.core.statement.ErrorGrammarProgram; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Value; + +import java.io.IOException; +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +@RequiredArgsConstructor +public class DataRuleSqlHandler { + protected Logger logger = LoggerFactory.getLogger(getClass()); + + private static GroupTemplate groupTemplate; + + @Value("${spring.datasource.driverClassName}") + String driverClassName; + + static { + StringTemplateResourceLoader resourceLoader = new StringTemplateResourceLoader(); + Configuration configuration = null; + try { + configuration = Configuration.defaultConfiguration(); + } catch (IOException e) { + e.printStackTrace(); + } + groupTemplate = new GroupTemplate(resourceLoader, configuration); + } + + + private final DataRuleHandler dataRuleHandler; + + private DbType getDataSourceType() { + if (driverClassName.contains("mysql")) { + return JdbcConstants.MYSQL; + } else if (driverClassName.contains("sqlserver")) { + return JdbcConstants.SQL_SERVER; + } else if (driverClassName.contains("oracle")) { + return JdbcConstants.ORACLE; + } else { + return JdbcConstants.MYSQL; + } + } + + public String sqlCondition(DataRuleModel dataScope, LoginUser principal, String originalSql) { + + //判断数据权限类型并组装对应Sql + Integer scopeRule = Objects.requireNonNull(dataScope).getScopeType(); + if (DataRuleModel.ALL == scopeRule) { + return null; + } + Map userMap = dataRuleHandler.getUser(principal.getUserId()); + SQLSelectStatement selectStmt = (SQLSelectStatement) SQLUtils.parseSingleStatement(originalSql, getDataSourceType()); + SQLSelectQueryBlock mySqlSelectQueryBlock = (SQLSelectQueryBlock) selectStmt.getSelect().getQuery(); + SQLLimit limit = mySqlSelectQueryBlock.getLimit(); + mySqlSelectQueryBlock.setLimit(null); + String tempSql = selectStmt.toString(); + String id; + String result = ""; + if (DataRuleModel.CUSTOM == scopeRule) { + Template template = groupTemplate.getTemplate(StringEscapeUtils.unescapeHtml4(dataScope.getScopeValue())); + if (template.program instanceof ErrorGrammarProgram) { + logger.info(((ErrorGrammarProgram) template.program).getException().detailCode); + } + userMap.forEach(template::binding); + String whereSql = template.render(); + result = String.format(" select %s from (%s) scope " + whereSql, dataScope.getScopeField(), tempSql); + } else if (DataRuleModel.OWN == scopeRule) { + String whereSql = "where scope.%s = '%s'"; + id = principal.getUserId().toString(); + result = String.format(" select %s from (%s) scope " + whereSql, dataScope.getScopeField(), tempSql, dataScope.getScopeColumn(), id); + } else if (DataRuleModel.OWN_ORG == scopeRule) { + id = userMap.get(dataScope.getUserEntityField()).toString(); + if (StringUtils.isEmpty(id)) { + logger.error(String.format("DataRuleSqlHandler OWN_ORG error id is not exist userId:%s,UserColumn:%s", principal.getUserId(), dataScope.getUserEntityField())); + return null; + } + result = String.format("select %s from (%s) scope, %s a, sys_user sysu where a.id = sysu.%s" + + " and sysu.id = scope.%s and a.id = '%s'", + dataScope.getScopeField(), tempSql, + dataScope.getTableName(), + dataScope.getUserColumn(), dataScope.getScopeColumn(), + id); + } else if (DataRuleModel.OWN_ORG_CHILDREN == scopeRule) { + id = userMap.get(dataScope.getUserEntityField()).toString(); + if (StringUtils.isEmpty(id)) { + logger.error(String.format("DataRuleSqlHandler OWN_ORG_CHILDREN error id is not exist userId:%s,UserColumn:%s", principal.getUserId(), dataScope.getUserEntityField())); + return null; + } + List ids = new ArrayList<>(); + ids.add(id); + List deptIdList = dataRuleHandler.getChildren(dataScope.getTableName(), id); + ids.addAll(deptIdList); + id = StringUtils.join(ids, "','"); + result = String.format("select %s from (%s) scope, %s a, sys_user sysu where a.id = sysu.%s" + + " and sysu.id = scope.%s and a.id in ('%s')", + dataScope.getScopeField(), tempSql, + dataScope.getTableName(), + dataScope.getUserColumn(), dataScope.getScopeColumn(), + id); + } + SQLSelectStatement selectStmtResult = (SQLSelectStatement) SQLUtils.parseSingleStatement(result, getDataSourceType()); + SQLSelectQueryBlock mySqlSelectQueryBlockResult = (SQLSelectQueryBlock) selectStmtResult.getSelect().getQuery(); + mySqlSelectQueryBlockResult.setLimit(limit); + logger.info(String.format("result sql: %s", selectStmtResult)); + return selectStmtResult.toString(); + } + +} diff --git a/ruoyi-base-support/ruoyi-data-rule/src/main/java/com/ruoyi/datarule/interceptor/DataRuleInterceptor.java b/ruoyi-base-support/ruoyi-data-rule/src/main/java/com/ruoyi/datarule/interceptor/DataRuleInterceptor.java new file mode 100644 index 0000000..baf236a --- /dev/null +++ b/ruoyi-base-support/ruoyi-data-rule/src/main/java/com/ruoyi/datarule/interceptor/DataRuleInterceptor.java @@ -0,0 +1,108 @@ +package com.ruoyi.datarule.interceptor; + +import com.baomidou.mybatisplus.core.toolkit.PluginUtils; +import com.baomidou.mybatisplus.extension.handlers.AbstractSqlParserHandler; +import com.ruoyi.common.core.domain.model.LoginUser; +import com.ruoyi.common.utils.SecurityUtils; +import com.ruoyi.common.utils.StringUtils; +import com.ruoyi.common.utils.bean.BeanUtils; +import com.ruoyi.datarule.handler.DataRuleHandler; +import com.ruoyi.datarule.handler.DataRuleSqlHandler; +import com.ruoyi.datarule.model.DataRuleModel; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.apache.ibatis.executor.statement.StatementHandler; +import org.apache.ibatis.mapping.BoundSql; +import org.apache.ibatis.mapping.MappedStatement; +import org.apache.ibatis.mapping.SqlCommandType; +import org.apache.ibatis.mapping.StatementType; +import org.apache.ibatis.plugin.*; +import org.apache.ibatis.reflection.MetaObject; +import org.apache.ibatis.reflection.SystemMetaObject; + +import java.sql.Connection; +import java.util.Properties; + + +@Slf4j +@RequiredArgsConstructor +@Intercepts({@Signature(type = StatementHandler.class, method = "prepare", args = {Connection.class, Integer.class})}) +public class DataRuleInterceptor extends AbstractSqlParserHandler implements Interceptor { + + + private final DataRuleSqlHandler dataRuleSqlHandler; + private final DataRuleHandler dataRuleHandler; + + @Override + public Object intercept(Invocation invocation) throws Throwable { + //未取到用户则放行 + LoginUser principal = SecurityUtils.getLoginUser(); + if (principal == null) { + return invocation.proceed(); + } + + StatementHandler statementHandler = PluginUtils.realTarget(invocation.getTarget()); + MetaObject metaObject = SystemMetaObject.forObject(statementHandler); + this.sqlParser(metaObject); + + //非SELECT操作放行 + MappedStatement mappedStatement = (MappedStatement) metaObject.getValue("delegate.mappedStatement"); + if (SqlCommandType.SELECT != mappedStatement.getSqlCommandType() + || StatementType.CALLABLE == mappedStatement.getStatementType()) { + return invocation.proceed(); + } + + BoundSql boundSql = (BoundSql) metaObject.getValue("delegate.boundSql"); + String originalSql = boundSql.getSql(); + + //注解为空并且数据权限方法名未匹配到,则放行 + String mapperId = mappedStatement.getId(); + mapperId = mapperId.replace("_mpCount",""); + DataRuleModel dataScope = dataRuleHandler.getDataRule(mapperId, principal.getUser().getRoles());; + //如果还不行,那就只有不处理了 + if (dataScope == null) { + return invocation.proceed(); + } + // 如果包含_mpCount,说明是分页,也需要过滤 + if (mappedStatement.getId().contains("_mpCount")){ + dataScope = BeanUtils.clone(dataScope); + dataScope.setScopeField("COUNT(*)"); + originalSql = originalSql.replace("COUNT(*)", "*"); + } + + //获取数据权限规则对应的筛选Sql + String sqlCondition = dataRuleSqlHandler.sqlCondition(dataScope, principal, originalSql); + if (StringUtils.isBlank(sqlCondition)) { + return invocation.proceed(); + } else { + metaObject.setValue("delegate.boundSql.sql", sqlCondition); + return invocation.proceed(); + } + } + + /** + * 生成拦截对象的代理 + * + * @param target 目标对象 + * @return 代理对象 + */ + @Override + public Object plugin(Object target) { + if (target instanceof StatementHandler) { + return Plugin.wrap(target, this); + } + return target; + } + + /** + * mybatis配置的属性 + * + * @param properties mybatis配置的属性 + */ + @Override + public void setProperties(Properties properties) { + + } + + +} diff --git a/ruoyi-base-support/ruoyi-data-rule/src/main/java/com/ruoyi/datarule/model/DataRuleModel.java b/ruoyi-base-support/ruoyi-data-rule/src/main/java/com/ruoyi/datarule/model/DataRuleModel.java new file mode 100644 index 0000000..e959920 --- /dev/null +++ b/ruoyi-base-support/ruoyi-data-rule/src/main/java/com/ruoyi/datarule/model/DataRuleModel.java @@ -0,0 +1,46 @@ +package com.ruoyi.datarule.model; + +import com.ruoyi.datarule.constant.DataScopeConstant; +import lombok.Data; + +import java.io.Serializable; + +@Data +public class DataRuleModel implements Serializable { + + private static final long serialVersionUID = 1L; + + + public static final int ALL = 1; // 全部 + public static final int OWN = 2; // 本人可见 + public static final int OWN_ORG = 3; // 所在机构可见 + public static final int OWN_ORG_CHILDREN = 4; // 所在机构及子级可见 + public static final int CUSTOM = 5; // 自定义 + + + private String id; + + /** + * 数据权限字段 + */ + private String scopeColumn = DataScopeConstant.DEFAULT_COLUMN; + private String userColumn; + private String userEntityField = DataScopeConstant.DEFAULT_FIELD; + + private String tableName = DataScopeConstant.DEFAULT_TABLE; //数据权限关联表名 + /** + * 数据权限规则 + */ + private Integer scopeType = ALL; + /** + * 可见字段 + */ + private String scopeField; + /** + * 数据权限规则值 + */ + private String scopeValue; + + private String scopeClass; + +} diff --git a/ruoyi-base-support/ruoyi-data-rule/src/main/java/com/ruoyi/datarule/model/RoleDataRuleModel.java b/ruoyi-base-support/ruoyi-data-rule/src/main/java/com/ruoyi/datarule/model/RoleDataRuleModel.java new file mode 100644 index 0000000..9db6bee --- /dev/null +++ b/ruoyi-base-support/ruoyi-data-rule/src/main/java/com/ruoyi/datarule/model/RoleDataRuleModel.java @@ -0,0 +1,28 @@ +package com.ruoyi.datarule.model; + +import lombok.Data; + +import java.io.Serializable; + +/** + * All rights Reserved, Designed By www.sunseagear.com + * + * @version V1.0 + * @package sys + * @title: 角色数据权限关联表控制器 + * @description: 角色数据权限关联表控制器 + * @author: 未知 + * @date: 2019-11-29 03:21:37 + * @copyright: www.sunseagear.com Inc. All rights reserved. + */ + +@Data +@SuppressWarnings("serial") +public class RoleDataRuleModel implements Serializable { + + private String id; //id + private Integer dataRuleCategory; //权限类型(1:数据权限、2:接口权限) + private String dataRuleId; //权限id + private String roleId; //角色id + +} diff --git a/ruoyi-base-support/ruoyi-data-rule/src/main/java/com/ruoyi/datarule/model/TreeEntityModel.java b/ruoyi-base-support/ruoyi-data-rule/src/main/java/com/ruoyi/datarule/model/TreeEntityModel.java new file mode 100644 index 0000000..980530c --- /dev/null +++ b/ruoyi-base-support/ruoyi-data-rule/src/main/java/com/ruoyi/datarule/model/TreeEntityModel.java @@ -0,0 +1,14 @@ +package com.ruoyi.datarule.model; + +import com.ruoyi.common.core.domain.TreeEntity; +import lombok.Data; + +/** + * 树抽象实体基类 + */ +@Data +public class TreeEntityModel extends TreeEntity { + protected String id; // 编号 + protected String name; // 资源名称 + +} diff --git a/ruoyi-base-support/ruoyi-framework/pom.xml b/ruoyi-base-support/ruoyi-framework/pom.xml new file mode 100644 index 0000000..095dc7c --- /dev/null +++ b/ruoyi-base-support/ruoyi-framework/pom.xml @@ -0,0 +1,72 @@ + + + + ruoyi-base-support + com.ruoyi + 3.7.0 + + 4.0.0 + + ruoyi-framework + + + framework框架核心 + + + + + + + org.springframework.boot + spring-boot-starter-web + + + + + org.springframework.boot + spring-boot-starter-aop + + + + + com.alibaba + druid-spring-boot-starter + + + + + com.github.penggle + kaptcha + + + javax.servlet-api + javax.servlet + + + + + + + com.github.oshi + oshi-core + + + + + com.ruoyi + ruoyi-system + + + com.ruoyi + ruoyi-tenant + + + com.baomidou + mybatis-plus-extension + + + + + diff --git a/ruoyi-base-support/ruoyi-framework/src/main/java/com/ruoyi/framework/aspectj/DataScopeAspect.java b/ruoyi-base-support/ruoyi-framework/src/main/java/com/ruoyi/framework/aspectj/DataScopeAspect.java new file mode 100644 index 0000000..1d3e2ab --- /dev/null +++ b/ruoyi-base-support/ruoyi-framework/src/main/java/com/ruoyi/framework/aspectj/DataScopeAspect.java @@ -0,0 +1,149 @@ +package com.ruoyi.framework.aspectj; + +import com.ruoyi.common.annotation.DataScope; +import com.ruoyi.common.core.domain.BaseEntity; +import com.ruoyi.common.core.domain.entity.SysRole; +import com.ruoyi.common.core.domain.entity.SysUser; +import com.ruoyi.common.core.domain.model.LoginUser; +import com.ruoyi.common.utils.SecurityUtils; +import com.ruoyi.common.utils.StringUtils; +import org.aspectj.lang.JoinPoint; +import org.aspectj.lang.annotation.Aspect; +import org.aspectj.lang.annotation.Before; +import org.springframework.stereotype.Component; + +/** + * 数据过滤处理 + * + * @author ruoyi + */ +@Aspect +@Component +public class DataScopeAspect +{ + /** + * 全部数据权限 + */ + public static final String DATA_SCOPE_ALL = "1"; + + /** + * 自定数据权限 + */ + public static final String DATA_SCOPE_CUSTOM = "2"; + + /** + * 部门数据权限 + */ + public static final String DATA_SCOPE_DEPT = "3"; + + /** + * 部门及以下数据权限 + */ + public static final String DATA_SCOPE_DEPT_AND_CHILD = "4"; + + /** + * 仅本人数据权限 + */ + public static final String DATA_SCOPE_SELF = "5"; + + /** + * 数据权限过滤关键字 + */ + public static final String DATA_SCOPE = "dataScope"; + + @Before("@annotation(controllerDataScope)") + public void doBefore(JoinPoint point, DataScope controllerDataScope) throws Throwable + { + clearDataScope(point); + handleDataScope(point, controllerDataScope); + } + + protected void handleDataScope(final JoinPoint joinPoint, DataScope controllerDataScope) + { + // 获取当前的用户 + LoginUser loginUser = SecurityUtils.getLoginUser(); + if (StringUtils.isNotNull(loginUser)) + { + SysUser currentUser = loginUser.getUser(); + // 如果是超级管理员,则不过滤数据 + if (StringUtils.isNotNull(currentUser) && !currentUser.isAdmin()) + { + dataScopeFilter(joinPoint, currentUser, controllerDataScope.deptAlias(), + controllerDataScope.userAlias()); + } + } + } + + /** + * 数据范围过滤 + * + * @param joinPoint 切点 + * @param user 用户 + * @param userAlias 别名 + */ + public static void dataScopeFilter(JoinPoint joinPoint, SysUser user, String deptAlias, String userAlias) + { + StringBuilder sqlString = new StringBuilder(); + + for (SysRole role : user.getRoles()) + { + String dataScope = role.getDataScope(); + if (DATA_SCOPE_ALL.equals(dataScope)) + { + sqlString = new StringBuilder(); + break; + } + else if (DATA_SCOPE_CUSTOM.equals(dataScope)) + { + sqlString.append(StringUtils.format( + " OR {}.dept_id IN ( SELECT dept_id FROM sys_role_dept WHERE role_id = {} ) ", deptAlias, + role.getRoleId())); + } + else if (DATA_SCOPE_DEPT.equals(dataScope)) + { + sqlString.append(StringUtils.format(" OR {}.dept_id = {} ", deptAlias, user.getDeptId())); + } + else if (DATA_SCOPE_DEPT_AND_CHILD.equals(dataScope)) + { + sqlString.append(StringUtils.format( + " OR {}.dept_id IN ( SELECT dept_id FROM sys_dept WHERE dept_id = {} or find_in_set( {} , ancestors ) )", + deptAlias, user.getDeptId(), user.getDeptId())); + } + else if (DATA_SCOPE_SELF.equals(dataScope)) + { + if (StringUtils.isNotBlank(userAlias)) + { + sqlString.append(StringUtils.format(" OR {}.user_id = {} ", userAlias, user.getUserId())); + } + else + { + // 数据权限为仅本人且没有userAlias别名不查询任何数据 + sqlString.append(" OR 1=0 "); + } + } + } + + if (StringUtils.isNotBlank(sqlString.toString())) + { + Object params = joinPoint.getArgs()[0]; + if (StringUtils.isNotNull(params) && params instanceof BaseEntity) + { + BaseEntity baseEntity = (BaseEntity) params; + baseEntity.getParams().put(DATA_SCOPE, " AND (" + sqlString.substring(4) + ")"); + } + } + } + + /** + * 拼接权限sql前先清空params.dataScope参数防止注入 + */ + private void clearDataScope(final JoinPoint joinPoint) + { + Object params = joinPoint.getArgs()[0]; + if (StringUtils.isNotNull(params) && params instanceof BaseEntity) + { + BaseEntity baseEntity = (BaseEntity) params; + baseEntity.getParams().put(DATA_SCOPE, ""); + } + } +} diff --git a/ruoyi-base-support/ruoyi-framework/src/main/java/com/ruoyi/framework/aspectj/DataSourceAspect.java b/ruoyi-base-support/ruoyi-framework/src/main/java/com/ruoyi/framework/aspectj/DataSourceAspect.java new file mode 100644 index 0000000..04729e9 --- /dev/null +++ b/ruoyi-base-support/ruoyi-framework/src/main/java/com/ruoyi/framework/aspectj/DataSourceAspect.java @@ -0,0 +1,73 @@ +package com.ruoyi.framework.aspectj; + +import com.ruoyi.common.annotation.DataSource; +import com.ruoyi.common.utils.StringUtils; +import com.ruoyi.framework.datasource.DynamicDataSourceContextHolder; +import org.aspectj.lang.ProceedingJoinPoint; +import org.aspectj.lang.annotation.Around; +import org.aspectj.lang.annotation.Aspect; +import org.aspectj.lang.annotation.Pointcut; +import org.aspectj.lang.reflect.MethodSignature; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.core.annotation.AnnotationUtils; +import org.springframework.core.annotation.Order; +import org.springframework.stereotype.Component; + +import java.util.Objects; + +/** + * 多数据源处理 + * + * @author ruoyi + */ +@Aspect +@Order(1) +@Component +public class DataSourceAspect +{ + protected Logger logger = LoggerFactory.getLogger(getClass()); + + @Pointcut("@annotation(com.ruoyi.common.annotation.DataSource)" + + "|| @within(com.ruoyi.common.annotation.DataSource)") + public void dsPointCut() + { + + } + + @Around("dsPointCut()") + public Object around(ProceedingJoinPoint point) throws Throwable + { + DataSource dataSource = getDataSource(point); + + if (StringUtils.isNotNull(dataSource)) + { + DynamicDataSourceContextHolder.setDataSourceType(dataSource.value().name()); + } + + try + { + return point.proceed(); + } + finally + { + // 销毁数据源 在执行方法之后 + DynamicDataSourceContextHolder.clearDataSourceType(); + } + } + + /** + * 获取需要切换的数据源 + */ + public DataSource getDataSource(ProceedingJoinPoint point) + { + MethodSignature signature = (MethodSignature) point.getSignature(); + DataSource dataSource = AnnotationUtils.findAnnotation(signature.getMethod(), DataSource.class); + if (Objects.nonNull(dataSource)) + { + return dataSource; + } + + return AnnotationUtils.findAnnotation(signature.getDeclaringType(), DataSource.class); + } +} diff --git a/ruoyi-base-support/ruoyi-framework/src/main/java/com/ruoyi/framework/aspectj/LogAspect.java b/ruoyi-base-support/ruoyi-framework/src/main/java/com/ruoyi/framework/aspectj/LogAspect.java new file mode 100644 index 0000000..6ec3ee1 --- /dev/null +++ b/ruoyi-base-support/ruoyi-framework/src/main/java/com/ruoyi/framework/aspectj/LogAspect.java @@ -0,0 +1,219 @@ +package com.ruoyi.framework.aspectj; + +import com.alibaba.fastjson.JSON; +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.core.domain.model.LoginUser; +import com.ruoyi.common.enums.BusinessStatus; +import com.ruoyi.common.enums.HttpMethod; +import com.ruoyi.common.utils.SecurityUtils; +import com.ruoyi.common.utils.ServletUtils; +import com.ruoyi.common.utils.StringUtils; +import com.ruoyi.common.utils.ip.IpUtils; +import com.ruoyi.framework.manager.AsyncManager; +import com.ruoyi.framework.manager.factory.AsyncFactory; +import com.ruoyi.system.domain.SysOperLog; +import org.aspectj.lang.JoinPoint; +import org.aspectj.lang.annotation.AfterReturning; +import org.aspectj.lang.annotation.AfterThrowing; +import org.aspectj.lang.annotation.Aspect; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Component; +import org.springframework.validation.BindingResult; +import org.springframework.web.multipart.MultipartFile; +import org.springframework.web.servlet.HandlerMapping; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.util.Collection; +import java.util.Map; + +/** + * 操作日志记录处理 + * + * @author ruoyi + */ +@Aspect +@Component +public class LogAspect +{ + private static final Logger log = LoggerFactory.getLogger(LogAspect.class); + + /** + * 处理完请求后执行 + * + * @param joinPoint 切点 + */ + @AfterReturning(pointcut = "@annotation(controllerLog)", returning = "jsonResult") + public void doAfterReturning(JoinPoint joinPoint, Log controllerLog, Object jsonResult) + { + handleLog(joinPoint, controllerLog, null, jsonResult); + } + + /** + * 拦截异常操作 + * + * @param joinPoint 切点 + * @param e 异常 + */ + @AfterThrowing(value = "@annotation(controllerLog)", throwing = "e") + public void doAfterThrowing(JoinPoint joinPoint, Log controllerLog, Exception e) + { + handleLog(joinPoint, controllerLog, e, null); + } + + protected void handleLog(final JoinPoint joinPoint, Log controllerLog, final Exception e, Object jsonResult) + { + try + { + + // 获取当前的用户 + LoginUser loginUser = SecurityUtils.getLoginUser(); + + // *========数据库日志=========*// + SysOperLog operLog = new SysOperLog(); + operLog.setStatus(BusinessStatus.SUCCESS.ordinal()); + // 请求的地址 + String ip = IpUtils.getIpAddr(ServletUtils.getRequest()); + operLog.setOperIp(ip); + operLog.setOperUrl(ServletUtils.getRequest().getRequestURI()); + if (loginUser != null) + { + operLog.setOperName(loginUser.getUsername()); + } + + if (e != null) + { + operLog.setStatus(BusinessStatus.FAIL.ordinal()); + operLog.setErrorMsg(StringUtils.substring(e.getMessage(), 0, 2000)); + } + // 设置方法名称 + String className = joinPoint.getTarget().getClass().getName(); + String methodName = joinPoint.getSignature().getName(); + operLog.setMethod(className + "." + methodName + "()"); + // 设置请求方式 + operLog.setRequestMethod(ServletUtils.getRequest().getMethod()); + // 处理设置注解上的参数 + getControllerMethodDescription(joinPoint, controllerLog, operLog, jsonResult); + // 保存数据库 + AsyncManager.me().execute(AsyncFactory.recordOper(operLog)); + } + catch (Exception exp) + { + // 记录本地异常日志 + log.error("==前置通知异常=="); + log.error("异常信息:{}", exp.getMessage()); + exp.printStackTrace(); + } + } + + /** + * 获取注解中对方法的描述信息 用于Controller层注解 + * + * @param log 日志 + * @param operLog 操作日志 + * @throws Exception + */ + public void getControllerMethodDescription(JoinPoint joinPoint, Log log, SysOperLog operLog, Object jsonResult) throws Exception + { + // 设置action动作 + operLog.setBusinessType(log.businessType().ordinal()); + // 设置标题 + operLog.setTitle(log.title()); + // 设置操作人类别 + operLog.setOperatorType(log.operatorType().ordinal()); + // 是否需要保存request,参数和值 + if (log.isSaveRequestData()) + { + // 获取参数的信息,传入到数据库中。 + setRequestValue(joinPoint, operLog); + } + // 是否需要保存response,参数和值 + if (log.isSaveResponseData() && StringUtils.isNotNull(jsonResult)) + { + operLog.setJsonResult(StringUtils.substring(JSON.toJSONString(jsonResult), 0, 2000)); + } + } + + /** + * 获取请求的参数,放到log中 + * + * @param operLog 操作日志 + * @throws Exception 异常 + */ + private void setRequestValue(JoinPoint joinPoint, SysOperLog operLog) throws Exception + { + String requestMethod = operLog.getRequestMethod(); + if (HttpMethod.PUT.name().equals(requestMethod) || HttpMethod.POST.name().equals(requestMethod)) + { + String params = argsArrayToString(joinPoint.getArgs()); + operLog.setOperParam(StringUtils.substring(params, 0, 2000)); + } + else + { + Map paramsMap = (Map) ServletUtils.getRequest().getAttribute(HandlerMapping.URI_TEMPLATE_VARIABLES_ATTRIBUTE); + operLog.setOperParam(StringUtils.substring(paramsMap.toString(), 0, 2000)); + } + } + + /** + * 参数拼装 + */ + private String argsArrayToString(Object[] paramsArray) + { + String params = ""; + if (paramsArray != null && paramsArray.length > 0) + { + for (Object o : paramsArray) + { + if (StringUtils.isNotNull(o) && !isFilterObject(o)) + { + try + { + Object jsonObj = JSON.toJSON(o); + params += jsonObj.toString() + " "; + } + catch (Exception e) + { + } + } + } + } + return params.trim(); + } + + /** + * 判断是否需要过滤的对象。 + * + * @param o 对象信息。 + * @return 如果是需要过滤的对象,则返回true;否则返回false。 + */ + @SuppressWarnings("rawtypes") + public boolean isFilterObject(final Object o) + { + Class clazz = o.getClass(); + if (clazz.isArray()) + { + return clazz.getComponentType().isAssignableFrom(MultipartFile.class); + } + else if (Collection.class.isAssignableFrom(clazz)) + { + Collection collection = (Collection) o; + for (Object value : collection) + { + return value instanceof MultipartFile; + } + } + else if (Map.class.isAssignableFrom(clazz)) + { + Map map = (Map) o; + for (Object value : map.entrySet()) + { + Map.Entry entry = (Map.Entry) value; + return entry.getValue() instanceof MultipartFile; + } + } + return o instanceof MultipartFile || o instanceof HttpServletRequest || o instanceof HttpServletResponse + || o instanceof BindingResult; + } +} diff --git a/ruoyi-base-support/ruoyi-framework/src/main/java/com/ruoyi/framework/aspectj/RateLimiterAspect.java b/ruoyi-base-support/ruoyi-framework/src/main/java/com/ruoyi/framework/aspectj/RateLimiterAspect.java new file mode 100644 index 0000000..aea5fd8 --- /dev/null +++ b/ruoyi-base-support/ruoyi-framework/src/main/java/com/ruoyi/framework/aspectj/RateLimiterAspect.java @@ -0,0 +1,92 @@ +package com.ruoyi.framework.aspectj; + +import com.ruoyi.common.annotation.RateLimiter; +import com.ruoyi.common.enums.LimitType; +import com.ruoyi.common.exception.ServiceException; +import com.ruoyi.common.utils.ServletUtils; +import com.ruoyi.common.utils.StringUtils; +import com.ruoyi.common.utils.ip.IpUtils; +import org.aspectj.lang.JoinPoint; +import org.aspectj.lang.annotation.Aspect; +import org.aspectj.lang.annotation.Before; +import org.aspectj.lang.reflect.MethodSignature; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.redis.core.RedisTemplate; +import org.springframework.data.redis.core.script.RedisScript; +import org.springframework.stereotype.Component; + +import java.lang.reflect.Method; +import java.util.Collections; +import java.util.List; + +/** + * 限流处理 + * + * @author ruoyi + */ +@Aspect +@Component +public class RateLimiterAspect +{ + private static final Logger log = LoggerFactory.getLogger(RateLimiterAspect.class); + + private RedisTemplate redisTemplate; + + private RedisScript limitScript; + + @Autowired + public void setRedisTemplate1(RedisTemplate redisTemplate) + { + this.redisTemplate = redisTemplate; + } + + @Autowired + public void setLimitScript(RedisScript limitScript) + { + this.limitScript = limitScript; + } + + @Before("@annotation(rateLimiter)") + public void doBefore(JoinPoint point, RateLimiter rateLimiter) throws Throwable + { + String key = rateLimiter.key(); + int time = rateLimiter.time(); + int count = rateLimiter.count(); + + String combineKey = getCombineKey(rateLimiter, point); + List keys = Collections.singletonList(combineKey); + try + { + Long number = redisTemplate.execute(limitScript, keys, count, time); + if (StringUtils.isNull(number) || number.intValue() > count) + { + throw new ServiceException("访问过于频繁,请稍后再试"); + } + log.info("限制请求'{}',当前请求'{}',缓存key'{}'", count, number.intValue(), key); + } + catch (ServiceException e) + { + throw e; + } + catch (Exception e) + { + throw new RuntimeException("服务器限流异常,请稍后再试"); + } + } + + public String getCombineKey(RateLimiter rateLimiter, JoinPoint point) + { + StringBuffer stringBuffer = new StringBuffer(rateLimiter.key()); + if (rateLimiter.limitType() == LimitType.IP) + { + stringBuffer.append(IpUtils.getIpAddr(ServletUtils.getRequest())).append("-"); + } + MethodSignature signature = (MethodSignature) point.getSignature(); + Method method = signature.getMethod(); + Class targetClass = method.getDeclaringClass(); + stringBuffer.append(targetClass.getName()).append("-").append(method.getName()); + return stringBuffer.toString(); + } +} diff --git a/ruoyi-base-support/ruoyi-framework/src/main/java/com/ruoyi/framework/config/ApplicationConfig.java b/ruoyi-base-support/ruoyi-framework/src/main/java/com/ruoyi/framework/config/ApplicationConfig.java new file mode 100644 index 0000000..63693fb --- /dev/null +++ b/ruoyi-base-support/ruoyi-framework/src/main/java/com/ruoyi/framework/config/ApplicationConfig.java @@ -0,0 +1,31 @@ +package com.ruoyi.framework.config; + +import org.mybatis.spring.annotation.MapperScan; +import org.springframework.boot.autoconfigure.jackson.Jackson2ObjectMapperBuilderCustomizer; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.EnableAspectJAutoProxy; + +import java.util.TimeZone; + +/** + * 程序注解配置 + * + * @author ruoyi + */ +@Configuration +// 表示通过aop框架暴露该代理对象,AopContext能够访问 +@EnableAspectJAutoProxy(exposeProxy = true) +// 指定要扫描的Mapper类的包的路径 +@MapperScan("com.ruoyi.**.mapper") +public class ApplicationConfig +{ + /** + * 时区配置 + */ + @Bean + public Jackson2ObjectMapperBuilderCustomizer jacksonObjectMapperCustomization() + { + return jacksonObjectMapperBuilder -> jacksonObjectMapperBuilder.timeZone(TimeZone.getDefault()); + } +} diff --git a/ruoyi-base-support/ruoyi-framework/src/main/java/com/ruoyi/framework/config/CaptchaConfig.java b/ruoyi-base-support/ruoyi-framework/src/main/java/com/ruoyi/framework/config/CaptchaConfig.java new file mode 100644 index 0000000..b158c72 --- /dev/null +++ b/ruoyi-base-support/ruoyi-framework/src/main/java/com/ruoyi/framework/config/CaptchaConfig.java @@ -0,0 +1,85 @@ +package com.ruoyi.framework.config; + +import com.google.code.kaptcha.impl.DefaultKaptcha; +import com.google.code.kaptcha.util.Config; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +import java.util.Properties; + +import static com.google.code.kaptcha.Constants.*; + +/** + * 验证码配置 + * + * @author ruoyi + */ +@Configuration +public class CaptchaConfig +{ + @Bean(name = "captchaProducer") + public DefaultKaptcha getKaptchaBean() + { + DefaultKaptcha defaultKaptcha = new DefaultKaptcha(); + Properties properties = new Properties(); + // 是否有边框 默认为true 我们可以自己设置yes,no + properties.setProperty(KAPTCHA_BORDER, "yes"); + // 验证码文本字符颜色 默认为Color.BLACK + properties.setProperty(KAPTCHA_TEXTPRODUCER_FONT_COLOR, "black"); + // 验证码图片宽度 默认为200 + properties.setProperty(KAPTCHA_IMAGE_WIDTH, "160"); + // 验证码图片高度 默认为50 + properties.setProperty(KAPTCHA_IMAGE_HEIGHT, "60"); + // 验证码文本字符大小 默认为40 + properties.setProperty(KAPTCHA_TEXTPRODUCER_FONT_SIZE, "38"); + // KAPTCHA_SESSION_KEY + properties.setProperty(KAPTCHA_SESSION_CONFIG_KEY, "kaptchaCode"); + // 验证码文本字符长度 默认为5 + properties.setProperty(KAPTCHA_TEXTPRODUCER_CHAR_LENGTH, "4"); + // 验证码文本字体样式 默认为new Font("Arial", 1, fontSize), new Font("Courier", 1, fontSize) + properties.setProperty(KAPTCHA_TEXTPRODUCER_FONT_NAMES, "Arial,Courier"); + // 图片样式 水纹com.google.code.kaptcha.impl.WaterRipple 鱼眼com.google.code.kaptcha.impl.FishEyeGimpy 阴影com.google.code.kaptcha.impl.ShadowGimpy + properties.setProperty(KAPTCHA_OBSCURIFICATOR_IMPL, "com.google.code.kaptcha.impl.ShadowGimpy"); + Config config = new Config(properties); + defaultKaptcha.setConfig(config); + return defaultKaptcha; + } + + @Bean(name = "captchaProducerMath") + public DefaultKaptcha getKaptchaBeanMath() + { + DefaultKaptcha defaultKaptcha = new DefaultKaptcha(); + Properties properties = new Properties(); + // 是否有边框 默认为true 我们可以自己设置yes,no + properties.setProperty(KAPTCHA_BORDER, "yes"); + // 边框颜色 默认为Color.BLACK + properties.setProperty(KAPTCHA_BORDER_COLOR, "105,179,90"); + // 验证码文本字符颜色 默认为Color.BLACK + properties.setProperty(KAPTCHA_TEXTPRODUCER_FONT_COLOR, "blue"); + // 验证码图片宽度 默认为200 + properties.setProperty(KAPTCHA_IMAGE_WIDTH, "160"); + // 验证码图片高度 默认为50 + properties.setProperty(KAPTCHA_IMAGE_HEIGHT, "60"); + // 验证码文本字符大小 默认为40 + properties.setProperty(KAPTCHA_TEXTPRODUCER_FONT_SIZE, "35"); + // KAPTCHA_SESSION_KEY + properties.setProperty(KAPTCHA_SESSION_CONFIG_KEY, "kaptchaCodeMath"); + // 验证码文本生成器 + properties.setProperty(KAPTCHA_TEXTPRODUCER_IMPL, "com.ruoyi.framework.config.KaptchaTextCreator"); + // 验证码文本字符间距 默认为2 + properties.setProperty(KAPTCHA_TEXTPRODUCER_CHAR_SPACE, "3"); + // 验证码文本字符长度 默认为5 + properties.setProperty(KAPTCHA_TEXTPRODUCER_CHAR_LENGTH, "6"); + // 验证码文本字体样式 默认为new Font("Arial", 1, fontSize), new Font("Courier", 1, fontSize) + properties.setProperty(KAPTCHA_TEXTPRODUCER_FONT_NAMES, "Arial,Courier"); + // 验证码噪点颜色 默认为Color.BLACK + properties.setProperty(KAPTCHA_NOISE_COLOR, "white"); + // 干扰实现类 + properties.setProperty(KAPTCHA_NOISE_IMPL, "com.google.code.kaptcha.impl.NoNoise"); + // 图片样式 水纹com.google.code.kaptcha.impl.WaterRipple 鱼眼com.google.code.kaptcha.impl.FishEyeGimpy 阴影com.google.code.kaptcha.impl.ShadowGimpy + properties.setProperty(KAPTCHA_OBSCURIFICATOR_IMPL, "com.google.code.kaptcha.impl.ShadowGimpy"); + Config config = new Config(properties); + defaultKaptcha.setConfig(config); + return defaultKaptcha; + } +} diff --git a/ruoyi-base-support/ruoyi-framework/src/main/java/com/ruoyi/framework/config/DruidConfig.java b/ruoyi-base-support/ruoyi-framework/src/main/java/com/ruoyi/framework/config/DruidConfig.java new file mode 100644 index 0000000..52bf088 --- /dev/null +++ b/ruoyi-base-support/ruoyi-framework/src/main/java/com/ruoyi/framework/config/DruidConfig.java @@ -0,0 +1,123 @@ +package com.ruoyi.framework.config; + +import com.alibaba.druid.pool.DruidDataSource; +import com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceBuilder; +import com.alibaba.druid.spring.boot.autoconfigure.properties.DruidStatProperties; +import com.alibaba.druid.util.Utils; +import com.ruoyi.common.enums.DataSourceType; +import com.ruoyi.common.utils.spring.SpringUtils; +import com.ruoyi.framework.config.properties.DruidProperties; +import com.ruoyi.framework.datasource.DynamicDataSource; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.boot.web.servlet.FilterRegistrationBean; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Primary; + +import javax.servlet.*; +import javax.sql.DataSource; +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; + +/** + * druid 配置多数据源 + * + * @author ruoyi + */ +@Configuration +public class DruidConfig +{ + @Bean + @ConfigurationProperties("spring.datasource.druid.master") + public DataSource masterDataSource(DruidProperties druidProperties) + { + DruidDataSource dataSource = DruidDataSourceBuilder.create().build(); + return druidProperties.dataSource(dataSource); + } + + @Bean + @ConfigurationProperties("spring.datasource.druid.slave") + @ConditionalOnProperty(prefix = "spring.datasource.druid.slave", name = "enabled", havingValue = "true") + public DataSource slaveDataSource(DruidProperties druidProperties) + { + DruidDataSource dataSource = DruidDataSourceBuilder.create().build(); + return druidProperties.dataSource(dataSource); + } + + @Bean(name = "dynamicDataSource") + @Primary + public DynamicDataSource dataSource(DataSource masterDataSource) + { + Map targetDataSources = new HashMap<>(); + targetDataSources.put(DataSourceType.MASTER.name(), masterDataSource); + setDataSource(targetDataSources, DataSourceType.SLAVE.name(), "slaveDataSource"); + return new DynamicDataSource(masterDataSource, targetDataSources); + } + + /** + * 设置数据源 + * + * @param targetDataSources 备选数据源集合 + * @param sourceName 数据源名称 + * @param beanName bean名称 + */ + public void setDataSource(Map targetDataSources, String sourceName, String beanName) + { + try + { + DataSource dataSource = SpringUtils.getBean(beanName); + targetDataSources.put(sourceName, dataSource); + } + catch (Exception e) + { + } + } + + /** + * 去除监控页面底部的广告 + */ + @SuppressWarnings({ "rawtypes", "unchecked" }) + @Bean + @ConditionalOnProperty(name = "spring.datasource.druid.statViewServlet.enabled", havingValue = "true") + public FilterRegistrationBean removeDruidFilterRegistrationBean(DruidStatProperties properties) + { + // 获取web监控页面的参数 + DruidStatProperties.StatViewServlet config = properties.getStatViewServlet(); + // 提取common.js的配置路径 + String pattern = config.getUrlPattern() != null ? config.getUrlPattern() : "/druid/*"; + String commonJsPattern = pattern.replaceAll("\\*", "js/common.js"); + final String filePath = "support/http/resources/js/common.js"; + // 创建filter进行过滤 + Filter filter = new Filter() + { + @Override + public void init(javax.servlet.FilterConfig filterConfig) throws ServletException + { + } + @Override + public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) + throws IOException, ServletException + { + chain.doFilter(request, response); + // 重置缓冲区,响应头不会被重置 + response.resetBuffer(); + // 获取common.js + String text = Utils.readFromResource(filePath); + // 正则替换banner, 除去底部的广告信息 + text = text.replaceAll("
", ""); + text = text.replaceAll("powered.*?shrek.wang", ""); + response.getWriter().write(text); + } + @Override + public void destroy() + { + } + }; + FilterRegistrationBean registrationBean = new FilterRegistrationBean(); + registrationBean.setFilter(filter); + registrationBean.addUrlPatterns(commonJsPattern); + return registrationBean; + } +} diff --git a/ruoyi-base-support/ruoyi-framework/src/main/java/com/ruoyi/framework/config/FastJson2JsonRedisSerializer.java b/ruoyi-base-support/ruoyi-framework/src/main/java/com/ruoyi/framework/config/FastJson2JsonRedisSerializer.java new file mode 100644 index 0000000..0bce439 --- /dev/null +++ b/ruoyi-base-support/ruoyi-framework/src/main/java/com/ruoyi/framework/config/FastJson2JsonRedisSerializer.java @@ -0,0 +1,72 @@ +package com.ruoyi.framework.config; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.parser.ParserConfig; +import com.alibaba.fastjson.serializer.SerializerFeature; +import com.fasterxml.jackson.databind.JavaType; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.type.TypeFactory; +import org.springframework.data.redis.serializer.RedisSerializer; +import org.springframework.data.redis.serializer.SerializationException; +import org.springframework.util.Assert; + +import java.nio.charset.Charset; + +/** + * Redis使用FastJson序列化 + * + * @author ruoyi + */ +public class FastJson2JsonRedisSerializer implements RedisSerializer +{ + @SuppressWarnings("unused") + private ObjectMapper objectMapper = new ObjectMapper(); + + public static final Charset DEFAULT_CHARSET = Charset.forName("UTF-8"); + + private Class clazz; + + static + { + ParserConfig.getGlobalInstance().setAutoTypeSupport(true); + } + + public FastJson2JsonRedisSerializer(Class clazz) + { + super(); + this.clazz = clazz; + } + + @Override + public byte[] serialize(T t) throws SerializationException + { + if (t == null) + { + return new byte[0]; + } + return JSON.toJSONString(t, SerializerFeature.WriteClassName).getBytes(DEFAULT_CHARSET); + } + + @Override + public T deserialize(byte[] bytes) throws SerializationException + { + if (bytes == null || bytes.length <= 0) + { + return null; + } + String str = new String(bytes, DEFAULT_CHARSET); + + return JSON.parseObject(str, clazz); + } + + public void setObjectMapper(ObjectMapper objectMapper) + { + Assert.notNull(objectMapper, "'objectMapper' must not be null"); + this.objectMapper = objectMapper; + } + + protected JavaType getJavaType(Class clazz) + { + return TypeFactory.defaultInstance().constructType(clazz); + } +} diff --git a/ruoyi-base-support/ruoyi-framework/src/main/java/com/ruoyi/framework/config/FilterConfig.java b/ruoyi-base-support/ruoyi-framework/src/main/java/com/ruoyi/framework/config/FilterConfig.java new file mode 100644 index 0000000..42933cb --- /dev/null +++ b/ruoyi-base-support/ruoyi-framework/src/main/java/com/ruoyi/framework/config/FilterConfig.java @@ -0,0 +1,59 @@ +package com.ruoyi.framework.config; + +import com.ruoyi.common.filter.RepeatableFilter; +import com.ruoyi.common.filter.XssFilter; +import com.ruoyi.common.utils.StringUtils; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.boot.web.servlet.FilterRegistrationBean; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +import javax.servlet.DispatcherType; +import java.util.HashMap; +import java.util.Map; + +/** + * Filter配置 + * + * @author ruoyi + */ +@Configuration +@ConditionalOnProperty(value = "xss.enabled", havingValue = "true") +public class FilterConfig +{ + @Value("${xss.excludes}") + private String excludes; + + @Value("${xss.urlPatterns}") + private String urlPatterns; + + @SuppressWarnings({ "rawtypes", "unchecked" }) + @Bean + public FilterRegistrationBean xssFilterRegistration() + { + FilterRegistrationBean registration = new FilterRegistrationBean(); + registration.setDispatcherTypes(DispatcherType.REQUEST); + registration.setFilter(new XssFilter()); + registration.addUrlPatterns(StringUtils.split(urlPatterns, ",")); + registration.setName("xssFilter"); + registration.setOrder(FilterRegistrationBean.HIGHEST_PRECEDENCE); + Map initParameters = new HashMap(); + initParameters.put("excludes", excludes); + registration.setInitParameters(initParameters); + return registration; + } + + @SuppressWarnings({ "rawtypes", "unchecked" }) + @Bean + public FilterRegistrationBean someFilterRegistration() + { + FilterRegistrationBean registration = new FilterRegistrationBean(); + registration.setFilter(new RepeatableFilter()); + registration.addUrlPatterns("/*"); + registration.setName("repeatableFilter"); + registration.setOrder(FilterRegistrationBean.LOWEST_PRECEDENCE); + return registration; + } + +} diff --git a/ruoyi-base-support/ruoyi-framework/src/main/java/com/ruoyi/framework/config/KaptchaTextCreator.java b/ruoyi-base-support/ruoyi-framework/src/main/java/com/ruoyi/framework/config/KaptchaTextCreator.java new file mode 100644 index 0000000..1ed0a41 --- /dev/null +++ b/ruoyi-base-support/ruoyi-framework/src/main/java/com/ruoyi/framework/config/KaptchaTextCreator.java @@ -0,0 +1,76 @@ +package com.ruoyi.framework.config; + +import com.google.code.kaptcha.text.impl.DefaultTextCreator; + +import java.util.Random; + +/** + * 验证码文本生成器 + * + * @author ruoyi + */ +public class KaptchaTextCreator extends DefaultTextCreator +{ + private static final String[] CNUMBERS = "0,1,2,3,4,5,6,7,8,9,10".split(","); + + @Override + public String getText() + { + Integer result = 0; + Random random = new Random(); + int x = random.nextInt(10); + int y = random.nextInt(10); + StringBuilder suChinese = new StringBuilder(); + int randomoperands = (int) Math.round(Math.random() * 2); + if (randomoperands == 0) + { + result = x * y; + suChinese.append(CNUMBERS[x]); + suChinese.append("*"); + suChinese.append(CNUMBERS[y]); + } + else if (randomoperands == 1) + { + if (!(x == 0) && y % x == 0) + { + result = y / x; + suChinese.append(CNUMBERS[y]); + suChinese.append("/"); + suChinese.append(CNUMBERS[x]); + } + else + { + result = x + y; + suChinese.append(CNUMBERS[x]); + suChinese.append("+"); + suChinese.append(CNUMBERS[y]); + } + } + else if (randomoperands == 2) + { + if (x >= y) + { + result = x - y; + suChinese.append(CNUMBERS[x]); + suChinese.append("-"); + suChinese.append(CNUMBERS[y]); + } + else + { + result = y - x; + suChinese.append(CNUMBERS[y]); + suChinese.append("-"); + suChinese.append(CNUMBERS[x]); + } + } + else + { + result = x + y; + suChinese.append(CNUMBERS[x]); + suChinese.append("+"); + suChinese.append(CNUMBERS[y]); + } + suChinese.append("=?@" + result); + return suChinese.toString(); + } +} \ No newline at end of file diff --git a/ruoyi-base-support/ruoyi-framework/src/main/java/com/ruoyi/framework/config/MybatisPlusConfig.java b/ruoyi-base-support/ruoyi-framework/src/main/java/com/ruoyi/framework/config/MybatisPlusConfig.java new file mode 100644 index 0000000..ec2c38e --- /dev/null +++ b/ruoyi-base-support/ruoyi-framework/src/main/java/com/ruoyi/framework/config/MybatisPlusConfig.java @@ -0,0 +1,143 @@ +package com.ruoyi.framework.config; + +import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor; +import com.baomidou.mybatisplus.extension.plugins.handler.TenantLineHandler; +import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor; +import com.baomidou.mybatisplus.extension.plugins.inner.TenantLineInnerInterceptor; +import org.mybatis.spring.annotation.MapperScan; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.core.env.Environment; +import org.springframework.core.io.Resource; +import org.springframework.core.io.support.PathMatchingResourcePatternResolver; +import org.springframework.core.io.support.ResourcePatternResolver; +import org.springframework.core.type.classreading.CachingMetadataReaderFactory; +import org.springframework.core.type.classreading.MetadataReader; +import org.springframework.core.type.classreading.MetadataReaderFactory; +import org.springframework.util.ClassUtils; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashSet; +import java.util.List; + +/** + * Mybatis支持*匹配扫描包 + * + * @author ruoyi + */ +@Configuration +@MapperScan(basePackages = {"cn.ruoyi.**.mapper"}) +public class MybatisPlusConfig +{ + @Autowired + private Environment env; + + static final String DEFAULT_RESOURCE_PATTERN = "**/*.class"; + + public static String setTypeAliasesPackage(String typeAliasesPackage) + { + ResourcePatternResolver resolver = (ResourcePatternResolver) new PathMatchingResourcePatternResolver(); + MetadataReaderFactory metadataReaderFactory = new CachingMetadataReaderFactory(resolver); + List allResult = new ArrayList(); + try + { + for (String aliasesPackage : typeAliasesPackage.split(",")) + { + List result = new ArrayList(); + aliasesPackage = ResourcePatternResolver.CLASSPATH_ALL_URL_PREFIX + + ClassUtils.convertClassNameToResourcePath(aliasesPackage.trim()) + "/" + DEFAULT_RESOURCE_PATTERN; + Resource[] resources = resolver.getResources(aliasesPackage); + if (resources != null && resources.length > 0) + { + MetadataReader metadataReader = null; + for (Resource resource : resources) + { + if (resource.isReadable()) + { + metadataReader = metadataReaderFactory.getMetadataReader(resource); + try + { + result.add(Class.forName(metadataReader.getClassMetadata().getClassName()).getPackage().getName()); + } + catch (ClassNotFoundException e) + { + e.printStackTrace(); + } + } + } + } + if (result.size() > 0) + { + HashSet hashResult = new HashSet(result); + allResult.addAll(hashResult); + } + } + if (allResult.size() > 0) + { + typeAliasesPackage = String.join(",", (String[]) allResult.toArray(new String[0])); + } + else + { + throw new RuntimeException("mybatis typeAliasesPackage 路径扫描错误,参数typeAliasesPackage:" + typeAliasesPackage + "未找到任何包"); + } + } + catch (IOException e) + { + e.printStackTrace(); + } + return typeAliasesPackage; + } + + public Resource[] resolveMapperLocations(String[] mapperLocations) + { + ResourcePatternResolver resourceResolver = new PathMatchingResourcePatternResolver(); + List resources = new ArrayList(); + if (mapperLocations != null) + { + for (String mapperLocation : mapperLocations) + { + try + { + Resource[] mappers = resourceResolver.getResources(mapperLocation); + resources.addAll(Arrays.asList(mappers)); + } + catch (IOException e) + { + // ignore + } + } + } + return resources.toArray(new Resource[resources.size()]); + } + +// @Bean +// public SqlSessionFactory sqlSessionFactory(DataSource dataSource) throws Exception +// { +// String typeAliasesPackage = env.getProperty("type-aliases-package"); +// String mapperLocations = env.getProperty("mybatis-plus.mapper-locations"); +// String configLocation = env.getProperty("mybatis-plus.configLocation"); +// typeAliasesPackage = setTypeAliasesPackage(typeAliasesPackage); +// VFS.addImplClass(SpringBootVFS.class); +// +// final SqlSessionFactoryBean sessionFactory = new SqlSessionFactoryBean(); +// sessionFactory.setDataSource(dataSource); +// sessionFactory.setTypeAliasesPackage(typeAliasesPackage); +// sessionFactory.setMapperLocations(resolveMapperLocations(StringUtils.split(mapperLocations, ","))); +// sessionFactory.setConfigLocation(new DefaultResourceLoader().getResource(configLocation)); +// return sessionFactory.getObject(); +// } + + @Bean + public MybatisPlusInterceptor mybatisPlusInterceptor(TenantLineHandler tenantHandler) { + MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor(); + interceptor.addInnerInterceptor(new TenantLineInnerInterceptor(tenantHandler)); + // 如果用了分页插件注意先 add TenantLineInnerInterceptor 再 add PaginationInnerInterceptor + // 用了分页插件必须设置 MybatisConfiguration#useDeprecatedExecutor = false + interceptor.addInnerInterceptor(new PaginationInnerInterceptor()); + return interceptor; + } + +} diff --git a/ruoyi-base-support/ruoyi-framework/src/main/java/com/ruoyi/framework/config/RedisConfig.java b/ruoyi-base-support/ruoyi-framework/src/main/java/com/ruoyi/framework/config/RedisConfig.java new file mode 100644 index 0000000..7f930b5 --- /dev/null +++ b/ruoyi-base-support/ruoyi-framework/src/main/java/com/ruoyi/framework/config/RedisConfig.java @@ -0,0 +1,79 @@ +package com.ruoyi.framework.config; + +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.PropertyAccessor; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.jsontype.impl.LaissezFaireSubTypeValidator; +import org.springframework.cache.annotation.CachingConfigurerSupport; +import org.springframework.cache.annotation.EnableCaching; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.data.redis.connection.RedisConnectionFactory; +import org.springframework.data.redis.core.RedisTemplate; +import org.springframework.data.redis.core.script.DefaultRedisScript; +import org.springframework.data.redis.serializer.StringRedisSerializer; + +/** + * redis配置 + * + * @author ruoyi + */ +@Configuration +@EnableCaching +public class RedisConfig extends CachingConfigurerSupport +{ + @Bean + @SuppressWarnings(value = { "unchecked", "rawtypes" }) + public RedisTemplate redisTemplate(RedisConnectionFactory connectionFactory) + { + RedisTemplate template = new RedisTemplate<>(); + template.setConnectionFactory(connectionFactory); + + FastJson2JsonRedisSerializer serializer = new FastJson2JsonRedisSerializer(Object.class); + + ObjectMapper mapper = new ObjectMapper(); + mapper.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY); + mapper.activateDefaultTyping(LaissezFaireSubTypeValidator.instance, ObjectMapper.DefaultTyping.NON_FINAL, JsonTypeInfo.As.PROPERTY); + serializer.setObjectMapper(mapper); + + // 使用StringRedisSerializer来序列化和反序列化redis的key值 + template.setKeySerializer(new StringRedisSerializer()); + template.setValueSerializer(serializer); + + // Hash的key也采用StringRedisSerializer的序列化方式 + template.setHashKeySerializer(new StringRedisSerializer()); + template.setHashValueSerializer(serializer); + + template.afterPropertiesSet(); + return template; + } + + @Bean + public DefaultRedisScript limitScript() + { + DefaultRedisScript redisScript = new DefaultRedisScript<>(); + redisScript.setScriptText(limitScriptText()); + redisScript.setResultType(Long.class); + return redisScript; + } + + /** + * 限流脚本 + */ + private String limitScriptText() + { + return "local key = KEYS[1]\n" + + "local count = tonumber(ARGV[1])\n" + + "local time = tonumber(ARGV[2])\n" + + "local current = redis.call('get', key);\n" + + "if current and tonumber(current) > count then\n" + + " return tonumber(current);\n" + + "end\n" + + "current = redis.call('incr', key)\n" + + "if tonumber(current) == 1 then\n" + + " redis.call('expire', key, time)\n" + + "end\n" + + "return tonumber(current);"; + } +} diff --git a/ruoyi-base-support/ruoyi-framework/src/main/java/com/ruoyi/framework/config/ResourcesConfig.java b/ruoyi-base-support/ruoyi-framework/src/main/java/com/ruoyi/framework/config/ResourcesConfig.java new file mode 100644 index 0000000..83852ed --- /dev/null +++ b/ruoyi-base-support/ruoyi-framework/src/main/java/com/ruoyi/framework/config/ResourcesConfig.java @@ -0,0 +1,69 @@ +package com.ruoyi.framework.config; + +import com.ruoyi.common.config.RuoYiConfig; +import com.ruoyi.common.constant.Constants; +import com.ruoyi.framework.interceptor.RepeatSubmitInterceptor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.web.cors.CorsConfiguration; +import org.springframework.web.cors.UrlBasedCorsConfigurationSource; +import org.springframework.web.filter.CorsFilter; +import org.springframework.web.servlet.config.annotation.InterceptorRegistry; +import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; + +/** + * 通用配置 + * + * @author ruoyi + */ +@Configuration +@Slf4j +public class ResourcesConfig implements WebMvcConfigurer +{ + @Autowired + private RepeatSubmitInterceptor repeatSubmitInterceptor; + + @Override + public void addResourceHandlers(ResourceHandlerRegistry registry) + { + /** 本地文件上传路径 */ + registry.addResourceHandler(Constants.RESOURCE_PREFIX + "/**").addResourceLocations("file:" + RuoYiConfig.getProfile() + "/"); + + /** swagger配置 */ + registry.addResourceHandler("/swagger-ui/**").addResourceLocations("classpath:/META-INF/resources/webjars/springfox-swagger-ui/"); + } + + /** + * 自定义拦截规则 + */ + @Override + public void addInterceptors(InterceptorRegistry registry) + { + registry.addInterceptor(repeatSubmitInterceptor) + .excludePathPatterns("/api/**") + .addPathPatterns("/**"); + } + + /** + * 跨域配置 + */ + @Bean + public CorsFilter corsFilter() + { + UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource(); + CorsConfiguration config = new CorsConfiguration(); + config.setAllowCredentials(true); + // 设置访问源地址 + config.addAllowedOriginPattern("*"); + // 设置访问源请求头 + config.addAllowedHeader("*"); + // 设置访问源请求方法 + config.addAllowedMethod("*"); + // 对接口配置跨域设置 + source.registerCorsConfiguration("/**", config); + return new CorsFilter(source); + } +} diff --git a/ruoyi-base-support/ruoyi-framework/src/main/java/com/ruoyi/framework/config/SecurityConfig.java b/ruoyi-base-support/ruoyi-framework/src/main/java/com/ruoyi/framework/config/SecurityConfig.java new file mode 100644 index 0000000..12b0b4a --- /dev/null +++ b/ruoyi-base-support/ruoyi-framework/src/main/java/com/ruoyi/framework/config/SecurityConfig.java @@ -0,0 +1,145 @@ +package com.ruoyi.framework.config; + +import com.ruoyi.framework.security.filter.JwtAuthenticationTokenFilter; +import com.ruoyi.framework.security.handle.AuthenticationEntryPointImpl; +import com.ruoyi.framework.security.handle.LogoutSuccessHandlerImpl; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Bean; +import org.springframework.http.HttpMethod; +import org.springframework.security.authentication.AuthenticationManager; +import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; +import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity; +import org.springframework.security.config.annotation.web.builders.HttpSecurity; +import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; +import org.springframework.security.config.http.SessionCreationPolicy; +import org.springframework.security.core.userdetails.UserDetailsService; +import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; +import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter; +import org.springframework.security.web.authentication.logout.LogoutFilter; +import org.springframework.web.filter.CorsFilter; + +/** + * spring security配置 + * + * @author ruoyi + */ +@EnableGlobalMethodSecurity(prePostEnabled = true, securedEnabled = true) +public class SecurityConfig extends WebSecurityConfigurerAdapter +{ + /** + * 自定义用户认证逻辑 + */ + @Autowired + private UserDetailsService userDetailsService; + + /** + * 认证失败处理类 + */ + @Autowired + private AuthenticationEntryPointImpl unauthorizedHandler; + + /** + * 退出处理类 + */ + @Autowired + private LogoutSuccessHandlerImpl logoutSuccessHandler; + + /** + * token认证过滤器 + */ + @Autowired + private JwtAuthenticationTokenFilter authenticationTokenFilter; + + /** + * 跨域过滤器 + */ + @Autowired + private CorsFilter corsFilter; + + /** + * 解决 无法直接注入 AuthenticationManager + * + * @return + * @throws Exception + */ + @Bean + @Override + public AuthenticationManager authenticationManagerBean() throws Exception + { + return super.authenticationManagerBean(); + } + + /** + * anyRequest | 匹配所有请求路径 + * access | SpringEl表达式结果为true时可以访问 + * anonymous | 匿名可以访问 + * denyAll | 用户不能访问 + * fullyAuthenticated | 用户完全认证可以访问(非remember-me下自动登录) + * hasAnyAuthority | 如果有参数,参数表示权限,则其中任何一个权限可以访问 + * hasAnyRole | 如果有参数,参数表示角色,则其中任何一个角色可以访问 + * hasAuthority | 如果有参数,参数表示权限,则其权限可以访问 + * hasIpAddress | 如果有参数,参数表示IP地址,如果用户IP和参数匹配,则可以访问 + * hasRole | 如果有参数,参数表示角色,则其角色可以访问 + * permitAll | 用户可以任意访问 + * rememberMe | 允许通过remember-me登录的用户访问 + * authenticated | 用户登录后可访问 + */ + @Override + protected void configure(HttpSecurity httpSecurity) throws Exception + { + httpSecurity + // CSRF禁用,因为不使用session + .csrf().disable() + // 认证失败处理类 + .exceptionHandling().authenticationEntryPoint(unauthorizedHandler).and() + // 基于token,所以不需要session + .sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS).and() + // 过滤请求 + .authorizeRequests() + // 对于登录login 注册register 验证码captchaImage 允许匿名访问 + .antMatchers("/login","/system/cos/**", "/register", "/captchaImage").anonymous() + .antMatchers( + HttpMethod.GET, + "/", + "/*.html", + "/**/*.html", + "/**/*.css", + "/**/*.js", + "/profile/**" + ).permitAll() + .antMatchers("/swagger-ui.html").anonymous() + .antMatchers("/swagger-resources/**").anonymous() + .antMatchers("/webjars/**").anonymous() + .antMatchers("/*/api-docs").anonymous() + .antMatchers("/druid/**").anonymous() + .antMatchers("/api/**").anonymous() + // 除上面外的所有请求全部需要鉴权认证 + .anyRequest().authenticated() + .and() + .headers().frameOptions().disable(); + httpSecurity.logout().logoutUrl("/logout").logoutSuccessHandler(logoutSuccessHandler); + // 添加JWT filter + httpSecurity.addFilterBefore(authenticationTokenFilter, UsernamePasswordAuthenticationFilter.class); + // 添加CORS filter + httpSecurity.addFilterBefore(corsFilter, JwtAuthenticationTokenFilter.class); + httpSecurity.addFilterBefore(corsFilter, LogoutFilter.class); + } + + /** + * 强散列哈希加密实现 + */ + @Bean + public BCryptPasswordEncoder bCryptPasswordEncoder() + { + return new BCryptPasswordEncoder(); + } + + /** + * 身份认证接口 + */ + @Override + protected void configure(AuthenticationManagerBuilder auth) throws Exception + { + auth.userDetailsService(userDetailsService).passwordEncoder(bCryptPasswordEncoder()); + } +} diff --git a/ruoyi-base-support/ruoyi-framework/src/main/java/com/ruoyi/framework/config/ServerConfig.java b/ruoyi-base-support/ruoyi-framework/src/main/java/com/ruoyi/framework/config/ServerConfig.java new file mode 100644 index 0000000..fb1ea58 --- /dev/null +++ b/ruoyi-base-support/ruoyi-framework/src/main/java/com/ruoyi/framework/config/ServerConfig.java @@ -0,0 +1,33 @@ +package com.ruoyi.framework.config; + +import com.ruoyi.common.utils.ServletUtils; +import org.springframework.stereotype.Component; + +import javax.servlet.http.HttpServletRequest; + +/** + * 服务相关配置 + * + * @author ruoyi + */ +@Component +public class ServerConfig +{ + /** + * 获取完整的请求路径,包括:域名,端口,上下文访问路径 + * + * @return 服务地址 + */ + public String getUrl() + { + HttpServletRequest request = ServletUtils.getRequest(); + return getDomain(request); + } + + public static String getDomain(HttpServletRequest request) + { + StringBuffer url = request.getRequestURL(); + String contextPath = request.getServletContext().getContextPath(); + return url.delete(url.length() - request.getRequestURI().length(), url.length()).append(contextPath).toString(); + } +} diff --git a/ruoyi-base-support/ruoyi-framework/src/main/java/com/ruoyi/framework/config/ThreadPoolConfig.java b/ruoyi-base-support/ruoyi-framework/src/main/java/com/ruoyi/framework/config/ThreadPoolConfig.java new file mode 100644 index 0000000..a971014 --- /dev/null +++ b/ruoyi-base-support/ruoyi-framework/src/main/java/com/ruoyi/framework/config/ThreadPoolConfig.java @@ -0,0 +1,84 @@ +package com.ruoyi.framework.config; + +import com.ruoyi.common.utils.Threads; +import org.apache.commons.lang3.concurrent.BasicThreadFactory; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; + +import java.util.concurrent.Executor; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.ScheduledThreadPoolExecutor; +import java.util.concurrent.ThreadPoolExecutor; + +/** + * 线程池配置 + * + * @author ruoyi + **/ +@Configuration +public class ThreadPoolConfig +{ + // 核心线程池大小 + private int corePoolSize = 50; + + // 最大可创建的线程数 + private int maxPoolSize = 200; + + // 队列最大长度 + private int queueCapacity = 1000; + + // 线程池维护线程所允许的空闲时间 + private int keepAliveSeconds = 300; + + @Bean(name = "threadPoolTaskExecutor") + public ThreadPoolTaskExecutor threadPoolTaskExecutor() + { + ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor(); + executor.setMaxPoolSize(maxPoolSize); + executor.setCorePoolSize(corePoolSize); + executor.setQueueCapacity(queueCapacity); + executor.setKeepAliveSeconds(keepAliveSeconds); + // 线程池对拒绝任务(无线程可用)的处理策略 + executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy()); + return executor; + } + + /** + * 执行周期性或定时任务 + */ + @Bean(name = "scheduledExecutorService") + protected ScheduledExecutorService scheduledExecutorService() + { + return new ScheduledThreadPoolExecutor(corePoolSize, + new BasicThreadFactory.Builder().namingPattern("schedule-pool-%d").daemon(true).build()) + { + @Override + protected void afterExecute(Runnable r, Throwable t) + { + super.afterExecute(r, t); + Threads.printException(r, t); + } + }; + } + + + @Bean("async") + public Executor doSomethingExecutor() { + ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor(); + // 核心线程数:线程池创建时候初始化的线程数 + executor.setCorePoolSize(10); + // 最大线程数:线程池最大的线程数,只有在缓冲队列满了之后才会申请超过核心线程数的线程 + executor.setMaxPoolSize(20); + // 缓冲队列:用来缓冲执行任务的队列 + executor.setQueueCapacity(500); + // 允许线程的空闲时间60秒:当超过了核心线程之外的线程在空闲时间到达之后会被销毁 + executor.setKeepAliveSeconds(60); + // 线程池名的前缀:设置好了之后可以方便我们定位处理任务所在的线程池 + executor.setThreadNamePrefix("async-"); + // 缓冲队列满了之后的拒绝策略:由调用线程处理(一般是主线程) + executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy()); + executor.initialize(); + return executor; + } +} diff --git a/ruoyi-base-support/ruoyi-framework/src/main/java/com/ruoyi/framework/config/properties/DruidProperties.java b/ruoyi-base-support/ruoyi-framework/src/main/java/com/ruoyi/framework/config/properties/DruidProperties.java new file mode 100644 index 0000000..a004092 --- /dev/null +++ b/ruoyi-base-support/ruoyi-framework/src/main/java/com/ruoyi/framework/config/properties/DruidProperties.java @@ -0,0 +1,77 @@ +package com.ruoyi.framework.config.properties; + +import com.alibaba.druid.pool.DruidDataSource; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Configuration; + +/** + * druid 配置属性 + * + * @author ruoyi + */ +@Configuration +public class DruidProperties +{ + @Value("${spring.datasource.druid.initialSize}") + private int initialSize; + + @Value("${spring.datasource.druid.minIdle}") + private int minIdle; + + @Value("${spring.datasource.druid.maxActive}") + private int maxActive; + + @Value("${spring.datasource.druid.maxWait}") + private int maxWait; + + @Value("${spring.datasource.druid.timeBetweenEvictionRunsMillis}") + private int timeBetweenEvictionRunsMillis; + + @Value("${spring.datasource.druid.minEvictableIdleTimeMillis}") + private int minEvictableIdleTimeMillis; + + @Value("${spring.datasource.druid.maxEvictableIdleTimeMillis}") + private int maxEvictableIdleTimeMillis; + + @Value("${spring.datasource.druid.validationQuery}") + private String validationQuery; + + @Value("${spring.datasource.druid.testWhileIdle}") + private boolean testWhileIdle; + + @Value("${spring.datasource.druid.testOnBorrow}") + private boolean testOnBorrow; + + @Value("${spring.datasource.druid.testOnReturn}") + private boolean testOnReturn; + + public DruidDataSource dataSource(DruidDataSource datasource) + { + /** 配置初始化大小、最小、最大 */ + datasource.setInitialSize(initialSize); + datasource.setMaxActive(maxActive); + datasource.setMinIdle(minIdle); + + /** 配置获取连接等待超时的时间 */ + datasource.setMaxWait(maxWait); + + /** 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒 */ + datasource.setTimeBetweenEvictionRunsMillis(timeBetweenEvictionRunsMillis); + + /** 配置一个连接在池中最小、最大生存的时间,单位是毫秒 */ + datasource.setMinEvictableIdleTimeMillis(minEvictableIdleTimeMillis); + datasource.setMaxEvictableIdleTimeMillis(maxEvictableIdleTimeMillis); + + /** + * 用来检测连接是否有效的sql,要求是一个查询语句,常用select 'x'。如果validationQuery为null,testOnBorrow、testOnReturn、testWhileIdle都不会起作用。 + */ + datasource.setValidationQuery(validationQuery); + /** 建议配置为true,不影响性能,并且保证安全性。申请连接的时候检测,如果空闲时间大于timeBetweenEvictionRunsMillis,执行validationQuery检测连接是否有效。 */ + datasource.setTestWhileIdle(testWhileIdle); + /** 申请连接时执行validationQuery检测连接是否有效,做了这个配置会降低性能。 */ + datasource.setTestOnBorrow(testOnBorrow); + /** 归还连接时执行validationQuery检测连接是否有效,做了这个配置会降低性能。 */ + datasource.setTestOnReturn(testOnReturn); + return datasource; + } +} diff --git a/ruoyi-base-support/ruoyi-framework/src/main/java/com/ruoyi/framework/datasource/DynamicDataSource.java b/ruoyi-base-support/ruoyi-framework/src/main/java/com/ruoyi/framework/datasource/DynamicDataSource.java new file mode 100644 index 0000000..9d585fc --- /dev/null +++ b/ruoyi-base-support/ruoyi-framework/src/main/java/com/ruoyi/framework/datasource/DynamicDataSource.java @@ -0,0 +1,27 @@ +package com.ruoyi.framework.datasource; + +import org.springframework.jdbc.datasource.lookup.AbstractRoutingDataSource; + +import javax.sql.DataSource; +import java.util.Map; + +/** + * 动态数据源 + * + * @author ruoyi + */ +public class DynamicDataSource extends AbstractRoutingDataSource +{ + public DynamicDataSource(DataSource defaultTargetDataSource, Map targetDataSources) + { + super.setDefaultTargetDataSource(defaultTargetDataSource); + super.setTargetDataSources(targetDataSources); + super.afterPropertiesSet(); + } + + @Override + protected Object determineCurrentLookupKey() + { + return DynamicDataSourceContextHolder.getDataSourceType(); + } +} \ No newline at end of file diff --git a/ruoyi-base-support/ruoyi-framework/src/main/java/com/ruoyi/framework/datasource/DynamicDataSourceContextHolder.java b/ruoyi-base-support/ruoyi-framework/src/main/java/com/ruoyi/framework/datasource/DynamicDataSourceContextHolder.java new file mode 100644 index 0000000..3572db9 --- /dev/null +++ b/ruoyi-base-support/ruoyi-framework/src/main/java/com/ruoyi/framework/datasource/DynamicDataSourceContextHolder.java @@ -0,0 +1,45 @@ +package com.ruoyi.framework.datasource; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * 数据源切换处理 + * + * @author ruoyi + */ +public class DynamicDataSourceContextHolder +{ + public static final Logger log = LoggerFactory.getLogger(DynamicDataSourceContextHolder.class); + + /** + * 使用ThreadLocal维护变量,ThreadLocal为每个使用该变量的线程提供独立的变量副本, + * 所以每一个线程都可以独立地改变自己的副本,而不会影响其它线程所对应的副本。 + */ + private static final ThreadLocal CONTEXT_HOLDER = new ThreadLocal<>(); + + /** + * 设置数据源的变量 + */ + public static void setDataSourceType(String dsType) + { + log.info("切换到{}数据源", dsType); + CONTEXT_HOLDER.set(dsType); + } + + /** + * 获得数据源的变量 + */ + public static String getDataSourceType() + { + return CONTEXT_HOLDER.get(); + } + + /** + * 清空数据源变量 + */ + public static void clearDataSourceType() + { + CONTEXT_HOLDER.remove(); + } +} diff --git a/ruoyi-base-support/ruoyi-framework/src/main/java/com/ruoyi/framework/interceptor/RepeatSubmitInterceptor.java b/ruoyi-base-support/ruoyi-framework/src/main/java/com/ruoyi/framework/interceptor/RepeatSubmitInterceptor.java new file mode 100644 index 0000000..a4080b8 --- /dev/null +++ b/ruoyi-base-support/ruoyi-framework/src/main/java/com/ruoyi/framework/interceptor/RepeatSubmitInterceptor.java @@ -0,0 +1,58 @@ +package com.ruoyi.framework.interceptor; + +import java.lang.reflect.Method; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; +import org.springframework.web.method.HandlerMethod; +import com.alibaba.fastjson.JSONObject; +import com.ruoyi.common.annotation.RepeatSubmit; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.utils.ServletUtils; +import org.springframework.web.servlet.handler.HandlerInterceptorAdapter; + +/** + * 防止重复提交拦截器 + * + * @author ruoyi + */ +@Component +@Slf4j +public abstract class RepeatSubmitInterceptor extends HandlerInterceptorAdapter +{ + @Override + public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception + { + if (handler instanceof HandlerMethod) + { + HandlerMethod handlerMethod = (HandlerMethod) handler; + Method method = handlerMethod.getMethod(); + RepeatSubmit annotation = method.getAnnotation(RepeatSubmit.class); + if (annotation != null) + { + if (this.isRepeatSubmit(request, annotation)) + { + AjaxResult ajaxResult = AjaxResult.error(annotation.message()); + ServletUtils.renderString(response, JSONObject.toJSONString(ajaxResult)); + return false; + } + } + return true; + } + else + { + return super.preHandle(request, response, handler); + } + } + + /** + * 验证是否重复提交由子类实现具体的防重复提交的规则 + * + * @param request + * @return + * @throws Exception + */ + public abstract boolean isRepeatSubmit(HttpServletRequest request, RepeatSubmit annotation); +} diff --git a/ruoyi-base-support/ruoyi-framework/src/main/java/com/ruoyi/framework/interceptor/impl/SameUrlDataInterceptor.java b/ruoyi-base-support/ruoyi-framework/src/main/java/com/ruoyi/framework/interceptor/impl/SameUrlDataInterceptor.java new file mode 100644 index 0000000..d422d0b --- /dev/null +++ b/ruoyi-base-support/ruoyi-framework/src/main/java/com/ruoyi/framework/interceptor/impl/SameUrlDataInterceptor.java @@ -0,0 +1,114 @@ +package com.ruoyi.framework.interceptor.impl; + +import java.util.HashMap; +import java.util.Map; +import java.util.concurrent.TimeUnit; +import javax.servlet.http.HttpServletRequest; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Component; +import com.alibaba.fastjson.JSONObject; +import com.ruoyi.common.annotation.RepeatSubmit; +import com.ruoyi.common.constant.Constants; +import com.ruoyi.common.core.redis.RedisService; +import com.ruoyi.common.filter.RepeatedlyRequestWrapper; +import com.ruoyi.common.utils.StringUtils; +import com.ruoyi.common.utils.http.HttpHelper; +import com.ruoyi.framework.interceptor.RepeatSubmitInterceptor; + +/** + * 判断请求url和数据是否和上一次相同, + * 如果和上次相同,则是重复提交表单。 有效时间为10秒内。 + * + * @author ruoyi + */ +@Component +public class SameUrlDataInterceptor extends RepeatSubmitInterceptor +{ + public final String REPEAT_PARAMS = "repeatParams"; + + public final String REPEAT_TIME = "repeatTime"; + + // 令牌自定义标识 + @Value("${token.header}") + private String header; + + @Autowired + private RedisService redisCache; + + @SuppressWarnings("unchecked") + @Override + public boolean isRepeatSubmit(HttpServletRequest request, RepeatSubmit annotation) + { + String nowParams = ""; + if (request instanceof RepeatedlyRequestWrapper) + { + RepeatedlyRequestWrapper repeatedlyRequest = (RepeatedlyRequestWrapper) request; + nowParams = HttpHelper.getBodyString(repeatedlyRequest); + } + + // body参数为空,获取Parameter的数据 + if (StringUtils.isEmpty(nowParams)) + { + nowParams = JSONObject.toJSONString(request.getParameterMap()); + } + Map nowDataMap = new HashMap(); + nowDataMap.put(REPEAT_PARAMS, nowParams); + nowDataMap.put(REPEAT_TIME, System.currentTimeMillis()); + + // 请求地址(作为存放cache的key值) + String url = request.getRequestURI(); + + // 唯一值(没有消息头则使用请求地址) + String submitKey = request.getHeader(header); + if (StringUtils.isEmpty(submitKey)) + { + submitKey = url; + } + + // 唯一标识(指定key + 消息头) + String cacheRepeatKey = Constants.REPEAT_SUBMIT_KEY + submitKey; + + Object sessionObj = redisCache.getCacheObject(cacheRepeatKey); + if (sessionObj != null) + { + Map sessionMap = (Map) sessionObj; + if (sessionMap.containsKey(url)) + { + Map preDataMap = (Map) sessionMap.get(url); + if (compareParams(nowDataMap, preDataMap) && compareTime(nowDataMap, preDataMap, annotation.interval())) + { + return true; + } + } + } + Map cacheMap = new HashMap(); + cacheMap.put(url, nowDataMap); + redisCache.setCacheObject(cacheRepeatKey, cacheMap, annotation.interval(), TimeUnit.MILLISECONDS); + return false; + } + + /** + * 判断参数是否相同 + */ + private boolean compareParams(Map nowMap, Map preMap) + { + String nowParams = (String) nowMap.get(REPEAT_PARAMS); + String preParams = (String) preMap.get(REPEAT_PARAMS); + return nowParams.equals(preParams); + } + + /** + * 判断两次间隔时间 + */ + private boolean compareTime(Map nowMap, Map preMap, int interval) + { + long time1 = (Long) nowMap.get(REPEAT_TIME); + long time2 = (Long) preMap.get(REPEAT_TIME); + if ((time1 - time2) < interval) + { + return true; + } + return false; + } +} diff --git a/ruoyi-base-support/ruoyi-framework/src/main/java/com/ruoyi/framework/manager/AsyncManager.java b/ruoyi-base-support/ruoyi-framework/src/main/java/com/ruoyi/framework/manager/AsyncManager.java new file mode 100644 index 0000000..fa666e1 --- /dev/null +++ b/ruoyi-base-support/ruoyi-framework/src/main/java/com/ruoyi/framework/manager/AsyncManager.java @@ -0,0 +1,56 @@ +package com.ruoyi.framework.manager; + +import com.ruoyi.common.utils.Threads; +import com.ruoyi.common.utils.spring.SpringUtils; + +import java.util.TimerTask; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.TimeUnit; + +/** + * 异步任务管理器 + * + * @author ruoyi + */ +public class AsyncManager +{ + /** + * 操作延迟10毫秒 + */ + private final int OPERATE_DELAY_TIME = 10; + + /** + * 异步操作任务调度线程池 + */ + private ScheduledExecutorService executor = SpringUtils.getBean("scheduledExecutorService"); + + /** + * 单例模式 + */ + private AsyncManager(){} + + private static AsyncManager me = new AsyncManager(); + + public static AsyncManager me() + { + return me; + } + + /** + * 执行任务 + * + * @param task 任务 + */ + public void execute(TimerTask task) + { + executor.schedule(task, OPERATE_DELAY_TIME, TimeUnit.MILLISECONDS); + } + + /** + * 停止任务线程池 + */ + public void shutdown() + { + Threads.shutdownAndAwaitTermination(executor); + } +} diff --git a/ruoyi-base-support/ruoyi-framework/src/main/java/com/ruoyi/framework/manager/ShutdownManager.java b/ruoyi-base-support/ruoyi-framework/src/main/java/com/ruoyi/framework/manager/ShutdownManager.java new file mode 100644 index 0000000..db928d4 --- /dev/null +++ b/ruoyi-base-support/ruoyi-framework/src/main/java/com/ruoyi/framework/manager/ShutdownManager.java @@ -0,0 +1,40 @@ +package com.ruoyi.framework.manager; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Component; + +import javax.annotation.PreDestroy; + +/** + * 确保应用退出时能关闭后台线程 + * + * @author ruoyi + */ +@Component +public class ShutdownManager +{ + private static final Logger logger = LoggerFactory.getLogger("sys-user"); + + @PreDestroy + public void destroy() + { + shutdownAsyncManager(); + } + + /** + * 停止异步执行任务 + */ + private void shutdownAsyncManager() + { + try + { + logger.info("====关闭后台任务任务线程池===="); + AsyncManager.me().shutdown(); + } + catch (Exception e) + { + logger.error(e.getMessage(), e); + } + } +} diff --git a/ruoyi-base-support/ruoyi-framework/src/main/java/com/ruoyi/framework/manager/factory/AsyncFactory.java b/ruoyi-base-support/ruoyi-framework/src/main/java/com/ruoyi/framework/manager/factory/AsyncFactory.java new file mode 100644 index 0000000..8659cba --- /dev/null +++ b/ruoyi-base-support/ruoyi-framework/src/main/java/com/ruoyi/framework/manager/factory/AsyncFactory.java @@ -0,0 +1,103 @@ +package com.ruoyi.framework.manager.factory; + +import com.ruoyi.common.constant.Constants; +import com.ruoyi.common.utils.LogUtils; +import com.ruoyi.common.utils.ServletUtils; +import com.ruoyi.common.utils.StringUtils; +import com.ruoyi.common.utils.ip.AddressUtils; +import com.ruoyi.common.utils.ip.IpUtils; +import com.ruoyi.common.utils.spring.SpringUtils; +import com.ruoyi.system.domain.SysLogininfor; +import com.ruoyi.system.domain.SysOperLog; +import com.ruoyi.system.service.ISysLogininforService; +import com.ruoyi.system.service.ISysOperLogService; +import eu.bitwalker.useragentutils.UserAgent; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.TimerTask; + +/** + * 异步工厂(产生任务用) + * + * @author ruoyi + */ +public class AsyncFactory +{ + private static final Logger sys_user_logger = LoggerFactory.getLogger("sys-user"); + + /** + * 记录登录信息 + * + * @param username 用户名 + * @param status 状态 + * @param message 消息 + * @param args 列表 + * @return 任务task + */ + public static TimerTask recordLogininfor(final String username, final String status, final String message, + final Object... args) + { + final UserAgent userAgent = UserAgent.parseUserAgentString(ServletUtils.getRequest().getHeader("User-Agent")); + final String ip = IpUtils.getIpAddr(ServletUtils.getRequest()); + return new TimerTask() + { + @Override + public void run() + { + String address = AddressUtils.getRealAddressByIP(ip); + StringBuilder s = new StringBuilder(); + s.append(LogUtils.getBlock(ip)); + s.append(address); + s.append(LogUtils.getBlock(username)); + s.append(LogUtils.getBlock(status)); + s.append(LogUtils.getBlock(message)); + // 打印信息到日志 + sys_user_logger.info(s.toString(), args); + // 获取客户端操作系统 + String os = userAgent.getOperatingSystem().getName(); + // 获取客户端浏览器 + String browser = userAgent.getBrowser().getName(); + // 封装对象 + SysLogininfor logininfor = new SysLogininfor(); + logininfor.setUserName(username); + logininfor.setIpaddr(ip); + logininfor.setLoginLocation(address); + logininfor.setBrowser(browser); + logininfor.setOs(os); + logininfor.setMsg(message); + // 日志状态 + if (StringUtils.equalsAny(status, Constants.LOGIN_SUCCESS, Constants.LOGOUT, Constants.REGISTER)) + { + logininfor.setStatus(Constants.SUCCESS); + } + else if (Constants.LOGIN_FAIL.equals(status)) + { + logininfor.setStatus(Constants.FAIL); + } + // 插入数据 + SpringUtils.getBean(ISysLogininforService.class).insertLogininfor(logininfor); + } + }; + } + + /** + * 操作日志记录 + * + * @param operLog 操作日志信息 + * @return 任务task + */ + public static TimerTask recordOper(final SysOperLog operLog) + { + return new TimerTask() + { + @Override + public void run() + { + // 远程查询操作地点 + operLog.setOperLocation(AddressUtils.getRealAddressByIP(operLog.getOperIp())); + SpringUtils.getBean(ISysOperLogService.class).insertOperlog(operLog); + } + }; + } +} diff --git a/ruoyi-base-support/ruoyi-framework/src/main/java/com/ruoyi/framework/security/filter/JwtAuthenticationTokenFilter.java b/ruoyi-base-support/ruoyi-framework/src/main/java/com/ruoyi/framework/security/filter/JwtAuthenticationTokenFilter.java new file mode 100644 index 0000000..caadd4b --- /dev/null +++ b/ruoyi-base-support/ruoyi-framework/src/main/java/com/ruoyi/framework/security/filter/JwtAuthenticationTokenFilter.java @@ -0,0 +1,45 @@ +package com.ruoyi.framework.security.filter; + +import com.ruoyi.common.core.domain.model.LoginUser; +import com.ruoyi.common.utils.SecurityUtils; +import com.ruoyi.common.utils.StringUtils; +import com.ruoyi.framework.web.service.TokenService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; +import org.springframework.security.core.context.SecurityContextHolder; +import org.springframework.security.web.authentication.WebAuthenticationDetailsSource; +import org.springframework.stereotype.Component; +import org.springframework.web.filter.OncePerRequestFilter; + +import javax.servlet.FilterChain; +import javax.servlet.ServletException; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; + +/** + * token过滤器 验证token有效性 + * + * @author ruoyi + */ +@Component +public class JwtAuthenticationTokenFilter extends OncePerRequestFilter +{ + @Autowired + private TokenService tokenService; + + @Override + protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain chain) + throws ServletException, IOException + { + LoginUser loginUser = tokenService.getLoginUser(request); + if (StringUtils.isNotNull(loginUser) && StringUtils.isNull(SecurityUtils.getAuthentication())) + { + tokenService.verifyToken(loginUser); + UsernamePasswordAuthenticationToken authenticationToken = new UsernamePasswordAuthenticationToken(loginUser, null, loginUser.getAuthorities()); + authenticationToken.setDetails(new WebAuthenticationDetailsSource().buildDetails(request)); + SecurityContextHolder.getContext().setAuthentication(authenticationToken); + } + chain.doFilter(request, response); + } +} diff --git a/ruoyi-base-support/ruoyi-framework/src/main/java/com/ruoyi/framework/security/handle/AuthenticationEntryPointImpl.java b/ruoyi-base-support/ruoyi-framework/src/main/java/com/ruoyi/framework/security/handle/AuthenticationEntryPointImpl.java new file mode 100644 index 0000000..5d61671 --- /dev/null +++ b/ruoyi-base-support/ruoyi-framework/src/main/java/com/ruoyi/framework/security/handle/AuthenticationEntryPointImpl.java @@ -0,0 +1,36 @@ +package com.ruoyi.framework.security.handle; + +import com.alibaba.fastjson.JSON; +import com.ruoyi.common.constant.HttpStatus; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.utils.ServletUtils; +import com.ruoyi.common.utils.StringUtils; +import org.springframework.security.core.AuthenticationException; +import org.springframework.security.web.AuthenticationEntryPoint; +import org.springframework.stereotype.Component; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.io.Serializable; + +/** + * 认证失败处理类 返回未授权 + * + * @author ruoyi + */ +@Component +public class AuthenticationEntryPointImpl implements AuthenticationEntryPoint, Serializable +{ + private static final long serialVersionUID = -8970718410437077606L; + + @Override + public void commence(HttpServletRequest request, HttpServletResponse response, AuthenticationException e) + throws IOException + { + int code = HttpStatus.UNAUTHORIZED; + String msg = StringUtils.format("请求访问:{},认证失败,无法访问系统资源", request.getRequestURI()); + ServletUtils.renderString(response, JSON.toJSONString(AjaxResult.error(code, msg))); + + } +} diff --git a/ruoyi-base-support/ruoyi-framework/src/main/java/com/ruoyi/framework/security/handle/LogoutSuccessHandlerImpl.java b/ruoyi-base-support/ruoyi-framework/src/main/java/com/ruoyi/framework/security/handle/LogoutSuccessHandlerImpl.java new file mode 100644 index 0000000..4e64325 --- /dev/null +++ b/ruoyi-base-support/ruoyi-framework/src/main/java/com/ruoyi/framework/security/handle/LogoutSuccessHandlerImpl.java @@ -0,0 +1,54 @@ +package com.ruoyi.framework.security.handle; + +import com.alibaba.fastjson.JSON; +import com.ruoyi.common.constant.Constants; +import com.ruoyi.common.constant.HttpStatus; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.domain.model.LoginUser; +import com.ruoyi.common.utils.ServletUtils; +import com.ruoyi.common.utils.StringUtils; +import com.ruoyi.framework.manager.AsyncManager; +import com.ruoyi.framework.manager.factory.AsyncFactory; +import com.ruoyi.framework.web.service.TokenService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Configuration; +import org.springframework.security.core.Authentication; +import org.springframework.security.web.authentication.logout.LogoutSuccessHandler; + +import javax.servlet.ServletException; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; + +/** + * 自定义退出处理类 返回成功 + * + * @author ruoyi + */ +@Configuration +public class LogoutSuccessHandlerImpl implements LogoutSuccessHandler +{ + @Autowired + private TokenService tokenService; + + /** + * 退出处理 + * + * @return + */ + @Override + public void onLogoutSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) + throws IOException, ServletException + { + LoginUser loginUser = tokenService.getLoginUser(request); + if (StringUtils.isNotNull(loginUser)) + { + String userName = loginUser.getUsername(); + // 删除用户缓存记录 + tokenService.delLoginUser(loginUser.getToken()); + // 记录用户退出日志 + AsyncManager.me().execute(AsyncFactory.recordLogininfor(userName, Constants.LOGOUT, "退出成功")); + } + ServletUtils.renderString(response, JSON.toJSONString(AjaxResult.error(HttpStatus.SUCCESS, "退出成功"))); + } +} diff --git a/ruoyi-base-support/ruoyi-framework/src/main/java/com/ruoyi/framework/web/domain/Server.java b/ruoyi-base-support/ruoyi-framework/src/main/java/com/ruoyi/framework/web/domain/Server.java new file mode 100644 index 0000000..5298eeb --- /dev/null +++ b/ruoyi-base-support/ruoyi-framework/src/main/java/com/ruoyi/framework/web/domain/Server.java @@ -0,0 +1,237 @@ +package com.ruoyi.framework.web.domain; + +import com.ruoyi.common.utils.Arith; +import com.ruoyi.common.utils.ip.IpUtils; +import com.ruoyi.framework.web.domain.server.*; +import oshi.SystemInfo; +import oshi.hardware.CentralProcessor; +import oshi.hardware.CentralProcessor.TickType; +import oshi.hardware.GlobalMemory; +import oshi.hardware.HardwareAbstractionLayer; +import oshi.software.os.FileSystem; +import oshi.software.os.OSFileStore; +import oshi.software.os.OperatingSystem; +import oshi.util.Util; + +import java.net.UnknownHostException; +import java.util.LinkedList; +import java.util.List; +import java.util.Properties; + +/** + * 服务器相关信息 + * + * @author ruoyi + */ +public class Server +{ + private static final int OSHI_WAIT_SECOND = 1000; + + /** + * CPU相关信息 + */ + private Cpu cpu = new Cpu(); + + /** + * 內存相关信息 + */ + private Mem mem = new Mem(); + + /** + * JVM相关信息 + */ + private Jvm jvm = new Jvm(); + + /** + * 服务器相关信息 + */ + private Sys sys = new Sys(); + + /** + * 磁盘相关信息 + */ + private List sysFiles = new LinkedList(); + + public Cpu getCpu() + { + return cpu; + } + + public void setCpu(Cpu cpu) + { + this.cpu = cpu; + } + + public Mem getMem() + { + return mem; + } + + public void setMem(Mem mem) + { + this.mem = mem; + } + + public Jvm getJvm() + { + return jvm; + } + + public void setJvm(Jvm jvm) + { + this.jvm = jvm; + } + + public Sys getSys() + { + return sys; + } + + public void setSys(Sys sys) + { + this.sys = sys; + } + + public List getSysFiles() + { + return sysFiles; + } + + public void setSysFiles(List sysFiles) + { + this.sysFiles = sysFiles; + } + + public void copyTo() throws Exception + { + SystemInfo si = new SystemInfo(); + HardwareAbstractionLayer hal = si.getHardware(); + + setCpuInfo(hal.getProcessor()); + + setMemInfo(hal.getMemory()); + + setSysInfo(); + + setJvmInfo(); + + setSysFiles(si.getOperatingSystem()); + } + + /** + * 设置CPU信息 + */ + private void setCpuInfo(CentralProcessor processor) + { + // CPU信息 + long[] prevTicks = processor.getSystemCpuLoadTicks(); + Util.sleep(OSHI_WAIT_SECOND); + long[] ticks = processor.getSystemCpuLoadTicks(); + long nice = ticks[TickType.NICE.getIndex()] - prevTicks[TickType.NICE.getIndex()]; + long irq = ticks[TickType.IRQ.getIndex()] - prevTicks[TickType.IRQ.getIndex()]; + long softirq = ticks[TickType.SOFTIRQ.getIndex()] - prevTicks[TickType.SOFTIRQ.getIndex()]; + long steal = ticks[TickType.STEAL.getIndex()] - prevTicks[TickType.STEAL.getIndex()]; + long cSys = ticks[TickType.SYSTEM.getIndex()] - prevTicks[TickType.SYSTEM.getIndex()]; + long user = ticks[TickType.USER.getIndex()] - prevTicks[TickType.USER.getIndex()]; + long iowait = ticks[TickType.IOWAIT.getIndex()] - prevTicks[TickType.IOWAIT.getIndex()]; + long idle = ticks[TickType.IDLE.getIndex()] - prevTicks[TickType.IDLE.getIndex()]; + long totalCpu = user + nice + cSys + idle + iowait + irq + softirq + steal; + cpu.setCpuNum(processor.getLogicalProcessorCount()); + cpu.setTotal(totalCpu); + cpu.setSys(cSys); + cpu.setUsed(user); + cpu.setWait(iowait); + cpu.setFree(idle); + } + + /** + * 设置内存信息 + */ + private void setMemInfo(GlobalMemory memory) + { + mem.setTotal(memory.getTotal()); + mem.setUsed(memory.getTotal() - memory.getAvailable()); + mem.setFree(memory.getAvailable()); + } + + /** + * 设置服务器信息 + */ + private void setSysInfo() + { + Properties props = System.getProperties(); + sys.setComputerName(IpUtils.getHostName()); + sys.setComputerIp(IpUtils.getHostIp()); + sys.setOsName(props.getProperty("os.name")); + sys.setOsArch(props.getProperty("os.arch")); + sys.setUserDir(props.getProperty("user.dir")); + } + + /** + * 设置Java虚拟机 + */ + private void setJvmInfo() throws UnknownHostException + { + Properties props = System.getProperties(); + jvm.setTotal(Runtime.getRuntime().totalMemory()); + jvm.setMax(Runtime.getRuntime().maxMemory()); + jvm.setFree(Runtime.getRuntime().freeMemory()); + jvm.setVersion(props.getProperty("java.version")); + jvm.setHome(props.getProperty("java.home")); + } + + /** + * 设置磁盘信息 + */ + private void setSysFiles(OperatingSystem os) + { + FileSystem fileSystem = os.getFileSystem(); + List fsArray = fileSystem.getFileStores(); + for (OSFileStore fs : fsArray) + { + long free = fs.getUsableSpace(); + long total = fs.getTotalSpace(); + long used = total - free; + SysFile sysFile = new SysFile(); + sysFile.setDirName(fs.getMount()); + sysFile.setSysTypeName(fs.getType()); + sysFile.setTypeName(fs.getName()); + sysFile.setTotal(convertFileSize(total)); + sysFile.setFree(convertFileSize(free)); + sysFile.setUsed(convertFileSize(used)); + sysFile.setUsage(Arith.mul(Arith.div(used, total, 4), 100)); + sysFiles.add(sysFile); + } + } + + /** + * 字节转换 + * + * @param size 字节大小 + * @return 转换后值 + */ + public String convertFileSize(long size) + { + long kb = 1024; + long mb = kb * 1024; + long gb = mb * 1024; + if (size >= gb) + { + return String.format("%.1f GB", (float) size / gb); + } + else if (size >= mb) + { + float f = (float) size / mb; + return String.format(f > 100 ? "%.0f MB" : "%.1f MB", f); + } + else if (size >= kb) + { + float f = (float) size / kb; + return String.format(f > 100 ? "%.0f KB" : "%.1f KB", f); + } + else + { + return String.format("%d B", size); + } + } +} diff --git a/ruoyi-base-support/ruoyi-framework/src/main/java/com/ruoyi/framework/web/domain/server/Cpu.java b/ruoyi-base-support/ruoyi-framework/src/main/java/com/ruoyi/framework/web/domain/server/Cpu.java new file mode 100644 index 0000000..a13a66c --- /dev/null +++ b/ruoyi-base-support/ruoyi-framework/src/main/java/com/ruoyi/framework/web/domain/server/Cpu.java @@ -0,0 +1,101 @@ +package com.ruoyi.framework.web.domain.server; + +import com.ruoyi.common.utils.Arith; + +/** + * CPU相关信息 + * + * @author ruoyi + */ +public class Cpu +{ + /** + * 核心数 + */ + private int cpuNum; + + /** + * CPU总的使用率 + */ + private double total; + + /** + * CPU系统使用率 + */ + private double sys; + + /** + * CPU用户使用率 + */ + private double used; + + /** + * CPU当前等待率 + */ + private double wait; + + /** + * CPU当前空闲率 + */ + private double free; + + public int getCpuNum() + { + return cpuNum; + } + + public void setCpuNum(int cpuNum) + { + this.cpuNum = cpuNum; + } + + public double getTotal() + { + return Arith.round(Arith.mul(total, 100), 2); + } + + public void setTotal(double total) + { + this.total = total; + } + + public double getSys() + { + return Arith.round(Arith.mul(sys / total, 100), 2); + } + + public void setSys(double sys) + { + this.sys = sys; + } + + public double getUsed() + { + return Arith.round(Arith.mul(used / total, 100), 2); + } + + public void setUsed(double used) + { + this.used = used; + } + + public double getWait() + { + return Arith.round(Arith.mul(wait / total, 100), 2); + } + + public void setWait(double wait) + { + this.wait = wait; + } + + public double getFree() + { + return Arith.round(Arith.mul(free / total, 100), 2); + } + + public void setFree(double free) + { + this.free = free; + } +} diff --git a/ruoyi-base-support/ruoyi-framework/src/main/java/com/ruoyi/framework/web/domain/server/Jvm.java b/ruoyi-base-support/ruoyi-framework/src/main/java/com/ruoyi/framework/web/domain/server/Jvm.java new file mode 100644 index 0000000..19dfa36 --- /dev/null +++ b/ruoyi-base-support/ruoyi-framework/src/main/java/com/ruoyi/framework/web/domain/server/Jvm.java @@ -0,0 +1,123 @@ +package com.ruoyi.framework.web.domain.server; + +import com.ruoyi.common.utils.Arith; +import com.ruoyi.common.utils.DateUtils; + +import java.lang.management.ManagementFactory; + +/** + * JVM相关信息 + * + * @author ruoyi + */ +public class Jvm +{ + /** + * 当前JVM占用的内存总数(M) + */ + private double total; + + /** + * JVM最大可用内存总数(M) + */ + private double max; + + /** + * JVM空闲内存(M) + */ + private double free; + + /** + * JDK版本 + */ + private String version; + + /** + * JDK路径 + */ + private String home; + + public double getTotal() + { + return Arith.div(total, (1024 * 1024), 2); + } + + public void setTotal(double total) + { + this.total = total; + } + + public double getMax() + { + return Arith.div(max, (1024 * 1024), 2); + } + + public void setMax(double max) + { + this.max = max; + } + + public double getFree() + { + return Arith.div(free, (1024 * 1024), 2); + } + + public void setFree(double free) + { + this.free = free; + } + + public double getUsed() + { + return Arith.div(total - free, (1024 * 1024), 2); + } + + public double getUsage() + { + return Arith.mul(Arith.div(total - free, total, 4), 100); + } + + /** + * 获取JDK名称 + */ + public String getName() + { + return ManagementFactory.getRuntimeMXBean().getVmName(); + } + + public String getVersion() + { + return version; + } + + public void setVersion(String version) + { + this.version = version; + } + + public String getHome() + { + return home; + } + + public void setHome(String home) + { + this.home = home; + } + + /** + * JDK启动时间 + */ + public String getStartTime() + { + return DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, DateUtils.getServerStartDate()); + } + + /** + * JDK运行时间 + */ + public String getRunTime() + { + return DateUtils.getDatePoor(DateUtils.getNowDate(), DateUtils.getServerStartDate()); + } +} diff --git a/ruoyi-base-support/ruoyi-framework/src/main/java/com/ruoyi/framework/web/domain/server/Mem.java b/ruoyi-base-support/ruoyi-framework/src/main/java/com/ruoyi/framework/web/domain/server/Mem.java new file mode 100644 index 0000000..13eec52 --- /dev/null +++ b/ruoyi-base-support/ruoyi-framework/src/main/java/com/ruoyi/framework/web/domain/server/Mem.java @@ -0,0 +1,61 @@ +package com.ruoyi.framework.web.domain.server; + +import com.ruoyi.common.utils.Arith; + +/** + * 內存相关信息 + * + * @author ruoyi + */ +public class Mem +{ + /** + * 内存总量 + */ + private double total; + + /** + * 已用内存 + */ + private double used; + + /** + * 剩余内存 + */ + private double free; + + public double getTotal() + { + return Arith.div(total, (1024 * 1024 * 1024), 2); + } + + public void setTotal(long total) + { + this.total = total; + } + + public double getUsed() + { + return Arith.div(used, (1024 * 1024 * 1024), 2); + } + + public void setUsed(long used) + { + this.used = used; + } + + public double getFree() + { + return Arith.div(free, (1024 * 1024 * 1024), 2); + } + + public void setFree(long free) + { + this.free = free; + } + + public double getUsage() + { + return Arith.mul(Arith.div(used, total, 4), 100); + } +} diff --git a/ruoyi-base-support/ruoyi-framework/src/main/java/com/ruoyi/framework/web/domain/server/Sys.java b/ruoyi-base-support/ruoyi-framework/src/main/java/com/ruoyi/framework/web/domain/server/Sys.java new file mode 100644 index 0000000..45d64d9 --- /dev/null +++ b/ruoyi-base-support/ruoyi-framework/src/main/java/com/ruoyi/framework/web/domain/server/Sys.java @@ -0,0 +1,84 @@ +package com.ruoyi.framework.web.domain.server; + +/** + * 系统相关信息 + * + * @author ruoyi + */ +public class Sys +{ + /** + * 服务器名称 + */ + private String computerName; + + /** + * 服务器Ip + */ + private String computerIp; + + /** + * 项目路径 + */ + private String userDir; + + /** + * 操作系统 + */ + private String osName; + + /** + * 系统架构 + */ + private String osArch; + + public String getComputerName() + { + return computerName; + } + + public void setComputerName(String computerName) + { + this.computerName = computerName; + } + + public String getComputerIp() + { + return computerIp; + } + + public void setComputerIp(String computerIp) + { + this.computerIp = computerIp; + } + + public String getUserDir() + { + return userDir; + } + + public void setUserDir(String userDir) + { + this.userDir = userDir; + } + + public String getOsName() + { + return osName; + } + + public void setOsName(String osName) + { + this.osName = osName; + } + + public String getOsArch() + { + return osArch; + } + + public void setOsArch(String osArch) + { + this.osArch = osArch; + } +} diff --git a/ruoyi-base-support/ruoyi-framework/src/main/java/com/ruoyi/framework/web/domain/server/SysFile.java b/ruoyi-base-support/ruoyi-framework/src/main/java/com/ruoyi/framework/web/domain/server/SysFile.java new file mode 100644 index 0000000..1320cde --- /dev/null +++ b/ruoyi-base-support/ruoyi-framework/src/main/java/com/ruoyi/framework/web/domain/server/SysFile.java @@ -0,0 +1,114 @@ +package com.ruoyi.framework.web.domain.server; + +/** + * 系统文件相关信息 + * + * @author ruoyi + */ +public class SysFile +{ + /** + * 盘符路径 + */ + private String dirName; + + /** + * 盘符类型 + */ + private String sysTypeName; + + /** + * 文件类型 + */ + private String typeName; + + /** + * 总大小 + */ + private String total; + + /** + * 剩余大小 + */ + private String free; + + /** + * 已经使用量 + */ + private String used; + + /** + * 资源的使用率 + */ + private double usage; + + public String getDirName() + { + return dirName; + } + + public void setDirName(String dirName) + { + this.dirName = dirName; + } + + public String getSysTypeName() + { + return sysTypeName; + } + + public void setSysTypeName(String sysTypeName) + { + this.sysTypeName = sysTypeName; + } + + public String getTypeName() + { + return typeName; + } + + public void setTypeName(String typeName) + { + this.typeName = typeName; + } + + public String getTotal() + { + return total; + } + + public void setTotal(String total) + { + this.total = total; + } + + public String getFree() + { + return free; + } + + public void setFree(String free) + { + this.free = free; + } + + public String getUsed() + { + return used; + } + + public void setUsed(String used) + { + this.used = used; + } + + public double getUsage() + { + return usage; + } + + public void setUsage(double usage) + { + this.usage = usage; + } +} diff --git a/ruoyi-base-support/ruoyi-framework/src/main/java/com/ruoyi/framework/web/exception/GlobalExceptionHandler.java b/ruoyi-base-support/ruoyi-framework/src/main/java/com/ruoyi/framework/web/exception/GlobalExceptionHandler.java new file mode 100644 index 0000000..cc8064b --- /dev/null +++ b/ruoyi-base-support/ruoyi-framework/src/main/java/com/ruoyi/framework/web/exception/GlobalExceptionHandler.java @@ -0,0 +1,115 @@ +package com.ruoyi.framework.web.exception; + +import com.ruoyi.common.constant.HttpStatus; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.exception.DemoModeException; +import com.ruoyi.common.exception.ServiceException; +import com.ruoyi.common.utils.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.security.access.AccessDeniedException; +import org.springframework.validation.BindException; +import org.springframework.web.HttpRequestMethodNotSupportedException; +import org.springframework.web.bind.MethodArgumentNotValidException; +import org.springframework.web.bind.annotation.ExceptionHandler; +import org.springframework.web.bind.annotation.RestControllerAdvice; + +import javax.servlet.http.HttpServletRequest; + +/** + * 全局异常处理器 + * + * @author ruoyi + */ +@RestControllerAdvice +public class GlobalExceptionHandler +{ + private static final Logger log = LoggerFactory.getLogger(GlobalExceptionHandler.class); + + /** + * 权限校验异常 + */ + @ExceptionHandler(AccessDeniedException.class) + public AjaxResult handleAccessDeniedException(AccessDeniedException e, HttpServletRequest request) + { + String requestURI = request.getRequestURI(); + log.error("请求地址'{}',权限校验失败'{}'", requestURI, e.getMessage()); + return AjaxResult.error(HttpStatus.FORBIDDEN, "没有权限,请联系管理员授权"); + } + + /** + * 请求方式不支持 + */ + @ExceptionHandler(HttpRequestMethodNotSupportedException.class) + public AjaxResult handleHttpRequestMethodNotSupported(HttpRequestMethodNotSupportedException e, + HttpServletRequest request) + { + String requestURI = request.getRequestURI(); + log.error("请求地址'{}',不支持'{}'请求", requestURI, e.getMethod()); + return AjaxResult.error(e.getMessage()); + } + + /** + * 业务异常 + */ + @ExceptionHandler(ServiceException.class) + public AjaxResult handleServiceException(ServiceException e, HttpServletRequest request) + { + log.error(e.getMessage(), e); + Integer code = e.getCode(); + return StringUtils.isNotNull(code) ? AjaxResult.error(code, e.getMessage()) : AjaxResult.error(e.getMessage()); + } + + /** + * 拦截未知的运行时异常 + */ + @ExceptionHandler(RuntimeException.class) + public AjaxResult handleRuntimeException(RuntimeException e, HttpServletRequest request) + { + String requestURI = request.getRequestURI(); + log.error("请求地址'{}',发生未知异常.", requestURI, e); + return AjaxResult.error(e.getMessage()); + } + + /** + * 系统异常 + */ + @ExceptionHandler(Exception.class) + public AjaxResult handleException(Exception e, HttpServletRequest request) + { + String requestURI = request.getRequestURI(); + log.error("请求地址'{}',发生系统异常.", requestURI, e); + return AjaxResult.error(e.getMessage()); + } + + /** + * 自定义验证异常 + */ + @ExceptionHandler(BindException.class) + public AjaxResult handleBindException(BindException e) + { + log.error(e.getMessage(), e); + String message = e.getAllErrors().get(0).getDefaultMessage(); + return AjaxResult.error(message); + } + + /** + * 自定义验证异常 + */ + @ExceptionHandler(MethodArgumentNotValidException.class) + public Object handleMethodArgumentNotValidException(MethodArgumentNotValidException e) + { + log.error(e.getMessage(), e); + String message = e.getBindingResult().getFieldError().getDefaultMessage(); + return AjaxResult.error(message); + } + + /** + * 演示模式异常 + */ + @ExceptionHandler(DemoModeException.class) + public AjaxResult handleDemoModeException(DemoModeException e) + { + return AjaxResult.error("演示模式,不允许操作"); + } +} diff --git a/ruoyi-base-support/ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/PermissionService.java b/ruoyi-base-support/ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/PermissionService.java new file mode 100644 index 0000000..e067c0e --- /dev/null +++ b/ruoyi-base-support/ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/PermissionService.java @@ -0,0 +1,166 @@ +package com.ruoyi.framework.web.service; + +import com.ruoyi.common.core.domain.entity.SysRole; +import com.ruoyi.common.core.domain.model.LoginUser; +import com.ruoyi.common.utils.SecurityUtils; +import com.ruoyi.common.utils.StringUtils; +import org.springframework.stereotype.Service; +import org.springframework.util.CollectionUtils; + +import java.util.Set; + +/** + * RuoYi首创 自定义权限实现,ss取自SpringSecurity首字母 + * + * @author ruoyi + */ +@Service("ss") +public class PermissionService +{ + /** 所有权限标识 */ + private static final String ALL_PERMISSION = "*:*:*"; + + /** 管理员角色权限标识 */ + private static final String SUPER_ADMIN = "admin"; + + private static final String ROLE_DELIMETER = ","; + + private static final String PERMISSION_DELIMETER = ","; + + /** + * 验证用户是否具备某权限 + * + * @param permission 权限字符串 + * @return 用户是否具备某权限 + */ + public boolean hasPermi(String permission) + { + if (StringUtils.isEmpty(permission)) + { + return false; + } + LoginUser loginUser = SecurityUtils.getLoginUser(); + if (StringUtils.isNull(loginUser) || CollectionUtils.isEmpty(loginUser.getPermissions())) + { + return false; + } + return hasPermissions(loginUser.getPermissions(), permission); + } + + /** + * 验证用户是否不具备某权限,与 hasPermi逻辑相反 + * + * @param permission 权限字符串 + * @return 用户是否不具备某权限 + */ + public boolean lacksPermi(String permission) + { + return hasPermi(permission) != true; + } + + /** + * 验证用户是否具有以下任意一个权限 + * + * @param permissions 以 PERMISSION_NAMES_DELIMETER 为分隔符的权限列表 + * @return 用户是否具有以下任意一个权限 + */ + public boolean hasAnyPermi(String permissions) + { + if (StringUtils.isEmpty(permissions)) + { + return false; + } + LoginUser loginUser = SecurityUtils.getLoginUser(); + if (StringUtils.isNull(loginUser) || CollectionUtils.isEmpty(loginUser.getPermissions())) + { + return false; + } + Set authorities = loginUser.getPermissions(); + for (String permission : permissions.split(PERMISSION_DELIMETER)) + { + if (permission != null && hasPermissions(authorities, permission)) + { + return true; + } + } + return false; + } + + /** + * 判断用户是否拥有某个角色 + * + * @param role 角色字符串 + * @return 用户是否具备某角色 + */ + public boolean hasRole(String role) + { + if (StringUtils.isEmpty(role)) + { + return false; + } + LoginUser loginUser = SecurityUtils.getLoginUser(); + if (StringUtils.isNull(loginUser) || CollectionUtils.isEmpty(loginUser.getUser().getRoles())) + { + return false; + } + for (SysRole sysRole : loginUser.getUser().getRoles()) + { + String roleKey = sysRole.getRoleKey(); + if (SUPER_ADMIN.equals(roleKey) || roleKey.equals(StringUtils.trim(role))) + { + return true; + } + } + return false; + } + + /** + * 验证用户是否不具备某角色,与 isRole逻辑相反。 + * + * @param role 角色名称 + * @return 用户是否不具备某角色 + */ + public boolean lacksRole(String role) + { + return hasRole(role) != true; + } + + /** + * 验证用户是否具有以下任意一个角色 + * + * @param roles 以 ROLE_NAMES_DELIMETER 为分隔符的角色列表 + * @return 用户是否具有以下任意一个角色 + */ + public boolean hasAnyRoles(String roles) + { + if (StringUtils.isEmpty(roles)) + { + return false; + } + LoginUser loginUser = SecurityUtils.getLoginUser(); + if (StringUtils.isNull(loginUser) || CollectionUtils.isEmpty(loginUser.getUser().getRoles())) + { + return false; + } + for (String role : roles.split(ROLE_DELIMETER)) + { + if (hasRole(role)) + { + return true; + } + } + return false; + } + + /** + * 判断是否包含权限 + * + * @param permissions 权限列表 + * @param permission 权限字符串 + * @return 用户是否具备某权限 + */ + private boolean hasPermissions(Set permissions, String permission) + { + return permissions.contains(ALL_PERMISSION) || permissions.contains(StringUtils.trim(permission)); + } +} diff --git a/ruoyi-base-support/ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/SysLoginService.java b/ruoyi-base-support/ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/SysLoginService.java new file mode 100644 index 0000000..62a90cc --- /dev/null +++ b/ruoyi-base-support/ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/SysLoginService.java @@ -0,0 +1,148 @@ +package com.ruoyi.framework.web.service; + +import cn.hutool.core.util.ObjectUtil; +import com.ruoyi.common.constant.Constants; +import com.ruoyi.common.core.domain.entity.SysRole; +import com.ruoyi.common.core.domain.entity.SysUser; +import com.ruoyi.common.core.domain.model.LoginUser; +import com.ruoyi.common.core.redis.RedisService; +import com.ruoyi.common.exception.ServiceException; +import com.ruoyi.common.exception.user.CaptchaException; +import com.ruoyi.common.exception.user.CaptchaExpireException; +import com.ruoyi.common.exception.user.UserPasswordNotMatchException; +import com.ruoyi.common.utils.DateUtils; +import com.ruoyi.common.utils.MessageUtils; +import com.ruoyi.common.utils.SecurityUtils; +import com.ruoyi.common.utils.ServletUtils; +import com.ruoyi.common.utils.ip.IpUtils; +import com.ruoyi.framework.manager.AsyncManager; +import com.ruoyi.framework.manager.factory.AsyncFactory; +import com.ruoyi.system.service.ISysConfigService; +import com.ruoyi.system.service.ISysUserService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.authentication.AuthenticationManager; +import org.springframework.security.authentication.BadCredentialsException; +import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; +import org.springframework.security.core.Authentication; +import org.springframework.stereotype.Component; + +import javax.annotation.Resource; +import java.util.Arrays; +import java.util.List; + +/** + * 登录校验方法 + * + * @author ruoyi + */ +@Component +public class SysLoginService +{ + @Autowired + private TokenService tokenService; + + @Resource + private AuthenticationManager authenticationManager; + + @Autowired + private RedisService redisCache; + + @Autowired + private ISysUserService userService; + + @Autowired + private ISysConfigService configService; + + /** + * 登录验证 + * + * @param loginType 登入类型 + * @param username 用户名 + * @param password 密码 + * @param code 验证码 + * @param uuid 唯一标识 + * @return 结果 + */ + public String login(String loginType,String username, String password, String code, String uuid) + { + boolean captchaOnOff = configService.selectCaptchaOnOff(); + // 验证码开关 + if (captchaOnOff) + { + validateCaptcha(username, code, uuid); + } + // 用户验证 + Authentication authentication = null; + try + { + // 该方法会去调用UserDetailsServiceImpl.loadUserByUsername + authentication = authenticationManager + .authenticate(new UsernamePasswordAuthenticationToken(username, password)); + } + catch (Exception e) + { + if (e instanceof BadCredentialsException) + { + AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_FAIL, MessageUtils.message("user.password.not.match"))); + throw new UserPasswordNotMatchException(); + } + else + { + AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_FAIL, e.getMessage())); + throw new ServiceException(e.getMessage()); + } + } + + LoginUser loginUser = (LoginUser) authentication.getPrincipal(); + + //判断登入类型 + if (ObjectUtil.notEqual(loginType,loginUser.getUser().getUserType())){ + AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_FAIL, MessageUtils.message("user.password.not.match"))); + throw new UserPasswordNotMatchException(); + } + + AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_SUCCESS, MessageUtils.message("user.login.success"))); + recordLoginInfo(loginUser.getUserId()); + // 生成token + return tokenService.createToken(loginUser); + } + + /** + * 校验验证码 + * + * @param username 用户名 + * @param code 验证码 + * @param uuid 唯一标识 + * @return 结果 + */ + public void validateCaptcha(String username, String code, String uuid) + { + String verifyKey = Constants.CAPTCHA_CODE_KEY + uuid; + String captcha = redisCache.getCacheObject(verifyKey); + redisCache.deleteObject(verifyKey); + if (captcha == null) + { + AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_FAIL, MessageUtils.message("user.jcaptcha.expire"))); + throw new CaptchaExpireException(); + } + if (!code.equalsIgnoreCase(captcha)) + { + AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_FAIL, MessageUtils.message("user.jcaptcha.error"))); + throw new CaptchaException(); + } + } + + /** + * 记录登录信息 + * + * @param userId 用户ID + */ + public void recordLoginInfo(Long userId) + { + SysUser sysUser = new SysUser(); + sysUser.setUserId(userId); + sysUser.setLoginIp(IpUtils.getIpAddr(ServletUtils.getRequest())); + sysUser.setLoginDate(DateUtils.getNowDate()); + userService.updateUserProfile(sysUser); + } +} diff --git a/ruoyi-base-support/ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/SysPermissionService.java b/ruoyi-base-support/ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/SysPermissionService.java new file mode 100644 index 0000000..6c25c54 --- /dev/null +++ b/ruoyi-base-support/ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/SysPermissionService.java @@ -0,0 +1,67 @@ +package com.ruoyi.framework.web.service; + +import com.ruoyi.common.core.domain.entity.SysUser; +import com.ruoyi.system.service.ISysMenuService; +import com.ruoyi.system.service.ISysRoleService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import java.util.HashSet; +import java.util.Set; + +/** + * 用户权限处理 + * + * @author ruoyi + */ +@Component +public class SysPermissionService +{ + @Autowired + private ISysRoleService roleService; + + @Autowired + private ISysMenuService menuService; + + /** + * 获取角色数据权限 + * + * @param user 用户信息 + * @return 角色权限信息 + */ + public Set getRolePermission(SysUser user) + { + Set roles = new HashSet(); + // 管理员拥有所有权限 + if (user.isAdmin()) + { + roles.add("admin"); + } + else + { + roles.addAll(roleService.selectRolePermissionByUserId(user.getUserId())); + } + return roles; + } + + /** + * 获取菜单数据权限 + * + * @param user 用户信息 + * @return 菜单权限信息 + */ + public Set getMenuPermission(SysUser user) + { + Set perms = new HashSet(); + // 管理员拥有所有权限 + if (user.isAdmin()) + { + perms.add("*:*:*"); + } + else + { + perms.addAll(menuService.selectMenuPermsByUserId(user.getUserId())); + } + return perms; + } +} diff --git a/ruoyi-base-support/ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/SysRegisterService.java b/ruoyi-base-support/ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/SysRegisterService.java new file mode 100644 index 0000000..f6f9b43 --- /dev/null +++ b/ruoyi-base-support/ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/SysRegisterService.java @@ -0,0 +1,115 @@ +package com.ruoyi.framework.web.service; + +import com.ruoyi.common.constant.Constants; +import com.ruoyi.common.constant.UserConstants; +import com.ruoyi.common.core.domain.entity.SysUser; +import com.ruoyi.common.core.domain.model.RegisterBody; +import com.ruoyi.common.core.redis.RedisService; +import com.ruoyi.common.exception.user.CaptchaException; +import com.ruoyi.common.exception.user.CaptchaExpireException; +import com.ruoyi.common.utils.MessageUtils; +import com.ruoyi.common.utils.SecurityUtils; +import com.ruoyi.common.utils.StringUtils; +import com.ruoyi.framework.manager.AsyncManager; +import com.ruoyi.framework.manager.factory.AsyncFactory; +import com.ruoyi.system.service.ISysConfigService; +import com.ruoyi.system.service.ISysUserService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +/** + * 注册校验方法 + * + * @author ruoyi + */ +@Component +public class SysRegisterService +{ + @Autowired + private ISysUserService userService; + + @Autowired + private ISysConfigService configService; + + @Autowired + private RedisService redisCache; + + /** + * 注册 + */ + public String register(RegisterBody registerBody) + { + String msg = "", username = registerBody.getUsername(), password = registerBody.getPassword(); + + boolean captchaOnOff = configService.selectCaptchaOnOff(); + // 验证码开关 + if (captchaOnOff) + { + validateCaptcha(username, registerBody.getCode(), registerBody.getUuid()); + } + + if (StringUtils.isEmpty(username)) + { + msg = "用户名不能为空"; + } + else if (StringUtils.isEmpty(password)) + { + msg = "用户密码不能为空"; + } + else if (username.length() < UserConstants.USERNAME_MIN_LENGTH + || username.length() > UserConstants.USERNAME_MAX_LENGTH) + { + msg = "账户长度必须在2到20个字符之间"; + } + else if (password.length() < UserConstants.PASSWORD_MIN_LENGTH + || password.length() > UserConstants.PASSWORD_MAX_LENGTH) + { + msg = "密码长度必须在5到20个字符之间"; + } + else if (UserConstants.NOT_UNIQUE.equals(userService.checkUserNameUnique(username))) + { + msg = "保存用户'" + username + "'失败,注册账号已存在"; + } + else + { + SysUser sysUser = new SysUser(); + sysUser.setUserName(username); + sysUser.setNickName(username); + sysUser.setPassword(SecurityUtils.encryptPassword(registerBody.getPassword())); + boolean regFlag = userService.registerUser(sysUser); + if (!regFlag) + { + msg = "注册失败,请联系系统管理人员"; + } + else + { + AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.REGISTER, + MessageUtils.message("user.register.success"))); + } + } + return msg; + } + + /** + * 校验验证码 + * + * @param username 用户名 + * @param code 验证码 + * @param uuid 唯一标识 + * @return 结果 + */ + public void validateCaptcha(String username, String code, String uuid) + { + String verifyKey = Constants.CAPTCHA_CODE_KEY + uuid; + String captcha = redisCache.getCacheObject(verifyKey); + redisCache.deleteObject(verifyKey); + if (captcha == null) + { + throw new CaptchaExpireException(); + } + if (!code.equalsIgnoreCase(captcha)) + { + throw new CaptchaException(); + } + } +} diff --git a/ruoyi-base-support/ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/TokenService.java b/ruoyi-base-support/ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/TokenService.java new file mode 100644 index 0000000..5c5ed0d --- /dev/null +++ b/ruoyi-base-support/ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/TokenService.java @@ -0,0 +1,226 @@ +package com.ruoyi.framework.web.service; + +import com.ruoyi.common.constant.Constants; +import com.ruoyi.common.core.domain.model.LoginUser; +import com.ruoyi.common.core.redis.RedisService; +import com.ruoyi.common.utils.ServletUtils; +import com.ruoyi.common.utils.StringUtils; +import com.ruoyi.common.utils.ip.AddressUtils; +import com.ruoyi.common.utils.ip.IpUtils; +import com.ruoyi.common.utils.uuid.IdUtils; +import eu.bitwalker.useragentutils.UserAgent; +import io.jsonwebtoken.Claims; +import io.jsonwebtoken.Jwts; +import io.jsonwebtoken.SignatureAlgorithm; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Component; + +import javax.servlet.http.HttpServletRequest; +import java.util.HashMap; +import java.util.Map; +import java.util.concurrent.TimeUnit; + +/** + * token验证处理 + * + * @author ruoyi + */ +@Component +public class TokenService +{ + // 令牌自定义标识 + @Value("${token.header}") + private String header; + + // 令牌秘钥 + @Value("${token.secret}") + private String secret; + + // 令牌有效期(默认30分钟) + @Value("${token.expireTime}") + private int expireTime; + + protected static final long MILLIS_SECOND = 1000; + + protected static final long MILLIS_MINUTE = 60 * MILLIS_SECOND; + + private static final Long MILLIS_MINUTE_TEN = 20 * 60 * 1000L; + + @Autowired + private RedisService redisCache; + + /** + * 获取用户身份信息 + * + * @return 用户信息 + */ + public LoginUser getLoginUser(HttpServletRequest request) + { + // 获取请求携带的令牌 + String token = getToken(request); + if (StringUtils.isNotEmpty(token)) + { + try + { + Claims claims = parseToken(token); + // 解析对应的权限以及用户信息 + String uuid = (String) claims.get(Constants.LOGIN_USER_KEY); + String userKey = getTokenKey(uuid); + LoginUser user = redisCache.getCacheObject(userKey); + return user; + } + catch (Exception e) + { + } + } + return null; + } + + /** + * 设置用户身份信息 + */ + public void setLoginUser(LoginUser loginUser) + { + if (StringUtils.isNotNull(loginUser) && StringUtils.isNotEmpty(loginUser.getToken())) + { + refreshToken(loginUser); + } + } + + /** + * 删除用户身份信息 + */ + public void delLoginUser(String token) + { + if (StringUtils.isNotEmpty(token)) + { + String userKey = getTokenKey(token); + redisCache.deleteObject(userKey); + } + } + + /** + * 创建令牌 + * + * @param loginUser 用户信息 + * @return 令牌 + */ + public String createToken(LoginUser loginUser) + { + String token = IdUtils.fastUUID(); + loginUser.setToken(token); + setUserAgent(loginUser); + refreshToken(loginUser); + + Map claims = new HashMap<>(); + claims.put(Constants.LOGIN_USER_KEY, token); + return createToken(claims); + } + + /** + * 验证令牌有效期,相差不足20分钟,自动刷新缓存 + * + * @param loginUser + * @return 令牌 + */ + public void verifyToken(LoginUser loginUser) + { + long expireTime = loginUser.getExpireTime(); + long currentTime = System.currentTimeMillis(); + if (expireTime - currentTime <= MILLIS_MINUTE_TEN) + { + refreshToken(loginUser); + } + } + + /** + * 刷新令牌有效期 + * + * @param loginUser 登录信息 + */ + public void refreshToken(LoginUser loginUser) + { + loginUser.setLoginTime(System.currentTimeMillis()); + loginUser.setExpireTime(loginUser.getLoginTime() + expireTime * MILLIS_MINUTE); + // 根据uuid将loginUser缓存 + String userKey = getTokenKey(loginUser.getToken()); + redisCache.setCacheObject(userKey, loginUser, expireTime, TimeUnit.MINUTES); + } + + /** + * 设置用户代理信息 + * + * @param loginUser 登录信息 + */ + public void setUserAgent(LoginUser loginUser) + { + UserAgent userAgent = UserAgent.parseUserAgentString(ServletUtils.getRequest().getHeader("User-Agent")); + String ip = IpUtils.getIpAddr(ServletUtils.getRequest()); + loginUser.setIpaddr(ip); + loginUser.setLoginLocation(AddressUtils.getRealAddressByIP(ip)); + loginUser.setBrowser(userAgent.getBrowser().getName()); + loginUser.setOs(userAgent.getOperatingSystem().getName()); + } + + /** + * 从数据声明生成令牌 + * + * @param claims 数据声明 + * @return 令牌 + */ + private String createToken(Map claims) + { + String token = Jwts.builder() + .setClaims(claims) + .signWith(SignatureAlgorithm.HS512, secret).compact(); + return token; + } + + /** + * 从令牌中获取数据声明 + * + * @param token 令牌 + * @return 数据声明 + */ + private Claims parseToken(String token) + { + return Jwts.parser() + .setSigningKey(secret) + .parseClaimsJws(token) + .getBody(); + } + + /** + * 从令牌中获取用户名 + * + * @param token 令牌 + * @return 用户名 + */ + public String getUsernameFromToken(String token) + { + Claims claims = parseToken(token); + return claims.getSubject(); + } + + /** + * 获取请求token + * + * @param request + * @return token + */ + private String getToken(HttpServletRequest request) + { + String token = request.getHeader(header); + if (StringUtils.isNotEmpty(token) && token.startsWith(Constants.TOKEN_PREFIX)) + { + token = token.replace(Constants.TOKEN_PREFIX, ""); + } + return token; + } + + private String getTokenKey(String uuid) + { + return Constants.LOGIN_TOKEN_KEY + uuid; + } +} diff --git a/ruoyi-base-support/ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/UserDetailsServiceImpl.java b/ruoyi-base-support/ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/UserDetailsServiceImpl.java new file mode 100644 index 0000000..ad1c7fb --- /dev/null +++ b/ruoyi-base-support/ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/UserDetailsServiceImpl.java @@ -0,0 +1,60 @@ +package com.ruoyi.framework.web.service; + +import com.ruoyi.common.core.domain.entity.SysUser; +import com.ruoyi.common.core.domain.model.LoginUser; +import com.ruoyi.common.enums.UserStatus; +import com.ruoyi.common.exception.ServiceException; +import com.ruoyi.common.utils.StringUtils; +import com.ruoyi.system.service.ISysUserService; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.core.userdetails.UserDetails; +import org.springframework.security.core.userdetails.UserDetailsService; +import org.springframework.security.core.userdetails.UsernameNotFoundException; +import org.springframework.stereotype.Service; + +/** + * 用户验证处理 + * + * @author ruoyi + */ +@Service +public class UserDetailsServiceImpl implements UserDetailsService +{ + private static final Logger log = LoggerFactory.getLogger(UserDetailsServiceImpl.class); + + @Autowired + private ISysUserService userService; + + @Autowired + private SysPermissionService permissionService; + + @Override + public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException + { + SysUser user = userService.selectUserByUserName(username); + if (StringUtils.isNull(user)) + { + log.info("登录用户:{} 不存在.", username); + throw new ServiceException("登录用户:" + username + " 不存在"); + } + else if (UserStatus.DELETED.getCode().equals(user.getDelFlag())) + { + log.info("登录用户:{} 已被删除.", username); + throw new ServiceException("对不起,您的账号:" + username + " 已被删除"); + } + else if (UserStatus.DISABLE.getCode().equals(user.getStatus())) + { + log.info("登录用户:{} 已被停用.", username); + throw new ServiceException("对不起,您的账号:" + username + " 已停用"); + } + + return createLoginUser(user); + } + + public UserDetails createLoginUser(SysUser user) + { + return new LoginUser(user, permissionService.getMenuPermission(user)); + } +} diff --git a/ruoyi-base-support/ruoyi-generator/pom.xml b/ruoyi-base-support/ruoyi-generator/pom.xml new file mode 100644 index 0000000..33e7511 --- /dev/null +++ b/ruoyi-base-support/ruoyi-generator/pom.xml @@ -0,0 +1,40 @@ + + + + ruoyi-base-support + com.ruoyi + 3.7.0 + + 4.0.0 + + ruoyi-generator + + + generator代码生成 + + + + + + + org.apache.velocity + velocity + + + + + commons-collections + commons-collections + + + + + com.ruoyi + ruoyi-common + + + + + \ No newline at end of file diff --git a/ruoyi-base-support/ruoyi-generator/src/main/java/com/ruoyi/generator/config/GenConfig.java b/ruoyi-base-support/ruoyi-generator/src/main/java/com/ruoyi/generator/config/GenConfig.java new file mode 100644 index 0000000..cc4cd14 --- /dev/null +++ b/ruoyi-base-support/ruoyi-generator/src/main/java/com/ruoyi/generator/config/GenConfig.java @@ -0,0 +1,73 @@ +package com.ruoyi.generator.config; + +import org.springframework.beans.factory.annotation.Value; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.context.annotation.PropertySource; +import org.springframework.stereotype.Component; + +/** + * 读取代码生成相关配置 + * + * @author ruoyi + */ +@Component +@ConfigurationProperties(prefix = "gen") +@PropertySource(value = { "classpath:generator.yml" }) +public class GenConfig +{ + /** 作者 */ + public static String author; + + /** 生成包路径 */ + public static String packageName; + + /** 自动去除表前缀,默认是false */ + public static boolean autoRemovePre; + + /** 表前缀(类名不会包含表前缀) */ + public static String tablePrefix; + + public static String getAuthor() + { + return author; + } + + @Value("${author}") + public void setAuthor(String author) + { + GenConfig.author = author; + } + + public static String getPackageName() + { + return packageName; + } + + @Value("${packageName}") + public void setPackageName(String packageName) + { + GenConfig.packageName = packageName; + } + + public static boolean getAutoRemovePre() + { + return autoRemovePre; + } + + @Value("${autoRemovePre}") + public void setAutoRemovePre(boolean autoRemovePre) + { + GenConfig.autoRemovePre = autoRemovePre; + } + + public static String getTablePrefix() + { + return tablePrefix; + } + + @Value("${tablePrefix}") + public void setTablePrefix(String tablePrefix) + { + GenConfig.tablePrefix = tablePrefix; + } +} diff --git a/ruoyi-base-support/ruoyi-generator/src/main/java/com/ruoyi/generator/controller/GenController.java b/ruoyi-base-support/ruoyi-generator/src/main/java/com/ruoyi/generator/controller/GenController.java new file mode 100644 index 0000000..6dfe5e3 --- /dev/null +++ b/ruoyi-base-support/ruoyi-generator/src/main/java/com/ruoyi/generator/controller/GenController.java @@ -0,0 +1,214 @@ +package com.ruoyi.generator.controller; + +import java.io.IOException; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import javax.servlet.http.HttpServletResponse; +import org.apache.commons.io.IOUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.page.TableDataInfo; +import com.ruoyi.common.core.text.Convert; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.generator.domain.GenTable; +import com.ruoyi.generator.domain.GenTableColumn; +import com.ruoyi.generator.service.IGenTableColumnService; +import com.ruoyi.generator.service.IGenTableService; + +/** + * 代码生成 操作处理 + * + * @author ruoyi + */ +@RestController +@RequestMapping("/tool/gen") +public class GenController extends BaseController +{ + @Autowired + private IGenTableService genTableService; + + @Autowired + private IGenTableColumnService genTableColumnService; + + /** + * 查询代码生成列表 + */ + @PreAuthorize("@ss.hasPermi('tool:gen:list')") + @GetMapping("/list") + public TableDataInfo genList(GenTable genTable) + { + startPage(); + List list = genTableService.selectGenTableList(genTable); + return getDataTable(list); + } + + /** + * 修改代码生成业务 + */ + @PreAuthorize("@ss.hasPermi('tool:gen:query')") + @GetMapping(value = "/{talbleId}") + public AjaxResult getInfo(@PathVariable Long talbleId) + { + GenTable table = genTableService.selectGenTableById(talbleId); + List tables = genTableService.selectGenTableAll(); + List list = genTableColumnService.selectGenTableColumnListByTableId(talbleId); + Map map = new HashMap(); + map.put("info", table); + map.put("rows", list); + map.put("tables", tables); + return AjaxResult.success(map); + } + + /** + * 查询数据库列表 + */ + @PreAuthorize("@ss.hasPermi('tool:gen:list')") + @GetMapping("/db/list") + public TableDataInfo dataList(GenTable genTable) + { + startPage(); + List list = genTableService.selectDbTableList(genTable); + return getDataTable(list); + } + + /** + * 查询数据表字段列表 + */ + @PreAuthorize("@ss.hasPermi('tool:gen:list')") + @GetMapping(value = "/column/{talbleId}") + public TableDataInfo columnList(Long tableId) + { + TableDataInfo dataInfo = new TableDataInfo(); + List list = genTableColumnService.selectGenTableColumnListByTableId(tableId); + dataInfo.setRows(list); + dataInfo.setTotal(list.size()); + return dataInfo; + } + + /** + * 导入表结构(保存) + */ + @PreAuthorize("@ss.hasPermi('tool:gen:import')") + @Log(title = "代码生成", businessType = BusinessType.IMPORT) + @PostMapping("/importTable") + public AjaxResult importTableSave(String tables) + { + String[] tableNames = Convert.toStrArray(tables); + // 查询表信息 + List tableList = genTableService.selectDbTableListByNames(tableNames); + genTableService.importGenTable(tableList); + return AjaxResult.success(); + } + + /** + * 修改保存代码生成业务 + */ + @PreAuthorize("@ss.hasPermi('tool:gen:edit')") + @Log(title = "代码生成", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult editSave(@Validated @RequestBody GenTable genTable) + { + genTableService.validateEdit(genTable); + genTableService.updateGenTable(genTable); + return AjaxResult.success(); + } + + /** + * 删除代码生成 + */ + @PreAuthorize("@ss.hasPermi('tool:gen:remove')") + @Log(title = "代码生成", businessType = BusinessType.DELETE) + @DeleteMapping("/{tableIds}") + public AjaxResult remove(@PathVariable Long[] tableIds) + { + genTableService.deleteGenTableByIds(tableIds); + return AjaxResult.success(); + } + + /** + * 预览代码 + */ + @PreAuthorize("@ss.hasPermi('tool:gen:preview')") + @GetMapping("/preview/{tableId}") + public AjaxResult preview(@PathVariable("tableId") Long tableId) throws IOException + { + Map dataMap = genTableService.previewCode(tableId); + return AjaxResult.success(dataMap); + } + + /** + * 生成代码(下载方式) + */ + @PreAuthorize("@ss.hasPermi('tool:gen:code')") + @Log(title = "代码生成", businessType = BusinessType.GENCODE) + @GetMapping("/download/{tableName}") + public void download(HttpServletResponse response, @PathVariable("tableName") String tableName) throws IOException + { + byte[] data = genTableService.downloadCode(tableName); + genCode(response, data); + } + + /** + * 生成代码(自定义路径) + */ + @PreAuthorize("@ss.hasPermi('tool:gen:code')") + @Log(title = "代码生成", businessType = BusinessType.GENCODE) + @GetMapping("/genCode/{tableName}") + public AjaxResult genCode(@PathVariable("tableName") String tableName) + { + genTableService.generatorCode(tableName); + return AjaxResult.success(); + } + + /** + * 同步数据库 + */ + @PreAuthorize("@ss.hasPermi('tool:gen:edit')") + @Log(title = "代码生成", businessType = BusinessType.UPDATE) + @GetMapping("/synchDb/{tableName}") + public AjaxResult synchDb(@PathVariable("tableName") String tableName) + { + genTableService.synchDb(tableName); + return AjaxResult.success(); + } + + /** + * 批量生成代码 + */ + @PreAuthorize("@ss.hasPermi('tool:gen:code')") + @Log(title = "代码生成", businessType = BusinessType.GENCODE) + @GetMapping("/batchGenCode") + public void batchGenCode(HttpServletResponse response, String tables) throws IOException + { + String[] tableNames = Convert.toStrArray(tables); + byte[] data = genTableService.downloadCode(tableNames); + genCode(response, data); + } + + /** + * 生成zip文件 + */ + private void genCode(HttpServletResponse response, byte[] data) throws IOException + { + response.reset(); + response.addHeader("Access-Control-Allow-Origin", "*"); + response.addHeader("Access-Control-Expose-Headers", "Content-Disposition"); + response.setHeader("Content-Disposition", "attachment; filename=\"ruoyi.zip\""); + response.addHeader("Content-Length", "" + data.length); + response.setContentType("application/octet-stream; charset=UTF-8"); + IOUtils.write(data, response.getOutputStream()); + } +} \ No newline at end of file diff --git a/ruoyi-base-support/ruoyi-generator/src/main/java/com/ruoyi/generator/domain/GenTable.java b/ruoyi-base-support/ruoyi-generator/src/main/java/com/ruoyi/generator/domain/GenTable.java new file mode 100644 index 0000000..269779c --- /dev/null +++ b/ruoyi-base-support/ruoyi-generator/src/main/java/com/ruoyi/generator/domain/GenTable.java @@ -0,0 +1,372 @@ +package com.ruoyi.generator.domain; + +import java.util.List; +import javax.validation.Valid; +import javax.validation.constraints.NotBlank; +import org.apache.commons.lang3.ArrayUtils; +import com.ruoyi.common.constant.GenConstants; +import com.ruoyi.common.core.domain.BaseEntity; +import com.ruoyi.common.utils.StringUtils; + +/** + * 业务表 gen_table + * + * @author ruoyi + */ +public class GenTable extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** 编号 */ + private Long tableId; + + /** 表名称 */ + @NotBlank(message = "表名称不能为空") + private String tableName; + + /** 表描述 */ + @NotBlank(message = "表描述不能为空") + private String tableComment; + + /** 关联父表的表名 */ + private String subTableName; + + /** 本表关联父表的外键名 */ + private String subTableFkName; + + /** 实体类名称(首字母大写) */ + @NotBlank(message = "实体类名称不能为空") + private String className; + + /** 使用的模板(crud单表操作 tree树表操作 sub主子表操作) */ + private String tplCategory; + + /** 生成包路径 */ + @NotBlank(message = "生成包路径不能为空") + private String packageName; + + /** 生成模块名 */ + @NotBlank(message = "生成模块名不能为空") + private String moduleName; + + /** 生成业务名 */ + @NotBlank(message = "生成业务名不能为空") + private String businessName; + + /** 生成功能名 */ + @NotBlank(message = "生成功能名不能为空") + private String functionName; + + /** 生成作者 */ + @NotBlank(message = "作者不能为空") + private String functionAuthor; + + /** 生成代码方式(0zip压缩包 1自定义路径) */ + private String genType; + + /** 生成路径(不填默认项目路径) */ + private String genPath; + + /** 主键信息 */ + private GenTableColumn pkColumn; + + /** 子表信息 */ + private GenTable subTable; + + /** 表列信息 */ + @Valid + private List columns; + + /** 其它生成选项 */ + private String options; + + /** 树编码字段 */ + private String treeCode; + + /** 树父编码字段 */ + private String treeParentCode; + + /** 树名称字段 */ + private String treeName; + + /** 上级菜单ID字段 */ + private String parentMenuId; + + /** 上级菜单名称字段 */ + private String parentMenuName; + + public Long getTableId() + { + return tableId; + } + + public void setTableId(Long tableId) + { + this.tableId = tableId; + } + + public String getTableName() + { + return tableName; + } + + public void setTableName(String tableName) + { + this.tableName = tableName; + } + + public String getTableComment() + { + return tableComment; + } + + public void setTableComment(String tableComment) + { + this.tableComment = tableComment; + } + + public String getSubTableName() + { + return subTableName; + } + + public void setSubTableName(String subTableName) + { + this.subTableName = subTableName; + } + + public String getSubTableFkName() + { + return subTableFkName; + } + + public void setSubTableFkName(String subTableFkName) + { + this.subTableFkName = subTableFkName; + } + + public String getClassName() + { + return className; + } + + public void setClassName(String className) + { + this.className = className; + } + + public String getTplCategory() + { + return tplCategory; + } + + public void setTplCategory(String tplCategory) + { + this.tplCategory = tplCategory; + } + + public String getPackageName() + { + return packageName; + } + + public void setPackageName(String packageName) + { + this.packageName = packageName; + } + + public String getModuleName() + { + return moduleName; + } + + public void setModuleName(String moduleName) + { + this.moduleName = moduleName; + } + + public String getBusinessName() + { + return businessName; + } + + public void setBusinessName(String businessName) + { + this.businessName = businessName; + } + + public String getFunctionName() + { + return functionName; + } + + public void setFunctionName(String functionName) + { + this.functionName = functionName; + } + + public String getFunctionAuthor() + { + return functionAuthor; + } + + public void setFunctionAuthor(String functionAuthor) + { + this.functionAuthor = functionAuthor; + } + + public String getGenType() + { + return genType; + } + + public void setGenType(String genType) + { + this.genType = genType; + } + + public String getGenPath() + { + return genPath; + } + + public void setGenPath(String genPath) + { + this.genPath = genPath; + } + + public GenTableColumn getPkColumn() + { + return pkColumn; + } + + public void setPkColumn(GenTableColumn pkColumn) + { + this.pkColumn = pkColumn; + } + + public GenTable getSubTable() + { + return subTable; + } + + public void setSubTable(GenTable subTable) + { + this.subTable = subTable; + } + + public List getColumns() + { + return columns; + } + + public void setColumns(List columns) + { + this.columns = columns; + } + + public String getOptions() + { + return options; + } + + public void setOptions(String options) + { + this.options = options; + } + + public String getTreeCode() + { + return treeCode; + } + + public void setTreeCode(String treeCode) + { + this.treeCode = treeCode; + } + + public String getTreeParentCode() + { + return treeParentCode; + } + + public void setTreeParentCode(String treeParentCode) + { + this.treeParentCode = treeParentCode; + } + + public String getTreeName() + { + return treeName; + } + + public void setTreeName(String treeName) + { + this.treeName = treeName; + } + + public String getParentMenuId() + { + return parentMenuId; + } + + public void setParentMenuId(String parentMenuId) + { + this.parentMenuId = parentMenuId; + } + + public String getParentMenuName() + { + return parentMenuName; + } + + public void setParentMenuName(String parentMenuName) + { + this.parentMenuName = parentMenuName; + } + + public boolean isSub() + { + return isSub(this.tplCategory); + } + + public static boolean isSub(String tplCategory) + { + return tplCategory != null && StringUtils.equals(GenConstants.TPL_SUB, tplCategory); + } + + public boolean isTree() + { + return isTree(this.tplCategory); + } + + public static boolean isTree(String tplCategory) + { + return tplCategory != null && StringUtils.equals(GenConstants.TPL_TREE, tplCategory); + } + + public boolean isCrud() + { + return isCrud(this.tplCategory); + } + + public static boolean isCrud(String tplCategory) + { + return tplCategory != null && StringUtils.equals(GenConstants.TPL_CRUD, tplCategory); + } + + public boolean isSuperColumn(String javaField) + { + return isSuperColumn(this.tplCategory, javaField); + } + + public static boolean isSuperColumn(String tplCategory, String javaField) + { + if (isTree(tplCategory)) + { + return StringUtils.equalsAnyIgnoreCase(javaField, + ArrayUtils.addAll(GenConstants.TREE_ENTITY, GenConstants.BASE_ENTITY)); + } + return StringUtils.equalsAnyIgnoreCase(javaField, GenConstants.BASE_ENTITY); + } +} \ No newline at end of file diff --git a/ruoyi-base-support/ruoyi-generator/src/main/java/com/ruoyi/generator/domain/GenTableColumn.java b/ruoyi-base-support/ruoyi-generator/src/main/java/com/ruoyi/generator/domain/GenTableColumn.java new file mode 100644 index 0000000..d1733b6 --- /dev/null +++ b/ruoyi-base-support/ruoyi-generator/src/main/java/com/ruoyi/generator/domain/GenTableColumn.java @@ -0,0 +1,373 @@ +package com.ruoyi.generator.domain; + +import javax.validation.constraints.NotBlank; +import com.ruoyi.common.core.domain.BaseEntity; +import com.ruoyi.common.utils.StringUtils; + +/** + * 代码生成业务字段表 gen_table_column + * + * @author ruoyi + */ +public class GenTableColumn extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** 编号 */ + private Long columnId; + + /** 归属表编号 */ + private Long tableId; + + /** 列名称 */ + private String columnName; + + /** 列描述 */ + private String columnComment; + + /** 列类型 */ + private String columnType; + + /** JAVA类型 */ + private String javaType; + + /** JAVA字段名 */ + @NotBlank(message = "Java属性不能为空") + private String javaField; + + /** 是否主键(1是) */ + private String isPk; + + /** 是否自增(1是) */ + private String isIncrement; + + /** 是否必填(1是) */ + private String isRequired; + + /** 是否为插入字段(1是) */ + private String isInsert; + + /** 是否编辑字段(1是) */ + private String isEdit; + + /** 是否列表字段(1是) */ + private String isList; + + /** 是否查询字段(1是) */ + private String isQuery; + + /** 查询方式(EQ等于、NE不等于、GT大于、LT小于、LIKE模糊、BETWEEN范围) */ + private String queryType; + + /** 显示类型(input文本框、textarea文本域、select下拉框、checkbox复选框、radio单选框、datetime日期控件、image图片上传控件、upload文件上传控件、editor富文本控件) */ + private String htmlType; + + /** 字典类型 */ + private String dictType; + + /** 排序 */ + private Integer sort; + + public void setColumnId(Long columnId) + { + this.columnId = columnId; + } + + public Long getColumnId() + { + return columnId; + } + + public void setTableId(Long tableId) + { + this.tableId = tableId; + } + + public Long getTableId() + { + return tableId; + } + + public void setColumnName(String columnName) + { + this.columnName = columnName; + } + + public String getColumnName() + { + return columnName; + } + + public void setColumnComment(String columnComment) + { + this.columnComment = columnComment; + } + + public String getColumnComment() + { + return columnComment; + } + + public void setColumnType(String columnType) + { + this.columnType = columnType; + } + + public String getColumnType() + { + return columnType; + } + + public void setJavaType(String javaType) + { + this.javaType = javaType; + } + + public String getJavaType() + { + return javaType; + } + + public void setJavaField(String javaField) + { + this.javaField = javaField; + } + + public String getJavaField() + { + return javaField; + } + + public String getCapJavaField() + { + return StringUtils.capitalize(javaField); + } + + public void setIsPk(String isPk) + { + this.isPk = isPk; + } + + public String getIsPk() + { + return isPk; + } + + public boolean isPk() + { + return isPk(this.isPk); + } + + public boolean isPk(String isPk) + { + return isPk != null && StringUtils.equals("1", isPk); + } + + public String getIsIncrement() + { + return isIncrement; + } + + public void setIsIncrement(String isIncrement) + { + this.isIncrement = isIncrement; + } + + public boolean isIncrement() + { + return isIncrement(this.isIncrement); + } + + public boolean isIncrement(String isIncrement) + { + return isIncrement != null && StringUtils.equals("1", isIncrement); + } + + public void setIsRequired(String isRequired) + { + this.isRequired = isRequired; + } + + public String getIsRequired() + { + return isRequired; + } + + public boolean isRequired() + { + return isRequired(this.isRequired); + } + + public boolean isRequired(String isRequired) + { + return isRequired != null && StringUtils.equals("1", isRequired); + } + + public void setIsInsert(String isInsert) + { + this.isInsert = isInsert; + } + + public String getIsInsert() + { + return isInsert; + } + + public boolean isInsert() + { + return isInsert(this.isInsert); + } + + public boolean isInsert(String isInsert) + { + return isInsert != null && StringUtils.equals("1", isInsert); + } + + public void setIsEdit(String isEdit) + { + this.isEdit = isEdit; + } + + public String getIsEdit() + { + return isEdit; + } + + public boolean isEdit() + { + return isInsert(this.isEdit); + } + + public boolean isEdit(String isEdit) + { + return isEdit != null && StringUtils.equals("1", isEdit); + } + + public void setIsList(String isList) + { + this.isList = isList; + } + + public String getIsList() + { + return isList; + } + + public boolean isList() + { + return isList(this.isList); + } + + public boolean isList(String isList) + { + return isList != null && StringUtils.equals("1", isList); + } + + public void setIsQuery(String isQuery) + { + this.isQuery = isQuery; + } + + public String getIsQuery() + { + return isQuery; + } + + public boolean isQuery() + { + return isQuery(this.isQuery); + } + + public boolean isQuery(String isQuery) + { + return isQuery != null && StringUtils.equals("1", isQuery); + } + + public void setQueryType(String queryType) + { + this.queryType = queryType; + } + + public String getQueryType() + { + return queryType; + } + + public String getHtmlType() + { + return htmlType; + } + + public void setHtmlType(String htmlType) + { + this.htmlType = htmlType; + } + + public void setDictType(String dictType) + { + this.dictType = dictType; + } + + public String getDictType() + { + return dictType; + } + + public void setSort(Integer sort) + { + this.sort = sort; + } + + public Integer getSort() + { + return sort; + } + + public boolean isSuperColumn() + { + return isSuperColumn(this.javaField); + } + + public static boolean isSuperColumn(String javaField) + { + return StringUtils.equalsAnyIgnoreCase(javaField, + // BaseEntity + "createBy", "createTime", "updateBy", "updateTime", "remark", + // TreeEntity + "parentName", "parentId", "orderNum", "ancestors"); + } + + public boolean isUsableColumn() + { + return isUsableColumn(javaField); + } + + public static boolean isUsableColumn(String javaField) + { + // isSuperColumn()中的名单用于避免生成多余Domain属性,若某些属性在生成页面时需要用到不能忽略,则放在此处白名单 + return StringUtils.equalsAnyIgnoreCase(javaField, "parentId", "orderNum", "remark"); + } + + public String readConverterExp() + { + String remarks = StringUtils.substringBetween(this.columnComment, "(", ")"); + StringBuffer sb = new StringBuffer(); + if (StringUtils.isNotEmpty(remarks)) + { + for (String value : remarks.split(" ")) + { + if (StringUtils.isNotEmpty(value)) + { + Object startStr = value.subSequence(0, 1); + String endStr = value.substring(1); + sb.append("").append(startStr).append("=").append(endStr).append(","); + } + } + return sb.deleteCharAt(sb.length() - 1).toString(); + } + else + { + return this.columnComment; + } + } +} diff --git a/ruoyi-base-support/ruoyi-generator/src/main/java/com/ruoyi/generator/mapper/GenTableColumnMapper.java b/ruoyi-base-support/ruoyi-generator/src/main/java/com/ruoyi/generator/mapper/GenTableColumnMapper.java new file mode 100644 index 0000000..951e166 --- /dev/null +++ b/ruoyi-base-support/ruoyi-generator/src/main/java/com/ruoyi/generator/mapper/GenTableColumnMapper.java @@ -0,0 +1,60 @@ +package com.ruoyi.generator.mapper; + +import java.util.List; +import com.ruoyi.generator.domain.GenTableColumn; + +/** + * 业务字段 数据层 + * + * @author ruoyi + */ +public interface GenTableColumnMapper +{ + /** + * 根据表名称查询列信息 + * + * @param tableName 表名称 + * @return 列信息 + */ + public List selectDbTableColumnsByName(String tableName); + + /** + * 查询业务字段列表 + * + * @param tableId 业务字段编号 + * @return 业务字段集合 + */ + public List selectGenTableColumnListByTableId(Long tableId); + + /** + * 新增业务字段 + * + * @param genTableColumn 业务字段信息 + * @return 结果 + */ + public int insertGenTableColumn(GenTableColumn genTableColumn); + + /** + * 修改业务字段 + * + * @param genTableColumn 业务字段信息 + * @return 结果 + */ + public int updateGenTableColumn(GenTableColumn genTableColumn); + + /** + * 删除业务字段 + * + * @param genTableColumns 列数据 + * @return 结果 + */ + public int deleteGenTableColumns(List genTableColumns); + + /** + * 批量删除业务字段 + * + * @param ids 需要删除的数据ID + * @return 结果 + */ + public int deleteGenTableColumnByIds(Long[] ids); +} diff --git a/ruoyi-base-support/ruoyi-generator/src/main/java/com/ruoyi/generator/mapper/GenTableMapper.java b/ruoyi-base-support/ruoyi-generator/src/main/java/com/ruoyi/generator/mapper/GenTableMapper.java new file mode 100644 index 0000000..9b330df --- /dev/null +++ b/ruoyi-base-support/ruoyi-generator/src/main/java/com/ruoyi/generator/mapper/GenTableMapper.java @@ -0,0 +1,83 @@ +package com.ruoyi.generator.mapper; + +import java.util.List; +import com.ruoyi.generator.domain.GenTable; + +/** + * 业务 数据层 + * + * @author ruoyi + */ +public interface GenTableMapper +{ + /** + * 查询业务列表 + * + * @param genTable 业务信息 + * @return 业务集合 + */ + public List selectGenTableList(GenTable genTable); + + /** + * 查询据库列表 + * + * @param genTable 业务信息 + * @return 数据库表集合 + */ + public List selectDbTableList(GenTable genTable); + + /** + * 查询据库列表 + * + * @param tableNames 表名称组 + * @return 数据库表集合 + */ + public List selectDbTableListByNames(String[] tableNames); + + /** + * 查询所有表信息 + * + * @return 表信息集合 + */ + public List selectGenTableAll(); + + /** + * 查询表ID业务信息 + * + * @param id 业务ID + * @return 业务信息 + */ + public GenTable selectGenTableById(Long id); + + /** + * 查询表名称业务信息 + * + * @param tableName 表名称 + * @return 业务信息 + */ + public GenTable selectGenTableByName(String tableName); + + /** + * 新增业务 + * + * @param genTable 业务信息 + * @return 结果 + */ + public int insertGenTable(GenTable genTable); + + /** + * 修改业务 + * + * @param genTable 业务信息 + * @return 结果 + */ + public int updateGenTable(GenTable genTable); + + /** + * 批量删除业务 + * + * @param ids 需要删除的数据ID + * @return 结果 + */ + public int deleteGenTableByIds(Long[] ids); +} diff --git a/ruoyi-base-support/ruoyi-generator/src/main/java/com/ruoyi/generator/mapper/xml/GenTableColumnMapper.xml b/ruoyi-base-support/ruoyi-generator/src/main/java/com/ruoyi/generator/mapper/xml/GenTableColumnMapper.xml new file mode 100644 index 0000000..5fa790f --- /dev/null +++ b/ruoyi-base-support/ruoyi-generator/src/main/java/com/ruoyi/generator/mapper/xml/GenTableColumnMapper.xml @@ -0,0 +1,127 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + select column_id, table_id, column_name, column_comment, column_type, java_type, java_field, is_pk, is_increment, is_required, is_insert, is_edit, is_list, is_query, query_type, html_type, dict_type, sort, create_by, create_time, update_by, update_time from gen_table_column + + + + + + + + insert into gen_table_column ( + table_id, + column_name, + column_comment, + column_type, + java_type, + java_field, + is_pk, + is_increment, + is_required, + is_insert, + is_edit, + is_list, + is_query, + query_type, + html_type, + dict_type, + sort, + create_by, + create_time + )values( + #{tableId}, + #{columnName}, + #{columnComment}, + #{columnType}, + #{javaType}, + #{javaField}, + #{isPk}, + #{isIncrement}, + #{isRequired}, + #{isInsert}, + #{isEdit}, + #{isList}, + #{isQuery}, + #{queryType}, + #{htmlType}, + #{dictType}, + #{sort}, + #{createBy}, + sysdate() + ) + + + + update gen_table_column + + column_comment = #{columnComment}, + java_type = #{javaType}, + java_field = #{javaField}, + is_insert = #{isInsert}, + is_edit = #{isEdit}, + is_list = #{isList}, + is_query = #{isQuery}, + is_required = #{isRequired}, + query_type = #{queryType}, + html_type = #{htmlType}, + dict_type = #{dictType}, + sort = #{sort}, + update_by = #{updateBy}, + update_time = sysdate() + + where column_id = #{columnId} + + + + delete from gen_table_column where table_id in + + #{tableId} + + + + + delete from gen_table_column where column_id in + + #{item.columnId} + + + + \ No newline at end of file diff --git a/ruoyi-base-support/ruoyi-generator/src/main/java/com/ruoyi/generator/mapper/xml/GenTableMapper.xml b/ruoyi-base-support/ruoyi-generator/src/main/java/com/ruoyi/generator/mapper/xml/GenTableMapper.xml new file mode 100644 index 0000000..b605e90 --- /dev/null +++ b/ruoyi-base-support/ruoyi-generator/src/main/java/com/ruoyi/generator/mapper/xml/GenTableMapper.xml @@ -0,0 +1,202 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + select table_id, table_name, table_comment, sub_table_name, sub_table_fk_name, class_name, tpl_category, package_name, module_name, business_name, function_name, function_author, gen_type, gen_path, options, create_by, create_time, update_by, update_time, remark from gen_table + + + + + + + + + + + + + + + + + + insert into gen_table ( + table_name, + table_comment, + class_name, + tpl_category, + package_name, + module_name, + business_name, + function_name, + function_author, + gen_type, + gen_path, + remark, + create_by, + create_time + )values( + #{tableName}, + #{tableComment}, + #{className}, + #{tplCategory}, + #{packageName}, + #{moduleName}, + #{businessName}, + #{functionName}, + #{functionAuthor}, + #{genType}, + #{genPath}, + #{remark}, + #{createBy}, + sysdate() + ) + + + + update gen_table + + table_name = #{tableName}, + table_comment = #{tableComment}, + sub_table_name = #{subTableName}, + sub_table_fk_name = #{subTableFkName}, + class_name = #{className}, + function_author = #{functionAuthor}, + gen_type = #{genType}, + gen_path = #{genPath}, + tpl_category = #{tplCategory}, + package_name = #{packageName}, + module_name = #{moduleName}, + business_name = #{businessName}, + function_name = #{functionName}, + options = #{options}, + update_by = #{updateBy}, + remark = #{remark}, + update_time = sysdate() + + where table_id = #{tableId} + + + + delete from gen_table where table_id in + + #{tableId} + + + + \ No newline at end of file diff --git a/ruoyi-base-support/ruoyi-generator/src/main/java/com/ruoyi/generator/service/GenTableColumnServiceImpl.java b/ruoyi-base-support/ruoyi-generator/src/main/java/com/ruoyi/generator/service/GenTableColumnServiceImpl.java new file mode 100644 index 0000000..0679689 --- /dev/null +++ b/ruoyi-base-support/ruoyi-generator/src/main/java/com/ruoyi/generator/service/GenTableColumnServiceImpl.java @@ -0,0 +1,68 @@ +package com.ruoyi.generator.service; + +import java.util.List; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import com.ruoyi.common.core.text.Convert; +import com.ruoyi.generator.domain.GenTableColumn; +import com.ruoyi.generator.mapper.GenTableColumnMapper; + +/** + * 业务字段 服务层实现 + * + * @author ruoyi + */ +@Service +public class GenTableColumnServiceImpl implements IGenTableColumnService +{ + @Autowired + private GenTableColumnMapper genTableColumnMapper; + + /** + * 查询业务字段列表 + * + * @param tableId 业务字段编号 + * @return 业务字段集合 + */ + @Override + public List selectGenTableColumnListByTableId(Long tableId) + { + return genTableColumnMapper.selectGenTableColumnListByTableId(tableId); + } + + /** + * 新增业务字段 + * + * @param genTableColumn 业务字段信息 + * @return 结果 + */ + @Override + public int insertGenTableColumn(GenTableColumn genTableColumn) + { + return genTableColumnMapper.insertGenTableColumn(genTableColumn); + } + + /** + * 修改业务字段 + * + * @param genTableColumn 业务字段信息 + * @return 结果 + */ + @Override + public int updateGenTableColumn(GenTableColumn genTableColumn) + { + return genTableColumnMapper.updateGenTableColumn(genTableColumn); + } + + /** + * 删除业务字段对象 + * + * @param ids 需要删除的数据ID + * @return 结果 + */ + @Override + public int deleteGenTableColumnByIds(String ids) + { + return genTableColumnMapper.deleteGenTableColumnByIds(Convert.toLongArray(ids)); + } +} diff --git a/ruoyi-base-support/ruoyi-generator/src/main/java/com/ruoyi/generator/service/GenTableServiceImpl.java b/ruoyi-base-support/ruoyi-generator/src/main/java/com/ruoyi/generator/service/GenTableServiceImpl.java new file mode 100644 index 0000000..a14e9c8 --- /dev/null +++ b/ruoyi-base-support/ruoyi-generator/src/main/java/com/ruoyi/generator/service/GenTableServiceImpl.java @@ -0,0 +1,500 @@ +package com.ruoyi.generator.service; + +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.IOException; +import java.io.StringWriter; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; +import java.util.zip.ZipEntry; +import java.util.zip.ZipOutputStream; +import org.apache.commons.io.FileUtils; +import org.apache.commons.io.IOUtils; +import org.apache.velocity.Template; +import org.apache.velocity.VelocityContext; +import org.apache.velocity.app.Velocity; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.ruoyi.common.constant.Constants; +import com.ruoyi.common.constant.GenConstants; +import com.ruoyi.common.core.text.CharsetKit; +import com.ruoyi.common.exception.ServiceException; +import com.ruoyi.common.utils.SecurityUtils; +import com.ruoyi.common.utils.StringUtils; +import com.ruoyi.generator.domain.GenTable; +import com.ruoyi.generator.domain.GenTableColumn; +import com.ruoyi.generator.mapper.GenTableColumnMapper; +import com.ruoyi.generator.mapper.GenTableMapper; +import com.ruoyi.generator.util.GenUtils; +import com.ruoyi.generator.util.VelocityInitializer; +import com.ruoyi.generator.util.VelocityUtils; + +/** + * 业务 服务层实现 + * + * @author ruoyi + */ +@Service +public class GenTableServiceImpl implements IGenTableService +{ + private static final Logger log = LoggerFactory.getLogger(GenTableServiceImpl.class); + + @Autowired + private GenTableMapper genTableMapper; + + @Autowired + private GenTableColumnMapper genTableColumnMapper; + + /** + * 查询业务信息 + * + * @param id 业务ID + * @return 业务信息 + */ + @Override + public GenTable selectGenTableById(Long id) + { + GenTable genTable = genTableMapper.selectGenTableById(id); + setTableFromOptions(genTable); + return genTable; + } + + /** + * 查询业务列表 + * + * @param genTable 业务信息 + * @return 业务集合 + */ + @Override + public List selectGenTableList(GenTable genTable) + { + return genTableMapper.selectGenTableList(genTable); + } + + /** + * 查询据库列表 + * + * @param genTable 业务信息 + * @return 数据库表集合 + */ + @Override + public List selectDbTableList(GenTable genTable) + { + return genTableMapper.selectDbTableList(genTable); + } + + /** + * 查询据库列表 + * + * @param tableNames 表名称组 + * @return 数据库表集合 + */ + @Override + public List selectDbTableListByNames(String[] tableNames) + { + return genTableMapper.selectDbTableListByNames(tableNames); + } + + /** + * 查询所有表信息 + * + * @return 表信息集合 + */ + @Override + public List selectGenTableAll() + { + return genTableMapper.selectGenTableAll(); + } + + /** + * 修改业务 + * + * @param genTable 业务信息 + * @return 结果 + */ + @Override + @Transactional + public void updateGenTable(GenTable genTable) + { + String options = JSON.toJSONString(genTable.getParams()); + genTable.setOptions(options); + int row = genTableMapper.updateGenTable(genTable); + if (row > 0) + { + for (GenTableColumn cenTableColumn : genTable.getColumns()) + { + genTableColumnMapper.updateGenTableColumn(cenTableColumn); + } + } + } + + /** + * 删除业务对象 + * + * @param tableIds 需要删除的数据ID + * @return 结果 + */ + @Override + @Transactional + public void deleteGenTableByIds(Long[] tableIds) + { + genTableMapper.deleteGenTableByIds(tableIds); + genTableColumnMapper.deleteGenTableColumnByIds(tableIds); + } + + /** + * 导入表结构 + * + * @param tableList 导入表列表 + */ + @Override + @Transactional + public void importGenTable(List tableList) + { + String operName = SecurityUtils.getUsername(); + try + { + for (GenTable table : tableList) + { + String tableName = table.getTableName(); + GenUtils.initTable(table, operName); + int row = genTableMapper.insertGenTable(table); + if (row > 0) + { + // 保存列信息 + List genTableColumns = genTableColumnMapper.selectDbTableColumnsByName(tableName); + for (GenTableColumn column : genTableColumns) + { + GenUtils.initColumnField(column, table); + genTableColumnMapper.insertGenTableColumn(column); + } + } + } + } + catch (Exception e) + { + throw new ServiceException("导入失败:" + e.getMessage()); + } + } + + /** + * 预览代码 + * + * @param tableId 表编号 + * @return 预览数据列表 + */ + @Override + public Map previewCode(Long tableId) + { + Map dataMap = new LinkedHashMap<>(); + // 查询表信息 + GenTable table = genTableMapper.selectGenTableById(tableId); + // 设置主子表信息 + setSubTable(table); + // 设置主键列信息 + setPkColumn(table); + VelocityInitializer.initVelocity(); + + VelocityContext context = VelocityUtils.prepareContext(table); + + // 获取模板列表 + List templates = VelocityUtils.getTemplateList(table.getTplCategory()); + for (String template : templates) + { + // 渲染模板 + StringWriter sw = new StringWriter(); + Template tpl = Velocity.getTemplate(template, Constants.UTF8); + tpl.merge(context, sw); + dataMap.put(template, sw.toString()); + } + return dataMap; + } + + /** + * 生成代码(下载方式) + * + * @param tableName 表名称 + * @return 数据 + */ + @Override + public byte[] downloadCode(String tableName) + { + ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); + ZipOutputStream zip = new ZipOutputStream(outputStream); + generatorCode(tableName, zip); + IOUtils.closeQuietly(zip); + return outputStream.toByteArray(); + } + + /** + * 生成代码(自定义路径) + * + * @param tableName 表名称 + */ + @Override + public void generatorCode(String tableName) + { + // 查询表信息 + GenTable table = genTableMapper.selectGenTableByName(tableName); + // 设置主子表信息 + setSubTable(table); + // 设置主键列信息 + setPkColumn(table); + + VelocityInitializer.initVelocity(); + + VelocityContext context = VelocityUtils.prepareContext(table); + + // 获取模板列表 + List templates = VelocityUtils.getTemplateList(table.getTplCategory()); + for (String template : templates) + { + if (!StringUtils.containsAny(template, "sql.vm", "api.js.vm", "index.vue.vm", "index-tree.vue.vm")) + { + // 渲染模板 + StringWriter sw = new StringWriter(); + Template tpl = Velocity.getTemplate(template, Constants.UTF8); + tpl.merge(context, sw); + try + { + String path = getGenPath(table, template); + FileUtils.writeStringToFile(new File(path), sw.toString(), CharsetKit.UTF_8); + } + catch (IOException e) + { + throw new ServiceException("渲染模板失败,表名:" + table.getTableName()); + } + } + } + } + + /** + * 同步数据库 + * + * @param tableName 表名称 + */ + @Override + @Transactional + public void synchDb(String tableName) + { + GenTable table = genTableMapper.selectGenTableByName(tableName); + List tableColumns = table.getColumns(); + List tableColumnNames = tableColumns.stream().map(GenTableColumn::getColumnName).collect(Collectors.toList()); + + List dbTableColumns = genTableColumnMapper.selectDbTableColumnsByName(tableName); + if (StringUtils.isEmpty(dbTableColumns)) + { + throw new ServiceException("同步数据失败,原表结构不存在"); + } + List dbTableColumnNames = dbTableColumns.stream().map(GenTableColumn::getColumnName).collect(Collectors.toList()); + + dbTableColumns.forEach(column -> { + if (!tableColumnNames.contains(column.getColumnName())) + { + GenUtils.initColumnField(column, table); + genTableColumnMapper.insertGenTableColumn(column); + } + }); + + List delColumns = tableColumns.stream().filter(column -> !dbTableColumnNames.contains(column.getColumnName())).collect(Collectors.toList()); + if (StringUtils.isNotEmpty(delColumns)) + { + genTableColumnMapper.deleteGenTableColumns(delColumns); + } + } + + /** + * 批量生成代码(下载方式) + * + * @param tableNames 表数组 + * @return 数据 + */ + @Override + public byte[] downloadCode(String[] tableNames) + { + ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); + ZipOutputStream zip = new ZipOutputStream(outputStream); + for (String tableName : tableNames) + { + generatorCode(tableName, zip); + } + IOUtils.closeQuietly(zip); + return outputStream.toByteArray(); + } + + /** + * 查询表信息并生成代码 + */ + private void generatorCode(String tableName, ZipOutputStream zip) + { + // 查询表信息 + GenTable table = genTableMapper.selectGenTableByName(tableName); + // 设置主子表信息 + setSubTable(table); + // 设置主键列信息 + setPkColumn(table); + + VelocityInitializer.initVelocity(); + + VelocityContext context = VelocityUtils.prepareContext(table); + + // 获取模板列表 + List templates = VelocityUtils.getTemplateList(table.getTplCategory()); + for (String template : templates) + { + // 渲染模板 + StringWriter sw = new StringWriter(); + Template tpl = Velocity.getTemplate(template, Constants.UTF8); + tpl.merge(context, sw); + try + { + // 添加到zip + zip.putNextEntry(new ZipEntry(VelocityUtils.getFileName(template, table))); + IOUtils.write(sw.toString(), zip, Constants.UTF8); + IOUtils.closeQuietly(sw); + zip.flush(); + zip.closeEntry(); + } + catch (IOException e) + { + log.error("渲染模板失败,表名:" + table.getTableName(), e); + } + } + } + + /** + * 修改保存参数校验 + * + * @param genTable 业务信息 + */ + @Override + public void validateEdit(GenTable genTable) + { + if (GenConstants.TPL_TREE.equals(genTable.getTplCategory())) + { + String options = JSON.toJSONString(genTable.getParams()); + JSONObject paramsObj = JSONObject.parseObject(options); + if (StringUtils.isEmpty(paramsObj.getString(GenConstants.TREE_CODE))) + { + throw new ServiceException("树编码字段不能为空"); + } + else if (StringUtils.isEmpty(paramsObj.getString(GenConstants.TREE_PARENT_CODE))) + { + throw new ServiceException("树父编码字段不能为空"); + } + else if (StringUtils.isEmpty(paramsObj.getString(GenConstants.TREE_NAME))) + { + throw new ServiceException("树名称字段不能为空"); + } + else if (GenConstants.TPL_SUB.equals(genTable.getTplCategory())) + { + if (StringUtils.isEmpty(genTable.getSubTableName())) + { + throw new ServiceException("关联子表的表名不能为空"); + } + else if (StringUtils.isEmpty(genTable.getSubTableFkName())) + { + throw new ServiceException("子表关联的外键名不能为空"); + } + } + } + } + + /** + * 设置主键列信息 + * + * @param table 业务表信息 + */ + public void setPkColumn(GenTable table) + { + for (GenTableColumn column : table.getColumns()) + { + if (column.isPk()) + { + table.setPkColumn(column); + break; + } + } + if (StringUtils.isNull(table.getPkColumn())) + { + table.setPkColumn(table.getColumns().get(0)); + } + if (GenConstants.TPL_SUB.equals(table.getTplCategory())) + { + for (GenTableColumn column : table.getSubTable().getColumns()) + { + if (column.isPk()) + { + table.getSubTable().setPkColumn(column); + break; + } + } + if (StringUtils.isNull(table.getSubTable().getPkColumn())) + { + table.getSubTable().setPkColumn(table.getSubTable().getColumns().get(0)); + } + } + } + + /** + * 设置主子表信息 + * + * @param table 业务表信息 + */ + public void setSubTable(GenTable table) + { + String subTableName = table.getSubTableName(); + if (StringUtils.isNotEmpty(subTableName)) + { + table.setSubTable(genTableMapper.selectGenTableByName(subTableName)); + } + } + + /** + * 设置代码生成其他选项值 + * + * @param genTable 设置后的生成对象 + */ + public void setTableFromOptions(GenTable genTable) + { + JSONObject paramsObj = JSONObject.parseObject(genTable.getOptions()); + if (StringUtils.isNotNull(paramsObj)) + { + String treeCode = paramsObj.getString(GenConstants.TREE_CODE); + String treeParentCode = paramsObj.getString(GenConstants.TREE_PARENT_CODE); + String treeName = paramsObj.getString(GenConstants.TREE_NAME); + String parentMenuId = paramsObj.getString(GenConstants.PARENT_MENU_ID); + String parentMenuName = paramsObj.getString(GenConstants.PARENT_MENU_NAME); + + genTable.setTreeCode(treeCode); + genTable.setTreeParentCode(treeParentCode); + genTable.setTreeName(treeName); + genTable.setParentMenuId(parentMenuId); + genTable.setParentMenuName(parentMenuName); + } + } + + /** + * 获取代码生成地址 + * + * @param table 业务表信息 + * @param template 模板文件路径 + * @return 生成地址 + */ + public static String getGenPath(GenTable table, String template) + { + String genPath = table.getGenPath(); + if (StringUtils.equals(genPath, "/")) + { + return System.getProperty("user.dir") + File.separator + "src" + File.separator + VelocityUtils.getFileName(template, table); + } + return genPath + File.separator + VelocityUtils.getFileName(template, table); + } +} diff --git a/ruoyi-base-support/ruoyi-generator/src/main/java/com/ruoyi/generator/service/IGenTableColumnService.java b/ruoyi-base-support/ruoyi-generator/src/main/java/com/ruoyi/generator/service/IGenTableColumnService.java new file mode 100644 index 0000000..3037f70 --- /dev/null +++ b/ruoyi-base-support/ruoyi-generator/src/main/java/com/ruoyi/generator/service/IGenTableColumnService.java @@ -0,0 +1,44 @@ +package com.ruoyi.generator.service; + +import java.util.List; +import com.ruoyi.generator.domain.GenTableColumn; + +/** + * 业务字段 服务层 + * + * @author ruoyi + */ +public interface IGenTableColumnService +{ + /** + * 查询业务字段列表 + * + * @param tableId 业务字段编号 + * @return 业务字段集合 + */ + public List selectGenTableColumnListByTableId(Long tableId); + + /** + * 新增业务字段 + * + * @param genTableColumn 业务字段信息 + * @return 结果 + */ + public int insertGenTableColumn(GenTableColumn genTableColumn); + + /** + * 修改业务字段 + * + * @param genTableColumn 业务字段信息 + * @return 结果 + */ + public int updateGenTableColumn(GenTableColumn genTableColumn); + + /** + * 删除业务字段信息 + * + * @param ids 需要删除的数据ID + * @return 结果 + */ + public int deleteGenTableColumnByIds(String ids); +} diff --git a/ruoyi-base-support/ruoyi-generator/src/main/java/com/ruoyi/generator/service/IGenTableService.java b/ruoyi-base-support/ruoyi-generator/src/main/java/com/ruoyi/generator/service/IGenTableService.java new file mode 100644 index 0000000..9d53f95 --- /dev/null +++ b/ruoyi-base-support/ruoyi-generator/src/main/java/com/ruoyi/generator/service/IGenTableService.java @@ -0,0 +1,121 @@ +package com.ruoyi.generator.service; + +import java.util.List; +import java.util.Map; +import com.ruoyi.generator.domain.GenTable; + +/** + * 业务 服务层 + * + * @author ruoyi + */ +public interface IGenTableService +{ + /** + * 查询业务列表 + * + * @param genTable 业务信息 + * @return 业务集合 + */ + public List selectGenTableList(GenTable genTable); + + /** + * 查询据库列表 + * + * @param genTable 业务信息 + * @return 数据库表集合 + */ + public List selectDbTableList(GenTable genTable); + + /** + * 查询据库列表 + * + * @param tableNames 表名称组 + * @return 数据库表集合 + */ + public List selectDbTableListByNames(String[] tableNames); + + /** + * 查询所有表信息 + * + * @return 表信息集合 + */ + public List selectGenTableAll(); + + /** + * 查询业务信息 + * + * @param id 业务ID + * @return 业务信息 + */ + public GenTable selectGenTableById(Long id); + + /** + * 修改业务 + * + * @param genTable 业务信息 + * @return 结果 + */ + public void updateGenTable(GenTable genTable); + + /** + * 删除业务信息 + * + * @param tableIds 需要删除的表数据ID + * @return 结果 + */ + public void deleteGenTableByIds(Long[] tableIds); + + /** + * 导入表结构 + * + * @param tableList 导入表列表 + */ + public void importGenTable(List tableList); + + /** + * 预览代码 + * + * @param tableId 表编号 + * @return 预览数据列表 + */ + public Map previewCode(Long tableId); + + /** + * 生成代码(下载方式) + * + * @param tableName 表名称 + * @return 数据 + */ + public byte[] downloadCode(String tableName); + + /** + * 生成代码(自定义路径) + * + * @param tableName 表名称 + * @return 数据 + */ + public void generatorCode(String tableName); + + /** + * 同步数据库 + * + * @param tableName 表名称 + */ + public void synchDb(String tableName); + + /** + * 批量生成代码(下载方式) + * + * @param tableNames 表数组 + * @return 数据 + */ + public byte[] downloadCode(String[] tableNames); + + /** + * 修改保存参数校验 + * + * @param genTable 业务信息 + */ + public void validateEdit(GenTable genTable); +} diff --git a/ruoyi-base-support/ruoyi-generator/src/main/java/com/ruoyi/generator/util/GenUtils.java b/ruoyi-base-support/ruoyi-generator/src/main/java/com/ruoyi/generator/util/GenUtils.java new file mode 100644 index 0000000..ebf726c --- /dev/null +++ b/ruoyi-base-support/ruoyi-generator/src/main/java/com/ruoyi/generator/util/GenUtils.java @@ -0,0 +1,265 @@ +package com.ruoyi.generator.util; + +import java.util.Arrays; +import org.apache.commons.lang3.RegExUtils; +import com.ruoyi.common.constant.GenConstants; +import com.ruoyi.common.utils.StringUtils; +import com.ruoyi.generator.config.GenConfig; +import com.ruoyi.generator.domain.GenTable; +import com.ruoyi.generator.domain.GenTableColumn; + +/** + * 代码生成器 工具类 + * + * @author ruoyi + */ +public class GenUtils +{ + /** + * 初始化表信息 + */ + public static void initTable(GenTable genTable, String operName) + { + genTable.setClassName(convertClassName(genTable.getTableName())); + genTable.setPackageName(GenConfig.getPackageName()); + genTable.setModuleName(getModuleName(GenConfig.getPackageName())); + genTable.setBusinessName(getBusinessName(genTable.getTableName())); + genTable.setFunctionName(replaceText(genTable.getTableComment())); + genTable.setFunctionAuthor(GenConfig.getAuthor()); + genTable.setCreateBy(operName); + } + + /** + * 初始化列属性字段 + */ + public static void initColumnField(GenTableColumn column, GenTable table) + { + String dataType = getDbType(column.getColumnType()); + String columnName = column.getColumnName(); + column.setTableId(table.getTableId()); + column.setCreateBy(table.getCreateBy()); + // 设置java字段名 + column.setJavaField(StringUtils.toCamelCase(columnName)); + // 设置默认类型 + column.setJavaType(GenConstants.TYPE_STRING); + + if (arraysContains(GenConstants.COLUMNTYPE_STR, dataType) || arraysContains(GenConstants.COLUMNTYPE_TEXT, dataType)) + { + // 字符串长度超过500设置为文本域 + Integer columnLength = getColumnLength(column.getColumnType()); + String htmlType = columnLength >= 500 || arraysContains(GenConstants.COLUMNTYPE_TEXT, dataType) ? GenConstants.HTML_TEXTAREA : GenConstants.HTML_INPUT; + column.setHtmlType(htmlType); + } + else if (arraysContains(GenConstants.COLUMNTYPE_TIME, dataType)) + { + column.setJavaType(GenConstants.TYPE_DATE); + column.setHtmlType(GenConstants.HTML_DATETIME); + } + else if (arraysContains(GenConstants.COLUMNTYPE_NUMBER, dataType)) + { + column.setHtmlType(GenConstants.HTML_INPUT); + + // 如果是浮点型 统一用BigDecimal + String[] str = StringUtils.split(StringUtils.substringBetween(column.getColumnType(), "(", ")"), ","); + if (str != null && str.length == 2 && Integer.parseInt(str[1]) > 0) + { + column.setJavaType(GenConstants.TYPE_BIGDECIMAL); + } + // 如果是整形 + else if (str != null && str.length == 1 && Integer.parseInt(str[0]) <= 10) + { + column.setJavaType(GenConstants.TYPE_INTEGER); + } + // 长整形 + else + { + if (arraysContains(GenConstants.COLUMNTYPE_INT, dataType)){ + column.setJavaType(GenConstants.TYPE_INTEGER); + }else { + column.setJavaType(GenConstants.TYPE_LONG); + } + } + } + + // 插入字段(默认所有字段都需要插入) + column.setIsInsert(GenConstants.REQUIRE); + + // 编辑字段 + if (!arraysContains(GenConstants.COLUMNNAME_NOT_EDIT, columnName) && !column.isPk()) + { + column.setIsEdit(GenConstants.REQUIRE); + } + // 列表字段 + if (!arraysContains(GenConstants.COLUMNNAME_NOT_LIST, columnName) && !column.isPk()) + { + column.setIsList(GenConstants.REQUIRE); + } + // 查询字段 + if (!arraysContains(GenConstants.COLUMNNAME_NOT_QUERY, columnName) && !column.isPk()) + { + column.setIsQuery(GenConstants.REQUIRE); + } + + // 查询字段类型 + if (StringUtils.endsWithIgnoreCase(columnName, "name")) + { + column.setQueryType(GenConstants.QUERY_LIKE); + } + // 状态字段设置单选框 + if (StringUtils.endsWithIgnoreCase(columnName, "status")) + { + column.setHtmlType(GenConstants.HTML_RADIO); + } + // 类型&性别字段设置下拉框 + else if (StringUtils.endsWithIgnoreCase(columnName, "type") + || StringUtils.endsWithIgnoreCase(columnName, "sex")) + { + column.setHtmlType(GenConstants.HTML_SELECT); + } + // 图片字段设置图片上传控件 + else if (StringUtils.endsWithIgnoreCase(columnName, "image")) + { + column.setHtmlType(GenConstants.HTML_IMAGE_UPLOAD); + } + // 文件字段设置文件上传控件 + else if (StringUtils.endsWithIgnoreCase(columnName, "file")) + { + column.setHtmlType(GenConstants.HTML_FILE_UPLOAD); + } + // 内容字段设置富文本控件 + else if (StringUtils.endsWithIgnoreCase(columnName, "content")) + { + column.setHtmlType(GenConstants.HTML_EDITOR); + } + } + + /** + * 校验数组是否包含指定值 + * + * @param arr 数组 + * @param targetValue 值 + * @return 是否包含 + */ + public static boolean arraysContains(String[] arr, String targetValue) + { + return Arrays.asList(arr).contains(targetValue); + } + + /** + * 获取模块名 + * + * @param packageName 包名 + * @return 模块名 + */ + public static String getModuleName(String packageName) + { + int lastIndex = packageName.lastIndexOf("."); + int nameLength = packageName.length(); + String moduleName = StringUtils.substring(packageName, lastIndex + 1, nameLength); + return moduleName; + } + + /** + * 获取业务名 + * + * @param tableName 表名 + * @return 业务名 + */ + public static String getBusinessName(String tableName) + { + String tablePrefix = GenConfig.getTablePrefix(); + String businessName = tableName.replace(tablePrefix, "").replace("_", ""); + +// int index = tableName.indexOf("_"); +// int nameLength = tableName.length(); +// String businessName = StringUtils.substring(tableName, index + 1, nameLength); + return businessName; + } + + /** + * 表名转换成Java类名 + * + * @param tableName 表名称 + * @return 类名 + */ + public static String convertClassName(String tableName) + { + boolean autoRemovePre = GenConfig.getAutoRemovePre(); + String tablePrefix = GenConfig.getTablePrefix(); + if (autoRemovePre && StringUtils.isNotEmpty(tablePrefix)) + { + String[] searchList = StringUtils.split(tablePrefix, ","); + tableName = replaceFirst(tableName, searchList); + } + return StringUtils.convertToCamelCase(tableName); + } + + /** + * 批量替换前缀 + * + * @param replacementm 替换值 + * @param searchList 替换列表 + * @return + */ + public static String replaceFirst(String replacementm, String[] searchList) + { + String text = replacementm; + for (String searchString : searchList) + { + if (replacementm.startsWith(searchString)) + { + text = replacementm.replaceFirst(searchString, ""); + break; + } + } + return text; + } + + /** + * 关键字替换 + * + * @param text 需要被替换的名字 + * @return 替换后的名字 + */ + public static String replaceText(String text) + { + return RegExUtils.replaceAll(text, "(?:表|若依)", ""); + } + + /** + * 获取数据库类型字段 + * + * @param columnType 列类型 + * @return 截取后的列类型 + */ + public static String getDbType(String columnType) + { + if (StringUtils.indexOf(columnType, "(") > 0) + { + return StringUtils.substringBefore(columnType, "("); + } + else + { + return columnType; + } + } + + /** + * 获取字段长度 + * + * @param columnType 列类型 + * @return 截取后的列类型 + */ + public static Integer getColumnLength(String columnType) + { + if (StringUtils.indexOf(columnType, "(") > 0) + { + String length = StringUtils.substringBetween(columnType, "(", ")"); + return Integer.valueOf(length); + } + else + { + return 0; + } + } +} diff --git a/ruoyi-base-support/ruoyi-generator/src/main/java/com/ruoyi/generator/util/VelocityInitializer.java b/ruoyi-base-support/ruoyi-generator/src/main/java/com/ruoyi/generator/util/VelocityInitializer.java new file mode 100644 index 0000000..32452b8 --- /dev/null +++ b/ruoyi-base-support/ruoyi-generator/src/main/java/com/ruoyi/generator/util/VelocityInitializer.java @@ -0,0 +1,35 @@ +package com.ruoyi.generator.util; + +import java.util.Properties; +import org.apache.velocity.app.Velocity; +import com.ruoyi.common.constant.Constants; + +/** + * VelocityEngine工厂 + * + * @author ruoyi + */ +public class VelocityInitializer +{ + /** + * 初始化vm方法 + */ + public static void initVelocity() + { + Properties p = new Properties(); + try + { + // 加载classpath目录下的vm文件 + p.setProperty("file.resource.loader.class", "org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader"); + // 定义字符集 + p.setProperty(Velocity.INPUT_ENCODING, Constants.UTF8); + p.setProperty(Velocity.OUTPUT_ENCODING, Constants.UTF8); + // 初始化Velocity引擎,指定配置Properties + Velocity.init(p); + } + catch (Exception e) + { + throw new RuntimeException(e); + } + } +} diff --git a/ruoyi-base-support/ruoyi-generator/src/main/java/com/ruoyi/generator/util/VelocityUtils.java b/ruoyi-base-support/ruoyi-generator/src/main/java/com/ruoyi/generator/util/VelocityUtils.java new file mode 100644 index 0000000..f27dc36 --- /dev/null +++ b/ruoyi-base-support/ruoyi-generator/src/main/java/com/ruoyi/generator/util/VelocityUtils.java @@ -0,0 +1,404 @@ +package com.ruoyi.generator.util; + +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import org.apache.velocity.VelocityContext; +import com.alibaba.fastjson.JSONObject; +import com.ruoyi.common.constant.GenConstants; +import com.ruoyi.common.utils.DateUtils; +import com.ruoyi.common.utils.StringUtils; +import com.ruoyi.generator.domain.GenTable; +import com.ruoyi.generator.domain.GenTableColumn; + +/** + * 模板处理工具类 + * + * @author ruoyi + */ +public class VelocityUtils +{ + /** 项目空间路径 */ + private static final String PROJECT_PATH = "main/java"; + + /** mybatis空间路径 */ + private static final String MYBATIS_PATH = "main/resources/mapper"; + + /** 默认上级菜单,系统工具 */ + private static final String DEFAULT_PARENT_MENU_ID = "3"; + + /** + * 设置模板变量信息 + * + * @return 模板列表 + */ + public static VelocityContext prepareContext(GenTable genTable) + { + String moduleName = genTable.getModuleName(); + String businessName = genTable.getBusinessName(); + String packageName = genTable.getPackageName(); + String tplCategory = genTable.getTplCategory(); + String functionName = genTable.getFunctionName(); + + VelocityContext velocityContext = new VelocityContext(); + velocityContext.put("tplCategory", genTable.getTplCategory()); + velocityContext.put("tableName", genTable.getTableName()); + velocityContext.put("functionName", StringUtils.isNotEmpty(functionName) ? functionName : "【请填写功能名称】"); + velocityContext.put("ClassName", genTable.getClassName()); + velocityContext.put("className", StringUtils.uncapitalize(genTable.getClassName())); + velocityContext.put("moduleName", genTable.getModuleName()); + velocityContext.put("BusinessName", StringUtils.capitalize(genTable.getBusinessName())); + velocityContext.put("businessName", genTable.getBusinessName()); + velocityContext.put("basePackage", getPackagePrefix(packageName)); + velocityContext.put("packageName", packageName); + velocityContext.put("author", genTable.getFunctionAuthor()); + velocityContext.put("datetime", DateUtils.getDate()); + velocityContext.put("pkColumn", genTable.getPkColumn()); + velocityContext.put("importList", getImportList(genTable)); + velocityContext.put("permissionPrefix", getPermissionPrefix(moduleName, businessName)); + velocityContext.put("columns", genTable.getColumns()); + velocityContext.put("table", genTable); + velocityContext.put("dicts", getDicts(genTable)); + setMenuVelocityContext(velocityContext, genTable); + if (GenConstants.TPL_TREE.equals(tplCategory)) + { + setTreeVelocityContext(velocityContext, genTable); + } + if (GenConstants.TPL_SUB.equals(tplCategory)) + { + setSubVelocityContext(velocityContext, genTable); + } + return velocityContext; + } + + public static void setMenuVelocityContext(VelocityContext context, GenTable genTable) + { + String options = genTable.getOptions(); + JSONObject paramsObj = JSONObject.parseObject(options); + String parentMenuId = getParentMenuId(paramsObj); + context.put("parentMenuId", parentMenuId); + } + + public static void setTreeVelocityContext(VelocityContext context, GenTable genTable) + { + String options = genTable.getOptions(); + JSONObject paramsObj = JSONObject.parseObject(options); + String treeCode = getTreecode(paramsObj); + String treeParentCode = getTreeParentCode(paramsObj); + String treeName = getTreeName(paramsObj); + + context.put("treeCode", treeCode); + context.put("treeParentCode", treeParentCode); + context.put("treeName", treeName); + context.put("expandColumn", getExpandColumn(genTable)); + if (paramsObj.containsKey(GenConstants.TREE_PARENT_CODE)) + { + context.put("tree_parent_code", paramsObj.getString(GenConstants.TREE_PARENT_CODE)); + } + if (paramsObj.containsKey(GenConstants.TREE_NAME)) + { + context.put("tree_name", paramsObj.getString(GenConstants.TREE_NAME)); + } + } + + public static void setSubVelocityContext(VelocityContext context, GenTable genTable) + { + GenTable subTable = genTable.getSubTable(); + String subTableName = genTable.getSubTableName(); + String subTableFkName = genTable.getSubTableFkName(); + String subClassName = genTable.getSubTable().getClassName(); + String subTableFkClassName = StringUtils.convertToCamelCase(subTableFkName); + + context.put("subTable", subTable); + context.put("subTableName", subTableName); + context.put("subTableFkName", subTableFkName); + context.put("subTableFkClassName", subTableFkClassName); + context.put("subTableFkclassName", StringUtils.uncapitalize(subTableFkClassName)); + context.put("subClassName", subClassName); + context.put("subclassName", StringUtils.uncapitalize(subClassName)); + context.put("subImportList", getImportList(genTable.getSubTable())); + } + + /** + * 获取模板信息 + * + * @return 模板列表 + */ + public static List getTemplateList(String tplCategory) + { + List templates = new ArrayList(); + templates.add("vm/java/controller.java.vm"); + templates.add("vm/java/domain.java.vm"); + templates.add("vm/java/mapper.java.vm"); + + templates.add("vm/java/param.java.vm"); + templates.add("vm/java/result.java.vm"); + + templates.add("vm/java/service.java.vm"); + templates.add("vm/java/serviceImpl.java.vm"); + + templates.add("vm/xml/mapper.xml.vm"); + templates.add("vm/sql/sql.vm"); + templates.add("vm/js/api.js.vm"); + if (GenConstants.TPL_CRUD.equals(tplCategory)) + { + templates.add("vm/vue/index.vue.vm"); + } + else if (GenConstants.TPL_TREE.equals(tplCategory)) + { + templates.add("vm/vue/index-tree.vue.vm"); + } + else if (GenConstants.TPL_SUB.equals(tplCategory)) + { + templates.add("vm/vue/index.vue.vm"); + templates.add("vm/java/sub-domain.java.vm"); + } + return templates; + } + + /** + * 获取文件名 + */ + public static String getFileName(String template, GenTable genTable) + { + // 文件名称 + String fileName = ""; + // 包路径 + String packageName = genTable.getPackageName(); + // 模块名 + String moduleName = genTable.getModuleName(); + // 大写类名 + String className = genTable.getClassName(); + + // 业务名称 + String businessName = genTable.getBusinessName(); + + String javaPath = PROJECT_PATH + "/" + StringUtils.replace(packageName, ".", "/") +"/"+ businessName; +// String mybatisPath = MYBATIS_PATH + "/" + moduleName; + +// String controllerPath = PROJECT_PATH + "/web/controller/business"; + + + String vuePath = "vue"; + if (template.contains("param.java.vm")) + { + fileName = StringUtils.format("{}/model/param/{}Param.java", javaPath, className); + } + if (template.contains("result.java.vm")) + { + fileName = StringUtils.format("{}/model/result/{}Result.java", javaPath, className); + } + + if (template.contains("domain.java.vm")) + { + fileName = StringUtils.format("{}/entity/{}.java", javaPath, className); + } + if (template.contains("sub-domain.java.vm") && StringUtils.equals(GenConstants.TPL_SUB, genTable.getTplCategory())) + { + fileName = StringUtils.format("{}/domain/{}.java", javaPath, genTable.getSubTable().getClassName()); + } + else if (template.contains("mapper.java.vm")) + { + fileName = StringUtils.format("{}/mapper/{}Mapper.java", javaPath, className); + } + else if (template.contains("service.java.vm")) + { + fileName = StringUtils.format("{}/service/{}Service.java", javaPath, className); + } + else if (template.contains("serviceImpl.java.vm")) + { + fileName = StringUtils.format("{}/service/impl/{}ServiceImpl.java", javaPath, className); + } + else if (template.contains("controller.java.vm")) + { + fileName = StringUtils.format("{}/controller/{}Controller.java", javaPath, className); + +// fileName = StringUtils.format("{}/{}Controller.java", javaPath, className); + } + else if (template.contains("mapper.xml.vm")) + { + fileName = StringUtils.format("{}/mapper/mapping/{}Mapper.xml", javaPath, className); + } + else if (template.contains("sql.vm")) + { + fileName = businessName + "Menu.sql"; + } + else if (template.contains("api.js.vm")) + { + fileName = StringUtils.format("{}/api/{}/{}.js", vuePath, moduleName, businessName); + } + else if (template.contains("index.vue.vm")) + { + fileName = StringUtils.format("{}/views/{}/{}/index.vue", vuePath, moduleName, businessName); + } + else if (template.contains("index-tree.vue.vm")) + { + fileName = StringUtils.format("{}/views/{}/{}/index.vue", vuePath, moduleName, businessName); + } + return fileName; + } + + /** + * 获取包前缀 + * + * @param packageName 包名称 + * @return 包前缀名称 + */ + public static String getPackagePrefix(String packageName) + { + int lastIndex = packageName.lastIndexOf("."); + String basePackage = StringUtils.substring(packageName, 0, lastIndex); + return basePackage; + } + + /** + * 根据列类型获取导入包 + * + * @param genTable 业务表对象 + * @return 返回需要导入的包列表 + */ + public static HashSet getImportList(GenTable genTable) + { + List columns = genTable.getColumns(); + GenTable subGenTable = genTable.getSubTable(); + HashSet importList = new HashSet(); + if (StringUtils.isNotNull(subGenTable)) + { + importList.add("java.util.List"); + } + for (GenTableColumn column : columns) + { + if (!column.isSuperColumn() && GenConstants.TYPE_DATE.equals(column.getJavaType())) + { + importList.add("java.util.Date"); + importList.add("com.fasterxml.jackson.annotation.JsonFormat"); + } + else if (!column.isSuperColumn() && GenConstants.TYPE_BIGDECIMAL.equals(column.getJavaType())) + { + importList.add("java.math.BigDecimal"); + } + } + return importList; + } + + /** + * 根据列类型获取字典组 + * + * @param genTable 业务表对象 + * @return 返回字典组 + */ + public static String getDicts(GenTable genTable) + { + List columns = genTable.getColumns(); + List dicts = new ArrayList(); + for (GenTableColumn column : columns) + { + if (!column.isSuperColumn() && StringUtils.isNotEmpty(column.getDictType()) && StringUtils.equalsAny( + column.getHtmlType(), new String[] { GenConstants.HTML_SELECT, GenConstants.HTML_RADIO })) + { + dicts.add("'" + column.getDictType() + "'"); + } + } + return StringUtils.join(dicts, ", "); + } + + /** + * 获取权限前缀 + * + * @param moduleName 模块名称 + * @param businessName 业务名称 + * @return 返回权限前缀 + */ + public static String getPermissionPrefix(String moduleName, String businessName) + { + return StringUtils.format("{}:{}", moduleName, businessName); + } + + /** + * 获取上级菜单ID字段 + * + * @param paramsObj 生成其他选项 + * @return 上级菜单ID字段 + */ + public static String getParentMenuId(JSONObject paramsObj) + { + if (StringUtils.isNotEmpty(paramsObj) && paramsObj.containsKey(GenConstants.PARENT_MENU_ID) + && StringUtils.isNotEmpty(paramsObj.getString(GenConstants.PARENT_MENU_ID))) + { + return paramsObj.getString(GenConstants.PARENT_MENU_ID); + } + return DEFAULT_PARENT_MENU_ID; + } + + /** + * 获取树编码 + * + * @param paramsObj 生成其他选项 + * @return 树编码 + */ + public static String getTreecode(JSONObject paramsObj) + { + if (paramsObj.containsKey(GenConstants.TREE_CODE)) + { + return StringUtils.toCamelCase(paramsObj.getString(GenConstants.TREE_CODE)); + } + return StringUtils.EMPTY; + } + + /** + * 获取树父编码 + * + * @param paramsObj 生成其他选项 + * @return 树父编码 + */ + public static String getTreeParentCode(JSONObject paramsObj) + { + if (paramsObj.containsKey(GenConstants.TREE_PARENT_CODE)) + { + return StringUtils.toCamelCase(paramsObj.getString(GenConstants.TREE_PARENT_CODE)); + } + return StringUtils.EMPTY; + } + + /** + * 获取树名称 + * + * @param paramsObj 生成其他选项 + * @return 树名称 + */ + public static String getTreeName(JSONObject paramsObj) + { + if (paramsObj.containsKey(GenConstants.TREE_NAME)) + { + return StringUtils.toCamelCase(paramsObj.getString(GenConstants.TREE_NAME)); + } + return StringUtils.EMPTY; + } + + /** + * 获取需要在哪一列上面显示展开按钮 + * + * @param genTable 业务表对象 + * @return 展开按钮列序号 + */ + public static int getExpandColumn(GenTable genTable) + { + String options = genTable.getOptions(); + JSONObject paramsObj = JSONObject.parseObject(options); + String treeName = paramsObj.getString(GenConstants.TREE_NAME); + int num = 0; + for (GenTableColumn column : genTable.getColumns()) + { + if (column.isList()) + { + num++; + String columnName = column.getColumnName(); + if (columnName.equals(treeName)) + { + break; + } + } + } + return num; + } +} diff --git a/ruoyi-base-support/ruoyi-generator/src/main/resources/generator.yml b/ruoyi-base-support/ruoyi-generator/src/main/resources/generator.yml new file mode 100644 index 0000000..88505a3 --- /dev/null +++ b/ruoyi-base-support/ruoyi-generator/src/main/resources/generator.yml @@ -0,0 +1,10 @@ +# 代码生成 +gen: + # 作者 + author: liwenlong + # 默认生成包路径 system 需改成自己的模块名称 如 system monitor tool + packageName: com.ruoyi.frequency + # 自动去除表前缀,默认是false + autoRemovePre: true + # 表前缀(生成类名不会包含表前缀,多个用逗号分隔) + tablePrefix: t_ diff --git a/ruoyi-base-support/ruoyi-generator/src/main/resources/vm/java/controller.java.vm b/ruoyi-base-support/ruoyi-generator/src/main/resources/vm/java/controller.java.vm new file mode 100644 index 0000000..efc957d --- /dev/null +++ b/ruoyi-base-support/ruoyi-generator/src/main/resources/vm/java/controller.java.vm @@ -0,0 +1,114 @@ +package ${packageName}.${businessName}.controller; + +import java.util.List; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.enums.BusinessType; +import ${packageName}.${businessName}.entity.${ClassName}; +import ${packageName}.${businessName}.service.${ClassName}Service; +import com.ruoyi.common.utils.poi.ExcelUtil; +#if($table.crud || $table.sub) +import com.ruoyi.common.core.page.TableDataInfo; +#elseif($table.tree) +#end + +/** + * ${functionName}Controller + * + * @author ${author} + * @date ${datetime} + */ +@RestController +@RequestMapping("/${moduleName}/${businessName}") +public class ${ClassName}Controller extends BaseController +{ + @Autowired + private ${ClassName}Service ${className}Service; + + /** + * 查询${functionName}列表 + */ + @PreAuthorize("@ss.hasPermi('${permissionPrefix}:list')") + @GetMapping("/list") +#if($table.crud || $table.sub) + public TableDataInfo<${ClassName}> list(${ClassName} ${className}) + { + startPage(); + List<${ClassName}> list = ${className}Service.select${ClassName}List(${className}); + return getDataTable(list); + } +#elseif($table.tree) + public AjaxResult<${ClassName}> list(${ClassName} ${className}) + { + List<${ClassName}> list = ${className}Service.select${ClassName}List(${className}); + return AjaxResult.success(list); + } +#end + + /** + * 导出${functionName}列表 + */ + @PreAuthorize("@ss.hasPermi('${permissionPrefix}:export')") + @Log(title = "${functionName}", businessType = BusinessType.EXPORT) + @GetMapping("/export") + public AjaxResult export(${ClassName} ${className}) + { + List<${ClassName}> list = ${className}Service.select${ClassName}List(${className}); + ExcelUtil<${ClassName}> util = new ExcelUtil<${ClassName}>(${ClassName}.class); + return util.exportExcel(list, "${functionName}数据"); + } + + /** + * 获取${functionName}详细信息 + */ + @PreAuthorize("@ss.hasPermi('${permissionPrefix}:query')") + @GetMapping(value = "/{${pkColumn.javaField}}") + public AjaxResult<${ClassName}> getInfo(@PathVariable("${pkColumn.javaField}") ${pkColumn.javaType} ${pkColumn.javaField}) + { + return AjaxResult.success(${className}Service.select${ClassName}By${pkColumn.capJavaField}(${pkColumn.javaField})); + } + + /** + * 新增${functionName} + */ + @PreAuthorize("@ss.hasPermi('${permissionPrefix}:add')") + @Log(title = "${functionName}", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody ${ClassName} ${className}) + { + return toAjax(${className}Service.insert${ClassName}(${className})); + } + + /** + * 修改${functionName} + */ + @PreAuthorize("@ss.hasPermi('${permissionPrefix}:edit')") + @Log(title = "${functionName}", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody ${ClassName} ${className}) + { + return toAjax(${className}Service.update${ClassName}(${className})); + } + + /** + * 删除${functionName} + */ + @PreAuthorize("@ss.hasPermi('${permissionPrefix}:remove')") + @Log(title = "${functionName}", businessType = BusinessType.DELETE) + @DeleteMapping("/{${pkColumn.javaField}s}/{delFlag}") + public AjaxResult remove(@PathVariable("${pkColumn.javaField}s") ${pkColumn.javaType}[] ${pkColumn.javaField}s,@PathVariable("delFlag") Integer delFlag) + { + return toAjax(${className}Service.delete${ClassName}By${pkColumn.capJavaField}s(${pkColumn.javaField}s,delFlag)); + } +} diff --git a/ruoyi-base-support/ruoyi-generator/src/main/resources/vm/java/domain.java.vm b/ruoyi-base-support/ruoyi-generator/src/main/resources/vm/java/domain.java.vm new file mode 100644 index 0000000..38f8264 --- /dev/null +++ b/ruoyi-base-support/ruoyi-generator/src/main/resources/vm/java/domain.java.vm @@ -0,0 +1,120 @@ +package ${packageName}.${businessName}.entity; + +#foreach ($import in $importList) +import ${import}; +#end +import lombok.Data; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.experimental.Accessors; +import com.ruoyi.common.annotation.Excel; +import io.swagger.annotations.ApiModelProperty; +import com.baomidou.mybatisplus.annotation.TableField; +import com.ruoyi.vo.UserInfo; +#if($table.crud || $table.sub) +import com.ruoyi.common.core.domain.BaseEntity; +#elseif($table.tree) +import com.ruoyi.common.core.domain.TreeEntity; +#end + +/** + * ${functionName}对象 ${tableName} + * + * @author ${author} + * @date ${datetime} + */ +#if($table.crud || $table.sub) +#set($Entity="BaseEntity") +#elseif($table.tree) +#set($Entity="TreeEntity") +#end +@Data +@Accessors(chain = true) +@TableName("${tableName}") +public class ${ClassName} extends ${Entity} +{ + private static final long serialVersionUID = 1L; + + +#foreach ($column in $columns) +#if(!$table.isSuperColumn($column.javaField)) + @ApiModelProperty("$column.columnComment") +#if($column.list) +#set($parentheseIndex=$column.columnComment.indexOf("(")) +#if($parentheseIndex != -1) +#set($comment=$column.columnComment.substring(0, $parentheseIndex)) +#else +#set($comment=$column.columnComment) +#end +#if($parentheseIndex != -1) + @Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()") +#elseif($column.javaType == 'Date') +## @JsonFormat(pattern = "yyyy-MM-dd") + @Excel(name = "${comment}", width = 30, dateFormat = "yyyy-MM-dd") +#else + @Excel(name = "${comment}") +#end +#end + private $column.javaType $column.javaField; + +#end +#end +#foreach ($column in $columns)#if((${column.columnName} !="user_id"))#else + @ApiModelProperty("用户信息") + @TableField(exist = false) + private UserInfo userInfo; + #end +#end + +#if($table.sub) + /** $table.subTable.functionName信息 */ + private List<${subClassName}> ${subclassName}List; + +#end +#foreach ($column in $columns) +#if(!$table.isSuperColumn($column.javaField)) +#if($column.javaField.length() > 2 && $column.javaField.substring(1,2).matches("[A-Z]")) +#set($AttrName=$column.javaField) +#else +#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)}) +#end +## public void set${AttrName}($column.javaType $column.javaField) +## { +## this.$column.javaField = $column.javaField; +## } +## +## public $column.javaType get${AttrName}() +## { +## return $column.javaField; +## } +#end +#end + +#if($table.sub) + public List<${subClassName}> get${subClassName}List() + { + return ${subclassName}List; + } + + public void set${subClassName}List(List<${subClassName}> ${subclassName}List) + { + this.${subclassName}List = ${subclassName}List; + } + +#end +## @Override +## public String toString() { +## return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) +###foreach ($column in $columns) +###if($column.javaField.length() > 2 && $column.javaField.substring(1,2).matches("[A-Z]")) +###set($AttrName=$column.javaField) +###else +###set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)}) +###end +## .append("${column.javaField}", get${AttrName}()) +###end +###if($table.sub) +## .append("${subclassName}List", get${subClassName}List()) +###end +## .toString(); +## } +} diff --git a/ruoyi-base-support/ruoyi-generator/src/main/resources/vm/java/mapper.java.vm b/ruoyi-base-support/ruoyi-generator/src/main/resources/vm/java/mapper.java.vm new file mode 100644 index 0000000..8eca288 --- /dev/null +++ b/ruoyi-base-support/ruoyi-generator/src/main/resources/vm/java/mapper.java.vm @@ -0,0 +1,92 @@ +package ${packageName}.${businessName}.mapper; + +import java.util.List; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import ${packageName}.${businessName}.entity.${ClassName}; +#if($table.sub) +import ${packageName}.${businessName}.entity.${subClassName}; +#end + +/** + * ${functionName}Mapper接口 + * + * @author ${author} + * @date ${datetime} + */ +public interface ${ClassName}Mapper extends BaseMapper<${ClassName}> +{ + /** + * 查询${functionName} + * + * @param ${pkColumn.javaField} ${functionName}主键 + * @return ${functionName} + */ + public ${ClassName} select${ClassName}By${pkColumn.capJavaField}(${pkColumn.javaType} ${pkColumn.javaField}); + + /** + * 查询${functionName}列表 + * + * @param ${className} ${functionName} + * @return ${functionName}集合 + */ + public List<${ClassName}> select${ClassName}List(${ClassName} ${className}); + + /** + * 新增${functionName} + * + * @param ${className} ${functionName} + * @return 结果 + */ + public int insert${ClassName}(${ClassName} ${className}); + + /** + * 修改${functionName} + * + * @param ${className} ${functionName} + * @return 结果 + */ + public int update${ClassName}(${ClassName} ${className}); + +## /** +## * 删除${functionName} +## * +## * @param ${pkColumn.javaField} ${functionName}主键 +## * @return 结果 +## */ +## public int delete${ClassName}By${pkColumn.capJavaField}(${pkColumn.javaType} ${pkColumn.javaField}); +## +## /** +## * 批量删除${functionName} +## * +## * @param ${pkColumn.javaField}s 需要删除的数据主键集合 +## * @return 结果 +## */ +## public int delete${ClassName}By${pkColumn.capJavaField}s(${pkColumn.javaType}[] ${pkColumn.javaField}s); +###if($table.sub) +## +## /** +## * 批量删除${subTable.functionName} +## * +## * @param ${pkColumn.javaField}s 需要删除的数据主键集合 +## * @return 结果 +## */ +## public int delete${subClassName}By${subTableFkClassName}s(${pkColumn.javaType}[] ${pkColumn.javaField}s); +## +## /** +## * 批量新增${subTable.functionName} +## * +## * @param ${subclassName}List ${subTable.functionName}列表 +## * @return 结果 +## */ +## public int batch${subClassName}(List<${subClassName}> ${subclassName}List); +## +## +## /** +## * 通过${functionName}主键删除${subTable.functionName}信息 +## * +## * @param ${pkColumn.javaField} ${functionName}ID +## * @return 结果 +## */ +## public int delete${subClassName}By${subTableFkClassName}(${pkColumn.javaType} ${pkColumn.javaField}); +###end +} diff --git a/ruoyi-base-support/ruoyi-generator/src/main/resources/vm/java/param.java.vm b/ruoyi-base-support/ruoyi-generator/src/main/resources/vm/java/param.java.vm new file mode 100644 index 0000000..97aa0b1 --- /dev/null +++ b/ruoyi-base-support/ruoyi-generator/src/main/resources/vm/java/param.java.vm @@ -0,0 +1,108 @@ +package ${packageName}.${businessName}.entity.model.param; + +#foreach ($import in $importList) +import ${import}; +#end +import lombok.Data; +import lombok.experimental.Accessors; +import com.ruoyi.common.annotation.Excel; +import io.swagger.annotations.ApiModelProperty; +#if($table.crud || $table.sub) +import com.ruoyi.common.core.domain.BaseEntity; +#elseif($table.tree) +import com.ruoyi.common.core.domain.TreeEntity; +#end + +/** + * ${functionName}对象 ${tableName} + * + * @author ${author} + * @date ${datetime} + */ +#if($table.crud || $table.sub) +#set($Entity="BaseEntity") +#elseif($table.tree) +#set($Entity="TreeEntity") +#end +@Data +@Accessors(chain = true) +public class ${ClassName}Param extends ${Entity} +{ + private static final long serialVersionUID = 1L; + +#foreach ($column in $columns) +#if(!$table.isSuperColumn($column.javaField)) + @ApiModelProperty("$column.columnComment") +#if($column.list) +#set($parentheseIndex=$column.columnComment.indexOf("(")) +#if($parentheseIndex != -1) +#set($comment=$column.columnComment.substring(0, $parentheseIndex)) +#else +#set($comment=$column.columnComment) +#end +#if($parentheseIndex != -1) + @Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()") +#elseif($column.javaType == 'Date') +## @JsonFormat(pattern = "yyyy-MM-dd") + @Excel(name = "${comment}", width = 30, dateFormat = "yyyy-MM-dd") +#else + @Excel(name = "${comment}") +#end +#end + private $column.javaType $column.javaField; + +#end +#end +#if($table.sub) + /** $table.subTable.functionName信息 */ + private List<${subClassName}> ${subclassName}List; + +#end +#foreach ($column in $columns) +#if(!$table.isSuperColumn($column.javaField)) +#if($column.javaField.length() > 2 && $column.javaField.substring(1,2).matches("[A-Z]")) +#set($AttrName=$column.javaField) +#else +#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)}) +#end +## public void set${AttrName}($column.javaType $column.javaField) +## { +## this.$column.javaField = $column.javaField; +## } + +## public $column.javaType get${AttrName}() +## { +## return $column.javaField; +## } +#end +#end + +#if($table.sub) + public List<${subClassName}> get${subClassName}List() + { + return ${subclassName}List; + } + + public void set${subClassName}List(List<${subClassName}> ${subclassName}List) + { + this.${subclassName}List = ${subclassName}List; + } + +#end +## @Override +## public String toString() { +## return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) +###foreach ($column in $columns) +###if($column.javaField.length() > 2 && $column.javaField.substring(1,2).matches("[A-Z]")) +###set($AttrName=$column.javaField) +###else +###set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)}) +###end +## .append("${column.javaField}", get${AttrName}()) +###end +###if($table.sub) +## .append("${subclassName}List", get${subClassName}List()) +###end +## .toString(); +## } +} diff --git a/ruoyi-base-support/ruoyi-generator/src/main/resources/vm/java/result.java.vm b/ruoyi-base-support/ruoyi-generator/src/main/resources/vm/java/result.java.vm new file mode 100644 index 0000000..cf65faa --- /dev/null +++ b/ruoyi-base-support/ruoyi-generator/src/main/resources/vm/java/result.java.vm @@ -0,0 +1,108 @@ +package ${packageName}.${businessName}.entity.model.result; + +#foreach ($import in $importList) +import ${import}; +#end +import lombok.Data; +import lombok.experimental.Accessors; +import com.ruoyi.common.annotation.Excel; +import io.swagger.annotations.ApiModelProperty; +#if($table.crud || $table.sub) +import com.ruoyi.common.core.domain.BaseEntity; +#elseif($table.tree) +import com.ruoyi.common.core.domain.TreeEntity; +#end + +/** + * ${functionName}对象 ${tableName} + * + * @author ${author} + * @date ${datetime} + */ +#if($table.crud || $table.sub) +#set($Entity="BaseEntity") +#elseif($table.tree) +#set($Entity="TreeEntity") +#end +@Data +@Accessors(chain = true) +public class ${ClassName}Result extends ${Entity} +{ + private static final long serialVersionUID = 1L; + +#foreach ($column in $columns) +#if(!$table.isSuperColumn($column.javaField)) + @ApiModelProperty("$column.columnComment") +#if($column.list) +#set($parentheseIndex=$column.columnComment.indexOf("(")) +#if($parentheseIndex != -1) +#set($comment=$column.columnComment.substring(0, $parentheseIndex)) +#else +#set($comment=$column.columnComment) +#end +#if($parentheseIndex != -1) + @Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()") +#elseif($column.javaType == 'Date') +## @JsonFormat(pattern = "yyyy-MM-dd") + @Excel(name = "${comment}", width = 30, dateFormat = "yyyy-MM-dd") +#else + @Excel(name = "${comment}") +#end +#end + private $column.javaType $column.javaField; + +#end +#end +#if($table.sub) + /** $table.subTable.functionName信息 */ + private List<${subClassName}> ${subclassName}List; + +#end +#foreach ($column in $columns) +#if(!$table.isSuperColumn($column.javaField)) +#if($column.javaField.length() > 2 && $column.javaField.substring(1,2).matches("[A-Z]")) +#set($AttrName=$column.javaField) +#else +#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)}) +#end +## public void set${AttrName}($column.javaType $column.javaField) +## { +## this.$column.javaField = $column.javaField; +## } +## +## public $column.javaType get${AttrName}() +## { +## return $column.javaField; +## } +#end +#end + +#if($table.sub) + public List<${subClassName}> get${subClassName}List() + { + return ${subclassName}List; + } + + public void set${subClassName}List(List<${subClassName}> ${subclassName}List) + { + this.${subclassName}List = ${subclassName}List; + } + +#end +## @Override +## public String toString() { +## return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) +###foreach ($column in $columns) +###if($column.javaField.length() > 2 && $column.javaField.substring(1,2).matches("[A-Z]")) +###set($AttrName=$column.javaField) +###else +###set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)}) +###end +## .append("${column.javaField}", get${AttrName}()) +###end +###if($table.sub) +## .append("${subclassName}List", get${subClassName}List()) +###end +## .toString(); +## } +} diff --git a/ruoyi-base-support/ruoyi-generator/src/main/resources/vm/java/service.java.vm b/ruoyi-base-support/ruoyi-generator/src/main/resources/vm/java/service.java.vm new file mode 100644 index 0000000..a90a3d5 --- /dev/null +++ b/ruoyi-base-support/ruoyi-generator/src/main/resources/vm/java/service.java.vm @@ -0,0 +1,62 @@ +package ${packageName}.${businessName}.service; + +import java.util.List; +import ${packageName}.${businessName}.entity.${ClassName}; +import com.baomidou.mybatisplus.extension.service.IService; + +/** + * ${functionName}Service接口 + * + * @author ${author} + * @date ${datetime} + */ +public interface ${ClassName}Service extends IService<${ClassName}> +{ + /** + * 查询${functionName} + * + * @param ${pkColumn.javaField} ${functionName}主键 + * @return ${functionName} + */ + public ${ClassName} select${ClassName}By${pkColumn.capJavaField}(${pkColumn.javaType} ${pkColumn.javaField}); + + /** + * 查询${functionName}列表 + * + * @param ${className} ${functionName} + * @return ${functionName}集合 + */ + public List<${ClassName}> select${ClassName}List(${ClassName} ${className}); + + /** + * 新增${functionName} + * + * @param ${className} ${functionName} + * @return 结果 + */ + public int insert${ClassName}(${ClassName} ${className}); + + /** + * 修改${functionName} + * + * @param ${className} ${functionName} + * @return 结果 + */ + public int update${ClassName}(${ClassName} ${className}); + + /** + * 批量删除${functionName} + * + * @param ${pkColumn.javaField}s 需要删除的${functionName}主键集合 + * @return 结果 + */ + public int delete${ClassName}By${pkColumn.capJavaField}s(${pkColumn.javaType}[] ${pkColumn.javaField}s,Integer delFlag); + +## /** +## * 删除${functionName}信息 +## * +## * @param ${pkColumn.javaField} ${functionName}主键 +## * @return 结果 +## */ +## public int delete${ClassName}By${pkColumn.capJavaField}(${pkColumn.javaType} ${pkColumn.javaField}); +} diff --git a/ruoyi-base-support/ruoyi-generator/src/main/resources/vm/java/serviceImpl.java.vm b/ruoyi-base-support/ruoyi-generator/src/main/resources/vm/java/serviceImpl.java.vm new file mode 100644 index 0000000..d86aa60 --- /dev/null +++ b/ruoyi-base-support/ruoyi-generator/src/main/resources/vm/java/serviceImpl.java.vm @@ -0,0 +1,173 @@ +package ${packageName}.${businessName}.service.impl; + +import java.util.List; +#foreach ($column in $columns) +#if($column.javaField == 'createTime' || $column.javaField == 'updateTime') +import com.ruoyi.common.utils.DateUtils; +#break +#end +#end +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.ruoyi.code.PublicCommon; +#if($table.sub) +import java.util.ArrayList; +import com.ruoyi.common.utils.StringUtils; +import org.springframework.transaction.annotation.Transactional; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import ${packageName}.${businessName}.entity.${subClassName}; +#end +import ${packageName}.${businessName}.mapper.${ClassName}Mapper; +import ${packageName}.${businessName}.entity.${ClassName}; +import ${packageName}.${businessName}.service.${ClassName}Service; + +/** + * ${functionName}Service业务层处理 + * + * @author ${author} + * @date ${datetime} + */ +@Service +public class ${ClassName}ServiceImpl extends ServiceImpl<${ClassName}Mapper, ${ClassName}> implements ${ClassName}Service +{ + @Autowired + private ${ClassName}Mapper ${className}Mapper; + + /** + * 查询${functionName} + * + * @param ${pkColumn.javaField} ${functionName}主键 + * @return ${functionName} + */ + @Override + public ${ClassName} select${ClassName}By${pkColumn.capJavaField}(${pkColumn.javaType} ${pkColumn.javaField}) + { + return ${className}Mapper.select${ClassName}By${pkColumn.capJavaField}(${pkColumn.javaField}); + } + + /** + * 查询${functionName}列表 + * + * @param ${className} ${functionName} + * @return ${functionName} + */ + @Override + public List<${ClassName}> select${ClassName}List(${ClassName} ${className}) + { + return ${className}Mapper.select${ClassName}List(${className}); + } + + /** + * 新增${functionName} + * + * @param ${className} ${functionName} + * @return 结果 + */ +#if($table.sub) + @Transactional +#end + @Override + public int insert${ClassName}(${ClassName} ${className}) + { +#foreach ($column in $columns) +#if($column.javaField == 'createTime') + ${className}.setCreateData(); +#end +#end +#if($table.sub) + int rows = ${className}Mapper.insert${ClassName}(${className}); + insert${subClassName}(${className}); + return rows; +#else + return ${className}Mapper.insert(${className}); +#end + } + + /** + * 修改${functionName} + * + * @param ${className} ${functionName} + * @return 结果 + */ +#if($table.sub) + @Transactional +#end + @Override + public int update${ClassName}(${ClassName} ${className}) + { +#foreach ($column in $columns) +#if($column.javaField == 'updateTime') + ${className}.setUpdateData(); +#end +#end +#if($table.sub) + ${className}Mapper.delete${subClassName}By${subTableFkClassName}(${className}.get${pkColumn.capJavaField}()); + insert${subClassName}(${className}); +#end + return ${className}Mapper.update${ClassName}(${className}); + } + + /** + * 批量删除${functionName} + * + * @param ${pkColumn.javaField}s 需要删除的${functionName}主键 + * @return 结果 + */ +#if($table.sub) + @Transactional +#end + @Override + public int delete${ClassName}By${pkColumn.capJavaField}s(${pkColumn.javaType}[] ${pkColumn.javaField}s,Integer delFlag) + { +#if($table.sub) + ${className}Mapper.delete${subClassName}By${subTableFkClassName}s(${pkColumn.javaField}s); +#end + this.lambdaUpdate().set(${ClassName}::getDelFlag,delFlag).in(${ClassName}::getId,${pkColumn.javaField}s).update(); + return ${pkColumn.javaField}s.length; +## return ${className}Mapper.delete${ClassName}By${pkColumn.capJavaField}s(${pkColumn.javaField}s); + } + +## /** +## * 删除${functionName}信息 +## * +## * @param ${pkColumn.javaField} ${functionName}主键 +## * @return 结果 +## */ +## @Override +## public int delete${ClassName}By${pkColumn.capJavaField}(${pkColumn.javaType} ${pkColumn.javaField}) +## { +###if($table.sub) +## ${className}Mapper.delete${subClassName}By${subTableFkClassName}(${pkColumn.javaField}); +###end +## this.lambdaUpdate().set(${ClassName}::getDelFlag,PublicCommon.删除).eq(${ClassName}::getId,${pkColumn.javaField}).update(); +#### return ${className}Mapper.delete${ClassName}By${pkColumn.capJavaField}(${pkColumn.javaField}); +## return 1; +## } +#if($table.sub) + + /** + * 新增${subTable.functionName}信息 + * + * @param ${className} ${functionName}对象 + */ + public void insert${subClassName}(${ClassName} ${className}) + { + List<${subClassName}> ${subclassName}List = ${className}.get${subClassName}List(); + ${pkColumn.javaType} ${pkColumn.javaField} = ${className}.get${pkColumn.capJavaField}(); + if (StringUtils.isNotNull(${subclassName}List)) + { + List<${subClassName}> list = new ArrayList<${subClassName}>(); + for (${subClassName} ${subclassName} : ${subclassName}List) + { + ${subclassName}.set${subTableFkClassName}(${pkColumn.javaField}); + list.add(${subclassName}); + } + if (list.size() > 0) + { + ${className}Mapper.batch${subClassName}(list); + } + } + } +#end +} diff --git a/ruoyi-base-support/ruoyi-generator/src/main/resources/vm/java/sub-domain.java.vm b/ruoyi-base-support/ruoyi-generator/src/main/resources/vm/java/sub-domain.java.vm new file mode 100644 index 0000000..c20ee19 --- /dev/null +++ b/ruoyi-base-support/ruoyi-generator/src/main/resources/vm/java/sub-domain.java.vm @@ -0,0 +1,75 @@ +package ${packageName}.${businessName}.entity; + +#foreach ($import in $subImportList) +import ${import}; +#end +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import io.swagger.annotations.ApiModelProperty; + +/** + * ${subTable.functionName}对象 ${subTableName} + * + * @author ${author} + * @date ${datetime} + */ +public class ${subClassName} extends BaseEntity +{ + private static final long serialVersionUID = 1L; + +#foreach ($column in $subTable.columns) +#if(!$table.isSuperColumn($column.javaField)) + @ApiModelProperty("$column.columnComment") +#if($column.list) +#set($parentheseIndex=$column.columnComment.indexOf("(")) +#if($parentheseIndex != -1) +#set($comment=$column.columnComment.substring(0, $parentheseIndex)) +#else +#set($comment=$column.columnComment) +#end +#if($parentheseIndex != -1) + @Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()") +#elseif($column.javaType == 'Date') +## @JsonFormat(pattern = "yyyy-MM-dd") + @Excel(name = "${comment}", width = 30, dateFormat = "yyyy-MM-dd") +#else + @Excel(name = "${comment}") +#end +#end + private $column.javaType $column.javaField; + +#end +#end +#foreach ($column in $subTable.columns) +#if(!$table.isSuperColumn($column.javaField)) +#if($column.javaField.length() > 2 && $column.javaField.substring(1,2).matches("[A-Z]")) +#set($AttrName=$column.javaField) +#else +#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)}) +#end + public void set${AttrName}($column.javaType $column.javaField) + { + this.$column.javaField = $column.javaField; + } + + public $column.javaType get${AttrName}() + { + return $column.javaField; + } +#end +#end + + @Override + public String toString() { + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) +#foreach ($column in $subTable.columns) +#if($column.javaField.length() > 2 && $column.javaField.substring(1,2).matches("[A-Z]")) +#set($AttrName=$column.javaField) +#else +#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)}) +#end + .append("${column.javaField}", get${AttrName}()) +#end + .toString(); + } +} diff --git a/ruoyi-base-support/ruoyi-generator/src/main/resources/vm/js/api.js.vm b/ruoyi-base-support/ruoyi-generator/src/main/resources/vm/js/api.js.vm new file mode 100644 index 0000000..296d41a --- /dev/null +++ b/ruoyi-base-support/ruoyi-generator/src/main/resources/vm/js/api.js.vm @@ -0,0 +1,53 @@ +import request from '@/utils/request' + +// 查询${functionName}列表 +export function list${BusinessName}(query) { + return request({ + url: '/${moduleName}/${businessName}/list', + method: 'get', + params: query + }) +} + +// 查询${functionName}详细 +export function get${BusinessName}(${pkColumn.javaField}) { + return request({ + url: '/${moduleName}/${businessName}/' + ${pkColumn.javaField}, + method: 'get' + }) +} + +// 新增${functionName} +export function add${BusinessName}(data) { + return request({ + url: '/${moduleName}/${businessName}', + method: 'post', + data: data + }) +} + +// 修改${functionName} +export function update${BusinessName}(data) { + return request({ + url: '/${moduleName}/${businessName}', + method: 'put', + data: data + }) +} + +// 删除${functionName} +export function del${BusinessName}(${pkColumn.javaField}) { + return request({ + url: '/${moduleName}/${businessName}/' + ${pkColumn.javaField}, + method: 'delete' + }) +} + +// 导出${functionName} +export function export${BusinessName}(query) { + return request({ + url: '/${moduleName}/${businessName}/export', + method: 'get', + params: query + }) +} \ No newline at end of file diff --git a/ruoyi-base-support/ruoyi-generator/src/main/resources/vm/sql/sql.vm b/ruoyi-base-support/ruoyi-generator/src/main/resources/vm/sql/sql.vm new file mode 100644 index 0000000..0575583 --- /dev/null +++ b/ruoyi-base-support/ruoyi-generator/src/main/resources/vm/sql/sql.vm @@ -0,0 +1,22 @@ +-- 菜单 SQL +insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark) +values('${functionName}', '${parentMenuId}', '1', '${businessName}', '${moduleName}/${businessName}/index', 1, 0, 'C', '0', '0', '${permissionPrefix}:list', '#', 'admin', sysdate(), '', null, '${functionName}菜单'); + +-- 按钮父菜单ID +SELECT @parentId := LAST_INSERT_ID(); + +-- 按钮 SQL +insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark) +values('${functionName}查询', @parentId, '1', '#', '', 1, 0, 'F', '0', '0', '${permissionPrefix}:query', '#', 'admin', sysdate(), '', null, ''); + +insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark) +values('${functionName}新增', @parentId, '2', '#', '', 1, 0, 'F', '0', '0', '${permissionPrefix}:add', '#', 'admin', sysdate(), '', null, ''); + +insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark) +values('${functionName}修改', @parentId, '3', '#', '', 1, 0, 'F', '0', '0', '${permissionPrefix}:edit', '#', 'admin', sysdate(), '', null, ''); + +insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark) +values('${functionName}删除', @parentId, '4', '#', '', 1, 0, 'F', '0', '0', '${permissionPrefix}:remove', '#', 'admin', sysdate(), '', null, ''); + +insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark) +values('${functionName}导出', @parentId, '5', '#', '', 1, 0, 'F', '0', '0', '${permissionPrefix}:export', '#', 'admin', sysdate(), '', null, ''); \ No newline at end of file diff --git a/ruoyi-base-support/ruoyi-generator/src/main/resources/vm/vue/index-tree.vue.vm b/ruoyi-base-support/ruoyi-generator/src/main/resources/vm/vue/index-tree.vue.vm new file mode 100644 index 0000000..a7febf1 --- /dev/null +++ b/ruoyi-base-support/ruoyi-generator/src/main/resources/vm/vue/index-tree.vue.vm @@ -0,0 +1,476 @@ + + + diff --git a/ruoyi-base-support/ruoyi-generator/src/main/resources/vm/vue/index.vue.vm b/ruoyi-base-support/ruoyi-generator/src/main/resources/vm/vue/index.vue.vm new file mode 100644 index 0000000..a8caa56 --- /dev/null +++ b/ruoyi-base-support/ruoyi-generator/src/main/resources/vm/vue/index.vue.vm @@ -0,0 +1,576 @@ + + + diff --git a/ruoyi-base-support/ruoyi-generator/src/main/resources/vm/xml/mapper.xml.vm b/ruoyi-base-support/ruoyi-generator/src/main/resources/vm/xml/mapper.xml.vm new file mode 100644 index 0000000..994c92d --- /dev/null +++ b/ruoyi-base-support/ruoyi-generator/src/main/resources/vm/xml/mapper.xml.vm @@ -0,0 +1,160 @@ + + + + + + #foreach ($column in $columns) + #end +#foreach ($column in $columns)#if(${column.columnName} =="user_id") + #end#end + + + #foreach ($column in $columns)#if((${column.columnName} =="user_id")) + + + + + + + + + #end#end + + #if($table.sub) + + + + + + + #foreach ($column in $subTable.columns) + + #end + + #end + + + select + #foreach($column in $columns)t.$column.columnName #if($velocityCount != $columns.size()), + #end#end#foreach($column in $columns)#if( ${column.columnName} =="user_id"), + u.user_type, + u.id_no, + u.mobile, + u.avatar, + u.nickname#end#end + + from ${tableName} AS t + #foreach ($column in $columns)#if((${column.columnName} =="user_id"))LEFT JOIN t_user AS u ON t.user_id = u.id#end#end + + + + + + + + + insert into ${tableName} + +#foreach($column in $columns) +#if($column.columnName != $pkColumn.columnName || !$pkColumn.increment) + $column.columnName, +#end +#end + + +#foreach($column in $columns) +#if($column.columnName != $pkColumn.columnName || !$pkColumn.increment) + #{$column.javaField}, +#end +#end + + + + + update ${tableName} + +#foreach($column in $columns) +#if($column.columnName != $pkColumn.columnName) + $column.columnName = #{$column.javaField}, +#end +#end + + where ${pkColumn.columnName} = #{${pkColumn.javaField}} + + ## + ## delete from ${tableName} where ${pkColumn.columnName} = #{${pkColumn.javaField}} + ## + ## + ## + ## delete from ${tableName} where ${pkColumn.columnName} in + ## + ## #{${pkColumn.javaField}} + ## + ## + ###if($table.sub) + ## + ## + ## delete from ${subTableName} where ${subTableFkName} in + ## + ## #{${subTableFkclassName}} + ## + ## + ## + ## + ## delete from ${subTableName} where ${subTableFkName} = #{${subTableFkclassName}} + ## + ## + ## + ## insert into ${subTableName}(#foreach($column in $subTable.columns) $column.columnName#if($velocityCount != $subTable.columns.size()),#end#end) values + ## + ## (#foreach($column in $subTable.columns) #{item.$column.javaField}#if($velocityCount != $subTable.columns.size()),#end#end) + ## + ## + ###end + \ No newline at end of file diff --git a/ruoyi-base-support/ruoyi-oss/pom.xml b/ruoyi-base-support/ruoyi-oss/pom.xml new file mode 100644 index 0000000..dc321cc --- /dev/null +++ b/ruoyi-base-support/ruoyi-oss/pom.xml @@ -0,0 +1,65 @@ + + + + ruoyi-base-support + com.ruoyi + 3.7.0 + + 4.0.0 + + ruoyi-oss + + + + 2.5.0 + + 7.1.3 + + 3.3 + + 1.3.3 + + + + + com.qiniu + qiniu-java-sdk + ${qiniu.oss.version} + + + + com.aliyun.oss + aliyun-sdk-oss + ${aliyun.oss.version} + + + + com.qcloud + cos_api + ${qcloud.cos.version} + + + org.slf4j + slf4j-log4j12 + + + log4j + log4j + + + + + + commons-fileupload + commons-fileupload + ${commons-fileupload.version} + + + com.ruoyi + ruoyi-common + + + + diff --git a/ruoyi-base-support/ruoyi-oss/src/main/java/com/ruoyi/oss/OSSUploadHelper.java b/ruoyi-base-support/ruoyi-oss/src/main/java/com/ruoyi/oss/OSSUploadHelper.java new file mode 100644 index 0000000..4f31c55 --- /dev/null +++ b/ruoyi-base-support/ruoyi-oss/src/main/java/com/ruoyi/oss/OSSUploadHelper.java @@ -0,0 +1,367 @@ +package com.ruoyi.oss; + +import com.ruoyi.common.utils.DateUtils; +import com.ruoyi.common.utils.PropertiesUtil; +import com.ruoyi.common.utils.StringUtils; +import com.ruoyi.common.utils.file.FileUtils; +import com.ruoyi.oss.client.IOSSClient; +import com.ruoyi.oss.client.OSSClientFactory; +import com.ruoyi.oss.config.OssConfig; +import com.ruoyi.oss.constant.Constants; +import com.ruoyi.oss.exception.FileNameLengthLimitExceededException; +import com.ruoyi.oss.exception.InvalidExtensionException; +import org.apache.commons.fileupload.FileUploadBase.FileSizeLimitExceededException; +import org.apache.commons.io.FilenameUtils; +import org.apache.commons.lang3.time.DateFormatUtils; +import org.springframework.web.multipart.MultipartFile; + +import javax.servlet.http.HttpServletRequest; +import java.io.IOException; +import java.io.UnsupportedEncodingException; +import java.net.URL; +import java.util.Date; + +/** + * 文件上传操作助手 + */ +public class OSSUploadHelper { + public static final String DEFAULT_CONFIG_FILE = "upload.properties"; + + // 默认的文件名最大长度 + public static final int DEFAULT_FILE_NAME_LENGTH = 200; + + public static final String[] IMAGE_EXTENSION = {"bmp", "gif", "jpg", "jpeg", "png"}; + + public static final String[] FLASH_EXTENSION = {"swf", "flv"}; + + public static final String[] MEDIA_EXTENSION = {"swf", "flv", "mp3", "wav", "wma", "wmv", "mid", "avi", "mpg", + "asf", "rm", "rmvb"}; + + // 默认上传的地址 + private static final String DEFAULT_BASE_DIR = "upload"; + private String ossBaseDir = DEFAULT_BASE_DIR; + //文件大小限制 + // 默认大小 50M + public static final long DEFAULT_MAX_SIZE = 52428800; + private long maxSize = DEFAULT_MAX_SIZE; + private boolean needDatePath = false; + //允许扩展名 + public static final String[] DEFAULT_ALLOWED_EXTENSION = { + // 图片 + "bmp", "gif", "jpg", "jpeg", "png", + // word excel powerpoint + "doc", "docx", "xls", "xlsx", "ppt", "pptx", "html", "htm", "txt", + // 压缩文件 + "rar", "zip", "gz", "bz2", + // pdf + "pdf"}; + public String[] allowedExtension = DEFAULT_ALLOWED_EXTENSION; + //OSS上传客户端 + private String clientType = Constants.CLIENT_LOCAL; + private IOSSClient ossClient; + + public void init() { + init(DEFAULT_CONFIG_FILE); + } + + public void init(String configname) { + PropertiesUtil propertiesUtil = new PropertiesUtil(configname); + maxSize = propertiesUtil.getLong("upload.max.size"); + ossBaseDir = propertiesUtil.getString("upload.base.dir"); + String extension = propertiesUtil.getString("upload.allowed.extension"); + allowedExtension = extension.split(","); + clientType = propertiesUtil.getString("upload.client.type"); + this.ossClient = OSSClientFactory.build(clientType); + this.ossClient.init(); + } + + public void init(OssConfig ossConfig) { + maxSize = ossConfig.getMaxSize(); + ossBaseDir = ossConfig.getBaseDir(); + needDatePath = ossConfig.isNeedDatePath(); + String extension = ossConfig.getAllowedExtension(); + allowedExtension = extension.split(","); + clientType = ossConfig.getClientType(); + this.ossClient = OSSClientFactory.build(clientType); + this.ossClient.init(ossConfig); + } + + /** + * 以默认配置进行文件上传 + * + * @param request 当前请求 + * @param file 上传的文件 + * 添加出错信息 + * @return + * @throws IOException + * @throws FileNameLengthLimitExceededException + * @throws InvalidExtensionException + * @throws FileSizeLimitExceededException + */ + public String upload(HttpServletRequest request, MultipartFile file, String baseDir) + throws FileSizeLimitExceededException, InvalidExtensionException, FileNameLengthLimitExceededException, + IOException { + return upload(request, file, baseDir, allowedExtension); + } + + /** + * 以默认配置进行文件上传 + * + * @param request 当前请求 + * @param file 上传的文件 + * 添加出错信息 + * @param allowedExtension 允许上传的文件类型 + * @return + * @throws IOException + * @throws FileNameLengthLimitExceededException + * @throws InvalidExtensionException + * @throws FileSizeLimitExceededException + */ + public String upload(HttpServletRequest request, MultipartFile file, String baseDir, String[] allowedExtension) + throws FileSizeLimitExceededException, InvalidExtensionException, FileNameLengthLimitExceededException, + IOException { + return upload(request, file, baseDir, allowedExtension, maxSize, needDatePath); + } + + /** + * 文件上传 + * + * @param request 当前请求 从请求中提取 应用上下文根 + * @param baseDir 相对应用的基目录 + * @param file 上传的文件 + * @param allowedExtension 允许的文件类型 null 表示允许所有 + * @param maxSize 最大上传的大小 -1 表示不限制 + * @param needDatePath 是否需要日期目录和随机文件名前缀 + * @return 返回上传成功的文件名 + * @throws InvalidExtensionException 如果MIME类型不允许 + * @throws FileSizeLimitExceededException 如果超出最大大小 + * @throws FileNameLengthLimitExceededException 文件名太长 + * @throws IOException 比如读写文件出错时 + */ + public String upload(HttpServletRequest request, MultipartFile file, String baseDir, + String[] allowedExtension, long maxSize, boolean needDatePath) + throws InvalidExtensionException, FileSizeLimitExceededException, IOException, + FileNameLengthLimitExceededException { + int fileNamelength = file.getOriginalFilename().length(); + if (fileNamelength > OSSUploadHelper.DEFAULT_FILE_NAME_LENGTH) { + throw new FileNameLengthLimitExceededException(file.getOriginalFilename(), fileNamelength, + OSSUploadHelper.DEFAULT_FILE_NAME_LENGTH); + } + assertAllowed(file, allowedExtension, maxSize); + String filename = extractFilename(file, baseDir, needDatePath); + filename = StringUtils.trimDiagonal(filename); + return ossClient.upload(file.getInputStream(), filename); + } + + + /** + * 以默认配置进行文件上传 + * + * @param request 当前请求 + * @param remoteUrl 上传的文件 + * 添加出错信息 + * @return + * @throws IOException + * @throws FileNameLengthLimitExceededException + * @throws InvalidExtensionException + * @throws FileSizeLimitExceededException + */ + public String remote(HttpServletRequest request, String remoteUrl, String baseDir) + throws FileSizeLimitExceededException, InvalidExtensionException, FileNameLengthLimitExceededException, + IOException { + return remote(request, remoteUrl, baseDir, allowedExtension); + } + + /** + * 以默认配置进行文件上传 + * + * @param request 当前请求 + * @param remoteUrl 上传的文件 + * 添加出错信息 + * @param allowedExtension 允许上传的文件类型 + * @return + * @throws IOException + * @throws FileNameLengthLimitExceededException + * @throws InvalidExtensionException + * @throws FileSizeLimitExceededException + */ + public String remote(HttpServletRequest request, String remoteUrl, String baseDir, String[] allowedExtension) + throws FileSizeLimitExceededException, InvalidExtensionException, FileNameLengthLimitExceededException, + IOException { + return remote(request, remoteUrl, baseDir, allowedExtension, maxSize, true); + } + + /** + * 文件上传 + * + * @param request 当前请求 从请求中提取 应用上下文根 + * @param baseDir 相对应用的基目录 + * @param remoteUrl 上传的文件 + * @param allowedExtension 允许的文件类型 null 表示允许所有 + * @param maxSize 最大上传的大小 -1 表示不限制 + * @param needDatePathAndRandomName 是否需要日期目录和随机文件名前缀 + * @return 返回上传成功的文件名 + * @throws InvalidExtensionException 如果MIME类型不允许 + * @throws FileSizeLimitExceededException 如果超出最大大小 + * @throws FileNameLengthLimitExceededException 文件名太长 + * @throws IOException 比如读写文件出错时 + */ + public String remote(HttpServletRequest request, String remoteUrl, String baseDir, + String[] allowedExtension, long maxSize, boolean needDatePathAndRandomName) + throws InvalidExtensionException, FileSizeLimitExceededException, IOException, + FileNameLengthLimitExceededException { + URL url = new URL(remoteUrl); + assertAllowed(remoteUrl, allowedExtension, maxSize); + String filename = extractFilename(remoteUrl, baseDir, needDatePathAndRandomName); + filename = StringUtils.trimDiagonal(filename); + return ossClient.upload(url.openStream(), filename); + } + + public String extractFilename(String remoteUrl, String baseDir, boolean needDatePathAndRandomName) + throws UnsupportedEncodingException { + //字符串处理 + if (!StringUtils.isEmpty(this.ossBaseDir)) { + if (!StringUtils.isEmpty(baseDir)) { + baseDir = this.ossBaseDir + "/" + baseDir; + } else { + baseDir = this.ossBaseDir; + } + } + String filename = remoteUrl; + int slashIndex = filename.indexOf("/"); + if (slashIndex >= 0) { + filename = filename.substring(slashIndex + 1); + } + if (needDatePathAndRandomName) { + filename = datePath() + "/" + System.currentTimeMillis() + "." + + FileUtils.getExtensionName(filename); + } + if (!StringUtils.isEmpty(baseDir)) { + filename = baseDir + "/" + filename; + } + return filename; + } + + /** + * 是否允许文件上传 + * + * @param remoteUrl 上传的文件 + * @param allowedExtension 文件类型 null 表示允许所有 + * @param maxSize 最大大小 字节为单位 -1表示不限制 + * @return + * @throws InvalidExtensionException 如果MIME类型不允许 + * @throws FileSizeLimitExceededException 如果超出最大大小 + */ + public void assertAllowed(String remoteUrl, String[] allowedExtension, long maxSize) + throws InvalidExtensionException, FileSizeLimitExceededException { + + String extension = FilenameUtils.getExtension(remoteUrl); + if (allowedExtension != null && !isAllowedExtension(extension, allowedExtension)) { + if (allowedExtension == IMAGE_EXTENSION) { + throw new InvalidExtensionException.InvalidImageExtensionException(allowedExtension, extension, + remoteUrl); + } else if (allowedExtension == FLASH_EXTENSION) { + throw new InvalidExtensionException.InvalidFlashExtensionException(allowedExtension, extension, + remoteUrl); + } else if (allowedExtension == MEDIA_EXTENSION) { + throw new InvalidExtensionException.InvalidMediaExtensionException(allowedExtension, extension, + remoteUrl); + } else { + throw new InvalidExtensionException(allowedExtension, extension, remoteUrl); + } + } + } + + public String extractFilename(MultipartFile file, String baseDir, boolean needDatePathAndRandomName) + throws UnsupportedEncodingException { + if (!StringUtils.isEmpty(this.ossBaseDir)) { + if (!StringUtils.isEmpty(baseDir)) { + baseDir = this.ossBaseDir + "/" + baseDir; + } else { + baseDir = this.ossBaseDir; + } + } + String filename = file.getOriginalFilename(); + //文件名必须重新命名,以时间精确到毫秒命名 + filename = DateUtils.dateTimeNow() + "." + + FileUtils.getExtensionName(filename); + if (needDatePathAndRandomName) { + filename = datePath() + "/" + filename; + } + if (!StringUtils.isEmpty(baseDir)) { + filename = baseDir + "/" + filename; + } + return filename; + } + + /** + * 日期路径 即年/月/日 如2013/01/03 + * + * @return + */ + private String datePath() { + Date now = new Date(); + return DateFormatUtils.format(now, "yyyy/MM/dd"); + } + + /** + * 是否允许文件上传 + * + * @param file 上传的文件 + * @param allowedExtension 文件类型 null 表示允许所有 + * @param maxSize 最大大小 字节为单位 -1表示不限制 + * @return + * @throws InvalidExtensionException 如果MIME类型不允许 + * @throws FileSizeLimitExceededException 如果超出最大大小 + */ + public void assertAllowed(MultipartFile file, String[] allowedExtension, long maxSize) + throws InvalidExtensionException, FileSizeLimitExceededException { + + String filename = file.getOriginalFilename(); + String extension = FilenameUtils.getExtension(file.getOriginalFilename()); + + if (allowedExtension != null && !isAllowedExtension(extension, allowedExtension)) { + if (allowedExtension == IMAGE_EXTENSION) { + throw new InvalidExtensionException.InvalidImageExtensionException(allowedExtension, extension, + filename); + } else if (allowedExtension == FLASH_EXTENSION) { + throw new InvalidExtensionException.InvalidFlashExtensionException(allowedExtension, extension, + filename); + } else if (allowedExtension == MEDIA_EXTENSION) { + throw new InvalidExtensionException.InvalidMediaExtensionException(allowedExtension, extension, + filename); + } else { + throw new InvalidExtensionException(allowedExtension, extension, filename); + } + } + + long size = file.getSize(); + if (maxSize != -1 && size > maxSize) { + throw new FileSizeLimitExceededException("not allowed upload upload", size, maxSize); + } + } + + /** + * 判断MIME类型是否是允许的MIME类型 + * + * @param extension + * @param allowedExtension + * @return + */ + public boolean isAllowedExtension(String extension, String[] allowedExtension) { + for (String str : allowedExtension) { + if (str.trim().equalsIgnoreCase(extension.trim())) { + return true; + } + } + return false; + } + + + public void delete(HttpServletRequest request, String filename) throws IOException { + if (StringUtils.isEmpty(filename)) { + return; + } + ossClient.delete(filename); + } +} diff --git a/ruoyi-base-support/ruoyi-oss/src/main/java/com/ruoyi/oss/client/AbstractOSSClient.java b/ruoyi-base-support/ruoyi-oss/src/main/java/com/ruoyi/oss/client/AbstractOSSClient.java new file mode 100644 index 0000000..9862d56 --- /dev/null +++ b/ruoyi-base-support/ruoyi-oss/src/main/java/com/ruoyi/oss/client/AbstractOSSClient.java @@ -0,0 +1,13 @@ +package com.ruoyi.oss.client; + +/** + * All rights Reserved, Designed By kjt.gzst.gov.cn + * + * @version V1.0 + * @title: IOSSClient.java + * @description: 操作客户端虚类 * @date: 2017年8月11日 下午9:55:00 + * @copyright: 2017 kjt.gzst.gov.cn Inc. All rights reserved. + */ +public abstract class AbstractOSSClient implements IOSSClient { + //protected abstract void init(); +} diff --git a/ruoyi-base-support/ruoyi-oss/src/main/java/com/ruoyi/oss/client/AliyunOSSClient.java b/ruoyi-base-support/ruoyi-oss/src/main/java/com/ruoyi/oss/client/AliyunOSSClient.java new file mode 100644 index 0000000..5659916 --- /dev/null +++ b/ruoyi-base-support/ruoyi-oss/src/main/java/com/ruoyi/oss/client/AliyunOSSClient.java @@ -0,0 +1,97 @@ +package com.ruoyi.oss.client; + +import com.aliyun.oss.OSSClient; +import com.ruoyi.common.utils.PropertiesUtil; +import com.ruoyi.oss.config.AliyunConfig; +import com.ruoyi.oss.config.OssConfig; +import com.ruoyi.oss.exception.OSSException; + +import java.io.InputStream; + +/** + * All rights Reserved, Designed By kjt.gzst.gov.cn + * + * @version V1.0 + * @title: IOSSClient.java + * @description: 阿里云的客户端操作 * @date: 2017年8月11日 下午9:55:00 + * @copyright: 2017 kjt.gzst.gov.cn Inc. All rights reserved. + */ +public class AliyunOSSClient extends AbstractOSSClient { + public static final String DEFAULT_CONFIG_FILE = "aliyun.oss.properties"; + //阿里云客户端 + private OSSClient client; + //阿里云API的内或外网域名 + private String endpoint; + //阿里云API的密钥Access Key ID + private String accessKeyId; + //阿里云API的密钥Access Key Secret + private String accessKeySecret; + //访问域名 + private String domain; + //bucket名称 + private String bucketName; + + @Override + public void init() { + init(DEFAULT_CONFIG_FILE); + } + + @Override + public void init(String propertiesName) { + PropertiesUtil p = new PropertiesUtil(propertiesName); + endpoint = p.getString("aliyun.oss.endpoint"); + accessKeyId = p.getString("aliyun.oss.access-key-id"); + accessKeySecret = p.getString("aliyun.oss.access-key-secret"); + bucketName = p.getString("aliyun.oss.bucket-name"); + domain = p.getString("aliyun.oss.domain"); + client = new OSSClient(endpoint, accessKeyId, accessKeySecret); + } + + @Override + public void init(OssConfig config) { + AliyunConfig aliyunConfig = config.getAliyun(); + endpoint = aliyunConfig.getEndpoint(); + accessKeyId = aliyunConfig.getAccessKeyId(); + accessKeySecret = aliyunConfig.getAccessKeySecret(); + bucketName = aliyunConfig.getBucketName(); + domain = aliyunConfig.getDomain(); + client = new OSSClient(endpoint, accessKeyId, accessKeySecret); + } + + /** + * 一般不推荐使用 + * + * @return + */ + public OSSClient getClient() { + return this.client; + } + + /** + * 文件上传 + * + * @param inputStream + * @param path + * @return + */ + @Override + public String upload(InputStream inputStream, String path) { + try { + client.putObject(bucketName, path, inputStream); + } catch (Exception e) { + throw new OSSException("上传文件失败", e); + } + return domain + "/" + path; + } + + @Override + public void delete(String filename) { + + try { + filename = filename.replace(domain + "/", ""); + client.deleteObject(bucketName, filename); + } catch (Exception e) { + throw new OSSException("删除文件失败", e); + } + } +} diff --git a/ruoyi-base-support/ruoyi-oss/src/main/java/com/ruoyi/oss/client/IOSSClient.java b/ruoyi-base-support/ruoyi-oss/src/main/java/com/ruoyi/oss/client/IOSSClient.java new file mode 100644 index 0000000..660f550 --- /dev/null +++ b/ruoyi-base-support/ruoyi-oss/src/main/java/com/ruoyi/oss/client/IOSSClient.java @@ -0,0 +1,55 @@ +package com.ruoyi.oss.client; + +import com.ruoyi.oss.config.OssConfig; + +import java.io.InputStream; + +/** + * All rights Reserved, Designed By kjt.gzst.gov.cn + * + * @version V1.0 + * @title: IOSSClient.java + * @description: 常量 * @date: 2017年8月11日 下午9:55:00 + * @copyright: 2017 kjt.gzst.gov.cn Inc. All rights reserved. + */ +//接口:插入、刪除、修改 +//文件HTTP直接上传 +//用一个虚类来处理公用的 +//一个配置的地方,本系统默认采用阿里云,也就是云上贵州 +public interface IOSSClient { + + /** + * 客户端初始化 + */ + void init(); + + /** + * 客户端初始化 + * + * @param propertiesName + */ + void init(String propertiesName); + + /** + * 客户端初始化 + * + * @param config + */ + void init(OssConfig config); + + /** + * 文件上传 + * + * @param inputStream + * @param path + * @return 返回可以访问的路径 + */ + String upload(InputStream inputStream, String path); + + /** + * 删除文件 + * + * @param filename 文件的路径 + */ + void delete(String filename); +} diff --git a/ruoyi-base-support/ruoyi-oss/src/main/java/com/ruoyi/oss/client/LocalClient.java b/ruoyi-base-support/ruoyi-oss/src/main/java/com/ruoyi/oss/client/LocalClient.java new file mode 100644 index 0000000..fb58762 --- /dev/null +++ b/ruoyi-base-support/ruoyi-oss/src/main/java/com/ruoyi/oss/client/LocalClient.java @@ -0,0 +1,94 @@ +package com.ruoyi.oss.client; + +import com.ruoyi.common.utils.PropertiesUtil; +import com.ruoyi.oss.config.LocalConfig; +import com.ruoyi.oss.config.OssConfig; +import com.ruoyi.oss.exception.OSSException; +import org.apache.commons.io.FileUtils; + +import java.io.File; +import java.io.IOException; +import java.io.InputStream; + +/** + * All rights Reserved, Designed By kjt.gzst.gov.cn + * + * @version V1.0 + * @title: IOSSClient.java + * @description: 这里为本地操作 * @date: 2017年8月11日 下午9:55:00 + * @copyright: 2017 kjt.gzst.gov.cn Inc. All rights reserved. + */ +public class LocalClient extends AbstractOSSClient { + + public static final String DEFAULT_CONFIG_FILE = "local.properties"; + private String domain;//本地域名配置 + private String uploadFilePath;//上传路径 + + @Override + public void init() { + init(DEFAULT_CONFIG_FILE); + } + + @Override + public void init(String propertiesName) { + PropertiesUtil p = new PropertiesUtil(propertiesName); + domain = p.getString("local.domain"); + uploadFilePath = p.getString("local.upload-file-path"); + + } + + @Override + public void init(OssConfig config) { + LocalConfig localConfig = config.getLocal(); + domain = localConfig.getDomain(); + uploadFilePath = localConfig.getUploadFilePath(); + } + + + /** + * 判断文件地址保存文件 + * + * @param path + * @return + * @throws IOException + */ + private File getAbsoluteFile(String path) throws IOException { + String basePath = uploadFilePath; + File desc = new File(basePath + File.separator + path); + if (!desc.getParentFile().exists()) { + desc.getParentFile().mkdirs(); + } + if (!desc.exists()) { + desc.createNewFile(); + } + return desc; + } + + /** + * 文件上传 + * + * @param inputStream + * @param path + * @return + */ + @Override + public String upload(InputStream inputStream, String path) { + try { + File outFile = getAbsoluteFile(path); + FileUtils.copyInputStreamToFile(inputStream, outFile); + } catch (Exception e) { + throw new OSSException("上传文件失败", e); + } + return domain + "/" + path; + } + + @Override + public void delete(String filename) { + String basePath = uploadFilePath; + File desc = new File(basePath + File.pathSeparator + filename); + if (desc.exists()) { + desc.delete(); + } + } + +} diff --git a/ruoyi-base-support/ruoyi-oss/src/main/java/com/ruoyi/oss/client/OSSClientFactory.java b/ruoyi-base-support/ruoyi-oss/src/main/java/com/ruoyi/oss/client/OSSClientFactory.java new file mode 100644 index 0000000..ef0aaaf --- /dev/null +++ b/ruoyi-base-support/ruoyi-oss/src/main/java/com/ruoyi/oss/client/OSSClientFactory.java @@ -0,0 +1,22 @@ +package com.ruoyi.oss.client; + +import com.ruoyi.oss.constant.Constants; + +/** + * 文件上传Factory + */ +public final class OSSClientFactory { + + public static IOSSClient build(String clientType) { + IOSSClient ossClient; + if (Constants.CLIENT_LOCAL.equals(clientType)) { + ossClient = new LocalClient(); + } else if (Constants.CLIENTA_ALIYUN.equals(clientType)) { + ossClient = new AliyunOSSClient(); + } else { + return null; + } + return ossClient; + } + +} diff --git a/ruoyi-base-support/ruoyi-oss/src/main/java/com/ruoyi/oss/client/QiniuOSSClient.java b/ruoyi-base-support/ruoyi-oss/src/main/java/com/ruoyi/oss/client/QiniuOSSClient.java new file mode 100644 index 0000000..69f8e8f --- /dev/null +++ b/ruoyi-base-support/ruoyi-oss/src/main/java/com/ruoyi/oss/client/QiniuOSSClient.java @@ -0,0 +1,62 @@ +package com.ruoyi.oss.client; + +import com.qiniu.http.Response; +import com.qiniu.storage.UploadManager; +import com.ruoyi.oss.config.OssConfig; +import com.ruoyi.oss.exception.OSSException; +import org.apache.commons.io.IOUtils; + +import java.io.IOException; +import java.io.InputStream; + + +public class QiniuOSSClient extends AbstractOSSClient { + + private UploadManager uploadManager; + private String token; + //访问域名 + private String domain; + + @Override + public void init() { + + } + + @Override + public void init(String propertiesName) { + + } + + + @Override + public void init(OssConfig config) { + + } + + @Override + public String upload(InputStream inputStream, String path) { + try { + byte[] data = IOUtils.toByteArray(inputStream); + return this.upload(data, path); + } catch (IOException e) { + throw new OSSException("上传文件失败", e); + } + } + + private String upload(byte[] data, String path) { + try { + Response res = uploadManager.put(data, path, token); + if (!res.isOK()) { + throw new RuntimeException("上传七牛出错:" + res.toString()); + } + } catch (Exception e) { + throw new OSSException("上传文件失败,请核对七牛配置信息"); + } + return domain + "/" + path; + } + + @Override + public void delete(String filename) { + + } +} diff --git a/ruoyi-base-support/ruoyi-oss/src/main/java/com/ruoyi/oss/config/AliyunConfig.java b/ruoyi-base-support/ruoyi-oss/src/main/java/com/ruoyi/oss/config/AliyunConfig.java new file mode 100644 index 0000000..f9ebdde --- /dev/null +++ b/ruoyi-base-support/ruoyi-oss/src/main/java/com/ruoyi/oss/config/AliyunConfig.java @@ -0,0 +1,66 @@ +package com.ruoyi.oss.config; + +import org.springframework.boot.context.properties.ConfigurationProperties; + +/** + * All rights Reserved, Designed By www.sunseagear.com + * + * @version V1.0 + * @package com.ruoyi.oss.config + * @title: + * @description: 阿里云配置 * @date: 2018/4/26 9:39 + * @copyright: 2017 www.sunseagear.com Inc. All rights reserved. + */ +@ConfigurationProperties(prefix = "oss") +public class AliyunConfig { + //阿里云api的内或外网域名 + String endpoint = ""; + //阿里云api的密钥access key id + String accessKeyId = ""; + //阿里云api的密钥access key secret + String accessKeySecret = ""; + //阿里云api的bucket名称 + String bucketName = ""; + //外部访问域名 + String domain = ""; + + public String getEndpoint() { + return endpoint; + } + + public void setEndpoint(String endpoint) { + this.endpoint = endpoint; + } + + public String getAccessKeyId() { + return accessKeyId; + } + + public void setAccessKeyId(String accessKeyId) { + this.accessKeyId = accessKeyId; + } + + public String getAccessKeySecret() { + return accessKeySecret; + } + + public void setAccessKeySecret(String accessKeySecret) { + this.accessKeySecret = accessKeySecret; + } + + public String getBucketName() { + return bucketName; + } + + public void setBucketName(String bucketName) { + this.bucketName = bucketName; + } + + public String getDomain() { + return domain; + } + + public void setDomain(String domain) { + this.domain = domain; + } +} diff --git a/ruoyi-base-support/ruoyi-oss/src/main/java/com/ruoyi/oss/config/LocalConfig.java b/ruoyi-base-support/ruoyi-oss/src/main/java/com/ruoyi/oss/config/LocalConfig.java new file mode 100644 index 0000000..cee377d --- /dev/null +++ b/ruoyi-base-support/ruoyi-oss/src/main/java/com/ruoyi/oss/config/LocalConfig.java @@ -0,0 +1,36 @@ +package com.ruoyi.oss.config; + +import org.springframework.boot.context.properties.ConfigurationProperties; + +/** + * All rights Reserved, Designed By www.sunseagear.com + * + * @version V1.0 + * @package com.ruoyi.oss.config + * @title: + * @description: 阿里云配置 * @date: 2018/4/26 9:39 + * @copyright: 2017 www.sunseagear.com Inc. All rights reserved. + */ +@ConfigurationProperties(prefix = "oss") +public class LocalConfig { + //外部访问域名 + String domain = ""; + //上传路径 + String uploadFilePath = ""; + + public String getDomain() { + return domain; + } + + public void setDomain(String domain) { + this.domain = domain; + } + + public String getUploadFilePath() { + return uploadFilePath; + } + + public void setUploadFilePath(String uploadFilePath) { + this.uploadFilePath = uploadFilePath; + } +} diff --git a/ruoyi-base-support/ruoyi-oss/src/main/java/com/ruoyi/oss/config/OssConfig.java b/ruoyi-base-support/ruoyi-oss/src/main/java/com/ruoyi/oss/config/OssConfig.java new file mode 100644 index 0000000..f59e312 --- /dev/null +++ b/ruoyi-base-support/ruoyi-oss/src/main/java/com/ruoyi/oss/config/OssConfig.java @@ -0,0 +1,88 @@ +package com.ruoyi.oss.config; + +import org.springframework.boot.context.properties.ConfigurationProperties; + +/** + * All rights Reserved, Designed By www.sunseagear.com + * + * @version V1.0 + * @package com.ruoyi.oss.config + * @title: + * @description: OSS配置 * @date: 2018/4/26 9:43 + * @copyright: 2017 www.sunseagear.com Inc. All rights reserved. + */ +@ConfigurationProperties(prefix = "oss") +public class OssConfig { + + //使用的上传存储空间,local本地,aliyun:阿里云 + String clientType = ""; + //默认上传目录 + String baseDir = ""; + //允许的文件扩展名 + String allowedExtension = ""; + //最大文件大小 50M + long maxSize = 52428800; + //是否需要按照日期存放文件 + boolean needDatePath = false; + ; + + private AliyunConfig aliyun; + + private LocalConfig local; + + public AliyunConfig getAliyun() { + return aliyun; + } + + public void setAliyun(AliyunConfig aliyun) { + this.aliyun = aliyun; + } + + public LocalConfig getLocal() { + return local; + } + + public void setLocal(LocalConfig local) { + this.local = local; + } + + public String getClientType() { + return clientType; + } + + public void setClientType(String clientType) { + this.clientType = clientType; + } + + public String getBaseDir() { + return baseDir; + } + + public void setBaseDir(String baseDir) { + this.baseDir = baseDir; + } + + public String getAllowedExtension() { + return allowedExtension; + } + + public void setAllowedExtension(String allowedExtension) { + this.allowedExtension = allowedExtension; + } + + public long getMaxSize() { + return maxSize; + } + + public void setMaxSize(long maxSize) { + this.maxSize = maxSize; + } + + public boolean isNeedDatePath() { + return needDatePath; + } + + public void setNeedDatePath(boolean needDatePath) { + this.needDatePath = needDatePath; + } +} diff --git a/ruoyi-base-support/ruoyi-oss/src/main/java/com/ruoyi/oss/constant/Constants.java b/ruoyi-base-support/ruoyi-oss/src/main/java/com/ruoyi/oss/constant/Constants.java new file mode 100644 index 0000000..7dbade3 --- /dev/null +++ b/ruoyi-base-support/ruoyi-oss/src/main/java/com/ruoyi/oss/constant/Constants.java @@ -0,0 +1,6 @@ +package com.ruoyi.oss.constant; + +public interface Constants { + String CLIENT_LOCAL = "local"; //本地 + String CLIENTA_ALIYUN = "aliyun"; //本地 +} diff --git a/ruoyi-base-support/ruoyi-oss/src/main/java/com/ruoyi/oss/exception/FileNameLengthLimitExceededException.java b/ruoyi-base-support/ruoyi-oss/src/main/java/com/ruoyi/oss/exception/FileNameLengthLimitExceededException.java new file mode 100644 index 0000000..45653be --- /dev/null +++ b/ruoyi-base-support/ruoyi-oss/src/main/java/com/ruoyi/oss/exception/FileNameLengthLimitExceededException.java @@ -0,0 +1,38 @@ +package com.ruoyi.oss.exception; + +import org.apache.commons.fileupload.FileUploadException; + +/** + * 文件名超长 + *

User: Zhang Kaitao + *

Date: 13-3-8 下午8:44 + *

Version: 1.0 + */ +@SuppressWarnings("serial") +public class FileNameLengthLimitExceededException extends FileUploadException { + + private int length; + private int maxLength; + private String filename; + + public FileNameLengthLimitExceededException(String filename, int length, int maxLength) { + super("file name : [" + filename + "], length : [" + length + "], max length : [" + maxLength + "]"); + this.length = length; + this.maxLength = maxLength; + this.filename = filename; + } + + public String getFilename() { + return filename; + } + + public int getLength() { + return length; + } + + + public int getMaxLength() { + return maxLength; + } + +} diff --git a/ruoyi-base-support/ruoyi-oss/src/main/java/com/ruoyi/oss/exception/InvalidExtensionException.java b/ruoyi-base-support/ruoyi-oss/src/main/java/com/ruoyi/oss/exception/InvalidExtensionException.java new file mode 100644 index 0000000..b8d3f46 --- /dev/null +++ b/ruoyi-base-support/ruoyi-oss/src/main/java/com/ruoyi/oss/exception/InvalidExtensionException.java @@ -0,0 +1,55 @@ +package com.ruoyi.oss.exception; + +import org.apache.commons.fileupload.FileUploadException; + +import java.util.Arrays; + +/** + * + */ +@SuppressWarnings("serial") +public class InvalidExtensionException extends FileUploadException { + + private String[] allowedExtension; + private String extension; + private String filename; + + public InvalidExtensionException(String[] allowedExtension, String extension, String filename) { + super("filename : [" + filename + "], extension : [" + extension + "], allowed extension : [" + + Arrays.toString(allowedExtension) + "]"); + this.allowedExtension = allowedExtension; + this.extension = extension; + this.filename = filename; + } + + public String[] getAllowedExtension() { + return allowedExtension; + } + + public String getExtension() { + return extension; + } + + public String getFilename() { + return filename; + } + + public static class InvalidImageExtensionException extends InvalidExtensionException { + public InvalidImageExtensionException(String[] allowedExtension, String extension, String filename) { + super(allowedExtension, extension, filename); + } + } + + public static class InvalidFlashExtensionException extends InvalidExtensionException { + public InvalidFlashExtensionException(String[] allowedExtension, String extension, String filename) { + super(allowedExtension, extension, filename); + } + } + + public static class InvalidMediaExtensionException extends InvalidExtensionException { + public InvalidMediaExtensionException(String[] allowedExtension, String extension, String filename) { + super(allowedExtension, extension, filename); + } + } + +} diff --git a/ruoyi-base-support/ruoyi-oss/src/main/java/com/ruoyi/oss/exception/OSSException.java b/ruoyi-base-support/ruoyi-oss/src/main/java/com/ruoyi/oss/exception/OSSException.java new file mode 100644 index 0000000..a8fb091 --- /dev/null +++ b/ruoyi-base-support/ruoyi-oss/src/main/java/com/ruoyi/oss/exception/OSSException.java @@ -0,0 +1,33 @@ +package com.ruoyi.oss.exception; + +/** + * OSS异常 + * Created by 王存见 on 2017/8/11. + */ +public class OSSException extends RuntimeException { + + public OSSException() { + super(); + } + + + public OSSException(String message) { + super(message); + } + + public OSSException(String message, Throwable cause) { + super(message, cause); + } + + + public OSSException(Throwable cause) { + super(cause); + } + + + protected OSSException(String message, Throwable cause, + boolean enableSuppression, + boolean writableStackTrace) { + super(message, cause, enableSuppression, writableStackTrace); + } +} diff --git a/ruoyi-base-support/ruoyi-oss/src/main/java/com/ruoyi/oss/utils/AliyunOSSClientUtil.java b/ruoyi-base-support/ruoyi-oss/src/main/java/com/ruoyi/oss/utils/AliyunOSSClientUtil.java new file mode 100644 index 0000000..6f291d8 --- /dev/null +++ b/ruoyi-base-support/ruoyi-oss/src/main/java/com/ruoyi/oss/utils/AliyunOSSClientUtil.java @@ -0,0 +1,162 @@ +package com.ruoyi.oss.utils; + +import com.aliyun.oss.OSSClient; +import com.aliyun.oss.model.Bucket; +import com.aliyun.oss.model.OSSObject; +import com.aliyun.oss.model.ObjectMetadata; +import com.aliyun.oss.model.PutObjectResult; +import com.ruoyi.common.utils.PropertiesUtil; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.File; +import java.io.FileInputStream; +import java.io.InputStream; + +public class AliyunOSSClientUtil { + public static final String DEFAULT_CONFIG_FILE = "aliyun.oss.properties"; + //log + private static final Logger LOG = LoggerFactory.getLogger(AliyunOSSClientUtil.class); + + //阿里云API的内或外网域名 + private static String ENDPOINT; + //阿里云API的密钥Access Key ID + private static String ACCESS_KEY_ID; + //阿里云API的密钥Access Key Secret + private static String ACCESS_KEY_SECRET; + + //init static datas + static { + PropertiesUtil p = new PropertiesUtil(DEFAULT_CONFIG_FILE); + ENDPOINT = p.getString("aliyun.oss.endpoint"); + ACCESS_KEY_ID = p.getString("aliyun.oss.access_key_id"); + ACCESS_KEY_SECRET = p.getString("aliyun.oss.access_key_secret"); + } + + /** + * 获取阿里云OSS客户端对象 + */ + public static final OSSClient getOSSClient() { + return new OSSClient(ENDPOINT, ACCESS_KEY_ID, ACCESS_KEY_SECRET); + } + + /** + * 新建Bucket --Bucket权限:私有 + * + * @param bucketName bucket名称 + * @return true 新建Bucket成功 + */ + public static final boolean createBucket(OSSClient client, String bucketName) { + Bucket bucket = client.createBucket(bucketName); + return bucketName.equals(bucket.getName()); + } + + /** + * 删除Bucket + * + * @param bucketName bucket名称 + */ + public static final void deleteBucket(OSSClient client, String bucketName) { + client.deleteBucket(bucketName); + LOG.info("删除" + bucketName + "Bucket成功"); + } + + /** + * 向阿里云的OSS存储中存储文件 --file也可以用InputStream替代 + * + * @param client OSS客户端 + * @param file 上传文件 + * @param bucketName bucket名称 + * @param diskName 上传文件的目录 --bucket下文件的路径 + * @return String 唯一MD5数字签名 + */ + public static final String uploadObject2OSS(OSSClient client, File file, String bucketName, String diskName) { + String resultStr = null; + try { + InputStream is = new FileInputStream(file); + String fileName = file.getName(); + Long fileSize = file.length(); + //创建上传Object的Metadata + ObjectMetadata metadata = new ObjectMetadata(); + metadata.setContentLength(is.available()); + metadata.setCacheControl("no-cache"); + metadata.setHeader("Pragma", "no-cache"); + metadata.setContentEncoding("utf-8"); + metadata.setContentType(getContentType(fileName)); + metadata.setContentDisposition("filename/filesize=" + fileName + "/" + fileSize + "Byte."); + //上传文件 + PutObjectResult putResult = client.putObject(bucketName, diskName + fileName, is, metadata); + //解析结果 + resultStr = putResult.getETag(); + } catch (Exception e) { + LOG.error("上传阿里云OSS服务器异常." + e.getMessage(), e); + } + return resultStr; + } + + /** + * 根据key获取OSS服务器上的文件输入流 + * + * @param client OSS客户端 + * @param bucketName bucket名称 + * @param diskName 文件路径 + * @param key Bucket下的文件的路径名+文件名 + */ + public static final InputStream getOSS2InputStream(OSSClient client, String bucketName, String diskName, String key) { + OSSObject ossObj = client.getObject(bucketName, diskName + key); + return ossObj.getObjectContent(); + } + + /** + * 根据key删除OSS服务器上的文件 + * + * @param client OSS客户端 + * @param bucketName bucket名称 + * @param diskName 文件路径 + * @param key Bucket下的文件的路径名+文件名 + */ + public static void deleteFile(OSSClient client, String bucketName, String diskName, String key) { + client.deleteObject(bucketName, diskName + key); + LOG.info("删除" + bucketName + "下的文件" + diskName + key + "成功"); + } + + /** + * 通过文件名判断并获取OSS服务文件上传时文件的contentType + * + * @param fileName 文件名 + * @return 文件的contentType + */ + public static final String getContentType(String fileName) { + String fileExtension = fileName.substring(fileName.lastIndexOf(".")); + if ("bmp".equalsIgnoreCase(fileExtension)) { + return "image/bmp"; + } + if ("gif".equalsIgnoreCase(fileExtension)) { + return "image/gif"; + } + if ("jpeg".equalsIgnoreCase(fileExtension) || "jpg".equalsIgnoreCase(fileExtension) || "png".equalsIgnoreCase(fileExtension)) { + return "image/jpeg"; + } + if ("html".equalsIgnoreCase(fileExtension)) { + return "text/html"; + } + if ("txt".equalsIgnoreCase(fileExtension)) { + return "text/plain"; + } + if ("vsd".equalsIgnoreCase(fileExtension)) { + return "application/vnd.visio"; + } + if ("ppt".equalsIgnoreCase(fileExtension) || "pptx".equalsIgnoreCase(fileExtension)) { + return "application/vnd.ms-powerpoint"; + } + if ("doc".equalsIgnoreCase(fileExtension) || "docx".equalsIgnoreCase(fileExtension)) { + return "application/msword"; + } + if ("xml".equalsIgnoreCase(fileExtension)) { + return "text/xml"; + } + return "text/html"; + } + + +} diff --git a/ruoyi-base-support/ruoyi-oss/src/main/java/com/ruoyi/oss/utils/AttachmentHelper.java b/ruoyi-base-support/ruoyi-oss/src/main/java/com/ruoyi/oss/utils/AttachmentHelper.java new file mode 100644 index 0000000..3cbfcde --- /dev/null +++ b/ruoyi-base-support/ruoyi-oss/src/main/java/com/ruoyi/oss/utils/AttachmentHelper.java @@ -0,0 +1,61 @@ +package com.ruoyi.oss.utils; + +import com.ruoyi.oss.OSSUploadHelper; +import com.ruoyi.oss.config.OssConfig; +import com.ruoyi.oss.exception.FileNameLengthLimitExceededException; +import com.ruoyi.oss.exception.InvalidExtensionException; +import org.apache.commons.fileupload.FileUploadBase.FileSizeLimitExceededException; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.stereotype.Component; +import org.springframework.web.multipart.MultipartFile; + +import javax.annotation.PostConstruct; +import javax.servlet.http.HttpServletRequest; +import java.io.IOException; + +/** + * All rights Reserved, Designed By www.sunseagear.com + * + * @version V1.0 + * @package com.sunseagear.oss.controller + * @title: 附件上传助手 + * @description: 附件上传助手 * @date: 2018-04-25 14:25:55 + * @copyright: 2018 www.sunseagear.com Inc. All rights reserved. + */ +@Component("attachmentHelper") +@EnableConfigurationProperties({OssConfig.class}) +public class AttachmentHelper { + + @Autowired + private OssConfig ossConfig; + + private OSSUploadHelper uploadHelper; + + @PostConstruct + public void initHelper() { + uploadHelper = new OSSUploadHelper(); + uploadHelper.init(ossConfig); + } + + + public String upload(HttpServletRequest request, MultipartFile file) throws FileSizeLimitExceededException, + IOException, FileNameLengthLimitExceededException, InvalidExtensionException { + String basePath = request.getParameter("directory"); + return upload(request, file, basePath); + } + + public String upload(HttpServletRequest request, MultipartFile file, String directory) throws FileSizeLimitExceededException, + IOException, FileNameLengthLimitExceededException, InvalidExtensionException { + String url = uploadHelper.upload(request, file, directory); + return url; + } + + public String remote(HttpServletRequest request, String remoteUrl) throws FileSizeLimitExceededException, + IOException, FileNameLengthLimitExceededException, InvalidExtensionException { + String basePath = request.getParameter("base_path"); + String url = uploadHelper.remote(request, remoteUrl, basePath); + return url; + } + +} diff --git a/ruoyi-base-support/ruoyi-quartz/pom.xml b/ruoyi-base-support/ruoyi-quartz/pom.xml new file mode 100644 index 0000000..29e6a2a --- /dev/null +++ b/ruoyi-base-support/ruoyi-quartz/pom.xml @@ -0,0 +1,40 @@ + + + + ruoyi-base-support + com.ruoyi + 3.7.0 + + 4.0.0 + + ruoyi-quartz + + + quartz定时任务 + + + + + + + org.quartz-scheduler + quartz + + + com.mchange + c3p0 + + + + + + + com.ruoyi + ruoyi-common + + + + + \ No newline at end of file diff --git a/ruoyi-base-support/ruoyi-quartz/src/main/java/com/ruoyi/quartz/config/ScheduleConfig.java b/ruoyi-base-support/ruoyi-quartz/src/main/java/com/ruoyi/quartz/config/ScheduleConfig.java new file mode 100644 index 0000000..ccd22c3 --- /dev/null +++ b/ruoyi-base-support/ruoyi-quartz/src/main/java/com/ruoyi/quartz/config/ScheduleConfig.java @@ -0,0 +1,58 @@ +package com.ruoyi.quartz.config; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.scheduling.quartz.SchedulerFactoryBean; + +import javax.sql.DataSource; +import java.util.Properties; + +/** + * 定时任务配置 + * + * @author ruoyi + */ +@Configuration +public class ScheduleConfig +{ + @Bean + public SchedulerFactoryBean schedulerFactoryBean(DataSource dataSource) + { + SchedulerFactoryBean factory = new SchedulerFactoryBean(); + factory.setDataSource(dataSource); + + // quartz参数 + Properties prop = new Properties(); + prop.put("org.quartz.scheduler.instanceName", "RuoyiScheduler"); + prop.put("org.quartz.scheduler.instanceId", "AUTO"); + // 线程池配置 + prop.put("org.quartz.threadPool.class", "org.quartz.simpl.SimpleThreadPool"); + prop.put("org.quartz.threadPool.threadCount", "20"); + prop.put("org.quartz.threadPool.threadPriority", "5"); + // JobStore配置 + prop.put("org.quartz.jobStore.class", "org.quartz.impl.jdbcjobstore.JobStoreTX"); + // 集群配置 + prop.put("org.quartz.jobStore.isClustered", "true"); + prop.put("org.quartz.jobStore.clusterCheckinInterval", "15000"); + prop.put("org.quartz.jobStore.maxMisfiresToHandleAtATime", "1"); + prop.put("org.quartz.jobStore.txIsolationLevelSerializable", "true"); + + // sqlserver 启用 + // prop.put("org.quartz.jobStore.selectWithLockSQL", "SELECT * FROM {0}LOCKS UPDLOCK WHERE LOCK_NAME = ?"); + prop.put("org.quartz.jobStore.misfireThreshold", "12000"); + prop.put("org.quartz.jobStore.tablePrefix", "QRTZ_"); + factory.setQuartzProperties(prop); + + factory.setSchedulerName("RuoyiScheduler"); + // 延时启动 + factory.setStartupDelay(1); + factory.setApplicationContextSchedulerContextKey("applicationContextKey"); + // 可选,QuartzScheduler + // 启动时更新己存在的Job,这样就不用每次修改targetObject后删除qrtz_job_details表对应记录了 + factory.setOverwriteExistingJobs(true); + // 设置自动启动,默认为true + factory.setAutoStartup(true); + + return factory; + } +} diff --git a/ruoyi-base-support/ruoyi-quartz/src/main/java/com/ruoyi/quartz/controller/SysJobController.java b/ruoyi-base-support/ruoyi-quartz/src/main/java/com/ruoyi/quartz/controller/SysJobController.java new file mode 100644 index 0000000..9312650 --- /dev/null +++ b/ruoyi-base-support/ruoyi-quartz/src/main/java/com/ruoyi/quartz/controller/SysJobController.java @@ -0,0 +1,161 @@ +package com.ruoyi.quartz.controller; + +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.constant.Constants; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.page.TableDataInfo; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.common.exception.job.TaskException; +import com.ruoyi.common.utils.StringUtils; +import com.ruoyi.common.utils.poi.ExcelUtil; +import com.ruoyi.quartz.domain.SysJob; +import com.ruoyi.quartz.service.ISysJobService; +import com.ruoyi.quartz.util.CronUtils; +import org.quartz.SchedulerException; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +/** + * 调度任务信息操作处理 + * + * @author ruoyi + */ +@RestController +@RequestMapping("/monitor/job") +public class SysJobController extends BaseController +{ + @Autowired + private ISysJobService jobService; + + /** + * 查询定时任务列表 + */ + @PreAuthorize("@ss.hasPermi('monitor:job:list')") + @GetMapping("/list") + public TableDataInfo list(SysJob sysJob) + { + startPage(); + List list = jobService.selectJobList(sysJob); + return getDataTable(list); + } + + /** + * 导出定时任务列表 + */ + @PreAuthorize("@ss.hasPermi('monitor:job:export')") + @Log(title = "定时任务", businessType = BusinessType.EXPORT) + @GetMapping("/export") + public AjaxResult export(SysJob sysJob) + { + List list = jobService.selectJobList(sysJob); + ExcelUtil util = new ExcelUtil(SysJob.class); + return util.exportExcel(list, "定时任务"); + } + + /** + * 获取定时任务详细信息 + */ + @PreAuthorize("@ss.hasPermi('monitor:job:query')") + @GetMapping(value = "/{jobId}") + public AjaxResult getInfo(@PathVariable("jobId") Long jobId) + { + return AjaxResult.success(jobService.selectJobById(jobId)); + } + + /** + * 新增定时任务 + */ + @PreAuthorize("@ss.hasPermi('monitor:job:add')") + @Log(title = "定时任务", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody SysJob job) throws SchedulerException, TaskException + { + if (!CronUtils.isValid(job.getCronExpression())) + { + return error("新增任务'" + job.getJobName() + "'失败,Cron表达式不正确"); + } + else if (StringUtils.containsIgnoreCase(job.getInvokeTarget(), Constants.LOOKUP_RMI)) + { + return error("新增任务'" + job.getJobName() + "'失败,目标字符串不允许'rmi://'调用"); + } + else if (StringUtils.containsIgnoreCase(job.getInvokeTarget(), Constants.LOOKUP_LDAP)) + { + return error("新增任务'" + job.getJobName() + "'失败,目标字符串不允许'ldap://'调用"); + } + else if (StringUtils.containsAnyIgnoreCase(job.getInvokeTarget(), new String[] { Constants.HTTP, Constants.HTTPS })) + { + return error("新增任务'" + job.getJobName() + "'失败,目标字符串不允许'http(s)//'调用"); + } + job.setCreateBy(getUsername()); + return toAjax(jobService.insertJob(job)); + } + + /** + * 修改定时任务 + */ + @PreAuthorize("@ss.hasPermi('monitor:job:edit')") + @Log(title = "定时任务", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody SysJob job) throws SchedulerException, TaskException + { + if (!CronUtils.isValid(job.getCronExpression())) + { + return error("修改任务'" + job.getJobName() + "'失败,Cron表达式不正确"); + } + else if (StringUtils.containsIgnoreCase(job.getInvokeTarget(), Constants.LOOKUP_RMI)) + { + return error("修改任务'" + job.getJobName() + "'失败,目标字符串不允许'rmi://'调用"); + } + else if (StringUtils.containsIgnoreCase(job.getInvokeTarget(), Constants.LOOKUP_LDAP)) + { + return error("修改任务'" + job.getJobName() + "'失败,目标字符串不允许'ldap://'调用"); + } + else if (StringUtils.containsAnyIgnoreCase(job.getInvokeTarget(), new String[] { Constants.HTTP, Constants.HTTPS })) + { + return error("修改任务'" + job.getJobName() + "'失败,目标字符串不允许'http(s)//'调用"); + } + job.setUpdateBy(getUsername()); + return toAjax(jobService.updateJob(job)); + } + + /** + * 定时任务状态修改 + */ + @PreAuthorize("@ss.hasPermi('monitor:job:changeStatus')") + @Log(title = "定时任务", businessType = BusinessType.UPDATE) + @PutMapping("/changeStatus") + public AjaxResult changeStatus(@RequestBody SysJob job) throws SchedulerException + { + SysJob newJob = jobService.selectJobById(job.getJobId()); + newJob.setStatus(job.getStatus()); + return toAjax(jobService.changeStatus(newJob)); + } + + /** + * 定时任务立即执行一次 + */ + @PreAuthorize("@ss.hasPermi('monitor:job:changeStatus')") + @Log(title = "定时任务", businessType = BusinessType.UPDATE) + @PutMapping("/run") + public AjaxResult run(@RequestBody SysJob job) throws SchedulerException + { + jobService.run(job); + return AjaxResult.success(); + } + + /** + * 删除定时任务 + */ + @PreAuthorize("@ss.hasPermi('monitor:job:remove')") + @Log(title = "定时任务", businessType = BusinessType.DELETE) + @DeleteMapping("/{jobIds}") + public AjaxResult remove(@PathVariable Long[] jobIds) throws SchedulerException, TaskException + { + jobService.deleteJobByIds(jobIds); + return AjaxResult.success(); + } +} diff --git a/ruoyi-base-support/ruoyi-quartz/src/main/java/com/ruoyi/quartz/controller/SysJobLogController.java b/ruoyi-base-support/ruoyi-quartz/src/main/java/com/ruoyi/quartz/controller/SysJobLogController.java new file mode 100644 index 0000000..d18ea3e --- /dev/null +++ b/ruoyi-base-support/ruoyi-quartz/src/main/java/com/ruoyi/quartz/controller/SysJobLogController.java @@ -0,0 +1,87 @@ +package com.ruoyi.quartz.controller; + +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.page.TableDataInfo; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.common.utils.poi.ExcelUtil; +import com.ruoyi.quartz.domain.SysJobLog; +import com.ruoyi.quartz.service.ISysJobLogService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +/** + * 调度日志操作处理 + * + * @author ruoyi + */ +@RestController +@RequestMapping("/monitor/jobLog") +public class SysJobLogController extends BaseController +{ + @Autowired + private ISysJobLogService jobLogService; + + /** + * 查询定时任务调度日志列表 + */ + @PreAuthorize("@ss.hasPermi('monitor:job:list')") + @GetMapping("/list") + public TableDataInfo list(SysJobLog sysJobLog) + { + startPage(); + List list = jobLogService.selectJobLogList(sysJobLog); + return getDataTable(list); + } + + /** + * 导出定时任务调度日志列表 + */ + @PreAuthorize("@ss.hasPermi('monitor:job:export')") + @Log(title = "任务调度日志", businessType = BusinessType.EXPORT) + @GetMapping("/export") + public AjaxResult export(SysJobLog sysJobLog) + { + List list = jobLogService.selectJobLogList(sysJobLog); + ExcelUtil util = new ExcelUtil(SysJobLog.class); + return util.exportExcel(list, "调度日志"); + } + + /** + * 根据调度编号获取详细信息 + */ + @PreAuthorize("@ss.hasPermi('monitor:job:query')") + @GetMapping(value = "/{configId}") + public AjaxResult getInfo(@PathVariable Long jobLogId) + { + return AjaxResult.success(jobLogService.selectJobLogById(jobLogId)); + } + + + /** + * 删除定时任务调度日志 + */ + @PreAuthorize("@ss.hasPermi('monitor:job:remove')") + @Log(title = "定时任务调度日志", businessType = BusinessType.DELETE) + @DeleteMapping("/{jobLogIds}") + public AjaxResult remove(@PathVariable Long[] jobLogIds) + { + return toAjax(jobLogService.deleteJobLogByIds(jobLogIds)); + } + + /** + * 清空定时任务调度日志 + */ + @PreAuthorize("@ss.hasPermi('monitor:job:remove')") + @Log(title = "调度日志", businessType = BusinessType.CLEAN) + @DeleteMapping("/clean") + public AjaxResult clean() + { + jobLogService.cleanJobLog(); + return AjaxResult.success(); + } +} diff --git a/ruoyi-base-support/ruoyi-quartz/src/main/java/com/ruoyi/quartz/domain/SysJob.java b/ruoyi-base-support/ruoyi-quartz/src/main/java/com/ruoyi/quartz/domain/SysJob.java new file mode 100644 index 0000000..bab4824 --- /dev/null +++ b/ruoyi-base-support/ruoyi-quartz/src/main/java/com/ruoyi/quartz/domain/SysJob.java @@ -0,0 +1,172 @@ +package com.ruoyi.quartz.domain; + +import com.fasterxml.jackson.annotation.JsonFormat; +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.annotation.Excel.ColumnType; +import com.ruoyi.common.constant.ScheduleConstants; +import com.ruoyi.common.core.domain.BaseEntity; +import com.ruoyi.common.utils.StringUtils; +import com.ruoyi.quartz.util.CronUtils; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.Size; +import java.util.Date; + +/** + * 定时任务调度表 sys_job + * + * @author ruoyi + */ +public class SysJob extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** 任务ID */ + @Excel(name = "任务序号", cellType = ColumnType.NUMERIC) + private Long jobId; + + /** 任务名称 */ + @Excel(name = "任务名称") + private String jobName; + + /** 任务组名 */ + @Excel(name = "任务组名") + private String jobGroup; + + /** 调用目标字符串 */ + @Excel(name = "调用目标字符串") + private String invokeTarget; + + /** cron执行表达式 */ + @Excel(name = "执行表达式 ") + private String cronExpression; + + /** cron计划策略 */ + @Excel(name = "计划策略 ", readConverterExp = "0=默认,1=立即触发执行,2=触发一次执行,3=不触发立即执行") + private String misfirePolicy = ScheduleConstants.MISFIRE_DEFAULT; + + /** 是否并发执行(0允许 1禁止) */ + @Excel(name = "并发执行", readConverterExp = "0=允许,1=禁止") + private String concurrent; + + /** 任务状态(0正常 1暂停) */ + @Excel(name = "任务状态", readConverterExp = "0=正常,1=暂停") + private String status; + + public Long getJobId() + { + return jobId; + } + + public void setJobId(Long jobId) + { + this.jobId = jobId; + } + + @NotBlank(message = "任务名称不能为空") + @Size(min = 0, max = 64, message = "任务名称不能超过64个字符") + public String getJobName() + { + return jobName; + } + + public void setJobName(String jobName) + { + this.jobName = jobName; + } + + public String getJobGroup() + { + return jobGroup; + } + + public void setJobGroup(String jobGroup) + { + this.jobGroup = jobGroup; + } + + @NotBlank(message = "调用目标字符串不能为空") + @Size(min = 0, max = 500, message = "调用目标字符串长度不能超过500个字符") + public String getInvokeTarget() + { + return invokeTarget; + } + + public void setInvokeTarget(String invokeTarget) + { + this.invokeTarget = invokeTarget; + } + + @NotBlank(message = "Cron执行表达式不能为空") + @Size(min = 0, max = 255, message = "Cron执行表达式不能超过255个字符") + public String getCronExpression() + { + return cronExpression; + } + + public void setCronExpression(String cronExpression) + { + this.cronExpression = cronExpression; + } + + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + public Date getNextValidTime() + { + if (StringUtils.isNotEmpty(cronExpression)) + { + return CronUtils.getNextExecution(cronExpression); + } + return null; + } + + public String getMisfirePolicy() + { + return misfirePolicy; + } + + public void setMisfirePolicy(String misfirePolicy) + { + this.misfirePolicy = misfirePolicy; + } + + public String getConcurrent() + { + return concurrent; + } + + public void setConcurrent(String concurrent) + { + this.concurrent = concurrent; + } + + public String getStatus() + { + return status; + } + + public void setStatus(String status) + { + this.status = status; + } + + @Override + public String toString() { + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) + .append("jobId", getJobId()) + .append("jobName", getJobName()) + .append("jobGroup", getJobGroup()) + .append("cronExpression", getCronExpression()) + .append("nextValidTime", getNextValidTime()) + .append("misfirePolicy", getMisfirePolicy()) + .append("concurrent", getConcurrent()) + .append("status", getStatus()) + .append("createBy", getCreateBy()) + .append("createTime", getCreateTime()) + .append("updateBy", getUpdateBy()) + .append("updateTime", getUpdateTime()) + .append("remark", getRemark()) + .toString(); + } +} diff --git a/ruoyi-base-support/ruoyi-quartz/src/main/java/com/ruoyi/quartz/domain/SysJobLog.java b/ruoyi-base-support/ruoyi-quartz/src/main/java/com/ruoyi/quartz/domain/SysJobLog.java new file mode 100644 index 0000000..19f672b --- /dev/null +++ b/ruoyi-base-support/ruoyi-quartz/src/main/java/com/ruoyi/quartz/domain/SysJobLog.java @@ -0,0 +1,156 @@ +package com.ruoyi.quartz.domain; + +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; + +import java.util.Date; + +/** + * 定时任务调度日志表 sys_job_log + * + * @author ruoyi + */ +public class SysJobLog extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** ID */ + @Excel(name = "日志序号") + private Long jobLogId; + + /** 任务名称 */ + @Excel(name = "任务名称") + private String jobName; + + /** 任务组名 */ + @Excel(name = "任务组名") + private String jobGroup; + + /** 调用目标字符串 */ + @Excel(name = "调用目标字符串") + private String invokeTarget; + + /** 日志信息 */ + @Excel(name = "日志信息") + private String jobMessage; + + /** 执行状态(0正常 1失败) */ + @Excel(name = "执行状态", readConverterExp = "0=正常,1=失败") + private String status; + + /** 异常信息 */ + @Excel(name = "异常信息") + private String exceptionInfo; + + /** 开始时间 */ + private Date startTime; + + /** 停止时间 */ + private Date stopTime; + + public Long getJobLogId() + { + return jobLogId; + } + + public void setJobLogId(Long jobLogId) + { + this.jobLogId = jobLogId; + } + + public String getJobName() + { + return jobName; + } + + public void setJobName(String jobName) + { + this.jobName = jobName; + } + + public String getJobGroup() + { + return jobGroup; + } + + public void setJobGroup(String jobGroup) + { + this.jobGroup = jobGroup; + } + + public String getInvokeTarget() + { + return invokeTarget; + } + + public void setInvokeTarget(String invokeTarget) + { + this.invokeTarget = invokeTarget; + } + + public String getJobMessage() + { + return jobMessage; + } + + public void setJobMessage(String jobMessage) + { + this.jobMessage = jobMessage; + } + + public String getStatus() + { + return status; + } + + public void setStatus(String status) + { + this.status = status; + } + + public String getExceptionInfo() + { + return exceptionInfo; + } + + public void setExceptionInfo(String exceptionInfo) + { + this.exceptionInfo = exceptionInfo; + } + + public Date getStartTime() + { + return startTime; + } + + public void setStartTime(Date startTime) + { + this.startTime = startTime; + } + + public Date getStopTime() + { + return stopTime; + } + + public void setStopTime(Date stopTime) + { + this.stopTime = stopTime; + } + + @Override + public String toString() { + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) + .append("jobLogId", getJobLogId()) + .append("jobName", getJobName()) + .append("jobGroup", getJobGroup()) + .append("jobMessage", getJobMessage()) + .append("status", getStatus()) + .append("exceptionInfo", getExceptionInfo()) + .append("startTime", getStartTime()) + .append("stopTime", getStopTime()) + .toString(); + } +} diff --git a/ruoyi-base-support/ruoyi-quartz/src/main/java/com/ruoyi/quartz/mapper/SysJobLogMapper.java b/ruoyi-base-support/ruoyi-quartz/src/main/java/com/ruoyi/quartz/mapper/SysJobLogMapper.java new file mode 100644 index 0000000..ec6e431 --- /dev/null +++ b/ruoyi-base-support/ruoyi-quartz/src/main/java/com/ruoyi/quartz/mapper/SysJobLogMapper.java @@ -0,0 +1,65 @@ +package com.ruoyi.quartz.mapper; + +import com.ruoyi.quartz.domain.SysJobLog; + +import java.util.List; + +/** + * 调度任务日志信息 数据层 + * + * @author ruoyi + */ +public interface SysJobLogMapper +{ + /** + * 获取quartz调度器日志的计划任务 + * + * @param jobLog 调度日志信息 + * @return 调度任务日志集合 + */ + public List selectJobLogList(SysJobLog jobLog); + + /** + * 查询所有调度任务日志 + * + * @return 调度任务日志列表 + */ + public List selectJobLogAll(); + + /** + * 通过调度任务日志ID查询调度信息 + * + * @param jobLogId 调度任务日志ID + * @return 调度任务日志对象信息 + */ + public SysJobLog selectJobLogById(Long jobLogId); + + /** + * 新增任务日志 + * + * @param jobLog 调度日志信息 + * @return 结果 + */ + public int insertJobLog(SysJobLog jobLog); + + /** + * 批量删除调度日志信息 + * + * @param logIds 需要删除的数据ID + * @return 结果 + */ + public int deleteJobLogByIds(Long[] logIds); + + /** + * 删除任务日志 + * + * @param jobId 调度日志ID + * @return 结果 + */ + public int deleteJobLogById(Long jobId); + + /** + * 清空任务日志 + */ + public void cleanJobLog(); +} diff --git a/ruoyi-base-support/ruoyi-quartz/src/main/java/com/ruoyi/quartz/mapper/SysJobMapper.java b/ruoyi-base-support/ruoyi-quartz/src/main/java/com/ruoyi/quartz/mapper/SysJobMapper.java new file mode 100644 index 0000000..1016ac3 --- /dev/null +++ b/ruoyi-base-support/ruoyi-quartz/src/main/java/com/ruoyi/quartz/mapper/SysJobMapper.java @@ -0,0 +1,68 @@ +package com.ruoyi.quartz.mapper; + +import com.ruoyi.quartz.domain.SysJob; + +import java.util.List; + +/** + * 调度任务信息 数据层 + * + * @author ruoyi + */ +public interface SysJobMapper +{ + /** + * 查询调度任务日志集合 + * + * @param job 调度信息 + * @return 操作日志集合 + */ + public List selectJobList(SysJob job); + + /** + * 查询所有调度任务 + * + * @return 调度任务列表 + */ + public List selectJobAll(); + + /** + * 通过调度ID查询调度任务信息 + * + * @param jobId 调度ID + * @return 角色对象信息 + */ + public SysJob selectJobById(Long jobId); + + /** + * 通过调度ID删除调度任务信息 + * + * @param jobId 调度ID + * @return 结果 + */ + public int deleteJobById(Long jobId); + + /** + * 批量删除调度任务信息 + * + * @param ids 需要删除的数据ID + * @return 结果 + */ + public int deleteJobByIds(Long[] ids); + + /** + * 修改调度任务信息 + * + * @param job 调度任务信息 + * @return 结果 + */ + public int updateJob(SysJob job); + + /** + * 新增调度任务信息 + * + * @param job 调度任务信息 + * @return 结果 + */ + public int insertJob(SysJob job); +} diff --git a/ruoyi-base-support/ruoyi-quartz/src/main/java/com/ruoyi/quartz/mapper/xml/SysJobLogMapper.xml b/ruoyi-base-support/ruoyi-quartz/src/main/java/com/ruoyi/quartz/mapper/xml/SysJobLogMapper.xml new file mode 100644 index 0000000..e608e42 --- /dev/null +++ b/ruoyi-base-support/ruoyi-quartz/src/main/java/com/ruoyi/quartz/mapper/xml/SysJobLogMapper.xml @@ -0,0 +1,93 @@ + + + + + + + + + + + + + + + + + select job_log_id, job_name, job_group, invoke_target, job_message, status, exception_info, create_time + from sys_job_log + + + + + + + + + + delete from sys_job_log where job_log_id = #{jobLogId} + + + + delete from sys_job_log where job_log_id in + + #{jobLogId} + + + + + truncate table sys_job_log + + + + insert into sys_job_log( + job_log_id, + job_name, + job_group, + invoke_target, + job_message, + status, + exception_info, + create_time + )values( + #{jobLogId}, + #{jobName}, + #{jobGroup}, + #{invokeTarget}, + #{jobMessage}, + #{status}, + #{exceptionInfo}, + sysdate() + ) + + + \ No newline at end of file diff --git a/ruoyi-base-support/ruoyi-quartz/src/main/java/com/ruoyi/quartz/mapper/xml/SysJobMapper.xml b/ruoyi-base-support/ruoyi-quartz/src/main/java/com/ruoyi/quartz/mapper/xml/SysJobMapper.xml new file mode 100644 index 0000000..5605c44 --- /dev/null +++ b/ruoyi-base-support/ruoyi-quartz/src/main/java/com/ruoyi/quartz/mapper/xml/SysJobMapper.xml @@ -0,0 +1,111 @@ + + + + + + + + + + + + + + + + + + + + + + select job_id, job_name, job_group, invoke_target, cron_expression, misfire_policy, concurrent, status, create_by, create_time, remark + from sys_job + + + + + + + + + + delete from sys_job where job_id = #{jobId} + + + + delete from sys_job where job_id in + + #{jobId} + + + + + update sys_job + + job_name = #{jobName}, + job_group = #{jobGroup}, + invoke_target = #{invokeTarget}, + cron_expression = #{cronExpression}, + misfire_policy = #{misfirePolicy}, + concurrent = #{concurrent}, + status = #{status}, + remark = #{remark}, + update_by = #{updateBy}, + update_time = sysdate() + + where job_id = #{jobId} + + + + insert into sys_job( + job_id, + job_name, + job_group, + invoke_target, + cron_expression, + misfire_policy, + concurrent, + status, + remark, + create_by, + create_time + )values( + #{jobId}, + #{jobName}, + #{jobGroup}, + #{invokeTarget}, + #{cronExpression}, + #{misfirePolicy}, + #{concurrent}, + #{status}, + #{remark}, + #{createBy}, + sysdate() + ) + + + \ No newline at end of file diff --git a/ruoyi-base-support/ruoyi-quartz/src/main/java/com/ruoyi/quartz/service/ISysJobLogService.java b/ruoyi-base-support/ruoyi-quartz/src/main/java/com/ruoyi/quartz/service/ISysJobLogService.java new file mode 100644 index 0000000..cea825b --- /dev/null +++ b/ruoyi-base-support/ruoyi-quartz/src/main/java/com/ruoyi/quartz/service/ISysJobLogService.java @@ -0,0 +1,57 @@ +package com.ruoyi.quartz.service; + +import com.ruoyi.quartz.domain.SysJobLog; + +import java.util.List; + +/** + * 定时任务调度日志信息信息 服务层 + * + * @author ruoyi + */ +public interface ISysJobLogService +{ + /** + * 获取quartz调度器日志的计划任务 + * + * @param jobLog 调度日志信息 + * @return 调度任务日志集合 + */ + public List selectJobLogList(SysJobLog jobLog); + + /** + * 通过调度任务日志ID查询调度信息 + * + * @param jobLogId 调度任务日志ID + * @return 调度任务日志对象信息 + */ + public SysJobLog selectJobLogById(Long jobLogId); + + /** + * 新增任务日志 + * + * @param jobLog 调度日志信息 + */ + public void addJobLog(SysJobLog jobLog); + + /** + * 批量删除调度日志信息 + * + * @param logIds 需要删除的日志ID + * @return 结果 + */ + public int deleteJobLogByIds(Long[] logIds); + + /** + * 删除任务日志 + * + * @param jobId 调度日志ID + * @return 结果 + */ + public int deleteJobLogById(Long jobId); + + /** + * 清空任务日志 + */ + public void cleanJobLog(); +} diff --git a/ruoyi-base-support/ruoyi-quartz/src/main/java/com/ruoyi/quartz/service/ISysJobService.java b/ruoyi-base-support/ruoyi-quartz/src/main/java/com/ruoyi/quartz/service/ISysJobService.java new file mode 100644 index 0000000..5b60b35 --- /dev/null +++ b/ruoyi-base-support/ruoyi-quartz/src/main/java/com/ruoyi/quartz/service/ISysJobService.java @@ -0,0 +1,103 @@ +package com.ruoyi.quartz.service; + +import com.ruoyi.common.exception.job.TaskException; +import com.ruoyi.quartz.domain.SysJob; +import org.quartz.SchedulerException; + +import java.util.List; + +/** + * 定时任务调度信息信息 服务层 + * + * @author ruoyi + */ +public interface ISysJobService +{ + /** + * 获取quartz调度器的计划任务 + * + * @param job 调度信息 + * @return 调度任务集合 + */ + public List selectJobList(SysJob job); + + /** + * 通过调度任务ID查询调度信息 + * + * @param jobId 调度任务ID + * @return 调度任务对象信息 + */ + public SysJob selectJobById(Long jobId); + + /** + * 暂停任务 + * + * @param job 调度信息 + * @return 结果 + */ + public int pauseJob(SysJob job) throws SchedulerException; + + /** + * 恢复任务 + * + * @param job 调度信息 + * @return 结果 + */ + public int resumeJob(SysJob job) throws SchedulerException; + + /** + * 删除任务后,所对应的trigger也将被删除 + * + * @param job 调度信息 + * @return 结果 + */ + public int deleteJob(SysJob job) throws SchedulerException; + + /** + * 批量删除调度信息 + * + * @param jobIds 需要删除的任务ID + * @return 结果 + */ + public void deleteJobByIds(Long[] jobIds) throws SchedulerException; + + /** + * 任务调度状态修改 + * + * @param job 调度信息 + * @return 结果 + */ + public int changeStatus(SysJob job) throws SchedulerException; + + /** + * 立即运行任务 + * + * @param job 调度信息 + * @return 结果 + */ + public void run(SysJob job) throws SchedulerException; + + /** + * 新增任务 + * + * @param job 调度信息 + * @return 结果 + */ + public int insertJob(SysJob job) throws SchedulerException, TaskException; + + /** + * 更新任务 + * + * @param job 调度信息 + * @return 结果 + */ + public int updateJob(SysJob job) throws SchedulerException, TaskException; + + /** + * 校验cron表达式是否有效 + * + * @param cronExpression 表达式 + * @return 结果 + */ + public boolean checkCronExpressionIsValid(String cronExpression); +} diff --git a/ruoyi-base-support/ruoyi-quartz/src/main/java/com/ruoyi/quartz/service/impl/SysJobLogServiceImpl.java b/ruoyi-base-support/ruoyi-quartz/src/main/java/com/ruoyi/quartz/service/impl/SysJobLogServiceImpl.java new file mode 100644 index 0000000..40bc59c --- /dev/null +++ b/ruoyi-base-support/ruoyi-quartz/src/main/java/com/ruoyi/quartz/service/impl/SysJobLogServiceImpl.java @@ -0,0 +1,88 @@ +package com.ruoyi.quartz.service.impl; + +import com.ruoyi.quartz.domain.SysJobLog; +import com.ruoyi.quartz.mapper.SysJobLogMapper; +import com.ruoyi.quartz.service.ISysJobLogService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * 定时任务调度日志信息 服务层 + * + * @author ruoyi + */ +@Service +public class SysJobLogServiceImpl implements ISysJobLogService +{ + @Autowired + private SysJobLogMapper jobLogMapper; + + /** + * 获取quartz调度器日志的计划任务 + * + * @param jobLog 调度日志信息 + * @return 调度任务日志集合 + */ + @Override + public List selectJobLogList(SysJobLog jobLog) + { + return jobLogMapper.selectJobLogList(jobLog); + } + + /** + * 通过调度任务日志ID查询调度信息 + * + * @param jobLogId 调度任务日志ID + * @return 调度任务日志对象信息 + */ + @Override + public SysJobLog selectJobLogById(Long jobLogId) + { + return jobLogMapper.selectJobLogById(jobLogId); + } + + /** + * 新增任务日志 + * + * @param jobLog 调度日志信息 + */ + @Override + public void addJobLog(SysJobLog jobLog) + { + jobLogMapper.insertJobLog(jobLog); + } + + /** + * 批量删除调度日志信息 + * + * @param logIds 需要删除的数据ID + * @return 结果 + */ + @Override + public int deleteJobLogByIds(Long[] logIds) + { + return jobLogMapper.deleteJobLogByIds(logIds); + } + + /** + * 删除任务日志 + * + * @param jobId 调度日志ID + */ + @Override + public int deleteJobLogById(Long jobId) + { + return jobLogMapper.deleteJobLogById(jobId); + } + + /** + * 清空任务日志 + */ + @Override + public void cleanJobLog() + { + jobLogMapper.cleanJobLog(); + } +} diff --git a/ruoyi-base-support/ruoyi-quartz/src/main/java/com/ruoyi/quartz/service/impl/SysJobServiceImpl.java b/ruoyi-base-support/ruoyi-quartz/src/main/java/com/ruoyi/quartz/service/impl/SysJobServiceImpl.java new file mode 100644 index 0000000..e7eb444 --- /dev/null +++ b/ruoyi-base-support/ruoyi-quartz/src/main/java/com/ruoyi/quartz/service/impl/SysJobServiceImpl.java @@ -0,0 +1,255 @@ +package com.ruoyi.quartz.service.impl; + +import com.ruoyi.common.constant.ScheduleConstants; +import com.ruoyi.common.exception.job.TaskException; +import com.ruoyi.quartz.domain.SysJob; +import com.ruoyi.quartz.mapper.SysJobMapper; +import com.ruoyi.quartz.service.ISysJobService; +import com.ruoyi.quartz.util.CronUtils; +import com.ruoyi.quartz.util.ScheduleUtils; +import org.quartz.JobDataMap; +import org.quartz.JobKey; +import org.quartz.Scheduler; +import org.quartz.SchedulerException; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import javax.annotation.PostConstruct; +import java.util.List; + +/** + * 定时任务调度信息 服务层 + * + * @author ruoyi + */ +@Service +public class SysJobServiceImpl implements ISysJobService +{ + @Autowired + private Scheduler scheduler; + + @Autowired + private SysJobMapper jobMapper; + + /** + * 项目启动时,初始化定时器 主要是防止手动修改数据库导致未同步到定时任务处理(注:不能手动修改数据库ID和任务组名,否则会导致脏数据) + */ + @PostConstruct + public void init() throws SchedulerException, TaskException + { + scheduler.clear(); + List jobList = jobMapper.selectJobAll(); + for (SysJob job : jobList) + { + ScheduleUtils.createScheduleJob(scheduler, job); + } + } + + /** + * 获取quartz调度器的计划任务列表 + * + * @param job 调度信息 + * @return + */ + @Override + public List selectJobList(SysJob job) + { + return jobMapper.selectJobList(job); + } + + /** + * 通过调度任务ID查询调度信息 + * + * @param jobId 调度任务ID + * @return 调度任务对象信息 + */ + @Override + public SysJob selectJobById(Long jobId) + { + return jobMapper.selectJobById(jobId); + } + + /** + * 暂停任务 + * + * @param job 调度信息 + */ + @Override + @Transactional(rollbackFor = Exception.class) + public int pauseJob(SysJob job) throws SchedulerException + { + Long jobId = job.getJobId(); + String jobGroup = job.getJobGroup(); + job.setStatus(ScheduleConstants.Status.PAUSE.getValue()); + int rows = jobMapper.updateJob(job); + if (rows > 0) + { + scheduler.pauseJob(ScheduleUtils.getJobKey(jobId, jobGroup)); + } + return rows; + } + + /** + * 恢复任务 + * + * @param job 调度信息 + */ + @Override + @Transactional(rollbackFor = Exception.class) + public int resumeJob(SysJob job) throws SchedulerException + { + Long jobId = job.getJobId(); + String jobGroup = job.getJobGroup(); + job.setStatus(ScheduleConstants.Status.NORMAL.getValue()); + int rows = jobMapper.updateJob(job); + if (rows > 0) + { + scheduler.resumeJob(ScheduleUtils.getJobKey(jobId, jobGroup)); + } + return rows; + } + + /** + * 删除任务后,所对应的trigger也将被删除 + * + * @param job 调度信息 + */ + @Override + @Transactional(rollbackFor = Exception.class) + public int deleteJob(SysJob job) throws SchedulerException + { + Long jobId = job.getJobId(); + String jobGroup = job.getJobGroup(); + int rows = jobMapper.deleteJobById(jobId); + if (rows > 0) + { + scheduler.deleteJob(ScheduleUtils.getJobKey(jobId, jobGroup)); + } + return rows; + } + + /** + * 批量删除调度信息 + * + * @param jobIds 需要删除的任务ID + * @return 结果 + */ + @Override + @Transactional(rollbackFor = Exception.class) + public void deleteJobByIds(Long[] jobIds) throws SchedulerException + { + for (Long jobId : jobIds) + { + SysJob job = jobMapper.selectJobById(jobId); + deleteJob(job); + } + } + + /** + * 任务调度状态修改 + * + * @param job 调度信息 + */ + @Override + @Transactional(rollbackFor = Exception.class) + public int changeStatus(SysJob job) throws SchedulerException + { + int rows = 0; + String status = job.getStatus(); + if (ScheduleConstants.Status.NORMAL.getValue().equals(status)) + { + rows = resumeJob(job); + } + else if (ScheduleConstants.Status.PAUSE.getValue().equals(status)) + { + rows = pauseJob(job); + } + return rows; + } + + /** + * 立即运行任务 + * + * @param job 调度信息 + */ + @Override + @Transactional(rollbackFor = Exception.class) + public void run(SysJob job) throws SchedulerException + { + Long jobId = job.getJobId(); + String jobGroup = job.getJobGroup(); + SysJob properties = selectJobById(job.getJobId()); + // 参数 + JobDataMap dataMap = new JobDataMap(); + dataMap.put(ScheduleConstants.TASK_PROPERTIES, properties); + scheduler.triggerJob(ScheduleUtils.getJobKey(jobId, jobGroup), dataMap); + } + + /** + * 新增任务 + * + * @param job 调度信息 调度信息 + */ + @Override + @Transactional(rollbackFor = Exception.class) + public int insertJob(SysJob job) throws SchedulerException, TaskException + { + job.setStatus(ScheduleConstants.Status.PAUSE.getValue()); + int rows = jobMapper.insertJob(job); + if (rows > 0) + { + ScheduleUtils.createScheduleJob(scheduler, job); + } + return rows; + } + + /** + * 更新任务的时间表达式 + * + * @param job 调度信息 + */ + @Override + @Transactional(rollbackFor = Exception.class) + public int updateJob(SysJob job) throws SchedulerException, TaskException + { + SysJob properties = selectJobById(job.getJobId()); + int rows = jobMapper.updateJob(job); + if (rows > 0) + { + updateSchedulerJob(job, properties.getJobGroup()); + } + return rows; + } + + /** + * 更新任务 + * + * @param job 任务对象 + * @param jobGroup 任务组名 + */ + public void updateSchedulerJob(SysJob job, String jobGroup) throws SchedulerException, TaskException + { + Long jobId = job.getJobId(); + // 判断是否存在 + JobKey jobKey = ScheduleUtils.getJobKey(jobId, jobGroup); + if (scheduler.checkExists(jobKey)) + { + // 防止创建时存在数据问题 先移除,然后在执行创建操作 + scheduler.deleteJob(jobKey); + } + ScheduleUtils.createScheduleJob(scheduler, job); + } + + /** + * 校验cron表达式是否有效 + * + * @param cronExpression 表达式 + * @return 结果 + */ + @Override + public boolean checkCronExpressionIsValid(String cronExpression) + { + return CronUtils.isValid(cronExpression); + } +} diff --git a/ruoyi-base-support/ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/RyTask.java b/ruoyi-base-support/ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/RyTask.java new file mode 100644 index 0000000..c45e29b --- /dev/null +++ b/ruoyi-base-support/ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/RyTask.java @@ -0,0 +1,28 @@ +package com.ruoyi.quartz.task; + +import com.ruoyi.common.utils.StringUtils; +import org.springframework.stereotype.Component; + +/** + * 定时任务调度测试 + * + * @author ruoyi + */ +//@Component("ryTask") +public class RyTask +{ + public void ryMultipleParams(String s, Boolean b, Long l, Double d, Integer i) + { + System.out.println(StringUtils.format("执行多参方法: 字符串类型{},布尔类型{},长整型{},浮点型{},整形{}", s, b, l, d, i)); + } + + public void ryParams(String params) + { + System.out.println("执行有参方法:" + params); + } + + public void ryNoParams() + { + System.out.println("执行无参方法==================================================================="); + } +} diff --git a/ruoyi-base-support/ruoyi-quartz/src/main/java/com/ruoyi/quartz/util/AbstractQuartzJob.java b/ruoyi-base-support/ruoyi-quartz/src/main/java/com/ruoyi/quartz/util/AbstractQuartzJob.java new file mode 100644 index 0000000..192608d --- /dev/null +++ b/ruoyi-base-support/ruoyi-quartz/src/main/java/com/ruoyi/quartz/util/AbstractQuartzJob.java @@ -0,0 +1,108 @@ +package com.ruoyi.quartz.util; + +import com.ruoyi.common.constant.Constants; +import com.ruoyi.common.constant.ScheduleConstants; +import com.ruoyi.common.utils.ExceptionUtil; +import com.ruoyi.common.utils.StringUtils; +import com.ruoyi.common.utils.bean.BeanUtils; +import com.ruoyi.common.utils.spring.SpringUtils; +import com.ruoyi.quartz.domain.SysJob; +import com.ruoyi.quartz.domain.SysJobLog; +import com.ruoyi.quartz.service.ISysJobLogService; +import org.quartz.Job; +import org.quartz.JobExecutionContext; +import org.quartz.JobExecutionException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.Date; + +/** + * 抽象quartz调用 + * + * @author ruoyi + */ +public abstract class AbstractQuartzJob implements Job +{ + private static final Logger log = LoggerFactory.getLogger(AbstractQuartzJob.class); + + /** + * 线程本地变量 + */ + private static ThreadLocal threadLocal = new ThreadLocal<>(); + + @Override + public void execute(JobExecutionContext context) throws JobExecutionException + { + SysJob sysJob = new SysJob(); + BeanUtils.copyBeanProp(sysJob, context.getMergedJobDataMap().get(ScheduleConstants.TASK_PROPERTIES)); + try + { + before(context, sysJob); + if (sysJob != null) + { + doExecute(context, sysJob); + } + after(context, sysJob, null); + } + catch (Exception e) + { + log.error("任务执行异常 - :", e); + after(context, sysJob, e); + } + } + + /** + * 执行前 + * + * @param context 工作执行上下文对象 + * @param sysJob 系统计划任务 + */ + protected void before(JobExecutionContext context, SysJob sysJob) + { + threadLocal.set(new Date()); + } + + /** + * 执行后 + * + * @param context 工作执行上下文对象 + * @param sysJob 系统计划任务 + */ + protected void after(JobExecutionContext context, SysJob sysJob, Exception e) + { + Date startTime = threadLocal.get(); + threadLocal.remove(); + + final SysJobLog sysJobLog = new SysJobLog(); + sysJobLog.setJobName(sysJob.getJobName()); + sysJobLog.setJobGroup(sysJob.getJobGroup()); + sysJobLog.setInvokeTarget(sysJob.getInvokeTarget()); + sysJobLog.setStartTime(startTime); + sysJobLog.setStopTime(new Date()); + long runMs = sysJobLog.getStopTime().getTime() - sysJobLog.getStartTime().getTime(); + sysJobLog.setJobMessage(sysJobLog.getJobName() + " 总共耗时:" + runMs + "毫秒"); + if (e != null) + { + sysJobLog.setStatus(Constants.FAIL); + String errorMsg = StringUtils.substring(ExceptionUtil.getExceptionMessage(e), 0, 2000); + sysJobLog.setExceptionInfo(errorMsg); + } + else + { + sysJobLog.setStatus(Constants.SUCCESS); + } + + // 写入数据库当中 + SpringUtils.getBean(ISysJobLogService.class).addJobLog(sysJobLog); + } + + /** + * 执行方法,由子类重载 + * + * @param context 工作执行上下文对象 + * @param sysJob 系统计划任务 + * @throws Exception 执行过程中的异常 + */ + protected abstract void doExecute(JobExecutionContext context, SysJob sysJob) throws Exception; +} diff --git a/ruoyi-base-support/ruoyi-quartz/src/main/java/com/ruoyi/quartz/util/CronUtils.java b/ruoyi-base-support/ruoyi-quartz/src/main/java/com/ruoyi/quartz/util/CronUtils.java new file mode 100644 index 0000000..513d242 --- /dev/null +++ b/ruoyi-base-support/ruoyi-quartz/src/main/java/com/ruoyi/quartz/util/CronUtils.java @@ -0,0 +1,64 @@ +package com.ruoyi.quartz.util; + +import org.quartz.CronExpression; + +import java.text.ParseException; +import java.util.Date; + +/** + * cron表达式工具类 + * + * @author ruoyi + * + */ +public class CronUtils +{ + /** + * 返回一个布尔值代表一个给定的Cron表达式的有效性 + * + * @param cronExpression Cron表达式 + * @return boolean 表达式是否有效 + */ + public static boolean isValid(String cronExpression) + { + return CronExpression.isValidExpression(cronExpression); + } + + /** + * 返回一个字符串值,表示该消息无效Cron表达式给出有效性 + * + * @param cronExpression Cron表达式 + * @return String 无效时返回表达式错误描述,如果有效返回null + */ + public static String getInvalidMessage(String cronExpression) + { + try + { + new CronExpression(cronExpression); + return null; + } + catch (ParseException pe) + { + return pe.getMessage(); + } + } + + /** + * 返回下一个执行时间根据给定的Cron表达式 + * + * @param cronExpression Cron表达式 + * @return Date 下次Cron表达式执行时间 + */ + public static Date getNextExecution(String cronExpression) + { + try + { + CronExpression cron = new CronExpression(cronExpression); + return cron.getNextValidTimeAfter(new Date(System.currentTimeMillis())); + } + catch (ParseException e) + { + throw new IllegalArgumentException(e.getMessage()); + } + } +} diff --git a/ruoyi-base-support/ruoyi-quartz/src/main/java/com/ruoyi/quartz/util/JobInvokeUtil.java b/ruoyi-base-support/ruoyi-quartz/src/main/java/com/ruoyi/quartz/util/JobInvokeUtil.java new file mode 100644 index 0000000..902a7b0 --- /dev/null +++ b/ruoyi-base-support/ruoyi-quartz/src/main/java/com/ruoyi/quartz/util/JobInvokeUtil.java @@ -0,0 +1,183 @@ +package com.ruoyi.quartz.util; + +import com.ruoyi.common.utils.StringUtils; +import com.ruoyi.common.utils.spring.SpringUtils; +import com.ruoyi.quartz.domain.SysJob; + +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.util.LinkedList; +import java.util.List; + +/** + * 任务执行工具 + * + * @author ruoyi + */ +public class JobInvokeUtil +{ + /** + * 执行方法 + * + * @param sysJob 系统任务 + */ + public static void invokeMethod(SysJob sysJob) throws Exception + { + String invokeTarget = sysJob.getInvokeTarget(); + String beanName = getBeanName(invokeTarget); + String methodName = getMethodName(invokeTarget); + List methodParams = getMethodParams(invokeTarget); + + if (!isValidClassName(beanName)) + { + Object bean = SpringUtils.getBean(beanName); + invokeMethod(bean, methodName, methodParams); + } + else + { + Object bean = Class.forName(beanName).newInstance(); + invokeMethod(bean, methodName, methodParams); + } + } + + /** + * 调用任务方法 + * + * @param bean 目标对象 + * @param methodName 方法名称 + * @param methodParams 方法参数 + */ + private static void invokeMethod(Object bean, String methodName, List methodParams) + throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, + InvocationTargetException + { + if (StringUtils.isNotNull(methodParams) && methodParams.size() > 0) + { + Method method = bean.getClass().getDeclaredMethod(methodName, getMethodParamsType(methodParams)); + method.invoke(bean, getMethodParamsValue(methodParams)); + } + else + { + Method method = bean.getClass().getDeclaredMethod(methodName); + method.invoke(bean); + } + } + + /** + * 校验是否为为class包名 + * + * @param str 名称 + * @return true是 false否 + */ + public static boolean isValidClassName(String invokeTarget) + { + return StringUtils.countMatches(invokeTarget, ".") > 1; + } + + /** + * 获取bean名称 + * + * @param invokeTarget 目标字符串 + * @return bean名称 + */ + public static String getBeanName(String invokeTarget) + { + String beanName = StringUtils.substringBefore(invokeTarget, "("); + return StringUtils.substringBeforeLast(beanName, "."); + } + + /** + * 获取bean方法 + * + * @param invokeTarget 目标字符串 + * @return method方法 + */ + public static String getMethodName(String invokeTarget) + { + String methodName = StringUtils.substringBefore(invokeTarget, "("); + return StringUtils.substringAfterLast(methodName, "."); + } + + /** + * 获取method方法参数相关列表 + * + * @param invokeTarget 目标字符串 + * @return method方法相关参数列表 + */ + public static List getMethodParams(String invokeTarget) + { + String methodStr = StringUtils.substringBetween(invokeTarget, "(", ")"); + if (StringUtils.isEmpty(methodStr)) + { + return null; + } + String[] methodParams = methodStr.split(","); + List classs = new LinkedList<>(); + for (int i = 0; i < methodParams.length; i++) + { + String str = StringUtils.trimToEmpty(methodParams[i]); + // String字符串类型,包含' + if (StringUtils.contains(str, "'")) + { + classs.add(new Object[] { StringUtils.replace(str, "'", ""), String.class }); + } + // boolean布尔类型,等于true或者false + else if (StringUtils.equals(str, "true") || StringUtils.equalsIgnoreCase(str, "false")) + { + classs.add(new Object[] { Boolean.valueOf(str), Boolean.class }); + } + // long长整形,包含L + else if (StringUtils.containsIgnoreCase(str, "L")) + { + classs.add(new Object[] { Long.valueOf(StringUtils.replaceIgnoreCase(str, "L", "")), Long.class }); + } + // double浮点类型,包含D + else if (StringUtils.containsIgnoreCase(str, "D")) + { + classs.add(new Object[] { Double.valueOf(StringUtils.replaceIgnoreCase(str, "D", "")), Double.class }); + } + // 其他类型归类为整形 + else + { + classs.add(new Object[] { Integer.valueOf(str), Integer.class }); + } + } + return classs; + } + + /** + * 获取参数类型 + * + * @param methodParams 参数相关列表 + * @return 参数类型列表 + */ + public static Class[] getMethodParamsType(List methodParams) + { + Class[] classs = new Class[methodParams.size()]; + int index = 0; + for (Object[] os : methodParams) + { + classs[index] = (Class) os[1]; + index++; + } + return classs; + } + + /** + * 获取参数值 + * + * @param methodParams 参数相关列表 + * @return 参数值列表 + */ + public static Object[] getMethodParamsValue(List methodParams) + { + Object[] classs = new Object[methodParams.size()]; + int index = 0; + for (Object[] os : methodParams) + { + classs[index] = (Object) os[0]; + index++; + } + return classs; + } +} diff --git a/ruoyi-base-support/ruoyi-quartz/src/main/java/com/ruoyi/quartz/util/QuartzDisallowConcurrentExecution.java b/ruoyi-base-support/ruoyi-quartz/src/main/java/com/ruoyi/quartz/util/QuartzDisallowConcurrentExecution.java new file mode 100644 index 0000000..578f377 --- /dev/null +++ b/ruoyi-base-support/ruoyi-quartz/src/main/java/com/ruoyi/quartz/util/QuartzDisallowConcurrentExecution.java @@ -0,0 +1,21 @@ +package com.ruoyi.quartz.util; + +import com.ruoyi.quartz.domain.SysJob; +import org.quartz.DisallowConcurrentExecution; +import org.quartz.JobExecutionContext; + +/** + * 定时任务处理(禁止并发执行) + * + * @author ruoyi + * + */ +@DisallowConcurrentExecution +public class QuartzDisallowConcurrentExecution extends AbstractQuartzJob +{ + @Override + protected void doExecute(JobExecutionContext context, SysJob sysJob) throws Exception + { + JobInvokeUtil.invokeMethod(sysJob); + } +} diff --git a/ruoyi-base-support/ruoyi-quartz/src/main/java/com/ruoyi/quartz/util/QuartzJobExecution.java b/ruoyi-base-support/ruoyi-quartz/src/main/java/com/ruoyi/quartz/util/QuartzJobExecution.java new file mode 100644 index 0000000..e8c3ddc --- /dev/null +++ b/ruoyi-base-support/ruoyi-quartz/src/main/java/com/ruoyi/quartz/util/QuartzJobExecution.java @@ -0,0 +1,19 @@ +package com.ruoyi.quartz.util; + +import com.ruoyi.quartz.domain.SysJob; +import org.quartz.JobExecutionContext; + +/** + * 定时任务处理(允许并发执行) + * + * @author ruoyi + * + */ +public class QuartzJobExecution extends AbstractQuartzJob +{ + @Override + protected void doExecute(JobExecutionContext context, SysJob sysJob) throws Exception + { + JobInvokeUtil.invokeMethod(sysJob); + } +} diff --git a/ruoyi-base-support/ruoyi-quartz/src/main/java/com/ruoyi/quartz/util/ScheduleUtils.java b/ruoyi-base-support/ruoyi-quartz/src/main/java/com/ruoyi/quartz/util/ScheduleUtils.java new file mode 100644 index 0000000..2239f00 --- /dev/null +++ b/ruoyi-base-support/ruoyi-quartz/src/main/java/com/ruoyi/quartz/util/ScheduleUtils.java @@ -0,0 +1,104 @@ +package com.ruoyi.quartz.util; + +import com.ruoyi.common.constant.ScheduleConstants; +import com.ruoyi.common.exception.job.TaskException; +import com.ruoyi.common.exception.job.TaskException.Code; +import com.ruoyi.quartz.domain.SysJob; +import org.quartz.*; + +/** + * 定时任务工具类 + * + * @author ruoyi + * + */ +public class ScheduleUtils +{ + /** + * 得到quartz任务类 + * + * @param sysJob 执行计划 + * @return 具体执行任务类 + */ + private static Class getQuartzJobClass(SysJob sysJob) + { + boolean isConcurrent = "0".equals(sysJob.getConcurrent()); + return isConcurrent ? QuartzJobExecution.class : QuartzDisallowConcurrentExecution.class; + } + + /** + * 构建任务触发对象 + */ + public static TriggerKey getTriggerKey(Long jobId, String jobGroup) + { + return TriggerKey.triggerKey(ScheduleConstants.TASK_CLASS_NAME + jobId, jobGroup); + } + + /** + * 构建任务键对象 + */ + public static JobKey getJobKey(Long jobId, String jobGroup) + { + return JobKey.jobKey(ScheduleConstants.TASK_CLASS_NAME + jobId, jobGroup); + } + + /** + * 创建定时任务 + */ + public static void createScheduleJob(Scheduler scheduler, SysJob job) throws SchedulerException, TaskException + { + Class jobClass = getQuartzJobClass(job); + // 构建job信息 + Long jobId = job.getJobId(); + String jobGroup = job.getJobGroup(); + JobDetail jobDetail = JobBuilder.newJob(jobClass).withIdentity(getJobKey(jobId, jobGroup)).build(); + + // 表达式调度构建器 + CronScheduleBuilder cronScheduleBuilder = CronScheduleBuilder.cronSchedule(job.getCronExpression()); + cronScheduleBuilder = handleCronScheduleMisfirePolicy(job, cronScheduleBuilder); + + // 按新的cronExpression表达式构建一个新的trigger + CronTrigger trigger = TriggerBuilder.newTrigger().withIdentity(getTriggerKey(jobId, jobGroup)) + .withSchedule(cronScheduleBuilder).build(); + + // 放入参数,运行时的方法可以获取 + jobDetail.getJobDataMap().put(ScheduleConstants.TASK_PROPERTIES, job); + + // 判断是否存在 + if (scheduler.checkExists(getJobKey(jobId, jobGroup))) + { + // 防止创建时存在数据问题 先移除,然后在执行创建操作 + scheduler.deleteJob(getJobKey(jobId, jobGroup)); + } + + scheduler.scheduleJob(jobDetail, trigger); + + // 暂停任务 + if (job.getStatus().equals(ScheduleConstants.Status.PAUSE.getValue())) + { + scheduler.pauseJob(ScheduleUtils.getJobKey(jobId, jobGroup)); + } + } + + /** + * 设置定时任务策略 + */ + public static CronScheduleBuilder handleCronScheduleMisfirePolicy(SysJob job, CronScheduleBuilder cb) + throws TaskException + { + switch (job.getMisfirePolicy()) + { + case ScheduleConstants.MISFIRE_DEFAULT: + return cb; + case ScheduleConstants.MISFIRE_IGNORE_MISFIRES: + return cb.withMisfireHandlingInstructionIgnoreMisfires(); + case ScheduleConstants.MISFIRE_FIRE_AND_PROCEED: + return cb.withMisfireHandlingInstructionFireAndProceed(); + case ScheduleConstants.MISFIRE_DO_NOTHING: + return cb.withMisfireHandlingInstructionDoNothing(); + default: + throw new TaskException("The task misfire policy '" + job.getMisfirePolicy() + + "' cannot be used in cron schedule tasks", Code.CONFIG_ERROR); + } + } +} diff --git a/ruoyi-base-support/ruoyi-system/pom.xml b/ruoyi-base-support/ruoyi-system/pom.xml new file mode 100644 index 0000000..2acbf29 --- /dev/null +++ b/ruoyi-base-support/ruoyi-system/pom.xml @@ -0,0 +1,45 @@ + + + + ruoyi-base-support + com.ruoyi + 3.7.0 + + 4.0.0 + + ruoyi-system + + + system系统模块 + + + + + + + com.ruoyi + ruoyi-common + + + com.ruoyi + ruoyi-data-rule + + + com.baomidou + mybatis-plus-boot-starter + + + com.baomidou + mybatis-plus-extension + + + + org.springframework.boot + spring-boot-starter-validation + + + + + diff --git a/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/domain/SysConfig.java b/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/domain/SysConfig.java new file mode 100644 index 0000000..f3177d8 --- /dev/null +++ b/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/domain/SysConfig.java @@ -0,0 +1,112 @@ +package com.ruoyi.system.domain; + +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.annotation.Excel.ColumnType; +import com.ruoyi.common.core.domain.BaseEntity; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.Size; + +/** + * 参数配置表 sys_config + * + * @author ruoyi + */ +public class SysConfig extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** 参数主键 */ + @Excel(name = "参数主键", cellType = ColumnType.NUMERIC) + private Long configId; + + /** 参数名称 */ + @Excel(name = "参数名称") + private String configName; + + /** 参数键名 */ + @Excel(name = "参数键名") + private String configKey; + + /** 参数键值 */ + @Excel(name = "参数键值") + private String configValue; + + /** 系统内置(Y是 N否) */ + @Excel(name = "系统内置", readConverterExp = "Y=是,N=否") + private String configType; + + public Long getConfigId() + { + return configId; + } + + public void setConfigId(Long configId) + { + this.configId = configId; + } + + @NotBlank(message = "参数名称不能为空") + @Size(min = 0, max = 100, message = "参数名称不能超过100个字符") + public String getConfigName() + { + return configName; + } + + public void setConfigName(String configName) + { + this.configName = configName; + } + + @NotBlank(message = "参数键名长度不能为空") + @Size(min = 0, max = 100, message = "参数键名长度不能超过100个字符") + public String getConfigKey() + { + return configKey; + } + + public void setConfigKey(String configKey) + { + this.configKey = configKey; + } + + @NotBlank(message = "参数键值不能为空") + @Size(min = 0, max = 500, message = "参数键值长度不能超过500个字符") + public String getConfigValue() + { + return configValue; + } + + public void setConfigValue(String configValue) + { + this.configValue = configValue; + } + + public String getConfigType() + { + return configType; + } + + public void setConfigType(String configType) + { + this.configType = configType; + } + + @Override + public String toString() { + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) + .append("configId", getConfigId()) + .append("configName", getConfigName()) + .append("configKey", getConfigKey()) + .append("configValue", getConfigValue()) + .append("configType", getConfigType()) + .append("createBy", getCreateBy()) + .append("createTime", getCreateTime()) + .append("updateBy", getUpdateBy()) + .append("updateTime", getUpdateTime()) + .append("remark", getRemark()) + .toString(); + } +} diff --git a/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/domain/SysLogininfor.java b/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/domain/SysLogininfor.java new file mode 100644 index 0000000..4b87738 --- /dev/null +++ b/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/domain/SysLogininfor.java @@ -0,0 +1,145 @@ +package com.ruoyi.system.domain; + +import com.fasterxml.jackson.annotation.JsonFormat; +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.annotation.Excel.ColumnType; +import com.ruoyi.common.core.domain.BaseEntity; + +import java.util.Date; + +/** + * 系统访问记录表 sys_logininfor + * + * @author ruoyi + */ +public class SysLogininfor extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** ID */ + @Excel(name = "序号", cellType = ColumnType.NUMERIC) + private Long infoId; + + /** 用户账号 */ + @Excel(name = "用户账号") + private String userName; + + /** 登录状态 0成功 1失败 */ + @Excel(name = "登录状态", readConverterExp = "0=成功,1=失败") + private String status; + + /** 登录IP地址 */ + @Excel(name = "登录地址") + private String ipaddr; + + /** 登录地点 */ + @Excel(name = "登录地点") + private String loginLocation; + + /** 浏览器类型 */ + @Excel(name = "浏览器") + private String browser; + + /** 操作系统 */ + @Excel(name = "操作系统") + private String os; + + /** 提示消息 */ + @Excel(name = "提示消息") + private String msg; + + /** 访问时间 */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @Excel(name = "访问时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss") + private Date loginTime; + + public Long getInfoId() + { + return infoId; + } + + public void setInfoId(Long infoId) + { + this.infoId = infoId; + } + + public String getUserName() + { + return userName; + } + + public void setUserName(String userName) + { + this.userName = userName; + } + + public String getStatus() + { + return status; + } + + public void setStatus(String status) + { + this.status = status; + } + + public String getIpaddr() + { + return ipaddr; + } + + public void setIpaddr(String ipaddr) + { + this.ipaddr = ipaddr; + } + + public String getLoginLocation() + { + return loginLocation; + } + + public void setLoginLocation(String loginLocation) + { + this.loginLocation = loginLocation; + } + + public String getBrowser() + { + return browser; + } + + public void setBrowser(String browser) + { + this.browser = browser; + } + + public String getOs() + { + return os; + } + + public void setOs(String os) + { + this.os = os; + } + + public String getMsg() + { + return msg; + } + + public void setMsg(String msg) + { + this.msg = msg; + } + + public Date getLoginTime() + { + return loginTime; + } + + public void setLoginTime(Date loginTime) + { + this.loginTime = loginTime; + } +} diff --git a/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/domain/SysNotice.java b/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/domain/SysNotice.java new file mode 100644 index 0000000..6bedf6d --- /dev/null +++ b/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/domain/SysNotice.java @@ -0,0 +1,125 @@ +package com.ruoyi.system.domain; + +import com.baomidou.mybatisplus.annotation.TableField; +import com.ruoyi.common.core.domain.BaseEntity; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.Size; + +/** + * 通知公告表 sys_notice + * + * @author ruoyi + */ +public class SysNotice extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** 公告ID */ + private Long noticeId; + + /** 公告标题 */ + private String noticeTitle; + + /** 公告类型(1通知 2公告) */ + private String noticeType; + + /** 公告内容 */ + private String noticeContent; + + /** 公告状态(0正常 1关闭) */ + private String status; + + /** 租户ID */ + private String tenantId; + + /** 是否是app 1 不是 2是 */ + @TableField(exist = false) + private Integer isApp; + + public Long getNoticeId() + { + return noticeId; + } + + public void setNoticeId(Long noticeId) + { + this.noticeId = noticeId; + } + + public void setNoticeTitle(String noticeTitle) + { + this.noticeTitle = noticeTitle; + } + + @NotBlank(message = "公告标题不能为空") + @Size(min = 0, max = 50, message = "公告标题不能超过50个字符") + public String getNoticeTitle() + { + return noticeTitle; + } + + public void setNoticeType(String noticeType) + { + this.noticeType = noticeType; + } + + public String getNoticeType() + { + return noticeType; + } + + public void setNoticeContent(String noticeContent) + { + this.noticeContent = noticeContent; + } + + public String getNoticeContent() + { + return noticeContent; + } + + public void setStatus(String status) + { + this.status = status; + } + + public String getStatus() + { + return status; + } + + public String getTenantId() { + return tenantId; + } + + public void setTenantId(String tenantId) { + this.tenantId = tenantId; + } + + public Integer getIsApp() { + return isApp; + } + + public void setIsApp(Integer isApp) { + this.isApp = isApp; + } + + @Override + public String toString() { + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) + .append("noticeId", getNoticeId()) + .append("noticeTitle", getNoticeTitle()) + .append("noticeType", getNoticeType()) + .append("noticeContent", getNoticeContent()) + .append("status", getStatus()) + .append("createBy", getCreateBy()) + .append("createTime", getCreateTime()) + .append("updateBy", getUpdateBy()) + .append("updateTime", getUpdateTime()) + .append("remark", getRemark()) + .toString(); + } +} diff --git a/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/domain/SysOperLog.java b/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/domain/SysOperLog.java new file mode 100644 index 0000000..337bb78 --- /dev/null +++ b/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/domain/SysOperLog.java @@ -0,0 +1,256 @@ +package com.ruoyi.system.domain; + +import com.fasterxml.jackson.annotation.JsonFormat; +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.annotation.Excel.ColumnType; +import com.ruoyi.common.core.domain.BaseEntity; + +import java.util.Date; + +/** + * 操作日志记录表 oper_log + * + * @author ruoyi + */ +public class SysOperLog extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** 日志主键 */ + @Excel(name = "操作序号", cellType = ColumnType.NUMERIC) + private Long operId; + + /** 操作模块 */ + @Excel(name = "操作模块") + private String title; + + /** 业务类型(0其它 1新增 2修改 3删除) */ + @Excel(name = "业务类型", readConverterExp = "0=其它,1=新增,2=修改,3=删除,4=授权,5=导出,6=导入,7=强退,8=生成代码,9=清空数据") + private Integer businessType; + + /** 业务类型数组 */ + private Integer[] businessTypes; + + /** 请求方法 */ + @Excel(name = "请求方法") + private String method; + + /** 请求方式 */ + @Excel(name = "请求方式") + private String requestMethod; + + /** 操作类别(0其它 1后台用户 2手机端用户) */ + @Excel(name = "操作类别", readConverterExp = "0=其它,1=后台用户,2=手机端用户") + private Integer operatorType; + + /** 操作人员 */ + @Excel(name = "操作人员") + private String operName; + + /** 部门名称 */ + @Excel(name = "部门名称") + private String deptName; + + /** 请求url */ + @Excel(name = "请求地址") + private String operUrl; + + /** 操作地址 */ + @Excel(name = "操作地址") + private String operIp; + + /** 操作地点 */ + @Excel(name = "操作地点") + private String operLocation; + + /** 请求参数 */ + @Excel(name = "请求参数") + private String operParam; + + /** 返回参数 */ + @Excel(name = "返回参数") + private String jsonResult; + + /** 操作状态(0正常 1异常) */ + @Excel(name = "状态", readConverterExp = "0=正常,1=异常") + private Integer status; + + /** 错误消息 */ + @Excel(name = "错误消息") + private String errorMsg; + + /** 操作时间 */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @Excel(name = "操作时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss") + private Date operTime; + + public Long getOperId() + { + return operId; + } + + public void setOperId(Long operId) + { + this.operId = operId; + } + + public String getTitle() + { + return title; + } + + public void setTitle(String title) + { + this.title = title; + } + + public Integer getBusinessType() + { + return businessType; + } + + public void setBusinessType(Integer businessType) + { + this.businessType = businessType; + } + + public Integer[] getBusinessTypes() + { + return businessTypes; + } + + public void setBusinessTypes(Integer[] businessTypes) + { + this.businessTypes = businessTypes; + } + + public String getMethod() + { + return method; + } + + public void setMethod(String method) + { + this.method = method; + } + + public String getRequestMethod() + { + return requestMethod; + } + + public void setRequestMethod(String requestMethod) + { + this.requestMethod = requestMethod; + } + + public Integer getOperatorType() + { + return operatorType; + } + + public void setOperatorType(Integer operatorType) + { + this.operatorType = operatorType; + } + + public String getOperName() + { + return operName; + } + + public void setOperName(String operName) + { + this.operName = operName; + } + + public String getDeptName() + { + return deptName; + } + + public void setDeptName(String deptName) + { + this.deptName = deptName; + } + + public String getOperUrl() + { + return operUrl; + } + + public void setOperUrl(String operUrl) + { + this.operUrl = operUrl; + } + + public String getOperIp() + { + return operIp; + } + + public void setOperIp(String operIp) + { + this.operIp = operIp; + } + + public String getOperLocation() + { + return operLocation; + } + + public void setOperLocation(String operLocation) + { + this.operLocation = operLocation; + } + + public String getOperParam() + { + return operParam; + } + + public void setOperParam(String operParam) + { + this.operParam = operParam; + } + + public String getJsonResult() + { + return jsonResult; + } + + public void setJsonResult(String jsonResult) + { + this.jsonResult = jsonResult; + } + + public Integer getStatus() + { + return status; + } + + public void setStatus(Integer status) + { + this.status = status; + } + + public String getErrorMsg() + { + return errorMsg; + } + + public void setErrorMsg(String errorMsg) + { + this.errorMsg = errorMsg; + } + + public Date getOperTime() + { + return operTime; + } + + public void setOperTime(Date operTime) + { + this.operTime = operTime; + } +} diff --git a/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/domain/SysPost.java b/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/domain/SysPost.java new file mode 100644 index 0000000..9b77ac0 --- /dev/null +++ b/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/domain/SysPost.java @@ -0,0 +1,128 @@ +package com.ruoyi.system.domain; + +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.annotation.Excel.ColumnType; +import com.ruoyi.common.core.domain.BaseEntity; +import lombok.Data; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.Size; + +/** + * 岗位表 sys_post + * + * @author ruoyi + */ +@Data +public class SysPost extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** 岗位序号 */ + @Excel(name = "岗位序号", cellType = ColumnType.NUMERIC) + private Long postId; + + /** 岗位编码 */ + @Excel(name = "岗位编码") + private String postCode; + + /** 岗位名称 */ + @Excel(name = "岗位名称") + private String postName; + + /** 岗位排序 */ + @Excel(name = "岗位排序") + private String postSort; + + /** 状态(0正常 1停用) */ + @Excel(name = "状态", readConverterExp = "0=正常,1=停用") + private String status; + + private String tenantId; + + /** 用户是否存在此岗位标识 默认不存在 */ + private boolean flag = false; + + public Long getPostId() + { + return postId; + } + + public void setPostId(Long postId) + { + this.postId = postId; + } + + @NotBlank(message = "岗位编码不能为空") + @Size(min = 0, max = 64, message = "岗位编码长度不能超过64个字符") + public String getPostCode() + { + return postCode; + } + + public void setPostCode(String postCode) + { + this.postCode = postCode; + } + + @NotBlank(message = "岗位名称不能为空") + @Size(min = 0, max = 50, message = "岗位名称长度不能超过50个字符") + public String getPostName() + { + return postName; + } + + public void setPostName(String postName) + { + this.postName = postName; + } + + @NotBlank(message = "显示顺序不能为空") + public String getPostSort() + { + return postSort; + } + + public void setPostSort(String postSort) + { + this.postSort = postSort; + } + + public String getStatus() + { + return status; + } + + public void setStatus(String status) + { + this.status = status; + } + + public boolean isFlag() + { + return flag; + } + + public void setFlag(boolean flag) + { + this.flag = flag; + } + + @Override + public String toString() { + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) + .append("postId", getPostId()) + .append("postCode", getPostCode()) + .append("postName", getPostName()) + .append("postSort", getPostSort()) + .append("status", getStatus()) + .append("createBy", getCreateBy()) + .append("createTime", getCreateTime()) + .append("updateBy", getUpdateBy()) + .append("updateTime", getUpdateTime()) + .append("remark", getRemark()) + .toString(); + } +} diff --git a/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/domain/SysRoleDataRule.java b/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/domain/SysRoleDataRule.java new file mode 100644 index 0000000..8a1cc71 --- /dev/null +++ b/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/domain/SysRoleDataRule.java @@ -0,0 +1,40 @@ +package com.ruoyi.system.domain; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; + +import java.io.Serializable; + +/** + * All rights Reserved, Designed By www.sunseagear.com + * + * @version V1.0 + * @package sys + * @title: 角色数据权限关联表控制器 + * @description: 角色数据权限关联表控制器 + * @author: 未知 + * @date: 2019-12-03 13:03:38 + * @copyright: www.sunseagear.com Inc. All rights reserved. + */ + +@Data +@TableName("sys_role_data_rule") +@SuppressWarnings("serial") +public class SysRoleDataRule implements Serializable { + + + @TableId(value = "id", type = IdType.AUTO) + private String id; //id + @TableField(value = "data_rule_category") + private Integer scopeCategory; //权限类型(1:数据权限、2:接口权限) + @TableField(value = "data_rule_id") + private String scopeId; //权限id + @TableField(value = "role_id") + private String roleId; //角色id + @TableField(exist = false) + private String ids; + +} diff --git a/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/domain/SysRoleDept.java b/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/domain/SysRoleDept.java new file mode 100644 index 0000000..47b21bf --- /dev/null +++ b/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/domain/SysRoleDept.java @@ -0,0 +1,46 @@ +package com.ruoyi.system.domain; + +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; + +/** + * 角色和部门关联 sys_role_dept + * + * @author ruoyi + */ +public class SysRoleDept +{ + /** 角色ID */ + private Long roleId; + + /** 部门ID */ + private Long deptId; + + public Long getRoleId() + { + return roleId; + } + + public void setRoleId(Long roleId) + { + this.roleId = roleId; + } + + public Long getDeptId() + { + return deptId; + } + + public void setDeptId(Long deptId) + { + this.deptId = deptId; + } + + @Override + public String toString() { + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) + .append("roleId", getRoleId()) + .append("deptId", getDeptId()) + .toString(); + } +} diff --git a/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/domain/SysRoleMenu.java b/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/domain/SysRoleMenu.java new file mode 100644 index 0000000..de10a74 --- /dev/null +++ b/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/domain/SysRoleMenu.java @@ -0,0 +1,46 @@ +package com.ruoyi.system.domain; + +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; + +/** + * 角色和菜单关联 sys_role_menu + * + * @author ruoyi + */ +public class SysRoleMenu +{ + /** 角色ID */ + private Long roleId; + + /** 菜单ID */ + private Long menuId; + + public Long getRoleId() + { + return roleId; + } + + public void setRoleId(Long roleId) + { + this.roleId = roleId; + } + + public Long getMenuId() + { + return menuId; + } + + public void setMenuId(Long menuId) + { + this.menuId = menuId; + } + + @Override + public String toString() { + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) + .append("roleId", getRoleId()) + .append("menuId", getMenuId()) + .toString(); + } +} diff --git a/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/domain/SysUserOnline.java b/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/domain/SysUserOnline.java new file mode 100644 index 0000000..2bbd318 --- /dev/null +++ b/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/domain/SysUserOnline.java @@ -0,0 +1,113 @@ +package com.ruoyi.system.domain; + +/** + * 当前在线会话 + * + * @author ruoyi + */ +public class SysUserOnline +{ + /** 会话编号 */ + private String tokenId; + + /** 部门名称 */ + private String deptName; + + /** 用户名称 */ + private String userName; + + /** 登录IP地址 */ + private String ipaddr; + + /** 登录地址 */ + private String loginLocation; + + /** 浏览器类型 */ + private String browser; + + /** 操作系统 */ + private String os; + + /** 登录时间 */ + private Long loginTime; + + public String getTokenId() + { + return tokenId; + } + + public void setTokenId(String tokenId) + { + this.tokenId = tokenId; + } + + public String getDeptName() + { + return deptName; + } + + public void setDeptName(String deptName) + { + this.deptName = deptName; + } + + public String getUserName() + { + return userName; + } + + public void setUserName(String userName) + { + this.userName = userName; + } + + public String getIpaddr() + { + return ipaddr; + } + + public void setIpaddr(String ipaddr) + { + this.ipaddr = ipaddr; + } + + public String getLoginLocation() + { + return loginLocation; + } + + public void setLoginLocation(String loginLocation) + { + this.loginLocation = loginLocation; + } + + public String getBrowser() + { + return browser; + } + + public void setBrowser(String browser) + { + this.browser = browser; + } + + public String getOs() + { + return os; + } + + public void setOs(String os) + { + this.os = os; + } + + public Long getLoginTime() + { + return loginTime; + } + + public void setLoginTime(Long loginTime) + { + this.loginTime = loginTime; + } +} diff --git a/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/domain/SysUserPost.java b/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/domain/SysUserPost.java new file mode 100644 index 0000000..6e8c416 --- /dev/null +++ b/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/domain/SysUserPost.java @@ -0,0 +1,46 @@ +package com.ruoyi.system.domain; + +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; + +/** + * 用户和岗位关联 sys_user_post + * + * @author ruoyi + */ +public class SysUserPost +{ + /** 用户ID */ + private Long userId; + + /** 岗位ID */ + private Long postId; + + public Long getUserId() + { + return userId; + } + + public void setUserId(Long userId) + { + this.userId = userId; + } + + public Long getPostId() + { + return postId; + } + + public void setPostId(Long postId) + { + this.postId = postId; + } + + @Override + public String toString() { + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) + .append("userId", getUserId()) + .append("postId", getPostId()) + .toString(); + } +} diff --git a/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/domain/SysUserRole.java b/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/domain/SysUserRole.java new file mode 100644 index 0000000..4d15810 --- /dev/null +++ b/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/domain/SysUserRole.java @@ -0,0 +1,46 @@ +package com.ruoyi.system.domain; + +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; + +/** + * 用户和角色关联 sys_user_role + * + * @author ruoyi + */ +public class SysUserRole +{ + /** 用户ID */ + private Long userId; + + /** 角色ID */ + private Long roleId; + + public Long getUserId() + { + return userId; + } + + public void setUserId(Long userId) + { + this.userId = userId; + } + + public Long getRoleId() + { + return roleId; + } + + public void setRoleId(Long roleId) + { + this.roleId = roleId; + } + + @Override + public String toString() { + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) + .append("userId", getUserId()) + .append("roleId", getRoleId()) + .toString(); + } +} diff --git a/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/domain/vo/MetaVo.java b/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/domain/vo/MetaVo.java new file mode 100644 index 0000000..a5d5fdc --- /dev/null +++ b/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/domain/vo/MetaVo.java @@ -0,0 +1,106 @@ +package com.ruoyi.system.domain.vo; + +import com.ruoyi.common.utils.StringUtils; + +/** + * 路由显示信息 + * + * @author ruoyi + */ +public class MetaVo +{ + /** + * 设置该路由在侧边栏和面包屑中展示的名字 + */ + private String title; + + /** + * 设置该路由的图标,对应路径src/assets/icons/svg + */ + private String icon; + + /** + * 设置为true,则不会被 缓存 + */ + private boolean noCache; + + /** + * 内链地址(http(s)://开头) + */ + private String link; + + public MetaVo() + { + } + + public MetaVo(String title, String icon) + { + this.title = title; + this.icon = icon; + } + + public MetaVo(String title, String icon, boolean noCache) + { + this.title = title; + this.icon = icon; + this.noCache = noCache; + } + + public MetaVo(String title, String icon, String link) + { + this.title = title; + this.icon = icon; + this.link = link; + } + + public MetaVo(String title, String icon, boolean noCache, String link) + { + this.title = title; + this.icon = icon; + this.noCache = noCache; + if (StringUtils.ishttp(link)) + { + this.link = link; + } + } + + public boolean isNoCache() + { + return noCache; + } + + public void setNoCache(boolean noCache) + { + this.noCache = noCache; + } + + public String getTitle() + { + return title; + } + + public void setTitle(String title) + { + this.title = title; + } + + public String getIcon() + { + return icon; + } + + public void setIcon(String icon) + { + this.icon = icon; + } + + public String getLink() + { + return link; + } + + public void setLink(String link) + { + this.link = link; + } +} diff --git a/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/domain/vo/RouterVo.java b/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/domain/vo/RouterVo.java new file mode 100644 index 0000000..1c05d34 --- /dev/null +++ b/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/domain/vo/RouterVo.java @@ -0,0 +1,149 @@ +package com.ruoyi.system.domain.vo; + +import com.fasterxml.jackson.annotation.JsonInclude; + +import java.util.List; + +/** + * 路由配置信息 + * + * @author ruoyi + */ +@JsonInclude(JsonInclude.Include.NON_EMPTY) +public class RouterVo +{ + /** + * 路由名字 + */ + private String name; + + /** + * 路由地址 + */ + private String path; + + /** + * 是否隐藏路由,当设置 true 的时候该路由不会再侧边栏出现 + */ + private boolean hidden; + + /** + * 重定向地址,当设置 noRedirect 的时候该路由在面包屑导航中不可被点击 + */ + private String redirect; + + /** + * 组件地址 + */ + private String component; + + /** + * 路由参数:如 {"id": 1, "name": "ry"} + */ + private String query; + + /** + * 当你一个路由下面的 children 声明的路由大于1个时,自动会变成嵌套的模式--如组件页面 + */ + private Boolean alwaysShow; + + /** + * 其他元素 + */ + private MetaVo meta; + + /** + * 子路由 + */ + private List children; + + public String getName() + { + return name; + } + + public void setName(String name) + { + this.name = name; + } + + public String getPath() + { + return path; + } + + public void setPath(String path) + { + this.path = path; + } + + public boolean getHidden() + { + return hidden; + } + + public void setHidden(boolean hidden) + { + this.hidden = hidden; + } + + public String getRedirect() + { + return redirect; + } + + public void setRedirect(String redirect) + { + this.redirect = redirect; + } + + public String getComponent() + { + return component; + } + + public void setComponent(String component) + { + this.component = component; + } + + public String getQuery() + { + return query; + } + + public void setQuery(String query) + { + this.query = query; + } + + public Boolean getAlwaysShow() + { + return alwaysShow; + } + + public void setAlwaysShow(Boolean alwaysShow) + { + this.alwaysShow = alwaysShow; + } + + public MetaVo getMeta() + { + return meta; + } + + public void setMeta(MetaVo meta) + { + this.meta = meta; + } + + public List getChildren() + { + return children; + } + + public void setChildren(List children) + { + this.children = children; + } +} diff --git a/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysConfigMapper.java b/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysConfigMapper.java new file mode 100644 index 0000000..43b3353 --- /dev/null +++ b/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysConfigMapper.java @@ -0,0 +1,72 @@ +package com.ruoyi.system.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.ruoyi.system.domain.SysConfig; +import org.apache.ibatis.annotations.Mapper; + +import java.util.List; + +/** + * 参数配置 数据层 + * + * @author ruoyi + */ +@Mapper +public interface SysConfigMapper extends BaseMapper +{ + /** + * 查询参数配置信息 + * + * @param config 参数配置信息 + * @return 参数配置信息 + */ + public SysConfig selectConfig(SysConfig config); + + /** + * 查询参数配置列表 + * + * @param config 参数配置信息 + * @return 参数配置集合 + */ + public List selectConfigList(SysConfig config); + + /** + * 根据键名查询参数配置信息 + * + * @param configKey 参数键名 + * @return 参数配置信息 + */ + public SysConfig checkConfigKeyUnique(String configKey); + + /** + * 新增参数配置 + * + * @param config 参数配置信息 + * @return 结果 + */ + public int insertConfig(SysConfig config); + + /** + * 修改参数配置 + * + * @param config 参数配置信息 + * @return 结果 + */ + public int updateConfig(SysConfig config); + + /** + * 删除参数配置 + * + * @param configId 参数ID + * @return 结果 + */ + public int deleteConfigById(Long configId); + + /** + * 批量删除参数信息 + * + * @param configIds 需要删除的参数ID + * @return 结果 + */ + public int deleteConfigByIds(Long[] configIds); +} diff --git a/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysDataRuleMapper.java b/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysDataRuleMapper.java new file mode 100644 index 0000000..ab1a4c5 --- /dev/null +++ b/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysDataRuleMapper.java @@ -0,0 +1,21 @@ +package com.ruoyi.system.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.ruoyi.common.core.domain.entity.SysDataRule; +import org.apache.ibatis.annotations.Mapper; + +/** + * All rights Reserved, Designed By www.sunseagear.com + * + * @version V1.0 + * @package sys + * @title: 数据权限表控制器 + * @description: 数据权限表控制器 + * @author: 未知 + * @date: 2019-11-29 06:05:01 + * @copyright: www.sunseagear.com Inc. All rights reserved. + */ +@Mapper +public interface SysDataRuleMapper extends BaseMapper { + +} diff --git a/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysDeptMapper.java b/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysDeptMapper.java new file mode 100644 index 0000000..3f8139f --- /dev/null +++ b/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysDeptMapper.java @@ -0,0 +1,119 @@ +package com.ruoyi.system.mapper; + +import com.ruoyi.common.core.domain.entity.SysDept; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * 部门管理 数据层 + * + * @author ruoyi + */ +public interface SysDeptMapper +{ + /** + * 查询部门管理数据 + * + * @param dept 部门信息 + * @return 部门信息集合 + */ + public List selectDeptList(SysDept dept); + + /** + * 根据角色ID查询部门树信息 + * + * @param roleId 角色ID + * @param deptCheckStrictly 部门树选择项是否关联显示 + * @return 选中部门列表 + */ + public List selectDeptListByRoleId(@Param("roleId") Long roleId, @Param("deptCheckStrictly") boolean deptCheckStrictly); + + /** + * 根据部门ID查询信息 + * + * @param deptId 部门ID + * @return 部门信息 + */ + public SysDept selectDeptById(String deptId); + + /** + * 根据ID查询所有子部门 + * + * @param deptId 部门ID + * @return 部门列表 + */ + public List selectChildrenDeptById(String deptId); + + /** + * 根据ID查询所有子部门(正常状态) + * + * @param deptId 部门ID + * @return 子部门数 + */ + public int selectNormalChildrenDeptById(String deptId); + + /** + * 是否存在子节点 + * + * @param deptId 部门ID + * @return 结果 + */ + public int hasChildByDeptId(String deptId); + + /** + * 查询部门是否存在用户 + * + * @param deptId 部门ID + * @return 结果 + */ + public int checkDeptExistUser(String deptId); + + /** + * 校验部门名称是否唯一 + * + * @param deptName 部门名称 + * @param parentId 父部门ID + * @return 结果 + */ + public SysDept checkDeptNameUnique(@Param("deptName") String deptName, @Param("parentId") String parentId); + + /** + * 新增部门信息 + * + * @param dept 部门信息 + * @return 结果 + */ + public int insertDept(SysDept dept); + + /** + * 修改部门信息 + * + * @param dept 部门信息 + * @return 结果 + */ + public int updateDept(SysDept dept); + + /** + * 修改所在部门正常状态 + * + * @param deptIds 部门ID组 + */ + public void updateDeptStatusNormal(String[] deptIds); + + /** + * 修改子元素关系 + * + * @param depts 子元素 + * @return 结果 + */ + public int updateDeptChildren(@Param("depts") List depts); + + /** + * 删除部门管理信息 + * + * @param deptId 部门ID + * @return 结果 + */ + public int deleteDeptById(String deptId); +} diff --git a/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysDictDataMapper.java b/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysDictDataMapper.java new file mode 100644 index 0000000..1ccce26 --- /dev/null +++ b/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysDictDataMapper.java @@ -0,0 +1,96 @@ +package com.ruoyi.system.mapper; + +import com.ruoyi.common.core.domain.entity.SysDictData; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * 字典表 数据层 + * + * @author ruoyi + */ +public interface SysDictDataMapper +{ + /** + * 根据条件分页查询字典数据 + * + * @param dictData 字典数据信息 + * @return 字典数据集合信息 + */ + public List selectDictDataList(SysDictData dictData); + + /** + * 根据字典类型查询字典数据 + * + * @param dictType 字典类型 + * @return 字典数据集合信息 + */ + public List selectDictDataByType(String dictType); + + /** + * 根据字典类型和字典键值查询字典数据信息 + * + * @param dictType 字典类型 + * @param dictValue 字典键值 + * @return 字典标签 + */ + public String selectDictLabel(@Param("dictType") String dictType, @Param("dictValue") String dictValue); + + /** + * 根据字典数据ID查询信息 + * + * @param dictCode 字典数据ID + * @return 字典数据 + */ + public SysDictData selectDictDataById(Long dictCode); + + /** + * 查询字典数据 + * + * @param dictType 字典类型 + * @return 字典数据 + */ + public int countDictDataByType(String dictType); + + /** + * 通过字典ID删除字典数据信息 + * + * @param dictCode 字典数据ID + * @return 结果 + */ + public int deleteDictDataById(Long dictCode); + + /** + * 批量删除字典数据信息 + * + * @param dictCodes 需要删除的字典数据ID + * @return 结果 + */ + public int deleteDictDataByIds(Long[] dictCodes); + + /** + * 新增字典数据信息 + * + * @param dictData 字典数据信息 + * @return 结果 + */ + public int insertDictData(SysDictData dictData); + + /** + * 修改字典数据信息 + * + * @param dictData 字典数据信息 + * @return 结果 + */ + public int updateDictData(SysDictData dictData); + + /** + * 同步修改字典类型 + * + * @param oldDictType 旧字典类型 + * @param newDictType 新旧字典类型 + * @return 结果 + */ + public int updateDictDataType(@Param("oldDictType") String oldDictType, @Param("newDictType") String newDictType); +} diff --git a/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysDictTypeMapper.java b/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysDictTypeMapper.java new file mode 100644 index 0000000..2723484 --- /dev/null +++ b/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysDictTypeMapper.java @@ -0,0 +1,86 @@ +package com.ruoyi.system.mapper; + +import com.ruoyi.common.core.domain.entity.SysDictType; +import org.apache.ibatis.annotations.Mapper; + +import java.util.List; + +/** + * 字典表 数据层 + * + * @author ruoyi + */ +@Mapper +public interface SysDictTypeMapper +{ + /** + * 根据条件分页查询字典类型 + * + * @param dictType 字典类型信息 + * @return 字典类型集合信息 + */ + public List selectDictTypeList(SysDictType dictType); + + /** + * 根据所有字典类型 + * + * @return 字典类型集合信息 + */ + public List selectDictTypeAll(); + + /** + * 根据字典类型ID查询信息 + * + * @param dictId 字典类型ID + * @return 字典类型 + */ + public SysDictType selectDictTypeById(Long dictId); + + /** + * 根据字典类型查询信息 + * + * @param dictType 字典类型 + * @return 字典类型 + */ + public SysDictType selectDictTypeByType(String dictType); + + /** + * 通过字典ID删除字典信息 + * + * @param dictId 字典ID + * @return 结果 + */ + public int deleteDictTypeById(Long dictId); + + /** + * 批量删除字典类型信息 + * + * @param dictIds 需要删除的字典ID + * @return 结果 + */ + public int deleteDictTypeByIds(Long[] dictIds); + + /** + * 新增字典类型信息 + * + * @param dictType 字典类型信息 + * @return 结果 + */ + public int insertDictType(SysDictType dictType); + + /** + * 修改字典类型信息 + * + * @param dictType 字典类型信息 + * @return 结果 + */ + public int updateDictType(SysDictType dictType); + + /** + * 校验字典类型称是否唯一 + * + * @param dictType 字典类型 + * @return 结果 + */ + public SysDictType checkDictTypeUnique(String dictType); +} diff --git a/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysLogininforMapper.java b/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysLogininforMapper.java new file mode 100644 index 0000000..157c60e --- /dev/null +++ b/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysLogininforMapper.java @@ -0,0 +1,43 @@ +package com.ruoyi.system.mapper; + +import com.ruoyi.system.domain.SysLogininfor; + +import java.util.List; + +/** + * 系统访问日志情况信息 数据层 + * + * @author ruoyi + */ +public interface SysLogininforMapper +{ + /** + * 新增系统登录日志 + * + * @param logininfor 访问日志对象 + */ + public void insertLogininfor(SysLogininfor logininfor); + + /** + * 查询系统登录日志集合 + * + * @param logininfor 访问日志对象 + * @return 登录记录集合 + */ + public List selectLogininforList(SysLogininfor logininfor); + + /** + * 批量删除系统登录日志 + * + * @param infoIds 需要删除的登录日志ID + * @return 结果 + */ + public int deleteLogininforByIds(Long[] infoIds); + + /** + * 清空系统登录日志 + * + * @return 结果 + */ + public int cleanLogininfor(); +} diff --git a/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysMenuMapper.java b/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysMenuMapper.java new file mode 100644 index 0000000..ee141e0 --- /dev/null +++ b/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysMenuMapper.java @@ -0,0 +1,125 @@ +package com.ruoyi.system.mapper; + +import com.ruoyi.common.core.domain.entity.SysMenu; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * 菜单表 数据层 + * + * @author ruoyi + */ +public interface SysMenuMapper +{ + /** + * 查询系统菜单列表 + * + * @param menu 菜单信息 + * @return 菜单列表 + */ + public List selectMenuList(SysMenu menu); + + /** + * 根据用户所有权限 + * + * @return 权限列表 + */ + public List selectMenuPerms(); + + /** + * 根据用户查询系统菜单列表 + * + * @param menu 菜单信息 + * @return 菜单列表 + */ + public List selectMenuListByUserId(SysMenu menu); + + /** + * 根据用户ID查询权限 + * + * @param userId 用户ID + * @return 权限列表 + */ + public List selectMenuPermsByUserId(Long userId); + + /** + * 根据用户ID查询菜单 + * + * @return 菜单列表 + */ + public List selectMenuTreeAll(); + + /** + * 根据用户ID查询菜单 + * + * @param userId 用户ID + * @return 菜单列表 + */ + public List selectMenuTreeByUserId(Long userId); + + /** + * 根据角色ID查询菜单树信息 + * + * @param roleId 角色ID + * @param menuCheckStrictly 菜单树选择项是否关联显示 + * @return 选中菜单列表 + */ + public List selectMenuListByRoleId(@Param("roleId") Long roleId, @Param("menuCheckStrictly") boolean menuCheckStrictly); + + /** + * 根据菜单ID查询信息 + * + * @param menuId 菜单ID + * @return 菜单信息 + */ + public SysMenu selectMenuById(Long menuId); + + /** + * 是否存在菜单子节点 + * + * @param menuId 菜单ID + * @return 结果 + */ + public int hasChildByMenuId(Long menuId); + + /** + * 删除子菜单 + * @param menuId + */ + void deleteChildByMenuId(Long menuId); + + /** + * 新增菜单信息 + * + * @param menu 菜单信息 + * @return 结果 + */ + public int insertMenu(SysMenu menu); + + /** + * 修改菜单信息 + * + * @param menu 菜单信息 + * @return 结果 + */ + public int updateMenu(SysMenu menu); + + /** + * 删除菜单管理信息 + * + * @param menuId 菜单ID + * @return 结果 + */ + public int deleteMenuById(Long menuId); + + /** + * 校验菜单名称是否唯一 + * + * @param menuName 菜单名称 + * @param parentId 父菜单ID + * @return 结果 + */ + public SysMenu checkMenuNameUnique(@Param("menuName") String menuName, @Param("parentId") Long parentId); + +} diff --git a/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysNoticeMapper.java b/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysNoticeMapper.java new file mode 100644 index 0000000..6e664e3 --- /dev/null +++ b/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysNoticeMapper.java @@ -0,0 +1,61 @@ +package com.ruoyi.system.mapper; + +import com.ruoyi.system.domain.SysNotice; + +import java.util.List; + +/** + * 通知公告表 数据层 + * + * @author ruoyi + */ +public interface SysNoticeMapper +{ + /** + * 查询公告信息 + * + * @param noticeId 公告ID + * @return 公告信息 + */ + public SysNotice selectNoticeById(Long noticeId); + + /** + * 查询公告列表 + * + * @param notice 公告信息 + * @return 公告集合 + */ + public List selectNoticeList(SysNotice notice); + + /** + * 新增公告 + * + * @param notice 公告信息 + * @return 结果 + */ + public int insertNotice(SysNotice notice); + + /** + * 修改公告 + * + * @param notice 公告信息 + * @return 结果 + */ + public int updateNotice(SysNotice notice); + + /** + * 批量删除公告 + * + * @param noticeId 公告ID + * @return 结果 + */ + public int deleteNoticeById(Long noticeId); + + /** + * 批量删除公告信息 + * + * @param noticeIds 需要删除的公告ID + * @return 结果 + */ + public int deleteNoticeByIds(Long[] noticeIds); +} diff --git a/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysOperLogMapper.java b/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysOperLogMapper.java new file mode 100644 index 0000000..4a06458 --- /dev/null +++ b/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysOperLogMapper.java @@ -0,0 +1,49 @@ +package com.ruoyi.system.mapper; + +import com.ruoyi.system.domain.SysOperLog; + +import java.util.List; + +/** + * 操作日志 数据层 + * + * @author ruoyi + */ +public interface SysOperLogMapper +{ + /** + * 新增操作日志 + * + * @param operLog 操作日志对象 + */ + public void insertOperlog(SysOperLog operLog); + + /** + * 查询系统操作日志集合 + * + * @param operLog 操作日志对象 + * @return 操作日志集合 + */ + public List selectOperLogList(SysOperLog operLog); + + /** + * 批量删除系统操作日志 + * + * @param operIds 需要删除的操作日志ID + * @return 结果 + */ + public int deleteOperLogByIds(Long[] operIds); + + /** + * 查询操作日志详细 + * + * @param operId 操作ID + * @return 操作日志对象 + */ + public SysOperLog selectOperLogById(Long operId); + + /** + * 清空操作日志 + */ + public void cleanOperLog(); +} diff --git a/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysPostMapper.java b/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysPostMapper.java new file mode 100644 index 0000000..dfcb617 --- /dev/null +++ b/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysPostMapper.java @@ -0,0 +1,100 @@ +package com.ruoyi.system.mapper; + +import com.ruoyi.system.domain.SysPost; + +import java.util.List; + +/** + * 岗位信息 数据层 + * + * @author ruoyi + */ +public interface SysPostMapper +{ + /** + * 查询岗位数据集合 + * + * @param post 岗位信息 + * @return 岗位数据集合 + */ + public List selectPostList(SysPost post); + + /** + * 查询所有岗位 + * + * @return 岗位列表 + */ + public List selectPostAll(); + + /** + * 通过岗位ID查询岗位信息 + * + * @param postId 岗位ID + * @return 角色对象信息 + */ + public SysPost selectPostById(Long postId); + + /** + * 根据用户ID获取岗位选择框列表 + * + * @param userId 用户ID + * @return 选中岗位ID列表 + */ + public List selectPostListByUserId(Long userId); + + /** + * 查询用户所属岗位组 + * + * @param userName 用户名 + * @return 结果 + */ + public List selectPostsByUserName(String userName); + + /** + * 删除岗位信息 + * + * @param postId 岗位ID + * @return 结果 + */ + public int deletePostById(Long postId); + + /** + * 批量删除岗位信息 + * + * @param postIds 需要删除的岗位ID + * @return 结果 + */ + public int deletePostByIds(Long[] postIds); + + /** + * 修改岗位信息 + * + * @param post 岗位信息 + * @return 结果 + */ + public int updatePost(SysPost post); + + /** + * 新增岗位信息 + * + * @param post 岗位信息 + * @return 结果 + */ + public int insertPost(SysPost post); + + /** + * 校验岗位名称 + * + * @param postName 岗位名称 + * @return 结果 + */ + public SysPost checkPostNameUnique(String postName); + + /** + * 校验岗位编码 + * + * @param postCode 岗位编码 + * @return 结果 + */ + public SysPost checkPostCodeUnique(String postCode); +} diff --git a/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysRoleDataRuleMapper.java b/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysRoleDataRuleMapper.java new file mode 100644 index 0000000..3ff7352 --- /dev/null +++ b/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysRoleDataRuleMapper.java @@ -0,0 +1,21 @@ +package com.ruoyi.system.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.ruoyi.system.domain.SysRoleDataRule; +import org.apache.ibatis.annotations.Mapper; + +/** + * All rights Reserved, Designed By www.sunseagear.com + * + * @version V1.0 + * @package sys + * @title: 角色数据权限关联表控制器 + * @description: 角色数据权限关联表控制器 + * @author: 未知 + * @date: 2019-12-03 13:03:38 + * @copyright: www.sunseagear.com Inc. All rights reserved. + */ +@Mapper +public interface SysRoleDataRuleMapper extends BaseMapper { + +} diff --git a/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysRoleDeptMapper.java b/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysRoleDeptMapper.java new file mode 100644 index 0000000..b123404 --- /dev/null +++ b/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysRoleDeptMapper.java @@ -0,0 +1,45 @@ +package com.ruoyi.system.mapper; + +import com.ruoyi.system.domain.SysRoleDept; + +import java.util.List; + +/** + * 角色与部门关联表 数据层 + * + * @author ruoyi + */ +public interface SysRoleDeptMapper +{ + /** + * 通过角色ID删除角色和部门关联 + * + * @param roleId 角色ID + * @return 结果 + */ + public int deleteRoleDeptByRoleId(Long roleId); + + /** + * 批量删除角色部门关联信息 + * + * @param ids 需要删除的数据ID + * @return 结果 + */ + public int deleteRoleDept(Long[] ids); + + /** + * 查询部门使用数量 + * + * @param deptId 部门ID + * @return 结果 + */ + public int selectCountRoleDeptByDeptId(Long deptId); + + /** + * 批量新增角色部门信息 + * + * @param roleDeptList 角色部门列表 + * @return 结果 + */ + public int batchRoleDept(List roleDeptList); +} diff --git a/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysRoleMapper.java b/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysRoleMapper.java new file mode 100644 index 0000000..7fd980c --- /dev/null +++ b/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysRoleMapper.java @@ -0,0 +1,108 @@ +package com.ruoyi.system.mapper; + +import com.ruoyi.common.core.domain.entity.SysRole; + +import java.util.List; + +/** + * 角色表 数据层 + * + * @author ruoyi + */ +public interface SysRoleMapper +{ + /** + * 根据条件分页查询角色数据 + * + * @param role 角色信息 + * @return 角色数据集合信息 + */ + public List selectRoleList(SysRole role); + + /** + * 根据用户ID查询角色 + * + * @param userId 用户ID + * @return 角色列表 + */ + public List selectRolePermissionByUserId(Long userId); + + /** + * 查询所有角色 + * + * @return 角色列表 + */ + public List selectRoleAll(); + + /** + * 根据用户ID获取角色选择框列表 + * + * @param userId 用户ID + * @return 选中角色ID列表 + */ + public List selectRoleListByUserId(Long userId); + + /** + * 通过角色ID查询角色 + * + * @param roleId 角色ID + * @return 角色对象信息 + */ + public SysRole selectRoleById(Long roleId); + + /** + * 根据用户ID查询角色 + * + * @param userName 用户名 + * @return 角色列表 + */ + public List selectRolesByUserName(String userName); + + /** + * 校验角色名称是否唯一 + * + * @param roleName 角色名称 + * @return 角色信息 + */ + public SysRole checkRoleNameUnique(String roleName); + + /** + * 校验角色权限是否唯一 + * + * @param roleKey 角色权限 + * @return 角色信息 + */ + public SysRole checkRoleKeyUnique(String roleKey); + + /** + * 修改角色信息 + * + * @param role 角色信息 + * @return 结果 + */ + public int updateRole(SysRole role); + + /** + * 新增角色信息 + * + * @param role 角色信息 + * @return 结果 + */ + public int insertRole(SysRole role); + + /** + * 通过角色ID删除角色 + * + * @param roleId 角色ID + * @return 结果 + */ + public int deleteRoleById(Long roleId); + + /** + * 批量删除角色信息 + * + * @param roleIds 需要删除的角色ID + * @return 结果 + */ + public int deleteRoleByIds(Long[] roleIds); +} diff --git a/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysRoleMenuMapper.java b/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysRoleMenuMapper.java new file mode 100644 index 0000000..ce67eff --- /dev/null +++ b/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysRoleMenuMapper.java @@ -0,0 +1,45 @@ +package com.ruoyi.system.mapper; + +import com.ruoyi.system.domain.SysRoleMenu; + +import java.util.List; + +/** + * 角色与菜单关联表 数据层 + * + * @author ruoyi + */ +public interface SysRoleMenuMapper +{ + /** + * 查询菜单使用数量 + * + * @param menuId 菜单ID + * @return 结果 + */ + public int checkMenuExistRole(Long menuId); + + /** + * 通过角色ID删除角色和菜单关联 + * + * @param roleId 角色ID + * @return 结果 + */ + public int deleteRoleMenuByRoleId(Long roleId); + + /** + * 批量删除角色菜单关联信息 + * + * @param ids 需要删除的数据ID + * @return 结果 + */ + public int deleteRoleMenu(Long[] ids); + + /** + * 批量新增角色菜单信息 + * + * @param roleMenuList 角色菜单列表 + * @return 结果 + */ + public int batchRoleMenu(List roleMenuList); +} diff --git a/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysTenantMapper.java b/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysTenantMapper.java new file mode 100644 index 0000000..937807f --- /dev/null +++ b/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysTenantMapper.java @@ -0,0 +1,21 @@ +package com.ruoyi.system.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.ruoyi.common.core.domain.entity.SysTenant; +import org.apache.ibatis.annotations.Mapper; + +/** + * All rights Reserved, Designed By www.sunseagear.com + * + * @version V1.0 + * @package sys + * @title: 租户管理控制器 + * @description: 租户管理控制器 + * @author: 未知 + * @date: 2019-11-28 06:24:52 + * @copyright: www.sunseagear.com Inc. All rights reserved. + */ +@Mapper +public interface SysTenantMapper extends BaseMapper { + +} diff --git a/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysUserMapper.java b/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysUserMapper.java new file mode 100644 index 0000000..4792503 --- /dev/null +++ b/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysUserMapper.java @@ -0,0 +1,129 @@ +package com.ruoyi.system.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.ruoyi.common.core.domain.entity.SysUser; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * 用户表 数据层 + * + * @author ruoyi + */ +public interface SysUserMapper extends BaseMapper +{ + /** + * 根据条件分页查询用户列表 + * + * @param sysUser 用户信息 + * @return 用户信息集合信息 + */ + public List selectUserList(SysUser sysUser); + + /** + * 根据条件分页查询未已配用户角色列表 + * + * @param user 用户信息 + * @return 用户信息集合信息 + */ + public List selectAllocatedList(SysUser user); + + /** + * 根据条件分页查询未分配用户角色列表 + * + * @param user 用户信息 + * @return 用户信息集合信息 + */ + public List selectUnallocatedList(SysUser user); + + /** + * 通过用户名查询用户 + * + * @param userName 用户名 + * @return 用户对象信息 + */ + public SysUser selectUserByUserName(String userName); + + /** + * 通过用户ID查询用户 + * + * @param userId 用户ID + * @return 用户对象信息 + */ + public SysUser selectUserById(Long userId); + + /** + * 新增用户信息 + * + * @param user 用户信息 + * @return 结果 + */ + public int insertUser(SysUser user); + + /** + * 修改用户信息 + * + * @param user 用户信息 + * @return 结果 + */ + public int updateUser(SysUser user); + + /** + * 修改用户头像 + * + * @param userName 用户名 + * @param avatar 头像地址 + * @return 结果 + */ + public int updateUserAvatar(@Param("userName") String userName, @Param("avatar") String avatar); + + /** + * 重置用户密码 + * + * @param userName 用户名 + * @param password 密码 + * @return 结果 + */ + public int resetUserPwd(@Param("userName") String userName, @Param("password") String password); + + /** + * 通过用户ID删除用户 + * + * @param userId 用户ID + * @return 结果 + */ + public int deleteUserById(Long userId); + + /** + * 批量删除用户信息 + * + * @param userIds 需要删除的用户ID + * @return 结果 + */ + public int deleteUserByIds(Long[] userIds); + + /** + * 校验用户名称是否唯一 + * + * @param userName 用户名称 + * @return 结果 + */ + public int checkUserNameUnique(String userName); + + /** + * 校验手机号码是否唯一 + * + * @param phonenumber 手机号码 + * @return 结果 + */ + public SysUser checkPhoneUnique(String phonenumber); + + /** + * 校验email是否唯一 + * + * @param email 用户邮箱 + * @return 结果 + */ + public SysUser checkEmailUnique(String email); +} diff --git a/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysUserPostMapper.java b/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysUserPostMapper.java new file mode 100644 index 0000000..2118e59 --- /dev/null +++ b/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysUserPostMapper.java @@ -0,0 +1,45 @@ +package com.ruoyi.system.mapper; + +import com.ruoyi.system.domain.SysUserPost; + +import java.util.List; + +/** + * 用户与岗位关联表 数据层 + * + * @author ruoyi + */ +public interface SysUserPostMapper +{ + /** + * 通过用户ID删除用户和岗位关联 + * + * @param userId 用户ID + * @return 结果 + */ + public int deleteUserPostByUserId(Long userId); + + /** + * 通过岗位ID查询岗位使用数量 + * + * @param postId 岗位ID + * @return 结果 + */ + public int countUserPostById(Long postId); + + /** + * 批量删除用户和岗位关联 + * + * @param ids 需要删除的数据ID + * @return 结果 + */ + public int deleteUserPost(Long[] ids); + + /** + * 批量新增用户岗位信息 + * + * @param userPostList 用户角色列表 + * @return 结果 + */ + public int batchUserPost(List userPostList); +} diff --git a/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysUserRoleMapper.java b/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysUserRoleMapper.java new file mode 100644 index 0000000..d69a317 --- /dev/null +++ b/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysUserRoleMapper.java @@ -0,0 +1,63 @@ +package com.ruoyi.system.mapper; + +import com.ruoyi.system.domain.SysUserRole; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * 用户与角色关联表 数据层 + * + * @author ruoyi + */ +public interface SysUserRoleMapper +{ + /** + * 通过用户ID删除用户和角色关联 + * + * @param userId 用户ID + * @return 结果 + */ + public int deleteUserRoleByUserId(Long userId); + + /** + * 批量删除用户和角色关联 + * + * @param ids 需要删除的数据ID + * @return 结果 + */ + public int deleteUserRole(Long[] ids); + + /** + * 通过角色ID查询角色使用数量 + * + * @param roleId 角色ID + * @return 结果 + */ + public int countUserRoleByRoleId(Long roleId); + + /** + * 批量新增用户角色信息 + * + * @param userRoleList 用户角色列表 + * @return 结果 + */ + public int batchUserRole(List userRoleList); + + /** + * 删除用户和角色关联信息 + * + * @param userRole 用户和角色关联信息 + * @return 结果 + */ + public int deleteUserRoleInfo(SysUserRole userRole); + + /** + * 批量取消授权用户角色 + * + * @param roleId 角色ID + * @param userIds 需要删除的用户数据ID + * @return 结果 + */ + public int deleteUserRoleInfos(@Param("roleId") Long roleId, @Param("userIds") Long[] userIds); +} diff --git a/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/mapper/xml/SysConfigMapper.xml b/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/mapper/xml/SysConfigMapper.xml new file mode 100644 index 0000000..8b97906 --- /dev/null +++ b/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/mapper/xml/SysConfigMapper.xml @@ -0,0 +1,112 @@ + + + + + + + + + + + + + + + + + + select config_id, config_name, config_key, config_value, config_type, create_by, create_time, update_by, update_time, remark + from sys_config + + + + + + + and config_id = #{configId} + + + and config_key = #{configKey} + + + + + + + + + + + + insert into sys_config ( + config_name, + config_key, + config_value, + config_type, + create_by, + remark, + create_time + )values( + #{configName}, + #{configKey}, + #{configValue}, + #{configType}, + #{createBy}, + #{remark}, + sysdate() + ) + + + + update sys_config + + config_name = #{configName}, + config_key = #{configKey}, + config_value = #{configValue}, + config_type = #{configType}, + update_by = #{updateBy}, + remark = #{remark}, + update_time = sysdate() + + where config_id = #{configId} + + + + delete from sys_config where config_id = #{configId} + + + + delete from sys_config where config_id in + + #{configId} + + + + \ No newline at end of file diff --git a/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/mapper/xml/SysDeptMapper.xml b/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/mapper/xml/SysDeptMapper.xml new file mode 100644 index 0000000..f1a5684 --- /dev/null +++ b/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/mapper/xml/SysDeptMapper.xml @@ -0,0 +1,163 @@ + + + + + + + + + + + + + + + + + + + + + + + + + select d.dept_id, d.parent_id, d.ancestors, d.dept_name, d.order_num, d.leader, d.phone, d.email, d.status, d.del_flag, d.create_by, d.create_time,d.tenant_id + from sys_dept d + + + + + + + + + + + + + + + + + + + + insert into sys_dept( + dept_id, + parent_id, + dept_name, + ancestors, + order_num, + leader, + phone, + email, + status, + create_by, + tenant_id, + create_time + )values( + #{deptId}, + #{parentId}, + #{deptName}, + #{ancestors}, + #{orderNum}, + #{leader}, + #{phone}, + #{email}, + #{status}, + #{createBy}, + #{tenantId}, + sysdate() + ) + + + + update sys_dept + + parent_id = #{parentId}, + dept_name = #{deptName}, + ancestors = #{ancestors}, + order_num = #{orderNum}, + leader = #{leader}, + phone = #{phone}, + email = #{email}, + status = #{status}, + update_by = #{updateBy}, + update_time = sysdate() + + where dept_id = #{deptId} + + + + update sys_dept set ancestors = + + when #{item.deptId} then #{item.ancestors} + + where dept_id in + + #{item.deptId} + + + + + update sys_dept set status = '0' where dept_id in + + #{deptId} + + + + + update sys_dept set del_flag = '2' where dept_id = #{deptId} + + + diff --git a/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/mapper/xml/SysDictDataMapper.xml b/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/mapper/xml/SysDictDataMapper.xml new file mode 100644 index 0000000..f36945d --- /dev/null +++ b/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/mapper/xml/SysDictDataMapper.xml @@ -0,0 +1,136 @@ + + + + + + + + + + + + + + + + + + + + + + + + select dict_code, dict_sort, dict_label, dict_value, dict_type, css_class, list_class, is_default, status, create_by, create_time, remark, + images,code + from sys_dict_data + + + + + + + + + + + + + + delete from sys_dict_data where dict_code = #{dictCode} + + + + delete from sys_dict_data where dict_code in + + #{dictCode} + + + + + update sys_dict_data + + dict_sort = #{dictSort}, + dict_label = #{dictLabel}, + dict_value = #{dictValue}, + dict_type = #{dictType}, + css_class = #{cssClass}, + list_class = #{listClass}, + is_default = #{isDefault}, + status = #{status}, + remark = #{remark}, + update_by = #{updateBy}, + code = #{code}, + images = #{images}, + update_time = sysdate() + + where dict_code = #{dictCode} + + + + update sys_dict_data set dict_type = #{newDictType} where dict_type = #{oldDictType} + + + + insert into sys_dict_data( + dict_sort, + dict_label, + dict_value, + dict_type, + css_class, + list_class, + is_default, + status, + remark, + create_by, + code, + images, + create_time + )values( + #{dictSort}, + #{dictLabel}, + #{dictValue}, + #{dictType}, + #{cssClass}, + #{listClass}, + #{isDefault}, + #{status}, + #{remark}, + #{createBy}, + #{code}, + #{images}, + sysdate() + ) + + + \ No newline at end of file diff --git a/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/mapper/xml/SysDictTypeMapper.xml b/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/mapper/xml/SysDictTypeMapper.xml new file mode 100644 index 0000000..8fa53dc --- /dev/null +++ b/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/mapper/xml/SysDictTypeMapper.xml @@ -0,0 +1,105 @@ + + + + + + + + + + + + + + + + + select dict_id, dict_name, dict_type, status, create_by, create_time, remark + from sys_dict_type + + + + + + + + + + + + + + delete from sys_dict_type where dict_id = #{dictId} + + + + delete from sys_dict_type where dict_id in + + #{dictId} + + + + + update sys_dict_type + + dict_name = #{dictName}, + dict_type = #{dictType}, + status = #{status}, + remark = #{remark}, + update_by = #{updateBy}, + update_time = sysdate() + + where dict_id = #{dictId} + + + + insert into sys_dict_type( + dict_name, + dict_type, + status, + remark, + create_by, + create_time + )values( + #{dictName}, + #{dictType}, + #{status}, + #{remark}, + #{createBy}, + sysdate() + ) + + + diff --git a/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/mapper/xml/SysLogininforMapper.xml b/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/mapper/xml/SysLogininforMapper.xml new file mode 100644 index 0000000..b8178fa --- /dev/null +++ b/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/mapper/xml/SysLogininforMapper.xml @@ -0,0 +1,57 @@ + + + + + + + + + + + + + + + + + + insert into sys_logininfor (user_name, status, ipaddr, login_location, browser, os, msg, login_time) + values (#{userName}, #{status}, #{ipaddr}, #{loginLocation}, #{browser}, #{os}, #{msg}, sysdate()) + + + + + + delete from sys_logininfor where info_id in + + #{infoId} + + + + + truncate table sys_logininfor + + + \ No newline at end of file diff --git a/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/mapper/xml/SysMenuMapper.xml b/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/mapper/xml/SysMenuMapper.xml new file mode 100644 index 0000000..c7a77bb --- /dev/null +++ b/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/mapper/xml/SysMenuMapper.xml @@ -0,0 +1,206 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + select menu_id, menu_name, parent_id, order_num, path, component, query, is_frame, is_cache, menu_type, visible, status, ifnull(perms,'') as perms, icon, create_time, tenant_id + from sys_menu + + + + + + + + + + + + + + + + + + + + + + + + + + update sys_menu + + menu_name = #{menuName}, + parent_id = #{parentId}, + order_num = #{orderNum}, + path = #{path}, + component = #{component}, + query = #{query}, + is_frame = #{isFrame}, + is_cache = #{isCache}, + menu_type = #{menuType}, + visible = #{visible}, + status = #{status}, + perms = #{perms}, + icon = #{icon}, + remark = #{remark}, + update_by = #{updateBy}, + update_time = sysdate() + + where menu_id = #{menuId} + + + + insert into sys_menu( + menu_id, + parent_id, + menu_name, + order_num, + path, + component, + query, + is_frame, + is_cache, + menu_type, + visible, + status, + perms, + icon, + remark, + create_by, + tenant_id, + create_time + )values( + #{menuId}, + #{parentId}, + #{menuName}, + #{orderNum}, + #{path}, + #{component}, + #{query}, + #{isFrame}, + #{isCache}, + #{menuType}, + #{visible}, + #{status}, + #{perms}, + #{icon}, + #{remark}, + #{createBy}, + #{tenantId}, + sysdate() + ) + + + + delete from sys_menu where menu_id = #{menuId} + + + diff --git a/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/mapper/xml/SysNoticeMapper.xml b/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/mapper/xml/SysNoticeMapper.xml new file mode 100644 index 0000000..5040ece --- /dev/null +++ b/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/mapper/xml/SysNoticeMapper.xml @@ -0,0 +1,110 @@ + + + + + + + + + + + + + + + + + + + + select notice_id, notice_title, notice_type, cast(notice_content as char) as notice_content, status, create_by, create_time, update_by, update_time, remark, tenant_id + from sys_notice + + + + + + + + insert into sys_notice ( + notice_title, + notice_type, + notice_content, + status, + remark, + create_by, + tenant_id, + create_time + )values( + #{noticeTitle}, + #{noticeType}, + #{noticeContent}, + #{status}, + #{remark}, + #{createBy}, + #{tenantId}, + sysdate() + ) + + + + update sys_notice + + notice_title = #{noticeTitle}, + notice_type = #{noticeType}, + notice_content = #{noticeContent}, + status = #{status}, + update_by = #{updateBy}, + update_time = sysdate() + + where notice_id = #{noticeId} + + + + delete from sys_notice where notice_id = #{noticeId} + + + + delete from sys_notice where notice_id in + + #{noticeId} + + + + diff --git a/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/mapper/xml/SysOperLogMapper.xml b/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/mapper/xml/SysOperLogMapper.xml new file mode 100644 index 0000000..f017ef8 --- /dev/null +++ b/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/mapper/xml/SysOperLogMapper.xml @@ -0,0 +1,83 @@ + + + + + + + + + + + + + + + + + + + + + + + + + select oper_id, title, business_type, method, request_method, operator_type, oper_name, dept_name, oper_url, oper_ip, oper_location, oper_param, json_result, status, error_msg, oper_time + from sys_oper_log + + + + insert into sys_oper_log(title, business_type, method, request_method, operator_type, oper_name, dept_name, oper_url, oper_ip, oper_location, oper_param, json_result, status, error_msg, oper_time) + values (#{title}, #{businessType}, #{method}, #{requestMethod}, #{operatorType}, #{operName}, #{deptName}, #{operUrl}, #{operIp}, #{operLocation}, #{operParam}, #{jsonResult}, #{status}, #{errorMsg}, sysdate()) + + + + + + delete from sys_oper_log where oper_id in + + #{operId} + + + + + + + truncate table sys_oper_log + + + \ No newline at end of file diff --git a/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/mapper/xml/SysPostMapper.xml b/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/mapper/xml/SysPostMapper.xml new file mode 100644 index 0000000..6024a9e --- /dev/null +++ b/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/mapper/xml/SysPostMapper.xml @@ -0,0 +1,128 @@ + + + + + + + + + + + + + + + + + + + + select post_id, post_code, post_name, post_sort, status, create_by, create_time, remark, tenant_id + from sys_post + + + + + + + + + + + + + + + + + + update sys_post + + post_code = #{postCode}, + post_name = #{postName}, + post_sort = #{postSort}, + status = #{status}, + remark = #{remark}, + update_by = #{updateBy}, + update_time = sysdate() + + where post_id = #{postId} + + + + insert into sys_post( + post_id, + post_code, + post_name, + post_sort, + status, + remark, + create_by, + tenant_id, + create_time + )values( + #{postId}, + #{postCode}, + #{postName}, + #{postSort}, + #{status}, + #{remark}, + #{createBy}, + #{tenantId}, + sysdate() + ) + + + + delete from sys_post where post_id = #{postId} + + + + delete from sys_post where post_id in + + #{postId} + + + + diff --git a/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/mapper/xml/SysRoleDeptMapper.xml b/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/mapper/xml/SysRoleDeptMapper.xml new file mode 100644 index 0000000..7c4139b --- /dev/null +++ b/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/mapper/xml/SysRoleDeptMapper.xml @@ -0,0 +1,34 @@ + + + + + + + + + + + delete from sys_role_dept where role_id=#{roleId} + + + + + + delete from sys_role_dept where role_id in + + #{roleId} + + + + + insert into sys_role_dept(role_id, dept_id) values + + (#{item.roleId},#{item.deptId}) + + + + \ No newline at end of file diff --git a/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/mapper/xml/SysRoleMapper.xml b/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/mapper/xml/SysRoleMapper.xml new file mode 100644 index 0000000..0e829b7 --- /dev/null +++ b/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/mapper/xml/SysRoleMapper.xml @@ -0,0 +1,158 @@ + + + + + + + + + + + + + + + + + + + + + + + + select distinct r.role_id, r.role_name, r.role_key, r.role_sort, r.data_scope, r.menu_check_strictly, r.dept_check_strictly, r.tenant_id, + r.status, r.del_flag, r.create_time, r.remark + from sys_role r + left join sys_user_role ur on ur.role_id = r.role_id + left join sys_user u on u.user_id = ur.user_id + left join sys_dept d on u.dept_id = d.dept_id + + + + + + + + + + + + + + + + + + + + insert into sys_role( + role_id, + role_name, + role_key, + role_sort, + data_scope, + menu_check_strictly, + dept_check_strictly, + status, + remark, + create_by, + tenant_id, + create_time + )values( + #{roleId}, + #{roleName}, + #{roleKey}, + #{roleSort}, + #{dataScope}, + #{menuCheckStrictly}, + #{deptCheckStrictly}, + #{status}, + #{remark}, + #{createBy}, + #{tenantId}, + sysdate() + ) + + + + update sys_role + + role_name = #{roleName}, + role_key = #{roleKey}, + role_sort = #{roleSort}, + data_scope = #{dataScope}, + menu_check_strictly = #{menuCheckStrictly}, + dept_check_strictly = #{deptCheckStrictly}, + status = #{status}, + remark = #{remark}, + update_by = #{updateBy}, + update_time = sysdate() + + where role_id = #{roleId} + + + + update sys_role set del_flag = '2' where role_id = #{roleId} + + + + update sys_role set del_flag = '2' where role_id in + + #{roleId} + + + + diff --git a/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/mapper/xml/SysRoleMenuMapper.xml b/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/mapper/xml/SysRoleMenuMapper.xml new file mode 100644 index 0000000..cb60a85 --- /dev/null +++ b/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/mapper/xml/SysRoleMenuMapper.xml @@ -0,0 +1,34 @@ + + + + + + + + + + + + + delete from sys_role_menu where role_id=#{roleId} + + + + delete from sys_role_menu where role_id in + + #{roleId} + + + + + insert into sys_role_menu(role_id, menu_id) values + + (#{item.roleId},#{item.menuId}) + + + + \ No newline at end of file diff --git a/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/mapper/xml/SysTenantMapper.xml b/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/mapper/xml/SysTenantMapper.xml new file mode 100644 index 0000000..40177a8 --- /dev/null +++ b/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/mapper/xml/SysTenantMapper.xml @@ -0,0 +1,39 @@ + + + + + + a.*, + b.user_name as "userName" + + + left join sys_user b on b.user_id = a.user_id + + + + diff --git a/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/mapper/xml/SysUserMapper.xml b/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/mapper/xml/SysUserMapper.xml new file mode 100644 index 0000000..d3afebd --- /dev/null +++ b/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/mapper/xml/SysUserMapper.xml @@ -0,0 +1,229 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + select u.user_id,u.user_type, u.dept_id, u.user_name, u.nick_name, u.email, u.avatar, u.phonenumber, u.password, u.sex, u.status, u.del_flag, u.login_ip, u.login_date, u.create_by, u.create_time, u.remark,u.tenant_id, + d.dept_id, d.parent_id, d.dept_name, d.order_num, d.leader, d.status as dept_status, + r.role_id, r.role_name, r.role_key, r.role_sort, r.data_scope, r.status as role_status + from sys_user u + left join sys_dept d on u.dept_id = d.dept_id + left join sys_user_role ur on u.user_id = ur.user_id + left join sys_role r on r.role_id = ur.role_id + + + + + + + + + + + + + + + + + + + + insert into sys_user( + user_id, + dept_id, + user_name, + nick_name, + email, + avatar, + phonenumber, + sex, + password, + status, + create_by, + remark, + tenant_id, + user_type, + create_time + )values( + #{userId}, + #{deptId}, + #{userName}, + #{nickName}, + #{email}, + #{avatar}, + #{phonenumber}, + #{sex}, + #{password}, + #{status}, + #{createBy}, + #{remark}, + #{tenantId}, + #{userType}, + sysdate() + ) + + + + update sys_user + + dept_id = #{deptId}, + user_name = #{userName}, + nick_name = #{nickName}, + email = #{email}, + phonenumber = #{phonenumber}, + sex = #{sex}, + avatar = #{avatar}, + password = #{password}, + status = #{status}, + login_ip = #{loginIp}, + login_date = #{loginDate}, + update_by = #{updateBy}, + remark = #{remark}, + update_time = sysdate() + + where user_id = #{userId} + + + + update sys_user set status = #{status} where user_id = #{userId} + + + + update sys_user set avatar = #{avatar} where user_name = #{userName} + + + + update sys_user set password = #{password} where user_name = #{userName} + + + + update sys_user set del_flag = '2' where user_id = #{userId} + + + + update sys_user set del_flag = '2' where user_id in + + #{userId} + + + + diff --git a/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/mapper/xml/SysUserPostMapper.xml b/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/mapper/xml/SysUserPostMapper.xml new file mode 100644 index 0000000..2b90bc4 --- /dev/null +++ b/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/mapper/xml/SysUserPostMapper.xml @@ -0,0 +1,34 @@ + + + + + + + + + + + delete from sys_user_post where user_id=#{userId} + + + + + + delete from sys_user_post where user_id in + + #{userId} + + + + + insert into sys_user_post(user_id, post_id) values + + (#{item.userId},#{item.postId}) + + + + \ No newline at end of file diff --git a/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/mapper/xml/SysUserRoleMapper.xml b/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/mapper/xml/SysUserRoleMapper.xml new file mode 100644 index 0000000..dd72689 --- /dev/null +++ b/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/mapper/xml/SysUserRoleMapper.xml @@ -0,0 +1,44 @@ + + + + + + + + + + + delete from sys_user_role where user_id=#{userId} + + + + + + delete from sys_user_role where user_id in + + #{userId} + + + + + insert into sys_user_role(user_id, role_id) values + + (#{item.userId},#{item.roleId}) + + + + + delete from sys_user_role where user_id=#{userId} and role_id=#{roleId} + + + + delete from sys_user_role where role_id=#{roleId} and user_id in + + #{userId} + + + \ No newline at end of file diff --git a/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysConfigService.java b/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysConfigService.java new file mode 100644 index 0000000..b51fc12 --- /dev/null +++ b/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysConfigService.java @@ -0,0 +1,92 @@ +package com.ruoyi.system.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.ruoyi.system.domain.SysConfig; + +import java.util.List; + +/** + * 参数配置 服务层 + * + * @author ruoyi + */ +public interface ISysConfigService extends IService +{ + /** + * 查询参数配置信息 + * + * @param configId 参数配置ID + * @return 参数配置信息 + */ + public SysConfig selectConfigById(Long configId); + + /** + * 根据键名查询参数配置信息 + * + * @param configKey 参数键名 + * @return 参数键值 + */ + public String selectConfigByKey(String configKey); + + /** + * 获取验证码开关 + * + * @return true开启,false关闭 + */ + public boolean selectCaptchaOnOff(); + + /** + * 查询参数配置列表 + * + * @param config 参数配置信息 + * @return 参数配置集合 + */ + public List selectConfigList(SysConfig config); + + /** + * 新增参数配置 + * + * @param config 参数配置信息 + * @return 结果 + */ + public int insertConfig(SysConfig config); + + /** + * 修改参数配置 + * + * @param config 参数配置信息 + * @return 结果 + */ + public int updateConfig(SysConfig config); + + /** + * 批量删除参数信息 + * + * @param configIds 需要删除的参数ID + * @return 结果 + */ + public void deleteConfigByIds(Long[] configIds); + + /** + * 加载参数缓存数据 + */ + public void loadingConfigCache(); + + /** + * 清空参数缓存数据 + */ + public void clearConfigCache(); + + /** + * 重置参数缓存数据 + */ + public void resetConfigCache(); + + /** + * 校验参数键名是否唯一 + * + * @param config 参数信息 + * @return 结果 + */ + public String checkConfigKeyUnique(SysConfig config); +} diff --git a/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysDataRuleService.java b/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysDataRuleService.java new file mode 100644 index 0000000..c5f1ee7 --- /dev/null +++ b/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysDataRuleService.java @@ -0,0 +1,30 @@ +package com.ruoyi.system.service; + + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.service.IService; +import com.ruoyi.common.core.domain.entity.SysDataRule; +import com.ruoyi.system.domain.SysRoleDataRule; + +import java.util.List; + +/** + * All rights Reserved, Designed By www.sunseagear.com + * + * @version V1.0 + * @package sys + * @title: 数据权限表控制器 + * @description: 数据权限表控制器 + * @author: 未知 + * @date: 2019-11-29 06:05:01 + * @copyright: www.sunseagear.com Inc. All rights reserved. + */ +public interface ISysDataRuleService extends IService { + + List roleDataList(QueryWrapper roleDataRuleEntityWrapper); + + void removeRoleDataRule(QueryWrapper roleDataRuleEntityWrapper); + + void insertBatchRoleDataRule(List roleDataRuleList); + +} diff --git a/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysDeptService.java b/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysDeptService.java new file mode 100644 index 0000000..e56ee31 --- /dev/null +++ b/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysDeptService.java @@ -0,0 +1,117 @@ +package com.ruoyi.system.service; + +import com.ruoyi.common.core.domain.TreeSelect; +import com.ruoyi.common.core.domain.entity.SysDept; + +import java.util.List; + +/** + * 部门管理 服务层 + * + * @author ruoyi + */ +public interface ISysDeptService +{ + /** + * 查询部门管理数据 + * + * @param dept 部门信息 + * @return 部门信息集合 + */ + public List selectDeptList(SysDept dept); + + /** + * 构建前端所需要树结构 + * + * @param depts 部门列表 + * @return 树结构列表 + */ + public List buildDeptTree(List depts); + + /** + * 构建前端所需要下拉树结构 + * + * @param depts 部门列表 + * @return 下拉树结构列表 + */ + public List buildDeptTreeSelect(List depts); + + /** + * 根据角色ID查询部门树信息 + * + * @param roleId 角色ID + * @return 选中部门列表 + */ + public List selectDeptListByRoleId(Long roleId); + + /** + * 根据部门ID查询信息 + * + * @param deptId 部门ID + * @return 部门信息 + */ + public SysDept selectDeptById(String deptId); + + /** + * 根据ID查询所有子部门(正常状态) + * + * @param deptId 部门ID + * @return 子部门数 + */ + public int selectNormalChildrenDeptById(String deptId); + + /** + * 是否存在部门子节点 + * + * @param deptId 部门ID + * @return 结果 + */ + public boolean hasChildByDeptId(String deptId); + + /** + * 查询部门是否存在用户 + * + * @param deptId 部门ID + * @return 结果 true 存在 false 不存在 + */ + public boolean checkDeptExistUser(String deptId); + + /** + * 校验部门名称是否唯一 + * + * @param dept 部门信息 + * @return 结果 + */ + public String checkDeptNameUnique(SysDept dept); + + /** + * 校验部门是否有数据权限 + * + * @param deptId 部门id + */ + public void checkDeptDataScope(String deptId); + + /** + * 新增保存部门信息 + * + * @param dept 部门信息 + * @return 结果 + */ + public int insertDept(SysDept dept); + + /** + * 修改保存部门信息 + * + * @param dept 部门信息 + * @return 结果 + */ + public int updateDept(SysDept dept); + + /** + * 删除部门管理信息 + * + * @param deptId 部门ID + * @return 结果 + */ + public int deleteDeptById(String deptId); +} diff --git a/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysDictDataService.java b/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysDictDataService.java new file mode 100644 index 0000000..57d7f65 --- /dev/null +++ b/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysDictDataService.java @@ -0,0 +1,64 @@ +package com.ruoyi.system.service; + +import com.ruoyi.common.core.domain.entity.SysDictData; + +import java.util.List; + +/** + * 字典 业务层 + * + * @author ruoyi + */ +public interface ISysDictDataService +{ + /** + * 根据条件分页查询字典数据 + * + * @param dictData 字典数据信息 + * @return 字典数据集合信息 + */ + public List selectDictDataList(SysDictData dictData); + + /** + * 根据字典类型和字典键值查询字典数据信息 + * + * @param dictType 字典类型 + * @param dictValue 字典键值 + * @return 字典标签 + */ + public String selectDictLabel(String dictType, String dictValue); + + /** + * 根据字典数据ID查询信息 + * + * @param dictCode 字典数据ID + * @return 字典数据 + */ + public SysDictData selectDictDataById(Long dictCode); + + /** + * 批量删除字典数据信息 + * + * @param dictCodes 需要删除的字典数据ID + * @return 结果 + */ + public void deleteDictDataByIds(Long[] dictCodes); + + /** + * 新增保存字典数据信息 + * + * @param dictData 字典数据信息 + * @return 结果 + */ + public int insertDictData(SysDictData dictData); + + /** + * 修改保存字典数据信息 + * + * @param dictData 字典数据信息 + * @return 结果 + */ + public int updateDictData(SysDictData dictData); + + String md5FineList(String code); +} diff --git a/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysDictTypeService.java b/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysDictTypeService.java new file mode 100644 index 0000000..8d18556 --- /dev/null +++ b/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysDictTypeService.java @@ -0,0 +1,100 @@ +package com.ruoyi.system.service; + +import com.ruoyi.common.core.domain.entity.SysDictData; +import com.ruoyi.common.core.domain.entity.SysDictType; + +import java.util.List; + +/** + * 字典 业务层 + * + * @author ruoyi + */ +public interface ISysDictTypeService +{ + /** + * 根据条件分页查询字典类型 + * + * @param dictType 字典类型信息 + * @return 字典类型集合信息 + */ + public List selectDictTypeList(SysDictType dictType); + + /** + * 根据所有字典类型 + * + * @return 字典类型集合信息 + */ + public List selectDictTypeAll(); + + /** + * 根据字典类型查询字典数据 + * + * @param dictType 字典类型 + * @return 字典数据集合信息 + */ + public List selectDictDataByType(String dictType); + + /** + * 根据字典类型ID查询信息 + * + * @param dictId 字典类型ID + * @return 字典类型 + */ + public SysDictType selectDictTypeById(Long dictId); + + /** + * 根据字典类型查询信息 + * + * @param dictType 字典类型 + * @return 字典类型 + */ + public SysDictType selectDictTypeByType(String dictType); + + /** + * 批量删除字典信息 + * + * @param dictIds 需要删除的字典ID + * @return 结果 + */ + public void deleteDictTypeByIds(Long[] dictIds); + + /** + * 加载字典缓存数据 + */ + public void loadingDictCache(); + + /** + * 清空字典缓存数据 + */ + public void clearDictCache(); + + /** + * 重置字典缓存数据 + */ + public void resetDictCache(); + + /** + * 新增保存字典类型信息 + * + * @param dictType 字典类型信息 + * @return 结果 + */ + public int insertDictType(SysDictType dictType); + + /** + * 修改保存字典类型信息 + * + * @param dictType 字典类型信息 + * @return 结果 + */ + public int updateDictType(SysDictType dictType); + + /** + * 校验字典类型称是否唯一 + * + * @param dictType 字典类型 + * @return 结果 + */ + public String checkDictTypeUnique(SysDictType dictType); +} diff --git a/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysLogininforService.java b/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysLogininforService.java new file mode 100644 index 0000000..2579075 --- /dev/null +++ b/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysLogininforService.java @@ -0,0 +1,41 @@ +package com.ruoyi.system.service; + +import com.ruoyi.system.domain.SysLogininfor; + +import java.util.List; + +/** + * 系统访问日志情况信息 服务层 + * + * @author ruoyi + */ +public interface ISysLogininforService +{ + /** + * 新增系统登录日志 + * + * @param logininfor 访问日志对象 + */ + public void insertLogininfor(SysLogininfor logininfor); + + /** + * 查询系统登录日志集合 + * + * @param logininfor 访问日志对象 + * @return 登录记录集合 + */ + public List selectLogininforList(SysLogininfor logininfor); + + /** + * 批量删除系统登录日志 + * + * @param infoIds 需要删除的登录日志ID + * @return + */ + public int deleteLogininforByIds(Long[] infoIds); + + /** + * 清空系统登录日志 + */ + public void cleanLogininfor(); +} diff --git a/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysMenuService.java b/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysMenuService.java new file mode 100644 index 0000000..5675795 --- /dev/null +++ b/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysMenuService.java @@ -0,0 +1,145 @@ +package com.ruoyi.system.service; + +import com.ruoyi.common.core.domain.TreeSelect; +import com.ruoyi.common.core.domain.entity.SysMenu; +import com.ruoyi.system.domain.vo.RouterVo; + +import java.util.List; +import java.util.Set; + +/** + * 菜单 业务层 + * + * @author ruoyi + */ +public interface ISysMenuService +{ + /** + * 根据用户查询系统菜单列表 + * + * @param userId 用户ID + * @return 菜单列表 + */ + public List selectMenuList(Long userId); + + /** + * 根据用户查询系统菜单列表 + * + * @param menu 菜单信息 + * @param userId 用户ID + * @return 菜单列表 + */ + public List selectMenuList(SysMenu menu, Long userId); + + /** + * 根据用户ID查询权限 + * + * @param userId 用户ID + * @return 权限列表 + */ + public Set selectMenuPermsByUserId(Long userId); + + /** + * 根据用户ID查询菜单树信息 + * + * @param userId 用户ID + * @return 菜单列表 + */ + public List selectMenuTreeByUserId(Long userId); + + /** + * 根据角色ID查询菜单树信息 + * + * @param roleId 角色ID + * @return 选中菜单列表 + */ + public List selectMenuListByRoleId(Long roleId); + + /** + * 构建前端路由所需要的菜单 + * + * @param menus 菜单列表 + * @return 路由列表 + */ + public List buildMenus(List menus); + + /** + * 构建前端所需要树结构 + * + * @param menus 菜单列表 + * @return 树结构列表 + */ + public List buildMenuTree(List menus); + + /** + * 构建前端所需要下拉树结构 + * + * @param menus 菜单列表 + * @return 下拉树结构列表 + */ + public List buildMenuTreeSelect(List menus); + + /** + * 根据菜单ID查询信息 + * + * @param menuId 菜单ID + * @return 菜单信息 + */ + public SysMenu selectMenuById(Long menuId); + + /** + * 是否存在菜单子节点 + * + * @param menuId 菜单ID + * @return 结果 true 存在 false 不存在 + */ + public boolean hasChildByMenuId(Long menuId); + + /** + * 删除子菜单 + * @param menuId + */ + void deleteChildByMenuId(Long menuId); + + /** + * 查询菜单是否存在角色 + * + * @param menuId 菜单ID + * @return 结果 true 存在 false 不存在 + */ + public boolean checkMenuExistRole(Long menuId); + + /** + * 新增保存菜单信息 + * + * @param menu 菜单信息 + * @return 结果 + */ + public int insertMenu(SysMenu menu); + + /** + * 修改保存菜单信息 + * + * @param menu 菜单信息 + * @return 结果 + */ + public int updateMenu(SysMenu menu); + + /** + * 删除菜单管理信息 + * + * @param menuId 菜单ID + * @return 结果 + */ + public int deleteMenuById(Long menuId); + + /** + * 校验菜单名称是否唯一 + * + * @param menu 菜单信息 + * @return 结果 + */ + public String checkMenuNameUnique(SysMenu menu); + + +} diff --git a/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysNoticeService.java b/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysNoticeService.java new file mode 100644 index 0000000..510109b --- /dev/null +++ b/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysNoticeService.java @@ -0,0 +1,61 @@ +package com.ruoyi.system.service; + +import com.ruoyi.system.domain.SysNotice; + +import java.util.List; + +/** + * 公告 服务层 + * + * @author ruoyi + */ +public interface ISysNoticeService +{ + /** + * 查询公告信息 + * + * @param noticeId 公告ID + * @return 公告信息 + */ + public SysNotice selectNoticeById(Long noticeId); + + /** + * 查询公告列表 + * + * @param notice 公告信息 + * @return 公告集合 + */ + public List selectNoticeList(SysNotice notice); + + /** + * 新增公告 + * + * @param notice 公告信息 + * @return 结果 + */ + public int insertNotice(SysNotice notice); + + /** + * 修改公告 + * + * @param notice 公告信息 + * @return 结果 + */ + public int updateNotice(SysNotice notice); + + /** + * 删除公告信息 + * + * @param noticeId 公告ID + * @return 结果 + */ + public int deleteNoticeById(Long noticeId); + + /** + * 批量删除公告信息 + * + * @param noticeIds 需要删除的公告ID + * @return 结果 + */ + public int deleteNoticeByIds(Long[] noticeIds); +} diff --git a/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysOperLogService.java b/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysOperLogService.java new file mode 100644 index 0000000..e3d2aab --- /dev/null +++ b/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysOperLogService.java @@ -0,0 +1,49 @@ +package com.ruoyi.system.service; + +import com.ruoyi.system.domain.SysOperLog; + +import java.util.List; + +/** + * 操作日志 服务层 + * + * @author ruoyi + */ +public interface ISysOperLogService +{ + /** + * 新增操作日志 + * + * @param operLog 操作日志对象 + */ + public void insertOperlog(SysOperLog operLog); + + /** + * 查询系统操作日志集合 + * + * @param operLog 操作日志对象 + * @return 操作日志集合 + */ + public List selectOperLogList(SysOperLog operLog); + + /** + * 批量删除系统操作日志 + * + * @param operIds 需要删除的操作日志ID + * @return 结果 + */ + public int deleteOperLogByIds(Long[] operIds); + + /** + * 查询操作日志详细 + * + * @param operId 操作ID + * @return 操作日志对象 + */ + public SysOperLog selectOperLogById(Long operId); + + /** + * 清空操作日志 + */ + public void cleanOperLog(); +} diff --git a/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysPostService.java b/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysPostService.java new file mode 100644 index 0000000..52a2253 --- /dev/null +++ b/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysPostService.java @@ -0,0 +1,101 @@ +package com.ruoyi.system.service; + +import com.ruoyi.system.domain.SysPost; + +import java.util.List; + +/** + * 岗位信息 服务层 + * + * @author ruoyi + */ +public interface ISysPostService +{ + /** + * 查询岗位信息集合 + * + * @param post 岗位信息 + * @return 岗位列表 + */ + public List selectPostList(SysPost post); + + /** + * 查询所有岗位 + * + * @return 岗位列表 + */ + public List selectPostAll(); + + /** + * 通过岗位ID查询岗位信息 + * + * @param postId 岗位ID + * @return 角色对象信息 + */ + public SysPost selectPostById(Long postId); + + /** + * 根据用户ID获取岗位选择框列表 + * + * @param userId 用户ID + * @return 选中岗位ID列表 + */ + public List selectPostListByUserId(Long userId); + + /** + * 校验岗位名称 + * + * @param post 岗位信息 + * @return 结果 + */ + public String checkPostNameUnique(SysPost post); + + /** + * 校验岗位编码 + * + * @param post 岗位信息 + * @return 结果 + */ + public String checkPostCodeUnique(SysPost post); + + /** + * 通过岗位ID查询岗位使用数量 + * + * @param postId 岗位ID + * @return 结果 + */ + public int countUserPostById(Long postId); + + /** + * 删除岗位信息 + * + * @param postId 岗位ID + * @return 结果 + */ + public int deletePostById(Long postId); + + /** + * 批量删除岗位信息 + * + * @param postIds 需要删除的岗位ID + * @return 结果 + * @throws Exception 异常 + */ + public int deletePostByIds(Long[] postIds); + + /** + * 新增保存岗位信息 + * + * @param post 岗位信息 + * @return 结果 + */ + public int insertPost(SysPost post); + + /** + * 修改保存岗位信息 + * + * @param post 岗位信息 + * @return 结果 + */ + public int updatePost(SysPost post); +} diff --git a/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysRoleService.java b/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysRoleService.java new file mode 100644 index 0000000..1a72aad --- /dev/null +++ b/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysRoleService.java @@ -0,0 +1,174 @@ +package com.ruoyi.system.service; + +import com.ruoyi.common.core.domain.entity.SysRole; +import com.ruoyi.system.domain.SysUserRole; + +import java.util.List; +import java.util.Set; + +/** + * 角色业务层 + * + * @author ruoyi + */ +public interface ISysRoleService +{ + /** + * 根据条件分页查询角色数据 + * + * @param role 角色信息 + * @return 角色数据集合信息 + */ + public List selectRoleList(SysRole role); + + /** + * 根据用户ID查询角色列表 + * + * @param userId 用户ID + * @return 角色列表 + */ + public List selectRolesByUserId(Long userId); + + /** + * 根据用户ID查询角色权限 + * + * @param userId 用户ID + * @return 权限列表 + */ + public Set selectRolePermissionByUserId(Long userId); + + /** + * 查询所有角色 + * + * @return 角色列表 + */ + public List selectRoleAll(); + + /** + * 根据用户ID获取角色选择框列表 + * + * @param userId 用户ID + * @return 选中角色ID列表 + */ + public List selectRoleListByUserId(Long userId); + + /** + * 通过角色ID查询角色 + * + * @param roleId 角色ID + * @return 角色对象信息 + */ + public SysRole selectRoleById(Long roleId); + + /** + * 校验角色名称是否唯一 + * + * @param role 角色信息 + * @return 结果 + */ + public String checkRoleNameUnique(SysRole role); + + /** + * 校验角色权限是否唯一 + * + * @param role 角色信息 + * @return 结果 + */ + public String checkRoleKeyUnique(SysRole role); + + /** + * 校验角色是否允许操作 + * + * @param role 角色信息 + */ + public void checkRoleAllowed(SysRole role); + + /** + * 校验角色是否有数据权限 + * + * @param roleId 角色id + */ + public void checkRoleDataScope(Long roleId); + + /** + * 通过角色ID查询角色使用数量 + * + * @param roleId 角色ID + * @return 结果 + */ + public int countUserRoleByRoleId(Long roleId); + + /** + * 新增保存角色信息 + * + * @param role 角色信息 + * @return 结果 + */ + public int insertRole(SysRole role); + + /** + * 修改保存角色信息 + * + * @param role 角色信息 + * @return 结果 + */ + public int updateRole(SysRole role); + + /** + * 修改角色状态 + * + * @param role 角色信息 + * @return 结果 + */ + public int updateRoleStatus(SysRole role); + + /** + * 修改数据权限信息 + * + * @param role 角色信息 + * @return 结果 + */ + public int authDataScope(SysRole role); + + /** + * 通过角色ID删除角色 + * + * @param roleId 角色ID + * @return 结果 + */ + public int deleteRoleById(Long roleId); + + /** + * 批量删除角色信息 + * + * @param roleIds 需要删除的角色ID + * @return 结果 + */ + public int deleteRoleByIds(Long[] roleIds); + + /** + * 取消授权用户角色 + * + * @param userRole 用户和角色关联信息 + * @return 结果 + */ + public int deleteAuthUser(SysUserRole userRole); + + /** + * 批量取消授权用户角色 + * + * @param roleId 角色ID + * @param userIds 需要取消授权的用户数据ID + * @return 结果 + */ + public int deleteAuthUsers(Long roleId, Long[] userIds); + + /** + * 批量选择授权用户角色 + * + * @param roleId 角色ID + * @param userIds 需要删除的用户数据ID + * @return 结果 + */ + public int insertAuthUsers(Long roleId, Long[] userIds); +} diff --git a/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysTenantService.java b/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysTenantService.java new file mode 100644 index 0000000..386be40 --- /dev/null +++ b/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysTenantService.java @@ -0,0 +1,19 @@ +package com.ruoyi.system.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.ruoyi.common.core.domain.entity.SysTenant; + +/** + * All rights Reserved, Designed By www.sunseagear.com + * + * @version V1.0 + * @package sys + * @title: 租户管理控制器 + * @description: 租户管理控制器 + * @author: 未知 + * @date: 2019-11-28 06:24:52 + * @copyright: www.sunseagear.com Inc. All rights reserved. + */ +public interface ISysTenantService extends IService { + +} diff --git a/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysUserOnlineService.java b/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysUserOnlineService.java new file mode 100644 index 0000000..8eb5448 --- /dev/null +++ b/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysUserOnlineService.java @@ -0,0 +1,48 @@ +package com.ruoyi.system.service; + +import com.ruoyi.common.core.domain.model.LoginUser; +import com.ruoyi.system.domain.SysUserOnline; + +/** + * 在线用户 服务层 + * + * @author ruoyi + */ +public interface ISysUserOnlineService +{ + /** + * 通过登录地址查询信息 + * + * @param ipaddr 登录地址 + * @param user 用户信息 + * @return 在线用户信息 + */ + public SysUserOnline selectOnlineByIpaddr(String ipaddr, LoginUser user); + + /** + * 通过用户名称查询信息 + * + * @param userName 用户名称 + * @param user 用户信息 + * @return 在线用户信息 + */ + public SysUserOnline selectOnlineByUserName(String userName, LoginUser user); + + /** + * 通过登录地址/用户名称查询信息 + * + * @param ipaddr 登录地址 + * @param userName 用户名称 + * @param user 用户信息 + * @return 在线用户信息 + */ + public SysUserOnline selectOnlineByInfo(String ipaddr, String userName, LoginUser user); + + /** + * 设置在线用户信息 + * + * @param user 用户信息 + * @return 在线用户 + */ + public SysUserOnline loginUserToUserOnline(LoginUser user); +} diff --git a/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysUserService.java b/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysUserService.java new file mode 100644 index 0000000..2dd808f --- /dev/null +++ b/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysUserService.java @@ -0,0 +1,208 @@ +package com.ruoyi.system.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.ruoyi.common.core.domain.entity.SysUser; + +import java.util.List; + +/** + * 用户 业务层 + * + * @author ruoyi + */ +public interface ISysUserService extends IService +{ + /** + * 根据条件分页查询用户列表 + * + * @param user 用户信息 + * @return 用户信息集合信息 + */ + public List selectUserList(SysUser user); + + /** + * 根据条件分页查询已分配用户角色列表 + * + * @param user 用户信息 + * @return 用户信息集合信息 + */ + public List selectAllocatedList(SysUser user); + + /** + * 根据条件分页查询未分配用户角色列表 + * + * @param user 用户信息 + * @return 用户信息集合信息 + */ + public List selectUnallocatedList(SysUser user); + + /** + * 通过用户名查询用户 + * + * @param userName 用户名 + * @return 用户对象信息 + */ + public SysUser selectUserByUserName(String userName); + + /** + * 通过用户ID查询用户 + * + * @param userId 用户ID + * @return 用户对象信息 + */ + public SysUser selectUserById(Long userId); + + /** + * 根据用户ID查询用户所属角色组 + * + * @param userName 用户名 + * @return 结果 + */ + public String selectUserRoleGroup(String userName); + + /** + * 根据用户ID查询用户所属岗位组 + * + * @param userName 用户名 + * @return 结果 + */ + public String selectUserPostGroup(String userName); + + /** + * 校验用户名称是否唯一 + * + * @param userName 用户名称 + * @return 结果 + */ + public String checkUserNameUnique(String userName); + + /** + * 校验手机号码是否唯一 + * + * @param user 用户信息 + * @return 结果 + */ + public String checkPhoneUnique(SysUser user); + + /** + * 校验email是否唯一 + * + * @param user 用户信息 + * @return 结果 + */ + public String checkEmailUnique(SysUser user); + + /** + * 校验用户是否允许操作 + * + * @param user 用户信息 + */ + public void checkUserAllowed(SysUser user); + + /** + * 校验用户是否有数据权限 + * + * @param userId 用户id + */ + public void checkUserDataScope(Long userId); + + /** + * 新增用户信息 + * + * @param user 用户信息 + * @return 结果 + */ + public int insertUser(SysUser user); + + /** + * 注册用户信息 + * + * @param user 用户信息 + * @return 结果 + */ + public boolean registerUser(SysUser user); + + /** + * 修改用户信息 + * + * @param user 用户信息 + * @return 结果 + */ + public int updateUser(SysUser user); + + /** + * 用户授权角色 + * + * @param userId 用户ID + * @param roleIds 角色组 + */ + public void insertUserAuth(Long userId, Long[] roleIds); + + /** + * 修改用户状态 + * + * @param user 用户信息 + * @return 结果 + */ + public int updateUserStatus(SysUser user); + + /** + * 修改用户基本信息 + * + * @param user 用户信息 + * @return 结果 + */ + public int updateUserProfile(SysUser user); + + /** + * 修改用户头像 + * + * @param userName 用户名 + * @param avatar 头像地址 + * @return 结果 + */ + public boolean updateUserAvatar(String userName, String avatar); + + /** + * 重置用户密码 + * + * @param user 用户信息 + * @return 结果 + */ + public int resetPwd(SysUser user); + + /** + * 重置用户密码 + * + * @param userName 用户名 + * @param password 密码 + * @return 结果 + */ + public int resetUserPwd(String userName, String password); + + /** + * 通过用户ID删除用户 + * + * @param userId 用户ID + * @return 结果 + */ + public int deleteUserById(Long userId); + + /** + * 批量删除用户信息 + * + * @param userIds 需要删除的用户ID + * @return 结果 + */ + public int deleteUserByIds(Long[] userIds); + + /** + * 导入用户数据 + * + * @param userList 用户数据列表 + * @param isUpdateSupport 是否更新支持,如果已存在,则进行更新数据 + * @param operName 操作用户 + * @return 结果 + */ + public String importUser(List userList, Boolean isUpdateSupport, String operName); +} diff --git a/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysConfigServiceImpl.java b/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysConfigServiceImpl.java new file mode 100644 index 0000000..ffaaa54 --- /dev/null +++ b/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysConfigServiceImpl.java @@ -0,0 +1,229 @@ +package com.ruoyi.system.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.ruoyi.common.annotation.DataSource; +import com.ruoyi.common.constant.Constants; +import com.ruoyi.common.constant.UserConstants; +import com.ruoyi.common.core.redis.RedisService; +import com.ruoyi.common.core.text.Convert; +import com.ruoyi.common.enums.DataSourceType; +import com.ruoyi.common.exception.ServiceException; +import com.ruoyi.common.utils.StringUtils; +import com.ruoyi.system.domain.SysConfig; +import com.ruoyi.system.mapper.SysConfigMapper; +import com.ruoyi.system.service.ISysConfigService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import javax.annotation.PostConstruct; +import java.util.Collection; +import java.util.List; + +/** + * 参数配置 服务层实现 + * + * @author ruoyi + */ +@Service +public class SysConfigServiceImpl extends ServiceImpl implements ISysConfigService +{ + @Autowired + private SysConfigMapper configMapper; + + @Autowired + private RedisService redisCache; + + /** + * 项目启动时,初始化参数到缓存 + */ + @PostConstruct + public void init() + { + loadingConfigCache(); + } + + /** + * 查询参数配置信息 + * + * @param configId 参数配置ID + * @return 参数配置信息 + */ + @Override + @DataSource(DataSourceType.MASTER) + public SysConfig selectConfigById(Long configId) + { + SysConfig config = new SysConfig(); + config.setConfigId(configId); + return configMapper.selectConfig(config); + } + + /** + * 根据键名查询参数配置信息 + * + * @param configKey 参数key + * @return 参数键值 + */ + @Override + public String selectConfigByKey(String configKey) + { + String configValue = Convert.toStr(redisCache.getCacheObject(getCacheKey(configKey))); + if (StringUtils.isNotEmpty(configValue)) + { + return configValue; + } + SysConfig config = new SysConfig(); + config.setConfigKey(configKey); + SysConfig retConfig = configMapper.selectConfig(config); + if (StringUtils.isNotNull(retConfig)) + { + redisCache.setCacheObject(getCacheKey(configKey), retConfig.getConfigValue()); + return retConfig.getConfigValue(); + } + return StringUtils.EMPTY; + } + + /** + * 获取验证码开关 + * + * @return true开启,false关闭 + */ + @Override + public boolean selectCaptchaOnOff() + { + String captchaOnOff = selectConfigByKey("sys.account.captchaOnOff"); + if (StringUtils.isEmpty(captchaOnOff)) + { + return true; + } + return Convert.toBool(captchaOnOff); + } + + /** + * 查询参数配置列表 + * + * @param config 参数配置信息 + * @return 参数配置集合 + */ + @Override + public List selectConfigList(SysConfig config) + { + return configMapper.selectConfigList(config); + } + + /** + * 新增参数配置 + * + * @param config 参数配置信息 + * @return 结果 + */ + @Override + public int insertConfig(SysConfig config) + { + int row = configMapper.insertConfig(config); + if (row > 0) + { + redisCache.setCacheObject(getCacheKey(config.getConfigKey()), config.getConfigValue()); + } + return row; + } + + /** + * 修改参数配置 + * + * @param config 参数配置信息 + * @return 结果 + */ + @Override + public int updateConfig(SysConfig config) + { + int row = configMapper.updateConfig(config); + if (row > 0) + { + redisCache.setCacheObject(getCacheKey(config.getConfigKey()), config.getConfigValue()); + } + return row; + } + + /** + * 批量删除参数信息 + * + * @param configIds 需要删除的参数ID + * @return 结果 + */ + @Override + public void deleteConfigByIds(Long[] configIds) + { + for (Long configId : configIds) + { + SysConfig config = selectConfigById(configId); + if (StringUtils.equals(UserConstants.YES, config.getConfigType())) + { + throw new ServiceException(String.format("内置参数【%1$s】不能删除 ", config.getConfigKey())); + } + configMapper.deleteConfigById(configId); + redisCache.deleteObject(getCacheKey(config.getConfigKey())); + } + } + + /** + * 加载参数缓存数据 + */ + @Override + public void loadingConfigCache() + { + List configsList = configMapper.selectConfigList(new SysConfig()); + for (SysConfig config : configsList) + { + redisCache.setCacheObject(getCacheKey(config.getConfigKey()), config.getConfigValue()); + } + } + + /** + * 清空参数缓存数据 + */ + @Override + public void clearConfigCache() + { + Collection keys = redisCache.keys(Constants.SYS_CONFIG_KEY + "*"); + redisCache.deleteObject(keys); + } + + /** + * 重置参数缓存数据 + */ + @Override + public void resetConfigCache() + { + clearConfigCache(); + loadingConfigCache(); + } + + /** + * 校验参数键名是否唯一 + * + * @param config 参数配置信息 + * @return 结果 + */ + @Override + public String checkConfigKeyUnique(SysConfig config) + { + Long configId = StringUtils.isNull(config.getConfigId()) ? -1L : config.getConfigId(); + SysConfig info = configMapper.checkConfigKeyUnique(config.getConfigKey()); + if (StringUtils.isNotNull(info) && info.getConfigId().longValue() != configId.longValue()) + { + return UserConstants.NOT_UNIQUE; + } + return UserConstants.UNIQUE; + } + + /** + * 设置cache key + * + * @param configKey 参数键 + * @return 缓存键key + */ + private String getCacheKey(String configKey) + { + return Constants.SYS_CONFIG_KEY + configKey; + } +} diff --git a/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDataRuleServiceImpl.java b/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDataRuleServiceImpl.java new file mode 100644 index 0000000..a3b5035 --- /dev/null +++ b/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDataRuleServiceImpl.java @@ -0,0 +1,96 @@ +package com.ruoyi.system.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.ruoyi.common.core.domain.entity.SysDataRule; +import com.ruoyi.datarule.handler.DataRuleHandler; +import com.ruoyi.system.domain.SysRoleDataRule; +import com.ruoyi.system.mapper.SysDataRuleMapper; +import com.ruoyi.system.mapper.SysRoleDataRuleMapper; +import com.ruoyi.system.service.ISysDataRuleService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.io.Serializable; +import java.util.Collection; +import java.util.List; + + +/** + * All rights Reserved, Designed By www.sunseagear.com + * + * @version V1.0 + * @package sys + * @title: 数据权限表控制器 + * @description: 数据权限表控制器 + * @author: 未知 + * @date: 2019-11-29 06:05:01 + * @copyright: www.sunseagear.com Inc. All rights reserved. + */ +@Transactional +@Service +public class SysDataRuleServiceImpl extends ServiceImpl implements ISysDataRuleService { + + //所有数据更新都需要刷新数据权限 + @Autowired + private DataRuleHandler dataRuleHandler; + @Autowired + private SysRoleDataRuleMapper roleDataRuleMapper; + + @Override + public boolean updateById(SysDataRule entity) { + boolean result = super.updateById(entity); + dataRuleHandler.refreshDataRule(entity.getId()); + return result; + } + + @Override + public boolean save(SysDataRule entity) { + boolean save = super.save(entity); + dataRuleHandler.refreshDataRule(entity.getId()); + return save; + } + + @Override + public boolean saveOrUpdate(SysDataRule entity) { + boolean result = super.saveOrUpdate(entity); + dataRuleHandler.refreshDataRule(entity.getId()); + return result; + } + + @Override + public boolean removeById(Serializable id) { + boolean result = super.removeById(id); + roleDataRuleMapper.delete(new QueryWrapper().eq("role_id", id)); + dataRuleHandler.deleteDataRule(String.valueOf(id)); + return result; + } + + @Override + public boolean removeByIds(Collection idList) { + boolean result = super.removeByIds(idList); + idList.forEach(id -> { + roleDataRuleMapper.delete(new QueryWrapper().eq("role_id", id)); + dataRuleHandler.deleteDataRule(String.valueOf(id)); + }); + return result; + } + + @Override + public List roleDataList(QueryWrapper roleDataRuleEntityWrapper) { + return roleDataRuleMapper.selectList(roleDataRuleEntityWrapper); + } + + @Override + public void removeRoleDataRule(QueryWrapper roleDataRuleEntityWrapper) { + roleDataRuleMapper.delete(roleDataRuleEntityWrapper); + } + + @Override + public void insertBatchRoleDataRule(List roleDataRuleList) { + roleDataRuleList.forEach(item -> { + roleDataRuleMapper.insert(item); + }); + } +} diff --git a/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDeptServiceImpl.java b/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDeptServiceImpl.java new file mode 100644 index 0000000..59d395e --- /dev/null +++ b/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDeptServiceImpl.java @@ -0,0 +1,332 @@ +package com.ruoyi.system.service.impl; + +import com.ruoyi.common.annotation.DataScope; +import com.ruoyi.common.constant.UserConstants; +import com.ruoyi.common.core.domain.TreeSelect; +import com.ruoyi.common.core.domain.entity.SysDept; +import com.ruoyi.common.core.domain.entity.SysRole; +import com.ruoyi.common.core.domain.entity.SysUser; +import com.ruoyi.common.core.text.Convert; +import com.ruoyi.common.exception.ServiceException; +import com.ruoyi.common.utils.SecurityUtils; +import com.ruoyi.common.utils.StringUtils; +import com.ruoyi.common.utils.spring.SpringUtils; +import com.ruoyi.system.mapper.SysDeptMapper; +import com.ruoyi.system.mapper.SysRoleMapper; +import com.ruoyi.system.service.ISysDeptService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import java.util.stream.Collectors; + +/** + * 部门管理 服务实现 + * + * @author ruoyi + */ +@Service +public class SysDeptServiceImpl implements ISysDeptService +{ + @Autowired + private SysDeptMapper deptMapper; + + @Autowired + private SysRoleMapper roleMapper; + + /** + * 查询部门管理数据 + * + * @param dept 部门信息 + * @return 部门信息集合 + */ + @Override + @DataScope(deptAlias = "d") + public List selectDeptList(SysDept dept) + { + return deptMapper.selectDeptList(dept); + } + + /** + * 构建前端所需要树结构 + * + * @param depts 部门列表 + * @return 树结构列表 + */ + @Override + public List buildDeptTree(List depts) + { + List returnList = new ArrayList(); + List tempList = new ArrayList(); + for (SysDept dept : depts) + { + tempList.add(dept.getDeptId()); + } + for (Iterator iterator = depts.iterator(); iterator.hasNext();) + { + SysDept dept = (SysDept) iterator.next(); + // 如果是顶级节点, 遍历该父节点的所有子节点 + if (!tempList.contains(dept.getParentId())) + { + recursionFn(depts, dept); + returnList.add(dept); + } + } + if (returnList.isEmpty()) + { + returnList = depts; + } + return returnList; + } + + /** + * 构建前端所需要下拉树结构 + * + * @param depts 部门列表 + * @return 下拉树结构列表 + */ + @Override + public List buildDeptTreeSelect(List depts) + { + List deptTrees = buildDeptTree(depts); + return deptTrees.stream().map(TreeSelect::new).collect(Collectors.toList()); + } + + /** + * 根据角色ID查询部门树信息 + * + * @param roleId 角色ID + * @return 选中部门列表 + */ + @Override + public List selectDeptListByRoleId(Long roleId) + { + SysRole role = roleMapper.selectRoleById(roleId); + return deptMapper.selectDeptListByRoleId(roleId, role.isDeptCheckStrictly()); + } + + /** + * 根据部门ID查询信息 + * + * @param deptId 部门ID + * @return 部门信息 + */ + @Override + public SysDept selectDeptById(String deptId) + { + return deptMapper.selectDeptById(deptId); + } + + /** + * 根据ID查询所有子部门(正常状态) + * + * @param deptId 部门ID + * @return 子部门数 + */ + @Override + public int selectNormalChildrenDeptById(String deptId) + { + return deptMapper.selectNormalChildrenDeptById(deptId); + } + + /** + * 是否存在子节点 + * + * @param deptId 部门ID + * @return 结果 + */ + @Override + public boolean hasChildByDeptId(String deptId) + { + int result = deptMapper.hasChildByDeptId(deptId); + return result > 0 ? true : false; + } + + /** + * 查询部门是否存在用户 + * + * @param deptId 部门ID + * @return 结果 true 存在 false 不存在 + */ + @Override + public boolean checkDeptExistUser(String deptId) + { + int result = deptMapper.checkDeptExistUser(deptId); + return result > 0 ? true : false; + } + + /** + * 校验部门名称是否唯一 + * + * @param dept 部门信息 + * @return 结果 + */ + @Override + public String checkDeptNameUnique(SysDept dept) + { + SysDept info = deptMapper.checkDeptNameUnique(dept.getDeptName(), dept.getParentId()); + if (StringUtils.isNotNull(info)) + { + return UserConstants.NOT_UNIQUE; + } + return UserConstants.UNIQUE; + } + + /** + * 校验部门是否有数据权限 + * + * @param deptId 部门id + */ + @Override + public void checkDeptDataScope(String deptId) + { + if (!SysUser.isAdmin(SecurityUtils.getUserId())) + { + SysDept dept = new SysDept(); + dept.setDeptId(deptId); + List depts = SpringUtils.getAopProxy(this).selectDeptList(dept); + if (StringUtils.isEmpty(depts)) + { + throw new ServiceException("没有权限访问部门数据!"); + } + } + } + + /** + * 新增保存部门信息 + * + * @param dept 部门信息 + * @return 结果 + */ + @Override + public int insertDept(SysDept dept) + { + SysDept info = deptMapper.selectDeptById(dept.getParentId()); + // 如果父节点不为正常状态,则不允许新增子节点 + if (info != null){ + if (!UserConstants.DEPT_NORMAL.equals(info.getStatus())) + { + throw new ServiceException("部门停用,不允许新增"); + } + dept.setAncestors(info.getAncestors() + "," + dept.getParentId()); + } + return deptMapper.insertDept(dept); + } + + /** + * 修改保存部门信息 + * + * @param dept 部门信息 + * @return 结果 + */ + @Override + public int updateDept(SysDept dept) + { + SysDept newParentDept = deptMapper.selectDeptById(dept.getParentId()); + SysDept oldDept = deptMapper.selectDeptById(dept.getDeptId()); + if (StringUtils.isNotNull(newParentDept) && StringUtils.isNotNull(oldDept)) + { + String newAncestors = newParentDept.getAncestors() + "," + newParentDept.getDeptId(); + String oldAncestors = oldDept.getAncestors(); + dept.setAncestors(newAncestors); + updateDeptChildren(dept.getDeptId(), newAncestors, oldAncestors); + } + int result = deptMapper.updateDept(dept); + if (UserConstants.DEPT_NORMAL.equals(dept.getStatus()) && StringUtils.isNotEmpty(dept.getAncestors()) + && !StringUtils.equals("0", dept.getAncestors())) + { + // 如果该部门是启用状态,则启用该部门的所有上级部门 + updateParentDeptStatusNormal(dept); + } + return result; + } + + /** + * 修改该部门的父级部门状态 + * + * @param dept 当前部门 + */ + private void updateParentDeptStatusNormal(SysDept dept) + { + String ancestors = dept.getAncestors(); + String[] deptIds = Convert.toStrArray(ancestors); + deptMapper.updateDeptStatusNormal(deptIds); + } + + /** + * 修改子元素关系 + * + * @param deptId 被修改的部门ID + * @param newAncestors 新的父ID集合 + * @param oldAncestors 旧的父ID集合 + */ + public void updateDeptChildren(String deptId, String newAncestors, String oldAncestors) + { + List children = deptMapper.selectChildrenDeptById(deptId); + for (SysDept child : children) + { + child.setAncestors(child.getAncestors().replaceFirst(oldAncestors, newAncestors)); + } + if (children.size() > 0) + { + deptMapper.updateDeptChildren(children); + } + } + + /** + * 删除部门管理信息 + * + * @param deptId 部门ID + * @return 结果 + */ + @Override + public int deleteDeptById(String deptId) + { + return deptMapper.deleteDeptById(deptId); + } + + /** + * 递归列表 + */ + private void recursionFn(List list, SysDept t) + { + // 得到子节点列表 + List childList = getChildList(list, t); + t.setChildren(childList); + for (SysDept tChild : childList) + { + if (hasChild(list, tChild)) + { + recursionFn(list, tChild); + } + } + } + + /** + * 得到子节点列表 + */ + private List getChildList(List list, SysDept t) + { + List tlist = new ArrayList(); + Iterator it = list.iterator(); + while (it.hasNext()) + { + SysDept n = (SysDept) it.next(); + if (t.getDeptId().equals(n.getParentId())) + { + tlist.add(n); + } + } + return tlist; + } + + /** + * 判断是否有子节点 + */ + private boolean hasChild(List list, SysDept t) + { + return getChildList(list, t).size() > 0 ? true : false; + } +} diff --git a/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDictDataServiceImpl.java b/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDictDataServiceImpl.java new file mode 100644 index 0000000..66c87d7 --- /dev/null +++ b/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDictDataServiceImpl.java @@ -0,0 +1,135 @@ +package com.ruoyi.system.service.impl; + +import com.alibaba.fastjson.JSONObject; +import com.ruoyi.common.core.domain.entity.SysDictData; +import com.ruoyi.common.utils.AESUtil; +import com.ruoyi.common.utils.DictUtils; +import com.ruoyi.system.mapper.SysDictDataMapper; +import com.ruoyi.system.service.ISysDictDataService; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * 字典 业务层处理 + * + * @author ruoyi + */ +@Slf4j +@Service +public class SysDictDataServiceImpl implements ISysDictDataService +{ + @Autowired + private SysDictDataMapper dictDataMapper; + + /** + * 根据条件分页查询字典数据 + * + * @param dictData 字典数据信息 + * @return 字典数据集合信息 + */ + @Override + public List selectDictDataList(SysDictData dictData) + { + return dictDataMapper.selectDictDataList(dictData); + } + + /** + * 根据字典类型和字典键值查询字典数据信息 + * + * @param dictType 字典类型 + * @param dictValue 字典键值 + * @return 字典标签 + */ + @Override + public String selectDictLabel(String dictType, String dictValue) + { + return dictDataMapper.selectDictLabel(dictType, dictValue); + } + + /** + * 根据字典数据ID查询信息 + * + * @param dictCode 字典数据ID + * @return 字典数据 + */ + @Override + public SysDictData selectDictDataById(Long dictCode) + { + return dictDataMapper.selectDictDataById(dictCode); + } + + /** + * 批量删除字典数据信息 + * + * @param dictCodes 需要删除的字典数据ID + * @return 结果 + */ + @Override + public void deleteDictDataByIds(Long[] dictCodes) + { + for (Long dictCode : dictCodes) + { + SysDictData data = selectDictDataById(dictCode); + dictDataMapper.deleteDictDataById(dictCode); + List dictDatas = dictDataMapper.selectDictDataByType(data.getDictType()); + DictUtils.setDictCache(data.getDictType(), dictDatas); + } + } + + /** + * 新增保存字典数据信息 + * + * @param data 字典数据信息 + * @return 结果 + */ + @Override + public int insertDictData(SysDictData data) + { + int row = dictDataMapper.insertDictData(data); + if (row > 0) + { + List dictDatas = dictDataMapper.selectDictDataByType(data.getDictType()); + DictUtils.setDictCache(data.getDictType(), dictDatas); + } + return row; + } + + /** + * 修改保存字典数据信息 + * + * @param data 字典数据信息 + * @return 结果 + */ + @Override + public int updateDictData(SysDictData data) + { + int row = dictDataMapper.updateDictData(data); + if (row > 0) + { + List dictDatas = dictDataMapper.selectDictDataByType(data.getDictType()); + DictUtils.setDictCache(data.getDictType(), dictDatas); + } + return row; + } + + @Override + public String md5FineList(String code){ + SysDictData sysDictData = new SysDictData(); + sysDictData.setDictType(code); + List list = selectDictDataList(sysDictData); + + Map map = new HashMap(); + for (SysDictData dictData : list) { + map.put(dictData.getCode(), dictData.getDictValue()); + } + + String json = JSONObject.toJSONString(map); + String encrypt = AESUtil.encrypt(json, "huitu@77387.uurh"); + log.info("字典表下级加密:" + encrypt); + return encrypt; + } +} diff --git a/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDictTypeServiceImpl.java b/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDictTypeServiceImpl.java new file mode 100644 index 0000000..28dd910 --- /dev/null +++ b/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDictTypeServiceImpl.java @@ -0,0 +1,221 @@ +package com.ruoyi.system.service.impl; + +import com.ruoyi.common.constant.UserConstants; +import com.ruoyi.common.core.domain.entity.SysDictData; +import com.ruoyi.common.core.domain.entity.SysDictType; +import com.ruoyi.common.exception.ServiceException; +import com.ruoyi.common.utils.DictUtils; +import com.ruoyi.common.utils.StringUtils; +import com.ruoyi.system.mapper.SysDictDataMapper; +import com.ruoyi.system.mapper.SysDictTypeMapper; +import com.ruoyi.system.service.ISysDictTypeService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import javax.annotation.PostConstruct; +import java.util.List; + +/** + * 字典 业务层处理 + * + * @author ruoyi + */ +@Service +public class SysDictTypeServiceImpl implements ISysDictTypeService +{ + @Autowired + private SysDictTypeMapper dictTypeMapper; + + @Autowired + private SysDictDataMapper dictDataMapper; + + /** + * 项目启动时,初始化字典到缓存 + */ + @PostConstruct + public void init() + { + loadingDictCache(); + } + + /** + * 根据条件分页查询字典类型 + * + * @param dictType 字典类型信息 + * @return 字典类型集合信息 + */ + @Override + public List selectDictTypeList(SysDictType dictType) + { + return dictTypeMapper.selectDictTypeList(dictType); + } + + /** + * 根据所有字典类型 + * + * @return 字典类型集合信息 + */ + @Override + public List selectDictTypeAll() + { + return dictTypeMapper.selectDictTypeAll(); + } + + /** + * 根据字典类型查询字典数据 + * + * @param dictType 字典类型 + * @return 字典数据集合信息 + */ + @Override + public List selectDictDataByType(String dictType) + { + List dictDatas = DictUtils.getDictCache(dictType); + if (StringUtils.isNotEmpty(dictDatas)) + { + return dictDatas; + } + dictDatas = dictDataMapper.selectDictDataByType(dictType); + if (StringUtils.isNotEmpty(dictDatas)) + { + DictUtils.setDictCache(dictType, dictDatas); + return dictDatas; + } + return null; + } + + /** + * 根据字典类型ID查询信息 + * + * @param dictId 字典类型ID + * @return 字典类型 + */ + @Override + public SysDictType selectDictTypeById(Long dictId) + { + return dictTypeMapper.selectDictTypeById(dictId); + } + + /** + * 根据字典类型查询信息 + * + * @param dictType 字典类型 + * @return 字典类型 + */ + @Override + public SysDictType selectDictTypeByType(String dictType) + { + return dictTypeMapper.selectDictTypeByType(dictType); + } + + /** + * 批量删除字典类型信息 + * + * @param dictIds 需要删除的字典ID + * @return 结果 + */ + @Override + public void deleteDictTypeByIds(Long[] dictIds) + { + for (Long dictId : dictIds) + { + SysDictType dictType = selectDictTypeById(dictId); + if (dictDataMapper.countDictDataByType(dictType.getDictType()) > 0) + { + throw new ServiceException(String.format("%1$s已分配,不能删除", dictType.getDictName())); + } + dictTypeMapper.deleteDictTypeById(dictId); + DictUtils.removeDictCache(dictType.getDictType()); + } + } + + /** + * 加载字典缓存数据 + */ + @Override + public void loadingDictCache() + { + List dictTypeList = dictTypeMapper.selectDictTypeAll(); + for (SysDictType dictType : dictTypeList) + { + List dictDatas = dictDataMapper.selectDictDataByType(dictType.getDictType()); + DictUtils.setDictCache(dictType.getDictType(), dictDatas); + } + } + + /** + * 清空字典缓存数据 + */ + @Override + public void clearDictCache() + { + DictUtils.clearDictCache(); + } + + /** + * 重置字典缓存数据 + */ + @Override + public void resetDictCache() + { + clearDictCache(); + loadingDictCache(); + } + + /** + * 新增保存字典类型信息 + * + * @param dict 字典类型信息 + * @return 结果 + */ + @Override + public int insertDictType(SysDictType dict) + { + int row = dictTypeMapper.insertDictType(dict); + if (row > 0) + { + DictUtils.setDictCache(dict.getDictType(), null); + } + return row; + } + + /** + * 修改保存字典类型信息 + * + * @param dict 字典类型信息 + * @return 结果 + */ + @Override + @Transactional + public int updateDictType(SysDictType dict) + { + SysDictType oldDict = dictTypeMapper.selectDictTypeById(dict.getDictId()); + dictDataMapper.updateDictDataType(oldDict.getDictType(), dict.getDictType()); + int row = dictTypeMapper.updateDictType(dict); + if (row > 0) + { + List dictDatas = dictDataMapper.selectDictDataByType(dict.getDictType()); + DictUtils.setDictCache(dict.getDictType(), dictDatas); + } + return row; + } + + /** + * 校验字典类型称是否唯一 + * + * @param dict 字典类型 + * @return 结果 + */ + @Override + public String checkDictTypeUnique(SysDictType dict) + { + Long dictId = StringUtils.isNull(dict.getDictId()) ? -1L : dict.getDictId(); + SysDictType dictType = dictTypeMapper.checkDictTypeUnique(dict.getDictType()); + if (StringUtils.isNotNull(dictType) && dictType.getDictId().longValue() != dictId.longValue()) + { + return UserConstants.NOT_UNIQUE; + } + return UserConstants.UNIQUE; + } +} diff --git a/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysLogininforServiceImpl.java b/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysLogininforServiceImpl.java new file mode 100644 index 0000000..e3e202c --- /dev/null +++ b/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysLogininforServiceImpl.java @@ -0,0 +1,66 @@ +package com.ruoyi.system.service.impl; + +import com.ruoyi.system.domain.SysLogininfor; +import com.ruoyi.system.mapper.SysLogininforMapper; +import com.ruoyi.system.service.ISysLogininforService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * 系统访问日志情况信息 服务层处理 + * + * @author ruoyi + */ +@Service +public class SysLogininforServiceImpl implements ISysLogininforService +{ + + @Autowired + private SysLogininforMapper logininforMapper; + + /** + * 新增系统登录日志 + * + * @param logininfor 访问日志对象 + */ + @Override + public void insertLogininfor(SysLogininfor logininfor) + { + logininforMapper.insertLogininfor(logininfor); + } + + /** + * 查询系统登录日志集合 + * + * @param logininfor 访问日志对象 + * @return 登录记录集合 + */ + @Override + public List selectLogininforList(SysLogininfor logininfor) + { + return logininforMapper.selectLogininforList(logininfor); + } + + /** + * 批量删除系统登录日志 + * + * @param infoIds 需要删除的登录日志ID + * @return + */ + @Override + public int deleteLogininforByIds(Long[] infoIds) + { + return logininforMapper.deleteLogininforByIds(infoIds); + } + + /** + * 清空系统登录日志 + */ + @Override + public void cleanLogininfor() + { + logininforMapper.cleanLogininfor(); + } +} diff --git a/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysMenuServiceImpl.java b/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysMenuServiceImpl.java new file mode 100644 index 0000000..0068fcf --- /dev/null +++ b/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysMenuServiceImpl.java @@ -0,0 +1,503 @@ +package com.ruoyi.system.service.impl; + +import com.ruoyi.common.constant.Constants; +import com.ruoyi.common.constant.UserConstants; +import com.ruoyi.common.core.domain.TreeSelect; +import com.ruoyi.common.core.domain.entity.SysMenu; +import com.ruoyi.common.core.domain.entity.SysRole; +import com.ruoyi.common.core.domain.entity.SysUser; +import com.ruoyi.common.utils.SecurityUtils; +import com.ruoyi.common.utils.StringUtils; +import com.ruoyi.system.domain.vo.MetaVo; +import com.ruoyi.system.domain.vo.RouterVo; +import com.ruoyi.system.mapper.SysMenuMapper; +import com.ruoyi.system.mapper.SysRoleMapper; +import com.ruoyi.system.mapper.SysRoleMenuMapper; +import com.ruoyi.system.service.ISysMenuService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.*; +import java.util.stream.Collectors; + +/** + * 菜单 业务层处理 + * + * @author ruoyi + */ +@Service +public class SysMenuServiceImpl implements ISysMenuService +{ + public static final String PREMISSION_STRING = "perms[\"{0}\"]"; + + @Autowired + private SysMenuMapper menuMapper; + + @Autowired + private SysRoleMapper roleMapper; + + @Autowired + private SysRoleMenuMapper roleMenuMapper; + + /** + * 根据用户查询系统菜单列表 + * + * @param userId 用户ID + * @return 菜单列表 + */ + @Override + public List selectMenuList(Long userId) + { + return selectMenuList(new SysMenu(), userId); + } + + /** + * 查询系统菜单列表 + * + * @param menu 菜单信息 + * @return 菜单列表 + */ + @Override + public List selectMenuList(SysMenu menu, Long userId) + { + List menuList = null; + // 管理员显示所有菜单信息 + if (SysUser.isAdmin(userId)) + { + menuList = menuMapper.selectMenuList(menu); + } + else + { + menu.getParams().put("userId", userId); + menuList = menuMapper.selectMenuListByUserId(menu); + } + return menuList; + } + + /** + * 根据用户ID查询权限 + * + * @param userId 用户ID + * @return 权限列表 + */ + @Override + public Set selectMenuPermsByUserId(Long userId) + { + List perms = menuMapper.selectMenuPermsByUserId(userId); + Set permsSet = new HashSet<>(); + for (String perm : perms) + { + if (StringUtils.isNotEmpty(perm)) + { + permsSet.addAll(Arrays.asList(perm.trim().split(","))); + } + } + return permsSet; + } + + /** + * 根据用户ID查询菜单 + * + * @param userId 用户名称 + * @return 菜单列表 + */ + @Override + public List selectMenuTreeByUserId(Long userId) + { + List menus = null; + if (SecurityUtils.isAdmin(userId)) + { + menus = menuMapper.selectMenuTreeAll(); + } + else + { + menus = menuMapper.selectMenuTreeByUserId(userId); + } + return getChildPerms(menus, 0); + } + + /** + * 根据角色ID查询菜单树信息 + * + * @param roleId 角色ID + * @return 选中菜单列表 + */ + @Override + public List selectMenuListByRoleId(Long roleId) + { + SysRole role = roleMapper.selectRoleById(roleId); + return menuMapper.selectMenuListByRoleId(roleId, role.isMenuCheckStrictly()); + } + + /** + * 构建前端路由所需要的菜单 + * + * @param menus 菜单列表 + * @return 路由列表 + */ + @Override + public List buildMenus(List menus) + { + List routers = new LinkedList(); + for (SysMenu menu : menus) + { + RouterVo router = new RouterVo(); + router.setHidden("1".equals(menu.getVisible())); + router.setName(getRouteName(menu)); + router.setPath(getRouterPath(menu)); + router.setComponent(getComponent(menu)); + router.setQuery(menu.getQuery()); + router.setMeta(new MetaVo(menu.getMenuName(), menu.getIcon(), StringUtils.equals("1", menu.getIsCache()), menu.getPath())); + List cMenus = menu.getChildren(); + if (!cMenus.isEmpty() && cMenus.size() > 0 && UserConstants.TYPE_DIR.equals(menu.getMenuType())) + { + router.setAlwaysShow(true); + router.setRedirect("noRedirect"); + router.setChildren(buildMenus(cMenus)); + } + else if (isMenuFrame(menu)) + { + router.setMeta(null); + List childrenList = new ArrayList(); + RouterVo children = new RouterVo(); + children.setPath(menu.getPath()); + children.setComponent(menu.getComponent()); + children.setName(StringUtils.capitalize(menu.getPath())); + children.setMeta(new MetaVo(menu.getMenuName(), menu.getIcon(), StringUtils.equals("1", menu.getIsCache()), menu.getPath())); + children.setQuery(menu.getQuery()); + childrenList.add(children); + router.setChildren(childrenList); + } + else if (menu.getParentId().intValue() == 0 && isInnerLink(menu)) + { + router.setMeta(new MetaVo(menu.getMenuName(), menu.getIcon())); + router.setPath("/inner"); + List childrenList = new ArrayList(); + RouterVo children = new RouterVo(); + String routerPath = StringUtils.replaceEach(menu.getPath(), new String[] { Constants.HTTP, Constants.HTTPS }, new String[] { "", "" }); + children.setPath(routerPath); + children.setComponent(UserConstants.INNER_LINK); + children.setName(StringUtils.capitalize(routerPath)); + children.setMeta(new MetaVo(menu.getMenuName(), menu.getIcon(), menu.getPath())); + childrenList.add(children); + router.setChildren(childrenList); + } + routers.add(router); + } + return routers; + } + + /** + * 构建前端所需要树结构 + * + * @param menus 菜单列表 + * @return 树结构列表 + */ + @Override + public List buildMenuTree(List menus) + { + List returnList = new ArrayList(); + List tempList = new ArrayList(); + for (SysMenu dept : menus) + { + tempList.add(dept.getMenuId()); + } + for (Iterator iterator = menus.iterator(); iterator.hasNext();) + { + SysMenu menu = (SysMenu) iterator.next(); + // 如果是顶级节点, 遍历该父节点的所有子节点 + if (!tempList.contains(menu.getParentId())) + { + recursionFn(menus, menu); + returnList.add(menu); + } + } + if (returnList.isEmpty()) + { + returnList = menus; + } + return returnList; + } + + /** + * 构建前端所需要下拉树结构 + * + * @param menus 菜单列表 + * @return 下拉树结构列表 + */ + @Override + public List buildMenuTreeSelect(List menus) + { + List menuTrees = buildMenuTree(menus); + return menuTrees.stream().map(TreeSelect::new).collect(Collectors.toList()); + } + + /** + * 根据菜单ID查询信息 + * + * @param menuId 菜单ID + * @return 菜单信息 + */ + @Override + public SysMenu selectMenuById(Long menuId) + { + return menuMapper.selectMenuById(menuId); + } + + /** + * 是否存在菜单子节点 + * + * @param menuId 菜单ID + * @return 结果 + */ + @Override + public boolean hasChildByMenuId(Long menuId) + { + int result = menuMapper.hasChildByMenuId(menuId); + return result > 0 ? true : false; + } + + @Override + public void deleteChildByMenuId(Long menuId) { + menuMapper.deleteChildByMenuId(menuId); + } + + /** + * 查询菜单使用数量 + * + * @param menuId 菜单ID + * @return 结果 + */ + @Override + public boolean checkMenuExistRole(Long menuId) + { + int result = roleMenuMapper.checkMenuExistRole(menuId); + return result > 0 ? true : false; + } + + /** + * 新增保存菜单信息 + * + * @param menu 菜单信息 + * @return 结果 + */ + @Override + public int insertMenu(SysMenu menu) + { + return menuMapper.insertMenu(menu); + } + + /** + * 修改保存菜单信息 + * + * @param menu 菜单信息 + * @return 结果 + */ + @Override + public int updateMenu(SysMenu menu) + { + return menuMapper.updateMenu(menu); + } + + /** + * 删除菜单管理信息 + * + * @param menuId 菜单ID + * @return 结果 + */ + @Override + public int deleteMenuById(Long menuId) + { + return menuMapper.deleteMenuById(menuId); + } + + /** + * 校验菜单名称是否唯一 + * + * @param menu 菜单信息 + * @return 结果 + */ + @Override + public String checkMenuNameUnique(SysMenu menu) + { + Long menuId = StringUtils.isNull(menu.getMenuId()) ? -1L : menu.getMenuId(); + SysMenu info = menuMapper.checkMenuNameUnique(menu.getMenuName(), menu.getParentId()); + if (StringUtils.isNotNull(info) && info.getMenuId().longValue() != menuId.longValue()) + { + return UserConstants.NOT_UNIQUE; + } + return UserConstants.UNIQUE; + } + + /** + * 获取路由名称 + * + * @param menu 菜单信息 + * @return 路由名称 + */ + public String getRouteName(SysMenu menu) + { + String routerName = StringUtils.capitalize(menu.getPath()); + // 非外链并且是一级目录(类型为目录) + if (isMenuFrame(menu)) + { + routerName = StringUtils.EMPTY; + } + return routerName; + } + + /** + * 获取路由地址 + * + * @param menu 菜单信息 + * @return 路由地址 + */ + public String getRouterPath(SysMenu menu) + { + String routerPath = menu.getPath(); + // 内链打开外网方式 + if (menu.getParentId().intValue() != 0 && isInnerLink(menu)) + { + routerPath = StringUtils.replaceEach(routerPath, new String[] { Constants.HTTP, Constants.HTTPS }, new String[] { "", "" }); + } + // 非外链并且是一级目录(类型为目录) + if (0 == menu.getParentId().intValue() && UserConstants.TYPE_DIR.equals(menu.getMenuType()) + && UserConstants.NO_FRAME.equals(menu.getIsFrame())) + { + routerPath = "/" + menu.getPath(); + } + // 非外链并且是一级目录(类型为菜单) + else if (isMenuFrame(menu)) + { + routerPath = "/"; + } + return routerPath; + } + + /** + * 获取组件信息 + * + * @param menu 菜单信息 + * @return 组件信息 + */ + public String getComponent(SysMenu menu) + { + String component = UserConstants.LAYOUT; + if (StringUtils.isNotEmpty(menu.getComponent()) && !isMenuFrame(menu)) + { + component = menu.getComponent(); + } + else if (StringUtils.isEmpty(menu.getComponent()) && menu.getParentId().intValue() != 0 && isInnerLink(menu)) + { + component = UserConstants.INNER_LINK; + } + else if (StringUtils.isEmpty(menu.getComponent()) && isParentView(menu)) + { + component = UserConstants.PARENT_VIEW; + } + return component; + } + + /** + * 是否为菜单内部跳转 + * + * @param menu 菜单信息 + * @return 结果 + */ + public boolean isMenuFrame(SysMenu menu) + { + return menu.getParentId().intValue() == 0 && UserConstants.TYPE_MENU.equals(menu.getMenuType()) + && menu.getIsFrame().equals(UserConstants.NO_FRAME); + } + + /** + * 是否为内链组件 + * + * @param menu 菜单信息 + * @return 结果 + */ + public boolean isInnerLink(SysMenu menu) + { + return menu.getIsFrame().equals(UserConstants.NO_FRAME) && StringUtils.ishttp(menu.getPath()); + } + + /** + * 是否为parent_view组件 + * + * @param menu 菜单信息 + * @return 结果 + */ + public boolean isParentView(SysMenu menu) + { + return menu.getParentId().intValue() != 0 && UserConstants.TYPE_DIR.equals(menu.getMenuType()); + } + + /** + * 根据父节点的ID获取所有子节点 + * + * @param list 分类表 + * @param parentId 传入的父节点ID + * @return String + */ + public List getChildPerms(List list, int parentId) + { + List returnList = new ArrayList(); + for (Iterator iterator = list.iterator(); iterator.hasNext();) + { + SysMenu t = (SysMenu) iterator.next(); + // 一、根据传入的某个父节点ID,遍历该父节点的所有子节点 + if (t.getParentId() == parentId) + { + recursionFn(list, t); + returnList.add(t); + } + } + return returnList; + } + + /** + * 递归列表 + * + * @param list + * @param t + */ + private void recursionFn(List list, SysMenu t) + { + // 得到子节点列表 + List childList = getChildList(list, t); + t.setChildren(childList); + for (SysMenu tChild : childList) + { + if (hasChild(list, tChild)) + { + recursionFn(list, tChild); + } + } + } + + /** + * 得到子节点列表 + */ + private List getChildList(List list, SysMenu t) + { + List tlist = new ArrayList(); + Iterator it = list.iterator(); + while (it.hasNext()) + { + SysMenu n = (SysMenu) it.next(); + if (n.getParentId().longValue() == t.getMenuId().longValue()) + { + tlist.add(n); + } + } + return tlist; + } + + /** + * 判断是否有子节点 + */ + private boolean hasChild(List list, SysMenu t) + { + return getChildList(list, t).size() > 0 ? true : false; + } +} diff --git a/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysNoticeServiceImpl.java b/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysNoticeServiceImpl.java new file mode 100644 index 0000000..f174aa3 --- /dev/null +++ b/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysNoticeServiceImpl.java @@ -0,0 +1,93 @@ +package com.ruoyi.system.service.impl; + +import com.ruoyi.system.domain.SysNotice; +import com.ruoyi.system.mapper.SysNoticeMapper; +import com.ruoyi.system.service.ISysNoticeService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * 公告 服务层实现 + * + * @author ruoyi + */ +@Service +public class SysNoticeServiceImpl implements ISysNoticeService +{ + @Autowired + private SysNoticeMapper noticeMapper; + + /** + * 查询公告信息 + * + * @param noticeId 公告ID + * @return 公告信息 + */ + @Override + public SysNotice selectNoticeById(Long noticeId) + { + return noticeMapper.selectNoticeById(noticeId); + } + + /** + * 查询公告列表 + * + * @param notice 公告信息 + * @return 公告集合 + */ + @Override + public List selectNoticeList(SysNotice notice) + { + return noticeMapper.selectNoticeList(notice); + } + + /** + * 新增公告 + * + * @param notice 公告信息 + * @return 结果 + */ + @Override + public int insertNotice(SysNotice notice) + { + return noticeMapper.insertNotice(notice); + } + + /** + * 修改公告 + * + * @param notice 公告信息 + * @return 结果 + */ + @Override + public int updateNotice(SysNotice notice) + { + return noticeMapper.updateNotice(notice); + } + + /** + * 删除公告对象 + * + * @param noticeId 公告ID + * @return 结果 + */ + @Override + public int deleteNoticeById(Long noticeId) + { + return noticeMapper.deleteNoticeById(noticeId); + } + + /** + * 批量删除公告信息 + * + * @param noticeIds 需要删除的公告ID + * @return 结果 + */ + @Override + public int deleteNoticeByIds(Long[] noticeIds) + { + return noticeMapper.deleteNoticeByIds(noticeIds); + } +} diff --git a/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysOperLogServiceImpl.java b/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysOperLogServiceImpl.java new file mode 100644 index 0000000..59001e3 --- /dev/null +++ b/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysOperLogServiceImpl.java @@ -0,0 +1,77 @@ +package com.ruoyi.system.service.impl; + +import com.ruoyi.system.domain.SysOperLog; +import com.ruoyi.system.mapper.SysOperLogMapper; +import com.ruoyi.system.service.ISysOperLogService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * 操作日志 服务层处理 + * + * @author ruoyi + */ +@Service +public class SysOperLogServiceImpl implements ISysOperLogService +{ + @Autowired + private SysOperLogMapper operLogMapper; + + /** + * 新增操作日志 + * + * @param operLog 操作日志对象 + */ + @Override + public void insertOperlog(SysOperLog operLog) + { + operLogMapper.insertOperlog(operLog); + } + + /** + * 查询系统操作日志集合 + * + * @param operLog 操作日志对象 + * @return 操作日志集合 + */ + @Override + public List selectOperLogList(SysOperLog operLog) + { + return operLogMapper.selectOperLogList(operLog); + } + + /** + * 批量删除系统操作日志 + * + * @param operIds 需要删除的操作日志ID + * @return 结果 + */ + @Override + public int deleteOperLogByIds(Long[] operIds) + { + return operLogMapper.deleteOperLogByIds(operIds); + } + + /** + * 查询操作日志详细 + * + * @param operId 操作ID + * @return 操作日志对象 + */ + @Override + public SysOperLog selectOperLogById(Long operId) + { + return operLogMapper.selectOperLogById(operId); + } + + /** + * 清空操作日志 + */ + @Override + public void cleanOperLog() + { + operLogMapper.cleanOperLog(); + } +} diff --git a/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysPostServiceImpl.java b/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysPostServiceImpl.java new file mode 100644 index 0000000..51827ac --- /dev/null +++ b/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysPostServiceImpl.java @@ -0,0 +1,180 @@ +package com.ruoyi.system.service.impl; + +import com.ruoyi.common.constant.UserConstants; +import com.ruoyi.common.exception.ServiceException; +import com.ruoyi.common.utils.StringUtils; +import com.ruoyi.system.domain.SysPost; +import com.ruoyi.system.mapper.SysPostMapper; +import com.ruoyi.system.mapper.SysUserPostMapper; +import com.ruoyi.system.service.ISysPostService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * 岗位信息 服务层处理 + * + * @author ruoyi + */ +@Service +public class SysPostServiceImpl implements ISysPostService +{ + @Autowired + private SysPostMapper postMapper; + + @Autowired + private SysUserPostMapper userPostMapper; + + /** + * 查询岗位信息集合 + * + * @param post 岗位信息 + * @return 岗位信息集合 + */ + @Override + public List selectPostList(SysPost post) + { + return postMapper.selectPostList(post); + } + + /** + * 查询所有岗位 + * + * @return 岗位列表 + */ + @Override + public List selectPostAll() + { + return postMapper.selectPostAll(); + } + + /** + * 通过岗位ID查询岗位信息 + * + * @param postId 岗位ID + * @return 角色对象信息 + */ + @Override + public SysPost selectPostById(Long postId) + { + return postMapper.selectPostById(postId); + } + + /** + * 根据用户ID获取岗位选择框列表 + * + * @param userId 用户ID + * @return 选中岗位ID列表 + */ + @Override + public List selectPostListByUserId(Long userId) + { + return postMapper.selectPostListByUserId(userId); + } + + /** + * 校验岗位名称是否唯一 + * + * @param post 岗位信息 + * @return 结果 + */ + @Override + public String checkPostNameUnique(SysPost post) + { + Long postId = StringUtils.isNull(post.getPostId()) ? -1L : post.getPostId(); + SysPost info = postMapper.checkPostNameUnique(post.getPostName()); + if (StringUtils.isNotNull(info) && info.getPostId().longValue() != postId.longValue()) + { + return UserConstants.NOT_UNIQUE; + } + return UserConstants.UNIQUE; + } + + /** + * 校验岗位编码是否唯一 + * + * @param post 岗位信息 + * @return 结果 + */ + @Override + public String checkPostCodeUnique(SysPost post) + { + Long postId = StringUtils.isNull(post.getPostId()) ? -1L : post.getPostId(); + SysPost info = postMapper.checkPostCodeUnique(post.getPostCode()); + if (StringUtils.isNotNull(info) && info.getPostId().longValue() != postId.longValue()) + { + return UserConstants.NOT_UNIQUE; + } + return UserConstants.UNIQUE; + } + + /** + * 通过岗位ID查询岗位使用数量 + * + * @param postId 岗位ID + * @return 结果 + */ + @Override + public int countUserPostById(Long postId) + { + return userPostMapper.countUserPostById(postId); + } + + /** + * 删除岗位信息 + * + * @param postId 岗位ID + * @return 结果 + */ + @Override + public int deletePostById(Long postId) + { + return postMapper.deletePostById(postId); + } + + /** + * 批量删除岗位信息 + * + * @param postIds 需要删除的岗位ID + * @return 结果 + * @throws Exception 异常 + */ + @Override + public int deletePostByIds(Long[] postIds) + { + for (Long postId : postIds) + { + SysPost post = selectPostById(postId); + if (countUserPostById(postId) > 0) + { + throw new ServiceException(String.format("%1$s已分配,不能删除", post.getPostName())); + } + } + return postMapper.deletePostByIds(postIds); + } + + /** + * 新增保存岗位信息 + * + * @param post 岗位信息 + * @return 结果 + */ + @Override + public int insertPost(SysPost post) + { + return postMapper.insertPost(post); + } + + /** + * 修改保存岗位信息 + * + * @param post 岗位信息 + * @return 结果 + */ + @Override + public int updatePost(SysPost post) + { + return postMapper.updatePost(post); + } +} diff --git a/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysRoleServiceImpl.java b/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysRoleServiceImpl.java new file mode 100644 index 0000000..0e5d3b3 --- /dev/null +++ b/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysRoleServiceImpl.java @@ -0,0 +1,429 @@ +package com.ruoyi.system.service.impl; + +import com.ruoyi.common.annotation.DataScope; +import com.ruoyi.common.constant.UserConstants; +import com.ruoyi.common.core.domain.entity.SysRole; +import com.ruoyi.common.core.domain.entity.SysUser; +import com.ruoyi.common.exception.ServiceException; +import com.ruoyi.common.utils.SecurityUtils; +import com.ruoyi.common.utils.StringUtils; +import com.ruoyi.common.utils.spring.SpringUtils; +import com.ruoyi.system.domain.SysRoleDept; +import com.ruoyi.system.domain.SysRoleMenu; +import com.ruoyi.system.domain.SysUserRole; +import com.ruoyi.system.mapper.SysRoleDeptMapper; +import com.ruoyi.system.mapper.SysRoleMapper; +import com.ruoyi.system.mapper.SysRoleMenuMapper; +import com.ruoyi.system.mapper.SysUserRoleMapper; +import com.ruoyi.system.service.ISysRoleService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.*; + +/** + * 角色 业务层处理 + * + * @author ruoyi + */ +@Service +public class SysRoleServiceImpl implements ISysRoleService +{ + @Autowired + private SysRoleMapper roleMapper; + + @Autowired + private SysRoleMenuMapper roleMenuMapper; + + @Autowired + private SysUserRoleMapper userRoleMapper; + + @Autowired + private SysRoleDeptMapper roleDeptMapper; + + /** + * 根据条件分页查询角色数据 + * + * @param role 角色信息 + * @return 角色数据集合信息 + */ + @Override + @DataScope(deptAlias = "d") + public List selectRoleList(SysRole role) + { + return roleMapper.selectRoleList(role); + } + + /** + * 根据用户ID查询角色 + * + * @param userId 用户ID + * @return 角色列表 + */ + @Override + public List selectRolesByUserId(Long userId) + { + List userRoles = roleMapper.selectRolePermissionByUserId(userId); + List roles = selectRoleAll(); + for (SysRole role : roles) + { + for (SysRole userRole : userRoles) + { + if (role.getRoleId().longValue() == userRole.getRoleId().longValue()) + { + role.setFlag(true); + break; + } + } + } + return roles; + } + + /** + * 根据用户ID查询权限 + * + * @param userId 用户ID + * @return 权限列表 + */ + @Override + public Set selectRolePermissionByUserId(Long userId) + { + List perms = roleMapper.selectRolePermissionByUserId(userId); + Set permsSet = new HashSet<>(); + for (SysRole perm : perms) + { + if (StringUtils.isNotNull(perm)) + { + permsSet.addAll(Arrays.asList(perm.getRoleKey().trim().split(","))); + } + } + return permsSet; + } + + /** + * 查询所有角色 + * + * @return 角色列表 + */ + @Override + public List selectRoleAll() + { + return SpringUtils.getAopProxy(this).selectRoleList(new SysRole()); + } + + /** + * 根据用户ID获取角色选择框列表 + * + * @param userId 用户ID + * @return 选中角色ID列表 + */ + @Override + public List selectRoleListByUserId(Long userId) + { + return roleMapper.selectRoleListByUserId(userId); + } + + /** + * 通过角色ID查询角色 + * + * @param roleId 角色ID + * @return 角色对象信息 + */ + @Override + public SysRole selectRoleById(Long roleId) + { + return roleMapper.selectRoleById(roleId); + } + + /** + * 校验角色名称是否唯一 + * + * @param role 角色信息 + * @return 结果 + */ + @Override + public String checkRoleNameUnique(SysRole role) + { + Long roleId = StringUtils.isNull(role.getRoleId()) ? -1L : role.getRoleId(); + SysRole info = roleMapper.checkRoleNameUnique(role.getRoleName()); + if (StringUtils.isNotNull(info) && info.getRoleId().longValue() != roleId.longValue()) + { + return UserConstants.NOT_UNIQUE; + } + return UserConstants.UNIQUE; + } + + /** + * 校验角色权限是否唯一 + * + * @param role 角色信息 + * @return 结果 + */ + @Override + public String checkRoleKeyUnique(SysRole role) + { + Long roleId = StringUtils.isNull(role.getRoleId()) ? -1L : role.getRoleId(); + SysRole info = roleMapper.checkRoleKeyUnique(role.getRoleKey()); + if (StringUtils.isNotNull(info) && info.getRoleId().longValue() != roleId.longValue()) + { + return UserConstants.NOT_UNIQUE; + } + return UserConstants.UNIQUE; + } + + /** + * 校验角色是否允许操作 + * + * @param role 角色信息 + */ + @Override + public void checkRoleAllowed(SysRole role) + { + if (StringUtils.isNotNull(role.getRoleId()) && role.isAdmin()) + { + throw new ServiceException("不允许操作超级管理员角色"); + } + } + + /** + * 校验角色是否有数据权限 + * + * @param roleId 角色id + */ + @Override + public void checkRoleDataScope(Long roleId) + { + if (!SysUser.isAdmin(SecurityUtils.getUserId())) + { + SysRole role = new SysRole(); + role.setRoleId(roleId); + List roles = SpringUtils.getAopProxy(this).selectRoleList(role); + if (StringUtils.isEmpty(roles)) + { + throw new ServiceException("没有权限访问角色数据!"); + } + } + } + + /** + * 通过角色ID查询角色使用数量 + * + * @param roleId 角色ID + * @return 结果 + */ + @Override + public int countUserRoleByRoleId(Long roleId) + { + return userRoleMapper.countUserRoleByRoleId(roleId); + } + + /** + * 新增保存角色信息 + * + * @param role 角色信息 + * @return 结果 + */ + @Override + @Transactional + public int insertRole(SysRole role) + { + // 新增角色信息 + roleMapper.insertRole(role); + return insertRoleMenu(role); + } + + /** + * 修改保存角色信息 + * + * @param role 角色信息 + * @return 结果 + */ + @Override + @Transactional + public int updateRole(SysRole role) + { + // 修改角色信息 + roleMapper.updateRole(role); + // 删除角色与菜单关联 + roleMenuMapper.deleteRoleMenuByRoleId(role.getRoleId()); + return insertRoleMenu(role); + } + + /** + * 修改角色状态 + * + * @param role 角色信息 + * @return 结果 + */ + @Override + public int updateRoleStatus(SysRole role) + { + return roleMapper.updateRole(role); + } + + /** + * 修改数据权限信息 + * + * @param role 角色信息 + * @return 结果 + */ + @Override + @Transactional + public int authDataScope(SysRole role) + { + // 修改角色信息 + roleMapper.updateRole(role); + // 删除角色与部门关联 + roleDeptMapper.deleteRoleDeptByRoleId(role.getRoleId()); + // 新增角色和部门信息(数据权限) + return insertRoleDept(role); + } + + /** + * 新增角色菜单信息 + * + * @param role 角色对象 + */ + public int insertRoleMenu(SysRole role) + { + int rows = 1; + // 新增用户与角色管理 + List list = new ArrayList(); + for (Long menuId : role.getMenuIds()) + { + SysRoleMenu rm = new SysRoleMenu(); + rm.setRoleId(role.getRoleId()); + rm.setMenuId(menuId); + list.add(rm); + } + if (list.size() > 0) + { + rows = roleMenuMapper.batchRoleMenu(list); + } + return rows; + } + + /** + * 新增角色部门信息(数据权限) + * + * @param role 角色对象 + */ + public int insertRoleDept(SysRole role) + { + int rows = 1; + // 新增角色与部门(数据权限)管理 + List list = new ArrayList(); + for (Long deptId : role.getDeptIds()) + { + SysRoleDept rd = new SysRoleDept(); + rd.setRoleId(role.getRoleId()); + rd.setDeptId(deptId); + list.add(rd); + } + if (list.size() > 0) + { + rows = roleDeptMapper.batchRoleDept(list); + } + return rows; + } + + /** + * 通过角色ID删除角色 + * + * @param roleId 角色ID + * @return 结果 + */ + @Override + @Transactional + public int deleteRoleById(Long roleId) + { + // 删除角色与菜单关联 + roleMenuMapper.deleteRoleMenuByRoleId(roleId); + // 删除角色与部门关联 + roleDeptMapper.deleteRoleDeptByRoleId(roleId); + return roleMapper.deleteRoleById(roleId); + } + + /** + * 批量删除角色信息 + * + * @param roleIds 需要删除的角色ID + * @return 结果 + */ + @Override + @Transactional + public int deleteRoleByIds(Long[] roleIds) + { + + //企业角色不能删除 + List roleIdsList = Arrays.asList(roleIds); + SysRole sysRole = new SysRole(); + sysRole.setRoleKey("enterprise"); + List sysRoles = this.selectRoleList(sysRole); + if (roleIdsList.contains(sysRoles.get(0).getRoleId())){ + throw new ServiceException("企业角色不能删除"); + } + for (Long roleId : roleIds) + { + checkRoleAllowed(new SysRole(roleId)); + SysRole role = selectRoleById(roleId); + if (countUserRoleByRoleId(roleId) > 0) + { + throw new ServiceException(String.format("%1$s已分配,不能删除", role.getRoleName())); + } + } + // 删除角色与菜单关联 + roleMenuMapper.deleteRoleMenu(roleIds); + // 删除角色与部门关联 + roleDeptMapper.deleteRoleDept(roleIds); + return roleMapper.deleteRoleByIds(roleIds); + } + + /** + * 取消授权用户角色 + * + * @param userRole 用户和角色关联信息 + * @return 结果 + */ + @Override + public int deleteAuthUser(SysUserRole userRole) + { + return userRoleMapper.deleteUserRoleInfo(userRole); + } + + /** + * 批量取消授权用户角色 + * + * @param roleId 角色ID + * @param userIds 需要取消授权的用户数据ID + * @return 结果 + */ + @Override + public int deleteAuthUsers(Long roleId, Long[] userIds) + { + return userRoleMapper.deleteUserRoleInfos(roleId, userIds); + } + + /** + * 批量选择授权用户角色 + * + * @param roleId 角色ID + * @param userIds 需要删除的用户数据ID + * @return 结果 + */ + @Override + public int insertAuthUsers(Long roleId, Long[] userIds) + { + // 新增用户与角色管理 + List list = new ArrayList(); + for (Long userId : userIds) + { + SysUserRole ur = new SysUserRole(); + ur.setUserId(userId); + ur.setRoleId(roleId); + list.add(ur); + } + return userRoleMapper.batchUserRole(list); + } +} diff --git a/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysTenantServiceImpl.java b/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysTenantServiceImpl.java new file mode 100644 index 0000000..6d74499 --- /dev/null +++ b/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysTenantServiceImpl.java @@ -0,0 +1,58 @@ +package com.ruoyi.system.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.ruoyi.common.core.domain.entity.SysDept; +import com.ruoyi.common.core.domain.entity.SysTenant; +import com.ruoyi.common.core.domain.entity.SysUser; +import com.ruoyi.common.utils.SecurityUtils; +import com.ruoyi.common.utils.StringUtils; +import com.ruoyi.system.mapper.SysTenantMapper; +import com.ruoyi.system.service.ISysDeptService; +import com.ruoyi.system.service.ISysTenantService; +import com.ruoyi.system.service.ISysUserService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + + +/** + * All rights Reserved, Designed By www.sunseagear.com + * + * @version V1.0 + * @package sys + * @title: 租户管理控制器 + * @description: 租户管理控制器 + * @author: 未知 + * @date: 2019-11-28 06:24:52 + * @copyright: www.sunseagear.com Inc. All rights reserved. + */ +@Transactional +@Service +public class SysTenantServiceImpl extends ServiceImpl implements ISysTenantService { + + @Autowired + private ISysDeptService sysDeptService; + @Autowired + private ISysUserService sysUserService; + + @Override + public boolean save(SysTenant entity) { + entity.setTenantId(StringUtils.randomNumber(8)); + SysDept dept = new SysDept(); + dept.setDeptName(entity.getName()); + dept.setTenantId(entity.getTenantId()); + sysDeptService.insertDept(dept); + SysUser user = new SysUser(); + user.setUserName(entity.getUserName()); + user.setNickName(entity.getName()); + user.setPhonenumber(entity.getPhone()); + user.setDeptId(dept.getDeptId()); + user.setTenantId(entity.getTenantId()); + user.setPassword(SecurityUtils.encryptPassword(entity.getTenantId())); + sysUserService.insertUser(user); + Long[] roleIds = {2L}; + sysUserService.insertUserAuth(user.getUserId(), roleIds); + entity.setUserId(user.getUserId()); + return super.save(entity); + } +} diff --git a/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserOnlineServiceImpl.java b/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserOnlineServiceImpl.java new file mode 100644 index 0000000..7386ae0 --- /dev/null +++ b/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserOnlineServiceImpl.java @@ -0,0 +1,96 @@ +package com.ruoyi.system.service.impl; + +import com.ruoyi.common.core.domain.model.LoginUser; +import com.ruoyi.common.utils.StringUtils; +import com.ruoyi.system.domain.SysUserOnline; +import com.ruoyi.system.service.ISysUserOnlineService; +import org.springframework.stereotype.Service; + +/** + * 在线用户 服务层处理 + * + * @author ruoyi + */ +@Service +public class SysUserOnlineServiceImpl implements ISysUserOnlineService +{ + /** + * 通过登录地址查询信息 + * + * @param ipaddr 登录地址 + * @param user 用户信息 + * @return 在线用户信息 + */ + @Override + public SysUserOnline selectOnlineByIpaddr(String ipaddr, LoginUser user) + { + if (StringUtils.equals(ipaddr, user.getIpaddr())) + { + return loginUserToUserOnline(user); + } + return null; + } + + /** + * 通过用户名称查询信息 + * + * @param userName 用户名称 + * @param user 用户信息 + * @return 在线用户信息 + */ + @Override + public SysUserOnline selectOnlineByUserName(String userName, LoginUser user) + { + if (StringUtils.equals(userName, user.getUsername())) + { + return loginUserToUserOnline(user); + } + return null; + } + + /** + * 通过登录地址/用户名称查询信息 + * + * @param ipaddr 登录地址 + * @param userName 用户名称 + * @param user 用户信息 + * @return 在线用户信息 + */ + @Override + public SysUserOnline selectOnlineByInfo(String ipaddr, String userName, LoginUser user) + { + if (StringUtils.equals(ipaddr, user.getIpaddr()) && StringUtils.equals(userName, user.getUsername())) + { + return loginUserToUserOnline(user); + } + return null; + } + + /** + * 设置在线用户信息 + * + * @param user 用户信息 + * @return 在线用户 + */ + @Override + public SysUserOnline loginUserToUserOnline(LoginUser user) + { + if (StringUtils.isNull(user) || StringUtils.isNull(user.getUser())) + { + return null; + } + SysUserOnline sysUserOnline = new SysUserOnline(); + sysUserOnline.setTokenId(user.getToken()); + sysUserOnline.setUserName(user.getUsername()); + sysUserOnline.setIpaddr(user.getIpaddr()); + sysUserOnline.setLoginLocation(user.getLoginLocation()); + sysUserOnline.setBrowser(user.getBrowser()); + sysUserOnline.setOs(user.getOs()); + sysUserOnline.setLoginTime(user.getLoginTime()); + if (StringUtils.isNotNull(user.getUser().getDept())) + { + sysUserOnline.setDeptName(user.getUser().getDept().getDeptName()); + } + return sysUserOnline; + } +} diff --git a/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java b/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java new file mode 100644 index 0000000..f1d4a7e --- /dev/null +++ b/ruoyi-base-support/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java @@ -0,0 +1,560 @@ +package com.ruoyi.system.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.ruoyi.common.annotation.DataScope; +import com.ruoyi.common.constant.UserConstants; +import com.ruoyi.common.core.domain.entity.SysRole; +import com.ruoyi.common.core.domain.entity.SysUser; +import com.ruoyi.common.exception.ServiceException; +import com.ruoyi.common.utils.SecurityUtils; +import com.ruoyi.common.utils.StringUtils; +import com.ruoyi.common.utils.spring.SpringUtils; +import com.ruoyi.system.domain.SysPost; +import com.ruoyi.system.domain.SysUserPost; +import com.ruoyi.system.domain.SysUserRole; +import com.ruoyi.system.mapper.*; +import com.ruoyi.system.service.ISysConfigService; +import com.ruoyi.system.service.ISysUserService; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.ArrayList; +import java.util.List; + +/** + * 用户 业务层处理 + * + * @author ruoyi + */ +@Service +public class SysUserServiceImpl extends ServiceImpl implements ISysUserService +{ + private static final Logger log = LoggerFactory.getLogger(SysUserServiceImpl.class); + + @Autowired + private SysUserMapper userMapper; + + @Autowired + private SysRoleMapper roleMapper; + + @Autowired + private SysPostMapper postMapper; + + @Autowired + private SysUserRoleMapper userRoleMapper; + + @Autowired + private SysUserPostMapper userPostMapper; + + @Autowired + private ISysConfigService configService; + + /** + * 根据条件分页查询用户列表 + * + * @param user 用户信息 + * @return 用户信息集合信息 + */ + @Override + @DataScope(deptAlias = "d", userAlias = "u") + public List selectUserList(SysUser user) + { + return userMapper.selectUserList(user); + } + + /** + * 根据条件分页查询已分配用户角色列表 + * + * @param user 用户信息 + * @return 用户信息集合信息 + */ + @Override + @DataScope(deptAlias = "d", userAlias = "u") + public List selectAllocatedList(SysUser user) + { + return userMapper.selectAllocatedList(user); + } + + /** + * 根据条件分页查询未分配用户角色列表 + * + * @param user 用户信息 + * @return 用户信息集合信息 + */ + @Override + @DataScope(deptAlias = "d", userAlias = "u") + public List selectUnallocatedList(SysUser user) + { + return userMapper.selectUnallocatedList(user); + } + + /** + * 通过用户名查询用户 + * + * @param userName 用户名 + * @return 用户对象信息 + */ + @Override + public SysUser selectUserByUserName(String userName) + { + return userMapper.selectUserByUserName(userName); + } + + /** + * 通过用户ID查询用户 + * + * @param userId 用户ID + * @return 用户对象信息 + */ + @Override + public SysUser selectUserById(Long userId) + { + return userMapper.selectUserById(userId); + } + + /** + * 查询用户所属角色组 + * + * @param userName 用户名 + * @return 结果 + */ + @Override + public String selectUserRoleGroup(String userName) + { + List list = roleMapper.selectRolesByUserName(userName); + StringBuffer idsStr = new StringBuffer(); + for (SysRole role : list) + { + idsStr.append(role.getRoleName()).append(","); + } + if (StringUtils.isNotEmpty(idsStr.toString())) + { + return idsStr.substring(0, idsStr.length() - 1); + } + return idsStr.toString(); + } + + /** + * 查询用户所属岗位组 + * + * @param userName 用户名 + * @return 结果 + */ + @Override + public String selectUserPostGroup(String userName) + { + List list = postMapper.selectPostsByUserName(userName); + StringBuffer idsStr = new StringBuffer(); + for (SysPost post : list) + { + idsStr.append(post.getPostName()).append(","); + } + if (StringUtils.isNotEmpty(idsStr.toString())) + { + return idsStr.substring(0, idsStr.length() - 1); + } + return idsStr.toString(); + } + + /** + * 校验用户名称是否唯一 + * + * @param userName 用户名称 + * @return 结果 + */ + @Override + public String checkUserNameUnique(String userName) + { + int count = userMapper.checkUserNameUnique(userName); + if (count > 0) + { + return UserConstants.NOT_UNIQUE; + } + return UserConstants.UNIQUE; + } + + /** + * 校验用户名称是否唯一 + * + * @param user 用户信息 + * @return + */ + @Override + public String checkPhoneUnique(SysUser user) + { + Long userId = StringUtils.isNull(user.getUserId()) ? -1L : user.getUserId(); + SysUser info = userMapper.checkPhoneUnique(user.getPhonenumber()); + if (StringUtils.isNotNull(info) && info.getUserId().longValue() != userId.longValue()) + { + return UserConstants.NOT_UNIQUE; + } + return UserConstants.UNIQUE; + } + + /** + * 校验email是否唯一 + * + * @param user 用户信息 + * @return + */ + @Override + public String checkEmailUnique(SysUser user) + { + Long userId = StringUtils.isNull(user.getUserId()) ? -1L : user.getUserId(); + SysUser info = userMapper.checkEmailUnique(user.getEmail()); + if (StringUtils.isNotNull(info) && info.getUserId().longValue() != userId.longValue()) + { + return UserConstants.NOT_UNIQUE; + } + return UserConstants.UNIQUE; + } + + /** + * 校验用户是否允许操作 + * + * @param user 用户信息 + */ + @Override + public void checkUserAllowed(SysUser user) + { + if (StringUtils.isNotNull(user.getUserId()) && user.isAdmin()) + { + throw new ServiceException("不允许操作超级管理员用户"); + } + } + + /** + * 校验用户是否有数据权限 + * + * @param userId 用户id + */ + @Override + public void checkUserDataScope(Long userId) + { + if (!SysUser.isAdmin(SecurityUtils.getUserId())) + { + SysUser user = new SysUser(); + user.setUserId(userId); + List users = SpringUtils.getAopProxy(this).selectUserList(user); + if (StringUtils.isEmpty(users)) + { + throw new ServiceException("没有权限访问用户数据!"); + } + } + } + + /** + * 新增保存用户信息 + * + * @param user 用户信息 + * @return 结果 + */ + @Override + @Transactional + public int insertUser(SysUser user) + { + // 新增用户信息 + int rows = userMapper.insertUser(user); + // 新增用户岗位关联 + insertUserPost(user); + // 新增用户与角色管理 + insertUserRole(user); + return rows; + } + + /** + * 注册用户信息 + * + * @param user 用户信息 + * @return 结果 + */ + @Override + public boolean registerUser(SysUser user) + { + return userMapper.insertUser(user) > 0; + } + + /** + * 修改保存用户信息 + * + * @param user 用户信息 + * @return 结果 + */ + @Override + @Transactional + public int updateUser(SysUser user) + { + Long userId = user.getUserId(); + // 删除用户与角色关联 + userRoleMapper.deleteUserRoleByUserId(userId); + // 新增用户与角色管理 + insertUserRole(user); + // 删除用户与岗位关联 + userPostMapper.deleteUserPostByUserId(userId); + // 新增用户与岗位管理 + insertUserPost(user); + return userMapper.updateUser(user); + } + + /** + * 用户授权角色 + * + * @param userId 用户ID + * @param roleIds 角色组 + */ + @Override + @Transactional + public void insertUserAuth(Long userId, Long[] roleIds) + { + userRoleMapper.deleteUserRoleByUserId(userId); + insertUserRole(userId, roleIds); + } + + /** + * 修改用户状态 + * + * @param user 用户信息 + * @return 结果 + */ + @Override + public int updateUserStatus(SysUser user) + { + return userMapper.updateUser(user); + } + + /** + * 修改用户基本信息 + * + * @param user 用户信息 + * @return 结果 + */ + @Override + public int updateUserProfile(SysUser user) + { + return userMapper.updateUser(user); + } + + /** + * 修改用户头像 + * + * @param userName 用户名 + * @param avatar 头像地址 + * @return 结果 + */ + @Override + public boolean updateUserAvatar(String userName, String avatar) + { + return userMapper.updateUserAvatar(userName, avatar) > 0; + } + + /** + * 重置用户密码 + * + * @param user 用户信息 + * @return 结果 + */ + @Override + public int resetPwd(SysUser user) + { + return userMapper.updateUser(user); + } + + /** + * 重置用户密码 + * + * @param userName 用户名 + * @param password 密码 + * @return 结果 + */ + @Override + public int resetUserPwd(String userName, String password) + { + return userMapper.resetUserPwd(userName, password); + } + + /** + * 新增用户角色信息 + * + * @param user 用户对象 + */ + public void insertUserRole(SysUser user) + { + Long[] roles = user.getRoleIds(); + if (StringUtils.isNotNull(roles)) + { + // 新增用户与角色管理 + List list = new ArrayList(); + for (Long roleId : roles) + { + SysUserRole ur = new SysUserRole(); + ur.setUserId(user.getUserId()); + ur.setRoleId(roleId); + list.add(ur); + } + if (list.size() > 0) + { + userRoleMapper.batchUserRole(list); + } + } + } + + /** + * 新增用户岗位信息 + * + * @param user 用户对象 + */ + public void insertUserPost(SysUser user) + { + Long[] posts = user.getPostIds(); + if (StringUtils.isNotNull(posts)) + { + // 新增用户与岗位管理 + List list = new ArrayList(); + for (Long postId : posts) + { + SysUserPost up = new SysUserPost(); + up.setUserId(user.getUserId()); + up.setPostId(postId); + list.add(up); + } + if (list.size() > 0) + { + userPostMapper.batchUserPost(list); + } + } + } + + /** + * 新增用户角色信息 + * + * @param userId 用户ID + * @param roleIds 角色组 + */ + public void insertUserRole(Long userId, Long[] roleIds) + { + if (StringUtils.isNotNull(roleIds)) + { + // 新增用户与角色管理 + List list = new ArrayList(); + for (Long roleId : roleIds) + { + SysUserRole ur = new SysUserRole(); + ur.setUserId(userId); + ur.setRoleId(roleId); + list.add(ur); + } + if (list.size() > 0) + { + userRoleMapper.batchUserRole(list); + } + } + } + + /** + * 通过用户ID删除用户 + * + * @param userId 用户ID + * @return 结果 + */ + @Override + @Transactional + public int deleteUserById(Long userId) + { + // 删除用户与角色关联 + userRoleMapper.deleteUserRoleByUserId(userId); + // 删除用户与岗位表 + userPostMapper.deleteUserPostByUserId(userId); + return userMapper.deleteUserById(userId); + } + + /** + * 批量删除用户信息 + * + * @param userIds 需要删除的用户ID + * @return 结果 + */ + @Override + @Transactional + public int deleteUserByIds(Long[] userIds) + { + for (Long userId : userIds) + { + checkUserAllowed(new SysUser(userId)); + } + // 删除用户与角色关联 + userRoleMapper.deleteUserRole(userIds); + // 删除用户与岗位关联 + userPostMapper.deleteUserPost(userIds); + return userMapper.deleteUserByIds(userIds); + } + + /** + * 导入用户数据 + * + * @param userList 用户数据列表 + * @param isUpdateSupport 是否更新支持,如果已存在,则进行更新数据 + * @param operName 操作用户 + * @return 结果 + */ + @Override + public String importUser(List userList, Boolean isUpdateSupport, String operName) + { + if (StringUtils.isNull(userList) || userList.size() == 0) + { + throw new ServiceException("导入用户数据不能为空!"); + } + int successNum = 0; + int failureNum = 0; + StringBuilder successMsg = new StringBuilder(); + StringBuilder failureMsg = new StringBuilder(); + String password = configService.selectConfigByKey("sys.user.initPassword"); + for (SysUser user : userList) + { + try + { + // 验证是否存在这个用户 + SysUser u = userMapper.selectUserByUserName(user.getUserName()); + if (StringUtils.isNull(u)) + { + user.setPassword(SecurityUtils.encryptPassword(password)); + user.setCreateBy(operName); + this.insertUser(user); + successNum++; + successMsg.append("
" + successNum + "、账号 " + user.getUserName() + " 导入成功"); + } + else if (isUpdateSupport) + { + user.setUpdateBy(operName); + this.updateUser(user); + successNum++; + successMsg.append("
" + successNum + "、账号 " + user.getUserName() + " 更新成功"); + } + else + { + failureNum++; + failureMsg.append("
" + failureNum + "、账号 " + user.getUserName() + " 已存在"); + } + } + catch (Exception e) + { + failureNum++; + String msg = "
" + failureNum + "、账号 " + user.getUserName() + " 导入失败:"; + failureMsg.append(msg + e.getMessage()); + log.error(msg, e); + } + } + if (failureNum > 0) + { + failureMsg.insert(0, "很抱歉,导入失败!共 " + failureNum + " 条数据格式不正确,错误如下:"); + throw new ServiceException(failureMsg.toString()); + } + else + { + successMsg.insert(0, "恭喜您,数据已全部导入成功!共 " + successNum + " 条,数据如下:"); + } + return successMsg.toString(); + } +} diff --git a/ruoyi-base-support/ruoyi-tenant/pom.xml b/ruoyi-base-support/ruoyi-tenant/pom.xml new file mode 100644 index 0000000..3ea6928 --- /dev/null +++ b/ruoyi-base-support/ruoyi-tenant/pom.xml @@ -0,0 +1,35 @@ + + + + ruoyi-base-support + com.ruoyi + 3.7.0 + + 4.0.0 + + ruoyi-tenant + + + 17 + 17 + + + + + org.projectlombok + lombok + + + com.baomidou + mybatis-plus-extension + ${mybatis-plus-boot-starter.version} + compile + + + com.ruoyi + ruoyi-common + + + diff --git a/ruoyi-base-support/ruoyi-tenant/src/main/java/com/ruoyi/tenant/CommonTenantHandler.java b/ruoyi-base-support/ruoyi-tenant/src/main/java/com/ruoyi/tenant/CommonTenantHandler.java new file mode 100644 index 0000000..6da3856 --- /dev/null +++ b/ruoyi-base-support/ruoyi-tenant/src/main/java/com/ruoyi/tenant/CommonTenantHandler.java @@ -0,0 +1,52 @@ +package com.ruoyi.tenant; + +import com.baomidou.mybatisplus.extension.plugins.handler.TenantLineHandler; +import com.ruoyi.common.utils.SecurityUtils; +import com.ruoyi.common.utils.StringUtils; +import lombok.AllArgsConstructor; +import net.sf.jsqlparser.expression.Expression; +import net.sf.jsqlparser.expression.StringValue; + + +@AllArgsConstructor +public class CommonTenantHandler implements TenantLineHandler { + + /** + * 获取租户ID + * + * @return 租户ID + */ + @Override + public Expression getTenantId() { + if (SecurityUtils.getLoginUser() != null) { + String tenantId = SecurityUtils.getLoginUser().getTenantId(); + if (!StringUtils.isEmpty(tenantId)) { + return new StringValue(tenantId); + } + } + return new StringValue(TenantProperties.getInstance().getDefaultTenantId()); + } + /** + * 获取租户字段名称 + * + * @return 租户字段名称 + */ + @Override + public String getTenantIdColumn() { + return TenantProperties.getInstance().getColumn(); + } + + /** + * 过滤租户表 + * + * @param tableName 表名 + * @return 是否进行过滤 返回true 表示不进行多租户处理 + */ + @Override + public boolean ignoreTable(String tableName) { + if (Boolean.FALSE.equals(TenantProperties.getInstance().getEnable())){ + return true; + } + return TenantProperties.getInstance().getIgnoreTables().contains(tableName); + } +} diff --git a/ruoyi-base-support/ruoyi-tenant/src/main/java/com/ruoyi/tenant/TenantConfiguration.java b/ruoyi-base-support/ruoyi-tenant/src/main/java/com/ruoyi/tenant/TenantConfiguration.java new file mode 100644 index 0000000..cebc39b --- /dev/null +++ b/ruoyi-base-support/ruoyi-tenant/src/main/java/com/ruoyi/tenant/TenantConfiguration.java @@ -0,0 +1,46 @@ +package com.ruoyi.tenant; + +import com.baomidou.mybatisplus.extension.plugins.handler.TenantLineHandler; +import lombok.AllArgsConstructor; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + + +@Configuration +@AllArgsConstructor +public class TenantConfiguration { + + /** + * 自定义租户处理器 + * + * @return TenantHandler + */ + @Bean + @ConditionalOnMissingBean(TenantLineHandler.class) + public TenantLineHandler tenantHandler() { + return new CommonTenantHandler(); + } + + /** + * 分页插件 + * + * @param tenantHandler 自定义租户处理器 + * @return PaginationInterceptor + *//* + @Bean + public PaginationInnerInterceptor paginationInterceptor(TenantLineHandler tenantHandler) { + PaginationInnerInterceptor paginationInterceptor = new PaginationInnerInterceptor(); + paginationInterceptor. + List sqlParserList = new ArrayList<>(); + TenantSqlParser tenantSqlParser = new TenantSqlParser(); + tenantSqlParser.setTenantHandler(tenantHandler); + sqlParserList.add(tenantSqlParser); + paginationInterceptor.setSqlParserList(sqlParserList); + return paginationInterceptor; + }*/ + /** + * 新多租户插件配置,一缓和二缓遵循mybatis的规则,需要设置 MybatisConfiguration#useDeprecatedExecutor = false 避免缓存万一出现问题 + */ + +} diff --git a/ruoyi-base-support/ruoyi-tenant/src/main/java/com/ruoyi/tenant/TenantProperties.java b/ruoyi-base-support/ruoyi-tenant/src/main/java/com/ruoyi/tenant/TenantProperties.java new file mode 100644 index 0000000..83b010a --- /dev/null +++ b/ruoyi-base-support/ruoyi-tenant/src/main/java/com/ruoyi/tenant/TenantProperties.java @@ -0,0 +1,41 @@ +package com.ruoyi.tenant; + +import lombok.Data; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + + +@Data +public class TenantProperties { + + private static TenantProperties instance; + + private Boolean enable = false; + + private String defaultTenantId = "00000000"; + + /** + * 多租户字段名称 + */ + private String column = "tenant_id"; + + /** + * 多租户系统数据表 + */ + private List ignoreTables = new ArrayList<>(); + + + private TenantProperties() { + } + + public static TenantProperties getInstance() { + if (instance == null) { + instance = new TenantProperties(); + instance.getIgnoreTables().addAll(Arrays.asList("sys_menu", "sys_config", "sys_dict_data", "sys_dict_type", "sys_role_data_rule", "gen_table","columns","tables", + "gen_table_column", "sys_role_menu", "sys_logininfor", "sys_tenant", "sys_user", "sys_user_post","sys_role_dept", "sys_role_menu", "sys_role", "sys_dept", "sys_user_role", "sys_job", "sys_job_log", "sys_oper_log")); + } + return instance; + } +} diff --git a/ruoyi-extend/pom.xml b/ruoyi-extend/pom.xml new file mode 100644 index 0000000..0bb1ecd --- /dev/null +++ b/ruoyi-extend/pom.xml @@ -0,0 +1,25 @@ + + + + com.ruoyi + ruoyi + 3.7.0 + + + ruoyi-business + ruoyi-job + + + 4.0.0 + pom + ruoyi-extend + + + 8 + 8 + UTF-8 + + + diff --git a/ruoyi-extend/ruoyi-business/pom.xml b/ruoyi-extend/ruoyi-business/pom.xml new file mode 100644 index 0000000..7759f58 --- /dev/null +++ b/ruoyi-extend/ruoyi-business/pom.xml @@ -0,0 +1,79 @@ + + + 4.0.0 + + com.ruoyi + ruoyi-extend + 3.7.0 + + + ruoyi-business + + + 8 + 8 + UTF-8 + + + + + + com.belerweb + pinyin4j + 2.5.0 + + + + com.ruoyi + ruoyi-admin-core + 3.7.0 + + + + com.ruoyi + ruoyi-custom + 3.7.0 + + + + com.ruoyi + ruoyi-post + 3.7.0 + + + + + + + + org.springframework.boot + spring-boot-maven-plugin + 2.1.1.RELEASE + + true + true + + + + + repackage + + + + + + org.apache.maven.plugins + maven-war-plugin + 3.1.0 + + false + ${project.artifactId} + + + + ${project.artifactId} + + + diff --git a/ruoyi-extend/ruoyi-business/src/main/java/com/ruoyi/RuoYiApplication.java b/ruoyi-extend/ruoyi-business/src/main/java/com/ruoyi/RuoYiApplication.java new file mode 100644 index 0000000..3a7e8ff --- /dev/null +++ b/ruoyi-extend/ruoyi-business/src/main/java/com/ruoyi/RuoYiApplication.java @@ -0,0 +1,25 @@ +package com.ruoyi; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; +import org.springframework.scheduling.annotation.EnableAsync; +import org.springframework.scheduling.annotation.EnableScheduling; + +/** + * 启动程序 + * + * @author ruoyi + */ +@EnableAsync +@EnableScheduling +@SpringBootApplication(exclude = { DataSourceAutoConfiguration.class }) +public class RuoYiApplication +{ + public static void main(String[] args) + { +// System.setProperty("spring.devtools.restart.enabled", "false"); + SpringApplication.run(RuoYiApplication.class, args); + System.out.println("(♥◠‿◠)ノ゙ 后台系统启动成功 ლ(´ڡ`ლ)゙"); + } +} diff --git a/ruoyi-extend/ruoyi-business/src/main/java/com/ruoyi/RuoYiServletInitializer.java b/ruoyi-extend/ruoyi-business/src/main/java/com/ruoyi/RuoYiServletInitializer.java new file mode 100644 index 0000000..faae605 --- /dev/null +++ b/ruoyi-extend/ruoyi-business/src/main/java/com/ruoyi/RuoYiServletInitializer.java @@ -0,0 +1,18 @@ +package com.ruoyi; + +import org.springframework.boot.builder.SpringApplicationBuilder; +import org.springframework.boot.web.servlet.support.SpringBootServletInitializer; + +/** + * web容器中进行部署 + * + * @author ruoyi + */ +public class RuoYiServletInitializer extends SpringBootServletInitializer +{ + @Override + protected SpringApplicationBuilder configure(SpringApplicationBuilder application) + { + return application.sources(RuoYiApplication.class); + } +} diff --git a/ruoyi-extend/ruoyi-business/src/main/java/com/ruoyi/dataanalysis/controller/DataAnalysisController.java b/ruoyi-extend/ruoyi-business/src/main/java/com/ruoyi/dataanalysis/controller/DataAnalysisController.java new file mode 100644 index 0000000..a8573cd --- /dev/null +++ b/ruoyi-extend/ruoyi-business/src/main/java/com/ruoyi/dataanalysis/controller/DataAnalysisController.java @@ -0,0 +1,163 @@ +package com.ruoyi.dataanalysis.controller; + +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.page.TableDataInfo; +import com.ruoyi.common.utils.StringUtils; +import com.ruoyi.dataanalysis.model.param.CustomerChartsParam; +import com.ruoyi.dataanalysis.model.param.OrderSortParam; +import com.ruoyi.dataanalysis.model.param.SaleChartsParam; +import com.ruoyi.dataanalysis.model.param.StoreChartsParam; +import com.ruoyi.dataanalysis.service.DataAnalysisService; +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.ArrayList; +import java.util.Iterator; + +/** + * 后台——数据分析 + * + * @author: liwenlong + * @date: 2023-02-21 + */ +@RestController +@RequestMapping("/dataAnalysis") +public class DataAnalysisController extends BaseController { + + + @Autowired + private DataAnalysisService dataAnalysisService; + + private void customerFillParam(CustomerChartsParam customerChartsParam){ + //如果sort没有值,去除 + Iterator iterator = customerChartsParam.getOrderSortParamList().iterator(); + while (iterator.hasNext()){ + OrderSortParam next = iterator.next(); + if(StringUtils.isBlank(next.getSort())){ + iterator.remove(); + } + } + if (customerChartsParam.getOrderSortParamList() == null || customerChartsParam.getOrderSortParamList().size() == 0) { + customerChartsParam.setOrderSortParamList(new ArrayList<>()); + OrderSortParam orderSortParam = new OrderSortParam(); + orderSortParam.setColumn("payAmount"); + orderSortParam.setSort("desc"); + customerChartsParam.getOrderSortParamList().add(orderSortParam); + } + } + + /** + * 设计师排行榜 + * + * @return + */ + @PostMapping("/customerCharts") + public TableDataInfo customerCharts(@RequestBody CustomerChartsParam customerChartsParam) { + startPage(); + customerFillParam(customerChartsParam); + return getDataTable(dataAnalysisService.customerCharts(customerChartsParam)); + } + + + /** + * 设计师排行榜统计 + * + * @return + */ + @PostMapping("/customerChartsStatistics") + public AjaxResult customerChartsStatistics(@RequestBody CustomerChartsParam customerChartsParam) { + customerFillParam(customerChartsParam); + return AjaxResult.success(dataAnalysisService.customerChartsStatistics(customerChartsParam)); + } + + private void storeFillParam(StoreChartsParam storeChartsParam){ + //如果sort没有值,去除 + Iterator iterator = storeChartsParam.getOrderSortParamList().iterator(); + while (iterator.hasNext()){ + OrderSortParam next = iterator.next(); + if(StringUtils.isBlank(next.getSort())){ + iterator.remove(); + } + } + if (storeChartsParam.getOrderSortParamList() == null || storeChartsParam.getOrderSortParamList().size() == 0) { + storeChartsParam.setOrderSortParamList(new ArrayList<>()); + OrderSortParam orderSortParam = new OrderSortParam(); + orderSortParam.setColumn("hasReceivedAmount"); + orderSortParam.setSort("desc"); + storeChartsParam.getOrderSortParamList().add(orderSortParam); + } + } + + /** + * 表现师师排行榜 + * + * @return + */ + @PostMapping("/storeCharts") + public TableDataInfo storeCharts(@RequestBody StoreChartsParam storeChartsParam) { + startPage(); + storeFillParam(storeChartsParam); + + return getDataTable(dataAnalysisService.storeCharts(storeChartsParam)); + } + + + + /** + * 表现师师排行榜统计 + * + * @return + */ + @PostMapping("/storeChartsStatistics") + public AjaxResult storeChartsStatistics(@RequestBody StoreChartsParam storeChartsParam) { + storeFillParam(storeChartsParam); + return AjaxResult.success(dataAnalysisService.storeChartsStatistics(storeChartsParam)); + } + + private void saleFillParam(SaleChartsParam saleChartsParam){ + //如果sort没有值,去除 + Iterator iterator = saleChartsParam.getOrderSortParamList().iterator(); + while (iterator.hasNext()){ + OrderSortParam next = iterator.next(); + if(StringUtils.isBlank(next.getSort())){ + iterator.remove(); + } + } + if (saleChartsParam.getOrderSortParamList() == null || saleChartsParam.getOrderSortParamList().size() == 0) { + saleChartsParam.setOrderSortParamList(new ArrayList<>()); + OrderSortParam orderSortParam = new OrderSortParam(); + orderSortParam.setColumn("commission"); + orderSortParam.setSort("desc"); + saleChartsParam.getOrderSortParamList().add(orderSortParam); + } + } + + /** + * 推广员排行榜 + * + * @return + */ + @PostMapping("/saleCharts") + public TableDataInfo saleCharts(@RequestBody SaleChartsParam saleChartsParam) { + startPage(); + saleFillParam(saleChartsParam); + + return getDataTable(dataAnalysisService.saleCharts(saleChartsParam)); + } + + /** + * 推广员排行榜统计 + * + * @return + */ + @PostMapping("/saleChartsStatistics") + public AjaxResult saleChartsStatistics(@RequestBody SaleChartsParam saleChartsParam) { + saleFillParam(saleChartsParam); + return AjaxResult.success(dataAnalysisService.saleChartsStatistics(saleChartsParam)); + } + +} diff --git a/ruoyi-extend/ruoyi-business/src/main/java/com/ruoyi/dataanalysis/mapper/DataAnalysisMapper.java b/ruoyi-extend/ruoyi-business/src/main/java/com/ruoyi/dataanalysis/mapper/DataAnalysisMapper.java new file mode 100644 index 0000000..bb7bb48 --- /dev/null +++ b/ruoyi-extend/ruoyi-business/src/main/java/com/ruoyi/dataanalysis/mapper/DataAnalysisMapper.java @@ -0,0 +1,30 @@ +package com.ruoyi.dataanalysis.mapper; + +import com.ruoyi.dataanalysis.model.param.CustomerChartsParam; +import com.ruoyi.dataanalysis.model.param.SaleChartsParam; +import com.ruoyi.dataanalysis.model.param.StoreChartsParam; +import com.ruoyi.dataanalysis.model.result.CustomerChartsResult; +import com.ruoyi.dataanalysis.model.result.SaleChartsResult; +import com.ruoyi.dataanalysis.model.result.StoreChartsResult; +import com.ruoyi.homepage.model.param.ChartReq; +import com.ruoyi.homepage.model.result.*; +import org.apache.ibatis.annotations.Param; +import org.springframework.stereotype.Repository; + +import java.util.List; + +/** + * 后台数据统计 Mapper 接口 + * + * @author 李文龙 + * @date 2022/01/13 14:19 + */ +@Repository +public interface DataAnalysisMapper { + + List customerCharts(@Param("param") CustomerChartsParam customerChartsParam); + + List storeCharts(@Param("param")StoreChartsParam storeChartsParam); + + List saleCharts(@Param("param")SaleChartsParam saleChartsParam); +} \ No newline at end of file diff --git a/ruoyi-extend/ruoyi-business/src/main/java/com/ruoyi/dataanalysis/mapper/mapping/DataAnalysisMapper.xml b/ruoyi-extend/ruoyi-business/src/main/java/com/ruoyi/dataanalysis/mapper/mapping/DataAnalysisMapper.xml new file mode 100644 index 0000000..d143672 --- /dev/null +++ b/ruoyi-extend/ruoyi-business/src/main/java/com/ruoyi/dataanalysis/mapper/mapping/DataAnalysisMapper.xml @@ -0,0 +1,251 @@ + + + + + + + + + \ No newline at end of file diff --git a/ruoyi-extend/ruoyi-business/src/main/java/com/ruoyi/dataanalysis/model/param/CustomerChartsParam.java b/ruoyi-extend/ruoyi-business/src/main/java/com/ruoyi/dataanalysis/model/param/CustomerChartsParam.java new file mode 100644 index 0000000..e9eab56 --- /dev/null +++ b/ruoyi-extend/ruoyi-business/src/main/java/com/ruoyi/dataanalysis/model/param/CustomerChartsParam.java @@ -0,0 +1,36 @@ +package com.ruoyi.dataanalysis.model.param; + +import com.baomidou.mybatisplus.annotation.TableField; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.Date; +import java.util.List; + +@Data +public class CustomerChartsParam { + + //筛选字段-开始 + + @ApiModelProperty(value = "编号") + private String nickname; + + @ApiModelProperty(value = "昵称") + private String name; + + + @ApiModelProperty("开始时间") + @TableField(exist = false) + private Date beginTime; + + @ApiModelProperty("结束时间") + @TableField(exist = false) + private Date endTime; + //筛选字段-结束 + + //排序字段-开始 + @ApiModelProperty(value = "订单金额") + private List orderSortParamList; + + +} diff --git a/ruoyi-extend/ruoyi-business/src/main/java/com/ruoyi/dataanalysis/model/param/OrderSortParam.java b/ruoyi-extend/ruoyi-business/src/main/java/com/ruoyi/dataanalysis/model/param/OrderSortParam.java new file mode 100644 index 0000000..b805a40 --- /dev/null +++ b/ruoyi-extend/ruoyi-business/src/main/java/com/ruoyi/dataanalysis/model/param/OrderSortParam.java @@ -0,0 +1,21 @@ +package com.ruoyi.dataanalysis.model.param; + +import lombok.Data; + +@Data +public class OrderSortParam { + + /** + * orderAmount:订单金额 + * payAmount:付款金额 + * orderNum:订单数量 + * hasReceivedAmount:已到账金额 + * star:评分 + * customerNum:客户数量 + * commission:佣金 + */ + private String column; + + //asc 正序 desc 倒序 + private String sort; +} diff --git a/ruoyi-extend/ruoyi-business/src/main/java/com/ruoyi/dataanalysis/model/param/SaleChartsParam.java b/ruoyi-extend/ruoyi-business/src/main/java/com/ruoyi/dataanalysis/model/param/SaleChartsParam.java new file mode 100644 index 0000000..e8c4558 --- /dev/null +++ b/ruoyi-extend/ruoyi-business/src/main/java/com/ruoyi/dataanalysis/model/param/SaleChartsParam.java @@ -0,0 +1,35 @@ +package com.ruoyi.dataanalysis.model.param; + +import com.baomidou.mybatisplus.annotation.TableField; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.Date; +import java.util.List; + +@Data +public class SaleChartsParam { + + //筛选字段-开始 + + @ApiModelProperty(value = "编号") + private String nickname; + + @ApiModelProperty(value = "昵称") + private String name; + + @ApiModelProperty("开始时间") + @TableField(exist = false) + private Date beginTime; + + @ApiModelProperty("结束时间") + @TableField(exist = false) + private Date endTime; + //筛选字段-结束 + + //排序字段-开始 + @ApiModelProperty(value = "订单金额") + private List orderSortParamList; + + +} diff --git a/ruoyi-extend/ruoyi-business/src/main/java/com/ruoyi/dataanalysis/model/param/StoreChartsParam.java b/ruoyi-extend/ruoyi-business/src/main/java/com/ruoyi/dataanalysis/model/param/StoreChartsParam.java new file mode 100644 index 0000000..dd69d0f --- /dev/null +++ b/ruoyi-extend/ruoyi-business/src/main/java/com/ruoyi/dataanalysis/model/param/StoreChartsParam.java @@ -0,0 +1,40 @@ +package com.ruoyi.dataanalysis.model.param; + +import com.baomidou.mybatisplus.annotation.TableField; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.Date; +import java.util.List; + +@Data +public class StoreChartsParam { + + //筛选字段-开始 + + @ApiModelProperty(value = "编号") + private String nickname; + + @ApiModelProperty(value = "昵称") + private String name; + + @ApiModelProperty(value = "认证类型 1普通 2 高端 3 酷家乐,多选的话逗号分隔") + private String authType; + + private List authTypeList; + + @ApiModelProperty("开始时间") + @TableField(exist = false) + private Date beginTime; + + @ApiModelProperty("结束时间") + @TableField(exist = false) + private Date endTime; + //筛选字段-结束 + + //排序字段-开始 + @ApiModelProperty(value = "订单金额") + private List orderSortParamList; + + +} diff --git a/ruoyi-extend/ruoyi-business/src/main/java/com/ruoyi/dataanalysis/model/result/CustomerChartsResult.java b/ruoyi-extend/ruoyi-business/src/main/java/com/ruoyi/dataanalysis/model/result/CustomerChartsResult.java new file mode 100644 index 0000000..e5dd6f4 --- /dev/null +++ b/ruoyi-extend/ruoyi-business/src/main/java/com/ruoyi/dataanalysis/model/result/CustomerChartsResult.java @@ -0,0 +1,28 @@ +package com.ruoyi.dataanalysis.model.result; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.math.BigDecimal; + +@Data +public class CustomerChartsResult { + + @ApiModelProperty(value = "编号") + private String nickname; + + @ApiModelProperty(value = "昵称") + private String name; + + @ApiModelProperty(value = "订单金额") + private BigDecimal orderAmount; + + @ApiModelProperty(value = "付款金额") + private BigDecimal payAmount; + + @ApiModelProperty(value = "单数") + private Integer orderNum; + + @ApiModelProperty(value = "创建时间") + private String createTime; +} diff --git a/ruoyi-extend/ruoyi-business/src/main/java/com/ruoyi/dataanalysis/model/result/CustomerChartsStatisticsResult.java b/ruoyi-extend/ruoyi-business/src/main/java/com/ruoyi/dataanalysis/model/result/CustomerChartsStatisticsResult.java new file mode 100644 index 0000000..f9f9386 --- /dev/null +++ b/ruoyi-extend/ruoyi-business/src/main/java/com/ruoyi/dataanalysis/model/result/CustomerChartsStatisticsResult.java @@ -0,0 +1,19 @@ +package com.ruoyi.dataanalysis.model.result; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.math.BigDecimal; + +@Data +public class CustomerChartsStatisticsResult { + + @ApiModelProperty(value = "订单金额") + private BigDecimal orderAmount; + + @ApiModelProperty(value = "单数") + private Integer orderNum; + + @ApiModelProperty(value = "付款金额") + private BigDecimal payAmount; +} diff --git a/ruoyi-extend/ruoyi-business/src/main/java/com/ruoyi/dataanalysis/model/result/SaleChartsResult.java b/ruoyi-extend/ruoyi-business/src/main/java/com/ruoyi/dataanalysis/model/result/SaleChartsResult.java new file mode 100644 index 0000000..9034d4c --- /dev/null +++ b/ruoyi-extend/ruoyi-business/src/main/java/com/ruoyi/dataanalysis/model/result/SaleChartsResult.java @@ -0,0 +1,25 @@ +package com.ruoyi.dataanalysis.model.result; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.math.BigDecimal; + +@Data +public class SaleChartsResult { + + @ApiModelProperty(value = "编号") + private String nickname; + + @ApiModelProperty(value = "昵称") + private String name; + + @ApiModelProperty(value = "佣金") + private BigDecimal commission; + + @ApiModelProperty(value = "客户数量") + private Integer customerNum; + + @ApiModelProperty(value = "创建时间") + private String createTime; +} diff --git a/ruoyi-extend/ruoyi-business/src/main/java/com/ruoyi/dataanalysis/model/result/SaleChartsStatisticsResult.java b/ruoyi-extend/ruoyi-business/src/main/java/com/ruoyi/dataanalysis/model/result/SaleChartsStatisticsResult.java new file mode 100644 index 0000000..714b3ee --- /dev/null +++ b/ruoyi-extend/ruoyi-business/src/main/java/com/ruoyi/dataanalysis/model/result/SaleChartsStatisticsResult.java @@ -0,0 +1,17 @@ +package com.ruoyi.dataanalysis.model.result; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.math.BigDecimal; + +@Data +public class SaleChartsStatisticsResult { + + @ApiModelProperty(value = "佣金") + private BigDecimal commission; + + @ApiModelProperty(value = "客户数") + private Integer customerNum; + +} diff --git a/ruoyi-extend/ruoyi-business/src/main/java/com/ruoyi/dataanalysis/model/result/StoreChartsResult.java b/ruoyi-extend/ruoyi-business/src/main/java/com/ruoyi/dataanalysis/model/result/StoreChartsResult.java new file mode 100644 index 0000000..e3f7a13 --- /dev/null +++ b/ruoyi-extend/ruoyi-business/src/main/java/com/ruoyi/dataanalysis/model/result/StoreChartsResult.java @@ -0,0 +1,34 @@ +package com.ruoyi.dataanalysis.model.result; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.math.BigDecimal; + +@Data +public class StoreChartsResult { + + @ApiModelProperty(value = "编号") + private String nickname; + + @ApiModelProperty(value = "昵称") + private String name; + + @ApiModelProperty(value = "认证类型 1普通 2 高端 3 酷家乐,多选的话逗号分隔") + private String authType; + + @ApiModelProperty(value = "订单金额") + private BigDecimal orderAmount; + + @ApiModelProperty(value = "已到款金额") + private BigDecimal hasReceivedAmount; + + @ApiModelProperty(value = "单数") + private Integer orderNum; + + @ApiModelProperty(value = "评分") + private String star; + + @ApiModelProperty(value = "创建时间") + private String createTime; +} diff --git a/ruoyi-extend/ruoyi-business/src/main/java/com/ruoyi/dataanalysis/model/result/StoreChartsStatisticsResult.java b/ruoyi-extend/ruoyi-business/src/main/java/com/ruoyi/dataanalysis/model/result/StoreChartsStatisticsResult.java new file mode 100644 index 0000000..465a1db --- /dev/null +++ b/ruoyi-extend/ruoyi-business/src/main/java/com/ruoyi/dataanalysis/model/result/StoreChartsStatisticsResult.java @@ -0,0 +1,19 @@ +package com.ruoyi.dataanalysis.model.result; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.math.BigDecimal; + +@Data +public class StoreChartsStatisticsResult { + + @ApiModelProperty(value = "订单金额") + private BigDecimal orderAmount; + + @ApiModelProperty(value = "单数") + private Integer orderNum; + + @ApiModelProperty(value = "付款金额") + private BigDecimal payAmount; +} diff --git a/ruoyi-extend/ruoyi-business/src/main/java/com/ruoyi/dataanalysis/service/DataAnalysisService.java b/ruoyi-extend/ruoyi-business/src/main/java/com/ruoyi/dataanalysis/service/DataAnalysisService.java new file mode 100644 index 0000000..c2958f8 --- /dev/null +++ b/ruoyi-extend/ruoyi-business/src/main/java/com/ruoyi/dataanalysis/service/DataAnalysisService.java @@ -0,0 +1,34 @@ +package com.ruoyi.dataanalysis.service; + + +import com.ruoyi.dataanalysis.model.param.CustomerChartsParam; +import com.ruoyi.dataanalysis.model.param.SaleChartsParam; +import com.ruoyi.dataanalysis.model.param.StoreChartsParam; +import com.ruoyi.dataanalysis.model.result.CustomerChartsResult; +import com.ruoyi.dataanalysis.model.result.CustomerChartsStatisticsResult; +import com.ruoyi.dataanalysis.model.result.SaleChartsResult; +import com.ruoyi.dataanalysis.model.result.StoreChartsResult; + +import java.util.List; + +/** + * 首页数据统计 + * + * @author liwenlong + * @date 2023-02-13 + */ +public interface DataAnalysisService { + + + List customerCharts(CustomerChartsParam customerChartsParam); + + List storeCharts(StoreChartsParam storeChartsParam); + + List saleCharts(SaleChartsParam saleChartsParam); + + CustomerChartsStatisticsResult customerChartsStatistics(CustomerChartsParam customerChartsParam); + + Object storeChartsStatistics(StoreChartsParam storeChartsParam); + + Object saleChartsStatistics(SaleChartsParam saleChartsParam); +} \ No newline at end of file diff --git a/ruoyi-extend/ruoyi-business/src/main/java/com/ruoyi/dataanalysis/service/impl/DataAnalysisServiceImpl.java b/ruoyi-extend/ruoyi-business/src/main/java/com/ruoyi/dataanalysis/service/impl/DataAnalysisServiceImpl.java new file mode 100644 index 0000000..7fb2312 --- /dev/null +++ b/ruoyi-extend/ruoyi-business/src/main/java/com/ruoyi/dataanalysis/service/impl/DataAnalysisServiceImpl.java @@ -0,0 +1,132 @@ +package com.ruoyi.dataanalysis.service.impl; + +import cn.hutool.core.util.StrUtil; +import com.ruoyi.dataanalysis.mapper.DataAnalysisMapper; +import com.ruoyi.dataanalysis.model.param.CustomerChartsParam; +import com.ruoyi.dataanalysis.model.param.SaleChartsParam; +import com.ruoyi.dataanalysis.model.param.StoreChartsParam; +import com.ruoyi.dataanalysis.model.result.*; +import com.ruoyi.dataanalysis.service.DataAnalysisService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.List; + +/** + * 首页数据统计 + * + * @author liwenlong + * @date 2023-02-13 + */ +@Service +public class DataAnalysisServiceImpl implements DataAnalysisService { + + @Autowired + private DataAnalysisMapper dataAnalysisMapper; + + + @Override + public List customerCharts(CustomerChartsParam customerChartsParam) { + + List customerChartsResultList = customerChartsResultList(customerChartsParam); + return customerChartsResultList; + } + + private List customerChartsResultList(CustomerChartsParam customerChartsParam) { + List customerChartsResultList = dataAnalysisMapper.customerCharts(customerChartsParam); + return customerChartsResultList; + } + + @Override + public CustomerChartsStatisticsResult customerChartsStatistics(CustomerChartsParam customerChartsParam) { + List customerChartsResultList = customerChartsResultList(customerChartsParam); + + BigDecimal orderAmount = BigDecimal.ZERO; + BigDecimal payAmount = BigDecimal.ZERO; + Integer orderNum = 0; + CustomerChartsStatisticsResult customerChartsStatisticsResult = new CustomerChartsStatisticsResult(); + for (CustomerChartsResult result : customerChartsResultList) { + orderAmount = orderAmount.add(result.getOrderAmount()); + payAmount = payAmount.add(result.getPayAmount()); + orderNum = orderNum + result.getOrderNum(); + } + + customerChartsStatisticsResult.setOrderAmount(orderAmount); + customerChartsStatisticsResult.setPayAmount(payAmount); + customerChartsStatisticsResult.setOrderNum(orderNum); + + return customerChartsStatisticsResult; + } + + @Override + public List storeCharts(StoreChartsParam storeChartsParam) { + List storeChartsResultList = storeChartsResultList(storeChartsParam); + return storeChartsResultList; + } + + private List storeChartsResultList(StoreChartsParam storeChartsParam) { + if (storeChartsParam != null && StrUtil.isNotBlank(storeChartsParam.getAuthType())) { + storeChartsParam.setAuthTypeList(new ArrayList<>()); + String[] split = storeChartsParam.getAuthType().split(","); + for (String cur : split) { + storeChartsParam.getAuthTypeList().add(cur); + } + } + List storeChartsResultList = dataAnalysisMapper.storeCharts(storeChartsParam); + return storeChartsResultList; + } + + + @Override + public Object storeChartsStatistics(StoreChartsParam storeChartsParam) { + List storeChartsResultList = storeChartsResultList(storeChartsParam); + + BigDecimal orderAmount = BigDecimal.ZERO; + BigDecimal payAmount = BigDecimal.ZERO; + Integer orderNum = 0; + StoreChartsStatisticsResult storeChartsStatisticsResult = new StoreChartsStatisticsResult(); + for (StoreChartsResult result : storeChartsResultList) { + orderAmount = orderAmount.add(result.getOrderAmount()); + payAmount = payAmount.add(result.getHasReceivedAmount()); + orderNum = orderNum + result.getOrderNum(); + } + + storeChartsStatisticsResult.setOrderAmount(orderAmount); + storeChartsStatisticsResult.setPayAmount(payAmount); + storeChartsStatisticsResult.setOrderNum(orderNum); + + return storeChartsStatisticsResult; + } + + @Override + public List saleCharts(SaleChartsParam saleChartsParam) { + List saleChartsResultList = saleChartsResultList(saleChartsParam); + return saleChartsResultList; + } + + + @Override + public Object saleChartsStatistics(SaleChartsParam saleChartsParam) { + List saleChartsResultList = saleChartsResultList(saleChartsParam); + + BigDecimal commission = BigDecimal.ZERO; + Integer customerNum = 0; + SaleChartsStatisticsResult saleChartsStatisticsResult = new SaleChartsStatisticsResult(); + for (SaleChartsResult result : saleChartsResultList) { + commission = commission.add(result.getCommission()); + customerNum = customerNum + result.getCustomerNum(); + } + + saleChartsStatisticsResult.setCustomerNum(customerNum); + saleChartsStatisticsResult.setCommission(commission); + + return saleChartsStatisticsResult; + } + + private List saleChartsResultList(SaleChartsParam saleChartsParam) { + List saleChartsResultList = dataAnalysisMapper.saleCharts(saleChartsParam); + return saleChartsResultList; + } +} diff --git a/ruoyi-extend/ruoyi-business/src/main/java/com/ruoyi/homepage/controller/HomePageController.java b/ruoyi-extend/ruoyi-business/src/main/java/com/ruoyi/homepage/controller/HomePageController.java new file mode 100644 index 0000000..82ef30f --- /dev/null +++ b/ruoyi-extend/ruoyi-business/src/main/java/com/ruoyi/homepage/controller/HomePageController.java @@ -0,0 +1,88 @@ +package com.ruoyi.homepage.controller; + +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.homepage.model.param.ChartReq; +import com.ruoyi.homepage.model.param.RankingListReq; +import com.ruoyi.homepage.model.result.ChartResult; +import com.ruoyi.homepage.model.result.RankingResult; +import com.ruoyi.homepage.model.result.StatisticsResult; +import com.ruoyi.homepage.service.HomePageService; +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; + +/** + * 后台——首页数据统计 + * + * @author: liwenlong + * @date: 2023-02-21 + */ +@RestController +@RequestMapping("/homePage") +public class HomePageController { + + + @Autowired + private HomePageService homePageService; + + /** + * 后台首页统计 + * @return + */ + @PostMapping("/statistics") + public AjaxResult statistics() { + return homePageService.statistics(); + } + + /** + * 订单金额统计 + * @return + */ + @PostMapping("/orderAmountChart") + public AjaxResult orderAmountChart(@RequestBody ChartReq req) { + return homePageService.orderAmountChart(req); + } + + /** + * 订单金额统计2 + * @return + */ + @PostMapping("/orderAmountChartNear") + public AjaxResult orderAmountChartNear(@RequestBody ChartReq req) { + return homePageService.orderAmountChartNear(req); + } + + + /** + * 分类占比统计 + * @return + */ + @PostMapping("/classificationProportion") + public AjaxResult classificationProportion(@RequestBody ChartReq req) { + return homePageService.classificationProportion(req); + } + + + /** + * 新老客户数量占比 + * @return + */ + @PostMapping("/newOldCustomers") + public AjaxResult newOldCustomers(@RequestBody ChartReq req) { + return homePageService.newOldCustomers(req); + } + + + /** + * 消费排行榜 + * @return + */ + @PostMapping("/rankingList") + public AjaxResult rankingList(@RequestBody RankingListReq req) { + return homePageService.rankingList(req); + } + + +} diff --git a/ruoyi-extend/ruoyi-business/src/main/java/com/ruoyi/homepage/mapper/HomePageMapper.java b/ruoyi-extend/ruoyi-business/src/main/java/com/ruoyi/homepage/mapper/HomePageMapper.java new file mode 100644 index 0000000..6906422 --- /dev/null +++ b/ruoyi-extend/ruoyi-business/src/main/java/com/ruoyi/homepage/mapper/HomePageMapper.java @@ -0,0 +1,39 @@ +package com.ruoyi.homepage.mapper; + +import com.ruoyi.homepage.model.param.ChartReq; +import com.ruoyi.homepage.model.result.*; +import org.apache.ibatis.annotations.Param; +import org.springframework.stereotype.Repository; + +import java.util.List; + +/** + * 后台数据统计 Mapper 接口 + * + * @author 李文龙 + * @date 2022/01/13 14:19 + */ +@Repository +public interface HomePageMapper { + + List statistics(); + + List monthOrderAmountChart(@Param("month") String month); + + List yearOrderAmountChart(@Param("year") String year); + + + List monthOrderAmountChartNear(); + + List yearOrderAmountChartNear(); + + List rankingCustomerList(); + + List rankingStoreList(); + + List rankingSaleList(); + + List classificationProportion(@Param("req")ChartReq req); + + List newOldCustomers(@Param("req")ChartReq req); +} \ No newline at end of file diff --git a/ruoyi-extend/ruoyi-business/src/main/java/com/ruoyi/homepage/mapper/mapping/HomePageMapper.xml b/ruoyi-extend/ruoyi-business/src/main/java/com/ruoyi/homepage/mapper/mapping/HomePageMapper.xml new file mode 100644 index 0000000..c42bcc5 --- /dev/null +++ b/ruoyi-extend/ruoyi-business/src/main/java/com/ruoyi/homepage/mapper/mapping/HomePageMapper.xml @@ -0,0 +1,560 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ruoyi-extend/ruoyi-business/src/main/java/com/ruoyi/homepage/model/param/ChartReq.java b/ruoyi-extend/ruoyi-business/src/main/java/com/ruoyi/homepage/model/param/ChartReq.java new file mode 100644 index 0000000..627bc9b --- /dev/null +++ b/ruoyi-extend/ruoyi-business/src/main/java/com/ruoyi/homepage/model/param/ChartReq.java @@ -0,0 +1,20 @@ +package com.ruoyi.homepage.model.param; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + * @author a + * @date 2023/3/6 13:34 + */ +@Data +public class ChartReq { + + @ApiModelProperty(value = "1 近一月 2 近一年") + private Integer timeType = 1; + + private String year; //2022/2023 + + private String month;// 2021-11/2022-12 + +} diff --git a/ruoyi-extend/ruoyi-business/src/main/java/com/ruoyi/homepage/model/param/RankingListReq.java b/ruoyi-extend/ruoyi-business/src/main/java/com/ruoyi/homepage/model/param/RankingListReq.java new file mode 100644 index 0000000..e0e1d7e --- /dev/null +++ b/ruoyi-extend/ruoyi-business/src/main/java/com/ruoyi/homepage/model/param/RankingListReq.java @@ -0,0 +1,15 @@ +package com.ruoyi.homepage.model.param; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + * @author a + * @date 2023/10/25 17:36 + */ +@Data +public class RankingListReq { + + @ApiModelProperty(value = "1设计师 2表现师 3销售佣金") + private Integer type = 1; +} diff --git a/ruoyi-extend/ruoyi-business/src/main/java/com/ruoyi/homepage/model/result/ChartResult.java b/ruoyi-extend/ruoyi-business/src/main/java/com/ruoyi/homepage/model/result/ChartResult.java new file mode 100644 index 0000000..b375bf7 --- /dev/null +++ b/ruoyi-extend/ruoyi-business/src/main/java/com/ruoyi/homepage/model/result/ChartResult.java @@ -0,0 +1,21 @@ +package com.ruoyi.homepage.model.result; + +import lombok.Data; +import lombok.experimental.Accessors; + +/** + * @author a + * @date 2023/3/6 13:38 + */ +@Data +@Accessors(chain = true) +public class ChartResult { + + private String num;//数量 + + private String amount;//金额 + + private String hasReceiveAmount;//已到款 + + private String unit;//日期 +} diff --git a/ruoyi-extend/ruoyi-business/src/main/java/com/ruoyi/homepage/model/result/ClassificationProportionResult.java b/ruoyi-extend/ruoyi-business/src/main/java/com/ruoyi/homepage/model/result/ClassificationProportionResult.java new file mode 100644 index 0000000..a2c1c25 --- /dev/null +++ b/ruoyi-extend/ruoyi-business/src/main/java/com/ruoyi/homepage/model/result/ClassificationProportionResult.java @@ -0,0 +1,12 @@ +package com.ruoyi.homepage.model.result; + +import lombok.Data; + +@Data +public class ClassificationProportionResult { + + private Long worksTypeId; + private String worksTypeName; + private String parentWorksTypeName; + private String amount; +} diff --git a/ruoyi-extend/ruoyi-business/src/main/java/com/ruoyi/homepage/model/result/NewOldCustomersResult.java b/ruoyi-extend/ruoyi-business/src/main/java/com/ruoyi/homepage/model/result/NewOldCustomersResult.java new file mode 100644 index 0000000..3472cb6 --- /dev/null +++ b/ruoyi-extend/ruoyi-business/src/main/java/com/ruoyi/homepage/model/result/NewOldCustomersResult.java @@ -0,0 +1,12 @@ +package com.ruoyi.homepage.model.result; + +import lombok.Data; + +import java.util.Date; + +@Data +public class NewOldCustomersResult { + private Long customerId; + private Date createTime; + private Integer isNewCustomer;//是否是新用户 1 是 2 否 +} diff --git a/ruoyi-extend/ruoyi-business/src/main/java/com/ruoyi/homepage/model/result/RankingResult.java b/ruoyi-extend/ruoyi-business/src/main/java/com/ruoyi/homepage/model/result/RankingResult.java new file mode 100644 index 0000000..f6237c4 --- /dev/null +++ b/ruoyi-extend/ruoyi-business/src/main/java/com/ruoyi/homepage/model/result/RankingResult.java @@ -0,0 +1,23 @@ +package com.ruoyi.homepage.model.result; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.math.BigDecimal; + +/** + * @author a + * @date 2023/10/26 9:10 + */ +@Data +public class RankingResult { + + @ApiModelProperty(value = "排名") + private Integer ranking; + + @ApiModelProperty(value = "编号") + private String nickname; + + @ApiModelProperty(value = "金额") + private BigDecimal amount; +} diff --git a/ruoyi-extend/ruoyi-business/src/main/java/com/ruoyi/homepage/model/result/StatisticsResult.java b/ruoyi-extend/ruoyi-business/src/main/java/com/ruoyi/homepage/model/result/StatisticsResult.java new file mode 100644 index 0000000..867b131 --- /dev/null +++ b/ruoyi-extend/ruoyi-business/src/main/java/com/ruoyi/homepage/model/result/StatisticsResult.java @@ -0,0 +1,24 @@ +package com.ruoyi.homepage.model.result; + +import lombok.Data; + +/** + * @author a + * @date 2023/10/25 17:42 + */ +@Data +public class StatisticsResult { + + + private String position0; + + private String position1; + + private String position2; + + private String position3; + + private String position4; + + +} diff --git a/ruoyi-extend/ruoyi-business/src/main/java/com/ruoyi/homepage/service/HomePageService.java b/ruoyi-extend/ruoyi-business/src/main/java/com/ruoyi/homepage/service/HomePageService.java new file mode 100644 index 0000000..e2a6bde --- /dev/null +++ b/ruoyi-extend/ruoyi-business/src/main/java/com/ruoyi/homepage/service/HomePageService.java @@ -0,0 +1,45 @@ +package com.ruoyi.homepage.service; + + +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.homepage.model.param.ChartReq; +import com.ruoyi.homepage.model.param.RankingListReq; +import com.ruoyi.homepage.model.result.ChartResult; + +/** + * 首页数据统计 + * + * @author liwenlong + * @date 2023-02-13 + */ +public interface HomePageService { + + + /** + * 后台首页统计 + * @return + */ + AjaxResult statistics(); + + + /** + * 订单金额统计 + * @param req + * @return + */ + AjaxResult orderAmountChart(ChartReq req); + + + /** + * 消费排行榜 + * @param req + * @return + */ + AjaxResult rankingList(RankingListReq req); + + AjaxResult classificationProportion(ChartReq req); + + AjaxResult newOldCustomers(ChartReq req); + + AjaxResult orderAmountChartNear(ChartReq req); +} \ No newline at end of file diff --git a/ruoyi-extend/ruoyi-business/src/main/java/com/ruoyi/homepage/service/impl/HomePageServiceImpl.java b/ruoyi-extend/ruoyi-business/src/main/java/com/ruoyi/homepage/service/impl/HomePageServiceImpl.java new file mode 100644 index 0000000..81505e5 --- /dev/null +++ b/ruoyi-extend/ruoyi-business/src/main/java/com/ruoyi/homepage/service/impl/HomePageServiceImpl.java @@ -0,0 +1,233 @@ +package com.ruoyi.homepage.service.impl; + +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.frequency.workstype.entity.WorksType; +import com.ruoyi.frequency.workstype.service.WorksTypeService; +import com.ruoyi.homepage.mapper.HomePageMapper; +import com.ruoyi.homepage.model.param.ChartReq; +import com.ruoyi.homepage.model.param.RankingListReq; +import com.ruoyi.homepage.model.result.*; +import com.ruoyi.homepage.service.HomePageService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.math.BigDecimal; +import java.util.*; + +/** + * 首页数据统计 + * + * @author liwenlong + * @date 2023-02-13 + */ +@Service +public class HomePageServiceImpl implements HomePageService { + + @Autowired + private HomePageMapper homePageMapper; + + @Override + public AjaxResult statistics() { + + List list = homePageMapper.statistics(); + + if (list.size() > 0) { + //求环比 + list.stream().forEach(s -> { + + int index = list.indexOf(s); + + BigDecimal position_2 = new BigDecimal(s.getPosition2()); + + BigDecimal position_3 = new BigDecimal(s.getPosition3()); + + if (position_2.compareTo(BigDecimal.ZERO) == 0) { + s.setPosition4("0"); + } else if (position_3.compareTo(BigDecimal.ZERO) == 0) { + s.setPosition4("100"); + } else { + s.setPosition4(position_2.subtract(position_3).divide(position_3, 2, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(100)).setScale(2, BigDecimal.ROUND_HALF_UP).toString()); + } + + if (index >= 4) { + s.setPosition1(s.getPosition1() + "元"); + s.setPosition2(s.getPosition2() + "元"); + s.setPosition3(s.getPosition3() + "元"); + } else { + s.setPosition1(new BigDecimal(s.getPosition1()).intValue() + ""); + } + s.setPosition4(s.getPosition4() + "%"); + }); + } + + return AjaxResult.success(list); + } + + @Override + public AjaxResult orderAmountChartNear(ChartReq req) { + + List list = new ArrayList<>(); + //1 本月 2 近一年 + if (req.getTimeType() == 1) { + list = homePageMapper.monthOrderAmountChartNear(); + //补全没有数据的日期 + + } else if (req.getTimeType() == 2) { + list = homePageMapper.yearOrderAmountChartNear(); + } + + return AjaxResult.success(list); + } + + @Override + public AjaxResult orderAmountChart(ChartReq req) { + + List list = new ArrayList<>(); + + List listNew = new ArrayList<>(); + //1 本月 2 近一年 + if (req.getTimeType() == 1) { + list = homePageMapper.monthOrderAmountChart(req.getMonth()); + //补全没有数据的日期 + int daysInMonth = getDaysInMonth(Integer.valueOf(req.getMonth().split("-")[0]), Integer.valueOf(req.getMonth().split("-")[1])); + Map map = new HashMap<>(); + list.stream().forEach(x -> { + map.put(x.getUnit(), x); + }); + for (int i = 0; i < daysInMonth; i++) { + String unit = req.getMonth() + "-" + (i < 9 ? "0" + (i + 1) : (i + 1)); + if (map.containsKey(unit)) { + listNew.add(map.get(unit)); + } else { + ChartResult chartResult = new ChartResult(); + chartResult.setUnit(unit); + chartResult.setAmount("0"); + chartResult.setHasReceiveAmount("0"); + chartResult.setNum("0"); + listNew.add(chartResult); + } + } + + } else if (req.getTimeType() == 2) { + list = homePageMapper.yearOrderAmountChart(req.getYear()); + //补全没有数据的日期 + int monthsInYear = getMonthsInYear(Integer.valueOf(req.getYear())); + + Map map = new HashMap<>(); + list.stream().forEach(x -> { + map.put(x.getUnit(), x); + }); + + for (int i = 0; i < monthsInYear; i++) { + String unit = req.getYear() + "-" + (i < 9 ? "0" + (i + 1) : (i + 1)); + if (map.containsKey(unit)) { + listNew.add(map.get(unit)); + } else { + ChartResult chartResult = new ChartResult(); + chartResult.setUnit(unit); + chartResult.setAmount("0"); + chartResult.setHasReceiveAmount("0"); + chartResult.setNum("0"); + listNew.add(chartResult); + } + + } + } + + return AjaxResult.success(listNew); + } + + public static void main(String[] args) { + int year = 2022; + int month = 11; // 11代表11月 + + int daysInMonth = getDaysInMonth(year, month); + int monthsInYear = getMonthsInYear(2024); + System.out.println(monthsInYear); + + System.out.println("The number of days in " + month + "/" + year + " is: " + daysInMonth); + } + + public static int getDaysInMonth(int year, int month) { + Calendar calendar = Calendar.getInstance(); + calendar.set(year, month - 1, 1); // 月份是从0开始计算的,因此要减1 + + return calendar.getActualMaximum(Calendar.DAY_OF_MONTH); + } + + public static int getMonthsInYear(int year) { + Calendar calendar = Calendar.getInstance(); + calendar.set(year, 0, 1); // 月份是从0开始计算的,因此要减1 + + return calendar.getActualMaximum(Calendar.MONTH) + 1; + } + + @Override + public AjaxResult rankingList(RankingListReq req) { + + List list = new ArrayList<>(); + + //1设计师 2表现师 3销售佣金 + if (req.getType() == 1) { + list = homePageMapper.rankingCustomerList(); + } else if (req.getType() == 2) { + list = homePageMapper.rankingStoreList(); + } else if (req.getType() == 3) { + list = homePageMapper.rankingSaleList(); + } + + Integer i = 1; + //添加排名 + for (RankingResult s : list) { + s.setRanking(i++); + } + + return AjaxResult.success(list); + } + + @Autowired + private WorksTypeService worksTypeService; + + + @Override + public AjaxResult classificationProportion(ChartReq req) { + //查询当前所有的二级分类 + List worksTypes = worksTypeService.worksTypeList(); + + List workTypeIdList = new ArrayList<>(); + + worksTypes.stream().forEach(worksType -> { + List childList = worksType.getChildList(); + childList.stream().forEach(child -> { + workTypeIdList.add(child); + }); + }); + + //1 近一月 2 近一年 + List classificationProportionResultList = homePageMapper.classificationProportion(req); + Map result = new HashMap<>(); + result.put("worksTypeList", workTypeIdList); + result.put("classificationProportionResultList", classificationProportionResultList); + return AjaxResult.success(result); + } + + @Override + public AjaxResult newOldCustomers(ChartReq req) { + List newOldCustomersResultList = homePageMapper.newOldCustomers(req); + Integer newCount = 0; + Integer oldCount = 0; + for (NewOldCustomersResult newOldCustomersResult : newOldCustomersResultList) { + //用户注册时间是否大于查询的年月开始时间 1 是 2 否 + if (newOldCustomersResult.getIsNewCustomer() == 1) { + newCount = newCount + 1; + } else { + oldCount = oldCount + 1; + } + } + Map result = new HashMap<>(); + result.put("newCount", newCount); + result.put("oldCount", oldCount); + return AjaxResult.success(result); + } + +} diff --git a/ruoyi-extend/ruoyi-business/src/main/resources/META-INF/spring-devtools.properties b/ruoyi-extend/ruoyi-business/src/main/resources/META-INF/spring-devtools.properties new file mode 100644 index 0000000..2b23f85 --- /dev/null +++ b/ruoyi-extend/ruoyi-business/src/main/resources/META-INF/spring-devtools.properties @@ -0,0 +1 @@ +restart.include.json=/com.alibaba.fastjson.*.jar \ No newline at end of file diff --git a/ruoyi-extend/ruoyi-business/src/main/resources/application-dev.yml b/ruoyi-extend/ruoyi-business/src/main/resources/application-dev.yml new file mode 100644 index 0000000..ed8bab0 --- /dev/null +++ b/ruoyi-extend/ruoyi-business/src/main/resources/application-dev.yml @@ -0,0 +1,119 @@ + +# 数据源配置 +spring: + redis: + # 地址 + host: localhost + # 端口,默认为6379 + port: 6379 + # 数据库索引 + database: 0 + # 连接超时时间 + timeout: 30s + # 密码 + password: Huitu123 + datasource: + type: com.alibaba.druid.pool.DruidDataSource + driverClassName: com.mysql.cj.jdbc.Driver + druid: + # 主库数据源 + master: + url: jdbc:mysql://localhost:3306/ddht?useUnicode=true&allowMultiQueries=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 + username: root + password: root +# url: jdbc:mysql://124.223.56.113:13306/ddht?useUnicode=true&allowMultiQueries=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 +# username: ddht +# password: ZGFSCkDHmLN62Mnt + # 从库数据源 + slave: + # 从数据源开关/默认关闭 + enabled: true + url: jdbc:mysql://wiz.52o.site:13306/ddht?useUnicode=true&allowMultiQueries=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 + username: ddht + password: i5y4EacPLkWSm6sz + # 初始连接数 + initialSize: 5 + # 最小连接池数量 + minIdle: 10 + # 最大连接池数量 + maxActive: 20 + # 配置获取连接等待超时的时间 + maxWait: 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: ruoyi + login-password: 123456 + filter: + stat: + enabled: true + # 慢SQL记录 + log-slow-sql: true + slow-sql-millis: 1000 + merge-sql: true + wall: + config: + multi-statement-allow: true + +oss: + local: + #文件域名 + domain: http://localhost:8080 + #存储路径 + upload-file-path: D:/ruoyiVueS + aliyun: + #阿里云api的内或外网域名 + endpoint: oss-cn-beijing.aliyuncs.com + #阿里云api的密钥access key id + access-key-id: + #阿里云api的密钥access key secret + access-key-secret: + #阿里云api的bucket名称 + bucket-name: + #外部访问域名 + domain: http://xxxxx.oss-cn-beijing.aliyuncs.com + +basepath: + url: http://dianqi.natapp1.cc +wecom: + corpid: ww45fb4d72c735ee1d + corpsecret: 5x3F-AHQMO9VwpXH9_lOUX8887sqb1fUx0-5goN6U_Y + +# 拉卡拉测试支付参数 +lalkla: + #拉卡拉开放平台进行配置开通 + appId: OP00002734 + #商户号 + merchantNo: 8223610899900ZC + #商户证书序列号,和商户私钥对应 + serialNo: 018f86243d2c + #商户私钥地址,用于请求签名 + priKeyPath: G:/lakala/OP00000003_private_key.pem + #拉卡拉公钥证书地址,用于验签(测试证书为:lkl-apigw-v1.cer) + lklCerPath: G:/lakala/lkl-apigw-v2.cer + #拉卡拉支付平台证书地址2(用于拉卡拉通知验签,证书与lklCerPath)一致,测试证书为:lkl-apigw-v1.cer) + lklNotifyCerPath: G:/lakala/lkl-apigw-v2.cer + #拉卡拉开放平台服务地址 + serverUrl: https://s2.lakala.com + #如果需要密文传输请申请拉卡拉SM4密钥 + sm4Key: 0I4M0kmwFrNUU8hZ9AFpfA== + # 文件下载存储地址 + basePath: G:\download\ + # 文件下载存储地址 + filePath: G:\file\ diff --git a/ruoyi-extend/ruoyi-business/src/main/resources/application-prod.yml b/ruoyi-extend/ruoyi-business/src/main/resources/application-prod.yml new file mode 100644 index 0000000..d309a25 --- /dev/null +++ b/ruoyi-extend/ruoyi-business/src/main/resources/application-prod.yml @@ -0,0 +1,115 @@ +# 数据源配置 +spring: + redis: + # 地址 + host: localhost + # 端口,默认为6379 + port: 6379 + # 数据库索引 + database: 7 + # 密码 + password: Huitu123 + + datasource: + type: com.alibaba.druid.pool.DruidDataSource + driverClassName: com.mysql.cj.jdbc.Driver + druid: + # 主库数据源 + master: + url: jdbc:mysql://localhost:3306/ddht?useUnicode=true&allowMultiQueries=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 + username: root + password: root +# url: jdbc:mysql://124.223.56.113:13306/ddht?useUnicode=true&allowMultiQueries=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 +# username: ddht +# password: ZGFSCkDHmLN62Mnt + # 从库数据源 + slave: + # 从数据源开关/默认关闭 + enabled: true + url: jdbc:mysql://wiz.52o.site:13306/ddht?useUnicode=true&allowMultiQueries=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 + username: ddht + password: i5y4EacPLkWSm6sz + # 初始连接数 + initialSize: 5 + # 最小连接池数量 + minIdle: 10 + # 最大连接池数量 + maxActive: 20 + # 配置获取连接等待超时的时间 + maxWait: 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: ruoyi + login-password: 123456 + filter: + stat: + enabled: true + # 慢SQL记录 + log-slow-sql: true + slow-sql-millis: 1000 + merge-sql: true + wall: + config: + multi-statement-allow: true + +oss: + local: + #文件域名 + domain: http://localhost:8080 + #存储路径 + upload-file-path: D:/ruoyiVueS + aliyun: + #阿里云api的内或外网域名 + endpoint: oss-cn-beijing.aliyuncs.com + #阿里云api的密钥access key id + access-key-id: + #阿里云api的密钥access key secret + access-key-secret: + #阿里云api的bucket名称 + bucket-name: + #外部访问域名 + domain: http://xxxxx.oss-cn-beijing.aliyuncs.com + + +basepath: + url: http://erp.ddht.cn/huituApi + +# 拉卡拉测试支付参数 +lalkla: + #拉卡拉开放平台进行配置开通 + appId: OP00002734 + #商户号 + merchantNo: 8223610899900ZC + #商户证书序列号,和商户私钥对应 + serialNo: 018f86243d2c + #商户私钥地址,用于请求签名 + priKeyPath: /home/manage/huitu/OP00000003_private_key.pem + #拉卡拉公钥证书地址,用于验签(测试证书为:lkl-apigw-v2.cer) + lklCerPath: /home/manage/huitu/lkl-apigw-v2.cer + #拉卡拉支付平台证书地址2(用于拉卡拉通知验签,证书与lklCerPath)一致,测试证书为:lkl-apigw-v2.cer) + lklNotifyCerPath: /home/manage/huitu/lkl-apigw-v2.cer + #拉卡拉开放平台服务地址 + serverUrl: https://s2.lakala.com + #如果需要密文传输请申请拉卡拉SM4密钥 + sm4Key: 0I4M0kmwFrNUU8hZ9AFpfA== + # 文件下载存储地址 + basePath: /home/manage/huitu/download/ + # 文件下载存储地址 + filePath: /home/manage/huitu/file/ \ No newline at end of file diff --git a/ruoyi-extend/ruoyi-business/src/main/resources/application-test.yml b/ruoyi-extend/ruoyi-business/src/main/resources/application-test.yml new file mode 100644 index 0000000..ed05f0c --- /dev/null +++ b/ruoyi-extend/ruoyi-business/src/main/resources/application-test.yml @@ -0,0 +1,117 @@ + +# 数据源配置 +spring: + redis: + # 地址 + host: localhost + # 端口,默认为6379 + port: 6379 + # 数据库索引 + database: 0 + # 密码 + password: Huitu123 + datasource: + type: com.alibaba.druid.pool.DruidDataSource + driverClassName: com.mysql.cj.jdbc.Driver + druid: + # 主库数据源 + master: + url: jdbc:mysql://localhost:3306/ddht?useUnicode=true&allowMultiQueries=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 + username: root + password: root +# url: jdbc:mysql://124.223.56.113:13306/ddht?useUnicode=true&allowMultiQueries=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 +# username: ddht +# password: ZGFSCkDHmLN62Mnt + # 从库数据源 + slave: + # 从数据源开关/默认关闭 + enabled: true + url: jdbc:mysql://wiz.52o.site:13306/ddht?useUnicode=true&allowMultiQueries=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 + username: ddht + password: i5y4EacPLkWSm6sz + # 初始连接数 + initialSize: 5 + # 最小连接池数量 + minIdle: 10 + # 最大连接池数量 + maxActive: 20 + # 配置获取连接等待超时的时间 + maxWait: 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: ruoyi + login-password: 123456 + filter: + stat: + enabled: true + # 慢SQL记录 + log-slow-sql: true + slow-sql-millis: 1000 + merge-sql: true + wall: + config: + multi-statement-allow: true + +oss: + local: + #文件域名 + domain: http://localhost:8080 + #存储路径 + upload-file-path: D:/ruoyiVueS + aliyun: + #阿里云api的内或外网域名 + endpoint: oss-cn-beijing.aliyuncs.com + #阿里云api的密钥access key id + access-key-id: + #阿里云api的密钥access key secret + access-key-secret: + #阿里云api的bucket名称 + bucket-name: + #外部访问域名 + domain: http://xxxxx.oss-cn-beijing.aliyuncs.com + +basepath: + url: http://8.142.155.9/huituApi +wecom: + corpid: ww45fb4d72c735ee1d + corpsecret: 5x3F-AHQMO9VwpXH9_lOUX8887sqb1fUx0-5goN6U_Y + +# 拉卡拉测试支付参数 +lalkla: + #拉卡拉开放平台进行配置开通 + appId: OP00002734 + #商户号 + merchantNo: 8223610899900YF + #商户证书序列号,和商户私钥对应 + serialNo: 018f86243d2c + #商户私钥地址,用于请求签名 + priKeyPath: /home/manage/huitu/OP00000003_private_key.pem + #拉卡拉公钥证书地址,用于验签(测试证书为:lkl-apigw-v2.cer) + lklCerPath: /home/manage/huitu/lkl-apigw-v2.cer + #拉卡拉支付平台证书地址2(用于拉卡拉通知验签,证书与lklCerPath)一致,测试证书为:lkl-apigw-v2.cer) + lklNotifyCerPath: /home/manage/huitu/lkl-apigw-v2.cer + #拉卡拉开放平台服务地址 + serverUrl: https://s2.lakala.com + #如果需要密文传输请申请拉卡拉SM4密钥 + sm4Key: 0I4M0kmwFrNUU8hZ9AFpfA== + # 文件下载存储地址 + basePath: /home/manage/huitu/download/ + # 文件下载存储地址 + filePath: /home/manage/huitu/file/ diff --git a/ruoyi-extend/ruoyi-business/src/main/resources/application.yml b/ruoyi-extend/ruoyi-business/src/main/resources/application.yml new file mode 100644 index 0000000..0de1a86 --- /dev/null +++ b/ruoyi-extend/ruoyi-business/src/main/resources/application.yml @@ -0,0 +1,271 @@ +# 项目相关配置 +ruoyi: + # 名称 + name: RuoYi-Vue-S + # 版本 + version: 3.7.0 + # 版权年份 + copyrightYear: 2021 + # 实例演示开关 + demoEnabled: true + # 文件路径 示例( Windows配置D:/ruoyi/uploadPath,Linux配置 /home/ruoyi/uploadPath) + profile: D:/ruoyi/uploadPath + # 获取ip地址开关 + addressEnabled: false + # 验证码类型 math 数组计算 char 字符验证 + captchaType: math + +# 开发环境配置 +server: + # 服务器的HTTP端口,默认为8080 + port: 8888 + servlet: + # 应用的访问路径 + context-path: + tomcat: + # tomcat的URI编码 + uri-encoding: UTF-8 + # tomcat最大线程数,默认为200 + max-threads: 800 + # Tomcat启动初始化的线程数,默认值25 + min-spare-threads: 30 + +# 日志配置 +logging: + level: + com.ruoyi: debug + org.springframework: warn + +# Spring配置 +spring: + # 资源信息 + messages: + # 国际化资源文件路径 + basename: i18n/messages + profiles: + active: prod + jackson: + time-zone: GMT+8 + date-format: yyyy-MM-dd HH:mm:ss + locale: zh_CN + serialization: + # 格式化输出 + indent_output: false + # 文件上传 + servlet: + multipart: + # 单个文件大小 + max-file-size: 10MB + # 设置总上传的文件大小 + max-request-size: 20MB + # 服务模块 + devtools: + restart: + # 热部署开关 + enabled: false + # redis 配置 + redis: + # 连接超时时间 + timeout: 10s + lettuce: + pool: + # 连接池中的最小空闲连接 + min-idle: 0 + # 连接池中的最大空闲连接 + max-idle: 8 + # 连接池的最大数据库连接数 + max-active: 8 + # #连接池最大阻塞等待时间(使用负值表示没有限制) + max-wait: -1ms +# token配置 +token: + # 令牌自定义标识 + header: Authorization + # 令牌密钥 + secret: abcdefghijklmnopqrstuvwxyz + # 令牌有效期(默认30分钟) + expireTime: 300 + +mybatis-plus: + mapper-locations: classpath*:/com/ruoyi/**/*.xml,classpath*:com/ruoyi/**/mapping/*.xml + #实体扫描,多个package用逗号或者分号分隔 + type-aliases-package: com.ruoyi.**.domain,com.ruoyi.entity.** + #typeEnumsPackage: com.baomidou.springboot.entity.enums + global-config: + banner: false + db-config: + #主键类型 com.baomidou.mybatisplus.annotation.IdType"; + id-type: assign_id + #字段策略 com.baomidou.mybatisplus.annotation.FieldStrategy" + select-strategy: NOT_EMPTY + insert-strategy: NOT_EMPTY + update-strategy: NOT_EMPTY + #逻辑删除配置(下面3个配置) + logic-delete-value: 0 + logic-not-delete-value: 1 + configuration: + jdbc-type-for-null: 'null' + #数据库大写下划线转换 + map-underscore-to-camel-case: true + cache-enabled: false + lazy-loading-enabled: true + multiple-result-sets-enabled: true + log-impl: org.apache.ibatis.logging.slf4j.Slf4jImpl #开启sql日志 +# log-impl: org.apache.ibatis.logging.nologging.NoLoggingImpl + configuration-properties: + dbType: mysql #设置全局属性用于控制数据库的类型 + + +# PageHelper分页插件 +pagehelper: + helperDialect: mysql + supportMethodsArguments: true + params: count=countSql + +# Swagger配置 +swagger: + # 是否开启swagger + enabled: true + # 请求前缀 + pathMapping: + +# 防止XSS攻击 +xss: + # 过滤开关 + enabled: true + # 排除链接(多个用逗号分隔) + excludes: /system/notice + # 匹配链接 + urlPatterns: /system/*,/monitor/*,/tool/* + +#文件上传配置 +#使用的上传存储空间,local本地,aliyun:阿里云 +oss: + client-type: local + #默认上传目录 + base_dir: userfiles + #允许的文件扩展名 + allowed_extension: mp4,bmp, gif, jpg, jpeg, png,doc, docx, xls, xlsx, ppt, pptx,html,htm,txt,rar, zip, gz, bz2,pdf + #最大文件大小 50M + max_size: 52428800 + #是否需要按照日期存放文件 + needDatePath: false + +sms: + #三方短信类型 1 助通短信 2 阿里短信 3 腾讯云短信 + sms_type: 3 + + #阿里短信 + access-key-id: + access-key-secret: + signName: + templateCode: + + #助通短信 + username: huitu + password: 123456 + +# 消息推送 +push: + # 消息推送 1 goeasy ; 2 uniapp + push_type: 1 + #goeasy(消息推送,聊天) + goeasy: + appkey: BC-d4519ea15c3f4d67a0d923dc980cbdac + regionHost: https://rest-hangzhou.goeasy.io + secretKey: d3c00d08e684412e + + #uniapp消息推送 + uniapp: + appid: + appkey: + mastersecret: + +nohupLog: + size: 10MB + baseDir: /home/manage/ + +#一键登陆解密手机号参数 +decryptPhone: + url: https://api.verification.jpush.cn/v1/web/loginTokenVerify + app_key: fde270559d7d5d488d58f545 + master_Key: fdb70c3d0d1a622d5b8b1cd3 + private_key: MIICdQIBADANBgkqhkiG9w0BAQEFAASCAl8wggJbAgEAAoGBAJYswKGroaPqET+uV4SYtUuKt628Wa3J1wXrpV1dEFqVH6PnZgOBFLvrojHZ7XQfgjHazXZkTkra6mvRNO35CS9rnTZEnYVrD9MQnirMbGsSOtCyTVNQUoqmGgWVaM2F+2XS6F+p2BzLbEHhv+YyHC65qmh8iFyDykJY4dkRYjX7AgMBAAECgYBH/GXOWY5fG1lvVCwBlI37CyCm+E1ooAMhhGa9TVoEgc0r7UUaUurUdcxG5zcK3fuz2DV7FfPtr+iFDEC5/hFnW+KV+9R0c6Y8jJKW1p0qAKNU4Icvl/rViX8dQCV0nY0Gny6JtirKzGp0O8lwuynjBWwJds5emFXCippL57HVMQJBANhq53cSarStsf88CHwyG+SRQkX962eoGx7EBFGqAbM0l26mHh0t7bWtA+Thwv+EbgP2/GqOX6TPpHRB4jiJJCkCQQCxpDtGSpIBINRvv1BvVy0Tl058xUWLFFf5tar07DRG3qo9uJR75fLjBILip7bkkclFljmtoaQ4gkP9mlAYPa2DAkB4Yr9vVSdWamjhehueOqGZe9RJ6v3QI4syigd9Bfz8Gv1B59ZIlQvuS9gmsg8u5BPu0K2I+LnrjDYHFb8pg+BBAkAyUZcIvi7FawtB7CtYnpUCK6Xr6eVdFBInhbI7Vn0oZgJLIXHN9sDqVWjN0zwXWsRslbUY3eSqrRudRozRkQcJAkA2B3glMnfjzikFpshq0eKpJj4vUXBsAAO5er73eaC7u2iPls6ABeb9+9Vr8Cqt67wspRqKdX54Xka9CPhOwRWz + +#支付回调 +notifyurl: + #订单首款支付 + ali-order-url: /api/pay/orderAliNotify + wx-order-url: /api/pay/orderWxNotify + lkl-order-url: /api/pay/orderLakalaNotify + #订单尾款支付 + ali-secondOrder-url: /api/pay/secondOrderAliNotify + wx-secondOrder-url: /api/pay/secondOrderWxNotify + lkl-secondOrder-url: /api/pay/secondOrderLakalaNotify + #充值订单支付 + ali-recharge-url: /api/pay/rechargeAliNotify + wx-recharge-url: /api/pay/rechargeWxNotify + lkl-recharge-url: /api/pay/rechargeLakalaNotify + #保证金支付 + ali-bond-url: /api/pay/bondAliNotify + wx-bond-url: /api/pay/bondWxNotify + lkl-bond-url: /api/pay/bondLakalaNotify + #普通认证支付 + ali-auth-url: /api/pay/authAliNotify + wx-auth-url: /api/pay/authWxNotify + lkl-auth-url: /api/pay/authLakalaNotify + #高端认证支付 + ali-highend-auth-url: /api/pay/highendAuthAliNotify + wx-highend-auth-url: /api/pay/highendAuthWxNotify + lkl-highend-auth-url: /api/pay/highendAuthLakalaNotify + #设计师调价支付 + ali-adjustPrice-auth-url: /api/pay/orderAdjustPricePayAliNotify + wx-adjustPrice-auth-url: /api/pay/orderAdjustPricePayWxNotify + lkl-adjustPrice-auth-url: /api/pay/orderAdjustPricePayLakalaNotify + #表现师调价设计师确认支付 + ali-adjustPriceConfirm-auth-url: /api/pay/orderAdjustPriceConfirmPayAliNotify + wx-adjustPriceConfirm-auth-url: /api/pay/orderAdjustPriceConfirmPayWxNotify + lkl-adjustPriceConfirm-auth-url: /api/pay/orderAdjustPriceConfirmPayLakalaNotify + +#支付宝支付参数 +alipay: + appid: + private-key: + ali-public-key: + + h5appid: + partner: + h5private-key: + h5ali-public-key: + + subject: + sign-type: RSA2 + ali-url: https://openapi.alipay.com/gateway.do + product-code: QUICK_MSECURITY_PAY + +#微信支付参数 +wxpay: + appid: wx8cba639752e95ed0 + mchid: + paykey: + app-secret: 1e7d48b009a5e5c9902d6e9ae1b0e8d9 + + h5appid: + h5mchid: + h5paykey: + h5app-secret: + +wxrefundfile: + path: /home/manage/apiclient_cert.p12 + +#app名称 +app: + name: DD画图 + +DD_drawing: + appid: wxed96e8fe10ea8992 + secret: 5a1da24f97e49aa5762897045dd593b6 + +DD_co_creation: + appid: wx45d9099290a6ec3d + secret: fa6bc98943d4e0bdc3850475c320deb2 diff --git a/ruoyi-extend/ruoyi-business/src/main/resources/banner.txt b/ruoyi-extend/ruoyi-business/src/main/resources/banner.txt new file mode 100644 index 0000000..0931cb8 --- /dev/null +++ b/ruoyi-extend/ruoyi-business/src/main/resources/banner.txt @@ -0,0 +1,24 @@ +Application Version: ${ruoyi.version} +Spring Boot Version: ${spring-boot.version} +//////////////////////////////////////////////////////////////////// +// _ooOoo_ // +// o8888888o // +// 88" . "88 // +// (| ^_^ |) // +// O\ = /O // +// ____/`---'\____ // +// .' \\| |// `. // +// / \\||| : |||// \ // +// / _||||| -:- |||||- \ // +// | | \\\ - /// | | // +// | \_| ''\---/'' | | // +// \ .-\__ `-` ___/-. / // +// ___`. .' /--.--\ `. . ___ // +// ."" '< `.___\_<|>_/___.' >'"". // +// | | : `- \`.;`\ _ /`;.`/ - ` : | | // +// \ \ `-. \_ __\ /__ _/ .-` / / // +// ========`-.____`-.___\_____/___.-`____.-'======== // +// `=---=' // +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ // +// 佛祖保佑 永不宕机 永无BUG // +//////////////////////////////////////////////////////////////////// \ No newline at end of file diff --git a/ruoyi-extend/ruoyi-business/src/main/resources/i18n/messages.properties b/ruoyi-extend/ruoyi-business/src/main/resources/i18n/messages.properties new file mode 100644 index 0000000..954e0a9 --- /dev/null +++ b/ruoyi-extend/ruoyi-business/src/main/resources/i18n/messages.properties @@ -0,0 +1,41 @@ +#错误消息 +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}次,帐户锁定10分钟 +user.password.delete=对不起,您的账号已被删除 +user.blocked=用户已封禁,请联系管理员 +role.blocked=角色已封禁,请联系管理员 +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}] + + + +the.voting.activity.has.ended=投票活动已截止 diff --git a/ruoyi-extend/ruoyi-business/src/main/resources/logback.xml b/ruoyi-extend/ruoyi-business/src/main/resources/logback.xml new file mode 100644 index 0000000..a360583 --- /dev/null +++ b/ruoyi-extend/ruoyi-business/src/main/resources/logback.xml @@ -0,0 +1,93 @@ + + + + + + + + + + + ${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/ruoyi-extend/ruoyi-business/src/main/resources/mybatis/mybatis-config.xml b/ruoyi-extend/ruoyi-business/src/main/resources/mybatis/mybatis-config.xml new file mode 100644 index 0000000..ac47c03 --- /dev/null +++ b/ruoyi-extend/ruoyi-business/src/main/resources/mybatis/mybatis-config.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + diff --git a/ruoyi-extend/ruoyi-job/pom.xml b/ruoyi-extend/ruoyi-job/pom.xml new file mode 100644 index 0000000..a47a247 --- /dev/null +++ b/ruoyi-extend/ruoyi-job/pom.xml @@ -0,0 +1,85 @@ + + + 4.0.0 + + com.ruoyi + ruoyi-extend + 3.7.0 + + + ruoyi-job + + + 8 + 8 + UTF-8 + + + + + + com.belerweb + pinyin4j + 2.5.0 + + + + com.ruoyi + ruoyi-quartz + 3.7.0 + + + + com.ruoyi + ruoyi-admin-core + 3.7.0 + + + + com.ruoyi + ruoyi-custom + 3.7.0 + + + + com.ruoyi + ruoyi-post + 3.7.0 + + + + + + + + org.springframework.boot + spring-boot-maven-plugin + 2.1.1.RELEASE + + true + true + + + + + repackage + + + + + + org.apache.maven.plugins + maven-war-plugin + 3.1.0 + + false + ${project.artifactId} + + + + ${project.artifactId} + + + diff --git a/ruoyi-extend/ruoyi-job/src/main/java/com/ruoyi/JobApplication.java b/ruoyi-extend/ruoyi-job/src/main/java/com/ruoyi/JobApplication.java new file mode 100644 index 0000000..d28334d --- /dev/null +++ b/ruoyi-extend/ruoyi-job/src/main/java/com/ruoyi/JobApplication.java @@ -0,0 +1,25 @@ +package com.ruoyi; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; +import org.springframework.scheduling.annotation.EnableAsync; +import org.springframework.scheduling.annotation.EnableScheduling; + +/** + * 启动程序 + * + * @author ruoyi + */ +@EnableAsync +@EnableScheduling +@SpringBootApplication(exclude = { DataSourceAutoConfiguration.class }) +public class JobApplication +{ + public static void main(String[] args) + { +// System.setProperty("spring.devtools.restart.enabled", "false"); + SpringApplication.run(JobApplication.class, args); + System.out.println("(♥◠‿◠)ノ゙ 定时任务线程启动成功 ლ(´ڡ`ლ)゙"); + } +} diff --git a/ruoyi-extend/ruoyi-job/src/main/java/com/ruoyi/JobServletInitializer.java b/ruoyi-extend/ruoyi-job/src/main/java/com/ruoyi/JobServletInitializer.java new file mode 100644 index 0000000..d18e7c0 --- /dev/null +++ b/ruoyi-extend/ruoyi-job/src/main/java/com/ruoyi/JobServletInitializer.java @@ -0,0 +1,18 @@ +package com.ruoyi; + +import org.springframework.boot.builder.SpringApplicationBuilder; +import org.springframework.boot.web.servlet.support.SpringBootServletInitializer; + +/** + * web容器中进行部署 + * + * @author ruoyi + */ +public class JobServletInitializer extends SpringBootServletInitializer +{ + @Override + protected SpringApplicationBuilder configure(SpringApplicationBuilder application) + { + return application.sources(JobApplication.class); + } +} diff --git a/ruoyi-extend/ruoyi-job/src/main/java/com/ruoyi/task/RyTask.java b/ruoyi-extend/ruoyi-job/src/main/java/com/ruoyi/task/RyTask.java new file mode 100644 index 0000000..b4ebe96 --- /dev/null +++ b/ruoyi-extend/ruoyi-job/src/main/java/com/ruoyi/task/RyTask.java @@ -0,0 +1,353 @@ +package com.ruoyi.task; + +import cn.hutool.core.collection.CollectionUtil; +import cn.hutool.core.date.DateUtil; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; +import com.lkl.laop.sdk.LKLSDK; +import com.lkl.laop.sdk.request.V2LaepIndustryEwalletWithdrawD1Request; +import com.lkl.laop.sdk.request.V2MmsQueryLedgerMerRequest; +import com.lkl.laop.sdk.request.V3SacsBalanceSeparateQueryRequest; +import com.lkl.laop.sdk.utils.CommonUtil; +import com.ruoyi.code.DictConstant; +import com.ruoyi.code.PublicCommon; +import com.ruoyi.common.core.domain.BaseEntity; +import com.ruoyi.common.core.domain.entity.SysDictData; +import com.ruoyi.controller.req.MallOrderConfirmReq; +import com.ruoyi.enums.mallorder.MallOrderStatusEnums; +import com.ruoyi.enums.message.OrderMessageEnums; +import com.ruoyi.enums.order.OrderStatusEnums; +import com.ruoyi.enums.user.UserEnums; +import com.ruoyi.frequency.klkaccount.entity.KlkAccount; +import com.ruoyi.frequency.klkaccount.mapper.KlkAccountMapper; +import com.ruoyi.frequency.klkaccount.service.KlkAccountService; +import com.ruoyi.frequency.klkwithdrawalrecord.entity.KlkWithdrawalRecord; +import com.ruoyi.frequency.klkwithdrawalrecord.mapper.KlkWithdrawalRecordMapper; +import com.ruoyi.frequency.mallorder.entity.MallOrder; +import com.ruoyi.frequency.mallorder.service.MallOrderService; +import com.ruoyi.frequency.order.entity.Order; +import com.ruoyi.frequency.order.service.OrderService; +import com.ruoyi.frequency.ordermessage.service.OrderMessageService; +import com.ruoyi.frequency.withdrawalrecord.entity.WithdrawalRecord; +import com.ruoyi.frequency.withdrawalrecord.mapper.WithdrawalRecordMapper; +import com.ruoyi.klk.constant.KlkConstant; +import com.ruoyi.klk.service.KlkService; +import com.ruoyi.klk.util.InitUtil; +import com.ruoyi.utils.BusinessUtil; +import com.ruoyi.vo.UserVo; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Component; + +import java.math.BigDecimal; +import java.math.RoundingMode; +import java.util.Date; +import java.util.List; +import java.util.stream.Collectors; + +/** + * 定时任务 + * + * @author liwenlong + * @date 2023-10-23 + */ +@Component("businessTask") +@Slf4j +public class RyTask { + + @Value("${basepath.url}") + private String urlPrefix; + + @Autowired + private OrderService orderService; + + @Autowired + private BusinessUtil businessUtil; + + //商户号 + @Value("${lalkla.merchantNo}") + private String merchantNo; + + /** + * 订单定时取消 + */ + public void orderCancelTask() { + log.info("定时任务【订单定时取消】开始执行,执行时间:{}", DateUtil.formatDateTime(new Date())); + + SysDictData dict = businessUtil.getDict(DictConstant.订单自动取消时间); + Integer autoOrderCancelTime = 15; + if (dict != null) { + //查询订单自动取消时长 + autoOrderCancelTime = Integer.valueOf(dict.getDictValue()); + } + + //查询超出时间未支付的订单 + List orderList = orderService.list(new QueryWrapper().lambda() + .ne(Order::getStatus, OrderStatusEnums.cancel.getCode()) + .eq(Order::getSourceUserType, 1) + .eq(Order::getFirstStatus, PublicCommon.Pay.未支付) + .gt(BaseEntity::getCreateTime, DateUtil.offsetMinute(new Date(), autoOrderCancelTime)) + ); + if (orderList.size() > 0) { + orderList.stream().forEach(s -> { + orderService.orderCancel(s.getId(), new UserVo(UserEnums.customer.getCode(), s.getCustomerId())); + }); + } + + log.info("定时任务【订单定时取消】执行结束,执行时间:{}", DateUtil.formatDateTime(new Date())); + } + + + @Autowired + private OrderMessageService orderMessageService; + + + /** + * 超过对图时间,消息提醒 + */ + public void orderDeliveryTimoutPushTask() { + log.info("定时任务【超过对图时间第二天,消息提醒】开始执行,执行时间:{}", DateUtil.formatDateTime(new Date())); + + //查询未发送消息的订单 + List orderList = orderService.list(new QueryWrapper().lambda() + .eq(Order::getStatus, OrderStatusEnums.ongoing.getCode()) + .between(Order::getDeliverTime, DateUtil.beginOfDay(DateUtil.offsetDay(new Date(), -1)), + DateUtil.endOfDay(DateUtil.offsetDay(new Date(), -1))) + ); + orderList.stream().forEach(order -> { + + //表现师发送消息 + orderMessageService.addOrderMessage(new UserVo(UserEnums.store.getCode(), order.getStoreId()), order.getId(), order.getOrderNo(), PublicCommon.Order.订单, OrderMessageEnums.ORDER_AUTO_CONFIRM_DELIVER); + + //设计师发送消息 + orderMessageService.addOrderMessage(new UserVo(UserEnums.customer.getCode(), order.getCustomerId()), order.getId(), order.getOrderNo(), PublicCommon.Order.订单, OrderMessageEnums.ORDER_AUTO_CONFIRM_DELIVER); + + }); + + log.info("定时任务【超过对图时间第二天,消息提醒】开始执行:{}", DateUtil.formatDateTime(new Date())); + } + + @Autowired + private MallOrderService mallOrderService; + + + /** + * 发货时间超过 x天的订单自动确认收货 + */ + public void confirmMallOrder() { + log.info("定时任务【超过发货时间第X天,消息提醒】开始执行,执行时间:{}", DateUtil.formatDateTime(new Date())); + + SysDictData 平台发货后X天自动确认收货 = businessUtil.getDict(DictConstant.MallOrderDict.平台发货后X天自动确认收货); + + //查询未发送消息的订单 + List list = mallOrderService.list(new QueryWrapper().lambda().eq(MallOrder::getOrderStatus, MallOrderStatusEnums.已发货.getCode()) + .le(MallOrder::getSendTime, DateUtil.offsetDay(new Date(), -(Integer.valueOf(平台发货后X天自动确认收货.getDictValue()))))); + + list.stream().forEach(order -> { + MallOrderConfirmReq req = new MallOrderConfirmReq(); + req.setOrderId(order.getId()); + mallOrderService.orderConfirm(req, new UserVo(order.getUserType(), order.getUserId())); + }); + + } + + @Autowired + private KlkWithdrawalRecordMapper klkWithdrawalRecordMapper; + + @Autowired + private KlkService klkService; + + @Autowired + private InitUtil initUtil; + + /** + * 定时扫描分账记录,对已经分账成功的记录,进行银行卡提现 + */ + public void catDiscountToWithdrawal() { + log.info("定时任务【扫描分账成功的记录,进行下一步提现】"); + + // 1-处理中 2-已受理 + List klkWithdrawalRecordList = klkWithdrawalRecordMapper.selectList(new LambdaQueryWrapper() + .eq(KlkWithdrawalRecord::getDelFlag, PublicCommon.启用) + .in(KlkWithdrawalRecord::getBalanceSplitStatus, 1, 2)); + if (CollectionUtil.isEmpty(klkWithdrawalRecordList)) { + return; + } + + + klkWithdrawalRecordList.forEach(klkWithdrawalRecord -> { + + try { + // 根据商户分账指令流水号查询余额分账结果 + String outSeparateNo = klkWithdrawalRecord.getOutSeparateNo(); + initUtil.doInit(); + V3SacsBalanceSeparateQueryRequest request = new V3SacsBalanceSeparateQueryRequest(); + request.setMerchantNo(merchantNo); + request.setOutSeparateNo(outSeparateNo); + String response = LKLSDK.httpPost(request); + JSONObject jsonObject = JSON.parseObject(response); + if ("SACS0000".equals(jsonObject.getString("code"))) { + JSONObject respData = jsonObject.getJSONObject("resp_data"); + String status = respData.getString("status"); + klkWithdrawalRecordMapper.update(null, new LambdaUpdateWrapper() + .eq(KlkWithdrawalRecord::getOutSeparateNo, outSeparateNo) + .set(KlkWithdrawalRecord::getBalanceSplitStatus, klkService.getBalanceSplitStatus(status))); + if (KlkConstant.SUCCESS.equals(status)) { + // 成功后提现 + withdrawal(klkWithdrawalRecord); + } + } + } catch (Exception e) { + log.error("查询余额分账结果出现异常:{}", e.getMessage()); + } + }); + } + + + @Autowired + private KlkAccountMapper klkAccountMapper; + + /** + * 提现 + * + * @param klkWithdrawalRecord + */ + private void withdrawal(KlkWithdrawalRecord klkWithdrawalRecord) { + try { + // 查询用户卡拉卡账号 + KlkAccount klkAccount = klkAccountMapper.selectOne(new LambdaUpdateWrapper() + .eq(KlkAccount::getDelFlag, PublicCommon.启用) + .eq(KlkAccount::getUserType, klkWithdrawalRecord.getUserType()) + .eq(KlkAccount::getUserId, klkWithdrawalRecord.getUserId())); + initUtil.doInit(); + V2LaepIndustryEwalletWithdrawD1Request request = new V2LaepIndustryEwalletWithdrawD1Request(); + request.setOrgNo(KlkConstant.ORG_NO); + request.setMerchantNo(klkAccount.getReceiverNo()); + request.setDrawAmt(getDrawAmt(klkWithdrawalRecord.getTotalAmt())); + request.setNotifyUrl(urlPrefix + KlkConstant.WITHDRAWAL); + //账号类型(01:收款账户,04:分账接收方账户)未上送则默认为01 分账接收方提现时需填04 + request.setPayType("04"); + String response = LKLSDK.httpPost(request); + JSONObject jsonObject = JSON.parseObject(response); + if ("000000".equals(jsonObject.getString("retCode"))) { + JSONObject respData = jsonObject.getJSONObject("respData"); + klkWithdrawalRecordMapper.update(null, new LambdaUpdateWrapper() + .eq(KlkWithdrawalRecord::getDelFlag, PublicCommon.启用) + .eq(KlkWithdrawalRecord::getId, klkWithdrawalRecord.getId()) + .set(KlkWithdrawalRecord::getWithdrawalStatus, 1) + .set(KlkWithdrawalRecord::getDrawJnl, respData.getString("drawJnl"))); + } else { + klkWithdrawalRecordMapper.update(null, new LambdaUpdateWrapper() + .eq(KlkWithdrawalRecord::getDelFlag, PublicCommon.启用) + .eq(KlkWithdrawalRecord::getId, klkWithdrawalRecord.getId()) + .set(KlkWithdrawalRecord::getWithdrawalStatus, 4) + .set(KlkWithdrawalRecord::getWithdrawalRemark, jsonObject.getString("retMsg"))); + + withdrawalRecordMapper.update(null, new LambdaUpdateWrapper() + .eq(WithdrawalRecord::getId, klkWithdrawalRecord.getWithdrawalRecordId()) + .set(WithdrawalRecord::getRefuseReason, jsonObject.getString("retMsg"))); + } + } catch (Exception e) { + + log.error("提现出现异常:{}", e.getMessage()); + + } + } + + @Autowired + private WithdrawalRecordMapper withdrawalRecordMapper; + + /** + * 将分转换为元 + * + * @param totalAmt + * @return + */ + private String getDrawAmt(String totalAmt) { + return new BigDecimal(totalAmt).divide(new BigDecimal("100"), 2, RoundingMode.DOWN).toString(); + } + + @Autowired + private KlkAccountService klkAccountService; + + + /** + * 定时更新拉卡拉账号状态 + */ + public void updateTimeAccountStatus() { + log.info("定时更新拉卡拉账号状态..."); + // 查询所有账号为2的账号 + List klkAccountList = klkAccountMapper.selectList(new LambdaQueryWrapper() + .eq(KlkAccount::getDelFlag, PublicCommon.启用) + .eq(KlkAccount::getBindStatus, 2)); + if (CollectionUtil.isEmpty(klkAccountList)) { + return; + } + + // 调用三方接口,获取已经开通的账号 + List receiverNoList = getAlreadyOpenedAccount(); + if (CollectionUtil.isEmpty(receiverNoList)) { + return; + } + + // 如果查询的账号在三方存在,表示开通成功,直接修改账号状态 + updateAccStatus(receiverNoList, klkAccountList); + } + + /** + * 如果查询的账号在三方存在,表示开通成功,直接修改账号状态 + * @param receiverNoList + */ + private void updateAccStatus(List receiverNoList, List klkAccountList) { + if (CollectionUtil.isEmpty(receiverNoList) || CollectionUtil.isEmpty(klkAccountList)) { + return; + } + + for (KlkAccount klkAccount : klkAccountList) { + if (receiverNoList.contains(klkAccount.getReceiverNo())) { + klkAccount.setBindStatus(3); + } + } + + // 过滤只要3的 + klkAccountList = klkAccountList.stream().filter(s -> s.getBindStatus() == 3).collect(Collectors.toList()); + if (CollectionUtil.isEmpty(klkAccountList)) { + return; + } + + klkAccountService.updateBatchById(klkAccountList); + } + + /** + * 调用三方接口,获取已经开通的账号 + * @return + */ + private List getAlreadyOpenedAccount() { + try { + initUtil.doInit(); + V2MmsQueryLedgerMerRequest request = new V2MmsQueryLedgerMerRequest(); + request.setOrgCode(KlkConstant.ORG_CODE); + request.setOrderNo(CommonUtil.getOrderNo()); + request.setMerCupNo(merchantNo); + String response = LKLSDK.httpPost(request); + JSONObject jsonObject = JSON.parseObject(response); + if ("000000".equals(jsonObject.getString("retCode"))) { + JSONObject innerJsonObj = jsonObject.getJSONObject("respData"); + JSONArray jsonArray = innerJsonObj.getJSONArray("bindRelations"); + return jsonArray.stream().map(s -> { + JSONObject obj = (JSONObject) s; + return obj.getString("receiverNo"); + }).collect(Collectors.toList()); + } + return null; + } catch (Exception e) { + log.error("查询商户分账信息出现异常:{}", e.getMessage()); + return null; + } + } +} diff --git a/ruoyi-extend/ruoyi-job/src/main/resources/META-INF/spring-devtools.properties b/ruoyi-extend/ruoyi-job/src/main/resources/META-INF/spring-devtools.properties new file mode 100644 index 0000000..2b23f85 --- /dev/null +++ b/ruoyi-extend/ruoyi-job/src/main/resources/META-INF/spring-devtools.properties @@ -0,0 +1 @@ +restart.include.json=/com.alibaba.fastjson.*.jar \ No newline at end of file diff --git a/ruoyi-extend/ruoyi-job/src/main/resources/application-dev.yml b/ruoyi-extend/ruoyi-job/src/main/resources/application-dev.yml new file mode 100644 index 0000000..bdcb097 --- /dev/null +++ b/ruoyi-extend/ruoyi-job/src/main/resources/application-dev.yml @@ -0,0 +1,117 @@ + +# 数据源配置 +spring: + redis: + # 地址 + host: localhost + # 端口,默认为6379 + port: 6379 + # 数据库索引 + database: 0 + # 密码 + password: Huitu123 + datasource: + type: com.alibaba.druid.pool.DruidDataSource + driverClassName: com.mysql.cj.jdbc.Driver + druid: + # 主库数据源 + master: + url: jdbc:mysql://localhost:3306/ddht?useUnicode=true&allowMultiQueries=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 + username: root + password: root +# url: jdbc:mysql://124.223.56.113:13306/ddht?useUnicode=true&allowMultiQueries=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 +# username: ddht +# password: ZGFSCkDHmLN62Mnt + # 从库数据源 + slave: + # 从数据源开关/默认关闭 + enabled: false + url: jdbc:mysql://wiz.52o.site:13306/ddht?useUnicode=true&allowMultiQueries=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 + username: ddht + password: i5y4EacPLkWSm6sz + # 初始连接数 + initialSize: 5 + # 最小连接池数量 + minIdle: 10 + # 最大连接池数量 + maxActive: 20 + # 配置获取连接等待超时的时间 + maxWait: 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: ruoyi + login-password: 123456 + filter: + stat: + enabled: true + # 慢SQL记录 + log-slow-sql: true + slow-sql-millis: 1000 + merge-sql: true + wall: + config: + multi-statement-allow: true + +oss: + local: + #文件域名 + domain: http://localhost:8080 + #存储路径 + upload-file-path: D:/ruoyiVueS + aliyun: + #阿里云api的内或外网域名 + endpoint: oss-cn-beijing.aliyuncs.com + #阿里云api的密钥access key id + access-key-id: + #阿里云api的密钥access key secret + access-key-secret: + #阿里云api的bucket名称 + bucket-name: + #外部访问域名 + domain: http://xxxxx.oss-cn-beijing.aliyuncs.com + +basepath: + url: http://dianqi.natapp1.cc +wecom: + corpid: ww45fb4d72c735ee1d + corpsecret: 5x3F-AHQMO9VwpXH9_lOUX8887sqb1fUx0-5goN6U_Y + +# 拉卡拉测试支付参数 +lalkla: + #拉卡拉开放平台进行配置开通 + appId: OP00002734 + #商户号 + merchantNo: 8223610899900ZC + #商户证书序列号,和商户私钥对应 + serialNo: 018f86243d2c + #商户私钥地址,用于请求签名 + priKeyPath: G:/lakala/OP00000003_private_key.pem + #拉卡拉公钥证书地址,用于验签(测试证书为:lkl-apigw-v1.cer) + lklCerPath: G:/lakala/lkl-apigw-v2.cer + #拉卡拉支付平台证书地址2(用于拉卡拉通知验签,证书与lklCerPath)一致,测试证书为:lkl-apigw-v1.cer) + lklNotifyCerPath: G:/lakala/lkl-apigw-v2.cer + #拉卡拉开放平台服务地址 + serverUrl: https://s2.lakala.com + #如果需要密文传输请申请拉卡拉SM4密钥 + sm4Key: 0I4M0kmwFrNUU8hZ9AFpfA== + # 文件下载存储地址 + basePath: G:\download\ + # 文件下载存储地址 + filePath: G:\file\ \ No newline at end of file diff --git a/ruoyi-extend/ruoyi-job/src/main/resources/application-prod.yml b/ruoyi-extend/ruoyi-job/src/main/resources/application-prod.yml new file mode 100644 index 0000000..c7ae73c --- /dev/null +++ b/ruoyi-extend/ruoyi-job/src/main/resources/application-prod.yml @@ -0,0 +1,115 @@ +# 数据源配置 +spring: + redis: + # 地址 + host: localhost + # 端口,默认为6379 + port: 6379 + # 数据库索引 + database: 7 + # 密码 + password: Huitu123 + + datasource: + type: com.alibaba.druid.pool.DruidDataSource + driverClassName: com.mysql.cj.jdbc.Driver + druid: + # 主库数据源 + master: + url: jdbc:mysql://localhost:3306/ddht?useUnicode=true&allowMultiQueries=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 + username: root + password: root +# url: jdbc:mysql://124.223.56.113:13306/ddht?useUnicode=true&allowMultiQueries=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 +# username: ddht +# password: ZGFSCkDHmLN62Mnt + # 从库数据源 + slave: + # 从数据源开关/默认关闭 + enabled: false + url: jdbc:mysql://wiz.52o.site:13306/ddht?useUnicode=true&allowMultiQueries=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 + username: ddht + password: i5y4EacPLkWSm6sz + # 初始连接数 + initialSize: 5 + # 最小连接池数量 + minIdle: 10 + # 最大连接池数量 + maxActive: 20 + # 配置获取连接等待超时的时间 + maxWait: 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: ruoyi + login-password: 123456 + filter: + stat: + enabled: true + # 慢SQL记录 + log-slow-sql: true + slow-sql-millis: 1000 + merge-sql: true + wall: + config: + multi-statement-allow: true + +oss: + local: + #文件域名 + domain: http://localhost:8080 + #存储路径 + upload-file-path: D:/ruoyiVueS + aliyun: + #阿里云api的内或外网域名 + endpoint: oss-cn-beijing.aliyuncs.com + #阿里云api的密钥access key id + access-key-id: + #阿里云api的密钥access key secret + access-key-secret: + #阿里云api的bucket名称 + bucket-name: + #外部访问域名 + domain: http://xxxxx.oss-cn-beijing.aliyuncs.com + + +basepath: + url: http://erp.ddht.cn/huituApi + +# 拉卡拉测试支付参数 +lalkla: + #拉卡拉开放平台进行配置开通 + appId: OP00002734 + #商户号 + merchantNo: 8223610899900ZC + #商户证书序列号,和商户私钥对应 + serialNo: 018f86243d2c + #商户私钥地址,用于请求签名 + priKeyPath: /home/manage/huitu/OP00000003_private_key.pem + #拉卡拉公钥证书地址,用于验签(测试证书为:lkl-apigw-v2.cer) + lklCerPath: /home/manage/huitu/lkl-apigw-v2.cer + #拉卡拉支付平台证书地址2(用于拉卡拉通知验签,证书与lklCerPath)一致,测试证书为:lkl-apigw-v2.cer) + lklNotifyCerPath: /home/manage/huitu/lkl-apigw-v2.cer + #拉卡拉开放平台服务地址 + serverUrl: https://s2.lakala.com + #如果需要密文传输请申请拉卡拉SM4密钥 + sm4Key: 0I4M0kmwFrNUU8hZ9AFpfA== + # 文件下载存储地址 + basePath: /home/manage/huitu/download/ + # 文件下载存储地址 + filePath: /home/manage/huitu/file/ \ No newline at end of file diff --git a/ruoyi-extend/ruoyi-job/src/main/resources/application-test.yml b/ruoyi-extend/ruoyi-job/src/main/resources/application-test.yml new file mode 100644 index 0000000..38d31dd --- /dev/null +++ b/ruoyi-extend/ruoyi-job/src/main/resources/application-test.yml @@ -0,0 +1,117 @@ + +# 数据源配置 +spring: + redis: + # 地址 + host: localhost + # 端口,默认为6379 + port: 6379 + # 数据库索引 + database: 0 + # 密码 + password: Huitu123 + datasource: + type: com.alibaba.druid.pool.DruidDataSource + driverClassName: com.mysql.cj.jdbc.Driver + druid: + # 主库数据源 + master: + url: jdbc:mysql://localhost:3306/ddht?useUnicode=true&allowMultiQueries=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 + username: root + password: root +# url: jdbc:mysql://124.223.56.113:13306/ddht?useUnicode=true&allowMultiQueries=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 +# username: ddht +# password: ZGFSCkDHmLN62Mnt + # 从库数据源 + slave: + # 从数据源开关/默认关闭 + enabled: false + url: jdbc:mysql://wiz.52o.site:13306/ddht?useUnicode=true&allowMultiQueries=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 + username: ddht + password: i5y4EacPLkWSm6sz + # 初始连接数 + initialSize: 5 + # 最小连接池数量 + minIdle: 10 + # 最大连接池数量 + maxActive: 20 + # 配置获取连接等待超时的时间 + maxWait: 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: ruoyi + login-password: 123456 + filter: + stat: + enabled: true + # 慢SQL记录 + log-slow-sql: true + slow-sql-millis: 1000 + merge-sql: true + wall: + config: + multi-statement-allow: true + +oss: + local: + #文件域名 + domain: http://localhost:8080 + #存储路径 + upload-file-path: D:/ruoyiVueS + aliyun: + #阿里云api的内或外网域名 + endpoint: oss-cn-beijing.aliyuncs.com + #阿里云api的密钥access key id + access-key-id: + #阿里云api的密钥access key secret + access-key-secret: + #阿里云api的bucket名称 + bucket-name: + #外部访问域名 + domain: http://xxxxx.oss-cn-beijing.aliyuncs.com + +basepath: + url: http://8.142.155.9/huituApi +wecom: + corpid: ww45fb4d72c735ee1d + corpsecret: 5x3F-AHQMO9VwpXH9_lOUX8887sqb1fUx0-5goN6U_Y + +# 拉卡拉测试支付参数 +lalkla: + #拉卡拉开放平台进行配置开通 + appId: OP00002734 + #商户号 + merchantNo: 8223610899900YF + #商户证书序列号,和商户私钥对应 + serialNo: 018f86243d2c + #商户私钥地址,用于请求签名 + priKeyPath: /home/manage/huitu/OP00000003_private_key.pem + #拉卡拉公钥证书地址,用于验签(测试证书为:lkl-apigw-v2.cer) + lklCerPath: /home/manage/huitu/lkl-apigw-v2.cer + #拉卡拉支付平台证书地址2(用于拉卡拉通知验签,证书与lklCerPath)一致,测试证书为:lkl-apigw-v2.cer) + lklNotifyCerPath: /home/manage/huitu/lkl-apigw-v2.cer + #拉卡拉开放平台服务地址 + serverUrl: https://s2.lakala.com + #如果需要密文传输请申请拉卡拉SM4密钥 + sm4Key: 0I4M0kmwFrNUU8hZ9AFpfA== + # 文件下载存储地址 + basePath: /home/manage/huitu/download/ + # 文件下载存储地址 + filePath: /home/manage/huitu/file/ diff --git a/ruoyi-extend/ruoyi-job/src/main/resources/application.yml b/ruoyi-extend/ruoyi-job/src/main/resources/application.yml new file mode 100644 index 0000000..f4b1ed1 --- /dev/null +++ b/ruoyi-extend/ruoyi-job/src/main/resources/application.yml @@ -0,0 +1,271 @@ +# 项目相关配置 +ruoyi: + # 名称 + name: RuoYi-Vue-Job + # 版本 + version: 3.7.0 + # 版权年份 + copyrightYear: 2021 + # 实例演示开关 + demoEnabled: true + # 文件路径 示例( Windows配置D:/ruoyi/uploadPath,Linux配置 /home/ruoyi/uploadPath) + profile: D:/ruoyi/uploadPath + # 获取ip地址开关 + addressEnabled: false + # 验证码类型 math 数组计算 char 字符验证 + captchaType: math + +# 开发环境配置 +server: + # 服务器的HTTP端口,默认为8080 + port: 8889 + servlet: + # 应用的访问路径 + context-path: + tomcat: + # tomcat的URI编码 + uri-encoding: UTF-8 + # tomcat最大线程数,默认为200 + max-threads: 800 + # Tomcat启动初始化的线程数,默认值25 + min-spare-threads: 30 + +# 日志配置 +logging: + level: + com.ruoyi: debug + org.springframework: warn + +# Spring配置 +spring: + # 资源信息 + messages: + # 国际化资源文件路径 + basename: i18n/messages + profiles: + active: prod + jackson: + time-zone: GMT+8 + date-format: yyyy-MM-dd HH:mm:ss + locale: zh_CN + serialization: + # 格式化输出 + indent_output: false + # 文件上传 + servlet: + multipart: + # 单个文件大小 + max-file-size: 10MB + # 设置总上传的文件大小 + max-request-size: 20MB + # 服务模块 + devtools: + restart: + # 热部署开关 + enabled: false + # redis 配置 + redis: + # 连接超时时间 + timeout: 10s + lettuce: + pool: + # 连接池中的最小空闲连接 + min-idle: 0 + # 连接池中的最大空闲连接 + max-idle: 8 + # 连接池的最大数据库连接数 + max-active: 8 + # #连接池最大阻塞等待时间(使用负值表示没有限制) + max-wait: -1ms +# token配置 +token: + # 令牌自定义标识 + header: Authorization + # 令牌密钥 + secret: abcdefghijklmnopqrstuvwxyz + # 令牌有效期(默认30分钟) + expireTime: 300 + +mybatis-plus: + mapper-locations: classpath*:/com/ruoyi/**/*.xml,classpath*:com/ruoyi/**/mapping/*.xml + #实体扫描,多个package用逗号或者分号分隔 + type-aliases-package: com.ruoyi.**.domain,com.ruoyi.entity.** + #typeEnumsPackage: com.baomidou.springboot.entity.enums + global-config: + banner: false + db-config: + #主键类型 com.baomidou.mybatisplus.annotation.IdType"; + id-type: assign_id + #字段策略 com.baomidou.mybatisplus.annotation.FieldStrategy" + select-strategy: NOT_EMPTY + insert-strategy: NOT_EMPTY + update-strategy: NOT_EMPTY + #逻辑删除配置(下面3个配置) + logic-delete-value: 0 + logic-not-delete-value: 1 + configuration: + jdbc-type-for-null: 'null' + #数据库大写下划线转换 + map-underscore-to-camel-case: true + cache-enabled: false + lazy-loading-enabled: true + multiple-result-sets-enabled: true + log-impl: org.apache.ibatis.logging.slf4j.Slf4jImpl #开启sql日志 +# log-impl: org.apache.ibatis.logging.nologging.NoLoggingImpl + configuration-properties: + dbType: mysql #设置全局属性用于控制数据库的类型 + + +# PageHelper分页插件 +pagehelper: + helperDialect: mysql + supportMethodsArguments: true + params: count=countSql + +# Swagger配置 +swagger: + # 是否开启swagger + enabled: true + # 请求前缀 + pathMapping: + +# 防止XSS攻击 +xss: + # 过滤开关 + enabled: true + # 排除链接(多个用逗号分隔) + excludes: /system/notice + # 匹配链接 + urlPatterns: /system/*,/monitor/*,/tool/* + +#文件上传配置 +#使用的上传存储空间,local本地,aliyun:阿里云 +oss: + client-type: local + #默认上传目录 + base_dir: userfiles + #允许的文件扩展名 + allowed_extension: mp4,bmp, gif, jpg, jpeg, png,doc, docx, xls, xlsx, ppt, pptx,html,htm,txt,rar, zip, gz, bz2,pdf + #最大文件大小 50M + max_size: 52428800 + #是否需要按照日期存放文件 + needDatePath: false + +sms: + #三方短信类型 1 助通短信 2 阿里短信 3 腾讯云短信 + sms_type: 3 + + #阿里短信 + access-key-id: + access-key-secret: + signName: + templateCode: + + #助通短信 + username: huitu + password: 123456 + +# 消息推送 +push: + # 消息推送 1 goeasy ; 2 uniapp + push_type: 1 + #goeasy(消息推送,聊天) + goeasy: + appkey: BC-d4519ea15c3f4d67a0d923dc980cbdac + regionHost: https://rest-hangzhou.goeasy.io + secretKey: d3c00d08e684412e + + #uniapp消息推送 + uniapp: + appid: + appkey: + mastersecret: + +nohupLog: + size: 10MB + baseDir: /home/manage/ + +#一键登陆解密手机号参数 +decryptPhone: + url: https://api.verification.jpush.cn/v1/web/loginTokenVerify + app_key: fde270559d7d5d488d58f545 + master_Key: fdb70c3d0d1a622d5b8b1cd3 + private_key: MIICdQIBADANBgkqhkiG9w0BAQEFAASCAl8wggJbAgEAAoGBAJYswKGroaPqET+uV4SYtUuKt628Wa3J1wXrpV1dEFqVH6PnZgOBFLvrojHZ7XQfgjHazXZkTkra6mvRNO35CS9rnTZEnYVrD9MQnirMbGsSOtCyTVNQUoqmGgWVaM2F+2XS6F+p2BzLbEHhv+YyHC65qmh8iFyDykJY4dkRYjX7AgMBAAECgYBH/GXOWY5fG1lvVCwBlI37CyCm+E1ooAMhhGa9TVoEgc0r7UUaUurUdcxG5zcK3fuz2DV7FfPtr+iFDEC5/hFnW+KV+9R0c6Y8jJKW1p0qAKNU4Icvl/rViX8dQCV0nY0Gny6JtirKzGp0O8lwuynjBWwJds5emFXCippL57HVMQJBANhq53cSarStsf88CHwyG+SRQkX962eoGx7EBFGqAbM0l26mHh0t7bWtA+Thwv+EbgP2/GqOX6TPpHRB4jiJJCkCQQCxpDtGSpIBINRvv1BvVy0Tl058xUWLFFf5tar07DRG3qo9uJR75fLjBILip7bkkclFljmtoaQ4gkP9mlAYPa2DAkB4Yr9vVSdWamjhehueOqGZe9RJ6v3QI4syigd9Bfz8Gv1B59ZIlQvuS9gmsg8u5BPu0K2I+LnrjDYHFb8pg+BBAkAyUZcIvi7FawtB7CtYnpUCK6Xr6eVdFBInhbI7Vn0oZgJLIXHN9sDqVWjN0zwXWsRslbUY3eSqrRudRozRkQcJAkA2B3glMnfjzikFpshq0eKpJj4vUXBsAAO5er73eaC7u2iPls6ABeb9+9Vr8Cqt67wspRqKdX54Xka9CPhOwRWz + +#支付回调 +notifyurl: + #订单首款支付 + ali-order-url: /api/pay/orderAliNotify + wx-order-url: /api/pay/orderWxNotify + lkl-order-url: /api/pay/orderLakalaNotify + #订单尾款支付 + ali-secondOrder-url: /api/pay/secondOrderAliNotify + wx-secondOrder-url: /api/pay/secondOrderWxNotify + lkl-secondOrder-url: /api/pay/secondOrderLakalaNotify + #充值订单支付 + ali-recharge-url: /api/pay/rechargeAliNotify + wx-recharge-url: /api/pay/rechargeWxNotify + lkl-recharge-url: /api/pay/rechargeLakalaNotify + #保证金支付 + ali-bond-url: /api/pay/bondAliNotify + wx-bond-url: /api/pay/bondWxNotify + lkl-bond-url: /api/pay/bondLakalaNotify + #普通认证支付 + ali-auth-url: /api/pay/authAliNotify + wx-auth-url: /api/pay/authWxNotify + lkl-auth-url: /api/pay/authLakalaNotify + #高端认证支付 + ali-highend-auth-url: /api/pay/highendAuthAliNotify + wx-highend-auth-url: /api/pay/highendAuthWxNotify + lkl-highend-auth-url: /api/pay/highendAuthLakalaNotify + #设计师调价支付 + ali-adjustPrice-auth-url: /api/pay/orderAdjustPricePayAliNotify + wx-adjustPrice-auth-url: /api/pay/orderAdjustPricePayWxNotify + lkl-adjustPrice-auth-url: /api/pay/orderAdjustPricePayLakalaNotify + #表现师调价设计师确认支付 + ali-adjustPriceConfirm-auth-url: /api/pay/orderAdjustPriceConfirmPayAliNotify + wx-adjustPriceConfirm-auth-url: /api/pay/orderAdjustPriceConfirmPayWxNotify + lkl-adjustPriceConfirm-auth-url: /api/pay/orderAdjustPriceConfirmPayLakalaNotify + +#支付宝支付参数 +alipay: + appid: + private-key: + ali-public-key: + + h5appid: + partner: + h5private-key: + h5ali-public-key: + + subject: + sign-type: RSA2 + ali-url: https://openapi.alipay.com/gateway.do + product-code: QUICK_MSECURITY_PAY + +#微信支付参数 +wxpay: + appid: wx8cba639752e95ed0 + mchid: + paykey: + app-secret: 1e7d48b009a5e5c9902d6e9ae1b0e8d9 + + h5appid: + h5mchid: + h5paykey: + h5app-secret: + +wxrefundfile: + path: /home/manage/apiclient_cert.p12 + +#app名称 +app: + name: DD画图 + +DD_drawing: + appid: wxed96e8fe10ea8992 + secret: 5a1da24f97e49aa5762897045dd593b6 + +DD_co_creation: + appid: wx45d9099290a6ec3d + secret: fa6bc98943d4e0bdc3850475c320deb2 diff --git a/ruoyi-extend/ruoyi-job/src/main/resources/banner.txt b/ruoyi-extend/ruoyi-job/src/main/resources/banner.txt new file mode 100644 index 0000000..0931cb8 --- /dev/null +++ b/ruoyi-extend/ruoyi-job/src/main/resources/banner.txt @@ -0,0 +1,24 @@ +Application Version: ${ruoyi.version} +Spring Boot Version: ${spring-boot.version} +//////////////////////////////////////////////////////////////////// +// _ooOoo_ // +// o8888888o // +// 88" . "88 // +// (| ^_^ |) // +// O\ = /O // +// ____/`---'\____ // +// .' \\| |// `. // +// / \\||| : |||// \ // +// / _||||| -:- |||||- \ // +// | | \\\ - /// | | // +// | \_| ''\---/'' | | // +// \ .-\__ `-` ___/-. / // +// ___`. .' /--.--\ `. . ___ // +// ."" '< `.___\_<|>_/___.' >'"". // +// | | : `- \`.;`\ _ /`;.`/ - ` : | | // +// \ \ `-. \_ __\ /__ _/ .-` / / // +// ========`-.____`-.___\_____/___.-`____.-'======== // +// `=---=' // +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ // +// 佛祖保佑 永不宕机 永无BUG // +//////////////////////////////////////////////////////////////////// \ No newline at end of file diff --git a/ruoyi-extend/ruoyi-job/src/main/resources/i18n/messages.properties b/ruoyi-extend/ruoyi-job/src/main/resources/i18n/messages.properties new file mode 100644 index 0000000..954e0a9 --- /dev/null +++ b/ruoyi-extend/ruoyi-job/src/main/resources/i18n/messages.properties @@ -0,0 +1,41 @@ +#错误消息 +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}次,帐户锁定10分钟 +user.password.delete=对不起,您的账号已被删除 +user.blocked=用户已封禁,请联系管理员 +role.blocked=角色已封禁,请联系管理员 +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}] + + + +the.voting.activity.has.ended=投票活动已截止 diff --git a/ruoyi-extend/ruoyi-job/src/main/resources/logback.xml b/ruoyi-extend/ruoyi-job/src/main/resources/logback.xml new file mode 100644 index 0000000..a360583 --- /dev/null +++ b/ruoyi-extend/ruoyi-job/src/main/resources/logback.xml @@ -0,0 +1,93 @@ + + + + + + + + + + + ${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/ruoyi-extend/ruoyi-job/src/main/resources/mybatis/mybatis-config.xml b/ruoyi-extend/ruoyi-job/src/main/resources/mybatis/mybatis-config.xml new file mode 100644 index 0000000..ac47c03 --- /dev/null +++ b/ruoyi-extend/ruoyi-job/src/main/resources/mybatis/mybatis-config.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + diff --git a/ruoyi-main/pom.xml b/ruoyi-main/pom.xml new file mode 100644 index 0000000..2058f60 --- /dev/null +++ b/ruoyi-main/pom.xml @@ -0,0 +1,150 @@ + + + + com.ruoyi + ruoyi + 3.7.0 + + + ruoyi-post + ruoyi-custom + ruoyi-message + ruoyi-admin-core + + + 4.0.0 + pom + ruoyi-main + + + 8 + 8 + UTF-8 + + + + + org.springframework.boot + spring-boot-devtools + true + + + + org.springframework.boot + spring-boot-autoconfigure + + + + com.ruoyi + ruoyi-admin + 3.7.0 + + + + + com.gexin.platform + gexin-rp-sdk-http + 4.1.2.2 + + + + + com.gexin.platform + gexin-rp-sdk-base + 4.0.0.38 + + + + + com.gexin.platform + gexin-rp-sdk-template + 4.0.0.31 + + + + + + io.goeasy + goeasy-sdk + 0.4.2 + + + + + org.dom4j + dom4j + 2.1.3 + + + + + com.github.javen205 + IJPay-All + 2.5.2 + + + + + + com.github.wxpay + wxpay-sdk + 0.0.3 + + + + com.thoughtworks.xstream + xstream + 1.4.1 + + + + + com.alipay.sdk + alipay-sdk-java + 4.17.14.ALL + compile + + + + + com.aliyun + aliyun-java-sdk-dysmsapi + 1.1.0 + + + + com.aliyun + aliyun-java-sdk-core + 4.4.6 + + + com.aliyun + aliyun-java-sdk-ecs + 4.17.6 + + + + + com.tencentcloudapi + tencentcloud-sdk-java + 3.1.1065 + + + + com.qcloud + cos-sts_api + 3.1.0 + + + + + com.lkl.laop.sdk + lkl-laop-java-sdk + 1.0.5 + + + + + diff --git a/ruoyi-main/ruoyi-admin-core/pom.xml b/ruoyi-main/ruoyi-admin-core/pom.xml new file mode 100644 index 0000000..7395fc6 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/pom.xml @@ -0,0 +1,46 @@ + + + 4.0.0 + + com.ruoyi + ruoyi-main + 3.7.0 + + + ruoyi-admin-core + + + 8 + 8 + UTF-8 + + + + + + com.belerweb + pinyin4j + 2.5.0 + + + com.ruoyi + ruoyi-custom + 3.7.0 + + + + com.ruoyi + ruoyi-post + 3.7.0 + + + + com.ruoyi + ruoyi-message + 3.7.0 + + + + diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/ApiActivityController.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/ApiActivityController.java new file mode 100644 index 0000000..484868f --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/ApiActivityController.java @@ -0,0 +1,64 @@ +package com.ruoyi.controller; + +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.ruoyi.annotations.UserLoginToken; +import com.ruoyi.common.page.PageResult; +import com.ruoyi.controller.req.ActivityPageReq; +import com.ruoyi.controller.req.AppealMessagePageReq; +import com.ruoyi.controller.req.LikeReq; +import com.ruoyi.controller.req.SendMessageReq; +import com.ruoyi.controller.resp.*; +import com.ruoyi.frequency.activity.entity.Activity; +import com.ruoyi.frequency.activity.service.ActivityService; +import com.ruoyi.frequency.appeal.service.AppealService; +import com.ruoyi.frequency.appealdetail.service.AppealDetailService; +import com.ruoyi.frequency.like.service.LikeService; +import com.ruoyi.response.ResponseData; +import com.ruoyi.vo.BodyIdReq; +import com.ruoyi.vo.PageBasic; +import com.ruoyi.vo.RyController; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import io.swagger.v3.oas.annotations.tags.Tag; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import javax.validation.Valid; + +/** + * 活动 + */ +@CrossOrigin +@RestController +@RequestMapping("/api/activity") +@Api(tags = "活动") +public class ApiActivityController extends RyController { + + @Autowired + private ActivityService activityService; + + + @PostMapping("/activityPage") + @ApiOperation(value = "活动列表", notes = "活动列表") +// @UserLoginToken + public ResponseData>> activityPage(@RequestBody @Valid ActivityPageReq req) { + return activityService.activityPage(req,getUserVo()); + } + + @PostMapping("/activityDetail") + @ApiOperation(value = "活动详情", notes = "活动详情") +// @UserLoginToken + public ResponseData activityDetail(@RequestBody @Valid BodyIdReq req) { + return activityService.activityDetail(req.getId(),getUserVo()); + } + + @Autowired + private LikeService likeService; + + @PostMapping("/activityLike") + @UserLoginToken + @ApiOperation(value = "活动点赞", notes = "活动点赞") + public ResponseData activityLike(@RequestBody LikeReq req) { + return likeService.like(req,getUserVo()); + } +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/ApiAddressController.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/ApiAddressController.java new file mode 100644 index 0000000..16d39ce --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/ApiAddressController.java @@ -0,0 +1,95 @@ +package com.ruoyi.controller; + +import com.ruoyi.annotations.UserLoginToken; +import com.ruoyi.controller.req.AddressInsertReq; +import com.ruoyi.controller.req.AddressUpdateReq; +import com.ruoyi.frequency.malladdress.service.MallAddressService; +import com.ruoyi.response.ResponseData; +import com.ruoyi.vo.PageBasic; +import com.ruoyi.vo.RyController; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import net.sourceforge.pinyin4j.PinyinHelper; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import javax.validation.Valid; +import java.util.List; + +@CrossOrigin +@RestController +@RequestMapping("/api/address") +@Api(tags = "用户地址") +public class ApiAddressController extends RyController { + + + @Autowired + private MallAddressService addressService; + + @UserLoginToken + @PostMapping("/addressPage") + @ApiOperation(value = "用户地址",notes = "用户地址") + public ResponseData addressPage(@RequestBody PageBasic page) { + return this.addressService.addressPage(getUserVo(), page); + } + + @UserLoginToken + @PostMapping("/addressDetail") + @ApiOperation(value = "地址信息",notes = "地址信息") + public ResponseData detail(@Valid @RequestBody Long id) { + return ResponseData.success(this.addressService.getById(id)); + } + + @UserLoginToken + @PostMapping("/insertAddress") + @ApiOperation(value = "添加地址",notes = "添加地址") + public ResponseData insertAddress(@Valid @RequestBody AddressInsertReq addressInsertReq) { + return this.addressService.insertAddress(addressInsertReq, getUserVo()); + } + + @UserLoginToken + @PostMapping("/updateAddress") + @ApiOperation(value = "修改地址",notes = "修改地址") + public ResponseData updateAddress(@Valid @RequestBody AddressUpdateReq addressUpdateReq) { + return this.addressService.updateAddress(addressUpdateReq,getUserVo()); + } + + @UserLoginToken + @PostMapping("/setDefaultAddress") + @ApiOperation(value = "修改默认地址",notes = "修改默认地址") + public ResponseData setDefault(@Valid @RequestBody Long id) { + return this.addressService.setDefault(id); + } + + @UserLoginToken + @PostMapping("/deleteAddress") + @ApiOperation(value = "删除地址",notes = "删除地址") + public ResponseData deleteAddress(@RequestBody List ids) { + return this.addressService.deleteAddressById(ids, getUserVo()); + } + + @PostMapping("/defaultAddress") + @UserLoginToken + @ApiOperation(value = "获取用户默认地址",notes = "获取用户默认地址") + public ResponseData getDefaultAddress() { + return this.addressService.getDefaultAddress(getUserVo()); + } + + public static void main(String[] args) { + String chineseText = "你好世界"; + StringBuilder result = new StringBuilder(); + + for (char c : chineseText.toCharArray()) { + String[] pinyinArray = PinyinHelper.toHanyuPinyinStringArray(c); + if (pinyinArray != null) { + result.append(pinyinArray[0].charAt(0)); + break; + } else { + result.append(c); + break; + } + } + System.out.println(result.toString().toUpperCase()); + } +} + diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/ApiAppealController.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/ApiAppealController.java new file mode 100644 index 0000000..9bfdbbc --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/ApiAppealController.java @@ -0,0 +1,67 @@ +package com.ruoyi.controller; + +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.ruoyi.annotations.UserLoginToken; +import com.ruoyi.common.page.PageResult; +import com.ruoyi.controller.req.AppealMessagePageReq; +import com.ruoyi.controller.req.SendMessageReq; +import com.ruoyi.controller.resp.AppealDetailResp; +import com.ruoyi.controller.resp.AppealMessagePageResp; +import com.ruoyi.controller.resp.AppealPageResp; +import com.ruoyi.frequency.appeal.service.AppealService; +import com.ruoyi.frequency.appealdetail.service.AppealDetailService; +import com.ruoyi.response.ResponseData; +import com.ruoyi.vo.BodyIdReq; +import com.ruoyi.vo.PageBasic; +import com.ruoyi.vo.RyController; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import javax.validation.Valid; + +/** + * 申诉 + */ +@CrossOrigin +@RestController +@RequestMapping("/api/appeal") +@Api(tags = "申诉") +public class ApiAppealController extends RyController { + + @Autowired + private AppealService appealService; + + @Autowired + private AppealDetailService appealDetailService; + + + @PostMapping("/appealPage") + @ApiOperation(value = "申诉列表", notes = "申诉列表") + @UserLoginToken + public ResponseData>> appealPage(@RequestBody @Valid PageBasic req) { + return appealService.appealPage(req,getUserVo()); + } + + @PostMapping("/appealDetail") + @ApiOperation(value = "申诉详情", notes = "申诉详情") + @UserLoginToken + public ResponseData appealDetail(@RequestBody @Valid BodyIdReq req) { + return appealService.appealDetail(req.getId(),getUserVo()); + } + + @PostMapping("/appealMessagePage") + @ApiOperation(value = "申诉详情消息对话", notes = "申诉详情消息对话") + @UserLoginToken + public ResponseData>> appealMessagePage(@RequestBody @Valid AppealMessagePageReq req) { + return appealDetailService.appealMessagePage(req,getUserVo()); + } + + @PostMapping("/sendMessage") + @ApiOperation(value = "发送消息", notes = "发送消息") + @UserLoginToken + public ResponseData sendMessage(@RequestBody @Valid SendMessageReq req) { + return appealDetailService.sendMessage(req,getUserVo()); + } +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/ApiAppletAuthController.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/ApiAppletAuthController.java new file mode 100644 index 0000000..25662da --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/ApiAppletAuthController.java @@ -0,0 +1,227 @@ +package com.ruoyi.controller; + +import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.StrUtil; +import cn.hutool.http.HttpRequest; +import cn.hutool.http.HttpUtil; +import com.alibaba.fastjson.JSONObject; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.ruoyi.code.PublicCommon; +import com.ruoyi.common.cos.TxApiHttpUtils; +import com.ruoyi.common.cos.TxApiSdkUtils; +import com.ruoyi.controller.req.ContentCanUseReq; +import com.ruoyi.controller.req.TxContentReq; +import com.ruoyi.enums.user.UserEnums; +import com.ruoyi.frequency.customer.entity.Customer; +import com.ruoyi.frequency.customer.service.CustomerService; +import com.ruoyi.frequency.level.entity.Level; +import com.ruoyi.frequency.store.entity.Store; +import com.ruoyi.frequency.store.service.StoreService; +import com.ruoyi.response.ResponseData; +import com.ruoyi.vo.RyController; +import com.ruoyi.vo.UserVo; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.web.bind.annotation.*; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * 文本/图片安全验证 + */ +@Slf4j +@CrossOrigin +@RestController +@RequestMapping("/api/appletAuth") +@Api(tags = "文本/图片安全验证") +public class ApiAppletAuthController extends RyController { + + @Value("${DD_drawing.appid}") + private String DD_drawingAppId; + + @Value("${DD_drawing.secret}") + private String DD_drawingSecret; + + @Value("${DD_co_creation.appid}") + private String DD_co_creationAppId; + + @Value("${DD_co_creation.secret}") + private String DD_co_creationSecret; + + @Autowired + private CustomerService customerService; + @Autowired + private StoreService storeService; + + + @PostMapping("/checkContext") + @ApiOperation(value = "腾讯云文本内容安全识别", notes = "腾讯云文本内容安全识别") + public JSONObject checkContext(@RequestBody TxContentReq txContentReq) { + if (StrUtil.isEmpty(txContentReq.getContent())) { + return null; + } + return TxApiSdkUtils.checkContext(txContentReq.getContent()); + } + + + @PostMapping("/checkImages") + @ApiOperation(value = "腾讯云图片内容安全识别", notes = "腾讯云图片内容安全识别") + public JSONObject checkImages(@RequestBody TxContentReq txContentReq) { + if (StrUtil.isEmpty(txContentReq.getContent())) { + return null; + } + return TxApiSdkUtils.checkImages(txContentReq.getContent()); + } + + @PostMapping("/msgSecCheck/{type}") + @ApiOperation(value = "微信小程序文本内容安全识别", notes = "微信小程序文本内容安全识别") + public ResponseData msgSecCheck(@PathVariable("type") String type, @RequestBody ContentCanUseReq msgSecReq) { + if (StrUtil.isEmpty(msgSecReq.getContent())) { + return ResponseData.error("暂未授权!"); + } + + UserVo userVo = getUserVo(); + String openId = ""; + if (userVo.getUserType().equals(UserEnums.customer.getCode())) { + Customer customer = customerService.getById(userVo.getUserId()); + openId = customer.getWechatAppletOpenid(); + } else if (userVo.getUserType().equals(UserEnums.store.getCode())) { + Store store = storeService.getById(userVo.getUserId()); + openId = store.getWechatAppletOpenid(); + } else { + return ResponseData.success(); + } + + if (StrUtil.isNotEmpty(openId)) { + String str = "https://api.weixin.qq.com/wxa/msg_sec_check?access_token=" + getToken(type); + Map bodyMap = new HashMap<>(); + bodyMap.put("openid", openId); + bodyMap.put("version", 2); + bodyMap.put("scene", msgSecReq.getScene()); + bodyMap.put("content", msgSecReq.getContent()); + String result = HttpUtil.createPost(str).body(JSONObject.toJSONString(bodyMap)).execute().body(); + + System.out.println(result); + //判断是否获取成功 + if (ObjectUtil.isEmpty(result)) { + return ResponseData.error("获取参数错误"); + } + JSONObject jsonObject = JSONObject.parseObject(result); + return ResponseData.success(jsonObject); + + } + return ResponseData.success(); + } + + + @PostMapping("/mediaCheckAsync/{type}") + @ApiOperation(value = "微信小程序图片内容安全识别", notes = "微信小程序图片内容安全识别") + public ResponseData mediaCheckAsync(@PathVariable("type") String type, @RequestBody ContentCanUseReq msgSecReq) { + if (StrUtil.isEmpty(msgSecReq.getMediaUrl())) { + return ResponseData.error("暂未授权!"); + } + + UserVo userVo = getUserVo(); + String openId = ""; + if (userVo.getUserType().equals(UserEnums.customer.getCode())) { + Customer customer = customerService.getById(userVo.getUserId()); + openId = customer.getWechatAppletOpenid(); + } else if (userVo.getUserType().equals(UserEnums.store.getCode())) { + Store store = storeService.getById(userVo.getUserId()); + openId = store.getWechatAppletOpenid(); + } else { + return ResponseData.success(); + } + if (StrUtil.isNotEmpty(openId)) { + String str = "https://api.weixin.qq.com/wxa/media_check_async?access_token=" + getToken(type); + Map bodyMap = new HashMap<>(); + bodyMap.put("openid", openId); + bodyMap.put("version", 2); + bodyMap.put("media_type", 2); + bodyMap.put("scene", msgSecReq.getScene()); + bodyMap.put("media_url", msgSecReq.getMediaUrl()); + String result = HttpUtil.createPost(str).body(JSONObject.toJSONString(bodyMap)).execute().body(); + + System.out.println(result); + //判断是否获取成功 + if (ObjectUtil.isEmpty(result)) { + return ResponseData.error("获取参数错误"); + } + JSONObject jsonObject = JSONObject.parseObject(result); + return ResponseData.success(jsonObject); + } + return ResponseData.success(); + } + + + /** + * 获取access_token + * + * @return + */ + public String getToken(String type) { + + String appid = ""; + + String secret = ""; + + //type : DD_drawing DD画图, DD_co_creation DD共创 + if (ObjectUtil.equal(type, "DD_drawing")) { + appid = DD_drawingAppId; + + secret = DD_drawingSecret; + } else { + appid = DD_co_creationAppId; + + secret = DD_co_creationSecret; + } + + String url = "https://api.weixin.qq.com/cgi-bin/token" + "?grant_type=" + "client_credential" + "&appid=" + appid + "&secret=" + secret; + String result = HttpRequest.get(url).execute().body(); + System.err.println(result); + JSONObject jsonObject = JSONObject.parseObject(result); + //服务断了status会有值 + Integer errcode = (Integer) jsonObject.get("errcode"); + if (errcode == null) { + String access_token = (String) jsonObject.get("access_token"); + return access_token; + } else { + log.info("获取access_token失败:{}", jsonObject.toJSONString()); + } + return ""; + } + + + + + /*@UserLoginToken + @PostMapping("/textCanUse") + @ApiOperation(value = "文本是否可用", notes = "是否可以体验app或者小程序") + public ResponseData textCanUse(@RequestBody ContentCanUseReq req) { + + UserVo userVo = getUserVo(); + String openId = ""; + if (userVo.getUserType().equals(UserEnums.customer.getCode())) { + Customer customer = customerService.getById(userVo.getUserId()); + openId = customer.getWechatAppletOpenid(); + } else if (userVo.getUserType().equals(UserEnums.store.getCode())) { + Store store = storeService.getById(userVo.getUserId()); + openId = store.getWechatAppletOpenid(); + } else { + return ResponseData.success(); + } + if (StrUtil.isBlank(openId)) { + return ResponseData.success(); + } + + + return ResponseData.success(); + }*/ + + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/ApiAuthController.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/ApiAuthController.java new file mode 100644 index 0000000..ab55fde --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/ApiAuthController.java @@ -0,0 +1,54 @@ +package com.ruoyi.controller; + +import com.ruoyi.annotations.UserLoginToken; +import com.ruoyi.code.Token; +import com.ruoyi.controller.req.OrdinaryAuthReq; +import com.ruoyi.controller.req.UpscaleAuthReq; +import com.ruoyi.frequency.auth.entity.Auth; +import com.ruoyi.frequency.auth.service.AuthService; +import com.ruoyi.frequency.highendauth.service.HighendAuthService; +import com.ruoyi.response.ResponseData; +import com.ruoyi.vo.RyController; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +/** + * 认证 + */ +@CrossOrigin +@RestController +@RequestMapping("/api/auth") +@Api(tags = "认证") +public class ApiAuthController extends RyController { + + @Autowired + private AuthService authService; + + @Autowired + private HighendAuthService highendAuthService; + + + @PostMapping("/ordinaryAuth") + @ApiOperation(value = "普通认证", notes = "普通认证") + @UserLoginToken(userTokenPre = {Token.store}) + public ResponseData ordinaryAuth(@RequestBody OrdinaryAuthReq req) { + return authService.ordinaryAuth(req, getUserVo()); + } + + + @PostMapping("/highendAuth") + @ApiOperation(value = "高端认证", notes = "高端认证") + @UserLoginToken(userTokenPre = {Token.store}) + public ResponseData highendAuth(@RequestBody UpscaleAuthReq req) { + return highendAuthService.highendAuth(req, getUserVo()); + } + + @PostMapping("/ordinaryAuthDetail/{type}") + @ApiOperation(value = "普通认证详情", notes = "普通认证详情") + @UserLoginToken + public ResponseData ordinaryAuthDetail(@PathVariable Integer type) { + return authService.ordinaryAuthDetail(type,getUserVo()); + } +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/ApiBankCardController.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/ApiBankCardController.java new file mode 100644 index 0000000..13f0fc7 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/ApiBankCardController.java @@ -0,0 +1,81 @@ +package com.ruoyi.controller; + +import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.ruoyi.annotations.UserLoginToken; +import com.ruoyi.code.PublicCommon; +import com.ruoyi.common.core.domain.BaseEntity; +import com.ruoyi.common.page.PageResult; +import com.ruoyi.controller.req.BankCardAddReq; +import com.ruoyi.controller.req.BankCardEditReq; +import com.ruoyi.controller.req.BankCardPageReq; +import com.ruoyi.controller.resp.BankCardDetailResp; +import com.ruoyi.controller.resp.BankCardPageResp; +import com.ruoyi.frequency.bankcard.entity.BankCard; +import com.ruoyi.frequency.bankcard.service.BankCardService; +import com.ruoyi.response.ResponseData; +import com.ruoyi.vo.BodyIdReq; +import com.ruoyi.vo.RyController; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +@CrossOrigin +@RestController +@RequestMapping("/api/bankCard") +@Api(tags = "银行卡") +public class ApiBankCardController extends RyController { + + + @Autowired + private BankCardService bankCardService; + + @PostMapping("/bankCardPage") + @ApiOperation(value = "银行卡列表", notes = "银行卡列表") + @UserLoginToken + public ResponseData>> bankCardPage(@RequestBody BankCardPageReq req) { + return bankCardService.bankCardPage(req,getUserVo()); + } + + @PostMapping("/bankCardList") + @ApiOperation(value = "银行卡列表(不分页)", notes = "银行卡列表") + @UserLoginToken + public ResponseData> bankCardList() { + List list = bankCardService.list(new LambdaUpdateWrapper() + .eq(BankCard::getDelFlag, PublicCommon.启用) + .orderByDesc(BaseEntity::getCreateTime) + ); + return ResponseData.success(list); + } + + @PostMapping("/bankCardAdd") + @ApiOperation(value = "银行卡新增", notes = "银行卡新增") + @UserLoginToken + public ResponseData bankCardAdd(@RequestBody BankCardAddReq req) { + return bankCardService.bankCardAdd(req,getUserVo()); + } + + @PostMapping("/bankCardEdit") + @ApiOperation(value = "银行卡编辑", notes = "银行卡编辑") + @UserLoginToken + public ResponseData bankCardEdit(@RequestBody BankCardEditReq req) { + return bankCardService.bankCardEdit(req,getUserVo()); + } + + @PostMapping("/bankCardDetail") + @ApiOperation(value = "银行卡详情", notes = "银行卡详情") + @UserLoginToken + public ResponseData bankCardDetail(@RequestBody BodyIdReq req) { + return bankCardService.bankCardDetail(req.getId(),getUserVo()); + } + + @PostMapping("/bankCardDel") + @ApiOperation(value = "银行卡删除", notes = "银行卡删除") + @UserLoginToken + public ResponseData bankCardDel(@RequestBody BodyIdReq req) { + return bankCardService.bankCardDel(req.getId(),getUserVo()); + } +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/ApiBondController.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/ApiBondController.java new file mode 100644 index 0000000..ac1c058 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/ApiBondController.java @@ -0,0 +1,53 @@ +package com.ruoyi.controller; + +import com.ruoyi.annotations.UserLoginToken; +import com.ruoyi.controller.req.BondPayReq; +import com.ruoyi.controller.req.BondRecordPageReq; +import com.ruoyi.frequency.bondrecord.service.BondRecordService; +import com.ruoyi.response.ResponseData; +import com.ruoyi.vo.BodyIdReq; +import com.ruoyi.vo.RyController; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import javax.validation.Valid; + +/** + * 保证金 + */ +@CrossOrigin +@RestController +@RequestMapping("/api/bond") +@Api(tags = "保证金") +public class ApiBondController extends RyController { + + @Autowired + private BondRecordService bondRecordService; + + + @PostMapping("bondPay") + @UserLoginToken + @ApiOperation(value = "缴纳保证金", notes = "缴纳保证金") + public ResponseData bondPay(@Valid @RequestBody BondPayReq req) { + return bondRecordService.bondPay(req, getUserVo()); + } + + + @PostMapping("bondRecordPage") + @UserLoginToken + @ApiOperation(value = "缴纳保证金记录", notes = "缴纳保证金记录") + public ResponseData bondRecordPage(@Valid @RequestBody BondRecordPageReq req) { + return bondRecordService.bondRecordPage(req, getUserVo()); + } + + @PostMapping("bondRecordDetail") + @UserLoginToken + @ApiOperation(value = "缴纳保证金记录详情", notes = "缴纳保证金记录详情") + public ResponseData bondRecordDetail(@Valid @RequestBody BodyIdReq req) { + return bondRecordService.bondRecordDetail(req.getId(), getUserVo()); + } + + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/ApiBondWithdrawalController.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/ApiBondWithdrawalController.java new file mode 100644 index 0000000..18674b5 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/ApiBondWithdrawalController.java @@ -0,0 +1,100 @@ +package com.ruoyi.controller; + +import cn.hutool.core.util.ObjectUtil; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.ruoyi.annotations.UserLoginToken; +import com.ruoyi.code.PublicCommon; +import com.ruoyi.code.Token; +import com.ruoyi.controller.req.WithApplyReq; +import com.ruoyi.enums.process.ProcessResultEnums; +import com.ruoyi.frequency.auth.entity.Auth; +import com.ruoyi.frequency.auth.service.AuthService; +import com.ruoyi.frequency.bankcard.entity.BankCard; +import com.ruoyi.frequency.bankcard.service.BankCardService; +import com.ruoyi.frequency.bondwithdrawalrecord.service.BondWithdrawalRecordService; +import com.ruoyi.frequency.customer.service.UserService; +import com.ruoyi.frequency.highendauth.entity.HighendAuth; +import com.ruoyi.frequency.highendauth.service.HighendAuthService; +import com.ruoyi.response.ResponseData; +import com.ruoyi.vo.BodyIdReq; +import com.ruoyi.vo.PageBasic; +import com.ruoyi.vo.RyController; +import com.ruoyi.vo.UserVo; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RestController; + +import javax.validation.Valid; + + +/** + * 保证金提现相关 + * @author liwenlong + */ +@Slf4j +@RestController +@RequestMapping("/api/bondWithdrawal") +@Api(tags = "保证金提现相关") +public class ApiBondWithdrawalController extends RyController { + + + @Autowired + private BondWithdrawalRecordService bondWithdrawalRecordService; + + @Autowired + private AuthService authService; + + @Autowired + private HighendAuthService highendAuthService; + + @Autowired + private UserService userService; + + @Autowired + private BankCardService bankCardService; + + @UserLoginToken(userTokenPre = {Token.store,Token.enterprise}) + @RequestMapping(value = "/apply", method = RequestMethod.POST) + @ApiOperation(value = "申请提现") + public ResponseData apply(@RequestBody @Valid WithApplyReq req) { + + UserVo userVo = getUserVo(); + + userService.storeByEnterprise(userVo); + + if (ObjectUtil.isNotEmpty(req.getBankCardId())){ + //查询用户银行卡信息 + BankCard bankCard = bankCardService.getById(req.getBankCardId()); + + if (bankCard != null){ + req.setBank(bankCard.getBank()); + req.setSubbranch(bankCard.getOpeningBranch()); + req.setBankCard(bankCard.getBankCard()); + req.setFullName(bankCard.getFullName()); + } + } + return bondWithdrawalRecordService.apply(req,userVo); + } + + @UserLoginToken + @RequestMapping(value = "/withdrawalRecordPage", method = RequestMethod.POST) + @ApiOperation(value = "提现记录") + public ResponseData withdrawalRecordPage(@RequestBody @Valid PageBasic req) { + return bondWithdrawalRecordService.withdrawalRecordPage(req,getUserVo()); + } + + @UserLoginToken + @RequestMapping(value = "/detail", method = RequestMethod.POST) + @ApiOperation(value = "提现记录详情") + public ResponseData detail(@RequestBody @Valid BodyIdReq req) { + return bondWithdrawalRecordService.getDetail(req.getId()); + } + +} + + diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/ApiBrowserController.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/ApiBrowserController.java new file mode 100644 index 0000000..93f554b --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/ApiBrowserController.java @@ -0,0 +1,43 @@ +package com.ruoyi.controller; + +import com.ruoyi.annotations.UserLoginToken; +import com.ruoyi.controller.req.CollectPageReq; +import com.ruoyi.frequency.browserecord.service.BrowseRecordService; +import com.ruoyi.response.ResponseData; +import com.ruoyi.vo.RyController; +import com.ruoyi.vo.UserVo; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +/** + * 浏览记录 + */ +@CrossOrigin +@RestController +@RequestMapping("/api/browse") +@Api(tags = "浏览记录") +public class ApiBrowserController extends RyController { + + @Autowired + private BrowseRecordService browseRecordService; + + + @PostMapping("/browsePage") + @ApiOperation(value = "浏览列表", notes = "浏览列表") + @UserLoginToken + public ResponseData browsePage(@RequestBody CollectPageReq req) { + UserVo userVo = getUserVo(); + req.setUserId(userVo.getUserId()); + req.setUserType(userVo.getUserType()); + return browseRecordService.browsePage(req, userVo); + } + + @PostMapping("/otherBrowsePage") + @ApiOperation(value = "浏览列表(别人查看)", notes = "浏览列表(别人查看)") + public ResponseData otherBrowsePage(@RequestBody CollectPageReq req) { + return browseRecordService.otherBrowsePage(req,getUserVo()); + } + +} \ No newline at end of file diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/ApiCallbackController.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/ApiCallbackController.java new file mode 100644 index 0000000..077e082 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/ApiCallbackController.java @@ -0,0 +1,33 @@ +package com.ruoyi.controller; + +import com.alibaba.fastjson.JSONObject; +import com.ruoyi.vo.RyController; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.web.bind.annotation.*; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.util.Map; + + +/** + * 异步回调接口 + */ +@CrossOrigin +@RestController +@RequestMapping("/api/callback") +@Api(tags = "异步回调接口") +public class ApiCallbackController extends RyController { + + @RequestMapping(value = "/wxMediaCheckAsync", method = RequestMethod.POST) + @ApiOperation(value = "微信图片验证接口回调",notes = "微信图片验证接口回调") + public String wxMediaCheckAsync(HttpServletRequest request, HttpServletResponse response) { + Map map = request.getParameterMap(); + System.err.printf(map.toString()); + + + return "success"; + } + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/ApiCollectController.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/ApiCollectController.java new file mode 100644 index 0000000..2da0e9c --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/ApiCollectController.java @@ -0,0 +1,53 @@ +package com.ruoyi.controller; + +import com.ruoyi.annotations.UserLoginToken; +import com.ruoyi.controller.req.CollectObjectReq; +import com.ruoyi.controller.req.CollectPageReq; +import com.ruoyi.frequency.collect.service.CollectService; +import com.ruoyi.response.ResponseData; +import com.ruoyi.vo.RyController; +import com.ruoyi.vo.UserVo; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import javax.validation.Valid; + +/** + * 收藏 + */ +@CrossOrigin +@RestController +@RequestMapping("/api/collect") +@Api(tags = "收藏") +public class ApiCollectController extends RyController { + + @Autowired + private CollectService collectService; + + @PostMapping("/collectObject") + @UserLoginToken + @ApiOperation(value = "收藏", notes = "收藏") + public ResponseData collectObject(@Valid @RequestBody CollectObjectReq req) { + return collectService.collectObject(req, getUserVo()); + } + + + @PostMapping("/collectPage") + @ApiOperation(value = "收藏列表", notes = "收藏列表") + @UserLoginToken + public ResponseData collectPage(@RequestBody CollectPageReq req) { + UserVo userVo = getUserVo(); + req.setUserId(userVo.getUserId()); + req.setUserType(userVo.getUserType()); + return collectService.collectPage(req, userVo); + } + + @PostMapping("/otherCollectPage") + @ApiOperation(value = "收藏列表(别人查看)", notes = "收藏列表(别人查看)") + public ResponseData otherCollectPage(@RequestBody CollectPageReq req) { + return collectService.otherCollectPage(req,getUserVo()); + } + +} \ No newline at end of file diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/ApiCommentController.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/ApiCommentController.java new file mode 100644 index 0000000..8388ce9 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/ApiCommentController.java @@ -0,0 +1,71 @@ +package com.ruoyi.controller; + +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.ruoyi.annotations.UserLoginToken; +import com.ruoyi.common.page.PageResult; +import com.ruoyi.controller.req.CommentPageReq; +import com.ruoyi.controller.req.CommentReq; +import com.ruoyi.controller.req.DialoguePageReq; +import com.ruoyi.controller.resp.CommentPageResp; +import com.ruoyi.controller.resp.CommentResp; +import com.ruoyi.frequency.comment.service.CommentService; +import com.ruoyi.post.controller.req.DeleteCommentReq; +import com.ruoyi.response.ResponseData; +import com.ruoyi.vo.BodyIdReq; +import com.ruoyi.vo.RyController; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + + +/** + * 新闻评论相关 + * @author liwenlong + * + */ +@CrossOrigin +@RestController +@RequestMapping("/api/comment") +@Api(tags = "新闻评论相关") +public class ApiCommentController extends RyController { + + @Autowired + private CommentService commentService; + + @PostMapping("/comment") + @UserLoginToken + @ApiOperation(value = "评论", notes = "评论") + public ResponseData comment(@RequestBody CommentReq req) { + return commentService.comment(req,getUserVo()); + } + + + @PostMapping("/commentPage") + @ApiOperation(value = "评论列表", notes = "评论列表") + public ResponseData>> commentPage(@RequestBody CommentPageReq req) { + return commentService.commentPage(req,getUserVo()); + } + + + @PostMapping("/deleteComment") + @UserLoginToken + @ApiOperation(value = "删除评论", notes = "删除评论") + public ResponseData deleteComment(@RequestBody DeleteCommentReq req) { + return commentService.deleteComment(req,getUserVo()); + } + + @PostMapping("/commentDetail") + @ApiOperation(value = "新闻评论详情", notes = "新闻评论详情") + public ResponseData commentDetail(@RequestBody BodyIdReq req) { + return commentService.commentDetail(req.getId(),getUserVo()); + } + + + @PostMapping("/commentDialoguePage") + @ApiOperation(value = "对话评论列表", notes = "对话评论列表") + public ResponseData>> commentDialoguePage(@RequestBody DialoguePageReq req) { + return commentService.commentDialoguePage(req,getUserVo()); + } + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/ApiFollowController.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/ApiFollowController.java new file mode 100644 index 0000000..92312f9 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/ApiFollowController.java @@ -0,0 +1,100 @@ +package com.ruoyi.controller; + +import com.ruoyi.annotations.UserLoginToken; +import com.ruoyi.common.page.PageResult; +import com.ruoyi.controller.req.FollowUserReq; +import com.ruoyi.controller.req.FollowerPageByOther; +import com.ruoyi.controller.resp.FollowPageResp; +import com.ruoyi.frequency.follow.service.FollowService; +import com.ruoyi.response.ResponseData; +import com.ruoyi.vo.RyController; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import javax.validation.Valid; + +/** + * 关注 + */ +@CrossOrigin +@RestController +@RequestMapping("/api/follow") +@Api(tags = "关注") +public class ApiFollowController extends RyController { + + @Autowired + private FollowService followService; + + /** + * 关注用户 + * + * @return + */ + @PostMapping("/followUser") + @UserLoginToken + @ApiOperation("关注用户") + public ResponseData followUser(@Valid @RequestBody FollowUserReq req) { + return followService.followUser(req, getUserVo()); + } + + /** + * 关注列表(自己看) + * + * @return + */ + @PostMapping("/followerPageBySelf") + @UserLoginToken + @ApiOperation("关注列表(自己看)") + public ResponseData> followerPageBySelf(@Valid @RequestBody FollowerPageByOther req) { + return followService.followerPageBySelf(req, getUserVo()); + } + + /** + * 关注列表(别人看) + * + * @return + */ + @PostMapping("/followerPageByOther") + @ApiOperation("关注列表(别人看)") + public ResponseData> followerPageByOther(@Valid @RequestBody FollowerPageByOther req) { + return followService.followerPageByOther(req,getUserVo()); + } + + + + /** + * 粉丝列表(自己看) + * + * @return + */ + @PostMapping("/fansPageBySelf") + @UserLoginToken + @ApiOperation("粉丝列表(自己看)") + public ResponseData> fansPageBySelf(@Valid @RequestBody FollowerPageByOther req) { + return followService.fansPageBySelf(req, getUserVo()); + } + + /** + * 粉丝列表(别人看) + * + * @return + */ + @PostMapping("/fansPageByOther") + @ApiOperation("粉丝列表(别人看)") + public ResponseData> fansPageByOther(@Valid @RequestBody FollowerPageByOther req) { + return followService.fansPageByOther(req,getUserVo()); + } + + /** + * 查询未关注列表 + * + * @return + */ + @PostMapping("/notFollowerPageBySelf") + @ApiOperation("查询未关注列表") + public ResponseData> notFollowerPageBySelf(@Valid @RequestBody FollowerPageByOther req) { + return followService.notFollowerPageBySelf(req,getUserVo()); + } +} \ No newline at end of file diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/ApiGoodsController.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/ApiGoodsController.java new file mode 100644 index 0000000..b1b2ff5 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/ApiGoodsController.java @@ -0,0 +1,53 @@ +package com.ruoyi.controller; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.ruoyi.code.PublicCommon; +import com.ruoyi.common.page.PageResult; +import com.ruoyi.controller.req.*; +import com.ruoyi.controller.resp.GoodsDetailResp; +import com.ruoyi.controller.resp.GoodsPageResp; +import com.ruoyi.frequency.mallgoods.service.MallGoodsService; +import com.ruoyi.frequency.mallgoodstype.entity.MallGoodsType; +import com.ruoyi.frequency.mallgoodstype.service.MallGoodsTypeService; +import com.ruoyi.response.ResponseData; +import com.ruoyi.vo.RyController; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import javax.validation.constraints.NotNull; +import java.util.List; +@CrossOrigin +@RestController +@RequestMapping("/api/goods") +@Api(tags = "商城") +public class ApiGoodsController extends RyController { + + @Autowired + private MallGoodsService goodsService; + + @Autowired + private MallGoodsTypeService goodsTypeService; + + + @RequestMapping(value = "/goodsTypeList", method = RequestMethod.POST) + @ApiOperation(value = "商品类型列表") + public ResponseData> goodsTypeList() { + List list = goodsTypeService.list(new QueryWrapper().lambda() + .eq(MallGoodsType::getDelFlag, PublicCommon.启用).orderByAsc(MallGoodsType::getSort)); + return ResponseData.success(list); + } + + @RequestMapping(value = "/goodsPage", method = RequestMethod.POST) + @ApiOperation(value = "商品列表") + public ResponseData> goodsPage(@RequestBody GoodsPageReq req) { + return goodsService.goodsPage(req,getUserVo()); + } + + @RequestMapping(value = "/goodsDetail", method = RequestMethod.POST) + @ApiOperation(value = "商品列表_详情") + public ResponseData goodsDetail(@RequestBody @NotNull(message = "商品id不能为空") Long goodsId) { + return goodsService.goodsDetail(goodsId,getUserVo()); + } +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/ApiHomeController.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/ApiHomeController.java new file mode 100644 index 0000000..e8bdfaa --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/ApiHomeController.java @@ -0,0 +1,146 @@ +package com.ruoyi.controller; + +import cn.hutool.core.util.StrUtil; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.ruoyi.code.DictConstant; +import com.ruoyi.code.PublicCommon; +import com.ruoyi.common.core.domain.entity.SysDictData; +import com.ruoyi.common.core.redis.RedisService; +import com.ruoyi.controller.req.CanFellReq; +import com.ruoyi.controller.req.StatisticsReq; +import com.ruoyi.controller.resp.StatisticsResp; +import com.ruoyi.enums.order.OrderStatusEnums; +import com.ruoyi.frequency.customer.entity.Customer; +import com.ruoyi.frequency.customer.service.CustomerService; +import com.ruoyi.frequency.order.entity.Order; +import com.ruoyi.frequency.order.service.OrderService; +import com.ruoyi.frequency.store.entity.Store; +import com.ruoyi.frequency.store.service.StoreService; +import com.ruoyi.response.ResponseData; +import com.ruoyi.utils.BusinessUtil; +import com.ruoyi.vo.RyController; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +/** + * 首页 + */ +@CrossOrigin +@RestController +@RequestMapping("/api/home") +@Api(tags = "首页") +public class ApiHomeController extends RyController { + + @Autowired + private CustomerService customerService; + + @Autowired + private StoreService storeService; + + @Autowired + private OrderService orderService; + + @Autowired + private BusinessUtil businessUtil; + + @Autowired + private RedisService redisService; + + + @PostMapping("/canFell") + @ApiOperation(value = "是否可以体验app或者小程序", notes = "是否可以体验app或者小程序") + public ResponseData canFell(@RequestBody CanFellReq req) { + SysDictData dict = businessUtil.getDict("need_fell"); + if (dict == null || StrUtil.isBlank(dict.getDictValue())) { + return ResponseData.success(); + } + if ("2".equals(dict.getDictValue())) { + return ResponseData.success(); + } + + dict = businessUtil.getDict("fell_pwd"); + if (dict == null) { + return ResponseData.error("未配置字典,请联系平台"); + } + if (StrUtil.isBlank(dict.getDictValue())) { + return ResponseData.error("未配置字典,请联系平台"); + } + if (!dict.getDictValue().equals(req.getCode())) { + return ResponseData.error("密码错误"); + } + return ResponseData.success(); + } + + + @PostMapping("/statistics") + @ApiOperation(value = "首页统计", notes = "首页统计") + public ResponseData statistics(@RequestBody(required = false) StatisticsReq req) { + StatisticsResp statisticsResp = new StatisticsResp(); + + //平台设置比例系数 + Integer scale = Integer.valueOf(businessUtil.getDict(DictConstant.平台设置比例系数).getDictValue()); + + //查询入驻设计师 + int customerNum = customerService.count(new QueryWrapper().lambda() + .ne(Customer::getDelFlag, PublicCommon.删除)); + statisticsResp.setCustomerNum(customerNum + scale); + + //在线入驻设计师 + int onlineCustomerNum = customerService.count(new QueryWrapper().lambda() + .eq(Customer::getOnlineStatus, PublicCommon.在线) + .ne(Customer::getDelFlag, PublicCommon.删除)); + statisticsResp.setOnlineCustomerNum(onlineCustomerNum); + + //查询入驻技术 + List list = storeService.list(new QueryWrapper().lambda() + .ne(Store::getDelFlag, PublicCommon.删除)); + + int storeNum = 0; + if (list.size() > 0) { + //查询已经认证的表现师 + storeNum = storeService.getAuthStore(list.stream().map(Store::getId).collect(Collectors.toList()), req.getIfHighend()); + } + + statisticsResp.setStoreNum(storeNum + scale); + + + List userIds = new ArrayList<>(); + + //在线表现师数 + String last_time_map_key = "last_time_" + 2; + + Map cacheMap = redisService.getCacheMap(last_time_map_key); + + cacheMap.forEach((key, value) -> { + + long lastTimes = Long.valueOf(value.toString()); + + if (System.currentTimeMillis() - lastTimes < (6 * 60 * 1000)) { + userIds.add(Long.valueOf(key)); + } + }); + + int onlineStoreNum = userIds.size(); + + if (userIds.size() > 0) { + //查询已经认证的表现师 + onlineStoreNum = storeService.getAuthStore(userIds, req.getIfHighend()); + } + + statisticsResp.setOnlineStoreNum(onlineStoreNum + scale); + + //成交订单数 + int orderNum = orderService.count(new QueryWrapper().lambda() + .ge(Order::getStatus, OrderStatusEnums.to_be_evaluated.getCode())); + statisticsResp.setOrderNum(orderNum + scale); + + return ResponseData.success(statisticsResp); + } +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/ApiLevelController.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/ApiLevelController.java new file mode 100644 index 0000000..bd25c5d --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/ApiLevelController.java @@ -0,0 +1,117 @@ +package com.ruoyi.controller; + +import cn.hutool.core.util.ObjectUtil; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.ruoyi.annotations.UserLoginToken; +import com.ruoyi.code.PublicCommon; +import com.ruoyi.controller.resp.LevelResp; +import com.ruoyi.enums.user.UserEnums; +import com.ruoyi.frequency.customer.entity.Customer; +import com.ruoyi.frequency.customer.service.CustomerService; +import com.ruoyi.frequency.level.entity.Level; +import com.ruoyi.frequency.level.service.LevelService; +import com.ruoyi.frequency.store.entity.Store; +import com.ruoyi.frequency.store.service.StoreService; +import com.ruoyi.response.ResponseData; +import com.ruoyi.vo.RyController; +import com.ruoyi.vo.UserVo; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.extern.slf4j.Slf4j; +import org.bouncycastle.asn1.cms.ecc.ECCCMSSharedInfo; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import java.math.BigDecimal; +import java.util.Comparator; +import java.util.List; + + +/** + * 等级 + */ +@CrossOrigin +@RestController +@RequestMapping("/api/level") +@Slf4j +@Api(tags = "等级") +public class ApiLevelController extends RyController { + + @Autowired + private LevelService levelService; + + @Autowired + private CustomerService customerService; + + @Autowired + private StoreService storeService; + + + @PostMapping("/levelList") + @ApiOperation(value = "等级列表", notes = "等级列表") + public ResponseData> levelList(@RequestParam("type") Integer type) { + List list = levelService.list(new QueryWrapper().lambda() + .eq(Level::getType, type) + .eq(Level::getDelFlag, PublicCommon.启用).orderByAsc(Level::getCompliance)); + return ResponseData.success(list); + } + + @PostMapping("/level") + @ApiOperation(value = "会员等级", notes = "会员等级") + @UserLoginToken + public ResponseData level() { + LevelResp levelResp = new LevelResp(); + + UserVo userVo = getUserVo(); + + + if (ObjectUtil.equal(UserEnums.customer.getCode(),userVo.getUserType())){ + Customer customer = customerService.getById(userVo.getUserId()); + + levelResp.setPrice(customer.getConsumptionAmount()); + }else if (ObjectUtil.equal(UserEnums.store.getCode(),userVo.getUserType())){ + Store store = storeService.getById(userVo.getUserId()); + + levelResp.setPrice(store.getIncome()); + }else { + return ResponseData.success(); + } + + + + List levelList = levelService.list(new QueryWrapper().lambda() + .eq(Level::getDelFlag, PublicCommon.启用) + .eq(Level::getType, userVo.getUserType()) + .orderByDesc(Level::getCompliance) + ); + levelList.stream() + .filter(s -> levelResp.getPrice().compareTo(s.getCompliance()) >= 0) + .findFirst() + .ifPresent(one->{ + levelResp.setLevel(one.getName()); + levelResp.setLevelPrice(one.getCompliance()); + levelResp.setLevelVo(one); + }); + + if (levelResp.getLevel() == null){ + levelResp.setLevelPrice(BigDecimal.ZERO); + levelResp.setNextLevel(levelList.get(0).getName()); + levelResp.setNextLevelPrice(levelList.get(0).getCompliance()); + }else { + //排序 + Comparator comparing = Comparator.comparing(Level::getCompliance); + + levelList.stream().sorted(comparing) + .filter(s->levelResp.getPrice().compareTo(s.getCompliance()) < 0) + .findFirst() + .ifPresent(one->{ + levelResp.setNextLevel(one.getName()); + levelResp.setNextLevelPrice(one.getCompliance()); + }); + } + + return ResponseData.success(levelResp); + } + + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/ApiMallOrderController.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/ApiMallOrderController.java new file mode 100644 index 0000000..6afe818 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/ApiMallOrderController.java @@ -0,0 +1,132 @@ +package com.ruoyi.controller; + +import com.ruoyi.annotations.UserLoginToken; +import com.ruoyi.common.page.PageResult; +import com.ruoyi.controller.req.*; +import com.ruoyi.controller.resp.MallOrderDetailResp; +import com.ruoyi.controller.resp.MallOrderPageResp; +import com.ruoyi.frequency.mallorder.service.MallOrderService; +import com.ruoyi.frequency.mallrefund.entity.MallRefund; +import com.ruoyi.response.ResponseData; +import com.ruoyi.vo.PayVo; +import com.ruoyi.vo.RyController; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import javax.validation.constraints.NotNull; + +@CrossOrigin +@RestController +@RequestMapping("/api/mallOrder") +@Api(tags = "商城") +public class ApiMallOrderController extends RyController { + + + @Autowired + private MallOrderService orderService; + + @UserLoginToken + @RequestMapping(value = "/settlement", method = RequestMethod.POST) + @ApiOperation(value = "订单结算") + public ResponseData settlement(@RequestBody MallSettlementReq req) { + return ResponseData.success(orderService.settlement(req,getUserVo())); + } + + @UserLoginToken + @RequestMapping(value = "/createOrder", method = RequestMethod.POST) + @ApiOperation(value = "创建订单") + public ResponseData createOrder(@RequestBody CreateOrderReq req) { + return orderService.createOrder(req,getUserVo()); + } + + @UserLoginToken + @RequestMapping(value = "/orderPage", method = RequestMethod.POST) + @ApiOperation(value = "商城订单列表") + public ResponseData> orderPage(@RequestBody MallOrderPageReq req) { + return orderService.orderPage(req, getUserVo()); + } + + @UserLoginToken + @RequestMapping(value = "/orderDetail", method = RequestMethod.POST) + @ApiOperation(value = "商城订单列表_详情") + public ResponseData orderDetail(@RequestBody @NotNull(message = "订单id不能为空") Long orderId) { + return orderService.orderDetail(orderId, getUserVo()); + + } + + @UserLoginToken + @RequestMapping(value = "/orderPay", method = RequestMethod.POST) + @ApiOperation(value = "商城订单列表——付款") + public ResponseData orderPay(@RequestBody MallOrderPayReq req) { + return orderService.orderPay(req, getUserVo()); + + } + + @UserLoginToken + @RequestMapping(value = "/orderCancel", method = RequestMethod.POST) + @ApiOperation(value = "商城订单列表——取消") + public ResponseData orderCancel(@RequestBody @NotNull(message = "订单id不能为空") Long orderId) { + return orderService.orderCancel(orderId, getUserVo()); + } + + @UserLoginToken + @RequestMapping(value = "/orderRefund", method = RequestMethod.POST) + @ApiOperation(value = "商城订单列表——退款") + public ResponseData orderRefund(@RequestBody @NotNull(message = "订单id不能为空") Long orderId) { + return orderService.orderRefund(orderId, getUserVo()); + } + + @UserLoginToken + @RequestMapping(value = "/orderConfirm", method = RequestMethod.POST) + @ApiOperation(value = "商城订单列表——确认收货") + public ResponseData orderConfirm(@RequestBody MallOrderConfirmReq req) { + return orderService.orderConfirm(req, getUserVo()); + + } + + @UserLoginToken + @RequestMapping(value = "/orderAfterApply", method = RequestMethod.POST) + @ApiOperation(value = "商城订单列表——售后申请") + public ResponseData orderAfterApply(@RequestBody ApplyAfterSalesReq req) { + return orderService.orderAfterApply(req, getUserVo()); + + } + @UserLoginToken + @RequestMapping(value = "/orderAfterDetail", method = RequestMethod.POST) + @ApiOperation(value = "商城订单列表——售后——详情") + public ResponseData orderAfterDetail(@RequestBody Long orderId) { + return orderService.orderAfterDetail(orderId, getUserVo()); + + } + @UserLoginToken + @RequestMapping(value = "/orderAfterRevokeApply", method = RequestMethod.POST) + @ApiOperation(value = "商城订单列表——售后——撤销申请") + public ResponseData orderAfterRevokeApply(@RequestBody Long refundId) { + return orderService.orderAfterRevokeApply(refundId, getUserVo()); + + } + + @UserLoginToken + @RequestMapping("/customerDeliverGoods") + @ApiOperation(value = "商城订单列表——售后——用户发货(申请售后成功)") + public ResponseData customerDeliverGoods(@RequestBody CustomerDeliverGoodsReq req) { + return orderService.customerDeliverGoods(req); + } + + + @UserLoginToken + @RequestMapping(value = "/evaluate", method = RequestMethod.POST) + @ApiOperation(value = "用户评价") + public ResponseData evaluate(@RequestBody MallEvaluateReq req) { + return orderService.evaluate(req,getUserVo()); + } + + @UserLoginToken + @RequestMapping(value = "/onceAgainCreateOrder", method = RequestMethod.POST) + @ApiOperation(value = "再次下单") + public ResponseData onceAgainCreateOrder(@RequestBody OnceAgainCreateOrderReq req) { + return orderService.onceAgainCreateOrder(req,getUserVo()); + } +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/ApiMessageController.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/ApiMessageController.java new file mode 100644 index 0000000..246a36b --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/ApiMessageController.java @@ -0,0 +1,60 @@ +package com.ruoyi.controller; + +import com.ruoyi.annotations.UserLoginToken; +import com.ruoyi.controller.req.IsNeedGetOrderDetailReq; +import com.ruoyi.controller.req.IsNeedGetOrderDetailReq2; +import com.ruoyi.controller.req.MessageReadOrDeleteReq; +import com.ruoyi.response.ResponseData; +import com.ruoyi.service.MessageService; +import com.ruoyi.vo.RyController; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import java.util.Map; + + +/** + * 消息中心 + * @author liwenlong + * + */ +@CrossOrigin +@RestController +@RequestMapping("/api/message") +@Api(tags = "消息中心") +public class ApiMessageController extends RyController { + + + @Autowired + private MessageService messageService; + + + /** + * 消息中心 + * + * @author liwenlong + * + */ + @UserLoginToken + @PostMapping("/messageCenter") + public ResponseData> messageCenter() { + return messageService.messageCenter(getUserVo()); + } + + @PostMapping("/isNeedGetMessageCenter") + @ApiOperation(value = "是否需要重新调用消息中心接口", notes = "是否需要重新调用消息中心接口") + @UserLoginToken + public ResponseData isNeedGetMessageCenter(@RequestBody IsNeedGetOrderDetailReq2 req) { + return messageService.isNeedGetMessageCenter(req,getUserVo()); + } + + @UserLoginToken + @PostMapping("/messageReadOrDelete") + @ApiOperation(value = "消息列表_已读,删除消息", notes = "消息列表_已读,删除消息") + public ResponseData messageReadOrDelete(@RequestBody MessageReadOrDeleteReq req) { + return messageService.messageReadOrDelete(req, getUserVo()); + } + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/ApiNewsController.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/ApiNewsController.java new file mode 100644 index 0000000..1489b58 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/ApiNewsController.java @@ -0,0 +1,56 @@ +package com.ruoyi.controller; + +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.ruoyi.annotations.UserLoginToken; +import com.ruoyi.common.page.PageResult; +import com.ruoyi.controller.req.LikeReq; +import com.ruoyi.controller.req.NewsPageReq; +import com.ruoyi.frequency.like.service.LikeService; +import com.ruoyi.frequency.news.entity.News; +import com.ruoyi.frequency.news.service.NewsService; +import com.ruoyi.response.ResponseData; +import com.ruoyi.vo.BodyIdReq; +import com.ruoyi.vo.RyController; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import javax.validation.Valid; + +/** + * 新闻 + */ +@CrossOrigin +@RestController +@RequestMapping("/api/news") +@Api(tags = "新闻") +public class ApiNewsController extends RyController { + + @Autowired + private NewsService newsService; + + @PostMapping("/newsPage") + @ApiOperation(value = "新闻列表", notes = "新闻列表") +// @UserLoginToken + public ResponseData>> newsPage(@RequestBody @Valid NewsPageReq req) { + return newsService.newsPage(req,getUserVo()); + } + + @PostMapping("/newsDetail") + @ApiOperation(value = "新闻详情", notes = "新闻详情") +// @UserLoginToken + public ResponseData newsDetail(@RequestBody @Valid BodyIdReq req) { + return newsService.newsDetail(req.getId(),req.getIsAddBrowseNum(),getUserVo()); + } + + @Autowired + private LikeService likeService; + + @PostMapping("/newsLike") + @UserLoginToken + @ApiOperation(value = "新闻点赞", notes = "新闻点赞") + public ResponseData newsLike(@RequestBody LikeReq req) { + return likeService.like(req,getUserVo()); + } +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/ApiNoticeController.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/ApiNoticeController.java new file mode 100644 index 0000000..49c7cbc --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/ApiNoticeController.java @@ -0,0 +1,48 @@ +package com.ruoyi.controller; + +import com.ruoyi.response.ResponseData; +import com.ruoyi.system.domain.SysNotice; +import com.ruoyi.system.service.ISysNoticeService; +import com.ruoyi.vo.BodyIdReq; +import com.ruoyi.vo.RyController; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import javax.validation.Valid; +import javax.validation.constraints.NotNull; +import java.util.List; + +/** + * 公告 + */ +@CrossOrigin +@RestController +@RequestMapping("/api/notice") +@Api(tags = "公告") +public class ApiNoticeController extends RyController { + + + @Autowired + private ISysNoticeService sysNoticeService; + + @PostMapping("/noticeList") + @ApiOperation(value = "公告", notes = "公告") + public ResponseData> noticeList(@RequestBody(required = false) String noticeType) { + + SysNotice sysNotice = new SysNotice(); + sysNotice.setNoticeType(noticeType); + sysNotice.setIsApp(2); + sysNotice.setStatus("0"); + List sysNotices = sysNoticeService.selectNoticeList(sysNotice); + return ResponseData.success(sysNotices); + } + + @PostMapping("/detail") + @ApiOperation(value = "公告详情", notes = "公告详情") + public ResponseData detail(@Valid @NotNull(message = "id不能为空") @RequestBody BodyIdReq req) { + return ResponseData.success(this.sysNoticeService.selectNoticeById(req.getId())); + } + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/ApiOnlineController.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/ApiOnlineController.java new file mode 100644 index 0000000..75e9ecd --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/ApiOnlineController.java @@ -0,0 +1,98 @@ +package com.ruoyi.controller; + +import com.ruoyi.enums.user.UserEnums; +import com.ruoyi.frequency.customer.mapper.CustomerMapper; +import com.ruoyi.response.ResponseData; +import com.ruoyi.utils.BusinessUtil; +import com.ruoyi.vo.RyController; +import com.ruoyi.vo.UserVo; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.redis.core.RedisTemplate; +import org.springframework.web.bind.annotation.CrossOrigin; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + *在线 + */ +@CrossOrigin +@RestController +@RequestMapping("/api/online") +@Slf4j +@Api(tags = "在线") +public class ApiOnlineController extends RyController { + + @Autowired + private RedisTemplate redisTemplate; + + @Autowired + private BusinessUtil businessUtil; + + @Autowired + private CustomerMapper customerMapper; + + + @PostMapping("/online") + @ApiOperation(value = "定时调取统计在线时间", notes = "定时调取统计在线时间") + public ResponseData onlineTimeStatistics() { + + UserVo userVo = getUserVo(); + + if (userVo.getUserType() == -1 || userVo.getUserType().equals(UserEnums.sale.getCode())){ + return ResponseData.success(); + } + + //累计时长 + String total_times_map_key = "total_times_" + userVo.getUserType(); + + //上次调用此接口的时间 + String last_time_map_key = "last_time_" + userVo.getUserType(); + + //首先从redis里查 + Long totalTime = 0L; + if (redisTemplate.opsForHash().hasKey(total_times_map_key,userVo.getUserId().toString())) { + totalTime = Long.valueOf(redisTemplate.opsForHash().get(total_times_map_key, userVo.getUserId().toString()).toString()); + } else { + //从数据库查询的累计时长 + totalTime = Long.valueOf(businessUtil.getUserFieldValue(userVo,"onlineDuration").toString()) * 60 * 1000; + } + + Integer onlineStatus = 1; + + //查询上次调用此接口的时间 + Long lastTimes = 0L; + if (redisTemplate.opsForHash().hasKey(last_time_map_key,userVo.getUserId().toString())) { + lastTimes = Long.valueOf(redisTemplate.opsForHash().get(last_time_map_key, userVo.getUserId().toString()).toString()); + + log.info("用户" + userVo.getUserId() + "上次调取时长:" + (System.currentTimeMillis() - lastTimes)/60/1000 + "分钟"); + + //判断当前时间和上次时间是否超过5.5分钟(考虑到网络延时和程序卡顿,多半分钟) + if (System.currentTimeMillis() - lastTimes < (6* 60 * 1000)) { + totalTime = totalTime + (System.currentTimeMillis() - lastTimes); + }else { + onlineStatus = 2; + } + + } + + //上次调取时间 + redisTemplate.opsForHash().put(last_time_map_key, userVo.getUserId().toString(),System.currentTimeMillis()); + + //累计时长 + redisTemplate.opsForHash().put(total_times_map_key, userVo.getUserId().toString(),totalTime); + + //修改数据库在线时长 + businessUtil.updateOnlineDuration(userVo,totalTime,onlineStatus); + + log.info("用户" + userVo.getUserId() + "累计在线时长:" + totalTime/60/1000 + "分钟"); + + customerMapper.insertOnlineLog(userVo); + + return ResponseData.success(); + } + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/ApiOrderChangeRecordController.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/ApiOrderChangeRecordController.java new file mode 100644 index 0000000..c532046 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/ApiOrderChangeRecordController.java @@ -0,0 +1,38 @@ +package com.ruoyi.controller; + +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.ruoyi.annotations.UserLoginToken; +import com.ruoyi.common.page.PageResult; +import com.ruoyi.controller.req.OrderChangeRecordPageReq; +import com.ruoyi.frequency.orderchangerecord.entity.OrderChangeRecord; +import com.ruoyi.frequency.orderchangerecord.service.OrderChangeRecordService; +import com.ruoyi.response.ResponseData; +import com.ruoyi.vo.RyController; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import javax.validation.Valid; + +/** + * 调价 + */ +@CrossOrigin +@RestController +@RequestMapping("/api/orderChangeRecord") +@Api(tags = "调价") +public class ApiOrderChangeRecordController extends RyController { + + @Autowired + private OrderChangeRecordService orderChangeRecordService; + + + @PostMapping("/orderChangeRecordPage") + @ApiOperation(value = "订单调价记录", notes = "订单调价记录") + @UserLoginToken + public ResponseData>> orderChangeRecordPage(@RequestBody @Valid OrderChangeRecordPageReq req) { + return orderChangeRecordService.orderChangeRecordPage(req,getUserVo()); + } + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/ApiOrderController.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/ApiOrderController.java new file mode 100644 index 0000000..0c2fb4e --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/ApiOrderController.java @@ -0,0 +1,322 @@ +package com.ruoyi.controller; + +import cn.hutool.core.util.ObjectUtil; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.ruoyi.annotations.UserLoginToken; +import com.ruoyi.code.DictConstant; +import com.ruoyi.code.Token; +import com.ruoyi.common.annotation.RepeatSubmit; +import com.ruoyi.common.core.domain.entity.SysDictData; +import com.ruoyi.common.page.PageResult; +import com.ruoyi.controller.req.*; +import com.ruoyi.controller.resp.OrderDataResp; +import com.ruoyi.controller.resp.OrderDetailResp; +import com.ruoyi.controller.resp.OrderPageResp; +import com.ruoyi.frequency.customer.entity.Customer; +import com.ruoyi.frequency.customer.service.CustomerService; +import com.ruoyi.frequency.order.entity.Order; +import com.ruoyi.frequency.order.service.OrderService; +import com.ruoyi.frequency.workstype.service.WorksTypeService; +import com.ruoyi.response.ResponseData; +import com.ruoyi.utils.BusinessUtil; +import com.ruoyi.vo.BodyIdReq; +import com.ruoyi.vo.PayVo; +import com.ruoyi.vo.RyController; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import java.math.BigDecimal; +import java.util.List; + +/** + * 订单 + */ +@CrossOrigin +@RestController +@RequestMapping("/api/order") +@Api(tags = "订单") +public class ApiOrderController extends RyController { + + + @Autowired + private OrderService orderService; + + + @PostMapping("/orderRelease") + @ApiOperation(value = "发布订单", notes = "发布订单") + @UserLoginToken + public ResponseData orderRelease(@RequestBody OrderReleaseReq req) { + return orderService.orderRelease(req, getUserVo()); + } + + @PostMapping("/customerPay") + @ApiOperation(value = "表现师发布订单--设计师支付", notes = "表现师发布订单--设计师支付") + @UserLoginToken + public ResponseData customerPay(@RequestBody CustomerPayReq req) { + return orderService.customerPay(req, getUserVo()); + } + + @PostMapping("/orderPage") + @ApiOperation(value = "订单列表", notes = "订单列表") + @UserLoginToken + public ResponseData>> orderPage(@RequestBody OrderPageReq req) { + return orderService.orderPage(req, getUserVo()); + } + + + @PostMapping("/orderDetail") + @ApiOperation(value = "订单详情", notes = "订单详情") + @UserLoginToken + public ResponseData orderDetail(@RequestBody BodyIdReq req) { + return orderService.orderDetail(req.getId(), getUserVo()); + } + + + @PostMapping("/isNeedGetOrderDetail") + @ApiOperation(value = "是否需要重新调用订单详情接口", notes = "是否需要重新调用订单详情接口") + @UserLoginToken + public ResponseData isNeedGetOrderDetail(@RequestBody IsNeedGetOrderDetailReq req) { + return orderService.isNeedGetOrderDetail(req); + } + + + @PostMapping("/storeOrderReceiving") + @ApiOperation(value = "表现师接单", notes = "表现师接单") + @UserLoginToken + @RepeatSubmit + public ResponseData storeOrderReceiving(@RequestBody BodyIdReq req) { + return orderService.storeOrderReceiving(req.getId(), getUserVo()); + } + + @PostMapping("/orderCancel") + @ApiOperation(value = "取消订单", notes = "取消订单") + @UserLoginToken + public ResponseData orderCancel(@RequestBody BodyIdReq req) { + return orderService.orderCancel(req.getId(), getUserVo()); + } + + @PostMapping("/confirmStore") + @ApiOperation(value = "确认师傅(表现师)", notes = "确认师傅(表现师)") + @UserLoginToken + public ResponseData confirmStore(@RequestBody ConfirmStoreReq req) { + return orderService.confirmStore(req, getUserVo()); + } + + @PostMapping("/orderAppeal") + @ApiOperation(value = "订单申诉", notes = "订单申诉") + @UserLoginToken + public ResponseData orderAppeal(@RequestBody OrderAppealReq req) { + return orderService.orderAppeal(req, getUserVo()); + } + + @PostMapping("/cancelOrderAppeal") + @ApiOperation(value = "取消订单申诉", notes = "取消订单申诉") + @UserLoginToken + public ResponseData cancelOrderAppeal(@RequestBody BodyIdReq req) { + return orderService.cancelOrderAppeal(req, getUserVo()); + } + + @PostMapping("/orderAdjustPricePayCount") + @ApiOperation(value = "计算订单调价支付定金金额(超出现在价格)", notes = "计算订单调价支付定金金额(超出现在价格)") + @UserLoginToken + public ResponseData orderAdjustPricePayCount(@RequestBody OrderAdjustPricePayCountReq req) { + return orderService.orderAdjustPricePayCount(req, getUserVo()); + } + + @PostMapping("/orderAdjustPrice") + @ApiOperation(value = "订单调价", notes = "订单调价") + @UserLoginToken + public ResponseData orderAdjustPrice(@RequestBody OrderAdjustPriceReq req) { + return orderService.orderAdjustPrice(req, getUserVo()); + } + + @PostMapping("/orderAdjustPriceConfirm") + @ApiOperation(value = "订单调价确认", notes = "订单调价确认") + @UserLoginToken + public ResponseData orderAdjustPriceConfirm(@RequestBody OrderAdjustPriceConfirmReq req) { + return orderService.orderAdjustPriceConfirm(req, getUserVo()); + } + + @PostMapping("/orderAdjustPriceRefuse") + @ApiOperation(value = "订单调价拒绝", notes = "订单调价拒绝") + @UserLoginToken + public ResponseData orderAdjustPriceRefuse(@RequestBody RefuseReq req) { + return orderService.orderAdjustPriceRefuse(req, getUserVo()); + } + + @PostMapping("/orderExtension") + @ApiOperation(value = "订单延期", notes = "订单延期") + @UserLoginToken(userTokenPre = {Token.store}) + public ResponseData orderExtension(@RequestBody OrderExtensionReq req) { + return orderService.orderExtension(req, getUserVo()); + } + + @PostMapping("/orderExtensionCancel/{orderId}") + @ApiOperation(value = "订单延期取消", notes = "订单延期取消") + @UserLoginToken(userTokenPre = {Token.store}) + public ResponseData orderExtensionCancel(@PathVariable("orderId") Long orderId) { + return orderService.orderExtensionCancel(orderId); + } + + @PostMapping("/orderExtensionConfirm") + @ApiOperation(value = "订单延期确认", notes = "订单延期确认") + @UserLoginToken + public ResponseData orderExtensionConfirm(@RequestBody BodyIdReq req) { + return orderService.orderExtensionConfirm(req.getId(), getUserVo()); + } + + @PostMapping("/orderExtensionRefuse") + @ApiOperation(value = "订单延期拒绝", notes = "订单延期拒绝") + @UserLoginToken + public ResponseData orderExtensionRefuse(@RequestBody RefuseReq req) { + return orderService.orderExtensionRefuse(req, getUserVo()); + } + + @PostMapping("/receiveDrawingsAndPay") + @ApiOperation(value = "支付尾款", notes = "支付尾款") + @UserLoginToken + public ResponseData receiveDrawingsAndPay(@RequestBody ReceiveDrawingsAndPayReq req) { + return orderService.receiveDrawingsAndPay(req, getUserVo()); + } + + @PostMapping("/sampleImagesUpload") + @ApiOperation(value = "上传大图", notes = "上传大图") + @UserLoginToken + public ResponseData sampleImagesUpload(@RequestBody SampleImagesUploadReq req) { + return orderService.sampleImagesUpload(req, getUserVo()); + } + + @PostMapping("/sampleImagesAddendum") + @ApiOperation(value = "追加大图", notes = "追加大图") + @UserLoginToken + public ResponseData sampleImagesAddendum(@RequestBody SampleImagesUploadReq req) { + return orderService.sampleImagesAddendum(req, getUserVo()); + } + + @PostMapping("/evaluate") + @ApiOperation(value = "评价", notes = "评价") + @UserLoginToken + public ResponseData evaluate(@RequestBody EvaluateReq req) { + return orderService.evaluate(req, getUserVo()); + } + + + @PostMapping("/evaluateCountStar") + @ApiOperation(value = "评价计算评分", notes = "评价计算评分") + @UserLoginToken + public ResponseData evaluateCountStar(@RequestBody EvaluateReq req) { + return orderService.evaluateCountStar(req, getUserVo()); + } + + @Autowired + private WorksTypeService worksTypeService; + + @PostMapping("/projectHallPage") + @ApiOperation(value = "项目大厅", notes = "项目大厅") + public ResponseData>> projectHallPage(@RequestBody OrderPageReq req) { + if (ObjectUtil.isNotEmpty(req.getTypeId())) { + //根据类型id获取三级id + List typeIdList = worksTypeService.getIdsByTypeId(req.getTypeId()); + if (typeIdList.isEmpty()) { + return ResponseData.success(new PageResult<>(new Page<>(req.getPageNo(), req.getPageSize()))); + } + req.setTypeIds(typeIdList); + } + + req.setIsHall(true); + + return orderService.orderPage(req, getUserVo()); + } + + @PostMapping("/orderData") + @ApiOperation(value = "订单列表上方统计", notes = "订单列表上方统计") + @UserLoginToken() + public ResponseData orderData(@RequestBody(required = false) OrderPageReq orderPageReq) { + return orderService.orderData(orderPageReq == null ? new OrderPageReq() : orderPageReq, getUserVo()); + } + + + @Autowired + private BusinessUtil businessUtil; + + @Autowired + private CustomerService customerService; + + @PostMapping("/calculateFirstAmount") + @ApiOperation(value = "计算订单首款支付金额", notes = "计算订单首款支付金额") + @UserLoginToken + public ResponseData calculateFirstAmount(@RequestBody CalculateFirstAmountReq req) { + + PayVo payVo = new PayVo(); + BigDecimal firstPrice = null; + BigDecimal maxGivePrice = null; + if (req.getOrderId() != null) { + Order order = orderService.getById(req.getOrderId()); + firstPrice = order.getFirstPrice(); + maxGivePrice = order.getFirstGivePrice(); + } else { + + SysDictData dict = businessUtil.getDict(DictConstant.OrderDict.首款支付占比); + //首款支付比例 + BigDecimal ratio = BigDecimal.ZERO; + + if (dict != null && ObjectUtil.isNotEmpty(dict.getDictValue())) { + ratio = new BigDecimal(dict.getDictValue()); + } + + firstPrice = req.getAmount().multiply(ratio).setScale(2, BigDecimal.ROUND_HALF_UP); + maxGivePrice = businessUtil.userMaxGivePrice(getUserVo(), firstPrice); + } + + payVo.setPrice(firstPrice); + //赠送最大支付金额 + payVo.setMaxGivePrice(maxGivePrice); + + return ResponseData.success(payVo); + } + + @PostMapping("/calculateFinalAmount/{orderId}") + @ApiOperation(value = "计算订单尾款支付金额", notes = "计算订单尾款支付金额") + public ResponseData calculateFinalAmount(@PathVariable Long orderId) { + + //查询订单 + Order order = orderService.getById(orderId); + + PayVo payVo = new PayVo(); + + //尾款支付金额 + BigDecimal finalPrice = order.getAmount().subtract(order.getFirstPrice()); + payVo.setPrice(finalPrice); + + //赠送金额使用最大比例 + SysDictData give_dict = businessUtil.getDict(DictConstant.OrderDict.赠送金额支付占比); + //首款支付比例 + BigDecimal give_ratio = BigDecimal.ZERO; + + if (give_dict != null && ObjectUtil.isNotEmpty(give_dict.getDictValue())) { + give_ratio = new BigDecimal(give_dict.getDictValue()); + } + + //赠送最大支付金额 + BigDecimal maxGivePrice = finalPrice.multiply(give_ratio).setScale(2, BigDecimal.ROUND_HALF_UP); + + //查询用户抵用金 + Customer customer = customerService.getById(getUserVo().getUserId()); + + maxGivePrice = customer.getGiveBalance().compareTo(maxGivePrice) == 1 ? maxGivePrice : customer.getGiveBalance(); + + payVo.setMaxGivePrice(maxGivePrice); + + return ResponseData.success(payVo); + } + + @PostMapping("/getLakalaPaySuccess") + @ApiOperation(value = "获取拉卡拉支付是否成功", notes = "获取拉卡拉支付是否成功") + public ResponseData getLakalaPaySuccess(@RequestBody LakalaPaySuccessReq req) { + Boolean paySuccess = businessUtil.isPaySuccess(req.getOutOrderNo()); + return ResponseData.success(paySuccess); + } + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/ApiOrderExtensionRecordController.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/ApiOrderExtensionRecordController.java new file mode 100644 index 0000000..ad0d97f --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/ApiOrderExtensionRecordController.java @@ -0,0 +1,38 @@ +package com.ruoyi.controller; + +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.ruoyi.annotations.UserLoginToken; +import com.ruoyi.common.page.PageResult; +import com.ruoyi.controller.req.OrderChangeRecordPageReq; +import com.ruoyi.frequency.orderextensionrecord.entity.OrderExtensionRecord; +import com.ruoyi.frequency.orderextensionrecord.service.OrderExtensionRecordService; +import com.ruoyi.response.ResponseData; +import com.ruoyi.vo.RyController; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import javax.validation.Valid; + +/** + * 延期 + */ +@CrossOrigin +@RestController +@RequestMapping("/api/orderExtensionRecord") +@Api(tags = "延期") +public class ApiOrderExtensionRecordController extends RyController { + + @Autowired + private OrderExtensionRecordService orderExtensionRecordService; + + + @PostMapping("/orderExtensionRecordPage") + @ApiOperation(value = "订单延期记录", notes = "订单延期记录") + @UserLoginToken + public ResponseData>> orderExtensionRecordPage(@RequestBody @Valid OrderChangeRecordPageReq req) { + return orderExtensionRecordService.orderExtensionRecordPage(req,getUserVo()); + } + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/ApiOrderMessageController.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/ApiOrderMessageController.java new file mode 100644 index 0000000..1237852 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/ApiOrderMessageController.java @@ -0,0 +1,166 @@ +package com.ruoyi.controller; + +import cn.hutool.core.util.ObjectUtil; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.ruoyi.annotations.UserLoginToken; +import com.ruoyi.code.PublicCommon; +import com.ruoyi.common.page.PageResult; +import com.ruoyi.controller.req.OrderMessagePageReq; +import com.ruoyi.controller.resp.MallOrderPageResp; +import com.ruoyi.controller.resp.MessageOrderPageResp; +import com.ruoyi.controller.resp.OrderDetailResp; +import com.ruoyi.frequency.mallorder.service.MallOrderService; +import com.ruoyi.frequency.order.mapper.OrderMapper; +import com.ruoyi.frequency.ordermessage.entity.OrderMessage; +import com.ruoyi.frequency.ordermessage.entity.OrderMessageUtil; +import com.ruoyi.frequency.ordermessage.service.OrderMessageService; +import com.ruoyi.controller.req.MessageReadOrDeleteReq; +import com.ruoyi.response.ResponseData; +import com.ruoyi.vo.PageBasic; +import com.ruoyi.vo.RyController; +import com.ruoyi.vo.UserVo; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + + +/** + * 订单消息 + * @author liwenlong + * + */ +@CrossOrigin +@RestController +@RequestMapping("/api/message") +@Api(tags = "订单消息") +public class ApiOrderMessageController extends RyController { + + @Autowired + private OrderMessageService orderMessageService; + + @Autowired + private OrderMapper orderMapper; + + @Autowired + private MallOrderService mallOrderService; + + + @UserLoginToken + @PostMapping("/orderMessagePage") + @ApiOperation(value = "订单消息列表", notes = "订单消息列表") + public ResponseData> orderMessageList(@RequestBody OrderMessagePageReq req) { + + UserVo userVo = getUserVo(); + + List orderMessageList = this.orderMessageService.orderMessageList(req,userVo); + + if (orderMessageList.size() > 0){ + List orderIds = new ArrayList<>(); + + List mallOrderIds = new ArrayList<>(); + + orderMessageList.stream().forEach(s->{ + if (ObjectUtil.equal(PublicCommon.Order.订单,s.getOrderType())){ + orderIds.add(s.getOrderId()); + }else { + mallOrderIds.add(s.getOrderId()); + } + }); + + //订单 + orderIds.add(-1L); + List OrderDetailResps = orderMapper.orderList(orderIds, userVo); + Map> orderMap = OrderDetailResps.stream().collect(Collectors.groupingBy(OrderDetailResp::getId)); + + //商城订单 + mallOrderIds.add(-1L); + List mallOrderPageResps = mallOrderService.orderList(mallOrderIds, userVo); + Map> mallOrderMap = mallOrderPageResps.stream().collect(Collectors.groupingBy(MallOrderPageResp::getOrderId)); + + orderMessageList.forEach(orderMessage ->{ + + if (ObjectUtil.equal(PublicCommon.Order.订单,orderMessage.getOrderType())){ + List orderDetailRespList = orderMap.get(orderMessage.getOrderId()); + if (orderDetailRespList != null && orderDetailRespList.size() > 0) { + orderMessage.setOrder(orderDetailRespList.get(0)); + } + }else { + List mallOrderPageRespList = mallOrderMap.get(orderMessage.getOrderId()); + if (mallOrderPageRespList != null && mallOrderPageRespList.size() > 0) { + orderMessage.setMallOrder(mallOrderPageRespList.get(0)); + } + } + + }) ; + } + + return ResponseData.success(orderMessageList); + } + + + @UserLoginToken + @PostMapping("/messageOrderPage") + @ApiOperation(value = "订单消息订单分组列表(按订单展示)", notes = "订单消息订单分组列表(按订单展示)") + public ResponseData>> orderMessagePage(@RequestBody PageBasic req) { + + UserVo userVo = getUserVo(); + + Page messageOrderPage = this.orderMessageService.messageOrderPage(req,userVo); + + if (messageOrderPage.getRecords().size() > 0){ + List orderIds = new ArrayList<>(); + + List mallOrderIds = new ArrayList<>(); + + messageOrderPage.getRecords().stream().forEach(s->{ + if (ObjectUtil.equal(PublicCommon.Order.订单,s.getOrderType())){ + orderIds.add(s.getOrderId()); + }else { + mallOrderIds.add(s.getOrderId()); + } + }); + + + //订单 + orderIds.add(-1L); + List OrderDetailResps = orderMapper.orderList(orderIds, userVo); + Map> orderMap = OrderDetailResps.stream().collect(Collectors.groupingBy(OrderDetailResp::getId)); + + //商城订单 + mallOrderIds.add(-1L); + List mallOrderPageResps = mallOrderService.orderList(mallOrderIds, userVo); + Map> mallOrderMap = mallOrderPageResps.stream().collect(Collectors.groupingBy(MallOrderPageResp::getOrderId)); + + messageOrderPage.getRecords().forEach(orderMessage ->{ + + if (ObjectUtil.equal(PublicCommon.Order.订单,orderMessage.getOrderType())){ + List orderDetailRespList = orderMap.get(orderMessage.getOrderId()); + if (orderDetailRespList != null && orderDetailRespList.size() > 0) { + orderMessage.setOrder(orderDetailRespList.get(0)); + } + }else { + List mallOrderPageRespList = mallOrderMap.get(orderMessage.getOrderId()); + if (mallOrderPageRespList != null && mallOrderPageRespList.size() > 0) { + orderMessage.setMallOrder(mallOrderPageRespList.get(0)); + } + } + + }) ; + } + return ResponseData.success(new PageResult<>(messageOrderPage)); + } + + @UserLoginToken + @PostMapping("/orderMessageReadOrDelete") + @ApiOperation(value = "订单消息列表_已读,删除消息", notes = "订单消息列表_已读,删除消息") + public ResponseData orderMessageReadOrDelete(@RequestBody MessageReadOrDeleteReq req) { + return orderMessageService.orderMessageReadOrDelete(req, getUserVo()); + } + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/ApiPayController.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/ApiPayController.java new file mode 100644 index 0000000..f4ac99a --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/ApiPayController.java @@ -0,0 +1,515 @@ +package com.ruoyi.controller; + +import com.alibaba.fastjson.JSONObject; +import com.ruoyi.frequency.auth.service.AuthService; +import com.ruoyi.frequency.bondrecord.service.BondRecordService; +import com.ruoyi.frequency.highendauth.service.HighendAuthService; +import com.ruoyi.frequency.order.service.OrderService; +import com.ruoyi.frequency.rechargeorder.service.RechargeOrderService; +import com.ruoyi.response.ResponseData; +import com.ruoyi.utils.BusinessUtil; +import com.ruoyi.vo.RyController; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RestController; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.util.Map; + + +/** + * 支付回调 + */ +@RestController +@RequestMapping("/api/pay") +@Slf4j +@Api(tags = "支付回调") +public class ApiPayController extends RyController { + + + @Autowired + private BusinessUtil businessUtil; + + @Autowired + private OrderService orderService; + + /** + * 订单首款支付宝回调地址 + */ + @ApiOperation("订单首款支付宝回调地址") + @RequestMapping(value = "/orderAliNotify", method = RequestMethod.POST) + public void orderAliNotify(HttpServletRequest request, HttpServletResponse response) { + log.info("订单首款支付宝回调开始........"); + try { + ResponseData responseData = orderService.orderAliNotify(request, response); + if (responseData.getSuccess()) { + businessUtil.writeText(response, "success"); + } + + } catch (Exception e) { + e.getMessage(); + } + } + + /** + * 订单首款微信回调地址 + */ + @ApiOperation("订单首款微信回调地址") + @RequestMapping(value = "/orderWxNotify", method = RequestMethod.POST) + public void orderWxNotify(HttpServletRequest request, HttpServletResponse response) { + log.info("订单首款微信回调开始........"); + String msg = ""; + try { + ResponseData responseData = orderService.orderWxNotify(request, response); + if (responseData.getSuccess()) { + String resultMsg = String.format("", + ("SUCCESS"), msg); + businessUtil.writeText(response, resultMsg); + } + } catch (Exception e) { + msg = e.getMessage(); + } + } + + @ApiOperation("订单首款拉卡拉回调地址") + @RequestMapping(value = "/orderLakalaNotify", method = RequestMethod.POST) + public String orderLakalaNotify(@RequestBody String callbackData) { + log.info("订单首款拉卡拉回调开始........"); + // 转换请求参数为 Map + Map paramMap = JSONObject.parseObject(callbackData, Map.class); + + String msg = ""; + try { + ResponseData responseData = orderService.orderLakalaNotify(paramMap); + if (responseData.getSuccess()) { + return "SUCCESS"; + } + } catch (Exception e) { + msg = e.getMessage(); + } + return "SUCCESS"; + } + + + /** + * 订单尾款支付宝回调地址 + */ + @ApiOperation("订单尾款支付宝回调地址") + @RequestMapping(value = "/secondOrderAliNotify", method = RequestMethod.POST) + public void secondOrderAliNotify(HttpServletRequest request, HttpServletResponse response) { + log.info("订单尾款支付宝回调开始........"); + try { + ResponseData responseData = orderService.secondOrderAliNotify(request, response); + if (responseData.getSuccess()) { + businessUtil.writeText(response, "success"); + } + + } catch (Exception e) { + e.getMessage(); + } + } + + /** + * 订单尾款微信回调地址 + */ + @ApiOperation("订单尾款微信回调地址") + @RequestMapping(value = "/secondOrderWxNotify", method = RequestMethod.POST) + public void secondOrderWxNotify(HttpServletRequest request, HttpServletResponse response) { + log.info("订单尾款微信回调开始........"); + String msg = ""; + try { + ResponseData responseData = orderService.secondOrderWxNotify(request, response); + if (responseData.getSuccess()) { + String resultMsg = String.format("", + ("SUCCESS"), msg); + businessUtil.writeText(response, resultMsg); + } + } catch (Exception e) { + msg = e.getMessage(); + } + } + + @ApiOperation("订单尾款拉卡拉回调地址") + @RequestMapping(value = "/secondOrderLakalaNotify", method = RequestMethod.POST) + public String secondOrderLakalaNotify(@RequestBody String callbackData) { + log.info("订单尾款拉卡拉回调开始........"); + // 转换请求参数为 Map + Map paramMap = JSONObject.parseObject(callbackData, Map.class); + String msg = ""; + try { + ResponseData responseData = orderService.secondOrderLakalaNotify(paramMap); + if (responseData.getSuccess()) { + return "SUCCESS"; + } + } catch (Exception e) { + msg = e.getMessage(); + } + return "SUCCESS"; + } + + + @Autowired + private BondRecordService bondRecordService; + + /** + * 保证金支付宝回调地址 + */ + @ApiOperation("保证金支付宝回调地址") + @RequestMapping(value = "/bondAliNotify", method = RequestMethod.POST) + public void bondAliNotify(HttpServletRequest request, HttpServletResponse response) { + log.info("保证金支付宝回调开始........"); + try { + ResponseData responseData = bondRecordService.bondAliNotify(request, response); + if (responseData.getSuccess()) { + businessUtil.writeText(response, "success"); + } + + } catch (Exception e) { + e.getMessage(); + } + } + + /** + * 保证金微信回调地址 + */ + @ApiOperation("保证金微信回调地址") + @RequestMapping(value = "/bondWxNotify", method = RequestMethod.POST) + public void bondWxNotify(HttpServletRequest request, HttpServletResponse response) { + log.info("保证金微信回调开始........"); + String msg = ""; + try { + ResponseData responseData = bondRecordService.bondWxNotify(request, response); + if (responseData.getSuccess()) { + String resultMsg = String.format("", + ("SUCCESS"), msg); + businessUtil.writeText(response, resultMsg); + } + } catch (Exception e) { + msg = e.getMessage(); + } + } + + @ApiOperation("保证金拉卡拉回调地址") + @RequestMapping(value = "/bondLakalaNotify", method = RequestMethod.POST) + public String bondLakalaNotify(@RequestBody String callbackData) { + log.info("保证金拉卡拉回调开始........"); + // 转换请求参数为 Map + Map paramMap = JSONObject.parseObject(callbackData, Map.class); + String msg = ""; + try { + ResponseData responseData = bondRecordService.bondLakalaNotify(paramMap); + if (responseData.getSuccess()) { + return "SUCCESS"; + } + } catch (Exception e) { + msg = e.getMessage(); + } + return "SUCCESS"; + } + + + + @Autowired + private AuthService authService; + + /** + * 普通认证支付宝回调地址 + */ + @ApiOperation("普通认证支付宝回调地址") + @RequestMapping(value = "/authAliNotify", method = RequestMethod.POST) + public void authAliNotify(HttpServletRequest request, HttpServletResponse response) { + log.info("普通认证支付宝回调开始........"); + try { + ResponseData responseData = authService.authAliNotify(request, response); + if (responseData.getSuccess()) { + businessUtil.writeText(response, "success"); + } + + } catch (Exception e) { + e.getMessage(); + } + } + + /** + * 普通认证微信回调地址 + */ + @ApiOperation("普通认证微信回调地址") + @RequestMapping(value = "/authWxNotify", method = RequestMethod.POST) + public void authWxNotify(HttpServletRequest request, HttpServletResponse response) { + log.info("普通认证微信回调开始........"); + String msg = ""; + try { + ResponseData responseData = authService.authWxNotify(request, response); + if (responseData.getSuccess()) { + String resultMsg = String.format("", + ("SUCCESS"), msg); + businessUtil.writeText(response, resultMsg); + } + } catch (Exception e) { + msg = e.getMessage(); + } + } + + @ApiOperation("普通认证拉卡拉回调地址") + @RequestMapping(value = "/authLakalaNotify", method = RequestMethod.POST) + public String authLakalaNotify(@RequestBody String callbackData) { + log.info("普通认证拉卡拉回调开始........"); + // 转换请求参数为 Map + Map paramMap = JSONObject.parseObject(callbackData, Map.class); + String msg = ""; + try { + ResponseData responseData = authService.authLakalaNotify(paramMap); + if (responseData.getSuccess()) { + return "SUCCESS"; + } + } catch (Exception e) { + msg = e.getMessage(); + } + return "SUCCESS"; + } + + + @Autowired + private HighendAuthService highendAuthService; + + /** + * 高端认证支付宝回调地址 + */ + @ApiOperation("高端认证支付宝回调地址") + @RequestMapping(value = "/highendAuthAliNotify", method = RequestMethod.POST) + public void highendAuthAliNotify(HttpServletRequest request, HttpServletResponse response) { + log.info("高端认证支付宝回调开始........"); + try { + ResponseData responseData = highendAuthService.highendAuthAliNotify(request, response); + if (responseData.getSuccess()) { + businessUtil.writeText(response, "success"); + } + + } catch (Exception e) { + e.getMessage(); + } + } + + /** + * 高端认证微信回调地址 + */ + @ApiOperation("高端认证微信回调地址") + @RequestMapping(value = "/highendAuthWxNotify", method = RequestMethod.POST) + public void highendAuthWxNotify(HttpServletRequest request, HttpServletResponse response) { + log.info("高端认证微信回调开始........"); + String msg = ""; + try { + ResponseData responseData = highendAuthService.highendAuthWxNotify(request, response); + if (responseData.getSuccess()) { + String resultMsg = String.format("", + ("SUCCESS"), msg); + businessUtil.writeText(response, resultMsg); + } + } catch (Exception e) { + msg = e.getMessage(); + } + } + + @ApiOperation("高端认证拉卡拉回调地址") + @RequestMapping(value = "/highendAuthLakalaNotify", method = RequestMethod.POST) + public String highendAuthLakalaNotify(@RequestBody String callbackData) { + log.info("高端认证拉卡拉回调开始........"); + // 转换请求参数为 Map + Map paramMap = JSONObject.parseObject(callbackData, Map.class); + String msg = ""; + try { + ResponseData responseData = highendAuthService.highendAuthLakalaNotify(paramMap); + if (responseData.getSuccess()) { + return "SUCCESS"; + } + } catch (Exception e) { + msg = e.getMessage(); + } + return "SUCCESS"; + } + + + @Autowired + private RechargeOrderService rechargeOrderService; + + /** + * 充值支付宝回调地址 + */ + @ApiOperation("充值支付宝回调地址") + @RequestMapping(value = "/rechargeAliNotify", method = RequestMethod.POST) + public void rechargeAliNotify(HttpServletRequest request, HttpServletResponse response) { + log.info("充值支付宝回调开始........"); + try { + ResponseData responseData = rechargeOrderService.rechargeAliNotify(request, response); + if (responseData.getSuccess()) { + businessUtil.writeText(response, "success"); + } + + } catch (Exception e) { + e.getMessage(); + } + } + + /** + * 充值微信回调地址 + */ + @ApiOperation("充值微信回调地址") + @RequestMapping(value = "/rechargeWxNotify", method = RequestMethod.POST) + public void rechargeWxNotify(HttpServletRequest request, HttpServletResponse response) { + log.info("充值微信回调开始........"); + String msg = ""; + try { + ResponseData responseData = rechargeOrderService.rechargeWxNotify(request, response); + if (responseData.getSuccess()) { + String resultMsg = String.format("", + ("SUCCESS"), msg); + businessUtil.writeText(response, resultMsg); + } + } catch (Exception e) { + msg = e.getMessage(); + } + } + + @ApiOperation("充值拉卡拉回调地址") + @RequestMapping(value = "/rechargeLakalaNotify", method = RequestMethod.POST) + public String rechargeLakalaNotify(@RequestBody String callbackData) { + log.info("充值拉卡拉回调开始........"); + // 转换请求参数为 Map + Map paramMap = JSONObject.parseObject(callbackData, Map.class); + String msg = ""; + try { + ResponseData responseData = rechargeOrderService.rechargeLakalaNotify(paramMap); + if (responseData.getSuccess()) { + return "SUCCESS"; + } + } catch (Exception e) { + msg = e.getMessage(); + } + return "SUCCESS"; + } + + + + /** + * 设计师调价支付宝回调地址 + */ + @ApiOperation("设计师调价支付宝回调地址") + @RequestMapping(value = "/orderAdjustPricePayAliNotify", method = RequestMethod.POST) + public void orderAdjustPricePayAliNotify(HttpServletRequest request, HttpServletResponse response) { + log.info("设计师调价支付宝回调开始........"); + try { + ResponseData responseData = orderService.orderAdjustPricePayAliNotify(request, response); + if (responseData.getSuccess()) { + businessUtil.writeText(response, "success"); + } + + } catch (Exception e) { + e.getMessage(); + } + } + + /** + * 设计师调价微信回调地址 + */ + @ApiOperation("设计师调价微信回调地址") + @RequestMapping(value = "/orderAdjustPricePayWxNotify", method = RequestMethod.POST) + public void orderAdjustPricePayWxNotify(HttpServletRequest request, HttpServletResponse response) { + log.info("设计师调价微信回调开始........"); + String msg = ""; + try { + ResponseData responseData = orderService.orderAdjustPricePayWxNotify(request, response); + if (responseData.getSuccess()) { + String resultMsg = String.format("", + ("SUCCESS"), msg); + businessUtil.writeText(response, resultMsg); + } + } catch (Exception e) { + msg = e.getMessage(); + } + } + + @ApiOperation("设计师调价拉卡拉回调地址") + @RequestMapping(value = "/orderAdjustPricePayLakalaNotify", method = RequestMethod.POST) + public String orderAdjustPricePayLakalaNotify(@RequestBody String callbackData) { + log.info("设计师调价拉卡拉回调开始........"); + // 转换请求参数为 Map + Map paramMap = JSONObject.parseObject(callbackData, Map.class); + String msg = ""; + try { + ResponseData responseData = orderService.orderAdjustPricePayLakalaNotify(paramMap); + if (responseData.getSuccess()) { + return "SUCCESS"; + } + } catch (Exception e) { + msg = e.getMessage(); + } + return "SUCCESS"; + } + + + /** + * 表现师调价设计师确认支付宝回调地址 + */ + @ApiOperation("表现师调价设计师确认支付宝回调地址") + @RequestMapping(value = "/orderAdjustPriceConfirmPayAliNotify", method = RequestMethod.POST) + public void orderAdjustPriceConfirmPayAliNotify(HttpServletRequest request, HttpServletResponse response) { + log.info("表现师调价设计师确认支付宝回调地址开始........"); + String msg = ""; + try { + ResponseData responseData = orderService.orderAdjustPriceConfirmPayAliNotify(request, response); + if (responseData.getSuccess()) { + businessUtil.writeText(response, "success"); + } + + } catch (Exception e) { + e.getMessage(); + } + } + + /** + * 表现师调价设计师确认微信回调地址 + */ + @ApiOperation("表现师调价设计师确认微信回调地址") + @RequestMapping(value = "/orderAdjustPriceConfirmPayWxNotify", method = RequestMethod.POST) + public void orderAdjustPriceConfirmPayWxNotify(HttpServletRequest request, HttpServletResponse response) { + log.info("表现师调价设计师确认微信回调地址开始........"); + String msg = ""; + try { + ResponseData responseData = orderService.orderAdjustPriceConfirmPayWxNotify(request, response); + if (responseData.getSuccess()) { + String resultMsg = String.format("", + ("SUCCESS"), msg); + businessUtil.writeText(response, resultMsg); + } + } catch (Exception e) { + msg = e.getMessage(); + } + } + + @ApiOperation("表现师调价设计师确认拉卡拉回调地址") + @RequestMapping(value = "/orderAdjustPriceConfirmPayLakalaNotify", method = RequestMethod.POST) + public String orderAdjustPriceConfirmPayLakalaNotify(@RequestBody String callbackData) { + + log.info("表现师调价设计师确认拉卡拉回调开始........"); + // 转换请求参数为 Map + Map paramMap = JSONObject.parseObject(callbackData, Map.class); + String msg = ""; + try { + ResponseData responseData = orderService.orderAdjustPriceConfirmPayLakalaNotify(paramMap); + if (responseData.getSuccess()) { + return "SUCCESS"; + } + } catch (Exception e) { + msg = e.getMessage(); + } + return "SUCCESS"; + } +} + + diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/ApiPlatformAnswerController.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/ApiPlatformAnswerController.java new file mode 100644 index 0000000..4e00084 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/ApiPlatformAnswerController.java @@ -0,0 +1,76 @@ +package com.ruoyi.controller; + +import cn.hutool.core.util.ObjectUtil; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.ruoyi.code.PublicCommon; +import com.ruoyi.common.page.PageResult; +import com.ruoyi.controller.req.AnswerPageReq; +import com.ruoyi.frequency.platformanswer.entity.PlatformAnswer; +import com.ruoyi.frequency.platformanswer.service.PlatformAnswerService; +import com.ruoyi.frequency.platformanswertype.entity.PlatformAnswerType; +import com.ruoyi.frequency.platformanswertype.service.PlatformAnswerTypeService; +import com.ruoyi.response.ResponseData; +import com.ruoyi.vo.BodyIdReq; +import com.ruoyi.vo.RyController; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import javax.validation.Valid; +import javax.validation.constraints.NotNull; +import java.util.List; + +/** + * 有问必答 + */ +@CrossOrigin +@RestController +@RequestMapping("/api/answer") +@Api(tags = "有问必答") +public class ApiPlatformAnswerController extends RyController { + + + @Autowired + private PlatformAnswerService platformAnswerService; + + @Autowired + private PlatformAnswerTypeService platformAnswerTypeService; + + @PostMapping("/answerTypeList/{userType}") + @ApiOperation(value = "有问必答分类", notes = "有问必答分类") + public ResponseData> answerTypeList(@PathVariable Integer userType) { + List list = platformAnswerTypeService.list(new QueryWrapper().lambda() + .eq(PlatformAnswerType::getDelFlag, PublicCommon.启用) + .eq(PlatformAnswerType::getUserType,userType) + .orderByAsc(PlatformAnswerType::getSort)); + return ResponseData.success(list); + } + + @PostMapping("/answerPage") + @ApiOperation(value = "有问必答", notes = "有问必答") + public ResponseData> answerPage(@RequestBody AnswerPageReq req) { + Page page = platformAnswerService.page(new Page<>(req.getPageNo(),req.getPageSize()),new QueryWrapper().lambda() + .eq(PlatformAnswer::getDelFlag, PublicCommon.启用) + .eq(PlatformAnswer::getUserType,req.getUserType()) + .eq(ObjectUtil.isNotEmpty(req.getPlatformAnswerTypeId()),PlatformAnswer::getPlatformAnswerTypeId,req.getPlatformAnswerTypeId()) + .orderByAsc(PlatformAnswer::getSort)); + return ResponseData.success(new PageResult<>(page)); + } + + + @PostMapping("/detail") + @ApiOperation(value = "有问必答详情", notes = "有问必答详情") + public ResponseData detail(@Valid @NotNull(message = "id不能为空") @RequestBody BodyIdReq req) { + PlatformAnswer platformAnswer = this.platformAnswerService.getById(req.getId()); + PlatformAnswerType platformAnswerType = platformAnswerTypeService.getById(platformAnswer.getPlatformAnswerTypeId()); + platformAnswer.setPlatformAnswerTypeName(platformAnswerType.getName()); + //修改浏览数 + platformAnswerService.lambdaUpdate().setSql("browse_num = browse_num + 1") + .eq(PlatformAnswer::getId,req.getId()).update(); + + return ResponseData.success(platformAnswer); + } + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/ApiPlatformRulesController.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/ApiPlatformRulesController.java new file mode 100644 index 0000000..6f54b38 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/ApiPlatformRulesController.java @@ -0,0 +1,73 @@ +package com.ruoyi.controller; + +import cn.hutool.core.util.ObjectUtil; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.ruoyi.code.PublicCommon; +import com.ruoyi.common.page.PageResult; +import com.ruoyi.controller.req.PlatformRulesPageReq; +import com.ruoyi.frequency.platformrules.entity.PlatformRules; +import com.ruoyi.frequency.platformrules.service.PlatformRulesService; +import com.ruoyi.frequency.platformrulestype.entity.PlatformRulesType; +import com.ruoyi.frequency.platformrulestype.service.PlatformRulesTypeService; +import com.ruoyi.response.ResponseData; +import com.ruoyi.vo.BodyIdReq; +import com.ruoyi.vo.RyController; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import javax.validation.Valid; +import java.util.List; + +@CrossOrigin +@RestController +@RequestMapping("/api/platformRules") +@Api(tags = "平台规则") +public class ApiPlatformRulesController extends RyController { + + @Autowired + private PlatformRulesService platformRulesService; + + + @Autowired + private PlatformRulesTypeService platformRulesTypeService; + + @PostMapping("/rulesTypeList/{userType}") + @ApiOperation(value = "平台规则分类列表", notes = "平台规则分类列表") + public ResponseData> rulesTypeList(@PathVariable Integer userType) { + List list = platformRulesTypeService.list(new QueryWrapper().lambda() + .eq(PlatformRulesType::getDelFlag, PublicCommon.启用) + .eq(PlatformRulesType::getUserType, userType) + .orderByAsc(PlatformRulesType::getSort)); + return ResponseData.success(list); + } + + @PostMapping("/platformRulesPage") + @ApiOperation(value = "平台规则列表", notes = "平台规则列表") + public ResponseData> platformRulesPage(@RequestBody PlatformRulesPageReq req) { + Page page = platformRulesService.page(new Page<>(req.getPageNo(), req.getPageSize()), new QueryWrapper().lambda() + .eq(PlatformRules::getUserType, req.getUserType()) + .eq(PlatformRules::getDelFlag, PublicCommon.启用) + .eq(ObjectUtil.isNotEmpty(req.getPlatformRulesTypeId()), PlatformRules::getPlatformRulesTypeId, req.getPlatformRulesTypeId()) + .orderByAsc(PlatformRules::getSort) + ); + if (page.getRecords().size() > 0) { + page.getRecords().stream().forEach(s -> s.setContent("")); + } + return ResponseData.success(new PageResult<>(page)); + } + + @PostMapping("/platformRulesDetail") + @ApiOperation(value = "平台规则详情", notes = "平台规则详情") + public ResponseData appealDetail(@RequestBody @Valid BodyIdReq req) { + PlatformRules platformRules = platformRulesService.getById(req.getId()); + PlatformRulesType platformRulesType = platformRulesTypeService.getById(platformRules.getPlatformRulesTypeId()); + if (platformRulesType != null) { + platformRules.setPlatformRulesTypeName(platformRulesType.getName()); + } + return ResponseData.success(platformRules); + } + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/ApiPostController.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/ApiPostController.java new file mode 100644 index 0000000..bc450c1 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/ApiPostController.java @@ -0,0 +1,109 @@ +package com.ruoyi.controller; + +import cn.hutool.core.util.ObjectUtil; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.ruoyi.annotations.UserLoginToken; +import com.ruoyi.common.page.PageResult; +import com.ruoyi.enums.user.UserEnums; +import com.ruoyi.frequency.auth.service.AuthService; +import com.ruoyi.frequency.highendauth.service.HighendAuthService; +import com.ruoyi.post.controller.req.PostPageReq; +import com.ruoyi.post.controller.req.PostReleaseReq; +import com.ruoyi.post.controller.resp.PostDetailResp; +import com.ruoyi.post.controller.resp.PostPageResp; +import com.ruoyi.post.frequency.post.service.PostService; +import com.ruoyi.response.ResponseData; +import com.ruoyi.utils.BusinessUtil; +import com.ruoyi.vo.BodyIdReq; +import com.ruoyi.vo.RyController; +import com.ruoyi.vo.UserInfo; +import com.ruoyi.vo.UserVo; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + + +/** + * 帖子相关 + * + * @author liwenlong + */ +@CrossOrigin +@RestController +@RequestMapping("/api/post") +@Api(tags = "帖子相关") +public class ApiPostController extends RyController { + + @Autowired + private PostService postService; + + @Autowired + private AuthService authService; + + @Autowired + private HighendAuthService highendAuthService; + + @Autowired + private BusinessUtil businessUtil; + + @UserLoginToken + @PostMapping("/postRelease") + @ApiOperation(value = "帖子发布", notes = "帖子发布") + public ResponseData postRelease(@RequestBody PostReleaseReq req) { + + UserVo userVo = getUserVo(); + + //判断表现师是否认证 + if (ObjectUtil.equal(UserEnums.store.getCode(), userVo.getUserType())) { + UserInfo userInfo = businessUtil.getUserInfo(userVo); + if (userInfo == null && userInfo.getIsAuth() != 2 && userInfo.getIfHighend() != 2 && userInfo.getIsKujialeAuth() != 2) { + return ResponseData.error("清先进行平台认证或高端认证"); + } + } + + return postService.postRelease(req, userVo); + } + + @ApiOperation(value = "帖子列表", notes = "帖子列表") + @PostMapping("/postPage") + public ResponseData>> postPage(@RequestBody PostPageReq req) { + return postService.postPage(req, getUserVo()); + } + + @ApiOperation(value = "帖子列表(自己查看)", notes = "帖子列表(自己查看)") + @PostMapping("/postPageBySelf") + public ResponseData>> postPageBySelf(@RequestBody PostPageReq req) { + UserVo userVo = getUserVo(); + req.setUserId(userVo.getUserId()); + req.setUserType(userVo.getUserType()); + + return postService.postPage(req, userVo); + } + + @ApiOperation(value = "帖子列表(他人查看)", notes = "帖子列表(他人查看)") + @PostMapping("/postPageByOtherSelf") + public ResponseData>> postPageByOtherSelf(@RequestBody PostPageReq req) { + return postService.postPage(req, getUserVo()); + } + + + @PostMapping("/postDetail") + @ApiOperation(value = "帖子详情", notes = "帖子详情") + public ResponseData postDetail(@RequestBody BodyIdReq req) { + return postService.postDetail(req.getId(), req.getIsAddBrowseNum(), getUserVo()); + } + + @PostMapping("/postEdit") + @ApiOperation(value = "帖子编辑", notes = "帖子编辑") + public ResponseData postEdit(@RequestBody PostReleaseReq req) { + return postService.postEdit(req, getUserVo()); + } + + @PostMapping("/postDelete") + @ApiOperation(value = "帖子删除", notes = "帖子删除") + public ResponseData postDelete(@RequestBody BodyIdReq req) { + return postService.postDelete(req.getId(), getUserVo()); + } + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/ApiRechargeOrderController.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/ApiRechargeOrderController.java new file mode 100644 index 0000000..5dfac82 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/ApiRechargeOrderController.java @@ -0,0 +1,56 @@ +package com.ruoyi.controller; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.ruoyi.annotations.UserLoginToken; +import com.ruoyi.code.PublicCommon; +import com.ruoyi.controller.req.RechargeOrderReq; +import com.ruoyi.frequency.rechargecoin.entity.RechargeCoin; +import com.ruoyi.frequency.rechargecoin.service.RechargeCoinService; +import com.ruoyi.frequency.rechargeorder.service.RechargeOrderService; +import com.ruoyi.response.ResponseData; +import com.ruoyi.vo.RyController; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +/** + * 充值 + * @author ly + */ +@CrossOrigin +@RestController +@RequestMapping("/api/rechargeOrder") +@Api(tags = "充值") +public class ApiRechargeOrderController extends RyController { + + + @Autowired + private RechargeOrderService rechargeOrderService; + + @Autowired + private RechargeCoinService rechargeCoinService; + + @UserLoginToken + @PostMapping("/rechargeOrder") + @ApiOperation(value = "充值余额") + public ResponseData rechargeOrder(@RequestBody RechargeOrderReq req) { + return rechargeOrderService.rechargeOrder(req, getUserVo()); + } + + + @RequestMapping(value = "/list", method = RequestMethod.POST) + @ApiOperation(value = "充值列表") + public ResponseData list(@RequestBody(required = false) Integer type) { + if (type == null) { + type = 1; + } + List list = rechargeCoinService.list(new QueryWrapper().lambda(). + eq(RechargeCoin::getPhoneType, type). + eq(RechargeCoin::getDelFlag, PublicCommon.启用).orderByAsc(RechargeCoin::getPrice)); + return ResponseData.success(list); + } + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/ApiSaleController.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/ApiSaleController.java new file mode 100644 index 0000000..55e310b --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/ApiSaleController.java @@ -0,0 +1,166 @@ +package com.ruoyi.controller; + +import cn.hutool.core.date.DateUtil; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.ruoyi.code.DictConstant; +import com.ruoyi.code.PublicCommon; +import com.ruoyi.common.page.PageResult; +import com.ruoyi.controller.req.SaleDetailPageReq; +import com.ruoyi.controller.resp.HomeDataResp; +import com.ruoyi.controller.resp.RankingResp; +import com.ruoyi.controller.resp.SaleDataResp; +import com.ruoyi.controller.resp.SaleDetailPageResp; +import com.ruoyi.frequency.customer.entity.Customer; +import com.ruoyi.frequency.customer.service.CustomerService; +import com.ruoyi.frequency.order.service.OrderService; +import com.ruoyi.frequency.sale.entity.Sale; +import com.ruoyi.frequency.sale.mapper.SaleMapper; +import com.ruoyi.frequency.sale.service.SaleService; +import com.ruoyi.frequency.store.entity.Store; +import com.ruoyi.frequency.store.service.StoreService; +import com.ruoyi.frequency.wallerecord.mapper.WalletRecordMapper; +import com.ruoyi.frequency.withdrawalrecord.mapper.WithdrawalRecordMapper; +import com.ruoyi.response.ResponseData; +import com.ruoyi.utils.BusinessUtil; +import com.ruoyi.vo.PageBasic; +import com.ruoyi.vo.RyController; +import com.ruoyi.vo.UserVo; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import java.math.BigDecimal; +import java.util.Date; + +/** + * 推广员端 + * + * @author liwenlong + * @date 2023-10-12 + */ +@CrossOrigin +@RestController +@RequestMapping("/api/sale") +@Api(tags = "推广员端") +public class ApiSaleController extends RyController { + @Autowired + private BusinessUtil businessUtil; + + @Autowired + private CustomerService customerService; + + @Autowired + private StoreService storeService; + + @Autowired + private SaleService saleService; + + @Autowired + private OrderService orderService; + + + @PostMapping("/homeData") + @ApiOperation(value = "首页数据", notes = "首页数据") + public ResponseData homeData() { + + UserVo userVo = getUserVo(); + HomeDataResp homeDataResp = new HomeDataResp(); + + //平台设置比例系数 + Integer scale = Integer.valueOf(businessUtil.getDict(DictConstant.平台设置比例系数).getDictValue()); + + //查询入驻设计师 + int customerNum = customerService.count(new QueryWrapper().lambda() + .ne(Customer::getDelFlag, PublicCommon.删除)); + homeDataResp.setCustomerNum(customerNum * scale); + + //查询入驻技术 + int storeNum = storeService.count(new QueryWrapper().lambda() + .ne(Store::getDelFlag, PublicCommon.删除)); + homeDataResp.setStoreNum(storeNum * scale); + + //查询入驻推广员 + int saleNum = saleService.count(new QueryWrapper().lambda() + .ne(Sale::getDelFlag, PublicCommon.删除)); + homeDataResp.setSaleNum(saleNum * scale); + + //佣金排名 + Integer commissionRanking = saleService.commissionRanking(userVo); + homeDataResp.setCommissionRanking(commissionRanking); + + //推广排名 + Integer saleRanking = saleService.saleRanking(userVo); + homeDataResp.setSaleRanking(saleRanking); + + //推广邀请码 + Sale sale = saleService.getById(userVo.getUserId()); + if (sale != null) { + homeDataResp.setInviteCode(sale.getInviteCode()); + homeDataResp.setAvatar(sale.getAvatar()); + homeDataResp.setNickname(sale.getNickname()); + homeDataResp.setName(sale.getName()); + homeDataResp.setInviteNum(sale.getInviteNum()); + homeDataResp.setIncome(sale.getIncome()); + } + + return ResponseData.success(homeDataResp); + } + + @PostMapping("/commissionRankingPage") + @ApiOperation(value = "佣金排名列表", notes = "佣金排名列表") + public ResponseData>> commissionRankingPage(@RequestBody PageBasic req) { + return saleService.commissionRankingPage(req, getUserVo()); + } + + @PostMapping("/saleRankingPage") + @ApiOperation(value = "推广人数排名列表", notes = "推广人数排名列表") + public ResponseData>> saleRankingPage(@RequestBody PageBasic req) { + return saleService.saleRankingPage(req, getUserVo()); + } + + + @PostMapping("/saleDetailPage") + @ApiOperation(value = "明细", notes = "明细") + public ResponseData>> saleDetailPage(@RequestBody SaleDetailPageReq req) { + return saleService.saleDetailPage(req, getUserVo()); + } + + + @Autowired + private SaleMapper saleMapper; + + @Autowired + private WalletRecordMapper walletRecordMapper; + + @Autowired + private WithdrawalRecordMapper withdrawalRecordMapper; + + @PostMapping("/saleData") + @ApiOperation(value = "我的页面数据", notes = "我的页面数据") + public ResponseData saleData() { + + UserVo userVo = getUserVo(); + + Sale sale = saleService.getById(userVo.getUserId()); + + SaleDataResp saleDataResp = saleMapper.saleOrderAmount(sale.getId()); + saleDataResp.setNum(sale.getInviteNum()); + saleDataResp.setIncome(sale.getIncome()); + saleDataResp.setBalance(sale.getBalance()); + //可提现金额(去除本月收益) + //获取本月开始时间 + Date beginOfMonth = DateUtil.beginOfMonth(new Date()); + + BigDecimal withdrawableAmount = walletRecordMapper.selectMonthBeforeAmount(beginOfMonth, userVo); + saleDataResp.setWithdrawableAmount(withdrawableAmount.compareTo(BigDecimal.ZERO) == 1 ? withdrawableAmount : BigDecimal.ZERO); + + //已提现金额 + BigDecimal withdrawnAmount = withdrawalRecordMapper.withdrawnAmount(userVo); + saleDataResp.setWithdrawnAmount(withdrawnAmount); + + return ResponseData.success(saleDataResp); + } + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/ApiSearchController.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/ApiSearchController.java new file mode 100644 index 0000000..f5e0b5b --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/ApiSearchController.java @@ -0,0 +1,137 @@ +package com.ruoyi.controller; + +import cn.hutool.core.util.ObjectUtil; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.ruoyi.code.PublicCommon; +import com.ruoyi.common.core.domain.BaseEntity; +import com.ruoyi.common.page.PageResult; +import com.ruoyi.controller.req.*; +import com.ruoyi.enums.order.OrderStatusEnums; +import com.ruoyi.frequency.hosearch.entity.HotSearch; +import com.ruoyi.frequency.hosearch.service.HotSearchService; +import com.ruoyi.frequency.order.service.OrderService; +import com.ruoyi.frequency.works.service.WorksService; +import com.ruoyi.frequency.workstype.service.WorksTypeService; +import com.ruoyi.post.controller.req.PostPageReq; +import com.ruoyi.post.frequency.post.service.PostService; +import com.ruoyi.post.frequency.posttype.entity.PostType; +import com.ruoyi.response.ResponseData; +import com.ruoyi.utils.SnowIdUtils; +import com.ruoyi.vo.RyController; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +/** + * 搜索 + * + * @author liwenlong + * @date 2023-10-12 + */ +@CrossOrigin +@RestController +@RequestMapping("/api/search") +@Api(tags = "搜索") +public class ApiSearchController extends RyController +{ + + @Autowired + private WorksService worksService; + + @Autowired + private WorksTypeService worksTypeService; + + @Autowired + private PostService postService; + + @Autowired + private OrderService orderService; + + + @PostMapping("/searchPage") + @ApiOperation(value = "搜索", notes = "搜索") + public ResponseData searchPage(@RequestBody SearchPageReq req) { + + ResponseData responseData = new ResponseData(); + + //类型 1作品库 2绘图员 3论坛 4订单 + switch (req.getType()){ + case 1: + + WorksPageReq worksPageReq = new WorksPageReq(); + worksPageReq.setKeyword(req.getKeyword()); + worksPageReq.setPageNo(req.getPageNo()); + worksPageReq.setPageSize(req.getPageSize()); + worksPageReq.setShowEnterprise(2); + responseData = worksService.worksPage(worksPageReq,getUserVo()); + break; + case 2: + StorePageReq storePageReq = new StorePageReq(); + storePageReq.setKeyword(req.getKeyword()); + storePageReq.setPageNo(req.getPageNo()); + storePageReq.setPageSize(req.getPageSize()); + responseData = worksTypeService.storePage(storePageReq, getUserVo()); + break; + case 3: + PostPageReq postPageReq = new PostPageReq(); + postPageReq.setKeyword(req.getKeyword()); + postPageReq.setPageNo(req.getPageNo()); + postPageReq.setPageSize(req.getPageSize()); + responseData = postService.postPage(postPageReq,getUserVo()); + break; + case 4: + OrderPageReq orderPageReq = new OrderPageReq(); + orderPageReq.setKeyword(req.getKeyword()); + + orderPageReq.setStatus(OrderStatusEnums.to_be_confirm.getCode()); + + orderPageReq.setIsHall(true); + + orderPageReq.setPageNo(req.getPageNo()); + orderPageReq.setPageSize(req.getPageSize()); + + responseData = orderService.orderPage(orderPageReq,getUserVo()); + break; + default: + return ResponseData.success(); + } + + //记录搜索 + if (ObjectUtil.isNotEmpty(req.getKeyword())){ + HotSearch hotSearch = new HotSearch() + .setId(SnowIdUtils.uniqueLong()) + .setSearchTerm(req.getKeyword()); + hotSearch.setCreateData(); + hotSearch.setUpdateData(); + + //判断是否搜索出结果 + + Boolean isSuccess = false; + if(responseData.getData() != null){ + PageResult pageResult = (PageResult)responseData.getData(); + if (pageResult != null && pageResult.getRows().size() > 0){ + isSuccess = true; + } + } + + hotSearchService.addHotSearch(hotSearch,isSuccess); + } + + return responseData; + + } + + @Autowired + private HotSearchService hotSearchService; + + @PostMapping("/hotSearchList") + @ApiOperation(value = "热门搜索记录", notes = "热门搜索记录") + public ResponseData hotSearchList(@RequestBody HotSearchListReq req) { + List list = hotSearchService.hotSearchList(req); + return ResponseData.success(list); + } +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/ApiShoppingCarController.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/ApiShoppingCarController.java new file mode 100644 index 0000000..8fdff50 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/ApiShoppingCarController.java @@ -0,0 +1,65 @@ +package com.ruoyi.controller; + +import com.ruoyi.annotations.UserLoginToken; +import com.ruoyi.controller.req.InsertShoppingCarReq; +import com.ruoyi.controller.req.ShoppingCarCreateOrderReq; +import com.ruoyi.controller.req.ShoppingCartSettlementReq; +import com.ruoyi.frequency.mallshoppingcar.service.MallShoppingCarService; +import com.ruoyi.response.ResponseData; +import com.ruoyi.vo.RyController; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import javax.validation.Valid; +import javax.validation.constraints.NotEmpty; +import java.util.List; + +@CrossOrigin +@RestController +@RequestMapping("/api/goods") +@Api(tags = "购物车") +public class ApiShoppingCarController extends RyController { + + + @Autowired + private MallShoppingCarService shoppingCarService; + + @UserLoginToken + @RequestMapping(value = "/shoppingCarList", method = RequestMethod.POST) + @ApiOperation(value = "购物车列表") + public ResponseData shoppingCarList() { + return shoppingCarService.shoppingCarList(getUserVo()); + } + + @UserLoginToken + @RequestMapping(value = "/shoppingCarSettlement", method = RequestMethod.POST) + @ApiOperation(value = "购物车订单结算") + public ResponseData shoppingCarSettlement(@RequestBody ShoppingCartSettlementReq req) { + return ResponseData.success(shoppingCarService.shoppingCarSettlement(req,getUserVo())); + } + + @UserLoginToken + @RequestMapping(value = "/insertShoppingCar", method = RequestMethod.POST) + @ApiOperation(value = "加入购物车") + public ResponseData insertShoppingCar(@RequestBody InsertShoppingCarReq req) { + return shoppingCarService.insertShoppingCar(req,getUserVo()); + } + + + @UserLoginToken + @RequestMapping(value = "/removeShoppingCarGoods", method = RequestMethod.POST) + @ApiOperation(value = "删除购物车商品") + public ResponseData removeShoppingCarGoods(@Valid @NotEmpty(message = "参数不能为空") @RequestBody List ids) { + return shoppingCarService.removeShoppingCarGoods(ids,getUserVo()); + } + + @UserLoginToken + @RequestMapping(value = "/shoppingCarCreateOrder", method = RequestMethod.POST) + @ApiOperation(value = "购物车创建订单") + public ResponseData shoppingCarCreateOrder(@RequestBody ShoppingCarCreateOrderReq req) { + return shoppingCarService.shoppingCarCreateOrder(req,getUserVo()); + } + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/ApiUserController.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/ApiUserController.java new file mode 100644 index 0000000..a67a17d --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/ApiUserController.java @@ -0,0 +1,449 @@ +package com.ruoyi.controller; + +import cn.hutool.core.date.DateUtil; +import cn.hutool.core.util.ObjectUtil; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.ruoyi.annotations.UserLoginToken; +import com.ruoyi.code.DictConstant; +import com.ruoyi.code.PublicCommon; +import com.ruoyi.common.page.PageResult; +import com.ruoyi.controller.req.*; +import com.ruoyi.controller.resp.*; +import com.ruoyi.enums.order.OrderStatusEnums; +import com.ruoyi.enums.user.UserEnums; +import com.ruoyi.frequency.advertisingimages.entity.AdvertisingImages; +import com.ruoyi.frequency.advertisingimages.service.AdvertisingImagesService; +import com.ruoyi.frequency.block.entity.Block; +import com.ruoyi.frequency.block.service.BlockService; +import com.ruoyi.frequency.browserecord.entity.BrowseRecord; +import com.ruoyi.frequency.browserecord.service.BrowseRecordService; +import com.ruoyi.frequency.collect.service.CollectService; +import com.ruoyi.frequency.customer.entity.Customer; +import com.ruoyi.frequency.customer.service.CustomerService; +import com.ruoyi.frequency.customer.service.UserService; +import com.ruoyi.frequency.enterprise.entity.Enterprise; +import com.ruoyi.frequency.enterprise.service.EnterpriseService; +import com.ruoyi.frequency.follow.entity.Follow; +import com.ruoyi.frequency.follow.service.FollowService; +import com.ruoyi.frequency.givewallerecord.service.GiveWalletRecordService; +import com.ruoyi.frequency.illegaldeductionrecord.service.IllegalDeductionRecordService; +import com.ruoyi.frequency.order.entity.Order; +import com.ruoyi.frequency.order.mapper.OrderMapper; +import com.ruoyi.frequency.order.service.OrderService; +import com.ruoyi.frequency.refereeuser.entity.RefereeUser; +import com.ruoyi.frequency.refereeuser.service.RefereeUserService; +import com.ruoyi.frequency.sale.entity.Sale; +import com.ruoyi.frequency.sale.service.SaleService; +import com.ruoyi.frequency.shield.entity.Shield; +import com.ruoyi.frequency.shield.service.ShieldService; +import com.ruoyi.frequency.store.entity.Store; +import com.ruoyi.frequency.store.service.StoreService; +import com.ruoyi.frequency.wallerecord.mapper.WalletRecordMapper; +import com.ruoyi.frequency.wallerecord.service.WalletRecordService; +import com.ruoyi.frequency.withdrawalrecord.mapper.WithdrawalRecordMapper; +import com.ruoyi.frequency.works.entity.Works; +import com.ruoyi.frequency.works.service.WorksService; +import com.ruoyi.frequency.workstype.service.WorksTypeService; +import com.ruoyi.post.frequency.post.entity.Post; +import com.ruoyi.post.frequency.post.service.PostService; +import com.ruoyi.response.ResponseData; +import com.ruoyi.utils.BusinessUtil; +import com.ruoyi.vo.BodyIdReq; +import com.ruoyi.vo.RyController; +import com.ruoyi.vo.UserInfo; +import com.ruoyi.vo.UserVo; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import javax.validation.Valid; +import java.math.BigDecimal; +import java.util.Date; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.stream.Collectors; + +/** + * 用户相关(表现师(技术)列表,余额) + */ +@CrossOrigin +@RestController +@RequestMapping("/api/user") +@Api(tags = "用户相关(表现师(技术)列表,余额)))") +public class ApiUserController extends RyController { + + @Autowired + private WorksTypeService worksTypeService; + + @Autowired + private CustomerService customerService; + + @Autowired + private StoreService storeService; + + @Autowired + private SaleService saleService; + + @Autowired + private FollowService followService; + + @Autowired + private PostService postService; + + @Autowired + private OrderService orderService; + + @Autowired + private CollectService collectService; + + @Autowired + private WorksService worksService; + + @Autowired + private BlockService blockService; + + @Autowired + private ShieldService shieldService; + + @Autowired + private BrowseRecordService browseRecordService; + + @Autowired + private EnterpriseService enterpriseService; + + + @PostMapping("/storePage") + @ApiOperation(value = "表现师(技术)/企业列表", notes = "表现师(技术)/企业列表") + public ResponseData>> storePage(@Valid @RequestBody StorePageReq req) { + + //是否是企业: 1不是 2企业 + switch (req.getIsWorkingDrawing()) { + case 1: + return worksTypeService.storePage(req, getUserVo()); + case 2: + return enterpriseService.enterprisePage(req, getUserVo()); + default: + return ResponseData.error(String.format("isWorkingDrawing参数错误: %s", req.getIsWorkingDrawing())); + } + } + + + @PostMapping("/userData") + @UserLoginToken + @ApiOperation(value = "我的页面用户数据", notes = "我的页面用户数据") + public ResponseData userData() { + + UserVo userVo = getUserVo(); + + UserDataResp userDataResp = userData(userVo); + + return ResponseData.success(userDataResp); + } + + @PostMapping("/otherUserData") + @ApiOperation(value = "他人查看我的页面用户数据", notes = "我的页面用户数据") + public ResponseData otherUserData(@RequestBody UserVo userVo) { + UserDataResp userDataResp = userData(userVo); + return ResponseData.success(userDataResp); + } + + @Autowired + private RefereeUserService refereeUserService; + + @Autowired + private BusinessUtil businessUtil; + + @Autowired + private OrderMapper orderMapper; + + private UserDataResp userData(UserVo userVo) { + + UserDataResp userDataResp = new UserDataResp(); + + //用户类型 1设计师 2表现师 3销售(推广员) + if (ObjectUtil.equal(userVo.getUserType(), PublicCommon.设计师)) { + Customer customer = customerService.getById(userVo.getUserId()); + userDataResp.setBalance(customer.getBalance()); + userDataResp.setAmount(customer.getConsumptionAmount()); + userDataResp.setOnlineDuration(customer.getOnlineDuration()); + userDataResp.setStar(customer.getStar()); + userDataResp.setIntegral(customer.getIntegral()); + userDataResp.setAccumulateIntegral(customer.getAccumulateIntegral()); + } else if (ObjectUtil.equal(userVo.getUserType(), PublicCommon.表现师)) { + Store store = storeService.getById(userVo.getUserId()); + userDataResp.setBalance(store.getBalance()); + userDataResp.setAmount(store.getIncome()); + userDataResp.setOnlineDuration(store.getOnlineDuration()); + userDataResp.setStar(store.getStar()); + userDataResp.setIntegral(store.getIntegral()); + userDataResp.setAccumulateIntegral(store.getAccumulateIntegral()); + + //本月收益 + Date beginOfMonth = DateUtil.beginOfMonth(new Date()); + BigDecimal monthAmount = orderMapper.selectMonthBeforeAmount(beginOfMonth, userVo); + userDataResp.setMonthAmount(monthAmount); + } else if (ObjectUtil.equal(userVo.getUserType(), PublicCommon.销售)) { + Sale sale = saleService.getById(userVo.getUserId()); + userDataResp.setBalance(sale.getBalance()); + } else if (ObjectUtil.equal(userVo.getUserType(), PublicCommon.企业)) { + Enterprise enterprise = enterpriseService.getById(userVo.getUserId()); + userDataResp.setStar(enterprise.getStar()); + userDataResp.setAmount(enterprise.getServiceAmount()); + userDataResp.setOrderNum(enterprise.getServiceOrderNum()); + } + + + //作品数 + LambdaQueryWrapper lambdaQueryWrapper = new QueryWrapper().lambda() + .eq(Works::getDelFlag, PublicCommon.启用) + .ne(Works::getIsHide, 2); + if (UserEnums.customer.getCode().equals(userVo.getUserType())) { + + lambdaQueryWrapper.eq(Works::getCustomerId, userVo.getUserId()); + } else if (UserEnums.store.getCode().equals(userVo.getUserType())) { + + lambdaQueryWrapper.eq(Works::getStoreId, userVo.getUserId()) + .eq(Works::getUserType, userVo.getUserType()); + } else if (UserEnums.enterprise.getCode().equals(userVo.getUserType())) { + + lambdaQueryWrapper.eq(Works::getStoreId, userVo.getUserId()) + .eq(Works::getUserType, userVo.getUserType()); + } + int worksNum = worksService.count(lambdaQueryWrapper); + userDataResp.setWorksNum(worksNum); + + //粉丝数 + int fansNum = followService.count(new QueryWrapper().lambda() + .eq(Follow::getDelFlag, PublicCommon.启用) + .eq(Follow::getFollowerUserType, userVo.getUserType()) + .eq(Follow::getFollowerUserId, userVo.getUserId())); + userDataResp.setFansNum(fansNum); + + //动态数 + int postNum = postService.count(new QueryWrapper().lambda() + .eq(Post::getDelFlag, PublicCommon.启用) + .eq(Post::getUserType, userVo.getUserType()) + .eq(Post::getUserId, userVo.getUserId())); + userDataResp.setPostNum(postNum); + + //收藏数 + CollectPageReq req = new CollectPageReq(); + req.setPageNo(1); + req.setPageSize(1); + req.setUserId(userVo.getUserId()); + req.setUserType(userVo.getUserType()); + + //收藏作品数 + req.setType(1); + userDataResp.setCollectWorksNum(collectService.getCollectWorksPage(req,userVo).getTotal()); + + //收藏动态数 + req.setType(2); + userDataResp.setCollectPostNum(collectService.getCollectPostPage(req,userVo).getTotal()); + + //收藏新闻数 + req.setType(4); + userDataResp.setCollectNewsNum(collectService.getCollectNewsPage(req,userVo).getTotal()); + + userDataResp.setCollectNum(userDataResp.getCollectWorksNum()+userDataResp.getCollectPostNum()+userDataResp.getCollectNewsNum()); + + + //关注数 + int followNum = followService.count(new QueryWrapper().lambda() + .eq(Follow::getDelFlag, PublicCommon.启用) + .eq(Follow::getUserType, userVo.getUserType()) + .eq(Follow::getUserId, userVo.getUserId())); + userDataResp.setFollowNum(followNum); + + if (ObjectUtil.notEqual(userVo.getUserType(), PublicCommon.企业)) { + //累计服务单数基数 + Integer num = Integer.valueOf(businessUtil.getDict(DictConstant.OrderDict.累计服务单数基数).getDictValue()); + + //订单数 + int orderNum = orderService.count(new QueryWrapper().lambda() + .eq(Order::getDelFlag, PublicCommon.启用) + .ge(Order::getStatus, OrderStatusEnums.to_be_evaluated.getCode()) + .eq(ObjectUtil.equal(UserEnums.customer.getCode(), userVo.getUserType()), Order::getCustomerId, userVo.getUserId()) + .eq(ObjectUtil.equal(UserEnums.store.getCode(), userVo.getUserType()), Order::getStoreId, userVo.getUserId())); + userDataResp.setOrderNum(orderNum + num); + } + + //拉黑数 + int blockNum = blockService.count(new QueryWrapper().lambda() + .eq(Block::getDelFlag, PublicCommon.启用) + .eq(Block::getUserType, userVo.getUserType()) + .eq(Block::getUserId, userVo.getUserId())); + userDataResp.setBlockNum(blockNum); + + + //屏蔽数 + int shieldNum = shieldService.count(new QueryWrapper().lambda() + .eq(Shield::getDelFlag, PublicCommon.启用) + .eq(Shield::getUserType, userVo.getUserType()) + .eq(Shield::getUserId, userVo.getUserId())); + userDataResp.setShieldNum(shieldNum); + + //浏览数 + int browseNum = browseRecordService.count(new QueryWrapper().lambda() + .eq(BrowseRecord::getDelFlag, PublicCommon.启用) + .eq(BrowseRecord::getType, 1) //浏览类型 1作品 2 动态 + .eq(BrowseRecord::getUserType, userVo.getUserType()) + .eq(BrowseRecord::getUserId, userVo.getUserId())); + userDataResp.setBrowseNum(browseNum); + + //邀请数 + int inviteNum = refereeUserService.count(new QueryWrapper().lambda() + .eq(RefereeUser::getDelFlag, PublicCommon.启用) + .eq(RefereeUser::getParentUserId, userVo.getUserId()) + .eq(RefereeUser::getParentUserType, userVo.getUserType()) + ); + userDataResp.setInviteNum(inviteNum); + + userDataResp.setUserInfo(businessUtil.getUserInfo(userVo)); + return userDataResp; + } + + @Autowired + private UserService userService; + + @Autowired + private WalletRecordMapper walletRecordMapper; + + @Autowired + private WithdrawalRecordMapper withdrawalRecordMapper; + + @PostMapping("/storeAmountData") + @UserLoginToken + @ApiOperation(value = "表现师金额数据", notes = "用户金额数据") + public ResponseData storeAmountData() { + + UserVo userVo = getUserVo(); + + if (userVo.getUserType().equals(UserEnums.customer.getCode()) || userVo.getUserType().equals(UserEnums.sale.getCode())) { + return ResponseData.success(); + } + + if (userVo.getUserType().equals(UserEnums.enterprise.getCode())) { + Store one = storeService.getOne(new QueryWrapper().lambda().eq(Store::getBindEnterpriseId, userVo.getUserId())); + userVo = new UserVo(UserEnums.store.getCode(), one.getId()); + } + + StoreAmountDataResp userAmountDataResp = new StoreAmountDataResp(); + + Store store = storeService.getById(userVo.getUserId()); + + //累计收益 + userAmountDataResp.setIncome(store.getIncome()); + + //可提现金额(去除本月收益) + //获取本月开始时间 + Date beginOfMonth = DateUtil.beginOfMonth(new Date()); + + BigDecimal withdrawableAmount = walletRecordMapper.selectMonthBeforeAmount(beginOfMonth, userVo); + userAmountDataResp.setWithdrawableAmount(withdrawableAmount.compareTo(BigDecimal.ZERO) == 1 ? withdrawableAmount : BigDecimal.ZERO); + + //已提现金额 + BigDecimal withdrawnAmount = withdrawalRecordMapper.withdrawnAmount(userVo); + userAmountDataResp.setWithdrawnAmount(withdrawnAmount); + + //待提现金额 + userAmountDataResp.setToBeWithdrawnAmount(store.getBalance().subtract(userAmountDataResp.getWithdrawableAmount())); + + //扣款 + userAmountDataResp.setViolationDeduction(store.getViolationDeduction()); + + return ResponseData.success(userAmountDataResp); + } + + @Autowired + private WalletRecordService walletRecordService; + + @Autowired + private GiveWalletRecordService giveWalletRecordService; + + + @PostMapping("/giveWalletPage") + @UserLoginToken + @ApiOperation(value = "抵用金明细", notes = "抵用金明细") + public ResponseData giveWalletPage(@RequestBody WalletPageReq req) { + return giveWalletRecordService.giveWalletPage(req, getUserVo()); + } + + @PostMapping("/walletPage") + @UserLoginToken + @ApiOperation(value = "钱包明细", notes = "钱包明细") + public ResponseData walletPage(@RequestBody WalletPageReq req) { + return walletRecordService.walletPage(req, getUserVo()); + } + + @PostMapping("/expenditurePage") + @UserLoginToken + @ApiOperation(value = "支出明细", notes = "支出明细") + public ResponseData expenditurePage(@RequestBody WalletPageReq req) { + return walletRecordService.expenditurePage(req, getUserVo()); + } + + @PostMapping("/walletDetail") + @UserLoginToken + @ApiOperation(value = "钱包明细详情", notes = "钱包明细详情") + public ResponseData walletDetail(@RequestBody BodyIdReq req) { + return walletRecordService.walletDetail(req, getUserVo()); + } + + @PostMapping("/customerPage") + @UserLoginToken + @ApiOperation(value = "设计师列表", notes = "设计师列表") + public ResponseData>> customerPage(@Valid @RequestBody CustomerPageReq req) { + return customerService.customerPage(req, getUserVo()); + } + + @Autowired + private IllegalDeductionRecordService illegalDeductionRecordService; + + @PostMapping("/illegalDeductionPage") + @UserLoginToken + @ApiOperation(value = "扣款明细", notes = "扣款明细") + public ResponseData illegalDeductionPage(@RequestBody IllegalDeductionPageReq req) { + return illegalDeductionRecordService.illegalDeductionPage(req, getUserVo()); + } + + @Autowired + private AdvertisingImagesService advertisingImagesService; + + @PostMapping("/advertisingImages") + @ApiOperation(value = "广告图", notes = "广告图") + public ResponseData advertisingImages() { + + List list = advertisingImagesService.list(new QueryWrapper().lambda() + .eq(AdvertisingImages::getDelFlag, PublicCommon.启用) + ); + + //类型 1富文本 2 设计师主页 3 表现师主页 4 首页 5活动页面 6新闻页面 + + if (!list.isEmpty()){ + Set userVoSet = list.stream().filter(s->s.getType() == 2 || s.getType() == 3) + .map(s -> new UserVo(s.getType() == 2? UserEnums.customer.getCode():UserEnums.store.getCode(), Long.valueOf(s.getContent()))) + .collect(Collectors.toSet()); + //查询用户信息 + Map userMap = userService.selectUserInfoMap(userVoSet,null); + + list.stream().forEach(s ->{ + if (s.getType() == 2 || s.getType() == 3) { + s.setUserInfo(userMap.get(new UserVo(s.getType() == 2 ? UserEnums.customer.getCode() : UserEnums.store.getCode(), Long.valueOf(s.getContent())))); + } + }); + } + + return ResponseData.success(list); + } + + @PostMapping("/advertisingImagesDetail") + @ApiOperation(value = "广告图", notes = "广告图") + public ResponseData advertisingImages(@RequestBody BodyIdReq req) { + return ResponseData.success(advertisingImagesService.getById(req.getId())); + } +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/ApiVoteCommentController.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/ApiVoteCommentController.java new file mode 100644 index 0000000..0fc8cb1 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/ApiVoteCommentController.java @@ -0,0 +1,72 @@ +package com.ruoyi.controller; + +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.ruoyi.annotations.UserLoginToken; +import com.ruoyi.common.page.PageResult; +import com.ruoyi.controller.req.DialoguePageReq; +import com.ruoyi.controller.req.VoteCommentPageReq; +import com.ruoyi.controller.req.VoteCommentReq; +import com.ruoyi.controller.resp.VoteCommentPageResp; +import com.ruoyi.controller.resp.VoteCommentResp; +import com.ruoyi.frequency.votecomment.service.VoteCommentService; +import com.ruoyi.frequency.votecomment.service.VoteCommentService; +import com.ruoyi.post.controller.req.DeleteCommentReq; +import com.ruoyi.response.ResponseData; +import com.ruoyi.vo.BodyIdReq; +import com.ruoyi.vo.RyController; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + + +/** + * 投票评论相关 + * + * @author liwenlong + */ +@CrossOrigin +@RestController +@RequestMapping("/api/voteComment") +@Api(tags = "投票评论相关") +public class ApiVoteCommentController extends RyController { + + @Autowired + private VoteCommentService voteCommentService; + + @PostMapping("/voteComment") + @UserLoginToken + @ApiOperation(value = "投票评论", notes = "投票评论") + public ResponseData voteComment(@RequestBody VoteCommentReq req) { + return voteCommentService.voteComment(req, getUserVo()); + } + + + @PostMapping("/voteCommentPage") + @ApiOperation(value = "投票评论列表", notes = "投票评论列表") + public ResponseData> voteCommentPage(@RequestBody VoteCommentPageReq req) { + return voteCommentService.voteCommentPage(req, getUserVo()); + } + + + @PostMapping("/deleteComment") + @UserLoginToken + @ApiOperation(value = "删除评论", notes = "删除评论") + public ResponseData deleteComment(@RequestBody DeleteCommentReq req) { + return voteCommentService.deleteComment(req, getUserVo()); + } + + @PostMapping("/voteCommentDetail") + @ApiOperation(value = "投票评论详情", notes = "投票评论详情") + public ResponseData voteCommentDetail(@RequestBody BodyIdReq req) { + return voteCommentService.voteCommentDetail(req.getId(), getUserVo()); + } + + + @PostMapping("/voteCommentDialoguePage") + @ApiOperation(value = "投票对话评论列表", notes = "投票对话评论列表") + public ResponseData>> voteCommentDialoguePage(@RequestBody DialoguePageReq req) { + return voteCommentService.voteCommentDialoguePage(req, getUserVo()); + } + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/ApiVoteController.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/ApiVoteController.java new file mode 100644 index 0000000..045e41b --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/ApiVoteController.java @@ -0,0 +1,74 @@ +package com.ruoyi.controller; + +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.ruoyi.annotations.UserLoginToken; +import com.ruoyi.common.page.PageResult; +import com.ruoyi.controller.req.VoteLikeReq; +import com.ruoyi.controller.req.VoteReq; +import com.ruoyi.controller.req.WorksLikeReq; +import com.ruoyi.controller.resp.VoteDetailResp; +import com.ruoyi.controller.resp.VotePageResp; +import com.ruoyi.frequency.vote.service.VoteService; +import com.ruoyi.frequency.votelike.service.VoteLikeService; +import com.ruoyi.response.ResponseData; +import com.ruoyi.vo.BodyIdReq; +import com.ruoyi.vo.PageBasic; +import com.ruoyi.vo.RyController; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +/** + * 投票 + * + * @author liwenlong + * @date 2023-10-12 + */ +@CrossOrigin +@RestController +@RequestMapping("/api/vote") +@Api(tags = "投票") +public class ApiVoteController extends RyController +{ + @Autowired + private VoteService voteService; + + + @PostMapping("/votePage") + @ApiOperation(value = "投票列表", notes = "投票列表") + public ResponseData>> votePage(@RequestBody PageBasic req) { + return voteService.votePage(req,getUserVo(),false); + } + + @PostMapping("/votePageBySelf") + @ApiOperation(value = "我参与投票列表", notes = "我参与投票列表") + @UserLoginToken + public ResponseData>> votePageBySelf(@RequestBody PageBasic req) { + return voteService.votePage(req,getUserVo(),true); + } + + @PostMapping("/vote") + @UserLoginToken + @ApiOperation(value = "投票", notes = "投票") + public ResponseData vote(@RequestBody VoteReq req) { + return voteService.vote(req,getUserVo()); + } + + @PostMapping("/voteDetail") + @ApiOperation(value = "投票详情", notes = "投票详情") + public ResponseData voteDetail(@RequestBody BodyIdReq req) { + return voteService.voteDetail(req.getId(),req.getIsAddBrowseNum(),getUserVo()); + } + + @Autowired + private VoteLikeService voteLikeService; + + @PostMapping("/voteLike") + @UserLoginToken + @ApiOperation(value = "投票点赞", notes = "投票点赞") + public ResponseData voteLike(@RequestBody VoteLikeReq req) { + return voteLikeService.voteLike(req,getUserVo()); + } + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/ApiWithdrawalController.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/ApiWithdrawalController.java new file mode 100644 index 0000000..35d6725 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/ApiWithdrawalController.java @@ -0,0 +1,206 @@ +package com.ruoyi.controller; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.ruoyi.annotations.UserLoginToken; +import com.ruoyi.code.PublicCommon; +import com.ruoyi.common.exception.ServiceException; +import com.ruoyi.controller.req.WithApplyReq; +import com.ruoyi.controller.req.WithdrawalRecordPageReq; +import com.ruoyi.enums.process.ProcessResultEnums; +import com.ruoyi.frequency.auth.entity.Auth; +import com.ruoyi.frequency.auth.service.AuthService; +import com.ruoyi.frequency.bankcard.service.BankCardService; +import com.ruoyi.frequency.customer.service.UserService; +import com.ruoyi.frequency.highendauth.entity.HighendAuth; +import com.ruoyi.frequency.highendauth.service.HighendAuthService; +import com.ruoyi.frequency.klkaccount.entity.KlkAccount; +import com.ruoyi.frequency.klkaccount.mapper.KlkAccountMapper; +import com.ruoyi.frequency.withdrawalconfig.entity.WithdrawalConfig; +import com.ruoyi.frequency.withdrawalconfig.service.WithdrawalConfigService; +import com.ruoyi.frequency.withdrawalrecord.service.WithdrawalRecordService; +import com.ruoyi.response.ResponseData; +import com.ruoyi.vo.BodyIdReq; +import com.ruoyi.vo.RyController; +import com.ruoyi.vo.UserVo; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RestController; + +import javax.validation.Valid; + + +/** + * 提现相关 + * + * @author liwenlong + */ +@Slf4j +@RestController +@RequestMapping("/api/withdrawal") +@Api(tags = "提现相关") +public class ApiWithdrawalController extends RyController { + + + @Autowired + private WithdrawalRecordService withdrawalRecordService; + + @Autowired + private WithdrawalConfigService withdrawalConfigService; + + + /** + * 查询提现配置信息 + * + * @return + */ + @UserLoginToken + @RequestMapping(value = "/withdrawalConfig", method = RequestMethod.POST) + @ApiOperation(value = "查询提现配置信息") + public ResponseData withdrawalConfig() { + + WithdrawalConfig withdrawalConfig = withdrawalConfigService.getOne(new QueryWrapper().lambda() + .eq(WithdrawalConfig::getUserType, getUserVo().getUserType()) + .eq(WithdrawalConfig::getDelFlag, PublicCommon.启用)); + return ResponseData.success(withdrawalConfig); + } + + + @Autowired + private AuthService authService; + + @Autowired + private HighendAuthService highendAuthService; + + @Autowired + private UserService userService; + + @Autowired + private BankCardService bankCardService; + + + /** + * 申请提现 + * + * @param req + * @return + */ + @UserLoginToken + @RequestMapping(value = "/apply", method = RequestMethod.POST) + @ApiOperation(value = "申请提现") + public ResponseData apply(@RequestBody @Valid WithApplyReq req) { + + + UserVo userVo = getUserVo(); + + // 判断当前用户能否提现 + KlkAccount klkAccount = checkCanApply(userVo); + + userService.storeByEnterprise(userVo); + + req.setBank(klkAccount.getAcctOpenBankName()); + req.setBankCard(klkAccount.getAcctNo()); + req.setFullName(klkAccount.getAcctName()); + + return withdrawalRecordService.apply(req, userVo); + } + + @Autowired + private KlkAccountMapper klkAccountMapper; + + private KlkAccount checkCanApply(UserVo userVo) { + KlkAccount klkAccount = klkAccountMapper.selectOne(new LambdaQueryWrapper() + .eq(KlkAccount::getDelFlag, PublicCommon.启用) + .eq(KlkAccount::getUserId, userVo.getUserId()) + .eq(KlkAccount::getUserType, userVo.getUserType())); + if (klkAccount == null) { + throw new ServiceException("对不起,您未绑定银行卡,无法提现"); + } + if (klkAccount.getBindStatus() == 1) { + throw new ServiceException("对不起,您未绑定银行卡,无法提现"); + } + if (klkAccount.getBindStatus() == 2) { + throw new ServiceException("对不起,您绑定的银行卡正在审核中,无法提现"); + } + if (klkAccount.getBindStatus() == 4) { + throw new ServiceException("对不起,您绑定的银行卡审核失败,请重新绑定"); + } + return klkAccount; + } + + /** + * 提现记录 + * + * @param req + * @return + */ + @UserLoginToken + @RequestMapping(value = "/withdrawalRecordPage", method = RequestMethod.POST) + @ApiOperation(value = "提现记录") + public ResponseData withdrawalRecordPage(@RequestBody @Valid WithdrawalRecordPageReq req) { + return withdrawalRecordService.withdrawalRecordPage(req, getUserVo()); + } + + + /** + * 提现记录详情 + * + * @return + */ + @UserLoginToken + @RequestMapping(value = "/detail", method = RequestMethod.POST) + @ApiOperation(value = "提现记录详情") + public ResponseData detail(@RequestBody @Valid BodyIdReq req) { + return withdrawalRecordService.getDetail(req.getId()); + } + + + /** + * 银行账号 + * + * @return + */ + @UserLoginToken + @RequestMapping(value = "/bankAccount", method = RequestMethod.POST) + @ApiOperation(value = "银行账号") + public ResponseData bankAccount() { + + UserVo userVo = getUserVo(); + + userService.storeByEnterprise(userVo); + + WithApplyReq req = new WithApplyReq(); + + //判断认证状态 + HighendAuth highendAuth = highendAuthService.getOne(new QueryWrapper().lambda() + .eq(HighendAuth::getStoreId, userVo.getUserId()) + .eq(HighendAuth::getStatus, 3) + .eq(HighendAuth::getDelFlag, PublicCommon.启用)); + if (highendAuth == null) { + //获取银行账号 + Auth auth = authService.getOne(new QueryWrapper().lambda() + .eq(Auth::getStoreId, userVo.getUserId()) + .eq(Auth::getResult, ProcessResultEnums.APPROVED.getCode()) + .eq(Auth::getDelFlag, PublicCommon.启用)); + if (auth == null) { + return ResponseData.error("请先进行平台认证或高端认证"); + } + + req.setBank(auth.getBank()); + req.setSubbranch(auth.getSubbranch()); + req.setBankCard(auth.getBankCard()); + } else { + req.setBank(highendAuth.getBank()); + req.setSubbranch(highendAuth.getSubbranch()); + req.setBankCard(highendAuth.getBankCard()); + } + return ResponseData.success(req); + } +} + + diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/ApiWorksCommentController.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/ApiWorksCommentController.java new file mode 100644 index 0000000..44ba602 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/ApiWorksCommentController.java @@ -0,0 +1,71 @@ +package com.ruoyi.controller; + +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.ruoyi.annotations.UserLoginToken; +import com.ruoyi.common.page.PageResult; +import com.ruoyi.controller.req.DialoguePageReq; +import com.ruoyi.controller.req.WorksCommentPageReq; +import com.ruoyi.controller.req.WorksCommentReq; +import com.ruoyi.controller.resp.WorksCommentPageResp; +import com.ruoyi.controller.resp.WorksCommentResp; +import com.ruoyi.frequency.workscomment.service.WorksCommentService; +import com.ruoyi.post.controller.req.DeleteCommentReq; +import com.ruoyi.response.ResponseData; +import com.ruoyi.vo.BodyIdReq; +import com.ruoyi.vo.RyController; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + + +/** + * 作品评论相关 + * + * @author liwenlong + */ +@CrossOrigin +@RestController +@RequestMapping("/api/worksComment") +@Api(tags = "作品评论相关") +public class ApiWorksCommentController extends RyController { + + @Autowired + private WorksCommentService worksCommentService; + + @PostMapping("/worksComment") + @UserLoginToken + @ApiOperation(value = "作品评论", notes = "作品评论") + public ResponseData worksComment(@RequestBody WorksCommentReq req) { + return worksCommentService.worksComment(req, getUserVo()); + } + + + @PostMapping("/worksCommentPage") + @ApiOperation(value = "作品评论列表", notes = "作品评论列表") + public ResponseData> worksCommentPage(@RequestBody WorksCommentPageReq req) { + return worksCommentService.worksCommentPage(req, getUserVo()); + } + + + @PostMapping("/deleteComment") + @UserLoginToken + @ApiOperation(value = "删除评论", notes = "删除评论") + public ResponseData deleteComment(@RequestBody DeleteCommentReq req) { + return worksCommentService.deleteComment(req, getUserVo()); + } + + @PostMapping("/worksCommentDetail") + @ApiOperation(value = "作品评论详情", notes = "作品评论详情") + public ResponseData worksCommentDetail(@RequestBody BodyIdReq req) { + return worksCommentService.worksCommentDetail(req.getId(), getUserVo()); + } + + + @PostMapping("/worksCommentDialoguePage") + @ApiOperation(value = "作品对话评论列表", notes = "作品对话评论列表") + public ResponseData>> worksCommentDialoguePage(@RequestBody DialoguePageReq req) { + return worksCommentService.worksCommentDialoguePage(req, getUserVo()); + } + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/ApiWorksController.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/ApiWorksController.java new file mode 100644 index 0000000..42aa726 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/ApiWorksController.java @@ -0,0 +1,150 @@ +package com.ruoyi.controller; + +import cn.hutool.core.collection.CollectionUtil; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.ruoyi.annotations.UserLoginToken; +import com.ruoyi.code.DictConstant; +import com.ruoyi.code.PublicCommon; +import com.ruoyi.common.core.domain.entity.SysDictData; +import com.ruoyi.common.page.PageResult; +import com.ruoyi.controller.req.*; +import com.ruoyi.controller.resp.OrderWorksPricePage; +import com.ruoyi.controller.resp.WorksDetailResp; +import com.ruoyi.controller.resp.WorksPageResp; +import com.ruoyi.frequency.worklike.service.WorkLikeService; +import com.ruoyi.frequency.works.entity.Works; +import com.ruoyi.frequency.works.service.WorksService; +import com.ruoyi.frequency.workstep.service.WorkStepService; +import com.ruoyi.response.ResponseData; +import com.ruoyi.utils.BusinessUtil; +import com.ruoyi.vo.BodyIdReq; +import com.ruoyi.vo.RyController; +import com.ruoyi.vo.UserVo; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Collectors; + +/** + * 作品 + */ +@CrossOrigin +@RestController +@RequestMapping("/api/works") +@Api(tags = "作品") +public class ApiWorksController extends RyController { + + + @Autowired + private WorksService worksService; + + @Autowired + private BusinessUtil businessUtil; + + @PostMapping("/worksRelease") + @ApiOperation(value = "作品发布", notes = "作品发布") + @UserLoginToken + public ResponseData worksRelease(@RequestBody WorksReleaseReq req) { + + + UserVo userVo = getUserVo(); + + //最大上传作品数量 + Integer bigNum = Integer.valueOf(businessUtil.getDict(DictConstant.作品最大数量).getDictValue()); + + //判断作品上传数量 + int worksNum = worksService.count(new QueryWrapper().lambda() + .isNull(Works::getOrderId) + .ne(Works::getDelFlag, PublicCommon.删除) + .eq(Works::getStoreId, userVo.getUserId())); + + if (worksNum >= bigNum) { + return ResponseData.error("作品上传数量不能超过" + bigNum + "个"); + } + + return worksService.worksRelease(req, userVo); + } + + + @PostMapping("/worksPage") + @ApiOperation(value = "作品列表", notes = "作品列表") + public ResponseData>> worksPage(@RequestBody WorksPageReq req) { + req.setShowEnterprise(2); + return worksService.worksPage(req, getUserVo()); + } + + @PostMapping("/worksPageBySelf") + @ApiOperation(value = "我的作品(自己查看)", notes = "我的作品(自己查看)") + public ResponseData>> worksPageBySelf(@RequestBody WorksPageReq req) { + UserVo userVo = getUserVo(); + req.setUserId(userVo.getUserId()); + req.setUserType(userVo.getUserType()); + req.setIsSelf(1); + return worksService.worksPage(req, userVo); + } + + @PostMapping("/worksPageByOtherSelf") + @ApiOperation(value = "我的作品(他人查看)", notes = "我的作品(他人查看)") + public ResponseData>> worksPageByOtherSelf(@RequestBody WorksPageReq req) { + return worksService.worksPage(req, getUserVo()); + } + + + @PostMapping("/worksDetail") + @ApiOperation(value = "作品详情", notes = "作品详情") + public ResponseData worksDetail(@RequestBody BodyIdReq req) { + return worksService.worksDetail(req.getId(), req.getIsAddBrowseNum(), getUserVo()); + } + + @Autowired + private WorkLikeService workLikeService; + + @PostMapping("/worksLike") + @UserLoginToken + @ApiOperation(value = "作品点赞", notes = "作品点赞") + public ResponseData worksLike(@RequestBody WorksLikeReq req) { + return workLikeService.worksLike(req, getUserVo()); + } + + @PostMapping("/hideWork") + @UserLoginToken + @ApiOperation(value = "隐藏作品", notes = "隐藏作品") + public ResponseData hideWork(@RequestBody BodyIdReq req) { + return worksService.hideWork(req, getUserVo()); + } + + + @Autowired + private WorkStepService workStepService; + + @PostMapping("/worksStep") + @UserLoginToken + @ApiOperation(value = "作品踩赞", notes = "作品踩赞") + public ResponseData worksStep(@RequestBody WorksStepReq req) { + return workStepService.worksStep(req, getUserVo()); + } + + + @PostMapping("/drawingDetailsPage") + @ApiOperation(value = "制图明细", notes = "制图明细") + public ResponseData drawingDetailsPage(@RequestBody DrawingDetailsPageReq req) { + return worksService.drawingDetailsPage(req, getUserVo()); + } + + + /** + * 获取有作品的分类 + * @return + */ + @ResponseBody + @RequestMapping(value = "/getHaveWorkCategory", method = RequestMethod.POST) + @ApiOperation(value = "字典表下级") + public ResponseData> getHaveWorkCategory(@RequestBody WorksPageReq req) { + return worksService.getHaveWorkCategory(req); + } +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/ApiWorksReportController.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/ApiWorksReportController.java new file mode 100644 index 0000000..285ec4e --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/ApiWorksReportController.java @@ -0,0 +1,34 @@ +package com.ruoyi.controller; + +import com.ruoyi.annotations.UserLoginToken; +import com.ruoyi.controller.req.WorksReportReq; +import com.ruoyi.frequency.worksreport.service.WorksReportService; +import com.ruoyi.response.ResponseData; +import com.ruoyi.vo.RyController; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + + +/** + * 作品举报相关 + * @author liwenlong + * + */ +@CrossOrigin +@RestController +@RequestMapping("/api/postReport") +@Api(tags = "作品举报相关") +public class ApiWorksReportController extends RyController { + + @Autowired + private WorksReportService worksReportService; + + @PostMapping("/worksReport") + @UserLoginToken + @ApiOperation(value = "作品举报", notes = "作品举报") + public ResponseData worksReport(@RequestBody WorksReportReq req) { + return worksReportService.worksReport(req,getUserVo()); + } +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/ApiWorksShieldController.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/ApiWorksShieldController.java new file mode 100644 index 0000000..e011197 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/ApiWorksShieldController.java @@ -0,0 +1,34 @@ +package com.ruoyi.controller; + +import com.ruoyi.annotations.UserLoginToken; +import com.ruoyi.frequency.worksshield.service.WorksShieldService; +import com.ruoyi.response.ResponseData; +import com.ruoyi.vo.BodyIdReq; +import com.ruoyi.vo.RyController; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + + +/** + * 作品屏蔽 + * @author liwenlong + * + */ +@CrossOrigin +@RestController +@RequestMapping("/api/worksShield") +@Api(tags = "作品屏蔽") +public class ApiWorksShieldController extends RyController { + + @Autowired + private WorksShieldService worksShieldService; + + @PostMapping("/worksShield") + @UserLoginToken + @ApiOperation(value = "作品屏蔽", notes = "作品屏蔽") + public ResponseData worksShield(@RequestBody BodyIdReq req) { + return worksShieldService.worksShield(req.getId(),getUserVo()); + } +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/ApiWorksTypeController.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/ApiWorksTypeController.java new file mode 100644 index 0000000..708df16 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/ApiWorksTypeController.java @@ -0,0 +1,37 @@ +package com.ruoyi.controller; + +import com.ruoyi.frequency.workstype.entity.WorksType; +import com.ruoyi.frequency.workstype.service.WorksTypeService; +import com.ruoyi.response.ResponseData; +import com.ruoyi.vo.RyController; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.CrossOrigin; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.util.List; + +/** + * 作品类型 + */ +@CrossOrigin +@RestController +@RequestMapping("/api/worksType") +@Api(tags = "作品类型") +public class ApiWorksTypeController extends RyController { + + + @Autowired + private WorksTypeService worksTypeService; + + + @PostMapping("/worksTypeTree") + @ApiOperation(value = "作品类型树", notes = "作品类型树") + public ResponseData> worksTypeTree() { + return ResponseData.success(worksTypeService.worksTypeList()); + } + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/ActivityPageReq.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/ActivityPageReq.java new file mode 100644 index 0000000..2252835 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/ActivityPageReq.java @@ -0,0 +1,12 @@ +package com.ruoyi.controller.req; + +import com.ruoyi.vo.PageBasic; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +@Data +public class ActivityPageReq extends PageBasic { + + @ApiModelProperty(value = "关键字") + private String keyword; +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/AddressInsertReq.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/AddressInsertReq.java new file mode 100644 index 0000000..5474c1d --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/AddressInsertReq.java @@ -0,0 +1,46 @@ +package com.ruoyi.controller.req; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; + +@Data +public class AddressInsertReq { + + @NotBlank(message = "收货人姓名不能为空") + @ApiModelProperty(value = "收货人姓名", required = true) + private String username; + + @NotBlank(message = "收货人联系方式不能为空") + @ApiModelProperty(value = "收货人联系方式", required = true) + private String mobile; + + private String areaCode; + + @ApiModelProperty(value = "省份名称", required = true) + private String province; + + @ApiModelProperty(value = "城市名称") + private String city; + + @ApiModelProperty(value = "区域名称") + private String area; + + @ApiModelProperty(value = "地址") + private String address; + + @ApiModelProperty(value = "详细地址") + private String detail; + + @ApiModelProperty(value = "经度") + private String longitude; + + @ApiModelProperty(value = "纬度") + private String latitude; + + @ApiModelProperty(value = "是否默认") + @NotNull(message = "是否默认不能为空") + private Integer isDefault; +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/AddressUpdateReq.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/AddressUpdateReq.java new file mode 100644 index 0000000..5720276 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/AddressUpdateReq.java @@ -0,0 +1,49 @@ +package com.ruoyi.controller.req; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; + +@Data +public class AddressUpdateReq { + + @ApiModelProperty(value = "用户地址id", required = true) + private Long id; + + @NotBlank(message = "收货人姓名不能为空") + @ApiModelProperty(value = "收货人姓名", required = true) + private String username; + + @NotBlank(message = "收货人联系方式不能为空") + @ApiModelProperty(value = "收货人联系方式", required = true) + private String mobile; + + private String areaCode; + + @ApiModelProperty(value = "省份名称", required = true) + private String province; + + @ApiModelProperty(value = "城市名称") + private String city; + + @ApiModelProperty(value = "区域名称") + private String area; + + @ApiModelProperty(value = "地址") + private String address; + + @ApiModelProperty(value = "详细地址") + private String detail; + + @ApiModelProperty(value = "经度") + private String longitude; + + @ApiModelProperty(value = "纬度") + private String latitude; + + @ApiModelProperty(value = "是否默认") + @NotNull(message = "是否默认不能为空") + private Integer isDefault; +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/AnswerPageReq.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/AnswerPageReq.java new file mode 100644 index 0000000..bbbcf9c --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/AnswerPageReq.java @@ -0,0 +1,18 @@ +package com.ruoyi.controller.req; + +import com.ruoyi.vo.PageBasic; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + * @author a + * @date 2024/1/29 14:43 + */ +@Data +public class AnswerPageReq extends PageBasic { + + @ApiModelProperty("用户类型 1设计师 2表现师") + private Integer userType; + + private Long platformAnswerTypeId; +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/AppealMessagePageReq.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/AppealMessagePageReq.java new file mode 100644 index 0000000..de834b0 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/AppealMessagePageReq.java @@ -0,0 +1,29 @@ +package com.ruoyi.controller.req; + +import com.ruoyi.vo.PageBasic; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import javax.validation.constraints.NotNull; +import java.util.Date; + +/** + * @author a + * @date 2023/10/16 10:25 + */ +@Data +public class AppealMessagePageReq extends PageBasic { + + @ApiModelProperty("申诉id") + @NotNull(message = "申诉id不能为空") + private Long appealId; + + @ApiModelProperty("开始时间") + private Date beginTime; + + @ApiModelProperty("结束时间") + private Date endTime; + + @ApiModelProperty("最早一條消息的时间") + private Date lasttimestamp; +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/ApplyAfterSalesReq.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/ApplyAfterSalesReq.java new file mode 100644 index 0000000..594d128 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/ApplyAfterSalesReq.java @@ -0,0 +1,26 @@ +package com.ruoyi.controller.req; + +import lombok.Data; + +/** + * @Author 刘耀 + * @Date 2022/1/18 19:36 + */ +@Data +public class ApplyAfterSalesReq { + private Long orderId; + + //1 退款 2 退款退货 + private Integer refundType; + + //退款原因 + private String refundReason; + + //退款说明 + private String refundExplain; + + //申请配图 + private String refundImages; + + private Long refundId; +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/BondPayReq.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/BondPayReq.java new file mode 100644 index 0000000..7650a47 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/BondPayReq.java @@ -0,0 +1,24 @@ +package com.ruoyi.controller.req; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.math.BigDecimal; + +/** + * @author a + * @date 2023/10/18 15:46 + */ +@Data +public class BondPayReq { + + + @ApiModelProperty("金额") + private BigDecimal amount; + + @ApiModelProperty("支付类型: 1 app支付宝 2 h5支付宝 3 app微信 4 h5微信 5 小程序 6 苹果支付 7 余额") + private Integer payType; + + @ApiModelProperty("使用余额支付时 支付密码") + private String payPwd; +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/BondRecordPageReq.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/BondRecordPageReq.java new file mode 100644 index 0000000..9893c72 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/BondRecordPageReq.java @@ -0,0 +1,12 @@ +package com.ruoyi.controller.req; + +import com.ruoyi.vo.PageBasic; +import lombok.Data; + +/** + * @author a + * @date 2023/10/18 15:48 + */ +@Data +public class BondRecordPageReq extends PageBasic { +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/CalculateFirstAmountReq.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/CalculateFirstAmountReq.java new file mode 100644 index 0000000..652c7dd --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/CalculateFirstAmountReq.java @@ -0,0 +1,11 @@ +package com.ruoyi.controller.req; + +import lombok.Data; + +import java.math.BigDecimal; + +@Data +public class CalculateFirstAmountReq { + private BigDecimal amount; + private Long orderId; +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/CanFellReq.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/CanFellReq.java new file mode 100644 index 0000000..54e9e4a --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/CanFellReq.java @@ -0,0 +1,8 @@ +package com.ruoyi.controller.req; + +import lombok.Data; + +@Data +public class CanFellReq { + private String code; +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/CommentPageReq.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/CommentPageReq.java new file mode 100644 index 0000000..9c5eca2 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/CommentPageReq.java @@ -0,0 +1,32 @@ +package com.ruoyi.controller.req; + +import com.ruoyi.vo.PageBasic; +import com.ruoyi.vo.UserVo; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import javax.validation.constraints.NotNull; +import java.util.List; + +@Data +public class CommentPageReq extends PageBasic { + + @NotNull(message = "关联id不能为空") + @ApiModelProperty(value = "关联id", required = true) + private Long linkId; + + @ApiModelProperty(value = "上级评论id", required = false) + private Long parentId; + + @ApiModelProperty(value = "拉黑用户") + private List blockUserList; + + @ApiModelProperty(value = "屏蔽用户") + private List shieldUserList; + + @ApiModelProperty("排序 1时间 2热度") + private Integer sortType; + + @ApiModelProperty(value = "1升序 2 降序") + private Integer isAsc; +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/CommentReq.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/CommentReq.java new file mode 100644 index 0000000..432afa0 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/CommentReq.java @@ -0,0 +1,24 @@ +package com.ruoyi.controller.req; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import javax.validation.constraints.NotNull; + +@Data +public class CommentReq { + + @NotNull(message = "关联id不能为空") + @ApiModelProperty(value = "关联id", required = true) + private Long linkId; + + @ApiModelProperty(value = "上级评论id,如果没有上级评论,(不传值默认0,评论作品)") + private Long parentId = 0L; + + @ApiModelProperty(value = "评论内容", required = true) + @NotNull(message = "评论内容不能为空") + private String content; + + @ApiModelProperty("评论图片") + private String image; +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/ConfirmStoreReq.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/ConfirmStoreReq.java new file mode 100644 index 0000000..3600f51 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/ConfirmStoreReq.java @@ -0,0 +1,18 @@ +package com.ruoyi.controller.req; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + * @author a + * @date 2023/10/13 9:44 + */ +@Data +public class ConfirmStoreReq { + + @ApiModelProperty("订单id") + private Long orderId; + + @ApiModelProperty("表现师id") + private Long storeId; +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/ContentCanUseReq.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/ContentCanUseReq.java new file mode 100644 index 0000000..44a5ea2 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/ContentCanUseReq.java @@ -0,0 +1,31 @@ +package com.ruoyi.controller.req; + +import lombok.Data; + +@Data +public class ContentCanUseReq { + /** + * 需检测的文本内容,文本字数的上限为2500字,需使用UTF-8编码 + */ + private String content; + /** + * 需要检测的图片或音频的url + */ + private String mediaUrl; + /** + * 场景枚举值(1 资料;2 评论;3 论坛;4 社交日志) + */ + private Integer scene; + /** + * 文本标题,需使用UTF-8编码 + */ + private String title; + /** + * 用户昵称,需使用UTF-8编码 + */ + private String nickname; + /** + * 个性签名,该参数仅在资料类场景有效(scene=1),需使用UTF-8编码 + */ + private String signature; +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/CreateOrderReq.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/CreateOrderReq.java new file mode 100644 index 0000000..c0ecdd4 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/CreateOrderReq.java @@ -0,0 +1,40 @@ +package com.ruoyi.controller.req; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import javax.validation.constraints.NotNull; +import java.math.BigDecimal; + +/** + * @Author liwenlong + */ +@Data +public class CreateOrderReq { + + @NotNull(message = "商品id不能为空") + @ApiModelProperty(required = true, value = "商品id") + private Long goodsId; + + @NotNull(message = "规格id不能为空") + @ApiModelProperty(required = true, value = "规格id") + private Long specId; + + @NotNull(message = "数量不能为空") + @ApiModelProperty(required = true, value = "数量") + private Integer quantity; + + @ApiModelProperty("支付类型") + private Integer payType; + + @ApiModelProperty("选择余额支付的时候密码校验") + private String balancePayPwd; + + @ApiModelProperty("备注") + private String remark; + + @NotNull(message = "用户地址id不能为空") + @ApiModelProperty(required = true, value = "用户地址id") + private Long addressId; + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/CustomerDeliverGoodsReq.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/CustomerDeliverGoodsReq.java new file mode 100644 index 0000000..84fe2f7 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/CustomerDeliverGoodsReq.java @@ -0,0 +1,19 @@ +package com.ruoyi.controller.req; + +import lombok.Data; + +/** + * @Date 2022/1/19 10:27 + */ +@Data +public class CustomerDeliverGoodsReq { + private Long orderId; + + private Integer orderType; + + private String comCourierId;//退货物流单号 + + private Long dictId; + + private Long refundId; +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/CustomerPayReq.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/CustomerPayReq.java new file mode 100644 index 0000000..5fa5011 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/CustomerPayReq.java @@ -0,0 +1,22 @@ +package com.ruoyi.controller.req; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + * @author a + * @date 2023/10/13 17:13 + */ +@Data +public class CustomerPayReq { + + + @ApiModelProperty("订单id") + private Long orderId; + + @ApiModelProperty("支付类型: 1 app支付宝 2 h5支付宝 3 app微信 4 h5微信 5 小程序 6 苹果支付 7 余额") + private Integer payType; + + @ApiModelProperty("使用余额支付时 支付密码") + private String payPwd; +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/DrawingDetailsPageReq.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/DrawingDetailsPageReq.java new file mode 100644 index 0000000..c08cb26 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/DrawingDetailsPageReq.java @@ -0,0 +1,17 @@ +package com.ruoyi.controller.req; + +import com.ruoyi.vo.PageBasic; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + * @author a + * @date 2024/1/27 16:56 + */ +@Data +public class DrawingDetailsPageReq extends PageBasic { + + @ApiModelProperty("订单id") + private Long orderId; + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/EvaluateReq.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/EvaluateReq.java new file mode 100644 index 0000000..341dd62 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/EvaluateReq.java @@ -0,0 +1,26 @@ +package com.ruoyi.controller.req; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.math.BigDecimal; + +/** + * @author a + * @date 2023/10/13 9:55 + */ +@Data +public class EvaluateReq { + + @ApiModelProperty("订单id") + private Long orderId; + + @ApiModelProperty("质量评分") + private BigDecimal qualityStar; + + @ApiModelProperty("效率评分") + private BigDecimal efficiencyStar; + + @ApiModelProperty("服务评分") + private BigDecimal serviceStar; +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/GoodsPageReq.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/GoodsPageReq.java new file mode 100644 index 0000000..e99ce4e --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/GoodsPageReq.java @@ -0,0 +1,26 @@ +package com.ruoyi.controller.req; + +import com.ruoyi.vo.PageBasic; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + * @author a + * @date 2023/2/13 15:07 + */ +@Data +public class GoodsPageReq extends PageBasic { + + + @ApiModelProperty("商品类型id") + private Long goodsTypeId; + + @ApiModelProperty("关键字搜索") + private String keyword; + + @ApiModelProperty("排序 1 综合推荐 2 销量 3 价格 4上架时间") + private Integer sortType; + + @ApiModelProperty(value = "1升序 2 降序") + private Integer isAsc; +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/HotSearchListReq.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/HotSearchListReq.java new file mode 100644 index 0000000..b0f8b8d --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/HotSearchListReq.java @@ -0,0 +1,11 @@ +package com.ruoyi.controller.req; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +@Data +public class HotSearchListReq { + + @ApiModelProperty(value = "关键字") + private String keyword; +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/InsertShoppingCarReq.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/InsertShoppingCarReq.java new file mode 100644 index 0000000..aa062f6 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/InsertShoppingCarReq.java @@ -0,0 +1,20 @@ +package com.ruoyi.controller.req; + +import lombok.Data; + +import javax.validation.constraints.NotNull; + +/** + * @author a + * @date 2023/2/13 16:15 + */ +@Data +public class InsertShoppingCarReq { + @NotNull(message = "规格id不能为空") + private Long speId; //规格Id + @NotNull(message = "规格数量不能为空") + private Integer quantity; //数量 + + @NotNull(message = "商品id不能为空") + private Long goodsId; +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/IsNeedGetOrderDetailReq.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/IsNeedGetOrderDetailReq.java new file mode 100644 index 0000000..d631460 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/IsNeedGetOrderDetailReq.java @@ -0,0 +1,13 @@ +package com.ruoyi.controller.req; + +import lombok.Data; + +import java.util.Date; + +@Data +public class IsNeedGetOrderDetailReq { + + private String date; + + private Long orderId; +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/IsNeedGetOrderDetailReq2.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/IsNeedGetOrderDetailReq2.java new file mode 100644 index 0000000..26d5ebd --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/IsNeedGetOrderDetailReq2.java @@ -0,0 +1,13 @@ +package com.ruoyi.controller.req; + +import lombok.Data; + +import java.util.Date; + +@Data +public class IsNeedGetOrderDetailReq2 { + + private Date date; + + private Long orderId; +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/LakalaPaySuccessReq.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/LakalaPaySuccessReq.java new file mode 100644 index 0000000..e1286bc --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/LakalaPaySuccessReq.java @@ -0,0 +1,11 @@ +package com.ruoyi.controller.req; + +import lombok.Data; + +@Data +public class LakalaPaySuccessReq { + /** + * 商户订单号 + */ + private String outOrderNo; +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/LikeReq.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/LikeReq.java new file mode 100644 index 0000000..95c4dfa --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/LikeReq.java @@ -0,0 +1,20 @@ +package com.ruoyi.controller.req; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import javax.validation.constraints.NotNull; + +@Data +public class LikeReq { + + /** + * 1 新闻 2 新闻评论 3 活动 + */ + @NotNull(message = "类型不能为空") + private Integer type; + + @NotNull(message = "关联id不能为空") + @ApiModelProperty("关联id 新闻id/新闻评论id/活动id") + private Long linkId; +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/MallEvaluateReq.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/MallEvaluateReq.java new file mode 100644 index 0000000..d526a14 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/MallEvaluateReq.java @@ -0,0 +1,26 @@ +package com.ruoyi.controller.req; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.math.BigDecimal; + +/** + * @author a + * @date 2024/1/26 17:37 + */ +@Data +public class MallEvaluateReq { + + @ApiModelProperty("订单id") + private Long orderId; + + @ApiModelProperty("评价星级;1~5个星级") + private BigDecimal star; + + @ApiModelProperty("评价内容") + private String content; + + @ApiModelProperty("评价图片") + private String images; +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/MallOrderConfirmReq.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/MallOrderConfirmReq.java new file mode 100644 index 0000000..5521008 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/MallOrderConfirmReq.java @@ -0,0 +1,17 @@ +package com.ruoyi.controller.req; + +import lombok.Data; +import lombok.experimental.Accessors; + +/** + * @author a + * @date 2023/2/15 13:56 + */ +@Data +@Accessors(chain = true) +public class MallOrderConfirmReq { + + private Long orderId; + + private Integer orderType; +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/MallOrderPageReq.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/MallOrderPageReq.java new file mode 100644 index 0000000..069955b --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/MallOrderPageReq.java @@ -0,0 +1,17 @@ +package com.ruoyi.controller.req; + +import com.ruoyi.vo.PageBasic; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + * @author a + * @date 2023/2/15 10:16 + */ +@Data +public class MallOrderPageReq extends PageBasic { + + @ApiModelProperty("订单状态") + private Integer status; + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/MallOrderPayReq.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/MallOrderPayReq.java new file mode 100644 index 0000000..ec3c788 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/MallOrderPayReq.java @@ -0,0 +1,25 @@ +package com.ruoyi.controller.req; + +import lombok.Data; + +import java.math.BigDecimal; + +/** + * @author a + * @date 2023/2/16 9:23 + */ +@Data +public class MallOrderPayReq { + + private Long orderId;//订单id + + private Integer payType = -1;//支付方式, -1 不使用 1:支付宝 2 微信 + + private String balancePayPwd;//选择余额支付的时候密码校验 + + private String remark; + + private BigDecimal commissionPrice ;//佣金金额 不使用佣金余额支付时为空 + + private BigDecimal integralPrice;//积分金额 不使用积分金额支付时为空 +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/MallSettlementReq.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/MallSettlementReq.java new file mode 100644 index 0000000..6b70b9a --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/MallSettlementReq.java @@ -0,0 +1,24 @@ +package com.ruoyi.controller.req; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; + +import javax.validation.constraints.NotNull; + +/** + * @author a + * @date 2023/2/14 13:59 + */ +@Data +@Accessors(chain = true) +public class MallSettlementReq { + + @NotNull(message = "规格id不能为空") + @ApiModelProperty(value = "规格id", required = true) + private Long specId; + + @NotNull(message = "数量不能为空") + @ApiModelProperty(value = "数量", required = true) + private Integer quantity; +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/NewsPageReq.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/NewsPageReq.java new file mode 100644 index 0000000..155b904 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/NewsPageReq.java @@ -0,0 +1,12 @@ +package com.ruoyi.controller.req; + +import com.ruoyi.vo.PageBasic; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +@Data +public class NewsPageReq extends PageBasic { + + @ApiModelProperty(value = "关键字") + private String keyword; +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/NoticeListReq.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/NoticeListReq.java new file mode 100644 index 0000000..ddccbf2 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/NoticeListReq.java @@ -0,0 +1,18 @@ +package com.ruoyi.controller.req; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + * @author a + * @date 2023/12/25 10:58 + */ +@Data +public class NoticeListReq { + + @ApiModelProperty("用户类型") + private Integer userType; + + @ApiModelProperty("公告类型") + private String noticeType; +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/OnceAgainCreateOrderReq.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/OnceAgainCreateOrderReq.java new file mode 100644 index 0000000..4c1a785 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/OnceAgainCreateOrderReq.java @@ -0,0 +1,32 @@ +package com.ruoyi.controller.req; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import javax.validation.constraints.NotNull; + +/** + * @author a + * @date 2024/1/26 17:10 + */ +@Data +public class OnceAgainCreateOrderReq { + + @NotNull(message = "订单id不能为空") + @ApiModelProperty(required = true, value = "订单id不能为空") + private Long orderId; + + @ApiModelProperty("支付类型") + private Integer payType; + + @ApiModelProperty("选择余额支付的时候密码校验") + private String balancePayPwd; + + @ApiModelProperty("备注") + private String remark; + + @NotNull(message = "用户地址id不能为空") + @ApiModelProperty(required = true, value = "用户地址id") + private Long addressId; + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/OrderAdjustPriceConfirmReq.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/OrderAdjustPriceConfirmReq.java new file mode 100644 index 0000000..e13b184 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/OrderAdjustPriceConfirmReq.java @@ -0,0 +1,24 @@ +package com.ruoyi.controller.req; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import javax.validation.constraints.NotNull; + +/** + * @author a + * @date 2024/1/27 17:27 + */ +@Data +public class OrderAdjustPriceConfirmReq { + + + @NotNull(message = "id不能为空") + private Long id; + + @ApiModelProperty("支付类型: 1 app支付宝 2 h5支付宝 3 app微信 4 h5微信 5 小程序 6 苹果支付 7 余额") + private Integer payType; + + @ApiModelProperty("使用余额支付时 支付密码") + private String payPwd; +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/OrderAdjustPricePayCountReq.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/OrderAdjustPricePayCountReq.java new file mode 100644 index 0000000..fbdfddc --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/OrderAdjustPricePayCountReq.java @@ -0,0 +1,20 @@ +package com.ruoyi.controller.req; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.math.BigDecimal; + +/** + * @author a + * @date 2024/1/24 10:41 + */ +@Data +public class OrderAdjustPricePayCountReq { + + @ApiModelProperty(value = "订单id") + private Long orderId; + + @ApiModelProperty(value = "调价金额") + private BigDecimal amount; +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/OrderAdjustPricePayReq.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/OrderAdjustPricePayReq.java new file mode 100644 index 0000000..a7cbb61 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/OrderAdjustPricePayReq.java @@ -0,0 +1,29 @@ +package com.ruoyi.controller.req; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.math.BigDecimal; + +/** + * @author a + * @date 2024/1/24 10:44 + */ +@Data +public class OrderAdjustPricePayReq { + + @ApiModelProperty("订单id") + private Long orderId; + + @ApiModelProperty(value = "调价金额") + private BigDecimal amount; + + @ApiModelProperty("调价备注") + private String remark; + + @ApiModelProperty("支付类型: 1 app支付宝 2 h5支付宝 3 app微信 4 h5微信 5 小程序 6 苹果支付 7 余额") + private Integer payType; + + @ApiModelProperty("使用余额支付时 支付密码") + private String payPwd; +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/OrderAdjustPriceReq.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/OrderAdjustPriceReq.java new file mode 100644 index 0000000..3d22483 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/OrderAdjustPriceReq.java @@ -0,0 +1,29 @@ +package com.ruoyi.controller.req; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.math.BigDecimal; + +/** + * @author a + * @date 2023/10/13 9:49 + */ +@Data +public class OrderAdjustPriceReq { + + @ApiModelProperty("订单id") + private Long orderId; + + @ApiModelProperty("调价价格") + private BigDecimal amount; + + @ApiModelProperty("调价备注") + private String remark; + + @ApiModelProperty("支付类型: 1 app支付宝 2 h5支付宝 3 app微信 4 h5微信 5 小程序 6 苹果支付 7 余额") + private Integer payType; + + @ApiModelProperty("使用余额支付时 支付密码") + private String payPwd; +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/OrderAppealReq.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/OrderAppealReq.java new file mode 100644 index 0000000..4738e34 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/OrderAppealReq.java @@ -0,0 +1,20 @@ +package com.ruoyi.controller.req; + +import com.ruoyi.frequency.appeal.entity.Appeal; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + * @author a + * @date 2023/10/13 9:42 + */ +@Data +public class OrderAppealReq { + + @ApiModelProperty("订单id") + private Long orderId; + + @ApiModelProperty("申诉信息") + private Appeal appeal; + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/OrderChangeRecordPageReq.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/OrderChangeRecordPageReq.java new file mode 100644 index 0000000..09431da --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/OrderChangeRecordPageReq.java @@ -0,0 +1,19 @@ +package com.ruoyi.controller.req; + +import com.ruoyi.vo.PageBasic; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import javax.validation.constraints.NotNull; + +/** + * @author a + * @date 2023/10/20 10:56 + */ +@Data +public class OrderChangeRecordPageReq extends PageBasic { + + @ApiModelProperty("订单id") + @NotNull(message = "订单id不能为空") + private Long orderId; +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/OrderExtensionReq.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/OrderExtensionReq.java new file mode 100644 index 0000000..43bdb47 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/OrderExtensionReq.java @@ -0,0 +1,23 @@ +package com.ruoyi.controller.req; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.Date; + +/** + * @author a + * @date 2023/11/3 11:49 + */ +@Data +public class OrderExtensionReq { + + @ApiModelProperty("订单id") + private Long orderId; + + @ApiModelProperty("延期时间") + private Date extensionTime; + + @ApiModelProperty("备注") + private String remark; +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/OrderMessagePageReq.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/OrderMessagePageReq.java new file mode 100644 index 0000000..548ba38 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/OrderMessagePageReq.java @@ -0,0 +1,15 @@ +package com.ruoyi.controller.req; + +import com.ruoyi.vo.PageBasic; +import lombok.Data; + +import javax.validation.constraints.NotNull; + +@Data +public class OrderMessagePageReq { + @NotNull(message = "订单ID不能为空") + private Long orderId; + + @NotNull(message = "订单类型不能为空") + private Integer orderType; +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/OrderPageReq.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/OrderPageReq.java new file mode 100644 index 0000000..8cce621 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/OrderPageReq.java @@ -0,0 +1,63 @@ +package com.ruoyi.controller.req; + +import com.ruoyi.vo.PageBasic; +import com.ruoyi.vo.UserVo; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.Date; +import java.util.List; + +/** + * @author a + * @date 2023/10/13 9:35 + */ +@Data +public class OrderPageReq extends PageBasic { + + @ApiModelProperty("订单状态:-1 已取消 0首款待支付 1待确认 2进行中 3待收图 4待评价 5已评价 ") + private Integer status; + + @ApiModelProperty("开始时间") + private Date beginTime; + + @ApiModelProperty("结束时间") + private Date endTime; + + @ApiModelProperty("作品id") + private Long typeId; + + @ApiModelProperty("排序类型 1最新 2价格") + private Integer sortType = 1; + + @ApiModelProperty("排序类型 1升序 2降序") + private Integer lifting; + + @ApiModelProperty("作品ids") + private List typeIds; + + @ApiModelProperty("项目大厅") + private Boolean isHall = false; + + @ApiModelProperty(value = "关键字搜索") + private String keyword; + + @ApiModelProperty("是否高端认证:1:普通技术 2高端技术") + private Integer ifHighend; + + @ApiModelProperty("查询设计师和表现师互相之间的订单") + private Boolean isEachOther = false; + + @ApiModelProperty("查询设计师和表现师互相之间的订单,对方的用户ID") + private Long otherUserId; + + @ApiModelProperty("查询设计师和表现师互相之间的订单,对方的用户类型 通过判断来处理") + private Integer otherUserType; + + + @ApiModelProperty(value = "拉黑用户") + private List blockUserList; + + @ApiModelProperty(value = "屏蔽用户") + private List shieldUserList; +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/OrderReleaseReq.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/OrderReleaseReq.java new file mode 100644 index 0000000..d388ff4 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/OrderReleaseReq.java @@ -0,0 +1,56 @@ +package com.ruoyi.controller.req; + +import com.ruoyi.common.annotation.Excel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.math.BigDecimal; +import java.util.Date; + +/** + * @author a + * @date 2023/10/13 9:34 + */ +@Data +public class OrderReleaseReq { + + @ApiModelProperty("作品类型ID") + private Long worksTypeId; + + @ApiModelProperty("订单标题") + @Excel(name = "订单标题") + private String title; + + @ApiModelProperty("订单金额") + private BigDecimal amount; + + @ApiModelProperty("对图时间") + private Date deliverTime; + + @ApiModelProperty("内容") + private String content; + + @ApiModelProperty("素材") + @Excel(name = "素材") + private String sourceMaterial; + + @ApiModelProperty("表现师发布订单传---设计师nickname") + private Long customerId; + + @ApiModelProperty("设计师在表现师主页发布订单传---表现师id") + private Long storeId; + + @ApiModelProperty("支付类型: 1 app支付宝 2 h5支付宝 3 app微信 4 h5微信 5 小程序 6 苹果支付 7 余额") + private Integer payType; + + @ApiModelProperty("使用余额支付时 支付密码") + private String payPwd; + + @ApiModelProperty("图纸张数") + private Integer drawingNum; + + @ApiModelProperty("是否是高端客户 1普通 2 高端 ") + private Integer ifHighend; + + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/OrdinaryAuthReq.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/OrdinaryAuthReq.java new file mode 100644 index 0000000..94784d2 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/OrdinaryAuthReq.java @@ -0,0 +1,68 @@ +package com.ruoyi.controller.req; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.math.BigDecimal; +import java.util.Date; + +/** + * @author a + * @date 2023/10/18 14:04 + */ +@Data +public class OrdinaryAuthReq { + + + @ApiModelProperty("认证类型 1普通认证 3酷家乐") + private Integer type; + + @ApiModelProperty("身份证正面") + private String idFront; + + @ApiModelProperty("身份证反面") + private String idBack; + + @ApiModelProperty("手持身份证照片") + private String idHandHand; + + @ApiModelProperty("姓名") + private String name; + + @ApiModelProperty("身份证号码") + private String idcardNo; + + @ApiModelProperty("性别;性别 S:未知,M:男,F:女") + private String sex; + + @ApiModelProperty("从业时间") + private String practiceDate; + + @ApiModelProperty("擅长领域") + private String specialityArea; + + @ApiModelProperty("区域") + private String area; + + @ApiModelProperty("开户行") + private String bank; + + @ApiModelProperty("开户支行") + private String subbranch; + + @ApiModelProperty("银行卡") + private String bankCard; + + @ApiModelProperty("认证金额") + private BigDecimal amount; + + @ApiModelProperty("支付类型: 1 app支付宝 2 h5支付宝 3 app微信 4 h5微信 5 小程序 6 苹果支付 7 余额") + private Integer payType; + + @ApiModelProperty("使用余额支付时 支付密码") + private String payPwd; + + @ApiModelProperty("工种") + private String branchWork; + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/PlatformRulesPageReq.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/PlatformRulesPageReq.java new file mode 100644 index 0000000..64a8e57 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/PlatformRulesPageReq.java @@ -0,0 +1,18 @@ +package com.ruoyi.controller.req; + +import com.ruoyi.vo.PageBasic; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + * @author a + * @date 2024/1/29 14:40 + */ +@Data +public class PlatformRulesPageReq extends PageBasic { + + @ApiModelProperty("用户类型 1设计师 2表现师") + private Integer userType; + + private Long platformRulesTypeId; +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/ReceiveDrawingsAndPayReq.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/ReceiveDrawingsAndPayReq.java new file mode 100644 index 0000000..ff19865 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/ReceiveDrawingsAndPayReq.java @@ -0,0 +1,24 @@ +package com.ruoyi.controller.req; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + * @author a + * @date 2023/10/13 9:52 + */ +@Data +public class ReceiveDrawingsAndPayReq { + + @ApiModelProperty("订单id") + private Long orderId; + + @ApiModelProperty("支付类型: 1 app支付宝 2 h5支付宝 3 app微信 4 h5微信 5 小程序 6 苹果支付 7 余额") + private Integer payType; + + @ApiModelProperty("使用余额支付时 支付密码") + private String payPwd; + + @ApiModelProperty("是否同意作品进入到会员作品库 1 否 2 同意") + private Integer isAgree = 2; +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/RefuseReq.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/RefuseReq.java new file mode 100644 index 0000000..f4d53c6 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/RefuseReq.java @@ -0,0 +1,18 @@ +package com.ruoyi.controller.req; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + * @author a + * @date 2023/11/15 15:27 + */ +@Data +public class RefuseReq { + + @ApiModelProperty(value = "id") + private Long id; + + @ApiModelProperty(value = "拒绝原因") + private String reason; +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/SampleImagesUploadReq.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/SampleImagesUploadReq.java new file mode 100644 index 0000000..cf18dd8 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/SampleImagesUploadReq.java @@ -0,0 +1,28 @@ +package com.ruoyi.controller.req; + +import com.ruoyi.frequency.orderpanorama.entity.OrderPanorama; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.List; + +/** + * @author a + * @date 2023/10/13 9:50 + */ +@Data +public class SampleImagesUploadReq { + + @ApiModelProperty("订单id") + private Long orderId; + + @ApiModelProperty("作品图片") + private String coverImage; + + @ApiModelProperty("作品图片") + private String images; + + @ApiModelProperty("3D图片") + private List orderPanoramaList; + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/SearchPageReq.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/SearchPageReq.java new file mode 100644 index 0000000..4e99b00 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/SearchPageReq.java @@ -0,0 +1,22 @@ +package com.ruoyi.controller.req; + +import com.ruoyi.vo.PageBasic; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + * @author a + * @date 2023/10/16 11:59 + */ +@Data +public class SearchPageReq extends PageBasic { + + @ApiModelProperty(value = "类型 1作品库 2绘图员 3论坛 4订单") + private Integer type; + + @ApiModelProperty(value = "关键字") + private String keyword; + +} + + diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/SendMessageReq.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/SendMessageReq.java new file mode 100644 index 0000000..26a4d23 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/SendMessageReq.java @@ -0,0 +1,29 @@ +package com.ruoyi.controller.req; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import javax.validation.constraints.NotNull; + +/** + * @author a + * @date 2023/10/16 10:27 + */ +@Data +public class SendMessageReq { + + + @ApiModelProperty("申诉主表id") + @NotNull(message = "申诉id不能为空") + private Long appealId; + + @ApiModelProperty("对话消息;文字或图片") + private String message; + + @ApiModelProperty("图片") + private String images; + + @ApiModelProperty("消息类型") + private String messageType; + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/ShoppingCarCreateOrderReq.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/ShoppingCarCreateOrderReq.java new file mode 100644 index 0000000..c773497 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/ShoppingCarCreateOrderReq.java @@ -0,0 +1,29 @@ +package com.ruoyi.controller.req; + +import lombok.Data; + +import java.math.BigDecimal; +import java.util.List; + +/** + * @author a + * @date 2023/2/14 10:45 + */ +@Data +public class ShoppingCarCreateOrderReq { + + private List shoppingCardIdList;//购物车id + + private Long addressId;//用户地址id + + private String remark;//备注 + + private Integer payType = -1;//支付方式,-1 不使用 1:支付宝 2 微信 + + private String balancePayPwd;//选择余额支付的时候密码校验 + + private BigDecimal commissionPrice;//佣金金额 不使用佣金余额支付时为空 + + private BigDecimal integralPrice;//积分金额 不使用积分金额支付时为空 + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/ShoppingCartSettlementReq.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/ShoppingCartSettlementReq.java new file mode 100644 index 0000000..476ec05 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/ShoppingCartSettlementReq.java @@ -0,0 +1,18 @@ +package com.ruoyi.controller.req; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.List; + +/** + * @Author 刘耀 + * @Date 2022/1/17 16:17 + */ +@Data +public class ShoppingCartSettlementReq { + + @ApiModelProperty(value = "购物车id集合") + private List shoppingCardIdList; + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/StatisticsReq.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/StatisticsReq.java new file mode 100644 index 0000000..5486483 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/StatisticsReq.java @@ -0,0 +1,10 @@ +package com.ruoyi.controller.req; + +import lombok.Data; + +@Data +public class StatisticsReq { + + //1 普通 2 高端 3 酷家乐 + private Integer ifHighend; +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/TxContentReq.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/TxContentReq.java new file mode 100644 index 0000000..72d54eb --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/TxContentReq.java @@ -0,0 +1,8 @@ +package com.ruoyi.controller.req; + +import lombok.Data; + +@Data +public class TxContentReq { + private String content; +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/UpscaleAuthReq.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/UpscaleAuthReq.java new file mode 100644 index 0000000..9843b88 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/UpscaleAuthReq.java @@ -0,0 +1,18 @@ +package com.ruoyi.controller.req; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + * @author a + * @date 2023/10/18 14:05 + */ +@Data +public class UpscaleAuthReq { + + @ApiModelProperty("支付类型: 1 app支付宝 2 h5支付宝 3 app微信 4 h5微信 5 小程序 6 苹果支付 7 余额") + private Integer payType; + + @ApiModelProperty("使用余额支付时 支付密码") + private String payPwd; +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/VoteCommentPageReq.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/VoteCommentPageReq.java new file mode 100644 index 0000000..4bddd92 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/VoteCommentPageReq.java @@ -0,0 +1,36 @@ +package com.ruoyi.controller.req; + +import com.ruoyi.vo.PageBasic; +import com.ruoyi.vo.UserVo; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import javax.validation.constraints.NotNull; +import java.util.List; + +/** + * @author liwenlong + * @date 2023/4/17 14:18 + */ +@Data +public class VoteCommentPageReq extends PageBasic { + + @NotNull(message = "投票id不能为空") + @ApiModelProperty(value = "投票id", required = true) + private Long voteId; + + @ApiModelProperty(value = "上级评论id", required = false) + private Long parentId; + + @ApiModelProperty("排序 1时间 2热度") + private Integer sortType; + + @ApiModelProperty(value = "1升序 2 降序") + private Integer isAsc; + + @ApiModelProperty(value = "拉黑用户") + private List blockUserList; + + @ApiModelProperty(value = "屏蔽用户") + private List shieldUserList; +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/VoteCommentReq.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/VoteCommentReq.java new file mode 100644 index 0000000..58144a2 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/VoteCommentReq.java @@ -0,0 +1,29 @@ +package com.ruoyi.controller.req; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import javax.validation.constraints.NotNull; + +/** + * @author liwenlong + * @date 2023/4/17 14:17 + */ +@Data +public class VoteCommentReq { + + + @NotNull(message = "投票id不能为空") + @ApiModelProperty(value = "投票id", required = true) + private Long voteId; + + @ApiModelProperty(value = "上级评论id,如果没有上级评论,(不传值默认0,评论帖子)") + private Long parentId = 0L; + + @ApiModelProperty(value = "评论内容", required = true) + @NotNull(message = "评论内容不能为空") + private String content; + + @ApiModelProperty("评论图片") + private String image; +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/VoteLikeReq.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/VoteLikeReq.java new file mode 100644 index 0000000..c64b148 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/VoteLikeReq.java @@ -0,0 +1,21 @@ +package com.ruoyi.controller.req; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import javax.validation.constraints.NotNull; + +@Data +public class VoteLikeReq { + + + @NotNull(message = "投票id不能为空") + @ApiModelProperty("投票id") + private Long objectId; + + /** + * 1 投票 2 作品评论 + */ + @NotNull(message = "类型不能为空") + private Integer type; +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/VoteReq.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/VoteReq.java new file mode 100644 index 0000000..5bc4023 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/VoteReq.java @@ -0,0 +1,23 @@ +package com.ruoyi.controller.req; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.List; + +/** + * @author a + * @date 2023/10/12 16:34 + */ +@Data +public class VoteReq { + + @ApiModelProperty(value = "投票id") + private Long voteId; + + @ApiModelProperty(value = "投票选项id") + private Long voteOptionId; + + @ApiModelProperty(value = "投票选项ids") + private List voteOptionIds; +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/WorksCommentPageReq.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/WorksCommentPageReq.java new file mode 100644 index 0000000..010b860 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/WorksCommentPageReq.java @@ -0,0 +1,36 @@ +package com.ruoyi.controller.req; + +import com.ruoyi.vo.PageBasic; +import com.ruoyi.vo.UserVo; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import javax.validation.constraints.NotNull; +import java.util.List; + +/** + * @author liwenlong + * @date 2023/4/17 14:18 + */ +@Data +public class WorksCommentPageReq extends PageBasic { + + @NotNull(message = "作品id不能为空") + @ApiModelProperty(value = "作品id", required = true) + private Long worksId; + + @ApiModelProperty(value = "上级评论id", required = false) + private Long parentId; + + @ApiModelProperty(value = "拉黑用户") + private List blockUserList; + + @ApiModelProperty(value = "屏蔽用户") + private List shieldUserList; + + @ApiModelProperty("排序 1时间 2热度") + private Integer sortType; + + @ApiModelProperty(value = "1升序 2 降序") + private Integer isAsc; +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/WorksCommentReq.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/WorksCommentReq.java new file mode 100644 index 0000000..ce5d669 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/WorksCommentReq.java @@ -0,0 +1,29 @@ +package com.ruoyi.controller.req; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import javax.validation.constraints.NotNull; + +/** + * @author liwenlong + * @date 2023/4/17 14:17 + */ +@Data +public class WorksCommentReq { + + + @NotNull(message = "作品id不能为空") + @ApiModelProperty(value = "作品id", required = true) + private Long worksId; + + @ApiModelProperty(value = "上级评论id,如果没有上级评论,(不传值默认0,评论作品)") + private Long parentId = 0L; + + @ApiModelProperty(value = "评论内容", required = true) + @NotNull(message = "评论内容不能为空") + private String content; + + @ApiModelProperty("评论图片") + private String image; +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/WorksLikeReq.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/WorksLikeReq.java new file mode 100644 index 0000000..f3219fa --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/WorksLikeReq.java @@ -0,0 +1,25 @@ +package com.ruoyi.controller.req; + +import lombok.Data; + +import javax.validation.constraints.NotNull; + +/** + * @author a + * @date 2023/10/12 15:15 + */ +@Data +public class WorksLikeReq { + + /** + * 点赞对象id + */ + @NotNull(message = "点赞对象id不能为空") + private Long objectId; + + /** + * 1 作品 2 作品评论 + */ + @NotNull(message = "类型不能为空") + private Integer type; +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/WorksPageReq.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/WorksPageReq.java new file mode 100644 index 0000000..704fecc --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/WorksPageReq.java @@ -0,0 +1,53 @@ +package com.ruoyi.controller.req; + +import com.ruoyi.vo.PageBasic; +import com.ruoyi.vo.UserVo; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.List; + +/** + * @author a + * @date 2023/10/12 11:35 + */ +@Data +public class WorksPageReq extends PageBasic { + + @ApiModelProperty(value = "用户类型 1 用户 对应枚举 UserEnums") + private Integer userType; + + @ApiModelProperty(value = "用户id") + private Long userId; + + @ApiModelProperty(value = "分类id") + private Long typeId; + + + @ApiModelProperty(value = "作品绑定的分类ids") + private List typeIds; + + @ApiModelProperty(value = "关键字") + private String keyword; + + @ApiModelProperty("是否高端;1 普通 2 高端") + private Integer ifHighend; + + @ApiModelProperty("排序方式 1 最新 2 点赞最多 3 评论最多") + private Integer orderSort; + + @ApiModelProperty("是否展示企业作品 1 展示 2 不展示") + private Integer showEnterprise = 1; + + @ApiModelProperty("是否是查看自己的 1 是 2 否") + private Integer isSelf = 2; + + @ApiModelProperty(value = "拉黑用户") + private List blockUserList; + + @ApiModelProperty(value = "屏蔽用户") + private List shieldUserList; + + @ApiModelProperty(value = "屏蔽的作品") + private List shieldWorksIdList; +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/WorksReleaseReq.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/WorksReleaseReq.java new file mode 100644 index 0000000..8410051 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/WorksReleaseReq.java @@ -0,0 +1,48 @@ +package com.ruoyi.controller.req; + +import com.ruoyi.frequency.workspanorama.entity.WorksPanorama; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; + +import java.math.BigDecimal; +import java.util.List; + +/** + * @author a + * @date 2023/10/12 11:34 + */ +@Data +@Accessors(chain = true) +public class WorksReleaseReq { + + @ApiModelProperty(value = "作品类型ID") + private Long worksTypeId; + + @ApiModelProperty(value = "标题") + private String title; + + @ApiModelProperty(value = "封面图") + private String coverImage; + + @ApiModelProperty(value = "作品图片") + private String images; + + @ApiModelProperty(value = "价格(订单来源的作品)") + private BigDecimal price; + + @ApiModelProperty(value = "来源 1 手动创建 2 订单同步") + private Integer source = 1; + + @ApiModelProperty(value = "订单id") + private Long orderId; + + @ApiModelProperty(value = "设计师ID") + private Long customerId; + + @ApiModelProperty(value = "3D图") + private List worksPanoramaList; + + @ApiModelProperty("是否是高端客户 1普通 2 高端 ") + private Integer ifHighend; +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/WorksReportReq.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/WorksReportReq.java new file mode 100644 index 0000000..4f99223 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/WorksReportReq.java @@ -0,0 +1,30 @@ +package com.ruoyi.controller.req; + +import lombok.Data; + +/** + * @author a + * @date 2023/11/30 15:10 + */ +@Data +public class WorksReportReq { + + /** + * 作品id + */ + private Long worksId; + + /** + * 举报原因 + */ + private String reason; + + /** + * 内容 + */ + private String content; + /** + * 图片 + */ + private String images; +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/WorksStepReq.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/WorksStepReq.java new file mode 100644 index 0000000..b130d06 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/WorksStepReq.java @@ -0,0 +1,18 @@ +package com.ruoyi.controller.req; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import javax.validation.constraints.NotNull; + +/** + * @author a + * @date 2023/10/12 15:15 + */ +@Data +public class WorksStepReq { + + @NotNull(message = "作品id不能为空") + @ApiModelProperty("作品id") + private Long workId; +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/calculateAmountReq.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/calculateAmountReq.java new file mode 100644 index 0000000..a2e13d4 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/req/calculateAmountReq.java @@ -0,0 +1,19 @@ +package com.ruoyi.controller.req; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.math.BigDecimal; + +/** + * @author a + * @date 2023/11/9 11:20 + */ +@Data +public class calculateAmountReq { + + @ApiModelProperty("类型 1订单首款支付 2订单尾款支付") + private Integer type; + + private BigDecimal amount; +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/resp/ActivityDetailResp.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/resp/ActivityDetailResp.java new file mode 100644 index 0000000..3522281 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/resp/ActivityDetailResp.java @@ -0,0 +1,7 @@ +package com.ruoyi.controller.resp; + +import lombok.Data; + +@Data +public class ActivityDetailResp { +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/resp/ActivityPageResp.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/resp/ActivityPageResp.java new file mode 100644 index 0000000..95d2256 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/resp/ActivityPageResp.java @@ -0,0 +1,42 @@ +package com.ruoyi.controller.resp; + +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.Date; + +@Data +public class ActivityPageResp extends BaseEntity { + + @ApiModelProperty("租户号") + private Long id; + + @ApiModelProperty("删除标志;1 正常 2 删除 3 禁用") + private Long delFlag; + + @ApiModelProperty("标题") + @Excel(name = "标题") + private String title; + + @ApiModelProperty("图片") + @Excel(name = "图片") + private String image; + + @ApiModelProperty("排序") + @Excel(name = "排序") + private Long sort; + + @ApiModelProperty("开始时间") + @Excel(name = "开始时间", width = 30, dateFormat = "yyyy-MM-dd") + private Date startTime; + + @ApiModelProperty("结束时间") + @Excel(name = "结束时间", width = 30, dateFormat = "yyyy-MM-dd") + private Date endTime; + + @ApiModelProperty("浏览量") + @Excel(name = "浏览量") + private Long browseNum; +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/resp/AppealDetailResp.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/resp/AppealDetailResp.java new file mode 100644 index 0000000..46bbb14 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/resp/AppealDetailResp.java @@ -0,0 +1,95 @@ +package com.ruoyi.controller.resp; + +import com.ruoyi.frequency.appealdetail.entity.AppealDetail; +import com.ruoyi.vo.UserInfo; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.math.BigDecimal; +import java.util.Date; +import java.util.List; + +/** + * @author a + * @date 2023/10/16 10:22 + */ +@Data +public class AppealDetailResp { + + @ApiModelProperty("租户号") + private Long id; + + @ApiModelProperty("订单id") + private Long orderId; + + @ApiModelProperty("申诉内容") + private String content; + + @ApiModelProperty("申诉图片/视频") + private String picture; + + @ApiModelProperty("申诉人") + private Long appealUserId; + + @ApiModelProperty("申诉人用户类型") + private Integer appealUserType; + + @ApiModelProperty("被申诉人") + private Long passiveAppealUserId; + + @ApiModelProperty("被申诉人用户类型") + private Integer passiveAppealUserType; + + @ApiModelProperty("申诉结果;状态 1 待处理 2 已处理") + private Integer appealResult; + + @ApiModelProperty("订单编号") + private String orderNo; + + @ApiModelProperty("订单标题") + private String title; + + @ApiModelProperty("订单内容") + private String orderContent; + + @ApiModelProperty("订单素材") + private String sourceMaterial; + + @ApiModelProperty("申诉视频") + private String videoUrl; + + + @ApiModelProperty("订单金额") + private BigDecimal orderAmount; + + @ApiModelProperty(value = "是否高端认证 1 没有 2认证") + private Integer ifHighend; + + @ApiModelProperty("申诉金额") + private BigDecimal amount; + + @ApiModelProperty("申诉人信息") + private UserInfo appealUserInfo; + + @ApiModelProperty("被申诉人信息") + private UserInfo passiveAppealUserInfo; + + @ApiModelProperty("订单时间") + private Date orderTime; + + @ApiModelProperty("退款金额") + private BigDecimal refundPrice; + + + @ApiModelProperty("订单状态") + private Integer orderStatus; + + @ApiModelProperty("投诉删除状态") + private Integer delFlag; + + @ApiModelProperty("投诉创建时间") + private Date createTime; + + @ApiModelProperty("申诉聊天") + private List appealDetailList; +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/resp/AppealMessagePageResp.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/resp/AppealMessagePageResp.java new file mode 100644 index 0000000..e440ab3 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/resp/AppealMessagePageResp.java @@ -0,0 +1,47 @@ +package com.ruoyi.controller.resp; + +import com.ruoyi.vo.UserInfo; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.Date; + +/** + * @author a + * @date 2023/10/16 10:24 + */ +@Data +public class AppealMessagePageResp { + + @ApiModelProperty("租户号") + private Long id; + + @ApiModelProperty("创建时间") + private Date createTime; + + @ApiModelProperty("删除标志 1 正常 2 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("申诉主表id") + private Long appealId; + + @ApiModelProperty("发送消息用户") + private Long sendUserId; + + @ApiModelProperty("发送消息用户类型") + private Integer sendUserType; + + @ApiModelProperty("对话消息;文字或图片") + private String message; + + @ApiModelProperty("图片") + private String images; + + @ApiModelProperty("消息类型") + private String messageType; + + @ApiModelProperty("发送消息用户信息") + private UserInfo sendUserInfo; + + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/resp/AppealPageResp.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/resp/AppealPageResp.java new file mode 100644 index 0000000..1d2cc0f --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/resp/AppealPageResp.java @@ -0,0 +1,79 @@ +package com.ruoyi.controller.resp; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.math.BigDecimal; +import java.util.Date; + +/** + * @author a + * @date 2023/10/16 10:20 + */ +@Data +public class AppealPageResp { + + @ApiModelProperty("租户号") + private Long id; + + @ApiModelProperty("订单id") + private Long orderId; + + @ApiModelProperty("申诉内容") + private String content; + + @ApiModelProperty("申诉图片/视频") + private String picture; + + @ApiModelProperty("申诉人") + private Long appealUserId; + + @ApiModelProperty("申诉人用户类型") + private Integer appealUserType; + + @ApiModelProperty("被申诉人") + private Long passiveAppealUserId; + + @ApiModelProperty("被申诉人用户类型") + private Integer passiveAppealUserType; + + @ApiModelProperty("申诉结果;状态 1 待处理 2 已处理") + private Integer appealResult; + + @ApiModelProperty("订单编号") + private String orderNo; + + @ApiModelProperty("订单标题") + private String title; + + @ApiModelProperty("订单内容") + private String orderContent; + + @ApiModelProperty("订单素材") + private String sourceMaterial; + + @ApiModelProperty("申诉视频") + private String videoUrl; + + + @ApiModelProperty("订单金额") + private BigDecimal orderAmount; + + @ApiModelProperty("申诉金额") + private BigDecimal amount; + + @ApiModelProperty("订单时间") + private Date orderTime; + + @ApiModelProperty("投诉时间") + private Date createTime; + + @ApiModelProperty("订单状态") + private Integer orderStatus; + + @ApiModelProperty("退款金额") + private BigDecimal refundPrice; + + + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/resp/CommentPageResp.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/resp/CommentPageResp.java new file mode 100644 index 0000000..14530ff --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/resp/CommentPageResp.java @@ -0,0 +1,66 @@ +package com.ruoyi.controller.resp; + +import com.ruoyi.vo.UserInfo; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.Date; +import java.util.List; + +@Data +public class CommentPageResp { + + @ApiModelProperty(value = "租户号") + private Long id; + + @ApiModelProperty(value = "创建时间") + private Date createTime; + + @ApiModelProperty(value = "用户类型") + private Integer userType; + + @ApiModelProperty(value = "用户id") + private Long userId; + + @ApiModelProperty(value = "上级用户类型") + private Integer parentUserType; + + @ApiModelProperty(value = "上级用户id") + private Long parentUserId; + + @ApiModelProperty(value = "上级评论id") + private Long parentId; + + @ApiModelProperty(value = "用户信息") + private UserInfo userInfo; + + @ApiModelProperty(value = "上级用户用户昵称") + private UserInfo parentUserInfo; + + @ApiModelProperty(value = "内容") + private String content; + + @ApiModelProperty(value = "图片") + private String image; + + @ApiModelProperty(value = "点赞数") + private Integer likeNum; + + @ApiModelProperty(value = "评论数") + private Integer commentNum; + + @ApiModelProperty(value = "是否点赞 1 没有 2 点赞") + private Integer isLike; + + @ApiModelProperty(value = "是否自己 1 不是 2 是自己") + private Integer isSelf; + + @ApiModelProperty(value = "是否精选评论 1 不是 2 是") + private Integer isSelectedComment; + + @ApiModelProperty("顶级评论id") + private Long topId; + + @ApiModelProperty(value = "二级评论") + private List childrenList; +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/resp/CommentResp.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/resp/CommentResp.java new file mode 100644 index 0000000..2a8a0e4 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/resp/CommentResp.java @@ -0,0 +1,54 @@ +package com.ruoyi.controller.resp; + +import com.ruoyi.vo.UserInfo; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.Date; + +@Data +public class CommentResp { + + @ApiModelProperty(value = "评论id") + private Long id; + + @ApiModelProperty(value = "上级评论id") + private Long parentId; + + @ApiModelProperty(value = "评论内容") + private String content; + + @ApiModelProperty(value = "点赞数") + private Integer likeNum; + + @ApiModelProperty(value = "评论数") + private Integer commentNum; + + @ApiModelProperty(value = "是否点赞1没有 2点赞") + private Integer isLike; + + + @ApiModelProperty(value = "评论时间") + private Date createTime; + + @ApiModelProperty("用户类型") + private Integer userType; + + @ApiModelProperty("评论用户id") + private Long userId; + + @ApiModelProperty(value = "评论用户信息") + private UserInfo userInfo; + + @ApiModelProperty("用户类型") + private Integer parentUserType; + + @ApiModelProperty("上级评论用户id") + private Long parentUserId; + + @ApiModelProperty("顶级评论id") + private Long topId; + + @ApiModelProperty(value = "上级评论用户信息") + private UserInfo parentUserInfo; +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/resp/GoodsDetailResp.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/resp/GoodsDetailResp.java new file mode 100644 index 0000000..52792e5 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/resp/GoodsDetailResp.java @@ -0,0 +1,82 @@ +package com.ruoyi.controller.resp; + +import com.ruoyi.frequency.mallspecifications.entity.MallSpecifications; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; +import java.math.BigDecimal; +import java.util.List; + +/** + * 商品表 + * + * @author liwenlong + * @date 2023-02-13 + */ +@Data +public class GoodsDetailResp implements Serializable { + /** + * 主键id + */ + private Long id; + /** + * 商品名称 + */ + private String name; + /** + * 轮播图 + */ + private String rotationImages; + /** + * 描述 + */ + private String describe; + /** + * 价格(展示用) + */ + private String price; + + /** + * 会员价格(展示用) + */ + private String memberPrice; + + /** + * 商品详情 + */ + private String detail; + + /** + * 会员优惠比例 + */ + private BigDecimal ratio; + + /** + * 外链 + */ + private String goodsUrl; + + /** + * 外链类型 + */ + private Integer urlType; + + private Long goodsTypeId;//商品类型id + + private String goodsTypeName; + + /** + * 封面图 + */ + private String coverImage; + + @ApiModelProperty("销量") + private Integer sales; + + /** + * 商品规格 + */ + private List goodsSpecList; + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/resp/GoodsPageResp.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/resp/GoodsPageResp.java new file mode 100644 index 0000000..a27f02d --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/resp/GoodsPageResp.java @@ -0,0 +1,69 @@ +package com.ruoyi.controller.resp; + +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.frequency.mallspecifications.entity.MallSpecifications; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; +import java.math.BigDecimal; +import java.util.List; + +/** + * 商品表 + * + * @author liwenlong + * @date 2023-02-13 + */ +@Data +public class GoodsPageResp implements Serializable { + /** + * 主键id + */ + private Long id; + /** + * 商品名称 + */ + private String name; + /** + * 封面图 + */ + private String coverImage; + /** + * 描述 + */ + private String describe; + /** + * 价格(展示用) + */ + private String price; + + /** + * 会员价格(展示用) + */ + private String memberPrice; + + + private BigDecimal ratio; + + /** + * 外链 + */ + private String goodsUrl; + + /** + * 外链类型 + */ + private Integer urlType; + + private Long goodsTypeId;//商品类型id + + private String goodsTypeName; + + @ApiModelProperty("销量") + private Integer sales; + /** + * 商品规格 + */ + private List goodsSpecList; +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/resp/HomeDataResp.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/resp/HomeDataResp.java new file mode 100644 index 0000000..f6bcf5a --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/resp/HomeDataResp.java @@ -0,0 +1,49 @@ +package com.ruoyi.controller.resp; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.math.BigDecimal; + +/** + * @author a + * @date 2023/10/19 9:14 + */ +@Data +public class HomeDataResp { + + @ApiModelProperty("入驻技术") + private Integer storeNum; + + @ApiModelProperty("入驻设计师") + private Integer customerNum; + + @ApiModelProperty("入驻推广员") + private Integer saleNum; + + @ApiModelProperty("佣金排名") + private Integer commissionRanking; + + @ApiModelProperty("推广排名") + private Integer saleRanking; + + @ApiModelProperty("邀请码") + private String inviteCode; + + + @ApiModelProperty("头像") + private String avatar; + + @ApiModelProperty("昵称") + private String nickname; + + @ApiModelProperty("姓名") + private String name; + + + @ApiModelProperty("累计佣金") + private BigDecimal income; + + @ApiModelProperty("推广人数") + private Integer inviteNum; +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/resp/LevelResp.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/resp/LevelResp.java new file mode 100644 index 0000000..fa7dfac --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/resp/LevelResp.java @@ -0,0 +1,33 @@ +package com.ruoyi.controller.resp; + +import com.ruoyi.frequency.level.entity.Level; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.math.BigDecimal; + +/** + * @author a + * @date 2023/10/24 9:06 + */ +@Data +public class LevelResp { + + @ApiModelProperty(value = "等级") + private String level; + + @ApiModelProperty(value = "下一级") + private String nextLevel; + + @ApiModelProperty(value = "用户消费金额") + private BigDecimal price; + + @ApiModelProperty(value = "当前等级消费金额") + private BigDecimal levelPrice; + + @ApiModelProperty(value = "下一级消费金额") + private BigDecimal nextLevelPrice; + + @ApiModelProperty(value = "等级") + private Level levelVo; +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/resp/MallOrderDetailResp.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/resp/MallOrderDetailResp.java new file mode 100644 index 0000000..fed52da --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/resp/MallOrderDetailResp.java @@ -0,0 +1,144 @@ +package com.ruoyi.controller.resp; + +import com.ruoyi.frequency.mallevaluate.entity.MallEvaluate; +import com.ruoyi.frequency.mallorderaddress.entity.MallOrderAddress; +import com.ruoyi.frequency.mallordergoods.entity.MallOrderGoods; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.math.BigDecimal; +import java.util.Date; +import java.util.List; + +/** + * @author a + * @date 2023/2/15 11:12 + */ +@Data +public class MallOrderDetailResp { + /** + * 主键id + */ + private Long id; + + /** + * 创建时间time + */ + private Date createTime; + + /** + * 用户id + */ + private Long customerId; + + /** + * 商品总价 + */ + private BigDecimal goodsPrice; + + /** + * 支付价格 + */ + private BigDecimal payPrice; + + /** + * 订单号(不作为支付订单号) + */ + private String orderNo; + + /** + * 支付状态1:未支付;2:成功,3;失败 + */ + private Integer payStatus; + + /** + * 订单状态;具体看代码 + */ + private Integer orderStatus; + + /** + * 支付时间time + */ + private Date payTime; + + /** + * 取消订单时间time + */ + private Date cancelTime; + + /** + * 发货时间time + */ + private Date sendTime; + + /** + * 收货时间time + */ + private Date receiveTime; + + /** + * 完成时间time + */ + private Date completeTime; + + /** + * 发货物流单号 + */ + private String sendComCourierId; + + /** + * 发货物流公司 + */ + private String sendComLogistics; + + /** + * 发货物流公司编码 + */ + private String sendComLogisticsCode; + + /** + * 备注 + */ + private String remark; + + /** + * 支付方式,1:支付宝;2微信3余额 + */ + private Integer payType; + + /** + * 到账时间time + */ + private Date arrivalTime; + + /** + * 佣金 + */ + private BigDecimal commissionPrice; + + /** + * 积分 + */ + private BigDecimal integralPrice; + + + @ApiModelProperty("订单地址") + private MallOrderAddress orderAddress; + + @ApiModelProperty("订单商品") + private List orderGoodsList; + + @ApiModelProperty("自动确认收货时间") + private Date voluntarilyReceiptTime; + + @ApiModelProperty("售后截止时间") + private Date afterSalesTime; + + @ApiModelProperty("售后状态") + private Integer refundStatus; + + @ApiModelProperty("评价") + private MallEvaluate evaluate; + + private Date currentTime = new Date(); +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/resp/MallOrderPageResp.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/resp/MallOrderPageResp.java new file mode 100644 index 0000000..f56f4bf --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/resp/MallOrderPageResp.java @@ -0,0 +1,72 @@ +package com.ruoyi.controller.resp; + +import com.baomidou.mybatisplus.annotation.TableField; +import com.ruoyi.frequency.mallordergoods.entity.MallOrderGoods; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.math.BigDecimal; +import java.util.Date; +import java.util.List; + +/** + * @author a + * @date 2023/2/15 10:41 + */ +@Data +public class MallOrderPageResp { + + @ApiModelProperty("订单id") + private Long orderId; + + @ApiModelProperty("订单状态") + private Integer orderStatus; + + @ApiModelProperty("订单总价") + private BigDecimal goodsPrice; + + @ApiModelProperty("订单实付金额") + private BigDecimal payPrice; + + @ApiModelProperty("是否是售后 1不是 2 是") + private Integer isRefund; + + @ApiModelProperty("售后状态 1申请退款退货,2商家同意退款退货,3 用户发货 4 商家确认收货 5 商家拒绝退款退货") + private Integer refundStatus; + + @ApiModelProperty("订单积分") + private BigDecimal integralPrice; + + @ApiModelProperty("订单编号") + private String orderNo; + + @ApiModelProperty("订单商品") + private List orderGoodsList; + + @ApiModelProperty("发货时间time") + private Date sendTime; + + @ApiModelProperty("收货时间time") + private Date receiveTime; + + @ApiModelProperty("完成时间time") + private Date completeTime; + + @ApiModelProperty("发货物流单号") + private String sendComCourierId; + + @ApiModelProperty("发货物流公司") + private String sendComLogistics; + + @ApiModelProperty("发货物流公司编码") + private String sendComLogisticsCode; + + + @ApiModelProperty("开始时间") + @TableField(exist = false) + private Date beginTime; + + @ApiModelProperty("结束时间") + @TableField(exist = false) + private Date endTime; +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/resp/MessageOrderPageResp.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/resp/MessageOrderPageResp.java new file mode 100644 index 0000000..4feaf89 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/resp/MessageOrderPageResp.java @@ -0,0 +1,51 @@ +package com.ruoyi.controller.resp; + +import com.baomidou.mybatisplus.annotation.TableField; +import com.ruoyi.frequency.ordermessage.entity.OrderMessageUtil; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.Date; + +@Data +public class MessageOrderPageResp { + + private Long orderId; + + private Integer orderType; + + /** + * 1未读 2 已读 + */ + private Integer isRead; + + /** + * 消息时间 + */ + private Date createTime; + + /** + * 消息类型 + */ + private Integer messageType; + + /** + * 消息标题 + */ + private String title; + + /** + * 消息内容 + */ + private String content; + + + @ApiModelProperty("订单信息") + @TableField(exist = false) + private OrderDetailResp order; + + @ApiModelProperty("商城订单信息") + @TableField(exist = false) + private MallOrderPageResp mallOrder; + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/resp/NewsDetailResp.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/resp/NewsDetailResp.java new file mode 100644 index 0000000..a22eecd --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/resp/NewsDetailResp.java @@ -0,0 +1,7 @@ +package com.ruoyi.controller.resp; + +import lombok.Data; + +@Data +public class NewsDetailResp { +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/resp/NewsPageResp.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/resp/NewsPageResp.java new file mode 100644 index 0000000..c46d853 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/resp/NewsPageResp.java @@ -0,0 +1,7 @@ +package com.ruoyi.controller.resp; + +import lombok.Data; + +@Data +public class NewsPageResp { +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/resp/OrderDataResp.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/resp/OrderDataResp.java new file mode 100644 index 0000000..f2f340d --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/resp/OrderDataResp.java @@ -0,0 +1,24 @@ +package com.ruoyi.controller.resp; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.math.BigDecimal; + +/** + * @author a + * @date 2023/10/23 10:46 + */ +@Data +public class OrderDataResp { + + @ApiModelProperty(value = "累计订单金额") + private BigDecimal amount = BigDecimal.ZERO; + + @ApiModelProperty(value = "收益") + private BigDecimal income = BigDecimal.ZERO; + + @ApiModelProperty(value = "订单数量") + private Integer orderNum = 0; + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/resp/OrderDetailResp.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/resp/OrderDetailResp.java new file mode 100644 index 0000000..07de4fa --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/resp/OrderDetailResp.java @@ -0,0 +1,224 @@ +package com.ruoyi.controller.resp; + +import com.fasterxml.jackson.annotation.JsonFormat; +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.frequency.orderchangerecord.entity.OrderChangeRecord; +import com.ruoyi.frequency.orderevaluate.entity.OrderEvaluate; +import com.ruoyi.frequency.orderextensionrecord.entity.OrderExtensionRecord; +import com.ruoyi.frequency.orderpanorama.entity.OrderPanorama; +import com.ruoyi.frequency.orderreceiving.entity.OrderReceiving; +import com.ruoyi.vo.UserInfo; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.math.BigDecimal; +import java.util.Date; +import java.util.List; + +/** + * @author a + * @date 2023/10/13 9:58 + */ +@Data +public class OrderDetailResp { + + @ApiModelProperty("租户号") + private Long id; + + @ApiModelProperty("创建时间") + private Date createTime; + + @ApiModelProperty("删除标志;1 正常 2 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("订单标题") + @Excel(name = "订单标题") + private String title; + + @ApiModelProperty("素材") + @Excel(name = "素材") + private String sourceMaterial; + + @ApiModelProperty("原价") + @Excel(name = "原价") + private BigDecimal originAmount; + + @ApiModelProperty("订单金额") + @Excel(name = "订单金额") + private BigDecimal amount; + + @ApiModelProperty("改价后金额(客户确认后,改价后金额同步到amount中)") + @Excel(name = "改价后金额(客户确认后,改价后金额同步到amount中)") + private BigDecimal changeAmount; + + @ApiModelProperty("提出改价的用户身份 1 设计师 2 表现师") + @Excel(name = "提出改价的用户身份 1 设计师 2 表现师") + private Integer changeUserType; + + @ApiModelProperty("改价状态 1 待确认 2 已确认") + @Excel(name = "改价状态 1 待确认 2 已确认") + private Integer changeStatus; + + @ApiModelProperty("价格调整备注") + @Excel(name = "价格调整备注") + private String changeRemark; + + @ApiModelProperty("对图时间") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm") + @Excel(name = "对图时间", width = 30, dateFormat = "yyyy-MM-dd") + private Date confirmDate; + + @ApiModelProperty("设计师id") + @Excel(name = "设计师id") + private Long customerId; + + @ApiModelProperty("表现师id") + @Excel(name = "表现师id") + private Long storeId; + + @ApiModelProperty("销售从中拿到的佣金") + @Excel(name = "销售从中拿到的佣金") + private BigDecimal saleAmount; + + @ApiModelProperty("销售id") + @Excel(name = "销售id") + private Long saleId; + + @ApiModelProperty("内容") + @Excel(name = "内容") + private String content; + + @ApiModelProperty("订单状态;-1 已取消 1待确认 2进行中 3待收图 4待评价 5已评价 ") + @Excel(name = "订单状态;-1 已取消 1待确认 2进行中 3待收图 4待评价 5已评价 ") + private Integer status; + + @ApiModelProperty("申诉状态;1无申诉 2申诉中 3申诉完成") + @Excel(name = "申诉状态;1无申诉 2申诉中 3申诉完成") + private String appealStatus; + + @ApiModelProperty("申请用户类型 1 设计师 2 表现师") + @Excel(name = "申请用户类型 1 设计师 2 表现师") + private Integer appealUserType; + + @ApiModelProperty("申诉id") + private Long appealId; + + @ApiModelProperty("订单来源 1 设计师自己下单 2 表现师帮设计师下单") + @Excel(name = "订单来源 1 设计师自己下单 2 表现师帮设计师下单") + private Integer sourceUserType; + + @ApiModelProperty("封面图") + @Excel(name = "封面图") + private String coverImage; + + @ApiModelProperty("作品图片") + @Excel(name = "作品图片") + private String images; + + @ApiModelProperty("首款") + @Excel(name = "首款") + private BigDecimal firstPrice; + + @ApiModelProperty("首款支付状态 1 未支付 2 已支付") + @Excel(name = "首款支付状态 1 未支付 2 已支付") + private Integer firstStatus; + + @ApiModelProperty("首款支付方式 1app支付宝 2 h5支付宝 3 app微信 4 h5微信 5 小程序 6 苹果支付 7 余额") + @Excel(name = "首款支付方式 1app支付宝 2 h5支付宝 3 app微信 4 h5微信 5 小程序 6 苹果支付 7 余额") + private Integer firstPayType; + + @ApiModelProperty("尾款支付方式 1app支付宝 2 h5支付宝 3 app微信 4 h5微信 5 小程序 6 苹果支付 7 余额") + @Excel(name = "尾款支付方式 1app支付宝 2 h5支付宝 3 app微信 4 h5微信 5 小程序 6 苹果支付 7 余额") + private Integer secondPayType; + + @ApiModelProperty("订单号") + @Excel(name = "订单号") + private String orderNo; + + @ApiModelProperty("支付宝支付返回的订单号") + @Excel(name = "支付宝支付返回的订单号") + private String aliBusinessId; + + @ApiModelProperty("首款支付时间") + @Excel(name = "首款支付时间", width = 30, dateFormat = "yyyy-MM-dd") + private Date firstPayTime; + + @ApiModelProperty("尾款支付时间") + @Excel(name = "尾款支付时间", width = 30, dateFormat = "yyyy-MM-dd") + private Date secondPayTime; + + @ApiModelProperty("作品类型ID") + private Long worksTypeId; + + @ApiModelProperty("作品类型名称") + private String worksTypeName; + + + @ApiModelProperty("首款支付单号") + private String firstPayOrderNo; + + @ApiModelProperty("尾款支付单号") + private String secondPayOrderNo; + + @ApiModelProperty("图纸张数") + private Integer drawingNum; + + + @ApiModelProperty("原始交付时间") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm") + private Date originDeliverTime; + + @ApiModelProperty("交付时间") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm") + private Date deliverTime; + + @ApiModelProperty("延期后时间 表现师确认后 更新交付时间") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm") + private Date extensionDeliverTime; + + @ApiModelProperty("延期用户身份 1 设计师 2 表现师") + private Integer extensionUserType; + + @ApiModelProperty("延期状态 1 待确认 2 已确认") + private Integer extensionStatus; + + @ApiModelProperty("延期备注") + private String extensionRemark; + + + @ApiModelProperty("用户(设计师)信息") + private UserInfo customerInfo; + + @ApiModelProperty("是否可以接单 1 不可以 2 可以") + private Integer isReceivingOrder = 1; + + @ApiModelProperty("表现师信息") + private UserInfo storeInfo; + + @ApiModelProperty("确认后调价信息") + private OrderChangeRecord orderChangeRecord; + + @ApiModelProperty("确认后延期信息") + private OrderExtensionRecord orderExtensionRecord; + + @ApiModelProperty("3D图") + private List panoramaList; + + @ApiModelProperty("接单表现师") + private List orderReceivingList; + + @ApiModelProperty("表现师评价信息") + private OrderEvaluate storeOrderEvaluate; + + @ApiModelProperty("设计师师评价信息") + private OrderEvaluate customerOrderEvaluate; + + @ApiModelProperty("1 普通 2 高端 3酷家乐") + private Integer ifHighend; + + @ApiModelProperty("调价变动定金") + private BigDecimal depositAmount; + + @ApiModelProperty("所有的表现师id列表集合") + private String recentlyReceiveStr; +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/resp/OrderPageResp.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/resp/OrderPageResp.java new file mode 100644 index 0000000..75e3cec --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/resp/OrderPageResp.java @@ -0,0 +1,97 @@ +package com.ruoyi.controller.resp; + +import com.fasterxml.jackson.annotation.JsonFormat; +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.vo.UserInfo; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.math.BigDecimal; +import java.util.Date; + +/** + * @author a + * @date 2023/10/13 9:35 + */ +@Data +public class OrderPageResp { + + @ApiModelProperty("租户号") + private Long id; + + @ApiModelProperty("创建时间") + private Date createTime; + + @ApiModelProperty("删除标志;1 正常 2 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("订单标题") + private String title; + + @ApiModelProperty("素材") + private String sourceMaterial; + + @ApiModelProperty("订单金额") + private BigDecimal amount; + + @ApiModelProperty("提出改价的用户身份 1 设计师 2 表现师") + private Integer changeUserType; + + @ApiModelProperty("改价状态 1 待确认 2 已确认") + @Excel(name = "改价状态 1 待确认 2 已确认") + private Integer changeStatus; + + @ApiModelProperty("对图时间") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm") + private Date confirmDate; + + @ApiModelProperty("设计师id") + private Long customerId; + + @ApiModelProperty("表现师id") + private Long storeId; + + @ApiModelProperty("内容") + @Excel(name = "内容") + private String content; + + @ApiModelProperty("订单状态;-1 已取消 1待确认 2进行中 3待收图 4待评价 5已评价 ") + private Integer status; + + @ApiModelProperty("首款") + private BigDecimal firstPrice; + @ApiModelProperty("支付状态 1 未支付 2 已支付") + private Integer firstStatus; + + @ApiModelProperty("图纸张数") + private Integer drawingNum; + + @ApiModelProperty("订单来源 1 设计师自己下单 2 表现师帮设计师下单") + private Integer sourceUserType; + + @ApiModelProperty("作品类型名称") + private String worksTypeName; + + @ApiModelProperty("用户(设计师)信息") + private UserInfo customerInfo; + + @ApiModelProperty("表现师信息") + private UserInfo storeInfo; + + @ApiModelProperty("申诉状态;1无申诉 2申诉中 3申诉完成") + private String appealStatus; + + @ApiModelProperty("申诉id") + private Long appealId; + + @ApiModelProperty("申请用户类型 1 设计师 2 表现师") + @Excel(name = "申请用户类型 1 设计师 2 表现师") + private Integer appealUserType; + + @ApiModelProperty("是否可以接单 1 不可以 2 可以") + private Integer isReceivingOrder = 1; + + @ApiModelProperty("1 普通 2 高端 3酷家乐") + private Integer ifHighend; + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/resp/OrderWorksPricePage.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/resp/OrderWorksPricePage.java new file mode 100644 index 0000000..f2b6ba3 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/resp/OrderWorksPricePage.java @@ -0,0 +1,24 @@ +package com.ruoyi.controller.resp; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.math.BigDecimal; +import java.util.Date; + +/** + * @author a + * @date 2024/1/23 16:15 + */ +@Data +public class OrderWorksPricePage { + + @ApiModelProperty(value = "名称") + private String name; + + @ApiModelProperty(value = "价格") + private BigDecimal price; + + @ApiModelProperty(value = "时间") + private Date createTime; +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/resp/OrdinaryAuthDetailResp.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/resp/OrdinaryAuthDetailResp.java new file mode 100644 index 0000000..8445072 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/resp/OrdinaryAuthDetailResp.java @@ -0,0 +1,11 @@ +package com.ruoyi.controller.resp; + +import lombok.Data; + +/** + * @author a + * @date 2023/10/18 15:06 + */ +@Data +public class OrdinaryAuthDetailResp { +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/resp/ShoppingCarListResp.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/resp/ShoppingCarListResp.java new file mode 100644 index 0000000..ac955c6 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/resp/ShoppingCarListResp.java @@ -0,0 +1,23 @@ +package com.ruoyi.controller.resp; + +import lombok.Data; + +import java.util.ArrayList; +import java.util.List; + +/** + * @author a + * @date 2023/2/13 16:28 + */ +@Data +public class ShoppingCarListResp { + + + //用户购物车列表 + private List effective = new ArrayList<>(); + + //下架的购物车列表 + private List invalid = new ArrayList<>(); + + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/resp/ShoppingCarListVo.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/resp/ShoppingCarListVo.java new file mode 100644 index 0000000..bf6bd0d --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/resp/ShoppingCarListVo.java @@ -0,0 +1,55 @@ +package com.ruoyi.controller.resp; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.math.BigDecimal; + +/** + * @author a + * @date 2023/2/13 16:28 + */ +@Data +public class ShoppingCarListVo { + + @ApiModelProperty(value = "购物车id") + private Long id; + + @ApiModelProperty(value = "商品id") + private Long goodsId; + + @ApiModelProperty(value = "规格id") + private Long specId; + + @ApiModelProperty(value = "商品图片") + private String image; + + @ApiModelProperty(value = "商品封面图") + private String coverImage; + + @ApiModelProperty(value = "销售价") + private BigDecimal price; + + @ApiModelProperty(value = "积分") + private BigDecimal integral; + + @ApiModelProperty(value = "数量") + private Integer quantity; + + @ApiModelProperty(value = "商品名称") + private String goodsName; + + @ApiModelProperty(value = "规格名称") + private String specName; + + @ApiModelProperty(value = "商品规格状态") + private Integer specFlag; + + @ApiModelProperty(value = "商品状态") + private Integer goodsFlag; + + @ApiModelProperty(value = "库存") + private Integer stock; + + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/resp/StatisticsResp.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/resp/StatisticsResp.java new file mode 100644 index 0000000..852355a --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/resp/StatisticsResp.java @@ -0,0 +1,28 @@ +package com.ruoyi.controller.resp; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + * @author a + * @date 2023/10/12 11:18 + */ +@Data +public class StatisticsResp { + + @ApiModelProperty("入驻技术") + private Integer storeNum; + + @ApiModelProperty("在线技术") + private Integer onlineStoreNum; + + @ApiModelProperty("设计师") + private Integer customerNum; + + @ApiModelProperty("在线设计师") + private Integer onlineCustomerNum; + + @ApiModelProperty("成交订单数") + private Integer orderNum; + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/resp/StoreAmountDataResp.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/resp/StoreAmountDataResp.java new file mode 100644 index 0000000..3879d3c --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/resp/StoreAmountDataResp.java @@ -0,0 +1,29 @@ +package com.ruoyi.controller.resp; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.math.BigDecimal; + +/** + * @author a + * @date 2023/10/18 17:27 + */ +@Data +public class StoreAmountDataResp { + + @ApiModelProperty(value = "累计收益") + private BigDecimal income; + + @ApiModelProperty(value = "可提现金额") + private BigDecimal withdrawableAmount; + + @ApiModelProperty(value = "已提现金额") + private BigDecimal withdrawnAmount; + + @ApiModelProperty(value = "待提现金额") + private BigDecimal toBeWithdrawnAmount; + + @ApiModelProperty(value = "扣款") + private BigDecimal violationDeduction; +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/resp/UserDataResp.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/resp/UserDataResp.java new file mode 100644 index 0000000..de1d820 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/resp/UserDataResp.java @@ -0,0 +1,79 @@ +package com.ruoyi.controller.resp; + +import com.ruoyi.vo.UserInfo; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.math.BigDecimal; + +/** + * @author a + * @date 2023/10/18 17:19 + */ +@Data +public class UserDataResp { + + @ApiModelProperty(value = "余额") + private BigDecimal balance; + + @ApiModelProperty(value = "粉丝数") + private Integer fansNum; + + @ApiModelProperty(value = "动态数") + private Integer postNum; + + @ApiModelProperty(value = "收藏数") + private Long collectNum; + + @ApiModelProperty(value = "收藏作品数") + private Long collectWorksNum; + + @ApiModelProperty(value = "收藏动态数") + private Long collectPostNum; + + @ApiModelProperty(value = "收藏新闻数") + private Long collectNewsNum; + + @ApiModelProperty(value = "关注数") + private Integer followNum; + + @ApiModelProperty(value = "收益") + private BigDecimal amount; + + @ApiModelProperty(value = "累计订单") + private Integer orderNum; + + @ApiModelProperty(value = "在线时长:分钟") + private Integer onlineDuration; + + @ApiModelProperty(value = "评分") + private BigDecimal star; + + @ApiModelProperty(value = "作品数") + private Integer worksNum; + + @ApiModelProperty(value = "拉黑数") + private Integer blockNum; + + @ApiModelProperty(value = "屏蔽数") + private Integer shieldNum; + + @ApiModelProperty(value = "浏览数") + private Integer browseNum; + + @ApiModelProperty(value = "累计积分收益") + private BigDecimal accumulateIntegral; + + @ApiModelProperty(value = "积分") + private BigDecimal integral; + + @ApiModelProperty(value = "邀请数") + private Integer inviteNum; + + @ApiModelProperty(value = "本月收益") + private BigDecimal monthAmount; + + @ApiModelProperty(value = "用户信息") + private UserInfo userInfo; + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/resp/VoteCommentPageResp.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/resp/VoteCommentPageResp.java new file mode 100644 index 0000000..27707da --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/resp/VoteCommentPageResp.java @@ -0,0 +1,70 @@ +package com.ruoyi.controller.resp; + +import com.ruoyi.vo.UserInfo; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.Date; +import java.util.List; + +/** + * @author liwenlong + * @date 2023/4/17 14:26 + */ +@Data +public class VoteCommentPageResp { + + @ApiModelProperty(value = "租户号") + private Long id; + + @ApiModelProperty(value = "创建时间") + private Date createTime; + + @ApiModelProperty(value = "用户类型") + private Integer userType; + + @ApiModelProperty(value = "用户id") + private Long userId; + + @ApiModelProperty(value = "上级用户类型") + private Integer parentUserType; + + @ApiModelProperty(value = "上级用户id") + private Long parentUserId; + + @ApiModelProperty(value = "上级评论id") + private Long parentId; + + @ApiModelProperty(value = "用户信息") + private UserInfo userInfo; + + @ApiModelProperty(value = "上级用户用户昵称") + private UserInfo parentUserInfo; + + @ApiModelProperty(value = "内容") + private String content; + + @ApiModelProperty(value = "图片") + private String image; + + @ApiModelProperty(value = "点赞数") + private Integer likeNum; + + @ApiModelProperty(value = "评论数") + private Integer commentNum; + + @ApiModelProperty(value = "是否点赞 1 没有 2 点赞") + private Integer isLike; + + @ApiModelProperty(value = "是否自己 1 不是 2 是自己") + private Integer isSelf; + + @ApiModelProperty(value = "是否精选评论 1 不是 2 是") + private Integer isSelectedComment; + + @ApiModelProperty("顶级评论id") + private Long topId; + + @ApiModelProperty(value = "二级评论") + private List childrenList; +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/resp/VoteCommentResp.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/resp/VoteCommentResp.java new file mode 100644 index 0000000..6f1723e --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/resp/VoteCommentResp.java @@ -0,0 +1,61 @@ +package com.ruoyi.controller.resp; + +import com.ruoyi.vo.UserInfo; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.Date; + +/** + * @author liwenlong + * + */ +@Data +public class VoteCommentResp { + + + @ApiModelProperty(value = "评论id") + private Long id; + + @ApiModelProperty(value = "上级评论id") + private Long parentId; + + @ApiModelProperty(value = "评论内容") + private String content; + + @ApiModelProperty(value = "点赞数") + private Integer likeNum; + + @ApiModelProperty(value = "评论数") + private Integer commentNum; + + @ApiModelProperty(value = "是否点赞1没有 2点赞") + private Integer isLike; + + + @ApiModelProperty(value = "评论时间") + private Date createTime; + + @ApiModelProperty("用户类型") + private Integer userType; + + @ApiModelProperty("评论用户id") + private Long userId; + + @ApiModelProperty(value = "评论用户信息") + private UserInfo userInfo; + + @ApiModelProperty("用户类型") + private Integer parentUserType; + + @ApiModelProperty("上级评论用户id") + private Long parentUserId; + + @ApiModelProperty("顶级评论id") + private Long topId; + + @ApiModelProperty(value = "上级评论用户信息") + private UserInfo parentUserInfo; + + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/resp/VoteDetailResp.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/resp/VoteDetailResp.java new file mode 100644 index 0000000..b1d7f5d --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/resp/VoteDetailResp.java @@ -0,0 +1,70 @@ +package com.ruoyi.controller.resp; + +import com.ruoyi.frequency.voteoption.entity.VoteOption; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.Date; +import java.util.List; + +/** + * @author a + * @date 2023/10/12 17:34 + */ +@Data +public class VoteDetailResp { + + @ApiModelProperty("租户号") + private Long id; + + @ApiModelProperty("创建时间") + private Date createTime; + + @ApiModelProperty("删除标志;1 正常 2 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("标题") + private String title; + + @ApiModelProperty("内容") + private String content; + + @ApiModelProperty("活动截止日期") + private Date cutoffDate; + + @ApiModelProperty("投票发起人;默认官方") + private String initiator; + + + @ApiModelProperty("参与人数") + private Integer num; + + @ApiModelProperty("官方头像") + private String avatar; + + @ApiModelProperty("1单选 2多选") + private Integer type; + + @ApiModelProperty("选择数量") + private Integer pickNum; + + + + @ApiModelProperty("是否投票;1 未投票 2 已投票") + private Integer isVote; + + @ApiModelProperty(value = "是否点赞 1没有 2点赞") + private Integer isLike; + + @ApiModelProperty(value = "点赞数") + private Integer likeNum; + + @ApiModelProperty(value = "浏览数") + private Integer browseNum; + + @ApiModelProperty(value = "评论数") + private Integer commentNum; + + @ApiModelProperty("投票选项") + private List voteOptionList; +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/resp/VotePageResp.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/resp/VotePageResp.java new file mode 100644 index 0000000..d958026 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/resp/VotePageResp.java @@ -0,0 +1,70 @@ +package com.ruoyi.controller.resp; + +import com.fasterxml.jackson.annotation.JsonFormat; +import com.ruoyi.frequency.voteoption.entity.VoteOption; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.Date; +import java.util.List; + +/** + * @author a + * @date 2023/10/12 16:38 + */ +@Data +public class VotePageResp { + + @ApiModelProperty("租户号") + private Long id; + + @ApiModelProperty("创建时间") + private Date createTime; + + @ApiModelProperty("删除标志;1 正常 2 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("标题") + private String title; + + @ApiModelProperty("内容") + private String content; + + @ApiModelProperty("活动截止日期") + @JsonFormat(pattern = "yyyy-MM-dd") + private Date cutoffDate; + + @ApiModelProperty("投票发起人;默认官方") + private String initiator; + + + @ApiModelProperty("参与人数") + private Integer num; + + @ApiModelProperty("官方头像") + private String avatar; + + @ApiModelProperty("1单选 2多选") + private Integer type; + + @ApiModelProperty("选择数量") + private Integer pickNum; + + @ApiModelProperty("是否投票;1 未投票 2 已投票") + private Integer isVote; + + @ApiModelProperty(value = "是否点赞 1没有 2点赞") + private Integer isLike; + + @ApiModelProperty(value = "点赞数") + private Integer likeNum; + + @ApiModelProperty(value = "浏览数") + private Integer browseNum; + + @ApiModelProperty(value = "评论数") + private Integer commentNum; + + @ApiModelProperty("投票选项") + private List voteOptionList; +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/resp/WorksCommentPageResp.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/resp/WorksCommentPageResp.java new file mode 100644 index 0000000..3b7228e --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/resp/WorksCommentPageResp.java @@ -0,0 +1,70 @@ +package com.ruoyi.controller.resp; + +import com.ruoyi.vo.UserInfo; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.Date; +import java.util.List; + +/** + * @author liwenlong + * @date 2023/4/17 14:26 + */ +@Data +public class WorksCommentPageResp { + + @ApiModelProperty(value = "租户号") + private Long id; + + @ApiModelProperty(value = "创建时间") + private Date createTime; + + @ApiModelProperty(value = "用户类型") + private Integer userType; + + @ApiModelProperty(value = "用户id") + private Long userId; + + @ApiModelProperty(value = "上级用户类型") + private Integer parentUserType; + + @ApiModelProperty(value = "上级用户id") + private Long parentUserId; + + @ApiModelProperty(value = "上级评论id") + private Long parentId; + + @ApiModelProperty(value = "用户信息") + private UserInfo userInfo; + + @ApiModelProperty(value = "上级用户用户昵称") + private UserInfo parentUserInfo; + + @ApiModelProperty(value = "内容") + private String content; + + @ApiModelProperty(value = "图片") + private String image; + + @ApiModelProperty(value = "点赞数") + private Integer likeNum; + + @ApiModelProperty(value = "评论数") + private Integer commentNum; + + @ApiModelProperty(value = "是否点赞 1 没有 2 点赞") + private Integer isLike; + + @ApiModelProperty(value = "是否自己 1 不是 2 是自己") + private Integer isSelf; + + @ApiModelProperty(value = "是否精选评论 1 不是 2 是") + private Integer isSelectedComment; + + @ApiModelProperty("顶级评论id") + private Long topId; + + @ApiModelProperty(value = "二级评论") + private List childrenList; +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/resp/WorksCommentResp.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/resp/WorksCommentResp.java new file mode 100644 index 0000000..85927d2 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/resp/WorksCommentResp.java @@ -0,0 +1,62 @@ +package com.ruoyi.controller.resp; + +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.vo.UserInfo; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.Date; + +/** + * @author liwenlong + * + */ +@Data +public class WorksCommentResp { + + + @ApiModelProperty(value = "评论id") + private Long id; + + @ApiModelProperty(value = "上级评论id") + private Long parentId; + + @ApiModelProperty(value = "评论内容") + private String content; + + @ApiModelProperty(value = "点赞数") + private Integer likeNum; + + @ApiModelProperty(value = "评论数") + private Integer commentNum; + + @ApiModelProperty(value = "是否点赞1没有 2点赞") + private Integer isLike; + + + @ApiModelProperty(value = "评论时间") + private Date createTime; + + @ApiModelProperty("用户类型") + private Integer userType; + + @ApiModelProperty("评论用户id") + private Long userId; + + @ApiModelProperty(value = "评论用户信息") + private UserInfo userInfo; + + @ApiModelProperty("用户类型") + private Integer parentUserType; + + @ApiModelProperty("上级评论用户id") + private Long parentUserId; + + @ApiModelProperty("顶级评论id") + private Long topId; + + @ApiModelProperty(value = "上级评论用户信息") + private UserInfo parentUserInfo; + + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/resp/WorksDetailResp.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/resp/WorksDetailResp.java new file mode 100644 index 0000000..85aad97 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/resp/WorksDetailResp.java @@ -0,0 +1,106 @@ +package com.ruoyi.controller.resp; + +import com.ruoyi.frequency.enterprise.entity.Enterprise; +import com.ruoyi.frequency.workspanorama.entity.WorksPanorama; +import com.ruoyi.vo.UserInfo; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.math.BigDecimal; +import java.util.Date; +import java.util.List; + +/** + * @author a + * @date 2023/10/12 14:20 + */ +@Data +public class WorksDetailResp { + + @ApiModelProperty(value = "租户号") + private Long id; + + @ApiModelProperty(value = "删除标志;1 正常 2 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty(value = "作品类型ID") + private Long worksTypeId; + + @ApiModelProperty(value = "标题") + private String title; + + @ApiModelProperty(value = "封面图") + private String coverImage; + + @ApiModelProperty(value = "作品图片") + private String images; + + @ApiModelProperty(value = "价格(订单来源的作品)") + private BigDecimal price; + + private Integer userType; + + @ApiModelProperty(value = "表现师id") + private Long storeId; + + @ApiModelProperty(value = "来源 1 手动创建 2 订单同步") + private Integer source; + + @ApiModelProperty(value = "订单id") + private Long orderId; + + @ApiModelProperty(value = "订单时间") + private Date orderCreateTime; + + + @ApiModelProperty(value = "点赞数") + private Integer likeNum; + + @ApiModelProperty(value = "踩的数量") + private Integer stepNum; + + @ApiModelProperty(value = "评论数") + private Integer commentNum; + + @ApiModelProperty(value = "收藏数") + private Integer collectNum; + + @ApiModelProperty(value = "浏览数") + private Integer browseNum; + + @ApiModelProperty(value = "创建时间") + private Date createTime; + + @ApiModelProperty(value = "用户信息") + private UserInfo userInfo; + + @ApiModelProperty(value = "是否点赞 1没有 2点赞") + private Integer isLike; + + @ApiModelProperty(value = "是否踩赞 1没有 2踩赞") + private Integer isStep; + + @ApiModelProperty(value = "是否收藏 1没有 2收藏") + private Integer isCollect; + + @ApiModelProperty(value = "是否是自己 1不是 2是") + private Integer isSelf; + + @ApiModelProperty(value = "是否是设计师自己的 1不是 2是") + private Integer isCustomerSelf; + + @ApiModelProperty(value = "订单编号") + private String orderNo; + + @ApiModelProperty("是否是高端客户 1普通 2 高端 3酷家乐") + private Integer ifHighend; + + @ApiModelProperty("企业信息") + private Enterprise enterprise; + + @ApiModelProperty(value = "3D 全景图") + private List worksPanoramaList; + + @ApiModelProperty(value = "订单同步 改图明细") + private List OrderWorksPriceList; +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/resp/WorksPageResp.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/resp/WorksPageResp.java new file mode 100644 index 0000000..aa03d3f --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/controller/resp/WorksPageResp.java @@ -0,0 +1,86 @@ +package com.ruoyi.controller.resp; + +import com.ruoyi.frequency.workspanorama.entity.WorksPanorama; +import com.ruoyi.vo.UserInfo; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.math.BigDecimal; +import java.util.Date; +import java.util.List; + +/** + * @author a + * @date 2023/10/12 14:20 + */ +@Data +public class WorksPageResp { + + @ApiModelProperty(value = "租户号") + private Long id; + + @ApiModelProperty(value = "删除标志;1 正常 2 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty(value = "作品类型ID") + private Long worksTypeId; + + @ApiModelProperty(value = "标题") + private String title; + + @ApiModelProperty(value = "封面图") + private String coverImage; + + @ApiModelProperty(value = "作品图片") + private String images; + + @ApiModelProperty(value = "价格(订单来源的作品)") + private BigDecimal price; + + private Integer userType; + + @ApiModelProperty(value = "表现师id") + private Long storeId; + + @ApiModelProperty(value = "来源 1 手动创建 2 订单同步") + private Integer source; + + @ApiModelProperty(value = "来源 1 手动创建 2 订单同步") + private Long orderId; + + @ApiModelProperty(value = "点赞数") + private Long likeNum; + + @ApiModelProperty(value = "踩的数量") + private Long stepNum; + + @ApiModelProperty(value = "评论数") + private Long commentNum; + + @ApiModelProperty(value = "收藏数") + private Long collectNum; + + @ApiModelProperty(value = "浏览数") + private Long browseNum; + + @ApiModelProperty(value = "创建时间") + private Date createTime; + + @ApiModelProperty(value = "用户信息") + private UserInfo userInfo; + + @ApiModelProperty("是否推荐 1否 2是") + private Integer isRecommend; + + @ApiModelProperty(value = "是否点赞 1没有 2点赞") + private Integer isLike; + + @ApiModelProperty("是否高端;1 普通 2 高端") + private Integer ifHighend; + + @ApiModelProperty("推荐排序") + private Integer sort; + + @ApiModelProperty(value = "3D 全景图") + private List worksPanoramaList; +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/activity/controller/ActivityController.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/activity/controller/ActivityController.java new file mode 100644 index 0000000..c032797 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/activity/controller/ActivityController.java @@ -0,0 +1,118 @@ +package com.ruoyi.frequency.activity.controller; + +import java.util.List; + +import com.ruoyi.frequency.activity.model.result.ActivityCount; +import com.ruoyi.frequency.news.entity.News; +import com.ruoyi.frequency.news.model.result.NewsCount; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.frequency.activity.entity.Activity; +import com.ruoyi.frequency.activity.service.ActivityService; +import com.ruoyi.common.utils.poi.ExcelUtil; +import com.ruoyi.common.core.page.TableDataInfo; + +/** + * 活动Controller + * + * @author liwenlong + * @date 2024-03-19 + */ +@RestController +@RequestMapping("/frequency/activity") +public class ActivityController extends BaseController +{ + @Autowired + private ActivityService activityService; + + /** + * 查询活动列表 + */ + @PreAuthorize("@ss.hasPermi('frequency:activity:list')") + @PostMapping("/list") + public TableDataInfo list(@RequestBody Activity activity) + { + startPage(); + List list = activityService.selectActivityList(activity); + return getDataTable(list); + } + + + /** + * 统计 + */ + @PostMapping("/statistics") + public AjaxResult statistics(@RequestBody Activity activity) + { + ActivityCount count = activityService.statistics(activity); + return AjaxResult.success(count); + } + + /** + * 导出活动列表 + */ + @PreAuthorize("@ss.hasPermi('frequency:activity:export')") + @Log(title = "活动", businessType = BusinessType.EXPORT) + @GetMapping("/export") + public AjaxResult export(Activity activity) + { + List list = activityService.selectActivityList(activity); + ExcelUtil util = new ExcelUtil(Activity.class); + return util.exportExcel(list, "活动数据"); + } + + /** + * 获取活动详细信息 + */ + @PreAuthorize("@ss.hasPermi('frequency:activity:query')") + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") Long id) + { + return AjaxResult.success(activityService.selectActivityById(id)); + } + + /** + * 新增活动 + */ + @PreAuthorize("@ss.hasPermi('frequency:activity:add')") + @Log(title = "活动", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody Activity activity) + { + return toAjax(activityService.insertActivity(activity)); + } + + /** + * 修改活动 + */ + @PreAuthorize("@ss.hasPermi('frequency:activity:edit')") + @Log(title = "活动", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody Activity activity) + { + return toAjax(activityService.updateActivity(activity)); + } + + /** + * 删除活动 + */ + @PreAuthorize("@ss.hasPermi('frequency:activity:remove')") + @Log(title = "活动", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}/{delFlag}") + public AjaxResult remove(@PathVariable("ids") Long[] ids,@PathVariable("delFlag") Integer delFlag) + { + return toAjax(activityService.deleteActivityByIds(ids,delFlag)); + } +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/activity/entity/Activity.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/activity/entity/Activity.java new file mode 100644 index 0000000..90bf03d --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/activity/entity/Activity.java @@ -0,0 +1,73 @@ +package com.ruoyi.frequency.activity.entity; + +import java.util.Date; +import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.Data; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.experimental.Accessors; +import com.ruoyi.common.annotation.Excel; +import io.swagger.annotations.ApiModelProperty; +import com.baomidou.mybatisplus.annotation.TableField; +import com.ruoyi.vo.UserInfo; +import com.ruoyi.common.core.domain.BaseEntity; + +/** + * 活动对象 t_activity + * + * @author liwenlong + * @date 2024-03-19 + */ +@Data +@Accessors(chain = true) +@TableName("t_activity") +public class Activity extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + + @ApiModelProperty("租户号") + private Long id; + + @ApiModelProperty("删除标志;1 正常 2 删除 3 禁用") + private Long delFlag; + + @ApiModelProperty("标题") + @Excel(name = "标题") + private String title; + + @ApiModelProperty("内容(富文本)") + private String content; + + @ApiModelProperty("图片") + @Excel(name = "图片") + private String image; + + @ApiModelProperty("排序") + @Excel(name = "排序") + private Long sort; + + @ApiModelProperty("开始时间") + @Excel(name = "开始时间", width = 30, dateFormat = "yyyy-MM-dd") + private Date startTime; + + @ApiModelProperty("结束时间") + @Excel(name = "结束时间", width = 30, dateFormat = "yyyy-MM-dd") + private Date endTime; + + @ApiModelProperty("浏览量") + @Excel(name = "浏览量") + private Integer browseNum; + + @ApiModelProperty("点赞数") + @Excel(name = "点赞数") + private Integer likeNum; + + @ApiModelProperty(value = "是否点赞 1 没有 2 点赞") + @TableField(exist = false) + private Integer isLike; + + @ApiModelProperty(value = "是否自己 1 不是 2 是自己") + @TableField(exist = false) + private Integer isSelf; + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/activity/mapper/ActivityMapper.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/activity/mapper/ActivityMapper.java new file mode 100644 index 0000000..0dad979 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/activity/mapper/ActivityMapper.java @@ -0,0 +1,60 @@ +package com.ruoyi.frequency.activity.mapper; + +import java.util.List; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.ruoyi.common.annotation.DataSource; +import com.ruoyi.common.enums.DataSourceType; +import com.ruoyi.controller.req.ActivityPageReq; +import com.ruoyi.frequency.activity.entity.Activity; +import com.ruoyi.frequency.activity.model.result.ActivityCount; +import com.ruoyi.vo.UserVo; +import org.apache.ibatis.annotations.Param; + +/** + * 活动Mapper接口 + * + * @author liwenlong + * @date 2024-03-19 + */ +@DataSource(DataSourceType.MASTER) +public interface ActivityMapper extends BaseMapper +{ + /** + * 查询活动 + * + * @param id 活动主键 + * @return 活动 + */ + public Activity selectActivityById(Long id); + + /** + * 查询活动列表 + * + * @param activity 活动 + * @return 活动集合 + */ + public List selectActivityList(Activity activity); + + /** + * 新增活动 + * + * @param activity 活动 + * @return 结果 + */ + public int insertActivity(Activity activity); + + /** + * 修改活动 + * + * @param activity 活动 + * @return 结果 + */ + public int updateActivity(Activity activity); + + Page activityPage(@Param("page") Page objectPage,@Param("req") ActivityPageReq req, @Param("userVo") UserVo userVo); + + Activity activityDetail(@Param("id") Long id, @Param("userVo") UserVo userVo); + + ActivityCount statistics(@Param("list") List activityIdList); +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/activity/mapper/mapping/ActivityMapper.xml b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/activity/mapper/mapping/ActivityMapper.xml new file mode 100644 index 0000000..cbd638e --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/activity/mapper/mapping/ActivityMapper.xml @@ -0,0 +1,188 @@ + + + + + + + + + + + + + + + + + + + + + + + + + select + t.id , + t.create_by , + t.create_time , + t.update_by , + t.update_time , + t.del_flag , + t.title , + t.image , + t.sort , + t.start_time , + t.end_time , + t.browse_num, + t.content, + t.like_num + from t_activity AS t + + + + + + + + + insert into t_activity + + id, + create_by, + create_time, + update_by, + update_time, + del_flag, + title, + image, + sort, + start_time, + end_time, + browse_num, + + + #{id}, + #{createBy}, + #{createTime}, + #{updateBy}, + #{updateTime}, + #{delFlag}, + #{title}, + #{image}, + #{sort}, + #{startTime}, + #{endTime}, + #{browseNum}, + + + + + update t_activity + + create_by = #{createBy}, + create_time = #{createTime}, + update_by = #{updateBy}, + update_time = #{updateTime}, + del_flag = #{delFlag}, + title = #{title}, + image = #{image}, + sort = #{sort}, + start_time = #{startTime}, + end_time = #{endTime}, + browse_num = browse_num + #{browseNum}, + content = #{content}, + like_num = like_num + #{likeNum}, + + where id = #{id} + and like_num + #{likeNum} >= 0 + and browse_num + #{browseNum} >= 0 + + + + + + + \ No newline at end of file diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/activity/model/param/ActivityParam.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/activity/model/param/ActivityParam.java new file mode 100644 index 0000000..6819edc --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/activity/model/param/ActivityParam.java @@ -0,0 +1,62 @@ +package com.ruoyi.frequency.activity.entity.model.param; + +import java.util.Date; +import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.Data; +import lombok.experimental.Accessors; +import com.ruoyi.common.annotation.Excel; +import io.swagger.annotations.ApiModelProperty; +import com.ruoyi.common.core.domain.BaseEntity; + +/** + * 活动对象 t_activity + * + * @author liwenlong + * @date 2024-03-19 + */ +@Data +@Accessors(chain = true) +public class ActivityParam extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + @ApiModelProperty("租户号") + private Long id; + + @ApiModelProperty("删除标志;1 正常 2 删除 3 禁用") + private Long delFlag; + + @ApiModelProperty("标题") + @Excel(name = "标题") + private String title; + + @ApiModelProperty("图片") + @Excel(name = "图片") + private String image; + + @ApiModelProperty("排序") + @Excel(name = "排序") + private Long sort; + + @ApiModelProperty("开始时间") + @Excel(name = "开始时间", width = 30, dateFormat = "yyyy-MM-dd") + private Date startTime; + + @ApiModelProperty("结束时间") + @Excel(name = "结束时间", width = 30, dateFormat = "yyyy-MM-dd") + private Date endTime; + + @ApiModelProperty("浏览量") + @Excel(name = "浏览量") + private Long browseNum; + + + + + + + + + + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/activity/model/result/ActivityCount.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/activity/model/result/ActivityCount.java new file mode 100644 index 0000000..c80906e --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/activity/model/result/ActivityCount.java @@ -0,0 +1,16 @@ +package com.ruoyi.frequency.activity.model.result; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +@Data +public class ActivityCount { + @ApiModelProperty("数量") + private Integer num; + + @ApiModelProperty("浏览量") + private Integer browseNum; + + @ApiModelProperty("点赞量") + private Integer likeNum; +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/activity/model/result/ActivityResult.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/activity/model/result/ActivityResult.java new file mode 100644 index 0000000..2d1e626 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/activity/model/result/ActivityResult.java @@ -0,0 +1,54 @@ +package com.ruoyi.frequency.activity.entity.model.result; + +import java.util.Date; +import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.Data; +import lombok.experimental.Accessors; +import com.ruoyi.common.annotation.Excel; +import io.swagger.annotations.ApiModelProperty; +import com.ruoyi.common.core.domain.BaseEntity; + +/** + * 活动对象 t_activity + * + * @author liwenlong + * @date 2024-03-19 + */ +@Data +@Accessors(chain = true) +public class ActivityResult extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + @ApiModelProperty("租户号") + private Long id; + + @ApiModelProperty("删除标志;1 正常 2 删除 3 禁用") + private Long delFlag; + + @ApiModelProperty("标题") + @Excel(name = "标题") + private String title; + + @ApiModelProperty("图片") + @Excel(name = "图片") + private String image; + + @ApiModelProperty("排序") + @Excel(name = "排序") + private Long sort; + + @ApiModelProperty("开始时间") + @Excel(name = "开始时间", width = 30, dateFormat = "yyyy-MM-dd") + private Date startTime; + + @ApiModelProperty("结束时间") + @Excel(name = "结束时间", width = 30, dateFormat = "yyyy-MM-dd") + private Date endTime; + + @ApiModelProperty("浏览量") + @Excel(name = "浏览量") + private Long browseNum; + + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/activity/service/ActivityService.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/activity/service/ActivityService.java new file mode 100644 index 0000000..e10c820 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/activity/service/ActivityService.java @@ -0,0 +1,81 @@ +package com.ruoyi.frequency.activity.service; + +import java.util.List; + +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.ruoyi.common.page.PageResult; +import com.ruoyi.controller.req.ActivityPageReq; +import com.ruoyi.controller.resp.ActivityDetailResp; +import com.ruoyi.controller.resp.ActivityPageResp; +import com.ruoyi.frequency.activity.entity.Activity; +import com.baomidou.mybatisplus.extension.service.IService; +import com.ruoyi.frequency.activity.model.result.ActivityCount; +import com.ruoyi.response.ResponseData; +import com.ruoyi.vo.UserVo; + +/** + * 活动Service接口 + * + * @author liwenlong + * @date 2024-03-19 + */ +public interface ActivityService extends IService +{ + /** + * 查询活动 + * + * @param id 活动主键 + * @return 活动 + */ + public Activity selectActivityById(Long id); + + /** + * 查询活动列表 + * + * @param activity 活动 + * @return 活动集合 + */ + public List selectActivityList(Activity activity); + + /** + * 新增活动 + * + * @param activity 活动 + * @return 结果 + */ + public int insertActivity(Activity activity); + + /** + * 修改活动 + * + * @param activity 活动 + * @return 结果 + */ + public int updateActivity(Activity activity); + + /** + * 批量删除活动 + * + * @param ids 需要删除的活动主键集合 + * @return 结果 + */ + public int deleteActivityByIds(Long[] ids,Integer delFlag); + + /** + * 活动列表 + * @param req + * @param userVo + * @return + */ + ResponseData>> activityPage(ActivityPageReq req, UserVo userVo); + + /** + * 活动详情 + * @param id + * @param userVo + * @return + */ + ResponseData activityDetail(Long id, UserVo userVo); + + ActivityCount statistics(Activity activity); +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/activity/service/impl/ActivityServiceImpl.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/activity/service/impl/ActivityServiceImpl.java new file mode 100644 index 0000000..b11ad4a --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/activity/service/impl/ActivityServiceImpl.java @@ -0,0 +1,150 @@ +package com.ruoyi.frequency.activity.service.impl; + +import java.util.Date; +import java.util.List; +import java.util.stream.Collectors; + +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.util.ObjectUtil; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.ruoyi.common.core.domain.BaseEntity; +import com.ruoyi.common.page.PageResult; +import com.ruoyi.common.utils.DateUtils; +import com.ruoyi.controller.req.ActivityPageReq; +import com.ruoyi.controller.resp.ActivityDetailResp; +import com.ruoyi.controller.resp.ActivityPageResp; +import com.ruoyi.frequency.activity.model.result.ActivityCount; +import com.ruoyi.frequency.news.entity.News; +import com.ruoyi.post.frequency.post.mapper.PostMapper; +import com.ruoyi.response.ResponseData; +import com.ruoyi.utils.SnowIdUtils; +import com.ruoyi.vo.UserVo; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.ruoyi.code.PublicCommon; +import com.ruoyi.frequency.activity.mapper.ActivityMapper; +import com.ruoyi.frequency.activity.entity.Activity; +import com.ruoyi.frequency.activity.service.ActivityService; + +/** + * 活动Service业务层处理 + * + * @author liwenlong + * @date 2024-03-19 + */ +@Service +public class ActivityServiceImpl extends ServiceImpl implements ActivityService +{ + @Autowired + private ActivityMapper activityMapper; + + /** + * 查询活动 + * + * @param id 活动主键 + * @return 活动 + */ + @Override + public Activity selectActivityById(Long id) + { + return activityMapper.selectActivityById(id); + } + + /** + * 查询活动列表 + * + * @param activity 活动 + * @return 活动 + */ + @Override + public List selectActivityList(Activity activity) + { + return activityList(activity); + } + + private List activityList(Activity activity){ + return activityMapper.selectActivityList(activity); + } + + @Override + public ActivityCount statistics(Activity activity) { + List activities = activityList(activity); + List activityIdList = activities.stream().map(x -> x.getId()).collect(Collectors.toList()); + activityIdList.add(-1L); + + ActivityCount count =activityMapper.statistics(activityIdList); + + return count; + } + + + /** + * 新增活动 + * + * @param activity 活动 + * @return 结果 + */ + @Override + public int insertActivity(Activity activity) + { + activity.setCreateData(); + return activityMapper.insert(activity); + } + + /** + * 修改活动 + * + * @param activity 活动 + * @return 结果 + */ + @Override + public int updateActivity(Activity activity) + { + activity.setUpdateData(); + return activityMapper.updateActivity(activity); + } + + /** + * 批量删除活动 + * + * @param ids 需要删除的活动主键 + * @return 结果 + */ + @Override + public int deleteActivityByIds(Long[] ids,Integer delFlag) + { + this.lambdaUpdate().set(Activity::getDelFlag,delFlag).in(Activity::getId,ids).update(); + return ids.length; + } + + @Override + public ResponseData>> activityPage(ActivityPageReq req, UserVo userVo) { + + Page page = this.baseMapper.activityPage(new Page<>(req.getPageNo(), req.getPageSize()), req,userVo); + + return ResponseData.success(new PageResult<>(page)); + } + + @Autowired + private PostMapper postMapper; + + @Override + public ResponseData activityDetail(Long id, UserVo userVo) { + Activity activity = this.baseMapper.activityDetail(id,userVo); + + if (activity != null){ + //增加浏览数 + this.baseMapper.updateActivity(new Activity().setId(id).setBrowseNum(1)); + + //type: 类型 1作品 2 帖子 3投票 4新闻 5活动 + postMapper.updateBrowseRecord(SnowIdUtils.uniqueLong(),5,new Date(),id,userVo); + } + + return ResponseData.success(activity); + } + + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/advertisingimages/controller/AdvertisingImagesController.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/advertisingimages/controller/AdvertisingImagesController.java new file mode 100644 index 0000000..183e904 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/advertisingimages/controller/AdvertisingImagesController.java @@ -0,0 +1,103 @@ +package com.ruoyi.frequency.advertisingimages.controller; + +import java.util.List; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.frequency.advertisingimages.entity.AdvertisingImages; +import com.ruoyi.frequency.advertisingimages.service.AdvertisingImagesService; +import com.ruoyi.common.utils.poi.ExcelUtil; +import com.ruoyi.common.core.page.TableDataInfo; + +/** + * 广告图Controller + * + * @author liwenlong + * @date 2024-02-05 + */ +@RestController +@RequestMapping("/frequency/advertisingimages") +public class AdvertisingImagesController extends BaseController +{ + @Autowired + private AdvertisingImagesService advertisingImagesService; + + /** + * 查询广告图列表 + */ + //@PreAuthorize("@ss.hasPermi('frequency:advertisingimages:list')") + @PostMapping("/list") + public TableDataInfo list(@RequestBody AdvertisingImages advertisingImages) + { + startPage(); + List list = advertisingImagesService.selectAdvertisingImagesList(advertisingImages); + return getDataTable(list); + } + + /** + * 导出广告图列表 + */ + //@PreAuthorize("@ss.hasPermi('frequency:advertisingimages:export')") + @Log(title = "广告图", businessType = BusinessType.EXPORT) + @GetMapping("/export") + public AjaxResult export(AdvertisingImages advertisingImages) + { + List list = advertisingImagesService.selectAdvertisingImagesList(advertisingImages); + ExcelUtil util = new ExcelUtil(AdvertisingImages.class); + return util.exportExcel(list, "广告图数据"); + } + + /** + * 获取广告图详细信息 + */ + //@PreAuthorize("@ss.hasPermi('frequency:advertisingimages:query')") + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") Long id) + { + return AjaxResult.success(advertisingImagesService.selectAdvertisingImagesById(id)); + } + + /** + * 新增广告图 + */ + //@PreAuthorize("@ss.hasPermi('frequency:advertisingimages:add')") + @Log(title = "广告图", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody AdvertisingImages advertisingImages) + { + return toAjax(advertisingImagesService.insertAdvertisingImages(advertisingImages)); + } + + /** + * 修改广告图 + */ + //@PreAuthorize("@ss.hasPermi('frequency:advertisingimages:edit')") + @Log(title = "广告图", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody AdvertisingImages advertisingImages) + { + return toAjax(advertisingImagesService.updateAdvertisingImages(advertisingImages)); + } + + /** + * 删除广告图 + */ + //@PreAuthorize("@ss.hasPermi('frequency:advertisingimages:remove')") + @Log(title = "广告图", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}/{delFlag}") + public AjaxResult remove(@PathVariable("ids") Long[] ids,@PathVariable("delFlag") Integer delFlag) + { + return toAjax(advertisingImagesService.deleteAdvertisingImagesByIds(ids,delFlag)); + } +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/advertisingimages/entity/AdvertisingImages.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/advertisingimages/entity/AdvertisingImages.java new file mode 100644 index 0000000..e5a01c1 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/advertisingimages/entity/AdvertisingImages.java @@ -0,0 +1,74 @@ +package com.ruoyi.frequency.advertisingimages.entity; + +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableName; +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import com.ruoyi.vo.UserInfo; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; + +import java.util.Date; + +/** + * 广告图对象 t_advertising_images + * + * @author liwenlong + * @date 2024-02-05 + */ +@Data +@Accessors(chain = true) +@TableName("t_advertising_images") +public class AdvertisingImages extends BaseEntity { + private static final long serialVersionUID = 1L; + + + @ApiModelProperty("租户号") + private Long id; + + @ApiModelProperty("删除标识 1 正常 2 删除 3 禁用") + private Long delFlag; + + @ApiModelProperty("展示图") + @Excel(name = "展示图") + private String image; + + @ApiModelProperty("内容") + @Excel(name = "内容") + private String content; + + @ApiModelProperty("排序") + @Excel(name = "排序") + private Long sort; + + @ApiModelProperty("类型") + @Excel(name = "类型") + private Long userType; + + @ApiModelProperty("标题") + private String title; + + @ApiModelProperty("类型 1富文本 2 设计师主页 3 表现师主页 4 首页 5活动页面 6新闻页面 ") + @Excel(name = "类型 1富文本 2 设计师主页 3 表现师主页 4 首页 5活动页面 6新闻页面 ") + private Integer type; + + @TableField(exist = false) + private UserInfo userInfo; + + @TableField(exist = false) + @ApiModelProperty("活动标题") + private String activityTitle; + + @TableField(exist = false) + @ApiModelProperty("活动标题") + private String newsTitle; + + @ApiModelProperty("开始时间") + @TableField(exist = false) + private Date beginTime; + + @ApiModelProperty("结束时间") + @TableField(exist = false) + private Date endTime; +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/advertisingimages/mapper/AdvertisingImagesMapper.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/advertisingimages/mapper/AdvertisingImagesMapper.java new file mode 100644 index 0000000..1966559 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/advertisingimages/mapper/AdvertisingImagesMapper.java @@ -0,0 +1,47 @@ +package com.ruoyi.frequency.advertisingimages.mapper; + +import java.util.List; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.ruoyi.frequency.advertisingimages.entity.AdvertisingImages; + +/** + * 广告图Mapper接口 + * + * @author liwenlong + * @date 2024-02-05 + */ +public interface AdvertisingImagesMapper extends BaseMapper +{ + /** + * 查询广告图 + * + * @param id 广告图主键 + * @return 广告图 + */ + public AdvertisingImages selectAdvertisingImagesById(Long id); + + /** + * 查询广告图列表 + * + * @param advertisingImages 广告图 + * @return 广告图集合 + */ + public List selectAdvertisingImagesList(AdvertisingImages advertisingImages); + + /** + * 新增广告图 + * + * @param advertisingImages 广告图 + * @return 结果 + */ + public int insertAdvertisingImages(AdvertisingImages advertisingImages); + + /** + * 修改广告图 + * + * @param advertisingImages 广告图 + * @return 结果 + */ + public int updateAdvertisingImages(AdvertisingImages advertisingImages); + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/advertisingimages/mapper/mapping/AdvertisingImagesMapper.xml b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/advertisingimages/mapper/mapping/AdvertisingImagesMapper.xml new file mode 100644 index 0000000..d6abc20 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/advertisingimages/mapper/mapping/AdvertisingImagesMapper.xml @@ -0,0 +1,115 @@ + + + + + + + + + + + + + + + + + + + + + + + select + t.id , + t.create_by , + t.create_time , + t.update_by , + t.update_time , + t.del_flag , + t.image , + t.content , + t.sort , + t.user_type , + t.title, + t.type + from t_advertising_images AS t + + + + + + + + + insert into t_advertising_images + + id, + create_by, + create_time, + update_by, + update_time, + del_flag, + image, + content, + sort, + user_type, + type, + + + #{id}, + #{createBy}, + #{createTime}, + #{updateBy}, + #{updateTime}, + #{delFlag}, + #{image}, + #{content}, + #{sort}, + #{userType}, + #{type}, + + + + + update t_advertising_images + + create_by = #{createBy}, + create_time = #{createTime}, + update_by = #{updateBy}, + update_time = #{updateTime}, + del_flag = #{delFlag}, + image = #{image}, + content = #{content}, + sort = #{sort}, + user_type = #{userType}, + title = #{title}, + type = #{type}, + + where id = #{id} + + diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/advertisingimages/model/param/AdvertisingImagesParam.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/advertisingimages/model/param/AdvertisingImagesParam.java new file mode 100644 index 0000000..281e6ff --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/advertisingimages/model/param/AdvertisingImagesParam.java @@ -0,0 +1,47 @@ +package com.ruoyi.frequency.advertisingimages.model.param; + +import lombok.Data; +import lombok.experimental.Accessors; +import com.ruoyi.common.annotation.Excel; +import io.swagger.annotations.ApiModelProperty; +import com.ruoyi.common.core.domain.BaseEntity; + +/** + * 广告图对象 t_advertising_images + * + * @author liwenlong + * @date 2024-02-05 + */ +@Data +@Accessors(chain = true) +public class AdvertisingImagesParam extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + @ApiModelProperty("租户号") + private Long id; + + @ApiModelProperty("删除标识 1 正常 2 删除 3 禁用") + private Long delFlag; + + @ApiModelProperty("展示图") + @Excel(name = "展示图") + private String image; + + @ApiModelProperty("内容") + @Excel(name = "内容") + private String content; + + @ApiModelProperty("排序") + @Excel(name = "排序") + private Long sort; + + @ApiModelProperty("类型") + @Excel(name = "类型") + private Long userType; + + @ApiModelProperty("类型 1富文本 2 设计师主页 3 表现师主页 4 首页 5活动页面 6新闻页面 ") + @Excel(name = "类型 1富文本 2 设计师主页 3 表现师主页 4 首页 5活动页面 6新闻页面 ") + private Integer type; + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/advertisingimages/model/result/AdvertisingImagesResult.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/advertisingimages/model/result/AdvertisingImagesResult.java new file mode 100644 index 0000000..bfb4126 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/advertisingimages/model/result/AdvertisingImagesResult.java @@ -0,0 +1,47 @@ +package com.ruoyi.frequency.advertisingimages.model.result; + +import lombok.Data; +import lombok.experimental.Accessors; +import com.ruoyi.common.annotation.Excel; +import io.swagger.annotations.ApiModelProperty; +import com.ruoyi.common.core.domain.BaseEntity; + +/** + * 广告图对象 t_advertising_images + * + * @author liwenlong + * @date 2024-02-05 + */ +@Data +@Accessors(chain = true) +public class AdvertisingImagesResult extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + @ApiModelProperty("租户号") + private Long id; + + @ApiModelProperty("删除标识 1 正常 2 删除 3 禁用") + private Long delFlag; + + @ApiModelProperty("展示图") + @Excel(name = "展示图") + private String image; + + @ApiModelProperty("内容") + @Excel(name = "内容") + private String content; + + @ApiModelProperty("排序") + @Excel(name = "排序") + private Long sort; + + @ApiModelProperty("类型") + @Excel(name = "类型") + private Long userType; + + @ApiModelProperty("类型 1富文本 2 设计师主页 3 表现师主页 4 首页 5活动页面 6新闻页面 ") + @Excel(name = "类型 1富文本 2 设计师主页 3 表现师主页 4 首页 5活动页面 6新闻页面 ") + private Integer type; + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/advertisingimages/service/AdvertisingImagesService.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/advertisingimages/service/AdvertisingImagesService.java new file mode 100644 index 0000000..83b607c --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/advertisingimages/service/AdvertisingImagesService.java @@ -0,0 +1,55 @@ +package com.ruoyi.frequency.advertisingimages.service; + +import java.util.List; +import com.ruoyi.frequency.advertisingimages.entity.AdvertisingImages; +import com.baomidou.mybatisplus.extension.service.IService; + +/** + * 广告图Service接口 + * + * @author liwenlong + * @date 2024-02-05 + */ +public interface AdvertisingImagesService extends IService +{ + /** + * 查询广告图 + * + * @param id 广告图主键 + * @return 广告图 + */ + public AdvertisingImages selectAdvertisingImagesById(Long id); + + /** + * 查询广告图列表 + * + * @param advertisingImages 广告图 + * @return 广告图集合 + */ + public List selectAdvertisingImagesList(AdvertisingImages advertisingImages); + + /** + * 新增广告图 + * + * @param advertisingImages 广告图 + * @return 结果 + */ + public int insertAdvertisingImages(AdvertisingImages advertisingImages); + + /** + * 修改广告图 + * + * @param advertisingImages 广告图 + * @return 结果 + */ + public int updateAdvertisingImages(AdvertisingImages advertisingImages); + + /** + * 批量删除广告图 + * + * @param ids 需要删除的广告图主键集合 + * @return 结果 + */ + public int deleteAdvertisingImagesByIds(Long[] ids,Integer delFlag); + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/advertisingimages/service/impl/AdvertisingImagesServiceImpl.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/advertisingimages/service/impl/AdvertisingImagesServiceImpl.java new file mode 100644 index 0000000..c623c99 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/advertisingimages/service/impl/AdvertisingImagesServiceImpl.java @@ -0,0 +1,138 @@ +package com.ruoyi.frequency.advertisingimages.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.ruoyi.code.PublicCommon; +import com.ruoyi.enums.user.UserEnums; +import com.ruoyi.frequency.activity.entity.Activity; +import com.ruoyi.frequency.activity.service.ActivityService; +import com.ruoyi.frequency.advertisingimages.entity.AdvertisingImages; +import com.ruoyi.frequency.advertisingimages.mapper.AdvertisingImagesMapper; +import com.ruoyi.frequency.advertisingimages.service.AdvertisingImagesService; +import com.ruoyi.frequency.customer.service.UserService; +import com.ruoyi.frequency.news.entity.News; +import com.ruoyi.frequency.news.service.NewsService; +import com.ruoyi.vo.UserInfo; +import com.ruoyi.vo.UserVo; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +/** + * 广告图Service业务层处理 + * + * @author liwenlong + * @date 2024-02-05 + */ +@Service +public class AdvertisingImagesServiceImpl extends ServiceImpl implements AdvertisingImagesService { + @Autowired + private AdvertisingImagesMapper advertisingImagesMapper; + + @Autowired + private UserService userService; + + @Autowired + private ActivityService activityService; + + @Autowired + private NewsService newsService; + + /** + * 查询广告图 + * + * @param id 广告图主键 + * @return 广告图 + */ + @Override + public AdvertisingImages selectAdvertisingImagesById(Long id) { + AdvertisingImages advertisingImages = advertisingImagesMapper.selectAdvertisingImagesById(id); + //类型 1富文本 2 设计师主页 3 表现师主页 4 首页 5活动页面 6新闻页面 + if (advertisingImages.getType() != null) { + if (advertisingImages.getType() == 2 || advertisingImages.getType() == 3) { + Set userVoSet = new HashSet<>(); + + UserVo userVo = new UserVo(advertisingImages.getType() == 2 ? UserEnums.customer.getCode() : UserEnums.store.getCode(), Long.valueOf(advertisingImages.getContent())); + + userVoSet.add(userVo); + + //查询用户信息 + Map userMap = userService.selectUserInfoMap(userVoSet, null); + + advertisingImages.setUserInfo(userMap.get(userVo)); + } else if (advertisingImages.getType() == 5) { + Activity activity = activityService.getById(advertisingImages.getContent()); + if (activity != null) { + advertisingImages.setActivityTitle(activity.getTitle()); + } + } else if (advertisingImages.getType() == 6) { + News news = newsService.newsInfo(Long.valueOf(advertisingImages.getContent())); + if (news != null) { + advertisingImages.setNewsTitle(news.getTitle()); + } + } + } + + return advertisingImages; + } + + /** + * 查询广告图列表 + * + * @param advertisingImages 广告图 + * @return 广告图 + */ + @Override + public List selectAdvertisingImagesList(AdvertisingImages advertisingImages) { + return advertisingImagesMapper.selectAdvertisingImagesList(advertisingImages); + } + + /** + * 新增广告图 + * + * @param advertisingImages 广告图 + * @return 结果 + */ + @Override + public int insertAdvertisingImages(AdvertisingImages advertisingImages) { + advertisingImages.setCreateData(); + + int insert = advertisingImagesMapper.insert(advertisingImages); + + if (insert > 0) { + this.lambdaUpdate().set(AdvertisingImages::getDelFlag, PublicCommon.禁用) + .eq(AdvertisingImages::getDelFlag, PublicCommon.启用) + .ne(AdvertisingImages::getId, advertisingImages.getId()).update(); + } + return insert; + } + + /** + * 修改广告图 + * + * @param advertisingImages 广告图 + * @return 结果 + */ + @Override + public int updateAdvertisingImages(AdvertisingImages advertisingImages) { + advertisingImages.setUpdateData(); + return advertisingImagesMapper.updateAdvertisingImages(advertisingImages); + } + + /** + * 批量删除广告图 + * + * @param ids 需要删除的广告图主键 + * @return 结果 + */ + @Override + public int deleteAdvertisingImagesByIds(Long[] ids, Integer delFlag) { + this.lambdaUpdate().set(AdvertisingImages::getDelFlag, delFlag).in(AdvertisingImages::getId, ids).update(); + + return ids.length; + } + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/appeal/controller/AppealController.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/appeal/controller/AppealController.java new file mode 100644 index 0000000..cc41d7b --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/appeal/controller/AppealController.java @@ -0,0 +1,122 @@ +package com.ruoyi.frequency.appeal.controller; + +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.page.TableDataInfo; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.common.utils.poi.ExcelUtil; +import com.ruoyi.frequency.appeal.entity.Appeal; +import com.ruoyi.frequency.appeal.model.result.AppealCount; +import com.ruoyi.frequency.appeal.service.AppealService; +import com.ruoyi.frequency.works.entity.Works; +import com.ruoyi.frequency.works.model.result.WorksCount; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +/** + * 申诉Controller + * + * @author zj + * @date 2023-10-13 + */ +@RestController +@RequestMapping("/frequency/appeal") +public class AppealController extends BaseController +{ + @Autowired + private AppealService appealService; + + /** + * 查询申诉列表 + */ + @PreAuthorize("@ss.hasPermi('frequency:appeal:list')") + @PostMapping("/list") + public TableDataInfo list(@RequestBody Appeal appeal) + { + startPage(); + List list = appealService.selectAppealList(appeal); + return getDataTable(list); + } + + /** + * 统计 + */ + @PostMapping("/statistics") + public AjaxResult statistics(@RequestBody Appeal appeal) + { + AppealCount count = appealService.statistics(appeal); + return AjaxResult.success(count); + } + + + /** + * 导出申诉列表 + */ + @PreAuthorize("@ss.hasPermi('frequency:appeal:export')") + @Log(title = "申诉", businessType = BusinessType.EXPORT) + @GetMapping("/export") + public AjaxResult export(Appeal appeal) + { + List list = appealService.selectAppealList(appeal); + ExcelUtil util = new ExcelUtil(Appeal.class); + return util.exportExcel(list, "申诉数据"); + } + + /** + * 获取申诉详细信息 + */ + @PreAuthorize("@ss.hasPermi('frequency:appeal:query')") + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") Long id) + { + return AjaxResult.success(appealService.selectAppealById(id)); + } + + /** + * 新增申诉 + */ + @PreAuthorize("@ss.hasPermi('frequency:appeal:add')") + @Log(title = "申诉", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody Appeal appeal) + { + return toAjax(appealService.insertAppeal(appeal)); + } + + /** + * 修改申诉 + */ + @PreAuthorize("@ss.hasPermi('frequency:appeal:edit')") + @Log(title = "申诉", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody Appeal appeal) + { + return toAjax(appealService.updateAppeal(appeal)); + } + + /** + * 删除申诉 + */ + @PreAuthorize("@ss.hasPermi('frequency:appeal:remove')") + @Log(title = "申诉", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}") + public AjaxResult remove(@PathVariable Long[] ids) + { + return toAjax(appealService.deleteAppealByIds(ids)); + } + + + /** + * 申诉处理 + */ + @PreAuthorize("@ss.hasPermi('frequency:appeal:handle')") + @PostMapping("/handle") + public AjaxResult handle(@RequestBody Appeal appeal) + { + return appealService.handle(appeal); + } +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/appeal/entity/Appeal.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/appeal/entity/Appeal.java new file mode 100644 index 0000000..df02539 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/appeal/entity/Appeal.java @@ -0,0 +1,115 @@ +package com.ruoyi.frequency.appeal.entity; + +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableName; +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import com.ruoyi.vo.UserInfo; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; + +import java.math.BigDecimal; +import java.util.Date; + +/** + * 申诉对象 t_appeal + * + * @author zj + * @date 2023-10-13 + */ +@Data +@Accessors(chain = true) +@TableName("t_appeal") +public class Appeal extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + + @ApiModelProperty("租户号") + private Long id; + + @ApiModelProperty("删除标志 1 正常 2 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("订单id") + @Excel(name = "订单id") + private Long orderId; + + @ApiModelProperty("申诉内容") + @Excel(name = "申诉内容") + private String content; + + @ApiModelProperty("申诉图片/视频") + @Excel(name = "申诉图片/视频") + private String picture; + + @ApiModelProperty("申诉人") + @Excel(name = "申诉人") + private Long appealUserId; + + @ApiModelProperty("被申诉人") + @Excel(name = "被申诉人") + private Long passiveAppealUserId; + + @ApiModelProperty("申诉结果;状态 1 待处理 2申诉人胜诉 3被申诉人胜诉") + @Excel(name = "申诉结果;状态 1 待处理 2申诉人胜诉 3被申诉人胜诉") + private Integer appealResult; + + @ApiModelProperty("申诉人用户类型") + private Integer appealUserType; + + @ApiModelProperty("被申诉人用户类型") + private Integer passiveAppealUserType; + + @ApiModelProperty("申诉视频") + @Excel(name = "申诉视频") + private String videoUrl; + + @ApiModelProperty("订单结果") + private String remark; + + @ApiModelProperty("调价价格") + private BigDecimal amount; + + @ApiModelProperty("退款金额 申诉价格小于订单价格") + private BigDecimal refundPrice; + + + @ApiModelProperty("订单编号") + @TableField(exist = false) + private String orderNo; + + @ApiModelProperty("订单标题") + @TableField(exist = false) + private String title; + + @ApiModelProperty("订单内容") + @TableField(exist = false) + private String orderContent; + + @ApiModelProperty("素材") + @Excel(name = "素材") + @TableField(exist = false) + private String sourceMaterial; + + + @ApiModelProperty("申诉人信息") + @TableField(exist = false) + private UserInfo appealUserInfo; + + @ApiModelProperty("被申诉人信息") + @TableField(exist = false) + private UserInfo passiveAppealUserInfo; + + + @ApiModelProperty("开始时间") + @TableField(exist = false) + private Date beginTime; + + @ApiModelProperty("结束时间") + @TableField(exist = false) + private Date endTime; + + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/appeal/mapper/AppealMapper.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/appeal/mapper/AppealMapper.java new file mode 100644 index 0000000..c573b23 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/appeal/mapper/AppealMapper.java @@ -0,0 +1,75 @@ +package com.ruoyi.frequency.appeal.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.ruoyi.controller.resp.AppealDetailResp; +import com.ruoyi.controller.resp.AppealPageResp; +import com.ruoyi.frequency.appeal.entity.Appeal; +import com.ruoyi.frequency.appeal.model.result.AppealCount; +import com.ruoyi.vo.UserVo; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * 申诉Mapper接口 + * + * @author zj + * @date 2023-10-13 + */ +public interface AppealMapper extends BaseMapper +{ + /** + * 查询申诉 + * + * @param id 申诉主键 + * @return 申诉 + */ + public Appeal selectAppealById(Long id); + + /** + * 查询申诉列表 + * + * @param appeal 申诉 + * @return 申诉集合 + */ + public List selectAppealList(Appeal appeal); + + /** + * 新增申诉 + * + * @param appeal 申诉 + * @return 结果 + */ + public int insertAppeal(Appeal appeal); + + /** + * 修改申诉 + * + * @param appeal 申诉 + * @return 结果 + */ + public int updateAppeal(Appeal appeal); + + /** + * 删除申诉 + * + * @param id 申诉主键 + * @return 结果 + */ + public int deleteAppealById(Long id); + + /** + * 批量删除申诉 + * + * @param ids 需要删除的数据主键集合 + * @return 结果 + */ + public int deleteAppealByIds(Long[] ids); + + Page appealPage(@Param("page") Page objectPage,@Param("userVo") UserVo userVo); + + AppealDetailResp appealDetail(@Param("id") Long appealId, @Param("userVo") UserVo userVo); + + AppealCount statistics(@Param("list")List appealIdList); +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/appeal/mapper/mapping/AppealMapper.xml b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/appeal/mapper/mapping/AppealMapper.xml new file mode 100644 index 0000000..a36fa8e --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/appeal/mapper/mapping/AppealMapper.xml @@ -0,0 +1,270 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + SELECT + t.id, + t.create_by, + t.create_time, + t.update_by, + t.update_time, + t.del_flag, + t.order_id, + t.content, + t.picture, + t.appeal_user_id, + t.passive_appeal_user_id, + t.appeal_result, + t.passive_appeal_user_type, + t.appeal_user_type, + t.video_url, + t.amount, + t2.order_no, + t2.title, + t2.content orderContent, + t2.source_material + FROM + t_appeal AS t + LEFT JOIN t_order AS t2 ON t.order_id = t2.id + LEFT JOIN t_customer AS c ON c.id = t.appeal_user_id + AND t.appeal_user_type = 1 + LEFT JOIN t_store AS s ON s.id = t.appeal_user_id + AND t.appeal_user_type = 2 + + + + + + + + insert into t_appeal + + id, + create_by, + create_time, + update_by, + update_time, + del_flag, + order_id, + content, + picture, + appeal_user, + passive_appeal_user, + appeal_result, + + + #{id}, + #{createBy}, + #{createTime}, + #{updateBy}, + #{updateTime}, + #{delFlag}, + #{orderId}, + #{content}, + #{picture}, + #{appealUser}, + #{passiveAppealUser}, + #{appealResult}, + + + + + update t_appeal + + create_by = #{createBy}, + create_time = #{createTime}, + update_by = #{updateBy}, + update_time = #{updateTime}, + del_flag = #{delFlag}, + order_id = #{orderId}, + content = #{content}, + picture = #{picture}, + appeal_user = #{appealUser}, + passive_appeal_user = #{passiveAppealUser}, + appeal_result = #{appealResult}, + + where id = #{id} + + + + delete from t_appeal where id = #{id} + + + + delete from t_appeal where id in + + #{id} + + + + + + + + diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/appeal/model/param/AppealParam.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/appeal/model/param/AppealParam.java new file mode 100644 index 0000000..cdad12c --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/appeal/model/param/AppealParam.java @@ -0,0 +1,61 @@ +package com.ruoyi.frequency.appeal.model.param; + +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; + +/** + * 申诉对象 t_appeal + * + * @author zj + * @date 2023-10-13 + */ +@Data +@Accessors(chain = true) +public class AppealParam extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + @ApiModelProperty("租户号") + private Long id; + + @ApiModelProperty("删除标志 1 正常 2 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("订单id") + @Excel(name = "订单id") + private Long orderId; + + @ApiModelProperty("申诉内容") + @Excel(name = "申诉内容") + private String content; + + @ApiModelProperty("申诉图片/视频") + @Excel(name = "申诉图片/视频") + private String picture; + + @ApiModelProperty("申诉人") + @Excel(name = "申诉人") + private Long appealUser; + + @ApiModelProperty("被申诉人") + @Excel(name = "被申诉人") + private Long passiveAppealUser; + + @ApiModelProperty("申诉结果;状态 1 待处理 2 已处理") + @Excel(name = "申诉结果;状态 1 待处理 2 已处理") + private Integer appealResult; + + + + + + + + + + + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/appeal/model/result/AppealCount.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/appeal/model/result/AppealCount.java new file mode 100644 index 0000000..aee79c7 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/appeal/model/result/AppealCount.java @@ -0,0 +1,20 @@ +package com.ruoyi.frequency.appeal.model.result; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +@Data +public class AppealCount { + + @ApiModelProperty("数量") + private Integer num; + + @ApiModelProperty("已通过数量") + private Integer passNumber; + + @ApiModelProperty("未通过数量") + private Integer noPassNumber; + + @ApiModelProperty("待处理人数") + private Integer auditNumber; +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/appeal/model/result/AppealResult.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/appeal/model/result/AppealResult.java new file mode 100644 index 0000000..0557cb3 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/appeal/model/result/AppealResult.java @@ -0,0 +1,52 @@ +package com.ruoyi.frequency.appeal.model.result; + +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; + +/** + * 申诉对象 t_appeal + * + * @author zj + * @date 2023-10-13 + */ +@Data +@Accessors(chain = true) +public class AppealResult extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + @ApiModelProperty("租户号") + private Long id; + + @ApiModelProperty("删除标志 1 正常 2 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("订单id") + @Excel(name = "订单id") + private Long orderId; + + @ApiModelProperty("申诉内容") + @Excel(name = "申诉内容") + private String content; + + @ApiModelProperty("申诉图片/视频") + @Excel(name = "申诉图片/视频") + private String picture; + + @ApiModelProperty("申诉人") + @Excel(name = "申诉人") + private Long appealUser; + + @ApiModelProperty("被申诉人") + @Excel(name = "被申诉人") + private Long passiveAppealUser; + + @ApiModelProperty("申诉结果;状态 1 待处理 2 已处理") + @Excel(name = "申诉结果;状态 1 待处理 2 已处理") + private Integer appealResult; + + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/appeal/service/AppealService.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/appeal/service/AppealService.java new file mode 100644 index 0000000..daf30e8 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/appeal/service/AppealService.java @@ -0,0 +1,100 @@ +package com.ruoyi.frequency.appeal.service; + +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.IService; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.page.PageResult; +import com.ruoyi.controller.resp.AppealDetailResp; +import com.ruoyi.controller.resp.AppealPageResp; +import com.ruoyi.frequency.appeal.entity.Appeal; +import com.ruoyi.frequency.appeal.model.result.AppealCount; +import com.ruoyi.frequency.works.entity.Works; +import com.ruoyi.response.ResponseData; +import com.ruoyi.vo.PageBasic; +import com.ruoyi.vo.UserVo; + +import java.util.List; + +/** + * 申诉Service接口 + * + * @author zj + * @date 2023-10-13 + */ +public interface AppealService extends IService +{ + /** + * 查询申诉 + * + * @param id 申诉主键 + * @return 申诉 + */ + public Appeal selectAppealById(Long id); + + /** + * 查询申诉列表 + * + * @param appeal 申诉 + * @return 申诉集合 + */ + public List selectAppealList(Appeal appeal); + + /** + * 新增申诉 + * + * @param appeal 申诉 + * @return 结果 + */ + public int insertAppeal(Appeal appeal); + + /** + * 修改申诉 + * + * @param appeal 申诉 + * @return 结果 + */ + public int updateAppeal(Appeal appeal); + + /** + * 批量删除申诉 + * + * @param ids 需要删除的申诉主键集合 + * @return 结果 + */ + public int deleteAppealByIds(Long[] ids); + + /** + * 删除申诉信息 + * + * @param id 申诉主键 + * @return 结果 + */ + public int deleteAppealById(Long id); + + /** + * 申诉处理 + * @param appeal + * @return + */ + AjaxResult handle(Appeal appeal); + + + /** + * 申诉列表 + * @param req + * @param userVo + * @return + */ + ResponseData>> appealPage(PageBasic req, UserVo userVo); + + + /** + * 申诉详情 + * @param appealId + * @param userVo + * @return + */ + ResponseData appealDetail(Long appealId, UserVo userVo); + + AppealCount statistics(Appeal appeal); +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/appeal/service/impl/AppealServiceImpl.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/appeal/service/impl/AppealServiceImpl.java new file mode 100644 index 0000000..204643a --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/appeal/service/impl/AppealServiceImpl.java @@ -0,0 +1,328 @@ +package com.ruoyi.frequency.appeal.service.impl; + +import cn.hutool.core.util.ObjectUtil; +import com.baomidou.mybatisplus.extension.conditions.update.LambdaUpdateChainWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.ruoyi.code.DictConstant; +import com.ruoyi.code.PublicCommon; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.domain.entity.SysDictData; +import com.ruoyi.common.page.PageResult; +import com.ruoyi.common.utils.DateUtils; +import com.ruoyi.controller.resp.AppealDetailResp; +import com.ruoyi.controller.resp.AppealPageResp; +import com.ruoyi.enums.WalletDetailEnums; +import com.ruoyi.enums.message.OrderMessageEnums; +import com.ruoyi.enums.order.OrderPriceEnums; +import com.ruoyi.enums.user.UserEnums; +import com.ruoyi.frequency.appeal.entity.Appeal; +import com.ruoyi.frequency.appeal.mapper.AppealMapper; +import com.ruoyi.frequency.appeal.model.result.AppealCount; +import com.ruoyi.frequency.appeal.service.AppealService; +import com.ruoyi.frequency.customer.service.UserService; +import com.ruoyi.frequency.order.entity.Order; +import com.ruoyi.frequency.order.service.OrderService; +import com.ruoyi.frequency.orderchangerecord.entity.OrderChangeRecord; +import com.ruoyi.frequency.orderchangerecord.service.OrderChangeRecordService; +import com.ruoyi.frequency.ordermessage.service.OrderMessageService; +import com.ruoyi.frequency.orderoperatorhistory.entity.OrderOperatorHistory; +import com.ruoyi.frequency.orderoperatorhistory.service.OrderOperatorHistoryService; +import com.ruoyi.frequency.orderpricerecord.service.OrderPriceRecordService; +import com.ruoyi.frequency.wallerecord.service.WalletRecordService; +import com.ruoyi.response.ResponseData; +import com.ruoyi.utils.BusinessUtil; +import com.ruoyi.vo.PageBasic; +import com.ruoyi.vo.UserInfo; +import com.ruoyi.vo.UserVo; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.math.BigDecimal; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.stream.Collectors; + +/** + * 申诉Service业务层处理 + * + * @author zj + * @date 2023-10-13 + */ +@Service +@Transactional(rollbackFor = Exception.class) +public class AppealServiceImpl extends ServiceImpl implements AppealService { + @Autowired + private AppealMapper appealMapper; + + /** + * 查询申诉 + * + * @param id 申诉主键 + * @return 申诉 + */ + @Override + public Appeal selectAppealById(Long id) { + + Appeal appeal = appealMapper.selectAppealById(id); + + if (appeal != null) { + + Set userVoSet = new HashSet<>(); + //申诉人 + UserVo appealUserVo = new UserVo(appeal.getAppealUserType(), appeal.getAppealUserId()); + userVoSet.add(appealUserVo); + + //被申诉人 + UserVo passiveAppealUserVo = new UserVo(appeal.getPassiveAppealUserType(), appeal.getPassiveAppealUserId()); + userVoSet.add(passiveAppealUserVo); + + //查询用户信息 + Map userMap = userService.selectUserInfoMap(userVoSet, null); + + appeal.setAppealUserInfo(userMap.get(appealUserVo)); + appeal.setPassiveAppealUserInfo(userMap.get(passiveAppealUserVo)); + } + + return appeal; + } + + /** + * 查询申诉列表 + * + * @param appeal 申诉 + * @return 申诉 + */ + @Override + public List selectAppealList(Appeal appeal) { + + List appeals = appealList(appeal); + + if (appeals.size() > 0) { + Set userVoSet = new HashSet<>(); + appeals.stream().forEach(s -> { + //申诉人 + UserVo appealUserVo = new UserVo(s.getAppealUserType(), s.getAppealUserId()); + userVoSet.add(appealUserVo); + + //被申诉人 + UserVo passiveAppealUserVo = new UserVo(s.getPassiveAppealUserType(), s.getPassiveAppealUserId()); + userVoSet.add(passiveAppealUserVo); + }); + + //查询用户信息 + Map userMap = userService.selectUserInfoMap(userVoSet, null); + + appeals.stream().forEach(s -> { + s.setAppealUserInfo(userMap.get(new UserVo(s.getAppealUserType(), s.getAppealUserId()))); + s.setPassiveAppealUserInfo(userMap.get(new UserVo(s.getPassiveAppealUserType(), s.getPassiveAppealUserId()))); + }); + } + + return appeals; + } + + private List appealList(Appeal appeal) { + List appeals = appealMapper.selectAppealList(appeal); + return appeals; + } + + @Override + public AppealCount statistics(Appeal appeal) { + List appeals = appealList(appeal); + List appealIdList = appeals.stream().map(x -> x.getId()).collect(Collectors.toList()); + appealIdList.add(-1L); + + AppealCount count = baseMapper.statistics(appealIdList); + return count; + } + + /** + * 新增申诉 + * + * @param appeal 申诉 + * @return 结果 + */ + @Override + public int insertAppeal(Appeal appeal) { + return appealMapper.insertAppeal(appeal); + } + + /** + * 修改申诉 + * + * @param appeal 申诉 + * @return 结果 + */ + @Override + public int updateAppeal(Appeal appeal) { + appeal.setUpdateTime(DateUtils.getNowDate()); + return appealMapper.updateAppeal(appeal); + } + + /** + * 批量删除申诉 + * + * @param ids 需要删除的申诉主键 + * @return 结果 + */ + @Override + public int deleteAppealByIds(Long[] ids) { + this.lambdaUpdate().set(Appeal::getDelFlag, PublicCommon.删除).in(Appeal::getId, ids).update(); + return ids.length; + } + + /** + * 删除申诉信息 + * + * @param id 申诉主键 + * @return 结果 + */ + @Override + public int deleteAppealById(Long id) { + this.lambdaUpdate().set(Appeal::getDelFlag, PublicCommon.删除).eq(Appeal::getId, id).update(); + return 1; + } + + @Autowired + private OrderService orderService; + + @Autowired + private OrderMessageService orderMessageService; + + @Autowired + private BusinessUtil businessUtil; + + @Autowired + private WalletRecordService walletRecordService; + + @Autowired + private OrderPriceRecordService orderPriceRecordService; + + @Autowired + private OrderChangeRecordService orderChangeRecordService; + + @Override + public AjaxResult handle(Appeal appeal) { + boolean update = this.lambdaUpdate().set(Appeal::getAppealResult, appeal.getAppealResult()) + .set(Appeal::getRemark, appeal.getRemark()) + .eq(Appeal::getId, appeal.getId()).update(); + + if (update) { + Appeal byId = this.getById(appeal.getId()); + + //更新订单申诉状态 + LambdaUpdateChainWrapper wrapper = orderService.lambdaUpdate().set(Order::getAppealStatus, PublicCommon.Appeal.申诉完成) + .eq(Order::getId, byId.getOrderId()); + //调价价格不为空 申诉结果;状态 1 待处理 2申诉人胜诉 3被申诉人胜诉 + if (ObjectUtil.equal(2, appeal.getAppealResult())) { + + Order order = orderService.getById(byId.getOrderId()); + + BigDecimal difference = byId.getAmount(); + + if (difference != null && difference.compareTo(BigDecimal.ZERO) > 0) { + //修改订单金额 + wrapper.set(Order::getAmount, order.getAmount().subtract(difference)); + + // 调价金额小于原价格 (退还金额到用户余额) + + //查询定金支付比例 + SysDictData dict = businessUtil.getDict(DictConstant.OrderDict.首款支付占比); + //首款支付比例 + BigDecimal ratio = BigDecimal.ZERO; + + if (dict != null && ObjectUtil.isNotEmpty(dict.getDictValue())) { + ratio = new BigDecimal(dict.getDictValue()); + } + + //计算退还定金 + BigDecimal refundPrice = difference.multiply(ratio).setScale(2, BigDecimal.ROUND_HALF_UP); + + //定金 + BigDecimal fistPrice = order.getFirstPrice().subtract(refundPrice); + + walletRecordService.updateBalance(new UserVo(UserEnums.customer.getCode(), order.getCustomerId()), WalletDetailEnums.DEPOSIT_REFUND, byId.getId(), refundPrice, PublicCommon.Wallet.可提现); + + wrapper.set(Order::getFirstPrice, fistPrice); + + //订单支付金额 + orderPriceRecordService.addOrderPriceRecord(OrderPriceEnums.appeal_sub, order.getId(), refundPrice.negate()); + + //添加调价记录 设计师调价 表现师自动同意的记录 + OrderChangeRecord record = new OrderChangeRecord(); + record.setChangeAmount(order.getAmount().subtract(byId.getAmount())) + .setOriginAmount(order.getAmount()) + .setRemark(byId.getRemark()) + .setOrderId(order.getId()) + .setUserType(UserEnums.customer.getCode()) + .setStatus(2) + .setUserId(order.getCustomerId()); + orderChangeRecordService.save(record); + + wrapper.set(Order::getChangeStatus, PublicCommon.OrderChange.已确认); + + this.lambdaUpdate().set(Appeal::getRefundPrice, refundPrice) + .eq(Appeal::getId, appeal.getId()).update(); + } + } + + wrapper.update(); + + //发送消息 + orderMessageService.addOrderMessage(new UserVo(byId.getAppealUserType(), byId.getAppealUserId()), byId.getOrderId(), "", PublicCommon.Order.订单, OrderMessageEnums.APPEAL_RESULT); + + //记录订单操作日志 + orderOperatorHistoryService.insertOrderOperatorHistory(OrderOperatorHistory.addBackHistory(byId.getOrderId(), "申诉判定","申诉判定:" + (ObjectUtil.equal(2, appeal.getAppealResult()) ? "申诉人胜诉" : "申诉人败诉"))); + + + } + return AjaxResult.success(); + } + + @Autowired + private OrderOperatorHistoryService orderOperatorHistoryService; + + @Autowired + private UserService userService; + + @Override + public ResponseData>> appealPage(PageBasic req, UserVo userVo) { + Page page = appealMapper.appealPage(new Page<>(req.getPageNo(), req.getPageSize()), userVo); + + return ResponseData.success(new PageResult<>(page)); + } + + @Override + public ResponseData appealDetail(Long appealId, UserVo userVo) { + AppealDetailResp appealDetailResp = appealMapper.appealDetail(appealId, userVo); + if (appealDetailResp == null || !appealDetailResp.getDelFlag().equals(PublicCommon.启用)) { + return ResponseData.error("投诉已取消"); + } + + if (appealDetailResp != null) { + + Set userVoSet = new HashSet<>(); + //申诉人 + UserVo appealUserVo = new UserVo(appealDetailResp.getAppealUserType(), appealDetailResp.getAppealUserId()); + userVoSet.add(appealUserVo); + + //被申诉人 + UserVo passiveAppealUserVo = new UserVo(appealDetailResp.getPassiveAppealUserType(), appealDetailResp.getPassiveAppealUserId()); + userVoSet.add(passiveAppealUserVo); + + //查询用户信息 + Map userMap = userService.selectUserInfoMap(userVoSet, userVo); + + appealDetailResp.setAppealUserInfo(userMap.get(appealUserVo)); + appealDetailResp.setPassiveAppealUserInfo(userMap.get(passiveAppealUserVo)); + } + + return ResponseData.success(appealDetailResp); + } + + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/appealdetail/controller/AppealDetailController.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/appealdetail/controller/AppealDetailController.java new file mode 100644 index 0000000..4fee320 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/appealdetail/controller/AppealDetailController.java @@ -0,0 +1,103 @@ +package com.ruoyi.frequency.appealdetail.controller; + +import java.util.List; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.frequency.appealdetail.entity.AppealDetail; +import com.ruoyi.frequency.appealdetail.service.AppealDetailService; +import com.ruoyi.common.utils.poi.ExcelUtil; +import com.ruoyi.common.core.page.TableDataInfo; + +/** + * 申诉详情Controller + * + * @author zj + * @date 2023-10-13 + */ +@RestController +@RequestMapping("/frequency/appealdetail") +public class AppealDetailController extends BaseController +{ + @Autowired + private AppealDetailService appealDetailService; + + /** + * 查询申诉详情列表 + */ + @PreAuthorize("@ss.hasPermi('frequency:appealdetail:list')") + @PostMapping("/list") + public TableDataInfo list(@RequestBody AppealDetail appealDetail) + { + startPage(); + List list = appealDetailService.selectAppealDetailList(appealDetail); + return getDataTable(list); + } + + /** + * 导出申诉详情列表 + */ + @PreAuthorize("@ss.hasPermi('frequency:appealdetail:export')") + @Log(title = "申诉详情", businessType = BusinessType.EXPORT) + @GetMapping("/export") + public AjaxResult export(AppealDetail appealDetail) + { + List list = appealDetailService.selectAppealDetailList(appealDetail); + ExcelUtil util = new ExcelUtil(AppealDetail.class); + return util.exportExcel(list, "申诉详情数据"); + } + + /** + * 获取申诉详情详细信息 + */ + @PreAuthorize("@ss.hasPermi('frequency:appealdetail:query')") + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") Long id) + { + return AjaxResult.success(appealDetailService.selectAppealDetailById(id)); + } + + /** + * 新增申诉详情 + */ + @PreAuthorize("@ss.hasPermi('frequency:appealdetail:add')") + @Log(title = "申诉详情", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody AppealDetail appealDetail) + { + return toAjax(appealDetailService.insertAppealDetail(appealDetail)); + } + + /** + * 修改申诉详情 + */ + @PreAuthorize("@ss.hasPermi('frequency:appealdetail:edit')") + @Log(title = "申诉详情", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody AppealDetail appealDetail) + { + return toAjax(appealDetailService.updateAppealDetail(appealDetail)); + } + + /** + * 删除申诉详情 + */ + @PreAuthorize("@ss.hasPermi('frequency:appealdetail:remove')") + @Log(title = "申诉详情", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}") + public AjaxResult remove(@PathVariable Long[] ids) + { + return toAjax(appealDetailService.deleteAppealDetailByIds(ids)); + } +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/appealdetail/entity/AppealDetail.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/appealdetail/entity/AppealDetail.java new file mode 100644 index 0000000..cab2a78 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/appealdetail/entity/AppealDetail.java @@ -0,0 +1,66 @@ +package com.ruoyi.frequency.appealdetail.entity; + +import java.util.Date; + +import com.baomidou.mybatisplus.annotation.TableField; +import com.fasterxml.jackson.annotation.JsonFormat; +import com.ruoyi.vo.UserInfo; +import lombok.Data; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.experimental.Accessors; +import com.ruoyi.common.annotation.Excel; +import io.swagger.annotations.ApiModelProperty; +import com.ruoyi.common.core.domain.BaseEntity; + +/** + * 申诉详情对象 t_appeal_detail + * + * @author zj + * @date 2023-10-13 + */ +@Data +@Accessors(chain = true) +@TableName("t_appeal_detail") +public class AppealDetail extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + + @ApiModelProperty("租户号") + private Long id; + + @ApiModelProperty("删除标志 1 正常 2 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("申诉主表id") + @Excel(name = "申诉主表id") + private Long appealId; + + @ApiModelProperty("发送消息用户") + private Long sendUserId; + + @ApiModelProperty("发送消息用户类型") + private Integer sendUserType; + + @ApiModelProperty("对话消息;文字或图片") + @Excel(name = "对话消息;文字或图片") + private String message; + + @ApiModelProperty("图片") + private String images; + + @ApiModelProperty("消息类型") + private String messageType; + + @ApiModelProperty("发送消息用户信息") + @TableField(exist = false) + private UserInfo userInfo; + + @ApiModelProperty("开始时间") + @TableField(exist = false) + private Date beginTime; + + @ApiModelProperty("结束时间") + @TableField(exist = false) + private Date endTime; +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/appealdetail/mapper/AppealDetailMapper.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/appealdetail/mapper/AppealDetailMapper.java new file mode 100644 index 0000000..00426c2 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/appealdetail/mapper/AppealDetailMapper.java @@ -0,0 +1,69 @@ +package com.ruoyi.frequency.appealdetail.mapper; + +import java.util.List; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.ruoyi.controller.req.AppealMessagePageReq; +import com.ruoyi.controller.resp.AppealMessagePageResp; +import com.ruoyi.frequency.appealdetail.entity.AppealDetail; +import com.ruoyi.vo.UserVo; +import org.apache.ibatis.annotations.Param; + +/** + * 申诉详情Mapper接口 + * + * @author zj + * @date 2023-10-13 + */ +public interface AppealDetailMapper extends BaseMapper +{ + /** + * 查询申诉详情 + * + * @param id 申诉详情主键 + * @return 申诉详情 + */ + public AppealDetail selectAppealDetailById(Long id); + + /** + * 查询申诉详情列表 + * + * @param appealDetail 申诉详情 + * @return 申诉详情集合 + */ + public List selectAppealDetailList(AppealDetail appealDetail); + + /** + * 新增申诉详情 + * + * @param appealDetail 申诉详情 + * @return 结果 + */ + public int insertAppealDetail(AppealDetail appealDetail); + + /** + * 修改申诉详情 + * + * @param appealDetail 申诉详情 + * @return 结果 + */ + public int updateAppealDetail(AppealDetail appealDetail); + + /** + * 删除申诉详情 + * + * @param id 申诉详情主键 + * @return 结果 + */ + public int deleteAppealDetailById(Long id); + + /** + * 批量删除申诉详情 + * + * @param ids 需要删除的数据主键集合 + * @return 结果 + */ + public int deleteAppealDetailByIds(Long[] ids); + + Page appealMessagePage(@Param("page") Page objectPage, @Param("req")AppealMessagePageReq req, @Param("userVo") UserVo userVo); +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/appealdetail/mapper/mapping/AppealDetailMapper.xml b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/appealdetail/mapper/mapping/AppealDetailMapper.xml new file mode 100644 index 0000000..9ce34d9 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/appealdetail/mapper/mapping/AppealDetailMapper.xml @@ -0,0 +1,165 @@ + + + + + + + + + + + + + + + + + + + + + SELECT + t.id, + t.create_by, + t.create_time, + t.update_by, + t.update_time, + t.del_flag, + t.appeal_id, + t.send_user_id, + t.message, + t.send_user_type, + t.images, + t.message_type + FROM + t_appeal_detail AS t + LEFT JOIN t_store s on t.send_user_id = s.id and t.send_user_type = 2 + LEFT JOIN t_customer c on t.send_user_id = c.id and t.send_user_type = 1 + LEFT JOIN t_sale sa on t.send_user_id = sa.id and t.send_user_type = 3 + LEFT JOIN t_enterprise e on t.send_user_id = e.id and t.send_user_type = 4 + LEFT JOIN t_store es on e.id = es.bind_enterprise_id and t.send_user_type = 4 + + + + + + + + insert into t_appeal_detail + + id, + create_by, + create_time, + update_by, + update_time, + del_flag, + appeal_id, + send_user_id, + message, + + + #{id}, + #{createBy}, + #{createTime}, + #{updateBy}, + #{updateTime}, + #{delFlag}, + #{appealId}, + #{sendUserId}, + #{message}, + + + + + update t_appeal_detail + + create_by = #{createBy}, + create_time = #{createTime}, + update_by = #{updateBy}, + update_time = #{updateTime}, + del_flag = #{delFlag}, + appeal_id = #{appealId}, + send_user_id = #{sendUserId}, + message = #{message}, + + where id = #{id} + + + + delete from t_appeal_detail where id = #{id} + + + + delete from t_appeal_detail where id in + + #{id} + + + + + \ No newline at end of file diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/appealdetail/model/param/AppealDetailParam.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/appealdetail/model/param/AppealDetailParam.java new file mode 100644 index 0000000..f02d2a8 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/appealdetail/model/param/AppealDetailParam.java @@ -0,0 +1,48 @@ +package com.ruoyi.frequency.appealdetail.model.param; + +import java.util.Date; +import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.Data; +import lombok.experimental.Accessors; +import com.ruoyi.common.annotation.Excel; +import io.swagger.annotations.ApiModelProperty; +import com.ruoyi.common.core.domain.BaseEntity; + +/** + * 申诉详情对象 t_appeal_detail + * + * @author zj + * @date 2023-10-13 + */ +@Data +@Accessors(chain = true) +public class AppealDetailParam extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + @ApiModelProperty("租户号") + private Long id; + + @ApiModelProperty("删除标志 1 正常 2 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("申诉主表id") + @Excel(name = "申诉主表id") + private Long appealId; + + @ApiModelProperty("申诉人") + @Excel(name = "申诉人") + private Long sendUserId; + + @ApiModelProperty("对话消息;文字或图片") + @Excel(name = "对话消息;文字或图片") + private String message; + + + + + + + + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/appealdetail/model/result/AppealDetailResult.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/appealdetail/model/result/AppealDetailResult.java new file mode 100644 index 0000000..99ac337 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/appealdetail/model/result/AppealDetailResult.java @@ -0,0 +1,42 @@ +package com.ruoyi.frequency.appealdetail.model.result; + +import java.util.Date; +import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.Data; +import lombok.experimental.Accessors; +import com.ruoyi.common.annotation.Excel; +import io.swagger.annotations.ApiModelProperty; +import com.ruoyi.common.core.domain.BaseEntity; + +/** + * 申诉详情对象 t_appeal_detail + * + * @author zj + * @date 2023-10-13 + */ +@Data +@Accessors(chain = true) +public class AppealDetailResult extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + @ApiModelProperty("租户号") + private Long id; + + @ApiModelProperty("删除标志 1 正常 2 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("申诉主表id") + @Excel(name = "申诉主表id") + private Long appealId; + + @ApiModelProperty("申诉人") + @Excel(name = "申诉人") + private Long sendUserId; + + @ApiModelProperty("对话消息;文字或图片") + @Excel(name = "对话消息;文字或图片") + private String message; + + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/appealdetail/service/AppealDetailService.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/appealdetail/service/AppealDetailService.java new file mode 100644 index 0000000..47b13cd --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/appealdetail/service/AppealDetailService.java @@ -0,0 +1,87 @@ +package com.ruoyi.frequency.appealdetail.service; + +import java.util.List; + +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.ruoyi.common.page.PageResult; +import com.ruoyi.controller.req.AppealMessagePageReq; +import com.ruoyi.controller.req.SendMessageReq; +import com.ruoyi.controller.resp.AppealMessagePageResp; +import com.ruoyi.frequency.appealdetail.entity.AppealDetail; +import com.baomidou.mybatisplus.extension.service.IService; +import com.ruoyi.response.ResponseData; +import com.ruoyi.vo.UserVo; + +/** + * 申诉详情Service接口 + * + * @author zj + * @date 2023-10-13 + */ +public interface AppealDetailService extends IService +{ + /** + * 查询申诉详情 + * + * @param id 申诉详情主键 + * @return 申诉详情 + */ + public AppealDetail selectAppealDetailById(Long id); + + /** + * 查询申诉详情列表 + * + * @param appealDetail 申诉详情 + * @return 申诉详情集合 + */ + public List selectAppealDetailList(AppealDetail appealDetail); + + /** + * 新增申诉详情 + * + * @param appealDetail 申诉详情 + * @return 结果 + */ + public int insertAppealDetail(AppealDetail appealDetail); + + /** + * 修改申诉详情 + * + * @param appealDetail 申诉详情 + * @return 结果 + */ + public int updateAppealDetail(AppealDetail appealDetail); + + /** + * 批量删除申诉详情 + * + * @param ids 需要删除的申诉详情主键集合 + * @return 结果 + */ + public int deleteAppealDetailByIds(Long[] ids); + + /** + * 删除申诉详情信息 + * + * @param id 申诉详情主键 + * @return 结果 + */ + public int deleteAppealDetailById(Long id); + + /** + *申诉详情消息对话 + * @param req + * @param userVo + * @return + */ + ResponseData>> appealMessagePage(AppealMessagePageReq req, UserVo userVo); + + + /** + * 发送消息 + * @param req + * @param userVo + * @return + */ + ResponseData sendMessage(SendMessageReq req, UserVo userVo); +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/appealdetail/service/impl/AppealDetailServiceImpl.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/appealdetail/service/impl/AppealDetailServiceImpl.java new file mode 100644 index 0000000..2b4641c --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/appealdetail/service/impl/AppealDetailServiceImpl.java @@ -0,0 +1,195 @@ +package com.ruoyi.frequency.appealdetail.service.impl; + +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.util.ObjectUtil; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.ruoyi.code.PublicCommon; +import com.ruoyi.common.page.PageResult; +import com.ruoyi.common.utils.DateUtils; +import com.ruoyi.controller.req.AppealMessagePageReq; +import com.ruoyi.controller.req.SendMessageReq; +import com.ruoyi.controller.resp.AppealMessagePageResp; +import com.ruoyi.enums.message.OrderMessageEnums; +import com.ruoyi.enums.user.UserEnums; +import com.ruoyi.frequency.appeal.entity.Appeal; +import com.ruoyi.frequency.appeal.mapper.AppealMapper; +import com.ruoyi.frequency.appealdetail.entity.AppealDetail; +import com.ruoyi.frequency.appealdetail.mapper.AppealDetailMapper; +import com.ruoyi.frequency.appealdetail.service.AppealDetailService; +import com.ruoyi.frequency.customer.service.UserService; +import com.ruoyi.frequency.ordermessage.service.OrderMessageService; +import com.ruoyi.response.ResponseData; +import com.ruoyi.utils.BusinessUtil; +import com.ruoyi.vo.UserInfo; +import com.ruoyi.vo.UserVo; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.Comparator; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.stream.Collectors; + +/** + * 申诉详情Service业务层处理 + * + * @author zj + * @date 2023-10-13 + */ +@Service +@Transactional(rollbackFor = Exception.class) +public class AppealDetailServiceImpl extends ServiceImpl implements AppealDetailService { + @Autowired + private AppealDetailMapper appealDetailMapper; + + /** + * 查询申诉详情 + * + * @param id 申诉详情主键 + * @return 申诉详情 + */ + @Override + public AppealDetail selectAppealDetailById(Long id) { + return appealDetailMapper.selectAppealDetailById(id); + } + + /** + * 查询申诉详情列表 + * + * @param appealDetail 申诉详情 + * @return 申诉详情 + */ + @Override + public List selectAppealDetailList(AppealDetail appealDetail) { + + List appealDetails = appealDetailMapper.selectAppealDetailList(appealDetail); + + if (!appealDetails.isEmpty()) { + Set userVoSet = appealDetails.stream().map(s -> new UserVo(s.getSendUserType(), s.getSendUserId())).collect(Collectors.toSet()); + //查询用户信息 + Map userMap = userService.selectUserInfoMap(userVoSet, null); + + appealDetails.stream().forEach(s -> { + s.setUserInfo(userMap.get(new UserVo(s.getSendUserType(), s.getSendUserId()))); + }); + } + + return appealDetails; + } + + /** + * 新增申诉详情 + * + * @param appealDetail 申诉详情 + * @return 结果 + */ + @Override + public int insertAppealDetail(AppealDetail appealDetail) { + return appealDetailMapper.insertAppealDetail(appealDetail); + } + + /** + * 修改申诉详情 + * + * @param appealDetail 申诉详情 + * @return 结果 + */ + @Override + public int updateAppealDetail(AppealDetail appealDetail) { + appealDetail.setUpdateTime(DateUtils.getNowDate()); + return appealDetailMapper.updateAppealDetail(appealDetail); + } + + /** + * 批量删除申诉详情 + * + * @param ids 需要删除的申诉详情主键 + * @return 结果 + */ + @Override + public int deleteAppealDetailByIds(Long[] ids) { + this.lambdaUpdate().set(AppealDetail::getDelFlag, PublicCommon.删除).in(AppealDetail::getId, ids).update(); + return ids.length; + } + + /** + * 删除申诉详情信息 + * + * @param id 申诉详情主键 + * @return 结果 + */ + @Override + public int deleteAppealDetailById(Long id) { + this.lambdaUpdate().set(AppealDetail::getDelFlag, PublicCommon.删除).eq(AppealDetail::getId, id).update(); + return 1; + } + + @Autowired + private UserService userService; + + @Override + public ResponseData>> appealMessagePage(AppealMessagePageReq req, UserVo userVo) { + + Page page = appealDetailMapper.appealMessagePage(new Page<>(req.getPageNo(), req.getPageSize()), req, userVo); +// page.getRecords().sort(Comparator.comparing(AppealMessagePageResp::getCreateTime)); + + if (!page.getRecords().isEmpty()) { + + Set userVoSet = page.getRecords().stream().map(resp -> new UserVo(resp.getSendUserType(), resp.getSendUserId())).collect(Collectors.toSet()); + + //查询用户信息 + Map userMap = userService.selectUserInfoMap(userVoSet, userVo); + + page.getRecords().stream().forEach(resp -> { + resp.setSendUserInfo(userMap.get(new UserVo(resp.getSendUserType(), resp.getSendUserId()))); + }); + } + + return ResponseData.success(new PageResult<>(page)); + } + + @Autowired + private OrderMessageService orderMessageService; + + @Autowired + private AppealMapper appealMapper; + + @Autowired + private BusinessUtil businessUtil; + + @Override + public ResponseData sendMessage(SendMessageReq req, UserVo userVo) { + AppealDetail appealDetail = new AppealDetail(); + BeanUtil.copyProperties(req, appealDetail); + appealDetail.setSendUserId(userVo.getUserId()) + .setSendUserType(userVo.getUserType()); + boolean save = this.save(appealDetail); + + if (save) { + Appeal appeal = appealMapper.selectById(req.getAppealId()); + + UserVo sendMessageUserVo = new UserVo(); + if (appeal != null) { + if (appeal.getAppealUserId().equals(userVo.getUserId()) && appeal.getAppealUserType().equals(userVo.getUserType())) { + sendMessageUserVo.setUserId(appeal.getPassiveAppealUserId()); + sendMessageUserVo.setUserType(appeal.getPassiveAppealUserType()); + } else { + sendMessageUserVo.setUserId(appeal.getAppealUserId()); + sendMessageUserVo.setUserType(appeal.getAppealUserType()); + } + } + + + String nickname = (String) businessUtil.getUserFieldValue(userVo, "nickname"); + + //发送消息提醒用户 + orderMessageService.addOrderMessage(sendMessageUserVo, appeal.getOrderId(), "", PublicCommon.Order.订单, OrderMessageEnums.APPEAL_MESSAGE, + ObjectUtil.equal(UserEnums.store.getCode(), userVo.getUserType()) ? "表现师" : "设计师" + nickname); + } + + return ResponseData.success(); + } +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/auth/controller/AuthController.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/auth/controller/AuthController.java new file mode 100644 index 0000000..a275b74 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/auth/controller/AuthController.java @@ -0,0 +1,122 @@ +package com.ruoyi.frequency.auth.controller; + +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.page.TableDataInfo; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.common.utils.poi.ExcelUtil; +import com.ruoyi.frequency.auth.entity.Auth; +import com.ruoyi.frequency.auth.model.result.AuthCount; +import com.ruoyi.frequency.auth.service.AuthService; +import com.ruoyi.frequency.vote.entity.Vote; +import com.ruoyi.frequency.vote.model.result.VoteCount; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +/** + * 平台认证Controller + * + * @author liwenlong + * @date 2023-10-18 + */ +@RestController +@RequestMapping("/frequency/auth") +public class AuthController extends BaseController +{ + @Autowired + private AuthService authService; + + /** + * 查询平台认证列表 + */ + @PreAuthorize("@ss.hasPermi('frequency:auth:list')") + @PostMapping("/list") + public TableDataInfo list(@RequestBody Auth auth) + { + startPage(); + List list = authService.selectAuthList(auth); + return getDataTable(list); + } + + /** + * 统计 + */ + @PostMapping("/statistics") + public AjaxResult statistics(@RequestBody Auth auth) + { + AuthCount count = authService.statistics(auth); + return AjaxResult.success(count); + } + + /** + * 导出平台认证列表 + */ + @PreAuthorize("@ss.hasPermi('frequency:auth:export')") + @Log(title = "平台认证", businessType = BusinessType.EXPORT) + @GetMapping("/export") + public AjaxResult export(Auth auth) + { + List list = authService.selectAuthList(auth); + ExcelUtil util = new ExcelUtil(Auth.class); + return util.exportExcel(list, "平台认证数据"); + } + + /** + * 获取平台认证详细信息 + */ + @PreAuthorize("@ss.hasPermi('frequency:auth:query')") + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") Long id) + { + return AjaxResult.success(authService.selectAuthById(id)); + } + + /** + * 新增平台认证 + */ + @PreAuthorize("@ss.hasPermi('frequency:auth:add')") + @Log(title = "平台认证", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody Auth auth) + { + return toAjax(authService.insertAuth(auth)); + } + + /** + * 修改平台认证 + */ + @PreAuthorize("@ss.hasPermi('frequency:auth:edit')") + @Log(title = "平台认证", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody Auth auth) + { + return toAjax(authService.updateAuth(auth)); + } + + /** + * 删除平台认证 + */ + @PreAuthorize("@ss.hasPermi('frequency:auth:remove')") + @Log(title = "平台认证", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}") + public AjaxResult remove(@PathVariable Long[] ids) + { + return toAjax(authService.deleteAuthByIds(ids)); + } + + + /** + * 审核 + */ + @PreAuthorize("@ss.hasPermi('frequency:auth:process')") + @Log(title = "平台认证", businessType = BusinessType.UPDATE) + @PostMapping("/process") + public AjaxResult process(@RequestBody Auth auth) + { + return toAjax(authService.process(auth)); + } +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/auth/entity/Auth.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/auth/entity/Auth.java new file mode 100644 index 0000000..ba39a37 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/auth/entity/Auth.java @@ -0,0 +1,139 @@ +package com.ruoyi.frequency.auth.entity; + +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableName; +import com.fasterxml.jackson.annotation.JsonFormat; +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import com.ruoyi.vo.UserInfo; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; + +import java.math.BigDecimal; +import java.util.Date; + +/** + * 平台认证对象 t_auth + * + * @author liwenlong + * @date 2023-10-18 + */ +@Data +@Accessors(chain = true) +@TableName("t_auth") +public class Auth extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + + @ApiModelProperty("租户号") + private Long id; + + @ApiModelProperty("删除标志 1 正常 2 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("身份证正面") + @Excel(name = "身份证正面") + private String idFront; + + @ApiModelProperty("身份证反面") + @Excel(name = "身份证反面") + private String idBack; + + @ApiModelProperty("手持身份证照片") + @Excel(name = "手持身份证照片") + private String idHandHand; + + @ApiModelProperty("姓名") + @Excel(name = "姓名") + private String name; + + @ApiModelProperty("身份证号码") + @Excel(name = "身份证号码") + private String idcardNo; + + @ApiModelProperty("性别;性别 S:未知,M:男,F:女") + @Excel(name = "性别;性别 S:未知,M:男,F:女") + private String sex; + + @ApiModelProperty("从业时间") + @JsonFormat(pattern = "yyyy") + @Excel(name = "从业时间", width = 30, dateFormat = "yyyy-MM-dd") + private Date practiceDate; + + @ApiModelProperty("擅长领域") + @Excel(name = "擅长领域") + private String specialityArea; + + @ApiModelProperty("审核状态;1待审核 2审核成功 3审核失败") + @Excel(name = "审核状态;1待审核 2审核成功 3审核失败") + private Integer result; + + @ApiModelProperty("开户行") + @Excel(name = "开户行") + private String bank; + + @ApiModelProperty("开户支行") + @Excel(name = "开户支行") + private String subbranch; + + @ApiModelProperty("银行卡") + @Excel(name = "银行卡") + private String bankCard; + + @ApiModelProperty("认证金额") + @Excel(name = "认证金额") + private BigDecimal amount; + + @ApiModelProperty("审核失败原因") + @Excel(name = "审核失败原因") + private String reason; + + + @ApiModelProperty("表现师id") + @Excel(name = "表现师id") + private Long storeId; + + @ApiModelProperty("普通认证是否缴纳 1没有 2 缴纳") + private Integer isOrdinaryPay; + + + @ApiModelProperty("普通认证支付单号") + private String payOrderNo; + + @ApiModelProperty("支付状态 1 待支付 2支付成功 3支付失败") + private Integer payStatus; + + @ApiModelProperty("支付宝支付返回的订单号") + private String aliBusinessId; + + @ApiModelProperty("支付方式 1app支付宝 2 h5支付宝 3 app微信 4 h5微信 5 小程序 6 苹果支付 7 余额") + private Integer payType; + + @ApiModelProperty("区域") + private String area; + + @ApiModelProperty("工种") + private String branchWork; + + @ApiModelProperty("认证类型 1普通认证 3酷家乐") + private Integer type; + + @ApiModelProperty("开始时间") + @TableField(exist = false) + private Date beginTime; + + @ApiModelProperty("结束时间") + @TableField(exist = false) + private Date endTime; + + @ApiModelProperty("用户信息") + @TableField(exist = false) + private UserInfo userInfo; + + @ApiModelProperty("企业微信二维码") + @TableField(exist = false) + private String wecomQrcode; + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/auth/mapper/AuthMapper.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/auth/mapper/AuthMapper.java new file mode 100644 index 0000000..537f05b --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/auth/mapper/AuthMapper.java @@ -0,0 +1,67 @@ +package com.ruoyi.frequency.auth.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.ruoyi.frequency.auth.entity.Auth; +import com.ruoyi.frequency.auth.model.result.AuthCount; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * 平台认证Mapper接口 + * + * @author liwenlong + * @date 2023-10-18 + */ +public interface AuthMapper extends BaseMapper +{ + /** + * 查询平台认证 + * + * @param id 平台认证主键 + * @return 平台认证 + */ + public Auth selectAuthById(Long id); + + /** + * 查询平台认证列表 + * + * @param auth 平台认证 + * @return 平台认证集合 + */ + public List selectAuthList(Auth auth); + + /** + * 新增平台认证 + * + * @param auth 平台认证 + * @return 结果 + */ + public int insertAuth(Auth auth); + + /** + * 修改平台认证 + * + * @param auth 平台认证 + * @return 结果 + */ + public int updateAuth(Auth auth); + + /** + * 删除平台认证 + * + * @param id 平台认证主键 + * @return 结果 + */ + public int deleteAuthById(Long id); + + /** + * 批量删除平台认证 + * + * @param ids 需要删除的数据主键集合 + * @return 结果 + */ + public int deleteAuthByIds(Long[] ids); + + AuthCount statistics(@Param("list") List authIdList); +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/auth/mapper/mapping/AuthMapper.xml b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/auth/mapper/mapping/AuthMapper.xml new file mode 100644 index 0000000..aea7762 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/auth/mapper/mapping/AuthMapper.xml @@ -0,0 +1,254 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + SELECT + t.id, + t.branch_work, + t.create_by, + t.create_time, + t.update_by, + t.update_time, + t.del_flag, + t.id_front, + t.id_back, + t.id_hand_hand, + t.`name`, + t.idcard_no, + t.sex, + t.practice_date, + t.speciality_area, + t.result, + t.bank, + t.subbranch, + t.bank_card, + t.amount, + t.reason, + t.store_id, + t.is_ordinary_pay, + t.pay_order_no, + t.pay_status, + t.pay_type, + t.ali_business_id, + s.wecom_qrcode, + t.area, + t.type + FROM + t_auth AS t + LEFT JOIN t_store AS s ON s.id = t.store_id + + + + + + + + + + insert into t_auth + + id, + create_by, + create_time, + update_by, + update_time, + del_flag, + id_front, + id_back, + id_hand_hand, + name, + idcard_no, + sex, + practice_date, + speciality_area, + result, + bank, + subbranch, + bank_card, + amount, + reason, + store_id, + + + #{id}, + #{createBy}, + #{createTime}, + #{updateBy}, + #{updateTime}, + #{delFlag}, + #{idFront}, + #{idBack}, + #{idHandHand}, + #{name}, + #{idcardNo}, + #{sex}, + #{practiceDate}, + #{specialityArea}, + #{result}, + #{bank}, + #{subbranch}, + #{bankCard}, + #{amount}, + #{reason}, + #{storeId}, + + + + + update t_auth + + create_by = #{createBy}, + create_time = #{createTime}, + update_by = #{updateBy}, + update_time = #{updateTime}, + del_flag = #{delFlag}, + id_front = #{idFront}, + id_back = #{idBack}, + id_hand_hand = #{idHandHand}, + name = #{name}, + idcard_no = #{idcardNo}, + sex = #{sex}, + practice_date = #{practiceDate}, + speciality_area = #{specialityArea}, + result = #{result}, + bank = #{bank}, + subbranch = #{subbranch}, + bank_card = #{bankCard}, + amount = #{amount}, + reason = #{reason}, + store_id = #{storeId}, + + where id = #{id} + + + + delete from t_auth where id = #{id} + + + + delete from t_auth where id in + + #{id} + + + diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/auth/model/param/AuthParam.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/auth/model/param/AuthParam.java new file mode 100644 index 0000000..f874234 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/auth/model/param/AuthParam.java @@ -0,0 +1,114 @@ +package com.ruoyi.frequency.auth.model.param; + +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; + +import java.math.BigDecimal; +import java.util.Date; + +/** + * 平台认证对象 t_auth + * + * @author liwenlong + * @date 2023-10-18 + */ +@Data +@Accessors(chain = true) +public class AuthParam extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + @ApiModelProperty("租户号") + private Long id; + + @ApiModelProperty("删除标志 1 正常 2 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("身份证正面") + @Excel(name = "身份证正面") + private String idFront; + + @ApiModelProperty("身份证反面") + @Excel(name = "身份证反面") + private String idBack; + + @ApiModelProperty("手持身份证照片") + @Excel(name = "手持身份证照片") + private String idHandHand; + + @ApiModelProperty("姓名") + @Excel(name = "姓名") + private String name; + + @ApiModelProperty("身份证号码") + @Excel(name = "身份证号码") + private String idcardNo; + + @ApiModelProperty("性别;性别 S:未知,M:男,F:女") + @Excel(name = "性别;性别 S:未知,M:男,F:女") + private String sex; + + @ApiModelProperty("从业时间") + @Excel(name = "从业时间", width = 30, dateFormat = "yyyy-MM-dd") + private Date practiceDate; + + @ApiModelProperty("擅长领域") + @Excel(name = "擅长领域") + private String specialityArea; + + @ApiModelProperty("审核状态;1待审核 2审核成功 3审核失败") + @Excel(name = "审核状态;1待审核 2审核成功 3审核失败") + private Integer result; + + @ApiModelProperty("开户行") + @Excel(name = "开户行") + private String bank; + + @ApiModelProperty("开户支行") + @Excel(name = "开户支行") + private String subbranch; + + @ApiModelProperty("银行卡") + @Excel(name = "银行卡") + private String bankCard; + + @ApiModelProperty("认证金额") + @Excel(name = "认证金额") + private BigDecimal amount; + + @ApiModelProperty("审核失败原因") + @Excel(name = "审核失败原因") + private String reason; + + @ApiModelProperty("是否高端认证;1:待审核,2通过,3失败") + @Excel(name = "是否高端认证;1:待审核,2通过,3失败") + private Integer ifHighend; + + @ApiModelProperty("表现师id") + @Excel(name = "表现师id") + private Long storeId; + + + + + + + + + + + + + + + + + + + + + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/auth/model/result/AuthCount.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/auth/model/result/AuthCount.java new file mode 100644 index 0000000..86088b5 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/auth/model/result/AuthCount.java @@ -0,0 +1,24 @@ +package com.ruoyi.frequency.auth.model.result; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + * @author a + * @date 2024/2/22 9:15 + */ +@Data +public class AuthCount { + + @ApiModelProperty("总人数") + private Integer number; + + @ApiModelProperty("已通过人数") + private Integer passNumber; + + @ApiModelProperty("未通过人数") + private Integer noPassNumber; + + @ApiModelProperty("待审核人数") + private Integer auditNumber; +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/auth/model/result/AuthResult.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/auth/model/result/AuthResult.java new file mode 100644 index 0000000..0aa252d --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/auth/model/result/AuthResult.java @@ -0,0 +1,95 @@ +package com.ruoyi.frequency.auth.model.result; + +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; + +import java.math.BigDecimal; +import java.util.Date; + +/** + * 平台认证对象 t_auth + * + * @author liwenlong + * @date 2023-10-18 + */ +@Data +@Accessors(chain = true) +public class AuthResult extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + @ApiModelProperty("租户号") + private Long id; + + @ApiModelProperty("删除标志 1 正常 2 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("身份证正面") + @Excel(name = "身份证正面") + private String idFront; + + @ApiModelProperty("身份证反面") + @Excel(name = "身份证反面") + private String idBack; + + @ApiModelProperty("手持身份证照片") + @Excel(name = "手持身份证照片") + private String idHandHand; + + @ApiModelProperty("姓名") + @Excel(name = "姓名") + private String name; + + @ApiModelProperty("身份证号码") + @Excel(name = "身份证号码") + private String idcardNo; + + @ApiModelProperty("性别;性别 S:未知,M:男,F:女") + @Excel(name = "性别;性别 S:未知,M:男,F:女") + private String sex; + + @ApiModelProperty("从业时间") + @Excel(name = "从业时间", width = 30, dateFormat = "yyyy-MM-dd") + private Date practiceDate; + + @ApiModelProperty("擅长领域") + @Excel(name = "擅长领域") + private String specialityArea; + + @ApiModelProperty("审核状态;1待审核 2审核成功 3审核失败") + @Excel(name = "审核状态;1待审核 2审核成功 3审核失败") + private Integer result; + + @ApiModelProperty("开户行") + @Excel(name = "开户行") + private String bank; + + @ApiModelProperty("开户支行") + @Excel(name = "开户支行") + private String subbranch; + + @ApiModelProperty("银行卡") + @Excel(name = "银行卡") + private String bankCard; + + @ApiModelProperty("认证金额") + @Excel(name = "认证金额") + private BigDecimal amount; + + @ApiModelProperty("审核失败原因") + @Excel(name = "审核失败原因") + private String reason; + + @ApiModelProperty("是否高端认证;1:待审核,2通过,3失败") + @Excel(name = "是否高端认证;1:待审核,2通过,3失败") + private Integer ifHighend; + + @ApiModelProperty("表现师id") + @Excel(name = "表现师id") + private Long storeId; + + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/auth/service/AuthService.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/auth/service/AuthService.java new file mode 100644 index 0000000..61ed2c6 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/auth/service/AuthService.java @@ -0,0 +1,115 @@ +package com.ruoyi.frequency.auth.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.ruoyi.controller.req.OrdinaryAuthReq; +import com.ruoyi.frequency.auth.entity.Auth; +import com.ruoyi.frequency.auth.model.result.AuthCount; +import com.ruoyi.response.ResponseData; +import com.ruoyi.vo.UserVo; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.util.List; +import java.util.Map; + +/** + * 平台认证Service接口 + * + * @author liwenlong + * @date 2023-10-18 + */ +public interface AuthService extends IService +{ + /** + * 查询平台认证 + * + * @param id 平台认证主键 + * @return 平台认证 + */ + public Auth selectAuthById(Long id); + + /** + * 查询平台认证列表 + * + * @param auth 平台认证 + * @return 平台认证集合 + */ + public List selectAuthList(Auth auth); + + AuthCount statistics(Auth auth); + + /** + * 新增平台认证 + * + * @param auth 平台认证 + * @return 结果 + */ + public int insertAuth(Auth auth); + + /** + * 修改平台认证 + * + * @param auth 平台认证 + * @return 结果 + */ + public int updateAuth(Auth auth); + + /** + * 批量删除平台认证 + * + * @param ids 需要删除的平台认证主键集合 + * @return 结果 + */ + public int deleteAuthByIds(Long[] ids); + + /** + * 删除平台认证信息 + * + * @param id 平台认证主键 + * @return 结果 + */ + public int deleteAuthById(Long id); + + + /** + * 审核 + * @param auth + * @return + */ + int process(Auth auth); + + + /** + * 普通认证 + * @param req + * @param userVo + * @return + */ + ResponseData ordinaryAuth(OrdinaryAuthReq req, UserVo userVo); + + + /** + * 普通认证详情 + * @param userVo + * @return + */ + ResponseData ordinaryAuthDetail(Integer type,UserVo userVo); + + /** + * 支付宝回调 + * @param request + * @param response + * @return + */ + ResponseData authAliNotify(HttpServletRequest request, HttpServletResponse response); + + /** + * 微信回调 + * @param request + * @param response + * @return + */ + ResponseData authWxNotify(HttpServletRequest request, HttpServletResponse response); + + ResponseData authLakalaNotify(Map paramMap); +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/auth/service/impl/AuthServiceImpl.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/auth/service/impl/AuthServiceImpl.java new file mode 100644 index 0000000..91fe688 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/auth/service/impl/AuthServiceImpl.java @@ -0,0 +1,584 @@ +package com.ruoyi.frequency.auth.service.impl; + +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.date.DateUtil; +import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.RandomUtil; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.ruoyi.code.DictConstant; +import com.ruoyi.code.PublicCommon; +import com.ruoyi.common.core.domain.entity.SysDictData; +import com.ruoyi.common.exception.CustomException; +import com.ruoyi.common.utils.DateUtils; +import com.ruoyi.controller.req.OrdinaryAuthReq; +import com.ruoyi.enums.PlatformRecordEnums; +import com.ruoyi.enums.WalletDetailEnums; +import com.ruoyi.enums.message.AppMessageEnums; +import com.ruoyi.enums.process.ProcessResultEnums; +import com.ruoyi.enums.user.UserEnums; +import com.ruoyi.frequency.appmessage.service.AppMessageService; +import com.ruoyi.frequency.auth.entity.Auth; +import com.ruoyi.frequency.auth.mapper.AuthMapper; +import com.ruoyi.frequency.auth.model.result.AuthCount; +import com.ruoyi.frequency.auth.service.AuthService; +import com.ruoyi.frequency.customer.service.UserService; +import com.ruoyi.frequency.highendauth.entity.HighendAuth; +import com.ruoyi.frequency.highendauth.service.HighendAuthService; +import com.ruoyi.frequency.onlinerecord.service.OnlineRecordService; +import com.ruoyi.frequency.platformrecord.service.PlatformRecordService; +import com.ruoyi.frequency.store.entity.Store; +import com.ruoyi.frequency.store.service.StoreService; +import com.ruoyi.pay.enums.PayEnums; +import com.ruoyi.pay.enums.PaySourceEnums; +import com.ruoyi.pay.utils.AlipayCore; +import com.ruoyi.pay.utils.HttpRequestUtil; +import com.ruoyi.pay.utils.PayUtil; +import com.ruoyi.response.ResponseData; +import com.ruoyi.utils.BusinessUtil; +import com.ruoyi.vo.UserInfo; +import com.ruoyi.vo.UserVo; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.math.BigDecimal; +import java.util.*; +import java.util.stream.Collectors; + +/** + * 平台认证Service业务层处理 + * + * @author liwenlong + * @date 2023-10-18 + */ +@Service +@Transactional(rollbackFor = Exception.class) +@Slf4j +public class AuthServiceImpl extends ServiceImpl implements AuthService { + @Autowired + private AuthMapper authMapper; + + @Autowired + private UserService userService; + + /** + * 查询平台认证 + * + * @param id 平台认证主键 + * @return 平台认证 + */ + @Override + public Auth selectAuthById(Long id) { + Auth auth = authMapper.selectAuthById(id); + + if (auth != null) { + Set userVoSet = new HashSet<>(); + + userVoSet.add(new UserVo(UserEnums.store.getCode(), auth.getStoreId())); + + //查询用户信息 + Map userMap = userService.selectUserInfoMap(userVoSet, null); + + auth.setUserInfo(userMap.get(new UserVo(UserEnums.store.getCode(), auth.getStoreId()))); + } + + return auth; + } + + /** + * 查询平台认证列表 + * + * @param auth 平台认证 + * @return 平台认证 + */ + @Override + public List selectAuthList(Auth auth) { + + List auths = authList(auth); + + if (auths != null && auths.size() > 0) { + Set userVoSet = auths.stream().map(s -> new UserVo(UserEnums.store.getCode(), s.getStoreId())).collect(Collectors.toSet()); + //查询用户信息 + Map userMap = userService.selectUserInfoMap(userVoSet, null); + + auths.stream().forEach(s -> { + s.setUserInfo(userMap.get(new UserVo(UserEnums.store.getCode(), s.getStoreId()))); + }); + } + + return auths; + } + + + private List authList(Auth auth) { + List auths = authMapper.selectAuthList(auth); + return auths; + } + + @Override + public AuthCount statistics(Auth auth) { + List auths = authList(auth); + List authIdList = auths.stream().map(x -> x.getId()).collect(Collectors.toList()); + authIdList.add(-1L); + return authMapper.statistics(authIdList); + } + + /** + * 新增平台认证 + * + * @param auth 平台认证 + * @return 结果 + */ + @Override + public int insertAuth(Auth auth) { + return authMapper.insertAuth(auth); + } + + /** + * 修改平台认证 + * + * @param auth 平台认证 + * @return 结果 + */ + @Override + public int updateAuth(Auth auth) { + auth.setUpdateTime(DateUtils.getNowDate()); + return authMapper.updateAuth(auth); + } + + /** + * 批量删除平台认证 + * + * @param ids 需要删除的平台认证主键 + * @return 结果 + */ + @Override + public int deleteAuthByIds(Long[] ids) { + this.lambdaUpdate().set(Auth::getDelFlag, PublicCommon.删除).in(Auth::getId, ids).update(); + return ids.length; + } + + /** + * 删除平台认证信息 + * + * @param id 平台认证主键 + * @return 结果 + */ + @Override + public int deleteAuthById(Long id) { + this.lambdaUpdate().set(Auth::getDelFlag, PublicCommon.删除).eq(Auth::getId, id).update(); + return 1; + } + + @Autowired + private AppMessageService appMessageService; + + @Autowired + private StoreService storeService; + + @Override + public int process(Auth auth) { + + boolean update = this.lambdaUpdate().set(Auth::getResult, auth.getResult()) + .set(Auth::getReason, auth.getReason()) + .eq(Auth::getId, auth.getId()) + .update(); + + if (update) { + + String wecomQrcode = auth.getWecomQrcode(); + + auth = this.getById(auth.getId()); + //发送消息 + if (ProcessResultEnums.APPROVED.getCode().equals(auth.getResult())) { + //成功 + appMessageService.addAppMessage(new UserVo(UserEnums.store.getCode(), auth.getStoreId()), auth.getId(), AppMessageEnums.AUTH_MESSAGE_SUSESS); + + storeService.lambdaUpdate().set(Store::getWecomQrcode, wecomQrcode) + .set(Store::getArea, auth.getArea()) + .set(Store::getEnterDate, auth.getPracticeDate()) + .eq(Store::getId, auth.getStoreId()).update(); + + } else if (ProcessResultEnums.REJECTED.getCode().equals(auth.getResult())) { + //失败 + appMessageService.addAppMessage(new UserVo(UserEnums.store.getCode(), auth.getStoreId()), auth.getId(), AppMessageEnums.AUTH_MESSAGE_FAIL); + } + } + + return 1; + } + + @Autowired + private PayUtil payUtil; + + @Autowired + private BusinessUtil businessUtil; + + @Override + public ResponseData ordinaryAuth(OrdinaryAuthReq req, UserVo userVo) { + + userService.storeByEnterprise(userVo); + + if (req.getType() == null) { + req.setType(1); + } + //判断认证状态 + Auth auth = judgeAuthStatus(userVo, req.getType()); + + //判断已支付/未支付 认证金额 + Boolean isPay = auth == null || auth.getIsOrdinaryPay() == 1; + + Auth newAuth = new Auth(); + BeanUtil.copyProperties(req, newAuth); + newAuth.setStoreId(userVo.getUserId()) + .setIsOrdinaryPay(isPay ? 1 : 2)//普通认证是否缴纳 1没有 2 缴纳 + .setResult(PublicCommon.待审核); + + newAuth.setPracticeDate(DateUtil.parse(req.getPracticeDate(), "yyyy")); + + //支付与未支付走不同逻辑 + if (isPay) { + //未支付 + return payAuth(newAuth, req, userVo); + } else { + //已支付 + return noPayAuth(newAuth, auth); + } + } + + + /** + * 支付--认证 + * + * @return + */ + private ResponseData payAuth(Auth newAuth, OrdinaryAuthReq req, UserVo userVo) { + + SysDictData dict = null; + if (req.getType() == 1) { + //查询字典配置--普通认证缴纳金额 + dict = businessUtil.getDict(DictConstant.普通认证缴纳金额); + } else { + //查询字典配置--酷家乐认证缴纳金额 + dict = businessUtil.getDict(DictConstant.酷家乐认证缴纳金额); + } + + BigDecimal amount = dict == null ? BigDecimal.ZERO : new BigDecimal(dict.getDictValue()); + + //支付金额 + newAuth.setAmount(amount); + + //余额支付 验证密码 + if (req.getPayType().equals(PayEnums.balance.getCode())) { + //判断余额支付 + businessUtil.judgeBalancePay(userVo, amount, req.getPayPwd()); + } + + //支付订单号 + newAuth.setPayOrderNo(generateOrderNo()); + + this.save(newAuth); + + //支付 + ResponseData responseData = payUtil.pay(userVo, newAuth.getId(), req.getPayType(), amount, BigDecimal.ZERO, newAuth.getPayOrderNo(), PaySourceEnums.auth_pay, WalletDetailEnums.PLATFORM_AUTH_PAY); + + if (responseData.getSuccess() || responseData.getCode().equals(210)) { + //支付后操作 + if (req.getPayType().equals(PayEnums.balance.getCode()) || req.getPayType().equals(PayEnums.apple.getCode())) { + after(newAuth); + } + } + + return responseData; + } + + /** + * 不用支付--认证 + * + * @param newAuth + * @param auth + * @return + */ + private ResponseData noPayAuth(Auth newAuth, Auth auth) { + + if (auth != null) { + newAuth.setPayType(auth.getPayType()) + .setPayStatus(auth.getPayStatus()) + .setAmount(auth.getAmount()); + } + this.save(newAuth); + return ResponseData.success(); + } + + /** + * 判断认证状态 + * + * @param userVo + */ + private Auth judgeAuthStatus(UserVo userVo, Integer type) { + + Auth auth = this.getOne(new QueryWrapper().lambda() + .eq(Auth::getStoreId, userVo.getUserId()) + .eq(Auth::getPayStatus, PublicCommon.Pay.已支付) + .eq(Auth::getDelFlag, PublicCommon.启用) + ); + + //普通认证 + if (type == 1) { + if (auth != null && ObjectUtil.isNotEmpty(auth.getResult())) { + if (auth.getResult().equals(ProcessResultEnums.PENDING.getCode())) { + if (auth.getType() == 1) { + throw new CustomException("您已提交认证,请勿重复申请"); + } else { + throw new CustomException("您正在进行酷家乐认证,请勿重复申请"); + } + } else if (auth.getResult().equals(ProcessResultEnums.APPROVED.getCode())) { + if (auth.getType() == 1) { + throw new CustomException("您已认证成功,请勿重复认证"); + } else { + throw new CustomException("您已认证成功,请勿重复认证"); + } + } + } + } + + //酷家乐认证 + if (type == 3) { + + if (auth != null && ObjectUtil.isNotEmpty(auth.getResult())) { + if (auth.getResult().equals(ProcessResultEnums.PENDING.getCode())) { + throw new CustomException("您正在进行普通认证,请勿重复申请"); + } else if (auth.getResult().equals(ProcessResultEnums.APPROVED.getCode())) { + throw new CustomException("您已进行酷家乐认证,请勿重复认证"); + } + } + + //是否进行高端认证 + judgeAuthStatus(userVo); + } + + if (auth != null) { + //假删除认证记录 + this.lambdaUpdate().set(Auth::getDelFlag, PublicCommon.禁用).eq(Auth::getId, auth.getId()).update(); + } + + return auth; + } + + @Autowired + private HighendAuthService highendAuthService; + + /** + * 判断认证状态 + * + * @param userVo + * @return + */ + private HighendAuth judgeAuthStatus(UserVo userVo) { + + //判断认证状态 + HighendAuth auth = highendAuthService.getOne(new QueryWrapper().lambda() + .eq(HighendAuth::getStoreId, userVo.getUserId()) + .eq(HighendAuth::getDelFlag, PublicCommon.启用) + ); + if (auth != null) { + if (auth.getStatus() < 3) { + throw new CustomException("您正在进行高端认证,请勿重复认证"); + } else { + throw new CustomException("您已进行高端认证,请勿重复认证"); + } + } + + return auth; + } + + @Autowired + private PlatformRecordService platformRecordService; + + /** + * 支付后操作 + * + * @param auth + */ + private void after(Auth auth) { + this.lambdaUpdate().set(Auth::getPayStatus, PublicCommon.Pay.已支付) + .set(Auth::getIsOrdinaryPay, 2) + .eq(Auth::getId, auth.getId()).update(); + + //平台流水 + platformRecordService.addPlatformRecord(new UserVo(UserEnums.store.getCode(), auth.getStoreId()), auth.getId(), auth.getAmount(), PlatformRecordEnums.PLATFORM_AUTH_PAY); + } + + @Override + public ResponseData ordinaryAuthDetail(Integer type, UserVo userVo) { + + userService.storeByEnterprise(userVo); + + Auth auth = this.getOne(new QueryWrapper().lambda() + .eq(Auth::getStoreId, userVo.getUserId()) + .eq(Auth::getType, type) + .eq(Auth::getDelFlag, PublicCommon.启用) + .eq(Auth::getPayStatus, PublicCommon.Pay.已支付)); + return ResponseData.success(auth); + } + + + /** + * 生成订单号 + * + * @return + */ + private String generateOrderNo() { + String orderNo; + String prefix = "PA"; + while (true) { + orderNo = prefix + DateUtil.format(new Date(), "MMdd" + RandomUtil.randomNumbers(6)); + Auth old = this.getBaseMapper().selectOne(new QueryWrapper().lambda() + .eq(Auth::getPayOrderNo, orderNo) + + ); + if (old == null) { + break; + } + } + return orderNo; + } + + @Override + public ResponseData authAliNotify(HttpServletRequest request, HttpServletResponse response) { + log.info("******************************进入支付宝支付回调"); + //接收参数进行校验 + Map paramsMap = AlipayCore.updateMap(request); + //流水号 + String payId = paramsMap.get("out_trade_no"); + // 支付宝订单号 + String orderNo = paramsMap.get("trade_no"); + //付款状态 + String tradeStatus = paramsMap.get("trade_status"); + log.info("******************************payId=" + payId); + + Auth cur = baseMapper.selectOne(new QueryWrapper().lambda().eq(Auth::getPayOrderNo, payId)); + if (cur == null) { + log.error("支付信息丢失"); + return ResponseData.error("支付信息丢失"); + } + if (cur.getPayStatus() == 2) { + log.error("支付宝回调已经开始 回去吧"); + return ResponseData.error("支付宝回调已经开始 回去吧"); + } + if (cur.getPayStatus() == 3) { + //退款 + ResponseData responseData = payUtil.refund(new UserVo(UserEnums.store.getCode(), cur.getStoreId()), cur.getId(), cur.getPayType(), cur.getAmount(), cur.getAmount(), cur.getPayOrderNo(), cur.getAliBusinessId(), BigDecimal.ZERO); + if (!responseData.getSuccess()) { + log.error("退款失败:" + cur.getPayOrderNo()); + } + return responseData; + } + if ("TRADE_SUCCESS".equalsIgnoreCase(tradeStatus)) { + + this.lambdaUpdate().set(Auth::getAliBusinessId, orderNo).eq(Auth::getId, cur.getId()).update(); + + after(cur);//支付后逻辑处理 + log.info("正常"); + return ResponseData.success(); + } else { + cur.setPayStatus(3); + baseMapper.updateById(cur); + log.error("支付失败"); + } + return ResponseData.error(""); + } + + @Override + public ResponseData authWxNotify(HttpServletRequest request, HttpServletResponse response) { + Map requestMap = HttpRequestUtil.parseXml(request); + System.out.println("requestMap:" + requestMap.toString()); + // 微信中的订单号 + String transactionId = requestMap.get("transaction_id"); + // 用户唯一标识 + String openid = requestMap.get("openid"); + //流水号 + String payId = requestMap.get("out_trade_no"); + + Auth cur = baseMapper.selectOne(new QueryWrapper().lambda().eq(Auth::getPayOrderNo, payId)); + if (cur == null) { + log.error("支付信息丢失"); + return ResponseData.error("支付信息丢失"); + } + if (cur.getPayStatus() == 2) { + log.error("微信回调已经开始 回去吧"); + return ResponseData.error("支付宝回调已经开始 回去吧"); + } + if (cur.getPayStatus() == 3) { + //退款 + ResponseData responseData = payUtil.refund(new UserVo(UserEnums.store.getCode(), cur.getStoreId()), cur.getId(), cur.getPayType(), cur.getAmount(), cur.getAmount(), cur.getPayOrderNo(), cur.getAliBusinessId(), BigDecimal.ZERO); + if (!responseData.getSuccess()) { + log.error("退款失败:" + cur.getPayOrderNo()); + } + return responseData; + } + + if ("SUCCESS".equals(requestMap.get("result_code"))) { + after(cur);//支付后逻辑处理 + log.info("正常"); + return ResponseData.success(); + } else { + cur.setPayStatus(3); + baseMapper.updateById(cur); + log.error("支付失败"); + } + + return ResponseData.error(""); + } + + @Override + public ResponseData authLakalaNotify(Map requestMap) { + System.out.println("requestMap:" + requestMap.toString()); + //流水号 + String payId = requestMap.get("out_order_no"); + Auth cur = baseMapper.selectOne(new QueryWrapper().lambda().eq(Auth::getPayOrderNo, payId)); + if (cur == null) { + log.error("支付信息丢失"); + return ResponseData.error("支付信息丢失"); + } + if (cur.getPayStatus() == 2) { + log.error("拉卡拉回调已经开始 回去吧"); + return ResponseData.error("拉卡拉回调已经开始 回去吧"); + } + if (cur.getPayStatus() == 3) { + //退款 + ResponseData responseData = payUtil.refund(new UserVo(UserEnums.store.getCode(), cur.getStoreId()), cur.getId(), cur.getPayType(), cur.getAmount(), cur.getAmount(), cur.getPayOrderNo(), cur.getAliBusinessId(), BigDecimal.ZERO); + if (!responseData.getSuccess()) { + log.error("退款失败:" + cur.getPayOrderNo()); + } + return responseData; + } + + //order_status 聚合收银台订单状态 0:待支付 1:支付中 2:支付成功 3:支付失败 4:已过期 5:已取消 6:部分退款或者全部退款 + if (("2").equals(requestMap.get("order_status"))) { + after(cur);//支付后逻辑处理 + log.info("正常"); + + //设置成功标识 + businessUtil.setOutTradeNo(payId); + + //添加支付记录 + onlineRecordService.addOnlineRecord(new UserVo(UserEnums.customer.getCode(), cur.getStoreId()), cur.getId(), cur.getAmount(), WalletDetailEnums.PLATFORM_AUTH_PAY); + + return ResponseData.success(); + } else { + cur.setPayStatus(3); + baseMapper.updateById(cur); + log.error("支付失败"); + } + + return ResponseData.error(""); + } + + @Autowired + private OnlineRecordService onlineRecordService; +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/bondamounrecord/controller/BondAmountRecordController.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/bondamounrecord/controller/BondAmountRecordController.java new file mode 100644 index 0000000..2fa9e8c --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/bondamounrecord/controller/BondAmountRecordController.java @@ -0,0 +1,97 @@ +package com.ruoyi.frequency.bondamounrecord.controller; + +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.page.TableDataInfo; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.common.utils.poi.ExcelUtil; +import com.ruoyi.frequency.bondamounrecord.entity.BondAmountRecord; +import com.ruoyi.frequency.bondamounrecord.service.BondAmountRecordService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +/** + * 缴纳保证金Controller + * + * @author liwenlong + * @date 2023-10-31 + */ +@RestController +@RequestMapping("/frequency/bondamounrecord") +public class BondAmountRecordController extends BaseController +{ + @Autowired + private BondAmountRecordService bondAmountRecordService; + + /** + * 查询缴纳保证金列表 + */ + @PreAuthorize("@ss.hasPermi('frequency:bondamounrecord:list')") + @PostMapping("/list") + public TableDataInfo list(@RequestBody BondAmountRecord bondAmountRecord) + { + startPage(); + List list = bondAmountRecordService.selectBondAmountRecordList(bondAmountRecord); + return getDataTable(list); + } + + /** + * 导出缴纳保证金列表 + */ + @PreAuthorize("@ss.hasPermi('frequency:bondamounrecord:export')") + @Log(title = "缴纳保证金", businessType = BusinessType.EXPORT) + @GetMapping("/export") + public AjaxResult export(BondAmountRecord bondAmountRecord) + { + List list = bondAmountRecordService.selectBondAmountRecordList(bondAmountRecord); + ExcelUtil util = new ExcelUtil(BondAmountRecord.class); + return util.exportExcel(list, "缴纳保证金数据"); + } + + /** + * 获取缴纳保证金详细信息 + */ + @PreAuthorize("@ss.hasPermi('frequency:bondamounrecord:query')") + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") Long id) + { + return AjaxResult.success(bondAmountRecordService.selectBondAmountRecordById(id)); + } + + /** + * 新增缴纳保证金 + */ + @PreAuthorize("@ss.hasPermi('frequency:bondamounrecord:add')") + @Log(title = "缴纳保证金", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody BondAmountRecord bondAmountRecord) + { + return toAjax(bondAmountRecordService.insertBondAmountRecord(bondAmountRecord)); + } + + /** + * 修改缴纳保证金 + */ + @PreAuthorize("@ss.hasPermi('frequency:bondamounrecord:edit')") + @Log(title = "缴纳保证金", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody BondAmountRecord bondAmountRecord) + { + return toAjax(bondAmountRecordService.updateBondAmountRecord(bondAmountRecord)); + } + + /** + * 删除缴纳保证金 + */ + @PreAuthorize("@ss.hasPermi('frequency:bondamounrecord:remove')") + @Log(title = "缴纳保证金", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}/{delFlag}") + public AjaxResult remove(@PathVariable("ids") Long[] ids,@PathVariable("delFlag") Integer delFalg) + { + return toAjax(bondAmountRecordService.deleteBondAmountRecordByIds(ids,delFalg)); + } +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/bondamounrecord/entity/BondAmountRecord.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/bondamounrecord/entity/BondAmountRecord.java new file mode 100644 index 0000000..56a097f --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/bondamounrecord/entity/BondAmountRecord.java @@ -0,0 +1,56 @@ +package com.ruoyi.frequency.bondamounrecord.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; + +import java.math.BigDecimal; + +/** + * 缴纳保证金对象 t_bond_amount_record + * + * @author liwenlong + * @date 2023-10-31 + */ +@Data +@Accessors(chain = true) +@TableName("t_bond_amount_record") +public class BondAmountRecord extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + + @ApiModelProperty("租户号") + private Long id; + + @ApiModelProperty("删除标志;1 正常 2 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("用户类型") + @Excel(name = "用户类型") + private Integer userType; + + @ApiModelProperty("表现师id") + @Excel(name = "表现师id") + private Long userId; + + @ApiModelProperty("提现金额") + @Excel(name = "提现金额") + private BigDecimal amount; + + @ApiModelProperty("当前金额") + @Excel(name = "当前金额") + private BigDecimal currentAmount; + + @ApiModelProperty("保证金提现类型 1 提现 2 提现返还") + @Excel(name = "保证金提现类型 1 提现 2 提现返还") + private Integer type; + + @ApiModelProperty("来源id") + private Long objectId; + + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/bondamounrecord/mapper/BondAmountRecordMapper.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/bondamounrecord/mapper/BondAmountRecordMapper.java new file mode 100644 index 0000000..5a2bdc7 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/bondamounrecord/mapper/BondAmountRecordMapper.java @@ -0,0 +1,48 @@ +package com.ruoyi.frequency.bondamounrecord.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.ruoyi.frequency.bondamounrecord.entity.BondAmountRecord; + +import java.util.List; + +/** + * 缴纳保证金Mapper接口 + * + * @author liwenlong + * @date 2023-10-31 + */ +public interface BondAmountRecordMapper extends BaseMapper +{ + /** + * 查询缴纳保证金 + * + * @param id 缴纳保证金主键 + * @return 缴纳保证金 + */ + public BondAmountRecord selectBondAmountRecordById(Long id); + + /** + * 查询缴纳保证金列表 + * + * @param bondAmountRecord 缴纳保证金 + * @return 缴纳保证金集合 + */ + public List selectBondAmountRecordList(BondAmountRecord bondAmountRecord); + + /** + * 新增缴纳保证金 + * + * @param bondAmountRecord 缴纳保证金 + * @return 结果 + */ + public int insertBondAmountRecord(BondAmountRecord bondAmountRecord); + + /** + * 修改缴纳保证金 + * + * @param bondAmountRecord 缴纳保证金 + * @return 结果 + */ + public int updateBondAmountRecord(BondAmountRecord bondAmountRecord); + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/bondamounrecord/mapper/mapping/BondAmountRecordMapper.xml b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/bondamounrecord/mapper/mapping/BondAmountRecordMapper.xml new file mode 100644 index 0000000..a597523 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/bondamounrecord/mapper/mapping/BondAmountRecordMapper.xml @@ -0,0 +1,90 @@ + + + + + + + + + + + + + + + + + + + + select id, create_by, created_time, update_by, update_time, del_flag, user_type, user_id, amount, current_amount, type from t_bond_amount_record + + + + + + + + insert into t_bond_amount_record + + id, + create_by, + created_time, + update_by, + update_time, + del_flag, + user_type, + user_id, + amount, + current_amount, + type, + + + #{id}, + #{createBy}, + #{createdTime}, + #{updateBy}, + #{updateTime}, + #{delFlag}, + #{userType}, + #{userId}, + #{amount}, + #{currentAmount}, + #{type}, + + + + + update t_bond_amount_record + + create_by = #{createBy}, + created_time = #{createdTime}, + update_by = #{updateBy}, + update_time = #{updateTime}, + del_flag = #{delFlag}, + user_type = #{userType}, + user_id = #{userId}, + amount = #{amount}, + current_amount = #{currentAmount}, + type = #{type}, + + where id = #{id} + + + \ No newline at end of file diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/bondamounrecord/model/param/BondAmountRecordParam.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/bondamounrecord/model/param/BondAmountRecordParam.java new file mode 100644 index 0000000..439ce77 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/bondamounrecord/model/param/BondAmountRecordParam.java @@ -0,0 +1,63 @@ +package com.ruoyi.frequency.bondamounrecord.model.param; + +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; + +import java.math.BigDecimal; +import java.util.Date; + +/** + * 缴纳保证金对象 t_bond_amount_record + * + * @author liwenlong + * @date 2023-10-31 + */ +@Data +@Accessors(chain = true) +public class BondAmountRecordParam extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + @ApiModelProperty("租户号") + private Long id; + + @ApiModelProperty("创建时间") + @Excel(name = "创建时间", width = 30, dateFormat = "yyyy-MM-dd") + private Date createdTime; + + @ApiModelProperty("删除标志;1 正常 2 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("用户类型") + @Excel(name = "用户类型") + private Integer userType; + + @ApiModelProperty("表现师id") + @Excel(name = "表现师id") + private Long userId; + + @ApiModelProperty("提现金额") + @Excel(name = "提现金额") + private BigDecimal amount; + + @ApiModelProperty("当前金额") + @Excel(name = "当前金额") + private BigDecimal currentAmount; + + @ApiModelProperty("保证金提现类型 1 提现 2 提现返还") + @Excel(name = "保证金提现类型 1 提现 2 提现返还") + private Integer type; + + + + + + + + + + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/bondamounrecord/model/result/BondAmountRecordResult.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/bondamounrecord/model/result/BondAmountRecordResult.java new file mode 100644 index 0000000..f43c4b8 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/bondamounrecord/model/result/BondAmountRecordResult.java @@ -0,0 +1,55 @@ +package com.ruoyi.frequency.bondamounrecord.model.result; + +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; + +import java.math.BigDecimal; +import java.util.Date; + +/** + * 缴纳保证金对象 t_bond_amount_record + * + * @author liwenlong + * @date 2023-10-31 + */ +@Data +@Accessors(chain = true) +public class BondAmountRecordResult extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + @ApiModelProperty("租户号") + private Long id; + + @ApiModelProperty("创建时间") + @Excel(name = "创建时间", width = 30, dateFormat = "yyyy-MM-dd") + private Date createdTime; + + @ApiModelProperty("删除标志;1 正常 2 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("用户类型") + @Excel(name = "用户类型") + private Integer userType; + + @ApiModelProperty("表现师id") + @Excel(name = "表现师id") + private Long userId; + + @ApiModelProperty("提现金额") + @Excel(name = "提现金额") + private BigDecimal amount; + + @ApiModelProperty("当前金额") + @Excel(name = "当前金额") + private BigDecimal currentAmount; + + @ApiModelProperty("保证金提现类型 1 提现 2 提现返还") + @Excel(name = "保证金提现类型 1 提现 2 提现返还") + private Integer type; + + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/bondamounrecord/service/BondAmountRecordService.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/bondamounrecord/service/BondAmountRecordService.java new file mode 100644 index 0000000..83d821e --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/bondamounrecord/service/BondAmountRecordService.java @@ -0,0 +1,67 @@ +package com.ruoyi.frequency.bondamounrecord.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.ruoyi.frequency.bondamounrecord.entity.BondAmountRecord; +import com.ruoyi.vo.UserVo; + +import java.math.BigDecimal; +import java.util.List; + +/** + * 缴纳保证金Service接口 + * + * @author liwenlong + * @date 2023-10-31 + */ +public interface BondAmountRecordService extends IService +{ + /** + * 查询缴纳保证金 + * + * @param id 缴纳保证金主键 + * @return 缴纳保证金 + */ + public BondAmountRecord selectBondAmountRecordById(Long id); + + /** + * 查询缴纳保证金列表 + * + * @param bondAmountRecord 缴纳保证金 + * @return 缴纳保证金集合 + */ + public List selectBondAmountRecordList(BondAmountRecord bondAmountRecord); + + /** + * 新增缴纳保证金 + * + * @param bondAmountRecord 缴纳保证金 + * @return 结果 + */ + public int insertBondAmountRecord(BondAmountRecord bondAmountRecord); + + /** + * 修改缴纳保证金 + * + * @param bondAmountRecord 缴纳保证金 + * @return 结果 + */ + public int updateBondAmountRecord(BondAmountRecord bondAmountRecord); + + /** + * 批量删除缴纳保证金 + * + * @param ids 需要删除的缴纳保证金主键集合 + * @return 结果 + */ + public int deleteBondAmountRecordByIds(Long[] ids,Integer delFalg); + + /** + * + * @param userVo + * @param type 1 提现 2 提现返还 + * @param withDrawlRecordId + * @param amount + * @param status + */ + void updateBond(UserVo userVo,Long objectId, Integer type, Long withDrawlRecordId, BigDecimal amount, Integer status); +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/bondamounrecord/service/impl/BondAmountRecordServiceImpl.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/bondamounrecord/service/impl/BondAmountRecordServiceImpl.java new file mode 100644 index 0000000..626a506 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/bondamounrecord/service/impl/BondAmountRecordServiceImpl.java @@ -0,0 +1,146 @@ +package com.ruoyi.frequency.bondamounrecord.service.impl; + +import cn.hutool.core.util.ObjectUtil; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.ruoyi.code.PublicCommon; +import com.ruoyi.common.exception.CustomException; +import com.ruoyi.common.exception.enums.CoreExceptionEnum; +import com.ruoyi.common.utils.DateUtils; +import com.ruoyi.frequency.bondamounrecord.entity.BondAmountRecord; +import com.ruoyi.frequency.bondamounrecord.mapper.BondAmountRecordMapper; +import com.ruoyi.frequency.bondamounrecord.service.BondAmountRecordService; +import com.ruoyi.frequency.store.mapper.StoreMapper; +import com.ruoyi.utils.BusinessUtil; +import com.ruoyi.vo.UserVo; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.math.BigDecimal; +import java.util.List; + +/** + * 缴纳保证金Service业务层处理 + * + * @author liwenlong + * @date 2023-10-31 + */ +@Service +public class BondAmountRecordServiceImpl extends ServiceImpl implements BondAmountRecordService +{ + @Autowired + private BondAmountRecordMapper bondAmountRecordMapper; + + /** + * 查询缴纳保证金 + * + * @param id 缴纳保证金主键 + * @return 缴纳保证金 + */ + @Override + public BondAmountRecord selectBondAmountRecordById(Long id) + { + return bondAmountRecordMapper.selectBondAmountRecordById(id); + } + + /** + * 查询缴纳保证金列表 + * + * @param bondAmountRecord 缴纳保证金 + * @return 缴纳保证金 + */ + @Override + public List selectBondAmountRecordList(BondAmountRecord bondAmountRecord) + { + return bondAmountRecordMapper.selectBondAmountRecordList(bondAmountRecord); + } + + /** + * 新增缴纳保证金 + * + * @param bondAmountRecord 缴纳保证金 + * @return 结果 + */ + @Override + public int insertBondAmountRecord(BondAmountRecord bondAmountRecord) + { + return bondAmountRecordMapper.insert(bondAmountRecord); + } + + /** + * 修改缴纳保证金 + * + * @param bondAmountRecord 缴纳保证金 + * @return 结果 + */ + @Override + public int updateBondAmountRecord(BondAmountRecord bondAmountRecord) + { + bondAmountRecord.setUpdateTime(DateUtils.getNowDate()); + return bondAmountRecordMapper.updateById(bondAmountRecord); + } + + /** + * 批量删除缴纳保证金 + * + * @param ids 需要删除的缴纳保证金主键 + * @return 结果 + */ + @Override + public int deleteBondAmountRecordByIds(Long[] ids,Integer delFalg) + { + this.lambdaUpdate().set(BondAmountRecord::getDelFlag,delFalg).in(BondAmountRecord::getId,ids).update(); + return ids.length; + } + + @Autowired + private StoreMapper storeMapper; + + @Override + public void updateBond(UserVo userVo,Long objectId, Integer type, Long withDrawlRecordId, BigDecimal updatePrice, Integer status) { + if (userVo.getUserType() != 2){ + return; + } + + if (updatePrice.compareTo(BigDecimal.ZERO) == 0 || ObjectUtil.equal(PublicCommon.Wallet.到账取消, status)) { + throw new CustomException(CoreExceptionEnum.ERROR_PARAM); + } + + if (updatePrice.compareTo(BigDecimal.ZERO) == 1) { + storeMapper.addBondAmount(userVo.getUserId(), updatePrice); + }else { + boolean subBalance = storeMapper.subBondAmount(userVo.getUserId(), updatePrice.negate()); + if (!subBalance) { + throw new CustomException(CoreExceptionEnum.BALANCE_INSUFFICIENT); + } + } + + + //添加保证金金额记录 + addBondWalletRecord(userVo, objectId, updatePrice, type, status); + } + + @Autowired + private BusinessUtil businessUtil; + + /** + * 增加余额记录 + * + * @param userVo 用户 + * @param price 金额 + */ + public void addBondWalletRecord(UserVo userVo,Long objectId, BigDecimal price, Integer type, Integer status) { + if (price.setScale(2, BigDecimal.ROUND_HALF_UP).compareTo(new BigDecimal(0)) != 0) { + BondAmountRecord bondAmountRecord = new BondAmountRecord(); + bondAmountRecord.setUserId(userVo.getUserId()); + bondAmountRecord.setUserType(userVo.getUserType()); + bondAmountRecord.setType(type); + bondAmountRecord.setObjectId(objectId); + bondAmountRecord.setAmount(price); + + //获取用户当前余额 + BigDecimal userBalance = new BigDecimal(businessUtil.getUserFieldValue(userVo, "bondAmount").toString()); + bondAmountRecord.setCurrentAmount(userBalance); + this.save(bondAmountRecord); + } + } +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/bondrecord/controller/BondRecordController.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/bondrecord/controller/BondRecordController.java new file mode 100644 index 0000000..5d10797 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/bondrecord/controller/BondRecordController.java @@ -0,0 +1,97 @@ +package com.ruoyi.frequency.bondrecord.controller; + +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.page.TableDataInfo; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.common.utils.poi.ExcelUtil; +import com.ruoyi.frequency.bondrecord.entity.BondRecord; +import com.ruoyi.frequency.bondrecord.service.BondRecordService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +/** + * 保证金记录Controller + * + * @author liwenlong + * @date 2023-10-18 + */ +@RestController +@RequestMapping("/frequency/bondrecord") +public class BondRecordController extends BaseController +{ + @Autowired + private BondRecordService bondRecordService; + + /** + * 查询保证金记录列表 + */ + @PreAuthorize("@ss.hasPermi('frequency:bondrecord:list')") + @PostMapping("/list") + public TableDataInfo list(@RequestBody BondRecord bondRecord) + { + startPage(); + List list = bondRecordService.selectBondRecordList(bondRecord); + return getDataTable(list); + } + + /** + * 导出保证金记录列表 + */ + @PreAuthorize("@ss.hasPermi('frequency:bondrecord:export')") + @Log(title = "保证金记录", businessType = BusinessType.EXPORT) + @GetMapping("/export") + public AjaxResult export(BondRecord bondRecord) + { + List list = bondRecordService.selectBondRecordList(bondRecord); + ExcelUtil util = new ExcelUtil(BondRecord.class); + return util.exportExcel(list, "保证金记录数据"); + } + + /** + * 获取保证金记录详细信息 + */ + @PreAuthorize("@ss.hasPermi('frequency:bondrecord:query')") + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") Long id) + { + return AjaxResult.success(bondRecordService.selectBondRecordById(id)); + } + + /** + * 新增保证金记录 + */ + @PreAuthorize("@ss.hasPermi('frequency:bondrecord:add')") + @Log(title = "保证金记录", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody BondRecord bondRecord) + { + return toAjax(bondRecordService.insertBondRecord(bondRecord)); + } + + /** + * 修改保证金记录 + */ + @PreAuthorize("@ss.hasPermi('frequency:bondrecord:edit')") + @Log(title = "保证金记录", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody BondRecord bondRecord) + { + return toAjax(bondRecordService.updateBondRecord(bondRecord)); + } + + /** + * 删除保证金记录 + */ + @PreAuthorize("@ss.hasPermi('frequency:bondrecord:remove')") + @Log(title = "保证金记录", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}") + public AjaxResult remove(@PathVariable Long[] ids) + { + return toAjax(bondRecordService.deleteBondRecordByIds(ids)); + } +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/bondrecord/entity/BondRecord.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/bondrecord/entity/BondRecord.java new file mode 100644 index 0000000..e59a872 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/bondrecord/entity/BondRecord.java @@ -0,0 +1,113 @@ +package com.ruoyi.frequency.bondrecord.entity; + +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableName; +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; + +import java.math.BigDecimal; +import java.util.Date; + +/** + * 保证金记录对象 t_bond_record + * + * @author liwenlong + * @date 2023-10-18 + */ +@Data +@Accessors(chain = true) +@TableName("t_bond_record") +public class BondRecord extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + + @ApiModelProperty("租户号") + private Long id; + + @ApiModelProperty("删除标志;1 正常 2 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("表现师id") + @Excel(name = "表现师id") + private Long userId; + + @ApiModelProperty("金额") + @Excel(name = "金额") + private BigDecimal amount; + + @ApiModelProperty("支付方式,1app支付宝 2 h5支付宝 3 app微信 4 h5微信 5 小程序 6 苹果支付 7 余额") + @Excel(name = "支付方式,1app支付宝 2 h5支付宝 3 app微信 4 h5微信 5 小程序 6 苹果支付 7 余额") + private Integer payType; + + @ApiModelProperty("支付宝支付返回的订单号") + @Excel(name = "支付宝支付返回的订单号") + private String aliBusinessId; + + @ApiModelProperty("支付订单号") + private String payOrderNo; + + @ApiModelProperty("支付状态 1待支付 2支付成功 3支付失败") + private Integer payStatus; + + @ApiModelProperty("保证金提现类型 1 缴纳 2 提现 3 提现返还") + @TableField(exist = false) + private Integer type; + + @ApiModelProperty("保证金提现类型 1 缴纳 2 提现 3 提现返还 4 平台扣除 5 平台赠与") + @TableField(exist = false) + private String typeName; + + @ApiModelProperty("当前保证金") + @TableField(exist = false) + private BigDecimal currentAmount; + + @TableField(exist = false) + private Integer status; + + /** + * 用户备注 + */ + @TableField(exist = false) + private String remarks; + + /** + * 转账凭证 + */ + @TableField(exist = false) + private String transferVoucher; + + @TableField(exist = false) + private String refuseReason; + + + @ApiModelProperty("开户行") + @TableField(exist = false) + private String bank; + + @ApiModelProperty("开户支行") + @TableField(exist = false) + private String subbranch; + + @ApiModelProperty("银行卡") + @TableField(exist = false) + private String bankCard; + + @ApiModelProperty("申请时间") + @TableField(exist = false) + private Date applyTime; + + @ApiModelProperty("审核通过时间") + @TableField(exist = false) + private Date processTime; + + @ApiModelProperty("姓名") + @TableField(exist = false) + private String fullName; + + + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/bondrecord/mapper/BondRecordMapper.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/bondrecord/mapper/BondRecordMapper.java new file mode 100644 index 0000000..ce5164f --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/bondrecord/mapper/BondRecordMapper.java @@ -0,0 +1,71 @@ +package com.ruoyi.frequency.bondrecord.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.ruoyi.controller.req.BondRecordPageReq; +import com.ruoyi.frequency.bondrecord.entity.BondRecord; +import com.ruoyi.vo.UserVo; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * 保证金记录Mapper接口 + * + * @author liwenlong + * @date 2023-10-18 + */ +public interface BondRecordMapper extends BaseMapper +{ + /** + * 查询保证金记录 + * + * @param id 保证金记录主键 + * @return 保证金记录 + */ + public BondRecord selectBondRecordById(Long id); + + /** + * 查询保证金记录列表 + * + * @param bondRecord 保证金记录 + * @return 保证金记录集合 + */ + public List selectBondRecordList(BondRecord bondRecord); + + /** + * 新增保证金记录 + * + * @param bondRecord 保证金记录 + * @return 结果 + */ + public int insertBondRecord(BondRecord bondRecord); + + /** + * 修改保证金记录 + * + * @param bondRecord 保证金记录 + * @return 结果 + */ + public int updateBondRecord(BondRecord bondRecord); + + /** + * 删除保证金记录 + * + * @param id 保证金记录主键 + * @return 结果 + */ + public int deleteBondRecordById(Long id); + + /** + * 批量删除保证金记录 + * + * @param ids 需要删除的数据主键集合 + * @return 结果 + */ + public int deleteBondRecordByIds(Long[] ids); + + Page bondRecordPage(@Param("page") Page objectPage,@Param("req") BondRecordPageReq req, @Param("userVo") UserVo userVo); + + BondRecord bondRecordDetail(@Param("id") Long id,@Param("userVo") UserVo userVo); +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/bondrecord/mapper/mapping/BondRecordMapper.xml b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/bondrecord/mapper/mapping/BondRecordMapper.xml new file mode 100644 index 0000000..814b341 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/bondrecord/mapper/mapping/BondRecordMapper.xml @@ -0,0 +1,203 @@ + + + + + + + + + + + + + + + + + + + select id, create_by, create_time, update_by, update_time, del_flag, user_id, amount, pay_type, ali_business_id from t_bond_record + + + + + + + + insert into t_bond_record + + id, + create_by, + create_time, + update_by, + update_time, + del_flag, + user_id, + amount, + pay_type, + ali_business_id, + + + #{id}, + #{createBy}, + #{createTime}, + #{updateBy}, + #{updateTime}, + #{delFlag}, + #{userId}, + #{amount}, + #{payType}, + #{aliBusinessId}, + + + + + update t_bond_record + + create_by = #{createBy}, + create_time = #{createTime}, + update_by = #{updateBy}, + update_time = #{updateTime}, + del_flag = #{delFlag}, + user_id = #{userId}, + amount = #{amount}, + pay_type = #{payType}, + ali_business_id = #{aliBusinessId}, + + where id = #{id} + + + + delete from t_bond_record where id = #{id} + + + + delete from t_bond_record where id in + + #{id} + + + + + + + \ No newline at end of file diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/bondrecord/model/param/BondRecordParam.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/bondrecord/model/param/BondRecordParam.java new file mode 100644 index 0000000..18a05a6 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/bondrecord/model/param/BondRecordParam.java @@ -0,0 +1,54 @@ +package com.ruoyi.frequency.bondrecord.model.param; + +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; + +import java.math.BigDecimal; + +/** + * 保证金记录对象 t_bond_record + * + * @author liwenlong + * @date 2023-10-18 + */ +@Data +@Accessors(chain = true) +public class BondRecordParam extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + @ApiModelProperty("租户号") + private Long id; + + + @ApiModelProperty("删除标志;1 正常 2 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("表现师id") + @Excel(name = "表现师id") + private Long userId; + + @ApiModelProperty("金额") + @Excel(name = "金额") + private BigDecimal amount; + + @ApiModelProperty("支付方式,1app支付宝 2 h5支付宝 3 app微信 4 h5微信 5 小程序 6 苹果支付 7 余额") + @Excel(name = "支付方式,1app支付宝 2 h5支付宝 3 app微信 4 h5微信 5 小程序 6 苹果支付 7 余额") + private Integer payType; + + @ApiModelProperty("支付宝支付返回的订单号") + @Excel(name = "支付宝支付返回的订单号") + private String aliBusinessId; + + + + + + + + + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/bondrecord/model/result/BondRecordResult.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/bondrecord/model/result/BondRecordResult.java new file mode 100644 index 0000000..4734343 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/bondrecord/model/result/BondRecordResult.java @@ -0,0 +1,48 @@ +package com.ruoyi.frequency.bondrecord.model.result; + +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; + +import java.math.BigDecimal; + +/** + * 保证金记录对象 t_bond_record + * + * @author liwenlong + * @date 2023-10-18 + */ +@Data +@Accessors(chain = true) +public class BondRecordResult extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + @ApiModelProperty("租户号") + private Long id; + + + + @ApiModelProperty("删除标志;1 正常 2 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("表现师id") + @Excel(name = "表现师id") + private Long userId; + + @ApiModelProperty("金额") + @Excel(name = "金额") + private BigDecimal amount; + + @ApiModelProperty("支付方式,1app支付宝 2 h5支付宝 3 app微信 4 h5微信 5 小程序 6 苹果支付 7 余额") + @Excel(name = "支付方式,1app支付宝 2 h5支付宝 3 app微信 4 h5微信 5 小程序 6 苹果支付 7 余额") + private Integer payType; + + @ApiModelProperty("支付宝支付返回的订单号") + @Excel(name = "支付宝支付返回的订单号") + private String aliBusinessId; + + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/bondrecord/service/BondRecordService.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/bondrecord/service/BondRecordService.java new file mode 100644 index 0000000..9140186 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/bondrecord/service/BondRecordService.java @@ -0,0 +1,95 @@ +package com.ruoyi.frequency.bondrecord.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.ruoyi.controller.req.BondPayReq; +import com.ruoyi.controller.req.BondRecordPageReq; +import com.ruoyi.frequency.bondrecord.entity.BondRecord; +import com.ruoyi.response.ResponseData; +import com.ruoyi.vo.UserVo; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.util.List; +import java.util.Map; + +/** + * 保证金记录Service接口 + * + * @author liwenlong + * @date 2023-10-18 + */ +public interface BondRecordService extends IService +{ + /** + * 查询保证金记录 + * + * @param id 保证金记录主键 + * @return 保证金记录 + */ + public BondRecord selectBondRecordById(Long id); + + /** + * 查询保证金记录列表 + * + * @param bondRecord 保证金记录 + * @return 保证金记录集合 + */ + public List selectBondRecordList(BondRecord bondRecord); + + /** + * 新增保证金记录 + * + * @param bondRecord 保证金记录 + * @return 结果 + */ + public int insertBondRecord(BondRecord bondRecord); + + /** + * 修改保证金记录 + * + * @param bondRecord 保证金记录 + * @return 结果 + */ + public int updateBondRecord(BondRecord bondRecord); + + /** + * 批量删除保证金记录 + * + * @param ids 需要删除的保证金记录主键集合 + * @return 结果 + */ + public int deleteBondRecordByIds(Long[] ids); + + /** + * 删除保证金记录信息 + * + * @param id 保证金记录主键 + * @return 结果 + */ + public int deleteBondRecordById(Long id); + + ResponseData bondPay(BondPayReq req, UserVo userVo); + + ResponseData bondRecordPage(BondRecordPageReq req, UserVo userVo); + + + /** + * 保证金支付宝回调 + * @param request + * @param response + * @return + */ + ResponseData bondAliNotify(HttpServletRequest request, HttpServletResponse response); + + /** + * 保证金微信回调 + * @param request + * @param response + * @return + */ + ResponseData bondWxNotify(HttpServletRequest request, HttpServletResponse response); + + ResponseData bondRecordDetail(Long id, UserVo userVo); + + ResponseData bondLakalaNotify(Map paramMap); +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/bondrecord/service/impl/BondRecordServiceImpl.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/bondrecord/service/impl/BondRecordServiceImpl.java new file mode 100644 index 0000000..2b6f74d --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/bondrecord/service/impl/BondRecordServiceImpl.java @@ -0,0 +1,365 @@ +package com.ruoyi.frequency.bondrecord.service.impl; + +import cn.hutool.core.date.DateUtil; +import cn.hutool.core.util.RandomUtil; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.ruoyi.code.PublicCommon; +import com.ruoyi.common.page.PageResult; +import com.ruoyi.common.utils.DateUtils; +import com.ruoyi.controller.req.BondPayReq; +import com.ruoyi.controller.req.BondRecordPageReq; +import com.ruoyi.enums.PlatformRecordEnums; +import com.ruoyi.enums.WalletDetailEnums; +import com.ruoyi.enums.user.UserEnums; +import com.ruoyi.frequency.bondamounrecord.service.BondAmountRecordService; +import com.ruoyi.frequency.bondrecord.entity.BondRecord; +import com.ruoyi.frequency.bondrecord.mapper.BondRecordMapper; +import com.ruoyi.frequency.bondrecord.service.BondRecordService; +import com.ruoyi.frequency.customer.service.UserService; +import com.ruoyi.frequency.onlinerecord.service.OnlineRecordService; +import com.ruoyi.frequency.platformrecord.service.PlatformRecordService; +import com.ruoyi.frequency.store.entity.Store; +import com.ruoyi.frequency.store.service.StoreService; +import com.ruoyi.pay.enums.PayEnums; +import com.ruoyi.pay.enums.PaySourceEnums; +import com.ruoyi.pay.utils.AlipayCore; +import com.ruoyi.pay.utils.HttpRequestUtil; +import com.ruoyi.pay.utils.PayUtil; +import com.ruoyi.response.ResponseData; +import com.ruoyi.utils.BusinessUtil; +import com.ruoyi.vo.UserVo; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.math.BigDecimal; +import java.util.Date; +import java.util.List; +import java.util.Map; + +/** + * 保证金记录Service业务层处理 + * + * @author liwenlong + * @date 2023-10-18 + */ +@Service +@Transactional(rollbackFor = Exception.class) +@Slf4j +public class BondRecordServiceImpl extends ServiceImpl implements BondRecordService +{ + @Autowired + private BondRecordMapper bondRecordMapper; + + /** + * 查询保证金记录 + * + * @param id 保证金记录主键 + * @return 保证金记录 + */ + @Override + public BondRecord selectBondRecordById(Long id) + { + return bondRecordMapper.selectBondRecordById(id); + } + + /** + * 查询保证金记录列表 + * + * @param bondRecord 保证金记录 + * @return 保证金记录 + */ + @Override + public List selectBondRecordList(BondRecord bondRecord) + { + return bondRecordMapper.selectBondRecordList(bondRecord); + } + + /** + * 新增保证金记录 + * + * @param bondRecord 保证金记录 + * @return 结果 + */ + @Override + public int insertBondRecord(BondRecord bondRecord) + { + return bondRecordMapper.insertBondRecord(bondRecord); + } + + /** + * 修改保证金记录 + * + * @param bondRecord 保证金记录 + * @return 结果 + */ + @Override + public int updateBondRecord(BondRecord bondRecord) + { + bondRecord.setUpdateTime(DateUtils.getNowDate()); + return bondRecordMapper.updateBondRecord(bondRecord); + } + + /** + * 批量删除保证金记录 + * + * @param ids 需要删除的保证金记录主键 + * @return 结果 + */ + @Override + public int deleteBondRecordByIds(Long[] ids) + { + this.lambdaUpdate().set(BondRecord::getDelFlag,PublicCommon.删除).in(BondRecord::getId,ids).update(); + return ids.length; + } + + /** + * 删除保证金记录信息 + * + * @param id 保证金记录主键 + * @return 结果 + */ + @Override + public int deleteBondRecordById(Long id) + { + this.lambdaUpdate().set(BondRecord::getDelFlag,PublicCommon.删除).eq(BondRecord::getId,id).update(); + return 1; + } + + @Autowired + private PayUtil payUtil; + + @Autowired + private StoreService storeService; + + @Autowired + private BusinessUtil businessUtil; + + @Autowired + private UserService userService; + + @Override + public ResponseData bondPay(BondPayReq req, UserVo userVo) { + + userService.storeByEnterprise(userVo); + + //余额支付 验证密码 + if (req.getPayType().equals(PayEnums.balance.getCode())) { + //判断余额支付 + businessUtil.judgeBalancePay(userVo, req.getAmount(),req.getPayPwd()); + } + + BondRecord bondRecord = new BondRecord(); + bondRecord.setPayType(req.getPayType()) + .setPayOrderNo(generateOrderNo()) + .setAmount(req.getAmount()) + .setUserId(userVo.getUserId()); + this.save(bondRecord); + + //支付 + ResponseData responseData = payUtil.pay(userVo, userVo.getUserId(), req.getPayType(), req.getAmount(), BigDecimal.ZERO, bondRecord.getPayOrderNo(), PaySourceEnums.bond_pay, WalletDetailEnums.BOND_PAY); + + //支付成功/支付金额为0 + if (responseData.getSuccess() || responseData.getCode().equals(210)) { + //余额支付/苹果支付 + if (req.getPayType().equals(PayEnums.balance.getCode()) || req.getPayType().equals(PayEnums.apple.getCode())) { + after(bondRecord); + } + } + + return responseData; + } + + @Autowired + private BondAmountRecordService bondAmountRecordService; + + @Autowired + private PlatformRecordService platformRecordService; + + /** + * 支付后操作 + * @param bondRecord + */ + private void after(BondRecord bondRecord) { + this.lambdaUpdate().set(BondRecord::getPayStatus,PublicCommon.Pay.已支付) + .eq(BondRecord::getId, bondRecord.getId()).update(); + + storeService.lambdaUpdate().set(Store::getIsBond,2) + .eq(Store::getId, bondRecord.getUserId()).update(); + + //修改用户保证金余额,添加保证金金额记录 + bondAmountRecordService.updateBond(new UserVo(UserEnums.store.getCode(),bondRecord.getUserId()),bondRecord.getId(), PublicCommon.BondWith.缴纳,null, bondRecord.getAmount(),PublicCommon.Wallet.可提现); + + //平台流水 + platformRecordService.addPlatformRecord(new UserVo(UserEnums.store.getCode(),bondRecord.getUserId()),bondRecord.getId(),bondRecord.getAmount(), PlatformRecordEnums.BOND_PAY); + } + + + /** + * 生成订单号 + * @return + */ + private String generateOrderNo() { + String orderNo; + String prefix = "BZJ"; + while (true) { + orderNo = prefix + DateUtil.format(new Date(), "MMdd" + RandomUtil.randomNumbers(6)); + BondRecord old = this.getBaseMapper().selectOne(new QueryWrapper().lambda() + .eq(BondRecord::getPayOrderNo, orderNo) + + ); + if (old == null) { + break; + } + } + return orderNo; + } + + + + @Override + public ResponseData bondRecordPage(BondRecordPageReq req, UserVo userVo) { + userService.storeByEnterprise(userVo); + Page page = bondRecordMapper.bondRecordPage(new Page<>(req.getPageNo(), req.getPageSize()),req,userVo); + return ResponseData.success(new PageResult<>(page)); + } + + @Override + public ResponseData bondAliNotify(HttpServletRequest request, HttpServletResponse response) { + log.info("******************************进入支付宝支付回调"); + //接收参数进行校验 + Map paramsMap = AlipayCore.updateMap(request); + //流水号 + String payId = paramsMap.get("out_trade_no"); + // 支付宝订单号 + String orderNo = paramsMap.get("trade_no"); + //付款状态 + String tradeStatus = paramsMap.get("trade_status"); + log.info("******************************payId=" + payId); + + BondRecord cur = baseMapper.selectOne(new QueryWrapper().lambda().eq(BondRecord::getPayOrderNo, payId)); + if (cur == null) { + log.error("支付信息丢失"); + return ResponseData.error("支付信息丢失"); + } + if (cur.getPayStatus() == 2) { + log.error("支付宝回调已经开始 回去吧"); + return ResponseData.error("支付宝回调已经开始 回去吧"); + } + if (cur.getPayStatus() == 3) { + //退款 + ResponseData responseData = payUtil.refund(new UserVo(UserEnums.store.getCode(),cur.getUserId()), cur.getId(), cur.getPayType(), cur.getAmount(), cur.getAmount(), cur.getPayOrderNo(), orderNo,BigDecimal.ZERO); + if (!responseData.getSuccess()) { + log.error("退款失败:" + cur.getPayOrderNo()); + } + return responseData; + } + if ("TRADE_SUCCESS".equalsIgnoreCase(tradeStatus)) { + + this.lambdaUpdate().set(BondRecord::getAliBusinessId, orderNo).eq(BondRecord::getId, cur.getId()).update(); + + after(cur);//支付后逻辑处理 + log.info("正常"); + return ResponseData.success(); + } else { + cur.setPayStatus(3); + baseMapper.updateById(cur); + log.error("支付失败"); + } + return ResponseData.error(""); + } + + @Override + public ResponseData bondWxNotify(HttpServletRequest request, HttpServletResponse response) { + Map requestMap = HttpRequestUtil.parseXml(request); + System.out.println("requestMap:" + requestMap.toString()); + // 微信中的订单号 + String transactionId = requestMap.get("transaction_id"); + // 用户唯一标识 + String openid = requestMap.get("openid"); + //流水号 + String payId = requestMap.get("out_trade_no"); + + BondRecord cur = baseMapper.selectOne(new QueryWrapper().lambda().eq(BondRecord::getPayOrderNo, payId)); + if (cur == null) { + log.error("支付信息丢失"); + return ResponseData.error("支付信息丢失"); + } + if (cur.getPayStatus() == 2) { + log.error("微信回调已经开始 回去吧"); + return ResponseData.error("支付宝回调已经开始 回去吧"); + } + if (cur.getPayStatus() == 3) { + //退款 + ResponseData responseData = payUtil.refund(new UserVo(UserEnums.store.getCode(),cur.getUserId()), cur.getId(), cur.getPayType(), cur.getAmount(), cur.getAmount(), cur.getPayOrderNo(), cur.getAliBusinessId(),BigDecimal.ZERO); + if (!responseData.getSuccess()) { + log.error("退款失败:" + cur.getPayOrderNo()); + } + return responseData; + } + + if ("SUCCESS".equals(requestMap.get("result_code"))) { + after(cur);//支付后逻辑处理 + log.info("正常"); + return ResponseData.success(); + } else { + cur.setPayStatus(3); + baseMapper.updateById(cur); + log.error("支付失败"); + } + + return ResponseData.error(""); + } + + @Override + public ResponseData bondLakalaNotify(Map requestMap) { + System.out.println("requestMap:" + requestMap.toString()); + //流水号 + String payId = requestMap.get("out_order_no"); + + BondRecord cur = baseMapper.selectOne(new QueryWrapper().lambda().eq(BondRecord::getPayOrderNo, payId)); + if (cur == null) { + log.error("支付信息丢失"); + return ResponseData.error("支付信息丢失"); + } + if (cur.getPayStatus() == 2) { + log.error("拉卡拉回调已经开始 回去吧"); + return ResponseData.error("拉卡拉回调已经开始 回去吧"); + } + + //order_status 聚合收银台订单状态 0:待支付 1:支付中 2:支付成功 3:支付失败 4:已过期 5:已取消 6:部分退款或者全部退款 + if (("2").equals(requestMap.get("order_status"))) { + after(cur);//支付后逻辑处理 + log.info("正常"); + + //设置成功标识 + businessUtil.setOutTradeNo(payId); + + //添加支付记录 + onlineRecordService.addOnlineRecord(new UserVo(UserEnums.customer.getCode(), cur.getUserId()), cur.getId(), cur.getAmount(), WalletDetailEnums.BOND_RECHARGE); + + return ResponseData.success(); + } else { + cur.setPayStatus(3); + baseMapper.updateById(cur); + log.error("支付失败"); + } + + return ResponseData.error(""); + } + + @Autowired + private OnlineRecordService onlineRecordService; + + @Override + public ResponseData bondRecordDetail(Long id, UserVo userVo) { + userService.storeByEnterprise(userVo); + BondRecord bondRecord = bondRecordMapper.bondRecordDetail(id,userVo); + return ResponseData.success(bondRecord); + } +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/bondwithdrawalrecord/controller/BondWithdrawalRecordController.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/bondwithdrawalrecord/controller/BondWithdrawalRecordController.java new file mode 100644 index 0000000..da190ec --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/bondwithdrawalrecord/controller/BondWithdrawalRecordController.java @@ -0,0 +1,121 @@ +package com.ruoyi.frequency.bondwithdrawalrecord.controller; + +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.page.TableDataInfo; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.common.utils.poi.ExcelUtil; +import com.ruoyi.frequency.bondwithdrawalrecord.entity.BondWithdrawalRecord; +import com.ruoyi.frequency.bondwithdrawalrecord.model.result.BondWithdrawalRecordCount; +import com.ruoyi.frequency.bondwithdrawalrecord.service.BondWithdrawalRecordService; +import com.ruoyi.frequency.withdrawalrecord.entity.WithdrawalRecord; +import com.ruoyi.frequency.withdrawalrecord.model.result.WithdrawalRecordCount; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +/** + * 保证金提现记录Controller + * + * @author liwenlong + * @date 2023-10-31 + */ +@RestController +@RequestMapping("/frequency/bondwithdrawalrecord") +public class BondWithdrawalRecordController extends BaseController +{ + @Autowired + private BondWithdrawalRecordService bondWithdrawalRecordService; + + /** + * 查询保证金提现记录列表 + */ + @PreAuthorize("@ss.hasPermi('frequency:bondwithdrawalrecord:list')") + @PostMapping("/list") + public TableDataInfo list(@RequestBody BondWithdrawalRecord bondWithdrawalRecord) + { + startPage(); + List list = bondWithdrawalRecordService.selectBondWithdrawalRecordList(bondWithdrawalRecord); + return getDataTable(list); + } + + /** + * 统计 + */ + @PostMapping("/statistics") + public AjaxResult statistics(@RequestBody BondWithdrawalRecord bondWithdrawalRecord) + { + BondWithdrawalRecordCount count = bondWithdrawalRecordService.statistics(bondWithdrawalRecord); + return AjaxResult.success(count); + } + + /** + * 导出保证金提现记录列表 + */ + @PreAuthorize("@ss.hasPermi('frequency:bondwithdrawalrecord:export')") + @Log(title = "保证金提现记录", businessType = BusinessType.EXPORT) + @GetMapping("/export") + public AjaxResult export(BondWithdrawalRecord bondWithdrawalRecord) + { + List list = bondWithdrawalRecordService.selectBondWithdrawalRecordList(bondWithdrawalRecord); + ExcelUtil util = new ExcelUtil(BondWithdrawalRecord.class); + return util.exportExcel(list, "保证金提现记录数据"); + } + + /** + * 获取保证金提现记录详细信息 + */ + @PreAuthorize("@ss.hasPermi('frequency:bondwithdrawalrecord:query')") + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") Long id) + { + return AjaxResult.success(bondWithdrawalRecordService.selectBondWithdrawalRecordById(id)); + } + + /** + * 新增保证金提现记录 + */ + @PreAuthorize("@ss.hasPermi('frequency:bondwithdrawalrecord:add')") + @Log(title = "保证金提现记录", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody BondWithdrawalRecord bondWithdrawalRecord) + { + return toAjax(bondWithdrawalRecordService.insertBondWithdrawalRecord(bondWithdrawalRecord)); + } + + /** + * 修改保证金提现记录 + */ + @PreAuthorize("@ss.hasPermi('frequency:bondwithdrawalrecord:edit')") + @Log(title = "保证金提现记录", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody BondWithdrawalRecord bondWithdrawalRecord) + { + return toAjax(bondWithdrawalRecordService.updateBondWithdrawalRecord(bondWithdrawalRecord)); + } + + /** + * 删除保证金提现记录 + */ + @PreAuthorize("@ss.hasPermi('frequency:bondwithdrawalrecord:remove')") + @Log(title = "保证金提现记录", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}/{delFlag}") + public AjaxResult remove(@PathVariable("ids") Long[] ids,@PathVariable("delFlag") Integer delFalg) + { + return toAjax(bondWithdrawalRecordService.deleteBondWithdrawalRecordByIds(ids,delFalg)); + } + + /** + * 提现审核 + */ + @PreAuthorize("@ss.hasPermi('frequency:bondwithdrawalrecord:process')") + @Log(title = "保证金提现记录", businessType = BusinessType.UPDATE) + @PostMapping("/process") + public AjaxResult process(@RequestBody BondWithdrawalRecord bondWithdrawalRecord) + { + return bondWithdrawalRecordService.process(bondWithdrawalRecord); + } +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/bondwithdrawalrecord/entity/BondWithdrawalRecord.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/bondwithdrawalrecord/entity/BondWithdrawalRecord.java new file mode 100644 index 0000000..429633f --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/bondwithdrawalrecord/entity/BondWithdrawalRecord.java @@ -0,0 +1,120 @@ +package com.ruoyi.frequency.bondwithdrawalrecord.entity; + +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableName; +import com.fasterxml.jackson.annotation.JsonFormat; +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import com.ruoyi.vo.UserInfo; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; + +import java.math.BigDecimal; +import java.util.Date; + +/** + * 保证金提现记录对象 t_bond_withdrawal_record + * + * @author liwenlong + * @date 2023-10-31 + */ +@Data +@Accessors(chain = true) +@TableName("t_bond_withdrawal_record") +public class BondWithdrawalRecord extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + + @ApiModelProperty("租户号") + private Long id; + + @ApiModelProperty("删除标识;1 正常 2 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("用户类型;") + @Excel(name = "用户类型;") + private Integer userType; + + @ApiModelProperty("用户id") + @Excel(name = "用户id") + private Long userId; + + @ApiModelProperty("转账金额") + @Excel(name = "转账金额") + private BigDecimal price; + + @ApiModelProperty("手续费") + @Excel(name = "手续费") + private BigDecimal serviceCharge; + + @ApiModelProperty("用户备注") + @Excel(name = "用户备注") + private String remarks; + + @ApiModelProperty("状态1审核中2审核通过3审核失败") + @Excel(name = "状态1审核中2审核通过3审核失败") + private Integer status; + + @ApiModelProperty("转账凭证") + @Excel(name = "转账凭证") + private String transferVoucher; + + @ApiModelProperty("失败原因") + @Excel(name = "失败原因") + private String refuseReason; + + @ApiModelProperty("提现方式ID") + @Excel(name = "提现方式ID") + private Long wiId; + + @ApiModelProperty("扣款") + @Excel(name = "扣款") + private BigDecimal violationDeduction; + + @ApiModelProperty("开户行") + private String bank; + + @ApiModelProperty("开户支行") + private String subbranch; + + @ApiModelProperty("银行卡") + private String bankCard; + + @ApiModelProperty("姓名") + private String fullName; + + @ApiModelProperty("银行卡Id") + private Long bankCardId; + + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @ApiModelProperty("审核时间") + private Date processTime; + + @ApiModelProperty("用户信息") + @TableField(exist = false) + private UserInfo userInfo; + + @ApiModelProperty("姓名") + @TableField(exist = false) + private String name; + + @ApiModelProperty("开始时间") + @TableField(exist = false) + private Date beginTime; + + @ApiModelProperty("结束时间") + @TableField(exist = false) + private Date endTime; + + + @ApiModelProperty("开始时间") + @TableField(exist = false) + private Date processBeginTime; + + @ApiModelProperty("结束时间") + @TableField(exist = false) + private Date processEndTime; + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/bondwithdrawalrecord/mapper/BondWithdrawalRecordMapper.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/bondwithdrawalrecord/mapper/BondWithdrawalRecordMapper.java new file mode 100644 index 0000000..08276d1 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/bondwithdrawalrecord/mapper/BondWithdrawalRecordMapper.java @@ -0,0 +1,58 @@ +package com.ruoyi.frequency.bondwithdrawalrecord.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.ruoyi.controller.resp.WithdrawalRecordPageResp; +import com.ruoyi.frequency.bondwithdrawalrecord.entity.BondWithdrawalRecord; +import com.ruoyi.frequency.bondwithdrawalrecord.model.result.BondWithdrawalRecordCount; +import com.ruoyi.vo.UserVo; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * 保证金提现记录Mapper接口 + * + * @author liwenlong + * @date 2023-10-31 + */ +public interface BondWithdrawalRecordMapper extends BaseMapper +{ + /** + * 查询保证金提现记录 + * + * @param id 保证金提现记录主键 + * @return 保证金提现记录 + */ + public BondWithdrawalRecord selectBondWithdrawalRecordById(Long id); + + /** + * 查询保证金提现记录列表 + * + * @param bondWithdrawalRecord 保证金提现记录 + * @return 保证金提现记录集合 + */ + public List selectBondWithdrawalRecordList(BondWithdrawalRecord bondWithdrawalRecord); + + /** + * 新增保证金提现记录 + * + * @param bondWithdrawalRecord 保证金提现记录 + * @return 结果 + */ + public int insertBondWithdrawalRecord(BondWithdrawalRecord bondWithdrawalRecord); + + /** + * 修改保证金提现记录 + * + * @param bondWithdrawalRecord 保证金提现记录 + * @return 结果 + */ + public int updateBondWithdrawalRecord(BondWithdrawalRecord bondWithdrawalRecord); + + Page withdrawalRecordPage(@Param("page") Page page,@Param("userVo") UserVo userVo); + + WithdrawalRecordPageResp getDetail(@Param("id") Long id); + + BondWithdrawalRecordCount statistics(@Param("list") List bondWithdrawalRecordIdList); +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/bondwithdrawalrecord/mapper/mapping/BondWithdrawalRecordMapper.xml b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/bondwithdrawalrecord/mapper/mapping/BondWithdrawalRecordMapper.xml new file mode 100644 index 0000000..d5ccaab --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/bondwithdrawalrecord/mapper/mapping/BondWithdrawalRecordMapper.xml @@ -0,0 +1,253 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + SELECT + t.id, + t.create_by, + t.create_time, + t.update_by, + t.update_time, + t.del_flag, + t.user_type, + t.user_id, + t.price, + t.service_charge, + t.remarks, + t.`status`, + t.transfer_voucher, + t.refuse_reason, + t.wi_id, + t.violation_deduction, + t.bank, + t.subbranch, + t.bank_card, + t.process_time, + case when h.id is not null then h.name else a.name end as name + FROM + t_bond_withdrawal_record AS t + LEFT JOIN t_store AS s ON s.id = t.user_id and t.user_type = 2 + LEFT JOIN t_highend_auth AS h ON t.user_id = h.store_id + AND t.user_type = 2 + AND h.`status` >= 3 + AND h.del_flag = 1 + LEFT JOIN t_auth AS a ON t.user_id = a.store_id + AND a.del_flag = 1 + AND t.user_type = 2 + + + + + + + + + + insert into t_bond_withdrawal_record + + id, + create_by, + create_time, + update_by, + update_time, + del_flag, + user_type, + user_id, + price, + service_charge, + remarks, + status, + transfer_voucher, + refuse_reason, + wi_id, + violation_deduction, + + + #{id}, + #{createBy}, + #{createTime}, + #{updateBy}, + #{updateTime}, + #{delFlag}, + #{userType}, + #{userId}, + #{price}, + #{serviceCharge}, + #{remarks}, + #{status}, + #{transferVoucher}, + #{refuseReason}, + #{wiId}, + #{violationDeduction}, + + + + + update t_bond_withdrawal_record + + create_by = #{createBy}, + create_time = #{createTime}, + update_by = #{updateBy}, + update_time = #{updateTime}, + del_flag = #{delFlag}, + user_type = #{userType}, + user_id = #{userId}, + price = #{price}, + service_charge = #{serviceCharge}, + remarks = #{remarks}, + status = #{status}, + transfer_voucher = #{transferVoucher}, + refuse_reason = #{refuseReason}, + wi_id = #{wiId}, + violation_deduction = #{violationDeduction}, + + where id = #{id} + + + + + + + + diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/bondwithdrawalrecord/model/param/BondWithdrawalRecordParam.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/bondwithdrawalrecord/model/param/BondWithdrawalRecordParam.java new file mode 100644 index 0000000..bb3e81f --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/bondwithdrawalrecord/model/param/BondWithdrawalRecordParam.java @@ -0,0 +1,82 @@ +package com.ruoyi.frequency.bondwithdrawalrecord.model.param; + +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; + +import java.math.BigDecimal; + +/** + * 保证金提现记录对象 t_bond_withdrawal_record + * + * @author liwenlong + * @date 2023-10-31 + */ +@Data +@Accessors(chain = true) +public class BondWithdrawalRecordParam extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + @ApiModelProperty("租户号") + private Long id; + + @ApiModelProperty("删除标识;1 正常 2 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("用户类型;") + @Excel(name = "用户类型;") + private Integer userType; + + @ApiModelProperty("用户id") + @Excel(name = "用户id") + private Long userId; + + @ApiModelProperty("转账金额") + @Excel(name = "转账金额") + private BigDecimal price; + + @ApiModelProperty("手续费") + @Excel(name = "手续费") + private BigDecimal serviceCharge; + + @ApiModelProperty("用户备注") + @Excel(name = "用户备注") + private String remarks; + + @ApiModelProperty("状态1审核中2审核通过3审核失败") + @Excel(name = "状态1审核中2审核通过3审核失败") + private Integer status; + + @ApiModelProperty("转账凭证") + @Excel(name = "转账凭证") + private String transferVoucher; + + @ApiModelProperty("失败原因") + @Excel(name = "失败原因") + private String refuseReason; + + @ApiModelProperty("提现方式ID") + @Excel(name = "提现方式ID") + private Long wiId; + + @ApiModelProperty("扣款") + @Excel(name = "扣款") + private BigDecimal violationDeduction; + + + + + + + + + + + + + + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/bondwithdrawalrecord/model/result/BondWithdrawalRecordCount.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/bondwithdrawalrecord/model/result/BondWithdrawalRecordCount.java new file mode 100644 index 0000000..b175c59 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/bondwithdrawalrecord/model/result/BondWithdrawalRecordCount.java @@ -0,0 +1,20 @@ +package com.ruoyi.frequency.bondwithdrawalrecord.model.result; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.math.BigDecimal; + +/** + * @author a + * @date 2024/2/22 10:46 + */ +@Data +public class BondWithdrawalRecordCount { + + @ApiModelProperty("提现记录数") + private Integer total; + + @ApiModelProperty("提现金额") + private BigDecimal amount; +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/bondwithdrawalrecord/model/result/BondWithdrawalRecordResult.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/bondwithdrawalrecord/model/result/BondWithdrawalRecordResult.java new file mode 100644 index 0000000..a70a48d --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/bondwithdrawalrecord/model/result/BondWithdrawalRecordResult.java @@ -0,0 +1,70 @@ +package com.ruoyi.frequency.bondwithdrawalrecord.model.result; + +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; + +import java.math.BigDecimal; + +/** + * 保证金提现记录对象 t_bond_withdrawal_record + * + * @author liwenlong + * @date 2023-10-31 + */ +@Data +@Accessors(chain = true) +public class BondWithdrawalRecordResult extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + @ApiModelProperty("租户号") + private Long id; + + @ApiModelProperty("删除标识;1 正常 2 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("用户类型;") + @Excel(name = "用户类型;") + private Integer userType; + + @ApiModelProperty("用户id") + @Excel(name = "用户id") + private Long userId; + + @ApiModelProperty("转账金额") + @Excel(name = "转账金额") + private BigDecimal price; + + @ApiModelProperty("手续费") + @Excel(name = "手续费") + private BigDecimal serviceCharge; + + @ApiModelProperty("用户备注") + @Excel(name = "用户备注") + private String remarks; + + @ApiModelProperty("状态1审核中2审核通过3审核失败") + @Excel(name = "状态1审核中2审核通过3审核失败") + private Integer status; + + @ApiModelProperty("转账凭证") + @Excel(name = "转账凭证") + private String transferVoucher; + + @ApiModelProperty("失败原因") + @Excel(name = "失败原因") + private String refuseReason; + + @ApiModelProperty("提现方式ID") + @Excel(name = "提现方式ID") + private Long wiId; + + @ApiModelProperty("扣款") + @Excel(name = "扣款") + private BigDecimal violationDeduction; + + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/bondwithdrawalrecord/service/BondWithdrawalRecordService.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/bondwithdrawalrecord/service/BondWithdrawalRecordService.java new file mode 100644 index 0000000..c956a9f --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/bondwithdrawalrecord/service/BondWithdrawalRecordService.java @@ -0,0 +1,76 @@ +package com.ruoyi.frequency.bondwithdrawalrecord.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.controller.req.WithApplyReq; +import com.ruoyi.frequency.bondwithdrawalrecord.entity.BondWithdrawalRecord; +import com.ruoyi.frequency.bondwithdrawalrecord.model.result.BondWithdrawalRecordCount; +import com.ruoyi.response.ResponseData; +import com.ruoyi.vo.PageBasic; +import com.ruoyi.vo.UserVo; + +import java.util.List; + +/** + * 保证金提现记录Service接口 + * + * @author liwenlong + * @date 2023-10-31 + */ +public interface BondWithdrawalRecordService extends IService +{ + /** + * 查询保证金提现记录 + * + * @param id 保证金提现记录主键 + * @return 保证金提现记录 + */ + public BondWithdrawalRecord selectBondWithdrawalRecordById(Long id); + + /** + * 查询保证金提现记录列表 + * + * @param bondWithdrawalRecord 保证金提现记录 + * @return 保证金提现记录集合 + */ + public List selectBondWithdrawalRecordList(BondWithdrawalRecord bondWithdrawalRecord); + + + BondWithdrawalRecordCount statistics(BondWithdrawalRecord bondWithdrawalRecord); + /** + * 新增保证金提现记录 + * + * @param bondWithdrawalRecord 保证金提现记录 + * @return 结果 + */ + public int insertBondWithdrawalRecord(BondWithdrawalRecord bondWithdrawalRecord); + + /** + * 修改保证金提现记录 + * + * @param bondWithdrawalRecord 保证金提现记录 + * @return 结果 + */ + public int updateBondWithdrawalRecord(BondWithdrawalRecord bondWithdrawalRecord); + + /** + * 批量删除保证金提现记录 + * + * @param ids 需要删除的保证金提现记录主键集合 + * @return 结果 + */ + public int deleteBondWithdrawalRecordByIds(Long[] ids,Integer delFalg); + + /** + * 保证金提现审核 + * @param bondWithdrawalRecord + * @return + */ + AjaxResult process(BondWithdrawalRecord bondWithdrawalRecord); + + ResponseData apply(WithApplyReq req, UserVo userVo); + + ResponseData withdrawalRecordPage(PageBasic req, UserVo userVo); + + ResponseData getDetail(Long id); +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/bondwithdrawalrecord/service/impl/BondWithdrawalRecordServiceImpl.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/bondwithdrawalrecord/service/impl/BondWithdrawalRecordServiceImpl.java new file mode 100644 index 0000000..cf47c58 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/bondwithdrawalrecord/service/impl/BondWithdrawalRecordServiceImpl.java @@ -0,0 +1,282 @@ +package com.ruoyi.frequency.bondwithdrawalrecord.service.impl; + +import cn.hutool.core.collection.CollectionUtil; +import cn.hutool.core.util.ObjectUtil; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.ruoyi.code.PublicCommon; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.exception.CustomException; +import com.ruoyi.common.exception.enums.CoreExceptionEnum; +import com.ruoyi.common.page.PageResult; +import com.ruoyi.common.utils.DateUtils; +import com.ruoyi.controller.req.WithApplyReq; +import com.ruoyi.controller.resp.WithdrawalRecordPageResp; +import com.ruoyi.enums.PlatformRecordEnums; +import com.ruoyi.enums.WalletDetailEnums; +import com.ruoyi.enums.message.AppMessageEnums; +import com.ruoyi.enums.process.ProcessResultEnums; +import com.ruoyi.frequency.appmessage.service.AppMessageService; +import com.ruoyi.frequency.bondamounrecord.service.BondAmountRecordService; +import com.ruoyi.frequency.bondwithdrawalrecord.entity.BondWithdrawalRecord; +import com.ruoyi.frequency.bondwithdrawalrecord.mapper.BondWithdrawalRecordMapper; +import com.ruoyi.frequency.bondwithdrawalrecord.model.result.BondWithdrawalRecordCount; +import com.ruoyi.frequency.bondwithdrawalrecord.service.BondWithdrawalRecordService; +import com.ruoyi.frequency.customer.service.UserService; +import com.ruoyi.frequency.platformrecord.service.PlatformRecordService; +import com.ruoyi.frequency.store.service.StoreService; +import com.ruoyi.frequency.wallerecord.service.WalletRecordService; +import com.ruoyi.response.ResponseData; +import com.ruoyi.utils.BusinessUtil; +import com.ruoyi.vo.PageBasic; +import com.ruoyi.vo.UserInfo; +import com.ruoyi.vo.UserVo; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.math.BigDecimal; +import java.util.Date; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.stream.Collectors; + +/** + * 保证金提现记录Service业务层处理 + * + * @author liwenlong + * @date 2023-10-31 + */ +@Service +public class BondWithdrawalRecordServiceImpl extends ServiceImpl implements BondWithdrawalRecordService { + @Autowired + private BondWithdrawalRecordMapper bondWithdrawalRecordMapper; + + @Autowired + private UserService userService; + + /** + * 查询保证金提现记录 + * + * @param id 保证金提现记录主键 + * @return 保证金提现记录 + */ + @Override + public BondWithdrawalRecord selectBondWithdrawalRecordById(Long id) { + + BondWithdrawalRecord bondWithdrawalRecord = bondWithdrawalRecordMapper.selectBondWithdrawalRecordById(id); + + if (bondWithdrawalRecord != null) { + Set userVoSet = CollectionUtil.newHashSet(new UserVo(bondWithdrawalRecord.getUserType(), bondWithdrawalRecord.getUserId())); + + //查询用户信息 + Map userMap = userService.selectUserInfoMap(userVoSet, null); + + bondWithdrawalRecord.setUserInfo(userMap.get(new UserVo(bondWithdrawalRecord.getUserType(), bondWithdrawalRecord.getUserId()))); + } + + return bondWithdrawalRecord; + } + + /** + * 查询保证金提现记录列表 + * + * @param bondWithdrawalRecord 保证金提现记录 + * @return 保证金提现记录 + */ + @Override + public List selectBondWithdrawalRecordList(BondWithdrawalRecord bondWithdrawalRecord) { + + List bondWithdrawalRecords = bondWithdrawalRecordList(bondWithdrawalRecord); + + if (bondWithdrawalRecords != null && bondWithdrawalRecords.size() > 0) { + + Set userVoSet = bondWithdrawalRecords.stream().map(s -> new UserVo(s.getUserType(), s.getUserId())).collect(Collectors.toSet()); + + //查询用户信息 + Map userMap = userService.selectUserInfoMap(userVoSet, null); + + bondWithdrawalRecords.stream().forEach(s -> { + s.setUserInfo(userMap.get(new UserVo(s.getUserType(), s.getUserId()))); + }); + } + return bondWithdrawalRecords; + } + + private List bondWithdrawalRecordList(BondWithdrawalRecord bondWithdrawalRecord){ + List bondWithdrawalRecords = bondWithdrawalRecordMapper.selectBondWithdrawalRecordList(bondWithdrawalRecord); + return bondWithdrawalRecords; + } + + @Override + public BondWithdrawalRecordCount statistics(BondWithdrawalRecord bondWithdrawalRecord) { + List bondWithdrawalRecords = bondWithdrawalRecordList(bondWithdrawalRecord); + List bondWithdrawalRecordIdList = bondWithdrawalRecords.stream().map(x -> x.getId()).collect(Collectors.toList()); + bondWithdrawalRecordIdList.add(-1L); + + return bondWithdrawalRecordMapper.statistics(bondWithdrawalRecordIdList); + } + + /** + * 新增保证金提现记录 + * + * @param bondWithdrawalRecord 保证金提现记录 + * @return 结果 + */ + @Override + public int insertBondWithdrawalRecord(BondWithdrawalRecord bondWithdrawalRecord) { + bondWithdrawalRecord.setCreateTime(DateUtils.getNowDate()); + return bondWithdrawalRecordMapper.insert(bondWithdrawalRecord); + } + + /** + * 修改保证金提现记录 + * + * @param bondWithdrawalRecord 保证金提现记录 + * @return 结果 + */ + @Override + public int updateBondWithdrawalRecord(BondWithdrawalRecord bondWithdrawalRecord) { + bondWithdrawalRecord.setUpdateTime(DateUtils.getNowDate()); + return bondWithdrawalRecordMapper.updateById(bondWithdrawalRecord); + } + + /** + * 批量删除保证金提现记录 + * + * @param ids 需要删除的保证金提现记录主键 + * @return 结果 + */ + @Override + public int deleteBondWithdrawalRecordByIds(Long[] ids, Integer delFalg) { + this.lambdaUpdate().set(BondWithdrawalRecord::getDelFlag, delFalg).in(BondWithdrawalRecord::getId, ids).update(); + return ids.length; + } + + @Autowired + private WalletRecordService walletRecordService; + + @Override + public AjaxResult process(BondWithdrawalRecord bondWithdrawalRecord) { + this.lambdaUpdate().set(BondWithdrawalRecord::getStatus, bondWithdrawalRecord.getStatus()) + .set(BondWithdrawalRecord::getRefuseReason, bondWithdrawalRecord.getRefuseReason()) + .set(BondWithdrawalRecord::getTransferVoucher, bondWithdrawalRecord.getTransferVoucher()) + .set(BondWithdrawalRecord::getProcessTime, new Date()) + .eq(BondWithdrawalRecord::getId, bondWithdrawalRecord.getId()) + .update(); + + BondWithdrawalRecord byId = this.getById(bondWithdrawalRecord.getId()); + //审核失败 提现返还 + if (ObjectUtil.equal(ProcessResultEnums.REJECTED.getCode(), bondWithdrawalRecord.getStatus())) { + + //修改用户保证金余额,添加保证金金额记录 + bondAmountRecordService.updateBond(new UserVo(byId.getUserType(), byId.getUserId()), bondWithdrawalRecord.getId(), PublicCommon.BondWith.提现返还, bondWithdrawalRecord.getId(), byId.getPrice(), PublicCommon.Wallet.可提现); + + //平台流水 + platformRecordService.addPlatformRecord(new UserVo(byId.getUserType(), byId.getUserId()), bondWithdrawalRecord.getId(), byId.getPrice(), PlatformRecordEnums.BOND_WITHDRAWAL_RETURN); + + } else if (ObjectUtil.equal(ProcessResultEnums.APPROVED.getCode(), bondWithdrawalRecord.getStatus())) { + if (ObjectUtil.isEmpty(byId.getBankCardId())) { + walletRecordService.updateBalance(new UserVo(byId.getUserType(), byId.getUserId()), WalletDetailEnums.BOND_WITHDRAWAL, byId.getId(), byId.getPrice(), PublicCommon.Wallet.可提现); + } + } + + //提现结果提醒 + if (ObjectUtil.equal(ProcessResultEnums.APPROVED.getCode(), bondWithdrawalRecord.getStatus())) { + //审核失败 提现返还 + appMessageService.addAppMessage(new UserVo(byId.getUserType(), byId.getUserId()), byId.getId(), AppMessageEnums.BOND_WITHDRAWAL_SUCCESS); + + } else { + //审核失败 提现返还 + appMessageService.addAppMessage(new UserVo(byId.getUserType(), byId.getUserId()), byId.getId(), AppMessageEnums.BOND_WITHDRAWAL_FAIL); + } + return AjaxResult.success(); + } + + + @Autowired + private AppMessageService appMessageService; + + @Autowired + private BusinessUtil businessUtil; + + @Autowired + private BondAmountRecordService bondAmountRecordService; + + @Autowired + private StoreService storeService; + + @Autowired + private PlatformRecordService platformRecordService; + + @Override + public ResponseData apply(WithApplyReq req, UserVo userVo) { + //判断支付密码 + if (!businessUtil.payPwdTrue(userVo, req.getPayPwd())) { + return ResponseData.error(CoreExceptionEnum.PWD_ERROR); + } + + //可提现用户保证金余额 + BigDecimal balance = storeService.getById(userVo.getUserId()).getBondAmount(); + + //判断余额 + if (balance.compareTo(req.getAmount()) == -1) { + throw new CustomException(CoreExceptionEnum.BALANCE_INSUFFICIENT); + } + + //提现记录 + Long withDrawlRecordId = createWithDrawlRecord(userVo, req); + + //修改用户保证金余额,添加保证金金额记录 + bondAmountRecordService.updateBond(userVo, withDrawlRecordId, PublicCommon.BondWith.提现, withDrawlRecordId, req.getAmount().negate(), PublicCommon.Wallet.可提现); + + //平台流水 + platformRecordService.addPlatformRecord(userVo, withDrawlRecordId, req.getAmount().negate(), PlatformRecordEnums.BOND_WITHDRAWAL); + + return ResponseData.success(); + } + + + /** + * 提现记录 + * + * @param userVo + * @param req + * @return + */ + private Long createWithDrawlRecord(UserVo userVo, WithApplyReq req) { + + //提现记录 + BondWithdrawalRecord withdrawalRecord = new BondWithdrawalRecord() + .setUserId(userVo.getUserId()) + .setUserType(userVo.getUserType()) + .setPrice(req.getAmount()) + .setServiceCharge(BigDecimal.ZERO) + .setDelFlag(PublicCommon.启用) + .setRemarks(req.getRemark()) + .setBank(req.getBank()) + .setSubbranch(req.getSubbranch()) + .setBankCard(req.getBankCard()) + .setBankCardId(req.getBankCardId()) + .setFullName(req.getFullName()) + .setStatus(ProcessResultEnums.PENDING.getCode()); + this.save(withdrawalRecord); + + return withdrawalRecord.getId(); + } + + @Override + public ResponseData withdrawalRecordPage(PageBasic req, UserVo userVo) { + userService.storeByEnterprise(userVo); + Page page = baseMapper.withdrawalRecordPage(new Page(req.getPageNo(), req.getPageSize()), userVo); + return ResponseData.success(new PageResult<>(page)); + } + + @Override + public ResponseData getDetail(Long id) { + + WithdrawalRecordPageResp detail = baseMapper.getDetail(id); + + return ResponseData.success(detail); + } +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/browserecord/controller/BrowseRecordController.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/browserecord/controller/BrowseRecordController.java new file mode 100644 index 0000000..77f676d --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/browserecord/controller/BrowseRecordController.java @@ -0,0 +1,103 @@ +package com.ruoyi.frequency.browserecord.controller; + +import java.util.List; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.frequency.browserecord.entity.BrowseRecord; +import com.ruoyi.frequency.browserecord.service.BrowseRecordService; +import com.ruoyi.common.utils.poi.ExcelUtil; +import com.ruoyi.common.core.page.TableDataInfo; + +/** + * 浏览记录Controller + * + * @author liwenlong + * @date 2023-11-25 + */ +@RestController +@RequestMapping("/frequency/browserecord") +public class BrowseRecordController extends BaseController +{ + @Autowired + private BrowseRecordService browseRecordService; + + /** + * 查询浏览记录列表 + */ + @PreAuthorize("@ss.hasPermi('frequency:browserecord:list')") + @PostMapping("/list") + public TableDataInfo list(@RequestBody BrowseRecord browseRecord) + { + startPage(); + List list = browseRecordService.selectBrowseRecordList(browseRecord); + return getDataTable(list); + } + + /** + * 导出浏览记录列表 + */ + @PreAuthorize("@ss.hasPermi('frequency:browserecord:export')") + @Log(title = "浏览记录", businessType = BusinessType.EXPORT) + @GetMapping("/export") + public AjaxResult export(BrowseRecord browseRecord) + { + List list = browseRecordService.selectBrowseRecordList(browseRecord); + ExcelUtil util = new ExcelUtil(BrowseRecord.class); + return util.exportExcel(list, "浏览记录数据"); + } + + /** + * 获取浏览记录详细信息 + */ + @PreAuthorize("@ss.hasPermi('frequency:browserecord:query')") + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") Long id) + { + return AjaxResult.success(browseRecordService.selectBrowseRecordById(id)); + } + + /** + * 新增浏览记录 + */ + @PreAuthorize("@ss.hasPermi('frequency:browserecord:add')") + @Log(title = "浏览记录", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody BrowseRecord browseRecord) + { + return toAjax(browseRecordService.insertBrowseRecord(browseRecord)); + } + + /** + * 修改浏览记录 + */ + @PreAuthorize("@ss.hasPermi('frequency:browserecord:edit')") + @Log(title = "浏览记录", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody BrowseRecord browseRecord) + { + return toAjax(browseRecordService.updateBrowseRecord(browseRecord)); + } + + /** + * 删除浏览记录 + */ + @PreAuthorize("@ss.hasPermi('frequency:browserecord:remove')") + @Log(title = "浏览记录", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}/{delFlag}") + public AjaxResult remove(@PathVariable("ids") Long[] ids,@PathVariable("delFlag") Integer delFlag) + { + return toAjax(browseRecordService.deleteBrowseRecordByIds(ids,delFlag)); + } +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/browserecord/entity/BrowseRecord.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/browserecord/entity/BrowseRecord.java new file mode 100644 index 0000000..bd3ef7e --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/browserecord/entity/BrowseRecord.java @@ -0,0 +1,53 @@ +package com.ruoyi.frequency.browserecord.entity; + +import lombok.Data; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.experimental.Accessors; +import com.ruoyi.common.annotation.Excel; +import io.swagger.annotations.ApiModelProperty; +import com.baomidou.mybatisplus.annotation.TableField; +import com.ruoyi.vo.UserInfo; +import com.ruoyi.common.core.domain.BaseEntity; + +/** + * 浏览记录对象 t_browse_record + * + * @author liwenlong + * @date 2023-11-25 + */ +@Data +@Accessors(chain = true) +@TableName("t_browse_record") +public class BrowseRecord extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + + @ApiModelProperty("租户号") + private Long id; + + @ApiModelProperty("删除标志;1 正常 2 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("类型 1作品 2 帖子 3投票") + @Excel(name = "类型 1作品 2 帖子 3投票") + private Integer type; + + @ApiModelProperty("作品 /帖子id") + @Excel(name = "作品 /帖子id") + private Long objectId; + + @ApiModelProperty("设计师和表现师的id") + @Excel(name = "设计师和表现师的id") + private Long userId; + + @ApiModelProperty("用户类型") + @Excel(name = "用户类型") + private Integer userType; + + @ApiModelProperty("用户信息") + @TableField(exist = false) + private UserInfo userInfo; + + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/browserecord/mapper/BrowseRecordMapper.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/browserecord/mapper/BrowseRecordMapper.java new file mode 100644 index 0000000..21ca9d3 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/browserecord/mapper/BrowseRecordMapper.java @@ -0,0 +1,56 @@ +package com.ruoyi.frequency.browserecord.mapper; + +import java.util.List; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.ruoyi.controller.req.CollectPageReq; +import com.ruoyi.controller.resp.WorksPageResp; +import com.ruoyi.frequency.browserecord.entity.BrowseRecord; +import com.ruoyi.post.controller.resp.PostPageResp; +import com.ruoyi.vo.UserVo; +import org.apache.ibatis.annotations.Param; + +/** + * 浏览记录Mapper接口 + * + * @author liwenlong + * @date 2023-11-25 + */ +public interface BrowseRecordMapper extends BaseMapper +{ + /** + * 查询浏览记录 + * + * @param id 浏览记录主键 + * @return 浏览记录 + */ + public BrowseRecord selectBrowseRecordById(Long id); + + /** + * 查询浏览记录列表 + * + * @param browseRecord 浏览记录 + * @return 浏览记录集合 + */ + public List selectBrowseRecordList(BrowseRecord browseRecord); + + /** + * 新增浏览记录 + * + * @param browseRecord 浏览记录 + * @return 结果 + */ + public int insertBrowseRecord(BrowseRecord browseRecord); + + /** + * 修改浏览记录 + * + * @param browseRecord 浏览记录 + * @return 结果 + */ + public int updateBrowseRecord(BrowseRecord browseRecord); + + Page worksBrowsePage(@Param("page") Page objectPage, @Param("req") CollectPageReq req,@Param("userVo") UserVo userVo); + + Page postBrowsePage(@Param("page") Page objectPage, @Param("req") CollectPageReq req, @Param("userVo") UserVo userVo); +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/browserecord/mapper/mapping/BrowseRecordMapper.xml b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/browserecord/mapper/mapping/BrowseRecordMapper.xml new file mode 100644 index 0000000..e76406b --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/browserecord/mapper/mapping/BrowseRecordMapper.xml @@ -0,0 +1,196 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + select + t.id , + t.create_by , + t.create_time , + t.update_by , + t.update_time , + t.del_flag , + t.type , + t.object_id , + t.user_id , + t.user_type , + u.user_type, + u.id_no, + u.mobile, + u.avatar, + u.nickname + from t_browse_record AS t + LEFT JOIN t_user AS u ON t.user_id = u.id + + + + + + + + insert into t_browse_record + + id, + create_by, + create_time, + update_by, + update_time, + del_flag, + type, + object_id, + user_id, + user_type, + + + #{id}, + #{createBy}, + #{createTime}, + #{updateBy}, + #{updateTime}, + #{delFlag}, + #{type}, + #{objectId}, + #{userId}, + #{userType}, + + + + + update t_browse_record + + create_by = #{createBy}, + create_time = #{createTime}, + update_by = #{updateBy}, + update_time = #{updateTime}, + del_flag = #{delFlag}, + type = #{type}, + object_id = #{objectId}, + user_id = #{userId}, + user_type = #{userType}, + + where id = #{id} + + + + + + + \ No newline at end of file diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/browserecord/model/param/BrowseRecordParam.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/browserecord/model/param/BrowseRecordParam.java new file mode 100644 index 0000000..6c9c034 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/browserecord/model/param/BrowseRecordParam.java @@ -0,0 +1,50 @@ +package com.ruoyi.frequency.browserecord.model.param; + +import lombok.Data; +import lombok.experimental.Accessors; +import com.ruoyi.common.annotation.Excel; +import io.swagger.annotations.ApiModelProperty; +import com.ruoyi.common.core.domain.BaseEntity; + +/** + * 浏览记录对象 t_browse_record + * + * @author liwenlong + * @date 2023-11-25 + */ +@Data +@Accessors(chain = true) +public class BrowseRecordParam extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + @ApiModelProperty("租户号") + private Long id; + + @ApiModelProperty("删除标志;1 正常 2 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("类型 1作品 2 帖子") + @Excel(name = "类型 1作品 2 帖子") + private Integer type; + + @ApiModelProperty("作品 /帖子id") + @Excel(name = "作品 /帖子id") + private Long objectId; + + @ApiModelProperty("设计师和表现师的id") + @Excel(name = "设计师和表现师的id") + private Long userId; + + @ApiModelProperty("用户类型") + @Excel(name = "用户类型") + private Integer userType; + + + + + + + + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/browserecord/model/result/BrowseRecordResult.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/browserecord/model/result/BrowseRecordResult.java new file mode 100644 index 0000000..39283a0 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/browserecord/model/result/BrowseRecordResult.java @@ -0,0 +1,44 @@ +package com.ruoyi.frequency.browserecord.model.result; + +import lombok.Data; +import lombok.experimental.Accessors; +import com.ruoyi.common.annotation.Excel; +import io.swagger.annotations.ApiModelProperty; +import com.ruoyi.common.core.domain.BaseEntity; + +/** + * 浏览记录对象 t_browse_record + * + * @author liwenlong + * @date 2023-11-25 + */ +@Data +@Accessors(chain = true) +public class BrowseRecordResult extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + @ApiModelProperty("租户号") + private Long id; + + @ApiModelProperty("删除标志;1 正常 2 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("类型 1作品 2 帖子") + @Excel(name = "类型 1作品 2 帖子") + private Integer type; + + @ApiModelProperty("作品 /帖子id") + @Excel(name = "作品 /帖子id") + private Long objectId; + + @ApiModelProperty("设计师和表现师的id") + @Excel(name = "设计师和表现师的id") + private Long userId; + + @ApiModelProperty("用户类型") + @Excel(name = "用户类型") + private Integer userType; + + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/browserecord/service/BrowseRecordService.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/browserecord/service/BrowseRecordService.java new file mode 100644 index 0000000..8531e48 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/browserecord/service/BrowseRecordService.java @@ -0,0 +1,62 @@ +package com.ruoyi.frequency.browserecord.service; + +import java.util.List; + +import com.ruoyi.controller.req.CollectPageReq; +import com.ruoyi.frequency.browserecord.entity.BrowseRecord; +import com.baomidou.mybatisplus.extension.service.IService; +import com.ruoyi.response.ResponseData; +import com.ruoyi.vo.UserVo; + +/** + * 浏览记录Service接口 + * + * @author liwenlong + * @date 2023-11-25 + */ +public interface BrowseRecordService extends IService +{ + /** + * 查询浏览记录 + * + * @param id 浏览记录主键 + * @return 浏览记录 + */ + public BrowseRecord selectBrowseRecordById(Long id); + + /** + * 查询浏览记录列表 + * + * @param browseRecord 浏览记录 + * @return 浏览记录集合 + */ + public List selectBrowseRecordList(BrowseRecord browseRecord); + + /** + * 新增浏览记录 + * + * @param browseRecord 浏览记录 + * @return 结果 + */ + public int insertBrowseRecord(BrowseRecord browseRecord); + + /** + * 修改浏览记录 + * + * @param browseRecord 浏览记录 + * @return 结果 + */ + public int updateBrowseRecord(BrowseRecord browseRecord); + + /** + * 批量删除浏览记录 + * + * @param ids 需要删除的浏览记录主键集合 + * @return 结果 + */ + public int deleteBrowseRecordByIds(Long[] ids,Integer delFlag); + + ResponseData browsePage(CollectPageReq req, UserVo userVo); + + ResponseData otherBrowsePage(CollectPageReq req, UserVo userVo); +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/browserecord/service/impl/BrowseRecordServiceImpl.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/browserecord/service/impl/BrowseRecordServiceImpl.java new file mode 100644 index 0000000..002c89a --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/browserecord/service/impl/BrowseRecordServiceImpl.java @@ -0,0 +1,242 @@ +package com.ruoyi.frequency.browserecord.service.impl; + +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.stream.Collectors; + +import cn.hutool.core.util.ObjectUtil; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.ruoyi.common.page.PageResult; +import com.ruoyi.common.utils.DateUtils; +import com.ruoyi.controller.req.CollectPageReq; +import com.ruoyi.controller.resp.WorksPageResp; +import com.ruoyi.frequency.customer.service.UserService; +import com.ruoyi.frequency.workspanorama.entity.WorksPanorama; +import com.ruoyi.frequency.workspanorama.service.WorksPanoramaService; +import com.ruoyi.frequency.workstype.service.WorksTypeService; +import com.ruoyi.post.controller.resp.PostPageResp; +import com.ruoyi.post.controller.vo.SelectedComment; +import com.ruoyi.post.frequency.postcomment.service.PostCommentService; +import com.ruoyi.response.ResponseData; +import com.ruoyi.vo.UserInfo; +import com.ruoyi.vo.UserVo; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.ruoyi.code.PublicCommon; +import com.ruoyi.frequency.browserecord.mapper.BrowseRecordMapper; +import com.ruoyi.frequency.browserecord.entity.BrowseRecord; +import com.ruoyi.frequency.browserecord.service.BrowseRecordService; + +/** + * 浏览记录Service业务层处理 + * + * @author liwenlong + * @date 2023-11-25 + */ +@Service +public class BrowseRecordServiceImpl extends ServiceImpl implements BrowseRecordService +{ + @Autowired + private BrowseRecordMapper browseRecordMapper; + + /** + * 查询浏览记录 + * + * @param id 浏览记录主键 + * @return 浏览记录 + */ + @Override + public BrowseRecord selectBrowseRecordById(Long id) + { + return browseRecordMapper.selectBrowseRecordById(id); + } + + /** + * 查询浏览记录列表 + * + * @param browseRecord 浏览记录 + * @return 浏览记录 + */ + @Override + public List selectBrowseRecordList(BrowseRecord browseRecord) + { + return browseRecordMapper.selectBrowseRecordList(browseRecord); + } + + /** + * 新增浏览记录 + * + * @param browseRecord 浏览记录 + * @return 结果 + */ + @Override + public int insertBrowseRecord(BrowseRecord browseRecord) + { + browseRecord.setCreateData(); + return browseRecordMapper.insert(browseRecord); + } + + /** + * 修改浏览记录 + * + * @param browseRecord 浏览记录 + * @return 结果 + */ + @Override + public int updateBrowseRecord(BrowseRecord browseRecord) + { + browseRecord.setUpdateData(); + return browseRecordMapper.updateBrowseRecord(browseRecord); + } + + /** + * 批量删除浏览记录 + * + * @param ids 需要删除的浏览记录主键 + * @return 结果 + */ + @Override + public int deleteBrowseRecordByIds(Long[] ids,Integer delFlag) + { + this.lambdaUpdate().set(BrowseRecord::getDelFlag,delFlag).in(BrowseRecord::getId,ids).update(); + return ids.length; + } + + @Autowired + private WorksTypeService worksTypeService; + + @Autowired + private PostCommentService postCommentService; + + @Autowired + private UserService userService; + + @Autowired + private WorksPanoramaService worksPanoramaService; + + @Override + public ResponseData browsePage(CollectPageReq req, UserVo userVo) { + //收藏类型 1作品 2 动态 + switch (req.getType()){ + case 1: + if (ObjectUtil.isNotEmpty(req.getTypeId())){ + //根据类型id获取三级id + List typeIdList = worksTypeService.getIdsByTypeId(req.getTypeId()); + if (typeIdList.isEmpty()){ + return ResponseData.success(new PageResult<>(new Page<>(req.getPageNo(),req.getPageSize()))); + } + req.setTypeIds(typeIdList); + } + + Page worksPage = baseMapper.worksBrowsePage(new Page<>(req.getPageNo(),req.getPageSize()),req,userVo); + if (!worksPage.getRecords().isEmpty()){ + + Set userVoSet = worksPage.getRecords().stream().map(worksPageResp -> new UserVo(worksPageResp.getUserType(), worksPageResp.getStoreId())).collect(Collectors.toSet()); + //查询用户信息 + Map userMap = userService.selectUserInfoMap(userVoSet,userVo); + + //作品ids + List worksIds = worksPage.getRecords().stream().map(WorksPageResp::getId).collect(Collectors.toList()); + //查询3D图 + List worksPanoramaList = worksPanoramaService.list(new QueryWrapper().lambda().in(WorksPanorama::getWorksId, worksIds).orderByDesc(WorksPanorama::getCreateTime)); + + Map> map = worksPanoramaList.stream().collect(Collectors.groupingBy(WorksPanorama::getWorksId)); + + worksPage.getRecords().stream().forEach(worksPageResp ->{ + worksPageResp.setUserInfo(userMap.get(new UserVo(worksPageResp.getUserType(), worksPageResp.getStoreId()))); + worksPageResp.setWorksPanoramaList(map.get(worksPageResp.getId())); + }); + } + + return ResponseData.success(new PageResult<>(worksPage)); + case 2: + Page postPage = baseMapper.postBrowsePage(new Page<>(req.getPageNo(), req.getPageSize()),req,userVo); + + if (!postPage.getRecords().isEmpty()){ + Set userVoSet = postPage.getRecords().stream().map(postPageResp -> new UserVo(postPageResp.getUserType(), postPageResp.getUserId())).collect(Collectors.toSet()); + //查询用户信息 + Map userMap = userService.selectUserInfoMap(userVoSet,userVo); + + //精彩评论ids + List commentIds = postPage.getRecords().stream().filter(s-> ObjectUtil.isNotEmpty(s.getCommentId())).map(PostPageResp::getCommentId).collect(Collectors.toList()); + + //查询精选评论 + Map selectedCommentMap = postCommentService.getSelectedCommentMap(commentIds,userVo); + + postPage.getRecords().stream().forEach(videoPageResp ->{ + videoPageResp.setUserInfo(userMap.get(new UserVo(videoPageResp.getUserType(), videoPageResp.getUserId()))); + videoPageResp.setSelectedComment(selectedCommentMap.get(videoPageResp.getId())); + }); + } + + return ResponseData.success(new PageResult<>(postPage)); + default: + throw new IllegalStateException("Unexpected value: " + req.getType()); + } + } + + @Override + public ResponseData otherBrowsePage(CollectPageReq req, UserVo userVo) { + //收藏类型 1作品 2 动态 + switch (req.getType()){ + case 1: + if (ObjectUtil.isNotEmpty(req.getTypeId())){ + //根据类型id获取三级id + List typeIdList = worksTypeService.getIdsByTypeId(req.getTypeId()); + if (typeIdList.isEmpty()){ + return ResponseData.success(new PageResult<>(new Page<>(req.getPageNo(),req.getPageSize()))); + } + req.setTypeIds(typeIdList); + } + + Page worksPage = baseMapper.worksBrowsePage(new Page<>(req.getPageNo(),req.getPageSize()),req,userVo); + + if (!worksPage.getRecords().isEmpty()){ + + Set userVoSet = worksPage.getRecords().stream().map(worksPageResp -> new UserVo(worksPageResp.getUserType(), worksPageResp.getStoreId())).collect(Collectors.toSet()); + //查询用户信息 + Map userMap = userService.selectUserInfoMap(userVoSet,userVo); + + //作品ids + List worksIds = worksPage.getRecords().stream().map(WorksPageResp::getId).collect(Collectors.toList()); + //查询3D图 + List worksPanoramaList = worksPanoramaService.list(new QueryWrapper().lambda().in(WorksPanorama::getWorksId, worksIds).orderByDesc(WorksPanorama::getCreateTime)); + + Map> map = worksPanoramaList.stream().collect(Collectors.groupingBy(WorksPanorama::getWorksId)); + + worksPage.getRecords().stream().forEach(worksPageResp ->{ + worksPageResp.setUserInfo(userMap.get(new UserVo(worksPageResp.getUserType(), worksPageResp.getStoreId()))); + worksPageResp.setWorksPanoramaList(map.get(worksPageResp.getId())); + }); + } + + return ResponseData.success(new PageResult<>(worksPage)); + case 2: + Page postPage = baseMapper.postBrowsePage(new Page<>(req.getPageNo(), req.getPageSize()),req,userVo); + + if (!postPage.getRecords().isEmpty()){ + Set userVoSet = postPage.getRecords().stream().map(postPageResp -> new UserVo(postPageResp.getUserType(), postPageResp.getUserId())).collect(Collectors.toSet()); + //查询用户信息 + Map userMap = userService.selectUserInfoMap(userVoSet,userVo); + + //精彩评论ids + List commentIds = postPage.getRecords().stream().filter(s-> ObjectUtil.isNotEmpty(s.getCommentId())).map(PostPageResp::getCommentId).collect(Collectors.toList()); + + //查询精选评论 + Map selectedCommentMap = postCommentService.getSelectedCommentMap(commentIds,userVo); + + postPage.getRecords().stream().forEach(videoPageResp ->{ + videoPageResp.setUserInfo(userMap.get(new UserVo(videoPageResp.getUserType(), videoPageResp.getUserId()))); + videoPageResp.setSelectedComment(selectedCommentMap.get(videoPageResp.getId())); + }); + } + + return ResponseData.success(new PageResult<>(postPage)); + default: + throw new IllegalStateException("Unexpected value: " + req.getType()); + } + } +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/collect/controller/CollectController.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/collect/controller/CollectController.java new file mode 100644 index 0000000..3698f1d --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/collect/controller/CollectController.java @@ -0,0 +1,97 @@ +package com.ruoyi.frequency.collect.controller; + +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.page.TableDataInfo; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.common.utils.poi.ExcelUtil; +import com.ruoyi.frequency.collect.entity.Collect; +import com.ruoyi.frequency.collect.service.CollectService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +/** + * 收藏Controller + * + * @author zj + * @date 2023-10-16 + */ +@RestController +@RequestMapping("/frequency/collect") +public class CollectController extends BaseController +{ + @Autowired + private CollectService collectService; + + /** + * 查询收藏列表 + */ + @PreAuthorize("@ss.hasPermi('frequency:collect:list')") + @GetMapping("/list") + public TableDataInfo list(Collect collect) + { + startPage(); + List list = collectService.selectCollectList(collect); + return getDataTable(list); + } + + /** + * 导出收藏列表 + */ + @PreAuthorize("@ss.hasPermi('frequency:collect:export')") + @Log(title = "收藏", businessType = BusinessType.EXPORT) + @GetMapping("/export") + public AjaxResult export(Collect collect) + { + List list = collectService.selectCollectList(collect); + ExcelUtil util = new ExcelUtil(Collect.class); + return util.exportExcel(list, "收藏数据"); + } + + /** + * 获取收藏详细信息 + */ + @PreAuthorize("@ss.hasPermi('frequency:collect:query')") + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") Long id) + { + return AjaxResult.success(collectService.selectCollectById(id)); + } + + /** + * 新增收藏 + */ + @PreAuthorize("@ss.hasPermi('frequency:collect:add')") + @Log(title = "收藏", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody Collect collect) + { + return toAjax(collectService.insertCollect(collect)); + } + + /** + * 修改收藏 + */ + @PreAuthorize("@ss.hasPermi('frequency:collect:edit')") + @Log(title = "收藏", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody Collect collect) + { + return toAjax(collectService.updateCollect(collect)); + } + + /** + * 删除收藏 + */ + @PreAuthorize("@ss.hasPermi('frequency:collect:remove')") + @Log(title = "收藏", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}") + public AjaxResult remove(@PathVariable Long[] ids) + { + return toAjax(collectService.deleteCollectByIds(ids)); + } +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/collect/entity/Collect.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/collect/entity/Collect.java new file mode 100644 index 0000000..7ac77e5 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/collect/entity/Collect.java @@ -0,0 +1,55 @@ +package com.ruoyi.frequency.collect.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import com.ruoyi.utils.SnowIdUtils; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; + +/** + * 收藏对象 t_collect + * + * @author zj + * @date 2023-10-16 + */ +@Data +@Accessors(chain = true) +@TableName("t_collect") +public class Collect extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + + @ApiModelProperty("主键id") + private Long id; + + @ApiModelProperty("删除标志 1正常 2删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("用户id") + @Excel(name = "用户id") + private Long userId; + + @ApiModelProperty("收藏类型 1作品 2 动态 ") + @Excel(name = "收藏类型 1作品 2 动态 ") + private Integer type; + + @ApiModelProperty("收藏品id(作品id,动态id)") + @Excel(name = "收藏品id", readConverterExp = "作=品id,动态id") + private Long objectId; + + @ApiModelProperty("用户角色 1 设计师 2 表现师") + @Excel(name = "用户角色 1 设计师 2 表现师") + private Integer userType; + + public Collect() { + } + + public Collect(Integer type, Long objectId) { + this.id = SnowIdUtils.uniqueLong(); + this.type = type; + this.objectId = objectId; + } +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/collect/mapper/CollectMapper.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/collect/mapper/CollectMapper.java new file mode 100644 index 0000000..ec46e53 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/collect/mapper/CollectMapper.java @@ -0,0 +1,81 @@ +package com.ruoyi.frequency.collect.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.ruoyi.controller.req.CollectPageReq; +import com.ruoyi.controller.resp.WorksPageResp; +import com.ruoyi.frequency.collect.entity.Collect; +import com.ruoyi.frequency.collect.model.param.UserCollectNumParam; +import com.ruoyi.frequency.news.entity.News; +import com.ruoyi.post.controller.resp.PostPageResp; +import com.ruoyi.vo.UserVo; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * 收藏Mapper接口 + * + * @author zj + * @date 2023-10-16 + */ +public interface CollectMapper extends BaseMapper +{ + /** + * 查询收藏 + * + * @param id 收藏主键 + * @return 收藏 + */ + public Collect selectCollectById(Long id); + + /** + * 查询收藏列表 + * + * @param collect 收藏 + * @return 收藏集合 + */ + public List selectCollectList(Collect collect); + + /** + * 新增收藏 + * + * @param collect 收藏 + * @return 结果 + */ + public int insertCollect(Collect collect); + + /** + * 修改收藏 + * + * @param collect 收藏 + * @return 结果 + */ + public int updateCollect(Collect collect); + + /** + * 删除收藏 + * + * @param id 收藏主键 + * @return 结果 + */ + public int deleteCollectById(Long id); + + /** + * 批量删除收藏 + * + * @param ids 需要删除的数据主键集合 + * @return 结果 + */ + public int deleteCollectByIds(Long[] ids); + + void collect(@Param("req") Collect collect, @Param("userVo") UserVo userVo); + + Page worksCollectPage(@Param("page") Page objectPage,@Param("req") CollectPageReq req, @Param("userVo") UserVo userVo); + + Page postCollectPage(@Param("page")Page objectPage, @Param("req") CollectPageReq req, @Param("userVo") UserVo userVo); + + Page newsCollectPage(@Param("page")Page objectPage, @Param("req") CollectPageReq req, @Param("userVo") UserVo userVo); + + Integer getUserCollectNum( @Param("userVo")UserVo userVo, @Param("req")UserCollectNumParam req); +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/collect/mapper/mapping/CollectMapper.xml b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/collect/mapper/mapping/CollectMapper.xml new file mode 100644 index 0000000..b848d26 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/collect/mapper/mapping/CollectMapper.xml @@ -0,0 +1,415 @@ + + + + + + + + + + + + + + + + + + + select id, create_by, create_time, update_by, update_time, del_flag, user_id, type, object_id, user_type from t_collect + + + + + + + + insert into t_collect + + id, + create_by, + create_time, + update_by, + update_time, + del_flag, + user_id, + type, + object_id, + user_type, + + + #{id}, + #{createBy}, + #{createTime}, + #{updateBy}, + #{updateTime}, + #{delFlag}, + #{userId}, + #{type}, + #{objectId}, + #{userType}, + + + + + update t_collect + + create_by = #{createBy}, + create_time = #{createTime}, + update_by = #{updateBy}, + update_time = #{updateTime}, + del_flag = #{delFlag}, + user_id = #{userId}, + type = #{type}, + object_id = #{objectId}, + user_type = #{userType}, + + where id = #{id} + + + + delete from t_collect where id = #{id} + + + + delete from t_collect where id in + + #{id} + + + + + insert into t_collect + (id, create_by, create_time, update_by, update_time, type, user_type, user_id, object_id) + values + (#{req.id},#{req.updateBy},#{req.updateTime},#{req.updateBy},#{req.updateTime},#{req.type},#{userVo.userType}, #{userVo.userId}, #{req.objectId}) + ON DUPLICATE KEY UPDATE + del_flag = IF( del_flag = 1, 3, 1 ), + update_time = #{req.updateTime}, + update_by = #{req.updateBy}; + + + + + + + + + + + diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/collect/model/param/CollectParam.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/collect/model/param/CollectParam.java new file mode 100644 index 0000000..64afa7b --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/collect/model/param/CollectParam.java @@ -0,0 +1,50 @@ +package com.ruoyi.frequency.collect.model.param; + +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; + +/** + * 收藏对象 t_collect + * + * @author zj + * @date 2023-10-16 + */ +@Data +@Accessors(chain = true) +public class CollectParam extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + @ApiModelProperty("主键id") + private Long id; + + @ApiModelProperty("删除标志 1正常 2删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("用户id") + @Excel(name = "用户id") + private Long userId; + + @ApiModelProperty("收藏类型 1作品 2 动态 ") + @Excel(name = "收藏类型 1作品 2 动态 ") + private Integer type; + + @ApiModelProperty("收藏品id(作品id,动态id)") + @Excel(name = "收藏品id", readConverterExp = "作=品id,动态id") + private Long objectId; + + @ApiModelProperty("用户角色 1 设计师 2 表现师") + @Excel(name = "用户角色 1 设计师 2 表现师") + private Integer userType; + + + + + + + + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/collect/model/param/UserCollectNumParam.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/collect/model/param/UserCollectNumParam.java new file mode 100644 index 0000000..26d1049 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/collect/model/param/UserCollectNumParam.java @@ -0,0 +1,26 @@ +package com.ruoyi.frequency.collect.model.param; + +import com.ruoyi.vo.UserVo; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.List; + +@Data +public class UserCollectNumParam { + + @ApiModelProperty(value = "收藏类型 1作品 2 动态 3资讯 4新闻") + private Integer type; + + @ApiModelProperty(value = "拉黑用户") + private List blockUserList; + + @ApiModelProperty(value = "屏蔽用户") + private List shieldUserList; + + @ApiModelProperty(value = "屏蔽作品") + private List shieldWorksIdList; + + @ApiModelProperty(value = "屏蔽动态") + private List shieldPostIdList; +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/collect/model/result/CollectResult.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/collect/model/result/CollectResult.java new file mode 100644 index 0000000..897a55d --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/collect/model/result/CollectResult.java @@ -0,0 +1,44 @@ +package com.ruoyi.frequency.collect.model.result; + +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; + +/** + * 收藏对象 t_collect + * + * @author zj + * @date 2023-10-16 + */ +@Data +@Accessors(chain = true) +public class CollectResult extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + @ApiModelProperty("主键id") + private Long id; + + @ApiModelProperty("删除标志 1正常 2删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("用户id") + @Excel(name = "用户id") + private Long userId; + + @ApiModelProperty("收藏类型 1作品 2 动态 ") + @Excel(name = "收藏类型 1作品 2 动态 ") + private Integer type; + + @ApiModelProperty("收藏品id(作品id,动态id)") + @Excel(name = "收藏品id", readConverterExp = "作=品id,动态id") + private Long objectId; + + @ApiModelProperty("用户角色 1 设计师 2 表现师") + @Excel(name = "用户角色 1 设计师 2 表现师") + private Integer userType; + + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/collect/service/CollectService.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/collect/service/CollectService.java new file mode 100644 index 0000000..c1f2402 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/collect/service/CollectService.java @@ -0,0 +1,104 @@ +package com.ruoyi.frequency.collect.service; + +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.IService; +import com.ruoyi.controller.req.CollectObjectReq; +import com.ruoyi.controller.req.CollectPageReq; +import com.ruoyi.controller.resp.WorksPageResp; +import com.ruoyi.frequency.collect.entity.Collect; +import com.ruoyi.frequency.news.entity.News; +import com.ruoyi.post.controller.resp.PostPageResp; +import com.ruoyi.response.ResponseData; +import com.ruoyi.vo.UserVo; + +import java.util.List; + +/** + * 收藏Service接口 + * + * @author zj + * @date 2023-10-16 + */ +public interface CollectService extends IService +{ + /** + * 查询收藏 + * + * @param id 收藏主键 + * @return 收藏 + */ + public Collect selectCollectById(Long id); + + /** + * 查询收藏列表 + * + * @param collect 收藏 + * @return 收藏集合 + */ + public List selectCollectList(Collect collect); + + /** + * 新增收藏 + * + * @param collect 收藏 + * @return 结果 + */ + public int insertCollect(Collect collect); + + /** + * 修改收藏 + * + * @param collect 收藏 + * @return 结果 + */ + public int updateCollect(Collect collect); + + /** + * 批量删除收藏 + * + * @param ids 需要删除的收藏主键集合 + * @return 结果 + */ + public int deleteCollectByIds(Long[] ids); + + /** + * 删除收藏信息 + * + * @param id 收藏主键 + * @return 结果 + */ + public int deleteCollectById(Long id); + + + /** + * 收藏 + * @param req + * @param userVo + * @return + */ + ResponseData collectObject(CollectObjectReq req, UserVo userVo); + + + /** + * 收藏列表 + * @param req + * @param userVo + * @return + */ + ResponseData collectPage(CollectPageReq req, UserVo userVo); + + Page getCollectWorksPage(CollectPageReq req, UserVo userVo); + + Page getCollectNewsPage(CollectPageReq req, UserVo userVo); + + Page getCollectPostPage(CollectPageReq req, UserVo userVo); + + /** + * 收藏列表(别人查看) + * @param req + * @return + */ + ResponseData otherCollectPage(CollectPageReq req, UserVo userVo); + + Integer getUserCollectNum(UserVo userVo,Integer type); +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/collect/service/impl/CollectServiceImpl.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/collect/service/impl/CollectServiceImpl.java new file mode 100644 index 0000000..e6f6dc6 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/collect/service/impl/CollectServiceImpl.java @@ -0,0 +1,500 @@ +package com.ruoyi.frequency.collect.service.impl; + +import cn.hutool.core.collection.CollectionUtil; +import cn.hutool.core.util.ObjectUtil; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.ruoyi.code.PublicCommon; +import com.ruoyi.common.page.PageResult; +import com.ruoyi.common.utils.DateUtils; +import com.ruoyi.controller.req.CollectObjectReq; +import com.ruoyi.controller.req.CollectPageReq; +import com.ruoyi.controller.resp.WorksPageResp; +import com.ruoyi.frequency.collect.entity.Collect; +import com.ruoyi.frequency.collect.mapper.CollectMapper; +import com.ruoyi.frequency.collect.model.param.UserCollectNumParam; +import com.ruoyi.frequency.collect.service.CollectService; +import com.ruoyi.frequency.customer.service.UserService; +import com.ruoyi.frequency.news.entity.News; +import com.ruoyi.frequency.news.mapper.NewsMapper; +import com.ruoyi.frequency.works.entity.Works; +import com.ruoyi.frequency.works.mapper.WorksMapper; +import com.ruoyi.frequency.workspanorama.entity.WorksPanorama; +import com.ruoyi.frequency.workspanorama.service.WorksPanoramaService; +import com.ruoyi.frequency.worksshield.service.WorksShieldService; +import com.ruoyi.frequency.workstype.service.WorksTypeService; +import com.ruoyi.post.controller.resp.PostPageResp; +import com.ruoyi.post.controller.vo.SelectedComment; +import com.ruoyi.post.frequency.posshield.service.PostShieldService; +import com.ruoyi.post.frequency.post.mapper.PostMapper; +import com.ruoyi.post.frequency.postcomment.service.PostCommentService; +import com.ruoyi.response.ResponseData; +import com.ruoyi.vo.UserInfo; +import com.ruoyi.vo.UserVo; +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.Map; +import java.util.Set; +import java.util.stream.Collectors; + +/** + * 收藏Service业务层处理 + * + * @author zj + * @date 2023-10-16 + */ +@Service +@Transactional(rollbackFor = Exception.class) +public class CollectServiceImpl extends ServiceImpl implements CollectService { + @Autowired + private CollectMapper collectMapper; + + /** + * 查询收藏 + * + * @param id 收藏主键 + * @return 收藏 + */ + @Override + public Collect selectCollectById(Long id) { + return collectMapper.selectCollectById(id); + } + + /** + * 查询收藏列表 + * + * @param collect 收藏 + * @return 收藏 + */ + @Override + public List selectCollectList(Collect collect) { + return collectMapper.selectCollectList(collect); + } + + /** + * 新增收藏 + * + * @param collect 收藏 + * @return 结果 + */ + @Override + public int insertCollect(Collect collect) { + collect.setCreateTime(DateUtils.getNowDate()); + return collectMapper.insertCollect(collect); + } + + /** + * 修改收藏 + * + * @param collect 收藏 + * @return 结果 + */ + @Override + public int updateCollect(Collect collect) { + collect.setUpdateTime(DateUtils.getNowDate()); + return collectMapper.updateCollect(collect); + } + + /** + * 批量删除收藏 + * + * @param ids 需要删除的收藏主键 + * @return 结果 + */ + @Override + public int deleteCollectByIds(Long[] ids) { + this.lambdaUpdate().set(Collect::getDelFlag, PublicCommon.删除).in(Collect::getId, ids).update(); + return ids.length; + } + + /** + * 删除收藏信息 + * + * @param id 收藏主键 + * @return 结果 + */ + @Override + public int deleteCollectById(Long id) { + this.lambdaUpdate().set(Collect::getDelFlag, PublicCommon.删除).eq(Collect::getId, id).update(); + return 1; + } + + @Override + public ResponseData collectObject(CollectObjectReq req, UserVo userVo) { + + Collect collect = new Collect(req.getType(), req.getObjectId()); + + collect.setCreateData(); + collect.setUpdateData(); + collect.setUserType(userVo.getUserType()) + .setUserId(userVo.getUserId()); + + //收藏 + collectMapper.collect(collect, userVo); + + collect = collectMapper.selectOne(new QueryWrapper().lambda().eq(Collect::getObjectId, req.getObjectId()) + .eq(Collect::getType, req.getType()) + .eq(Collect::getUserType, userVo.getUserType()) + .eq(Collect::getUserId, userVo.getUserId())); + + //是否收藏 + Boolean isCollect = collect.getDelFlag().equals(PublicCommon.启用); + + //收藏类型 1作品 2 动态 3资讯 4新闻 + updateCollectNum(req.getType(), req.getObjectId(), isCollect); + + return ResponseData.success(); + } + + @Autowired + private UserService userService; + + @Autowired + private PostCommentService postCommentService; + + @Autowired + private WorksTypeService worksTypeService; + + @Autowired + private WorksPanoramaService worksPanoramaService; + + @Autowired + private PostShieldService postShieldService; + + @Autowired + private WorksShieldService worksShieldService; + + @Override + public ResponseData collectPage(CollectPageReq req, UserVo userVo) { + + //收藏类型 1作品 2 动态 3咨询 4新闻 + switch (req.getType()) { + case 1: + Page worksPage = getCollectWorksPage(req, userVo); + if (!worksPage.getRecords().isEmpty()) { + + Set userVoSet = worksPage.getRecords().stream().map(worksPageResp -> new UserVo(worksPageResp.getUserType(), worksPageResp.getStoreId())).collect(Collectors.toSet()); + //查询用户信息 + Map userMap = userService.selectUserInfoMap(userVoSet, userVo); + + //作品ids + List worksIds = worksPage.getRecords().stream().map(WorksPageResp::getId).collect(Collectors.toList()); + //查询3D图 + List worksPanoramaList = worksPanoramaService.list(new QueryWrapper().lambda().in(WorksPanorama::getWorksId, worksIds).orderByDesc(WorksPanorama::getCreateTime)); + + Map> map = worksPanoramaList.stream().collect(Collectors.groupingBy(WorksPanorama::getWorksId)); + + worksPage.getRecords().stream().forEach(worksPageResp -> { + worksPageResp.setUserInfo(userMap.get(new UserVo(worksPageResp.getUserType(), worksPageResp.getStoreId()))); + worksPageResp.setWorksPanoramaList(map.get(worksPageResp.getId())); + }); + } + return ResponseData.success(new PageResult<>(worksPage)); + case 4: + Page newsPage = getCollectNewsPage(req, userVo); + return ResponseData.success(new PageResult<>(newsPage)); + default: + Page postPage = getCollectPostPage(req, userVo); + + if (!postPage.getRecords().isEmpty()) { + Set userVoSet = postPage.getRecords().stream().map(postPageResp -> new UserVo(postPageResp.getUserType(), postPageResp.getUserId())).collect(Collectors.toSet()); + //查询用户信息 + Map userMap = userService.selectUserInfoMap(userVoSet, userVo); + + //精彩评论ids + List commentIds = postPage.getRecords().stream().filter(s -> ObjectUtil.isNotEmpty(s.getCommentId())).map(PostPageResp::getCommentId).collect(Collectors.toList()); + + //查询精选评论 + Map selectedCommentMap = postCommentService.getSelectedCommentMap(commentIds, userVo); + + + //帖子ids + List postIds = postPage.getRecords().stream().filter(s -> ObjectUtil.isNotEmpty(s.getId())).map(PostPageResp::getId).collect(Collectors.toList()); + + //查询最新评论 帖子id ->最新评论 + Map selectedNewCommentMap = postCommentService.getSelectedNewCommentMap(postIds, userVo); + + postPage.getRecords().stream().forEach(postPageResp -> { + postPageResp.setUserInfo(userMap.get(new UserVo(postPageResp.getUserType(), postPageResp.getUserId()))); + if (selectedCommentMap.get(postPageResp.getCommentId()) != null) { + postPageResp.setSelectedComment(selectedCommentMap.get(postPageResp.getCommentId())); + } else { + //没有精选评论-->查询最新一条评论 + postPageResp.setSelectedComment(selectedNewCommentMap.get(postPageResp.getId())); + } + }); + } + + return ResponseData.success(new PageResult<>(postPage)); + } + } + + private void setBlockShieldUserOrPost(CollectPageReq req, UserVo userVo) { + if (req.getType() == 1) { + //筛去拉黑与被拉黑用户 + if (CollectionUtil.isEmpty(req.getBlockUserList())) { + List blockUserList = userService.blockUserList(userVo); + req.setBlockUserList(blockUserList); + } + + //筛去屏蔽用户 + if (CollectionUtil.isEmpty(req.getShieldUserList())) { + List shieldUserList = userService.shieldUserList(userVo); + req.setShieldUserList(shieldUserList); + } + + //筛去屏蔽的帖子 + if (CollectionUtil.isEmpty(req.getShieldWorksIdList())) { + List shieldWorksList = worksShieldService.shieldWorksList(userVo); + req.setShieldWorksIdList(shieldWorksList); + } + } else if (req.getType() == 2) { + //筛去拉黑与被拉黑用户 + if (CollectionUtil.isEmpty(req.getBlockUserList())) { + List blockUserList = userService.blockUserList(userVo); + req.setBlockUserList(blockUserList); + } + + //筛去屏蔽用户 + if (CollectionUtil.isEmpty(req.getShieldUserList())) { + List shieldUserList = userService.shieldUserList(userVo); + req.setShieldUserList(shieldUserList); + } + + //筛去屏蔽的帖子 + if (CollectionUtil.isEmpty(req.getShieldPostIdList())) { + List shieldPostIdList = postShieldService.shieldPostList(userVo); + req.setShieldPostIdList(shieldPostIdList); + } + } + + } + + + /** + * 作品收藏数量 + * + * @param req + * @param userVo + * @return + */ + @Override + public Page getCollectWorksPage(CollectPageReq req, UserVo userVo) { + + setBlockShieldUserOrPost(req, userVo); + + if (ObjectUtil.isNotEmpty(req.getTypeId())) { + //根据类型id获取三级id + List typeIdList = worksTypeService.getIdsByTypeId(req.getTypeId()); + if (typeIdList.isEmpty()) { + return new Page<>(req.getPageNo(), req.getPageSize()); + } + req.setTypeIds(typeIdList); + } + + Page worksPage = baseMapper.worksCollectPage(new Page<>(req.getPageNo(), req.getPageSize()), req, userVo); + return worksPage; + } + + + /** + * 作品收藏数量 + * + * @param req + * @param userVo + * @return + */ + @Override + public Page getCollectNewsPage(CollectPageReq req, UserVo userVo) { + + setBlockShieldUserOrPost(req, userVo); + + Page newsPage = baseMapper.newsCollectPage(new Page<>(req.getPageNo(), req.getPageSize()), req, userVo); + return newsPage; + } + + /** + * 帖子收藏数量 + * + * @param req + * @param userVo + * @return + */ + @Override + public Page getCollectPostPage(CollectPageReq req, UserVo userVo) { + + setBlockShieldUserOrPost(req, userVo); + + Page postPage = baseMapper.postCollectPage(new Page<>(req.getPageNo(), req.getPageSize()), req, userVo); + return postPage; + } + + @Override + public ResponseData otherCollectPage(CollectPageReq req, UserVo userVoSelf) { + + UserVo userVo = new UserVo(req.getUserType(), req.getUserId()); + + if (req.getType() == 1) { + //筛去拉黑与被拉黑用户 + List blockUserList = userService.blockUserList(userVo); + req.setBlockUserList(blockUserList); + + //筛去屏蔽用户 + List shieldUserList = userService.shieldUserList(userVo); + req.setShieldUserList(shieldUserList); + + //筛去屏蔽的帖子 + List shieldPostIdList = worksShieldService.shieldWorksList(userVo); + req.setShieldPostIdList(shieldPostIdList); + } else if (req.getType() == 2) { + //筛去拉黑与被拉黑用户 + List blockUserList = userService.blockUserList(userVo); + req.setBlockUserList(blockUserList); + + //筛去屏蔽用户 + List shieldUserList = userService.shieldUserList(userVo); + req.setShieldUserList(shieldUserList); + + //筛去屏蔽的帖子 + List shieldPostIdList = postShieldService.shieldPostList(userVo); + req.setShieldPostIdList(shieldPostIdList); + } + + //收藏类型 1作品 2 动态 + switch (req.getType()) { + case 1: + if (ObjectUtil.isNotEmpty(req.getTypeId())) { + //根据类型id获取三级id + List typeIdList = worksTypeService.getIdsByTypeId(req.getTypeId()); + if (typeIdList.isEmpty()) { + return ResponseData.success(new PageResult<>(new Page<>(req.getPageNo(), req.getPageSize()))); + } + req.setTypeIds(typeIdList); + } + Page worksPage = baseMapper.worksCollectPage(new Page<>(req.getPageNo(), req.getPageSize()), req, userVoSelf); + + if (!worksPage.getRecords().isEmpty()) { + + Set userVoSet = worksPage.getRecords().stream().map(worksPageResp -> new UserVo(worksPageResp.getUserType(), worksPageResp.getStoreId())).collect(Collectors.toSet()); + //查询用户信息 + Map userMap = userService.selectUserInfoMap(userVoSet, userVoSelf); + + //作品ids + List worksIds = worksPage.getRecords().stream().map(WorksPageResp::getId).collect(Collectors.toList()); + //查询3D图 + List worksPanoramaList = worksPanoramaService.list(new QueryWrapper().lambda().in(WorksPanorama::getWorksId, worksIds).orderByDesc(WorksPanorama::getCreateTime)); + + Map> map = worksPanoramaList.stream().collect(Collectors.groupingBy(WorksPanorama::getWorksId)); + + worksPage.getRecords().stream().forEach(worksPageResp -> { + worksPageResp.setUserInfo(userMap.get(new UserVo(worksPageResp.getUserType(), worksPageResp.getStoreId()))); + worksPageResp.setWorksPanoramaList(map.get(worksPageResp.getId())); + }); + } + + return ResponseData.success(new PageResult<>(worksPage)); + default: + Page postPage = baseMapper.postCollectPage(new Page<>(req.getPageNo(), req.getPageSize()), req, userVoSelf); + + if (!postPage.getRecords().isEmpty()) { + Set userVoSet = postPage.getRecords().stream().map(postPageResp -> new UserVo(postPageResp.getUserType(), postPageResp.getUserId())).collect(Collectors.toSet()); + //查询用户信息 + Map userMap = userService.selectUserInfoMap(userVoSet, userVoSelf); + + //精彩评论ids + List commentIds = postPage.getRecords().stream().filter(s -> ObjectUtil.isNotEmpty(s.getCommentId())).map(PostPageResp::getCommentId).collect(Collectors.toList()); + + //查询精选评论 + Map selectedCommentMap = postCommentService.getSelectedCommentMap(commentIds, userVoSelf); + + postPage.getRecords().stream().forEach(videoPageResp -> { + videoPageResp.setUserInfo(userMap.get(new UserVo(videoPageResp.getUserType(), videoPageResp.getUserId()))); + videoPageResp.setSelectedComment(selectedCommentMap.get(videoPageResp.getId())); + }); + } + return ResponseData.success(new PageResult<>(postPage)); + } + } + + @Override + public Integer getUserCollectNum(UserVo userVo, Integer type) { + + UserCollectNumParam req = new UserCollectNumParam(); + req.setType(type); + //筛去拉黑与被拉黑用户 +// List blockUserList = userService.blockUserList(userVo); +// req.setBlockUserList(blockUserList); + + //筛去屏蔽用户 +// List shieldUserList = userService.shieldUserList(userVo); +// req.setShieldUserList(shieldUserList); +// +// if (req.getType() != null) { +// if (req.getType() == 1) { +// //筛去屏蔽的作品 +// List shieldWorksList = worksShieldService.shieldWorksList(userVo); +// req.setShieldWorksIdList(shieldWorksList); +// } else if (req.getType() == 2) { +// //筛去屏蔽的作品 +// List shieldPostList = postShieldService.shieldPostList(userVo); +// req.setShieldPostIdList(shieldPostList); +// } +// } else { +// //筛去屏蔽的作品 +// List shieldWorksList = worksShieldService.shieldWorksList(userVo); +// req.setShieldWorksIdList(shieldWorksList); +// +// //筛去屏蔽的作品 +// List shieldPostList = postShieldService.shieldPostList(userVo); +// req.setShieldPostIdList(shieldPostList); +// } + + return baseMapper.getUserCollectNum(userVo, req); + } + + + @Autowired + private PostMapper postMapper; + + @Autowired + private NewsMapper newsMapper; + + @Autowired + private WorksMapper worksMapper; + + /** + * 修改收藏数量 + * + * @param type 收藏类型 1作品 2 动态 3资讯 4新闻 + * @param objectId 收藏对象id + * @param isCollect 是否收藏 + */ + private void updateCollectNum(Integer type, Long objectId, Boolean isCollect) { + + //收藏 +1 ,取消收藏 -1 + Integer num = isCollect ? 1 : -1; + + switch (type) { + case 1: + Works works = new Works().setId(objectId).setCollectNum(num); + works.setUpdateData(); + worksMapper.updateWorks(works); + break; + case 2: + postMapper.updateNumPost(objectId, PublicCommon.Post.收藏数, num); + break; + case 3: + postMapper.updateNumPost(objectId, PublicCommon.Post.收藏数, num); + break; + case 4: + newsMapper.updateNews(new News().setId(objectId).setCollectNum(num)); + break; + default: + throw new IllegalStateException("Unexpected value: " + type); + } + } +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/comment/controller/CommentController.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/comment/controller/CommentController.java new file mode 100644 index 0000000..35897c6 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/comment/controller/CommentController.java @@ -0,0 +1,103 @@ +package com.ruoyi.frequency.comment.controller; + +import java.util.List; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.frequency.comment.entity.Comment; +import com.ruoyi.frequency.comment.service.CommentService; +import com.ruoyi.common.utils.poi.ExcelUtil; +import com.ruoyi.common.core.page.TableDataInfo; + +/** + * 评论(新闻)Controller + * + * @author liwenlong + * @date 2024-04-15 + */ +@RestController +@RequestMapping("/frequency/comment") +public class CommentController extends BaseController +{ + @Autowired + private CommentService commentService; + + /** + * 查询评论(新闻)列表 + */ + @PreAuthorize("@ss.hasPermi('frequency:comment:list')") + @PostMapping("/list") + public TableDataInfo list(@RequestBody Comment comment) + { + startPage(); + List list = commentService.selectCommentList(comment); + return getDataTable(list); + } + + /** + * 导出评论(新闻)列表 + */ + @PreAuthorize("@ss.hasPermi('frequency:comment:export')") + @Log(title = "评论(新闻)", businessType = BusinessType.EXPORT) + @GetMapping("/export") + public AjaxResult export(Comment comment) + { + List list = commentService.selectCommentList(comment); + ExcelUtil util = new ExcelUtil(Comment.class); + return util.exportExcel(list, "评论(新闻)数据"); + } + + /** + * 获取评论(新闻)详细信息 + */ + @PreAuthorize("@ss.hasPermi('frequency:comment:query')") + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") Long id) + { + return AjaxResult.success(commentService.selectCommentById(id)); + } + + /** + * 新增评论(新闻) + */ + @PreAuthorize("@ss.hasPermi('frequency:comment:add')") + @Log(title = "评论(新闻)", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody Comment comment) + { + return toAjax(commentService.insertComment(comment)); + } + + /** + * 修改评论(新闻) + */ + @PreAuthorize("@ss.hasPermi('frequency:comment:edit')") + @Log(title = "评论(新闻)", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody Comment comment) + { + return toAjax(commentService.updateComment(comment)); + } + + /** + * 删除评论(新闻) + */ + @PreAuthorize("@ss.hasPermi('frequency:comment:remove')") + @Log(title = "评论(新闻)", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}/{delFlag}") + public AjaxResult remove(@PathVariable("ids") Long[] ids,@PathVariable("delFlag") Integer delFlag) + { + return toAjax(commentService.deleteCommentByIds(ids,delFlag)); + } +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/comment/entity/Comment.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/comment/entity/Comment.java new file mode 100644 index 0000000..6b8c315 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/comment/entity/Comment.java @@ -0,0 +1,107 @@ +package com.ruoyi.frequency.comment.entity; + +import com.ruoyi.controller.req.CommentReq; +import com.ruoyi.utils.SnowIdUtils; +import com.ruoyi.vo.UserVo; +import lombok.Data; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.experimental.Accessors; +import com.ruoyi.common.annotation.Excel; +import io.swagger.annotations.ApiModelProperty; +import com.baomidou.mybatisplus.annotation.TableField; +import com.ruoyi.vo.UserInfo; +import com.ruoyi.common.core.domain.BaseEntity; + +/** + * 评论(新闻)对象 t_comment + * + * @author liwenlong + * @date 2024-04-15 + */ +@Data +@Accessors(chain = true) +@TableName("t_comment") +public class Comment extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + + @ApiModelProperty("租户号") + private Long id; + + @ApiModelProperty("删除状态 1 正常 2 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("类型 1 新闻 ") + @Excel(name = "类型 1 新闻 ") + private Integer type; + + @ApiModelProperty("用户类型") + @Excel(name = "用户类型") + private Integer userType; + + @ApiModelProperty("评论用户id") + @Excel(name = "评论用户id") + private Long userId; + + @ApiModelProperty("关联id(新闻id)") + @Excel(name = "关联id(新闻id)") + private Long linkId; + + @ApiModelProperty("顶级评论id(对主体的直接评论)") + @Excel(name = "顶级评论id(对主体的直接评论)") + private Long topId; + + @ApiModelProperty("上级评论id 默认-1") + @Excel(name = "上级评论id 默认-1") + private Long parentId; + + @ApiModelProperty("用户类型") + @Excel(name = "用户类型") + private Integer parentUserType; + + @ApiModelProperty("上级评论用户id") + @Excel(name = "上级评论用户id") + private Long parentUserId; + + @ApiModelProperty("评论内容") + @Excel(name = "评论内容") + private String content; + + @ApiModelProperty("点赞数") + @Excel(name = "点赞数") + private Integer likeNum; + + @ApiModelProperty("评论数") + @Excel(name = "评论数") + private Integer commentNum; + + @ApiModelProperty("图片") + @Excel(name = "图片") + private String image; + + @ApiModelProperty("上级评论id集合,逗号拼接") + @Excel(name = "上级评论id集合,逗号拼接") + private String parentIds; + + @ApiModelProperty("用户信息") + @TableField(exist = false) + private UserInfo userInfo; + + @ApiModelProperty(value = "上级用户用户昵称") + @TableField(exist = false) + private UserInfo parentUserInfo; + public Comment() { + + } + + public Comment(CommentReq req, UserVo userVo) { + this.id = SnowIdUtils.uniqueLong(); + this.userType = userVo.getUserType(); + this.userId = userVo.getUserId(); + this.linkId = req.getLinkId(); + this.content = req.getContent(); + this.image = req.getImage(); + this.parentId = req.getParentId(); + } +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/comment/mapper/CommentMapper.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/comment/mapper/CommentMapper.java new file mode 100644 index 0000000..c9c97a5 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/comment/mapper/CommentMapper.java @@ -0,0 +1,67 @@ +package com.ruoyi.frequency.comment.mapper; + +import java.util.List; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.ruoyi.controller.req.CommentPageReq; +import com.ruoyi.controller.req.DialoguePageReq; +import com.ruoyi.controller.resp.CommentNum; +import com.ruoyi.controller.resp.CommentPageResp; +import com.ruoyi.controller.resp.CommentResp; +import com.ruoyi.controller.resp.WorksCommentPageResp; +import com.ruoyi.frequency.comment.entity.Comment; +import com.ruoyi.vo.UserVo; +import org.apache.ibatis.annotations.Param; + +/** + * 评论(新闻)Mapper接口 + * + * @author liwenlong + * @date 2024-04-15 + */ +public interface CommentMapper extends BaseMapper +{ + /** + * 查询评论(新闻) + * + * @param id 评论(新闻)主键 + * @return 评论(新闻) + */ + public Comment selectCommentById(Long id); + + /** + * 查询评论(新闻)列表 + * + * @param comment 评论(新闻) + * @return 评论(新闻)集合 + */ + public List selectCommentList(Comment comment); + + /** + * 新增评论(新闻) + * + * @param comment 评论(新闻) + * @return 结果 + */ + public int insertComment(Comment comment); + + /** + * 修改评论(新闻) + * + * @param comment 评论(新闻) + * @return 结果 + */ + public int updateComment(Comment comment); + + CommentResp getCommentResp(@Param("id") Long id,@Param("userVo") UserVo userVo); + + Page commentPage(@Param("page")Page objectPage, @Param("req")CommentPageReq req, @Param("userVo")UserVo userVo); + + List commentList(@Param("req")CommentPageReq req, @Param("userVo") UserVo userVo,@Param("list") List parentIds); + + List selectCommentNumList(@Param("commentIds")List commentIds,@Param("userVoList") List userVoList); + + Page commentDialoguePage(@Param("page")Page objectPage,@Param("req") DialoguePageReq req,@Param("userVo") UserVo userVo); + + void updateCommentBatch(@Param("list")List comments); +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/comment/mapper/mapping/CommentMapper.xml b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/comment/mapper/mapping/CommentMapper.xml new file mode 100644 index 0000000..1f7bfd7 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/comment/mapper/mapping/CommentMapper.xml @@ -0,0 +1,575 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + select + t.id , + t.del_flag , + t.create_by , + t.create_time , + t.update_by , + t.update_time , + t.type , + t.user_type , + t.user_id , + t.link_id , + t.top_id , + t.parent_id , + t.parent_user_type , + t.parent_user_id , + t.content , + t.like_num , + t.comment_num , + t.image , + t.remark + from t_comment AS t + + + + + + + + insert into t_comment + + id, + del_flag, + create_by, + create_time, + update_by, + update_time, + type, + user_type, + user_id, + link_id, + top_id, + parent_id, + parent_user_type, + parent_user_id, + content, + like_num, + comment_num, + image, + remark, + + + #{id}, + #{delFlag}, + #{createBy}, + #{createTime}, + #{updateBy}, + #{updateTime}, + #{type}, + #{userType}, + #{userId}, + #{linkId}, + #{topId}, + #{parentId}, + #{parentUserType}, + #{parentUserId}, + #{content}, + #{likeNum}, + #{commentNum}, + #{image}, + #{remark}, + + + + + update t_comment + + del_flag = #{delFlag}, + create_by = #{createBy}, + create_time = #{createTime}, + update_by = #{updateBy}, + update_time = #{updateTime}, + type = #{type}, + user_type = #{userType}, + user_id = #{userId}, + link_id = #{linkId}, + top_id = #{topId}, + parent_id = #{parentId}, + parent_user_type = #{parentUserType}, + parent_user_id = #{parentUserId}, + content = #{content}, + like_num = like_num + #{likeNum}, + comment_num = comment_num + #{commentNum}, + image = #{image}, + remark = #{remark}, + + where id = #{id} + and like_num + #{likeNum} >= 0 + and comment_num + #{commentNum} >= 0 + + + + + + + + + + + + + + + update t_comment + + like_num = like_num + #{item.likeNum}, + comment_num = comment_num + #{item.commentNum}, + + where id = #{item.id} + and like_num + #{item.likeNum}>=0 + and comment_num + #{item.commentNum} >= 0 + + + \ No newline at end of file diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/comment/model/param/CommentParam.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/comment/model/param/CommentParam.java new file mode 100644 index 0000000..417dd28 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/comment/model/param/CommentParam.java @@ -0,0 +1,93 @@ +package com.ruoyi.frequency.comment.model.param; + +import lombok.Data; +import lombok.experimental.Accessors; +import com.ruoyi.common.annotation.Excel; +import io.swagger.annotations.ApiModelProperty; +import com.ruoyi.common.core.domain.BaseEntity; + +/** + * 评论(新闻)对象 t_comment + * + * @author liwenlong + * @date 2024-04-15 + */ +@Data +@Accessors(chain = true) +public class CommentParam extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + @ApiModelProperty("租户号") + private Long id; + + @ApiModelProperty("删除状态 1 正常 2 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("类型 1 新闻 ") + @Excel(name = "类型 1 新闻 ") + private Integer type; + + @ApiModelProperty("用户类型") + @Excel(name = "用户类型") + private Integer userType; + + @ApiModelProperty("评论用户id") + @Excel(name = "评论用户id") + private Long userId; + + @ApiModelProperty("关联id(新闻id)") + @Excel(name = "关联id(新闻id)") + private Long linkId; + + @ApiModelProperty("顶级评论id(对主体的直接评论)") + @Excel(name = "顶级评论id(对主体的直接评论)") + private Long topId; + + @ApiModelProperty("上级评论id 默认-1") + @Excel(name = "上级评论id 默认-1") + private Long parentId; + + @ApiModelProperty("用户类型") + @Excel(name = "用户类型") + private Integer parentUserType; + + @ApiModelProperty("上级评论用户id") + @Excel(name = "上级评论用户id") + private Long parentUserId; + + @ApiModelProperty("评论内容") + @Excel(name = "评论内容") + private String content; + + @ApiModelProperty("点赞数") + @Excel(name = "点赞数") + private Integer likeNum; + + @ApiModelProperty("评论数") + @Excel(name = "评论数") + private Integer commentNum; + + @ApiModelProperty("图片") + @Excel(name = "图片") + private String image; + + @ApiModelProperty("上级评论id集合,逗号拼接") + @Excel(name = "上级评论id集合,逗号拼接") + private String parentIds; + + + + + + + + + + + + + + + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/comment/model/result/CommentResult.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/comment/model/result/CommentResult.java new file mode 100644 index 0000000..57efdea --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/comment/model/result/CommentResult.java @@ -0,0 +1,79 @@ +package com.ruoyi.frequency.comment.model.result; + +import lombok.Data; +import lombok.experimental.Accessors; +import com.ruoyi.common.annotation.Excel; +import io.swagger.annotations.ApiModelProperty; +import com.ruoyi.common.core.domain.BaseEntity; + +/** + * 评论(新闻)对象 t_comment + * + * @author liwenlong + * @date 2024-04-15 + */ +@Data +@Accessors(chain = true) +public class CommentResult extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + @ApiModelProperty("租户号") + private Long id; + + @ApiModelProperty("删除状态 1 正常 2 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("类型 1 新闻 ") + @Excel(name = "类型 1 新闻 ") + private Integer type; + + @ApiModelProperty("用户类型") + @Excel(name = "用户类型") + private Integer userType; + + @ApiModelProperty("评论用户id") + @Excel(name = "评论用户id") + private Long userId; + + @ApiModelProperty("关联id(新闻id)") + @Excel(name = "关联id(新闻id)") + private Long linkId; + + @ApiModelProperty("顶级评论id(对主体的直接评论)") + @Excel(name = "顶级评论id(对主体的直接评论)") + private Long topId; + + @ApiModelProperty("上级评论id 默认-1") + @Excel(name = "上级评论id 默认-1") + private Long parentId; + + @ApiModelProperty("用户类型") + @Excel(name = "用户类型") + private Integer parentUserType; + + @ApiModelProperty("上级评论用户id") + @Excel(name = "上级评论用户id") + private Long parentUserId; + + @ApiModelProperty("评论内容") + @Excel(name = "评论内容") + private String content; + + @ApiModelProperty("点赞数") + @Excel(name = "点赞数") + private Integer likeNum; + + @ApiModelProperty("评论数") + @Excel(name = "评论数") + private Integer commentNum; + + @ApiModelProperty("图片") + @Excel(name = "图片") + private String image; + + @ApiModelProperty("上级评论id集合,逗号拼接") + @Excel(name = "上级评论id集合,逗号拼接") + private String parentIds; + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/comment/service/CommentService.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/comment/service/CommentService.java new file mode 100644 index 0000000..2ea1c67 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/comment/service/CommentService.java @@ -0,0 +1,75 @@ +package com.ruoyi.frequency.comment.service; + +import java.util.List; + +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.ruoyi.common.page.PageResult; +import com.ruoyi.controller.req.CommentPageReq; +import com.ruoyi.controller.req.CommentReq; +import com.ruoyi.controller.req.DialoguePageReq; +import com.ruoyi.controller.resp.CommentPageResp; +import com.ruoyi.controller.resp.CommentResp; +import com.ruoyi.frequency.comment.entity.Comment; +import com.baomidou.mybatisplus.extension.service.IService; +import com.ruoyi.post.controller.req.DeleteCommentReq; +import com.ruoyi.response.ResponseData; +import com.ruoyi.vo.UserVo; + +/** + * 评论(新闻)Service接口 + * + * @author liwenlong + * @date 2024-04-15 + */ +public interface CommentService extends IService +{ + /** + * 查询评论(新闻) + * + * @param id 评论(新闻)主键 + * @return 评论(新闻) + */ + public Comment selectCommentById(Long id); + + /** + * 查询评论(新闻)列表 + * + * @param comment 评论(新闻) + * @return 评论(新闻)集合 + */ + public List selectCommentList(Comment comment); + + /** + * 新增评论(新闻) + * + * @param comment 评论(新闻) + * @return 结果 + */ + public int insertComment(Comment comment); + + /** + * 修改评论(新闻) + * + * @param comment 评论(新闻) + * @return 结果 + */ + public int updateComment(Comment comment); + + /** + * 批量删除评论(新闻) + * + * @param ids 需要删除的评论(新闻)主键集合 + * @return 结果 + */ + public int deleteCommentByIds(Long[] ids,Integer delFlag); + + ResponseData comment(CommentReq req, UserVo userVo); + + ResponseData>> commentPage(CommentPageReq req, UserVo userVo); + + ResponseData deleteComment(DeleteCommentReq req, UserVo userVo); + + ResponseData commentDetail(Long id, UserVo userVo); + + ResponseData>> commentDialoguePage(DialoguePageReq req, UserVo userVo); +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/comment/service/impl/CommentServiceImpl.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/comment/service/impl/CommentServiceImpl.java new file mode 100644 index 0000000..0e5578d --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/comment/service/impl/CommentServiceImpl.java @@ -0,0 +1,434 @@ +package com.ruoyi.frequency.comment.service.impl; + +import java.util.*; +import java.util.stream.Collectors; + +import cn.hutool.core.collection.CollectionUtil; +import cn.hutool.core.util.ObjectUtil; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.ruoyi.common.page.PageResult; +import com.ruoyi.common.utils.DateUtils; +import com.ruoyi.controller.req.CommentPageReq; +import com.ruoyi.controller.req.CommentReq; +import com.ruoyi.controller.req.DialoguePageReq; +import com.ruoyi.controller.req.WorksCommentReq; +import com.ruoyi.controller.resp.*; +import com.ruoyi.enums.message.InteractionMessageEnums; +import com.ruoyi.frequency.customer.service.UserService; +import com.ruoyi.frequency.news.entity.News; +import com.ruoyi.frequency.news.mapper.NewsMapper; +import com.ruoyi.frequency.vote.entity.Vote; +import com.ruoyi.frequency.votecomment.entity.VoteComment; +import com.ruoyi.frequency.works.entity.Works; +import com.ruoyi.frequency.workscomment.entity.WorksComment; +import com.ruoyi.message.frequency.interactionmessagerecord.service.InteractionMessageRecordService; +import com.ruoyi.post.controller.req.DeleteCommentReq; +import com.ruoyi.response.ResponseData; +import com.ruoyi.vo.UserInfo; +import com.ruoyi.vo.UserVo; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.ruoyi.code.PublicCommon; +import com.ruoyi.frequency.comment.mapper.CommentMapper; +import com.ruoyi.frequency.comment.entity.Comment; +import com.ruoyi.frequency.comment.service.CommentService; + +/** + * 评论(新闻)Service业务层处理 + * + * @author liwenlong + * @date 2024-04-15 + */ +@Service +public class CommentServiceImpl extends ServiceImpl implements CommentService +{ + @Autowired + private CommentMapper commentMapper; + + /** + * 查询评论(新闻) + * + * @param id 评论(新闻)主键 + * @return 评论(新闻) + */ + @Override + public Comment selectCommentById(Long id) + { + return commentMapper.selectCommentById(id); + } + + /** + * 查询评论(新闻)列表 + * + * @param comment 评论(新闻) + * @return 评论(新闻) + */ + @Override + public List selectCommentList(Comment comment) + { + List comments = commentMapper.selectCommentList(comment); + if (!comments.isEmpty()) { + Set userVoSet = comments.stream().map(s -> new UserVo(s.getUserType(), s.getUserId())).collect(Collectors.toSet()); + Set parentUserVoSet = comments.stream().map(s -> new UserVo(s.getParentUserType(), s.getParentUserId())).collect(Collectors.toSet()); + + userVoSet.addAll(parentUserVoSet); + + //查询用户信息 + Map userMap = userService.selectUserInfoMap(userVoSet, null); + + comments.stream().forEach(s -> { + s.setUserInfo(userMap.get(new UserVo(s.getUserType(), s.getUserId()))); + s.setParentUserInfo(userMap.get(new UserVo(s.getParentUserType(), s.getParentUserId()))); + }); + } + return comments; + } + + /** + * 新增评论(新闻) + * + * @param comment 评论(新闻) + * @return 结果 + */ + @Override + public int insertComment(Comment comment) + { + comment.setCreateData(); + return commentMapper.insert(comment); + } + + /** + * 修改评论(新闻) + * + * @param comment 评论(新闻) + * @return 结果 + */ + @Override + public int updateComment(Comment comment) + { + comment.setUpdateData(); + return commentMapper.updateComment(comment); + } + + + + @Autowired + private UserService userService; + + @Override + public ResponseData comment(CommentReq req, UserVo userVo) { + //评论 + Comment comment = new Comment(req,userVo); + + //新闻-->评论 + if (ObjectUtil.isEmpty(req.getParentId()) || ObjectUtil.equal(0L,req.getParentId())){ + //顶级评论id + comment.setTopId(comment.getId()); + }else { + //查询上级评论 + Comment parentComment = this.getById(req.getParentId()); + + //评论用户 + comment.setParentUserId(parentComment.getUserId()) + .setParentUserType(parentComment.getUserType()); + + comment.setTopId(parentComment.getTopId()); + + //上级id + if (ObjectUtil.isNotEmpty(parentComment.getParentIds())) { + comment.setParentIds(parentComment.getParentIds() + "," + parentComment.getId()); + }else { + comment.setParentIds(parentComment.getId() + ""); + } + } + + this.save(comment); + + //1 新闻 2 新闻评论 + Integer type = ObjectUtil.equal(0L,req.getParentId()) || ObjectUtil.isEmpty(req.getParentId()) ?1: 2; + + //修改评论数(只要针对这个新闻下的评论 新闻评论数都要+1) + newsMapper.updateNews(new News().setId(comment.getLinkId()).setCommentNum(1)); + //新闻评论 所有上级评论数+1 + if (ObjectUtil.equal(2,type)){ + //上级评论ids + List pids = Arrays.stream(comment.getParentIds().split(",")).collect(Collectors.toList()); + + List comments = pids.stream().map(id -> { + Comment comment1 = new Comment().setId(Long.valueOf(id)).setCommentNum(1); + comment1.setUpdateTime(DateUtils.getNowDate()); + return comment1; + } + ).collect(Collectors.toList()); + + this.baseMapper.updateCommentBatch(comments); + } + + //返回结果 + CommentResp commentResp = baseMapper.getCommentResp(comment.getId(),userVo); + + if (commentResp != null){ + + UserVo parentUserVo = new UserVo(comment.getParentUserType(), comment.getParentUserId()); + + Set userVoSet = CollectionUtil.newHashSet(userVo,parentUserVo); + //查询用户信息 + Map userMap = userService.selectUserInfoMap(userVoSet,userVo); + + commentResp.setUserInfo(userMap.get(userVo)); + + commentResp.setParentUserInfo(userMap.get(parentUserVo)); + } + + //推送消息 + pushMessage(req,userVo,true); + + return ResponseData.success(commentResp); + } + + @Autowired + private InteractionMessageRecordService interactionMessageRecordService; + + /** + * 推送消息 + * @param req + * @param userVo + * @param isPush + */ + private void pushMessage(CommentReq req, UserVo userVo, Boolean isPush) { + + InteractionMessageEnums enums = ObjectUtil.equal(0L,req.getParentId())?InteractionMessageEnums.COMMENT_NEWS:InteractionMessageEnums.REPLY_NEWS_COMMENT; + + //关联id + Long linkId = null; + + //接收消息用户 + UserVo sendUserVo = null; + + if (ObjectUtil.equal(0L,req.getParentId())){ + return; + } + + //回复评论 + Comment comment = this.getById(req.getParentId()); + linkId = comment.getLinkId(); + sendUserVo = new UserVo(comment.getUserType(),comment.getUserId()); + + //互动消息 + interactionMessageRecordService.addInteractionMessage(userVo,sendUserVo,PublicCommon.InteractionMessage.评论,linkId,isPush, enums); + + } + + @Autowired + private NewsMapper newsMapper; + + private void updateCommentNum(Long objectId, Integer type, Integer num) { + switch (type){ + case 1: + newsMapper.updateNews(new News().setId(objectId).setCommentNum(num)); + break; + case 2: + this.updateComment(new Comment().setId(objectId).setCommentNum(num)); + break; + default: + throw new IllegalStateException("Unexpected value: " + type); + } + } + + @Override + public ResponseData>> commentPage(CommentPageReq req, UserVo userVo) { + //筛去拉黑与被拉黑用户 + List blockUserList = userService.blockUserList(userVo); + req.setBlockUserList(blockUserList); + + //筛去屏蔽用户 + List shieldUserList = userService.shieldUserList(userVo); + req.setShieldUserList(shieldUserList); + + Page page = this.baseMapper.commentPage(new Page<>(req.getPageNo(),req.getPageSize()),req,userVo); + + if (!page.getRecords().isEmpty()){ + Set userVoSet = page.getRecords().stream().map(resp -> new UserVo(resp.getUserType(), resp.getUserId())).collect(Collectors.toSet()); + Set parentUserVoSet = page.getRecords().stream().map(resp -> new UserVo(resp.getParentUserType(), resp.getParentUserId())).collect(Collectors.toSet()); + + userVoSet.addAll(parentUserVoSet); + + List commentList = twoCommentList(req,userVo,page); + + commentList.stream().forEach(resp->{ + userVoSet.add(new UserVo(resp.getUserType(), resp.getUserId())); + userVoSet.add(new UserVo(resp.getParentUserType(), resp.getParentUserId())); + }); + + + //查询用户信息 + Map userMap = userService.selectUserInfoMap(userVoSet,userVo); + + List userVoList = CollectionUtil.addAllIfNotContains(blockUserList, shieldUserList); + + Map commentNumMap = getCommentNumMap(userVoList,page.getRecords()); + + commentList.stream().forEach(resp->{ + resp.setUserInfo(userMap.get(new UserVo(resp.getUserType(), resp.getUserId()))); + resp.setParentUserInfo(userMap.get(new UserVo(resp.getParentUserType(), resp.getParentUserId()))); + }); + //获取二级评论 + Map> map = commentList.stream().collect(Collectors.groupingBy(CommentPageResp::getParentId));; + + + page.getRecords().stream().forEach(resp ->{ + resp.setUserInfo(userMap.get(new UserVo(resp.getUserType(), resp.getUserId()))); + resp.setParentUserInfo(userMap.get(new UserVo(resp.getParentUserType(), resp.getParentUserId()))); + if (commentNumMap.get(resp.getId()) != null){ + resp.setCommentNum(resp.getCommentNum() - commentNumMap.get(resp.getId())); + } + + //二级评论 + resp.setChildrenList(map.get(resp.getId())); + }); + } + + return ResponseData.success(new PageResult<>(page)); + } + + private Map getCommentNumMap(List userVoList, List respList) { + if (userVoList.size() == 0) { + return new HashMap<>(); + } + List commentIds = respList.stream().map(CommentPageResp::getId).collect(Collectors.toList()); + //查询用户对应评论的数量 key一级评论id value 隐藏数量 + List commentNums = commentMapper.selectCommentNumList(commentIds, userVoList); + + Map commentNumMap = new HashMap<>(); + commentNums.stream().forEach(s->{ + commentNumMap.put(s.getWorksId(), s.getCommentNum()); + }); + return commentNumMap; + } + + private List twoCommentList(CommentPageReq req, UserVo userVo, Page page) { + + if (ObjectUtil.isEmpty(req.getParentId())){ + //一级评论ID + List parentIds = page.getRecords().stream().map(CommentPageResp::getId).collect(Collectors.toList()); + + if (CollectionUtil.isEmpty(parentIds)){ + return new ArrayList<>(); + } + //查询二级评论 + List worksCommentList = this.baseMapper.commentList(req,userVo,parentIds); + + return worksCommentList; + } + return new ArrayList<>(); + } + + @Override + public ResponseData deleteComment(DeleteCommentReq req, UserVo userVo) { + boolean update = this.lambdaUpdate().set(Comment::getDelFlag, PublicCommon.删除) + .eq(Comment::getUserType,userVo.getUserType()) + .eq(Comment::getUserId, userVo.getUserId()) + .eq(Comment::getId, req.getId()) + .eq(Comment::getDelFlag, PublicCommon.启用).update(); + + if (update){ + afterDeleteComment(req.getId()); + } + return ResponseData.success(); + } + + private void afterDeleteComment(Long objectId) { + + Comment comment = this.getById(objectId); + + //1 新闻 2 新闻评论 + Integer type = ObjectUtil.equal(0L,comment.getParentId())?1: 2; + + Integer num = - (comment.getCommentNum() + 1); + //帖子评论 上级数量 + if (ObjectUtil.equal(2, type)){ + //当前评论上级ids + List pids = Arrays.stream(comment.getParentIds() + .split(",")).collect(Collectors.toList()); + num = -1 * pids.size() ; + + //上级评论数都要减去当前删除评论数 + 1(本身评论) + List comments = pids.stream().map(id -> { + Comment comment1 = new Comment().setId(Long.valueOf(id)).setCommentNum(-1 * (comment.getCommentNum() + 1)); + comment1.setUpdateTime(DateUtils.getNowDate()); + return comment1; + }).collect(Collectors.toList()); + + this.baseMapper.updateCommentBatch(comments); + } + this.lambdaUpdate().set(Comment::getDelFlag, PublicCommon.删除) + .like(Comment::getParentIds, objectId) + .eq(Comment::getDelFlag, PublicCommon.启用).update(); + + + //修改评论数 + newsMapper.updateNews(new News().setId(comment.getLinkId()).setCommentNum(num)); + } + + /** + * 批量删除评论(新闻) + * + * @param ids 需要删除的评论(新闻)主键 + * @return 结果 + */ + @Override + public int deleteCommentByIds(Long[] ids, Integer delFlag) { + + if (PublicCommon.删除.equals(delFlag)) { + for (Long objectId : ids) { + afterDeleteComment(objectId); + } + } + + this.lambdaUpdate().set(Comment::getDelFlag, delFlag).in(Comment::getId, ids).update(); + return 1; + } + + @Override + public ResponseData commentDetail(Long id, UserVo userVo) { + CommentResp commentResp = baseMapper.getCommentResp(id,userVo); + + if (commentResp != null){ + + UserVo parentUserVo = new UserVo(commentResp.getParentUserType(), commentResp.getParentUserId()); + UserVo user = new UserVo(commentResp.getUserType(), commentResp.getUserId()); + + Set userVoSet = CollectionUtil.newHashSet(user,parentUserVo); + //查询用户信息 + Map userMap = userService.selectUserInfoMap(userVoSet,userVo); + + commentResp.setUserInfo(userMap.get(user)); + + commentResp.setParentUserInfo(userMap.get(parentUserVo)); + } + return ResponseData.success(commentResp); + } + + @Override + public ResponseData>> commentDialoguePage(DialoguePageReq req, UserVo userVo) { + Page page = this.baseMapper.commentDialoguePage(new Page<>(req.getPageNo(),req.getPageSize()),req,userVo); + + if (!page.getRecords().isEmpty()){ + Set userVoSet = page.getRecords().stream().map(postPageResp -> new UserVo(postPageResp.getUserType(), postPageResp.getUserId())).collect(Collectors.toSet()); + Set parentUserVoSet = page.getRecords().stream().map(postPageResp -> new UserVo(postPageResp.getParentUserType(), postPageResp.getParentUserId())).collect(Collectors.toSet()); + + userVoSet.addAll(parentUserVoSet); + + //查询用户信息 + Map userMap = userService.selectUserInfoMap(userVoSet,userVo); + + page.getRecords().stream().forEach(resp ->{ + resp.setUserInfo(userMap.get(new UserVo(resp.getUserType(), resp.getUserId()))); + resp.setParentUserInfo(userMap.get(new UserVo(resp.getParentUserType(), resp.getParentUserId()))); + }); + } + + return ResponseData.success(new PageResult<>(page)); + } +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/follow/controller/FollowController.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/follow/controller/FollowController.java new file mode 100644 index 0000000..98f4528 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/follow/controller/FollowController.java @@ -0,0 +1,97 @@ +package com.ruoyi.frequency.follow.controller; + +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.page.TableDataInfo; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.common.utils.poi.ExcelUtil; +import com.ruoyi.frequency.follow.entity.Follow; +import com.ruoyi.frequency.follow.service.FollowService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +/** + * 关注Controller + * + * @author liwenlong + * @date 2023-07-22 + */ +@RestController +@RequestMapping("/frequency/follow") +public class FollowController extends BaseController +{ + @Autowired + private FollowService followService; + + /** + * 查询关注列表 + */ +// @PreAuthorize("@ss.hasPermi('frequency:follow:list')") + @PostMapping("/list") + public TableDataInfo list(@RequestBody Follow follow) + { + startPage(); + List list = followService.selectFollowList(follow); + return getDataTable(list); + } + + /** + * 导出关注列表 + */ + @PreAuthorize("@ss.hasPermi('frequency:follow:export')") + @Log(title = "关注", businessType = BusinessType.EXPORT) + @GetMapping("/export") + public AjaxResult export(Follow follow) + { + List list = followService.selectFollowList(follow); + ExcelUtil util = new ExcelUtil(Follow.class); + return util.exportExcel(list, "关注数据"); + } + + /** + * 获取关注详细信息 + */ + @PreAuthorize("@ss.hasPermi('frequency:follow:query')") + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") Long id) + { + return AjaxResult.success(followService.selectFollowById(id)); + } + + /** + * 新增关注 + */ + @PreAuthorize("@ss.hasPermi('frequency:follow:add')") + @Log(title = "关注", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody Follow follow) + { + return toAjax(followService.insertFollow(follow)); + } + + /** + * 修改关注 + */ + @PreAuthorize("@ss.hasPermi('frequency:follow:edit')") + @Log(title = "关注", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody Follow follow) + { + return toAjax(followService.updateFollow(follow)); + } + + /** + * 删除关注 + */ + @PreAuthorize("@ss.hasPermi('frequency:follow:remove')") + @Log(title = "关注", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}") + public AjaxResult remove(@PathVariable Long[] ids) + { + return toAjax(followService.deleteFollowByIds(ids)); + } +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/follow/entity/Follow.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/follow/entity/Follow.java new file mode 100644 index 0000000..f525767 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/follow/entity/Follow.java @@ -0,0 +1,71 @@ +package com.ruoyi.frequency.follow.entity; + +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableName; +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import com.ruoyi.vo.UserInfo; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; + +import java.math.BigDecimal; +import java.util.Date; + +/** + * 关注对象 t_follow + * + * @author liwenlong + * @date 2023-07-22 + */ +@Data +@Accessors(chain = true) +@TableName("t_follow") +public class Follow extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** 主键id */ + private Long id; + + /** 删除标志 1正常 删除 3 禁用 */ + private Integer delFlag; + + /** 关注用户id */ + @Excel(name = "关注用户id") + private Long userId; + + /** 被关注用户id */ + @Excel(name = "被关注用户id") + private Long followerUserId; + + /** 关注用户类型 1 用户 2 表现师 */ + @Excel(name = "关注用户类型 1 用户 2 表现师") + private Integer userType; + + /** 被关注用户类型 1 用户 2 表现师 */ + @Excel(name = "被关注用户类型 1 用户 2 表现师") + private Integer followerUserType; + + @ApiModelProperty(value = "用户信息") + @TableField(exist = false) + private UserInfo userInfo; + + @ApiModelProperty("开始时间") + @TableField(exist = false) + private Date beginTime; + + @ApiModelProperty("结束时间") + @TableField(exist = false) + private Date endTime; + + + @ApiModelProperty(value = "累计订单数") + @TableField(exist = false) + private Integer orderNum; + + @ApiModelProperty(value = "累计金额") + @TableField(exist = false) + private BigDecimal orderAmount; + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/follow/mapper/FollowMapper.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/follow/mapper/FollowMapper.java new file mode 100644 index 0000000..f14f77a --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/follow/mapper/FollowMapper.java @@ -0,0 +1,97 @@ +package com.ruoyi.frequency.follow.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.ruoyi.controller.req.FollowerPageByOther; +import com.ruoyi.controller.resp.FollowPageResp; +import com.ruoyi.frequency.follow.entity.Follow; +import com.ruoyi.vo.UserVo; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * 关注Mapper接口 + * + * @author liwenlong + * @date 2023-07-22 + */ +public interface FollowMapper extends BaseMapper +{ + /** + * 查询关注 + * + * @param id 关注主键 + * @return 关注 + */ + public Follow selectFollowById(Long id); + + /** + * 查询关注列表 + * + * @param follow 关注 + * @return 关注集合 + */ + public List selectFollowList(Follow follow); + + /** + * 新增关注 + * + * @param follow 关注 + * @return 结果 + */ + public int insertFollow(Follow follow); + + /** + * 修改关注 + * + * @param follow 关注 + * @return 结果 + */ + public int updateFollow(Follow follow); + + /** + * 删除关注 + * + * @param id 关注主键 + * @return 结果 + */ + public int deleteFollowById(Long id); + + /** + * 批量删除关注 + * + * @param ids 需要删除的数据主键集合 + * @return 结果 + */ + public int deleteFollowByIds(Long[] ids); + + /** + * + * @param objectPage + * @param userVo 查询这个关注的用户 + * @param queryUserVo 当前查询用户 + * @return + */ + Page followerPageBySelf(@Param("page") Page objectPage, @Param("userVo") UserVo userVo, @Param("queryUserVo") UserVo queryUserVo, @Param("req") FollowerPageByOther req); + + + /** + *查询未关注列表 + * @param objectPage + * @param userVo 查询这个关注的用户 + * @param queryUserVo 当前查询用户 + * @return + */ + Page notFollowerPageBySelf(@Param("page") Page objectPage, @Param("userVo") UserVo userVo, @Param("queryUserVo") UserVo queryUserVo, @Param("req") FollowerPageByOther req); + + + /** + * + * @param objectPage + * @param userVo 查询这个关注的用户 + * @return + */ + Page fansPageBySelf(@Param("page") Page objectPage, @Param("userVo") UserVo userVo, @Param("req") FollowerPageByOther req); + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/follow/mapper/mapping/FollowMapper.xml b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/follow/mapper/mapping/FollowMapper.xml new file mode 100644 index 0000000..a5ad315 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/follow/mapper/mapping/FollowMapper.xml @@ -0,0 +1,422 @@ + + + + + + + + + + + + + + + + + + + + + SELECT + t.id, + t.create_by, + t.create_time, + t.update_by, + t.update_time, + t.del_flag, + t.user_id, + t.follower_user_id, + t.follower_user_type, + t.user_type, + case t.user_type + when 1 + then (select count(1) from t_order o where o.customer_id = t.user_id and o.status >= 4) + when 2 + then (select count(1) from t_order o where o.store_id = t.user_id and o.status >= 4) + else 0 end orderNum, + case t.user_type + when 1 + then ifnull((select sum(o.amount) from t_order o where o.customer_id = t.user_id and o.status >= 4),0) + when 2 + then ifnull((select sum(o.amount) from t_order o where o.store_id = t.user_id and o.status >= 4),0) + else 0 end orderAmount + FROM + t_follow AS t + LEFT JOIN t_store s on t.user_id = s.id and t.user_type = 2 + LEFT JOIN t_customer c on t.user_id = c.id and t.user_type = 1 + LEFT JOIN t_sale sa on t.user_id = sa.id and t.user_type = 3 + LEFT JOIN t_enterprise e on t.user_id = e.id and t.user_type = 4 + LEFT JOIN t_store es on e.id = es.bind_enterprise_id and t.user_type = 4 + + + + + + + + insert into t_follow + + id, + create_by, + create_time, + update_by, + update_time, + del_flag, + user_id, + follower_user_id, + user_type, + follower_user_type, + + + #{id}, + #{createBy}, + #{createTime}, + #{updateBy}, + #{updateTime}, + #{delFlag}, + #{userId}, + #{followerUserId}, + #{userType}, + #{followerUserType}, + + + + + update t_follow + + create_by = #{createBy}, + create_time = #{createTime}, + update_by = #{updateBy}, + update_time = #{updateTime}, + del_flag = #{delFlag}, + user_id = #{userId}, + follower_user_id = #{followerUserId}, + user_type = #{userType}, + follower_user_type = #{followerUserType}, + + where id = #{id} + + + + delete from t_follow where id = #{id} + + + + delete from t_follow where id in + + #{id} + + + + + + + + + + \ No newline at end of file diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/follow/model/param/FollowParam.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/follow/model/param/FollowParam.java new file mode 100644 index 0000000..c770a88 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/follow/model/param/FollowParam.java @@ -0,0 +1,49 @@ +package com.ruoyi.frequency.follow.model.param; + +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import lombok.Data; +import lombok.experimental.Accessors; + +/** + * 关注对象 t_follow + * + * @author liwenlong + * @date 2023-07-22 + */ +@Data +@Accessors(chain = true) +public class FollowParam extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** 主键id */ + private Long id; + + /** 删除标志 1正常 删除 3 禁用 */ + private Integer delFlag; + + /** 关注用户id */ + @Excel(name = "关注用户id") + private Long userId; + + /** 被关注用户id */ + @Excel(name = "被关注用户id") + private Long followerUserId; + + /** 关注用户类型 1 用户 2 表现师 */ + @Excel(name = "关注用户类型 1 用户 2 表现师") + private Integer userType; + + /** 被关注用户类型 1 用户 2 表现师 */ + @Excel(name = "被关注用户类型 1 用户 2 表现师") + private Integer followerUserType; + + + + + + + + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/follow/model/result/FollowResult.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/follow/model/result/FollowResult.java new file mode 100644 index 0000000..577cf00 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/follow/model/result/FollowResult.java @@ -0,0 +1,43 @@ +package com.ruoyi.frequency.follow.model.result; + +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import lombok.Data; +import lombok.experimental.Accessors; + +/** + * 关注对象 t_follow + * + * @author liwenlong + * @date 2023-07-22 + */ +@Data +@Accessors(chain = true) +public class FollowResult extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** 主键id */ + private Long id; + + /** 删除标志 1正常 删除 3 禁用 */ + private Integer delFlag; + + /** 关注用户id */ + @Excel(name = "关注用户id") + private Long userId; + + /** 被关注用户id */ + @Excel(name = "被关注用户id") + private Long followerUserId; + + /** 关注用户类型 1 用户 2 表现师 */ + @Excel(name = "关注用户类型 1 用户 2 表现师") + private Integer userType; + + /** 被关注用户类型 1 用户 2 表现师 */ + @Excel(name = "被关注用户类型 1 用户 2 表现师") + private Integer followerUserType; + + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/follow/service/FollowService.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/follow/service/FollowService.java new file mode 100644 index 0000000..12053f4 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/follow/service/FollowService.java @@ -0,0 +1,117 @@ +package com.ruoyi.frequency.follow.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.ruoyi.common.page.PageResult; +import com.ruoyi.controller.req.FollowUserReq; +import com.ruoyi.controller.req.FollowerPageByOther; +import com.ruoyi.controller.resp.FollowPageResp; +import com.ruoyi.frequency.follow.entity.Follow; +import com.ruoyi.response.ResponseData; +import com.ruoyi.vo.UserVo; + +import java.util.List; + +/** + * 关注Service接口 + * + * @author liwenlong + * @date 2023-07-22 + */ +public interface FollowService extends IService +{ + /** + * 查询关注 + * + * @param id 关注主键 + * @return 关注 + */ + public Follow selectFollowById(Long id); + + /** + * 查询关注列表 + * + * @param follow 关注 + * @return 关注集合 + */ + public List selectFollowList(Follow follow); + + /** + * 新增关注 + * + * @param follow 关注 + * @return 结果 + */ + public int insertFollow(Follow follow); + + /** + * 修改关注 + * + * @param follow 关注 + * @return 结果 + */ + public int updateFollow(Follow follow); + + /** + * 批量删除关注 + * + * @param ids 需要删除的关注主键集合 + * @return 结果 + */ + public int deleteFollowByIds(Long[] ids); + + /** + * 删除关注信息 + * + * @param id 关注主键 + * @return 结果 + */ + public int deleteFollowById(Long id); + + /** + * 关注用户 + * @param req + * @param userVo + * @return + */ + ResponseData followUser(FollowUserReq req, UserVo userVo); + + /** + * 关注列表(自己看) + * @param req + * @param userVo + * @return + */ + ResponseData followerPageBySelf(FollowerPageByOther req, UserVo userVo); + + /** + * 关注列表(别人看) + * @param req + * @param userVo + * @return + */ + ResponseData followerPageByOther(FollowerPageByOther req, UserVo userVo); + + /** + * 粉丝列表(自己看) + * @param req + * @param userVo + * @return + */ + ResponseData fansPageBySelf(FollowerPageByOther req, UserVo userVo); + + /** + * 粉丝列表(别人看) + * @param req + * @param userVo + * @return + */ + ResponseData fansPageByOther(FollowerPageByOther req, UserVo userVo); + + /** + * 查询未关注列表 + * @param req + * @param userVo + * @return + */ + ResponseData> notFollowerPageBySelf(FollowerPageByOther req, UserVo userVo); +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/follow/service/impl/FollowServiceImpl.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/follow/service/impl/FollowServiceImpl.java new file mode 100644 index 0000000..2d2e4c0 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/follow/service/impl/FollowServiceImpl.java @@ -0,0 +1,334 @@ +package com.ruoyi.frequency.follow.service.impl; + +import cn.hutool.core.util.ObjectUtil; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.ruoyi.code.PublicCommon; +import com.ruoyi.common.page.PageResult; +import com.ruoyi.common.utils.DateUtils; +import com.ruoyi.common.utils.SecurityUtils; +import com.ruoyi.controller.req.FollowUserReq; +import com.ruoyi.controller.req.FollowerPageByOther; +import com.ruoyi.controller.resp.FollowPageResp; +import com.ruoyi.enums.message.InteractionMessageEnums; +import com.ruoyi.enums.user.UserEnums; +import com.ruoyi.frequency.customer.service.UserService; +import com.ruoyi.frequency.enterprise.entity.Enterprise; +import com.ruoyi.frequency.enterprise.service.EnterpriseService; +import com.ruoyi.frequency.follow.entity.Follow; +import com.ruoyi.frequency.follow.mapper.FollowMapper; +import com.ruoyi.frequency.follow.service.FollowService; +import com.ruoyi.message.frequency.interactionmessagerecord.service.InteractionMessageRecordService; +import com.ruoyi.response.ResponseData; +import com.ruoyi.vo.UserInfo; +import com.ruoyi.vo.UserVo; +import io.swagger.annotations.ApiModelProperty; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.*; +import java.util.stream.Collectors; + +/** + * 关注Service业务层处理 + * + * @author liwenlong + * @date 2023-07-22 + */ +@Service +public class FollowServiceImpl extends ServiceImpl implements FollowService +{ + @Autowired + private FollowMapper followMapper; + + /** + * 查询关注 + * + * @param id 关注主键 + * @return 关注 + */ + @Override + public Follow selectFollowById(Long id) + { + return followMapper.selectFollowById(id); + } + + @Autowired + private EnterpriseService enterpriseService; + /** + * 查询关注列表 + * + * @param follow 关注 + * @return 关注 + */ + @Override + public List selectFollowList(Follow follow) + { + + if (SecurityUtils.hasRoleKey("enterprise")){ + Enterprise enterprise = enterpriseService.getOne(new QueryWrapper().lambda() + .ne(Enterprise::getDelFlag, PublicCommon.删除) + .eq(Enterprise::getSysUserId, SecurityUtils.getUserId())); + if (enterprise == null){ + return new ArrayList<>(); + } + follow.setFollowerUserType(UserEnums.enterprise.getCode()); + follow.setFollowerUserId(enterprise.getId()); + }else { + return new ArrayList<>(); + } + List follows = followMapper.selectFollowList(follow); + + if (!follows.isEmpty()){ + Set userVoSet = follows.stream().map(s -> new UserVo(s.getUserType(), s.getUserId())).collect(Collectors.toSet()); + //查询用户信息 + Map userMap = userService.selectUserInfoMap(userVoSet,null); + + follows.stream().forEach(s ->{ + s.setUserInfo(userMap.get(new UserVo(s.getUserType(), s.getUserId()))); + }); + } + return follows; + } + + /** + * 新增关注 + * + * @param follow 关注 + * @return 结果 + */ + @Override + public int insertFollow(Follow follow) + { + follow.setCreateTime(DateUtils.getNowDate()); + return followMapper.insertFollow(follow); + } + + /** + * 修改关注 + * + * @param follow 关注 + * @return 结果 + */ + @Override + public int updateFollow(Follow follow) + { + follow.setUpdateTime(DateUtils.getNowDate()); + return followMapper.updateFollow(follow); + } + + /** + * 批量删除关注 + * + * @param ids 需要删除的关注主键 + * @return 结果 + */ + @Override + public int deleteFollowByIds(Long[] ids) + { + return followMapper.deleteFollowByIds(ids); + } + + /** + * 删除关注信息 + * + * @param id 关注主键 + * @return 结果 + */ + @Override + public int deleteFollowById(Long id) + { + return followMapper.deleteFollowById(id); + } + + + @Override + public ResponseData followUser(FollowUserReq req, UserVo userVo) { + + //查询数据是否存在 + Follow follow = this.getOne(new QueryWrapper().lambda() + .eq(Follow::getUserType, userVo.getUserType()) + .eq(Follow::getUserId, userVo.getUserId()) + .eq(Follow::getFollowerUserType, req.getUserType()) + .eq(Follow::getFollowerUserId, req.getUserId()) + ); + + //是否关注 + boolean isFollow = false; + + if (follow == null){ + follow = new Follow().setUserId(userVo.getUserId()) + .setUserType(userVo.getUserType()) + .setFollowerUserId(req.getUserId()) + .setFollowerUserType(req.getUserType()); + follow.setUpdateTime(new Date()); + this.save(follow); + + //关注 + isFollow = true; + }else { + //是否关注 + isFollow = ObjectUtil.notEqual(PublicCommon.启用,follow.getDelFlag()); + + this.lambdaUpdate().set(Follow::getDelFlag,isFollow? PublicCommon.启用:PublicCommon.删除 ) + .eq(Follow::getId,follow.getId()).update(); + } + + //互动消息 + pushMessage(req,userVo,isFollow); + + return ResponseData.success(); + } + + @Autowired + private InteractionMessageRecordService interactionMessageRecordService; + + /** + * 推送消息 + * @param req + * @param userVo + * @param isPush + */ + private void pushMessage(FollowUserReq req, UserVo userVo, Boolean isPush) { + + InteractionMessageEnums enums = InteractionMessageEnums.FOLLOW; + + Long userId = req.getUserId(); + + //互动消息 + interactionMessageRecordService.addInteractionMessage(userVo,new UserVo(req.getUserType(),req.getUserId()),PublicCommon.InteractionMessage.关注,userId,isPush, enums); + + } + + @Autowired + private UserService userService; + + @Override + public ResponseData followerPageBySelf(FollowerPageByOther req, UserVo userVo) { + + //筛去拉黑与被拉黑用户 +// List blockUserList = userService.blockUserList(userVo); +// req.setBlockUserList(blockUserList); +// +// //筛去屏蔽用户 +// List shieldUserList = userService.shieldUserList(userVo); +// req.setShieldUserList(shieldUserList); + + Page page = baseMapper.followerPageBySelf(new Page<>(req.getPageNo(), req.getPageSize()), userVo,userVo,req); + + if (!page.getRecords().isEmpty()){ + Set userVoSet = page.getRecords().stream().map(resp -> new UserVo(resp.getUserType(), resp.getUserId())).collect(Collectors.toSet()); + //查询用户信息 + Map userMap = userService.selectUserInfoMap(userVoSet,userVo); + + page.getRecords().stream().forEach(resp ->{ + resp.setUserInfo(userMap.get(new UserVo(resp.getUserType(), resp.getUserId()))); + }); + } + + return ResponseData.success(new PageResult<>(page)); + } + + @Override + public ResponseData followerPageByOther(FollowerPageByOther req, UserVo userVo) { + //筛去拉黑与被拉黑用户 +// List blockUserList = userService.blockUserList(userVo); +// req.setBlockUserList(blockUserList); +// +// //筛去屏蔽用户 +// List shieldUserList = userService.shieldUserList(userVo); +// req.setShieldUserList(shieldUserList); + + Page page = baseMapper.followerPageBySelf(new Page<>(req.getPageNo(), req.getPageSize()), new UserVo(req.getUserType(),req.getUserId()),userVo,req); + + if (!page.getRecords().isEmpty()){ + Set userVoSet = page.getRecords().stream().map(resp -> new UserVo(resp.getUserType(), resp.getUserId())).collect(Collectors.toSet()); + //查询用户信息 + Map userMap = userService.selectUserInfoMap(userVoSet,userVo); + + page.getRecords().stream().forEach(resp ->{ + resp.setUserInfo(userMap.get(new UserVo(resp.getUserType(), resp.getUserId()))); + }); + } + + return ResponseData.success(new PageResult<>(page)); + } + + @Override + public ResponseData fansPageBySelf(FollowerPageByOther req, UserVo userVo) { + + //筛去拉黑与被拉黑用户 +// List blockUserList = userService.blockUserList(userVo); +// req.setBlockUserList(blockUserList); +// +// //筛去屏蔽用户 +// List shieldUserList = userService.shieldUserList(userVo); +// req.setShieldUserList(shieldUserList); + + Page page = baseMapper.fansPageBySelf(new Page<>(req.getPageNo(), req.getPageSize()), userVo,req); + if (!page.getRecords().isEmpty()){ + Set userVoSet = page.getRecords().stream().map(resp -> new UserVo(resp.getUserType(), resp.getUserId())).collect(Collectors.toSet()); + //查询用户信息 + Map userMap = userService.selectUserInfoMap(userVoSet,userVo); + + page.getRecords().stream().forEach(resp ->{ + resp.setUserInfo(userMap.get(new UserVo(resp.getUserType(), resp.getUserId()))); + }); + } + + return ResponseData.success(new PageResult<>(page)); + } + + @Override + public ResponseData fansPageByOther(FollowerPageByOther req, UserVo userVo) { + + //筛去拉黑与被拉黑用户 +// List blockUserList = userService.blockUserList(userVo); +// req.setBlockUserList(blockUserList); +// +// //筛去屏蔽用户 +// List shieldUserList = userService.shieldUserList(userVo); +// req.setShieldUserList(shieldUserList); + + Page page = baseMapper.fansPageBySelf(new Page<>(req.getPageNo(), req.getPageSize()), new UserVo(req.getUserType(),req.getUserId()),req); + + if (!page.getRecords().isEmpty()){ + Set userVoSet = page.getRecords().stream().map(resp -> new UserVo(resp.getUserType(), resp.getUserId())).collect(Collectors.toSet()); + //查询用户信息 + Map userMap = userService.selectUserInfoMap(userVoSet,userVo); + + page.getRecords().stream().forEach(resp ->{ + resp.setUserInfo(userMap.get(new UserVo(resp.getUserType(), resp.getUserId()))); + }); + } + + return ResponseData.success(new PageResult<>(page)); + } + + @Override + public ResponseData> notFollowerPageBySelf(FollowerPageByOther req, UserVo userVo) { + + //筛去拉黑与被拉黑用户 + List blockUserList = userService.blockUserList(userVo); + req.setBlockUserList(blockUserList); + + //筛去屏蔽用户 + List shieldUserList = userService.shieldUserList(userVo); + req.setShieldUserList(shieldUserList); + + Page page = baseMapper.notFollowerPageBySelf(new Page<>(req.getPageNo(), req.getPageSize()), userVo,userVo,req); + + if (!page.getRecords().isEmpty()){ + Set userVoSet = page.getRecords().stream().map(resp -> new UserVo(resp.getUserType(), resp.getUserId())).collect(Collectors.toSet()); + //查询用户信息 + Map userMap = userService.selectUserInfoMap(userVoSet,userVo); + + page.getRecords().stream().forEach(resp ->{ + resp.setUserInfo(userMap.get(new UserVo(resp.getUserType(), resp.getUserId()))); + }); + } + + return ResponseData.success(new PageResult<>(page)); + } +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/highendauth/controller/HighendAuthController.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/highendauth/controller/HighendAuthController.java new file mode 100644 index 0000000..51645e6 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/highendauth/controller/HighendAuthController.java @@ -0,0 +1,130 @@ +package com.ruoyi.frequency.highendauth.controller; + +import java.util.List; + +import com.ruoyi.frequency.auth.entity.Auth; +import com.ruoyi.frequency.auth.model.result.AuthCount; +import com.ruoyi.frequency.highendauth.model.result.HighendAuthCount; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.frequency.highendauth.entity.HighendAuth; +import com.ruoyi.frequency.highendauth.service.HighendAuthService; +import com.ruoyi.common.utils.poi.ExcelUtil; +import com.ruoyi.common.core.page.TableDataInfo; + +/** + * 高端认证Controller + * + * @author liwenlong + * @date 2023-10-20 + */ +@RestController +@RequestMapping("/frequency/highendauth") +public class HighendAuthController extends BaseController +{ + @Autowired + private HighendAuthService highendAuthService; + + /** + * 查询高端认证列表 + */ + @PreAuthorize("@ss.hasPermi('frequency:highendauth:list')") + @PostMapping("/list") + public TableDataInfo list(@RequestBody HighendAuth highendAuth) + { + startPage(); + List list = highendAuthService.selectHighendAuthList(highendAuth); + return getDataTable(list); + } + + /** + * 统计 + */ + @PostMapping("/statistics") + public AjaxResult statistics(@RequestBody HighendAuth highendAuth) + { + HighendAuthCount count = highendAuthService.statistics(highendAuth); + return AjaxResult.success(count); + } + + /** + * 导出高端认证列表 + */ + @PreAuthorize("@ss.hasPermi('frequency:highendauth:export')") + @Log(title = "高端认证", businessType = BusinessType.EXPORT) + @GetMapping("/export") + public AjaxResult export(HighendAuth highendAuth) + { + List list = highendAuthService.selectHighendAuthList(highendAuth); + ExcelUtil util = new ExcelUtil(HighendAuth.class); + return util.exportExcel(list, "高端认证数据"); + } + + /** + * 获取高端认证详细信息 + */ + @PreAuthorize("@ss.hasPermi('frequency:highendauth:query')") + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") Long id) + { + return AjaxResult.success(highendAuthService.selectHighendAuthById(id)); + } + + /** + * 新增高端认证 + */ + @PreAuthorize("@ss.hasPermi('frequency:highendauth:add')") + @Log(title = "高端认证", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody HighendAuth highendAuth) + { + return toAjax(highendAuthService.insertHighendAuth(highendAuth)); + } + + /** + * 完善 + */ + @PreAuthorize("@ss.hasPermi('frequency:highendauth:edit')") + @Log(title = "高端认证", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody HighendAuth highendAuth) + { + return toAjax(highendAuthService.updateHighendAuth(highendAuth)); + } + + + /** + * 删除高端认证 + */ + @PreAuthorize("@ss.hasPermi('frequency:highendauth:remove')") + @Log(title = "高端认证", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}") + public AjaxResult remove(@PathVariable Long[] ids) + { + return toAjax(highendAuthService.deleteHighendAuthByIds(ids)); + } + + + /** + *上传企业微信二维码 + */ + @PreAuthorize("@ss.hasPermi('frequency:highendauth:uploadCode')") + @Log(title = "高端认证", businessType = BusinessType.UPDATE) + @PostMapping("/uploadCode") + public AjaxResult uploadCode(@RequestBody HighendAuth highendAuth) + { + return toAjax(highendAuthService.uploadCode(highendAuth)); + } +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/highendauth/entity/HighendAuth.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/highendauth/entity/HighendAuth.java new file mode 100644 index 0000000..2992f53 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/highendauth/entity/HighendAuth.java @@ -0,0 +1,136 @@ +package com.ruoyi.frequency.highendauth.entity; + +import java.math.BigDecimal; +import java.util.Date; + +import com.baomidou.mybatisplus.annotation.TableField; +import com.fasterxml.jackson.annotation.JsonFormat; +import com.ruoyi.vo.UserInfo; +import lombok.Data; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.experimental.Accessors; +import com.ruoyi.common.annotation.Excel; +import io.swagger.annotations.ApiModelProperty; +import com.ruoyi.common.core.domain.BaseEntity; + +/** + * 高端认证对象 t_highend_auth + * + * @author liwenlong + * @date 2023-10-20 + */ +@Data +@Accessors(chain = true) +@TableName("t_highend_auth") +public class HighendAuth extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + + @ApiModelProperty("租户号") + private Long id; + + @ApiModelProperty("删除标志 1 正常 2 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("认证金额") + @Excel(name = "认证金额") + private BigDecimal amount; + + @ApiModelProperty("状态 1 待完善 2待付款 3待上传企业微信二维码 4") + @Excel(name = "状态 1 待完善 2待付款 3待上传企业微信二维码") + private Integer status; + + @ApiModelProperty("表现师id") + @Excel(name = "表现师id") + private Long storeId; + + @ApiModelProperty("高端认证是否缴纳 1没有 2 缴纳") + @Excel(name = "高端认证是否缴纳 1没有 2 缴纳") + private Integer isPay; + + @ApiModelProperty("高端认证支付单号") + @Excel(name = "高端认证支付单号") + private String payOrderNo; + + @ApiModelProperty("身份证正面") + @Excel(name = "身份证正面") + private String idFront; + + @ApiModelProperty("身份证反面") + @Excel(name = "身份证反面") + private String idBack; + + @ApiModelProperty("手持身份证照片") + @Excel(name = "手持身份证照片") + private String idHandHand; + + @ApiModelProperty("姓名") + @Excel(name = "姓名") + private String name; + + @ApiModelProperty("身份证号码") + @Excel(name = "身份证号码") + private String idcardNo; + + @ApiModelProperty("附件图片") + @Excel(name = "附件图片") + private String images; + + @ApiModelProperty("描述") + private String remark; + + @ApiModelProperty("支付状态 1 待支付 2支付成功 3支付失败") + private Integer payStatus; + + @ApiModelProperty("支付宝支付返回的订单号") + private String aliBusinessId; + + @ApiModelProperty("支付方式 1app支付宝 2 h5支付宝 3 app微信 4 h5微信 5 小程序 6 苹果支付 7 余额") + private Integer payType; + + + @ApiModelProperty("开户行") + @Excel(name = "开户行") + private String bank; + + @ApiModelProperty("开户支行") + @Excel(name = "开户支行") + private String subbranch; + + @ApiModelProperty("银行卡") + @Excel(name = "银行卡") + private String bankCard; + + @ApiModelProperty("性别") + private String sex; + + @ApiModelProperty("用户信息") + @TableField(exist = false) + private UserInfo userInfo; + + @ApiModelProperty("企业微信二维码") + @TableField(exist = false) + private String wecomQrcode; + + @ApiModelProperty("擅长领域") + @Excel(name = "擅长领域") + private String specialityArea; + + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @ApiModelProperty("审核时间") + private Date processTime; + + @ApiModelProperty("工种") + private String branchWork; + + @ApiModelProperty("开始时间") + @TableField(exist = false) + private Date beginTime; + + @ApiModelProperty("结束时间") + @TableField(exist = false) + private Date endTime; + + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/highendauth/mapper/HighendAuthMapper.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/highendauth/mapper/HighendAuthMapper.java new file mode 100644 index 0000000..0541fa1 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/highendauth/mapper/HighendAuthMapper.java @@ -0,0 +1,66 @@ +package com.ruoyi.frequency.highendauth.mapper; + +import java.util.List; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.ruoyi.frequency.highendauth.entity.HighendAuth; +import com.ruoyi.frequency.highendauth.model.result.HighendAuthCount; +import org.apache.ibatis.annotations.Param; + +/** + * 高端认证Mapper接口 + * + * @author liwenlong + * @date 2023-10-20 + */ +public interface HighendAuthMapper extends BaseMapper +{ + /** + * 查询高端认证 + * + * @param id 高端认证主键 + * @return 高端认证 + */ + public HighendAuth selectHighendAuthById(Long id); + + /** + * 查询高端认证列表 + * + * @param highendAuth 高端认证 + * @return 高端认证集合 + */ + public List selectHighendAuthList(HighendAuth highendAuth); + + /** + * 新增高端认证 + * + * @param highendAuth 高端认证 + * @return 结果 + */ + public int insertHighendAuth(HighendAuth highendAuth); + + /** + * 修改高端认证 + * + * @param highendAuth 高端认证 + * @return 结果 + */ + public int updateHighendAuth(HighendAuth highendAuth); + + /** + * 删除高端认证 + * + * @param id 高端认证主键 + * @return 结果 + */ + public int deleteHighendAuthById(Long id); + + /** + * 批量删除高端认证 + * + * @param ids 需要删除的数据主键集合 + * @return 结果 + */ + public int deleteHighendAuthByIds(Long[] ids); + + HighendAuthCount statistics(@Param("list") List highendAuthIdList); +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/highendauth/mapper/mapping/HighendAuthMapper.xml b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/highendauth/mapper/mapping/HighendAuthMapper.xml new file mode 100644 index 0000000..b4ab708 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/highendauth/mapper/mapping/HighendAuthMapper.xml @@ -0,0 +1,225 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + SELECT + t.id, + t.branch_work, + t.create_by, + t.create_time, + t.update_by, + t.update_time, + t.del_flag, + t.amount, + t.`status`, + t.store_id, + t.is_pay, + t.pay_order_no, + t.id_front, + t.id_back, + t.id_hand_hand, + t.`name`, + t.idcard_no, + t.images, + t.remark, + t.pay_status, + t.pay_type, + t.ali_business_id, + t.bank, + t.subbranch, + t.bank_card, + t.speciality_area, + t.process_time, + s.wecom_qrcode + FROM + t_highend_auth AS t + LEFT JOIN t_store AS s ON s.id = t.store_id + + + + + + + + + + + insert into t_highend_auth + + id, + create_by, + create_time, + update_by, + update_time, + del_flag, + amount, + status, + store_id, + is_pay, + pay_order_no, + id_front, + id_back, + id_hand_hand, + name, + idcard_no, + images, + + + #{id}, + #{createBy}, + #{createTime}, + #{updateBy}, + #{updateTime}, + #{delFlag}, + #{amount}, + #{status}, + #{storeId}, + #{isPay}, + #{payOrderNo}, + #{idFront}, + #{idBack}, + #{idHandHand}, + #{name}, + #{idcardNo}, + #{images}, + + + + + update t_highend_auth + + create_by = #{createBy}, + create_time = #{createTime}, + update_by = #{updateBy}, + update_time = #{updateTime}, + del_flag = #{delFlag}, + amount = #{amount}, + status = #{status}, + store_id = #{storeId}, + is_pay = #{isPay}, + pay_order_no = #{payOrderNo}, + id_front = #{idFront}, + id_back = #{idBack}, + id_hand_hand = #{idHandHand}, + name = #{name}, + idcard_no = #{idcardNo}, + images = #{images}, + + where id = #{id} + + + + delete from t_highend_auth where id = #{id} + + + + delete from t_highend_auth where id in + + #{id} + + + diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/highendauth/model/param/HighendAuthParam.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/highendauth/model/param/HighendAuthParam.java new file mode 100644 index 0000000..ca3bcb0 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/highendauth/model/param/HighendAuthParam.java @@ -0,0 +1,86 @@ +package com.ruoyi.frequency.highendauth.model.param; + +import java.math.BigDecimal; +import lombok.Data; +import lombok.experimental.Accessors; +import com.ruoyi.common.annotation.Excel; +import io.swagger.annotations.ApiModelProperty; +import com.ruoyi.common.core.domain.BaseEntity; + +/** + * 高端认证对象 t_highend_auth + * + * @author liwenlong + * @date 2023-10-20 + */ +@Data +@Accessors(chain = true) +public class HighendAuthParam extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + @ApiModelProperty("租户号") + private Long id; + + @ApiModelProperty("删除标志 1 正常 2 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("认证金额") + @Excel(name = "认证金额") + private BigDecimal amount; + + @ApiModelProperty("状态 1 待完善 2待付款 3待上传企业微信二维码") + @Excel(name = "状态 1 待完善 2待付款 3待上传企业微信二维码") + private Integer status; + + @ApiModelProperty("表现师id") + @Excel(name = "表现师id") + private Long storeId; + + @ApiModelProperty("高端认证是否缴纳 1没有 2 缴纳") + @Excel(name = "高端认证是否缴纳 1没有 2 缴纳") + private Integer isPay; + + @ApiModelProperty("高端认证支付单号") + @Excel(name = "高端认证支付单号") + private String payOrderNo; + + @ApiModelProperty("身份证正面") + @Excel(name = "身份证正面") + private String idFront; + + @ApiModelProperty("身份证反面") + @Excel(name = "身份证反面") + private String idBack; + + @ApiModelProperty("手持身份证照片") + @Excel(name = "手持身份证照片") + private String idHandHand; + + @ApiModelProperty("姓名") + @Excel(name = "姓名") + private String name; + + @ApiModelProperty("身份证号码") + @Excel(name = "身份证号码") + private String idcardNo; + + @ApiModelProperty("附件图片") + @Excel(name = "附件图片") + private String images; + + + + + + + + + + + + + + + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/highendauth/model/result/HighendAuthCount.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/highendauth/model/result/HighendAuthCount.java new file mode 100644 index 0000000..66e14b0 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/highendauth/model/result/HighendAuthCount.java @@ -0,0 +1,24 @@ +package com.ruoyi.frequency.highendauth.model.result; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + * @author a + * @date 2024/2/22 10:05 + */ +@Data +public class HighendAuthCount { + + @ApiModelProperty("总人数") + private Integer number; + + @ApiModelProperty("已通过人数") + private Integer passNumber; + + @ApiModelProperty("未通过人数") + private Integer noPassNumber; + + @ApiModelProperty("待审核人数") + private Integer auditNumber; +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/highendauth/model/result/HighendAuthResult.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/highendauth/model/result/HighendAuthResult.java new file mode 100644 index 0000000..476d6d4 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/highendauth/model/result/HighendAuthResult.java @@ -0,0 +1,73 @@ +package com.ruoyi.frequency.highendauth.model.result; + +import java.math.BigDecimal; +import lombok.Data; +import lombok.experimental.Accessors; +import com.ruoyi.common.annotation.Excel; +import io.swagger.annotations.ApiModelProperty; +import com.ruoyi.common.core.domain.BaseEntity; + +/** + * 高端认证对象 t_highend_auth + * + * @author liwenlong + * @date 2023-10-20 + */ +@Data +@Accessors(chain = true) +public class HighendAuthResult extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + @ApiModelProperty("租户号") + private Long id; + + @ApiModelProperty("删除标志 1 正常 2 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("认证金额") + @Excel(name = "认证金额") + private BigDecimal amount; + + @ApiModelProperty("状态 1 待完善 2待付款 3待上传企业微信二维码") + @Excel(name = "状态 1 待完善 2待付款 3待上传企业微信二维码") + private Integer status; + + @ApiModelProperty("表现师id") + @Excel(name = "表现师id") + private Long storeId; + + @ApiModelProperty("高端认证是否缴纳 1没有 2 缴纳") + @Excel(name = "高端认证是否缴纳 1没有 2 缴纳") + private Integer isPay; + + @ApiModelProperty("高端认证支付单号") + @Excel(name = "高端认证支付单号") + private String payOrderNo; + + @ApiModelProperty("身份证正面") + @Excel(name = "身份证正面") + private String idFront; + + @ApiModelProperty("身份证反面") + @Excel(name = "身份证反面") + private String idBack; + + @ApiModelProperty("手持身份证照片") + @Excel(name = "手持身份证照片") + private String idHandHand; + + @ApiModelProperty("姓名") + @Excel(name = "姓名") + private String name; + + @ApiModelProperty("身份证号码") + @Excel(name = "身份证号码") + private String idcardNo; + + @ApiModelProperty("附件图片") + @Excel(name = "附件图片") + private String images; + + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/highendauth/service/HighendAuthService.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/highendauth/service/HighendAuthService.java new file mode 100644 index 0000000..5a90360 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/highendauth/service/HighendAuthService.java @@ -0,0 +1,109 @@ +package com.ruoyi.frequency.highendauth.service; + +import java.util.List; +import java.util.Map; + +import com.ruoyi.controller.req.UpscaleAuthReq; +import com.ruoyi.frequency.highendauth.entity.HighendAuth; +import com.baomidou.mybatisplus.extension.service.IService; +import com.ruoyi.frequency.highendauth.model.result.HighendAuthCount; +import com.ruoyi.response.ResponseData; +import com.ruoyi.vo.UserVo; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +/** + * 高端认证Service接口 + * + * @author liwenlong + * @date 2023-10-20 + */ +public interface HighendAuthService extends IService +{ + /** + * 查询高端认证 + * + * @param id 高端认证主键 + * @return 高端认证 + */ + public HighendAuth selectHighendAuthById(Long id); + + /** + * 查询高端认证列表 + * + * @param highendAuth 高端认证 + * @return 高端认证集合 + */ + public List selectHighendAuthList(HighendAuth highendAuth); + + HighendAuthCount statistics(HighendAuth highendAuth); + + /** + * 新增高端认证 + * + * @param highendAuth 高端认证 + * @return 结果 + */ + public int insertHighendAuth(HighendAuth highendAuth); + + /** + * 修改高端认证 + * + * @param highendAuth 高端认证 + * @return 结果 + */ + public int updateHighendAuth(HighendAuth highendAuth); + + /** + * 批量删除高端认证 + * + * @param ids 需要删除的高端认证主键集合 + * @return 结果 + */ + public int deleteHighendAuthByIds(Long[] ids); + + /** + * 删除高端认证信息 + * + * @param id 高端认证主键 + * @return 结果 + */ + public int deleteHighendAuthById(Long id); + + /** + * 上传企业微信二维码 + * @param highendAuth + * @return + */ + int uploadCode(HighendAuth highendAuth); + + + /** + * 高端认证 + * @param req + * @param userVo + * @return + */ + ResponseData highendAuth(UpscaleAuthReq req, UserVo userVo); + + + /** + * 支付宝回调 + * @param request + * @param response + * @return + */ + ResponseData highendAuthAliNotify(HttpServletRequest request, HttpServletResponse response); + + + /** + * 微信回调 + * @param request + * @param response + * @return + */ + ResponseData highendAuthWxNotify(HttpServletRequest request, HttpServletResponse response); + + ResponseData highendAuthLakalaNotify(Map paramMap); +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/highendauth/service/impl/HighendAuthServiceImpl.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/highendauth/service/impl/HighendAuthServiceImpl.java new file mode 100644 index 0000000..c3cb1d7 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/highendauth/service/impl/HighendAuthServiceImpl.java @@ -0,0 +1,490 @@ +package com.ruoyi.frequency.highendauth.service.impl; + +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.date.DateUtil; +import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.RandomUtil; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.ruoyi.code.DictConstant; +import com.ruoyi.code.PublicCommon; +import com.ruoyi.common.core.domain.entity.SysDictData; +import com.ruoyi.common.exception.CustomException; +import com.ruoyi.common.utils.DateUtils; +import com.ruoyi.controller.req.UpscaleAuthReq; +import com.ruoyi.enums.PlatformRecordEnums; +import com.ruoyi.enums.WalletDetailEnums; +import com.ruoyi.enums.process.ProcessResultEnums; +import com.ruoyi.enums.user.UserEnums; +import com.ruoyi.frequency.auth.entity.Auth; +import com.ruoyi.frequency.auth.mapper.AuthMapper; +import com.ruoyi.frequency.customer.service.UserService; +import com.ruoyi.frequency.highendauth.entity.HighendAuth; +import com.ruoyi.frequency.highendauth.mapper.HighendAuthMapper; +import com.ruoyi.frequency.highendauth.model.result.HighendAuthCount; +import com.ruoyi.frequency.highendauth.service.HighendAuthService; +import com.ruoyi.frequency.onlinerecord.service.OnlineRecordService; +import com.ruoyi.frequency.platformrecord.service.PlatformRecordService; +import com.ruoyi.frequency.store.entity.Store; +import com.ruoyi.frequency.store.service.StoreService; +import com.ruoyi.pay.enums.PayEnums; +import com.ruoyi.pay.enums.PaySourceEnums; +import com.ruoyi.pay.utils.AlipayCore; +import com.ruoyi.pay.utils.HttpRequestUtil; +import com.ruoyi.pay.utils.PayUtil; +import com.ruoyi.response.ResponseData; +import com.ruoyi.utils.BusinessUtil; +import com.ruoyi.vo.UserInfo; +import com.ruoyi.vo.UserVo; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.math.BigDecimal; +import java.util.*; +import java.util.stream.Collectors; + +/** + * 高端认证Service业务层处理 + * + * @author liwenlong + * @date 2023-10-20 + */ +@Service +@Transactional(rollbackFor = Exception.class) +@Slf4j +public class HighendAuthServiceImpl extends ServiceImpl implements HighendAuthService { + @Autowired + private HighendAuthMapper highendAuthMapper; + + @Autowired + private UserService userService; + + /** + * 查询高端认证 + * + * @param id 高端认证主键 + * @return 高端认证 + */ + @Override + public HighendAuth selectHighendAuthById(Long id) { + HighendAuth auth = highendAuthMapper.selectHighendAuthById(id); + + if (auth != null) { + Set userVoSet = new HashSet<>(); + + userVoSet.add(new UserVo(UserEnums.store.getCode(), auth.getStoreId())); + + //查询用户信息 + Map userMap = userService.selectUserInfoMap(userVoSet, null); + + auth.setUserInfo(userMap.get(new UserVo(UserEnums.store.getCode(), auth.getStoreId()))); + } + return auth; + } + + /** + * 查询高端认证列表 + * + * @param highendAuth 高端认证 + * @return 高端认证 + */ + @Override + public List selectHighendAuthList(HighendAuth highendAuth) { + + List highendAuths = highendAuth(highendAuth); + + if (highendAuths != null && highendAuths.size() > 0) { + + Set userVoSet = highendAuths.stream().map(s -> new UserVo(UserEnums.store.getCode(), s.getStoreId())).collect(Collectors.toSet()); + //查询用户信息 + Map userMap = userService.selectUserInfoMap(userVoSet, null); + + highendAuths.stream().forEach(s -> { + s.setUserInfo(userMap.get(new UserVo(UserEnums.store.getCode(), s.getStoreId()))); + }); + } + + return highendAuths; + } + + private List highendAuth(HighendAuth highendAuth) { + List highendAuths = highendAuthMapper.selectHighendAuthList(highendAuth); + return highendAuths; + } + + @Override + public HighendAuthCount statistics(HighendAuth highendAuth) { + List highendAuths = highendAuth(highendAuth); + List highendAuthIdList = highendAuths.stream().map(x -> x.getId()).collect(Collectors.toList()); + highendAuthIdList.add(-1L); + + return highendAuthMapper.statistics(highendAuthIdList); + } + + @Autowired + private AuthMapper authMapper; + + /** + * 新增高端认证 + * + * @param highendAuth 高端认证 + * @return 结果 + */ + @Override + public int insertHighendAuth(HighendAuth highendAuth) { + + Auth auth = authMapper.selectOne(new QueryWrapper().lambda() + .eq(Auth::getType, 3) + .eq(Auth::getStoreId, highendAuth.getStoreId()) + .eq(Auth::getDelFlag, PublicCommon.启用) + ); + + //判断是否进行酷家乐认证 + if (auth != null && ObjectUtil.isNotEmpty(auth.getResult())) { + if (auth.getResult().equals(ProcessResultEnums.PENDING.getCode())) { + throw new CustomException("您正在进行酷家乐认证,请勿重复申请"); + } else if (auth.getResult().equals(ProcessResultEnums.APPROVED.getCode())) { + throw new CustomException("您已进行酷家乐认证,请勿重复认证"); + } + } + + int count = this.count(new QueryWrapper().lambda() + .eq(HighendAuth::getDelFlag, PublicCommon.启用) + .eq(HighendAuth::getStoreId, highendAuth.getStoreId())); + //判断表现师是否重复创建 + if (count > 0) { + throw new CustomException("表现师已存在"); + } + + highendAuth.setCreateTime(DateUtils.getNowDate()); + + //查询普通认证信息 + Auth authCommon = authMapper.selectOne(new QueryWrapper().lambda() + .eq(Auth::getType, 1) + .eq(Auth::getStoreId, highendAuth.getStoreId()) + .eq(Auth::getDelFlag, PublicCommon.启用).last(" limit 1") + ); + if (authCommon != null) { + highendAuth.setName(authCommon.getName()); + highendAuth.setIdcardNo(authCommon.getIdcardNo()); + highendAuth.setSpecialityArea(authCommon.getSpecialityArea()); + highendAuth.setIdFront(authCommon.getIdFront()); + highendAuth.setIdBack(authCommon.getIdBack()); + highendAuth.setIdHandHand(authCommon.getIdHandHand()); + highendAuth.setBranchWork(authCommon.getBranchWork()); + } + + return highendAuthMapper.insert(highendAuth); + } + + /** + * 修改高端认证 + * + * @param highendAuth 高端认证 + * @return 结果 + */ + @Override + public int updateHighendAuth(HighendAuth highendAuth) { + highendAuth.setUpdateTime(DateUtils.getNowDate()); + highendAuth.setStatus(2); + return highendAuthMapper.updateById(highendAuth); + } + + /** + * 批量删除高端认证 + * + * @param ids 需要删除的高端认证主键 + * @return 结果 + */ + @Override + public int deleteHighendAuthByIds(Long[] ids) { + this.lambdaUpdate().set(HighendAuth::getDelFlag, PublicCommon.删除).in(HighendAuth::getId, ids).update(); + return ids.length; + } + + /** + * 删除高端认证信息 + * + * @param id 高端认证主键 + * @return 结果 + */ + @Override + public int deleteHighendAuthById(Long id) { + this.lambdaUpdate().set(HighendAuth::getDelFlag, PublicCommon.删除).eq(HighendAuth::getId, id).update(); + return 1; + } + + @Autowired + private StoreService storeService; + + @Override + public int uploadCode(HighendAuth highendAuth) { + HighendAuth h = this.getById(highendAuth.getId()); + + this.lambdaUpdate().set(HighendAuth::getStatus, 4).eq(HighendAuth::getId, h.getId()).update(); + + storeService.lambdaUpdate().set(Store::getWecomQrcode, highendAuth.getWecomQrcode()).eq(Store::getId, h.getStoreId()).update(); + + return 1; + } + + @Autowired + private BusinessUtil businessUtil; + + @Autowired + private PayUtil payUtil; + + @Override + public ResponseData highendAuth(UpscaleAuthReq req, UserVo userVo) { + + userService.storeByEnterprise(userVo); + + //判断认证状态 + HighendAuth auth = judgeAuthStatus(userVo); + + //判断已支付/未支付 认证金额 + Boolean isPay = auth == null || auth.getIsPay() == 1; + + BeanUtil.copyProperties(req, auth); + auth.setStoreId(userVo.getUserId()) + .setIsPay(isPay ? 1 : 2);//是否缴纳 1没有 2 缴纳 + return payAuth(auth, req, userVo); + } + + private ResponseData noPayAuth(HighendAuth auth) { + this.updateById(auth); + return ResponseData.success(); + } + + private ResponseData payAuth(HighendAuth auth, UpscaleAuthReq req, UserVo userVo) { + //需要支付 + //查询字典配置--普通认证缴纳金额 + SysDictData dict = businessUtil.getDict(DictConstant.高端认证缴纳金额); + BigDecimal amount = dict == null ? BigDecimal.ZERO : new BigDecimal(dict.getDictValue()); + + //支付金额 + auth.setAmount(amount); + + //余额支付 验证密码 + if (req.getPayType().equals(PayEnums.balance.getCode())) { + //判断余额支付 + businessUtil.judgeBalancePay(userVo, amount, req.getPayPwd()); + } + + //支付订单号 + auth.setPayOrderNo(generateOrderNo()); + + this.updateById(auth); + + //支付 + ResponseData responseData = payUtil.pay(userVo, auth.getId(), req.getPayType(), amount, BigDecimal.ZERO, auth.getPayOrderNo(), PaySourceEnums.highend_auth_pay, WalletDetailEnums.HEIGHT_AUTH_PAY); + + if (responseData.getSuccess() || responseData.getCode().equals(210)) { + //支付后操作 + if (req.getPayType().equals(PayEnums.balance.getCode()) || req.getPayType().equals(PayEnums.apple.getCode())) { + after(auth); + } + } + + return responseData; + } + + /** + * 判断认证状态 + * + * @param userVo + * @return + */ + private HighendAuth judgeAuthStatus(UserVo userVo) { + + //判断认证状态 + HighendAuth auth = this.getOne(new QueryWrapper().lambda() + .eq(HighendAuth::getStoreId, userVo.getUserId()) + .eq(HighendAuth::getDelFlag, PublicCommon.启用) + ); + if (auth == null || auth.getStatus() == 1) { + throw new CustomException("请联系平台 完善您的线下认证"); + } + if (auth.getStatus() == 3) { + throw new CustomException("您已认证成功,请勿重复认证"); + } + return auth; + } + + @Autowired + private PlatformRecordService platformRecordService; + + /** + * 支付后操作 + * + * @param auth + */ + private void after(HighendAuth auth) { + + this.lambdaUpdate().set(HighendAuth::getPayStatus, PublicCommon.Pay.已支付) + .set(HighendAuth::getIsPay, 2) + .set(HighendAuth::getStatus, 3) + .eq(HighendAuth::getId, auth.getId()).update(); + + //平台流水 + platformRecordService.addPlatformRecord(new UserVo(UserEnums.store.getCode(), auth.getStoreId()), auth.getId(), auth.getAmount(), PlatformRecordEnums.HEIGHT_AUTH_PAY); + } + + /** + * 生成订单号 + * + * @return + */ + private String generateOrderNo() { + String orderNo; + String prefix = "GA"; + while (true) { + orderNo = prefix + DateUtil.format(new Date(), "MMdd" + RandomUtil.randomNumbers(6)); + HighendAuth old = this.getBaseMapper().selectOne(new QueryWrapper().lambda() + .eq(HighendAuth::getPayOrderNo, orderNo) + + ); + if (old == null) { + break; + } + } + return orderNo; + } + + @Override + public ResponseData highendAuthAliNotify(HttpServletRequest request, HttpServletResponse response) { + log.info("******************************进入支付宝支付回调"); + //接收参数进行校验 + Map paramsMap = AlipayCore.updateMap(request); + //流水号 + String payId = paramsMap.get("out_trade_no"); + // 支付宝订单号 + String orderNo = paramsMap.get("trade_no"); + //付款状态 + String tradeStatus = paramsMap.get("trade_status"); + log.info("******************************payId=" + payId); + + HighendAuth cur = baseMapper.selectOne(new QueryWrapper().lambda().eq(HighendAuth::getPayOrderNo, payId)); + if (cur == null) { + log.error("支付信息丢失"); + return ResponseData.error("支付信息丢失"); + } + if (cur.getPayStatus() == 2) { + log.error("支付宝回调已经开始 回去吧"); + return ResponseData.error("支付宝回调已经开始 回去吧"); + } + if (cur.getPayStatus() == 3) { + //退款 + ResponseData responseData = payUtil.refund(new UserVo(UserEnums.store.getCode(), cur.getStoreId()), cur.getId(), cur.getPayType(), cur.getAmount(), cur.getAmount(), cur.getPayOrderNo(), orderNo, BigDecimal.ZERO); + if (!responseData.getSuccess()) { + log.error("退款失败:" + cur.getPayOrderNo()); + } + return responseData; + } + if ("TRADE_SUCCESS".equalsIgnoreCase(tradeStatus)) { + + this.lambdaUpdate().set(HighendAuth::getAliBusinessId, orderNo).eq(HighendAuth::getId, cur.getId()).update(); + + after(cur);//支付后逻辑处理 + log.info("正常"); + return ResponseData.success(); + } else { + cur.setPayStatus(3); + baseMapper.updateById(cur); + log.error("支付失败"); + } + return ResponseData.error(""); + } + + @Override + public ResponseData highendAuthWxNotify(HttpServletRequest request, HttpServletResponse response) { + Map requestMap = HttpRequestUtil.parseXml(request); + System.out.println("requestMap:" + requestMap.toString()); + // 微信中的订单号 + String transactionId = requestMap.get("transaction_id"); + // 用户唯一标识 + String openid = requestMap.get("openid"); + //流水号 + String payId = requestMap.get("out_trade_no"); + + HighendAuth cur = baseMapper.selectOne(new QueryWrapper().lambda().eq(HighendAuth::getPayOrderNo, payId)); + if (cur == null) { + log.error("支付信息丢失"); + return ResponseData.error("支付信息丢失"); + } + if (cur.getPayStatus() == 2) { + log.error("微信回调已经开始 回去吧"); + return ResponseData.error("支付宝回调已经开始 回去吧"); + } + if (cur.getPayStatus() == 3) { + //退款 + ResponseData responseData = payUtil.refund(new UserVo(UserEnums.store.getCode(), cur.getStoreId()), cur.getId(), cur.getPayType(), cur.getAmount(), cur.getAmount(), cur.getPayOrderNo(), null, BigDecimal.ZERO); + if (!responseData.getSuccess()) { + log.error("退款失败:" + cur.getPayOrderNo()); + } + return responseData; + } + + if ("SUCCESS".equals(requestMap.get("result_code"))) { + after(cur);//支付后逻辑处理 + log.info("正常"); + return ResponseData.success(); + } else { + cur.setPayStatus(3); + baseMapper.updateById(cur); + log.error("支付失败"); + } + + return ResponseData.error(""); + } + + @Override + public ResponseData highendAuthLakalaNotify(Map requestMap) { + System.out.println("requestMap:" + requestMap.toString()); + //流水号 + String payId = requestMap.get("out_order_no"); + HighendAuth cur = baseMapper.selectOne(new QueryWrapper().lambda().eq(HighendAuth::getPayOrderNo, payId)); + if (cur == null) { + log.error("支付信息丢失"); + return ResponseData.error("支付信息丢失"); + } + if (cur.getPayStatus() == 2) { + log.error("拉卡拉回调已经开始 回去吧"); + return ResponseData.error("拉卡拉回调已经开始 回去吧"); + } + if (cur.getPayStatus() == 3) { + //退款 + ResponseData responseData = payUtil.refund(new UserVo(UserEnums.store.getCode(), cur.getStoreId()), cur.getId(), cur.getPayType(), cur.getAmount(), cur.getAmount(), cur.getPayOrderNo(), null, BigDecimal.ZERO); + if (!responseData.getSuccess()) { + log.error("退款失败:" + cur.getPayOrderNo()); + } + return responseData; + } + + //order_status 聚合收银台订单状态 0:待支付 1:支付中 2:支付成功 3:支付失败 4:已过期 5:已取消 6:部分退款或者全部退款 + if (("2").equals(requestMap.get("order_status"))) { + after(cur);//支付后逻辑处理 + log.info("正常"); + + //添加支付记录 + onlineRecordService.addOnlineRecord(new UserVo(UserEnums.customer.getCode(), cur.getStoreId()), cur.getId(), cur.getAmount(), WalletDetailEnums.HEIGHT_AUTH_PAY); + + businessUtil.setOutTradeNo(payId); + + return ResponseData.success(); + } else { + cur.setPayStatus(3); + baseMapper.updateById(cur); + log.error("支付失败"); + } + + return ResponseData.error(""); + } + + @Autowired + private OnlineRecordService onlineRecordService; +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/hosearch/controller/HotSearchController.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/hosearch/controller/HotSearchController.java new file mode 100644 index 0000000..972d509 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/hosearch/controller/HotSearchController.java @@ -0,0 +1,103 @@ +package com.ruoyi.frequency.hosearch.controller; + +import java.util.List; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.frequency.hosearch.entity.HotSearch; +import com.ruoyi.frequency.hosearch.service.HotSearchService; +import com.ruoyi.common.utils.poi.ExcelUtil; +import com.ruoyi.common.core.page.TableDataInfo; + +/** + * 热门搜索记录Controller + * + * @author liwenlong + * @date 2024-03-19 + */ +@RestController +@RequestMapping("/frequency/hosearch") +public class HotSearchController extends BaseController +{ + @Autowired + private HotSearchService hotSearchService; + + /** + * 查询热门搜索记录列表 + */ + @PreAuthorize("@ss.hasPermi('frequency:hosearch:list')") + @GetMapping("/list") + public TableDataInfo list(HotSearch hotSearch) + { + startPage(); + List list = hotSearchService.selectHotSearchList(hotSearch); + return getDataTable(list); + } + + /** + * 导出热门搜索记录列表 + */ + @PreAuthorize("@ss.hasPermi('frequency:hosearch:export')") + @Log(title = "热门搜索记录", businessType = BusinessType.EXPORT) + @GetMapping("/export") + public AjaxResult export(HotSearch hotSearch) + { + List list = hotSearchService.selectHotSearchList(hotSearch); + ExcelUtil util = new ExcelUtil(HotSearch.class); + return util.exportExcel(list, "热门搜索记录数据"); + } + + /** + * 获取热门搜索记录详细信息 + */ + @PreAuthorize("@ss.hasPermi('frequency:hosearch:query')") + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") Long id) + { + return AjaxResult.success(hotSearchService.selectHotSearchById(id)); + } + + /** + * 新增热门搜索记录 + */ + @PreAuthorize("@ss.hasPermi('frequency:hosearch:add')") + @Log(title = "热门搜索记录", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody HotSearch hotSearch) + { + return toAjax(hotSearchService.insertHotSearch(hotSearch)); + } + + /** + * 修改热门搜索记录 + */ + @PreAuthorize("@ss.hasPermi('frequency:hosearch:edit')") + @Log(title = "热门搜索记录", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody HotSearch hotSearch) + { + return toAjax(hotSearchService.updateHotSearch(hotSearch)); + } + + /** + * 删除热门搜索记录 + */ + @PreAuthorize("@ss.hasPermi('frequency:hosearch:remove')") + @Log(title = "热门搜索记录", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}/{delFlag}") + public AjaxResult remove(@PathVariable("ids") Long[] ids,@PathVariable("delFlag") Integer delFlag) + { + return toAjax(hotSearchService.deleteHotSearchByIds(ids,delFlag)); + } +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/hosearch/entity/HotSearch.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/hosearch/entity/HotSearch.java new file mode 100644 index 0000000..2308680 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/hosearch/entity/HotSearch.java @@ -0,0 +1,46 @@ +package com.ruoyi.frequency.hosearch.entity; + +import lombok.Data; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.experimental.Accessors; +import com.ruoyi.common.annotation.Excel; +import io.swagger.annotations.ApiModelProperty; +import com.baomidou.mybatisplus.annotation.TableField; +import com.ruoyi.vo.UserInfo; +import com.ruoyi.common.core.domain.BaseEntity; + +/** + * 热门搜索记录对象 t_hot_search + * + * @author liwenlong + * @date 2024-03-19 + */ +@Data +@Accessors(chain = true) +@TableName("t_hot_search") +public class HotSearch extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + + @ApiModelProperty("租户号") + private Long id; + + @ApiModelProperty("删除标志;1 正常 2 删除 3 禁用") + private Long delFlag; + + @ApiModelProperty("搜索词") + @Excel(name = "搜索词") + private String searchTerm; + + @ApiModelProperty("搜索成功次数") + @Excel(name = "搜索成功次数") + private Integer successTimes; + + @ApiModelProperty("搜索失败次数") + @Excel(name = "搜索失败次数") + private Integer failTimes; + + + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/hosearch/mapper/HotSearchMapper.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/hosearch/mapper/HotSearchMapper.java new file mode 100644 index 0000000..fd7f2b3 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/hosearch/mapper/HotSearchMapper.java @@ -0,0 +1,52 @@ +package com.ruoyi.frequency.hosearch.mapper; + +import java.util.List; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.ruoyi.controller.req.HotSearchListReq; +import com.ruoyi.frequency.hosearch.entity.HotSearch; +import org.apache.ibatis.annotations.Param; + +/** + * 热门搜索记录Mapper接口 + * + * @author liwenlong + * @date 2024-03-19 + */ +public interface HotSearchMapper extends BaseMapper +{ + /** + * 查询热门搜索记录 + * + * @param id 热门搜索记录主键 + * @return 热门搜索记录 + */ + public HotSearch selectHotSearchById(Long id); + + /** + * 查询热门搜索记录列表 + * + * @param hotSearch 热门搜索记录 + * @return 热门搜索记录集合 + */ + public List selectHotSearchList(HotSearch hotSearch); + + /** + * 新增热门搜索记录 + * + * @param hotSearch 热门搜索记录 + * @return 结果 + */ + public int insertHotSearch(HotSearch hotSearch); + + /** + * 修改热门搜索记录 + * + * @param hotSearch 热门搜索记录 + * @return 结果 + */ + public int updateHotSearch(HotSearch hotSearch); + + List hotSearchList(@Param("req") HotSearchListReq req); + + void addHotSearch(@Param("item") HotSearch hotSearch, @Param("isSuccess") Boolean isSuccess); +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/hosearch/mapper/mapping/HotSearchMapper.xml b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/hosearch/mapper/mapping/HotSearchMapper.xml new file mode 100644 index 0000000..459cb78 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/hosearch/mapper/mapping/HotSearchMapper.xml @@ -0,0 +1,134 @@ + + + + + + + + + + + + + + + + + + + + select + t.id , + t.create_by , + t.create_time , + t.update_by , + t.update_time , + t.del_flag , + t.search_term , + t.success_times , + t.fail_times + from t_hot_search AS t + + + + + + + + + insert into t_hot_search + + id, + create_by, + create_time, + update_by, + update_time, + del_flag, + search_term, + success_times, + fail_times, + + + #{id}, + #{createBy}, + #{createTime}, + #{updateBy}, + #{updateTime}, + #{delFlag}, + #{searchTerm}, + #{successTimes}, + #{failTimes}, + + + + + update t_hot_search + + create_by = #{createBy}, + create_time = #{createTime}, + update_by = #{updateBy}, + update_time = #{updateTime}, + del_flag = #{delFlag}, + search_term = #{searchTerm}, + success_times = #{successTimes}, + fail_times = #{failTimes}, + + where id = #{id} + + + + + + insert into t_hot_search + (id, create_by, create_time, update_by, update_time, search_term, success_times, fail_times) + values + (#{item.id},#{item.updateBy},#{item.updateTime},#{item.updateBy},#{item.updateTime},#{item.searchTerm},#{item.successTimes}, #{item.failTimes}) + ON DUPLICATE KEY UPDATE + + + success_times = success_times + 1, + + + fail_times = fail_times + 1, + + + update_time = #{item.updateTime}, + update_by = #{item.updateBy}; + + \ No newline at end of file diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/hosearch/model/param/HotSearchParam.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/hosearch/model/param/HotSearchParam.java new file mode 100644 index 0000000..02f3d2d --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/hosearch/model/param/HotSearchParam.java @@ -0,0 +1,45 @@ +package com.ruoyi.frequency.hosearch.entity.model.param; + +import lombok.Data; +import lombok.experimental.Accessors; +import com.ruoyi.common.annotation.Excel; +import io.swagger.annotations.ApiModelProperty; +import com.ruoyi.common.core.domain.BaseEntity; + +/** + * 热门搜索记录对象 t_hot_search + * + * @author liwenlong + * @date 2024-03-19 + */ +@Data +@Accessors(chain = true) +public class HotSearchParam extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + @ApiModelProperty("租户号") + private Long id; + + @ApiModelProperty("删除标志;1 正常 2 删除 3 禁用") + private Long delFlag; + + @ApiModelProperty("搜索词") + @Excel(name = "搜索词") + private String searchTerm; + + @ApiModelProperty("搜索成功次数") + @Excel(name = "搜索成功次数") + private Long successTimes; + + @ApiModelProperty("搜索失败次数") + @Excel(name = "搜索失败次数") + private Long failTimes; + + + + + + + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/hosearch/model/result/HotSearchResult.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/hosearch/model/result/HotSearchResult.java new file mode 100644 index 0000000..ad2c254 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/hosearch/model/result/HotSearchResult.java @@ -0,0 +1,40 @@ +package com.ruoyi.frequency.hosearch.entity.model.result; + +import lombok.Data; +import lombok.experimental.Accessors; +import com.ruoyi.common.annotation.Excel; +import io.swagger.annotations.ApiModelProperty; +import com.ruoyi.common.core.domain.BaseEntity; + +/** + * 热门搜索记录对象 t_hot_search + * + * @author liwenlong + * @date 2024-03-19 + */ +@Data +@Accessors(chain = true) +public class HotSearchResult extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + @ApiModelProperty("租户号") + private Long id; + + @ApiModelProperty("删除标志;1 正常 2 删除 3 禁用") + private Long delFlag; + + @ApiModelProperty("搜索词") + @Excel(name = "搜索词") + private String searchTerm; + + @ApiModelProperty("搜索成功次数") + @Excel(name = "搜索成功次数") + private Long successTimes; + + @ApiModelProperty("搜索失败次数") + @Excel(name = "搜索失败次数") + private Long failTimes; + + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/hosearch/service/HotSearchService.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/hosearch/service/HotSearchService.java new file mode 100644 index 0000000..99da624 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/hosearch/service/HotSearchService.java @@ -0,0 +1,70 @@ +package com.ruoyi.frequency.hosearch.service; + +import java.util.List; + +import com.ruoyi.controller.req.HotSearchListReq; +import com.ruoyi.frequency.hosearch.entity.HotSearch; +import com.baomidou.mybatisplus.extension.service.IService; + +/** + * 热门搜索记录Service接口 + * + * @author liwenlong + * @date 2024-03-19 + */ +public interface HotSearchService extends IService +{ + /** + * 查询热门搜索记录 + * + * @param id 热门搜索记录主键 + * @return 热门搜索记录 + */ + public HotSearch selectHotSearchById(Long id); + + /** + * 查询热门搜索记录列表 + * + * @param hotSearch 热门搜索记录 + * @return 热门搜索记录集合 + */ + public List selectHotSearchList(HotSearch hotSearch); + + /** + * 新增热门搜索记录 + * + * @param hotSearch 热门搜索记录 + * @return 结果 + */ + public int insertHotSearch(HotSearch hotSearch); + + /** + * 修改热门搜索记录 + * + * @param hotSearch 热门搜索记录 + * @return 结果 + */ + public int updateHotSearch(HotSearch hotSearch); + + /** + * 批量删除热门搜索记录 + * + * @param ids 需要删除的热门搜索记录主键集合 + * @return 结果 + */ + public int deleteHotSearchByIds(Long[] ids,Integer delFlag); + + /** + * 查询热门搜索记录列表 + * @param req + * @return + */ + List hotSearchList(HotSearchListReq req); + + /** + * 记录搜索 + * @param hotSearch + * @param isSuccess 是否搜索出数据 + */ + void addHotSearch(HotSearch hotSearch, Boolean isSuccess); +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/hosearch/service/impl/HotSearchServiceImpl.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/hosearch/service/impl/HotSearchServiceImpl.java new file mode 100644 index 0000000..8c24817 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/hosearch/service/impl/HotSearchServiceImpl.java @@ -0,0 +1,101 @@ +package com.ruoyi.frequency.hosearch.service.impl; + +import java.util.List; +import com.ruoyi.common.utils.DateUtils; +import com.ruoyi.controller.req.HotSearchListReq; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.ruoyi.code.PublicCommon; +import com.ruoyi.frequency.hosearch.mapper.HotSearchMapper; +import com.ruoyi.frequency.hosearch.entity.HotSearch; +import com.ruoyi.frequency.hosearch.service.HotSearchService; + +/** + * 热门搜索记录Service业务层处理 + * + * @author liwenlong + * @date 2024-03-19 + */ +@Service +public class HotSearchServiceImpl extends ServiceImpl implements HotSearchService +{ + @Autowired + private HotSearchMapper hotSearchMapper; + + /** + * 查询热门搜索记录 + * + * @param id 热门搜索记录主键 + * @return 热门搜索记录 + */ + @Override + public HotSearch selectHotSearchById(Long id) + { + return hotSearchMapper.selectHotSearchById(id); + } + + /** + * 查询热门搜索记录列表 + * + * @param hotSearch 热门搜索记录 + * @return 热门搜索记录 + */ + @Override + public List selectHotSearchList(HotSearch hotSearch) + { + return hotSearchMapper.selectHotSearchList(hotSearch); + } + + /** + * 新增热门搜索记录 + * + * @param hotSearch 热门搜索记录 + * @return 结果 + */ + @Override + public int insertHotSearch(HotSearch hotSearch) + { + hotSearch.setCreateData(); + return hotSearchMapper.insert(hotSearch); + } + + /** + * 修改热门搜索记录 + * + * @param hotSearch 热门搜索记录 + * @return 结果 + */ + @Override + public int updateHotSearch(HotSearch hotSearch) + { + hotSearch.setUpdateData(); + return hotSearchMapper.updateHotSearch(hotSearch); + } + + /** + * 批量删除热门搜索记录 + * + * @param ids 需要删除的热门搜索记录主键 + * @return 结果 + */ + @Override + public int deleteHotSearchByIds(Long[] ids,Integer delFlag) + { + this.lambdaUpdate().set(HotSearch::getDelFlag,delFlag).in(HotSearch::getId,ids).update(); + return ids.length; + } + + @Override + public List hotSearchList(HotSearchListReq req) { + return this.baseMapper.hotSearchList(req); + } + + @Override + public void addHotSearch(HotSearch hotSearch, Boolean isSuccess) { + hotSearch.setUpdateData(); + hotSearch.setSuccessTimes(isSuccess?1:0); + hotSearch.setFailTimes(isSuccess?0:1); + this.baseMapper.addHotSearch(hotSearch,isSuccess); + } +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/like/controller/LikeController.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/like/controller/LikeController.java new file mode 100644 index 0000000..fbc9f50 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/like/controller/LikeController.java @@ -0,0 +1,103 @@ +package com.ruoyi.frequency.like.controller; + +import java.util.List; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.frequency.like.entity.Like; +import com.ruoyi.frequency.like.service.LikeService; +import com.ruoyi.common.utils.poi.ExcelUtil; +import com.ruoyi.common.core.page.TableDataInfo; + +/** + * 点赞(新闻,活动)Controller + * + * @author liwenlong + * @date 2024-04-16 + */ +@RestController +@RequestMapping("/frequency/like") +public class LikeController extends BaseController +{ + @Autowired + private LikeService likeService; + + /** + * 查询点赞(新闻,活动)列表 + */ + @PreAuthorize("@ss.hasPermi('frequency:like:list')") + @GetMapping("/list") + public TableDataInfo list(Like like) + { + startPage(); + List list = likeService.selectLikeList(like); + return getDataTable(list); + } + + /** + * 导出点赞(新闻,活动)列表 + */ + @PreAuthorize("@ss.hasPermi('frequency:like:export')") + @Log(title = "点赞(新闻,活动)", businessType = BusinessType.EXPORT) + @GetMapping("/export") + public AjaxResult export(Like like) + { + List list = likeService.selectLikeList(like); + ExcelUtil util = new ExcelUtil(Like.class); + return util.exportExcel(list, "点赞(新闻,活动)数据"); + } + + /** + * 获取点赞(新闻,活动)详细信息 + */ + @PreAuthorize("@ss.hasPermi('frequency:like:query')") + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") Long id) + { + return AjaxResult.success(likeService.selectLikeById(id)); + } + + /** + * 新增点赞(新闻,活动) + */ + @PreAuthorize("@ss.hasPermi('frequency:like:add')") + @Log(title = "点赞(新闻,活动)", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody Like like) + { + return toAjax(likeService.insertLike(like)); + } + + /** + * 修改点赞(新闻,活动) + */ + @PreAuthorize("@ss.hasPermi('frequency:like:edit')") + @Log(title = "点赞(新闻,活动)", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody Like like) + { + return toAjax(likeService.updateLike(like)); + } + + /** + * 删除点赞(新闻,活动) + */ + @PreAuthorize("@ss.hasPermi('frequency:like:remove')") + @Log(title = "点赞(新闻,活动)", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}/{delFlag}") + public AjaxResult remove(@PathVariable("ids") Long[] ids,@PathVariable("delFlag") Integer delFlag) + { + return toAjax(likeService.deleteLikeByIds(ids,delFlag)); + } +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/like/entity/Like.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/like/entity/Like.java new file mode 100644 index 0000000..675bf89 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/like/entity/Like.java @@ -0,0 +1,63 @@ +package com.ruoyi.frequency.like.entity; + +import com.ruoyi.utils.SnowIdUtils; +import lombok.Data; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.experimental.Accessors; +import com.ruoyi.common.annotation.Excel; +import io.swagger.annotations.ApiModelProperty; +import com.baomidou.mybatisplus.annotation.TableField; +import com.ruoyi.vo.UserInfo; +import com.ruoyi.common.core.domain.BaseEntity; + +/** + * 点赞(新闻,活动)对象 t_like + * + * @author liwenlong + * @date 2024-04-16 + */ +@Data +@Accessors(chain = true) +@TableName("t_like") +public class Like extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + + @ApiModelProperty("主键id") + private Long id; + + @ApiModelProperty("删除标志 1正常 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("类型 1新闻 2 新闻评论 3活动") + @Excel(name = "类型 1新闻 2 新闻评论 3活动") + private Integer type; + + @ApiModelProperty("用户类型 1 用户 2 商家") + @Excel(name = "用户类型 1 用户 2 商家") + private Integer userType; + + @ApiModelProperty("用户id") + @Excel(name = "用户id") + private Long userId; + + @ApiModelProperty("关联id") + @Excel(name = "关联id") + private Long linkId; + + @ApiModelProperty("用户信息") + @TableField(exist = false) + private UserInfo userInfo; + public Like() { + + } + + public Like(Integer type, Long linkId) { + this.id = SnowIdUtils.uniqueLong(); + this.linkId = linkId; + this.type = type; + this.setCreateData(); + this.setUpdateData(); + } +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/like/mapper/LikeMapper.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/like/mapper/LikeMapper.java new file mode 100644 index 0000000..74c0801 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/like/mapper/LikeMapper.java @@ -0,0 +1,50 @@ +package com.ruoyi.frequency.like.mapper; + +import java.util.List; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.ruoyi.frequency.like.entity.Like; +import com.ruoyi.vo.UserVo; +import org.apache.ibatis.annotations.Param; + +/** + * 点赞(新闻,活动)Mapper接口 + * + * @author liwenlong + * @date 2024-04-16 + */ +public interface LikeMapper extends BaseMapper +{ + /** + * 查询点赞(新闻,活动) + * + * @param id 点赞(新闻,活动)主键 + * @return 点赞(新闻,活动) + */ + public Like selectLikeById(Long id); + + /** + * 查询点赞(新闻,活动)列表 + * + * @param like 点赞(新闻,活动) + * @return 点赞(新闻,活动)集合 + */ + public List selectLikeList(Like like); + + /** + * 新增点赞(新闻,活动) + * + * @param like 点赞(新闻,活动) + * @return 结果 + */ + public int insertLike(Like like); + + /** + * 修改点赞(新闻,活动) + * + * @param like 点赞(新闻,活动) + * @return 结果 + */ + public int updateLike(Like like); + + void like(@Param("req") Like like,@Param("userVo") UserVo userVo); +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/like/mapper/mapping/LikeMapper.xml b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/like/mapper/mapping/LikeMapper.xml new file mode 100644 index 0000000..33dc1dc --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/like/mapper/mapping/LikeMapper.xml @@ -0,0 +1,123 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + select + t.id , + t.create_by , + t.create_time , + t.update_by , + t.update_time , + t.del_flag , + t.type , + t.user_type , + t.user_id , + t.link_id , + u.user_type, + u.id_no, + u.mobile, + u.avatar, + u.nickname + from t_like AS t + LEFT JOIN t_user AS u ON t.user_id = u.id + + + + + + + + insert into t_like + + id, + create_by, + create_time, + update_by, + update_time, + del_flag, + type, + user_type, + user_id, + link_id, + + + #{id}, + #{createBy}, + #{createTime}, + #{updateBy}, + #{updateTime}, + #{delFlag}, + #{type}, + #{userType}, + #{userId}, + #{linkId}, + + + + + update t_like + + create_by = #{createBy}, + create_time = #{createTime}, + update_by = #{updateBy}, + update_time = #{updateTime}, + del_flag = #{delFlag}, + type = #{type}, + user_type = #{userType}, + user_id = #{userId}, + link_id = #{linkId}, + + where id = #{id} + + + + insert into t_like + (id, create_by, create_time, update_by, update_time, type, user_type, user_id, link_id) + values + (#{req.id},#{req.updateBy},#{req.updateTime},#{req.updateBy},#{req.updateTime},#{req.type},#{userVo.userType}, #{userVo.userId}, #{req.linkId}) + ON DUPLICATE KEY UPDATE + del_flag = IF( del_flag = 1, 3, 1 ), + update_time = #{req.updateTime}, + update_by = #{req.updateBy}; + + \ No newline at end of file diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/like/model/param/LikeParam.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/like/model/param/LikeParam.java new file mode 100644 index 0000000..517c44c --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/like/model/param/LikeParam.java @@ -0,0 +1,50 @@ +package com.ruoyi.frequency.like.model.param; + +import lombok.Data; +import lombok.experimental.Accessors; +import com.ruoyi.common.annotation.Excel; +import io.swagger.annotations.ApiModelProperty; +import com.ruoyi.common.core.domain.BaseEntity; + +/** + * 点赞(新闻,活动)对象 t_like + * + * @author liwenlong + * @date 2024-04-16 + */ +@Data +@Accessors(chain = true) +public class LikeParam extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + @ApiModelProperty("主键id") + private Long id; + + @ApiModelProperty("删除标志 1正常 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("类型 1新闻 2 新闻评论 3活动") + @Excel(name = "类型 1新闻 2 新闻评论 3活动") + private Integer type; + + @ApiModelProperty("用户类型 1 用户 2 商家") + @Excel(name = "用户类型 1 用户 2 商家") + private Integer userType; + + @ApiModelProperty("用户id") + @Excel(name = "用户id") + private Long userId; + + @ApiModelProperty("关联id") + @Excel(name = "关联id") + private Long linkId; + + + + + + + + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/like/model/result/LikeResult.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/like/model/result/LikeResult.java new file mode 100644 index 0000000..69d5544 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/like/model/result/LikeResult.java @@ -0,0 +1,44 @@ +package com.ruoyi.frequency.like.model.result; + +import lombok.Data; +import lombok.experimental.Accessors; +import com.ruoyi.common.annotation.Excel; +import io.swagger.annotations.ApiModelProperty; +import com.ruoyi.common.core.domain.BaseEntity; + +/** + * 点赞(新闻,活动)对象 t_like + * + * @author liwenlong + * @date 2024-04-16 + */ +@Data +@Accessors(chain = true) +public class LikeResult extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + @ApiModelProperty("主键id") + private Long id; + + @ApiModelProperty("删除标志 1正常 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("类型 1新闻 2 新闻评论 3活动") + @Excel(name = "类型 1新闻 2 新闻评论 3活动") + private Integer type; + + @ApiModelProperty("用户类型 1 用户 2 商家") + @Excel(name = "用户类型 1 用户 2 商家") + private Integer userType; + + @ApiModelProperty("用户id") + @Excel(name = "用户id") + private Long userId; + + @ApiModelProperty("关联id") + @Excel(name = "关联id") + private Long linkId; + + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/like/service/LikeService.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/like/service/LikeService.java new file mode 100644 index 0000000..e7059fa --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/like/service/LikeService.java @@ -0,0 +1,66 @@ +package com.ruoyi.frequency.like.service; + +import java.util.List; + +import com.ruoyi.controller.req.LikeReq; +import com.ruoyi.frequency.like.entity.Like; +import com.baomidou.mybatisplus.extension.service.IService; +import com.ruoyi.response.ResponseData; +import com.ruoyi.vo.UserVo; + +/** + * 点赞(新闻,活动)Service接口 + * + * @author liwenlong + * @date 2024-04-16 + */ +public interface LikeService extends IService +{ + /** + * 查询点赞(新闻,活动) + * + * @param id 点赞(新闻,活动)主键 + * @return 点赞(新闻,活动) + */ + public Like selectLikeById(Long id); + + /** + * 查询点赞(新闻,活动)列表 + * + * @param like 点赞(新闻,活动) + * @return 点赞(新闻,活动)集合 + */ + public List selectLikeList(Like like); + + /** + * 新增点赞(新闻,活动) + * + * @param like 点赞(新闻,活动) + * @return 结果 + */ + public int insertLike(Like like); + + /** + * 修改点赞(新闻,活动) + * + * @param like 点赞(新闻,活动) + * @return 结果 + */ + public int updateLike(Like like); + + /** + * 批量删除点赞(新闻,活动) + * + * @param ids 需要删除的点赞(新闻,活动)主键集合 + * @return 结果 + */ + public int deleteLikeByIds(Long[] ids,Integer delFlag); + + /** + * 点赞 + * @param req + * @param userVo + * @return + */ + ResponseData like(LikeReq req, UserVo userVo); +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/like/service/impl/LikeServiceImpl.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/like/service/impl/LikeServiceImpl.java new file mode 100644 index 0000000..086678a --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/like/service/impl/LikeServiceImpl.java @@ -0,0 +1,156 @@ +package com.ruoyi.frequency.like.service.impl; + +import java.util.List; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.ruoyi.common.utils.DateUtils; +import com.ruoyi.controller.req.LikeReq; +import com.ruoyi.frequency.activity.entity.Activity; +import com.ruoyi.frequency.activity.mapper.ActivityMapper; +import com.ruoyi.frequency.comment.entity.Comment; +import com.ruoyi.frequency.comment.mapper.CommentMapper; +import com.ruoyi.frequency.news.entity.News; +import com.ruoyi.frequency.news.mapper.NewsMapper; +import com.ruoyi.frequency.vote.entity.Vote; +import com.ruoyi.frequency.votelike.entity.VoteLike; +import com.ruoyi.response.ResponseData; +import com.ruoyi.vo.UserVo; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.ruoyi.code.PublicCommon; +import com.ruoyi.frequency.like.mapper.LikeMapper; +import com.ruoyi.frequency.like.entity.Like; +import com.ruoyi.frequency.like.service.LikeService; + +/** + * 点赞(新闻,活动)Service业务层处理 + * + * @author liwenlong + * @date 2024-04-16 + */ +@Service +public class LikeServiceImpl extends ServiceImpl implements LikeService +{ + @Autowired + private LikeMapper likeMapper; + + /** + * 查询点赞(新闻,活动) + * + * @param id 点赞(新闻,活动)主键 + * @return 点赞(新闻,活动) + */ + @Override + public Like selectLikeById(Long id) + { + return likeMapper.selectLikeById(id); + } + + /** + * 查询点赞(新闻,活动)列表 + * + * @param like 点赞(新闻,活动) + * @return 点赞(新闻,活动) + */ + @Override + public List selectLikeList(Like like) + { + return likeMapper.selectLikeList(like); + } + + /** + * 新增点赞(新闻,活动) + * + * @param like 点赞(新闻,活动) + * @return 结果 + */ + @Override + public int insertLike(Like like) + { + like.setCreateData(); + return likeMapper.insert(like); + } + + /** + * 修改点赞(新闻,活动) + * + * @param like 点赞(新闻,活动) + * @return 结果 + */ + @Override + public int updateLike(Like like) + { + like.setUpdateData(); + return likeMapper.updateLike(like); + } + + /** + * 批量删除点赞(新闻,活动) + * + * @param ids 需要删除的点赞(新闻,活动)主键 + * @return 结果 + */ + @Override + public int deleteLikeByIds(Long[] ids,Integer delFlag) + { + this.lambdaUpdate().set(Like::getDelFlag,delFlag).in(Like::getId,ids).update(); + return ids.length; + } + + @Override + public ResponseData like(LikeReq req, UserVo userVo) { + Like like = new Like(req.getType(), req.getLinkId()); + + //更新帖子点赞记录 + this.baseMapper.like(like,userVo); + + like = this.getOne(new QueryWrapper().lambda() + .eq(Like::getLinkId,req.getLinkId()) + .eq(Like::getType,req.getType()) + .eq(Like::getUserType,userVo.getUserType()) + .eq(Like::getUserId,userVo.getUserId())); + + //是否点赞 + Boolean isLike = like.getDelFlag().equals(PublicCommon.启用); + + //1 新闻 2新闻评论 3 活动 + updateLikeNum(req.getType(),req.getLinkId(),isLike); + + return ResponseData.success(); + } + + @Autowired + private NewsMapper newsMapper; + + @Autowired + private CommentMapper commentMapper; + + @Autowired + private ActivityMapper activityMapper; + + /** + * 更新对应点赞数量 + * @param type 1 新闻 2新闻评论 3 活动 + * @param linkId + * @param isLike + */ + private void updateLikeNum(Integer type, Long linkId, Boolean isLike) { + //点赞 +1 ,取消点赞 -1 + Integer num = isLike ? 1 : -1; + + switch (type){ + case 1: + newsMapper.updateNews(new News().setId(linkId).setLikeNum(num)); + break; + case 2: + commentMapper.updateComment(new Comment().setId(linkId).setLikeNum(num)); + break; + case 3: + activityMapper.updateActivity(new Activity().setId(linkId).setLikeNum(num)); + break; + default: + throw new IllegalStateException("Unexpected value: " + type); + } + } +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/malladdress/controller/MallAddressController.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/malladdress/controller/MallAddressController.java new file mode 100644 index 0000000..bbac3c6 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/malladdress/controller/MallAddressController.java @@ -0,0 +1,97 @@ +package com.ruoyi.frequency.malladdress.controller; + +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.page.TableDataInfo; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.common.utils.poi.ExcelUtil; +import com.ruoyi.frequency.malladdress.entity.MallAddress; +import com.ruoyi.frequency.malladdress.service.MallAddressService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +/** + * 地址Controller + * + * @author liwenlong + * @date 2024-01-25 + */ +@RestController +@RequestMapping("/frequency/malladdress") +public class MallAddressController extends BaseController +{ + @Autowired + private MallAddressService mallAddressService; + + /** + * 查询地址列表 + */ + @PreAuthorize("@ss.hasPermi('frequency:malladdress:list')") + @GetMapping("/list") + public TableDataInfo list(MallAddress mallAddress) + { + startPage(); + List list = mallAddressService.selectMallAddressList(mallAddress); + return getDataTable(list); + } + + /** + * 导出地址列表 + */ + @PreAuthorize("@ss.hasPermi('frequency:malladdress:export')") + @Log(title = "地址", businessType = BusinessType.EXPORT) + @GetMapping("/export") + public AjaxResult export(MallAddress mallAddress) + { + List list = mallAddressService.selectMallAddressList(mallAddress); + ExcelUtil util = new ExcelUtil(MallAddress.class); + return util.exportExcel(list, "地址数据"); + } + + /** + * 获取地址详细信息 + */ + @PreAuthorize("@ss.hasPermi('frequency:malladdress:query')") + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") Long id) + { + return AjaxResult.success(mallAddressService.selectMallAddressById(id)); + } + + /** + * 新增地址 + */ + @PreAuthorize("@ss.hasPermi('frequency:malladdress:add')") + @Log(title = "地址", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody MallAddress mallAddress) + { + return toAjax(mallAddressService.insertMallAddress(mallAddress)); + } + + /** + * 修改地址 + */ + @PreAuthorize("@ss.hasPermi('frequency:malladdress:edit')") + @Log(title = "地址", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody MallAddress mallAddress) + { + return toAjax(mallAddressService.updateMallAddress(mallAddress)); + } + + /** + * 删除地址 + */ + @PreAuthorize("@ss.hasPermi('frequency:malladdress:remove')") + @Log(title = "地址", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}/{delFlag}") + public AjaxResult remove(@PathVariable("ids") Long[] ids,@PathVariable("delFlag") Integer delFlag) + { + return toAjax(mallAddressService.deleteMallAddressByIds(ids,delFlag)); + } +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/malladdress/entity/MallAddress.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/malladdress/entity/MallAddress.java new file mode 100644 index 0000000..7201596 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/malladdress/entity/MallAddress.java @@ -0,0 +1,89 @@ +package com.ruoyi.frequency.malladdress.entity; + +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableName; +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import com.ruoyi.vo.UserInfo; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; + +/** + * 地址对象 mall_address + * + * @author liwenlong + * @date 2024-01-25 + */ +@Data +@Accessors(chain = true) +@TableName("mall_address") +public class MallAddress extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + + @ApiModelProperty("租户号") + private Long id; + + @ApiModelProperty("删除标志 1 正常 2 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("用户类型 1设计师 2表现师") + @Excel(name = "用户类型 1设计师 2表现师") + private Integer userType; + + @ApiModelProperty("用户id") + @Excel(name = "用户id") + private Long userId; + + @ApiModelProperty("用户名") + @Excel(name = "用户名") + private String username; + + @ApiModelProperty("手机号") + @Excel(name = "手机号") + private String mobile; + + @ApiModelProperty("省") + @Excel(name = "省") + private String province; + + @ApiModelProperty("市") + @Excel(name = "市") + private String city; + + @ApiModelProperty("区") + @Excel(name = "区") + private String area; + + @ApiModelProperty("地址") + @Excel(name = "地址") + private String address; + + @ApiModelProperty("详细地址") + @Excel(name = "详细地址") + private String detail; + + @ApiModelProperty("是否默认地址 1 非默认 2 默认") + @Excel(name = "是否默认地址 1 非默认 2 默认") + private Integer isDefault; + + @ApiModelProperty("经度") + @Excel(name = "经度") + private String longitude; + + @ApiModelProperty("纬度") + @Excel(name = "纬度") + private String latitude; + + @ApiModelProperty("区号") + @Excel(name = "区号") + private String areaCode; + + @ApiModelProperty("用户信息") + @TableField(exist = false) + private UserInfo userInfo; + + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/malladdress/mapper/MallAddressMapper.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/malladdress/mapper/MallAddressMapper.java new file mode 100644 index 0000000..5997304 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/malladdress/mapper/MallAddressMapper.java @@ -0,0 +1,48 @@ +package com.ruoyi.frequency.malladdress.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.ruoyi.frequency.malladdress.entity.MallAddress; + +import java.util.List; + +/** + * 地址Mapper接口 + * + * @author liwenlong + * @date 2024-01-25 + */ +public interface MallAddressMapper extends BaseMapper +{ + /** + * 查询地址 + * + * @param id 地址主键 + * @return 地址 + */ + public MallAddress selectMallAddressById(Long id); + + /** + * 查询地址列表 + * + * @param mallAddress 地址 + * @return 地址集合 + */ + public List selectMallAddressList(MallAddress mallAddress); + + /** + * 新增地址 + * + * @param mallAddress 地址 + * @return 结果 + */ + public int insertMallAddress(MallAddress mallAddress); + + /** + * 修改地址 + * + * @param mallAddress 地址 + * @return 结果 + */ + public int updateMallAddress(MallAddress mallAddress); + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/malladdress/mapper/mapping/MallAddressMapper.xml b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/malladdress/mapper/mapping/MallAddressMapper.xml new file mode 100644 index 0000000..5ec9e9b --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/malladdress/mapper/mapping/MallAddressMapper.xml @@ -0,0 +1,149 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + select + t.id , + t.del_flag , + t.update_time , + t.create_time , + t.create_by , + t.update_by , + t.user_type , + t.user_id , + t.username , + t.mobile , + t.province , + t.city , + t.area , + t.address , + t.detail , + t.is_default , + t.longitude , + t.latitude , + t.area_code + from mall_address AS t + + + + + + + + insert into mall_address + + id, + del_flag, + update_time, + create_time, + create_by, + update_by, + user_type, + user_id, + username, + mobile, + province, + city, + area, + address, + detail, + is_default, + longitude, + latitude, + area_code, + + + #{id}, + #{delFlag}, + #{updateTime}, + #{createTime}, + #{createBy}, + #{updateBy}, + #{userType}, + #{userId}, + #{username}, + #{mobile}, + #{province}, + #{city}, + #{area}, + #{address}, + #{detail}, + #{isDefault}, + #{longitude}, + #{latitude}, + #{areaCode}, + + + + + update mall_address + + del_flag = #{delFlag}, + update_time = #{updateTime}, + create_time = #{createTime}, + create_by = #{createBy}, + update_by = #{updateBy}, + user_type = #{userType}, + user_id = #{userId}, + username = #{username}, + mobile = #{mobile}, + province = #{province}, + city = #{city}, + area = #{area}, + address = #{address}, + detail = #{detail}, + is_default = #{isDefault}, + longitude = #{longitude}, + latitude = #{latitude}, + area_code = #{areaCode}, + + where id = #{id} + + diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/malladdress/model/param/MallAddressParam.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/malladdress/model/param/MallAddressParam.java new file mode 100644 index 0000000..a5291f7 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/malladdress/model/param/MallAddressParam.java @@ -0,0 +1,95 @@ +package com.ruoyi.frequency.malladdress.model.param; + +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; + +/** + * 地址对象 mall_address + * + * @author liwenlong + * @date 2024-01-25 + */ +@Data +@Accessors(chain = true) +public class MallAddressParam extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + @ApiModelProperty("租户号") + private Long id; + + @ApiModelProperty("删除标志 1 正常 2 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("用户类型 1设计师 2表现师") + @Excel(name = "用户类型 1设计师 2表现师") + private Integer userType; + + @ApiModelProperty("用户id") + @Excel(name = "用户id") + private Long userId; + + @ApiModelProperty("用户名") + @Excel(name = "用户名") + private String username; + + @ApiModelProperty("手机号") + @Excel(name = "手机号") + private String mobile; + + @ApiModelProperty("省") + @Excel(name = "省") + private String province; + + @ApiModelProperty("市") + @Excel(name = "市") + private String city; + + @ApiModelProperty("区") + @Excel(name = "区") + private String area; + + @ApiModelProperty("地址") + @Excel(name = "地址") + private String address; + + @ApiModelProperty("详细地址") + @Excel(name = "详细地址") + private String detail; + + @ApiModelProperty("是否默认地址 1 非默认 2 默认") + @Excel(name = "是否默认地址 1 非默认 2 默认") + private Integer isDefault; + + @ApiModelProperty("经度") + @Excel(name = "经度") + private String longitude; + + @ApiModelProperty("纬度") + @Excel(name = "纬度") + private String latitude; + + @ApiModelProperty("区号") + @Excel(name = "区号") + private String areaCode; + + + + + + + + + + + + + + + + + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/malladdress/model/result/MallAddressResult.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/malladdress/model/result/MallAddressResult.java new file mode 100644 index 0000000..0f06b75 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/malladdress/model/result/MallAddressResult.java @@ -0,0 +1,80 @@ +package com.ruoyi.frequency.malladdress.model.result; + +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; + +/** + * 地址对象 mall_address + * + * @author liwenlong + * @date 2024-01-25 + */ +@Data +@Accessors(chain = true) +public class MallAddressResult extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + @ApiModelProperty("租户号") + private Long id; + + @ApiModelProperty("删除标志 1 正常 2 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("用户类型 1设计师 2表现师") + @Excel(name = "用户类型 1设计师 2表现师") + private Integer userType; + + @ApiModelProperty("用户id") + @Excel(name = "用户id") + private Long userId; + + @ApiModelProperty("用户名") + @Excel(name = "用户名") + private String username; + + @ApiModelProperty("手机号") + @Excel(name = "手机号") + private String mobile; + + @ApiModelProperty("省") + @Excel(name = "省") + private String province; + + @ApiModelProperty("市") + @Excel(name = "市") + private String city; + + @ApiModelProperty("区") + @Excel(name = "区") + private String area; + + @ApiModelProperty("地址") + @Excel(name = "地址") + private String address; + + @ApiModelProperty("详细地址") + @Excel(name = "详细地址") + private String detail; + + @ApiModelProperty("是否默认地址 1 非默认 2 默认") + @Excel(name = "是否默认地址 1 非默认 2 默认") + private Integer isDefault; + + @ApiModelProperty("经度") + @Excel(name = "经度") + private String longitude; + + @ApiModelProperty("纬度") + @Excel(name = "纬度") + private String latitude; + + @ApiModelProperty("区号") + @Excel(name = "区号") + private String areaCode; + + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/malladdress/service/MallAddressService.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/malladdress/service/MallAddressService.java new file mode 100644 index 0000000..4767f47 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/malladdress/service/MallAddressService.java @@ -0,0 +1,78 @@ +package com.ruoyi.frequency.malladdress.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.ruoyi.controller.req.AddressInsertReq; +import com.ruoyi.controller.req.AddressUpdateReq; +import com.ruoyi.frequency.malladdress.entity.MallAddress; +import com.ruoyi.response.ResponseData; +import com.ruoyi.vo.PageBasic; +import com.ruoyi.vo.UserVo; + +import java.util.List; + +/** + * 地址Service接口 + * + * @author liwenlong + * @date 2024-01-25 + */ +public interface MallAddressService extends IService +{ + /** + * 查询地址 + * + * @param id 地址主键 + * @return 地址 + */ + public MallAddress selectMallAddressById(Long id); + + /** + * 查询地址列表 + * + * @param mallAddress 地址 + * @return 地址集合 + */ + public List selectMallAddressList(MallAddress mallAddress); + + /** + * 新增地址 + * + * @param mallAddress 地址 + * @return 结果 + */ + public int insertMallAddress(MallAddress mallAddress); + + /** + * 修改地址 + * + * @param mallAddress 地址 + * @return 结果 + */ + public int updateMallAddress(MallAddress mallAddress); + + /** + * 批量删除地址 + * + * @param ids 需要删除的地址主键集合 + * @return 结果 + */ + public int deleteMallAddressByIds(Long[] ids,Integer delFlag); + + /** + * + * @param user + * @param page + * @return + */ + ResponseData addressPage(UserVo user, PageBasic page); + + ResponseData insertAddress(AddressInsertReq addressInsertReq, UserVo userVo); + + ResponseData updateAddress(AddressUpdateReq addressUpdateReq, UserVo userVo); + + ResponseData setDefault(Long id); + + ResponseData deleteAddressById(List ids,UserVo userVo); + + ResponseData getDefaultAddress(UserVo userVo); +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/malladdress/service/impl/MallAddressServiceImpl.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/malladdress/service/impl/MallAddressServiceImpl.java new file mode 100644 index 0000000..b04c285 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/malladdress/service/impl/MallAddressServiceImpl.java @@ -0,0 +1,225 @@ +package com.ruoyi.frequency.malladdress.service.impl; + +import cn.hutool.core.util.ObjectUtil; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.ruoyi.code.PublicCommon; +import com.ruoyi.common.exception.CustomException; +import com.ruoyi.common.exception.enums.CoreExceptionEnum; +import com.ruoyi.common.page.PageResult; +import com.ruoyi.controller.req.AddressInsertReq; +import com.ruoyi.controller.req.AddressUpdateReq; +import com.ruoyi.frequency.malladdress.entity.MallAddress; +import com.ruoyi.frequency.malladdress.mapper.MallAddressMapper; +import com.ruoyi.frequency.malladdress.service.MallAddressService; +import com.ruoyi.response.ResponseData; +import com.ruoyi.utils.JudgeLogicUtil; +import com.ruoyi.vo.PageBasic; +import com.ruoyi.vo.UserVo; +import org.springframework.beans.BeanUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * 地址Service业务层处理 + * + * @author liwenlong + * @date 2024-01-25 + */ +@Service +public class MallAddressServiceImpl extends ServiceImpl implements MallAddressService +{ + @Autowired + private MallAddressMapper mallAddressMapper; + + /** + * 查询地址 + * + * @param id 地址主键 + * @return 地址 + */ + @Override + public MallAddress selectMallAddressById(Long id) + { + return mallAddressMapper.selectMallAddressById(id); + } + + /** + * 查询地址列表 + * + * @param mallAddress 地址 + * @return 地址 + */ + @Override + public List selectMallAddressList(MallAddress mallAddress) + { + return mallAddressMapper.selectMallAddressList(mallAddress); + } + + /** + * 新增地址 + * + * @param mallAddress 地址 + * @return 结果 + */ + @Override + public int insertMallAddress(MallAddress mallAddress) + { + mallAddress.setCreateData(); + return mallAddressMapper.insert(mallAddress); + } + + /** + * 修改地址 + * + * @param mallAddress 地址 + * @return 结果 + */ + @Override + public int updateMallAddress(MallAddress mallAddress) + { + mallAddress.setUpdateData(); + return mallAddressMapper.updateMallAddress(mallAddress); + } + + /** + * 批量删除地址 + * + * @param ids 需要删除的地址主键 + * @return 结果 + */ + @Override + public int deleteMallAddressByIds(Long[] ids,Integer delFlag) + { + this.lambdaUpdate().set(MallAddress::getDelFlag,delFlag).in(MallAddress::getId,ids).update(); + return ids.length; + } + + @Override + public ResponseData addressPage(UserVo user, PageBasic page) { + + Page addressPage = baseMapper.selectPage(new Page<>(page.getPageNo(), page.getPageSize()), new QueryWrapper() + .lambda() + .eq(MallAddress::getUserId, user.getUserId()) + .eq(MallAddress::getUserType,user.getUserType()) + .ne(MallAddress::getDelFlag, PublicCommon.删除) + .orderByDesc(MallAddress::getIsDefault).orderByDesc(MallAddress::getCreateTime)); + + return ResponseData.success(new PageResult<>(addressPage)); + } + + + @Autowired + private JudgeLogicUtil judgeLogicUtil; + + @Override + public ResponseData insertAddress(AddressInsertReq addressInsertReq, UserVo userVo) { + MallAddress address = new MallAddress(); + BeanUtils.copyProperties(addressInsertReq, address); + + address.setUserId(userVo.getUserId()) + .setUserType(userVo.getUserType()); + + //默认地址唯一,用户拥有默认地址,改为非默认 + if (ObjectUtil.equal(PublicCommon.默认,addressInsertReq.getIsDefault())){ + this.lambdaUpdate().set(MallAddress::getIsDefault,PublicCommon.非默认) + .eq(MallAddress::getIsDefault,PublicCommon.默认) + .eq(MallAddress::getUserId,userVo.getUserId()) + .eq(MallAddress::getUserType,userVo.getUserType()) + .update(); + } + + int insertCount = this.baseMapper.insert(address); + + if (insertCount == 0) { + throw new CustomException(CoreExceptionEnum.INSERT_DATA); + } + + return ResponseData.success(address); + } + + @Override + public ResponseData updateAddress(AddressUpdateReq addressUpdateReq, UserVo userVo) { + + MallAddress address = this.baseMapper.selectById(addressUpdateReq.getId()); + + if (address == null) { + throw new CustomException(CoreExceptionEnum.RESOURCES_NOT_EXIST); + } + + //默认地址唯一,用户拥有默认地址,改为非默认 + if (ObjectUtil.equal(PublicCommon.默认,addressUpdateReq.getIsDefault())){ + this.lambdaUpdate().set(MallAddress::getIsDefault,PublicCommon.非默认) + .ne(MallAddress::getId,addressUpdateReq.getId()) + .eq(MallAddress::getIsDefault,PublicCommon.默认) + .eq(MallAddress::getUserId,userVo.getUserId()) + .eq(MallAddress::getUserType,userVo.getUserType()) + .update(); + } + + BeanUtils.copyProperties(addressUpdateReq, address); + + this.baseMapper.updateById(address); + + return ResponseData.success(address); + } + + @Override + public ResponseData setDefault(Long id) { + + MallAddress address = baseMapper.selectById(id); + + if (address == null) { + throw new CustomException(CoreExceptionEnum.RESOURCES_NOT_EXIST); + } + + //修改后的状态 + Integer isDefault = ObjectUtil.equal(address.getIsDefault(),PublicCommon.默认)?PublicCommon.非默认:PublicCommon.默认; + + //默认地址唯一,用户拥有默认地址,改为非默认 + if (ObjectUtil.equal(PublicCommon.默认,isDefault)){ + this.lambdaUpdate().set(MallAddress::getIsDefault,PublicCommon.非默认) + .ne(MallAddress::getId,id) + .eq(MallAddress::getIsDefault,PublicCommon.默认) + .eq(MallAddress::getUserId,address.getUserId()) + .eq(MallAddress::getUserType,address.getUserType()) + .update(); + } + + boolean update = this.update().set("is_default", isDefault).eq("id", id).update(); + if (!update){ + throw new CustomException(CoreExceptionEnum.UPDATE_DATA); + } + + return ResponseData.success(); + } + + @Override + public ResponseData deleteAddressById(List addressIds,UserVo userVo) { + + this.lambdaUpdate().set(MallAddress::getDelFlag,PublicCommon.删除) + .in(addressIds != null && addressIds.size() > 0 ,MallAddress::getId,addressIds) + .eq(MallAddress::getUserType,userVo.getUserType()) + .eq(MallAddress::getUserId,userVo.getUserId()) + .ne(MallAddress::getDelFlag,PublicCommon.删除) + .update(); + + return ResponseData.success(); + } + + @Override + public ResponseData getDefaultAddress(UserVo userVo) { + MallAddress address = this.baseMapper.selectOne(Wrappers.lambdaQuery() + .eq(MallAddress::getIsDefault, PublicCommon.默认) + .eq(MallAddress::getUserId, userVo.getUserId()) + .eq(MallAddress::getUserType,userVo.getUserType()) + .eq(MallAddress::getDelFlag, PublicCommon.启用) + .last("limit 1") + ); + return ResponseData.success(address); + } +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallevaluate/controller/MallEvaluateController.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallevaluate/controller/MallEvaluateController.java new file mode 100644 index 0000000..29e6c95 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallevaluate/controller/MallEvaluateController.java @@ -0,0 +1,97 @@ +package com.ruoyi.frequency.mallevaluate.controller; + +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.page.TableDataInfo; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.common.utils.poi.ExcelUtil; +import com.ruoyi.frequency.mallevaluate.entity.MallEvaluate; +import com.ruoyi.frequency.mallevaluate.service.MallEvaluateService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +/** + * 商城订单评价Controller + * + * @author liwenlong + * @date 2024-01-25 + */ +@RestController +@RequestMapping("/frequency/mallevaluate") +public class MallEvaluateController extends BaseController +{ + @Autowired + private MallEvaluateService mallEvaluateService; + + /** + * 查询商城订单评价列表 + */ + @PreAuthorize("@ss.hasPermi('frequency:mallevaluate:list')") + @GetMapping("/list") + public TableDataInfo list(MallEvaluate mallEvaluate) + { + startPage(); + List list = mallEvaluateService.selectMallEvaluateList(mallEvaluate); + return getDataTable(list); + } + + /** + * 导出商城订单评价列表 + */ + @PreAuthorize("@ss.hasPermi('frequency:mallevaluate:export')") + @Log(title = "商城订单评价", businessType = BusinessType.EXPORT) + @GetMapping("/export") + public AjaxResult export(MallEvaluate mallEvaluate) + { + List list = mallEvaluateService.selectMallEvaluateList(mallEvaluate); + ExcelUtil util = new ExcelUtil(MallEvaluate.class); + return util.exportExcel(list, "商城订单评价数据"); + } + + /** + * 获取商城订单评价详细信息 + */ + @PreAuthorize("@ss.hasPermi('frequency:mallevaluate:query')") + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") Long id) + { + return AjaxResult.success(mallEvaluateService.selectMallEvaluateById(id)); + } + + /** + * 新增商城订单评价 + */ + @PreAuthorize("@ss.hasPermi('frequency:mallevaluate:add')") + @Log(title = "商城订单评价", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody MallEvaluate mallEvaluate) + { + return toAjax(mallEvaluateService.insertMallEvaluate(mallEvaluate)); + } + + /** + * 修改商城订单评价 + */ + @PreAuthorize("@ss.hasPermi('frequency:mallevaluate:edit')") + @Log(title = "商城订单评价", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody MallEvaluate mallEvaluate) + { + return toAjax(mallEvaluateService.updateMallEvaluate(mallEvaluate)); + } + + /** + * 删除商城订单评价 + */ + @PreAuthorize("@ss.hasPermi('frequency:mallevaluate:remove')") + @Log(title = "商城订单评价", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}/{delFlag}") + public AjaxResult remove(@PathVariable("ids") Long[] ids,@PathVariable("delFlag") Integer delFlag) + { + return toAjax(mallEvaluateService.deleteMallEvaluateByIds(ids,delFlag)); + } +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallevaluate/entity/MallEvaluate.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallevaluate/entity/MallEvaluate.java new file mode 100644 index 0000000..62fa737 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallevaluate/entity/MallEvaluate.java @@ -0,0 +1,63 @@ +package com.ruoyi.frequency.mallevaluate.entity; + +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableName; +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import com.ruoyi.vo.UserInfo; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; + +import java.math.BigDecimal; + +/** + * 商城订单评价对象 mall_evaluate + * + * @author liwenlong + * @date 2024-01-25 + */ +@Data +@Accessors(chain = true) +@TableName("mall_evaluate") +public class MallEvaluate extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + + @ApiModelProperty("主键id") + private Long id; + + @ApiModelProperty("删除标志;1正常 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("用户类型 1设计师 2表现师") + @Excel(name = "用户类型 1设计师 2表现师") + private Integer userType; + + @ApiModelProperty("用户id") + @Excel(name = "用户id") + private Long userId; + + @ApiModelProperty("订单id") + @Excel(name = "订单id") + private Long orderId; + + @ApiModelProperty("评价星级;1~5个星级") + @Excel(name = "评价星级;1~5个星级") + private BigDecimal star; + + @ApiModelProperty("评价内容") + @Excel(name = "评价内容") + private String content; + + @ApiModelProperty("评价图片") + @Excel(name = "评价图片") + private String images; + + @ApiModelProperty("用户信息") + @TableField(exist = false) + private UserInfo userInfo; + + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallevaluate/mapper/MallEvaluateMapper.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallevaluate/mapper/MallEvaluateMapper.java new file mode 100644 index 0000000..f46fd75 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallevaluate/mapper/MallEvaluateMapper.java @@ -0,0 +1,48 @@ +package com.ruoyi.frequency.mallevaluate.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.ruoyi.frequency.mallevaluate.entity.MallEvaluate; + +import java.util.List; + +/** + * 商城订单评价Mapper接口 + * + * @author liwenlong + * @date 2024-01-25 + */ +public interface MallEvaluateMapper extends BaseMapper +{ + /** + * 查询商城订单评价 + * + * @param id 商城订单评价主键 + * @return 商城订单评价 + */ + public MallEvaluate selectMallEvaluateById(Long id); + + /** + * 查询商城订单评价列表 + * + * @param mallEvaluate 商城订单评价 + * @return 商城订单评价集合 + */ + public List selectMallEvaluateList(MallEvaluate mallEvaluate); + + /** + * 新增商城订单评价 + * + * @param mallEvaluate 商城订单评价 + * @return 结果 + */ + public int insertMallEvaluate(MallEvaluate mallEvaluate); + + /** + * 修改商城订单评价 + * + * @param mallEvaluate 商城订单评价 + * @return 结果 + */ + public int updateMallEvaluate(MallEvaluate mallEvaluate); + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallevaluate/mapper/mapping/MallEvaluateMapper.xml b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallevaluate/mapper/mapping/MallEvaluateMapper.xml new file mode 100644 index 0000000..7950b91 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallevaluate/mapper/mapping/MallEvaluateMapper.xml @@ -0,0 +1,109 @@ + + + + + + + + + + + + + + + + + + + + + select + t.id , + t.create_user , + t.create_time , + t.update_user , + t.update_time , + t.del_flag , + t.user_type , + t.user_id , + t.order_id , + t.star , + t.content , + t.images + from mall_evaluate AS t + + + + + + + + insert into mall_evaluate + + id, + create_user, + create_time, + update_user, + update_time, + del_flag, + user_type, + user_id, + order_id, + star, + content, + images, + + + #{id}, + #{createUser}, + #{createTime}, + #{updateUser}, + #{updateTime}, + #{delFlag}, + #{userType}, + #{userId}, + #{orderId}, + #{star}, + #{content}, + #{images}, + + + + + update mall_evaluate + + create_user = #{createUser}, + create_time = #{createTime}, + update_user = #{updateUser}, + update_time = #{updateTime}, + del_flag = #{delFlag}, + user_type = #{userType}, + user_id = #{userId}, + order_id = #{orderId}, + star = #{star}, + content = #{content}, + images = #{images}, + + where id = #{id} + + diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallevaluate/model/param/MallEvaluateParam.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallevaluate/model/param/MallEvaluateParam.java new file mode 100644 index 0000000..036791a --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallevaluate/model/param/MallEvaluateParam.java @@ -0,0 +1,72 @@ +package com.ruoyi.frequency.mallevaluate.model.param; + +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; + +import java.math.BigDecimal; + +/** + * 商城订单评价对象 mall_evaluate + * + * @author liwenlong + * @date 2024-01-25 + */ +@Data +@Accessors(chain = true) +public class MallEvaluateParam extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + @ApiModelProperty("主键id") + private Long id; + + @ApiModelProperty("创建人") + @Excel(name = "创建人") + private Long createUser; + + @ApiModelProperty("更新人") + @Excel(name = "更新人") + private Long updateUser; + + @ApiModelProperty("删除标志;1正常 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("用户类型 1设计师 2表现师") + @Excel(name = "用户类型 1设计师 2表现师") + private Integer userType; + + @ApiModelProperty("用户id") + @Excel(name = "用户id") + private Long userId; + + @ApiModelProperty("订单id") + @Excel(name = "订单id") + private Long orderId; + + @ApiModelProperty("评价星级;1~5个星级") + @Excel(name = "评价星级;1~5个星级") + private BigDecimal star; + + @ApiModelProperty("评价内容") + @Excel(name = "评价内容") + private String content; + + @ApiModelProperty("评价图片") + @Excel(name = "评价图片") + private String images; + + + + + + + + + + + + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallevaluate/model/result/MallEvaluateResult.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallevaluate/model/result/MallEvaluateResult.java new file mode 100644 index 0000000..6b52909 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallevaluate/model/result/MallEvaluateResult.java @@ -0,0 +1,62 @@ +package com.ruoyi.frequency.mallevaluate.model.result; + +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; + +import java.math.BigDecimal; + +/** + * 商城订单评价对象 mall_evaluate + * + * @author liwenlong + * @date 2024-01-25 + */ +@Data +@Accessors(chain = true) +public class MallEvaluateResult extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + @ApiModelProperty("主键id") + private Long id; + + @ApiModelProperty("创建人") + @Excel(name = "创建人") + private Long createUser; + + @ApiModelProperty("更新人") + @Excel(name = "更新人") + private Long updateUser; + + @ApiModelProperty("删除标志;1正常 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("用户类型 1设计师 2表现师") + @Excel(name = "用户类型 1设计师 2表现师") + private Integer userType; + + @ApiModelProperty("用户id") + @Excel(name = "用户id") + private Long userId; + + @ApiModelProperty("订单id") + @Excel(name = "订单id") + private Long orderId; + + @ApiModelProperty("评价星级;1~5个星级") + @Excel(name = "评价星级;1~5个星级") + private BigDecimal star; + + @ApiModelProperty("评价内容") + @Excel(name = "评价内容") + private String content; + + @ApiModelProperty("评价图片") + @Excel(name = "评价图片") + private String images; + + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallevaluate/service/MallEvaluateService.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallevaluate/service/MallEvaluateService.java new file mode 100644 index 0000000..148dca8 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallevaluate/service/MallEvaluateService.java @@ -0,0 +1,56 @@ +package com.ruoyi.frequency.mallevaluate.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.ruoyi.frequency.mallevaluate.entity.MallEvaluate; + +import java.util.List; + +/** + * 商城订单评价Service接口 + * + * @author liwenlong + * @date 2024-01-25 + */ +public interface MallEvaluateService extends IService +{ + /** + * 查询商城订单评价 + * + * @param id 商城订单评价主键 + * @return 商城订单评价 + */ + public MallEvaluate selectMallEvaluateById(Long id); + + /** + * 查询商城订单评价列表 + * + * @param mallEvaluate 商城订单评价 + * @return 商城订单评价集合 + */ + public List selectMallEvaluateList(MallEvaluate mallEvaluate); + + /** + * 新增商城订单评价 + * + * @param mallEvaluate 商城订单评价 + * @return 结果 + */ + public int insertMallEvaluate(MallEvaluate mallEvaluate); + + /** + * 修改商城订单评价 + * + * @param mallEvaluate 商城订单评价 + * @return 结果 + */ + public int updateMallEvaluate(MallEvaluate mallEvaluate); + + /** + * 批量删除商城订单评价 + * + * @param ids 需要删除的商城订单评价主键集合 + * @return 结果 + */ + public int deleteMallEvaluateByIds(Long[] ids,Integer delFlag); + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallevaluate/service/impl/MallEvaluateServiceImpl.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallevaluate/service/impl/MallEvaluateServiceImpl.java new file mode 100644 index 0000000..cabc04f --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallevaluate/service/impl/MallEvaluateServiceImpl.java @@ -0,0 +1,87 @@ +package com.ruoyi.frequency.mallevaluate.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.ruoyi.frequency.mallevaluate.entity.MallEvaluate; +import com.ruoyi.frequency.mallevaluate.mapper.MallEvaluateMapper; +import com.ruoyi.frequency.mallevaluate.service.MallEvaluateService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * 商城订单评价Service业务层处理 + * + * @author liwenlong + * @date 2024-01-25 + */ +@Service +public class MallEvaluateServiceImpl extends ServiceImpl implements MallEvaluateService +{ + @Autowired + private MallEvaluateMapper mallEvaluateMapper; + + /** + * 查询商城订单评价 + * + * @param id 商城订单评价主键 + * @return 商城订单评价 + */ + @Override + public MallEvaluate selectMallEvaluateById(Long id) + { + return mallEvaluateMapper.selectMallEvaluateById(id); + } + + /** + * 查询商城订单评价列表 + * + * @param mallEvaluate 商城订单评价 + * @return 商城订单评价 + */ + @Override + public List selectMallEvaluateList(MallEvaluate mallEvaluate) + { + return mallEvaluateMapper.selectMallEvaluateList(mallEvaluate); + } + + /** + * 新增商城订单评价 + * + * @param mallEvaluate 商城订单评价 + * @return 结果 + */ + @Override + public int insertMallEvaluate(MallEvaluate mallEvaluate) + { + mallEvaluate.setCreateData(); + return mallEvaluateMapper.insert(mallEvaluate); + } + + /** + * 修改商城订单评价 + * + * @param mallEvaluate 商城订单评价 + * @return 结果 + */ + @Override + public int updateMallEvaluate(MallEvaluate mallEvaluate) + { + mallEvaluate.setUpdateData(); + return mallEvaluateMapper.updateMallEvaluate(mallEvaluate); + } + + /** + * 批量删除商城订单评价 + * + * @param ids 需要删除的商城订单评价主键 + * @return 结果 + */ + @Override + public int deleteMallEvaluateByIds(Long[] ids,Integer delFlag) + { + this.lambdaUpdate().set(MallEvaluate::getDelFlag,delFlag).in(MallEvaluate::getId,ids).update(); + return ids.length; + } + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallgoods/controller/MallGoodsController.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallgoods/controller/MallGoodsController.java new file mode 100644 index 0000000..ddc1a0b --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallgoods/controller/MallGoodsController.java @@ -0,0 +1,97 @@ +package com.ruoyi.frequency.mallgoods.controller; + +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.page.TableDataInfo; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.common.utils.poi.ExcelUtil; +import com.ruoyi.frequency.mallgoods.entity.MallGoods; +import com.ruoyi.frequency.mallgoods.service.MallGoodsService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +/** + * 商品Controller + * + * @author liwenlong + * @date 2024-01-25 + */ +@RestController +@RequestMapping("/frequency/mallgoods") +public class MallGoodsController extends BaseController +{ + @Autowired + private MallGoodsService mallGoodsService; + + /** + * 查询商品列表 + */ + @PreAuthorize("@ss.hasPermi('frequency:mallgoods:list')") + @PostMapping("/list") + public TableDataInfo list(@RequestBody MallGoods mallGoods) + { + startPage(); + List list = mallGoodsService.selectMallGoodsList(mallGoods); + return getDataTable(list); + } + + /** + * 导出商品列表 + */ + @PreAuthorize("@ss.hasPermi('frequency:mallgoods:export')") + @Log(title = "商品", businessType = BusinessType.EXPORT) + @GetMapping("/export") + public AjaxResult export(MallGoods mallGoods) + { + List list = mallGoodsService.selectMallGoodsList(mallGoods); + ExcelUtil util = new ExcelUtil(MallGoods.class); + return util.exportExcel(list, "商品数据"); + } + + /** + * 获取商品详细信息 + */ + @PreAuthorize("@ss.hasPermi('frequency:mallgoods:query')") + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") Long id) + { + return AjaxResult.success(mallGoodsService.selectMallGoodsById(id)); + } + + /** + * 新增商品 + */ + @PreAuthorize("@ss.hasPermi('frequency:mallgoods:add')") + @Log(title = "商品", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody MallGoods mallGoods) + { + return toAjax(mallGoodsService.insertMallGoods(mallGoods)); + } + + /** + * 修改商品 + */ + @PreAuthorize("@ss.hasPermi('frequency:mallgoods:edit')") + @Log(title = "商品", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody MallGoods mallGoods) + { + return toAjax(mallGoodsService.updateMallGoods(mallGoods)); + } + + /** + * 删除商品 + */ + @PreAuthorize("@ss.hasPermi('frequency:mallgoods:remove')") + @Log(title = "商品", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}/{delFlag}") + public AjaxResult remove(@PathVariable("ids") Long[] ids,@PathVariable("delFlag") Integer delFlag) + { + return toAjax(mallGoodsService.deleteMallGoodsByIds(ids,delFlag)); + } +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallgoods/entity/MallGoods.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallgoods/entity/MallGoods.java new file mode 100644 index 0000000..2e79216 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallgoods/entity/MallGoods.java @@ -0,0 +1,108 @@ +package com.ruoyi.frequency.mallgoods.entity; + +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableName; +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import com.ruoyi.frequency.mallspecifications.entity.MallSpecifications; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; + +import java.math.BigDecimal; +import java.util.Date; +import java.util.List; + +/** + * 商品对象 mall_goods + * + * @author liwenlong + * @date 2024-01-25 + */ +@Data +@Accessors(chain = true) +@TableName("mall_goods") +public class MallGoods extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + + @ApiModelProperty("主键id") + private Long id; + + @ApiModelProperty("删除标志;1正常 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("商品名称") + @Excel(name = "商品名称") + private String name; + + @ApiModelProperty("封面图") + @Excel(name = "封面图") + private String coverImage; + + @ApiModelProperty("分类id") + @Excel(name = "分类id") + private Long goodsTypeId; + + @ApiModelProperty("描述") + @Excel(name = "描述") + private String describes; + + @ApiModelProperty("轮播图") + @Excel(name = "轮播图") + private String rotationImages; + + @ApiModelProperty("销量") + @Excel(name = "销量") + private Integer sales; + + @ApiModelProperty("规格类型;1 单规格 2 多规格") + @Excel(name = "规格类型;1 单规格 2 多规格") + private Integer specType; + + @ApiModelProperty("评分") + @Excel(name = "评分") + private BigDecimal star; + + @ApiModelProperty("价格(展示用)") + @Excel(name = "价格(展示用)") + private String price; + + @ApiModelProperty("商品详情(富文本)") + @Excel(name = "商品详情(富文本)") + private String detail; + + @ApiModelProperty("外链") + @Excel(name = "外链") + private String goodsUrl; + + @ApiModelProperty("1 淘宝 2 京东") + @Excel(name = "1 淘宝 2 京东") + private Integer urlType; + + @ApiModelProperty("上架时间") + @Excel(name = "上架时间") + private Date listingTime; + + @ApiModelProperty("商品类型名称") + @TableField(exist = false) + private String typeName; + + @ApiModelProperty("限制人数") + @Excel(name = "限制人数") + private Integer limitNum; + + @ApiModelProperty("规格") + @TableField(exist = false) + private List specificationsList; + + @ApiModelProperty("开始时间") + @TableField(exist = false) + private Date beginTime; + + @ApiModelProperty("结束时间") + @TableField(exist = false) + private Date endTime; + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallgoods/mapper/MallGoodsMapper.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallgoods/mapper/MallGoodsMapper.java new file mode 100644 index 0000000..f3acba2 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallgoods/mapper/MallGoodsMapper.java @@ -0,0 +1,62 @@ +package com.ruoyi.frequency.mallgoods.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.ruoyi.controller.req.GoodsPageReq; +import com.ruoyi.controller.resp.GoodsDetailResp; +import com.ruoyi.controller.resp.GoodsPageResp; +import com.ruoyi.frequency.mallgoods.entity.MallGoods; +import com.ruoyi.frequency.mallspecifications.entity.MallSpecifications; +import com.ruoyi.vo.UserVo; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * 商品Mapper接口 + * + * @author liwenlong + * @date 2024-01-25 + */ +public interface MallGoodsMapper extends BaseMapper +{ + /** + * 查询商品 + * + * @param id 商品主键 + * @return 商品 + */ + public MallGoods selectMallGoodsById(Long id); + + /** + * 查询商品列表 + * + * @param mallGoods 商品 + * @return 商品集合 + */ + public List selectMallGoodsList(MallGoods mallGoods); + + /** + * 新增商品 + * + * @param mallGoods 商品 + * @return 结果 + */ + public int insertMallGoods(MallGoods mallGoods); + + /** + * 修改商品 + * + * @param mallGoods 商品 + * @return 结果 + */ + public int updateMallGoods(MallGoods mallGoods); + + Page goodsPage(@Param("page") Page objectPage, @Param("req") GoodsPageReq req, @Param("userVo") UserVo userVo); + + GoodsDetailResp goodsDetail(@Param("goodsId") Long goodsId, @Param("userVo") UserVo userVo); + + Boolean addSales(@Param("list") List mallGoodsList ); + + Boolean subSales(@Param("list") List mallGoodsList ); +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallgoods/mapper/mapping/MallGoodsMapper.xml b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallgoods/mapper/mapping/MallGoodsMapper.xml new file mode 100644 index 0000000..a9bc924 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallgoods/mapper/mapping/MallGoodsMapper.xml @@ -0,0 +1,285 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + select + t.id , + t.create_by , + t.create_time , + t.update_by , + t.update_time , + t.del_flag , + t.name , + t.cover_image , + t.goods_type_id , + t.describes , + t.rotation_images , + t.sales , + t.spec_type , + t.star , + t.price , + t.detail , + t.goods_url , + t.url_type, + t.limit_num, + gt.name AS typeName + from mall_goods AS t + LEFT JOIN mall_goods_type AS gt ON t.goods_type_id = gt.id + + + + + + + + + insert into mall_goods + + id, + create_by, + create_time, + update_by, + update_time, + del_flag, + name, + cover_image, + goods_type_id, + describes, + rotation_images, + sales, + spec_type, + star, + price, + detail, + goods_url, + url_type, + + + #{id}, + #{createBy}, + #{createTime}, + #{updateBy}, + #{updateTime}, + #{delFlag}, + #{name}, + #{coverImage}, + #{goodsTypeId}, + #{describes}, + #{rotationImages}, + #{sales}, + #{speType}, + #{star}, + #{price}, + #{detail}, + #{goodsUrl}, + #{urlType}, + + + + + update mall_goods + + create_by = #{createBy}, + create_time = #{createTime}, + update_by = #{updateBy}, + update_time = #{updateTime}, + del_flag = #{delFlag}, + name = #{name}, + cover_image = #{coverImage}, + goods_type_id = #{goodsTypeId}, + describes = #{describes}, + rotation_images = #{rotationImages}, + sales = #{sales}, + spec_type = #{specType}, + star = #{star}, + price = #{price}, + detail = #{detail}, + goods_url = #{goodsUrl}, + url_type = #{urlType}, + + where id = #{id} + + + + + + + + + + update mall_goods + + sales = sales - #{item.sales} + + where id = #{item.id} + AND sales >= #{item.sales} + + + + + + update mall_goods + + sales = sales + #{item.sales} + + where id = #{item.id} + + + diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallgoods/model/param/MallGoodsParam.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallgoods/model/param/MallGoodsParam.java new file mode 100644 index 0000000..b94d701 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallgoods/model/param/MallGoodsParam.java @@ -0,0 +1,92 @@ +package com.ruoyi.frequency.mallgoods.model.param; + +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; + +import java.math.BigDecimal; + +/** + * 商品对象 mall_goods + * + * @author liwenlong + * @date 2024-01-25 + */ +@Data +@Accessors(chain = true) +public class MallGoodsParam extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + @ApiModelProperty("主键id") + private Long id; + + @ApiModelProperty("删除标志;1正常 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("商品名称") + @Excel(name = "商品名称") + private String name; + + @ApiModelProperty("封面图") + @Excel(name = "封面图") + private String coverImage; + + @ApiModelProperty("分类id") + @Excel(name = "分类id") + private Long goodsTypeId; + + @ApiModelProperty("描述") + @Excel(name = "描述") + private String describes; + + @ApiModelProperty("轮播图") + @Excel(name = "轮播图") + private String rotationImages; + + @ApiModelProperty("销量") + @Excel(name = "销量") + private Long sales; + + @ApiModelProperty("规格类型;1 单规格 2 多规格") + @Excel(name = "规格类型;1 单规格 2 多规格") + private Integer speType; + + @ApiModelProperty("评分") + @Excel(name = "评分") + private BigDecimal star; + + @ApiModelProperty("价格(展示用)") + @Excel(name = "价格(展示用)") + private String price; + + @ApiModelProperty("商品详情(富文本)") + @Excel(name = "商品详情(富文本)") + private String detail; + + @ApiModelProperty("外链") + @Excel(name = "外链") + private String goodsUrl; + + @ApiModelProperty("1 淘宝 2 京东") + @Excel(name = "1 淘宝 2 京东") + private Integer urlType; + + + + + + + + + + + + + + + + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallgoods/model/result/MallGoodsResult.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallgoods/model/result/MallGoodsResult.java new file mode 100644 index 0000000..a6986aa --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallgoods/model/result/MallGoodsResult.java @@ -0,0 +1,78 @@ +package com.ruoyi.frequency.mallgoods.model.result; + +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; + +import java.math.BigDecimal; + +/** + * 商品对象 mall_goods + * + * @author liwenlong + * @date 2024-01-25 + */ +@Data +@Accessors(chain = true) +public class MallGoodsResult extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + @ApiModelProperty("主键id") + private Long id; + + @ApiModelProperty("删除标志;1正常 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("商品名称") + @Excel(name = "商品名称") + private String name; + + @ApiModelProperty("封面图") + @Excel(name = "封面图") + private String coverImage; + + @ApiModelProperty("分类id") + @Excel(name = "分类id") + private Long goodsTypeId; + + @ApiModelProperty("描述") + @Excel(name = "描述") + private String describes; + + @ApiModelProperty("轮播图") + @Excel(name = "轮播图") + private String rotationImages; + + @ApiModelProperty("销量") + @Excel(name = "销量") + private Long sales; + + @ApiModelProperty("规格类型;1 单规格 2 多规格") + @Excel(name = "规格类型;1 单规格 2 多规格") + private Integer speType; + + @ApiModelProperty("评分") + @Excel(name = "评分") + private BigDecimal star; + + @ApiModelProperty("价格(展示用)") + @Excel(name = "价格(展示用)") + private String price; + + @ApiModelProperty("商品详情(富文本)") + @Excel(name = "商品详情(富文本)") + private String detail; + + @ApiModelProperty("外链") + @Excel(name = "外链") + private String goodsUrl; + + @ApiModelProperty("1 淘宝 2 京东") + @Excel(name = "1 淘宝 2 京东") + private Integer urlType; + + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallgoods/service/MallGoodsService.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallgoods/service/MallGoodsService.java new file mode 100644 index 0000000..6133a26 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallgoods/service/MallGoodsService.java @@ -0,0 +1,74 @@ +package com.ruoyi.frequency.mallgoods.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.ruoyi.controller.req.GoodsPageReq; +import com.ruoyi.frequency.mallgoods.entity.MallGoods; +import com.ruoyi.response.ResponseData; +import com.ruoyi.vo.UserVo; + +import java.util.List; + +/** + * 商品Service接口 + * + * @author liwenlong + * @date 2024-01-25 + */ +public interface MallGoodsService extends IService +{ + /** + * 查询商品 + * + * @param id 商品主键 + * @return 商品 + */ + public MallGoods selectMallGoodsById(Long id); + + /** + * 查询商品列表 + * + * @param mallGoods 商品 + * @return 商品集合 + */ + public List selectMallGoodsList(MallGoods mallGoods); + + /** + * 新增商品 + * + * @param mallGoods 商品 + * @return 结果 + */ + public int insertMallGoods(MallGoods mallGoods); + + /** + * 修改商品 + * + * @param mallGoods 商品 + * @return 结果 + */ + public int updateMallGoods(MallGoods mallGoods); + + /** + * 批量删除商品 + * + * @param ids 需要删除的商品主键集合 + * @return 结果 + */ + public int deleteMallGoodsByIds(Long[] ids,Integer delFlag); + + /** + * 商品列表 + * @param req + * @param userVo + * @return + */ + ResponseData goodsPage(GoodsPageReq req, UserVo userVo); + + /** + * 商品列表_详情 + * @param goodsId + * @param userVo + * @return + */ + ResponseData goodsDetail(Long goodsId, UserVo userVo); +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallgoods/service/impl/MallGoodsServiceImpl.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallgoods/service/impl/MallGoodsServiceImpl.java new file mode 100644 index 0000000..697771b --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallgoods/service/impl/MallGoodsServiceImpl.java @@ -0,0 +1,192 @@ +package com.ruoyi.frequency.mallgoods.service.impl; + +import cn.hutool.core.util.ObjectUtil; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.ruoyi.code.PublicCommon; +import com.ruoyi.common.core.domain.BaseEntity; +import com.ruoyi.common.page.PageResult; +import com.ruoyi.controller.req.GoodsPageReq; +import com.ruoyi.controller.resp.GoodsDetailResp; +import com.ruoyi.controller.resp.GoodsPageResp; +import com.ruoyi.frequency.mallgoods.entity.MallGoods; +import com.ruoyi.frequency.mallgoods.mapper.MallGoodsMapper; +import com.ruoyi.frequency.mallgoods.service.MallGoodsService; +import com.ruoyi.frequency.mallspecifications.entity.MallSpecifications; +import com.ruoyi.frequency.mallspecifications.service.MallSpecificationsService; +import com.ruoyi.response.ResponseData; +import com.ruoyi.vo.UserVo; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +/** + * 商品Service业务层处理 + * + * @author liwenlong + * @date 2024-01-25 + */ +@Service +public class MallGoodsServiceImpl extends ServiceImpl implements MallGoodsService +{ + @Autowired + private MallGoodsMapper mallGoodsMapper; + + /** + * 查询商品 + * + * @param id 商品主键 + * @return 商品 + */ + @Override + public MallGoods selectMallGoodsById(Long id) + { + + MallGoods mallGoods = mallGoodsMapper.selectMallGoodsById(id); + + if (mallGoods != null){ + List mallSpecificationsList = specificationsService.selectMallSpecificationsList(new MallSpecifications().setDelFlag(PublicCommon.启用).setGoodsId(id)); + mallGoods.setSpecificationsList(mallSpecificationsList); + } + return mallGoods; + } + + /** + * 查询商品列表 + * + * @param mallGoods 商品 + * @return 商品 + */ + @Override + public List selectMallGoodsList(MallGoods mallGoods) + { + return mallGoodsMapper.selectMallGoodsList(mallGoods); + } + + /** + * 新增商品 + * + * @param goods 商品 + * @return 结果 + */ + @Override + @Transactional(rollbackFor = Exception.class) + public int insertMallGoods(MallGoods goods) + { + + if (ObjectUtil.notEqual(PublicCommon.禁用,goods.getDelFlag())){ + //上架时间 + goods.setListingTime(new Date()); + } + // 将dto转为实体 + boolean save = this.save(goods); + + if (save && goods.getSpecificationsList().size() > 0){ + //关联规格 + goods.getSpecificationsList().stream().forEach(s->{ + s.setGoodsId(goods.getId()); + }); + specificationsService.saveBatch(goods.getSpecificationsList()); + } + return 1; + } + + /** + * 修改商品 + * + * @param goods 商品 + * @return 结果 + */ + @Override + public int updateMallGoods(MallGoods goods) + { + this.updateById(goods); + + //关联规格 + if (goods.getSpecificationsList().size() > 0){ + + List specIds = new ArrayList<>(); + goods.getSpecificationsList().stream().forEach(s->{ + if (ObjectUtil.isEmpty(s.getId())){ + s.setGoodsId(goods.getId()); + }else { + specIds.add(s.getId()); + } + }); + //删除 + specificationsService.remove(new QueryWrapper().lambda() + .eq(MallSpecifications::getGoodsId,goods.getId()) + .notIn(specIds.size() > 0,MallSpecifications::getGoodsId,specIds)); + + specificationsService.saveOrUpdateBatch(goods.getSpecificationsList()); + } + return 1; + } + + /** + * 批量删除商品 + * + * @param ids 需要删除的商品主键 + * @return 结果 + */ + @Override + public int deleteMallGoodsByIds(Long[] ids,Integer delFlag) + { + this.lambdaUpdate().set(MallGoods::getDelFlag,delFlag) + .set(ObjectUtil.equal(PublicCommon.启用,delFlag),MallGoods::getListingTime,new Date()) + .in(MallGoods::getId,ids).update(); + return ids.length; + } + + @Autowired + private MallSpecificationsService specificationsService; + + @Override + public ResponseData goodsPage(GoodsPageReq req, UserVo userVo) { + + Page page = this.baseMapper.goodsPage(new Page<>(req.getPageNo(),req.getPageSize()),req,userVo); + + if (page.getRecords().size() > 0){ + + page.getRecords().stream().forEach(s->{ + //商品规格 + List specifications = specificationsService.getBaseMapper().selectList(new QueryWrapper().lambda() + .eq(MallSpecifications::getGoodsId, s.getId()) + .eq(MallSpecifications::getDelFlag, PublicCommon.启用).orderByDesc(BaseEntity::getCreateTime)); + + s.setGoodsSpecList(specifications); + }); + + } + + return ResponseData.success(new PageResult<>(page)); + } + + + @Override + public ResponseData goodsDetail(Long goodsId, UserVo userVo) { + GoodsDetailResp goodsDetailResp = this.baseMapper.goodsDetail(goodsId,userVo); + + if (goodsDetailResp != null){ + //商品规格 + List specifications = specificationsService.getBaseMapper().selectList(new QueryWrapper().lambda() + .eq(MallSpecifications::getGoodsId, goodsId) +// .gt(MallSpecifications::getStock,BigDecimal.ZERO) + .eq(MallSpecifications::getDelFlag, PublicCommon.启用).orderByDesc(BaseEntity::getCreateTime)); + goodsDetailResp.setGoodsSpecList(specifications); + + Integer sales = 0; + for (MallSpecifications spec : specifications) { + sales = sales + spec.getSales(); + } + goodsDetailResp.setSales(sales); + } + return ResponseData.success(goodsDetailResp); + } +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallgoodstype/controller/MallGoodsTypeController.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallgoodstype/controller/MallGoodsTypeController.java new file mode 100644 index 0000000..623be34 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallgoodstype/controller/MallGoodsTypeController.java @@ -0,0 +1,97 @@ +package com.ruoyi.frequency.mallgoodstype.controller; + +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.page.TableDataInfo; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.common.utils.poi.ExcelUtil; +import com.ruoyi.frequency.mallgoodstype.entity.MallGoodsType; +import com.ruoyi.frequency.mallgoodstype.service.MallGoodsTypeService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +/** + * 商品类型Controller + * + * @author liwenlong + * @date 2024-01-25 + */ +@RestController +@RequestMapping("/frequency/mallgoodstype") +public class MallGoodsTypeController extends BaseController +{ + @Autowired + private MallGoodsTypeService mallGoodsTypeService; + + /** + * 查询商品类型列表 + */ + @PreAuthorize("@ss.hasPermi('frequency:mallgoodstype:list')") + @PostMapping("/list") + public TableDataInfo list(@RequestBody MallGoodsType mallGoodsType) + { + startPage(); + List list = mallGoodsTypeService.selectMallGoodsTypeList(mallGoodsType); + return getDataTable(list); + } + + /** + * 导出商品类型列表 + */ + @PreAuthorize("@ss.hasPermi('frequency:mallgoodstype:export')") + @Log(title = "商品类型", businessType = BusinessType.EXPORT) + @GetMapping("/export") + public AjaxResult export(MallGoodsType mallGoodsType) + { + List list = mallGoodsTypeService.selectMallGoodsTypeList(mallGoodsType); + ExcelUtil util = new ExcelUtil(MallGoodsType.class); + return util.exportExcel(list, "商品类型数据"); + } + + /** + * 获取商品类型详细信息 + */ + @PreAuthorize("@ss.hasPermi('frequency:mallgoodstype:query')") + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") Long id) + { + return AjaxResult.success(mallGoodsTypeService.selectMallGoodsTypeById(id)); + } + + /** + * 新增商品类型 + */ + @PreAuthorize("@ss.hasPermi('frequency:mallgoodstype:add')") + @Log(title = "商品类型", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody MallGoodsType mallGoodsType) + { + return toAjax(mallGoodsTypeService.insertMallGoodsType(mallGoodsType)); + } + + /** + * 修改商品类型 + */ + @PreAuthorize("@ss.hasPermi('frequency:mallgoodstype:edit')") + @Log(title = "商品类型", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody MallGoodsType mallGoodsType) + { + return toAjax(mallGoodsTypeService.updateMallGoodsType(mallGoodsType)); + } + + /** + * 删除商品类型 + */ + @PreAuthorize("@ss.hasPermi('frequency:mallgoodstype:remove')") + @Log(title = "商品类型", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}/{delFlag}") + public AjaxResult remove(@PathVariable("ids") Long[] ids,@PathVariable("delFlag") Integer delFlag) + { + return toAjax(mallGoodsTypeService.deleteMallGoodsTypeByIds(ids,delFlag)); + } +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallgoodstype/entity/MallGoodsType.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallgoodstype/entity/MallGoodsType.java new file mode 100644 index 0000000..06deed7 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallgoodstype/entity/MallGoodsType.java @@ -0,0 +1,44 @@ +package com.ruoyi.frequency.mallgoodstype.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; + +/** + * 商品类型对象 mall_goods_type + * + * @author liwenlong + * @date 2024-01-25 + */ +@Data +@Accessors(chain = true) +@TableName("mall_goods_type") +public class MallGoodsType extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + + @ApiModelProperty("租户号") + private Long id; + + @ApiModelProperty("乐观锁") + private Integer delFlag; + + @ApiModelProperty("商品分类名称") + @Excel(name = "商品分类名称") + private String name; + + @ApiModelProperty("排序") + @Excel(name = "排序") + private Long sort; + + @ApiModelProperty("logo") + @Excel(name = "logo") + private String logo; + + + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallgoodstype/mapper/MallGoodsTypeMapper.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallgoodstype/mapper/MallGoodsTypeMapper.java new file mode 100644 index 0000000..43613d1 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallgoodstype/mapper/MallGoodsTypeMapper.java @@ -0,0 +1,48 @@ +package com.ruoyi.frequency.mallgoodstype.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.ruoyi.frequency.mallgoodstype.entity.MallGoodsType; + +import java.util.List; + +/** + * 商品类型Mapper接口 + * + * @author liwenlong + * @date 2024-01-25 + */ +public interface MallGoodsTypeMapper extends BaseMapper +{ + /** + * 查询商品类型 + * + * @param id 商品类型主键 + * @return 商品类型 + */ + public MallGoodsType selectMallGoodsTypeById(Long id); + + /** + * 查询商品类型列表 + * + * @param mallGoodsType 商品类型 + * @return 商品类型集合 + */ + public List selectMallGoodsTypeList(MallGoodsType mallGoodsType); + + /** + * 新增商品类型 + * + * @param mallGoodsType 商品类型 + * @return 结果 + */ + public int insertMallGoodsType(MallGoodsType mallGoodsType); + + /** + * 修改商品类型 + * + * @param mallGoodsType 商品类型 + * @return 结果 + */ + public int updateMallGoodsType(MallGoodsType mallGoodsType); + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallgoodstype/mapper/mapping/MallGoodsTypeMapper.xml b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallgoodstype/mapper/mapping/MallGoodsTypeMapper.xml new file mode 100644 index 0000000..ced0298 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallgoodstype/mapper/mapping/MallGoodsTypeMapper.xml @@ -0,0 +1,92 @@ + + + + + + + + + + + + + + + + + + + + select + t.id , + t.del_flag , + t.create_by , + t.create_time , + t.update_by , + t.update_time , + t.name , + t.sort , + t.logo + from mall_goods_type AS t + + + + + + + + + insert into mall_goods_type + + id, + del_flag, + create_by, + create_time, + update_by, + update_time, + name, + sort, + logo, + + + #{id}, + #{delFlag}, + #{createBy}, + #{createTime}, + #{updateBy}, + #{updateTime}, + #{name}, + #{sort}, + #{logo}, + + + + + update mall_goods_type + + del_flag = #{delFlag}, + create_by = #{createBy}, + create_time = #{createTime}, + update_by = #{updateBy}, + update_time = #{updateTime}, + name = #{name}, + sort = #{sort}, + logo = #{logo}, + + where id = #{id} + + diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallgoodstype/model/param/MallGoodsTypeParam.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallgoodstype/model/param/MallGoodsTypeParam.java new file mode 100644 index 0000000..3494c41 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallgoodstype/model/param/MallGoodsTypeParam.java @@ -0,0 +1,45 @@ +package com.ruoyi.frequency.mallgoodstype.model.param; + +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; + +/** + * 商品类型对象 mall_goods_type + * + * @author liwenlong + * @date 2024-01-25 + */ +@Data +@Accessors(chain = true) +public class MallGoodsTypeParam extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + @ApiModelProperty("租户号") + private Long id; + + @ApiModelProperty("乐观锁") + private Integer delFlag; + + @ApiModelProperty("商品分类名称") + @Excel(name = "商品分类名称") + private String name; + + @ApiModelProperty("排序") + @Excel(name = "排序") + private Long sort; + + @ApiModelProperty("logo") + @Excel(name = "logo") + private String logo; + + + + + + + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallgoodstype/model/result/MallGoodsTypeResult.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallgoodstype/model/result/MallGoodsTypeResult.java new file mode 100644 index 0000000..94a6ca8 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallgoodstype/model/result/MallGoodsTypeResult.java @@ -0,0 +1,40 @@ +package com.ruoyi.frequency.mallgoodstype.model.result; + +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; + +/** + * 商品类型对象 mall_goods_type + * + * @author liwenlong + * @date 2024-01-25 + */ +@Data +@Accessors(chain = true) +public class MallGoodsTypeResult extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + @ApiModelProperty("租户号") + private Long id; + + @ApiModelProperty("乐观锁") + private Integer delFlag; + + @ApiModelProperty("商品分类名称") + @Excel(name = "商品分类名称") + private String name; + + @ApiModelProperty("排序") + @Excel(name = "排序") + private Long sort; + + @ApiModelProperty("logo") + @Excel(name = "logo") + private String logo; + + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallgoodstype/service/MallGoodsTypeService.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallgoodstype/service/MallGoodsTypeService.java new file mode 100644 index 0000000..0f0da19 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallgoodstype/service/MallGoodsTypeService.java @@ -0,0 +1,56 @@ +package com.ruoyi.frequency.mallgoodstype.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.ruoyi.frequency.mallgoodstype.entity.MallGoodsType; + +import java.util.List; + +/** + * 商品类型Service接口 + * + * @author liwenlong + * @date 2024-01-25 + */ +public interface MallGoodsTypeService extends IService +{ + /** + * 查询商品类型 + * + * @param id 商品类型主键 + * @return 商品类型 + */ + public MallGoodsType selectMallGoodsTypeById(Long id); + + /** + * 查询商品类型列表 + * + * @param mallGoodsType 商品类型 + * @return 商品类型集合 + */ + public List selectMallGoodsTypeList(MallGoodsType mallGoodsType); + + /** + * 新增商品类型 + * + * @param mallGoodsType 商品类型 + * @return 结果 + */ + public int insertMallGoodsType(MallGoodsType mallGoodsType); + + /** + * 修改商品类型 + * + * @param mallGoodsType 商品类型 + * @return 结果 + */ + public int updateMallGoodsType(MallGoodsType mallGoodsType); + + /** + * 批量删除商品类型 + * + * @param ids 需要删除的商品类型主键集合 + * @return 结果 + */ + public int deleteMallGoodsTypeByIds(Long[] ids,Integer delFlag); + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallgoodstype/service/impl/MallGoodsTypeServiceImpl.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallgoodstype/service/impl/MallGoodsTypeServiceImpl.java new file mode 100644 index 0000000..1ba577e --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallgoodstype/service/impl/MallGoodsTypeServiceImpl.java @@ -0,0 +1,87 @@ +package com.ruoyi.frequency.mallgoodstype.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.ruoyi.frequency.mallgoodstype.entity.MallGoodsType; +import com.ruoyi.frequency.mallgoodstype.mapper.MallGoodsTypeMapper; +import com.ruoyi.frequency.mallgoodstype.service.MallGoodsTypeService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * 商品类型Service业务层处理 + * + * @author liwenlong + * @date 2024-01-25 + */ +@Service +public class MallGoodsTypeServiceImpl extends ServiceImpl implements MallGoodsTypeService +{ + @Autowired + private MallGoodsTypeMapper mallGoodsTypeMapper; + + /** + * 查询商品类型 + * + * @param id 商品类型主键 + * @return 商品类型 + */ + @Override + public MallGoodsType selectMallGoodsTypeById(Long id) + { + return mallGoodsTypeMapper.selectMallGoodsTypeById(id); + } + + /** + * 查询商品类型列表 + * + * @param mallGoodsType 商品类型 + * @return 商品类型 + */ + @Override + public List selectMallGoodsTypeList(MallGoodsType mallGoodsType) + { + return mallGoodsTypeMapper.selectMallGoodsTypeList(mallGoodsType); + } + + /** + * 新增商品类型 + * + * @param mallGoodsType 商品类型 + * @return 结果 + */ + @Override + public int insertMallGoodsType(MallGoodsType mallGoodsType) + { + mallGoodsType.setCreateData(); + return mallGoodsTypeMapper.insert(mallGoodsType); + } + + /** + * 修改商品类型 + * + * @param mallGoodsType 商品类型 + * @return 结果 + */ + @Override + public int updateMallGoodsType(MallGoodsType mallGoodsType) + { + mallGoodsType.setUpdateData(); + return mallGoodsTypeMapper.updateMallGoodsType(mallGoodsType); + } + + /** + * 批量删除商品类型 + * + * @param ids 需要删除的商品类型主键 + * @return 结果 + */ + @Override + public int deleteMallGoodsTypeByIds(Long[] ids,Integer delFlag) + { + this.lambdaUpdate().set(MallGoodsType::getDelFlag,delFlag).in(MallGoodsType::getId,ids).update(); + return ids.length; + } + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallorder/controller/MallOrderController.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallorder/controller/MallOrderController.java new file mode 100644 index 0000000..e58acab --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallorder/controller/MallOrderController.java @@ -0,0 +1,123 @@ +package com.ruoyi.frequency.mallorder.controller; + +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.page.TableDataInfo; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.common.utils.poi.ExcelUtil; +import com.ruoyi.frequency.mallorder.entity.MallOrder; +import com.ruoyi.frequency.mallorder.model.result.MallOrderCount; +import com.ruoyi.frequency.mallorder.service.MallOrderService; +import com.ruoyi.frequency.store.entity.Store; +import com.ruoyi.frequency.store.model.result.StoreCount; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +/** + * 订单主Controller + * + * @author liwenlong + * @date 2024-01-25 + */ +@RestController +@RequestMapping("/frequency/mallorder") +public class MallOrderController extends BaseController +{ + @Autowired + private MallOrderService mallOrderService; + + /** + * 查询订单主列表 + */ + //@PreAuthorize("@ss.hasPermi('frequency:mallorder:list')") + @PostMapping("/list") + public TableDataInfo list(@RequestBody MallOrder mallOrder) + { + startPage(); + List list = mallOrderService.selectMallOrderList(mallOrder); + return getDataTable(list); + } + + /** + * 统计 + */ + @PostMapping("/statistics") + public AjaxResult statistics(@RequestBody MallOrder mallOrder) + { + MallOrderCount count = mallOrderService.statistics(mallOrder); + return AjaxResult.success(count); + } + + + + /** + * 导出订单主列表 + */ + //@PreAuthorize("@ss.hasPermi('frequency:mallorder:export')") + @Log(title = "订单主", businessType = BusinessType.EXPORT) + @GetMapping("/export") + public AjaxResult export(MallOrder mallOrder) + { + List list = mallOrderService.selectMallOrderList(mallOrder); + ExcelUtil util = new ExcelUtil(MallOrder.class); + return util.exportExcel(list, "订单主数据"); + } + + /** + * 获取订单主详细信息 + */ + //@PreAuthorize("@ss.hasPermi('frequency:mallorder:query')") + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") Long id) + { + return AjaxResult.success(mallOrderService.selectMallOrderById(id)); + } + + /** + * 新增订单主 + */ + //@PreAuthorize("@ss.hasPermi('frequency:mallorder:add')") + @Log(title = "订单主", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody MallOrder mallOrder) + { + return toAjax(mallOrderService.insertMallOrder(mallOrder)); + } + + /** + * 修改订单主 + */ + //@PreAuthorize("@ss.hasPermi('frequency:mallorder:edit')") + @Log(title = "订单主", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody MallOrder mallOrder) + { + return toAjax(mallOrderService.updateMallOrder(mallOrder)); + } + + /** + * 删除订单主 + */ + //@PreAuthorize("@ss.hasPermi('frequency:mallorder:remove')") + @Log(title = "订单主", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}/{delFlag}") + public AjaxResult remove(@PathVariable("ids") Long[] ids,@PathVariable("delFlag") Integer delFlag) + { + return toAjax(mallOrderService.deleteMallOrderByIds(ids,delFlag)); + } + + /** + * 发送货 + * + * @author 李文龙 + * @date 2022/01/13 14:19 + */ + @PostMapping("/send") + @Log(title = "订单主", businessType = BusinessType.UPDATE) + public AjaxResult send(@RequestBody MallOrder mallOrder) { + return mallOrderService.send(mallOrder); + } +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallorder/entity/MallOrder.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallorder/entity/MallOrder.java new file mode 100644 index 0000000..5639fec --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallorder/entity/MallOrder.java @@ -0,0 +1,179 @@ +package com.ruoyi.frequency.mallorder.entity; + +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableName; +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import com.ruoyi.frequency.mallevaluate.entity.MallEvaluate; +import com.ruoyi.frequency.mallorderaddress.entity.MallOrderAddress; +import com.ruoyi.frequency.mallordergoods.entity.MallOrderGoods; +import com.ruoyi.vo.UserInfo; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; + +import java.math.BigDecimal; +import java.util.Date; +import java.util.List; + +/** + * 订单主对象 mall_order + * + * @author liwenlong + * @date 2024-01-25 + */ +@Data +@Accessors(chain = true) +@TableName("mall_order") +public class MallOrder extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + + @ApiModelProperty("主键id") + private Long id; + + @ApiModelProperty("删除标志;1正常 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("用户类型 1设计师 2表现师") + @Excel(name = "用户类型 1设计师 2表现师") + private Integer userType; + + @ApiModelProperty("用户id") + @Excel(name = "用户id") + private Long userId; + + @ApiModelProperty("商品总价") + @Excel(name = "商品总价") + private BigDecimal goodsPrice; + + @ApiModelProperty("支付总价格") + @Excel(name = "支付总价格") + private BigDecimal payPrice; + + @ApiModelProperty("订单号(不作为支付订单号)") + @Excel(name = "订单号(不作为支付订单号)") + private String orderNo; + + @ApiModelProperty("支付订单号") + @Excel(name = "支付订单号") + private String payOrderNo; + + @ApiModelProperty("支付状态1:未支付;2:成功,3;失败") + @Excel(name = "支付状态1:未支付;2:成功,3;失败") + private Integer payStatus; + + @ApiModelProperty("订单状态;具体看代码") + @Excel(name = "订单状态;具体看代码") + private Integer orderStatus; + + @ApiModelProperty("支付时间") + @Excel(name = "支付时间", width = 30, dateFormat = "yyyy-MM-dd") + private Date payTime; + + @ApiModelProperty("取消订单时间") + @Excel(name = "取消订单时间", width = 30, dateFormat = "yyyy-MM-dd") + private Date cancelTime; + + @ApiModelProperty("发货时间") + @Excel(name = "发货时间", width = 30, dateFormat = "yyyy-MM-dd") + private Date sendTime; + + @ApiModelProperty("收货时间") + @Excel(name = "收货时间", width = 30, dateFormat = "yyyy-MM-dd") + private Date receiveTime; + + @ApiModelProperty("完成时间") + @Excel(name = "完成时间", width = 30, dateFormat = "yyyy-MM-dd") + private Date completeTime; + + @ApiModelProperty("发货物流单号") + @Excel(name = "发货物流单号") + private String sendComCourierId; + + @ApiModelProperty("发货物流公司") + @Excel(name = "发货物流公司") + private String sendComLogistics; + + @ApiModelProperty("发货物流公司编码") + @Excel(name = "发货物流公司编码") + private String sendComLogisticsCode; + + @ApiModelProperty("支付方式,1:支付宝;2 微信 3 余额") + @Excel(name = "支付方式,1:支付宝;2 微信 3 余额") + private Integer payType; + + @ApiModelProperty("支付宝支付业务号") + @Excel(name = "支付宝支付业务号") + private String aliReturnPayId; + + @ApiModelProperty("到账时间") + @Excel(name = "到账时间", width = 30, dateFormat = "yyyy-MM-dd") + private Date arrivalTime; + + @ApiModelProperty("允许售后时间(类似于7日包退),单位;天") + @Excel(name = "允许售后时间", readConverterExp = "类=似于7日包退") + private Integer afterSalesDays; + + @ApiModelProperty("用户是否删除; 1 没有删除 2 删除") + @Excel(name = "用户是否删除; 1 没有删除 2 删除") + private Integer customerShow; + + @ApiModelProperty("订单商品id") + @Excel(name = "订单商品id") + private Long orderGoodsId; + + @ApiModelProperty("抵用金支付金额") + @Excel(name = "抵用金支付金额") + private BigDecimal givePrice; + + @ApiModelProperty("积分") + @Excel(name = "积分") + private BigDecimal integralPrice; + + @ApiModelProperty("备注") + private String remark; + + @ApiModelProperty("用户信息") + @TableField(exist = false) + private UserInfo userInfo; + + @ApiModelProperty("字典code") + @TableField(exist = false) + private String dictCode; + + @ApiModelProperty("订单地址") + @TableField(exist = false) + private MallOrderAddress orderAddress; + + @ApiModelProperty("订单商品") + @TableField(exist = false) + private List mallOrderGoods; + + @ApiModelProperty("评价") + @TableField(exist = false) + private MallEvaluate evaluate; + + //管理后台列表筛选项 + @ApiModelProperty("用户昵称") + @TableField(exist = false) + private String name; + + @ApiModelProperty("用户编号") + @TableField(exist = false) + private String nickname; + + @ApiModelProperty("用户手机号") + @TableField(exist = false) + private String mobile; + + + @ApiModelProperty("开始时间") + @TableField(exist = false) + private Date beginTime; + + @ApiModelProperty("结束时间") + @TableField(exist = false) + private Date endTime; +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallorder/mapper/MallOrderMapper.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallorder/mapper/MallOrderMapper.java new file mode 100644 index 0000000..3690cc0 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallorder/mapper/MallOrderMapper.java @@ -0,0 +1,68 @@ +package com.ruoyi.frequency.mallorder.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.ruoyi.controller.req.MallOrderPageReq; +import com.ruoyi.controller.resp.MallOrderDetailResp; +import com.ruoyi.controller.resp.MallOrderPageResp; +import com.ruoyi.frequency.mallorder.entity.MallOrder; +import com.ruoyi.frequency.mallorder.model.result.MallOrderCount; +import com.ruoyi.vo.UserVo; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * 订单主Mapper接口 + * + * @author liwenlong + * @date 2024-01-25 + */ +public interface MallOrderMapper extends BaseMapper +{ + /** + * 查询订单主 + * + * @param id 订单主主键 + * @return 订单主 + */ + public MallOrder selectMallOrderById(Long id); + + /** + * 查询订单主列表 + * + * @param mallOrder 订单主 + * @return 订单主集合 + */ + public List selectMallOrderList(MallOrder mallOrder); + + /** + * 新增订单主 + * + * @param mallOrder 订单主 + * @return 结果 + */ + public int insertMallOrder(MallOrder mallOrder); + + /** + * 修改订单主 + * + * @param mallOrder 订单主 + * @return 结果 + */ + public int updateMallOrder(MallOrder mallOrder); + + List selectOrderNeedConfirmReceipt(@Param("days") Integer days); + + List arrivalAmount(); + + Page orderPage(@Param("page") Page objectPage, @Param("req") MallOrderPageReq req, @Param("userVo")UserVo userVo); + + MallOrderDetailResp orderDetail(@Param("orderId") Long orderId); + + List orderList(@Param("list") List mallOrderIds,@Param("userVo") UserVo userVo); + + Integer hasBuyNum(@Param("goodsId")Long goodsId, @Param("userVo")UserVo userVo); + + MallOrderCount statistics(@Param("list")List mallOrderIdList); +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallorder/mapper/mapping/MallOrderMapper.xml b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallorder/mapper/mapping/MallOrderMapper.xml new file mode 100644 index 0000000..7bc10e1 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallorder/mapper/mapping/MallOrderMapper.xml @@ -0,0 +1,493 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + select + t.id , + t.create_by , + t.create_time , + t.update_by , + t.update_time , + t.del_flag , + t.user_type , + t.user_id , + t.goods_price , + t.pay_price , + t.order_no , + t.pay_order_no , + t.pay_status , + t.order_status , + t.pay_time , + t.cancel_time , + t.send_time , + t.receive_time , + t.complete_time , + t.send_com_courier_id , + t.send_com_logistics , + t.send_com_logistics_code , + t.remark , + if(t.pay_price = 0,null,t.pay_type) pay_type, + t.ali_return_pay_id , + t.arrival_time , + t.after_sales_days , + t.customer_show , + t.order_goods_id , + t.give_price , + t.integral_price + from mall_order AS t + LEFT JOIN t_customer t2 on t.user_id = t2.id + + + + + + + + insert into mall_order + + id, + create_by, + create_time, + update_by, + update_time, + del_flag, + user_type, + user_id, + goods_price, + pay_price, + order_no, + pay_order_no, + pay_status, + order_status, + pay_time, + cancel_time, + send_time, + receive_time, + complete_time, + send_com_courier_id, + send_com_logistics, + send_com_logistics_code, + remark, + pay_type, + ali_return_pay_id, + arrival_time, + after_sales_days, + customer_show, + order_goods_id, + give_price, + integral_price, + + + #{id}, + #{createBy}, + #{createTime}, + #{updateBy}, + #{updateTime}, + #{delFlag}, + #{userType}, + #{userId}, + #{goodsPrice}, + #{payPrice}, + #{orderNo}, + #{payOrderNo}, + #{payStatus}, + #{orderStatus}, + #{payTime}, + #{cancelTime}, + #{sendTime}, + #{receiveTime}, + #{completeTime}, + #{sendComCourierId}, + #{sendComLogistics}, + #{sendComLogisticsCode}, + #{remark}, + #{payType}, + #{aliReturnPayId}, + #{arrivalTime}, + #{afterSalesDays}, + #{customerShow}, + #{orderGoodsId}, + #{givePrice}, + #{integralPrice}, + + + + + update mall_order + + create_by = #{createBy}, + create_time = #{createTime}, + update_by = #{updateBy}, + update_time = #{updateTime}, + del_flag = #{delFlag}, + user_type = #{userType}, + user_id = #{userId}, + goods_price = #{goodsPrice}, + pay_price = #{payPrice}, + order_no = #{orderNo}, + pay_order_no = #{payOrderNo}, + pay_status = #{payStatus}, + order_status = #{orderStatus}, + pay_time = #{payTime}, + cancel_time = #{cancelTime}, + send_time = #{sendTime}, + receive_time = #{receiveTime}, + complete_time = #{completeTime}, + send_com_courier_id = #{sendComCourierId}, + send_com_logistics = #{sendComLogistics}, + send_com_logistics_code = #{sendComLogisticsCode}, + remark = #{remark}, + pay_type = #{payType}, + ali_return_pay_id = #{aliReturnPayId}, + arrival_time = #{arrivalTime}, + after_sales_days = #{afterSalesDays}, + customer_show = #{customerShow}, + order_goods_id = #{orderGoodsId}, + give_price = #{givePrice}, + integral_price = #{integralPrice}, + + where id = #{id} + + + + + + + + + + + + + + + + + diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallorder/model/param/MallOrderParam.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallorder/model/param/MallOrderParam.java new file mode 100644 index 0000000..dd3dbc8 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallorder/model/param/MallOrderParam.java @@ -0,0 +1,153 @@ +package com.ruoyi.frequency.mallorder.model.param; + +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; + +import java.math.BigDecimal; +import java.util.Date; + +/** + * 订单主对象 mall_order + * + * @author liwenlong + * @date 2024-01-25 + */ +@Data +@Accessors(chain = true) +public class MallOrderParam extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + @ApiModelProperty("主键id") + private Long id; + + @ApiModelProperty("删除标志;1正常 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("用户类型 1设计师 2表现师") + @Excel(name = "用户类型 1设计师 2表现师") + private Integer userType; + + @ApiModelProperty("用户id") + @Excel(name = "用户id") + private Long userId; + + @ApiModelProperty("商品总价") + @Excel(name = "商品总价") + private BigDecimal goodsPrice; + + @ApiModelProperty("支付总价格") + @Excel(name = "支付总价格") + private BigDecimal payPrice; + + @ApiModelProperty("订单号(不作为支付订单号)") + @Excel(name = "订单号(不作为支付订单号)") + private String orderNo; + + @ApiModelProperty("支付订单号") + @Excel(name = "支付订单号") + private String payOrderNo; + + @ApiModelProperty("支付状态1:未支付;2:成功,3;失败") + @Excel(name = "支付状态1:未支付;2:成功,3;失败") + private Integer payStatus; + + @ApiModelProperty("订单状态;具体看代码") + @Excel(name = "订单状态;具体看代码") + private Integer orderStatus; + + @ApiModelProperty("支付时间") + @Excel(name = "支付时间", width = 30, dateFormat = "yyyy-MM-dd") + private Date payTime; + + @ApiModelProperty("取消订单时间") + @Excel(name = "取消订单时间", width = 30, dateFormat = "yyyy-MM-dd") + private Date cancelTime; + + @ApiModelProperty("发货时间") + @Excel(name = "发货时间", width = 30, dateFormat = "yyyy-MM-dd") + private Date sendTime; + + @ApiModelProperty("收货时间") + @Excel(name = "收货时间", width = 30, dateFormat = "yyyy-MM-dd") + private Date receiveTime; + + @ApiModelProperty("完成时间") + @Excel(name = "完成时间", width = 30, dateFormat = "yyyy-MM-dd") + private Date completeTime; + + @ApiModelProperty("发货物流单号") + @Excel(name = "发货物流单号") + private String sendComCourierId; + + @ApiModelProperty("发货物流公司") + @Excel(name = "发货物流公司") + private String sendComLogistics; + + @ApiModelProperty("发货物流公司编码") + @Excel(name = "发货物流公司编码") + private String sendComLogisticsCode; + + @ApiModelProperty("支付方式,1:支付宝;2 微信 3 余额") + @Excel(name = "支付方式,1:支付宝;2 微信 3 余额") + private Integer payType; + + @ApiModelProperty("支付宝支付业务号") + @Excel(name = "支付宝支付业务号") + private String aliReturnPayId; + + @ApiModelProperty("到账时间") + @Excel(name = "到账时间", width = 30, dateFormat = "yyyy-MM-dd") + private Date arrivalTime; + + @ApiModelProperty("允许售后时间(类似于7日包退),单位;天") + @Excel(name = "允许售后时间", readConverterExp = "类=似于7日包退") + private Long afterSalesDays; + + @ApiModelProperty("用户是否删除; 1 没有删除 2 删除") + @Excel(name = "用户是否删除; 1 没有删除 2 删除") + private Integer customerShow; + + @ApiModelProperty("订单商品id") + @Excel(name = "订单商品id") + private Long orderGoodsId; + + @ApiModelProperty("抵用金支付金额") + @Excel(name = "抵用金支付金额") + private BigDecimal givePrice; + + @ApiModelProperty("积分") + @Excel(name = "积分") + private BigDecimal integralPrice; + + + + + + + + + + + + + + + + + + + + + + + + + + + + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallorder/model/result/MallOrderCount.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallorder/model/result/MallOrderCount.java new file mode 100644 index 0000000..848f329 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallorder/model/result/MallOrderCount.java @@ -0,0 +1,18 @@ +package com.ruoyi.frequency.mallorder.model.result; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +@Data +public class MallOrderCount { + + @ApiModelProperty("总数量") + private Integer num =0; + + @ApiModelProperty("已发货数量") + private Integer hasSend =0; + + @ApiModelProperty("未发货数量") + private Integer notSend = 0; + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallorder/model/result/MallOrderResult.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallorder/model/result/MallOrderResult.java new file mode 100644 index 0000000..38f3b18 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallorder/model/result/MallOrderResult.java @@ -0,0 +1,127 @@ +package com.ruoyi.frequency.mallorder.model.result; + +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; + +import java.math.BigDecimal; +import java.util.Date; + +/** + * 订单主对象 mall_order + * + * @author liwenlong + * @date 2024-01-25 + */ +@Data +@Accessors(chain = true) +public class MallOrderResult extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + @ApiModelProperty("主键id") + private Long id; + + @ApiModelProperty("删除标志;1正常 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("用户类型 1设计师 2表现师") + @Excel(name = "用户类型 1设计师 2表现师") + private Integer userType; + + @ApiModelProperty("用户id") + @Excel(name = "用户id") + private Long userId; + + @ApiModelProperty("商品总价") + @Excel(name = "商品总价") + private BigDecimal goodsPrice; + + @ApiModelProperty("支付总价格") + @Excel(name = "支付总价格") + private BigDecimal payPrice; + + @ApiModelProperty("订单号(不作为支付订单号)") + @Excel(name = "订单号(不作为支付订单号)") + private String orderNo; + + @ApiModelProperty("支付订单号") + @Excel(name = "支付订单号") + private String payOrderNo; + + @ApiModelProperty("支付状态1:未支付;2:成功,3;失败") + @Excel(name = "支付状态1:未支付;2:成功,3;失败") + private Integer payStatus; + + @ApiModelProperty("订单状态;具体看代码") + @Excel(name = "订单状态;具体看代码") + private Integer orderStatus; + + @ApiModelProperty("支付时间") + @Excel(name = "支付时间", width = 30, dateFormat = "yyyy-MM-dd") + private Date payTime; + + @ApiModelProperty("取消订单时间") + @Excel(name = "取消订单时间", width = 30, dateFormat = "yyyy-MM-dd") + private Date cancelTime; + + @ApiModelProperty("发货时间") + @Excel(name = "发货时间", width = 30, dateFormat = "yyyy-MM-dd") + private Date sendTime; + + @ApiModelProperty("收货时间") + @Excel(name = "收货时间", width = 30, dateFormat = "yyyy-MM-dd") + private Date receiveTime; + + @ApiModelProperty("完成时间") + @Excel(name = "完成时间", width = 30, dateFormat = "yyyy-MM-dd") + private Date completeTime; + + @ApiModelProperty("发货物流单号") + @Excel(name = "发货物流单号") + private String sendComCourierId; + + @ApiModelProperty("发货物流公司") + @Excel(name = "发货物流公司") + private String sendComLogistics; + + @ApiModelProperty("发货物流公司编码") + @Excel(name = "发货物流公司编码") + private String sendComLogisticsCode; + + @ApiModelProperty("支付方式,1:支付宝;2 微信 3 余额") + @Excel(name = "支付方式,1:支付宝;2 微信 3 余额") + private Integer payType; + + @ApiModelProperty("支付宝支付业务号") + @Excel(name = "支付宝支付业务号") + private String aliReturnPayId; + + @ApiModelProperty("到账时间") + @Excel(name = "到账时间", width = 30, dateFormat = "yyyy-MM-dd") + private Date arrivalTime; + + @ApiModelProperty("允许售后时间(类似于7日包退),单位;天") + @Excel(name = "允许售后时间", readConverterExp = "类=似于7日包退") + private Long afterSalesDays; + + @ApiModelProperty("用户是否删除; 1 没有删除 2 删除") + @Excel(name = "用户是否删除; 1 没有删除 2 删除") + private Integer customerShow; + + @ApiModelProperty("订单商品id") + @Excel(name = "订单商品id") + private Long orderGoodsId; + + @ApiModelProperty("抵用金支付金额") + @Excel(name = "抵用金支付金额") + private BigDecimal givePrice; + + @ApiModelProperty("积分") + @Excel(name = "积分") + private BigDecimal integralPrice; + + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallorder/service/MallOrderService.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallorder/service/MallOrderService.java new file mode 100644 index 0000000..8e10c12 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallorder/service/MallOrderService.java @@ -0,0 +1,133 @@ +package com.ruoyi.frequency.mallorder.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.controller.req.*; +import com.ruoyi.controller.resp.MallOrderPageResp; +import com.ruoyi.frequency.mallorder.entity.MallOrder; +import com.ruoyi.frequency.mallorder.model.result.MallOrderCount; +import com.ruoyi.response.ResponseData; +import com.ruoyi.vo.PayVo; +import com.ruoyi.vo.UserVo; + +import java.util.List; + +/** + * 订单主Service接口 + * + * @author liwenlong + * @date 2024-01-25 + */ +public interface MallOrderService extends IService +{ + /** + * 查询订单主 + * + * @param id 订单主主键 + * @return 订单主 + */ + public MallOrder selectMallOrderById(Long id); + + /** + * 查询订单主列表 + * + * @param mallOrder 订单主 + * @return 订单主集合 + */ + public List selectMallOrderList(MallOrder mallOrder); + + /** + * 新增订单主 + * + * @param mallOrder 订单主 + * @return 结果 + */ + public int insertMallOrder(MallOrder mallOrder); + + /** + * 修改订单主 + * + * @param mallOrder 订单主 + * @return 结果 + */ + public int updateMallOrder(MallOrder mallOrder); + + /** + * 批量删除订单主 + * + * @param ids 需要删除的订单主主键集合 + * @return 结果 + */ + public int deleteMallOrderByIds(Long[] ids,Integer delFlag); + + /** + * 发货 + * @param mallOrder + * @return + */ + AjaxResult send(MallOrder mallOrder); + + /** + * 订单结算 + * @param req + * @param userVo + * @return + */ + PayVo settlement(MallSettlementReq req, UserVo userVo); + + /** + * 创建订单 + * @param req + * @param userVo + * @return + */ + ResponseData createOrder(CreateOrderReq req, UserVo userVo); + + /** + * 生成订单号 + * @param type + * @return + */ + public String generateOrderNo(Integer type); + + /** + * 支付后操作 + * @param order + */ + void after(MallOrder order); + + /** + * 商城订单列表 + * @param req + * @param userVo + * @return + */ + ResponseData orderPage(MallOrderPageReq req, UserVo userVo); + + List orderList(List mallOrderIds, UserVo userVo); + + ResponseData orderDetail(Long orderId, UserVo userVo); + + ResponseData orderPay(MallOrderPayReq req, UserVo userVo); + + ResponseData orderCancel(Long orderId, UserVo userVo); + + ResponseData orderRefund(Long orderId, UserVo userVo); + + ResponseData orderConfirm(MallOrderConfirmReq req, UserVo userVo); + + ResponseData orderAfterApply(ApplyAfterSalesReq req, UserVo userVo); + + ResponseData orderAfterDetail(Long orderId, UserVo userVo); + + ResponseData orderAfterRevokeApply(Long refundId, UserVo userVo); + + ResponseData customerDeliverGoods(CustomerDeliverGoodsReq req); + + + ResponseData evaluate(MallEvaluateReq req, UserVo userVo); + + ResponseData onceAgainCreateOrder(OnceAgainCreateOrderReq req, UserVo userVo); + + MallOrderCount statistics(MallOrder mallOrder); +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallorder/service/impl/MallOrderServiceImpl.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallorder/service/impl/MallOrderServiceImpl.java new file mode 100644 index 0000000..b491b69 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallorder/service/impl/MallOrderServiceImpl.java @@ -0,0 +1,858 @@ +package com.ruoyi.frequency.mallorder.service.impl; + +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.collection.CollectionUtil; +import cn.hutool.core.date.DateUtil; +import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.RandomUtil; +import com.alibaba.fastjson.JSONObject; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.ruoyi.code.DictConstant; +import com.ruoyi.code.PublicCommon; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.domain.entity.SysDictData; +import com.ruoyi.common.exception.CustomException; +import com.ruoyi.common.exception.ServiceException; +import com.ruoyi.common.page.PageResult; +import com.ruoyi.controller.req.*; +import com.ruoyi.controller.resp.MallOrderDetailResp; +import com.ruoyi.controller.resp.MallOrderPageResp; +import com.ruoyi.enums.IntegralDetailEnums; +import com.ruoyi.enums.MallExceptionEnum; +import com.ruoyi.enums.PlatformRecordEnums; +import com.ruoyi.enums.WalletDetailEnums; +import com.ruoyi.enums.mallorder.MallOrderStatusEnums; +import com.ruoyi.enums.mallorder.RefundStatusEnums; +import com.ruoyi.enums.message.OrderMessageEnums; +import com.ruoyi.frequency.customer.service.UserService; +import com.ruoyi.frequency.integralrecord.service.IntegralRecordService; +import com.ruoyi.frequency.mallevaluate.entity.MallEvaluate; +import com.ruoyi.frequency.mallevaluate.service.MallEvaluateService; +import com.ruoyi.frequency.mallgoods.entity.MallGoods; +import com.ruoyi.frequency.mallgoods.mapper.MallGoodsMapper; +import com.ruoyi.frequency.mallgoods.service.MallGoodsService; +import com.ruoyi.frequency.mallorder.entity.MallOrder; +import com.ruoyi.frequency.mallorder.mapper.MallOrderMapper; +import com.ruoyi.frequency.mallorder.model.result.MallOrderCount; +import com.ruoyi.frequency.mallorder.service.MallOrderService; +import com.ruoyi.frequency.mallorderaddress.entity.MallOrderAddress; +import com.ruoyi.frequency.mallorderaddress.service.MallOrderAddressService; +import com.ruoyi.frequency.mallordergoods.entity.MallOrderGoods; +import com.ruoyi.frequency.mallordergoods.service.MallOrderGoodsService; +import com.ruoyi.frequency.mallorderstatus.service.MallOrderStatusService; +import com.ruoyi.frequency.mallrefund.entity.MallRefund; +import com.ruoyi.frequency.mallrefund.service.MallRefundService; +import com.ruoyi.frequency.mallspecifications.entity.MallSpecifications; +import com.ruoyi.frequency.mallspecifications.mapper.MallSpecificationsMapper; +import com.ruoyi.frequency.mallspecifications.service.MallSpecificationsService; +import com.ruoyi.frequency.ordermessage.service.OrderMessageService; +import com.ruoyi.frequency.platformrecord.service.PlatformRecordService; +import com.ruoyi.pay.enums.PayEnums; +import com.ruoyi.pay.enums.PaySourceEnums; +import com.ruoyi.pay.utils.PayUtil; +import com.ruoyi.response.ResponseData; +import com.ruoyi.system.mapper.SysDictDataMapper; +import com.ruoyi.utils.BusinessUtil; +import com.ruoyi.vo.PayVo; +import com.ruoyi.vo.UserInfo; +import com.ruoyi.vo.UserVo; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.math.BigDecimal; +import java.util.*; +import java.util.stream.Collectors; + +/** + * 订单主Service业务层处理 + * + * @author liwenlong + * @date 2024-01-25 + */ +@Service +public class MallOrderServiceImpl extends ServiceImpl implements MallOrderService { + @Autowired + private MallOrderMapper mallOrderMapper; + + @Autowired + private MallOrderGoodsService orderGoodsService; + + /** + * 查询订单主 + * + * @param id 订单主主键 + * @return 订单主 + */ + @Override + public MallOrder selectMallOrderById(Long id) { + + MallOrder mallOrder = mallOrderMapper.selectMallOrderById(id); + + if (mallOrder != null) { + List mallOrderGoods = orderGoodsService.selectMallOrderGoodsList(new MallOrderGoods().setOrderId(id).setDelFlag(PublicCommon.启用)); + mallOrder.setMallOrderGoods(mallOrderGoods); + + Set userVoSet = CollectionUtil.newHashSet(new UserVo(mallOrder.getUserType(), mallOrder.getUserId())); + + //查询用户信息 + Map userMap = userService.selectUserInfoMap(userVoSet, null); + + mallOrder.setUserInfo(userMap.get(new UserVo(mallOrder.getUserType(), mallOrder.getUserId()))); + + //查询订单地址 + MallOrderAddress orderAddress = orderAddressService.getOne(new QueryWrapper().lambda() + .eq(MallOrderAddress::getOrderId, id) + .eq(MallOrderAddress::getDelFlag, PublicCommon.启用)); + mallOrder.setOrderAddress(orderAddress); + + //用户评价 + MallEvaluate evaluate = evaluateService.getOne(new QueryWrapper().lambda() + .eq(MallEvaluate::getOrderId, id) + .eq(MallEvaluate::getDelFlag, PublicCommon.启用)); + mallOrder.setEvaluate(evaluate); + + } + + return mallOrder; + } + + + @Autowired + private UserService userService; + + /** + * 查询订单主列表 + * + * @param mallOrder 订单主 + * @return 订单主 + */ + @Override + public List selectMallOrderList(MallOrder mallOrder) { + List mallOrders = mallOrderList(mallOrder); + if (mallOrders.size() > 0) { + + //获取订单id + List orderIdList = mallOrders.stream().map(MallOrder::getId).collect(Collectors.toList()); + //根据订单id 查询订单商品 + List orderGoodsList = orderGoodsService.orderGoodsList(orderIdList); + + //key 订单id value 订单商品 + Map> orderGoodsVOMap = orderGoodsList.stream().collect(Collectors.groupingBy(MallOrderGoods::getOrderId)); + + Set userVoSet = mallOrders.stream().map(s -> new UserVo(s.getUserType(), s.getUserId())).collect(Collectors.toSet()); + //查询用户信息 + Map userMap = userService.selectUserInfoMap(userVoSet, null); + + mallOrders.stream().forEach(s -> { + s.setMallOrderGoods(orderGoodsVOMap.get(s.getId())); + s.setUserInfo(userMap.get(new UserVo(s.getUserType(), s.getUserId()))); + }); + + } + + return mallOrders; + } + + private List mallOrderList(MallOrder mallOrder) { + List mallOrders = mallOrderMapper.selectMallOrderList(mallOrder); + return mallOrders; + } + + @Override + public MallOrderCount statistics(MallOrder mallOrder) { + List mallOrders = mallOrderList(mallOrder); + List mallOrderIdList = mallOrders.stream().map(x -> x.getId()).collect(Collectors.toList()); + mallOrderIdList.add(-1L); + + MallOrderCount count = mallOrderMapper.statistics(mallOrderIdList); + return count; + } + + /** + * 新增订单主 + * + * @param mallOrder 订单主 + * @return 结果 + */ + @Override + public int insertMallOrder(MallOrder mallOrder) { + mallOrder.setCreateData(); + return mallOrderMapper.insert(mallOrder); + } + + /** + * 修改订单主 + * + * @param mallOrder 订单主 + * @return 结果 + */ + @Override + public int updateMallOrder(MallOrder mallOrder) { + mallOrder.setUpdateData(); + return mallOrderMapper.updateMallOrder(mallOrder); + } + + /** + * 批量删除订单主 + * + * @param ids 需要删除的订单主主键 + * @return 结果 + */ + @Override + public int deleteMallOrderByIds(Long[] ids, Integer delFlag) { + this.lambdaUpdate().set(MallOrder::getDelFlag, delFlag).in(MallOrder::getId, ids).update(); + return ids.length; + } + + @Autowired + private OrderMessageService orderMessageService; + + @Override + public AjaxResult send(MallOrder mallOrder) { + MallOrder order = baseMapper.selectById(mallOrder.getId()); + + //判断订单是否是售后状态 + Integer count = refundService.count(new QueryWrapper().lambda() + .eq(MallRefund::getOrderId, mallOrder.getId()) + .eq(MallRefund::getDelFlag, PublicCommon.启用) + .eq(MallRefund::getStatus, 1) + ); + if (count > 0) { + return AjaxResult.error("退款申请中,请先处理退款申请"); + } + if (!order.getOrderStatus().equals(MallOrderStatusEnums.待发货.getCode())) { + return AjaxResult.error("订单状态错误 请刷新数据"); + } + order.setOrderStatus(MallOrderStatusEnums.已发货.getCode()); + order.setSendComCourierId(mallOrder.getSendComCourierId()); + + SysDictData dict = businessUtil.getDict(mallOrder.getDictCode()); + order.setSendComLogistics(dict.getDictLabel()); + order.setSendComLogisticsCode(dict.getDictValue()); + order.setSendTime(new Date()); + baseMapper.updateById(order); + + //订单流程状态 + orderStatusService.recordOrderStatus(order, MallOrderStatusEnums.已发货); + + //发送消息 + orderMessageService.addOrderMessage(new UserVo(order.getUserType(), order.getUserId()), order.getId(), "", PublicCommon.Order.商城订单, OrderMessageEnums.MALL_ORDER_SEND); + + return AjaxResult.success(); + } + + @Autowired + private MallSpecificationsService specificationsService; + + @Autowired + private MallGoodsService mallGoodsService; + + @Autowired + private BusinessUtil businessUtil; + + @Override + public PayVo settlement(MallSettlementReq req, UserVo userVo) { + + PayVo payVo = new PayVo(); + //规格 + MallSpecifications specifications = specificationsService.getById(req.getSpecId()); + + //限制购买数量 + MallGoods mallGoods = mallGoodsService.getById(specifications.getGoodsId()); + if (mallGoods.getLimitNum() != null && mallGoods.getLimitNum() > 0) { + //查询用户购买数量 + Integer hasBuyNum = baseMapper.hasBuyNum(mallGoods.getId(), userVo); + if (hasBuyNum + req.getQuantity() > mallGoods.getLimitNum()) { + Integer overNum = mallGoods.getLimitNum() - hasBuyNum; + throw new ServiceException("该商品每人限买" + mallGoods.getLimitNum() + "件,你还可购买" + (overNum < 0 ? 0 : overNum) + "件"); + } + } + + //支付金额 + BigDecimal price = specifications.getPrice().multiply(new BigDecimal(req.getQuantity())); + payVo.setPrice(price); + + //支付积分 + BigDecimal integral = specifications.getIntegral().multiply(new BigDecimal(req.getQuantity())); + payVo.setIntegral(integral); + + //最大使用赠送金额 + BigDecimal maxGivePrice = businessUtil.userMaxGivePrice(userVo, price); + payVo.setMaxGivePrice(maxGivePrice); + + return payVo; + } + + @Autowired + private MallGoodsService goodsService; + + @Autowired + private MallOrderAddressService orderAddressService; + + @Autowired + private PayUtil payUtil; + + @Override + @Transactional(rollbackFor = Exception.class) + public ResponseData createOrder(CreateOrderReq req, UserVo userVo) { + + //判断商品是否下架 + MallGoods goods = goodsService.getById(req.getGoodsId()); + MallSpecifications specifications = specificationsService.getById(req.getSpecId()); + + if (ObjectUtil.notEqual(PublicCommon.启用, goods.getDelFlag()) || ObjectUtil.notEqual(PublicCommon.启用, specifications.getDelFlag())) { + return ResponseData.error(MallExceptionEnum.GOODS_DEL_FLAG); + } + + //限制购买数量 + if (goods.getLimitNum() != null && goods.getLimitNum() > 0) { + //查询用户购买数量 + Integer hasBuyNum = baseMapper.hasBuyNum(goods.getId(), userVo); + if (hasBuyNum + req.getQuantity() > goods.getLimitNum()) { + throw new ServiceException("该商品每人限买" + goods.getLimitNum() + "件,你还可购买" + (goods.getLimitNum() - hasBuyNum) + "件"); + } + } + //计算金额 + PayVo payVo = settlement(new MallSettlementReq().setQuantity(req.getQuantity()).setSpecId(req.getSpecId()), userVo); + + //判断余额 + if (ObjectUtil.equal(PayEnums.balance.getCode(), req.getPayType())) { + businessUtil.judgeBalancePay(userVo, payVo.getPrice(), req.getBalancePayPwd()); + } + + //判断积分余额 + businessUtil.judgeIntegralPay(userVo, payVo.getIntegral(), req.getBalancePayPwd()); + + //扣除库存 + List specList = CollectionUtil.toList(new MallSpecifications().setId(req.getSpecId()).setStock(req.getQuantity())); + Boolean updateStock = specificationsMapper.subStock(specList); + if (!updateStock) { + throw new CustomException(MallExceptionEnum.NOT_STOCK); + } + + //组装订单 + MallOrder order = assembleOrder(userVo, req, payVo); + this.save(order); + + //关联订单商品中间表 + MallOrderGoods orderGoods = assembleOrderGoods(specifications, goods, req.getQuantity(), order.getId()); + orderGoodsService.save(orderGoods); + + //关联订单地址关联表 + MallOrderAddress orderAddress = orderAddressService.assembleOrderAddress(order.getId(), req.getAddressId()); + orderAddressService.saveOrUpdate(orderAddress); + + //记录订单状态 + orderStatusService.recordOrderStatus(order, MallOrderStatusEnums.待付款); + + //支付 + ResponseData responseData = payUtil.pay(userVo, order.getId(), req.getPayType(), payVo.getPrice().subtract(payVo.getMaxGivePrice()), payVo.getMaxGivePrice(), order.getPayOrderNo(), PaySourceEnums.mall_order_pay, WalletDetailEnums.MALL_ORDER_PAY); + + //支付成功/支付金额为0 + if (responseData.getSuccess() || responseData.getCode().equals(210)) { + //余额支付/苹果支付 + if (req.getPayType().equals(PayEnums.balance.getCode()) || req.getPayType().equals(PayEnums.apple.getCode())) { + after(order); + } + } + Map map = new HashMap<>(); + map.put("orderId", order.getId()); + responseData.setData(JSONObject.toJSON(map)); + return responseData; + } + + /** + * 组装订单商品 + * + * @param specifications + * @param goods + * @param buyNum + * @param orderId + * @return + */ + private MallOrderGoods assembleOrderGoods(MallSpecifications specifications, MallGoods goods, Integer buyNum, Long orderId) { + + //订单商品 + MallOrderGoods orderGoods = new MallOrderGoods() + .setGoodsName(goods.getName()) + .setOrderId(orderId) + .setGoodsImage(goods.getCoverImage()) + .setSpecImage(specifications.getImage()) + .setUnitPrice(specifications.getPrice()) + .setUnitIntegral(specifications.getIntegral()) + .setBuyNum(buyNum) + .setSpecName(specifications.getName()) + .setGoodsId(specifications.getGoodsId()) + .setSpecId(specifications.getId()); + + return orderGoods; + } + + /** + * 组装订单 + * + * @param userVo + * @param req + * @param payVo + * @return + */ + private MallOrder assembleOrder(UserVo userVo, CreateOrderReq req, PayVo payVo) { + + MallOrder order = new MallOrder() + .setOrderNo(generateOrderNo(1)) + .setUserId(userVo.getUserId()) + .setUserType(userVo.getUserType()) + .setGoodsPrice(payVo.getPrice()) + .setPayType(req.getPayType()) + .setRemark(req.getRemark()) + .setPayOrderNo(generateOrderNo(2)) + .setPayPrice(payVo.getPrice()) + .setOrderStatus(MallOrderStatusEnums.待付款.getCode()) + .setIntegralPrice(payVo.getIntegral()) + .setGivePrice(payVo.getMaxGivePrice()); + + //售后时间 + SysDictData dictOne = businessUtil.getDict(DictConstant.MallOrderDict.售后天数); + order.setAfterSalesDays(dictOne == null ? 7 : Integer.valueOf(dictOne.getDictValue())); + + return order; + } + + + /** + * 生成订单号 + * + * @param type 1订单号 2 支付单号 + * @return + */ + @Override + public String generateOrderNo(Integer type) { + String orderNo; + String prefix = type == 1 ? "JF" : "JFP"; + + while (true) { + orderNo = prefix + DateUtil.format(new Date(), "MMdd" + RandomUtil.randomNumbers(6)); + MallOrder old = this.getBaseMapper().selectOne(new QueryWrapper().lambda() + .eq(type == 1, MallOrder::getOrderNo, orderNo) + .eq(type == 2, MallOrder::getPayOrderNo, orderNo) + + ); + if (old == null) { + break; + } + } + return orderNo; + } + + @Autowired + private MallSpecificationsMapper specificationsMapper; + + @Autowired + private MallOrderStatusService orderStatusService; + + @Autowired + private IntegralRecordService integralRecordService; + + @Autowired + private MallGoodsMapper mallGoodsMapper; + + @Override + public void after(MallOrder order) { + + //扣除积分 + integralRecordService.updateIntegral(new UserVo(order.getUserType(), order.getUserId()), order.getId(), order.getIntegralPrice().negate(), IntegralDetailEnums.ORDER_PAY,null); + + //修改订单状态 + boolean update = this.lambdaUpdate().set(MallOrder::getOrderStatus, MallOrderStatusEnums.待发货.getCode()) + .set(MallOrder::getPayStatus, PublicCommon.Pay.已支付) + .set(MallOrder::getPayTime, new Date()) + .eq(MallOrder::getId, order.getId()) + .eq(MallOrder::getOrderStatus, MallOrderStatusEnums.待付款.getCode()) + .update(); + + if (update) { + //查询订单商品 + List orderGoods = orderGoodsService.list(new QueryWrapper().lambda() + .eq(MallOrderGoods::getOrderId, order.getId()) + .eq(MallOrderGoods::getDelFlag, PublicCommon.启用)); + + //增加销量 + List specList = orderGoods.stream().map(s -> new MallSpecifications().setId(s.getSpecId()).setSales(s.getBuyNum())).collect(Collectors.toList()); + specificationsMapper.addSales(specList); + + List mallGoodsList = orderGoods.stream().map(s -> new MallGoods().setId(s.getGoodsId()).setSales(s.getBuyNum())).collect(Collectors.toList()); + mallGoodsMapper.addSales(mallGoodsList); + + + //记录订单状态 + orderStatusService.recordOrderStatus(order, MallOrderStatusEnums.待发货); + } + + //订单消息 + orderMessageService.addOrderMessage(new UserVo(order.getUserType(), order.getUserId()), order.getId(), "", PublicCommon.Order.商城订单, OrderMessageEnums.MALL_PAY_ORDER); + + } + + @Override + public ResponseData orderPage(MallOrderPageReq req, UserVo userVo) { + Page page = this.baseMapper.orderPage(new Page<>(req.getPageNo(), req.getPageSize()), req, userVo); + + if (page.getRecords().size() > 0) { + + //获取订单id + List orderIdList = page.getRecords().stream().map(MallOrderPageResp::getOrderId).collect(Collectors.toList()); + //根据订单id 查询订单商品 + List orderGoodsList = orderGoodsService.orderGoodsList(orderIdList); + + //key 订单id value 订单商品 + Map> orderGoodsVOMap = orderGoodsList.stream().collect(Collectors.groupingBy(MallOrderGoods::getOrderId)); + + page.getRecords().stream().forEach(s -> { + s.setOrderGoodsList(orderGoodsVOMap.get(s.getOrderId())); + }); + + } + + return ResponseData.success(new PageResult<>(page)); + } + + @Override + public List orderList(List mallOrderIds, UserVo userVo) { + + if (mallOrderIds.size() == 0) { + return new ArrayList<>(); + } + + List list = this.baseMapper.orderList(mallOrderIds, userVo); + + if (list.size() > 0) { + + //获取订单id + List orderIdList = list.stream().map(MallOrderPageResp::getOrderId).collect(Collectors.toList()); + //根据订单id 查询订单商品 + List orderGoodsList = orderGoodsService.orderGoodsList(orderIdList); + + //key 订单id value 订单商品 + Map> orderGoodsVOMap = orderGoodsList.stream().collect(Collectors.groupingBy(MallOrderGoods::getOrderId)); + + list.stream().forEach(s -> { + s.setOrderGoodsList(orderGoodsVOMap.get(s.getOrderId())); + }); + + } + + return list; + } + + @Autowired + private MallEvaluateService evaluateService; + + @Override + public ResponseData orderDetail(Long orderId, UserVo userVo) { + MallOrderDetailResp orderDetailResp = this.baseMapper.orderDetail(orderId); + + if (orderDetailResp != null) { + List orderIdList = new ArrayList<>(); + orderIdList.add(orderId); + //根据订单id 查询订单商品 + List orderGoodsList = orderGoodsService.orderGoodsList(orderIdList); + orderDetailResp.setOrderGoodsList(orderGoodsList); + + //查询订单地址 + MallOrderAddress orderAddress = orderAddressService.getOne(new QueryWrapper().lambda() + .eq(MallOrderAddress::getOrderId, orderId) + .eq(MallOrderAddress::getDelFlag, PublicCommon.启用)); + orderDetailResp.setOrderAddress(orderAddress); + + //用户评价 + MallEvaluate evaluate = evaluateService.getOne(new QueryWrapper().lambda() + .eq(MallEvaluate::getOrderId, orderId) + .eq(MallEvaluate::getDelFlag, PublicCommon.启用)); + orderDetailResp.setEvaluate(evaluate); + } + + return ResponseData.success(orderDetailResp); + } + + @Override + public ResponseData orderPay(MallOrderPayReq req, UserVo userVo) { + return null; + } + + @Override + public ResponseData orderCancel(Long orderId, UserVo userVo) { + + MallOrder order = this.getById(orderId); + + //判断订单状态 + if (!order.getOrderStatus().equals(MallOrderStatusEnums.待付款.getCode())) { + return ResponseData.error(MallExceptionEnum.ORDER_STATUS_ERROR); + } + + //修改订单状态 + boolean update = this.lambdaUpdate().set(MallOrder::getOrderStatus, MallOrderStatusEnums.已取消.getCode()) + .eq(MallOrder::getOrderStatus, MallOrderStatusEnums.待付款.getCode()) + .eq(MallOrder::getId, orderId) + .update(); + if (update) { + //查询订单商品 + List orderGoods = orderGoodsService.list(new QueryWrapper().lambda() + .eq(MallOrderGoods::getOrderId, order.getId()) + .eq(MallOrderGoods::getDelFlag, PublicCommon.启用)); + + //添加库存 + List specList = orderGoods.stream().map(s -> new MallSpecifications().setId(s.getSpecId()).setStock(s.getBuyNum())).collect(Collectors.toList()); + specificationsMapper.subStock(specList); + + //记录订单状态 + orderStatusService.recordOrderStatus(order, MallOrderStatusEnums.已取消); + + } + + return ResponseData.success(); + } + + @Override + public ResponseData orderRefund(Long orderId, UserVo userVo) { + MallOrder order = this.getById(orderId); + + //判断订单状态 + if (!order.getOrderStatus().equals(MallOrderStatusEnums.待发货.getCode())) { + return ResponseData.error(MallExceptionEnum.ORDER_STATUS_ERROR); + } + + //修改订单状态 + boolean update = this.lambdaUpdate().set(MallOrder::getOrderStatus, MallOrderStatusEnums.已取消.getCode()) + .eq(MallOrder::getOrderStatus, MallOrderStatusEnums.待发货.getCode()) + .eq(MallOrder::getId, orderId) + .update(); + if (update) { + //查询订单商品 + List orderGoods = orderGoodsService.list(new QueryWrapper().lambda() + .eq(MallOrderGoods::getOrderId, order.getId()) + .eq(MallOrderGoods::getDelFlag, PublicCommon.启用)); + + //添加库存 + List specList = orderGoods.stream().map(s -> new MallSpecifications().setId(s.getSpecId()).setStock(s.getBuyNum()).setSales(s.getBuyNum())).collect(Collectors.toList()); + specificationsMapper.addStock(specList); + + //扣除销量 + specificationsMapper.subSales(specList); + + List mallGoodsList = orderGoods.stream().map(s -> new MallGoods().setId(s.getGoodsId()).setSales(s.getBuyNum())).collect(Collectors.toList()); + mallGoodsMapper.addSales(mallGoodsList); + + //退款 + ResponseData responseData = payUtil.refund(new UserVo(order.getUserType(), order.getUserId()), order.getId(), order.getPayType(), order.getPayPrice().subtract(order.getGivePrice()), order.getPayPrice().subtract(order.getGivePrice()), order.getPayOrderNo(), order.getAliReturnPayId(), order.getGivePrice()); + if (!responseData.getSuccess()) { + log.error("退款失败:" + order.getOrderNo()); + return responseData; + } + + //记录订单状态 + orderStatusService.recordOrderStatus(order, MallOrderStatusEnums.已取消); + + } + + return ResponseData.success(); + } + + @Override + public ResponseData orderConfirm(MallOrderConfirmReq req, UserVo userVo) { + + MallOrder order = baseMapper.selectById(req.getOrderId()); + + //判断该订单状态 + if (ObjectUtil.notEqual(MallOrderStatusEnums.已发货.getCode(), order.getOrderStatus())) { + return ResponseData.error(MallExceptionEnum.ORDER_STATUS_ERROR); + } + + //是否直接分佣(1用户确认收货直接到账,直接分佣 2 售后时间过后分佣) + Integer isDirect = 2; + + //是否允许退货 + if (isDirect == 2) { + + boolean update = this.lambdaUpdate().set(MallOrder::getOrderStatus, MallOrderStatusEnums.已完成.getCode()) + .set(MallOrder::getReceiveTime, new Date()) + .eq(MallOrder::getId, order.getId()).update(); + if (update) { + orderStatusService.recordOrderStatus(order, MallOrderStatusEnums.已完成); + } + } else { + boolean update = this.lambdaUpdate().set(MallOrder::getOrderStatus, MallOrderStatusEnums.已到账.getCode()) + .set(MallOrder::getReceiveTime, new Date()) + .set(MallOrder::getArrivalTime, new Date()) + .set(MallOrder::getCompleteTime, new Date()) + .eq(MallOrder::getId, order.getId()).update(); + + //记录订单状态 + if (update) { + orderStatusService.recordOrderStatus(order, MallOrderStatusEnums.已到账); + + //分佣 + distributeCommission(order); + } + } + + return ResponseData.success(); + } + + @Autowired + private PlatformRecordService platformRecordService; + + /** + * 分佣 + * + * @param order + */ + + public ResponseData distributeCommission(MallOrder order) { + + //平台收益 + BigDecimal platCommission = order.getPayPrice(); + + //平台流水 + platformRecordService.addPlatformRecord(new UserVo(order.getUserType(), order.getUserId()), order.getId(), platCommission, PlatformRecordEnums.MALL_ORDER_PAY); + + return ResponseData.success(); + } + + @Autowired + private MallRefundService refundService; + + @Override + public ResponseData orderAfterApply(ApplyAfterSalesReq req, UserVo userVo) { + + MallOrder order = baseMapper.selectById(req.getOrderId()); + + if (ObjectUtil.notEqual(MallOrderStatusEnums.已完成.getCode(), order.getOrderStatus())) { + return ResponseData.error(MallExceptionEnum.ORDER_STATUS_ERROR); + } + + MallRefund refund = null; + if (ObjectUtil.isNotEmpty(req.getRefundId())) { + refund = refundService.getById(req.getRefundId()); + if (!refund.getStatus().equals(RefundStatusEnums.待审核.getCode())) { + return ResponseData.error(MallExceptionEnum.ORDER_REPEAT_APPLY); + } + } else { + refundService.getOne(new QueryWrapper().lambda().eq(MallRefund::getOrderId, req.getOrderId()) + .eq(MallRefund::getDelFlag, PublicCommon.启用) + .orderByDesc(MallRefund::getCreateTime).last(" limit 1")); + if (refund != null) { + if (refund.getStatus() != 5) { + return ResponseData.error(MallExceptionEnum.ORDER_REPEAT_APPLY); + } + } else { + refund = new MallRefund(); + } + } + + refund.setOrderId(req.getOrderId()); + refund.setRefundImages(req.getRefundImages()); + refund.setRefundReason(req.getRefundReason()); + refund.setRefundExplain(req.getRefundExplain()); + refund.setRefundType(2); + refund.setStatus(1); + refund.setRefundPrice(order.getPayPrice()); + refundService.saveOrUpdate(refund); + + //订单消息 + orderMessageService.addOrderMessage(new UserVo(order.getUserType(), order.getUserId()), order.getId(), "", PublicCommon.Order.商城订单, OrderMessageEnums.MALL_ORDER_REFUND); + + return ResponseData.success(); + } + + @Override + public ResponseData orderAfterDetail(Long orderId, UserVo userVo) { + MallRefund refund = refundService.getOne(new QueryWrapper().lambda().eq(MallRefund::getOrderId, orderId) + .orderByDesc(MallRefund::getCreateTime).last(" limit 1")); + + if (refund != null) { + List orderIdList = new ArrayList<>(); + orderIdList.add(orderId); + //根据订单id 查询订单商品 + List orderGoodsList = orderGoodsService.orderGoodsList(orderIdList); + refund.setOrderGoodsList(orderGoodsList); + } + + return ResponseData.success(refund); + } + + @Override + public ResponseData orderAfterRevokeApply(Long refundId, UserVo userVo) { + + boolean update = refundService.lambdaUpdate().set(MallRefund::getDelFlag, PublicCommon.删除) + .eq(MallRefund::getStatus, RefundStatusEnums.待审核.getCode()) + .eq(MallRefund::getId, refundId).update(); + if (!update) { + return ResponseData.error(MallExceptionEnum.ORDER_STATUS_ERROR); + } + + return ResponseData.success(); + } + + @Autowired + private SysDictDataMapper sysDictDataMapper; + + @Override + public ResponseData customerDeliverGoods(CustomerDeliverGoodsReq req) { + MallRefund refund = new MallRefund(); + if (ObjectUtil.isNotEmpty(req.getRefundId())) { + refund = refundService.getById(req.getRefundId()); + } else { + refund = refundService.getOne(new QueryWrapper().lambda().eq(MallRefund::getOrderId, req.getOrderId()) + .eq(MallRefund::getOrderType, req.getOrderType()) + .eq(MallRefund::getDelFlag, PublicCommon.启用) + .orderByDesc(MallRefund::getCreateTime).last(" limit 1")); + } + + //只有退款退货类型才需要判断状态,只退款类型不需要判断状态,随时可退 + if (refund.getRefundType() != 2 || ObjectUtil.notEqual(RefundStatusEnums.商家同意退款退货.getCode(), refund.getStatus())) { + return ResponseData.error("订单状态错误 请刷新数据"); + } + //如果是退货,需要修改退货状态 + if (refund.getRefundType() == 2) { + refund.setStatus(RefundStatusEnums.用户发货.getCode()); + } + refund.setComCourierId(req.getComCourierId()); + SysDictData dict = sysDictDataMapper.selectDictDataById(req.getDictId()); + refund.setComLogistics(dict.getDictLabel()); + refund.setComLogisticsCode(dict.getDictValue()); + refundService.updateById(refund); + return ResponseData.success(); + } + + + @Override + public ResponseData evaluate(MallEvaluateReq req, UserVo userVo) { + + MallOrder order = this.getById(req.getOrderId()); + + //判断订单状态 + if (ObjectUtil.notEqual(MallOrderStatusEnums.已完成.getCode(), order.getOrderStatus()) + && ObjectUtil.notEqual(MallOrderStatusEnums.已到账.getCode(), order.getOrderStatus()) + ) { + return ResponseData.error(MallExceptionEnum.ORDER_STATUS_ERROR); + } + + MallEvaluate evaluate = new MallEvaluate(); + BeanUtil.copyProperties(req, evaluate); + evaluate.setUserId(userVo.getUserId()) + .setUserType(userVo.getUserType()); + evaluateService.save(evaluate); + + return ResponseData.success(); + } + + @Override + public ResponseData onceAgainCreateOrder(OnceAgainCreateOrderReq req, UserVo userVo) { + return null; + } + + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallorderaddress/controller/MallOrderAddressController.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallorderaddress/controller/MallOrderAddressController.java new file mode 100644 index 0000000..5f4150f --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallorderaddress/controller/MallOrderAddressController.java @@ -0,0 +1,97 @@ +package com.ruoyi.frequency.mallorderaddress.controller; + +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.page.TableDataInfo; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.common.utils.poi.ExcelUtil; +import com.ruoyi.frequency.mallorderaddress.entity.MallOrderAddress; +import com.ruoyi.frequency.mallorderaddress.service.MallOrderAddressService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +/** + * 订单地址Controller + * + * @author liwenlong + * @date 2024-01-25 + */ +@RestController +@RequestMapping("/frequency/mallorderaddress") +public class MallOrderAddressController extends BaseController +{ + @Autowired + private MallOrderAddressService mallOrderAddressService; + + /** + * 查询订单地址列表 + */ + @PreAuthorize("@ss.hasPermi('frequency:mallorderaddress:list')") + @GetMapping("/list") + public TableDataInfo list(MallOrderAddress mallOrderAddress) + { + startPage(); + List list = mallOrderAddressService.selectMallOrderAddressList(mallOrderAddress); + return getDataTable(list); + } + + /** + * 导出订单地址列表 + */ + @PreAuthorize("@ss.hasPermi('frequency:mallorderaddress:export')") + @Log(title = "订单地址", businessType = BusinessType.EXPORT) + @GetMapping("/export") + public AjaxResult export(MallOrderAddress mallOrderAddress) + { + List list = mallOrderAddressService.selectMallOrderAddressList(mallOrderAddress); + ExcelUtil util = new ExcelUtil(MallOrderAddress.class); + return util.exportExcel(list, "订单地址数据"); + } + + /** + * 获取订单地址详细信息 + */ + @PreAuthorize("@ss.hasPermi('frequency:mallorderaddress:query')") + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") Long id) + { + return AjaxResult.success(mallOrderAddressService.selectMallOrderAddressById(id)); + } + + /** + * 新增订单地址 + */ + @PreAuthorize("@ss.hasPermi('frequency:mallorderaddress:add')") + @Log(title = "订单地址", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody MallOrderAddress mallOrderAddress) + { + return toAjax(mallOrderAddressService.insertMallOrderAddress(mallOrderAddress)); + } + + /** + * 修改订单地址 + */ + @PreAuthorize("@ss.hasPermi('frequency:mallorderaddress:edit')") + @Log(title = "订单地址", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody MallOrderAddress mallOrderAddress) + { + return toAjax(mallOrderAddressService.updateMallOrderAddress(mallOrderAddress)); + } + + /** + * 删除订单地址 + */ + @PreAuthorize("@ss.hasPermi('frequency:mallorderaddress:remove')") + @Log(title = "订单地址", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}/{delFlag}") + public AjaxResult remove(@PathVariable("ids") Long[] ids,@PathVariable("delFlag") Integer delFlag) + { + return toAjax(mallOrderAddressService.deleteMallOrderAddressByIds(ids,delFlag)); + } +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallorderaddress/entity/MallOrderAddress.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallorderaddress/entity/MallOrderAddress.java new file mode 100644 index 0000000..5f41238 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallorderaddress/entity/MallOrderAddress.java @@ -0,0 +1,68 @@ +package com.ruoyi.frequency.mallorderaddress.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; + +/** + * 订单地址对象 mall_order_address + * + * @author liwenlong + * @date 2024-01-25 + */ +@Data +@Accessors(chain = true) +@TableName("mall_order_address") +public class MallOrderAddress extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + + @ApiModelProperty("主键id") + private Long id; + + @ApiModelProperty("删除标志;1正常 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("收货人姓名") + @Excel(name = "收货人姓名") + private String consigneeUsername; + + @ApiModelProperty("收货人手机号") + @Excel(name = "收货人手机号") + private String consigneeMobile; + + @ApiModelProperty("省") + @Excel(name = "省") + private String provinceName; + + @ApiModelProperty("市") + @Excel(name = "市") + private String cityName; + + @ApiModelProperty("区") + @Excel(name = "区") + private String areaName; + + @ApiModelProperty("地址") + @Excel(name = "地址") + private String address; + + @ApiModelProperty("订单id") + @Excel(name = "订单id") + private Long orderId; + + @ApiModelProperty("详细地址") + @Excel(name = "详细地址") + private String detail; + + @ApiModelProperty("区号") + @Excel(name = "区号") + private String areaCode; + + + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallorderaddress/mapper/MallOrderAddressMapper.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallorderaddress/mapper/MallOrderAddressMapper.java new file mode 100644 index 0000000..de9f1b9 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallorderaddress/mapper/MallOrderAddressMapper.java @@ -0,0 +1,48 @@ +package com.ruoyi.frequency.mallorderaddress.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.ruoyi.frequency.mallorderaddress.entity.MallOrderAddress; + +import java.util.List; + +/** + * 订单地址Mapper接口 + * + * @author liwenlong + * @date 2024-01-25 + */ +public interface MallOrderAddressMapper extends BaseMapper +{ + /** + * 查询订单地址 + * + * @param id 订单地址主键 + * @return 订单地址 + */ + public MallOrderAddress selectMallOrderAddressById(Long id); + + /** + * 查询订单地址列表 + * + * @param mallOrderAddress 订单地址 + * @return 订单地址集合 + */ + public List selectMallOrderAddressList(MallOrderAddress mallOrderAddress); + + /** + * 新增订单地址 + * + * @param mallOrderAddress 订单地址 + * @return 结果 + */ + public int insertMallOrderAddress(MallOrderAddress mallOrderAddress); + + /** + * 修改订单地址 + * + * @param mallOrderAddress 订单地址 + * @return 结果 + */ + public int updateMallOrderAddress(MallOrderAddress mallOrderAddress); + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallorderaddress/mapper/mapping/MallOrderAddressMapper.xml b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallorderaddress/mapper/mapping/MallOrderAddressMapper.xml new file mode 100644 index 0000000..14c3510 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallorderaddress/mapper/mapping/MallOrderAddressMapper.xml @@ -0,0 +1,128 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + select + t.id , + t.create_by , + t.create_time , + t.update_by , + t.update_time , + t.del_flag , + t.consignee_username , + t.consignee_mobile , + t.province_name , + t.city_name , + t.area_name , + t.address , + t.order_id , + t.detail , + t.area_code + from mall_order_address AS t + + + + + + + + + insert into mall_order_address + + id, + create_by, + create_time, + update_by, + update_time, + del_flag, + consignee_username, + consignee_mobile, + province_name, + city_name, + area_name, + address, + order_id, + detail, + area_code, + + + #{id}, + #{createBy}, + #{createTime}, + #{updateBy}, + #{updateTime}, + #{delFlag}, + #{consigneeUsername}, + #{consigneeMobile}, + #{provinceName}, + #{cityName}, + #{areaName}, + #{address}, + #{orderId}, + #{detail}, + #{areaCode}, + + + + + update mall_order_address + + create_by = #{createBy}, + create_time = #{createTime}, + update_by = #{updateBy}, + update_time = #{updateTime}, + del_flag = #{delFlag}, + consignee_username = #{consigneeUsername}, + consignee_mobile = #{consigneeMobile}, + province_name = #{provinceName}, + city_name = #{cityName}, + area_name = #{areaName}, + address = #{address}, + order_id = #{orderId}, + detail = #{detail}, + area_code = #{areaCode}, + + where id = #{id} + + \ No newline at end of file diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallorderaddress/model/param/MallOrderAddressParam.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallorderaddress/model/param/MallOrderAddressParam.java new file mode 100644 index 0000000..5b6e5f8 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallorderaddress/model/param/MallOrderAddressParam.java @@ -0,0 +1,75 @@ +package com.ruoyi.frequency.mallorderaddress.model.param; + +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; + +/** + * 订单地址对象 mall_order_address + * + * @author liwenlong + * @date 2024-01-25 + */ +@Data +@Accessors(chain = true) +public class MallOrderAddressParam extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + @ApiModelProperty("主键id") + private Long id; + + @ApiModelProperty("删除标志;1正常 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("收货人姓名") + @Excel(name = "收货人姓名") + private String consigneeUsername; + + @ApiModelProperty("收货人手机号") + @Excel(name = "收货人手机号") + private String consigneeMobile; + + @ApiModelProperty("省") + @Excel(name = "省") + private String provinceName; + + @ApiModelProperty("市") + @Excel(name = "市") + private String cityName; + + @ApiModelProperty("区") + @Excel(name = "区") + private String areaName; + + @ApiModelProperty("地址") + @Excel(name = "地址") + private String address; + + @ApiModelProperty("订单id") + @Excel(name = "订单id") + private Long orderId; + + @ApiModelProperty("详细地址") + @Excel(name = "详细地址") + private String detail; + + @ApiModelProperty("区号") + @Excel(name = "区号") + private String areaCode; + + + + + + + + + + + + + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallorderaddress/model/result/MallOrderAddressResult.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallorderaddress/model/result/MallOrderAddressResult.java new file mode 100644 index 0000000..6b836b0 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallorderaddress/model/result/MallOrderAddressResult.java @@ -0,0 +1,64 @@ +package com.ruoyi.frequency.mallorderaddress.model.result; + +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; + +/** + * 订单地址对象 mall_order_address + * + * @author liwenlong + * @date 2024-01-25 + */ +@Data +@Accessors(chain = true) +public class MallOrderAddressResult extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + @ApiModelProperty("主键id") + private Long id; + + @ApiModelProperty("删除标志;1正常 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("收货人姓名") + @Excel(name = "收货人姓名") + private String consigneeUsername; + + @ApiModelProperty("收货人手机号") + @Excel(name = "收货人手机号") + private String consigneeMobile; + + @ApiModelProperty("省") + @Excel(name = "省") + private String provinceName; + + @ApiModelProperty("市") + @Excel(name = "市") + private String cityName; + + @ApiModelProperty("区") + @Excel(name = "区") + private String areaName; + + @ApiModelProperty("地址") + @Excel(name = "地址") + private String address; + + @ApiModelProperty("订单id") + @Excel(name = "订单id") + private Long orderId; + + @ApiModelProperty("详细地址") + @Excel(name = "详细地址") + private String detail; + + @ApiModelProperty("区号") + @Excel(name = "区号") + private String areaCode; + + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallorderaddress/service/MallOrderAddressService.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallorderaddress/service/MallOrderAddressService.java new file mode 100644 index 0000000..bd9fb6d --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallorderaddress/service/MallOrderAddressService.java @@ -0,0 +1,63 @@ +package com.ruoyi.frequency.mallorderaddress.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.ruoyi.frequency.mallorderaddress.entity.MallOrderAddress; + +import java.util.List; + +/** + * 订单地址Service接口 + * + * @author liwenlong + * @date 2024-01-25 + */ +public interface MallOrderAddressService extends IService +{ + /** + * 查询订单地址 + * + * @param id 订单地址主键 + * @return 订单地址 + */ + public MallOrderAddress selectMallOrderAddressById(Long id); + + /** + * 查询订单地址列表 + * + * @param mallOrderAddress 订单地址 + * @return 订单地址集合 + */ + public List selectMallOrderAddressList(MallOrderAddress mallOrderAddress); + + /** + * 新增订单地址 + * + * @param mallOrderAddress 订单地址 + * @return 结果 + */ + public int insertMallOrderAddress(MallOrderAddress mallOrderAddress); + + /** + * 修改订单地址 + * + * @param mallOrderAddress 订单地址 + * @return 结果 + */ + public int updateMallOrderAddress(MallOrderAddress mallOrderAddress); + + /** + * 批量删除订单地址 + * + * @param ids 需要删除的订单地址主键集合 + * @return 结果 + */ + public int deleteMallOrderAddressByIds(Long[] ids,Integer delFlag); + + /** + * 组装订单地址 + * @param id + * @param addressId + * @return + */ + MallOrderAddress assembleOrderAddress(Long id, Long addressId); +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallorderaddress/service/impl/MallOrderAddressServiceImpl.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallorderaddress/service/impl/MallOrderAddressServiceImpl.java new file mode 100644 index 0000000..400dfc5 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallorderaddress/service/impl/MallOrderAddressServiceImpl.java @@ -0,0 +1,114 @@ +package com.ruoyi.frequency.mallorderaddress.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.ruoyi.frequency.malladdress.entity.MallAddress; +import com.ruoyi.frequency.malladdress.service.MallAddressService; +import com.ruoyi.frequency.mallorderaddress.entity.MallOrderAddress; +import com.ruoyi.frequency.mallorderaddress.mapper.MallOrderAddressMapper; +import com.ruoyi.frequency.mallorderaddress.service.MallOrderAddressService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * 订单地址Service业务层处理 + * + * @author liwenlong + * @date 2024-01-25 + */ +@Service +public class MallOrderAddressServiceImpl extends ServiceImpl implements MallOrderAddressService +{ + @Autowired + private MallOrderAddressMapper mallOrderAddressMapper; + + /** + * 查询订单地址 + * + * @param id 订单地址主键 + * @return 订单地址 + */ + @Override + public MallOrderAddress selectMallOrderAddressById(Long id) + { + return mallOrderAddressMapper.selectMallOrderAddressById(id); + } + + /** + * 查询订单地址列表 + * + * @param mallOrderAddress 订单地址 + * @return 订单地址 + */ + @Override + public List selectMallOrderAddressList(MallOrderAddress mallOrderAddress) + { + return mallOrderAddressMapper.selectMallOrderAddressList(mallOrderAddress); + } + + /** + * 新增订单地址 + * + * @param mallOrderAddress 订单地址 + * @return 结果 + */ + @Override + public int insertMallOrderAddress(MallOrderAddress mallOrderAddress) + { + mallOrderAddress.setCreateData(); + return mallOrderAddressMapper.insert(mallOrderAddress); + } + + /** + * 修改订单地址 + * + * @param mallOrderAddress 订单地址 + * @return 结果 + */ + @Override + public int updateMallOrderAddress(MallOrderAddress mallOrderAddress) + { + mallOrderAddress.setUpdateData(); + return mallOrderAddressMapper.updateMallOrderAddress(mallOrderAddress); + } + + /** + * 批量删除订单地址 + * + * @param ids 需要删除的订单地址主键 + * @return 结果 + */ + @Override + public int deleteMallOrderAddressByIds(Long[] ids,Integer delFlag) + { + this.lambdaUpdate().set(MallOrderAddress::getDelFlag,delFlag).in(MallOrderAddress::getId,ids).update(); + return ids.length; + } + + @Autowired + private MallAddressService addressService; + + @Override + public MallOrderAddress assembleOrderAddress(Long orderId, Long addressId) { + //用户地址 + MallAddress address = addressService.getById(addressId); + + MallOrderAddress orderAddress = this.baseMapper.selectOne(new QueryWrapper().lambda() + .eq(MallOrderAddress::getOrderId, orderId)); + if (orderAddress == null) { + orderAddress = new MallOrderAddress(); + } + orderAddress.setOrderId(orderId) + .setAreaCode(address.getAreaCode()) + .setConsigneeUsername(address.getUsername()) + .setConsigneeMobile(address.getMobile()) + .setProvinceName(address.getProvince()) + .setCityName(address.getCity()) + .setAreaName(address.getArea()) + .setAddress(address.getAddress()) + .setDetail(address.getDetail()); + return orderAddress; + } +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallordergoods/controller/MallOrderGoodsController.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallordergoods/controller/MallOrderGoodsController.java new file mode 100644 index 0000000..6ec0297 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallordergoods/controller/MallOrderGoodsController.java @@ -0,0 +1,97 @@ +package com.ruoyi.frequency.mallordergoods.controller; + +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.page.TableDataInfo; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.common.utils.poi.ExcelUtil; +import com.ruoyi.frequency.mallordergoods.entity.MallOrderGoods; +import com.ruoyi.frequency.mallordergoods.service.MallOrderGoodsService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +/** + * 订单商品Controller + * + * @author liwenlong + * @date 2024-01-25 + */ +@RestController +@RequestMapping("/frequency/mallordergoods") +public class MallOrderGoodsController extends BaseController +{ + @Autowired + private MallOrderGoodsService mallOrderGoodsService; + + /** + * 查询订单商品列表 + */ + @PreAuthorize("@ss.hasPermi('frequency:mallordergoods:list')") + @GetMapping("/list") + public TableDataInfo list(MallOrderGoods mallOrderGoods) + { + startPage(); + List list = mallOrderGoodsService.selectMallOrderGoodsList(mallOrderGoods); + return getDataTable(list); + } + + /** + * 导出订单商品列表 + */ + @PreAuthorize("@ss.hasPermi('frequency:mallordergoods:export')") + @Log(title = "订单商品", businessType = BusinessType.EXPORT) + @GetMapping("/export") + public AjaxResult export(MallOrderGoods mallOrderGoods) + { + List list = mallOrderGoodsService.selectMallOrderGoodsList(mallOrderGoods); + ExcelUtil util = new ExcelUtil(MallOrderGoods.class); + return util.exportExcel(list, "订单商品数据"); + } + + /** + * 获取订单商品详细信息 + */ + @PreAuthorize("@ss.hasPermi('frequency:mallordergoods:query')") + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") Long id) + { + return AjaxResult.success(mallOrderGoodsService.selectMallOrderGoodsById(id)); + } + + /** + * 新增订单商品 + */ + @PreAuthorize("@ss.hasPermi('frequency:mallordergoods:add')") + @Log(title = "订单商品", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody MallOrderGoods mallOrderGoods) + { + return toAjax(mallOrderGoodsService.insertMallOrderGoods(mallOrderGoods)); + } + + /** + * 修改订单商品 + */ + @PreAuthorize("@ss.hasPermi('frequency:mallordergoods:edit')") + @Log(title = "订单商品", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody MallOrderGoods mallOrderGoods) + { + return toAjax(mallOrderGoodsService.updateMallOrderGoods(mallOrderGoods)); + } + + /** + * 删除订单商品 + */ + @PreAuthorize("@ss.hasPermi('frequency:mallordergoods:remove')") + @Log(title = "订单商品", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}/{delFlag}") + public AjaxResult remove(@PathVariable("ids") Long[] ids,@PathVariable("delFlag") Integer delFlag) + { + return toAjax(mallOrderGoodsService.deleteMallOrderGoodsByIds(ids,delFlag)); + } +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallordergoods/entity/MallOrderGoods.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallordergoods/entity/MallOrderGoods.java new file mode 100644 index 0000000..e084aa0 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallordergoods/entity/MallOrderGoods.java @@ -0,0 +1,85 @@ +package com.ruoyi.frequency.mallordergoods.entity; + +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableName; +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; + +import java.math.BigDecimal; +import java.util.Date; + +/** + * 订单商品对象 mall_order_goods + * + * @author liwenlong + * @date 2024-01-25 + */ +@Data +@Accessors(chain = true) +@TableName("mall_order_goods") +public class MallOrderGoods extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + + @ApiModelProperty("主键id") + private Long id; + + @ApiModelProperty("删除标志;1正常 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("订单id") + @Excel(name = "订单id") + private Long orderId; + + @ApiModelProperty("商品id") + @Excel(name = "商品id") + private Long goodsId; + + @ApiModelProperty("规格id(如果是多规格;使用sku_id)") + @Excel(name = "规格id", readConverterExp = "如=果是多规格;使用sku_id") + private Long specId; + + @ApiModelProperty("购买数量") + @Excel(name = "购买数量") + private Integer buyNum; + + @ApiModelProperty("单价") + @Excel(name = "单价") + private BigDecimal unitPrice; + + @ApiModelProperty("购买时商品名称") + @Excel(name = "购买时商品名称") + private String goodsName; + + @ApiModelProperty("购买时规格名称") + @Excel(name = "购买时规格名称") + private String specName; + + @ApiModelProperty("购买时商品封面图") + @Excel(name = "购买时商品封面图") + private String goodsImage; + + @ApiModelProperty("购买时规格封面图") + @Excel(name = "购买时规格封面图") + private String specImage; + + @ApiModelProperty("购买时规格类型;1 单规格 2 多规格") + @Excel(name = "购买时规格类型;1 单规格 2 多规格") + private Integer specType; + + @ApiModelProperty("积分") + @Excel(name = "积分") + private BigDecimal unitIntegral; + + + @ApiModelProperty("商品分类") + @TableField(exist = false) + private String goodsTypeName; + + + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallordergoods/mapper/MallOrderGoodsMapper.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallordergoods/mapper/MallOrderGoodsMapper.java new file mode 100644 index 0000000..8be2b35 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallordergoods/mapper/MallOrderGoodsMapper.java @@ -0,0 +1,50 @@ +package com.ruoyi.frequency.mallordergoods.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.ruoyi.frequency.mallordergoods.entity.MallOrderGoods; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * 订单商品Mapper接口 + * + * @author liwenlong + * @date 2024-01-25 + */ +public interface MallOrderGoodsMapper extends BaseMapper +{ + /** + * 查询订单商品 + * + * @param id 订单商品主键 + * @return 订单商品 + */ + public MallOrderGoods selectMallOrderGoodsById(Long id); + + /** + * 查询订单商品列表 + * + * @param mallOrderGoods 订单商品 + * @return 订单商品集合 + */ + public List selectMallOrderGoodsList(MallOrderGoods mallOrderGoods); + + /** + * 新增订单商品 + * + * @param mallOrderGoods 订单商品 + * @return 结果 + */ + public int insertMallOrderGoods(MallOrderGoods mallOrderGoods); + + /** + * 修改订单商品 + * + * @param mallOrderGoods 订单商品 + * @return 结果 + */ + public int updateMallOrderGoods(MallOrderGoods mallOrderGoods); + + List orderGoodsList(@Param("list") List orderIdList); +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallordergoods/mapper/mapping/MallOrderGoodsMapper.xml b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallordergoods/mapper/mapping/MallOrderGoodsMapper.xml new file mode 100644 index 0000000..cce7e69 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallordergoods/mapper/mapping/MallOrderGoodsMapper.xml @@ -0,0 +1,180 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + select + t.id , + t.create_by , + t.create_time , + t.update_by , + t.update_time , + t.del_flag , + t.order_id , + t.goods_id , + t.spec_id , + t.buy_num , + t.unit_price , + t.goods_name , + t.spec_name , + t.goods_image , + t.spec_image , + t.spec_type , + t.member_price , + t.unit_integral, + t3.`name` goodsTypeName + FROM + mall_order_goods t + LEFT JOIN mall_goods t2 ON t.goods_id = t2.id + LEFT JOIN mall_goods_type t3 ON t3.id = t2.goods_type_id + + + + + + + + + insert into mall_order_goods + + id, + create_by, + create_time, + update_by, + update_time, + del_flag, + order_id, + goods_id, + spec_id, + buy_num, + unit_price, + goods_name, + spec_name, + goods_image, + spec_image, + spec_type, + unit_integral, + + + #{id}, + #{createBy}, + #{createTime}, + #{updateBy}, + #{updateTime}, + #{delFlag}, + #{orderId}, + #{goodsId}, + #{specId}, + #{buyNum}, + #{unitPrice}, + #{goodsName}, + #{specName}, + #{goodsImage}, + #{specImage}, + #{specType}, + #{unitIntegral}, + + + + + update mall_order_goods + + create_by = #{createBy}, + create_time = #{createTime}, + update_by = #{updateBy}, + update_time = #{updateTime}, + del_flag = #{delFlag}, + order_id = #{orderId}, + goods_id = #{goodsId}, + spec_id = #{specId}, + buy_num = #{buyNum}, + unit_price = #{unitPrice}, + goods_name = #{goodsName}, + spec_name = #{specName}, + goods_image = #{goodsImage}, + spec_image = #{specImage}, + spec_type = #{specType}, + unit_integral = #{unitIntegral}, + + where id = #{id} + + + + diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallordergoods/model/param/MallOrderGoodsParam.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallordergoods/model/param/MallOrderGoodsParam.java new file mode 100644 index 0000000..4ba636a --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallordergoods/model/param/MallOrderGoodsParam.java @@ -0,0 +1,92 @@ +package com.ruoyi.frequency.mallordergoods.model.param; + +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; + +import java.math.BigDecimal; + +/** + * 订单商品对象 mall_order_goods + * + * @author liwenlong + * @date 2024-01-25 + */ +@Data +@Accessors(chain = true) +public class MallOrderGoodsParam extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + @ApiModelProperty("主键id") + private Long id; + + @ApiModelProperty("删除标志;1正常 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("订单id") + @Excel(name = "订单id") + private Long orderId; + + @ApiModelProperty("商品id") + @Excel(name = "商品id") + private Long goodsId; + + @ApiModelProperty("规格id(如果是多规格;使用sku_id)") + @Excel(name = "规格id", readConverterExp = "如=果是多规格;使用sku_id") + private Long specId; + + @ApiModelProperty("购买数量") + @Excel(name = "购买数量") + private Long buyNum; + + @ApiModelProperty("单价") + @Excel(name = "单价") + private BigDecimal unitPrice; + + @ApiModelProperty("购买时商品名称") + @Excel(name = "购买时商品名称") + private String goodsName; + + @ApiModelProperty("购买时规格名称") + @Excel(name = "购买时规格名称") + private String specName; + + @ApiModelProperty("购买时商品封面图") + @Excel(name = "购买时商品封面图") + private String goodsImage; + + @ApiModelProperty("购买时规格封面图") + @Excel(name = "购买时规格封面图") + private String specImage; + + @ApiModelProperty("购买时规格类型;1 单规格 2 多规格") + @Excel(name = "购买时规格类型;1 单规格 2 多规格") + private Integer specType; + + @ApiModelProperty("会员价格") + @Excel(name = "会员价格") + private BigDecimal memberPrice; + + @ApiModelProperty("积分") + @Excel(name = "积分") + private BigDecimal unitIntegral; + + + + + + + + + + + + + + + + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallordergoods/model/result/MallOrderGoodsResult.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallordergoods/model/result/MallOrderGoodsResult.java new file mode 100644 index 0000000..e8507f8 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallordergoods/model/result/MallOrderGoodsResult.java @@ -0,0 +1,78 @@ +package com.ruoyi.frequency.mallordergoods.model.result; + +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; + +import java.math.BigDecimal; + +/** + * 订单商品对象 mall_order_goods + * + * @author liwenlong + * @date 2024-01-25 + */ +@Data +@Accessors(chain = true) +public class MallOrderGoodsResult extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + @ApiModelProperty("主键id") + private Long id; + + @ApiModelProperty("删除标志;1正常 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("订单id") + @Excel(name = "订单id") + private Long orderId; + + @ApiModelProperty("商品id") + @Excel(name = "商品id") + private Long goodsId; + + @ApiModelProperty("规格id(如果是多规格;使用sku_id)") + @Excel(name = "规格id", readConverterExp = "如=果是多规格;使用sku_id") + private Long specId; + + @ApiModelProperty("购买数量") + @Excel(name = "购买数量") + private Long buyNum; + + @ApiModelProperty("单价") + @Excel(name = "单价") + private BigDecimal unitPrice; + + @ApiModelProperty("购买时商品名称") + @Excel(name = "购买时商品名称") + private String goodsName; + + @ApiModelProperty("购买时规格名称") + @Excel(name = "购买时规格名称") + private String specName; + + @ApiModelProperty("购买时商品封面图") + @Excel(name = "购买时商品封面图") + private String goodsImage; + + @ApiModelProperty("购买时规格封面图") + @Excel(name = "购买时规格封面图") + private String specImage; + + @ApiModelProperty("购买时规格类型;1 单规格 2 多规格") + @Excel(name = "购买时规格类型;1 单规格 2 多规格") + private Integer specType; + + @ApiModelProperty("会员价格") + @Excel(name = "会员价格") + private BigDecimal memberPrice; + + @ApiModelProperty("积分") + @Excel(name = "积分") + private BigDecimal unitIntegral; + + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallordergoods/service/MallOrderGoodsService.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallordergoods/service/MallOrderGoodsService.java new file mode 100644 index 0000000..bf18044 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallordergoods/service/MallOrderGoodsService.java @@ -0,0 +1,57 @@ +package com.ruoyi.frequency.mallordergoods.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.ruoyi.frequency.mallordergoods.entity.MallOrderGoods; + +import java.util.List; + +/** + * 订单商品Service接口 + * + * @author liwenlong + * @date 2024-01-25 + */ +public interface MallOrderGoodsService extends IService +{ + /** + * 查询订单商品 + * + * @param id 订单商品主键 + * @return 订单商品 + */ + public MallOrderGoods selectMallOrderGoodsById(Long id); + + /** + * 查询订单商品列表 + * + * @param mallOrderGoods 订单商品 + * @return 订单商品集合 + */ + public List selectMallOrderGoodsList(MallOrderGoods mallOrderGoods); + + /** + * 新增订单商品 + * + * @param mallOrderGoods 订单商品 + * @return 结果 + */ + public int insertMallOrderGoods(MallOrderGoods mallOrderGoods); + + /** + * 修改订单商品 + * + * @param mallOrderGoods 订单商品 + * @return 结果 + */ + public int updateMallOrderGoods(MallOrderGoods mallOrderGoods); + + /** + * 批量删除订单商品 + * + * @param ids 需要删除的订单商品主键集合 + * @return 结果 + */ + public int deleteMallOrderGoodsByIds(Long[] ids,Integer delFlag); + + List orderGoodsList(List orderIdList); +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallordergoods/service/impl/MallOrderGoodsServiceImpl.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallordergoods/service/impl/MallOrderGoodsServiceImpl.java new file mode 100644 index 0000000..5f6c123 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallordergoods/service/impl/MallOrderGoodsServiceImpl.java @@ -0,0 +1,97 @@ +package com.ruoyi.frequency.mallordergoods.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.ruoyi.frequency.mallordergoods.entity.MallOrderGoods; +import com.ruoyi.frequency.mallordergoods.mapper.MallOrderGoodsMapper; +import com.ruoyi.frequency.mallordergoods.service.MallOrderGoodsService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.ArrayList; +import java.util.List; + +/** + * 订单商品Service业务层处理 + * + * @author liwenlong + * @date 2024-01-25 + */ +@Service +public class MallOrderGoodsServiceImpl extends ServiceImpl implements MallOrderGoodsService +{ + @Autowired + private MallOrderGoodsMapper mallOrderGoodsMapper; + + /** + * 查询订单商品 + * + * @param id 订单商品主键 + * @return 订单商品 + */ + @Override + public MallOrderGoods selectMallOrderGoodsById(Long id) + { + return mallOrderGoodsMapper.selectMallOrderGoodsById(id); + } + + /** + * 查询订单商品列表 + * + * @param mallOrderGoods 订单商品 + * @return 订单商品 + */ + @Override + public List selectMallOrderGoodsList(MallOrderGoods mallOrderGoods) + { + return mallOrderGoodsMapper.selectMallOrderGoodsList(mallOrderGoods); + } + + /** + * 新增订单商品 + * + * @param mallOrderGoods 订单商品 + * @return 结果 + */ + @Override + public int insertMallOrderGoods(MallOrderGoods mallOrderGoods) + { + mallOrderGoods.setCreateData(); + return mallOrderGoodsMapper.insert(mallOrderGoods); + } + + /** + * 修改订单商品 + * + * @param mallOrderGoods 订单商品 + * @return 结果 + */ + @Override + public int updateMallOrderGoods(MallOrderGoods mallOrderGoods) + { + mallOrderGoods.setUpdateData(); + return mallOrderGoodsMapper.updateMallOrderGoods(mallOrderGoods); + } + + /** + * 批量删除订单商品 + * + * @param ids 需要删除的订单商品主键 + * @return 结果 + */ + @Override + public int deleteMallOrderGoodsByIds(Long[] ids,Integer delFlag) + { + this.lambdaUpdate().set(MallOrderGoods::getDelFlag,delFlag).in(MallOrderGoods::getId,ids).update(); + return ids.length; + } + + @Override + public List orderGoodsList(List orderIdList) { + if (orderIdList.size() == 0){ + return new ArrayList<>(); + } + List orderGoodsList = this.baseMapper.orderGoodsList(orderIdList); + + return orderGoodsList; + } +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallorderstatus/controller/MallOrderStatusController.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallorderstatus/controller/MallOrderStatusController.java new file mode 100644 index 0000000..c0b5706 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallorderstatus/controller/MallOrderStatusController.java @@ -0,0 +1,97 @@ +package com.ruoyi.frequency.mallorderstatus.controller; + +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.page.TableDataInfo; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.common.utils.poi.ExcelUtil; +import com.ruoyi.frequency.mallorderstatus.entity.MallOrderStatus; +import com.ruoyi.frequency.mallorderstatus.service.MallOrderStatusService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +/** + * 订单流程Controller + * + * @author liwenlong + * @date 2024-01-25 + */ +@RestController +@RequestMapping("/frequency/mallorderstatus") +public class MallOrderStatusController extends BaseController +{ + @Autowired + private MallOrderStatusService mallOrderStatusService; + + /** + * 查询订单流程列表 + */ + @PreAuthorize("@ss.hasPermi('frequency:mallorderstatus:list')") + @GetMapping("/list") + public TableDataInfo list(MallOrderStatus mallOrderStatus) + { + startPage(); + List list = mallOrderStatusService.selectMallOrderStatusList(mallOrderStatus); + return getDataTable(list); + } + + /** + * 导出订单流程列表 + */ + @PreAuthorize("@ss.hasPermi('frequency:mallorderstatus:export')") + @Log(title = "订单流程", businessType = BusinessType.EXPORT) + @GetMapping("/export") + public AjaxResult export(MallOrderStatus mallOrderStatus) + { + List list = mallOrderStatusService.selectMallOrderStatusList(mallOrderStatus); + ExcelUtil util = new ExcelUtil(MallOrderStatus.class); + return util.exportExcel(list, "订单流程数据"); + } + + /** + * 获取订单流程详细信息 + */ + @PreAuthorize("@ss.hasPermi('frequency:mallorderstatus:query')") + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") Long id) + { + return AjaxResult.success(mallOrderStatusService.selectMallOrderStatusById(id)); + } + + /** + * 新增订单流程 + */ + @PreAuthorize("@ss.hasPermi('frequency:mallorderstatus:add')") + @Log(title = "订单流程", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody MallOrderStatus mallOrderStatus) + { + return toAjax(mallOrderStatusService.insertMallOrderStatus(mallOrderStatus)); + } + + /** + * 修改订单流程 + */ + @PreAuthorize("@ss.hasPermi('frequency:mallorderstatus:edit')") + @Log(title = "订单流程", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody MallOrderStatus mallOrderStatus) + { + return toAjax(mallOrderStatusService.updateMallOrderStatus(mallOrderStatus)); + } + + /** + * 删除订单流程 + */ + @PreAuthorize("@ss.hasPermi('frequency:mallorderstatus:remove')") + @Log(title = "订单流程", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}/{delFlag}") + public AjaxResult remove(@PathVariable("ids") Long[] ids,@PathVariable("delFlag") Integer delFlag) + { + return toAjax(mallOrderStatusService.deleteMallOrderStatusByIds(ids,delFlag)); + } +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallorderstatus/entity/MallOrderStatus.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallorderstatus/entity/MallOrderStatus.java new file mode 100644 index 0000000..07b9b5f --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallorderstatus/entity/MallOrderStatus.java @@ -0,0 +1,48 @@ +package com.ruoyi.frequency.mallorderstatus.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; + +/** + * 订单流程对象 mall_order_status + * + * @author liwenlong + * @date 2024-01-25 + */ +@Data +@Accessors(chain = true) +@TableName("mall_order_status") +public class MallOrderStatus extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + + @ApiModelProperty("主键id") + private Long id; + + @ApiModelProperty("删除标志;1正常 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("订单id") + @Excel(name = "订单id") + private Long orderId; + + @ApiModelProperty("订单类型;1 普通订单 ") + @Excel(name = "订单类型;1 普通订单 ") + private Integer orderType; + + @ApiModelProperty("订单流程") + @Excel(name = "订单流程") + private Integer status; + + @ApiModelProperty("订单流程") + @Excel(name = "订单流程") + private String name; + + + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallorderstatus/mapper/MallOrderStatusMapper.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallorderstatus/mapper/MallOrderStatusMapper.java new file mode 100644 index 0000000..5857ad8 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallorderstatus/mapper/MallOrderStatusMapper.java @@ -0,0 +1,48 @@ +package com.ruoyi.frequency.mallorderstatus.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.ruoyi.frequency.mallorderstatus.entity.MallOrderStatus; + +import java.util.List; + +/** + * 订单流程Mapper接口 + * + * @author liwenlong + * @date 2024-01-25 + */ +public interface MallOrderStatusMapper extends BaseMapper +{ + /** + * 查询订单流程 + * + * @param id 订单流程主键 + * @return 订单流程 + */ + public MallOrderStatus selectMallOrderStatusById(Long id); + + /** + * 查询订单流程列表 + * + * @param mallOrderStatus 订单流程 + * @return 订单流程集合 + */ + public List selectMallOrderStatusList(MallOrderStatus mallOrderStatus); + + /** + * 新增订单流程 + * + * @param mallOrderStatus 订单流程 + * @return 结果 + */ + public int insertMallOrderStatus(MallOrderStatus mallOrderStatus); + + /** + * 修改订单流程 + * + * @param mallOrderStatus 订单流程 + * @return 结果 + */ + public int updateMallOrderStatus(MallOrderStatus mallOrderStatus); + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallorderstatus/mapper/mapping/MallOrderStatusMapper.xml b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallorderstatus/mapper/mapping/MallOrderStatusMapper.xml new file mode 100644 index 0000000..6a6b45d --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallorderstatus/mapper/mapping/MallOrderStatusMapper.xml @@ -0,0 +1,98 @@ + + + + + + + + + + + + + + + + + + + + + select + t.id , + t.create_by , + t.create_time , + t.update_by , + t.update_time , + t.del_flag , + t.order_id , + t.order_type , + t.status , + t.name + from mall_order_status AS t + + + + + + + + + insert into mall_order_status + + id, + create_by, + create_time, + update_by, + update_time, + del_flag, + order_id, + order_type, + status, + name, + + + #{id}, + #{createBy}, + #{createTime}, + #{updateBy}, + #{updateTime}, + #{delFlag}, + #{orderId}, + #{orderType}, + #{status}, + #{name}, + + + + + update mall_order_status + + create_by = #{createBy}, + create_time = #{createTime}, + update_by = #{updateBy}, + update_time = #{updateTime}, + del_flag = #{delFlag}, + order_id = #{orderId}, + order_type = #{orderType}, + status = #{status}, + name = #{name}, + + where id = #{id} + + \ No newline at end of file diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallorderstatus/model/param/MallOrderStatusParam.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallorderstatus/model/param/MallOrderStatusParam.java new file mode 100644 index 0000000..6b795e6 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallorderstatus/model/param/MallOrderStatusParam.java @@ -0,0 +1,50 @@ +package com.ruoyi.frequency.mallorderstatus.model.param; + +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; + +/** + * 订单流程对象 mall_order_status + * + * @author liwenlong + * @date 2024-01-25 + */ +@Data +@Accessors(chain = true) +public class MallOrderStatusParam extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + @ApiModelProperty("主键id") + private Long id; + + @ApiModelProperty("删除标志;1正常 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("订单id") + @Excel(name = "订单id") + private Long orderId; + + @ApiModelProperty("订单类型;1 普通订单 ") + @Excel(name = "订单类型;1 普通订单 ") + private Integer orderType; + + @ApiModelProperty("订单流程") + @Excel(name = "订单流程") + private Integer status; + + @ApiModelProperty("订单流程") + @Excel(name = "订单流程") + private String name; + + + + + + + + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallorderstatus/model/result/MallOrderStatusResult.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallorderstatus/model/result/MallOrderStatusResult.java new file mode 100644 index 0000000..86447ad --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallorderstatus/model/result/MallOrderStatusResult.java @@ -0,0 +1,44 @@ +package com.ruoyi.frequency.mallorderstatus.model.result; + +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; + +/** + * 订单流程对象 mall_order_status + * + * @author liwenlong + * @date 2024-01-25 + */ +@Data +@Accessors(chain = true) +public class MallOrderStatusResult extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + @ApiModelProperty("主键id") + private Long id; + + @ApiModelProperty("删除标志;1正常 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("订单id") + @Excel(name = "订单id") + private Long orderId; + + @ApiModelProperty("订单类型;1 普通订单 ") + @Excel(name = "订单类型;1 普通订单 ") + private Integer orderType; + + @ApiModelProperty("订单流程") + @Excel(name = "订单流程") + private Integer status; + + @ApiModelProperty("订单流程") + @Excel(name = "订单流程") + private String name; + + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallorderstatus/service/MallOrderStatusService.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallorderstatus/service/MallOrderStatusService.java new file mode 100644 index 0000000..f4b58df --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallorderstatus/service/MallOrderStatusService.java @@ -0,0 +1,64 @@ +package com.ruoyi.frequency.mallorderstatus.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.ruoyi.enums.mallorder.MallOrderStatusEnums; +import com.ruoyi.frequency.mallorder.entity.MallOrder; +import com.ruoyi.frequency.mallorderstatus.entity.MallOrderStatus; + +import java.util.List; + +/** + * 订单流程Service接口 + * + * @author liwenlong + * @date 2024-01-25 + */ +public interface MallOrderStatusService extends IService +{ + /** + * 查询订单流程 + * + * @param id 订单流程主键 + * @return 订单流程 + */ + public MallOrderStatus selectMallOrderStatusById(Long id); + + /** + * 查询订单流程列表 + * + * @param mallOrderStatus 订单流程 + * @return 订单流程集合 + */ + public List selectMallOrderStatusList(MallOrderStatus mallOrderStatus); + + /** + * 新增订单流程 + * + * @param mallOrderStatus 订单流程 + * @return 结果 + */ + public int insertMallOrderStatus(MallOrderStatus mallOrderStatus); + + /** + * 修改订单流程 + * + * @param mallOrderStatus 订单流程 + * @return 结果 + */ + public int updateMallOrderStatus(MallOrderStatus mallOrderStatus); + + /** + * 批量删除订单流程 + * + * @param ids 需要删除的订单流程主键集合 + * @return 结果 + */ + public int deleteMallOrderStatusByIds(Long[] ids,Integer delFlag); + + /** + * 记录订单流程状态 + * @param order + * @param mallOrderStatusEnums + */ + void recordOrderStatus(MallOrder order, MallOrderStatusEnums mallOrderStatusEnums); +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallorderstatus/service/impl/MallOrderStatusServiceImpl.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallorderstatus/service/impl/MallOrderStatusServiceImpl.java new file mode 100644 index 0000000..c330f5d --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallorderstatus/service/impl/MallOrderStatusServiceImpl.java @@ -0,0 +1,100 @@ +package com.ruoyi.frequency.mallorderstatus.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.ruoyi.enums.mallorder.MallOrderStatusEnums; +import com.ruoyi.frequency.mallorder.entity.MallOrder; +import com.ruoyi.frequency.mallorderstatus.entity.MallOrderStatus; +import com.ruoyi.frequency.mallorderstatus.mapper.MallOrderStatusMapper; +import com.ruoyi.frequency.mallorderstatus.service.MallOrderStatusService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.Date; +import java.util.List; + +/** + * 订单流程Service业务层处理 + * + * @author liwenlong + * @date 2024-01-25 + */ +@Service +public class MallOrderStatusServiceImpl extends ServiceImpl implements MallOrderStatusService +{ + @Autowired + private MallOrderStatusMapper mallOrderStatusMapper; + + /** + * 查询订单流程 + * + * @param id 订单流程主键 + * @return 订单流程 + */ + @Override + public MallOrderStatus selectMallOrderStatusById(Long id) + { + return mallOrderStatusMapper.selectMallOrderStatusById(id); + } + + /** + * 查询订单流程列表 + * + * @param mallOrderStatus 订单流程 + * @return 订单流程 + */ + @Override + public List selectMallOrderStatusList(MallOrderStatus mallOrderStatus) + { + return mallOrderStatusMapper.selectMallOrderStatusList(mallOrderStatus); + } + + /** + * 新增订单流程 + * + * @param mallOrderStatus 订单流程 + * @return 结果 + */ + @Override + public int insertMallOrderStatus(MallOrderStatus mallOrderStatus) + { + mallOrderStatus.setCreateData(); + return mallOrderStatusMapper.insert(mallOrderStatus); + } + + /** + * 修改订单流程 + * + * @param mallOrderStatus 订单流程 + * @return 结果 + */ + @Override + public int updateMallOrderStatus(MallOrderStatus mallOrderStatus) + { + mallOrderStatus.setUpdateData(); + return mallOrderStatusMapper.updateMallOrderStatus(mallOrderStatus); + } + + /** + * 批量删除订单流程 + * + * @param ids 需要删除的订单流程主键 + * @return 结果 + */ + @Override + public int deleteMallOrderStatusByIds(Long[] ids,Integer delFlag) + { + this.lambdaUpdate().set(MallOrderStatus::getDelFlag,delFlag).in(MallOrderStatus::getId,ids).update(); + return ids.length; + } + + @Override + public void recordOrderStatus(MallOrder order, MallOrderStatusEnums orderStatusEnums) { + MallOrderStatus orderStatus = new MallOrderStatus(); + orderStatus.setStatus(orderStatusEnums.getCode()); + orderStatus.setCreateTime(new Date()); + orderStatus.setOrderType(1); + orderStatus.setName(orderStatusEnums.getName()); + orderStatus.setOrderId(order.getId()); + this.save(orderStatus); + } +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallrefund/controller/MallRefundController.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallrefund/controller/MallRefundController.java new file mode 100644 index 0000000..f872321 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallrefund/controller/MallRefundController.java @@ -0,0 +1,97 @@ +package com.ruoyi.frequency.mallrefund.controller; + +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.page.TableDataInfo; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.common.utils.poi.ExcelUtil; +import com.ruoyi.frequency.mallrefund.entity.MallRefund; +import com.ruoyi.frequency.mallrefund.service.MallRefundService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +/** + * 订单退款Controller + * + * @author liwenlong + * @date 2024-01-25 + */ +@RestController +@RequestMapping("/frequency/mallrefund") +public class MallRefundController extends BaseController +{ + @Autowired + private MallRefundService mallRefundService; + + /** + * 查询订单退款列表 + */ + @PreAuthorize("@ss.hasPermi('frequency:mallrefund:list')") + @PostMapping("/list") + public TableDataInfo list(@RequestBody MallRefund mallRefund) + { + startPage(); + List list = mallRefundService.selectMallRefundList(mallRefund); + return getDataTable(list); + } + + /** + * 导出订单退款列表 + */ + @PreAuthorize("@ss.hasPermi('frequency:mallrefund:export')") + @Log(title = "订单退款", businessType = BusinessType.EXPORT) + @GetMapping("/export") + public AjaxResult export(MallRefund mallRefund) + { + List list = mallRefundService.selectMallRefundList(mallRefund); + ExcelUtil util = new ExcelUtil(MallRefund.class); + return util.exportExcel(list, "订单退款数据"); + } + + /** + * 获取订单退款详细信息 + */ + @PreAuthorize("@ss.hasPermi('frequency:mallrefund:query')") + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") Long id) + { + return AjaxResult.success(mallRefundService.selectMallRefundById(id)); + } + + /** + * 新增订单退款 + */ + @PreAuthorize("@ss.hasPermi('frequency:mallrefund:add')") + @Log(title = "订单退款", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody MallRefund mallRefund) + { + return toAjax(mallRefundService.insertMallRefund(mallRefund)); + } + + /** + * 修改订单退款 + */ + @PreAuthorize("@ss.hasPermi('frequency:mallrefund:edit')") + @Log(title = "订单退款", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody MallRefund mallRefund) + { + return toAjax(mallRefundService.updateMallRefund(mallRefund)); + } + + /** + * 删除订单退款 + */ + @PreAuthorize("@ss.hasPermi('frequency:mallrefund:remove')") + @Log(title = "订单退款", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}/{delFlag}") + public AjaxResult remove(@PathVariable("ids") Long[] ids,@PathVariable("delFlag") Integer delFlag) + { + return toAjax(mallRefundService.deleteMallRefundByIds(ids,delFlag)); + } +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallrefund/entity/MallRefund.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallrefund/entity/MallRefund.java new file mode 100644 index 0000000..fd9ed6e --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallrefund/entity/MallRefund.java @@ -0,0 +1,104 @@ +package com.ruoyi.frequency.mallrefund.entity; + +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableName; +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import com.ruoyi.frequency.mallordergoods.entity.MallOrderGoods; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; + +import java.math.BigDecimal; +import java.util.Date; +import java.util.List; + +/** + * 订单退款对象 mall_refund + * + * @author liwenlong + * @date 2024-01-25 + */ +@Data +@Accessors(chain = true) +@TableName("mall_refund") +public class MallRefund extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + + @ApiModelProperty("主键id") + private Long id; + + @ApiModelProperty("删除标志 1正常 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("订单id") + @Excel(name = "订单id") + private Long orderId; + + @ApiModelProperty("当前退款流程 当refund_type=1时,1 申请退款 2 商家同意退款 3 商家拒绝退款 ;当refund_type为2时,1申请退款退货,2商家同意退款退货,3 用户发货 4 商家确认收货 5 商家拒绝退款退货") + @Excel(name = "当前退款流程 当refund_type=1时,1 申请退款 2 商家同意退款 3 商家拒绝退款 ;当refund_type为2时,1申请退款退货,2商家同意退款退货,3 用户发货 4 商家确认收货 5 商家拒绝退款退货") + private Integer status; + + @ApiModelProperty("1 退款 2 退款退货") + @Excel(name = "1 退款 2 退款退货") + private Integer refundType; + + @ApiModelProperty("退货物流单号") + @Excel(name = "退货物流单号") + private String comCourierId; + + @ApiModelProperty("退货物流公司编码") + @Excel(name = "退货物流公司编码") + private String comLogisticsCode; + + @ApiModelProperty("退货物流公司") + @Excel(name = "退货物流公司") + private String comLogistics; + + @ApiModelProperty("申请原因") + @Excel(name = "申请原因") + private String refundReason; + + @ApiModelProperty("申请配图") + @Excel(name = "申请配图") + private String refundImages; + + @ApiModelProperty("商家拒绝原因") + @Excel(name = "商家拒绝原因") + private String refuseReason; + + @ApiModelProperty("退款说明") + @Excel(name = "退款说明") + private String refundExplain; + + @ApiModelProperty("审核时间") + @Excel(name = "审核时间", width = 30, dateFormat = "yyyy-MM-dd") + private Date checkTime; + + @ApiModelProperty("商家id") + @Excel(name = "商家id") + private Long storeId; + + @ApiModelProperty("订单类型 1 普通订单") + @Excel(name = "订单类型 1 普通订单") + private Integer orderType; + + @ApiModelProperty("商品退款数量") + @Excel(name = "商品退款数量") + private Long refundNum; + + @ApiModelProperty("退款金额") + @Excel(name = "退款金额") + private BigDecimal refundPrice; + + @ApiModelProperty("售后确认收货时间") + @Excel(name = "售后确认收货时间", width = 30, dateFormat = "yyyy-MM-dd") + private Date affirmTime; + + @ApiModelProperty("订单商品") + @TableField(exist = false) + private List orderGoodsList; + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallrefund/mapper/MallRefundMapper.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallrefund/mapper/MallRefundMapper.java new file mode 100644 index 0000000..905e008 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallrefund/mapper/MallRefundMapper.java @@ -0,0 +1,48 @@ +package com.ruoyi.frequency.mallrefund.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.ruoyi.frequency.mallrefund.entity.MallRefund; + +import java.util.List; + +/** + * 订单退款Mapper接口 + * + * @author liwenlong + * @date 2024-01-25 + */ +public interface MallRefundMapper extends BaseMapper +{ + /** + * 查询订单退款 + * + * @param id 订单退款主键 + * @return 订单退款 + */ + public MallRefund selectMallRefundById(Long id); + + /** + * 查询订单退款列表 + * + * @param mallRefund 订单退款 + * @return 订单退款集合 + */ + public List selectMallRefundList(MallRefund mallRefund); + + /** + * 新增订单退款 + * + * @param mallRefund 订单退款 + * @return 结果 + */ + public int insertMallRefund(MallRefund mallRefund); + + /** + * 修改订单退款 + * + * @param mallRefund 订单退款 + * @return 结果 + */ + public int updateMallRefund(MallRefund mallRefund); + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallrefund/mapper/mapping/MallRefundMapper.xml b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallrefund/mapper/mapping/MallRefundMapper.xml new file mode 100644 index 0000000..0850d83 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallrefund/mapper/mapping/MallRefundMapper.xml @@ -0,0 +1,170 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + select + t.id , + t.create_by , + t.create_time , + t.update_by , + t.update_time , + t.del_flag , + t.order_id , + t.status , + t.refund_type , + t.com_courier_id , + t.com_logistics_code , + t.com_logistics , + t.refund_reason , + t.refund_images , + t.refuse_reason , + t.refund_explain , + t.check_time , + t.store_id , + t.order_type , + t.refund_num , + t.refund_price , + t.affirm_time + from mall_refund AS t + + + + + + + + + insert into mall_refund + + id, + create_by, + create_time, + update_by, + update_time, + del_flag, + order_id, + status, + refund_type, + com_courier_id, + com_logistics_code, + com_logistics, + refund_reason, + refund_images, + refuse_reason, + refund_explain, + check_time, + store_id, + order_type, + refund_num, + refund_price, + affirm_time, + + + #{id}, + #{createBy}, + #{createTime}, + #{updateBy}, + #{updateTime}, + #{delFlag}, + #{orderId}, + #{status}, + #{refundType}, + #{comCourierId}, + #{comLogisticsCode}, + #{comLogistics}, + #{refundReason}, + #{refundImages}, + #{refuseReason}, + #{refundExplain}, + #{checkTime}, + #{storeId}, + #{orderType}, + #{refundNum}, + #{refundPrice}, + #{affirmTime}, + + + + + update mall_refund + + create_by = #{createBy}, + create_time = #{createTime}, + update_by = #{updateBy}, + update_time = #{updateTime}, + del_flag = #{delFlag}, + order_id = #{orderId}, + status = #{status}, + refund_type = #{refundType}, + com_courier_id = #{comCourierId}, + com_logistics_code = #{comLogisticsCode}, + com_logistics = #{comLogistics}, + refund_reason = #{refundReason}, + refund_images = #{refundImages}, + refuse_reason = #{refuseReason}, + refund_explain = #{refundExplain}, + check_time = #{checkTime}, + store_id = #{storeId}, + order_type = #{orderType}, + refund_num = #{refundNum}, + refund_price = #{refundPrice}, + affirm_time = #{affirmTime}, + + where id = #{id} + + \ No newline at end of file diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallrefund/model/param/MallRefundParam.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallrefund/model/param/MallRefundParam.java new file mode 100644 index 0000000..e577c21 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallrefund/model/param/MallRefundParam.java @@ -0,0 +1,113 @@ +package com.ruoyi.frequency.mallrefund.model.param; + +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; + +import java.math.BigDecimal; +import java.util.Date; + +/** + * 订单退款对象 mall_refund + * + * @author liwenlong + * @date 2024-01-25 + */ +@Data +@Accessors(chain = true) +public class MallRefundParam extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + @ApiModelProperty("主键id") + private Long id; + + @ApiModelProperty("删除标志 1正常 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("订单id") + @Excel(name = "订单id") + private Long orderId; + + @ApiModelProperty("当前退款流程 当refund_type=1时,1 申请退款 2 商家同意退款 3 商家拒绝退款 ;当refund_type为2时,1申请退款退货,2商家同意退款退货,3 用户发货 4 商家确认收货 5 商家拒绝退款退货") + @Excel(name = "当前退款流程 当refund_type=1时,1 申请退款 2 商家同意退款 3 商家拒绝退款 ;当refund_type为2时,1申请退款退货,2商家同意退款退货,3 用户发货 4 商家确认收货 5 商家拒绝退款退货") + private Integer status; + + @ApiModelProperty("1 退款 2 退款退货") + @Excel(name = "1 退款 2 退款退货") + private Integer refundType; + + @ApiModelProperty("退货物流单号") + @Excel(name = "退货物流单号") + private String comCourierId; + + @ApiModelProperty("退货物流公司编码") + @Excel(name = "退货物流公司编码") + private String comLogisticsCode; + + @ApiModelProperty("退货物流公司") + @Excel(name = "退货物流公司") + private String comLogistics; + + @ApiModelProperty("申请原因") + @Excel(name = "申请原因") + private String refundReason; + + @ApiModelProperty("申请配图") + @Excel(name = "申请配图") + private String refundImages; + + @ApiModelProperty("商家拒绝原因") + @Excel(name = "商家拒绝原因") + private String refuseReason; + + @ApiModelProperty("退款说明") + @Excel(name = "退款说明") + private String refundExplain; + + @ApiModelProperty("审核时间") + @Excel(name = "审核时间", width = 30, dateFormat = "yyyy-MM-dd") + private Date checkTime; + + @ApiModelProperty("商家id") + @Excel(name = "商家id") + private Long storeId; + + @ApiModelProperty("订单类型 1 普通订单") + @Excel(name = "订单类型 1 普通订单") + private Integer orderType; + + @ApiModelProperty("商品退款数量") + @Excel(name = "商品退款数量") + private Long refundNum; + + @ApiModelProperty("退款金额") + @Excel(name = "退款金额") + private BigDecimal refundPrice; + + @ApiModelProperty("售后确认收货时间") + @Excel(name = "售后确认收货时间", width = 30, dateFormat = "yyyy-MM-dd") + private Date affirmTime; + + + + + + + + + + + + + + + + + + + + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallrefund/model/result/MallRefundResult.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallrefund/model/result/MallRefundResult.java new file mode 100644 index 0000000..12617c8 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallrefund/model/result/MallRefundResult.java @@ -0,0 +1,95 @@ +package com.ruoyi.frequency.mallrefund.model.result; + +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; + +import java.math.BigDecimal; +import java.util.Date; + +/** + * 订单退款对象 mall_refund + * + * @author liwenlong + * @date 2024-01-25 + */ +@Data +@Accessors(chain = true) +public class MallRefundResult extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + @ApiModelProperty("主键id") + private Long id; + + @ApiModelProperty("删除标志 1正常 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("订单id") + @Excel(name = "订单id") + private Long orderId; + + @ApiModelProperty("当前退款流程 当refund_type=1时,1 申请退款 2 商家同意退款 3 商家拒绝退款 ;当refund_type为2时,1申请退款退货,2商家同意退款退货,3 用户发货 4 商家确认收货 5 商家拒绝退款退货") + @Excel(name = "当前退款流程 当refund_type=1时,1 申请退款 2 商家同意退款 3 商家拒绝退款 ;当refund_type为2时,1申请退款退货,2商家同意退款退货,3 用户发货 4 商家确认收货 5 商家拒绝退款退货") + private Integer status; + + @ApiModelProperty("1 退款 2 退款退货") + @Excel(name = "1 退款 2 退款退货") + private Integer refundType; + + @ApiModelProperty("退货物流单号") + @Excel(name = "退货物流单号") + private String comCourierId; + + @ApiModelProperty("退货物流公司编码") + @Excel(name = "退货物流公司编码") + private String comLogisticsCode; + + @ApiModelProperty("退货物流公司") + @Excel(name = "退货物流公司") + private String comLogistics; + + @ApiModelProperty("申请原因") + @Excel(name = "申请原因") + private String refundReason; + + @ApiModelProperty("申请配图") + @Excel(name = "申请配图") + private String refundImages; + + @ApiModelProperty("商家拒绝原因") + @Excel(name = "商家拒绝原因") + private String refuseReason; + + @ApiModelProperty("退款说明") + @Excel(name = "退款说明") + private String refundExplain; + + @ApiModelProperty("审核时间") + @Excel(name = "审核时间", width = 30, dateFormat = "yyyy-MM-dd") + private Date checkTime; + + @ApiModelProperty("商家id") + @Excel(name = "商家id") + private Long storeId; + + @ApiModelProperty("订单类型 1 普通订单") + @Excel(name = "订单类型 1 普通订单") + private Integer orderType; + + @ApiModelProperty("商品退款数量") + @Excel(name = "商品退款数量") + private Long refundNum; + + @ApiModelProperty("退款金额") + @Excel(name = "退款金额") + private BigDecimal refundPrice; + + @ApiModelProperty("售后确认收货时间") + @Excel(name = "售后确认收货时间", width = 30, dateFormat = "yyyy-MM-dd") + private Date affirmTime; + + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallrefund/service/MallRefundService.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallrefund/service/MallRefundService.java new file mode 100644 index 0000000..8e58d08 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallrefund/service/MallRefundService.java @@ -0,0 +1,56 @@ +package com.ruoyi.frequency.mallrefund.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.ruoyi.frequency.mallrefund.entity.MallRefund; + +import java.util.List; + +/** + * 订单退款Service接口 + * + * @author liwenlong + * @date 2024-01-25 + */ +public interface MallRefundService extends IService +{ + /** + * 查询订单退款 + * + * @param id 订单退款主键 + * @return 订单退款 + */ + public MallRefund selectMallRefundById(Long id); + + /** + * 查询订单退款列表 + * + * @param mallRefund 订单退款 + * @return 订单退款集合 + */ + public List selectMallRefundList(MallRefund mallRefund); + + /** + * 新增订单退款 + * + * @param mallRefund 订单退款 + * @return 结果 + */ + public int insertMallRefund(MallRefund mallRefund); + + /** + * 修改订单退款 + * + * @param mallRefund 订单退款 + * @return 结果 + */ + public int updateMallRefund(MallRefund mallRefund); + + /** + * 批量删除订单退款 + * + * @param ids 需要删除的订单退款主键集合 + * @return 结果 + */ + public int deleteMallRefundByIds(Long[] ids,Integer delFlag); + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallrefund/service/impl/MallRefundServiceImpl.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallrefund/service/impl/MallRefundServiceImpl.java new file mode 100644 index 0000000..f5e6a73 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallrefund/service/impl/MallRefundServiceImpl.java @@ -0,0 +1,87 @@ +package com.ruoyi.frequency.mallrefund.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.ruoyi.frequency.mallrefund.entity.MallRefund; +import com.ruoyi.frequency.mallrefund.mapper.MallRefundMapper; +import com.ruoyi.frequency.mallrefund.service.MallRefundService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * 订单退款Service业务层处理 + * + * @author liwenlong + * @date 2024-01-25 + */ +@Service +public class MallRefundServiceImpl extends ServiceImpl implements MallRefundService +{ + @Autowired + private MallRefundMapper mallRefundMapper; + + /** + * 查询订单退款 + * + * @param id 订单退款主键 + * @return 订单退款 + */ + @Override + public MallRefund selectMallRefundById(Long id) + { + return mallRefundMapper.selectMallRefundById(id); + } + + /** + * 查询订单退款列表 + * + * @param mallRefund 订单退款 + * @return 订单退款 + */ + @Override + public List selectMallRefundList(MallRefund mallRefund) + { + return mallRefundMapper.selectMallRefundList(mallRefund); + } + + /** + * 新增订单退款 + * + * @param mallRefund 订单退款 + * @return 结果 + */ + @Override + public int insertMallRefund(MallRefund mallRefund) + { + mallRefund.setCreateData(); + return mallRefundMapper.insert(mallRefund); + } + + /** + * 修改订单退款 + * + * @param mallRefund 订单退款 + * @return 结果 + */ + @Override + public int updateMallRefund(MallRefund mallRefund) + { + mallRefund.setUpdateData(); + return mallRefundMapper.updateMallRefund(mallRefund); + } + + /** + * 批量删除订单退款 + * + * @param ids 需要删除的订单退款主键 + * @return 结果 + */ + @Override + public int deleteMallRefundByIds(Long[] ids,Integer delFlag) + { + this.lambdaUpdate().set(MallRefund::getDelFlag,delFlag).in(MallRefund::getId,ids).update(); + return ids.length; + } + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallrefundordergoods/controller/MallRefundOrderGoodsController.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallrefundordergoods/controller/MallRefundOrderGoodsController.java new file mode 100644 index 0000000..1df05b3 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallrefundordergoods/controller/MallRefundOrderGoodsController.java @@ -0,0 +1,97 @@ +package com.ruoyi.frequency.mallrefundordergoods.controller; + +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.page.TableDataInfo; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.common.utils.poi.ExcelUtil; +import com.ruoyi.frequency.mallrefundordergoods.entity.MallRefundOrderGoods; +import com.ruoyi.frequency.mallrefundordergoods.service.MallRefundOrderGoodsService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +/** + * 订单退款商品关联Controller + * + * @author liwenlong + * @date 2024-01-25 + */ +@RestController +@RequestMapping("/frequency/mallrefundordergoods") +public class MallRefundOrderGoodsController extends BaseController +{ + @Autowired + private MallRefundOrderGoodsService mallRefundOrderGoodsService; + + /** + * 查询订单退款商品关联列表 + */ + @PreAuthorize("@ss.hasPermi('frequency:mallrefundordergoods:list')") + @GetMapping("/list") + public TableDataInfo list(MallRefundOrderGoods mallRefundOrderGoods) + { + startPage(); + List list = mallRefundOrderGoodsService.selectMallRefundOrderGoodsList(mallRefundOrderGoods); + return getDataTable(list); + } + + /** + * 导出订单退款商品关联列表 + */ + @PreAuthorize("@ss.hasPermi('frequency:mallrefundordergoods:export')") + @Log(title = "订单退款商品关联", businessType = BusinessType.EXPORT) + @GetMapping("/export") + public AjaxResult export(MallRefundOrderGoods mallRefundOrderGoods) + { + List list = mallRefundOrderGoodsService.selectMallRefundOrderGoodsList(mallRefundOrderGoods); + ExcelUtil util = new ExcelUtil(MallRefundOrderGoods.class); + return util.exportExcel(list, "订单退款商品关联数据"); + } + + /** + * 获取订单退款商品关联详细信息 + */ + @PreAuthorize("@ss.hasPermi('frequency:mallrefundordergoods:query')") + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") Long id) + { + return AjaxResult.success(mallRefundOrderGoodsService.selectMallRefundOrderGoodsById(id)); + } + + /** + * 新增订单退款商品关联 + */ + @PreAuthorize("@ss.hasPermi('frequency:mallrefundordergoods:add')") + @Log(title = "订单退款商品关联", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody MallRefundOrderGoods mallRefundOrderGoods) + { + return toAjax(mallRefundOrderGoodsService.insertMallRefundOrderGoods(mallRefundOrderGoods)); + } + + /** + * 修改订单退款商品关联 + */ + @PreAuthorize("@ss.hasPermi('frequency:mallrefundordergoods:edit')") + @Log(title = "订单退款商品关联", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody MallRefundOrderGoods mallRefundOrderGoods) + { + return toAjax(mallRefundOrderGoodsService.updateMallRefundOrderGoods(mallRefundOrderGoods)); + } + + /** + * 删除订单退款商品关联 + */ + @PreAuthorize("@ss.hasPermi('frequency:mallrefundordergoods:remove')") + @Log(title = "订单退款商品关联", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}/{delFlag}") + public AjaxResult remove(@PathVariable("ids") Long[] ids,@PathVariable("delFlag") Integer delFlag) + { + return toAjax(mallRefundOrderGoodsService.deleteMallRefundOrderGoodsByIds(ids,delFlag)); + } +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallrefundordergoods/entity/MallRefundOrderGoods.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallrefundordergoods/entity/MallRefundOrderGoods.java new file mode 100644 index 0000000..c2afd0d --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallrefundordergoods/entity/MallRefundOrderGoods.java @@ -0,0 +1,44 @@ +package com.ruoyi.frequency.mallrefundordergoods.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; + +/** + * 订单退款商品关联对象 mall_refund_order_goods + * + * @author liwenlong + * @date 2024-01-25 + */ +@Data +@Accessors(chain = true) +@TableName("mall_refund_order_goods") +public class MallRefundOrderGoods extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + + @ApiModelProperty("主键id") + private Long id; + + @ApiModelProperty("删除标志;1正常 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("退款ID") + @Excel(name = "退款ID") + private Long refundId; + + @ApiModelProperty("订单商品ID") + @Excel(name = "订单商品ID") + private Long orderGoodsId; + + @ApiModelProperty("商品退款数量") + @Excel(name = "商品退款数量") + private Long refundNum; + + + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallrefundordergoods/mapper/MallRefundOrderGoodsMapper.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallrefundordergoods/mapper/MallRefundOrderGoodsMapper.java new file mode 100644 index 0000000..409af3e --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallrefundordergoods/mapper/MallRefundOrderGoodsMapper.java @@ -0,0 +1,48 @@ +package com.ruoyi.frequency.mallrefundordergoods.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.ruoyi.frequency.mallrefundordergoods.entity.MallRefundOrderGoods; + +import java.util.List; + +/** + * 订单退款商品关联Mapper接口 + * + * @author liwenlong + * @date 2024-01-25 + */ +public interface MallRefundOrderGoodsMapper extends BaseMapper +{ + /** + * 查询订单退款商品关联 + * + * @param id 订单退款商品关联主键 + * @return 订单退款商品关联 + */ + public MallRefundOrderGoods selectMallRefundOrderGoodsById(Long id); + + /** + * 查询订单退款商品关联列表 + * + * @param mallRefundOrderGoods 订单退款商品关联 + * @return 订单退款商品关联集合 + */ + public List selectMallRefundOrderGoodsList(MallRefundOrderGoods mallRefundOrderGoods); + + /** + * 新增订单退款商品关联 + * + * @param mallRefundOrderGoods 订单退款商品关联 + * @return 结果 + */ + public int insertMallRefundOrderGoods(MallRefundOrderGoods mallRefundOrderGoods); + + /** + * 修改订单退款商品关联 + * + * @param mallRefundOrderGoods 订单退款商品关联 + * @return 结果 + */ + public int updateMallRefundOrderGoods(MallRefundOrderGoods mallRefundOrderGoods); + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallrefundordergoods/mapper/mapping/MallRefundOrderGoodsMapper.xml b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallrefundordergoods/mapper/mapping/MallRefundOrderGoodsMapper.xml new file mode 100644 index 0000000..77ee9dc --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallrefundordergoods/mapper/mapping/MallRefundOrderGoodsMapper.xml @@ -0,0 +1,92 @@ + + + + + + + + + + + + + + + + + + + + select + t.id , + t.create_by , + t.create_time , + t.update_by , + t.update_time , + t.del_flag , + t.refund_id , + t.order_goods_id , + t.refund_num + from mall_refund_order_goods AS t + + + + + + + + + insert into mall_refund_order_goods + + id, + create_by, + create_time, + update_by, + update_time, + del_flag, + refund_id, + order_goods_id, + refund_num, + + + #{id}, + #{createBy}, + #{createTime}, + #{updateBy}, + #{updateTime}, + #{delFlag}, + #{refundId}, + #{orderGoodsId}, + #{refundNum}, + + + + + update mall_refund_order_goods + + create_by = #{createBy}, + create_time = #{createTime}, + update_by = #{updateBy}, + update_time = #{updateTime}, + del_flag = #{delFlag}, + refund_id = #{refundId}, + order_goods_id = #{orderGoodsId}, + refund_num = #{refundNum}, + + where id = #{id} + + \ No newline at end of file diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallrefundordergoods/model/param/MallRefundOrderGoodsParam.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallrefundordergoods/model/param/MallRefundOrderGoodsParam.java new file mode 100644 index 0000000..69a0a0f --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallrefundordergoods/model/param/MallRefundOrderGoodsParam.java @@ -0,0 +1,45 @@ +package com.ruoyi.frequency.mallrefundordergoods.model.param; + +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; + +/** + * 订单退款商品关联对象 mall_refund_order_goods + * + * @author liwenlong + * @date 2024-01-25 + */ +@Data +@Accessors(chain = true) +public class MallRefundOrderGoodsParam extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + @ApiModelProperty("主键id") + private Long id; + + @ApiModelProperty("删除标志;1正常 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("退款ID") + @Excel(name = "退款ID") + private Long refundId; + + @ApiModelProperty("订单商品ID") + @Excel(name = "订单商品ID") + private Long orderGoodsId; + + @ApiModelProperty("商品退款数量") + @Excel(name = "商品退款数量") + private Long refundNum; + + + + + + + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallrefundordergoods/model/result/MallRefundOrderGoodsResult.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallrefundordergoods/model/result/MallRefundOrderGoodsResult.java new file mode 100644 index 0000000..cb20d25 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallrefundordergoods/model/result/MallRefundOrderGoodsResult.java @@ -0,0 +1,40 @@ +package com.ruoyi.frequency.mallrefundordergoods.model.result; + +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; + +/** + * 订单退款商品关联对象 mall_refund_order_goods + * + * @author liwenlong + * @date 2024-01-25 + */ +@Data +@Accessors(chain = true) +public class MallRefundOrderGoodsResult extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + @ApiModelProperty("主键id") + private Long id; + + @ApiModelProperty("删除标志;1正常 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("退款ID") + @Excel(name = "退款ID") + private Long refundId; + + @ApiModelProperty("订单商品ID") + @Excel(name = "订单商品ID") + private Long orderGoodsId; + + @ApiModelProperty("商品退款数量") + @Excel(name = "商品退款数量") + private Long refundNum; + + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallrefundordergoods/service/MallRefundOrderGoodsService.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallrefundordergoods/service/MallRefundOrderGoodsService.java new file mode 100644 index 0000000..b4ab832 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallrefundordergoods/service/MallRefundOrderGoodsService.java @@ -0,0 +1,56 @@ +package com.ruoyi.frequency.mallrefundordergoods.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.ruoyi.frequency.mallrefundordergoods.entity.MallRefundOrderGoods; + +import java.util.List; + +/** + * 订单退款商品关联Service接口 + * + * @author liwenlong + * @date 2024-01-25 + */ +public interface MallRefundOrderGoodsService extends IService +{ + /** + * 查询订单退款商品关联 + * + * @param id 订单退款商品关联主键 + * @return 订单退款商品关联 + */ + public MallRefundOrderGoods selectMallRefundOrderGoodsById(Long id); + + /** + * 查询订单退款商品关联列表 + * + * @param mallRefundOrderGoods 订单退款商品关联 + * @return 订单退款商品关联集合 + */ + public List selectMallRefundOrderGoodsList(MallRefundOrderGoods mallRefundOrderGoods); + + /** + * 新增订单退款商品关联 + * + * @param mallRefundOrderGoods 订单退款商品关联 + * @return 结果 + */ + public int insertMallRefundOrderGoods(MallRefundOrderGoods mallRefundOrderGoods); + + /** + * 修改订单退款商品关联 + * + * @param mallRefundOrderGoods 订单退款商品关联 + * @return 结果 + */ + public int updateMallRefundOrderGoods(MallRefundOrderGoods mallRefundOrderGoods); + + /** + * 批量删除订单退款商品关联 + * + * @param ids 需要删除的订单退款商品关联主键集合 + * @return 结果 + */ + public int deleteMallRefundOrderGoodsByIds(Long[] ids,Integer delFlag); + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallrefundordergoods/service/impl/MallRefundOrderGoodsServiceImpl.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallrefundordergoods/service/impl/MallRefundOrderGoodsServiceImpl.java new file mode 100644 index 0000000..3468d22 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallrefundordergoods/service/impl/MallRefundOrderGoodsServiceImpl.java @@ -0,0 +1,87 @@ +package com.ruoyi.frequency.mallrefundordergoods.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.ruoyi.frequency.mallrefundordergoods.entity.MallRefundOrderGoods; +import com.ruoyi.frequency.mallrefundordergoods.mapper.MallRefundOrderGoodsMapper; +import com.ruoyi.frequency.mallrefundordergoods.service.MallRefundOrderGoodsService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * 订单退款商品关联Service业务层处理 + * + * @author liwenlong + * @date 2024-01-25 + */ +@Service +public class MallRefundOrderGoodsServiceImpl extends ServiceImpl implements MallRefundOrderGoodsService +{ + @Autowired + private MallRefundOrderGoodsMapper mallRefundOrderGoodsMapper; + + /** + * 查询订单退款商品关联 + * + * @param id 订单退款商品关联主键 + * @return 订单退款商品关联 + */ + @Override + public MallRefundOrderGoods selectMallRefundOrderGoodsById(Long id) + { + return mallRefundOrderGoodsMapper.selectMallRefundOrderGoodsById(id); + } + + /** + * 查询订单退款商品关联列表 + * + * @param mallRefundOrderGoods 订单退款商品关联 + * @return 订单退款商品关联 + */ + @Override + public List selectMallRefundOrderGoodsList(MallRefundOrderGoods mallRefundOrderGoods) + { + return mallRefundOrderGoodsMapper.selectMallRefundOrderGoodsList(mallRefundOrderGoods); + } + + /** + * 新增订单退款商品关联 + * + * @param mallRefundOrderGoods 订单退款商品关联 + * @return 结果 + */ + @Override + public int insertMallRefundOrderGoods(MallRefundOrderGoods mallRefundOrderGoods) + { + mallRefundOrderGoods.setCreateData(); + return mallRefundOrderGoodsMapper.insert(mallRefundOrderGoods); + } + + /** + * 修改订单退款商品关联 + * + * @param mallRefundOrderGoods 订单退款商品关联 + * @return 结果 + */ + @Override + public int updateMallRefundOrderGoods(MallRefundOrderGoods mallRefundOrderGoods) + { + mallRefundOrderGoods.setUpdateData(); + return mallRefundOrderGoodsMapper.updateMallRefundOrderGoods(mallRefundOrderGoods); + } + + /** + * 批量删除订单退款商品关联 + * + * @param ids 需要删除的订单退款商品关联主键 + * @return 结果 + */ + @Override + public int deleteMallRefundOrderGoodsByIds(Long[] ids,Integer delFlag) + { + this.lambdaUpdate().set(MallRefundOrderGoods::getDelFlag,delFlag).in(MallRefundOrderGoods::getId,ids).update(); + return ids.length; + } + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallshoppingcar/controller/MallShoppingCarController.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallshoppingcar/controller/MallShoppingCarController.java new file mode 100644 index 0000000..fc9dc62 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallshoppingcar/controller/MallShoppingCarController.java @@ -0,0 +1,103 @@ +package com.ruoyi.frequency.mallshoppingcar.controller; + +import java.util.List; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.frequency.mallshoppingcar.entity.MallShoppingCar; +import com.ruoyi.frequency.mallshoppingcar.service.MallShoppingCarService; +import com.ruoyi.common.utils.poi.ExcelUtil; +import com.ruoyi.common.core.page.TableDataInfo; + +/** + * 购物车Controller + * + * @author liwenlong + * @date 2024-01-25 + */ +@RestController +@RequestMapping("/frequency/mallshoppingcar") +public class MallShoppingCarController extends BaseController +{ + @Autowired + private MallShoppingCarService mallShoppingCarService; + + /** + * 查询购物车列表 + */ + @PreAuthorize("@ss.hasPermi('frequency:mallshoppingcar:list')") + @GetMapping("/list") + public TableDataInfo list(MallShoppingCar mallShoppingCar) + { + startPage(); + List list = mallShoppingCarService.selectMallShoppingCarList(mallShoppingCar); + return getDataTable(list); + } + + /** + * 导出购物车列表 + */ + @PreAuthorize("@ss.hasPermi('frequency:mallshoppingcar:export')") + @Log(title = "购物车", businessType = BusinessType.EXPORT) + @GetMapping("/export") + public AjaxResult export(MallShoppingCar mallShoppingCar) + { + List list = mallShoppingCarService.selectMallShoppingCarList(mallShoppingCar); + ExcelUtil util = new ExcelUtil(MallShoppingCar.class); + return util.exportExcel(list, "购物车数据"); + } + + /** + * 获取购物车详细信息 + */ + @PreAuthorize("@ss.hasPermi('frequency:mallshoppingcar:query')") + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") Long id) + { + return AjaxResult.success(mallShoppingCarService.selectMallShoppingCarById(id)); + } + + /** + * 新增购物车 + */ + @PreAuthorize("@ss.hasPermi('frequency:mallshoppingcar:add')") + @Log(title = "购物车", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody MallShoppingCar mallShoppingCar) + { + return toAjax(mallShoppingCarService.insertMallShoppingCar(mallShoppingCar)); + } + + /** + * 修改购物车 + */ + @PreAuthorize("@ss.hasPermi('frequency:mallshoppingcar:edit')") + @Log(title = "购物车", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody MallShoppingCar mallShoppingCar) + { + return toAjax(mallShoppingCarService.updateMallShoppingCar(mallShoppingCar)); + } + + /** + * 删除购物车 + */ + @PreAuthorize("@ss.hasPermi('frequency:mallshoppingcar:remove')") + @Log(title = "购物车", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}/{delFlag}") + public AjaxResult remove(@PathVariable("ids") Long[] ids,@PathVariable("delFlag") Integer delFlag) + { + return toAjax(mallShoppingCarService.deleteMallShoppingCarByIds(ids,delFlag)); + } +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallshoppingcar/entity/MallShoppingCar.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallshoppingcar/entity/MallShoppingCar.java new file mode 100644 index 0000000..9423fad --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallshoppingcar/entity/MallShoppingCar.java @@ -0,0 +1,53 @@ +package com.ruoyi.frequency.mallshoppingcar.entity; + +import lombok.Data; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.experimental.Accessors; +import com.ruoyi.common.annotation.Excel; +import io.swagger.annotations.ApiModelProperty; +import com.baomidou.mybatisplus.annotation.TableField; +import com.ruoyi.vo.UserInfo; +import com.ruoyi.common.core.domain.BaseEntity; + +/** + * 购物车对象 mall_shopping_car + * + * @author liwenlong + * @date 2024-01-25 + */ +@Data +@Accessors(chain = true) +@TableName("mall_shopping_car") +public class MallShoppingCar extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + + @ApiModelProperty("主键id") + private Long id; + + @ApiModelProperty("删除标志;1正常 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("用户类型 1设计师 2表现师") + private Integer userType; + + @ApiModelProperty("用户id") + @Excel(name = "用户id") + private Long userId; + + @ApiModelProperty("商品id") + @Excel(name = "商品id") + private Long goodsId; + + @ApiModelProperty("$column.columnComment") + @Excel(name = "商品id") + private Long skuId; + + @ApiModelProperty("数量") + @Excel(name = "数量") + private Integer quantity; + + + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallshoppingcar/mapper/MallShoppingCarMapper.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallshoppingcar/mapper/MallShoppingCarMapper.java new file mode 100644 index 0000000..70461cf --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallshoppingcar/mapper/MallShoppingCarMapper.java @@ -0,0 +1,51 @@ +package com.ruoyi.frequency.mallshoppingcar.mapper; + +import java.util.List; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.ruoyi.controller.resp.ShoppingCarListVo; +import com.ruoyi.frequency.mallshoppingcar.entity.MallShoppingCar; +import com.ruoyi.vo.UserVo; +import org.apache.ibatis.annotations.Param; + +/** + * 购物车Mapper接口 + * + * @author liwenlong + * @date 2024-01-25 + */ +public interface MallShoppingCarMapper extends BaseMapper +{ + /** + * 查询购物车 + * + * @param id 购物车主键 + * @return 购物车 + */ + public MallShoppingCar selectMallShoppingCarById(Long id); + + /** + * 查询购物车列表 + * + * @param mallShoppingCar 购物车 + * @return 购物车集合 + */ + public List selectMallShoppingCarList(MallShoppingCar mallShoppingCar); + + /** + * 新增购物车 + * + * @param mallShoppingCar 购物车 + * @return 结果 + */ + public int insertMallShoppingCar(MallShoppingCar mallShoppingCar); + + /** + * 修改购物车 + * + * @param mallShoppingCar 购物车 + * @return 结果 + */ + public int updateMallShoppingCar(MallShoppingCar mallShoppingCar); + + List shoppingCarList(@Param("userVo") UserVo userVo, @Param("list") List shoppingCardIdList); +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallshoppingcar/mapper/mapping/MallShoppingCarMapper.xml b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallshoppingcar/mapper/mapping/MallShoppingCarMapper.xml new file mode 100644 index 0000000..d632a5c --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallshoppingcar/mapper/mapping/MallShoppingCarMapper.xml @@ -0,0 +1,131 @@ + + + + + + + + + + + + + + + + + + + + + select + t.id , + t.create_by , + t.create_time , + t.update_by , + t.update_time , + t.del_flag , + t.customer_id , + t.goods_id , + t.sku_id , + t.quantity + from mall_shopping_car AS t + + + + + + + + + insert into mall_shopping_car + + id, + create_by, + create_time, + update_by, + update_time, + del_flag, + customer_id, + goods_id, + sku_id, + quantity, + + + #{id}, + #{createBy}, + #{createTime}, + #{updateBy}, + #{updateTime}, + #{delFlag}, + #{customerId}, + #{goodsId}, + #{skuId}, + #{quantity}, + + + + + update mall_shopping_car + + create_by = #{createBy}, + create_time = #{createTime}, + update_by = #{updateBy}, + update_time = #{updateTime}, + del_flag = #{delFlag}, + customer_id = #{customerId}, + goods_id = #{goodsId}, + sku_id = #{skuId}, + quantity = #{quantity}, + + where id = #{id} + + + + diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallshoppingcar/model/param/MallShoppingCarParam.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallshoppingcar/model/param/MallShoppingCarParam.java new file mode 100644 index 0000000..d507862 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallshoppingcar/model/param/MallShoppingCarParam.java @@ -0,0 +1,50 @@ +package com.ruoyi.frequency.mallshoppingcar.model.param; + +import lombok.Data; +import lombok.experimental.Accessors; +import com.ruoyi.common.annotation.Excel; +import io.swagger.annotations.ApiModelProperty; +import com.ruoyi.common.core.domain.BaseEntity; + +/** + * 购物车对象 mall_shopping_car + * + * @author liwenlong + * @date 2024-01-25 + */ +@Data +@Accessors(chain = true) +public class MallShoppingCarParam extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + @ApiModelProperty("主键id") + private Long id; + + @ApiModelProperty("删除标志;1正常 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("用户id") + @Excel(name = "用户id") + private Long customerId; + + @ApiModelProperty("商品id") + @Excel(name = "商品id") + private Long goodsId; + + @ApiModelProperty("$column.columnComment") + @Excel(name = "商品id") + private Long skuId; + + @ApiModelProperty("数量") + @Excel(name = "数量") + private Long quantity; + + + + + + + + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallshoppingcar/model/result/MallShoppingCarResult.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallshoppingcar/model/result/MallShoppingCarResult.java new file mode 100644 index 0000000..eac230d --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallshoppingcar/model/result/MallShoppingCarResult.java @@ -0,0 +1,44 @@ +package com.ruoyi.frequency.mallshoppingcar.model.result; + +import lombok.Data; +import lombok.experimental.Accessors; +import com.ruoyi.common.annotation.Excel; +import io.swagger.annotations.ApiModelProperty; +import com.ruoyi.common.core.domain.BaseEntity; + +/** + * 购物车对象 mall_shopping_car + * + * @author liwenlong + * @date 2024-01-25 + */ +@Data +@Accessors(chain = true) +public class MallShoppingCarResult extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + @ApiModelProperty("主键id") + private Long id; + + @ApiModelProperty("删除标志;1正常 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("用户id") + @Excel(name = "用户id") + private Long customerId; + + @ApiModelProperty("商品id") + @Excel(name = "商品id") + private Long goodsId; + + @ApiModelProperty("$column.columnComment") + @Excel(name = "商品id") + private Long skuId; + + @ApiModelProperty("数量") + @Excel(name = "数量") + private Long quantity; + + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallshoppingcar/service/MallShoppingCarService.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallshoppingcar/service/MallShoppingCarService.java new file mode 100644 index 0000000..055ccbf --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallshoppingcar/service/MallShoppingCarService.java @@ -0,0 +1,83 @@ +package com.ruoyi.frequency.mallshoppingcar.service; + +import java.util.List; + +import com.ruoyi.controller.req.InsertShoppingCarReq; +import com.ruoyi.controller.req.ShoppingCarCreateOrderReq; +import com.ruoyi.controller.req.ShoppingCartSettlementReq; +import com.ruoyi.frequency.mallshoppingcar.entity.MallShoppingCar; +import com.baomidou.mybatisplus.extension.service.IService; +import com.ruoyi.response.ResponseData; +import com.ruoyi.vo.PayVo; +import com.ruoyi.vo.UserVo; + +/** + * 购物车Service接口 + * + * @author liwenlong + * @date 2024-01-25 + */ +public interface MallShoppingCarService extends IService +{ + /** + * 查询购物车 + * + * @param id 购物车主键 + * @return 购物车 + */ + public MallShoppingCar selectMallShoppingCarById(Long id); + + /** + * 查询购物车列表 + * + * @param mallShoppingCar 购物车 + * @return 购物车集合 + */ + public List selectMallShoppingCarList(MallShoppingCar mallShoppingCar); + + /** + * 新增购物车 + * + * @param mallShoppingCar 购物车 + * @return 结果 + */ + public int insertMallShoppingCar(MallShoppingCar mallShoppingCar); + + /** + * 修改购物车 + * + * @param mallShoppingCar 购物车 + * @return 结果 + */ + public int updateMallShoppingCar(MallShoppingCar mallShoppingCar); + + /** + * 批量删除购物车 + * + * @param ids 需要删除的购物车主键集合 + * @return 结果 + */ + public int deleteMallShoppingCarByIds(Long[] ids,Integer delFlag); + + /** + * 购物车列表 + * @param userVo + * @return + */ + ResponseData shoppingCarList(UserVo userVo); + + /** + * 购物车结算 + * @param req + * @param userVo + * @return + */ + PayVo shoppingCarSettlement(ShoppingCartSettlementReq req, UserVo userVo); + + ResponseData insertShoppingCar(InsertShoppingCarReq req, UserVo userVo); + + ResponseData removeShoppingCarGoods(List ids, UserVo userVo); + + ResponseData shoppingCarCreateOrder(ShoppingCarCreateOrderReq req, UserVo userVo); + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallshoppingcar/service/impl/MallShoppingCarServiceImpl.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallshoppingcar/service/impl/MallShoppingCarServiceImpl.java new file mode 100644 index 0000000..58db054 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallshoppingcar/service/impl/MallShoppingCarServiceImpl.java @@ -0,0 +1,429 @@ +package com.ruoyi.frequency.mallshoppingcar.service.impl; + +import java.math.BigDecimal; +import java.util.*; +import java.util.stream.Collectors; + +import cn.hutool.core.collection.CollectionUtil; +import cn.hutool.core.util.ObjectUtil; +import com.alibaba.fastjson.JSONObject; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.ruoyi.code.DictConstant; +import com.ruoyi.common.core.domain.entity.SysDictData; +import com.ruoyi.common.exception.CustomException; +import com.ruoyi.common.exception.enums.CoreExceptionEnum; +import com.ruoyi.controller.req.InsertShoppingCarReq; +import com.ruoyi.controller.req.ShoppingCarCreateOrderReq; +import com.ruoyi.controller.req.ShoppingCartSettlementReq; +import com.ruoyi.controller.resp.ShoppingCarListResp; +import com.ruoyi.controller.resp.ShoppingCarListVo; +import com.ruoyi.enums.MallExceptionEnum; +import com.ruoyi.enums.WalletDetailEnums; +import com.ruoyi.enums.mallorder.MallOrderStatusEnums; +import com.ruoyi.frequency.mallorder.entity.MallOrder; +import com.ruoyi.frequency.mallorder.service.MallOrderService; +import com.ruoyi.frequency.mallorderaddress.entity.MallOrderAddress; +import com.ruoyi.frequency.mallorderaddress.service.MallOrderAddressService; +import com.ruoyi.frequency.mallordergoods.entity.MallOrderGoods; +import com.ruoyi.frequency.mallordergoods.service.MallOrderGoodsService; +import com.ruoyi.frequency.mallorderstatus.service.MallOrderStatusService; +import com.ruoyi.frequency.mallspecifications.entity.MallSpecifications; +import com.ruoyi.frequency.mallspecifications.mapper.MallSpecificationsMapper; +import com.ruoyi.pay.enums.PayEnums; +import com.ruoyi.pay.enums.PaySourceEnums; +import com.ruoyi.pay.utils.PayUtil; +import com.ruoyi.response.ResponseData; +import com.ruoyi.utils.BusinessUtil; +import com.ruoyi.vo.PayVo; +import com.ruoyi.vo.UserVo; +import org.apache.ibatis.session.SqlSession; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.ruoyi.code.PublicCommon; +import com.ruoyi.frequency.mallshoppingcar.mapper.MallShoppingCarMapper; +import com.ruoyi.frequency.mallshoppingcar.entity.MallShoppingCar; +import com.ruoyi.frequency.mallshoppingcar.service.MallShoppingCarService; +import org.springframework.transaction.annotation.Transactional; + +/** + * 购物车Service业务层处理 + * + * @author liwenlong + * @date 2024-01-25 + */ +@Service +public class MallShoppingCarServiceImpl extends ServiceImpl implements MallShoppingCarService +{ + @Autowired + private MallShoppingCarMapper mallShoppingCarMapper; + + /** + * 查询购物车 + * + * @param id 购物车主键 + * @return 购物车 + */ + @Override + public MallShoppingCar selectMallShoppingCarById(Long id) + { + return mallShoppingCarMapper.selectMallShoppingCarById(id); + } + + /** + * 查询购物车列表 + * + * @param mallShoppingCar 购物车 + * @return 购物车 + */ + @Override + public List selectMallShoppingCarList(MallShoppingCar mallShoppingCar) + { + return mallShoppingCarMapper.selectMallShoppingCarList(mallShoppingCar); + } + + /** + * 新增购物车 + * + * @param mallShoppingCar 购物车 + * @return 结果 + */ + @Override + public int insertMallShoppingCar(MallShoppingCar mallShoppingCar) + { + mallShoppingCar.setCreateData(); + return mallShoppingCarMapper.insert(mallShoppingCar); + } + + /** + * 修改购物车 + * + * @param mallShoppingCar 购物车 + * @return 结果 + */ + @Override + public int updateMallShoppingCar(MallShoppingCar mallShoppingCar) + { + mallShoppingCar.setUpdateData(); + return mallShoppingCarMapper.updateMallShoppingCar(mallShoppingCar); + } + + /** + * 批量删除购物车 + * + * @param ids 需要删除的购物车主键 + * @return 结果 + */ + @Override + public int deleteMallShoppingCarByIds(Long[] ids,Integer delFlag) + { + this.lambdaUpdate().set(MallShoppingCar::getDelFlag,delFlag).in(MallShoppingCar::getId,ids).update(); + return ids.length; + } + + @Override + public ResponseData shoppingCarList(UserVo userVo) { + + //返回结果 + ShoppingCarListResp shoppingCarListResp = new ShoppingCarListResp(); + + //查询用户购物车列表(包含已经下架的商品) + List shoppingCarList = this.baseMapper.shoppingCarList(userVo,null); + + if (shoppingCarList.size() > 0){ + shoppingCarList.stream().forEach(s->{ + + if (ObjectUtil.equal(s.getGoodsFlag(), PublicCommon.启用) && ObjectUtil.equal(s.getSpecFlag(), PublicCommon.启用)){ + //用户购物车列表 + shoppingCarListResp.getEffective().add(s); + }else { + //已经下架的购物车列表 + shoppingCarListResp.getInvalid().add(s); + } + }); + + } + + return ResponseData.success(shoppingCarListResp); + } + + @Autowired + private BusinessUtil businessUtil; + + @Override + public PayVo shoppingCarSettlement(ShoppingCartSettlementReq req, UserVo userVo) { + + //判断购物车商品 并返回购物车商品 + List shoppingCarList = judgeShoppingCarGoods(userVo, req.getShoppingCardIdList()); + + //购物车结算金额 + return shoppingCarCount(shoppingCarList,userVo); + + } + + /** + * 购物车结算金额 + * @param shoppingCarList + * @return + */ + private PayVo shoppingCarCount(List shoppingCarList,UserVo userVo) { + + //购物车总金额 + BigDecimal totalPrice = new BigDecimal(0); + + //购物车总积分 + BigDecimal totalIntegral = new BigDecimal(0); + + for (ShoppingCarListVo vo : shoppingCarList) { + totalPrice = totalPrice.add(vo.getPrice().multiply(new BigDecimal(vo.getQuantity()))); + + totalIntegral = totalIntegral.add(vo.getIntegral().multiply(new BigDecimal(vo.getQuantity()))); + } + + //获取购物车最大使用赠送金额 + BigDecimal maxGivePrice = businessUtil.userMaxGivePrice(userVo,totalPrice); + + return new PayVo(totalPrice,totalIntegral,maxGivePrice); + } + + /** + * 判断购物车商品 并返回购物车商品 + * @param userVo + * @param shoppingCardIdList + * @return 购物车商品 + */ + private List judgeShoppingCarGoods(UserVo userVo, List shoppingCardIdList) { + + //查询用户购物车列表(包含已经下架的商品) + List shoppingCarList = this.baseMapper.shoppingCarList(userVo,shoppingCardIdList); + + //下架的购物车列表 + List invalidList = new ArrayList<>(); + + //库存不足的购物车列表 + List notStockList = new ArrayList<>(); + + if (shoppingCarList.size() > 0){ + shoppingCarList.stream().forEach(s->{ + + if (ObjectUtil.notEqual(s.getGoodsFlag(), PublicCommon.启用) || ObjectUtil.notEqual(s.getSpecFlag(), PublicCommon.启用)){ + invalidList.add(s); + } + + if (s.getQuantity() > s.getStock()){ + notStockList.add(s); + } + }); + + //判断购物车中商品是否下架 + if (invalidList.size() > 0){ + throw new CustomException(MallExceptionEnum.GOODS_DEL_FLAG,invalidList); + } + //判断商品库存是否足够 + if (notStockList.size() > 0){ + throw new CustomException(MallExceptionEnum.NOT_STOCK,notStockList); + } + + } + + return shoppingCarList; + } + + @Override + public ResponseData insertShoppingCar(InsertShoppingCarReq req, UserVo userVo) { + + //查询购物车 + MallShoppingCar shoppingCar = baseMapper.selectOne(new QueryWrapper().lambda() + .eq(MallShoppingCar::getUserId, userVo.getUserId()) + .eq(MallShoppingCar::getUserType, userVo.getUserType()) + .eq(MallShoppingCar::getSkuId, req.getSpeId())); + + if (shoppingCar != null) { + shoppingCar.setQuantity(req.getQuantity()); + if (shoppingCar.getQuantity() == 0) { + baseMapper.deleteById(shoppingCar.getId()); + } else { + int resultCount = this.baseMapper.updateById(shoppingCar); + if (resultCount == 0) { + return ResponseData.error("加入购物车失败"); + } + } + } else { + shoppingCar = new MallShoppingCar(); + shoppingCar.setUserId(userVo.getUserId()); + shoppingCar.setUserType(userVo.getUserType()); + shoppingCar.setGoodsId(req.getGoodsId()); + shoppingCar.setSkuId(req.getSpeId()); + shoppingCar.setQuantity(req.getQuantity()); + int resultCount = this.baseMapper.insert(shoppingCar); + if (resultCount == 0) { + return ResponseData.error("加入购物车失败"); + } + } + return ResponseData.success(); + } + + @Override + public ResponseData removeShoppingCarGoods(List ids, UserVo userVo) { + + if (CollectionUtil.isEmpty(ids)){ + return ResponseData.error(CoreExceptionEnum.NOT_NULL_PARAM); + } + + int result = this.baseMapper.deleteBatchIds(ids); + + if (result == 0) { + return ResponseData.error(MallExceptionEnum.DELETER_SHOPPING_CAR_ERROR); + } + + return ResponseData.success(); + } + + @Autowired + private MallSpecificationsMapper specificationsMapper; + + @Autowired + private PayUtil payUtil; + + @Autowired + private MallOrderAddressService orderAddressService; + + @Autowired + private MallOrderStatusService orderStatusService; + + @Override + @Transactional(rollbackFor = Exception.class) + public ResponseData shoppingCarCreateOrder(ShoppingCarCreateOrderReq req, UserVo userVo) { + + + //判断购物车商品 并返回购物车商品 + List shoppingCarList = judgeShoppingCarGoods(userVo, req.getShoppingCardIdList()); + + if (shoppingCarList.size() == 0){ + return ResponseData.error("购物车数据为空"); + } + + //购物车结算金额 + PayVo payVo = shoppingCarCount(shoppingCarList, userVo); + + //判断余额 + if (ObjectUtil.equal(PayEnums.balance.getCode(),req.getPayType())){ + businessUtil.judgeBalancePay(userVo,payVo.getPrice(),req.getBalancePayPwd()); + } + + //判断积分余额 + businessUtil.judgeIntegralPay(userVo,payVo.getIntegral(),req.getBalancePayPwd()); + + //扣除库存 + List specList = shoppingCarList.stream().map(s -> new MallSpecifications().setId(s.getSpecId()).setStock(s.getQuantity())).collect(Collectors.toList()); + Boolean updateStock = specificationsMapper.subStock(specList); + if (!updateStock){ + throw new CustomException(MallExceptionEnum.NOT_STOCK); + } + + //组装订单 + MallOrder order = assembleOrder(userVo, req,payVo); + orderService.save(order); + + //关联订单商品中间表 + List mallOrderGoods = assembleOrderGoods(shoppingCarList, order.getId()); + orderGoodsService.saveBatch(mallOrderGoods); + + //关联订单地址关联表 + MallOrderAddress orderAddress = orderAddressService.assembleOrderAddress(order.getId(),req.getAddressId()); + orderAddressService.saveOrUpdate(orderAddress); + + //删除购物车 + this.baseMapper.deleteBatchIds(req.getShoppingCardIdList()); + + //记录订单状态 + orderStatusService.recordOrderStatus(order, MallOrderStatusEnums.待付款); + + //支付 + ResponseData responseData = payUtil.pay(userVo, order.getId(), req.getPayType(), payVo.getPrice().subtract(payVo.getMaxGivePrice()), payVo.getMaxGivePrice(), order.getPayOrderNo(), PaySourceEnums.mall_order_pay, WalletDetailEnums.MALL_ORDER_PAY); + + //支付成功/支付金额为0 + if (responseData.getSuccess() || responseData.getCode().equals(210)) { + //余额支付/苹果支付 + if (req.getPayType().equals(PayEnums.balance.getCode()) || req.getPayType().equals(PayEnums.apple.getCode())) { + orderService.after(order); + } + } + + Map map = new HashMap<>(); + map.put("orderId",order.getId()); + responseData.setData(JSONObject.toJSON(map)); + + return responseData; + } + + @Autowired + private MallOrderGoodsService orderGoodsService; + + /** + * 组装订单 + * @param userVo + * @param req + * @return + */ + private MallOrder assembleOrder(UserVo userVo,ShoppingCarCreateOrderReq req, + PayVo payVo){ + + MallOrder order = new MallOrder() + .setOrderNo(orderService.generateOrderNo(1)) + .setUserId(userVo.getUserId()) + .setUserType(userVo.getUserType()) + .setGoodsPrice(payVo.getPrice()) + .setPayType(req.getPayType()) + .setRemark(req.getRemark()) + .setPayOrderNo(orderService.generateOrderNo(2)) + .setPayPrice(payVo.getPrice()) + .setOrderStatus(MallOrderStatusEnums.待付款.getCode()) + .setIntegralPrice(payVo.getIntegral()) + .setGivePrice(payVo.getMaxGivePrice()) + ; + + //售后时间 + SysDictData dictOne = businessUtil.getDict(DictConstant.MallOrderDict.售后天数); + order.setAfterSalesDays(dictOne == null ? 7 : Integer.valueOf(dictOne.getDictValue())); + + return order; + } + + /** + * 订单商品中间表 + * @param shoppingCarListVos + * @param orderId + * @return + */ + private List assembleOrderGoods(List shoppingCarListVos,Long orderId){ + + //订单商品关联集合 + List orderGoodsList = new ArrayList<>(); + + //生成订单商品表 + for (ShoppingCarListVo s : shoppingCarListVos) { + + //订单商品 + MallOrderGoods orderGoods = new MallOrderGoods().setGoodsId(s.getGoodsId()) + .setGoodsName(s.getGoodsName()) + .setOrderId(orderId) + .setGoodsImage(s.getCoverImage()) + .setSpecImage(s.getImage()) + .setUnitPrice(s.getPrice()) + .setUnitIntegral(s.getIntegral()) + .setBuyNum(s.getQuantity()) + .setSpecName(s.getSpecName()) + .setGoodsId(s.getGoodsId()) + .setSpecId(s.getSpecId()) + ; + orderGoodsList.add(orderGoods); + } + + return orderGoodsList; + } + + @Autowired + private MallOrderService orderService; + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallspecifications/controller/MallSpecificationsController.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallspecifications/controller/MallSpecificationsController.java new file mode 100644 index 0000000..3d9748d --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallspecifications/controller/MallSpecificationsController.java @@ -0,0 +1,103 @@ +package com.ruoyi.frequency.mallspecifications.controller; + +import java.util.List; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.frequency.mallspecifications.entity.MallSpecifications; +import com.ruoyi.frequency.mallspecifications.service.MallSpecificationsService; +import com.ruoyi.common.utils.poi.ExcelUtil; +import com.ruoyi.common.core.page.TableDataInfo; + +/** + * 单规格规格Controller + * + * @author liwenlong + * @date 2024-01-25 + */ +@RestController +@RequestMapping("/frequency/mallspecifications") +public class MallSpecificationsController extends BaseController +{ + @Autowired + private MallSpecificationsService mallSpecificationsService; + + /** + * 查询单规格规格列表 + */ + @PreAuthorize("@ss.hasPermi('frequency:mallspecifications:list')") + @PostMapping("/list") + public TableDataInfo list(@RequestBody MallSpecifications mallSpecifications) + { + startPage(); + List list = mallSpecificationsService.selectMallSpecificationsList(mallSpecifications); + return getDataTable(list); + } + + /** + * 导出单规格规格列表 + */ + @PreAuthorize("@ss.hasPermi('frequency:mallspecifications:export')") + @Log(title = "单规格规格", businessType = BusinessType.EXPORT) + @GetMapping("/export") + public AjaxResult export(MallSpecifications mallSpecifications) + { + List list = mallSpecificationsService.selectMallSpecificationsList(mallSpecifications); + ExcelUtil util = new ExcelUtil(MallSpecifications.class); + return util.exportExcel(list, "单规格规格数据"); + } + + /** + * 获取单规格规格详细信息 + */ + @PreAuthorize("@ss.hasPermi('frequency:mallspecifications:query')") + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") Long id) + { + return AjaxResult.success(mallSpecificationsService.selectMallSpecificationsById(id)); + } + + /** + * 新增单规格规格 + */ + @PreAuthorize("@ss.hasPermi('frequency:mallspecifications:add')") + @Log(title = "单规格规格", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody MallSpecifications mallSpecifications) + { + return toAjax(mallSpecificationsService.insertMallSpecifications(mallSpecifications)); + } + + /** + * 修改单规格规格 + */ + @PreAuthorize("@ss.hasPermi('frequency:mallspecifications:edit')") + @Log(title = "单规格规格", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody MallSpecifications mallSpecifications) + { + return toAjax(mallSpecificationsService.updateMallSpecifications(mallSpecifications)); + } + + /** + * 删除单规格规格 + */ + @PreAuthorize("@ss.hasPermi('frequency:mallspecifications:remove')") + @Log(title = "单规格规格", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}/{delFlag}") + public AjaxResult remove(@PathVariable("ids") Long[] ids,@PathVariable("delFlag") Integer delFlag) + { + return toAjax(mallSpecificationsService.deleteMallSpecificationsByIds(ids,delFlag)); + } +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallspecifications/entity/MallSpecifications.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallspecifications/entity/MallSpecifications.java new file mode 100644 index 0000000..7ba4532 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallspecifications/entity/MallSpecifications.java @@ -0,0 +1,63 @@ +package com.ruoyi.frequency.mallspecifications.entity; + +import java.math.BigDecimal; +import lombok.Data; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.experimental.Accessors; +import com.ruoyi.common.annotation.Excel; +import io.swagger.annotations.ApiModelProperty; +import com.baomidou.mybatisplus.annotation.TableField; +import com.ruoyi.vo.UserInfo; +import com.ruoyi.common.core.domain.BaseEntity; + +/** + * 单规格规格对象 mall_specifications + * + * @author liwenlong + * @date 2024-01-25 + */ +@Data +@Accessors(chain = true) +@TableName("mall_specifications") +public class MallSpecifications extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + + @ApiModelProperty("主键id") + private Long id; + + @ApiModelProperty("删除标志;1正常 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("商品id") + @Excel(name = "商品id") + private Long goodsId; + + @ApiModelProperty("规格名称") + @Excel(name = "规格名称") + private String name; + + @ApiModelProperty("销量") + @Excel(name = "销量") + private Integer sales; + + @ApiModelProperty("库存") + @Excel(name = "库存") + private Integer stock; + + @ApiModelProperty("售价") + @Excel(name = "售价") + private BigDecimal price; + + @ApiModelProperty("图片") + @Excel(name = "图片") + private String image; + + @ApiModelProperty("积分") + @Excel(name = "积分") + private BigDecimal integral; + + + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallspecifications/mapper/MallSpecificationsMapper.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallspecifications/mapper/MallSpecificationsMapper.java new file mode 100644 index 0000000..ee4d55e --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallspecifications/mapper/MallSpecificationsMapper.java @@ -0,0 +1,55 @@ +package com.ruoyi.frequency.mallspecifications.mapper; + +import java.util.List; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.ruoyi.frequency.mallspecifications.entity.MallSpecifications; +import org.apache.ibatis.annotations.Param; + +/** + * 单规格规格Mapper接口 + * + * @author liwenlong + * @date 2024-01-25 + */ +public interface MallSpecificationsMapper extends BaseMapper +{ + /** + * 查询单规格规格 + * + * @param id 单规格规格主键 + * @return 单规格规格 + */ + public MallSpecifications selectMallSpecificationsById(Long id); + + /** + * 查询单规格规格列表 + * + * @param mallSpecifications 单规格规格 + * @return 单规格规格集合 + */ + public List selectMallSpecificationsList(MallSpecifications mallSpecifications); + + /** + * 新增单规格规格 + * + * @param mallSpecifications 单规格规格 + * @return 结果 + */ + public int insertMallSpecifications(MallSpecifications mallSpecifications); + + /** + * 修改单规格规格 + * + * @param mallSpecifications 单规格规格 + * @return 结果 + */ + public int updateMallSpecifications(MallSpecifications mallSpecifications); + + Boolean subStock(@Param("list") List specList); + + Boolean addStock(@Param("list") List specList); + + Boolean subSales(@Param("list") List specList); + + Boolean addSales(@Param("list") List specList); +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallspecifications/mapper/mapping/MallSpecificationsMapper.xml b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallspecifications/mapper/mapping/MallSpecificationsMapper.xml new file mode 100644 index 0000000..1fd0267 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallspecifications/mapper/mapping/MallSpecificationsMapper.xml @@ -0,0 +1,159 @@ + + + + + + + + + + + + + + + + + + + + + + + + select + t.id , + t.create_by , + t.create_time , + t.update_by , + t.update_time , + t.del_flag , + t.goods_id , + t.name , + t.sales , + t.stock , + t.price , + t.image , + t.integral + from mall_specifications AS t + + + + + + + + + insert into mall_specifications + + id, + create_by, + create_time, + update_by, + update_time, + del_flag, + goods_id, + name, + sales, + stock, + price, + image, + integral, + + + #{id}, + #{createBy}, + #{createTime}, + #{updateBy}, + #{updateTime}, + #{delFlag}, + #{goodsId}, + #{name}, + #{sales}, + #{stock}, + #{price}, + #{image}, + #{integral}, + + + + + update mall_specifications + + create_by = #{createBy}, + create_time = #{createTime}, + update_by = #{updateBy}, + update_time = #{updateTime}, + del_flag = #{delFlag}, + goods_id = #{goodsId}, + name = #{name}, + sales = #{sales}, + stock = #{stock}, + price = #{price}, + image = #{image}, + integral = #{integral}, + + where id = #{id} + + + + + update mall_specifications + + stock = stock - #{item.stock} + + where id = #{item.id} + AND stock >= #{item.stock} + + + + + + update mall_specifications + + stock = stock + #{item.stock} + + where id = #{item.id} + + + + + + update mall_specifications + + sales = sales - #{item.sales} + + where id = #{item.id} + AND sales >= #{item.sales} + + + + + + update mall_specifications + + sales = sales + #{item.sales} + + where id = #{item.id} + + + + diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallspecifications/model/param/MallSpecificationsParam.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallspecifications/model/param/MallSpecificationsParam.java new file mode 100644 index 0000000..e889ead --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallspecifications/model/param/MallSpecificationsParam.java @@ -0,0 +1,66 @@ +package com.ruoyi.frequency.mallspecifications.model.param; + +import java.math.BigDecimal; +import lombok.Data; +import lombok.experimental.Accessors; +import com.ruoyi.common.annotation.Excel; +import io.swagger.annotations.ApiModelProperty; +import com.ruoyi.common.core.domain.BaseEntity; + +/** + * 单规格规格对象 mall_specifications + * + * @author liwenlong + * @date 2024-01-25 + */ +@Data +@Accessors(chain = true) +public class MallSpecificationsParam extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + @ApiModelProperty("主键id") + private Long id; + + @ApiModelProperty("删除标志;1正常 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("商品id") + @Excel(name = "商品id") + private Long goodsId; + + @ApiModelProperty("规格名称") + @Excel(name = "规格名称") + private String name; + + @ApiModelProperty("销量") + @Excel(name = "销量") + private Long sales; + + @ApiModelProperty("库存") + @Excel(name = "库存") + private Long stock; + + @ApiModelProperty("售价") + @Excel(name = "售价") + private BigDecimal price; + + @ApiModelProperty("图片") + @Excel(name = "图片") + private String image; + + @ApiModelProperty("积分") + @Excel(name = "积分") + private BigDecimal integral; + + + + + + + + + + + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallspecifications/model/result/MallSpecificationsResult.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallspecifications/model/result/MallSpecificationsResult.java new file mode 100644 index 0000000..b9ad41f --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallspecifications/model/result/MallSpecificationsResult.java @@ -0,0 +1,57 @@ +package com.ruoyi.frequency.mallspecifications.model.result; + +import java.math.BigDecimal; +import lombok.Data; +import lombok.experimental.Accessors; +import com.ruoyi.common.annotation.Excel; +import io.swagger.annotations.ApiModelProperty; +import com.ruoyi.common.core.domain.BaseEntity; + +/** + * 单规格规格对象 mall_specifications + * + * @author liwenlong + * @date 2024-01-25 + */ +@Data +@Accessors(chain = true) +public class MallSpecificationsResult extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + @ApiModelProperty("主键id") + private Long id; + + @ApiModelProperty("删除标志;1正常 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("商品id") + @Excel(name = "商品id") + private Long goodsId; + + @ApiModelProperty("规格名称") + @Excel(name = "规格名称") + private String name; + + @ApiModelProperty("销量") + @Excel(name = "销量") + private Long sales; + + @ApiModelProperty("库存") + @Excel(name = "库存") + private Long stock; + + @ApiModelProperty("售价") + @Excel(name = "售价") + private BigDecimal price; + + @ApiModelProperty("图片") + @Excel(name = "图片") + private String image; + + @ApiModelProperty("积分") + @Excel(name = "积分") + private BigDecimal integral; + + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallspecifications/service/MallSpecificationsService.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallspecifications/service/MallSpecificationsService.java new file mode 100644 index 0000000..dd2d283 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallspecifications/service/MallSpecificationsService.java @@ -0,0 +1,55 @@ +package com.ruoyi.frequency.mallspecifications.service; + +import java.util.List; +import com.ruoyi.frequency.mallspecifications.entity.MallSpecifications; +import com.baomidou.mybatisplus.extension.service.IService; + +/** + * 单规格规格Service接口 + * + * @author liwenlong + * @date 2024-01-25 + */ +public interface MallSpecificationsService extends IService +{ + /** + * 查询单规格规格 + * + * @param id 单规格规格主键 + * @return 单规格规格 + */ + public MallSpecifications selectMallSpecificationsById(Long id); + + /** + * 查询单规格规格列表 + * + * @param mallSpecifications 单规格规格 + * @return 单规格规格集合 + */ + public List selectMallSpecificationsList(MallSpecifications mallSpecifications); + + /** + * 新增单规格规格 + * + * @param mallSpecifications 单规格规格 + * @return 结果 + */ + public int insertMallSpecifications(MallSpecifications mallSpecifications); + + /** + * 修改单规格规格 + * + * @param mallSpecifications 单规格规格 + * @return 结果 + */ + public int updateMallSpecifications(MallSpecifications mallSpecifications); + + /** + * 批量删除单规格规格 + * + * @param ids 需要删除的单规格规格主键集合 + * @return 结果 + */ + public int deleteMallSpecificationsByIds(Long[] ids,Integer delFlag); + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallspecifications/service/impl/MallSpecificationsServiceImpl.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallspecifications/service/impl/MallSpecificationsServiceImpl.java new file mode 100644 index 0000000..961003c --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/mallspecifications/service/impl/MallSpecificationsServiceImpl.java @@ -0,0 +1,87 @@ +package com.ruoyi.frequency.mallspecifications.service.impl; + +import java.util.List; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.ruoyi.frequency.mallspecifications.mapper.MallSpecificationsMapper; +import com.ruoyi.frequency.mallspecifications.entity.MallSpecifications; +import com.ruoyi.frequency.mallspecifications.service.MallSpecificationsService; + +/** + * 单规格规格Service业务层处理 + * + * @author liwenlong + * @date 2024-01-25 + */ +@Service +public class MallSpecificationsServiceImpl extends ServiceImpl implements MallSpecificationsService +{ + @Autowired + private MallSpecificationsMapper mallSpecificationsMapper; + + /** + * 查询单规格规格 + * + * @param id 单规格规格主键 + * @return 单规格规格 + */ + @Override + public MallSpecifications selectMallSpecificationsById(Long id) + { + return mallSpecificationsMapper.selectMallSpecificationsById(id); + } + + /** + * 查询单规格规格列表 + * + * @param mallSpecifications 单规格规格 + * @return 单规格规格 + */ + @Override + public List selectMallSpecificationsList(MallSpecifications mallSpecifications) + { + return mallSpecificationsMapper.selectMallSpecificationsList(mallSpecifications); + } + + /** + * 新增单规格规格 + * + * @param mallSpecifications 单规格规格 + * @return 结果 + */ + @Override + public int insertMallSpecifications(MallSpecifications mallSpecifications) + { + mallSpecifications.setCreateData(); + return mallSpecificationsMapper.insert(mallSpecifications); + } + + /** + * 修改单规格规格 + * + * @param mallSpecifications 单规格规格 + * @return 结果 + */ + @Override + public int updateMallSpecifications(MallSpecifications mallSpecifications) + { + mallSpecifications.setUpdateData(); + return mallSpecificationsMapper.updateMallSpecifications(mallSpecifications); + } + + /** + * 批量删除单规格规格 + * + * @param ids 需要删除的单规格规格主键 + * @return 结果 + */ + @Override + public int deleteMallSpecificationsByIds(Long[] ids,Integer delFlag) + { + this.lambdaUpdate().set(MallSpecifications::getDelFlag,delFlag).in(MallSpecifications::getId,ids).update(); + return ids.length; + } + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/news/controller/NewsController.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/news/controller/NewsController.java new file mode 100644 index 0000000..3ca2ae5 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/news/controller/NewsController.java @@ -0,0 +1,85 @@ +package com.ruoyi.frequency.news.controller; + +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.page.TableDataInfo; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.frequency.news.entity.News; +import com.ruoyi.frequency.news.model.result.NewsCount; +import com.ruoyi.frequency.news.service.NewsService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.*; + +/** + * 新闻Controller + * + * @author liwenlong + * @date 2024-03-19 + */ +@RestController +@RequestMapping("/frequency/news") +public class NewsController extends BaseController { + @Autowired + private NewsService newsService; + + /** + * 查询新闻列表 + */ + @PreAuthorize("@ss.hasPermi('frequency:news:list')") + @PostMapping("/list") + public TableDataInfo list(@RequestBody News news) { + return newsService.selectNewsList(news); + } + + + /** + * 统计 + */ + @PostMapping("/statistics") + public AjaxResult statistics(@RequestBody News news) { + NewsCount count = newsService.statistics(news); + return AjaxResult.success(count); + } + + + /** + * 获取新闻详细信息 + */ + @PreAuthorize("@ss.hasPermi('frequency:news:query')") + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") Long id) { + return AjaxResult.success(newsService.selectNewsById(id)); + } + + /** + * 新增新闻 + */ + @PreAuthorize("@ss.hasPermi('frequency:news:add')") + @Log(title = "新闻", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody News news) { + return toAjax(newsService.insertNews(news)); + } + + /** + * 修改新闻 + */ + @PreAuthorize("@ss.hasPermi('frequency:news:edit')") + @Log(title = "新闻", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody News news) { + return toAjax(newsService.updateNews(news)); + } + + /** + * 删除新闻 + */ + @PreAuthorize("@ss.hasPermi('frequency:news:remove')") + @Log(title = "新闻", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}/{delFlag}") + public AjaxResult remove(@PathVariable("ids") Long[] ids, @PathVariable("delFlag") Integer delFlag) { + return toAjax(newsService.deleteNewsByIds(ids, delFlag)); + } +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/news/entity/News.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/news/entity/News.java new file mode 100644 index 0000000..d76b85e --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/news/entity/News.java @@ -0,0 +1,99 @@ +package com.ruoyi.frequency.news.entity; + +import lombok.Data; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.experimental.Accessors; +import com.ruoyi.common.annotation.Excel; +import io.swagger.annotations.ApiModelProperty; +import com.baomidou.mybatisplus.annotation.TableField; +import com.ruoyi.vo.UserInfo; +import com.ruoyi.common.core.domain.BaseEntity; + +import java.util.Date; +import java.util.List; + +/** + * 新闻对象 t_news + * + * @author liwenlong + * @date 2024-03-19 + */ +@Data +@Accessors(chain = true) +@TableName("t_news") +public class News extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + + @ApiModelProperty("租户号") + private Long id; + + @ApiModelProperty("删除标志;1 正常 2 删除 3 禁用") + private Long delFlag; + + @ApiModelProperty("标题") + @Excel(name = "标题") + private String title; + + @ApiModelProperty("图片") + @Excel(name = "图片") + private String image; + + + @ApiModelProperty("内容(富文本)") + private String content; + + @ApiModelProperty("父id;上级id") + @Excel(name = "父id;上级id") + private Long pid; + + @ApiModelProperty("排序") + @Excel(name = "排序") + private Integer sort; + + @ApiModelProperty("点赞数") + @Excel(name = "点赞数") + private Integer likeNum; + + @ApiModelProperty("评论数") + @Excel(name = "评论数") + private Integer commentNum; + + @ApiModelProperty("收藏数") + @Excel(name = "收藏数") + private Integer collectNum; + + @ApiModelProperty("浏览数") + @Excel(name = "浏览数") + private Integer browseNum; + + @ApiModelProperty("精彩评论id") + @Excel(name = "精彩评论id") + private Long commentId; + + @ApiModelProperty(value = "是否点赞 1没有 2点赞") + @TableField(exist = false) + private Integer isLike; + + @ApiModelProperty(value = "是否收藏 1没有 2收藏") + @TableField(exist = false) + private Integer isCollect; + + @ApiModelProperty(value = "是否是自己 1不是 2是") + @TableField(exist = false) + private Integer isSelf; + + @ApiModelProperty("新闻子集") + @TableField(exist = false) + private List childList; + + + @ApiModelProperty("开始时间") + @TableField(exist = false) + private Date beginTime; + + @ApiModelProperty("结束时间") + @TableField(exist = false) + private Date endTime; +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/news/mapper/NewsMapper.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/news/mapper/NewsMapper.java new file mode 100644 index 0000000..192abc2 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/news/mapper/NewsMapper.java @@ -0,0 +1,57 @@ +package com.ruoyi.frequency.news.mapper; + +import java.util.List; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.ruoyi.controller.req.NewsPageReq; +import com.ruoyi.frequency.news.entity.News; +import com.ruoyi.frequency.news.model.result.NewsCount; +import com.ruoyi.vo.UserVo; +import org.apache.ibatis.annotations.Param; + +/** + * 新闻Mapper接口 + * + * @author liwenlong + * @date 2024-03-19 + */ +public interface NewsMapper extends BaseMapper +{ + /** + * 查询新闻 + * + * @param id 新闻主键 + * @return 新闻 + */ + public News selectNewsById(Long id); + + /** + * 查询新闻列表 + * + * @param news 新闻 + * @return 新闻集合 + */ + public List selectNewsList(News news); + + /** + * 新增新闻 + * + * @param news 新闻 + * @return 结果 + */ + public int insertNews(News news); + + /** + * 修改新闻 + * + * @param news 新闻 + * @return 结果 + */ + public int updateNews(News news); + + Page newsPage(@Param("page") Page objectPage, @Param("req") NewsPageReq req,@Param("userVo") UserVo userVo); + + News newsDetail(@Param("id") Long id,@Param("userVo") UserVo userVo); + + NewsCount statistics(@Param("list") List newsIdList); +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/news/mapper/mapping/NewsMapper.xml b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/news/mapper/mapping/NewsMapper.xml new file mode 100644 index 0000000..b8dfd1a --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/news/mapper/mapping/NewsMapper.xml @@ -0,0 +1,203 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + select + t.id , + t.create_by , + t.create_time , + t.update_by , + t.update_time , + t.del_flag , + t.title , + t.image , + t.pid , + t.sort , + t.content, + t.like_num , + t.comment_num , + t.collect_num , + t.browse_num , + t.comment_id + from t_news AS t + + + + + + + + + insert into t_news + + id, + create_by, + create_time, + update_by, + update_time, + del_flag, + title, + image, + pid, + sort, + content, + like_num, + comment_num, + collect_num, + browse_num, + comment_id, + + + #{id}, + #{createBy}, + #{createTime}, + #{updateBy}, + #{updateTime}, + #{delFlag}, + #{title}, + #{image}, + #{pid}, + #{sort}, + #{content}, + #{likeNum}, + #{commentNum}, + #{collectNum}, + #{browseNum}, + #{commentId}, + + + + + update t_news + + create_by = #{createBy}, + create_time = #{createTime}, + update_by = #{updateBy}, + update_time = #{updateTime}, + del_flag = #{delFlag}, + title = #{title}, + image = #{image}, + pid = #{pid}, + sort = #{sort}, + content = #{content}, + like_num = like_num + #{likeNum}, + comment_num = comment_num + #{commentNum}, + collect_num = collect_num + #{collectNum}, + browse_num = browse_num + #{browseNum}, + comment_id = #{commentId}, + + where id = #{id} + and like_num + #{likeNum} >= 0 + and comment_num + #{commentNum} >= 0 + and collect_num + #{collectNum} >= 0 + and browse_num + #{browseNum} >= 0 + + + + + + + \ No newline at end of file diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/news/model/param/NewsParam.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/news/model/param/NewsParam.java new file mode 100644 index 0000000..65c58ff --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/news/model/param/NewsParam.java @@ -0,0 +1,55 @@ +package com.ruoyi.frequency.news.entity.model.param; + +import lombok.Data; +import lombok.experimental.Accessors; +import com.ruoyi.common.annotation.Excel; +import io.swagger.annotations.ApiModelProperty; +import com.ruoyi.common.core.domain.BaseEntity; + +/** + * 新闻对象 t_news + * + * @author liwenlong + * @date 2024-03-19 + */ +@Data +@Accessors(chain = true) +public class NewsParam extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + @ApiModelProperty("租户号") + private Long id; + + @ApiModelProperty("删除标志;1 正常 2 删除 3 禁用") + private Long delFlag; + + @ApiModelProperty("标题") + @Excel(name = "标题") + private String title; + + @ApiModelProperty("图片") + @Excel(name = "图片") + private String image; + + @ApiModelProperty("父id;上级id") + @Excel(name = "父id;上级id") + private Long pid; + + @ApiModelProperty("排序") + @Excel(name = "排序") + private Long sort; + + @ApiModelProperty("新闻草稿ID") + @Excel(name = "新闻草稿ID") + private Long newsDraftId; + + + + + + + + + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/news/model/result/NewsCount.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/news/model/result/NewsCount.java new file mode 100644 index 0000000..31b8c0c --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/news/model/result/NewsCount.java @@ -0,0 +1,22 @@ +package com.ruoyi.frequency.news.model.result; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +@Data +public class NewsCount { + @ApiModelProperty("数量") + private Integer num; + + @ApiModelProperty("浏览量") + private Integer browseNum; + + @ApiModelProperty("点赞量") + private Integer likeNum; + + @ApiModelProperty("评论量") + private Integer commentNum; + + @ApiModelProperty("收藏量") + private Integer collectNum; +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/news/model/result/NewsResult.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/news/model/result/NewsResult.java new file mode 100644 index 0000000..d30729d --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/news/model/result/NewsResult.java @@ -0,0 +1,48 @@ +package com.ruoyi.frequency.news.entity.model.result; + +import lombok.Data; +import lombok.experimental.Accessors; +import com.ruoyi.common.annotation.Excel; +import io.swagger.annotations.ApiModelProperty; +import com.ruoyi.common.core.domain.BaseEntity; + +/** + * 新闻对象 t_news + * + * @author liwenlong + * @date 2024-03-19 + */ +@Data +@Accessors(chain = true) +public class NewsResult extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + @ApiModelProperty("租户号") + private Long id; + + @ApiModelProperty("删除标志;1 正常 2 删除 3 禁用") + private Long delFlag; + + @ApiModelProperty("标题") + @Excel(name = "标题") + private String title; + + @ApiModelProperty("图片") + @Excel(name = "图片") + private String image; + + @ApiModelProperty("父id;上级id") + @Excel(name = "父id;上级id") + private Long pid; + + @ApiModelProperty("排序") + @Excel(name = "排序") + private Long sort; + + @ApiModelProperty("新闻草稿ID") + @Excel(name = "新闻草稿ID") + private Long newsDraftId; + + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/news/service/NewsService.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/news/service/NewsService.java new file mode 100644 index 0000000..68c7edf --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/news/service/NewsService.java @@ -0,0 +1,84 @@ +package com.ruoyi.frequency.news.service; + +import java.util.List; + +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.ruoyi.common.core.page.TableDataInfo; +import com.ruoyi.common.page.PageResult; +import com.ruoyi.controller.req.NewsPageReq; +import com.ruoyi.controller.resp.NewsDetailResp; +import com.ruoyi.controller.resp.NewsPageResp; +import com.ruoyi.frequency.news.entity.News; +import com.baomidou.mybatisplus.extension.service.IService; +import com.ruoyi.frequency.news.model.result.NewsCount; +import com.ruoyi.response.ResponseData; +import com.ruoyi.vo.UserVo; + +/** + * 新闻Service接口 + * + * @author liwenlong + * @date 2024-03-19 + */ +public interface NewsService extends IService +{ + /** + * 查询新闻 + * + * @param id 新闻主键 + * @return 新闻 + */ + public News selectNewsById(Long id); + + /** + * 查询新闻列表 + * + * @param news 新闻 + * @return 新闻集合 + */ + public TableDataInfo selectNewsList(News news); + + /** + * 新增新闻 + * + * @param news 新闻 + * @return 结果 + */ + public int insertNews(News news); + + /** + * 修改新闻 + * + * @param news 新闻 + * @return 结果 + */ + public int updateNews(News news); + + /** + * 批量删除新闻 + * + * @param ids 需要删除的新闻主键集合 + * @return 结果 + */ + public int deleteNewsByIds(Long[] ids,Integer delFlag); + + /** + * 新闻列表 + * @param req + * @param userVo + * @return + */ + ResponseData>> newsPage(NewsPageReq req, UserVo userVo); + + /** + * 新闻详情 + * @param id + * @param userVo + * @return + */ + ResponseData newsDetail(Long id,Integer isAddBrowseNum, UserVo userVo); + + News newsInfo(Long id); + + NewsCount statistics(News news); +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/news/service/impl/NewsServiceImpl.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/news/service/impl/NewsServiceImpl.java new file mode 100644 index 0000000..9cff0aa --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/news/service/impl/NewsServiceImpl.java @@ -0,0 +1,343 @@ +package com.ruoyi.frequency.news.service.impl; + +import cn.hutool.core.collection.CollectionUtil; +import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.StrUtil; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.ruoyi.code.PublicCommon; +import com.ruoyi.common.constant.HttpStatus; +import com.ruoyi.common.core.domain.BaseEntity; +import com.ruoyi.common.core.page.TableDataInfo; +import com.ruoyi.common.page.ManualPagination; +import com.ruoyi.common.page.PageResult; +import com.ruoyi.controller.req.NewsPageReq; +import com.ruoyi.frequency.news.entity.News; +import com.ruoyi.frequency.news.mapper.NewsMapper; +import com.ruoyi.frequency.news.model.result.NewsCount; +import com.ruoyi.frequency.news.service.NewsService; +import com.ruoyi.post.frequency.post.mapper.PostMapper; +import com.ruoyi.response.ResponseData; +import com.ruoyi.utils.SnowIdUtils; +import com.ruoyi.vo.UserVo; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.*; +import java.util.stream.Collectors; + +/** + * 新闻Service业务层处理 + * + * @author liwenlong + * @date 2024-03-19 + */ +@Service +public class NewsServiceImpl extends ServiceImpl implements NewsService { + @Autowired + private NewsMapper newsMapper; + + /** + * 查询新闻 + * + * @param id 新闻主键 + * @return 新闻 + */ + @Override + public News selectNewsById(Long id) { + + News news = newsMapper.selectNewsById(id); + + if (news != null) { + List list = this.list(new QueryWrapper().lambda().eq(News::getDelFlag, PublicCommon.启用).ne(News::getPid, 0L) + .eq(News::getPid, news.getId())); + news.setChildList(list); + } + + return news; + } + + /** + * 查询新闻列表 + * + * @param news 新闻 + * @return 新闻 + */ + @Override + public TableDataInfo selectNewsList(News news) { + List newsList = newsList(news); + + TableDataInfo rspData = new TableDataInfo(); + rspData.setCode(HttpStatus.SUCCESS); + rspData.setMsg("查询成功"); + rspData.setRows(ManualPagination.getPage(newsList)); + rspData.setTotal(newsList.size()); + return rspData; + } + + private List newsList(News news) { + List newsList = newsMapper.selectNewsList(news); + if (newsList.size() > 0) { + //新闻ids + List newsIds = newsList.stream().map(News::getId).collect(Collectors.toList()); + + List list = this.list(new QueryWrapper().lambda().eq(News::getDelFlag, PublicCommon.启用).ne(News::getPid, 0L).in(News::getPid, newsIds)); + + Map> map = list.stream().collect(Collectors.groupingBy(News::getPid)); + + newsList.stream().forEach(s -> { + s.setChildList(map.get(s.getId())); + }); + } + //筛选 + Iterator iterator = newsList.iterator(); + while (iterator.hasNext()) { + News next = iterator.next(); + List childList = next.getChildList(); + if (childList != null && childList.size() > 0) { + News child = childList.get(0); + if (news != null) { + if (StrUtil.isNotBlank(news.getTitle()) && !child.getTitle().contains(news.getTitle())) { + iterator.remove(); + } + if (news.getBeginTime() != null && child.getCreateTime().getTime() < news.getBeginTime().getTime()) { + iterator.remove(); + } + if (news.getEndTime() != null && child.getCreateTime().getTime() > news.getEndTime().getTime()) { + iterator.remove(); + } + } + } + } + + newsList.stream().forEach(x -> { + List childList = x.getChildList(); + if (CollectionUtil.isNotEmpty(childList)) { + News news1 = childList.get(0); + x.setId(news1.getId()); + x.setDelFlag(news1.getDelFlag()); + x.setImage(news1.getImage()); + x.setPid(news1.getPid()); + x.setSort(news1.getSort()); + x.setTitle(news1.getTitle()); + x.setContent(news1.getContent()); + x.setLikeNum(news1.getLikeNum()); + x.setCollectNum(news1.getCollectNum()); + x.setCommentNum(news1.getCommentNum()); + x.setBrowseNum(news1.getBrowseNum()); + x.setCommentId(news1.getCommentId()); + x.setCreateTime(news1.getCreateTime()); + x.setCreateBy(news1.getCreateBy()); + x.setUpdateTime(news1.getUpdateTime()); + x.setUpdateBy(news1.getUpdateBy()); + + List childList2 = childList.subList(1, childList.size()); + x.setChildList(childList2); + } + }); + + return newsList; + } + + + @Override + public News newsInfo(Long id) { + News news = newsMapper.selectById(id); + if (news != null) { + //新闻ids + List newsIds = new ArrayList<>(); + newsIds.add(id); + + List list = this.list(new QueryWrapper().lambda().eq(News::getDelFlag, PublicCommon.启用).ne(News::getPid, 0L).in(News::getPid, newsIds)); + + Map> map = list.stream().collect(Collectors.groupingBy(News::getPid)); + + news.setChildList(map.get(id)); + } + + List childList = news.getChildList(); + if (CollectionUtil.isNotEmpty(childList)) { + News news1 = childList.get(0); + news.setId(news1.getId()); + news.setDelFlag(news1.getDelFlag()); + news.setImage(news1.getImage()); + news.setPid(news1.getPid()); + news.setSort(news1.getSort()); + news.setTitle(news1.getTitle()); + news.setContent(news1.getContent()); + news.setLikeNum(news1.getLikeNum()); + news.setCollectNum(news1.getCollectNum()); + news.setCommentNum(news1.getCommentNum()); + news.setBrowseNum(news1.getBrowseNum()); + news.setCommentId(news1.getCommentId()); + news.setCreateTime(news1.getCreateTime()); + news.setCreateBy(news1.getCreateBy()); + news.setUpdateTime(news1.getUpdateTime()); + news.setUpdateBy(news1.getUpdateBy()); + + List childList2 = childList.subList(1, childList.size()); + news.setChildList(childList2); + } + return news; + } + + @Override + public NewsCount statistics(News news) { + List newsList = newsList(news); + List newsIdList = newsList.stream().map(x -> x.getId()).collect(Collectors.toList()); + newsIdList.add(-1L); + + Integer likeNum = 0; + Integer collectNum = 0; + Integer browseNum = 0; + Integer commentNum = 0; + for (News cur : newsList) { + likeNum = likeNum + cur.getLikeNum(); + collectNum = collectNum + cur.getCollectNum(); + browseNum = browseNum + cur.getBrowseNum(); + commentNum = commentNum + cur.getCommentNum(); + List childList = cur.getChildList(); + if (CollectionUtil.isNotEmpty(childList)) { + for (News news1 : childList) { + likeNum = likeNum + news1.getLikeNum(); + collectNum = collectNum + news1.getCollectNum(); + browseNum = browseNum + news1.getBrowseNum(); + commentNum = commentNum + news1.getCommentNum(); + } + } + } + + NewsCount count = newsMapper.statistics(newsIdList); + count.setBrowseNum(browseNum); + count.setCollectNum(collectNum); + count.setCommentNum(commentNum); + count.setLikeNum(likeNum); + return count; + } + + /** + * 新增新闻 + * + * @param news 新闻 + * @return 结果 + */ + @Override + public int insertNews(News news) { + if (news.getChildList() != null && news.getChildList().size() > 0) { + List childList = news.getChildList(); + news.setPid(0L); + news.setCreateData(); + newsMapper.insert(news); + + childList.stream().forEach(s -> { + s.setCreateData(); + s.setPid(news.getId()); + }); + + this.saveBatch(childList); + } + + return 1; + } + + /** + * 修改新闻 + * + * @param news 新闻 + * @return 结果 + */ + @Override + public int updateNews(News news) { + news.setUpdateData(); + int i = newsMapper.updateNews(news); + + this.remove(new QueryWrapper().lambda().eq(News::getPid, news.getId())); + + if (i > 0 && news.getChildList() != null && news.getChildList().size() > 0) { + List childList = news.getChildList(); + + childList.stream().forEach(s -> { + s.setCreateData(); + s.setPid(news.getId()); + }); + + this.saveBatch(childList); + } + + return 1; + } + + /** + * 批量删除新闻 + * + * @param ids 需要删除的新闻主键 + * @return 结果 + */ + @Override + public int deleteNewsByIds(Long[] ids, Integer delFlag) { + this.lambdaUpdate().set(News::getDelFlag, delFlag).in(News::getId, ids).update(); + + News news = getById(ids[0]); + if (news != null) { + //删除的id同级如果没有启用的话,就把上级也删掉 + Integer count = baseMapper.selectCount(new QueryWrapper().lambda().eq(News::getPid, news.getPid()) + .eq(News::getDelFlag, PublicCommon.启用)); + if (count == 0) { + this.lambdaUpdate().set(News::getDelFlag, delFlag).in(News::getId, news.getPid()).update(); + } + + } + + return ids.length; + } + + @Override + public ResponseData>> newsPage(NewsPageReq req, UserVo userVo) { + + Page page = this.baseMapper.newsPage(new Page<>(req.getPageNo(), req.getPageSize()), req, userVo); + + //查询子集 + if (page.getRecords().size() > 0) { + List newsIds = page.getRecords().stream().map(News::getId).collect(Collectors.toList()); + List list = this.list(new QueryWrapper().lambda() + .eq(News::getDelFlag, PublicCommon.启用) + .in(News::getPid, newsIds) + .orderByAsc(News::getSort, BaseEntity::getCreateTime) + ); + //进行分组 + Map> map = list.stream().collect(Collectors.groupingBy(News::getPid)); + + page.getRecords().stream().forEach(s -> { + s.setChildList(map.get(s.getId())); + }); + } + + return ResponseData.success(new PageResult<>(page)); + } + + @Autowired + private PostMapper postMapper; + + @Override + public ResponseData newsDetail(Long id, Integer isAddBrowseNum, UserVo userVo) { + News news = this.baseMapper.newsDetail(id, userVo); + + //查询子集 + if (news != null) { + + //是否增加浏览数 1不增加 2 加 + if (ObjectUtil.equal(2, isAddBrowseNum)) { + //增加浏览数 + this.baseMapper.updateNews(new News().setId(id).setBrowseNum(1)); + + //type: 类型 1作品 2 帖子 3投票 4新闻 5活动 + postMapper.updateBrowseRecord(SnowIdUtils.uniqueLong(), 4, new Date(), id, userVo); + } + } + + return ResponseData.success(news); + } + + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/order/controller/OrderController.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/order/controller/OrderController.java new file mode 100644 index 0000000..d987de2 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/order/controller/OrderController.java @@ -0,0 +1,76 @@ +package com.ruoyi.frequency.order.controller; + +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.page.TableDataInfo; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.common.utils.poi.ExcelUtil; +import com.ruoyi.frequency.order.entity.Order; +import com.ruoyi.frequency.order.model.result.OrderCount; +import com.ruoyi.frequency.order.service.OrderService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +/** + * 订单主Controller + * + * @author zj + * @date 2023-10-13 + */ +@RestController +@RequestMapping("/frequency/order") +public class OrderController extends BaseController +{ + @Autowired + private OrderService orderService; + + /** + * 查询订单主列表 + */ + @PreAuthorize("@ss.hasPermi('frequency:order:list')") + @PostMapping("/list") + public TableDataInfo list(@RequestBody Order order) + { + startPage(); + List list = orderService.selectOrderList(order); + return getDataTable(list); + } + + /** + * 统计 + */ + @PostMapping("/statistics") + public AjaxResult statistics(@RequestBody Order order) + { + OrderCount count = orderService.statistics(order); + return AjaxResult.success(count); + } + + /** + * 导出订单主列表 + */ + @PreAuthorize("@ss.hasPermi('frequency:order:export')") + @Log(title = "订单主", businessType = BusinessType.EXPORT) + @GetMapping("/export") + public AjaxResult export(Order order) + { + List list = orderService.selectOrderList(order); + ExcelUtil util = new ExcelUtil(Order.class); + return util.exportExcel(list, "订单主数据"); + } + + /** + * 获取订单主详细信息 + */ + @PreAuthorize("@ss.hasPermi('frequency:order:query')") + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") Long id) + { + return AjaxResult.success(orderService.selectOrderById(id)); + } + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/order/entity/Order.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/order/entity/Order.java new file mode 100644 index 0000000..95f2534 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/order/entity/Order.java @@ -0,0 +1,277 @@ +package com.ruoyi.frequency.order.entity; + +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableName; +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import com.ruoyi.controller.resp.AppealDetailResp; +import com.ruoyi.frequency.orderevaluate.entity.OrderEvaluate; +import com.ruoyi.frequency.orderpanorama.entity.OrderPanorama; +import com.ruoyi.vo.UserInfo; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; + +import java.math.BigDecimal; +import java.util.Date; +import java.util.List; + +/** + * 订单主对象 t_order + * + * @author zj + * @date 2023-10-13 + */ +@Data +@Accessors(chain = true) +@TableName("t_order") +public class Order extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + + @ApiModelProperty("租户号") + private Long id; + + @ApiModelProperty("删除标志;1 正常 2 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("订单标题") + @Excel(name = "订单标题") + private String title; + + @ApiModelProperty("素材") + @Excel(name = "素材") + private String sourceMaterial; + + @ApiModelProperty("原价") + @Excel(name = "原价") + private BigDecimal originAmount; + + @ApiModelProperty("订单金额") + @Excel(name = "订单金额") + private BigDecimal amount; + + @ApiModelProperty("改价后金额(客户确认后,改价后金额同步到amount中)") + @Excel(name = "改价后金额(客户确认后,改价后金额同步到amount中)") + private BigDecimal changeAmount; + + @ApiModelProperty("提出改价的用户身份 1 设计师 2 表现师") + @Excel(name = "提出改价的用户身份 1 设计师 2 表现师") + private Integer changeUserType; + + @ApiModelProperty("改价状态 1 待确认 2 已确认") + @Excel(name = "改价状态 1 待确认 2 已确认") + private Integer changeStatus; + + @ApiModelProperty("价格调整备注") + @Excel(name = "价格调整备注") + private String changeRemark; + + @ApiModelProperty("交付时间") + @Excel(name = "交付时间", width = 30, dateFormat = "yyyy-MM-dd") + private Date confirmDate; + + @ApiModelProperty("设计师id") + @Excel(name = "设计师id") + private Long customerId; + + @ApiModelProperty("表现师id") + @Excel(name = "表现师id") + private Long storeId; + + @ApiModelProperty("销售从中拿到的佣金") + @Excel(name = "销售从中拿到的佣金") + private BigDecimal saleAmount; + + @ApiModelProperty("销售id") + @Excel(name = "销售id") + private Long saleId; + + @ApiModelProperty("内容") + @Excel(name = "内容") + private String content; + + @ApiModelProperty("订单状态;-1 已取消 1待确认 2进行中 3待收图 4待评价 5已评价 ") + @Excel(name = "订单状态;-1 已取消 1待确认 2进行中 3待收图 4待评价 5已评价 ") + private Integer status; + + @ApiModelProperty("申诉状态;1无申诉 2申诉中 3申诉完成") + @Excel(name = "申诉状态;1无申诉 2申诉中 3申诉完成") + private Integer appealStatus; + + @ApiModelProperty("申请用户类型 1 设计师 2 表现师") + @Excel(name = "申请用户类型 1 设计师 2 表现师") + private Integer appealUserType; + + @ApiModelProperty("订单来源 1 设计师自己下单 2 表现师帮设计师下单") + @Excel(name = "订单来源 1 设计师自己下单 2 表现师帮设计师下单") + private Integer sourceUserType; + + /** 封面图 */ + @Excel(name = "封面图") + private String coverImage; + @ApiModelProperty("作品图片") + @Excel(name = "作品图片") + private String images; + + @ApiModelProperty("首款") + @Excel(name = "首款") + private BigDecimal firstPrice; + + @ApiModelProperty("首款支付状态 1 未支付 2 已支付") + @Excel(name = "首款支付状态 1 未支付 2 已支付") + private Integer firstStatus; + + @ApiModelProperty("首款支付方式 1app支付宝 2 h5支付宝 3 app微信 4 h5微信 5 小程序 6 苹果支付 7 余额") + @Excel(name = "首款支付方式 1app支付宝 2 h5支付宝 3 app微信 4 h5微信 5 小程序 6 苹果支付 7 余额") + private Integer firstPayType; + + + @ApiModelProperty("尾款支付状态 1 未支付 2 已支付") + @Excel(name = "尾款支付状态 1 未支付 2 已支付") + private Integer secondStatus; + + @ApiModelProperty("尾款支付方式 1app支付宝 2 h5支付宝 3 app微信 4 h5微信 5 小程序 6 苹果支付 7 余额") + @Excel(name = "尾款支付方式 1app支付宝 2 h5支付宝 3 app微信 4 h5微信 5 小程序 6 苹果支付 7 余额") + private Integer secondPayType; + + @ApiModelProperty("订单号") + @Excel(name = "订单号") + private String orderNo; + + @ApiModelProperty("支付宝支付返回的订单号") + @Excel(name = "支付宝支付返回的订单号") + private String aliBusinessId; + + @ApiModelProperty("首款支付时间") + @Excel(name = "首款支付时间", width = 30, dateFormat = "yyyy-MM-dd") + private Date firstPayTime; + + @ApiModelProperty("尾款支付时间") + @Excel(name = "尾款支付时间", width = 30, dateFormat = "yyyy-MM-dd") + private Date secondPayTime; + + @ApiModelProperty("作品类型ID") + private Long worksTypeId; + + + @ApiModelProperty("首款支付单号") + private String firstPayOrderNo; + + @ApiModelProperty("尾款支付单号") + private String secondPayOrderNo; + + @ApiModelProperty("设计师是否评价 1 没有 2 评价") + private Integer isCustomerEvaluate; + + + @ApiModelProperty("表现师是否评价1 没有 2 评价") + private Integer isStoreEvaluate; + + @ApiModelProperty("图纸张数") + private Integer drawingNum; + + @ApiModelProperty("是否同步到作品库 1不同步 2同步") + private Integer isAgree; + + + @ApiModelProperty("尾款支付宝支付返回的订单号") + private String secondAliBusinessId; + + + + @ApiModelProperty("原始对图时间") + @Excel(name = "原始对图时间", width = 30, dateFormat = "yyyy-MM-dd") + private Date originDeliverTime; + + @ApiModelProperty("对图时间") + @Excel(name = "对图时间", width = 30, dateFormat = "yyyy-MM-dd") + private Date deliverTime; + + @ApiModelProperty("延期后时间 表现师确认后 更新对图时间") + @Excel(name = "延期后时间 表现师确认后 更新对图时间", width = 30, dateFormat = "yyyy-MM-dd") + private Date extensionDeliverTime; + + @ApiModelProperty("延期用户身份 1 设计师 2 表现师") + @Excel(name = "延期用户身份 1 设计师 2 表现师") + private Integer extensionUserType; + + @ApiModelProperty("延期状态 1 待确认 2 已确认") + @Excel(name = "延期状态 1 待确认 2 已确认") + private Integer extensionStatus; + + @ApiModelProperty("延期备注") + @Excel(name = "延期备注") + private String extensionRemark; + + + @ApiModelProperty("是否到交付时间发送消息 1没有 2 发送") + private Integer isPushMessage; + + + @ApiModelProperty("是否高端认证:1:普通技术 2高端技术") + private Integer ifHighend; + + @ApiModelProperty("首款赠送支付金额") + private BigDecimal firstGivePrice; + + @ApiModelProperty("尾款赠送支付金额") + private BigDecimal secondGivePrice; + + @ApiModelProperty("首款三方支付金额") + private BigDecimal firstTripartitePrice; + + @ApiModelProperty("尾款三方支付金额") + private BigDecimal secondTripartitePrice; + + + @ApiModelProperty("作品类型名称") + @TableField(exist = false) + private String worksTypeName; + + + @ApiModelProperty("开始时间") + @TableField(exist = false) + private Date beginTime; + + @ApiModelProperty("结束时间") + @TableField(exist = false) + private Date endTime; + + @ApiModelProperty("开始时间") + @TableField(exist = false) + private Date confirmBeginTime; + + @ApiModelProperty("结束时间") + @TableField(exist = false) + private Date confirmEndTime; + + @ApiModelProperty("设计师信息") + @TableField(exist = false) + private UserInfo customerInfo; + + @ApiModelProperty("表现师信息") + @TableField(exist = false) + private UserInfo storeInfo; + + @ApiModelProperty("3D图") + @TableField(exist = false) + private List panoramaList; + + @ApiModelProperty("申诉详情") + @TableField(exist = false) + private AppealDetailResp appeal; + + @ApiModelProperty("申诉id") + @TableField(exist = false) + private Long appealId; + + @ApiModelProperty("设计师评价") + @TableField(exist = false) + private OrderEvaluate customerEvaluate; + + @ApiModelProperty("表现师评价") + @TableField(exist = false) + private OrderEvaluate storeEvaluate; +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/order/mapper/OrderMapper.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/order/mapper/OrderMapper.java new file mode 100644 index 0000000..5de0f70 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/order/mapper/OrderMapper.java @@ -0,0 +1,85 @@ +package com.ruoyi.frequency.order.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.ruoyi.controller.req.OrderPageReq; +import com.ruoyi.controller.resp.MallOrderDetailResp; +import com.ruoyi.controller.resp.OrderDetailResp; +import com.ruoyi.controller.resp.OrderPageResp; +import com.ruoyi.frequency.order.entity.Order; +import com.ruoyi.frequency.order.model.result.OrderCount; +import com.ruoyi.vo.UserVo; +import org.apache.ibatis.annotations.Param; + +import java.math.BigDecimal; +import java.util.Date; +import java.util.List; + +/** + * 订单主Mapper接口 + * + * @author zj + * @date 2023-10-13 + */ +public interface OrderMapper extends BaseMapper +{ + /** + * 查询订单主 + * + * @param id 订单主主键 + * @return 订单主 + */ + public Order selectOrderById(Long id); + + /** + * 查询订单主列表 + * + * @param order 订单主 + * @return 订单主集合 + */ + public List selectOrderList(Order order); + + /** + * 新增订单主 + * + * @param order 订单主 + * @return 结果 + */ + public int insertOrder(Order order); + + /** + * 修改订单主 + * + * @param order 订单主 + * @return 结果 + */ + public int updateOrder(Order order); + + /** + * 删除订单主 + * + * @param id 订单主主键 + * @return 结果 + */ + public int deleteOrderById(Long id); + + /** + * 批量删除订单主 + * + * @param ids 需要删除的数据主键集合 + * @return 结果 + */ + public int deleteOrderByIds(Long[] ids); + + Page orderPage(@Param("page") Page objectPage, @Param("req") OrderPageReq req, @Param("userVo") UserVo userVo); + + Integer orderCount(@Param("userVo") UserVo userVo,@Param("req")OrderPageReq orderPageReq); + + OrderDetailResp orderDetail(@Param("id") Long id, @Param("userVo") UserVo userVo); + + List orderList(@Param("list") List orderIds, @Param("userVo") UserVo userVo); + + BigDecimal selectMonthBeforeAmount(@Param("beginOfMonth") Date beginOfMonth, @Param("userVo") UserVo userVo); + + OrderCount statistics(@Param("list") List orderIds); +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/order/mapper/mapping/OrderMapper.xml b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/order/mapper/mapping/OrderMapper.xml new file mode 100644 index 0000000..ff775b4 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/order/mapper/mapping/OrderMapper.xml @@ -0,0 +1,749 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + SELECT + t.id, + t.create_time, + t.del_flag, + t.title, + t.source_material, + t.origin_amount, + t.amount, + t.change_amount, + t.change_user_type, + t.change_status, + t.change_remark, + t.confirm_date, + t.customer_id, + t.store_id, + t.sale_amount, + t.sale_id, + t.content, + case when t.is_customer_evaluate = 2 and t.is_store_evaluate = 2 then 5 + else t.`status` end status, + t.appeal_status, + t.appeal_user_type, + t.source_user_type, + t.cover_image, + t.images, + t.first_price, + t.first_status, + t.first_pay_type, + t.second_pay_type, + t.order_no, + t.ali_business_id, + t.first_pay_time, + t.second_pay_time, + t.works_type_id, + t.first_pay_order_no, + t.second_pay_order_no, + t.is_customer_evaluate, + t.is_store_evaluate, + t.second_status, + t.origin_deliver_time, + t.deliver_time, + t.extension_deliver_time, + t.extension_user_type, + t.extension_status, + t.extension_remark, + t.if_highend, + CONCAT(t3.`name`, '-', t2.`name` ) worksTypeName, + (select a.id from t_appeal a where a.order_id = t.id and a.del_flag = 1 order by a.create_time desc limit 1) as appealId + FROM + t_order AS t + LEFT JOIN t_works_type AS t2 ON t.works_type_id = t2.id + LEFT JOIN t_works_type AS t3 ON t2.pid = t3.id + LEFT JOIN t_customer AS c ON t.customer_id = c.id + LEFT JOIN t_store AS s ON t.store_id = s.id + + + + + + + + insert into t_order + + id, + create_by, + create_time, + update_by, + update_time, + del_flag, + title, + source_material, + origin_amount, + amount, + change_amount, + change_user_type, + change_status, + change_remark, + confirm_date, + customer_id, + store_id, + sale_amount, + sale_id, + content, + status, + appeal_status, + appeal_user_type, + source_user_type, + cover_image, + images, + first_price, + first_status, + first_pay_type, + second_pay_type, + order_no, + ali_business_id, + first_pay_time, + second_pay_time, + + + #{id}, + #{createBy}, + #{createTime}, + #{updateBy}, + #{updateTime}, + #{delFlag}, + #{title}, + #{sourceMaterial}, + #{originAmount}, + #{amount}, + #{changeAmount}, + #{changeUserType}, + #{changeStatus}, + #{changeRemark}, + #{confirmDate}, + #{customerId}, + #{storeId}, + #{saleAmount}, + #{saleId}, + #{content}, + #{status}, + #{appealStatus}, + #{appealUserType}, + #{sourceUserType}, + #{coverImage}, + #{images}, + #{firstPrice}, + #{firstStatus}, + #{firstPayType}, + #{secondPayType}, + #{orderNo}, + #{aliBusinessId}, + #{firstPayTime}, + #{secondPayTime}, + + + + + update t_order + + create_by = #{createBy}, + create_time = #{createTime}, + update_by = #{updateBy}, + update_time = #{updateTime}, + del_flag = #{delFlag}, + title = #{title}, + source_material = #{sourceMaterial}, + origin_amount = #{originAmount}, + amount = #{amount}, + change_amount = #{changeAmount}, + change_user_type = #{changeUserType}, + change_status = #{changeStatus}, + change_remark = #{changeRemark}, + confirm_date = #{confirmDate}, + customer_id = #{customerId}, + store_id = #{storeId}, + sale_amount = #{saleAmount}, + sale_id = #{saleId}, + content = #{content}, + status = #{status}, + appeal_status = #{appealStatus}, + appeal_user_type = #{appealUserType}, + source_user_type = #{sourceUserType}, + cover_image = #{coverImage}, + images = #{images}, + first_price = #{firstPrice}, + first_status = #{firstStatus}, + first_pay_type = #{firstPayType}, + second_pay_type = #{secondPayType}, + order_no = #{orderNo}, + ali_business_id = #{aliBusinessId}, + first_pay_time = #{firstPayTime}, + second_pay_time = #{secondPayTime}, + + where id = #{id} + + + + delete from t_order where id = #{id} + + + + delete from t_order where id in + + #{id} + + + + + + + + + + + + + + + + diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/order/model/param/OrderParam.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/order/model/param/OrderParam.java new file mode 100644 index 0000000..b191b23 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/order/model/param/OrderParam.java @@ -0,0 +1,172 @@ +package com.ruoyi.frequency.order.model.param; + +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; + +import java.math.BigDecimal; +import java.util.Date; + +/** + * 订单主对象 t_order + * + * @author zj + * @date 2023-10-13 + */ +@Data +@Accessors(chain = true) +public class OrderParam extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + @ApiModelProperty("租户号") + private Long id; + + @ApiModelProperty("删除标志;1 正常 2 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("订单标题") + @Excel(name = "订单标题") + private String title; + + @ApiModelProperty("素材") + @Excel(name = "素材") + private String sourceMaterial; + + @ApiModelProperty("原价") + @Excel(name = "原价") + private BigDecimal originAmount; + + @ApiModelProperty("订单金额") + @Excel(name = "订单金额") + private BigDecimal amount; + + @ApiModelProperty("改价后金额(客户确认后,改价后金额同步到amount中)") + @Excel(name = "改价后金额(客户确认后,改价后金额同步到amount中)") + private BigDecimal changeAmount; + + @ApiModelProperty("提出改价的用户身份 1 设计师 2 表现师") + @Excel(name = "提出改价的用户身份 1 设计师 2 表现师") + private Integer changeUserType; + + @ApiModelProperty("改价状态 1 待确认 2 已确认") + @Excel(name = "改价状态 1 待确认 2 已确认") + private Integer changeStatus; + + @ApiModelProperty("价格调整备注") + @Excel(name = "价格调整备注") + private String changeRemark; + + @ApiModelProperty("对图时间") + @Excel(name = "对图时间", width = 30, dateFormat = "yyyy-MM-dd") + private Date confirmDate; + + @ApiModelProperty("设计师id") + @Excel(name = "设计师id") + private Long customerId; + + @ApiModelProperty("表现师id") + @Excel(name = "表现师id") + private Long storeId; + + @ApiModelProperty("销售从中拿到的佣金") + @Excel(name = "销售从中拿到的佣金") + private BigDecimal saleAmount; + + @ApiModelProperty("销售id") + @Excel(name = "销售id") + private Long saleId; + + @ApiModelProperty("内容") + @Excel(name = "内容") + private String content; + + @ApiModelProperty("订单状态;-1 已取消 1待确认 2进行中 3待收图 4待评价 5已评价 ") + @Excel(name = "订单状态;-1 已取消 1待确认 2进行中 3待收图 4待评价 5已评价 ") + private Integer status; + + @ApiModelProperty("申诉状态;1无申诉 2申诉中 3申诉完成") + @Excel(name = "申诉状态;1无申诉 2申诉中 3申诉完成") + private String appealStatus; + + @ApiModelProperty("申请用户类型 1 设计师 2 表现师") + @Excel(name = "申请用户类型 1 设计师 2 表现师") + private Integer appealUserType; + + @ApiModelProperty("订单来源 1 设计师自己下单 2 表现师帮设计师下单") + @Excel(name = "订单来源 1 设计师自己下单 2 表现师帮设计师下单") + private Integer sourceUserType; + + /** 封面图 */ + @Excel(name = "封面图") + private String coverImage; + @ApiModelProperty("作品图片") + @Excel(name = "作品图片") + private String images; + + @ApiModelProperty("首款") + @Excel(name = "首款") + private BigDecimal firstPrice; + + @ApiModelProperty("首款支付状态 1 未支付 2 已支付") + @Excel(name = "首款支付状态 1 未支付 2 已支付") + private Integer firstStatus; + + @ApiModelProperty("首款支付方式 1app支付宝 2 h5支付宝 3 app微信 4 h5微信 5 小程序 6 苹果支付 7 余额") + @Excel(name = "首款支付方式 1app支付宝 2 h5支付宝 3 app微信 4 h5微信 5 小程序 6 苹果支付 7 余额") + private Integer firstPayType; + + @ApiModelProperty("尾款支付方式 1app支付宝 2 h5支付宝 3 app微信 4 h5微信 5 小程序 6 苹果支付 7 余额") + @Excel(name = "尾款支付方式 1app支付宝 2 h5支付宝 3 app微信 4 h5微信 5 小程序 6 苹果支付 7 余额") + private Integer secondPayType; + + @ApiModelProperty("订单号") + @Excel(name = "订单号") + private String orderNo; + + @ApiModelProperty("支付宝支付返回的订单号") + @Excel(name = "支付宝支付返回的订单号") + private String aliBusinessId; + + @ApiModelProperty("首款支付时间") + @Excel(name = "首款支付时间", width = 30, dateFormat = "yyyy-MM-dd") + private Date firstPayTime; + + @ApiModelProperty("尾款支付时间") + @Excel(name = "尾款支付时间", width = 30, dateFormat = "yyyy-MM-dd") + private Date secondPayTime; + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/order/model/result/OrderCount.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/order/model/result/OrderCount.java new file mode 100644 index 0000000..5438510 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/order/model/result/OrderCount.java @@ -0,0 +1,29 @@ +package com.ruoyi.frequency.order.model.result; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.math.BigDecimal; + +/** + * @author a + * @date 2024/2/19 9:44 + */ +@Data +public class OrderCount { + + @ApiModelProperty("订单数量") + private Integer orderNum; + + @ApiModelProperty("订单总额") + private BigDecimal orderPrice; + + @ApiModelProperty("已付金额") + private BigDecimal payPrice; + + @ApiModelProperty("待支付金额") + private BigDecimal noPayPrice; + + @ApiModelProperty("赠送支付金额") + private BigDecimal givePrice; +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/order/model/result/OrderResult.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/order/model/result/OrderResult.java new file mode 100644 index 0000000..6b1f956 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/order/model/result/OrderResult.java @@ -0,0 +1,143 @@ +package com.ruoyi.frequency.order.model.result; + +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; + +import java.math.BigDecimal; +import java.util.Date; + +/** + * 订单主对象 t_order + * + * @author zj + * @date 2023-10-13 + */ +@Data +@Accessors(chain = true) +public class OrderResult extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + @ApiModelProperty("租户号") + private Long id; + + + @ApiModelProperty("删除标志;1 正常 2 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("订单标题") + @Excel(name = "订单标题") + private String title; + + @ApiModelProperty("素材") + @Excel(name = "素材") + private String sourceMaterial; + + @ApiModelProperty("原价") + @Excel(name = "原价") + private BigDecimal originAmount; + + @ApiModelProperty("订单金额") + @Excel(name = "订单金额") + private BigDecimal amount; + + @ApiModelProperty("改价后金额(客户确认后,改价后金额同步到amount中)") + @Excel(name = "改价后金额(客户确认后,改价后金额同步到amount中)") + private BigDecimal changeAmount; + + @ApiModelProperty("提出改价的用户身份 1 设计师 2 表现师") + @Excel(name = "提出改价的用户身份 1 设计师 2 表现师") + private Integer changeUserType; + + @ApiModelProperty("改价状态 1 待确认 2 已确认") + @Excel(name = "改价状态 1 待确认 2 已确认") + private Integer changeStatus; + + @ApiModelProperty("价格调整备注") + @Excel(name = "价格调整备注") + private String changeRemark; + + @ApiModelProperty("对图时间") + @Excel(name = "对图时间", width = 30, dateFormat = "yyyy-MM-dd") + private Date confirmDate; + + @ApiModelProperty("设计师id") + @Excel(name = "设计师id") + private Long customerId; + + @ApiModelProperty("表现师id") + @Excel(name = "表现师id") + private Long storeId; + + @ApiModelProperty("销售从中拿到的佣金") + @Excel(name = "销售从中拿到的佣金") + private BigDecimal saleAmount; + + @ApiModelProperty("销售id") + @Excel(name = "销售id") + private Long saleId; + + @ApiModelProperty("内容") + @Excel(name = "内容") + private String content; + + @ApiModelProperty("订单状态;-1 已取消 1待确认 2进行中 3待收图 4待评价 5已评价 ") + @Excel(name = "订单状态;-1 已取消 1待确认 2进行中 3待收图 4待评价 5已评价 ") + private Integer status; + + @ApiModelProperty("申诉状态;1无申诉 2申诉中 3申诉完成") + @Excel(name = "申诉状态;1无申诉 2申诉中 3申诉完成") + private String appealStatus; + + @ApiModelProperty("申请用户类型 1 设计师 2 表现师") + @Excel(name = "申请用户类型 1 设计师 2 表现师") + private Integer appealUserType; + + @ApiModelProperty("订单来源 1 设计师自己下单 2 表现师帮设计师下单") + @Excel(name = "订单来源 1 设计师自己下单 2 表现师帮设计师下单") + private Integer sourceUserType; + + /** 封面图 */ + @Excel(name = "封面图") + private String coverImage; + @ApiModelProperty("作品图片") + @Excel(name = "作品图片") + private String images; + + @ApiModelProperty("首款") + @Excel(name = "首款") + private BigDecimal firstPrice; + + @ApiModelProperty("首款支付状态 1 未支付 2 已支付") + @Excel(name = "首款支付状态 1 未支付 2 已支付") + private Integer firstStatus; + + @ApiModelProperty("首款支付方式 1app支付宝 2 h5支付宝 3 app微信 4 h5微信 5 小程序 6 苹果支付 7 余额") + @Excel(name = "首款支付方式 1app支付宝 2 h5支付宝 3 app微信 4 h5微信 5 小程序 6 苹果支付 7 余额") + private Integer firstPayType; + + @ApiModelProperty("尾款支付方式 1app支付宝 2 h5支付宝 3 app微信 4 h5微信 5 小程序 6 苹果支付 7 余额") + @Excel(name = "尾款支付方式 1app支付宝 2 h5支付宝 3 app微信 4 h5微信 5 小程序 6 苹果支付 7 余额") + private Integer secondPayType; + + @ApiModelProperty("订单号") + @Excel(name = "订单号") + private String orderNo; + + @ApiModelProperty("支付宝支付返回的订单号") + @Excel(name = "支付宝支付返回的订单号") + private String aliBusinessId; + + @ApiModelProperty("首款支付时间") + @Excel(name = "首款支付时间", width = 30, dateFormat = "yyyy-MM-dd") + private Date firstPayTime; + + @ApiModelProperty("尾款支付时间") + @Excel(name = "尾款支付时间", width = 30, dateFormat = "yyyy-MM-dd") + private Date secondPayTime; + + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/order/service/OrderService.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/order/service/OrderService.java new file mode 100644 index 0000000..eabe6e2 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/order/service/OrderService.java @@ -0,0 +1,339 @@ +package com.ruoyi.frequency.order.service; + +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.IService; +import com.ruoyi.common.page.PageResult; +import com.ruoyi.controller.req.*; +import com.ruoyi.controller.resp.OrderDataResp; +import com.ruoyi.controller.resp.MallOrderDetailResp; +import com.ruoyi.controller.resp.OrderDetailResp; +import com.ruoyi.controller.resp.OrderPageResp; +import com.ruoyi.frequency.order.model.result.OrderCount; +import com.ruoyi.vo.BodyIdReq; +import com.ruoyi.vo.PayVo; +import com.ruoyi.frequency.order.entity.Order; +import com.ruoyi.response.ResponseData; +import com.ruoyi.vo.UserVo; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.util.List; +import java.util.Map; + +/** + * 订单主Service接口 + * + * @author zj + * @date 2023-10-13 + */ +public interface OrderService extends IService +{ + /** + * 查询订单主 + * + * @param id 订单主主键 + * @return 订单主 + */ + public Order selectOrderById(Long id); + + /** + * 查询订单主列表 + * + * @param order 订单主 + * @return 订单主集合 + */ + public List selectOrderList(Order order); + + /** + * 新增订单主 + * + * @param order 订单主 + * @return 结果 + */ + public int insertOrder(Order order); + + /** + * 修改订单主 + * + * @param order 订单主 + * @return 结果 + */ + public int updateOrder(Order order); + + /** + * 批量删除订单主 + * + * @param ids 需要删除的订单主主键集合 + * @return 结果 + */ + public int deleteOrderByIds(Long[] ids); + + /** + * 删除订单主信息 + * + * @param id 订单主主键 + * @return 结果 + */ + public int deleteOrderById(Long id); + + /** + * 订单发布 + * @param req + * @param userVo + * @return + */ + ResponseData orderRelease(OrderReleaseReq req, UserVo userVo); + + + /** + * 表现师发布订单--设计师支付 + * @param req + * @param userVo + * @return + */ + ResponseData customerPay(CustomerPayReq req, UserVo userVo); + + /** + * 订单列表 + * @param req + * @param userVo + * @return + */ + ResponseData>> orderPage(OrderPageReq req, UserVo userVo); + + /** + * 订单详情 + * @param id + * @param userVo + * @return + */ + ResponseData orderDetail(Long id, UserVo userVo); + + /** + * 表现师接单 + * @param id + * @param userVo + * @return + */ + ResponseData storeOrderReceiving(Long id, UserVo userVo); + + /** + * 取消订单 + * @param orderId + * @param userVo + * @return + */ + ResponseData orderCancel(Long orderId, UserVo userVo); + + + /** + * 确认师傅(表现师) + * @param req + * @param userVo + * @return + */ + ResponseData confirmStore(ConfirmStoreReq req, UserVo userVo); + + /** + * 订单申诉 + * @param req + * @param userVo + * @return + */ + ResponseData orderAppeal(OrderAppealReq req, UserVo userVo); + + /** + * 订单调价 + * @param req + * @param userVo + * @return + */ + ResponseData orderAdjustPrice(OrderAdjustPriceReq req, UserVo userVo); + + + /** + * 计算订单调价支付定金金额(超出现在价格) + * @param req + * @param userVo + * @return + */ + ResponseData orderAdjustPricePayCount(OrderAdjustPricePayCountReq req, UserVo userVo); + + /** + * 订单调价确认 + * @param req + * @param userVo + * @return + */ + ResponseData orderAdjustPriceConfirm(OrderAdjustPriceConfirmReq req, UserVo userVo); + + + /** + * 订单调价拒绝 + * @param req + * @param userVo + * @return + */ + ResponseData orderAdjustPriceRefuse(RefuseReq req, UserVo userVo); + + /** + * 订单延期 + * @param req + * @param userVo + * @return + */ + ResponseData orderExtension(OrderExtensionReq req, UserVo userVo); + + /** + * 订单延期取消 + * @param orderId + * @return + */ + ResponseData orderExtensionCancel(Long orderId); + + /** + * 订单延期确认 + * @param orderId + * @param userVo + * @return + */ + ResponseData orderExtensionConfirm(Long orderId, UserVo userVo); + + /** + * 订单延期拒绝 + * @param req + * @param userVo + * @return + */ + ResponseData orderExtensionRefuse(RefuseReq req, UserVo userVo); + + /** + * 样图上传 + * @param req + * @param userVo + * @return + */ + ResponseData sampleImagesUpload(SampleImagesUploadReq req, UserVo userVo); + + /** + * 收图并支付 + * @param req + * @param userVo + * @return + */ + ResponseData receiveDrawingsAndPay(ReceiveDrawingsAndPayReq req, UserVo userVo); + + /** + * 评价 + * @param req + * @param userVo + * @return + */ + ResponseData evaluate(EvaluateReq req, UserVo userVo); + + /** + * 评价计算评分 + * @param req + * @param userVo + * @return + */ + ResponseData evaluateCountStar(EvaluateReq req, UserVo userVo); + + + /** + * 订单列表上方统计 + * @param orderPageReq + * @param userVo + * @return + */ + ResponseData orderData(OrderPageReq orderPageReq,UserVo userVo); + + + /** + * 订单首款支付宝回调 + * @param request + * @param response + * @return + */ + ResponseData orderAliNotify(HttpServletRequest request, HttpServletResponse response); + + + /** + * 订单首款微信回调 + * @param request + * @param response + * @return + */ + ResponseData orderWxNotify(HttpServletRequest request, HttpServletResponse response); + + /** + * 订单尾款支付宝回调 + * @param request + * @param response + * @return + */ + ResponseData secondOrderAliNotify(HttpServletRequest request, HttpServletResponse response); + + /** + * 订单尾款微信回调 + * @param request + * @param response + * @return + */ + ResponseData secondOrderWxNotify(HttpServletRequest request, HttpServletResponse response); + + /** + * 设计师调价支付宝回调地址 + * @param request + * @param response + * @return + */ + ResponseData orderAdjustPricePayAliNotify(HttpServletRequest request, HttpServletResponse response); + + /** + * 设计师调价微信回调地址 + * @param request + * @param response + * @return + */ + ResponseData orderAdjustPricePayWxNotify(HttpServletRequest request, HttpServletResponse response); + + /** + * 表现师调价设计师确认支付宝回调地址 + * @param request + * @param response + * @return + */ + ResponseData orderAdjustPriceConfirmPayAliNotify(HttpServletRequest request, HttpServletResponse response); + + /** + * 表现师调价设计师确认微信回调地址 + * @param request + * @param response + * @return + */ + ResponseData orderAdjustPriceConfirmPayWxNotify(HttpServletRequest request, HttpServletResponse response); + + /** + * 后台列表统计 + * @param order + * @return + */ + OrderCount statistics(Order order); + + ResponseData orderLakalaNotify(Map paramMap); + + ResponseData secondOrderLakalaNotify(Map paramMap); + + ResponseData orderAdjustPricePayLakalaNotify(Map paramMap); + + ResponseData orderAdjustPriceConfirmPayLakalaNotify(Map paramMap); + + ResponseData isNeedGetOrderDetail(IsNeedGetOrderDetailReq req); + + ResponseData cancelOrderAppeal(BodyIdReq req, UserVo userVo); + + ResponseData getLakalaPaySuccess(LakalaPaySuccessReq req); + + ResponseData sampleImagesAddendum(SampleImagesUploadReq req, UserVo userVo); +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/order/service/impl/OrderServiceImpl.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/order/service/impl/OrderServiceImpl.java new file mode 100644 index 0000000..30babc7 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/order/service/impl/OrderServiceImpl.java @@ -0,0 +1,3166 @@ +package com.ruoyi.frequency.order.service.impl; + +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.date.DateUtil; +import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.RandomUtil; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.conditions.update.LambdaUpdateChainWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.ruoyi.code.DictConstant; +import com.ruoyi.code.PublicCommon; +import com.ruoyi.common.core.domain.BaseEntity; +import com.ruoyi.common.core.domain.entity.SysDictData; +import com.ruoyi.common.exception.CustomException; +import com.ruoyi.common.exception.ServiceException; +import com.ruoyi.common.exception.enums.CoreExceptionEnum; +import com.ruoyi.common.page.PageResult; +import com.ruoyi.common.utils.DateUtils; +import com.ruoyi.common.utils.StringUtils; +import com.ruoyi.controller.req.*; +import com.ruoyi.controller.resp.AppealDetailResp; +import com.ruoyi.controller.resp.OrderDataResp; +import com.ruoyi.controller.resp.OrderDetailResp; +import com.ruoyi.controller.resp.OrderPageResp; +import com.ruoyi.enums.IntegralDetailEnums; +import com.ruoyi.enums.PlatformRecordEnums; +import com.ruoyi.enums.WalletDetailEnums; +import com.ruoyi.enums.message.OrderMessageEnums; +import com.ruoyi.enums.order.OrderPriceEnums; +import com.ruoyi.enums.order.OrderStatusEnums; +import com.ruoyi.enums.process.ProcessResultEnums; +import com.ruoyi.enums.user.UserEnums; +import com.ruoyi.frequency.appeal.entity.Appeal; +import com.ruoyi.frequency.appeal.service.AppealService; +import com.ruoyi.frequency.appealdetail.entity.AppealDetail; +import com.ruoyi.frequency.appealdetail.service.AppealDetailService; +import com.ruoyi.frequency.auth.entity.Auth; +import com.ruoyi.frequency.auth.service.AuthService; +import com.ruoyi.frequency.block.entity.Block; +import com.ruoyi.frequency.block.service.BlockService; +import com.ruoyi.frequency.customer.mapper.CustomerMapper; +import com.ruoyi.frequency.customer.service.CustomerService; +import com.ruoyi.frequency.customer.service.UserService; +import com.ruoyi.frequency.givewallerecord.service.GiveWalletRecordService; +import com.ruoyi.frequency.highendauth.entity.HighendAuth; +import com.ruoyi.frequency.highendauth.service.HighendAuthService; +import com.ruoyi.frequency.integralrecord.service.IntegralRecordService; +import com.ruoyi.frequency.onlinerecord.service.OnlineRecordService; +import com.ruoyi.frequency.order.entity.Order; +import com.ruoyi.frequency.order.mapper.OrderMapper; +import com.ruoyi.frequency.order.model.result.OrderCount; +import com.ruoyi.frequency.order.service.OrderService; +import com.ruoyi.frequency.orderchangerecord.entity.OrderChangeRecord; +import com.ruoyi.frequency.orderchangerecord.service.OrderChangeRecordService; +import com.ruoyi.frequency.orderevaluate.entity.OrderEvaluate; +import com.ruoyi.frequency.orderevaluate.service.OrderEvaluateService; +import com.ruoyi.frequency.orderextensionrecord.entity.OrderExtensionRecord; +import com.ruoyi.frequency.orderextensionrecord.service.OrderExtensionRecordService; +import com.ruoyi.frequency.ordermessage.service.OrderMessageService; +import com.ruoyi.frequency.orderoperatorhistory.entity.OrderOperatorHistory; +import com.ruoyi.frequency.orderoperatorhistory.service.OrderOperatorHistoryService; +import com.ruoyi.frequency.orderpanorama.entity.OrderPanorama; +import com.ruoyi.frequency.orderpanorama.service.OrderPanoramaService; +import com.ruoyi.frequency.orderpricerecord.service.OrderPriceRecordService; +import com.ruoyi.frequency.orderreceiving.entity.OrderReceiving; +import com.ruoyi.frequency.orderreceiving.service.OrderReceivingService; +import com.ruoyi.frequency.platformrecord.service.PlatformRecordService; +import com.ruoyi.frequency.refereeuser.entity.RefereeUser; +import com.ruoyi.frequency.refereeuser.service.RefereeUserService; +import com.ruoyi.frequency.store.entity.Store; +import com.ruoyi.frequency.store.mapper.StoreMapper; +import com.ruoyi.frequency.store.service.StoreService; +import com.ruoyi.frequency.wallerecord.service.WalletRecordService; +import com.ruoyi.frequency.works.entity.Works; +import com.ruoyi.frequency.works.service.WorksService; +import com.ruoyi.frequency.workspanorama.entity.WorksPanorama; +import com.ruoyi.frequency.workspanorama.service.WorksPanoramaService; +import com.ruoyi.pay.enums.PayEnums; +import com.ruoyi.pay.enums.PaySourceEnums; +import com.ruoyi.pay.utils.AlipayCore; +import com.ruoyi.pay.utils.HttpRequestUtil; +import com.ruoyi.pay.utils.PayUtil; +import com.ruoyi.response.ResponseData; +import com.ruoyi.utils.BusinessUtil; +import com.ruoyi.vo.BodyIdReq; +import com.ruoyi.vo.PayVo; +import com.ruoyi.vo.UserInfo; +import com.ruoyi.vo.UserVo; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.redis.core.StringRedisTemplate; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.math.BigDecimal; +import java.math.RoundingMode; +import java.util.*; +import java.util.concurrent.CompletableFuture; +import java.util.stream.Collectors; + +import static com.ruoyi.enums.message.OrderMessageEnums.EVALUATE_ORDER; + +/** + * 订单主Service业务层处理 + * + * @author zj + * @date 2023-10-13 + */ +@Service +@Transactional(rollbackFor = Exception.class) +@Slf4j +public class OrderServiceImpl extends ServiceImpl implements OrderService { + @Autowired + private OrderMapper orderMapper; + + @Autowired + private OrderEvaluateService orderEvaluateService; + + @Autowired + private AppealDetailService appealDetailService; + + + /** + * 查询订单主 + * + * @param id 订单主主键 + * @return 订单主 + */ + @Override + public Order selectOrderById(Long id) { + Order order = orderMapper.selectOrderById(id); + + if (order != null) { + + Set userVoSet = new HashSet<>(); + userVoSet.add(new UserVo(UserEnums.customer.getCode(), order.getCustomerId())); + userVoSet.add(new UserVo(UserEnums.store.getCode(), order.getStoreId())); + + //查询用户信息 + Map userMap = userService.selectUserInfoMap(userVoSet, null); + + order.setStoreInfo(userMap.get(new UserVo(UserEnums.store.getCode(), order.getStoreId()))); + order.setCustomerInfo(userMap.get(new UserVo(UserEnums.customer.getCode(), order.getCustomerId()))); + + //查询3D图 + List panoramaList = orderPanoramaService.list(new QueryWrapper().lambda() + .eq(OrderPanorama::getDelFlag, PublicCommon.启用) + .eq(OrderPanorama::getOrderId, id).orderByDesc(BaseEntity::getCreateTime)); + order.setPanoramaList(panoramaList); + + //查询最新一条申诉 + Appeal appeal = appealService.getOne(new QueryWrapper().lambda() + .eq(Appeal::getOrderId, id).orderByDesc(BaseEntity::getCreateTime).last("limit 1")); + + if (appeal != null) { + AppealDetailResp appealDetailResp = appealService.appealDetail(appeal.getId(), null).getData(); + + List appealDetailList = appealDetailService.list(new QueryWrapper().lambda() + .eq(AppealDetail::getDelFlag, PublicCommon.启用) + .eq(AppealDetail::getAppealId, appeal.getId()) + .orderByDesc(BaseEntity::getCreateTime) + ); + appealDetailResp.setAppealDetailList(appealDetailList); + + order.setAppeal(appealDetailResp); + } + + //查询表现师评价 + if (order.getIsStoreEvaluate() == 2) { + OrderEvaluate storeEvaluate = orderEvaluateService.getOne(new QueryWrapper().lambda() + .eq(OrderEvaluate::getOrderId, id) + .eq(OrderEvaluate::getUserType, UserEnums.store.getCode()) + .eq(OrderEvaluate::getUserId, order.getStoreId()) + ); + order.setStoreEvaluate(storeEvaluate); + } + + //查询设计师评价 + if (order.getIsCustomerEvaluate() == 2) { + OrderEvaluate customerEvaluate = orderEvaluateService.getOne(new QueryWrapper().lambda() + .eq(OrderEvaluate::getOrderId, id) + .eq(OrderEvaluate::getUserType, UserEnums.customer.getCode()) + .eq(OrderEvaluate::getUserId, order.getCustomerId()) + ); + order.setCustomerEvaluate(customerEvaluate); + } + + + } + return order; + } + + private List orderList(Order order) { + List orders = orderMapper.selectOrderList(order); + return orders; + } + + /** + * 查询订单主列表 + * + * @param order 订单主 + * @return 订单主 + */ + @Override + public List selectOrderList(Order order) { + + List orders = orderList(order); + + if (orders != null && orders.size() > 0) { + Set userVoSet = new HashSet<>(); + orders.stream().forEach(s -> { + userVoSet.add(new UserVo(UserEnums.customer.getCode(), s.getCustomerId())); + userVoSet.add(new UserVo(UserEnums.store.getCode(), s.getStoreId())); + }); + + //查询用户信息 + Map userMap = userService.selectUserInfoMap(userVoSet, null); + + orders.stream().forEach(s -> { + s.setCustomerInfo(userMap.get(new UserVo(UserEnums.customer.getCode(), s.getCustomerId()))); + s.setStoreInfo(userMap.get(new UserVo(UserEnums.store.getCode(), s.getStoreId()))); + }); + } + + + return orders; + } + + @Override + public OrderCount statistics(Order order) { + List orders = orderList(order); + + List orderIdList = orders.stream().map(x -> x.getId()).collect(Collectors.toList()); + orderIdList.add(-1L); + return orderMapper.statistics(orderIdList); + } + + /** + * 新增订单主 + * + * @param order 订单主 + * @return 结果 + */ + @Override + public int insertOrder(Order order) { + return orderMapper.insertOrder(order); + } + + /** + * 修改订单主 + * + * @param order 订单主 + * @return 结果 + */ + @Override + public int updateOrder(Order order) { + order.setUpdateTime(DateUtils.getNowDate()); + return orderMapper.updateOrder(order); + } + + /** + * 批量删除订单主 + * + * @param ids 需要删除的订单主主键 + * @return 结果 + */ + @Override + public int deleteOrderByIds(Long[] ids) { + this.lambdaUpdate().set(Order::getDelFlag, PublicCommon.删除).in(Order::getId, ids).update(); + return ids.length; + } + + /** + * 删除订单主信息 + * + * @param id 订单主主键 + * @return 结果 + */ + @Override + public int deleteOrderById(Long id) { + this.lambdaUpdate().set(Order::getDelFlag, PublicCommon.删除).eq(Order::getId, id).update(); + return 1; + } + + @Autowired + private PayUtil payUtil; + + @Autowired + private OrderReceivingService orderReceivingService; + + @Autowired + private BusinessUtil businessUtil; + + @Autowired + private OrderMessageService orderMessageService; + + @Autowired + private PlatformRecordService platformRecordService; + + @Override + public ResponseData orderRelease(OrderReleaseReq req, UserVo userVo) { + + if (UserEnums.enterprise.getCode().equals(userVo.getUserType())) { + return ResponseData.error("企业不可以发布订单"); + } + + //首款支付占比 + BigDecimal ratio = firstPayRatio(); + + if (UserEnums.store.getCode().equals(userVo.getUserType())) { + //表现师发布订单 + return storeReleaseOrder(req, userVo, ratio); + } else if (UserEnums.customer.getCode().equals(userVo.getUserType()) && ObjectUtil.isNotEmpty(req.getStoreId())) { + //设计师在表现师主页发布订单 + return customerReleaseDefaultStoreOrder(req, userVo, ratio); + } else { + //设计师发布订单 + return customerReleaseOrder(req, userVo, ratio); + } + } + + /** + * 设计师在表现师主页发布订单 + * + * @param req + * @param userVo + * @param ratio + * @return + */ + private ResponseData customerReleaseDefaultStoreOrder(OrderReleaseReq req, UserVo userVo, BigDecimal ratio) { + + //判断屏蔽关系 + checkUserRelation(userVo, new UserVo(UserEnums.store.getCode(), req.getStoreId())); + + + //余额支付判断 + judgeBlancePay(req, userVo, ratio); + + //组装订单 + Order order = assembleOrder(req, userVo, ratio); + order.setStoreId(req.getStoreId()); + this.save(order); + + //记录订单操作日志 + orderOperatorHistoryService.insertOrderOperatorHistory(OrderOperatorHistory.addAppHistory(order.getId(), "设计师在表现师主页发布订单", "设计师在表现师主页发布订单", userVo)); + //支付 + ResponseData responseData = payUtil.pay(userVo, order.getId(), req.getPayType(), order.getFirstTripartitePrice(), order.getFirstGivePrice(), order.getFirstPayOrderNo(), PaySourceEnums.order_pay, WalletDetailEnums.ORDER_PAY); + + if (responseData.getSuccess() || responseData.getCode().equals(210)) { + //余额支付/苹果支付 + if (PayEnums.balance.getCode().equals(req.getPayType()) || PayEnums.apple.getCode().equals(req.getPayType())) { + after(order); + } + } + + return responseData; + } + + /** + * 获取字典首款支付占比 + * + * @return + */ + private BigDecimal firstPayRatio() { + SysDictData dict = businessUtil.getDict(DictConstant.OrderDict.首款支付占比); + //首款支付比例 + BigDecimal ratio = BigDecimal.ZERO; + + if (dict != null && ObjectUtil.isNotEmpty(dict.getDictValue())) { + ratio = new BigDecimal(dict.getDictValue()); + } + return ratio; + } + + + /** + * 设计师发布订单 + * + * @param req + * @param userVo + * @return + */ + private ResponseData customerReleaseOrder(OrderReleaseReq req, UserVo userVo, BigDecimal ratio) { + + //余额支付判断 + judgeBlancePay(req, userVo, ratio); + + //组装订单 + Order order = assembleOrder(req, userVo, ratio); + + this.save(order); + + //记录订单操作日志 + orderOperatorHistoryService.insertOrderOperatorHistory(OrderOperatorHistory.addAppHistory(order.getId(), "设计师发布订单", "设计师发布订单", userVo)); + //支付 + ResponseData responseData = payUtil.pay(userVo, order.getId(), req.getPayType(), order.getFirstTripartitePrice(), order.getFirstGivePrice(), order.getFirstPayOrderNo(), PaySourceEnums.order_pay, WalletDetailEnums.ORDER_PAY); + + + if (responseData.getSuccess() || responseData.getCode().equals(210)) { + //余额支付/苹果支付 + if (PayEnums.balance.getCode().equals(req.getPayType()) || PayEnums.apple.getCode().equals(req.getPayType())) { + after(order); + } + } + + return responseData; + + } + + @Autowired + private BlockService blockService; + + + private void checkUserRelation(UserVo self, UserVo other) { + List userVos = blockService.list(new QueryWrapper().lambda().eq(Block::getUserId, self.getUserId()) + .eq(Block::getUserType, self.getUserType()).eq(Block::getDelFlag, PublicCommon.启用)); + + for (Block cur : userVos) { + if (cur.getBlockUserId().equals(other.getUserId()) && cur.getBlockUserType().equals(other.getUserType())) { + throw new ServiceException("你已将对方拉黑"); + } + } + userVos = blockService.list(new QueryWrapper().lambda().eq(Block::getUserId, other.getUserId()) + .eq(Block::getUserType, other.getUserType()).eq(Block::getDelFlag, PublicCommon.启用)); + for (Block cur : userVos) { + if (cur.getBlockUserId().equals(self.getUserId()) && cur.getBlockUserType().equals(self.getUserType())) { + throw new ServiceException("对方已将你拉黑"); + } + } + + //屏蔽 + List userVosShield = userService.shieldUserList(self); + for (UserVo cur : userVosShield) { + if (cur.getUserId().equals(other.getUserId()) && cur.getUserType().equals(other.getUserType())) { + throw new ServiceException("你已将对方屏蔽"); + } + } + + userVosShield = userService.shieldUserList(other); + for (UserVo cur : userVosShield) { + if (cur.getUserId().equals(self.getUserId()) && cur.getUserType().equals(self.getUserType())) { + throw new ServiceException("对方已将你屏蔽"); + } + } + + } + + /** + * 表现师发布订单 + * + * @param req + * @param userVo + * @return + */ + private ResponseData storeReleaseOrder(OrderReleaseReq req, UserVo userVo, BigDecimal ratio) { + //判断表现师认证情况 + checkStoreAuthType(userVo, req.getIfHighend()); + + //设计师id是否存在 + if (ObjectUtil.isNull(req.getCustomerId())) { + return ResponseData.error("请选择设计师"); + } + + //判断屏蔽关系 + checkUserRelation(userVo, new UserVo(UserEnums.customer.getCode(), req.getCustomerId())); + + //组装订单 + Order order = assembleOrder(req, userVo, ratio); + + this.save(order); + + //记录订单操作日志 + orderOperatorHistoryService.insertOrderOperatorHistory(OrderOperatorHistory.addAppHistory(order.getId(), "表现师发布订单", "表现师发布订单", userVo)); + + //关联记录 + OrderReceiving orderReceiving = new OrderReceiving() + .setOrderId(order.getId()) + .setStoreId(userVo.getUserId()) + .setReceivingStatus(PublicCommon.OrderReceiving.接单成功); + orderReceivingService.save(orderReceiving); + + //表现师发布订单 给设计师发送消息 + orderMessageService.addOrderMessage(new UserVo(UserEnums.customer.getCode(), order.getCustomerId()), order.getId(), order.getOrderNo(), PublicCommon.Order.订单, OrderMessageEnums.STORE_RELEASE_ORDER); + + + Map map = new HashMap<>(); + map.put("orderId", order.getId()); + return ResponseData.success(map); + } + + @Autowired + private OrderOperatorHistoryService orderOperatorHistoryService; + + /** + * 余额支付判断 + * + * @param req + * @param userVo + */ + private void judgeBlancePay(OrderReleaseReq req, UserVo userVo, BigDecimal ratio) { + + //表现师创建订单不需要判断 + if (userVo.getUserType().equals(UserEnums.store.getCode())) { + return; + } + //余额支付 验证密码 + if (req.getPayType().equals(PayEnums.balance.getCode())) { + + //支付密码验证 + Boolean isTrue = businessUtil.payPwdTrue(userVo, req.getPayPwd()); + if (!isTrue) { + throw new CustomException(CoreExceptionEnum.PWD_ERROR); + } + //判断余额 + BigDecimal userBalance = businessUtil.getUserBalance(userVo); + if (userBalance.compareTo(req.getAmount().multiply(ratio)) == -1) { + throw new CustomException(CoreExceptionEnum.BALANCE_INSUFFICIENT); + } + + } + } + + + /** + * 组装订单 + * + * @param req + * @param userVo + * @param ratio + * @return + */ + private Order assembleOrder(OrderReleaseReq req, UserVo userVo, BigDecimal ratio) { + + Order order = new Order(); + + BeanUtil.copyProperties(req, order); + + order.setOriginAmount(req.getAmount()); + order.setOriginDeliverTime(order.getDeliverTime()); + + //订单来源 1 设计师自己下单 2 表现师帮设计师下单 + order.setSourceUserType(userVo.getUserType()); + + + //计算首款支付金额 + order.setFirstPrice(req.getAmount().multiply(ratio).setScale(2, BigDecimal.ROUND_HALF_UP)); + + //计算首款赠送支付金额 + BigDecimal maxGivePrice = businessUtil.userMaxGivePrice(userVo, order.getFirstPrice()); + order.setFirstGivePrice(maxGivePrice); + + //三方支付金额(支付宝,微信) + order.setFirstTripartitePrice(order.getFirstPrice().subtract(maxGivePrice)); + + //订单号 + order.setOrderNo(generateOrderNo(1)); + + //订单状态 + order.setStatus(OrderStatusEnums.to_be_confirm.getCode()); + + order.setDrawingNum(req.getDrawingNum()); + + //表现师发布订单 默认选中 + if (UserEnums.store.getCode().equals(userVo.getUserType())) { + //默认接单 + order.setStoreId(userVo.getUserId()); + //设计师ID + order.setCustomerId(req.getCustomerId()); + } else { + order.setCustomerId(userVo.getUserId()); + + //首款支付单号 + order.setFirstPayOrderNo(generateOrderNo(2)); + + //首款支付类型 + order.setFirstPayType(req.getPayType()); + } + + return order; + } + + @Override + public ResponseData customerPay(CustomerPayReq req, UserVo userVo) { + + //订单 + Order order = this.getById(req.getOrderId()); + + //判断订单状态 + if (ObjectUtil.notEqual(OrderStatusEnums.to_be_confirm.getCode(), order.getStatus()) && + ObjectUtil.notEqual(PublicCommon.Pay.未支付, order.getFirstStatus())) { + return ResponseData.error("订单状态错误"); + } + + String firstPayOrderNo = ""; + //如果支付单号 不为空 重新生成支付单号 payOrderNo_次数 + if (StringUtils.isNotBlank(order.getFirstPayOrderNo())) { + + if (order.getFirstPayOrderNo().split("_").length > 1) { + firstPayOrderNo = order.getFirstPayOrderNo().split("_")[0] + "_" + (Integer.valueOf(order.getFirstPayOrderNo().split("_")[1]) + 1); + } else { + firstPayOrderNo = order.getFirstPayOrderNo().concat("_") + 1; + } + } else { + firstPayOrderNo = generateOrderNo(2); + } + + //重新计算支付金额 + BigDecimal maxGivePrice = businessUtil.userMaxGivePrice(userVo, order.getFirstPrice()); + + + BigDecimal firstTripartitePrice = order.getFirstPrice().subtract(maxGivePrice); + //支付单号 + this.lambdaUpdate() + .set(Order::getFirstGivePrice, maxGivePrice) + .set(Order::getFirstTripartitePrice, firstTripartitePrice) + .set(Order::getFirstPayOrderNo, firstPayOrderNo) + .eq(Order::getId, order.getId()).update(); + + //支付 + ResponseData responseData = payUtil.pay(userVo, order.getId(), req.getPayType(), firstTripartitePrice, maxGivePrice, firstPayOrderNo, PaySourceEnums.order_pay, WalletDetailEnums.ORDER_PAY); + + if (responseData.getSuccess() || responseData.getCode().equals(210)) { + //余额支付 + if (req.getPayType().equals(PayEnums.balance.getCode()) || req.getPayType().equals(PayEnums.apple.getCode())) { + after(order); + } + } + + + return responseData; + } + + @Autowired + private OrderPriceRecordService orderPriceRecordService; + + /** + * 支付成功 + * + * @param order + */ + private void after(Order order) { + + + Integer status = null; + + + if (UserEnums.store.getCode().equals(order.getSourceUserType())) { + //表现师发布订单 + status = OrderStatusEnums.ongoing.getCode(); + //发送消息提醒用户 + orderMessageService.addOrderMessage(new UserVo(UserEnums.store.getCode(), order.getStoreId()), order.getId(), order.getOrderNo(), PublicCommon.Order.订单, OrderMessageEnums.FIRST_PRICE_PAY); + + } else if (UserEnums.customer.getCode().equals(order.getSourceUserType()) && ObjectUtil.isNotEmpty(order.getStoreId())) { + //设计师在表现师主页发布订单 + status = OrderStatusEnums.ongoing.getCode(); + //发送消息提醒用户 + orderMessageService.addOrderMessage(new UserVo(UserEnums.store.getCode(), order.getStoreId()), order.getId(), "", PublicCommon.Order.订单, OrderMessageEnums.CUSTOMER_CHOOSE_STORE); + + } else { + //设计师发布订单 + status = OrderStatusEnums.to_be_confirm.getCode(); + } + + //修改状态 + LambdaUpdateChainWrapper wrapper = this.lambdaUpdate().set(Order::getStatus, status) + .set(Order::getFirstStatus, PublicCommon.Pay.已支付) + .set(Order::getFirstPayTime, new Date()) + .eq(Order::getId, order.getId()); + wrapper.update(); + //平台流水 + platformRecordService.addPlatformRecord(new UserVo(UserEnums.customer.getCode(), order.getCustomerId()), order.getId(), order.getFirstPrice(), PlatformRecordEnums.ORDER_PAY); + + //订单支付金额 + orderPriceRecordService.addOrderPriceRecord(OrderPriceEnums.first_pay, order.getId(), order.getFirstPrice()); + + } + + @Autowired + private UserService userService; + + @Override + public ResponseData>> orderPage(OrderPageReq req, UserVo userVo) { + + //项目大厅订单要晒去拉黑屏蔽 + if (req.getIsHall()) { + //筛去拉黑与被拉黑用户 + List blockUserList = userService.blockUserList(userVo); + req.setBlockUserList(blockUserList); + + //筛去屏蔽用户 + List shieldUserList = userService.shieldUserList(userVo); + req.setShieldUserList(shieldUserList); + } + + //查询设计师和表现师互相之间的订单 + if (req.getIsEachOther() != null && req.getIsEachOther()) { + if (userVo.getUserType().equals(UserEnums.customer.getCode())) { + req.setOtherUserType(UserEnums.store.getCode()); + } else if (userVo.getUserType().equals(UserEnums.store.getCode())) { + req.setOtherUserType(UserEnums.customer.getCode()); + } + } + + Page page = orderMapper.orderPage(new Page<>(req.getPageNo(), req.getPageSize()), req, userVo); + + if (!page.getRecords().isEmpty()) { + + Set userVoSet = new HashSet<>(); + page.getRecords().stream().forEach(orderPageResp -> { + userVoSet.add(new UserVo(UserEnums.customer.getCode(), orderPageResp.getCustomerId())); + userVoSet.add(new UserVo(UserEnums.store.getCode(), orderPageResp.getStoreId())); + }); + + //查询用户信息 + Map userMap = userService.selectUserInfoMap(userVoSet, userVo); + + page.getRecords().stream().forEach(orderPageResp -> { + orderPageResp.setCustomerInfo(userMap.get(new UserVo(UserEnums.customer.getCode(), orderPageResp.getCustomerId()))); + orderPageResp.setStoreInfo(userMap.get(new UserVo(UserEnums.store.getCode(), orderPageResp.getStoreId()))); + }); + } + + return ResponseData.success(new PageResult<>(page)); + } + + @Override + public ResponseData orderDetail(Long id, UserVo userVo) { + OrderDetailResp orderDetailResp = orderMapper.orderDetail(id, userVo); + if (orderDetailResp != null) { + + Set userVoSet = new HashSet<>(); + userVoSet.add(new UserVo(UserEnums.customer.getCode(), orderDetailResp.getCustomerId())); + userVoSet.add(new UserVo(UserEnums.store.getCode(), orderDetailResp.getStoreId())); + + //查询用户信息 + Map userMap = userService.selectUserInfoMap(userVoSet, userVo); + + orderDetailResp.setStoreInfo(userMap.get(new UserVo(UserEnums.store.getCode(), orderDetailResp.getStoreId()))); + orderDetailResp.setCustomerInfo(userMap.get(new UserVo(UserEnums.customer.getCode(), orderDetailResp.getCustomerId()))); + + //查询3D图 + List panoramaList = orderPanoramaService.list(new QueryWrapper().lambda() + .eq(OrderPanorama::getDelFlag, PublicCommon.启用) + .eq(OrderPanorama::getOrderId, id).orderByDesc(BaseEntity::getCreateTime)); + orderDetailResp.setPanoramaList(panoramaList); + + //查询接单表现师 + List orderReceivingList = orderReceivingService.list(new QueryWrapper().lambda() + .eq(OrderReceiving::getOrderId, id).eq(OrderReceiving::getDelFlag, PublicCommon.启用).orderByDesc(BaseEntity::getCreateTime)); + Set storeVoSet = orderReceivingList.stream().map(orderReceiving -> new UserVo(UserEnums.store.getCode(), orderReceiving.getStoreId())).collect(Collectors.toSet()); + + //查询表现师信息 + Map storeMap = userService.selectUserInfoMap(storeVoSet, userVo); + + orderReceivingList.stream().forEach(orderReceiving -> orderReceiving.setUserInfo(storeMap.get(new UserVo(UserEnums.store.getCode(), orderReceiving.getStoreId())))); + + orderDetailResp.setOrderReceivingList(orderReceivingList); + if (orderReceivingList.size() > 0) { + StringBuffer stringBuffer = new StringBuffer(); + orderReceivingList.stream().forEach(x -> { + stringBuffer.append(x.getId()); + }); + orderDetailResp.setRecentlyReceiveStr(stringBuffer.toString()); + } + + //调价信息 + OrderChangeRecord changeRecord = orderChangeRecordService.getOne(new QueryWrapper().lambda() + .eq(OrderChangeRecord::getDelFlag, PublicCommon.启用) + .eq(OrderChangeRecord::getOrderId, id) + .eq(OrderChangeRecord::getStatus, PublicCommon.OrderChange.已确认) + .orderByDesc(BaseEntity::getCreateTime) + .last("LIMIT 1") + ); + orderDetailResp.setOrderChangeRecord(changeRecord); + + //延期信息 + OrderExtensionRecord orderExtensionRecord = orderExtensionRecordService.getOne(new QueryWrapper().lambda() + .eq(OrderExtensionRecord::getDelFlag, PublicCommon.启用) + .eq(OrderExtensionRecord::getOrderId, id) + .eq(OrderExtensionRecord::getStatus, PublicCommon.OrderChange.已确认) + .orderByDesc(BaseEntity::getCreateTime) + .last("LIMIT 1") + ); + orderDetailResp.setOrderExtensionRecord(orderExtensionRecord); + + //评价信息 + List orderEvaluates = orderEvaluateService.list(new QueryWrapper().lambda() + .eq(OrderEvaluate::getDelFlag, PublicCommon.启用) + .eq(OrderEvaluate::getOrderId, id) + ); + + if (orderEvaluates.size() > 0) { + orderEvaluates.stream().forEach(s -> { + if (ObjectUtil.equal(UserEnums.customer.getCode(), s.getUserType())) { + s.setUserInfo(orderDetailResp.getCustomerInfo()); + orderDetailResp.setCustomerOrderEvaluate(s); + } else { + s.setUserInfo(orderDetailResp.getCustomerInfo()); + orderDetailResp.setStoreOrderEvaluate(s); + } + }); + } + + BigDecimal depositAmount = depositChangeAmount(orderDetailResp.getAmount(), orderDetailResp.getChangeAmount(),orderDetailResp.getFirstPrice(),orderDetailResp.getFirstStatus()); + orderDetailResp.setDepositAmount(depositAmount); + } + return ResponseData.success(orderDetailResp); + } + + /** + * 表现师接单 + * + * @param orderId + * @param userVo + * @return + */ + @Override + public ResponseData storeOrderReceiving(Long orderId, UserVo userVo) { + + //企业不能接单 + if (UserEnums.enterprise.getCode().equals(userVo.getUserType())) { + return ResponseData.error("企业不能接单"); + } + + //订单 + Order order = this.getById(orderId); + //判断表现师认证情况 + checkStoreAuthType(userVo, order.getIfHighend()); + + //判断屏蔽关系 + checkUserRelation(userVo, new UserVo(UserEnums.customer.getCode(), order.getCustomerId())); + + + //判断订单状态 + if (ObjectUtil.notEqual(OrderStatusEnums.to_be_confirm.getCode(), order.getStatus())) { + return ResponseData.error("订单状态错误"); + } + + //判断表现师是否接单 + int count = orderReceivingService.count(new QueryWrapper().lambda() + .eq(OrderReceiving::getDelFlag, PublicCommon.启用) + .eq(OrderReceiving::getOrderId, orderId) + .eq(OrderReceiving::getStoreId, userVo.getUserId())); + if (count > 0) { + return ResponseData.error("订单已接取 请勿重复接单"); + } + + //添加表现师接单记录 + OrderReceiving orderReceiving = new OrderReceiving(); + orderReceiving.setOrderId(orderId) + .setStoreId(userVo.getUserId()); + orderReceivingService.save(orderReceiving); + + //发送消息 + orderMessageService.addOrderMessage(new UserVo(UserEnums.customer.getCode(), order.getCustomerId()), order.getId(), order.getOrderNo(), PublicCommon.Order.订单, OrderMessageEnums.RECEIVING_ORDER); + + //记录订单操作日志 + orderOperatorHistoryService.insertOrderOperatorHistory(OrderOperatorHistory.addAppHistory(order.getId(), "表现师接单", "表现师接单", userVo)); + + return ResponseData.success(); + } + + @Autowired + private AuthService authService; + + @Autowired + private HighendAuthService highendAuthService; + + /** + * 判断表现师是否认证 + * + * @param userVo + * @return + */ + private Boolean isAuth(UserVo userVo) { + //判断认证状态 + Boolean isAuth = authService.count(new QueryWrapper().lambda() + .eq(Auth::getStoreId, userVo.getUserId()) + .eq(Auth::getResult, ProcessResultEnums.APPROVED.getCode()) + .eq(Auth::getDelFlag, PublicCommon.启用)) > 0; + + //判断认证状态 + Boolean ishigHendAuth = highendAuthService.count(new QueryWrapper().lambda() + .eq(HighendAuth::getStoreId, userVo.getUserId()) + .eq(HighendAuth::getStatus, 3) + .eq(HighendAuth::getDelFlag, PublicCommon.启用)) > 0; + + return isAuth || ishigHendAuth; + } + + /** + * 判断表现师是否认证 + * + * @param userVo + * @return + */ + private void checkStoreAuthType(UserVo userVo, Integer ifHighend) { + + if (ifHighend == null) { + return; + } + + //高端认证可以接高端和酷家乐,酷家乐认证可以接酷家乐,普通只能接普通 + + //普通认证 + Boolean commonAuth = authService.count(new QueryWrapper().lambda() + .eq(Auth::getStoreId, userVo.getUserId()) + .eq(Auth::getType, 1) + .eq(Auth::getResult, ProcessResultEnums.APPROVED.getCode()) + .eq(Auth::getDelFlag, PublicCommon.启用)) > 0; + + //酷家乐认证 + Boolean kujialeAuth = authService.count(new QueryWrapper().lambda() + .eq(Auth::getStoreId, userVo.getUserId()) + .eq(Auth::getType, 3) + .eq(Auth::getResult, ProcessResultEnums.APPROVED.getCode()) + .eq(Auth::getDelFlag, PublicCommon.启用)) > 0; + + //高端认证 + Boolean ishigHendAuth = highendAuthService.count(new QueryWrapper().lambda() + .eq(HighendAuth::getStoreId, userVo.getUserId()) + .ge(HighendAuth::getStatus, 3) + .eq(HighendAuth::getDelFlag, PublicCommon.启用)) > 0; + + //1普通 2 高端 3酷家乐 + if (ifHighend == 1) { + if (!commonAuth && !ishigHendAuth) { + throw new ServiceException("请先进行普通认证"); + } + + } else if (ifHighend == 2) { + if (!ishigHendAuth) { + throw new ServiceException("请先进行高端认证"); + } + } else if (ifHighend == 3) { + if (!kujialeAuth) { + throw new ServiceException("请先进行酷家乐认证"); + } + } + + } + + + @Override + public ResponseData orderCancel(Long orderId, UserVo userVo) { + + //订单 + Order order = this.getById(orderId); + + //判断订单状态 + if (ObjectUtil.notEqual(OrderStatusEnums.to_be_confirm.getCode(), order.getStatus()) || ObjectUtil.equal(OrderStatusEnums.cancel.getCode(), order.getStatus())) { + return ResponseData.error("订单状态错误"); + } + + switch (UserEnums.getUserEnums(userVo.getUserType())) { + case customer: + //设计师 + //修改状态 + this.lambdaUpdate().set(Order::getStatus, OrderStatusEnums.cancel.getCode()) + .eq(Order::getId, orderId).update(); + + if (order.getFirstStatus().equals(PublicCommon.Pay.已支付)) { + //退款 + payUtil.refund(userVo, orderId, order.getFirstPayType(), order.getFirstTripartitePrice(), order.getFirstTripartitePrice(), order.getFirstPayOrderNo(), order.getAliBusinessId(), order.getFirstGivePrice()); + + //平台流水 + platformRecordService.addPlatformRecord(new UserVo(UserEnums.customer.getCode(), order.getCustomerId()), order.getId(), order.getFirstPrice().negate(), PlatformRecordEnums.ORDER_RETURN); + } + + break; + case store: + //表现师取消,删除对应的接单记录 + orderReceivingService.lambdaUpdate().set(OrderReceiving::getDelFlag, PublicCommon.删除) + .eq(OrderReceiving::getOrderId, orderId) + .eq(OrderReceiving::getStoreId, userVo.getUserId()).update(); + //如果是表现师发布的订单 并且设计师未支付取消订单 + if (ObjectUtil.isNotEmpty(order.getStoreId()) && !order.getFirstStatus().equals(PublicCommon.Pay.已支付)) { + this.lambdaUpdate().set(Order::getStatus, OrderStatusEnums.cancel.getCode()) + .eq(Order::getId, orderId).update(); + + //消息推送给用户 + orderMessageService.addOrderMessage(new UserVo(UserEnums.customer.getCode(), order.getCustomerId()), order.getId(), order.getOrderNo(), PublicCommon.Order.订单, OrderMessageEnums.ORDER_STORE_CANCEL); + } + + break; + } + + //记录订单操作日志 + orderOperatorHistoryService.insertOrderOperatorHistory(OrderOperatorHistory.addAppHistory(order.getId(), "取消订单", "取消订单", userVo)); + + + return ResponseData.success(); + } + + @Override + public ResponseData confirmStore(ConfirmStoreReq req, UserVo userVo) { + //订单 + Order order = this.getById(req.getOrderId()); + + //判断屏蔽关系 + checkUserRelation(userVo, new UserVo(UserEnums.store.getCode(), req.getStoreId())); + + //判断订单状态 + if (ObjectUtil.notEqual(OrderStatusEnums.to_be_confirm.getCode(), order.getStatus())) { + return ResponseData.error("订单状态错误"); + } + + //判断表现师是否已取消接单 + OrderReceiving orderReceiving = orderReceivingService.getOne(new QueryWrapper().lambda() + .eq(OrderReceiving::getOrderId, req.getOrderId()) + .eq(OrderReceiving::getStoreId, req.getStoreId()) + .orderByDesc(BaseEntity::getCreateTime).last(" limit 1")); + if (orderReceiving == null) { + return ResponseData.error("表现师不存在"); + } + if (!orderReceiving.getDelFlag().equals(PublicCommon.启用)) { + return ResponseData.error("表现师已取消接单"); + } + + //修改关联表现师接单状态 + orderReceivingService.lambdaUpdate() + .set(OrderReceiving::getReceivingStatus, PublicCommon.OrderReceiving.接单成功) + .eq(OrderReceiving::getOrderId, req.getOrderId()) + .eq(OrderReceiving::getStoreId, req.getStoreId()) + .update(); + + //其他接单失败 + orderReceivingService.lambdaUpdate() + .set(OrderReceiving::getReceivingStatus, PublicCommon.OrderReceiving.接单失败) + .eq(OrderReceiving::getOrderId, req.getOrderId()) + .ne(OrderReceiving::getStoreId, req.getStoreId()) + .update(); + + //修改状态 + this.lambdaUpdate().set(Order::getStatus, OrderStatusEnums.ongoing.getCode()) + .set(Order::getStoreId, req.getStoreId()) + .eq(Order::getId, req.getOrderId()).update(); + + //记录订单操作日志 + orderOperatorHistoryService.insertOrderOperatorHistory(OrderOperatorHistory.addAppHistory(order.getId(), "客户确定表现师", "客户确定表现师", userVo)); + + + CompletableFuture.runAsync(() -> { + List list = orderReceivingService.list(new QueryWrapper().lambda() + .eq(OrderReceiving::getDelFlag, PublicCommon.启用) + .eq(OrderReceiving::getOrderId, req.getOrderId())); + list.stream().forEach(s -> { + + //接单状态;1等待接单 2接单成功 3接单失败 + if (s.getReceivingStatus().equals(PublicCommon.OrderReceiving.接单成功)) { + //发送消息 + orderMessageService.addOrderMessage(new UserVo(UserEnums.store.getCode(), s.getStoreId()), order.getId(), order.getOrderNo(), PublicCommon.Order.订单, OrderMessageEnums.CONFIRM); + } else { + //发送消息 + orderMessageService.addOrderMessage(new UserVo(UserEnums.store.getCode(), s.getStoreId()), order.getId(), order.getOrderNo(), PublicCommon.Order.订单, OrderMessageEnums.NOT_CONFIRM); + + } + }); + }); + + return ResponseData.success(); + } + + @Autowired + private AppealService appealService; + + @Override + public ResponseData orderAppeal(OrderAppealReq req, UserVo userVo) { + + //订单 + Order order = this.getById(req.getOrderId()); + + + //判断申诉价格 + if (ObjectUtil.isNotEmpty(req.getAppeal().getAmount()) && req.getAppeal().getAmount().compareTo(order.getAmount()) >= 0) { + return ResponseData.error("申诉价格要低于订单价格!"); + } + + //判断订单状态 + if (ObjectUtil.notEqual(OrderStatusEnums.ongoing.getCode(), order.getStatus())) { + return ResponseData.error("订单状态错误"); + } + + //判断是否申诉过 + if (ObjectUtil.equal(order.getAppealStatus(), PublicCommon.Appeal.申诉中)) { + return ResponseData.error("订单已申诉!"); + } + + //判断是否调价 + if (ObjectUtil.equal(order.getChangeStatus(), PublicCommon.OrderChange.待确认)) { + return ResponseData.error("订单已调价 请先确认!"); + } + + this.lambdaUpdate().set(Order::getAppealStatus, PublicCommon.Appeal.申诉中) + .set(Order::getAppealUserType, userVo.getUserType()) + .eq(Order::getId, req.getOrderId()).update(); + + //生成申诉记录 + Appeal appeal = req.getAppeal(); + appeal.setOrderId(req.getOrderId()) + .setAppealUserType(userVo.getUserType()) + .setAppealUserId(userVo.getUserId()) + .setPassiveAppealUserType(userVo.getUserType().equals(UserEnums.store.getCode()) ? UserEnums.customer.getCode() : UserEnums.store.getCode()) + .setPassiveAppealUserId(userVo.getUserType().equals(UserEnums.store.getCode()) ? order.getCustomerId() : order.getStoreId()); + appealService.save(appeal); + + //发送消息 + orderMessageService.addOrderMessage(new UserVo(appeal.getPassiveAppealUserType(), appeal.getPassiveAppealUserId()), order.getId(), order.getOrderNo(), PublicCommon.Order.订单, OrderMessageEnums.APPEAL); + + //记录订单操作日志 + orderOperatorHistoryService.insertOrderOperatorHistory(OrderOperatorHistory.addAppHistory(order.getId(), "发起申诉", "发起申诉", userVo)); + + + return ResponseData.success(); + } + + @Override + public ResponseData cancelOrderAppeal(BodyIdReq req, UserVo userVo) { + Appeal appeal = appealService.getById(req.getId()); + if (appeal == null || !appeal.getDelFlag().equals(PublicCommon.启用)) { + return ResponseData.error("投诉已取消"); + } + //只有投诉方才可以取消投诉 + Order order = getById(appeal.getOrderId()); + if (!order.getAppealUserType().equals(userVo.getUserType())) { + return ResponseData.error("您无权取消投诉"); + } + //投诉处理中才可以取消投诉 + if (!appeal.getAppealResult().equals(1)) { + return ResponseData.error("投诉已处理,不可取消"); + } + //48小时内才可以取消投诉 +// if (DateUtil.offsetHour(appeal.getCreateTime(), 48).getTime() < System.currentTimeMillis()) { +// return ResponseData.error("48小时内方可取消投诉"); +// } + appeal.setDelFlag(PublicCommon.删除); + appealService.updateById(appeal); + + this.lambdaUpdate().set(Order::getAppealStatus, PublicCommon.Appeal.无申诉) + .set(Order::getAppealUserType, null) + .eq(Order::getId, appeal.getOrderId()).update(); + //发送消息 + orderMessageService.addOrderMessage(new UserVo(appeal.getPassiveAppealUserType(), appeal.getPassiveAppealUserId()), order.getId(), order.getOrderNo(), PublicCommon.Order.订单, OrderMessageEnums.CANCEL_APPEAL); + + + //记录订单操作日志 + orderOperatorHistoryService.insertOrderOperatorHistory(OrderOperatorHistory.addAppHistory(order.getId(), "取消申诉", "取消申诉", userVo)); + + + return ResponseData.success(); + } + + @Autowired + private StringRedisTemplate redisTemplate; + + @Override + public ResponseData getLakalaPaySuccess(LakalaPaySuccessReq req) { + + return ResponseData.success(redisTemplate.hasKey(req.getOutOrderNo())); + } + + @Override + public ResponseData sampleImagesAddendum(SampleImagesUploadReq req, UserVo userVo) { + + //订单 + Order order = this.getById(req.getOrderId()); + + //判断订单状态 + if (ObjectUtil.notEqual(OrderStatusEnums.to_be_evaluated.getCode(), order.getStatus())) { + return ResponseData.error("订单状态错误"); + } + + //修改订单 + this.lambdaUpdate().set(Order::getCoverImage, req.getCoverImage()).set(Order::getImages, req.getImages()) + .eq(Order::getId, req.getOrderId()).update(); + + List orderPanoramaList = req.getOrderPanoramaList().stream().filter(s -> ObjectUtil.isAllNotEmpty(s.getPanorama(), s.getPanoramaImage())).collect(Collectors.toList()); + + if (orderPanoramaList.isEmpty() && ObjectUtil.isEmpty(req.getImages())) { + return ResponseData.error("请上传大图"); + } + + //清除原有的数据 + orderPanoramaService.remove(new QueryWrapper().lambda().eq(OrderPanorama::getOrderId, req.getOrderId())); + + //关联添加 3D图 + req.getOrderPanoramaList().stream().forEach(s -> s.setOrderId(req.getOrderId())); + orderPanoramaService.saveBatch(req.getOrderPanoramaList()); + + + //发送消息 + orderMessageService.addOrderMessage(new UserVo(UserEnums.customer.getCode(), order.getCustomerId()), order.getId(), order.getOrderNo(), PublicCommon.Order.订单, OrderMessageEnums.UPLOAD_LARGE_IMAGES); + + //查询3D图 + List worksPanoramas = req.getOrderPanoramaList().stream().map(s -> new WorksPanorama(s)).collect(Collectors.toList()); + + Works works = worksService.getOne(new QueryWrapper().lambda().eq(Works::getOrderId, order.getId())); + works.setCoverImage(req.getCoverImage()); + works.setImages(req.getImages()); + worksService.updateById(works); + + //清除原有的数据 + worksPanoramaService.remove(new QueryWrapper().lambda().eq(WorksPanorama::getWorksId, works.getId())); + + //关联3D图 + if (worksPanoramas != null && !worksPanoramas.isEmpty()) { + + List saveList = worksPanoramas.stream().filter(s -> ObjectUtil.isAllNotEmpty(s.getPanorama(), s.getPanoramaImage())).collect(Collectors.toList()); + + if (saveList.size() > 0) { + saveList.stream().forEach(w -> w.setWorksId(works.getId())); + worksPanoramaService.saveBatch(saveList); + } + } + + //记录订单操作日志 + orderOperatorHistoryService.insertOrderOperatorHistory(OrderOperatorHistory.addAppHistory(order.getId(), "追加大图", "追加大图", userVo)); + + return ResponseData.success(); + } + + @Autowired + private WorksPanoramaService worksPanoramaService; + + @Autowired + private OrderChangeRecordService orderChangeRecordService; + + @Override + public ResponseData orderAdjustPricePayCount(OrderAdjustPricePayCountReq req, UserVo userVo) { + //订单 + Order order = this.getById(req.getOrderId()); + + if (order.getAmount().compareTo(req.getAmount()) >= 0) { + return ResponseData.success(new PayVo()); + } + + //计算调价后还需支付定金金额 + PayVo payVo = depositAmountCount(order, req.getAmount()); + + return ResponseData.success(payVo); + } + + @Override + public ResponseData orderAdjustPrice(OrderAdjustPriceReq req, UserVo userVo) { + + //订单 + Order order = this.getById(req.getOrderId()); + + //判断订单状态 + if (ObjectUtil.notEqual(OrderStatusEnums.ongoing.getCode(), order.getStatus())) { + return ResponseData.error("订单状态错误"); + } + + //判断是否调价 + if (ObjectUtil.equal(order.getChangeStatus(), PublicCommon.OrderChange.待确认)) { + return ResponseData.error("订单已调价 请先确认!"); + } + + //判断是否申诉过 + if (ObjectUtil.equal(order.getAppealStatus(), PublicCommon.Appeal.申诉中)) { + return ResponseData.error("订单已申诉!"); + } + + /*if(order.getAmount().compareTo(req.getAmount()) == 0){ + return ResponseData.error("新价不能和原价一样!"); + }*/ + + if (ObjectUtil.equal(UserEnums.customer.getCode(), userVo.getUserType())) { + //设计师调价 + //调价分为两种情况 1 调价后价格大于原价格(先支付) 2 调价后价格小于等于原价格(对方确认后:需要退款) + if (order.getAmount().compareTo(req.getAmount()) >= 0) { + return orderAdjustPriceNoPay(order, req, userVo); + } else { + return orderAdjustPricePay(order, req, userVo); + } + } else { + //表现师调价 设计师确认后 需要支付或退款 + return orderAdjustPriceNoPay(order, req, userVo); + } + + + } + + /** + * 调价后价格小于等于原价格(对方确认后:需要退款) + * + * @param order + * @param req + * @param userVo + * @return + */ + private ResponseData orderAdjustPriceNoPay(Order order, OrderAdjustPriceReq req, UserVo userVo) { + + //计算调价后还需支付定金金额 + PayVo payVo = depositAmountCount(order, req.getAmount()); + + //生成调价记录 + OrderChangeRecord record = new OrderChangeRecord(); + record.setChangeAmount(req.getAmount()) + .setOriginAmount(order.getAmount()) + .setRemark(req.getRemark()) + .setOrderId(req.getOrderId()) + .setUserType(userVo.getUserType()) + .setPayPrice(payVo.getPrice()) + .setGivePrice(payVo.getMaxGivePrice()) + .setUserId(userVo.getUserId()); + orderChangeRecordService.save(record); + + //修改 + this.lambdaUpdate().set(Order::getChangeStatus, PublicCommon.OrderChange.待确认) + .set(Order::getChangeAmount, req.getAmount()) + .set(Order::getChangeRemark, req.getRemark()) + .set(Order::getChangeUserType, userVo.getUserType()) + .eq(Order::getId, req.getOrderId()).update(); + + //发送消息 + Long userId = userVo.getUserType().equals(UserEnums.store.getCode()) ? order.getCustomerId() : order.getStoreId(); + Integer userType = userVo.getUserType().equals(UserEnums.store.getCode()) ? UserEnums.customer.getCode() : UserEnums.store.getCode(); + orderMessageService.addOrderMessage(new UserVo(userType, userId), order.getId(), order.getOrderNo(), PublicCommon.Order.订单, OrderMessageEnums.ADJUST_PRICE); + + //记录订单操作日志 + orderOperatorHistoryService.insertOrderOperatorHistory(OrderOperatorHistory.addAppHistory(order.getId(), "申请调价", "申请调价", userVo)); + + + return ResponseData.success(); + } + + + /** + * 调价后价格大于原价格(对方确认后:需要追加首付款) + * @param order + * @param req + * @param userVo + * @return + */ + private ResponseData orderAdjustPricePay(Order order, OrderAdjustPriceReq req, UserVo userVo) { + + //计算调价后还需支付定金金额 + PayVo payVo = depositAmountCount(order, req.getAmount()); + + //生成调价记录 + OrderChangeRecord record = new OrderChangeRecord(); + record.setChangeAmount(req.getAmount()) + .setOriginAmount(order.getAmount()) + .setRemark(req.getRemark()) + .setOrderId(req.getOrderId()) + .setPayOrderNo(generateOrderNo(4)) + .setPayPrice(payVo.getPrice()) + .setGivePrice(payVo.getMaxGivePrice()) + .setUserType(userVo.getUserType()) + .setUserId(userVo.getUserId()); + orderChangeRecordService.save(record); + + //支付 + ResponseData responseData = payUtil.pay(userVo, order.getId(), req.getPayType(), record.getPayPrice().subtract(record.getGivePrice()), record.getGivePrice(), record.getPayOrderNo(), PaySourceEnums.adjust_price_pay, WalletDetailEnums.ADJUST_PRICE_PAY); + + if (responseData.getSuccess() || responseData.getCode().equals(210)) { + //余额支付 + if (req.getPayType().equals(PayEnums.balance.getCode()) || req.getPayType().equals(PayEnums.apple.getCode())) { + record.setPayType(req.getPayType()); + afterAdjustPricePay(record); + } + } + return responseData; + } + + + /** + * 计算金额 + * + * @return + */ + private PayVo depositAmountCount(Order order, BigDecimal adjustAmount) { + + PayVo payVo = new PayVo(); + + //还需要支付定金 + BigDecimal depositPrice = depositChangeAmount(order.getAmount(), adjustAmount,order.getFirstPrice(),order.getFirstStatus()); + payVo.setPrice(depositPrice); + + //查询赠送金额最大支付比例 + BigDecimal maxGivePrice = businessUtil.userMaxGivePrice(new UserVo(UserEnums.customer.getCode(), order.getCustomerId()), depositPrice); + + //赠送金额支付最大值 + payVo.setMaxGivePrice(maxGivePrice); + + return payVo; + } + + /** + * 获取条件之后的定金差额 + * + * @param originAmount + * @param changeAmount + * @return + */ + private BigDecimal depositChangeAmount(BigDecimal originAmount, BigDecimal changeAmount, BigDecimal firstPrice,Integer firstStatus) { + //超出金额 + //BigDecimal amount = originAmount.subtract(changeAmount == null ? originAmount : changeAmount); + + //查询定金支付比例 + BigDecimal ratio = firstPayRatio(); + + if (ObjectUtil.isNull(changeAmount)){ + //还需要支付定金/需要退还定金 + return originAmount.multiply(ratio).setScale(2, RoundingMode.HALF_UP); + } + + //还需要支付定金/需要退还定金 + BigDecimal depositPrice = changeAmount.multiply(ratio).setScale(2, RoundingMode.HALF_UP); + + if(firstStatus == 2){ + //减去首付 + return depositPrice.subtract(firstPrice); + } + return depositPrice; + } + + /** + * 获取条件之后的抵用金差额 + * + * @param originAmount + * @param changeAmount + * @return + */ + private BigDecimal depositChangeGiveAmount(BigDecimal originAmount, BigDecimal changeAmount, BigDecimal firstOriginGiveAmount) { + //超出金额 + BigDecimal amount = originAmount.subtract(changeAmount == null ? originAmount : changeAmount); + + //查询定金支付比例 + BigDecimal ratio = firstPayRatio(); + + //还需要支付定金/需要退还定金 + BigDecimal depositPrice = amount.multiply(ratio).setScale(2, RoundingMode.HALF_UP); + return firstOriginGiveAmount.multiply(depositPrice.divide(originAmount, 2, BigDecimal.ROUND_HALF_UP)); + } + + /** + * 调价定金支付(超出原有价格) + * + * @param record + */ + private void afterAdjustPricePay(OrderChangeRecord record) { + + //支付后修改 + boolean update = orderChangeRecordService.lambdaUpdate().set(OrderChangeRecord::getPayStatus, PublicCommon.Pay.已支付) + .set(OrderChangeRecord::getPayType, record.getPayType()) + .eq(OrderChangeRecord::getPayStatus, PublicCommon.Pay.未支付) + .eq(OrderChangeRecord::getId, record.getId()) + .update(); + if (update) { + + Order order = this.getById(record.getOrderId()); + + //修改 + boolean update1 = this.lambdaUpdate().set(Order::getChangeStatus, PublicCommon.OrderChange.待确认) + .set(Order::getChangeAmount, record.getChangeAmount()) + .set(Order::getChangeRemark, record.getRemark()) + .set(Order::getChangeUserType, record.getUserType()) + .eq(Order::getId, record.getOrderId()).update(); + + //发送消息 + Long userId = record.getUserType().equals(UserEnums.store.getCode()) ? order.getCustomerId() : order.getStoreId(); + Integer userType = record.getUserType().equals(UserEnums.store.getCode()) ? UserEnums.customer.getCode() : UserEnums.store.getCode(); + orderMessageService.addOrderMessage(new UserVo(userType, userId), order.getId(), order.getOrderNo(), PublicCommon.Order.订单, OrderMessageEnums.ADJUST_PRICE); + + + //订单支付金额 + orderPriceRecordService.addOrderPriceRecord(OrderPriceEnums.change, order.getId(), record.getPayPrice()); + + //记录订单操作日志 + orderOperatorHistoryService.insertOrderOperatorHistory(OrderOperatorHistory.addAppHistory(order.getId(), "申请调价", "申请调价,原价:" + order.getAmount() + "; 申请调价后金额:" + record.getChangeAmount(), new UserVo(record.getUserType(), record.getUserId()))); + + + } + } + + @Override + public ResponseData orderAdjustPriceConfirm(OrderAdjustPriceConfirmReq req, UserVo userVo) { + + //订单id + Long orderId = req.getId(); + + //订单 + Order order = this.getById(orderId); + + //判断订单状态 + if (ObjectUtil.notEqual(OrderStatusEnums.ongoing.getCode(), order.getStatus())) { + return ResponseData.error("订单状态错误"); + } + + //判断调价状态 + if (ObjectUtil.notEqual(order.getChangeStatus(), PublicCommon.OrderChange.待确认)) { + return ResponseData.error("调价状态错误!"); + } + + //调价后的价格 小于原价 + if (order.getChangeAmount().compareTo(order.getAmount()) < 0) { + //小于原价退款(退还部分定金到余额) + orderAdjustPriceConfirmRefund(order, userVo); + + } else if (order.getChangeAmount().compareTo(order.getAmount()) > 0) { + //高于原价 + return orderAdjustPriceConfirmPay(order, req, userVo); + } else { + //等于原价 不需要支付定金 + //修改订单 + boolean update = this.lambdaUpdate().set(Order::getChangeStatus, PublicCommon.OrderChange.已确认) + .set(Order::getAmount, order.getChangeAmount()) + .eq(Order::getId, order.getId()).update(); + + if (update) { + //发送消息 + Long userId = userVo.getUserType().equals(UserEnums.store.getCode()) ? order.getCustomerId() : order.getStoreId(); + Integer userType = userVo.getUserType().equals(UserEnums.store.getCode()) ? UserEnums.customer.getCode() : UserEnums.store.getCode(); + orderMessageService.addOrderMessage(new UserVo(userType, userId), order.getId(), order.getOrderNo(), PublicCommon.Order.订单, OrderMessageEnums.ADJUST_PRICE_CONFIRM); + + //记录订单操作日志 + orderOperatorHistoryService.insertOrderOperatorHistory(OrderOperatorHistory.addAppHistory(order.getId(), "同意调价", "同意调价,调价后金额:" + order.getChangeAmount(), userVo)); + + } + } + return ResponseData.success(); + } + + /** + * 调价确认(设计师申请,表现师确认) 退款 + */ + private void orderAdjustPriceConfirmRefund(Order order, UserVo userVo) { + + //修改调价记录状态 + boolean update = orderChangeRecordService.lambdaUpdate().set(OrderChangeRecord::getStatus, PublicCommon.OrderChange.已确认) + .eq(OrderChangeRecord::getStatus, PublicCommon.OrderChange.待确认) + .eq(OrderChangeRecord::getOrderId, order.getId()).update(); + + if (update) { + + //计算退还定金 负数转为正数 + BigDecimal refundPrice = depositChangeAmount(order.getAmount(), order.getChangeAmount(),order.getFirstPrice(),order.getFirstStatus()).negate(); + //计算退还抵用金 + BigDecimal refundGivePrice = order.getFirstGivePrice().multiply(refundPrice.divide(order.getFirstPrice(), 8, RoundingMode.HALF_UP)).setScale(2, RoundingMode.HALF_UP); + + //退还定金到余额 + walletRecordService.updateBalance(new UserVo(UserEnums.customer.getCode(), order.getCustomerId()), WalletDetailEnums.DEPOSIT_REFUND, order.getId(), refundPrice.subtract(refundGivePrice), PublicCommon.Wallet.可提现); + //退还抵用金到余额 + giveWalletRecordService.updateGiveBalance(new UserVo(UserEnums.customer.getCode(), order.getCustomerId()), WalletDetailEnums.DEPOSIT_REFUND, order.getId(), refundGivePrice, PublicCommon.Wallet.可提现); + + + //修改订单 + LambdaUpdateChainWrapper updateChainWrapper = this.lambdaUpdate().set(Order::getChangeStatus, PublicCommon.OrderChange.已确认) + .set(Order::getAmount, order.getChangeAmount()) + .eq(Order::getId, order.getId()); + + BigDecimal firstPrice = order.getFirstPrice().subtract(refundPrice); + updateChainWrapper.set(Order::getFirstPrice, firstPrice); + + BigDecimal fistGivePrice = order.getFirstGivePrice().subtract(refundGivePrice); + updateChainWrapper.set(Order::getFirstGivePrice, fistGivePrice); + updateChainWrapper.update(); + + //订单支付金额 + orderPriceRecordService.addOrderPriceRecord(OrderPriceEnums.change, order.getId(), refundPrice); + + //发送消息 + Long userId = userVo.getUserType().equals(UserEnums.store.getCode()) ? order.getCustomerId() : order.getStoreId(); + Integer userType = userVo.getUserType().equals(UserEnums.store.getCode()) ? UserEnums.customer.getCode() : UserEnums.store.getCode(); + orderMessageService.addOrderMessage(new UserVo(userType, userId), order.getId(), order.getOrderNo(), PublicCommon.Order.订单, OrderMessageEnums.ADJUST_PRICE_CONFIRM); + + //记录订单操作日志 + orderOperatorHistoryService.insertOrderOperatorHistory(OrderOperatorHistory.addAppHistory(order.getId(), "同意调价", "同意调价,调价后金额:" + order.getChangeAmount(), userVo)); + + + } + } + + /** + * 调价确认(表现师申请,设计师确认) 支付 + */ + private ResponseData orderAdjustPriceConfirmPay(Order order, OrderAdjustPriceConfirmReq req, UserVo userVo) { + + + OrderChangeRecord orderChangeRecord = orderChangeRecordService.getOne(new QueryWrapper().lambda().eq(OrderChangeRecord::getOrderId, req.getId()) + .eq(OrderChangeRecord::getStatus, PublicCommon.OrderChange.待确认).eq(OrderChangeRecord::getDelFlag, PublicCommon.启用) + .orderByDesc(BaseEntity::getCreateTime).last(" limit 1")); + if (orderChangeRecord == null) { + throw new ServiceException("调价记录不存在"); + } + + //表现师发起,设计师确认时需要支付 + if (orderChangeRecord.getUserType().equals(UserEnums.store.getCode())) { + //调价支付订单号 + String payOrderNo = generateOrderNo(4); + + /*//差值(超出原价的金额) + BigDecimal excessAmount = order.getChangeAmount().subtract(order.getAmount()); + //定金比例 + BigDecimal ratio = firstPayRatio();*/ + + //需要支付定金金额 + BigDecimal payPrice = depositChangeAmount(order.getOriginAmount(), order.getChangeAmount(), order.getFirstPrice(), order.getFirstStatus()); + + //最大使用赠送金额 + BigDecimal maxGivePrice = businessUtil.userMaxGivePrice(userVo, payPrice); + + //修改调价记录状态 + boolean update = orderChangeRecordService.lambdaUpdate() + .set(OrderChangeRecord::getPayOrderNo, payOrderNo) + .eq(OrderChangeRecord::getStatus, PublicCommon.OrderChange.待确认) + .eq(OrderChangeRecord::getOrderId, order.getId()).update(); + + //支付 + ResponseData responseData = payUtil.pay(userVo, order.getId(), req.getPayType(), payPrice.subtract(maxGivePrice), maxGivePrice, payOrderNo, PaySourceEnums.store_adjust_price_pay, WalletDetailEnums.ADJUST_PRICE_PAY); + + if (responseData.getSuccess() || responseData.getCode().equals(210)) { + //余额支付 + if (req.getPayType().equals(PayEnums.balance.getCode()) || req.getPayType().equals(PayEnums.apple.getCode())) { + afterAdjustPriceConfirmPay(orderChangeRecordService.getById(orderChangeRecord.getId())); + } + } + + return responseData; + } else { + afterAdjustPriceConfirmPay(orderChangeRecordService.getById(orderChangeRecord.getId())); + } + return ResponseData.success(); + } + + private void afterAdjustPriceConfirmPay(OrderChangeRecord record) { + + //支付后修改 + boolean update = orderChangeRecordService.lambdaUpdate().set(OrderChangeRecord::getPayStatus, PublicCommon.Pay.已支付) + .set(OrderChangeRecord::getStatus, PublicCommon.OrderChange.已确认) + .eq(OrderChangeRecord::getStatus, PublicCommon.OrderChange.待确认) + .eq(OrderChangeRecord::getId, record.getId()) + .update(); + + if (update) { + + Order order = this.getById(record.getOrderId()); + BigDecimal newPayPrice = order.getFirstPrice().add(record.getPayPrice()); + BigDecimal newGivePrice = order.getFirstGivePrice().add(record.getGivePrice()); + + boolean update1 = this.lambdaUpdate().set(Order::getChangeStatus, PublicCommon.OrderChange.已确认) + .set(Order::getAmount, record.getChangeAmount()) + .set(Order::getFirstPrice, newPayPrice) + .set(Order::getFirstGivePrice, newGivePrice) +// .setSql("first_price = first_price + " + record.getPayPrice()) +// .setSql("first_give_price = first_give_price + " + record.getGivePrice()) + .eq(Order::getId, record.getOrderId()).update(); + + if (update1) { + + if (ObjectUtil.equal(UserEnums.store.getCode(), record.getUserType())) { + //订单支付金额 + orderPriceRecordService.addOrderPriceRecord(OrderPriceEnums.change, record.getOrderId(), record.getPayPrice()); + } + + //发送消息 + orderMessageService.addOrderMessage(new UserVo(record.getUserType(), record.getUserId()), record.getOrderId(), "", PublicCommon.Order.订单, OrderMessageEnums.ADJUST_PRICE_CONFIRM); + + //记录订单操作日志 + orderOperatorHistoryService.insertOrderOperatorHistory(OrderOperatorHistory.addAppHistory(record.getOrderId(), "同意调价", "同意调价,调价后金额:" + record.getChangeAmount(), new UserVo(record.getUserType(), record.getUserId()))); + + } + } + } + + @Override + public ResponseData orderAdjustPriceRefuse(RefuseReq req, UserVo userVo) { + + Long orderId = req.getId(); + //订单 + Order order = this.getById(orderId); + + //判断订单状态 + if (ObjectUtil.notEqual(OrderStatusEnums.ongoing.getCode(), order.getStatus())) { + return ResponseData.error("订单状态错误"); + } + + //判断调价状态 + if (ObjectUtil.notEqual(order.getChangeStatus(), PublicCommon.OrderChange.待确认)) { + return ResponseData.error("调价状态错误!"); + } + + //修改调价记录状态 + boolean update = orderChangeRecordService.lambdaUpdate().set(OrderChangeRecord::getStatus, PublicCommon.OrderChange.拒绝) + .set(OrderChangeRecord::getReason, req.getReason()) + .eq(OrderChangeRecord::getStatus, PublicCommon.OrderChange.待确认) + .eq(OrderChangeRecord::getOrderId, orderId).update(); + + if (update) { + //修改订单 + LambdaUpdateChainWrapper updateChainWrapper = this.lambdaUpdate().set(Order::getChangeStatus, PublicCommon.OrderChange.拒绝) + .eq(Order::getId, orderId); + + //调价价格大于原价 拒绝退还已支付定金到余额 + if (ObjectUtil.equal(UserEnums.customer.getCode(), order.getChangeUserType()) && order.getChangeAmount().compareTo(order.getAmount()) > 0) { + + OrderChangeRecord orderChangeRecord = orderChangeRecordService.getOne(new QueryWrapper().lambda() + .eq(OrderChangeRecord::getDelFlag, PublicCommon.启用) + .eq(OrderChangeRecord::getOrderId, orderId) + .orderByDesc(BaseEntity::getCreateTime) + .last("limit 1") + ); + + + walletRecordService.updateBalance(new UserVo(UserEnums.customer.getCode(), order.getCustomerId()), WalletDetailEnums.DEPOSIT_REFUND, order.getId(), orderChangeRecord.getPayPrice().subtract(orderChangeRecord.getGivePrice()), PublicCommon.Wallet.可提现); + giveWalletRecordService.updateGiveBalance(new UserVo(UserEnums.customer.getCode(), order.getCustomerId()), WalletDetailEnums.DEPOSIT_REFUND, order.getId(), orderChangeRecord.getGivePrice(), PublicCommon.Wallet.可提现); + + + //订单支付金额 + orderPriceRecordService.addOrderPriceRecord(OrderPriceEnums.change, order.getId(), orderChangeRecord.getPayPrice().negate()); + } + + updateChainWrapper.update(); + + + //发送消息 + Long userId = userVo.getUserType().equals(UserEnums.store.getCode()) ? order.getCustomerId() : order.getStoreId(); + Integer userType = userVo.getUserType().equals(UserEnums.store.getCode()) ? UserEnums.customer.getCode() : UserEnums.store.getCode(); + orderMessageService.addOrderMessage(new UserVo(userType, userId), order.getId(), order.getOrderNo(), PublicCommon.Order.订单, OrderMessageEnums.ADJUST_PRICE_REFUSE); + + //记录订单操作日志 + orderOperatorHistoryService.insertOrderOperatorHistory(OrderOperatorHistory.addAppHistory(order.getId(), "拒绝调价", "拒绝调价", userVo)); + + + } + + + return ResponseData.success(); + } + + @Autowired + private GiveWalletRecordService giveWalletRecordService; + + @Autowired + private OrderExtensionRecordService orderExtensionRecordService; + + @Override + public ResponseData orderExtension(OrderExtensionReq req, UserVo userVo) { + //订单 + Order order = this.getById(req.getOrderId()); + + //判断订单状态 + if (ObjectUtil.notEqual(OrderStatusEnums.ongoing.getCode(), order.getStatus())) { + return ResponseData.error("订单状态错误"); + } + + //判断是否延期 + if (ObjectUtil.equal(order.getChangeStatus(), PublicCommon.Extension.待确认)) { + return ResponseData.error("订单已延期 请先确认!"); + } + + //判断延期时间 + if (req.getExtensionTime().getTime() < order.getDeliverTime().getTime()) { + return ResponseData.error(String.format("延期时间不能小于%s", DateUtil.format(order.getDeliverTime(), "yyyy-MM-dd HH:mm"))); + } + + + //生成延期记录 + OrderExtensionRecord record = new OrderExtensionRecord(); + record.setChangeTime(req.getExtensionTime()) + .setOriginTime(order.getDeliverTime()) + .setRemark(req.getRemark()) + .setOrderId(req.getOrderId()) + .setUserType(userVo.getUserType()) + .setUserId(userVo.getUserId()); + orderExtensionRecordService.save(record); + + //修改 + this.lambdaUpdate().set(Order::getExtensionStatus, PublicCommon.Extension.待确认) + .set(Order::getExtensionDeliverTime, req.getExtensionTime()) + .set(Order::getExtensionRemark, req.getRemark()) + .set(Order::getExtensionUserType, userVo.getUserType()) + .eq(Order::getId, req.getOrderId()).update(); + //发送消息 + orderMessageService.addOrderMessage(new UserVo(UserEnums.customer.getCode(), order.getCustomerId()), order.getId(), order.getOrderNo(), PublicCommon.Order.订单, OrderMessageEnums.EXTENSION); + + //记录订单操作日志 + orderOperatorHistoryService.insertOrderOperatorHistory(OrderOperatorHistory.addAppHistory(order.getId(), "订单申请延期", "订单申请延期,延期至:" + DateUtil.formatDateTime(req.getExtensionTime()), userVo)); + + + return ResponseData.success(); + } + + @Override + public ResponseData orderExtensionCancel(Long orderId) { + + //延期信息 + OrderExtensionRecord orderExtensionRecord = orderExtensionRecordService.getOne(new QueryWrapper().lambda() + .eq(OrderExtensionRecord::getDelFlag, PublicCommon.启用) + .eq(OrderExtensionRecord::getOrderId, orderId) + .eq(OrderExtensionRecord::getStatus, PublicCommon.OrderChange.待确认) + .orderByDesc(BaseEntity::getCreateTime) + .last("LIMIT 1") + ); + + //判断延期 设计师是否已操作 + if (orderExtensionRecord == null || ObjectUtil.notEqual(orderExtensionRecord.getStatus(), PublicCommon.Extension.待确认)) { + return ResponseData.error("订单已延期 请不要重复操作!"); + } + + boolean update = orderExtensionRecordService.lambdaUpdate().set(OrderExtensionRecord::getDelFlag, PublicCommon.删除) + .eq(OrderExtensionRecord::getId, orderExtensionRecord.getId()) + .update(); + if (update) { + //同步修改订单中延期信息 + this.lambdaUpdate().set(Order::getExtensionStatus, PublicCommon.Extension.取消) + .eq(Order::getId, orderExtensionRecord.getOrderId()).update(); + + //记录订单操作日志 + orderOperatorHistoryService.insertOrderOperatorHistory(OrderOperatorHistory.addAppHistory(orderExtensionRecord.getOrderId(), "订单延期取消", "订单延期取消", new UserVo(orderExtensionRecord.getUserType(), orderExtensionRecord.getUserId()))); + + } + + return ResponseData.success(); + } + + @Override + public ResponseData orderExtensionConfirm(Long orderId, UserVo userVo) { + //订单 + Order order = this.getById(orderId); + + //判断订单状态 + if (ObjectUtil.notEqual(OrderStatusEnums.ongoing.getCode(), order.getStatus())) { + return ResponseData.error("订单状态错误"); + } + + //判断延期状态 + if (ObjectUtil.notEqual(order.getExtensionStatus(), PublicCommon.OrderChange.待确认)) { + return ResponseData.error("延期状态错误!"); + } + + //修改延期记录状态 + orderExtensionRecordService.lambdaUpdate().set(OrderExtensionRecord::getStatus, PublicCommon.Extension.已确认) + .eq(OrderExtensionRecord::getStatus, PublicCommon.OrderChange.待确认) + .eq(OrderExtensionRecord::getOrderId, orderId).update(); + + //修改订单 + this.lambdaUpdate().set(Order::getExtensionStatus, PublicCommon.Extension.已确认) + .set(Order::getDeliverTime, order.getExtensionDeliverTime()) + .eq(Order::getId, orderId).update(); + + //发送消息 + orderMessageService.addOrderMessage(new UserVo(UserEnums.store.getCode(), order.getStoreId()), order.getId(), order.getOrderNo(), PublicCommon.Order.订单, OrderMessageEnums.EXTENSION_CONFIRM); + + + //记录订单操作日志 + orderOperatorHistoryService.insertOrderOperatorHistory(OrderOperatorHistory.addAppHistory(order.getId(), "同意订单延期", "同意订单延期", userVo)); + + + return ResponseData.success(); + } + + @Override + public ResponseData orderExtensionRefuse(RefuseReq req, UserVo userVo) { + + Long orderId = req.getId(); + //订单 + Order order = this.getById(orderId); + + //判断订单状态 + if (ObjectUtil.notEqual(OrderStatusEnums.ongoing.getCode(), order.getStatus())) { + return ResponseData.error("订单状态错误"); + } + + //判断延期状态 + if (ObjectUtil.notEqual(order.getExtensionStatus(), PublicCommon.Extension.待确认)) { + return ResponseData.error("延期状态错误!"); + } + + //修改延期记录状态 + orderExtensionRecordService.lambdaUpdate().set(OrderExtensionRecord::getStatus, PublicCommon.Extension.拒绝) + .set(OrderExtensionRecord::getReason, req.getReason()) + .eq(OrderExtensionRecord::getStatus, PublicCommon.Extension.待确认) + .eq(OrderExtensionRecord::getOrderId, orderId).update(); + + //修改订单 + this.lambdaUpdate().set(Order::getExtensionStatus, PublicCommon.Extension.拒绝) + .eq(Order::getId, orderId).update(); + + //发送消息 + orderMessageService.addOrderMessage(new UserVo(UserEnums.store.getCode(), order.getStoreId()), order.getId(), order.getOrderNo(), PublicCommon.Order.订单, OrderMessageEnums.EXTENSION_REFUSE); + + + //记录订单操作日志 + orderOperatorHistoryService.insertOrderOperatorHistory(OrderOperatorHistory.addAppHistory(order.getId(), "拒绝订单延期", "拒绝订单延期", userVo)); + + + return ResponseData.success(); + } + + @Autowired + private OrderPanoramaService orderPanoramaService; + + @Override + public ResponseData sampleImagesUpload(SampleImagesUploadReq req, UserVo userVo) { + + //订单 + Order order = this.getById(req.getOrderId()); + + //判断订单状态 + if (ObjectUtil.notEqual(OrderStatusEnums.pending_drawings.getCode(), order.getStatus())) { + return ResponseData.error("订单状态错误"); + } + + + List orderPanoramaList = req.getOrderPanoramaList().stream().filter(s -> ObjectUtil.isAllNotEmpty(s.getPanorama(), s.getPanoramaImage())).collect(Collectors.toList()); + + if (orderPanoramaList.isEmpty() && ObjectUtil.isEmpty(req.getImages())) { + return ResponseData.error("请上传大图"); + } + + //关联添加 3D图 + req.getOrderPanoramaList().stream().forEach(s -> s.setOrderId(req.getOrderId())); + orderPanoramaService.saveBatch(req.getOrderPanoramaList()); + + //修改订单 + boolean update = this.lambdaUpdate().set(Order::getCoverImage, req.getCoverImage()).set(Order::getImages, req.getImages()) + .set(Order::getStatus, OrderStatusEnums.to_be_evaluated.getCode()) + .set(Order::getConfirmDate, new Date()) + .eq(Order::getId, req.getOrderId()).update(); + + if (update) { + //发送消息 + orderMessageService.addOrderMessage(new UserVo(UserEnums.customer.getCode(), order.getCustomerId()), order.getId(), order.getOrderNo(), PublicCommon.Order.订单, OrderMessageEnums.UPLOAD_LARGE_IMAGES); + } + + //生成表现师作品 + WorksReleaseReq worksReleaseReq = new WorksReleaseReq() + .setOrderId(order.getId()) + .setWorksTypeId(order.getWorksTypeId()) + .setCoverImage(req.getCoverImage()) + .setImages(req.getImages()) + .setTitle(order.getTitle()) + .setPrice(order.getAmount()) + .setCustomerId(order.getCustomerId()) + .setSource(2);//来源 1 手动创建 2 订单同步" + + //查询3D图 + List panoramaList = req.getOrderPanoramaList(); + + List worksPanoramas = panoramaList.stream().map(s -> new WorksPanorama(s)).collect(Collectors.toList()); + worksReleaseReq.setWorksPanoramaList(worksPanoramas); + + worksService.worksRelease(worksReleaseReq, new UserVo(UserEnums.store.getCode(), order.getStoreId())); + + //记录订单操作日志 + orderOperatorHistoryService.insertOrderOperatorHistory(OrderOperatorHistory.addAppHistory(order.getId(), "上传大图", "上传大图", userVo)); + + + return ResponseData.success(); + } + + @Override + public ResponseData receiveDrawingsAndPay(ReceiveDrawingsAndPayReq req, UserVo userVo) { + + //订单 + Order order = this.getById(req.getOrderId()); + + //判断订单状态 + if (ObjectUtil.notEqual(OrderStatusEnums.ongoing.getCode(), order.getStatus())) { + return ResponseData.error("订单状态错误"); + } + + //判断是否申诉 + if (ObjectUtil.equal(order.getAppealStatus(), PublicCommon.Appeal.申诉中)) { + return ResponseData.error("订单申诉中! 请联系平台关闭申诉"); + } + + //判断是否延期 + if (ObjectUtil.equal(order.getExtensionStatus(), PublicCommon.Extension.待确认)) { + String msg = "订单延期中 请先确认!"; + if (ObjectUtil.equal(userVo.getUserType(), order.getExtensionUserType())) { + msg = "订单延期中 请等待对方确认!"; + } + return ResponseData.error(msg); + } + + //判断调价状态 + if (ObjectUtil.equal(order.getChangeStatus(), PublicCommon.OrderChange.待确认)) { + String msg = "订单调价中 请先确认!"; + if (ObjectUtil.equal(userVo.getUserType(), order.getChangeUserType())) { + msg = "订单调价中 请等待对方确认!"; + } + return ResponseData.error(msg); + } + + + //三方支付金额 + BigDecimal secondPayPrice = order.getAmount().subtract(order.getFirstPrice()); + + BigDecimal maxGivePrice = businessUtil.userMaxGivePrice(userVo, secondPayPrice); + + //余额支付 验证密码 + if (req.getPayType().equals(PayEnums.balance.getCode())) { + //支付密码验证 + Boolean isTrue = businessUtil.payPwdTrue(userVo, req.getPayPwd()); + if (!isTrue) { + return ResponseData.error(CoreExceptionEnum.PWD_ERROR); + } + + //判断余额 + BigDecimal userBalance = businessUtil.getUserBalance(userVo); + if (userBalance.compareTo(secondPayPrice.subtract(maxGivePrice)) == -1) { + return ResponseData.error(CoreExceptionEnum.BALANCE_INSUFFICIENT); + } + + } + + + //尾款支付单号 + String secondPayOrderNo = ""; + + //如果尾款支付单号 不为空 重新生成尾款支付单号 payOrderNo_次数 + if (StringUtils.isNotBlank(order.getSecondPayOrderNo())) { + + if (order.getSecondPayOrderNo().split("_").length > 1) { + secondPayOrderNo = order.getSecondPayOrderNo().split("_")[0] + "_" + (Integer.valueOf(order.getSecondPayOrderNo().split("_")[1]) + 1); + } else { + secondPayOrderNo = order.getSecondPayOrderNo().concat("_") + 1; + } + } else { + secondPayOrderNo = generateOrderNo(3); + } + + //修改订单 + this.lambdaUpdate() + .set(Order::getIsAgree, req.getIsAgree()) + .set(Order::getSecondPayType, req.getPayType()) + .set(Order::getSecondPayOrderNo, secondPayOrderNo) + .set(Order::getSecondTripartitePrice, secondPayPrice.subtract(maxGivePrice)) + .set(Order::getSecondGivePrice, maxGivePrice) + .eq(Order::getId, req.getOrderId()).update(); + + //支付 + ResponseData responseData = payUtil.pay(userVo, order.getId(), req.getPayType(), secondPayPrice.subtract(maxGivePrice), maxGivePrice, secondPayOrderNo, PaySourceEnums.order_second_pay, WalletDetailEnums.ORDER_PAY); + + if (responseData.getSuccess() || responseData.getCode().equals(210)) { + //余额支付 + if (req.getPayType().equals(PayEnums.balance.getCode()) || req.getPayType().equals(PayEnums.apple.getCode())) { + endPayAfter(order, req.getIsAgree() == 1 ? false : true); + } + } + + return responseData; + } + + @Autowired + private WalletRecordService walletRecordService; + + + @Autowired + private WorksService worksService; + + @Autowired + private RefereeUserService refereeUserService; + + @Autowired + private StoreMapper storeMapper; + + @Autowired + private CustomerMapper customerMapper; + + @Autowired + private IntegralRecordService integralRecordService; + + /** + * 收图支付后操作 + * + * @param order + */ + private void endPayAfter(Order order, boolean isAddWorks) { + + + //平台流水 + platformRecordService.addPlatformRecord(new UserVo(UserEnums.customer.getCode(), order.getCustomerId()), order.getId(), order.getAmount().subtract(order.getFirstPrice()), PlatformRecordEnums.ORDER_SECOND_PAY); + + //判断销售是否分佣 + RefereeUser refereeUser = refereeUserService.getOne(new QueryWrapper().lambda() + .eq(RefereeUser::getDelFlag, PublicCommon.启用) + .eq(RefereeUser::getUserId, order.getCustomerId()) + .eq(RefereeUser::getUserType, UserEnums.customer.getCode()) + .orderByDesc(BaseEntity::getCreateTime)); + + + //销售分佣 + BigDecimal commission = BigDecimal.ZERO; + + Order dbOrder = getById(order.getId()); + + //订单用来分佣的钱(实际支付金额=订单总金额-抵用金) + BigDecimal canCommission = order.getAmount().subtract(order.getFirstGivePrice()).subtract(dbOrder.getSecondGivePrice()); + + //邀请销售id + Long saleId = null; + + //销售邀请(销售分佣) + if (refereeUser != null && ObjectUtil.equal(UserEnums.sale.getCode(), refereeUser.getParentUserType())) { + + //获取销售分佣比例 + SysDictData commissionRatio = businessUtil.getDict(DictConstant.推广师分佣比例); + + //计算销售分佣金额 + commission = canCommission.multiply(new BigDecimal(commissionRatio.getDictValue())); + + saleId = refereeUser.getParentUserId(); + } + + //表现师分佣 + Store store = storeService.getById(order.getStoreId()); + BigDecimal storeCommissionRatio = store.getCommissionRatio(); + if (storeCommissionRatio == null) { + storeCommissionRatio = new BigDecimal(businessUtil.getDict(DictConstant.表现师分佣比例).getDictValue()); + } + + BigDecimal storeCommission = canCommission.multiply(storeCommissionRatio).setScale(2, RoundingMode.HALF_UP); + + + //修改状态 + this.lambdaUpdate().set(Order::getStatus, OrderStatusEnums.pending_drawings.getCode()) + .set(Order::getSecondStatus, PublicCommon.Pay.已支付) + .set(Order::getSecondPayTime, new Date()) + .set(saleId != null, Order::getSaleId, saleId) + .set(saleId != null, Order::getSaleAmount, commission) + .eq(Order::getId, order.getId()).update(); + + + //修改用户余额,添加余额记录 (表现师) + walletRecordService.updateBalance(new UserVo(UserEnums.store.getCode(), order.getStoreId()), WalletDetailEnums.ORDER_INCOME, order.getId(), storeCommission, PublicCommon.Wallet.可提现); + + if (refereeUser != null) { + + switch (UserEnums.getUserEnums(refereeUser.getParentUserType())) { + case sale: + //销售分佣 + walletRecordService.updateBalance(new UserVo(UserEnums.sale.getCode(), refereeUser.getParentUserId()), WalletDetailEnums.TEAM_COMMISSION, order.getId(), commission, PublicCommon.Wallet.可提现); + + //平台流水 + platformRecordService.addPlatformRecord(new UserVo(UserEnums.sale.getCode(), refereeUser.getParentUserId()), order.getId(), commission.negate(), PlatformRecordEnums.TEAM_COMMISSION); + + break; + default: + //赠送积分比例 + SysDictData dict = businessUtil.getDict(DictConstant.OrderDict.邀请用户下单获取积分与消费额的比例); + + BigDecimal ratio = BigDecimal.ZERO; + if (dict != null) { + ratio = new BigDecimal(dict.getDictValue()); + } + + //赠送积分 + BigDecimal integral = ratio.multiply(canCommission).setScale(2, BigDecimal.ROUND_HALF_UP); + + //积分记录 + integralRecordService.updateIntegral(new UserVo(refereeUser.getParentUserType(), refereeUser.getParentUserId()), + order.getId(), integral, IntegralDetailEnums.SHARE_TEAM_COMMISSION,null); + + break; + } + } + + //平台流水 + platformRecordService.addPlatformRecord(new UserVo(UserEnums.store.getCode(), order.getStoreId()), order.getId(), storeCommission.negate(), PlatformRecordEnums.STORE_ORDER_INCOME); + + //表现师累计收益 + storeMapper.addIncome(order.getStoreId(), storeCommission); + + //设计师累计消费额 + customerMapper.addConsumptionAmount(order.getCustomerId(), order.getAmount()); + + //订单支付金额 + orderPriceRecordService.addOrderPriceRecord(OrderPriceEnums.second_pay, order.getId(), order.getAmount().subtract(order.getFirstPrice())); + + //发送消息 + orderMessageService.addOrderMessage(new UserVo(UserEnums.store.getCode(), order.getStoreId()), order.getId(), order.getOrderNo(), PublicCommon.Order.订单, OrderMessageEnums.FINAL_PAY); + + //记录订单操作日志 + orderOperatorHistoryService.insertOrderOperatorHistory(OrderOperatorHistory.addAppHistory(order.getId(), "支付尾款", "支付尾款,尾款金额:" + order.getAmount().subtract(order.getFirstPrice()), new UserVo(UserEnums.customer.getCode(), order.getCustomerId()))); + + + } + + @Autowired + private CustomerService customerService; + + @Autowired + private StoreService storeService; + + + @Override + public ResponseData evaluate(EvaluateReq req, UserVo userVo) { + + //订单 + Order order = this.getById(req.getOrderId()); + + //判断订单状态 + if (ObjectUtil.notEqual(OrderStatusEnums.to_be_evaluated.getCode(), order.getStatus())) { + return ResponseData.error("订单状态错误"); + } + + //判断是否已经评价过 是否评价 1 没有 2 评价 + if (ObjectUtil.equal(UserEnums.customer.getCode(), userVo.getUserType()) ? + ObjectUtil.equal(2, order.getIsCustomerEvaluate()) : ObjectUtil.equal(2, order.getIsStoreEvaluate())) { + return ResponseData.error("订单已评价"); + } + + //添加评价记录 + OrderEvaluate evaluate = new OrderEvaluate(); + evaluate.setUserId(userVo.getUserId()) + .setUserType(userVo.getUserType()) + .setOrderId(req.getOrderId()) + .setEfficiencyStar(req.getEfficiencyStar()) + .setServiceStar(req.getServiceStar()) + .setQualityStar(req.getQualityStar()); + + //根据配置的权重--->计算总评分 + BigDecimal quality_ratio = new BigDecimal(businessUtil.getDict(DictConstant.质量评分占比).getDictValue()); + BigDecimal efficiency_ratio = new BigDecimal(businessUtil.getDict(DictConstant.效率评分占比).getDictValue()); + BigDecimal service_ratio = new BigDecimal(businessUtil.getDict(DictConstant.服务评分占比).getDictValue()); + + BigDecimal star = quality_ratio.multiply(evaluate.getQualityStar()) + .add(efficiency_ratio.multiply(evaluate.getEfficiencyStar())) + .add(service_ratio.multiply(evaluate.getServiceStar())); + + evaluate.setStar(star); + + orderEvaluateService.save(evaluate); + + //修改订单 + this.lambdaUpdate().set(Order::getStatus, OrderStatusEnums.to_be_evaluated.getCode()) + .set(ObjectUtil.equal(UserEnums.customer.getCode(), userVo.getUserType()), Order::getIsStoreEvaluate, 2) + .set(ObjectUtil.equal(UserEnums.customer.getCode(), userVo.getUserType()), Order::getIsCustomerEvaluate, 2) + .eq(Order::getId, req.getOrderId()).update(); + + + //评价对象 + UserVo evaluateUserVo = new UserVo(); + if (ObjectUtil.equal(UserEnums.store.getCode(), userVo.getUserType())) { + evaluateUserVo.setUserType(UserEnums.customer.getCode()); + evaluateUserVo.setUserId(order.getCustomerId()); + } else { + evaluateUserVo.setUserType(UserEnums.store.getCode()); + evaluateUserVo.setUserId(order.getStoreId()); + } + + //计算评分 + BigDecimal userStar = orderEvaluateService.getUserStar(evaluateUserVo); + + switch (UserEnums.getUserEnums(evaluateUserVo.getUserType())) { + case store: + //表现师评分 + storeService.update().set("star", userStar).eq("id", evaluateUserVo.getUserId()).update(); + + //消息通知 + orderMessageService.addOrderMessage(new UserVo(UserEnums.store.getCode(), order.getStoreId()), order.getId(), order.getOrderNo(), PublicCommon.Order.订单, EVALUATE_ORDER); + + break; + case customer: + //设计师评分 + customerService.update().set("star", userStar).eq("id", evaluateUserVo.getUserId()).update(); + break; + default: + break; + } + + //记录订单操作日志 + orderOperatorHistoryService.insertOrderOperatorHistory(OrderOperatorHistory.addAppHistory(order.getId(), "订单评价", "订单评价", userVo)); + + + return ResponseData.success(); + } + + + @Override + public ResponseData evaluateCountStar(EvaluateReq req, UserVo userVo) { + + //根据配置的权重--->计算总评分 + BigDecimal quality_ratio = new BigDecimal(businessUtil.getDict(DictConstant.质量评分占比).getDictValue()); + BigDecimal efficiency_ratio = new BigDecimal(businessUtil.getDict(DictConstant.效率评分占比).getDictValue()); + BigDecimal service_ratio = new BigDecimal(businessUtil.getDict(DictConstant.服务评分占比).getDictValue()); + + BigDecimal star = quality_ratio.multiply(req.getQualityStar()) + .add(efficiency_ratio.multiply(req.getEfficiencyStar())) + .add(service_ratio.multiply(req.getServiceStar())); + + return ResponseData.success(star); + } + + @Override + public ResponseData orderData(OrderPageReq orderPageReq, UserVo userVo) { + OrderDataResp orderDataResp = new OrderDataResp(); + LambdaQueryWrapper lambdaQueryWrapper = new QueryWrapper().lambda() + .eq(userVo.getUserType().equals(UserEnums.store.getCode()), Order::getStoreId, userVo.getUserId()) + .eq(userVo.getUserType().equals(UserEnums.customer.getCode()), Order::getCustomerId, userVo.getUserId()) + .eq(Order::getFirstStatus, PublicCommon.Pay.已支付) + .eq(Order::getDelFlag, PublicCommon.启用); + + if (orderPageReq != null && orderPageReq.getIsEachOther() != null && orderPageReq.getIsEachOther()) { + if (userVo.getUserType().equals(UserEnums.customer.getCode())) { + lambdaQueryWrapper.eq(Order::getStoreId, orderPageReq.getOtherUserId()); + } else if (userVo.getUserType().equals(UserEnums.store.getCode())) { + lambdaQueryWrapper.eq(Order::getCustomerId, orderPageReq.getOtherUserId()); + } + } + List list = this.list(lambdaQueryWrapper); + BigDecimal amount = BigDecimal.ZERO; + BigDecimal income = BigDecimal.ZERO; + + for (Order order : list) { + amount = amount.add(order.getAmount()); + if ( + (order.getStatus().equals(OrderStatusEnums.to_be_confirm.getCode()) + || order.getStatus().equals(OrderStatusEnums.ongoing.getCode())) + && order.getSourceUserType() == 1 + ) { + income = income.add(order.getFirstPrice()); + } else if (order.getStatus().equals(OrderStatusEnums.ongoing.getCode()) && order.getSourceUserType() == 2) { + income = income.add(order.getFirstPrice()); + } else { + income = income.add(order.getAmount()); + } + } + + orderDataResp.setIncome(income); + orderDataResp.setAmount(amount); + + if (orderPageReq.getIsEachOther()) { + if (userVo.getUserType().equals(UserEnums.customer.getCode())) { + orderPageReq.setOtherUserType(UserEnums.store.getCode()); + } else if (userVo.getUserType().equals(UserEnums.store.getCode())) { + orderPageReq.setOtherUserType(UserEnums.customer.getCode()); + } + } + + //订单数量 + Integer orderNum = this.baseMapper.orderCount(userVo, orderPageReq); + orderDataResp.setOrderNum(orderNum); + + return ResponseData.success(orderDataResp); + } + + /** + * 生成订单号 + * + * @param type 1订单号 2 首款支付单号 3 尾款支付单号 4调价支付定金 + * @return + */ + private String generateOrderNo(Integer type) { + String orderNo; + String prefix = type == 1 ? "HT" : type == 2 ? "HTS" : "HTW"; + if (type == 4) { + prefix = "TJ"; + + while (true) { + orderNo = prefix + DateUtil.format(new Date(), "MMdd" + RandomUtil.randomNumbers(6)); + OrderChangeRecord old = orderChangeRecordService.getBaseMapper().selectOne(new QueryWrapper().lambda() + .eq(OrderChangeRecord::getPayOrderNo, orderNo) + ); + if (old == null) { + break; + } + } + return orderNo; + } + + while (true) { + orderNo = prefix + DateUtil.format(new Date(), "MMdd" + RandomUtil.randomNumbers(6)); + Order old = this.getBaseMapper().selectOne(new QueryWrapper().lambda() + .eq(type == 1, Order::getOrderNo, orderNo) + .eq(type == 2, Order::getFirstPayOrderNo, orderNo) + .eq(type == 3, Order::getSecondPayOrderNo, orderNo) + + ); + if (old == null) { + break; + } + } + return orderNo; + } + + + @Override + public ResponseData orderAliNotify(HttpServletRequest request, HttpServletResponse response) { + log.info("******************************进入支付宝支付回调"); + //接收参数进行校验 + Map paramsMap = AlipayCore.updateMap(request); + //流水号 + String payId = paramsMap.get("out_trade_no"); + // 支付宝订单号 + String orderNo = paramsMap.get("trade_no"); + //付款状态 + String tradeStatus = paramsMap.get("trade_status"); + log.info("******************************payId=" + payId); + + Order cur = baseMapper.selectOne(new QueryWrapper().lambda().eq(Order::getFirstPayOrderNo, payId)); + if (cur == null) { + log.error("支付信息丢失"); + return ResponseData.error("支付信息丢失"); + } + if (cur.getFirstStatus() == 2) { + log.error("支付宝回调已经开始 回去吧"); + return ResponseData.error("支付宝回调已经开始 回去吧"); + } + if (cur.getFirstStatus() == 3) { + //退款 + ResponseData responseData = payUtil.refund(new UserVo(UserEnums.customer.getCode(), cur.getCustomerId()), cur.getId(), cur.getFirstPayType(), cur.getFirstTripartitePrice(), cur.getFirstTripartitePrice(), cur.getFirstPayOrderNo(), orderNo, cur.getFirstGivePrice()); + if (!responseData.getSuccess()) { + log.error("退款失败:" + cur.getOrderNo()); + } + return responseData; + } + if ("TRADE_SUCCESS".equalsIgnoreCase(tradeStatus)) { + + //是否使用抵用金支付 + if (ObjectUtil.isNotEmpty(cur.getFirstGivePrice()) && cur.getFirstGivePrice().compareTo(BigDecimal.ZERO) > 0) { + //抵用金 + try { + giveWalletRecordService.updateGiveBalance(new UserVo(UserEnums.customer.getCode(), cur.getCustomerId()), WalletDetailEnums.GIVE_ORDER_PAY, cur.getId(), + cur.getFirstGivePrice().negate(), PublicCommon.Wallet.可提现); + } catch (CustomException c) { + log.error("抵用金支付失败:" + cur.getOrderNo()); + + //退款 + ResponseData responseData = payUtil.refund(new UserVo(UserEnums.customer.getCode(), cur.getCustomerId()), cur.getId(), cur.getFirstPayType(), cur.getFirstTripartitePrice(), cur.getFirstTripartitePrice(), cur.getFirstPayOrderNo(), orderNo, cur.getFirstGivePrice()); + if (!responseData.getSuccess()) { + log.error("退款失败:" + cur.getOrderNo()); + } + return responseData; + } + } + + this.lambdaUpdate().set(Order::getAliBusinessId, orderNo).eq(Order::getId, cur.getId()).update(); + + after(cur);//支付后逻辑处理 + log.info("正常"); + return ResponseData.success(); + } else { + cur.setFirstStatus(3); + baseMapper.updateById(cur); + log.error("支付失败"); + } + return ResponseData.error(""); + } + + @Override + public ResponseData orderWxNotify(HttpServletRequest request, HttpServletResponse response) { + Map requestMap = HttpRequestUtil.parseXml(request); + // 微信中的订单号 + String transactionId = requestMap.get("transaction_id"); + // 用户唯一标识 + String openid = requestMap.get("openid"); + //流水号 + String payId = requestMap.get("out_trade_no"); + + Order cur = baseMapper.selectOne(new QueryWrapper().lambda().eq(Order::getFirstPayOrderNo, payId)); + if (cur == null) { + log.error("支付信息丢失"); + return ResponseData.error("支付信息丢失"); + } + if (cur.getFirstStatus() == 2) { + log.error("微信回调已经开始 回去吧"); + return ResponseData.error("支付宝回调已经开始 回去吧"); + } + if (cur.getFirstStatus() == 3) { + //退款 + ResponseData responseData = payUtil.refund(new UserVo(UserEnums.customer.getCode(), cur.getCustomerId()), cur.getId(), cur.getFirstPayType(), cur.getFirstTripartitePrice(), cur.getFirstTripartitePrice(), cur.getFirstPayOrderNo(), cur.getAliBusinessId(), cur.getFirstGivePrice()); + if (!responseData.getSuccess()) { + log.error("退款失败:" + cur.getOrderNo()); + } + return responseData; + } + + if ("SUCCESS".equals(requestMap.get("result_code"))) { + + //是否使用抵用金支付 + if (ObjectUtil.isNotEmpty(cur.getFirstGivePrice()) && cur.getFirstGivePrice().compareTo(BigDecimal.ZERO) > 0) { + //抵用金 + try { + giveWalletRecordService.updateGiveBalance(new UserVo(UserEnums.customer.getCode(), cur.getCustomerId()), WalletDetailEnums.GIVE_ORDER_PAY, cur.getId(), cur.getFirstGivePrice().negate(), PublicCommon.Wallet.可提现); + } catch (CustomException c) { + log.error("抵用金支付失败:" + cur.getOrderNo()); + + //退款 + ResponseData responseData = payUtil.refund(new UserVo(UserEnums.customer.getCode(), cur.getCustomerId()), cur.getId(), cur.getFirstPayType(), cur.getFirstTripartitePrice(), cur.getFirstTripartitePrice(), cur.getFirstPayOrderNo(), cur.getAliBusinessId(), cur.getFirstGivePrice()); + if (!responseData.getSuccess()) { + log.error("退款失败:" + cur.getOrderNo()); + } + return responseData; + } + } + + + after(cur);//支付后逻辑处理 + log.info("正常"); + return ResponseData.success(); + } else { + cur.setFirstStatus(3); + baseMapper.updateById(cur); + log.error("支付失败"); + } + + return ResponseData.error(""); + } + + @Autowired + private OnlineRecordService onlineRecordService; + + @Override + public ResponseData orderLakalaNotify(Map requestMap) { + //商户订单号 + String payId = requestMap.get("out_order_no"); + + Order cur = baseMapper.selectOne(new QueryWrapper().lambda().eq(Order::getFirstPayOrderNo, payId)); + if (cur == null) { + log.error("支付信息丢失"); + return ResponseData.error("支付信息丢失"); + } + if (cur.getFirstStatus() == 2) { + log.error("拉卡拉回调已经开始 回去吧"); + return ResponseData.error("拉卡拉回调已经开始 回去吧"); + } + + //order_status 聚合收银台订单状态 0:待支付 1:支付中 2:支付成功 3:支付失败 4:已过期 5:已取消 6:部分退款或者全部退款 + if (("2").equals(requestMap.get("order_status"))) { + + //是否使用抵用金支付 + if (ObjectUtil.isNotEmpty(cur.getFirstGivePrice()) && cur.getFirstGivePrice().compareTo(BigDecimal.ZERO) > 0) { + //抵用金 + try { + giveWalletRecordService.updateGiveBalance(new UserVo(UserEnums.customer.getCode(), cur.getCustomerId()), WalletDetailEnums.GIVE_ORDER_PAY, cur.getId(), cur.getFirstGivePrice().negate(), PublicCommon.Wallet.可提现); + } catch (CustomException c) { + log.error("抵用金支付失败:" + cur.getOrderNo()); + + //退款 + ResponseData responseData = payUtil.refund(new UserVo(UserEnums.customer.getCode(), cur.getCustomerId()), cur.getId(), cur.getFirstPayType(), cur.getFirstTripartitePrice(), cur.getFirstTripartitePrice(), cur.getFirstPayOrderNo(), cur.getAliBusinessId(), cur.getFirstGivePrice()); + if (!responseData.getSuccess()) { + log.error("退款失败:" + cur.getOrderNo()); + } + return responseData; + } + } + + + after(cur);//支付后逻辑处理 + log.info("正常"); + + //设置成功标识 + businessUtil.setOutTradeNo(payId); + + //添加支付记录 + onlineRecordService.addOnlineRecord(new UserVo(UserEnums.customer.getCode(), cur.getCustomerId()), cur.getId(), cur.getFirstTripartitePrice(), WalletDetailEnums.ORDER_PAY); + + return ResponseData.success(); + } else { + cur.setFirstStatus(3); + baseMapper.updateById(cur); + log.error("支付失败"); + } + + return ResponseData.error(""); + } + + @Override + public ResponseData secondOrderAliNotify(HttpServletRequest request, HttpServletResponse response) { + log.info("******************************进入支付宝支付回调"); + //接收参数进行校验 + Map paramsMap = AlipayCore.updateMap(request); + //流水号 + String payId = paramsMap.get("out_trade_no"); + // 支付宝订单号 + String orderNo = paramsMap.get("trade_no"); + //付款状态 + String tradeStatus = paramsMap.get("trade_status"); + log.info("******************************payId=" + payId); + + Order cur = baseMapper.selectOne(new QueryWrapper().lambda().eq(Order::getSecondPayOrderNo, payId)); + if (cur == null) { + log.error("支付信息丢失"); + return ResponseData.error("支付信息丢失"); + } + if (cur.getSecondStatus() == 2) { + log.error("支付宝回调已经开始 回去吧"); + return ResponseData.error("支付宝回调已经开始 回去吧"); + } + if (cur.getSecondStatus() == 3) { + //退款 + ResponseData responseData = payUtil.refund(new UserVo(UserEnums.customer.getCode(), cur.getCustomerId()), cur.getId(), cur.getSecondPayType(), cur.getSecondTripartitePrice(), cur.getSecondTripartitePrice(), cur.getSecondPayOrderNo(), orderNo, cur.getSecondGivePrice()); + if (!responseData.getSuccess()) { + log.error("退款失败:" + cur.getOrderNo()); + } + return responseData; + } + if ("TRADE_SUCCESS".equalsIgnoreCase(tradeStatus)) { + + //是否使用抵用金支付 + if (ObjectUtil.isNotEmpty(cur.getSecondGivePrice()) && cur.getSecondGivePrice().compareTo(BigDecimal.ZERO) > 0) { + //抵用金 + try { + giveWalletRecordService.updateGiveBalance(new UserVo(UserEnums.customer.getCode(), cur.getCustomerId()), WalletDetailEnums.GIVE_ORDER_PAY, cur.getId(), cur.getSecondGivePrice().negate(), PublicCommon.Wallet.可提现); + } catch (CustomException c) { + log.error("抵用金支付失败:" + cur.getOrderNo()); + + //退款 + ResponseData responseData = payUtil.refund(new UserVo(UserEnums.customer.getCode(), cur.getCustomerId()), cur.getId(), cur.getFirstPayType(), cur.getSecondTripartitePrice(), cur.getSecondTripartitePrice(), cur.getSecondPayOrderNo(), orderNo, cur.getSecondGivePrice()); + if (!responseData.getSuccess()) { + log.error("退款失败:" + cur.getOrderNo()); + } + return responseData; + } + } + + this.lambdaUpdate().set(Order::getSecondAliBusinessId, orderNo).eq(Order::getId, cur.getId()).update(); + + endPayAfter(cur, cur.getIsAgree() == 1 ? false : true);//支付后逻辑处理 + log.info("正常"); + return ResponseData.success(); + } else { + cur.setSecondStatus(3); + baseMapper.updateById(cur); + log.error("支付失败"); + } + return ResponseData.error(""); + } + + @Override + public ResponseData secondOrderWxNotify(HttpServletRequest request, HttpServletResponse response) { + Map requestMap = HttpRequestUtil.parseXml(request); + // 微信中的订单号 + String transactionId = requestMap.get("transaction_id"); + // 用户唯一标识 + String openid = requestMap.get("openid"); + //流水号 + String payId = requestMap.get("out_trade_no"); + + Order cur = baseMapper.selectOne(new QueryWrapper().lambda().eq(Order::getSecondPayOrderNo, payId)); + if (cur == null) { + log.error("支付信息丢失"); + return ResponseData.error("支付信息丢失"); + } + if (cur.getSecondStatus() == 2) { + log.error("微信回调已经开始 回去吧"); + return ResponseData.error("支付宝回调已经开始 回去吧"); + } + if (cur.getSecondStatus() == 3) { + //退款 + ResponseData responseData = payUtil.refund(new UserVo(UserEnums.customer.getCode(), cur.getCustomerId()), cur.getId(), cur.getSecondPayType(), cur.getSecondTripartitePrice(), cur.getSecondTripartitePrice(), cur.getSecondPayOrderNo(), cur.getSecondAliBusinessId(), cur.getSecondGivePrice()); + if (!responseData.getSuccess()) { + log.error("退款失败:" + cur.getOrderNo()); + } + return responseData; + } + + if ("SUCCESS".equals(requestMap.get("result_code"))) { + + //是否使用抵用金支付 + if (ObjectUtil.isNotEmpty(cur.getSecondGivePrice()) && cur.getSecondGivePrice().compareTo(BigDecimal.ZERO) > 0) { + //抵用金 + try { + giveWalletRecordService.updateGiveBalance(new UserVo(UserEnums.customer.getCode(), cur.getCustomerId()), WalletDetailEnums.GIVE_ORDER_PAY, cur.getId(), cur.getSecondGivePrice().negate(), PublicCommon.Wallet.可提现); + } catch (CustomException c) { + log.error("抵用金支付失败:" + cur.getOrderNo()); + + //退款 + ResponseData responseData = payUtil.refund(new UserVo(UserEnums.customer.getCode(), cur.getCustomerId()), cur.getId(), cur.getFirstPayType(), cur.getSecondTripartitePrice(), cur.getSecondTripartitePrice(), cur.getSecondPayOrderNo(), cur.getAliBusinessId(), cur.getSecondGivePrice()); + if (!responseData.getSuccess()) { + log.error("退款失败:" + cur.getOrderNo()); + } + return responseData; + } + } + + + endPayAfter(cur, cur.getIsAgree() == 1 ? false : true);//支付后逻辑处理 + log.info("正常"); + return ResponseData.success(); + } else { + cur.setSecondStatus(3); + baseMapper.updateById(cur); + log.error("支付失败"); + } + + return ResponseData.error(""); + } + + @Override + public ResponseData secondOrderLakalaNotify(Map requestMap) { + //商户订单号 + String payId = requestMap.get("out_order_no"); + Order cur = baseMapper.selectOne(new QueryWrapper().lambda().eq(Order::getSecondPayOrderNo, payId)); + if (cur == null) { + log.error("支付信息丢失"); + return ResponseData.error("支付信息丢失"); + } + if (cur.getSecondStatus() == 2) { + log.error("拉卡拉回调已经开始 回去吧"); + return ResponseData.error("拉卡拉回调已经开始 回去吧"); + } + + //order_status 聚合收银台订单状态 0:待支付 1:支付中 2:支付成功 3:支付失败 4:已过期 5:已取消 6:部分退款或者全部退款 + if (("2").equals(requestMap.get("order_status"))) { + + //是否使用抵用金支付 + if (ObjectUtil.isNotEmpty(cur.getSecondGivePrice()) && cur.getSecondGivePrice().compareTo(BigDecimal.ZERO) > 0) { + //抵用金 + try { + giveWalletRecordService.updateGiveBalance(new UserVo(UserEnums.customer.getCode(), cur.getCustomerId()), WalletDetailEnums.GIVE_ORDER_PAY, cur.getId(), cur.getSecondGivePrice().negate(), PublicCommon.Wallet.可提现); + } catch (CustomException c) { + log.error("抵用金支付失败:" + cur.getOrderNo()); + + //退款 + ResponseData responseData = payUtil.refund(new UserVo(UserEnums.customer.getCode(), cur.getCustomerId()), cur.getId(), cur.getFirstPayType(), cur.getSecondTripartitePrice(), cur.getSecondTripartitePrice(), cur.getSecondPayOrderNo(), cur.getAliBusinessId(), cur.getSecondGivePrice()); + if (!responseData.getSuccess()) { + log.error("退款失败:" + cur.getOrderNo()); + } + return responseData; + } + } + + + endPayAfter(cur, cur.getIsAgree() == 1 ? false : true);//支付后逻辑处理 + log.info("正常"); + + //设置成功标识 + businessUtil.setOutTradeNo(payId); + + //添加支付记录 + onlineRecordService.addOnlineRecord(new UserVo(UserEnums.customer.getCode(), cur.getCustomerId()), cur.getId(), cur.getSecondTripartitePrice(), WalletDetailEnums.ORDER_PAY); + + return ResponseData.success(); + } else { + cur.setSecondStatus(3); + baseMapper.updateById(cur); + log.error("支付失败"); + } + + return ResponseData.error(""); + } + + @Override + public ResponseData orderAdjustPricePayAliNotify(HttpServletRequest request, HttpServletResponse response) { + log.info("******************************进入支付宝支付回调"); + //接收参数进行校验 + Map paramsMap = AlipayCore.updateMap(request); + //流水号 + String payId = paramsMap.get("out_trade_no"); + // 支付宝订单号 + String orderNo = paramsMap.get("trade_no"); + //付款状态 + String tradeStatus = paramsMap.get("trade_status"); + log.info("******************************payId=" + payId); + + OrderChangeRecord cur = orderChangeRecordService.getOne(new QueryWrapper().lambda().eq(OrderChangeRecord::getPayOrderNo, payId)); + if (cur == null) { + log.error("支付信息丢失"); + return ResponseData.error("支付信息丢失"); + } + if (cur.getPayStatus() == 2) { + log.error("支付宝回调已经开始 回去吧"); + return ResponseData.error("支付宝回调已经开始 回去吧"); + } + + Order order = this.getById(cur.getOrderId()); + + + BigDecimal tripartitePrice = cur.getPayPrice().subtract(cur.getGivePrice()); + + if (cur.getPayStatus() == 3) { + //退款 + ResponseData responseData = payUtil.refund(new UserVo(UserEnums.customer.getCode(), order.getCustomerId()), order.getId(), cur.getPayType(), tripartitePrice, tripartitePrice, cur.getPayOrderNo(), orderNo, cur.getGivePrice()); + if (!responseData.getSuccess()) { + log.error("退款失败:" + cur.getPayOrderNo()); + } + return responseData; + } + if ("TRADE_SUCCESS".equalsIgnoreCase(tradeStatus)) { + + //是否使用抵用金支付 + if (ObjectUtil.isNotEmpty(cur.getGivePrice()) && cur.getGivePrice().compareTo(BigDecimal.ZERO) > 0) { + //赠送余额 + try { + giveWalletRecordService.updateGiveBalance(new UserVo(UserEnums.customer.getCode(), order.getCustomerId()), WalletDetailEnums.GIVE_ORDER_PAY, cur.getId(), cur.getGivePrice().negate(), PublicCommon.Wallet.可提现); + } catch (CustomException c) { + log.error("抵用金支付失败:" + cur.getPayOrderNo()); + + //退款 + ResponseData responseData = payUtil.refund(new UserVo(UserEnums.customer.getCode(), order.getCustomerId()), cur.getId(), cur.getPayType(), tripartitePrice, tripartitePrice, cur.getPayOrderNo(), orderNo, cur.getGivePrice()); + if (!responseData.getSuccess()) { + log.error("退款失败:" + cur.getPayOrderNo()); + } + return responseData; + } + } + + orderChangeRecordService.lambdaUpdate().set(OrderChangeRecord::getAliBusinessId, orderNo).eq(OrderChangeRecord::getId, cur.getId()).update(); + cur.setPayType(PayEnums.app_alipay.getCode()); + afterAdjustPricePay(cur);//支付后逻辑处理 + log.info("正常"); + return ResponseData.success(); + } else { + cur.setPayStatus(3); + orderChangeRecordService.updateById(cur); + log.error("支付失败"); + } + return ResponseData.error(""); + } + + @Override + public ResponseData orderAdjustPricePayWxNotify(HttpServletRequest request, HttpServletResponse response) { + Map requestMap = HttpRequestUtil.parseXml(request); + // 微信中的订单号 + String transactionId = requestMap.get("transaction_id"); + // 用户唯一标识 + String openid = requestMap.get("openid"); + //流水号 + String payId = requestMap.get("out_trade_no"); + + OrderChangeRecord cur = orderChangeRecordService.getOne(new QueryWrapper().lambda().eq(OrderChangeRecord::getPayOrderNo, payId)); + if (cur == null) { + log.error("支付信息丢失"); + return ResponseData.error("支付信息丢失"); + } + if (cur.getPayStatus() == 2) { + log.error("微信回调已经开始 回去吧"); + return ResponseData.error("支付宝回调已经开始 回去吧"); + } + + Order order = this.getById(cur.getOrderId()); + + BigDecimal tripartitePrice = cur.getPayPrice().subtract(cur.getGivePrice()); + + if (cur.getPayStatus() == 3) { + //退款 + ResponseData responseData = payUtil.refund(new UserVo(UserEnums.customer.getCode(), order.getCustomerId()), order.getId(), cur.getPayType(), tripartitePrice, tripartitePrice, cur.getPayOrderNo(), cur.getAliBusinessId(), cur.getGivePrice()); + if (!responseData.getSuccess()) { + log.error("退款失败:" + cur.getPayOrderNo()); + } + return responseData; + } + + if ("SUCCESS".equals(requestMap.get("result_code"))) { + + //是否使用抵用金支付 + if (ObjectUtil.isNotEmpty(cur.getGivePrice()) && cur.getGivePrice().compareTo(BigDecimal.ZERO) > 0) { + //抵用金 + try { + giveWalletRecordService.updateGiveBalance(new UserVo(UserEnums.customer.getCode(), order.getCustomerId()), WalletDetailEnums.GIVE_ORDER_PAY, cur.getId(), cur.getGivePrice().negate(), PublicCommon.Wallet.可提现); + } catch (CustomException c) { + log.error("抵用金支付失败:" + cur.getPayOrderNo()); + + //退款 + ResponseData responseData = payUtil.refund(new UserVo(UserEnums.customer.getCode(), order.getCustomerId()), cur.getId(), cur.getPayType(), tripartitePrice, tripartitePrice, cur.getPayOrderNo(), cur.getAliBusinessId(), cur.getGivePrice()); + if (!responseData.getSuccess()) { + log.error("退款失败:" + cur.getPayOrderNo()); + } + return responseData; + } + } + cur.setPayType(PayEnums.app_weChat.getCode()); + afterAdjustPricePay(cur);//支付后逻辑处理 + log.info("正常"); + return ResponseData.success(); + } else { + cur.setPayStatus(3); + orderChangeRecordService.updateById(cur); + log.error("支付失败"); + } + + return ResponseData.error(""); + } + + @Override + public ResponseData orderAdjustPricePayLakalaNotify(Map requestMap) { + //流水号 + String payId = requestMap.get("out_order_no"); + + OrderChangeRecord cur = orderChangeRecordService.getOne(new QueryWrapper().lambda().eq(OrderChangeRecord::getPayOrderNo, payId)); + if (cur == null) { + log.error("支付信息丢失"); + return ResponseData.error("支付信息丢失"); + } + if (cur.getPayStatus() == 2) { + log.error("拉卡拉回调已经开始 回去吧"); + return ResponseData.error("拉卡拉回调已经开始 回去吧"); + } + + Order order = this.getById(cur.getOrderId()); + + BigDecimal tripartitePrice = cur.getPayPrice().subtract(cur.getGivePrice()); + + if (cur.getPayStatus() == 3) { + //退款 + ResponseData responseData = payUtil.refund(new UserVo(UserEnums.customer.getCode(), order.getCustomerId()), order.getId(), cur.getPayType(), tripartitePrice, tripartitePrice, cur.getPayOrderNo(), cur.getAliBusinessId(), cur.getGivePrice()); + if (!responseData.getSuccess()) { + log.error("退款失败:" + cur.getPayOrderNo()); + } + return responseData; + } + + //order_status 聚合收银台订单状态 0:待支付 1:支付中 2:支付成功 3:支付失败 4:已过期 5:已取消 6:部分退款或者全部退款 + if (("2").equals(requestMap.get("order_status"))) { + + //是否使用抵用金支付 + if (ObjectUtil.isNotEmpty(cur.getGivePrice()) && cur.getGivePrice().compareTo(BigDecimal.ZERO) > 0) { + //抵用金 + try { + giveWalletRecordService.updateGiveBalance(new UserVo(UserEnums.customer.getCode(), order.getCustomerId()), WalletDetailEnums.GIVE_ORDER_PAY, cur.getId(), cur.getGivePrice().negate(), PublicCommon.Wallet.可提现); + } catch (CustomException c) { + log.error("抵用金支付失败:" + cur.getPayOrderNo()); + + //退款 + ResponseData responseData = payUtil.refund(new UserVo(UserEnums.customer.getCode(), order.getCustomerId()), cur.getId(), cur.getPayType(), tripartitePrice, tripartitePrice, cur.getPayOrderNo(), cur.getAliBusinessId(), cur.getGivePrice()); + if (!responseData.getSuccess()) { + log.error("退款失败:" + cur.getPayOrderNo()); + } + return responseData; + } + } + cur.setPayType(PayEnums.lakala_ccss.getCode()); + afterAdjustPricePay(cur);//支付后逻辑处理 + log.info("正常"); + + //设置成功标识 + businessUtil.setOutTradeNo(payId); + + //添加支付记录 + onlineRecordService.addOnlineRecord(new UserVo(UserEnums.customer.getCode(), cur.getUserId()), cur.getId(), cur.getPayPrice(), WalletDetailEnums.ADJUST_PRICE_PAY); + + return ResponseData.success(); + } else { + cur.setPayStatus(3); + orderChangeRecordService.updateById(cur); + log.error("支付失败"); + } + + return ResponseData.error(""); + } + + @Override + public ResponseData orderAdjustPriceConfirmPayAliNotify(HttpServletRequest request, HttpServletResponse response) { + log.info("******************************进入支付宝支付回调"); + //接收参数进行校验 + Map paramsMap = AlipayCore.updateMap(request); + //流水号 + String payId = paramsMap.get("out_trade_no"); + // 支付宝订单号 + String orderNo = paramsMap.get("trade_no"); + //付款状态 + String tradeStatus = paramsMap.get("trade_status"); + log.info("******************************payId=" + payId); + + OrderChangeRecord cur = orderChangeRecordService.getOne(new QueryWrapper().lambda().eq(OrderChangeRecord::getPayOrderNo, payId)); + if (cur == null) { + log.error("支付信息丢失"); + return ResponseData.error("支付信息丢失"); + } + if (cur.getPayStatus() == 2) { + log.error("支付宝回调已经开始 回去吧"); + return ResponseData.error("支付宝回调已经开始 回去吧"); + } + + Order order = this.getById(cur.getOrderId()); + + + BigDecimal tripartitePrice = cur.getPayPrice().subtract(cur.getGivePrice()); + + if (cur.getPayStatus() == 3) { + //退款 + ResponseData responseData = payUtil.refund(new UserVo(UserEnums.customer.getCode(), order.getCustomerId()), order.getId(), cur.getPayType(), tripartitePrice, tripartitePrice, cur.getPayOrderNo(), orderNo, cur.getGivePrice()); + if (!responseData.getSuccess()) { + log.error("退款失败:" + cur.getPayOrderNo()); + } + return responseData; + } + if ("TRADE_SUCCESS".equalsIgnoreCase(tradeStatus)) { + + //是否使用抵用金支付 + if (ObjectUtil.isNotEmpty(cur.getGivePrice()) && cur.getGivePrice().compareTo(BigDecimal.ZERO) > 0) { + //抵用金 + try { + giveWalletRecordService.updateGiveBalance(new UserVo(UserEnums.customer.getCode(), order.getCustomerId()), WalletDetailEnums.GIVE_ORDER_PAY, cur.getId(), cur.getGivePrice().negate(), PublicCommon.Wallet.可提现); + } catch (CustomException c) { + log.error("抵用金支付失败:" + cur.getPayOrderNo()); + + //退款 + ResponseData responseData = payUtil.refund(new UserVo(UserEnums.customer.getCode(), order.getCustomerId()), cur.getId(), cur.getPayType(), tripartitePrice, tripartitePrice, cur.getPayOrderNo(), orderNo, cur.getGivePrice()); + if (!responseData.getSuccess()) { + log.error("退款失败:" + cur.getPayOrderNo()); + } + return responseData; + } + } + + orderChangeRecordService.lambdaUpdate().set(OrderChangeRecord::getAliBusinessId, orderNo).eq(OrderChangeRecord::getId, cur.getId()).update(); + + afterAdjustPriceConfirmPay(cur);//支付后逻辑处理 + log.info("正常"); + return ResponseData.success(); + } else { + cur.setPayStatus(3); + orderChangeRecordService.updateById(cur); + log.error("支付失败"); + } + return ResponseData.error(""); + } + + @Override + public ResponseData orderAdjustPriceConfirmPayWxNotify(HttpServletRequest request, HttpServletResponse response) { + Map requestMap = HttpRequestUtil.parseXml(request); + // 微信中的订单号 + String transactionId = requestMap.get("transaction_id"); + // 用户唯一标识 + String openid = requestMap.get("openid"); + //流水号 + String payId = requestMap.get("out_trade_no"); + + OrderChangeRecord cur = orderChangeRecordService.getOne(new QueryWrapper().lambda().eq(OrderChangeRecord::getPayOrderNo, payId)); + if (cur == null) { + log.error("支付信息丢失"); + return ResponseData.error("支付信息丢失"); + } + if (cur.getPayStatus() == 2) { + log.error("微信回调已经开始 回去吧"); + return ResponseData.error("支付宝回调已经开始 回去吧"); + } + + Order order = this.getById(cur.getOrderId()); + + BigDecimal tripartitePrice = cur.getPayPrice().subtract(cur.getGivePrice()); + + if (cur.getPayStatus() == 3) { + //退款 + ResponseData responseData = payUtil.refund(new UserVo(UserEnums.customer.getCode(), order.getCustomerId()), order.getId(), cur.getPayType(), tripartitePrice, tripartitePrice, cur.getPayOrderNo(), cur.getAliBusinessId(), cur.getGivePrice()); + if (!responseData.getSuccess()) { + log.error("退款失败:" + cur.getPayOrderNo()); + } + return responseData; + } + + if ("SUCCESS".equals(requestMap.get("result_code"))) { + + //是否使用抵用金支付 + if (ObjectUtil.isNotEmpty(cur.getGivePrice()) && cur.getGivePrice().compareTo(BigDecimal.ZERO) > 0) { + //抵用金 + try { + giveWalletRecordService.updateGiveBalance(new UserVo(UserEnums.customer.getCode(), order.getCustomerId()), WalletDetailEnums.GIVE_ORDER_PAY, cur.getId(), cur.getGivePrice().negate(), PublicCommon.Wallet.可提现); + } catch (CustomException c) { + log.error("抵用金支付失败:" + cur.getPayOrderNo()); + + //退款 + ResponseData responseData = payUtil.refund(new UserVo(UserEnums.customer.getCode(), order.getCustomerId()), cur.getId(), cur.getPayType(), tripartitePrice, tripartitePrice, cur.getPayOrderNo(), cur.getAliBusinessId(), cur.getGivePrice()); + if (!responseData.getSuccess()) { + log.error("退款失败:" + cur.getPayOrderNo()); + } + return responseData; + } + } + afterAdjustPriceConfirmPay(cur);//支付后逻辑处理 + log.info("正常"); + return ResponseData.success(); + } else { + cur.setPayStatus(3); + orderChangeRecordService.updateById(cur); + log.error("支付失败"); + } + + return ResponseData.error(""); + } + + @Override + public ResponseData orderAdjustPriceConfirmPayLakalaNotify(Map requestMap) { + //流水号 + String payId = requestMap.get("out_order_no"); + + OrderChangeRecord cur = orderChangeRecordService.getOne(new QueryWrapper().lambda().eq(OrderChangeRecord::getPayOrderNo, payId)); + if (cur == null) { + log.error("支付信息丢失"); + return ResponseData.error("支付信息丢失"); + } + if (cur.getPayStatus() == 2) { + log.error("拉卡拉回调已经开始 回去吧"); + return ResponseData.error("拉卡拉回调已经开始 回去吧"); + } + + Order order = this.getById(cur.getOrderId()); + + BigDecimal tripartitePrice = cur.getPayPrice().subtract(cur.getGivePrice()); + + if (cur.getPayStatus() == 3) { + //退款 + ResponseData responseData = payUtil.refund(new UserVo(UserEnums.customer.getCode(), order.getCustomerId()), order.getId(), cur.getPayType(), tripartitePrice, tripartitePrice, cur.getPayOrderNo(), cur.getAliBusinessId(), cur.getGivePrice()); + if (!responseData.getSuccess()) { + log.error("退款失败:" + cur.getPayOrderNo()); + } + return responseData; + } + + //order_status 聚合收银台订单状态 0:待支付 1:支付中 2:支付成功 3:支付失败 4:已过期 5:已取消 6:部分退款或者全部退款 + if (("2").equals(requestMap.get("order_status"))) { + + //是否使用抵用金支付 + if (ObjectUtil.isNotEmpty(cur.getGivePrice()) && cur.getGivePrice().compareTo(BigDecimal.ZERO) > 0) { + //抵用金 + try { + giveWalletRecordService.updateGiveBalance(new UserVo(UserEnums.customer.getCode(), order.getCustomerId()), WalletDetailEnums.GIVE_ORDER_PAY, cur.getId(), cur.getGivePrice().negate(), PublicCommon.Wallet.可提现); + } catch (CustomException c) { + log.error("抵用金支付失败:" + cur.getPayOrderNo()); + + //退款 + ResponseData responseData = payUtil.refund(new UserVo(UserEnums.customer.getCode(), order.getCustomerId()), cur.getId(), cur.getPayType(), tripartitePrice, tripartitePrice, cur.getPayOrderNo(), cur.getAliBusinessId(), cur.getGivePrice()); + if (!responseData.getSuccess()) { + log.error("退款失败:" + cur.getPayOrderNo()); + } + return responseData; + } + } + afterAdjustPriceConfirmPay(cur);//支付后逻辑处理 + log.info("正常"); + + //设置成功标识 + businessUtil.setOutTradeNo(payId); + + //添加支付记录 + onlineRecordService.addOnlineRecord(new UserVo(UserEnums.customer.getCode(), cur.getUserId()), cur.getId(), cur.getPayPrice(), WalletDetailEnums.ADJUST_PRICE_PAY); + + return ResponseData.success(); + } else { + cur.setPayStatus(3); + orderChangeRecordService.updateById(cur); + log.error("支付失败"); + } + + return ResponseData.error(""); + } + + @Override + public ResponseData isNeedGetOrderDetail(IsNeedGetOrderDetailReq req) { + //查询接单表现师 + List orderReceivingList = orderReceivingService.list(new QueryWrapper().lambda() + .eq(OrderReceiving::getOrderId, req.getOrderId()).eq(OrderReceiving::getDelFlag, PublicCommon.启用).orderByDesc(BaseEntity::getCreateTime)); + + if (StringUtils.isBlank(req.getDate()) && orderReceivingList.size() > 0) { + return ResponseData.success(true); + } + if (StringUtils.isNotBlank(req.getDate())) { + if (orderReceivingList.size() == 0) { + return ResponseData.success(true); + } + + StringBuffer stringBuffer = new StringBuffer(); + orderReceivingList.stream().forEach(x -> { + stringBuffer.append(x.getId()); + }); + if (!stringBuffer.toString().equals(req.getDate())) { + return ResponseData.success(true); + } + } + return ResponseData.success(false); + } + + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/orderchangerecord/controller/OrderChangeRecordController.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/orderchangerecord/controller/OrderChangeRecordController.java new file mode 100644 index 0000000..e9d7030 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/orderchangerecord/controller/OrderChangeRecordController.java @@ -0,0 +1,97 @@ +package com.ruoyi.frequency.orderchangerecord.controller; + +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.page.TableDataInfo; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.common.utils.poi.ExcelUtil; +import com.ruoyi.frequency.orderchangerecord.entity.OrderChangeRecord; +import com.ruoyi.frequency.orderchangerecord.service.OrderChangeRecordService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +/** + * 订单改价记录Controller + * + * @author zj + * @date 2023-10-13 + */ +@RestController +@RequestMapping("/frequency/orderchangerecord") +public class OrderChangeRecordController extends BaseController +{ + @Autowired + private OrderChangeRecordService orderChangeRecordService; + + /** + * 查询订单改价记录列表 + */ + @PreAuthorize("@ss.hasPermi('frequency:orderchangerecord:list')") + @PostMapping("/list") + public TableDataInfo list(@RequestBody OrderChangeRecord orderChangeRecord) + { + startPage(); + List list = orderChangeRecordService.selectOrderChangeRecordList(orderChangeRecord); + return getDataTable(list); + } + + /** + * 导出订单改价记录列表 + */ + @PreAuthorize("@ss.hasPermi('frequency:orderchangerecord:export')") + @Log(title = "订单改价记录", businessType = BusinessType.EXPORT) + @GetMapping("/export") + public AjaxResult export(OrderChangeRecord orderChangeRecord) + { + List list = orderChangeRecordService.selectOrderChangeRecordList(orderChangeRecord); + ExcelUtil util = new ExcelUtil(OrderChangeRecord.class); + return util.exportExcel(list, "订单改价记录数据"); + } + + /** + * 获取订单改价记录详细信息 + */ + @PreAuthorize("@ss.hasPermi('frequency:orderchangerecord:query')") + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") Long id) + { + return AjaxResult.success(orderChangeRecordService.selectOrderChangeRecordById(id)); + } + + /** + * 新增订单改价记录 + */ + @PreAuthorize("@ss.hasPermi('frequency:orderchangerecord:add')") + @Log(title = "订单改价记录", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody OrderChangeRecord orderChangeRecord) + { + return toAjax(orderChangeRecordService.insertOrderChangeRecord(orderChangeRecord)); + } + + /** + * 修改订单改价记录 + */ + @PreAuthorize("@ss.hasPermi('frequency:orderchangerecord:edit')") + @Log(title = "订单改价记录", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody OrderChangeRecord orderChangeRecord) + { + return toAjax(orderChangeRecordService.updateOrderChangeRecord(orderChangeRecord)); + } + + /** + * 删除订单改价记录 + */ + @PreAuthorize("@ss.hasPermi('frequency:orderchangerecord:remove')") + @Log(title = "订单改价记录", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}") + public AjaxResult remove(@PathVariable Long[] ids) + { + return toAjax(orderChangeRecordService.deleteOrderChangeRecordByIds(ids)); + } +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/orderchangerecord/entity/OrderChangeRecord.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/orderchangerecord/entity/OrderChangeRecord.java new file mode 100644 index 0000000..f0b622e --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/orderchangerecord/entity/OrderChangeRecord.java @@ -0,0 +1,84 @@ +package com.ruoyi.frequency.orderchangerecord.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; + +import java.math.BigDecimal; + +/** + * 订单改价记录对象 t_order_change_record + * + * @author zj + * @date 2023-10-13 + */ +@Data +@Accessors(chain = true) +@TableName("t_order_change_record") +public class OrderChangeRecord extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + + @ApiModelProperty("租户号") + private Long id; + + + @ApiModelProperty("删除标志;1 正常 2 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("订单ID") + @Excel(name = "订单ID") + private Long orderId; + + @ApiModelProperty("改价前价格") + @Excel(name = "改价前价格") + private BigDecimal originAmount; + + @ApiModelProperty("改价后价格") + @Excel(name = "改价后价格") + private BigDecimal changeAmount; + + @ApiModelProperty("用户ID") + @Excel(name = "用户ID") + private Long userId; + + @ApiModelProperty("用户类型") + @Excel(name = "用户类型") + private Integer userType; + + @ApiModelProperty("1待确认 2 已确认") + @Excel(name = "1待确认 2 已确认") + private Integer status; + + @ApiModelProperty("备注") + private String remark; + + @ApiModelProperty("拒绝原因") + private String reason; + + @ApiModelProperty("定金支付编号") + private String payOrderNo; + + @ApiModelProperty("定金支付金额(超出订单金额)") + private BigDecimal payPrice; + + @ApiModelProperty("赠送支付金额") + private BigDecimal givePrice; + + @ApiModelProperty("支付类型") + private Integer payType; + + @ApiModelProperty("支付状态 1待支付 2已支付 3支付失败") + private Integer payStatus; + + @ApiModelProperty("支付宝支付返回的订单号") + @Excel(name = "支付宝支付返回的订单号") + private String aliBusinessId; + + + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/orderchangerecord/mapper/OrderChangeRecordMapper.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/orderchangerecord/mapper/OrderChangeRecordMapper.java new file mode 100644 index 0000000..6e319dc --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/orderchangerecord/mapper/OrderChangeRecordMapper.java @@ -0,0 +1,63 @@ +package com.ruoyi.frequency.orderchangerecord.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.ruoyi.frequency.orderchangerecord.entity.OrderChangeRecord; + +import java.util.List; + +/** + * 订单改价记录Mapper接口 + * + * @author zj + * @date 2023-10-13 + */ +public interface OrderChangeRecordMapper extends BaseMapper +{ + /** + * 查询订单改价记录 + * + * @param id 订单改价记录主键 + * @return 订单改价记录 + */ + public OrderChangeRecord selectOrderChangeRecordById(Long id); + + /** + * 查询订单改价记录列表 + * + * @param orderChangeRecord 订单改价记录 + * @return 订单改价记录集合 + */ + public List selectOrderChangeRecordList(OrderChangeRecord orderChangeRecord); + + /** + * 新增订单改价记录 + * + * @param orderChangeRecord 订单改价记录 + * @return 结果 + */ + public int insertOrderChangeRecord(OrderChangeRecord orderChangeRecord); + + /** + * 修改订单改价记录 + * + * @param orderChangeRecord 订单改价记录 + * @return 结果 + */ + public int updateOrderChangeRecord(OrderChangeRecord orderChangeRecord); + + /** + * 删除订单改价记录 + * + * @param id 订单改价记录主键 + * @return 结果 + */ + public int deleteOrderChangeRecordById(Long id); + + /** + * 批量删除订单改价记录 + * + * @param ids 需要删除的数据主键集合 + * @return 结果 + */ + public int deleteOrderChangeRecordByIds(Long[] ids); +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/orderchangerecord/mapper/mapping/OrderChangeRecordMapper.xml b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/orderchangerecord/mapper/mapping/OrderChangeRecordMapper.xml new file mode 100644 index 0000000..70896a3 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/orderchangerecord/mapper/mapping/OrderChangeRecordMapper.xml @@ -0,0 +1,108 @@ + + + + + + + + + + + + + + + + + + + + + + select id, create_by, create_time, update_by, update_time, del_flag, order_id, origin_amount, change_amount, user_id, user_type, status, remark from t_order_change_record + + + + + + + + insert into t_order_change_record + + id, + create_by, + create_time, + update_by, + update_time, + del_flag, + order_id, + origin_amount, + change_amount, + user_id, + user_type, + status, + remark, + + + #{id}, + #{createBy}, + #{createTime}, + #{updateBy}, + #{updateTime}, + #{delFlag}, + #{orderId}, + #{originAmount}, + #{changeAmount}, + #{userId}, + #{userType}, + #{status}, + #{remark}, + + + + + update t_order_change_record + + create_by = #{createBy}, + create_time = #{createTime}, + update_by = #{updateBy}, + update_time = #{updateTime}, + del_flag = #{delFlag}, + order_id = #{orderId}, + origin_amount = #{originAmount}, + change_amount = #{changeAmount}, + user_id = #{userId}, + user_type = #{userType}, + status = #{status}, + remark = #{remark}, + + where id = #{id} + + + + delete from t_order_change_record where id = #{id} + + + + delete from t_order_change_record where id in + + #{id} + + + \ No newline at end of file diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/orderchangerecord/model/param/OrderChangeRecordParam.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/orderchangerecord/model/param/OrderChangeRecordParam.java new file mode 100644 index 0000000..8192dcc --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/orderchangerecord/model/param/OrderChangeRecordParam.java @@ -0,0 +1,64 @@ +package com.ruoyi.frequency.orderchangerecord.model.param; + +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; + +import java.math.BigDecimal; + +/** + * 订单改价记录对象 t_order_change_record + * + * @author zj + * @date 2023-10-13 + */ +@Data +@Accessors(chain = true) +public class OrderChangeRecordParam extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + @ApiModelProperty("租户号") + private Long id; + + + @ApiModelProperty("删除标志;1 正常 2 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("订单ID") + @Excel(name = "订单ID") + private Long orderId; + + @ApiModelProperty("改价前价格") + @Excel(name = "改价前价格") + private BigDecimal originAmount; + + @ApiModelProperty("改价后价格") + @Excel(name = "改价后价格") + private BigDecimal changeAmount; + + @ApiModelProperty("用户ID") + @Excel(name = "用户ID") + private Long userId; + + @ApiModelProperty("用户类型") + @Excel(name = "用户类型") + private Integer userType; + + @ApiModelProperty("1待确认 2 已确认") + @Excel(name = "1待确认 2 已确认") + private Integer status; + + + + + + + + + + + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/orderchangerecord/model/result/OrderChangeRecordResult.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/orderchangerecord/model/result/OrderChangeRecordResult.java new file mode 100644 index 0000000..d77f0af --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/orderchangerecord/model/result/OrderChangeRecordResult.java @@ -0,0 +1,55 @@ +package com.ruoyi.frequency.orderchangerecord.model.result; + +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; + +import java.math.BigDecimal; + +/** + * 订单改价记录对象 t_order_change_record + * + * @author zj + * @date 2023-10-13 + */ +@Data +@Accessors(chain = true) +public class OrderChangeRecordResult extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + @ApiModelProperty("租户号") + private Long id; + + + @ApiModelProperty("删除标志;1 正常 2 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("订单ID") + @Excel(name = "订单ID") + private Long orderId; + + @ApiModelProperty("改价前价格") + @Excel(name = "改价前价格") + private BigDecimal originAmount; + + @ApiModelProperty("改价后价格") + @Excel(name = "改价后价格") + private BigDecimal changeAmount; + + @ApiModelProperty("用户ID") + @Excel(name = "用户ID") + private Long userId; + + @ApiModelProperty("用户类型") + @Excel(name = "用户类型") + private Integer userType; + + @ApiModelProperty("1待确认 2 已确认") + @Excel(name = "1待确认 2 已确认") + private Integer status; + + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/orderchangerecord/service/OrderChangeRecordService.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/orderchangerecord/service/OrderChangeRecordService.java new file mode 100644 index 0000000..2309c0a --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/orderchangerecord/service/OrderChangeRecordService.java @@ -0,0 +1,77 @@ +package com.ruoyi.frequency.orderchangerecord.service; + +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.IService; +import com.ruoyi.common.page.PageResult; +import com.ruoyi.controller.req.OrderChangeRecordPageReq; +import com.ruoyi.frequency.orderchangerecord.entity.OrderChangeRecord; +import com.ruoyi.response.ResponseData; +import com.ruoyi.vo.UserVo; + +import java.util.List; + +/** + * 订单改价记录Service接口 + * + * @author zj + * @date 2023-10-13 + */ +public interface OrderChangeRecordService extends IService +{ + /** + * 查询订单改价记录 + * + * @param id 订单改价记录主键 + * @return 订单改价记录 + */ + public OrderChangeRecord selectOrderChangeRecordById(Long id); + + /** + * 查询订单改价记录列表 + * + * @param orderChangeRecord 订单改价记录 + * @return 订单改价记录集合 + */ + public List selectOrderChangeRecordList(OrderChangeRecord orderChangeRecord); + + /** + * 新增订单改价记录 + * + * @param orderChangeRecord 订单改价记录 + * @return 结果 + */ + public int insertOrderChangeRecord(OrderChangeRecord orderChangeRecord); + + /** + * 修改订单改价记录 + * + * @param orderChangeRecord 订单改价记录 + * @return 结果 + */ + public int updateOrderChangeRecord(OrderChangeRecord orderChangeRecord); + + /** + * 批量删除订单改价记录 + * + * @param ids 需要删除的订单改价记录主键集合 + * @return 结果 + */ + public int deleteOrderChangeRecordByIds(Long[] ids); + + /** + * 删除订单改价记录信息 + * + * @param id 订单改价记录主键 + * @return 结果 + */ + public int deleteOrderChangeRecordById(Long id); + + + /** + * 订单调价记录 + * @param req + * @param userVo + * @return + */ + ResponseData>> orderChangeRecordPage(OrderChangeRecordPageReq req, UserVo userVo); +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/orderchangerecord/service/impl/OrderChangeRecordServiceImpl.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/orderchangerecord/service/impl/OrderChangeRecordServiceImpl.java new file mode 100644 index 0000000..563ed62 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/orderchangerecord/service/impl/OrderChangeRecordServiceImpl.java @@ -0,0 +1,113 @@ +package com.ruoyi.frequency.orderchangerecord.service.impl; + +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.ruoyi.code.PublicCommon; +import com.ruoyi.common.page.PageResult; +import com.ruoyi.common.utils.DateUtils; +import com.ruoyi.controller.req.OrderChangeRecordPageReq; +import com.ruoyi.frequency.orderchangerecord.entity.OrderChangeRecord; +import com.ruoyi.frequency.orderchangerecord.mapper.OrderChangeRecordMapper; +import com.ruoyi.frequency.orderchangerecord.service.OrderChangeRecordService; +import com.ruoyi.response.ResponseData; +import com.ruoyi.vo.UserVo; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.List; + +/** + * 订单改价记录Service业务层处理 + * + * @author zj + * @date 2023-10-13 + */ +@Service +@Transactional(rollbackFor = Exception.class) +public class OrderChangeRecordServiceImpl extends ServiceImpl implements OrderChangeRecordService { + @Autowired + private OrderChangeRecordMapper orderChangeRecordMapper; + + /** + * 查询订单改价记录 + * + * @param id 订单改价记录主键 + * @return 订单改价记录 + */ + @Override + public OrderChangeRecord selectOrderChangeRecordById(Long id) { + return orderChangeRecordMapper.selectOrderChangeRecordById(id); + } + + /** + * 查询订单改价记录列表 + * + * @param orderChangeRecord 订单改价记录 + * @return 订单改价记录 + */ + @Override + public List selectOrderChangeRecordList(OrderChangeRecord orderChangeRecord) { + + List orderChangeRecords = orderChangeRecordMapper.selectOrderChangeRecordList(orderChangeRecord); + + return orderChangeRecords; + } + + /** + * 新增订单改价记录 + * + * @param orderChangeRecord 订单改价记录 + * @return 结果 + */ + @Override + public int insertOrderChangeRecord(OrderChangeRecord orderChangeRecord) { + return orderChangeRecordMapper.insertOrderChangeRecord(orderChangeRecord); + } + + /** + * 修改订单改价记录 + * + * @param orderChangeRecord 订单改价记录 + * @return 结果 + */ + @Override + public int updateOrderChangeRecord(OrderChangeRecord orderChangeRecord) { + orderChangeRecord.setUpdateTime(DateUtils.getNowDate()); + return orderChangeRecordMapper.updateOrderChangeRecord(orderChangeRecord); + } + + /** + * 批量删除订单改价记录 + * + * @param ids 需要删除的订单改价记录主键 + * @return 结果 + */ + @Override + public int deleteOrderChangeRecordByIds(Long[] ids) { + this.lambdaUpdate().set(OrderChangeRecord::getDelFlag, PublicCommon.删除).in(OrderChangeRecord::getId, ids).update(); + return ids.length; + } + + /** + * 删除订单改价记录信息 + * + * @param id 订单改价记录主键 + * @return 结果 + */ + @Override + public int deleteOrderChangeRecordById(Long id) { + this.lambdaUpdate().set(OrderChangeRecord::getDelFlag, PublicCommon.删除).eq(OrderChangeRecord::getId, id).update(); + return 1; + } + + @Override + public ResponseData>> orderChangeRecordPage(OrderChangeRecordPageReq req, UserVo userVo) { + + Page page = this.lambdaQuery().eq(OrderChangeRecord::getDelFlag, PublicCommon.启用) + .eq(OrderChangeRecord::getOrderId, req.getOrderId()) + .ne(OrderChangeRecord::getStatus, PublicCommon.OrderChange.待确认) + .orderByDesc(OrderChangeRecord::getCreateTime).page(new Page<>(req.getPageNo(), req.getPageSize())); + return ResponseData.success(new PageResult<>(page)); + } +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/orderevaluate/controller/OrderEvaluateController.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/orderevaluate/controller/OrderEvaluateController.java new file mode 100644 index 0000000..74a71b4 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/orderevaluate/controller/OrderEvaluateController.java @@ -0,0 +1,103 @@ +package com.ruoyi.frequency.orderevaluate.controller; + +import java.util.List; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.frequency.orderevaluate.entity.OrderEvaluate; +import com.ruoyi.frequency.orderevaluate.service.OrderEvaluateService; +import com.ruoyi.common.utils.poi.ExcelUtil; +import com.ruoyi.common.core.page.TableDataInfo; + +/** + * 订单评价Controller + * + * @author zj + * @date 2023-10-13 + */ +@RestController +@RequestMapping("/frequency/orderevaluate") +public class OrderEvaluateController extends BaseController +{ + @Autowired + private OrderEvaluateService orderEvaluateService; + + /** + * 查询订单评价列表 + */ + @PreAuthorize("@ss.hasPermi('frequency:orderevaluate:list')") + @PostMapping("/list") + public TableDataInfo list(@RequestBody OrderEvaluate orderEvaluate) + { + startPage(); + List list = orderEvaluateService.selectOrderEvaluateList(orderEvaluate); + return getDataTable(list); + } + + /** + * 导出订单评价列表 + */ + @PreAuthorize("@ss.hasPermi('frequency:orderevaluate:export')") + @Log(title = "订单评价", businessType = BusinessType.EXPORT) + @GetMapping("/export") + public AjaxResult export(OrderEvaluate orderEvaluate) + { + List list = orderEvaluateService.selectOrderEvaluateList(orderEvaluate); + ExcelUtil util = new ExcelUtil(OrderEvaluate.class); + return util.exportExcel(list, "订单评价数据"); + } + + /** + * 获取订单评价详细信息 + */ + @PreAuthorize("@ss.hasPermi('frequency:orderevaluate:query')") + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") Long id) + { + return AjaxResult.success(orderEvaluateService.selectOrderEvaluateById(id)); + } + + /** + * 新增订单评价 + */ + @PreAuthorize("@ss.hasPermi('frequency:orderevaluate:add')") + @Log(title = "订单评价", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody OrderEvaluate orderEvaluate) + { + return toAjax(orderEvaluateService.insertOrderEvaluate(orderEvaluate)); + } + + /** + * 修改订单评价 + */ + @PreAuthorize("@ss.hasPermi('frequency:orderevaluate:edit')") + @Log(title = "订单评价", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody OrderEvaluate orderEvaluate) + { + return toAjax(orderEvaluateService.updateOrderEvaluate(orderEvaluate)); + } + + /** + * 删除订单评价 + */ + @PreAuthorize("@ss.hasPermi('frequency:orderevaluate:remove')") + @Log(title = "订单评价", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}") + public AjaxResult remove(@PathVariable Long[] ids) + { + return toAjax(orderEvaluateService.deleteOrderEvaluateByIds(ids)); + } +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/orderevaluate/entity/OrderEvaluate.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/orderevaluate/entity/OrderEvaluate.java new file mode 100644 index 0000000..61bf941 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/orderevaluate/entity/OrderEvaluate.java @@ -0,0 +1,70 @@ +package com.ruoyi.frequency.orderevaluate.entity; + +import java.math.BigDecimal; +import java.util.Date; + +import com.baomidou.mybatisplus.annotation.TableField; +import com.fasterxml.jackson.annotation.JsonFormat; +import com.ruoyi.vo.UserInfo; +import lombok.Data; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.experimental.Accessors; +import com.ruoyi.common.annotation.Excel; +import io.swagger.annotations.ApiModelProperty; +import com.ruoyi.common.core.domain.BaseEntity; + +/** + * 订单评价对象 t_order_evaluate + * + * @author zj + * @date 2023-10-13 + */ +@Data +@Accessors(chain = true) +@TableName("t_order_evaluate") +public class OrderEvaluate extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + + @ApiModelProperty("租户号") + private Long id; + + + @ApiModelProperty("删除标志;1 正常 2 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("订单id") + @Excel(name = "订单id") + private Long orderId; + + @ApiModelProperty("1质量 2 效率 3 服务") + @Excel(name = "1质量 2 效率 3 服务") + private Integer type; + + @ApiModelProperty("总评分") + @Excel(name = "总评分") + private BigDecimal star; + + @ApiModelProperty("质量评分") + @Excel(name = "质量评分") + private BigDecimal qualityStar; + + @ApiModelProperty("效率评分") + @Excel(name = "效率评分") + private BigDecimal efficiencyStar; + + @ApiModelProperty("服务评分") + @Excel(name = "服务评分") + private BigDecimal serviceStar; + + @ApiModelProperty("用户类型 1 用户 2 商家") + private Integer userType; + + @ApiModelProperty("用户id") + private Long userId; + + @ApiModelProperty("评价用户信息") + @TableField(exist = false) + private UserInfo userInfo; +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/orderevaluate/mapper/OrderEvaluateMapper.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/orderevaluate/mapper/OrderEvaluateMapper.java new file mode 100644 index 0000000..03beee0 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/orderevaluate/mapper/OrderEvaluateMapper.java @@ -0,0 +1,67 @@ +package com.ruoyi.frequency.orderevaluate.mapper; + +import java.math.BigDecimal; +import java.util.List; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.ruoyi.frequency.orderevaluate.entity.OrderEvaluate; +import com.ruoyi.vo.UserVo; +import org.apache.ibatis.annotations.Param; + +/** + * 订单评价Mapper接口 + * + * @author zj + * @date 2023-10-13 + */ +public interface OrderEvaluateMapper extends BaseMapper +{ + /** + * 查询订单评价 + * + * @param id 订单评价主键 + * @return 订单评价 + */ + public OrderEvaluate selectOrderEvaluateById(Long id); + + /** + * 查询订单评价列表 + * + * @param orderEvaluate 订单评价 + * @return 订单评价集合 + */ + public List selectOrderEvaluateList(OrderEvaluate orderEvaluate); + + /** + * 新增订单评价 + * + * @param orderEvaluate 订单评价 + * @return 结果 + */ + public int insertOrderEvaluate(OrderEvaluate orderEvaluate); + + /** + * 修改订单评价 + * + * @param orderEvaluate 订单评价 + * @return 结果 + */ + public int updateOrderEvaluate(OrderEvaluate orderEvaluate); + + /** + * 删除订单评价 + * + * @param id 订单评价主键 + * @return 结果 + */ + public int deleteOrderEvaluateById(Long id); + + /** + * 批量删除订单评价 + * + * @param ids 需要删除的数据主键集合 + * @return 结果 + */ + public int deleteOrderEvaluateByIds(Long[] ids); + + BigDecimal getUserStar(@Param("userVo") UserVo evaluateUserVo); +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/orderevaluate/mapper/mapping/OrderEvaluateMapper.xml b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/orderevaluate/mapper/mapping/OrderEvaluateMapper.xml new file mode 100644 index 0000000..403a3a7 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/orderevaluate/mapper/mapping/OrderEvaluateMapper.xml @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + select id, create_by, create_time, update_by, update_time, del_flag, order_id, type, star, quality_star, efficiency_star, service_star from t_order_evaluate + + + + + + + + insert into t_order_evaluate + + id, + create_by, + create_time, + update_by, + update_time, + del_flag, + order_id, + type, + star, + quality_star, + efficiency_star, + service_star, + + + #{id}, + #{createBy}, + #{createTime}, + #{updateBy}, + #{updateTime}, + #{delFlag}, + #{orderId}, + #{type}, + #{star}, + #{qualityStar}, + #{efficiencyStar}, + #{serviceStar}, + + + + + update t_order_evaluate + + create_by = #{createBy}, + create_time = #{createTime}, + update_by = #{updateBy}, + update_time = #{updateTime}, + del_flag = #{delFlag}, + order_id = #{orderId}, + type = #{type}, + star = #{star}, + quality_star = #{qualityStar}, + efficiency_star = #{efficiencyStar}, + service_star = #{serviceStar}, + + where id = #{id} + + + + delete from t_order_evaluate where id = #{id} + + + + delete from t_order_evaluate where id in + + #{id} + + + + + diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/orderevaluate/model/param/OrderEvaluateParam.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/orderevaluate/model/param/OrderEvaluateParam.java new file mode 100644 index 0000000..9f74280 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/orderevaluate/model/param/OrderEvaluateParam.java @@ -0,0 +1,65 @@ +package com.ruoyi.frequency.orderevaluate.model.param; + +import java.math.BigDecimal; +import java.util.Date; +import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.Data; +import lombok.experimental.Accessors; +import com.ruoyi.common.annotation.Excel; +import io.swagger.annotations.ApiModelProperty; +import com.ruoyi.common.core.domain.BaseEntity; + +/** + * 订单评价对象 t_order_evaluate + * + * @author zj + * @date 2023-10-13 + */ +@Data +@Accessors(chain = true) +public class OrderEvaluateParam extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + @ApiModelProperty("租户号") + private Long id; + + + @ApiModelProperty("删除标志;1 正常 2 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("订单id") + @Excel(name = "订单id") + private String orderId; + + @ApiModelProperty("1质量 2 效率 3 服务") + @Excel(name = "1质量 2 效率 3 服务") + private Integer type; + + @ApiModelProperty("总评分") + @Excel(name = "总评分") + private BigDecimal star; + + @ApiModelProperty("质量评分") + @Excel(name = "质量评分") + private BigDecimal qualityStar; + + @ApiModelProperty("效率评分") + @Excel(name = "效率评分") + private BigDecimal efficiencyStar; + + @ApiModelProperty("服务评分") + @Excel(name = "服务评分") + private BigDecimal serviceStar; + + + + + + + + + + + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/orderevaluate/model/result/OrderEvaluateResult.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/orderevaluate/model/result/OrderEvaluateResult.java new file mode 100644 index 0000000..efae7f9 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/orderevaluate/model/result/OrderEvaluateResult.java @@ -0,0 +1,56 @@ +package com.ruoyi.frequency.orderevaluate.model.result; + +import java.math.BigDecimal; +import java.util.Date; +import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.Data; +import lombok.experimental.Accessors; +import com.ruoyi.common.annotation.Excel; +import io.swagger.annotations.ApiModelProperty; +import com.ruoyi.common.core.domain.BaseEntity; + +/** + * 订单评价对象 t_order_evaluate + * + * @author zj + * @date 2023-10-13 + */ +@Data +@Accessors(chain = true) +public class OrderEvaluateResult extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + @ApiModelProperty("租户号") + private Long id; + + + @ApiModelProperty("删除标志;1 正常 2 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("订单id") + @Excel(name = "订单id") + private String orderId; + + @ApiModelProperty("1质量 2 效率 3 服务") + @Excel(name = "1质量 2 效率 3 服务") + private Integer type; + + @ApiModelProperty("总评分") + @Excel(name = "总评分") + private BigDecimal star; + + @ApiModelProperty("质量评分") + @Excel(name = "质量评分") + private BigDecimal qualityStar; + + @ApiModelProperty("效率评分") + @Excel(name = "效率评分") + private BigDecimal efficiencyStar; + + @ApiModelProperty("服务评分") + @Excel(name = "服务评分") + private BigDecimal serviceStar; + + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/orderevaluate/service/OrderEvaluateService.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/orderevaluate/service/OrderEvaluateService.java new file mode 100644 index 0000000..f5e562d --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/orderevaluate/service/OrderEvaluateService.java @@ -0,0 +1,72 @@ +package com.ruoyi.frequency.orderevaluate.service; + +import java.math.BigDecimal; +import java.util.List; +import com.ruoyi.frequency.orderevaluate.entity.OrderEvaluate; +import com.baomidou.mybatisplus.extension.service.IService; +import com.ruoyi.vo.UserVo; + +/** + * 订单评价Service接口 + * + * @author zj + * @date 2023-10-13 + */ +public interface OrderEvaluateService extends IService +{ + /** + * 查询订单评价 + * + * @param id 订单评价主键 + * @return 订单评价 + */ + public OrderEvaluate selectOrderEvaluateById(Long id); + + /** + * 查询订单评价列表 + * + * @param orderEvaluate 订单评价 + * @return 订单评价集合 + */ + public List selectOrderEvaluateList(OrderEvaluate orderEvaluate); + + /** + * 新增订单评价 + * + * @param orderEvaluate 订单评价 + * @return 结果 + */ + public int insertOrderEvaluate(OrderEvaluate orderEvaluate); + + /** + * 修改订单评价 + * + * @param orderEvaluate 订单评价 + * @return 结果 + */ + public int updateOrderEvaluate(OrderEvaluate orderEvaluate); + + /** + * 批量删除订单评价 + * + * @param ids 需要删除的订单评价主键集合 + * @return 结果 + */ + public int deleteOrderEvaluateByIds(Long[] ids); + + /** + * 删除订单评价信息 + * + * @param id 订单评价主键 + * @return 结果 + */ + public int deleteOrderEvaluateById(Long id); + + + /** + * 计算评分 + * @param evaluateUserVo + * @return + */ + BigDecimal getUserStar(UserVo evaluateUserVo); +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/orderevaluate/service/impl/OrderEvaluateServiceImpl.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/orderevaluate/service/impl/OrderEvaluateServiceImpl.java new file mode 100644 index 0000000..b2a8583 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/orderevaluate/service/impl/OrderEvaluateServiceImpl.java @@ -0,0 +1,108 @@ +package com.ruoyi.frequency.orderevaluate.service.impl; + +import java.math.BigDecimal; +import java.util.List; +import com.ruoyi.common.utils.DateUtils; +import com.ruoyi.vo.UserVo; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.ruoyi.code.PublicCommon; +import com.ruoyi.frequency.orderevaluate.mapper.OrderEvaluateMapper; +import com.ruoyi.frequency.orderevaluate.entity.OrderEvaluate; +import com.ruoyi.frequency.orderevaluate.service.OrderEvaluateService; +import org.springframework.transaction.annotation.Transactional; + +/** + * 订单评价Service业务层处理 + * + * @author zj + * @date 2023-10-13 + */ +@Service +@Transactional(rollbackFor = Exception.class) +public class OrderEvaluateServiceImpl extends ServiceImpl implements OrderEvaluateService +{ + @Autowired + private OrderEvaluateMapper orderEvaluateMapper; + + /** + * 查询订单评价 + * + * @param id 订单评价主键 + * @return 订单评价 + */ + @Override + public OrderEvaluate selectOrderEvaluateById(Long id) + { + return orderEvaluateMapper.selectOrderEvaluateById(id); + } + + /** + * 查询订单评价列表 + * + * @param orderEvaluate 订单评价 + * @return 订单评价 + */ + @Override + public List selectOrderEvaluateList(OrderEvaluate orderEvaluate) + { + return orderEvaluateMapper.selectOrderEvaluateList(orderEvaluate); + } + + /** + * 新增订单评价 + * + * @param orderEvaluate 订单评价 + * @return 结果 + */ + @Override + public int insertOrderEvaluate(OrderEvaluate orderEvaluate) + { + return orderEvaluateMapper.insertOrderEvaluate(orderEvaluate); + } + + /** + * 修改订单评价 + * + * @param orderEvaluate 订单评价 + * @return 结果 + */ + @Override + public int updateOrderEvaluate(OrderEvaluate orderEvaluate) + { + orderEvaluate.setUpdateTime(DateUtils.getNowDate()); + return orderEvaluateMapper.updateOrderEvaluate(orderEvaluate); + } + + /** + * 批量删除订单评价 + * + * @param ids 需要删除的订单评价主键 + * @return 结果 + */ + @Override + public int deleteOrderEvaluateByIds(Long[] ids) + { + this.lambdaUpdate().set(OrderEvaluate::getDelFlag,PublicCommon.删除).in(OrderEvaluate::getId,ids).update(); + return ids.length; + } + + /** + * 删除订单评价信息 + * + * @param id 订单评价主键 + * @return 结果 + */ + @Override + public int deleteOrderEvaluateById(Long id) + { + this.lambdaUpdate().set(OrderEvaluate::getDelFlag,PublicCommon.删除).eq(OrderEvaluate::getId,id).update(); + return 1; + } + + @Override + public BigDecimal getUserStar(UserVo evaluateUserVo) { + return orderEvaluateMapper.getUserStar(evaluateUserVo); + } +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/orderextensionrecord/controller/OrderExtensionRecordController.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/orderextensionrecord/controller/OrderExtensionRecordController.java new file mode 100644 index 0000000..e0ab936 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/orderextensionrecord/controller/OrderExtensionRecordController.java @@ -0,0 +1,97 @@ +package com.ruoyi.frequency.orderextensionrecord.controller; + +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.page.TableDataInfo; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.common.utils.poi.ExcelUtil; +import com.ruoyi.frequency.orderextensionrecord.entity.OrderExtensionRecord; +import com.ruoyi.frequency.orderextensionrecord.service.OrderExtensionRecordService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +/** + * 订单延期记录Controller + * + * @author liwenlong + * @date 2023-11-03 + */ +@RestController +@RequestMapping("/frequency/orderextensionrecord") +public class OrderExtensionRecordController extends BaseController +{ + @Autowired + private OrderExtensionRecordService orderExtensionRecordService; + + /** + * 查询订单延期记录列表 + */ + @PreAuthorize("@ss.hasPermi('frequency:orderextensionrecord:list')") + @PostMapping("/list") + public TableDataInfo list(@RequestBody OrderExtensionRecord orderExtensionRecord) + { + startPage(); + List list = orderExtensionRecordService.selectOrderExtensionRecordList(orderExtensionRecord); + return getDataTable(list); + } + + /** + * 导出订单延期记录列表 + */ + @PreAuthorize("@ss.hasPermi('frequency:orderextensionrecord:export')") + @Log(title = "订单延期记录", businessType = BusinessType.EXPORT) + @GetMapping("/export") + public AjaxResult export(OrderExtensionRecord orderExtensionRecord) + { + List list = orderExtensionRecordService.selectOrderExtensionRecordList(orderExtensionRecord); + ExcelUtil util = new ExcelUtil(OrderExtensionRecord.class); + return util.exportExcel(list, "订单延期记录数据"); + } + + /** + * 获取订单延期记录详细信息 + */ + @PreAuthorize("@ss.hasPermi('frequency:orderextensionrecord:query')") + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") Long id) + { + return AjaxResult.success(orderExtensionRecordService.selectOrderExtensionRecordById(id)); + } + + /** + * 新增订单延期记录 + */ + @PreAuthorize("@ss.hasPermi('frequency:orderextensionrecord:add')") + @Log(title = "订单延期记录", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody OrderExtensionRecord orderExtensionRecord) + { + return toAjax(orderExtensionRecordService.insertOrderExtensionRecord(orderExtensionRecord)); + } + + /** + * 修改订单延期记录 + */ + @PreAuthorize("@ss.hasPermi('frequency:orderextensionrecord:edit')") + @Log(title = "订单延期记录", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody OrderExtensionRecord orderExtensionRecord) + { + return toAjax(orderExtensionRecordService.updateOrderExtensionRecord(orderExtensionRecord)); + } + + /** + * 删除订单延期记录 + */ + @PreAuthorize("@ss.hasPermi('frequency:orderextensionrecord:remove')") + @Log(title = "订单延期记录", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}/{delFlag}") + public AjaxResult remove(@PathVariable("ids") Long[] ids,@PathVariable("delFlag") Integer delFalg) + { + return toAjax(orderExtensionRecordService.deleteOrderExtensionRecordByIds(ids,delFalg)); + } +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/orderextensionrecord/entity/OrderExtensionRecord.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/orderextensionrecord/entity/OrderExtensionRecord.java new file mode 100644 index 0000000..29a50b0 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/orderextensionrecord/entity/OrderExtensionRecord.java @@ -0,0 +1,64 @@ +package com.ruoyi.frequency.orderextensionrecord.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import com.fasterxml.jackson.annotation.JsonFormat; +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; + +import java.util.Date; + +/** + * 订单延期记录对象 t_order_extension_record + * + * @author liwenlong + * @date 2023-11-03 + */ +@Data +@Accessors(chain = true) +@TableName("t_order_extension_record") +public class OrderExtensionRecord extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + + @ApiModelProperty("租户号") + private Long id; + + @ApiModelProperty("删除标志;1 正常 2 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("订单ID") + @Excel(name = "订单ID") + private Long orderId; + + @ApiModelProperty("延期前时间") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm") + private Date originTime; + + @ApiModelProperty("延期后时间") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm") + private Date changeTime; + + @ApiModelProperty("用户ID") + @Excel(name = "用户ID") + private Long userId; + + @ApiModelProperty("用户类型") + @Excel(name = "用户类型") + private Integer userType; + + @ApiModelProperty("1待确认 2 已确认") + @Excel(name = "1待确认 2 已确认") + private Integer status; + + @ApiModelProperty("备注") + private String remark; + + @ApiModelProperty("拒绝原因") + private String reason; + + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/orderextensionrecord/mapper/OrderExtensionRecordMapper.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/orderextensionrecord/mapper/OrderExtensionRecordMapper.java new file mode 100644 index 0000000..8f9a106 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/orderextensionrecord/mapper/OrderExtensionRecordMapper.java @@ -0,0 +1,48 @@ +package com.ruoyi.frequency.orderextensionrecord.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.ruoyi.frequency.orderextensionrecord.entity.OrderExtensionRecord; + +import java.util.List; + +/** + * 订单延期记录Mapper接口 + * + * @author liwenlong + * @date 2023-11-03 + */ +public interface OrderExtensionRecordMapper extends BaseMapper +{ + /** + * 查询订单延期记录 + * + * @param id 订单延期记录主键 + * @return 订单延期记录 + */ + public OrderExtensionRecord selectOrderExtensionRecordById(Long id); + + /** + * 查询订单延期记录列表 + * + * @param orderExtensionRecord 订单延期记录 + * @return 订单延期记录集合 + */ + public List selectOrderExtensionRecordList(OrderExtensionRecord orderExtensionRecord); + + /** + * 新增订单延期记录 + * + * @param orderExtensionRecord 订单延期记录 + * @return 结果 + */ + public int insertOrderExtensionRecord(OrderExtensionRecord orderExtensionRecord); + + /** + * 修改订单延期记录 + * + * @param orderExtensionRecord 订单延期记录 + * @return 结果 + */ + public int updateOrderExtensionRecord(OrderExtensionRecord orderExtensionRecord); + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/orderextensionrecord/mapper/mapping/OrderExtensionRecordMapper.xml b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/orderextensionrecord/mapper/mapping/OrderExtensionRecordMapper.xml new file mode 100644 index 0000000..03187c4 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/orderextensionrecord/mapper/mapping/OrderExtensionRecordMapper.xml @@ -0,0 +1,98 @@ + + + + + + + + + + + + + + + + + + + + + + select id, create_by, create_time, update_by, update_time, del_flag, order_id, origin_time, change_time, user_id, user_type, status, remark from t_order_extension_record + + + + + + + + insert into t_order_extension_record + + id, + create_by, + create_time, + update_by, + update_time, + del_flag, + order_id, + origin_time, + change_time, + user_id, + user_type, + status, + remark, + + + #{id}, + #{createBy}, + #{createTime}, + #{updateBy}, + #{updateTime}, + #{delFlag}, + #{orderId}, + #{originTime}, + #{changeTime}, + #{userId}, + #{userType}, + #{status}, + #{remark}, + + + + + update t_order_extension_record + + create_by = #{createBy}, + create_time = #{createTime}, + update_by = #{updateBy}, + update_time = #{updateTime}, + del_flag = #{delFlag}, + order_id = #{orderId}, + origin_time = #{originTime}, + change_time = #{changeTime}, + user_id = #{userId}, + user_type = #{userType}, + status = #{status}, + remark = #{remark}, + + where id = #{id} + + + \ No newline at end of file diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/orderextensionrecord/model/param/OrderExtensionRecordParam.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/orderextensionrecord/model/param/OrderExtensionRecordParam.java new file mode 100644 index 0000000..17b4d9d --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/orderextensionrecord/model/param/OrderExtensionRecordParam.java @@ -0,0 +1,62 @@ +package com.ruoyi.frequency.orderextensionrecord.model.param; + +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; + +import java.util.Date; + +/** + * 订单延期记录对象 t_order_extension_record + * + * @author liwenlong + * @date 2023-11-03 + */ +@Data +@Accessors(chain = true) +public class OrderExtensionRecordParam extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + @ApiModelProperty("租户号") + private Long id; + + @ApiModelProperty("删除标志;1 正常 2 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("订单ID") + @Excel(name = "订单ID") + private Long orderId; + + @ApiModelProperty("延期前时间") + @Excel(name = "延期前时间", width = 30, dateFormat = "yyyy-MM-dd") + private Date originTime; + + @ApiModelProperty("延期后时间") + @Excel(name = "延期后时间", width = 30, dateFormat = "yyyy-MM-dd") + private Date changeTime; + + @ApiModelProperty("用户ID") + @Excel(name = "用户ID") + private Long userId; + + @ApiModelProperty("用户类型") + @Excel(name = "用户类型") + private Integer userType; + + @ApiModelProperty("1待确认 2 已确认") + @Excel(name = "1待确认 2 已确认") + private Integer status; + + + + + + + + + + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/orderextensionrecord/model/result/OrderExtensionRecordResult.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/orderextensionrecord/model/result/OrderExtensionRecordResult.java new file mode 100644 index 0000000..4e8f6af --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/orderextensionrecord/model/result/OrderExtensionRecordResult.java @@ -0,0 +1,54 @@ +package com.ruoyi.frequency.orderextensionrecord.model.result; + +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; + +import java.util.Date; + +/** + * 订单延期记录对象 t_order_extension_record + * + * @author liwenlong + * @date 2023-11-03 + */ +@Data +@Accessors(chain = true) +public class OrderExtensionRecordResult extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + @ApiModelProperty("租户号") + private Long id; + + @ApiModelProperty("删除标志;1 正常 2 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("订单ID") + @Excel(name = "订单ID") + private Long orderId; + + @ApiModelProperty("延期前时间") + @Excel(name = "延期前时间", width = 30, dateFormat = "yyyy-MM-dd") + private Date originTime; + + @ApiModelProperty("延期后时间") + @Excel(name = "延期后时间", width = 30, dateFormat = "yyyy-MM-dd") + private Date changeTime; + + @ApiModelProperty("用户ID") + @Excel(name = "用户ID") + private Long userId; + + @ApiModelProperty("用户类型") + @Excel(name = "用户类型") + private Integer userType; + + @ApiModelProperty("1待确认 2 已确认") + @Excel(name = "1待确认 2 已确认") + private Integer status; + + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/orderextensionrecord/service/OrderExtensionRecordService.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/orderextensionrecord/service/OrderExtensionRecordService.java new file mode 100644 index 0000000..7d8d304 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/orderextensionrecord/service/OrderExtensionRecordService.java @@ -0,0 +1,68 @@ +package com.ruoyi.frequency.orderextensionrecord.service; + +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.IService; +import com.ruoyi.common.page.PageResult; +import com.ruoyi.controller.req.OrderChangeRecordPageReq; +import com.ruoyi.frequency.orderextensionrecord.entity.OrderExtensionRecord; +import com.ruoyi.response.ResponseData; +import com.ruoyi.vo.UserVo; + +import java.util.List; + +/** + * 订单延期记录Service接口 + * + * @author liwenlong + * @date 2023-11-03 + */ +public interface OrderExtensionRecordService extends IService +{ + /** + * 查询订单延期记录 + * + * @param id 订单延期记录主键 + * @return 订单延期记录 + */ + public OrderExtensionRecord selectOrderExtensionRecordById(Long id); + + /** + * 查询订单延期记录列表 + * + * @param orderExtensionRecord 订单延期记录 + * @return 订单延期记录集合 + */ + public List selectOrderExtensionRecordList(OrderExtensionRecord orderExtensionRecord); + + /** + * 新增订单延期记录 + * + * @param orderExtensionRecord 订单延期记录 + * @return 结果 + */ + public int insertOrderExtensionRecord(OrderExtensionRecord orderExtensionRecord); + + /** + * 修改订单延期记录 + * + * @param orderExtensionRecord 订单延期记录 + * @return 结果 + */ + public int updateOrderExtensionRecord(OrderExtensionRecord orderExtensionRecord); + + /** + * 批量删除订单延期记录 + * + * @param ids 需要删除的订单延期记录主键集合 + * @return 结果 + */ + public int deleteOrderExtensionRecordByIds(Long[] ids,Integer delFalg); + + /** + * 订单延期记录 + * @param req + * @param userVo + * @return + */ + ResponseData>> orderExtensionRecordPage(OrderChangeRecordPageReq req, UserVo userVo); +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/orderextensionrecord/service/impl/OrderExtensionRecordServiceImpl.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/orderextensionrecord/service/impl/OrderExtensionRecordServiceImpl.java new file mode 100644 index 0000000..4fa3c69 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/orderextensionrecord/service/impl/OrderExtensionRecordServiceImpl.java @@ -0,0 +1,101 @@ +package com.ruoyi.frequency.orderextensionrecord.service.impl; + +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.ruoyi.code.PublicCommon; +import com.ruoyi.common.page.PageResult; +import com.ruoyi.common.utils.DateUtils; +import com.ruoyi.controller.req.OrderChangeRecordPageReq; +import com.ruoyi.frequency.orderextensionrecord.entity.OrderExtensionRecord; +import com.ruoyi.frequency.orderextensionrecord.mapper.OrderExtensionRecordMapper; +import com.ruoyi.frequency.orderextensionrecord.service.OrderExtensionRecordService; +import com.ruoyi.response.ResponseData; +import com.ruoyi.vo.UserVo; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * 订单延期记录Service业务层处理 + * + * @author liwenlong + * @date 2023-11-03 + */ +@Service +public class OrderExtensionRecordServiceImpl extends ServiceImpl implements OrderExtensionRecordService +{ + @Autowired + private OrderExtensionRecordMapper orderExtensionRecordMapper; + + /** + * 查询订单延期记录 + * + * @param id 订单延期记录主键 + * @return 订单延期记录 + */ + @Override + public OrderExtensionRecord selectOrderExtensionRecordById(Long id) + { + return orderExtensionRecordMapper.selectOrderExtensionRecordById(id); + } + + /** + * 查询订单延期记录列表 + * + * @param orderExtensionRecord 订单延期记录 + * @return 订单延期记录 + */ + @Override + public List selectOrderExtensionRecordList(OrderExtensionRecord orderExtensionRecord) + { + return orderExtensionRecordMapper.selectOrderExtensionRecordList(orderExtensionRecord); + } + + /** + * 新增订单延期记录 + * + * @param orderExtensionRecord 订单延期记录 + * @return 结果 + */ + @Override + public int insertOrderExtensionRecord(OrderExtensionRecord orderExtensionRecord) + { + orderExtensionRecord.setCreateTime(DateUtils.getNowDate()); + return orderExtensionRecordMapper.insert(orderExtensionRecord); + } + + /** + * 修改订单延期记录 + * + * @param orderExtensionRecord 订单延期记录 + * @return 结果 + */ + @Override + public int updateOrderExtensionRecord(OrderExtensionRecord orderExtensionRecord) + { + orderExtensionRecord.setUpdateTime(DateUtils.getNowDate()); + return orderExtensionRecordMapper.updateById(orderExtensionRecord); + } + + /** + * 批量删除订单延期记录 + * + * @param ids 需要删除的订单延期记录主键 + * @return 结果 + */ + @Override + public int deleteOrderExtensionRecordByIds(Long[] ids,Integer delFalg) + { + this.lambdaUpdate().set(OrderExtensionRecord::getDelFlag,delFalg).in(OrderExtensionRecord::getId,ids).update(); + return ids.length; + } + + @Override + public ResponseData>> orderExtensionRecordPage(OrderChangeRecordPageReq req, UserVo userVo) { + Page page = this.lambdaQuery().eq(OrderExtensionRecord::getDelFlag,PublicCommon.启用) + .eq(OrderExtensionRecord::getOrderId,req.getOrderId()) + .orderByDesc(OrderExtensionRecord::getCreateTime).page(new Page<>(req.getPageNo(), req.getPageSize())); + return ResponseData.success(new PageResult<>(page)); + } +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/ordermessage/controller/OrderMessageController.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/ordermessage/controller/OrderMessageController.java new file mode 100644 index 0000000..222c833 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/ordermessage/controller/OrderMessageController.java @@ -0,0 +1,91 @@ +package com.ruoyi.frequency.ordermessage.controller; + +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.page.TableDataInfo; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.common.utils.poi.ExcelUtil; +import com.ruoyi.frequency.ordermessage.entity.OrderMessage; +import com.ruoyi.frequency.ordermessage.entity.OrderMessageUtil; +import com.ruoyi.frequency.ordermessage.service.OrderMessageService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +/** + * 订单消息Controller + * + * @author zj + * @date 2023-10-13 + */ +@RestController +@RequestMapping("/frequency/ordermessage") +public class OrderMessageController extends BaseController { + @Autowired + private OrderMessageService orderMessageService; + + /** + * 查询订单消息列表 + */ + @PreAuthorize("@ss.hasPermi('frequency:ordermessage:list')") + @GetMapping("/list") + public TableDataInfo list(OrderMessage orderMessage) { + startPage(); + List list = orderMessageService.selectOrderMessageList(orderMessage); + return getDataTable(list); + } + + /** + * 导出订单消息列表 + */ + @PreAuthorize("@ss.hasPermi('frequency:ordermessage:export')") + @Log(title = "订单消息", businessType = BusinessType.EXPORT) + @GetMapping("/export") + public AjaxResult export(OrderMessage orderMessage) { + List list = orderMessageService.selectOrderMessageList(orderMessage); + ExcelUtil util = new ExcelUtil(OrderMessage.class); + return util.exportExcel(list, "订单消息数据"); + } + + /** + * 获取订单消息详细信息 + */ + @PreAuthorize("@ss.hasPermi('frequency:ordermessage:query')") + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") Long id) { + return AjaxResult.success(orderMessageService.selectOrderMessageById(id)); + } + + /** + * 新增订单消息 + */ + @PreAuthorize("@ss.hasPermi('frequency:ordermessage:add')") + @Log(title = "订单消息", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody OrderMessage orderMessage) { + return toAjax(orderMessageService.insertOrderMessage(orderMessage)); + } + + /** + * 修改订单消息 + */ + @PreAuthorize("@ss.hasPermi('frequency:ordermessage:edit')") + @Log(title = "订单消息", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody OrderMessage orderMessage) { + return toAjax(orderMessageService.updateOrderMessage(orderMessage)); + } + + /** + * 删除订单消息 + */ + @PreAuthorize("@ss.hasPermi('frequency:ordermessage:remove')") + @Log(title = "订单消息", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}") + public AjaxResult remove(@PathVariable Long[] ids) { + return toAjax(orderMessageService.deleteOrderMessageByIds(ids)); + } +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/ordermessage/entity/OrderMessage.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/ordermessage/entity/OrderMessage.java new file mode 100644 index 0000000..4a79a23 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/ordermessage/entity/OrderMessage.java @@ -0,0 +1,78 @@ +package com.ruoyi.frequency.ordermessage.entity; + +import com.baomidou.mybatisplus.annotation.TableField; +import com.ruoyi.controller.resp.MallOrderPageResp; +import com.ruoyi.controller.resp.OrderDetailResp; +import lombok.Data; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.experimental.Accessors; +import com.ruoyi.common.annotation.Excel; +import io.swagger.annotations.ApiModelProperty; +import com.ruoyi.common.core.domain.BaseEntity; + +/** + * 订单消息对象 t_order_message + * + * @author zj + * @date 2023-10-13 + */ +@Data +@Accessors(chain = true) +@TableName("t_order_message") +public class OrderMessage extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + + @ApiModelProperty("主键id") + private Long id; + + @ApiModelProperty("删除标志 1正常 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("订单id") + @Excel(name = "订单id") + private Long orderId; + + @ApiModelProperty("订单类型 1 普通订单 ") + @Excel(name = "订单类型 1 普通订单 ") + private Integer orderType; + + @ApiModelProperty("标题") + @Excel(name = "标题") + private String title; + + @ApiModelProperty("内容") + @Excel(name = "内容") + private String content; + + @ApiModelProperty("1未读 2 已读") + @Excel(name = "1未读 2 已读") + private Integer isRead; + + @ApiModelProperty("用户id") + @Excel(name = "用户id") + private Long userId; + + @ApiModelProperty("$column.columnComment") + @Excel(name = "用户id") + private Integer userType; + + @ApiModelProperty("是否清空 1 不清空 2 清空") + @Excel(name = "是否清空 1 不清空 2 清空") + private Integer isShow; + + @ApiModelProperty("消息类型") + @Excel(name = "消息类型") + private Integer messageType; + + @ApiModelProperty("订单信息") + @TableField(exist = false) + private OrderDetailResp order; + + @ApiModelProperty("商城订单信息") + @TableField(exist = false) + private MallOrderPageResp mallOrder; + + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/ordermessage/mapper/OrderMessageMapper.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/ordermessage/mapper/OrderMessageMapper.java new file mode 100644 index 0000000..94a64df --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/ordermessage/mapper/OrderMessageMapper.java @@ -0,0 +1,69 @@ +package com.ruoyi.frequency.ordermessage.mapper; + +import java.util.List; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.ruoyi.controller.resp.MessageOrderPageResp; +import com.ruoyi.frequency.ordermessage.entity.OrderMessage; +import com.ruoyi.frequency.ordermessage.entity.OrderMessageUtil; +import com.ruoyi.vo.UserVo; +import org.apache.ibatis.annotations.Param; + +/** + * 订单消息Mapper接口 + * + * @author zj + * @date 2023-10-13 + */ +public interface OrderMessageMapper extends BaseMapper +{ + /** + * 查询订单消息 + * + * @param id 订单消息主键 + * @return 订单消息 + */ + public OrderMessage selectOrderMessageById(Long id); + + /** + * 查询订单消息列表 + * + * @param orderMessage 订单消息 + * @return 订单消息集合 + */ + public List selectOrderMessageList(OrderMessage orderMessage); + + /** + * 新增订单消息 + * + * @param orderMessage 订单消息 + * @return 结果 + */ + public int insertOrderMessage(OrderMessage orderMessage); + + /** + * 修改订单消息 + * + * @param orderMessageUtil 订单消息 + * @return 结果 + */ + public int updateOrderMessage(OrderMessage orderMessage); + + /** + * 删除订单消息 + * + * @param id 订单消息主键 + * @return 结果 + */ + public int deleteOrderMessageById(Long id); + + /** + * 批量删除订单消息 + * + * @param ids 需要删除的数据主键集合 + * @return 结果 + */ + public int deleteOrderMessageByIds(Long[] ids); + + Page messageOrderPage(@Param("page") Page page, @Param("userVo") UserVo userVo); +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/ordermessage/mapper/mapping/OrderMessageUtilMapper.xml b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/ordermessage/mapper/mapping/OrderMessageUtilMapper.xml new file mode 100644 index 0000000..c45557d --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/ordermessage/mapper/mapping/OrderMessageUtilMapper.xml @@ -0,0 +1,138 @@ + + + + + + + + + + + + + + + + + + + + + + + + select id, create_by, create_time, update_by, update_time, del_flag, order_id, order_type, title, content, is_read, user_id, user_type, is_show, message_type from t_order_message + + + + + + + + insert into t_order_message + + id, + create_by, + create_time, + update_by, + update_time, + del_flag, + order_id, + order_type, + title, + content, + is_read, + user_id, + user_type, + is_show, + message_type, + + + #{id}, + #{createBy}, + #{createTime}, + #{updateBy}, + #{updateTime}, + #{delFlag}, + #{orderId}, + #{orderType}, + #{title}, + #{content}, + #{isRead}, + #{userId}, + #{userType}, + #{isShow}, + #{messageType}, + + + + + update t_order_message + + create_by = #{createBy}, + create_time = #{createTime}, + update_by = #{updateBy}, + update_time = #{updateTime}, + del_flag = #{delFlag}, + order_id = #{orderId}, + order_type = #{orderType}, + title = #{title}, + content = #{content}, + is_read = #{isRead}, + user_id = #{userId}, + user_type = #{userType}, + is_show = #{isShow}, + message_type = #{messageType}, + + where id = #{id} + + + + delete from t_order_message where id = #{id} + + + + delete from t_order_message where id in + + #{id} + + + + + + + \ No newline at end of file diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/ordermessage/model/param/OrderMessageParam.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/ordermessage/model/param/OrderMessageParam.java new file mode 100644 index 0000000..a460167 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/ordermessage/model/param/OrderMessageParam.java @@ -0,0 +1,75 @@ +package com.ruoyi.frequency.ordermessage.model.param; + +import lombok.Data; +import lombok.experimental.Accessors; +import com.ruoyi.common.annotation.Excel; +import io.swagger.annotations.ApiModelProperty; +import com.ruoyi.common.core.domain.BaseEntity; + +/** + * 订单消息对象 t_order_message + * + * @author zj + * @date 2023-10-13 + */ +@Data +@Accessors(chain = true) +public class OrderMessageParam extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + @ApiModelProperty("主键id") + private Long id; + + @ApiModelProperty("删除标志 1正常 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("订单id") + @Excel(name = "订单id") + private Long orderId; + + @ApiModelProperty("订单类型 1 普通订单 ") + @Excel(name = "订单类型 1 普通订单 ") + private Integer orderType; + + @ApiModelProperty("标题") + @Excel(name = "标题") + private String title; + + @ApiModelProperty("内容") + @Excel(name = "内容") + private String content; + + @ApiModelProperty("1未读 2 已读") + @Excel(name = "1未读 2 已读") + private Integer isRead; + + @ApiModelProperty("用户id") + @Excel(name = "用户id") + private Long userId; + + @ApiModelProperty("$column.columnComment") + @Excel(name = "用户id") + private Integer userType; + + @ApiModelProperty("是否清空 1 不清空 2 清空") + @Excel(name = "是否清空 1 不清空 2 清空") + private Integer isShow; + + @ApiModelProperty("消息类型") + @Excel(name = "消息类型") + private Integer messageType; + + + + + + + + + + + + + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/ordermessage/model/result/OrderMessageResult.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/ordermessage/model/result/OrderMessageResult.java new file mode 100644 index 0000000..6b97ea4 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/ordermessage/model/result/OrderMessageResult.java @@ -0,0 +1,64 @@ +package com.ruoyi.frequency.ordermessage.model.result; + +import lombok.Data; +import lombok.experimental.Accessors; +import com.ruoyi.common.annotation.Excel; +import io.swagger.annotations.ApiModelProperty; +import com.ruoyi.common.core.domain.BaseEntity; + +/** + * 订单消息对象 t_order_message + * + * @author zj + * @date 2023-10-13 + */ +@Data +@Accessors(chain = true) +public class OrderMessageResult extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + @ApiModelProperty("主键id") + private Long id; + + @ApiModelProperty("删除标志 1正常 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("订单id") + @Excel(name = "订单id") + private Long orderId; + + @ApiModelProperty("订单类型 1 普通订单 ") + @Excel(name = "订单类型 1 普通订单 ") + private Integer orderType; + + @ApiModelProperty("标题") + @Excel(name = "标题") + private String title; + + @ApiModelProperty("内容") + @Excel(name = "内容") + private String content; + + @ApiModelProperty("1未读 2 已读") + @Excel(name = "1未读 2 已读") + private Integer isRead; + + @ApiModelProperty("用户id") + @Excel(name = "用户id") + private Long userId; + + @ApiModelProperty("$column.columnComment") + @Excel(name = "用户id") + private Integer userType; + + @ApiModelProperty("是否清空 1 不清空 2 清空") + @Excel(name = "是否清空 1 不清空 2 清空") + private Integer isShow; + + @ApiModelProperty("消息类型") + @Excel(name = "消息类型") + private Integer messageType; + + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/ordermessage/service/OrderMessageService.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/ordermessage/service/OrderMessageService.java new file mode 100644 index 0000000..bfb1fe4 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/ordermessage/service/OrderMessageService.java @@ -0,0 +1,110 @@ +package com.ruoyi.frequency.ordermessage.service; + +import java.util.List; + +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.ruoyi.controller.req.MessageReadOrDeleteReq; +import com.ruoyi.controller.req.OrderMessagePageReq; +import com.ruoyi.controller.resp.MessageOrderPageResp; +import com.ruoyi.enums.message.OrderMessageEnums; +import com.ruoyi.frequency.ordermessage.entity.OrderMessage; +import com.ruoyi.frequency.ordermessage.entity.OrderMessageUtil; +import com.baomidou.mybatisplus.extension.service.IService; +import com.ruoyi.response.ResponseData; +import com.ruoyi.vo.PageBasic; +import com.ruoyi.vo.UserVo; + +/** + * 订单消息Service接口 + * + * @author zj + * @date 2023-10-13 + */ +public interface OrderMessageService extends IService +{ + /** + * 查询订单消息 + * + * @param id 订单消息主键 + * @return 订单消息 + */ + public OrderMessage selectOrderMessageById(Long id); + + /** + * 查询订单消息列表 + * + * @param orderMessage 订单消息 + * @return 订单消息集合 + */ + public List selectOrderMessageList(OrderMessage orderMessage); + + /** + * 新增订单消息 + * + * @param orderMessage 订单消息 + * @return 结果 + */ + public int insertOrderMessage(OrderMessage orderMessage); + + /** + * 修改订单消息 + * + * @param orderMessage 订单消息 + * @return 结果 + */ + public int updateOrderMessage(OrderMessage orderMessage); + + /** + * 批量删除订单消息 + * + * @param ids 需要删除的订单消息主键集合 + * @return 结果 + */ + public int deleteOrderMessageByIds(Long[] ids); + + /** + * 删除订单消息信息 + * + * @param id 订单消息主键 + * @return 结果 + */ + public int deleteOrderMessageById(Long id); + + /** + * 订单消息列表 + * @param req + * @param userVo + * @return + */ + List orderMessageList(OrderMessagePageReq req, UserVo userVo); + + + /** + * 订单消息列表_已读,删除消息 + * @param req + * @param userVo + * @return + */ + ResponseData orderMessageReadOrDelete(MessageReadOrDeleteReq req, UserVo userVo); + + + /** + * 添加订单消息 + * @param userVo + * @param orderId + * @param orderType + * @param orderMessageEnums + */ + void addOrderMessage(UserVo userVo, Long orderId, String orderNo,Integer orderType, OrderMessageEnums orderMessageEnums); + + /** + * 添加订单消息 + * @param userVo + * @param orderId + * @param orderType + * @param orderMessageEnums + */ + void addOrderMessage(UserVo userVo, Long orderId, String orderNo, Integer orderType, OrderMessageEnums orderMessageEnums,String... content); + + Page messageOrderPage(PageBasic req, UserVo userVo); +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/ordermessage/service/impl/OrderMessageServiceImpl.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/ordermessage/service/impl/OrderMessageServiceImpl.java new file mode 100644 index 0000000..f751573 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/ordermessage/service/impl/OrderMessageServiceImpl.java @@ -0,0 +1,279 @@ +package com.ruoyi.frequency.ordermessage.service.impl; + +import cn.hutool.core.collection.CollectionUtil; +import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.StrUtil; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.ruoyi.code.PublicCommon; +import com.ruoyi.common.core.domain.BaseEntity; +import com.ruoyi.common.utils.DateUtils; +import com.ruoyi.controller.req.MessageReadOrDeleteReq; +import com.ruoyi.controller.req.OrderMessagePageReq; +import com.ruoyi.controller.resp.MessageOrderPageResp; +import com.ruoyi.enums.message.OrderMessageEnums; +import com.ruoyi.frequency.ordermessage.entity.OrderMessage; +import com.ruoyi.frequency.ordermessage.mapper.OrderMessageMapper; +import com.ruoyi.frequency.ordermessage.service.OrderMessageService; +import com.ruoyi.push.service.PushService; +import com.ruoyi.response.ResponseData; +import com.ruoyi.vo.PageBasic; +import com.ruoyi.vo.UserVo; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * 订单消息Service业务层处理 + * + * @author zj + * @date 2023-10-13 + */ +@Service +@Transactional(rollbackFor = Exception.class) +public class OrderMessageServiceImpl extends ServiceImpl implements OrderMessageService { + @Autowired + private OrderMessageMapper orderMessageMapper; + + /** + * 查询订单消息 + * + * @param id 订单消息主键 + * @return 订单消息 + */ + @Override + public OrderMessage selectOrderMessageById(Long id) { + return orderMessageMapper.selectOrderMessageById(id); + } + + /** + * 查询订单消息列表 + * + * @param orderMessage 订单消息 + * @return 订单消息 + */ + @Override + public List selectOrderMessageList(OrderMessage orderMessage) { + return orderMessageMapper.selectOrderMessageList(orderMessage); + } + + /** + * 新增订单消息 + * + * @param orderMessage 订单消息 + * @return 结果 + */ + @Override + public int insertOrderMessage(OrderMessage orderMessage) { + orderMessage.setCreateTime(DateUtils.getNowDate()); + return orderMessageMapper.insertOrderMessage(orderMessage); + } + + /** + * 修改订单消息 + * + * @param orderMessage 订单消息 + * @return 结果 + */ + @Override + public int updateOrderMessage(OrderMessage orderMessage) { + orderMessage.setUpdateTime(DateUtils.getNowDate()); + return orderMessageMapper.updateOrderMessage(orderMessage); + } + + /** + * 批量删除订单消息 + * + * @param ids 需要删除的订单消息主键 + * @return 结果 + */ + @Override + public int deleteOrderMessageByIds(Long[] ids) { + this.lambdaUpdate().set(OrderMessage::getDelFlag, PublicCommon.删除).in(OrderMessage::getId, ids).update(); + return ids.length; + } + + /** + * 删除订单消息信息 + * + * @param id 订单消息主键 + * @return 结果 + */ + @Override + public int deleteOrderMessageById(Long id) { + this.lambdaUpdate().set(OrderMessage::getDelFlag, PublicCommon.删除).eq(OrderMessage::getId, id).update(); + return 1; + } + + @Override + public List orderMessageList(OrderMessagePageReq req, UserVo userVo) { + List orderMessageList = this.baseMapper.selectList(new QueryWrapper().lambda() + .eq(OrderMessage::getUserType, userVo.getUserType()).eq(OrderMessage::getUserId, userVo.getUserId()) + .eq(OrderMessage::getIsShow, PublicCommon.Message.未清空) + .eq(OrderMessage::getOrderId, req.getOrderId()) + .eq(OrderMessage::getOrderType, req.getOrderType()) + .eq(OrderMessage::getDelFlag, PublicCommon.启用).orderByDesc(OrderMessage::getCreateTime)); + return orderMessageList; + } + + + @Override + public ResponseData orderMessageReadOrDelete(MessageReadOrDeleteReq req, UserVo userVo) { + //1 标记已读 2 删除消息 + switch (req.getType()) { + case 1: + this.update().set("is_read", PublicCommon.Message.已读) + .eq("user_type", userVo.getUserType()) + .eq("user_id", userVo.getUserId()) + .eq("is_read", PublicCommon.Message.未读) + .eq(req.getOrderId() != null, "order_id", req.getOrderId()) + .eq(req.getOrderType() != null, "order_type", req.getOrderType()) + .in(CollectionUtil.isNotEmpty(req.getIds()), "id", req.getIds()).update(); + break; + case 2: + + this.update().set("is_show", PublicCommon.Message.清空) + .set("is_read", PublicCommon.Message.已读) + .eq("user_type", userVo.getUserType()) + .eq("user_id", userVo.getUserId()) + .eq("is_show", PublicCommon.Message.未清空) + .eq(req.getOrderId() != null, "order_id", req.getOrderId()) + .eq(req.getOrderType() != null, "order_type", req.getOrderType()) + .in(CollectionUtil.isNotEmpty(req.getIds()), "id", req.getIds()).update(); + break; + + default: + throw new IllegalStateException("Unexpected value: " + req.getType()); + } + return ResponseData.success(); + } + + @Autowired + private PushService pushService; + + /** + * 添加订单消息 + * + * @param userVo + * @param orderId + * @param orderType + */ + @Override + public void addOrderMessage(UserVo userVo, Long orderId, String orderNo, Integer orderType, OrderMessageEnums orderMessageEnums) { + + OrderMessage orderMessage = new OrderMessage() + .setMessageType(orderMessageEnums.getCode()) + .setTitle(orderMessageEnums.getTitle()) + .setContent(orderMessageEnums.getContent().replace("orderNo", orderNo)) + .setUserId(userVo.getUserId()) + .setUserType(userVo.getUserType()) + .setOrderId(orderId) + .setOrderType(orderType); + this.baseMapper.insert(orderMessage); + + //推送 + pushService.push(userVo, orderId, orderNo, orderMessage.getId(), orderMessageEnums); + + } + + + @Override + public void addOrderMessage(UserVo userVo, Long orderId, String orderNo, Integer orderType, OrderMessageEnums orderMessageEnums, String... content) { + OrderMessage orderMessage = new OrderMessage() + .setMessageType(orderMessageEnums.getCode()) + .setTitle(orderMessageEnums.getTitle()) + .setContent(String.format(orderMessageEnums.getContent(), content)) + .setUserId(userVo.getUserId()) + .setUserType(userVo.getUserType()) + .setOrderId(orderId) + .setOrderType(orderType); + + this.baseMapper.insert(orderMessage); + + //推送 + pushService.push(userVo, orderId, orderNo, orderMessage.getId(), orderMessageEnums); + } + + @Override + public Page messageOrderPage(PageBasic req, UserVo userVo) { + Page messageOrderPage = baseMapper.messageOrderPage(new Page<>(req.getPageNo(), req.getPageSize()), userVo); + if (CollectionUtil.isEmpty(messageOrderPage.getRecords())) { + return messageOrderPage; + } + List orderIds = new ArrayList<>(); + orderIds.add(-1L); + + List mallOrderIds = new ArrayList<>(); + mallOrderIds.add(-1L); + + List allOrderIds = new ArrayList<>(); + allOrderIds.add(-1L); + + Map messageOrderPageRespMap = new HashMap<>(); + + messageOrderPage.getRecords().stream().forEach(s -> { + if (ObjectUtil.equal(PublicCommon.Order.订单, s.getOrderType())) { + orderIds.add(s.getOrderId()); + } else { + mallOrderIds.add(s.getOrderId()); + } + + allOrderIds.add(s.getOrderId()); + + messageOrderPageRespMap.put(s.getOrderType() + "," + s.getOrderId(), s); + }); + + // 是否有未读消息 + List orderMessageList = this.baseMapper.selectList(new QueryWrapper().lambda() + .eq(OrderMessage::getUserType, userVo.getUserType()).eq(OrderMessage::getUserId, userVo.getUserId()) + .eq(OrderMessage::getIsShow, PublicCommon.Message.未清空) + .in(OrderMessage::getOrderId, allOrderIds) + .eq(OrderMessage::getIsRead, PublicCommon.Message.未读) + .eq(OrderMessage::getDelFlag, PublicCommon.启用)); + + Map hasNotReadMap = new HashMap<>(); + orderMessageList.stream().forEach(x -> { + hasNotReadMap.put(x.getOrderType() + "," + x.getOrderId(), true); + }); + + messageOrderPage.getRecords().stream().forEach(s -> { + s.setIsRead(hasNotReadMap.containsKey(s.getOrderType() + "," + s.getOrderId()) ? 1 : 2); + }); + + //最新消息 + orderMessageList = this.baseMapper.selectList(new QueryWrapper().lambda() + .eq(OrderMessage::getUserType, userVo.getUserType()).eq(OrderMessage::getUserId, userVo.getUserId()) + .eq(OrderMessage::getIsShow, PublicCommon.Message.未清空) + .in(OrderMessage::getOrderId, allOrderIds) + .eq(OrderMessage::getDelFlag, PublicCommon.启用).orderByDesc(BaseEntity::getCreateTime)); + + orderMessageList.stream().forEach(x -> { + if (StrUtil.isNotBlank(x.getContent())) { + + MessageOrderPageResp messageOrderPageResp = messageOrderPageRespMap.get(x.getOrderType() + "," + x.getOrderId()); + if (messageOrderPageResp != null && StrUtil.isBlank(messageOrderPageResp.getTitle()) && StrUtil.isNotBlank(x.getTitle())) { + messageOrderPageResp.setContent(x.getContent()); + messageOrderPageResp.setTitle(x.getTitle()); + messageOrderPageResp.setMessageType(x.getMessageType()); + messageOrderPageResp.setCreateTime(x.getCreateTime()); + } + } + }); + + messageOrderPage.getRecords().stream().forEach(s -> { + s.setIsRead(hasNotReadMap.containsKey(s.getOrderType() + "," + s.getOrderId()) ? 1 : 2); + }); + + return messageOrderPage; + } + + public static void main(String[] args) { + System.out.println((7350+8200) * 8 - 1750*8); + } +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/orderoperatorhistory/controller/OrderOperatorHistoryController.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/orderoperatorhistory/controller/OrderOperatorHistoryController.java new file mode 100644 index 0000000..5e94a0f --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/orderoperatorhistory/controller/OrderOperatorHistoryController.java @@ -0,0 +1,90 @@ +package com.ruoyi.frequency.orderoperatorhistory.controller; + +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.page.TableDataInfo; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.common.utils.poi.ExcelUtil; +import com.ruoyi.frequency.orderoperatorhistory.entity.OrderOperatorHistory; +import com.ruoyi.frequency.orderoperatorhistory.service.OrderOperatorHistoryService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +/** + * 订单操作记录Controller + * + * @author liwenlong + * @date 2024-06-12 + */ +@RestController +@RequestMapping("/frequency/orderoperatorhistory") +public class OrderOperatorHistoryController extends BaseController { + @Autowired + private OrderOperatorHistoryService orderOperatorHistoryService; + + /** + * 查询订单操作记录列表 + */ +// @PreAuthorize("@ss.hasPermi('frequency:orderoperatorhistory:list')") + @PostMapping("/list") + public TableDataInfo list(@RequestBody OrderOperatorHistory orderOperatorHistory) { + startPage(); + List list = orderOperatorHistoryService.selectOrderOperatorHistoryList(orderOperatorHistory); + return getDataTable(list); + } + + /** + * 导出订单操作记录列表 + */ +// @PreAuthorize("@ss.hasPermi('frequency:orderoperatorhistory:export')") + @Log(title = "订单操作记录", businessType = BusinessType.EXPORT) + @GetMapping("/export") + public AjaxResult export(OrderOperatorHistory orderOperatorHistory) { + List list = orderOperatorHistoryService.selectOrderOperatorHistoryList(orderOperatorHistory); + ExcelUtil util = new ExcelUtil(OrderOperatorHistory.class); + return util.exportExcel(list, "订单操作记录数据"); + } + + /** + * 获取订单操作记录详细信息 + */ +// @PreAuthorize("@ss.hasPermi('frequency:orderoperatorhistory:query')") + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") Long id) { + return AjaxResult.success(orderOperatorHistoryService.selectOrderOperatorHistoryById(id)); + } + + /** + * 新增订单操作记录 + */ +// @PreAuthorize("@ss.hasPermi('frequency:orderoperatorhistory:add')") + @Log(title = "订单操作记录", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody OrderOperatorHistory orderOperatorHistory) { + return toAjax(orderOperatorHistoryService.insertOrderOperatorHistory(orderOperatorHistory)); + } + + /** + * 修改订单操作记录 + */ +// @PreAuthorize("@ss.hasPermi('frequency:orderoperatorhistory:edit')") + @Log(title = "订单操作记录", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody OrderOperatorHistory orderOperatorHistory) { + return toAjax(orderOperatorHistoryService.updateOrderOperatorHistory(orderOperatorHistory)); + } + + /** + * 删除订单操作记录 + */ +// @PreAuthorize("@ss.hasPermi('frequency:orderoperatorhistory:remove')") + @Log(title = "订单操作记录", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}/{delFlag}") + public AjaxResult remove(@PathVariable("ids") Long[] ids, @PathVariable("delFlag") Integer delFlag) { + return toAjax(orderOperatorHistoryService.deleteOrderOperatorHistoryByIds(ids, delFlag)); + } +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/orderoperatorhistory/entity/OrderOperatorHistory.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/orderoperatorhistory/entity/OrderOperatorHistory.java new file mode 100644 index 0000000..faa8d4d --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/orderoperatorhistory/entity/OrderOperatorHistory.java @@ -0,0 +1,92 @@ +package com.ruoyi.frequency.orderoperatorhistory.entity; + +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableName; +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import com.ruoyi.vo.UserInfo; +import com.ruoyi.vo.UserVo; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; + +import java.util.Date; + +/** + * 订单操作记录对象 t_order_operator_history + * + * @author liwenlong + * @date 2024-06-12 + */ +@Data +@Accessors(chain = true) +@TableName("t_order_operator_history") +public class OrderOperatorHistory extends BaseEntity { + private static final long serialVersionUID = 1L; + + + @ApiModelProperty("租户号") + private Long id; + + @ApiModelProperty("删除标志;1 正常 2 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("订单id") + @Excel(name = "订单id") + private Long orderId; + + @ApiModelProperty("操作类型") + @Excel(name = "操作类型") + private String type; + + @ApiModelProperty("操作内容") + @Excel(name = "操作内容") + private String content; + + @ApiModelProperty("用户id") + @Excel(name = "用户id") + private Long userId; + + @ApiModelProperty("用户类型") + @Excel(name = "用户类型") + private Integer userType; + + @ApiModelProperty("操作端口 1 app 2 管理后台") + private Integer ports; + + @ApiModelProperty("用户信息") + @TableField(exist = false) + private UserInfo userInfo; + + @ApiModelProperty("操作人") + @TableField(exist = false) + private String operatorUser; + + @ApiModelProperty("开始时间") + @TableField(exist = false) + private Date beginTime; + + @ApiModelProperty("结束时间") + @TableField(exist = false) + private Date endTime; + + public static OrderOperatorHistory addAppHistory(Long orderId,String type, String content, UserVo userVo) { + OrderOperatorHistory orderOperatorHistory = new OrderOperatorHistory(); + orderOperatorHistory.setPorts(1); + orderOperatorHistory.setType(type); + orderOperatorHistory.setContent(content); + orderOperatorHistory.setUserId(userVo.getUserId()); + orderOperatorHistory.setUserType(userVo.getUserType()); + orderOperatorHistory.setOrderId(orderId); + return orderOperatorHistory; + } + + public static OrderOperatorHistory addBackHistory(Long orderId,String type, String content) { + OrderOperatorHistory orderOperatorHistory = new OrderOperatorHistory(); + orderOperatorHistory.setPorts(2); + orderOperatorHistory.setType(type); + orderOperatorHistory.setContent(content); + orderOperatorHistory.setOrderId(orderId); + return orderOperatorHistory; + } +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/orderoperatorhistory/mapper/OrderOperatorHistoryMapper.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/orderoperatorhistory/mapper/OrderOperatorHistoryMapper.java new file mode 100644 index 0000000..dd08d7e --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/orderoperatorhistory/mapper/OrderOperatorHistoryMapper.java @@ -0,0 +1,47 @@ +package com.ruoyi.frequency.orderoperatorhistory.mapper; + +import java.util.List; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.ruoyi.frequency.orderoperatorhistory.entity.OrderOperatorHistory; + +/** + * 订单操作记录Mapper接口 + * + * @author liwenlong + * @date 2024-06-12 + */ +public interface OrderOperatorHistoryMapper extends BaseMapper +{ + /** + * 查询订单操作记录 + * + * @param id 订单操作记录主键 + * @return 订单操作记录 + */ + public OrderOperatorHistory selectOrderOperatorHistoryById(Long id); + + /** + * 查询订单操作记录列表 + * + * @param orderOperatorHistory 订单操作记录 + * @return 订单操作记录集合 + */ + public List selectOrderOperatorHistoryList(OrderOperatorHistory orderOperatorHistory); + + /** + * 新增订单操作记录 + * + * @param orderOperatorHistory 订单操作记录 + * @return 结果 + */ + public int insertOrderOperatorHistory(OrderOperatorHistory orderOperatorHistory); + + /** + * 修改订单操作记录 + * + * @param orderOperatorHistory 订单操作记录 + * @return 结果 + */ + public int updateOrderOperatorHistory(OrderOperatorHistory orderOperatorHistory); + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/orderoperatorhistory/mapper/mapping/OrderOperatorHistoryMapper.xml b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/orderoperatorhistory/mapper/mapping/OrderOperatorHistoryMapper.xml new file mode 100644 index 0000000..347630c --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/orderoperatorhistory/mapper/mapping/OrderOperatorHistoryMapper.xml @@ -0,0 +1,127 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + select + t.id , + t.create_by , + t.create_time , + t.update_by , + t.update_time , + t.del_flag , + t.order_id , + t.type, + t.content , + t.user_id , + t.user_type, + t.ports + from t_order_operator_history AS t + + + + + + + + + insert into t_order_operator_history + + id, + create_by, + create_time, + update_by, + update_time, + del_flag, + order_id, + type, + content, + user_id, + user_type, + ports, + + + #{id}, + #{createBy}, + #{createTime}, + #{updateBy}, + #{updateTime}, + #{delFlag}, + #{orderId}, + #{type}, + #{content}, + #{userId}, + #{userType}, + #{ports}, + + + + + update t_order_operator_history + + create_by = #{createBy}, + create_time = #{createTime}, + update_by = #{updateBy}, + update_time = #{updateTime}, + del_flag = #{delFlag}, + order_id = #{orderId}, + type = #{type}, + content = #{content}, + user_id = #{userId}, + user_type = #{userType}, + ports = #{ports}, + + where id = #{id} + + + \ No newline at end of file diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/orderoperatorhistory/model/param/OrderOperatorHistoryParam.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/orderoperatorhistory/model/param/OrderOperatorHistoryParam.java new file mode 100644 index 0000000..efab3a6 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/orderoperatorhistory/model/param/OrderOperatorHistoryParam.java @@ -0,0 +1,56 @@ +package com.ruoyi.frequency.orderoperatorhistory.model.param; + +import lombok.Data; +import lombok.experimental.Accessors; +import com.ruoyi.common.annotation.Excel; +import io.swagger.annotations.ApiModelProperty; +import com.ruoyi.common.core.domain.BaseEntity; + +/** + * 订单操作记录对象 t_order_operator_history + * + * @author liwenlong + * @date 2024-06-12 + */ +@Data +@Accessors(chain = true) +public class OrderOperatorHistoryParam extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + @ApiModelProperty("租户号") + private Long id; + + @ApiModelProperty("删除标志;1 正常 2 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("订单id") + @Excel(name = "订单id") + private Long orderId; + + @ApiModelProperty("操作类型") + @Excel(name = "操作类型") + private String type; + + @ApiModelProperty("操作内容") + @Excel(name = "操作内容") + private String content; + + @ApiModelProperty("用户id") + @Excel(name = "用户id") + private Long userId; + + @ApiModelProperty("用户类型") + @Excel(name = "用户类型") + private Integer userType; + + + @ApiModelProperty("操作端口 1 app 2 管理后台") + private Integer ports; + + + + + + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/orderoperatorhistory/model/result/OrderOperatorHistoryResult.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/orderoperatorhistory/model/result/OrderOperatorHistoryResult.java new file mode 100644 index 0000000..59963ea --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/orderoperatorhistory/model/result/OrderOperatorHistoryResult.java @@ -0,0 +1,50 @@ +package com.ruoyi.frequency.orderoperatorhistory.model.result; + +import lombok.Data; +import lombok.experimental.Accessors; +import com.ruoyi.common.annotation.Excel; +import io.swagger.annotations.ApiModelProperty; +import com.ruoyi.common.core.domain.BaseEntity; + +/** + * 订单操作记录对象 t_order_operator_history + * + * @author liwenlong + * @date 2024-06-12 + */ +@Data +@Accessors(chain = true) +public class OrderOperatorHistoryResult extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + @ApiModelProperty("租户号") + private Long id; + + @ApiModelProperty("删除标志;1 正常 2 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("订单id") + @Excel(name = "订单id") + private Long orderId; + + @ApiModelProperty("操作类型") + @Excel(name = "操作类型") + private String type; + + @ApiModelProperty("操作内容") + @Excel(name = "操作内容") + private String content; + + @ApiModelProperty("用户id") + @Excel(name = "用户id") + private Long userId; + + @ApiModelProperty("用户类型") + @Excel(name = "用户类型") + private Integer userType; + + @ApiModelProperty("操作端口 1 app 2 管理后台") + private Integer ports; + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/orderoperatorhistory/service/OrderOperatorHistoryService.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/orderoperatorhistory/service/OrderOperatorHistoryService.java new file mode 100644 index 0000000..b7aaab4 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/orderoperatorhistory/service/OrderOperatorHistoryService.java @@ -0,0 +1,55 @@ +package com.ruoyi.frequency.orderoperatorhistory.service; + +import java.util.List; +import com.ruoyi.frequency.orderoperatorhistory.entity.OrderOperatorHistory; +import com.baomidou.mybatisplus.extension.service.IService; + +/** + * 订单操作记录Service接口 + * + * @author liwenlong + * @date 2024-06-12 + */ +public interface OrderOperatorHistoryService extends IService +{ + /** + * 查询订单操作记录 + * + * @param id 订单操作记录主键 + * @return 订单操作记录 + */ + public OrderOperatorHistory selectOrderOperatorHistoryById(Long id); + + /** + * 查询订单操作记录列表 + * + * @param orderOperatorHistory 订单操作记录 + * @return 订单操作记录集合 + */ + public List selectOrderOperatorHistoryList(OrderOperatorHistory orderOperatorHistory); + + /** + * 新增订单操作记录 + * + * @param orderOperatorHistory 订单操作记录 + * @return 结果 + */ + public int insertOrderOperatorHistory(OrderOperatorHistory orderOperatorHistory); + + /** + * 修改订单操作记录 + * + * @param orderOperatorHistory 订单操作记录 + * @return 结果 + */ + public int updateOrderOperatorHistory(OrderOperatorHistory orderOperatorHistory); + + /** + * 批量删除订单操作记录 + * + * @param ids 需要删除的订单操作记录主键集合 + * @return 结果 + */ + public int deleteOrderOperatorHistoryByIds(Long[] ids,Integer delFlag); + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/orderoperatorhistory/service/impl/OrderOperatorHistoryServiceImpl.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/orderoperatorhistory/service/impl/OrderOperatorHistoryServiceImpl.java new file mode 100644 index 0000000..f748ca6 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/orderoperatorhistory/service/impl/OrderOperatorHistoryServiceImpl.java @@ -0,0 +1,139 @@ +package com.ruoyi.frequency.orderoperatorhistory.service.impl; + +import cn.hutool.core.util.ObjectUtil; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.ruoyi.common.core.domain.entity.SysUser; +import com.ruoyi.common.utils.SecurityUtils; +import com.ruoyi.enums.user.UserEnums; +import com.ruoyi.frequency.customer.entity.Customer; +import com.ruoyi.frequency.customer.service.CustomerService; +import com.ruoyi.frequency.orderoperatorhistory.entity.OrderOperatorHistory; +import com.ruoyi.frequency.orderoperatorhistory.mapper.OrderOperatorHistoryMapper; +import com.ruoyi.frequency.orderoperatorhistory.service.OrderOperatorHistoryService; +import com.ruoyi.frequency.sale.entity.Sale; +import com.ruoyi.frequency.sale.service.SaleService; +import com.ruoyi.frequency.store.entity.Store; +import com.ruoyi.frequency.store.service.StoreService; +import com.ruoyi.system.service.ISysUserService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * 订单操作记录Service业务层处理 + * + * @author liwenlong + * @date 2024-06-12 + */ +@Service +public class OrderOperatorHistoryServiceImpl extends ServiceImpl implements OrderOperatorHistoryService { + @Autowired + private OrderOperatorHistoryMapper orderOperatorHistoryMapper; + + /** + * 查询订单操作记录 + * + * @param id 订单操作记录主键 + * @return 订单操作记录 + */ + @Override + public OrderOperatorHistory selectOrderOperatorHistoryById(Long id) { + return orderOperatorHistoryMapper.selectOrderOperatorHistoryById(id); + } + + @Autowired + private SaleService saleService; + @Autowired + private StoreService storeService; + @Autowired + private CustomerService customerService; + @Autowired + private ISysUserService iSysUserService; + + /** + * 查询订单操作记录列表 + * + * @param orderOperatorHistory 订单操作记录 + * @return 订单操作记录 + */ + @Override + public List selectOrderOperatorHistoryList(OrderOperatorHistory orderOperatorHistory) { + List orderOperatorHistories = orderOperatorHistoryMapper.selectOrderOperatorHistoryList(orderOperatorHistory); + orderOperatorHistories.stream().forEach(x -> { + if (x.getPorts() == 1) { + if (ObjectUtil.equal(x.getUserType(), UserEnums.customer.getCode())) { + Customer customer = customerService.getById(x.getUserId()); + x.setOperatorUser("编号:"+customer.getNickname() + "; 手机号:" + customer.getMobile() + "; 昵称" + customer.getName()); + } else if (ObjectUtil.equal(x.getUserType(), UserEnums.store.getCode())) { + Store store = storeService.getById(x.getUserId()); + x.setOperatorUser("编号:"+store.getNickname() + "; 手机号:" + store.getMobile() + "; 昵称" + store.getName()); + } else if (ObjectUtil.equal(x.getUserType(), UserEnums.sale.getCode())) { + Sale sale = saleService.getById(x.getUserId()); + x.setOperatorUser("编号:"+sale.getNickname() + "; 手机号:" + sale.getMobile() + "; 姓名:" + sale.getName()); + } + } else { + SysUser sysUser = iSysUserService.selectUserById(Long.valueOf(x.getCreateBy())); + if (sysUser != null) { + x.setOperatorUser("账号:"+sysUser.getUserName() + "; 昵称:" + sysUser.getNickName()); + } + } + }); + return orderOperatorHistories; + } + + + /** + * 新增订单操作记录 + * + * @param orderOperatorHistory 订单操作记录 + * @return 结果 + */ + @Override + public int insertOrderOperatorHistory(OrderOperatorHistory orderOperatorHistory) { + orderOperatorHistory.setCreateData(); +// StringBuilder content = new StringBuilder(); +// if (orderOperatorHistory.getUserId() == null || orderOperatorHistory.getUserType() == null) { +// content.append("后台用户【账号:" + SecurityUtils.getLoginUser().getUser().getUserName() + ";昵称:" + SecurityUtils.getLoginUser().getUser().getNickName() + "】"); +// } else { +// if (orderOperatorHistory.getUserType().equals(UserEnums.customer.getCode())) { +// Customer customer = customerService.getById(orderOperatorHistory.getUserId()); +// content.append("设计师【账号:" + customer.getMobile() + ";编号:" + customer.getNickname() + ";昵称:" + customer.getName() + "】"); +// } else if (orderOperatorHistory.getUserType().equals(UserEnums.store.getCode())) { +// Store store = storeService.getById(orderOperatorHistory.getUserId()); +// content.append("表现师【账号:" + store.getMobile() + ";编号:" + store.getNickname() + ";昵称:" + store.getName() + "】"); +// } else if (orderOperatorHistory.getUserType().equals(UserEnums.sale.getCode())) { +// Sale sale = saleService.getById(orderOperatorHistory.getUserId()); +// content.append("推广员【账号:" + sale.getMobile() + ";编号:" + sale.getNickname() + ";姓名:" + sale.getName() + "】"); +// } +// } +// content.append(orderOperatorHistory.getContent()); +// orderOperatorHistory.setContent(content.toString()); + return orderOperatorHistoryMapper.insert(orderOperatorHistory); + } + + /** + * 修改订单操作记录 + * + * @param orderOperatorHistory 订单操作记录 + * @return 结果 + */ + @Override + public int updateOrderOperatorHistory(OrderOperatorHistory orderOperatorHistory) { + orderOperatorHistory.setUpdateData(); + return orderOperatorHistoryMapper.updateOrderOperatorHistory(orderOperatorHistory); + } + + /** + * 批量删除订单操作记录 + * + * @param ids 需要删除的订单操作记录主键 + * @return 结果 + */ + @Override + public int deleteOrderOperatorHistoryByIds(Long[] ids, Integer delFlag) { + this.lambdaUpdate().set(OrderOperatorHistory::getDelFlag, delFlag).in(OrderOperatorHistory::getId, ids).update(); + return ids.length; + } + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/orderpanorama/controller/OrderPanoramaController.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/orderpanorama/controller/OrderPanoramaController.java new file mode 100644 index 0000000..87b7af2 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/orderpanorama/controller/OrderPanoramaController.java @@ -0,0 +1,103 @@ +package com.ruoyi.frequency.orderpanorama.controller; + +import java.util.List; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.frequency.orderpanorama.entity.OrderPanorama; +import com.ruoyi.frequency.orderpanorama.service.OrderPanoramaService; +import com.ruoyi.common.utils.poi.ExcelUtil; +import com.ruoyi.common.core.page.TableDataInfo; + +/** + * 订单和3D链接关联Controller + * + * @author zj + * @date 2023-10-13 + */ +@RestController +@RequestMapping("/frequency/orderpanorama") +public class OrderPanoramaController extends BaseController +{ + @Autowired + private OrderPanoramaService orderPanoramaService; + + /** + * 查询订单和3D链接关联列表 + */ + @PreAuthorize("@ss.hasPermi('frequency:orderpanorama:list')") + @GetMapping("/list") + public TableDataInfo list(OrderPanorama orderPanorama) + { + startPage(); + List list = orderPanoramaService.selectOrderPanoramaList(orderPanorama); + return getDataTable(list); + } + + /** + * 导出订单和3D链接关联列表 + */ + @PreAuthorize("@ss.hasPermi('frequency:orderpanorama:export')") + @Log(title = "订单和3D链接关联", businessType = BusinessType.EXPORT) + @GetMapping("/export") + public AjaxResult export(OrderPanorama orderPanorama) + { + List list = orderPanoramaService.selectOrderPanoramaList(orderPanorama); + ExcelUtil util = new ExcelUtil(OrderPanorama.class); + return util.exportExcel(list, "订单和3D链接关联数据"); + } + + /** + * 获取订单和3D链接关联详细信息 + */ + @PreAuthorize("@ss.hasPermi('frequency:orderpanorama:query')") + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") Long id) + { + return AjaxResult.success(orderPanoramaService.selectOrderPanoramaById(id)); + } + + /** + * 新增订单和3D链接关联 + */ + @PreAuthorize("@ss.hasPermi('frequency:orderpanorama:add')") + @Log(title = "订单和3D链接关联", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody OrderPanorama orderPanorama) + { + return toAjax(orderPanoramaService.insertOrderPanorama(orderPanorama)); + } + + /** + * 修改订单和3D链接关联 + */ + @PreAuthorize("@ss.hasPermi('frequency:orderpanorama:edit')") + @Log(title = "订单和3D链接关联", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody OrderPanorama orderPanorama) + { + return toAjax(orderPanoramaService.updateOrderPanorama(orderPanorama)); + } + + /** + * 删除订单和3D链接关联 + */ + @PreAuthorize("@ss.hasPermi('frequency:orderpanorama:remove')") + @Log(title = "订单和3D链接关联", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}") + public AjaxResult remove(@PathVariable Long[] ids) + { + return toAjax(orderPanoramaService.deleteOrderPanoramaByIds(ids)); + } +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/orderpanorama/entity/OrderPanorama.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/orderpanorama/entity/OrderPanorama.java new file mode 100644 index 0000000..0a1ca94 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/orderpanorama/entity/OrderPanorama.java @@ -0,0 +1,46 @@ +package com.ruoyi.frequency.orderpanorama.entity; + +import java.util.Date; +import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.Data; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.experimental.Accessors; +import com.ruoyi.common.annotation.Excel; +import io.swagger.annotations.ApiModelProperty; +import com.ruoyi.common.core.domain.BaseEntity; + +/** + * 订单和3D链接关联对象 t_order_panorama + * + * @author zj + * @date 2023-10-13 + */ +@Data +@Accessors(chain = true) +@TableName("t_order_panorama") +public class OrderPanorama extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + + @ApiModelProperty("租户号") + private Long id; + + + @ApiModelProperty("删除标志;1 正常 2 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("订单id") + @Excel(name = "订单id") + private Long orderId; + + @ApiModelProperty("全景图链接") + @Excel(name = "全景图链接") + private String panoramaImage; + + @ApiModelProperty("全景图链接封面") + @Excel(name = "全景图链接封面") + private String panorama; + + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/orderpanorama/mapper/OrderPanoramaMapper.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/orderpanorama/mapper/OrderPanoramaMapper.java new file mode 100644 index 0000000..e7c14ee --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/orderpanorama/mapper/OrderPanoramaMapper.java @@ -0,0 +1,62 @@ +package com.ruoyi.frequency.orderpanorama.mapper; + +import java.util.List; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.ruoyi.frequency.orderpanorama.entity.OrderPanorama; + +/** + * 订单和3D链接关联Mapper接口 + * + * @author zj + * @date 2023-10-13 + */ +public interface OrderPanoramaMapper extends BaseMapper +{ + /** + * 查询订单和3D链接关联 + * + * @param id 订单和3D链接关联主键 + * @return 订单和3D链接关联 + */ + public OrderPanorama selectOrderPanoramaById(Long id); + + /** + * 查询订单和3D链接关联列表 + * + * @param orderPanorama 订单和3D链接关联 + * @return 订单和3D链接关联集合 + */ + public List selectOrderPanoramaList(OrderPanorama orderPanorama); + + /** + * 新增订单和3D链接关联 + * + * @param orderPanorama 订单和3D链接关联 + * @return 结果 + */ + public int insertOrderPanorama(OrderPanorama orderPanorama); + + /** + * 修改订单和3D链接关联 + * + * @param orderPanorama 订单和3D链接关联 + * @return 结果 + */ + public int updateOrderPanorama(OrderPanorama orderPanorama); + + /** + * 删除订单和3D链接关联 + * + * @param id 订单和3D链接关联主键 + * @return 结果 + */ + public int deleteOrderPanoramaById(Long id); + + /** + * 批量删除订单和3D链接关联 + * + * @param ids 需要删除的数据主键集合 + * @return 结果 + */ + public int deleteOrderPanoramaByIds(Long[] ids); +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/orderpanorama/mapper/mapping/OrderPanoramaMapper.xml b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/orderpanorama/mapper/mapping/OrderPanoramaMapper.xml new file mode 100644 index 0000000..e4b3a73 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/orderpanorama/mapper/mapping/OrderPanoramaMapper.xml @@ -0,0 +1,89 @@ + + + + + + + + + + + + + + + + + + select id, create_by, create_time, update_by, update_time, del_flag, order_id, panorama_image, panorama from t_order_panorama + + + + + + + + insert into t_order_panorama + + id, + create_by, + create_time, + update_by, + update_time, + del_flag, + order_id, + panorama_image, + panorama, + + + #{id}, + #{createBy}, + #{createTime}, + #{updateBy}, + #{updateTime}, + #{delFlag}, + #{orderId}, + #{panoramaImage}, + #{panorama}, + + + + + update t_order_panorama + + create_by = #{createBy}, + create_time = #{createTime}, + update_by = #{updateBy}, + update_time = #{updateTime}, + del_flag = #{delFlag}, + order_id = #{orderId}, + panorama_image = #{panoramaImage}, + panorama = #{panorama}, + + where id = #{id} + + + + delete from t_order_panorama where id = #{id} + + + + delete from t_order_panorama where id in + + #{id} + + + \ No newline at end of file diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/orderpanorama/model/param/OrderPanoramaParam.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/orderpanorama/model/param/OrderPanoramaParam.java new file mode 100644 index 0000000..920daec --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/orderpanorama/model/param/OrderPanoramaParam.java @@ -0,0 +1,49 @@ +package com.ruoyi.frequency.orderpanorama.model.param; + +import java.util.Date; +import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.Data; +import lombok.experimental.Accessors; +import com.ruoyi.common.annotation.Excel; +import io.swagger.annotations.ApiModelProperty; +import com.ruoyi.common.core.domain.BaseEntity; + +/** + * 订单和3D链接关联对象 t_order_panorama + * + * @author zj + * @date 2023-10-13 + */ +@Data +@Accessors(chain = true) +public class OrderPanoramaParam extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + @ApiModelProperty("租户号") + private Long id; + + + @ApiModelProperty("删除标志;1 正常 2 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("订单id") + @Excel(name = "订单id") + private String orderId; + + @ApiModelProperty("全景图链接") + @Excel(name = "全景图链接") + private String panoramaImage; + + @ApiModelProperty("全景图链接封面") + @Excel(name = "全景图链接封面") + private String panorama; + + + + + + + + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/orderpanorama/model/result/OrderPanoramaResult.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/orderpanorama/model/result/OrderPanoramaResult.java new file mode 100644 index 0000000..41099c1 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/orderpanorama/model/result/OrderPanoramaResult.java @@ -0,0 +1,43 @@ +package com.ruoyi.frequency.orderpanorama.model.result; + +import java.util.Date; +import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.Data; +import lombok.experimental.Accessors; +import com.ruoyi.common.annotation.Excel; +import io.swagger.annotations.ApiModelProperty; +import com.ruoyi.common.core.domain.BaseEntity; + +/** + * 订单和3D链接关联对象 t_order_panorama + * + * @author zj + * @date 2023-10-13 + */ +@Data +@Accessors(chain = true) +public class OrderPanoramaResult extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + @ApiModelProperty("租户号") + private Long id; + + + @ApiModelProperty("删除标志;1 正常 2 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("订单id") + @Excel(name = "订单id") + private String orderId; + + @ApiModelProperty("全景图链接") + @Excel(name = "全景图链接") + private String panoramaImage; + + @ApiModelProperty("全景图链接封面") + @Excel(name = "全景图链接封面") + private String panorama; + + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/orderpanorama/service/OrderPanoramaService.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/orderpanorama/service/OrderPanoramaService.java new file mode 100644 index 0000000..6001f38 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/orderpanorama/service/OrderPanoramaService.java @@ -0,0 +1,62 @@ +package com.ruoyi.frequency.orderpanorama.service; + +import java.util.List; +import com.ruoyi.frequency.orderpanorama.entity.OrderPanorama; +import com.baomidou.mybatisplus.extension.service.IService; + +/** + * 订单和3D链接关联Service接口 + * + * @author zj + * @date 2023-10-13 + */ +public interface OrderPanoramaService extends IService +{ + /** + * 查询订单和3D链接关联 + * + * @param id 订单和3D链接关联主键 + * @return 订单和3D链接关联 + */ + public OrderPanorama selectOrderPanoramaById(Long id); + + /** + * 查询订单和3D链接关联列表 + * + * @param orderPanorama 订单和3D链接关联 + * @return 订单和3D链接关联集合 + */ + public List selectOrderPanoramaList(OrderPanorama orderPanorama); + + /** + * 新增订单和3D链接关联 + * + * @param orderPanorama 订单和3D链接关联 + * @return 结果 + */ + public int insertOrderPanorama(OrderPanorama orderPanorama); + + /** + * 修改订单和3D链接关联 + * + * @param orderPanorama 订单和3D链接关联 + * @return 结果 + */ + public int updateOrderPanorama(OrderPanorama orderPanorama); + + /** + * 批量删除订单和3D链接关联 + * + * @param ids 需要删除的订单和3D链接关联主键集合 + * @return 结果 + */ + public int deleteOrderPanoramaByIds(Long[] ids); + + /** + * 删除订单和3D链接关联信息 + * + * @param id 订单和3D链接关联主键 + * @return 结果 + */ + public int deleteOrderPanoramaById(Long id); +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/orderpanorama/service/impl/OrderPanoramaServiceImpl.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/orderpanorama/service/impl/OrderPanoramaServiceImpl.java new file mode 100644 index 0000000..dfc6b33 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/orderpanorama/service/impl/OrderPanoramaServiceImpl.java @@ -0,0 +1,101 @@ +package com.ruoyi.frequency.orderpanorama.service.impl; + +import java.util.List; +import com.ruoyi.common.utils.DateUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.ruoyi.code.PublicCommon; +import com.ruoyi.frequency.orderpanorama.mapper.OrderPanoramaMapper; +import com.ruoyi.frequency.orderpanorama.entity.OrderPanorama; +import com.ruoyi.frequency.orderpanorama.service.OrderPanoramaService; +import org.springframework.transaction.annotation.Transactional; + +/** + * 订单和3D链接关联Service业务层处理 + * + * @author zj + * @date 2023-10-13 + */ +@Service +@Transactional(rollbackFor = Exception.class) +public class OrderPanoramaServiceImpl extends ServiceImpl implements OrderPanoramaService +{ + @Autowired + private OrderPanoramaMapper orderPanoramaMapper; + + /** + * 查询订单和3D链接关联 + * + * @param id 订单和3D链接关联主键 + * @return 订单和3D链接关联 + */ + @Override + public OrderPanorama selectOrderPanoramaById(Long id) + { + return orderPanoramaMapper.selectOrderPanoramaById(id); + } + + /** + * 查询订单和3D链接关联列表 + * + * @param orderPanorama 订单和3D链接关联 + * @return 订单和3D链接关联 + */ + @Override + public List selectOrderPanoramaList(OrderPanorama orderPanorama) + { + return orderPanoramaMapper.selectOrderPanoramaList(orderPanorama); + } + + /** + * 新增订单和3D链接关联 + * + * @param orderPanorama 订单和3D链接关联 + * @return 结果 + */ + @Override + public int insertOrderPanorama(OrderPanorama orderPanorama) + { + return orderPanoramaMapper.insertOrderPanorama(orderPanorama); + } + + /** + * 修改订单和3D链接关联 + * + * @param orderPanorama 订单和3D链接关联 + * @return 结果 + */ + @Override + public int updateOrderPanorama(OrderPanorama orderPanorama) + { + orderPanorama.setUpdateTime(DateUtils.getNowDate()); + return orderPanoramaMapper.updateOrderPanorama(orderPanorama); + } + + /** + * 批量删除订单和3D链接关联 + * + * @param ids 需要删除的订单和3D链接关联主键 + * @return 结果 + */ + @Override + public int deleteOrderPanoramaByIds(Long[] ids) + { + this.lambdaUpdate().set(OrderPanorama::getDelFlag,PublicCommon.删除).in(OrderPanorama::getId,ids).update(); + return ids.length; + } + + /** + * 删除订单和3D链接关联信息 + * + * @param id 订单和3D链接关联主键 + * @return 结果 + */ + @Override + public int deleteOrderPanoramaById(Long id) + { + this.lambdaUpdate().set(OrderPanorama::getDelFlag,PublicCommon.删除).eq(OrderPanorama::getId,id).update(); + return 1; + } +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/orderpricerecord/controller/OrderPriceRecordController.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/orderpricerecord/controller/OrderPriceRecordController.java new file mode 100644 index 0000000..e6427ca --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/orderpricerecord/controller/OrderPriceRecordController.java @@ -0,0 +1,103 @@ +package com.ruoyi.frequency.orderpricerecord.controller; + +import java.util.List; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.frequency.orderpricerecord.entity.OrderPriceRecord; +import com.ruoyi.frequency.orderpricerecord.service.OrderPriceRecordService; +import com.ruoyi.common.utils.poi.ExcelUtil; +import com.ruoyi.common.core.page.TableDataInfo; + +/** + * 订单价格明细记录Controller + * + * @author liwenlong + * @date 2024-01-24 + */ +@RestController +@RequestMapping("/frequency/orderpricerecord") +public class OrderPriceRecordController extends BaseController +{ + @Autowired + private OrderPriceRecordService orderPriceRecordService; + + /** + * 查询订单价格明细记录列表 + */ + @PreAuthorize("@ss.hasPermi('frequency:orderpricerecord:list')") + @GetMapping("/list") + public TableDataInfo list(OrderPriceRecord orderPriceRecord) + { + startPage(); + List list = orderPriceRecordService.selectOrderPriceRecordList(orderPriceRecord); + return getDataTable(list); + } + + /** + * 导出订单价格明细记录列表 + */ + @PreAuthorize("@ss.hasPermi('frequency:orderpricerecord:export')") + @Log(title = "订单价格明细记录", businessType = BusinessType.EXPORT) + @GetMapping("/export") + public AjaxResult export(OrderPriceRecord orderPriceRecord) + { + List list = orderPriceRecordService.selectOrderPriceRecordList(orderPriceRecord); + ExcelUtil util = new ExcelUtil(OrderPriceRecord.class); + return util.exportExcel(list, "订单价格明细记录数据"); + } + + /** + * 获取订单价格明细记录详细信息 + */ + @PreAuthorize("@ss.hasPermi('frequency:orderpricerecord:query')") + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") Long id) + { + return AjaxResult.success(orderPriceRecordService.selectOrderPriceRecordById(id)); + } + + /** + * 新增订单价格明细记录 + */ + @PreAuthorize("@ss.hasPermi('frequency:orderpricerecord:add')") + @Log(title = "订单价格明细记录", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody OrderPriceRecord orderPriceRecord) + { + return toAjax(orderPriceRecordService.insertOrderPriceRecord(orderPriceRecord)); + } + + /** + * 修改订单价格明细记录 + */ + @PreAuthorize("@ss.hasPermi('frequency:orderpricerecord:edit')") + @Log(title = "订单价格明细记录", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody OrderPriceRecord orderPriceRecord) + { + return toAjax(orderPriceRecordService.updateOrderPriceRecord(orderPriceRecord)); + } + + /** + * 删除订单价格明细记录 + */ + @PreAuthorize("@ss.hasPermi('frequency:orderpricerecord:remove')") + @Log(title = "订单价格明细记录", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}/{delFlag}") + public AjaxResult remove(@PathVariable("ids") Long[] ids,@PathVariable("delFlag") Integer delFlag) + { + return toAjax(orderPriceRecordService.deleteOrderPriceRecordByIds(ids,delFlag)); + } +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/orderpricerecord/entity/OrderPriceRecord.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/orderpricerecord/entity/OrderPriceRecord.java new file mode 100644 index 0000000..774dcef --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/orderpricerecord/entity/OrderPriceRecord.java @@ -0,0 +1,51 @@ +package com.ruoyi.frequency.orderpricerecord.entity; + +import java.math.BigDecimal; +import lombok.Data; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.experimental.Accessors; +import com.ruoyi.common.annotation.Excel; +import io.swagger.annotations.ApiModelProperty; +import com.baomidou.mybatisplus.annotation.TableField; +import com.ruoyi.vo.UserInfo; +import com.ruoyi.common.core.domain.BaseEntity; + +/** + * 订单价格明细记录对象 t_order_price_record + * + * @author liwenlong + * @date 2024-01-24 + */ +@Data +@Accessors(chain = true) +@TableName("t_order_price_record") +public class OrderPriceRecord extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + + @ApiModelProperty("租户号") + private Long id; + + @ApiModelProperty("删除标志;1 正常 2 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("订单ID") + @Excel(name = "订单ID") + private Long orderId; + + @ApiModelProperty("类型") + @Excel(name = "类型") + private Integer type; + + @ApiModelProperty("价格") + @Excel(name = "价格") + private BigDecimal price; + + @ApiModelProperty("类型名称") + @Excel(name = "类型名称") + private String name; + + + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/orderpricerecord/mapper/OrderPriceRecordMapper.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/orderpricerecord/mapper/OrderPriceRecordMapper.java new file mode 100644 index 0000000..aa0393c --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/orderpricerecord/mapper/OrderPriceRecordMapper.java @@ -0,0 +1,47 @@ +package com.ruoyi.frequency.orderpricerecord.mapper; + +import java.util.List; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.ruoyi.frequency.orderpricerecord.entity.OrderPriceRecord; + +/** + * 订单价格明细记录Mapper接口 + * + * @author liwenlong + * @date 2024-01-24 + */ +public interface OrderPriceRecordMapper extends BaseMapper +{ + /** + * 查询订单价格明细记录 + * + * @param id 订单价格明细记录主键 + * @return 订单价格明细记录 + */ + public OrderPriceRecord selectOrderPriceRecordById(Long id); + + /** + * 查询订单价格明细记录列表 + * + * @param orderPriceRecord 订单价格明细记录 + * @return 订单价格明细记录集合 + */ + public List selectOrderPriceRecordList(OrderPriceRecord orderPriceRecord); + + /** + * 新增订单价格明细记录 + * + * @param orderPriceRecord 订单价格明细记录 + * @return 结果 + */ + public int insertOrderPriceRecord(OrderPriceRecord orderPriceRecord); + + /** + * 修改订单价格明细记录 + * + * @param orderPriceRecord 订单价格明细记录 + * @return 结果 + */ + public int updateOrderPriceRecord(OrderPriceRecord orderPriceRecord); + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/orderpricerecord/mapper/mapping/OrderPriceRecordMapper.xml b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/orderpricerecord/mapper/mapping/OrderPriceRecordMapper.xml new file mode 100644 index 0000000..c81088e --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/orderpricerecord/mapper/mapping/OrderPriceRecordMapper.xml @@ -0,0 +1,98 @@ + + + + + + + + + + + + + + + + + + + + + select + t.id , + t.create_by , + t.create_time , + t.update_by , + t.update_time , + t.del_flag , + t.order_id , + t.type , + t.price , + t.name + from t_order_price_record AS t + + + + + + + + + insert into t_order_price_record + + id, + create_by, + create_time, + update_by, + update_time, + del_flag, + order_id, + type, + price, + name, + + + #{id}, + #{createBy}, + #{createTime}, + #{updateBy}, + #{updateTime}, + #{delFlag}, + #{orderId}, + #{type}, + #{price}, + #{name}, + + + + + update t_order_price_record + + create_by = #{createBy}, + create_time = #{createTime}, + update_by = #{updateBy}, + update_time = #{updateTime}, + del_flag = #{delFlag}, + order_id = #{orderId}, + type = #{type}, + price = #{price}, + name = #{name}, + + where id = #{id} + + \ No newline at end of file diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/orderpricerecord/model/param/OrderPriceRecordParam.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/orderpricerecord/model/param/OrderPriceRecordParam.java new file mode 100644 index 0000000..01bf31a --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/orderpricerecord/model/param/OrderPriceRecordParam.java @@ -0,0 +1,51 @@ +package com.ruoyi.frequency.orderpricerecord.model.param; + +import java.math.BigDecimal; +import lombok.Data; +import lombok.experimental.Accessors; +import com.ruoyi.common.annotation.Excel; +import io.swagger.annotations.ApiModelProperty; +import com.ruoyi.common.core.domain.BaseEntity; + +/** + * 订单价格明细记录对象 t_order_price_record + * + * @author liwenlong + * @date 2024-01-24 + */ +@Data +@Accessors(chain = true) +public class OrderPriceRecordParam extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + @ApiModelProperty("租户号") + private Long id; + + @ApiModelProperty("删除标志;1 正常 2 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("订单ID") + @Excel(name = "订单ID") + private Long orderId; + + @ApiModelProperty("类型") + @Excel(name = "类型") + private Long type; + + @ApiModelProperty("价格") + @Excel(name = "价格") + private BigDecimal price; + + @ApiModelProperty("类型名称") + @Excel(name = "类型名称") + private String name; + + + + + + + + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/orderpricerecord/model/result/OrderPriceRecordResult.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/orderpricerecord/model/result/OrderPriceRecordResult.java new file mode 100644 index 0000000..9e3484f --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/orderpricerecord/model/result/OrderPriceRecordResult.java @@ -0,0 +1,45 @@ +package com.ruoyi.frequency.orderpricerecord.model.result; + +import java.math.BigDecimal; +import lombok.Data; +import lombok.experimental.Accessors; +import com.ruoyi.common.annotation.Excel; +import io.swagger.annotations.ApiModelProperty; +import com.ruoyi.common.core.domain.BaseEntity; + +/** + * 订单价格明细记录对象 t_order_price_record + * + * @author liwenlong + * @date 2024-01-24 + */ +@Data +@Accessors(chain = true) +public class OrderPriceRecordResult extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + @ApiModelProperty("租户号") + private Long id; + + @ApiModelProperty("删除标志;1 正常 2 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("订单ID") + @Excel(name = "订单ID") + private Long orderId; + + @ApiModelProperty("类型") + @Excel(name = "类型") + private Long type; + + @ApiModelProperty("价格") + @Excel(name = "价格") + private BigDecimal price; + + @ApiModelProperty("类型名称") + @Excel(name = "类型名称") + private String name; + + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/orderpricerecord/service/OrderPriceRecordService.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/orderpricerecord/service/OrderPriceRecordService.java new file mode 100644 index 0000000..6b593db --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/orderpricerecord/service/OrderPriceRecordService.java @@ -0,0 +1,65 @@ +package com.ruoyi.frequency.orderpricerecord.service; + +import java.math.BigDecimal; +import java.util.List; + +import com.ruoyi.enums.order.OrderPriceEnums; +import com.ruoyi.frequency.orderpricerecord.entity.OrderPriceRecord; +import com.baomidou.mybatisplus.extension.service.IService; + +/** + * 订单价格明细记录Service接口 + * + * @author liwenlong + * @date 2024-01-24 + */ +public interface OrderPriceRecordService extends IService +{ + /** + * 查询订单价格明细记录 + * + * @param id 订单价格明细记录主键 + * @return 订单价格明细记录 + */ + public OrderPriceRecord selectOrderPriceRecordById(Long id); + + /** + * 查询订单价格明细记录列表 + * + * @param orderPriceRecord 订单价格明细记录 + * @return 订单价格明细记录集合 + */ + public List selectOrderPriceRecordList(OrderPriceRecord orderPriceRecord); + + /** + * 新增订单价格明细记录 + * + * @param orderPriceRecord 订单价格明细记录 + * @return 结果 + */ + public int insertOrderPriceRecord(OrderPriceRecord orderPriceRecord); + + /** + * 修改订单价格明细记录 + * + * @param orderPriceRecord 订单价格明细记录 + * @return 结果 + */ + public int updateOrderPriceRecord(OrderPriceRecord orderPriceRecord); + + /** + * 批量删除订单价格明细记录 + * + * @param ids 需要删除的订单价格明细记录主键集合 + * @return 结果 + */ + public int deleteOrderPriceRecordByIds(Long[] ids,Integer delFlag); + + /** + * 订单金额流水 + * @param orderPriceEnums + * @param id + * @param amount + */ + void addOrderPriceRecord(OrderPriceEnums orderPriceEnums, Long id, BigDecimal amount); +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/orderpricerecord/service/impl/OrderPriceRecordServiceImpl.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/orderpricerecord/service/impl/OrderPriceRecordServiceImpl.java new file mode 100644 index 0000000..2a1e74f --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/orderpricerecord/service/impl/OrderPriceRecordServiceImpl.java @@ -0,0 +1,96 @@ +package com.ruoyi.frequency.orderpricerecord.service.impl; + +import java.math.BigDecimal; +import java.util.List; +import com.ruoyi.common.utils.DateUtils; +import com.ruoyi.enums.order.OrderPriceEnums; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.ruoyi.code.PublicCommon; +import com.ruoyi.frequency.orderpricerecord.mapper.OrderPriceRecordMapper; +import com.ruoyi.frequency.orderpricerecord.entity.OrderPriceRecord; +import com.ruoyi.frequency.orderpricerecord.service.OrderPriceRecordService; + +/** + * 订单价格明细记录Service业务层处理 + * + * @author liwenlong + * @date 2024-01-24 + */ +@Service +public class OrderPriceRecordServiceImpl extends ServiceImpl implements OrderPriceRecordService { + @Autowired + private OrderPriceRecordMapper orderPriceRecordMapper; + + /** + * 查询订单价格明细记录 + * + * @param id 订单价格明细记录主键 + * @return 订单价格明细记录 + */ + @Override + public OrderPriceRecord selectOrderPriceRecordById(Long id) { + return orderPriceRecordMapper.selectOrderPriceRecordById(id); + } + + /** + * 查询订单价格明细记录列表 + * + * @param orderPriceRecord 订单价格明细记录 + * @return 订单价格明细记录 + */ + @Override + public List selectOrderPriceRecordList(OrderPriceRecord orderPriceRecord) { + return orderPriceRecordMapper.selectOrderPriceRecordList(orderPriceRecord); + } + + /** + * 新增订单价格明细记录 + * + * @param orderPriceRecord 订单价格明细记录 + * @return 结果 + */ + @Override + public int insertOrderPriceRecord(OrderPriceRecord orderPriceRecord) { + orderPriceRecord.setCreateData(); + return orderPriceRecordMapper.insert(orderPriceRecord); + } + + /** + * 修改订单价格明细记录 + * + * @param orderPriceRecord 订单价格明细记录 + * @return 结果 + */ + @Override + public int updateOrderPriceRecord(OrderPriceRecord orderPriceRecord) { + orderPriceRecord.setUpdateData(); + return orderPriceRecordMapper.updateOrderPriceRecord(orderPriceRecord); + } + + /** + * 批量删除订单价格明细记录 + * + * @param ids 需要删除的订单价格明细记录主键 + * @return 结果 + */ + @Override + public int deleteOrderPriceRecordByIds(Long[] ids, Integer delFlag) { + this.lambdaUpdate().set(OrderPriceRecord::getDelFlag, delFlag).in(OrderPriceRecord::getId, ids).update(); + return ids.length; + } + + @Override + public void addOrderPriceRecord(OrderPriceEnums orderPriceEnums, Long id, BigDecimal amount) { + OrderPriceRecord orderPriceRecord = new OrderPriceRecord(); + orderPriceRecord.setOrderId(id); + orderPriceRecord.setType(orderPriceEnums.getCode()); + orderPriceRecord.setPrice(amount); + orderPriceRecord.setCreateData(); + orderPriceRecord.setName(orderPriceEnums.getName()); + orderPriceRecordMapper.insert(orderPriceRecord); + } + + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/orderreceiving/controller/OrderReceivingController.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/orderreceiving/controller/OrderReceivingController.java new file mode 100644 index 0000000..c610967 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/orderreceiving/controller/OrderReceivingController.java @@ -0,0 +1,97 @@ +package com.ruoyi.frequency.orderreceiving.controller; + +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.page.TableDataInfo; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.common.utils.poi.ExcelUtil; +import com.ruoyi.frequency.orderreceiving.entity.OrderReceiving; +import com.ruoyi.frequency.orderreceiving.service.OrderReceivingService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +/** + * 现师接单Controller + * + * @author zj + * @date 2023-10-13 + */ +@RestController +@RequestMapping("/frequency/orderreceiving") +public class OrderReceivingController extends BaseController +{ + @Autowired + private OrderReceivingService orderReceivingService; + + /** + * 查询现师接单列表 + */ + @PreAuthorize("@ss.hasPermi('frequency:orderreceiving:list')") + @PostMapping("/list") + public TableDataInfo list(@RequestBody OrderReceiving orderReceiving) + { + startPage(); + List list = orderReceivingService.selectOrderReceivingList(orderReceiving); + return getDataTable(list); + } + + /** + * 导出现师接单列表 + */ + @PreAuthorize("@ss.hasPermi('frequency:orderreceiving:export')") + @Log(title = "现师接单", businessType = BusinessType.EXPORT) + @GetMapping("/export") + public AjaxResult export(OrderReceiving orderReceiving) + { + List list = orderReceivingService.selectOrderReceivingList(orderReceiving); + ExcelUtil util = new ExcelUtil(OrderReceiving.class); + return util.exportExcel(list, "现师接单数据"); + } + + /** + * 获取现师接单详细信息 + */ + @PreAuthorize("@ss.hasPermi('frequency:orderreceiving:query')") + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") Long id) + { + return AjaxResult.success(orderReceivingService.selectOrderReceivingById(id)); + } + + /** + * 新增现师接单 + */ + @PreAuthorize("@ss.hasPermi('frequency:orderreceiving:add')") + @Log(title = "现师接单", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody OrderReceiving orderReceiving) + { + return toAjax(orderReceivingService.insertOrderReceiving(orderReceiving)); + } + + /** + * 修改现师接单 + */ + @PreAuthorize("@ss.hasPermi('frequency:orderreceiving:edit')") + @Log(title = "现师接单", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody OrderReceiving orderReceiving) + { + return toAjax(orderReceivingService.updateOrderReceiving(orderReceiving)); + } + + /** + * 删除现师接单 + */ + @PreAuthorize("@ss.hasPermi('frequency:orderreceiving:remove')") + @Log(title = "现师接单", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}") + public AjaxResult remove(@PathVariable Long[] ids) + { + return toAjax(orderReceivingService.deleteOrderReceivingByIds(ids)); + } +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/orderreceiving/entity/OrderReceiving.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/orderreceiving/entity/OrderReceiving.java new file mode 100644 index 0000000..7929166 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/orderreceiving/entity/OrderReceiving.java @@ -0,0 +1,50 @@ +package com.ruoyi.frequency.orderreceiving.entity; + +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableName; +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import com.ruoyi.vo.UserInfo; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; + +/** + * 现师接单对象 t_order_receiving + * + * @author zj + * @date 2023-10-13 + */ +@Data +@Accessors(chain = true) +@TableName("t_order_receiving") +public class OrderReceiving extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + + @ApiModelProperty("租户号") + private Long id; + + @ApiModelProperty("删除标志;1 正常 2 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("订单id") + @Excel(name = "订单id") + private Long orderId; + + @ApiModelProperty("表现师id") + @Excel(name = "表现师id") + private Long storeId; + + @ApiModelProperty("接单状态;1等待接单 2接单成功 3接单失败") + @Excel(name = "接单状态;1等待接单 2接单成功 3接单失败") + private Integer receivingStatus; + + + @ApiModelProperty("表现师信息") + @TableField(exist = false) + private UserInfo userInfo; + + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/orderreceiving/mapper/OrderReceivingMapper.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/orderreceiving/mapper/OrderReceivingMapper.java new file mode 100644 index 0000000..82fc717 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/orderreceiving/mapper/OrderReceivingMapper.java @@ -0,0 +1,63 @@ +package com.ruoyi.frequency.orderreceiving.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.ruoyi.frequency.orderreceiving.entity.OrderReceiving; + +import java.util.List; + +/** + * 现师接单Mapper接口 + * + * @author zj + * @date 2023-10-13 + */ +public interface OrderReceivingMapper extends BaseMapper +{ + /** + * 查询现师接单 + * + * @param id 现师接单主键 + * @return 现师接单 + */ + public OrderReceiving selectOrderReceivingById(Long id); + + /** + * 查询现师接单列表 + * + * @param orderReceiving 现师接单 + * @return 现师接单集合 + */ + public List selectOrderReceivingList(OrderReceiving orderReceiving); + + /** + * 新增现师接单 + * + * @param orderReceiving 现师接单 + * @return 结果 + */ + public int insertOrderReceiving(OrderReceiving orderReceiving); + + /** + * 修改现师接单 + * + * @param orderReceiving 现师接单 + * @return 结果 + */ + public int updateOrderReceiving(OrderReceiving orderReceiving); + + /** + * 删除现师接单 + * + * @param id 现师接单主键 + * @return 结果 + */ + public int deleteOrderReceivingById(Long id); + + /** + * 批量删除现师接单 + * + * @param ids 需要删除的数据主键集合 + * @return 结果 + */ + public int deleteOrderReceivingByIds(Long[] ids); +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/orderreceiving/mapper/mapping/OrderReceivingMapper.xml b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/orderreceiving/mapper/mapping/OrderReceivingMapper.xml new file mode 100644 index 0000000..f204f6e --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/orderreceiving/mapper/mapping/OrderReceivingMapper.xml @@ -0,0 +1,89 @@ + + + + + + + + + + + + + + + + + + select id, create_by, create_time, update_by, update_time, del_flag, order_id, store_id, receiving_status from t_order_receiving + + + + + + + + insert into t_order_receiving + + id, + create_by, + create_time, + update_by, + update_time, + del_flag, + order_id, + store_id, + receiving_status, + + + #{id}, + #{createBy}, + #{createTime}, + #{updateBy}, + #{updateTime}, + #{delFlag}, + #{orderId}, + #{storeId}, + #{receivingStatus}, + + + + + update t_order_receiving + + create_by = #{createBy}, + create_time = #{createTime}, + update_by = #{updateBy}, + update_time = #{updateTime}, + del_flag = #{delFlag}, + order_id = #{orderId}, + store_id = #{storeId}, + receiving_status = #{receivingStatus}, + + where id = #{id} + + + + delete from t_order_receiving where id = #{id} + + + + delete from t_order_receiving where id in + + #{id} + + + \ No newline at end of file diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/orderreceiving/model/param/OrderReceivingParam.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/orderreceiving/model/param/OrderReceivingParam.java new file mode 100644 index 0000000..c0b64a0 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/orderreceiving/model/param/OrderReceivingParam.java @@ -0,0 +1,47 @@ +package com.ruoyi.frequency.orderreceiving.model.param; + +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; + +/** + * 现师接单对象 t_order_receiving + * + * @author zj + * @date 2023-10-13 + */ +@Data +@Accessors(chain = true) +public class OrderReceivingParam extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + @ApiModelProperty("租户号") + private Long id; + + + @ApiModelProperty("删除标志;1 正常 2 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("订单id") + @Excel(name = "订单id") + private Long orderId; + + @ApiModelProperty("表现师id") + @Excel(name = "表现师id") + private Long storeId; + + @ApiModelProperty("接单状态;1等待接单 2接单成功 3接单失败") + @Excel(name = "接单状态;1等待接单 2接单成功 3接单失败") + private Integer receivingStatus; + + + + + + + + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/orderreceiving/model/result/OrderReceivingResult.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/orderreceiving/model/result/OrderReceivingResult.java new file mode 100644 index 0000000..dc24c72 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/orderreceiving/model/result/OrderReceivingResult.java @@ -0,0 +1,41 @@ +package com.ruoyi.frequency.orderreceiving.model.result; + +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; + +/** + * 现师接单对象 t_order_receiving + * + * @author zj + * @date 2023-10-13 + */ +@Data +@Accessors(chain = true) +public class OrderReceivingResult extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + @ApiModelProperty("租户号") + private Long id; + + + @ApiModelProperty("删除标志;1 正常 2 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("订单id") + @Excel(name = "订单id") + private Long orderId; + + @ApiModelProperty("表现师id") + @Excel(name = "表现师id") + private Long storeId; + + @ApiModelProperty("接单状态;1等待接单 2接单成功 3接单失败") + @Excel(name = "接单状态;1等待接单 2接单成功 3接单失败") + private Integer receivingStatus; + + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/orderreceiving/service/OrderReceivingService.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/orderreceiving/service/OrderReceivingService.java new file mode 100644 index 0000000..595d966 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/orderreceiving/service/OrderReceivingService.java @@ -0,0 +1,63 @@ +package com.ruoyi.frequency.orderreceiving.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.ruoyi.frequency.orderreceiving.entity.OrderReceiving; + +import java.util.List; + +/** + * 现师接单Service接口 + * + * @author zj + * @date 2023-10-13 + */ +public interface OrderReceivingService extends IService +{ + /** + * 查询现师接单 + * + * @param id 现师接单主键 + * @return 现师接单 + */ + public OrderReceiving selectOrderReceivingById(Long id); + + /** + * 查询现师接单列表 + * + * @param orderReceiving 现师接单 + * @return 现师接单集合 + */ + public List selectOrderReceivingList(OrderReceiving orderReceiving); + + /** + * 新增现师接单 + * + * @param orderReceiving 现师接单 + * @return 结果 + */ + public int insertOrderReceiving(OrderReceiving orderReceiving); + + /** + * 修改现师接单 + * + * @param orderReceiving 现师接单 + * @return 结果 + */ + public int updateOrderReceiving(OrderReceiving orderReceiving); + + /** + * 批量删除现师接单 + * + * @param ids 需要删除的现师接单主键集合 + * @return 结果 + */ + public int deleteOrderReceivingByIds(Long[] ids); + + /** + * 删除现师接单信息 + * + * @param id 现师接单主键 + * @return 结果 + */ + public int deleteOrderReceivingById(Long id); +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/orderreceiving/service/impl/OrderReceivingServiceImpl.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/orderreceiving/service/impl/OrderReceivingServiceImpl.java new file mode 100644 index 0000000..e151c8d --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/orderreceiving/service/impl/OrderReceivingServiceImpl.java @@ -0,0 +1,102 @@ +package com.ruoyi.frequency.orderreceiving.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.ruoyi.code.PublicCommon; +import com.ruoyi.common.utils.DateUtils; +import com.ruoyi.frequency.orderreceiving.entity.OrderReceiving; +import com.ruoyi.frequency.orderreceiving.mapper.OrderReceivingMapper; +import com.ruoyi.frequency.orderreceiving.service.OrderReceivingService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.List; + +/** + * 现师接单Service业务层处理 + * + * @author zj + * @date 2023-10-13 + */ +@Service +@Transactional(rollbackFor = Exception.class) +public class OrderReceivingServiceImpl extends ServiceImpl implements OrderReceivingService +{ + @Autowired + private OrderReceivingMapper orderReceivingMapper; + + /** + * 查询现师接单 + * + * @param id 现师接单主键 + * @return 现师接单 + */ + @Override + public OrderReceiving selectOrderReceivingById(Long id) + { + return orderReceivingMapper.selectOrderReceivingById(id); + } + + /** + * 查询现师接单列表 + * + * @param orderReceiving 现师接单 + * @return 现师接单 + */ + @Override + public List selectOrderReceivingList(OrderReceiving orderReceiving) + { + return orderReceivingMapper.selectOrderReceivingList(orderReceiving); + } + + /** + * 新增现师接单 + * + * @param orderReceiving 现师接单 + * @return 结果 + */ + @Override + public int insertOrderReceiving(OrderReceiving orderReceiving) + { + return orderReceivingMapper.insertOrderReceiving(orderReceiving); + } + + /** + * 修改现师接单 + * + * @param orderReceiving 现师接单 + * @return 结果 + */ + @Override + public int updateOrderReceiving(OrderReceiving orderReceiving) + { + orderReceiving.setUpdateTime(DateUtils.getNowDate()); + return orderReceivingMapper.updateOrderReceiving(orderReceiving); + } + + /** + * 批量删除现师接单 + * + * @param ids 需要删除的现师接单主键 + * @return 结果 + */ + @Override + public int deleteOrderReceivingByIds(Long[] ids) + { + this.lambdaUpdate().set(OrderReceiving::getDelFlag,PublicCommon.删除).in(OrderReceiving::getId,ids).update(); + return ids.length; + } + + /** + * 删除现师接单信息 + * + * @param id 现师接单主键 + * @return 结果 + */ + @Override + public int deleteOrderReceivingById(Long id) + { + this.lambdaUpdate().set(OrderReceiving::getDelFlag,PublicCommon.删除).eq(OrderReceiving::getId,id).update(); + return 1; + } +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/platformanswer/controller/PlatformAnswerController.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/platformanswer/controller/PlatformAnswerController.java new file mode 100644 index 0000000..7015e60 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/platformanswer/controller/PlatformAnswerController.java @@ -0,0 +1,103 @@ +package com.ruoyi.frequency.platformanswer.controller; + +import java.util.List; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.frequency.platformanswer.entity.PlatformAnswer; +import com.ruoyi.frequency.platformanswer.service.PlatformAnswerService; +import com.ruoyi.common.utils.poi.ExcelUtil; +import com.ruoyi.common.core.page.TableDataInfo; + +/** + * 平台有问必答Controller + * + * @author liwenlong + * @date 2024-01-24 + */ +@RestController +@RequestMapping("/frequency/platformanswer") +public class PlatformAnswerController extends BaseController +{ + @Autowired + private PlatformAnswerService platformAnswerService; + + /** + * 查询平台有问必答列表 + */ + @PreAuthorize("@ss.hasPermi('frequency:platformanswer:list')") + @PostMapping("/list") + public TableDataInfo list(@RequestBody PlatformAnswer platformAnswer) + { + startPage(); + List list = platformAnswerService.selectPlatformAnswerList(platformAnswer); + return getDataTable(list); + } + + /** + * 导出平台有问必答列表 + */ + @PreAuthorize("@ss.hasPermi('frequency:platformanswer:export')") + @Log(title = "平台有问必答", businessType = BusinessType.EXPORT) + @GetMapping("/export") + public AjaxResult export(PlatformAnswer platformAnswer) + { + List list = platformAnswerService.selectPlatformAnswerList(platformAnswer); + ExcelUtil util = new ExcelUtil(PlatformAnswer.class); + return util.exportExcel(list, "平台有问必答数据"); + } + + /** + * 获取平台有问必答详细信息 + */ + @PreAuthorize("@ss.hasPermi('frequency:platformanswer:query')") + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") Long id) + { + return AjaxResult.success(platformAnswerService.selectPlatformAnswerById(id)); + } + + /** + * 新增平台有问必答 + */ + @PreAuthorize("@ss.hasPermi('frequency:platformanswer:add')") + @Log(title = "平台有问必答", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody PlatformAnswer platformAnswer) + { + return toAjax(platformAnswerService.insertPlatformAnswer(platformAnswer)); + } + + /** + * 修改平台有问必答 + */ + @PreAuthorize("@ss.hasPermi('frequency:platformanswer:edit')") + @Log(title = "平台有问必答", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody PlatformAnswer platformAnswer) + { + return toAjax(platformAnswerService.updatePlatformAnswer(platformAnswer)); + } + + /** + * 删除平台有问必答 + */ + @PreAuthorize("@ss.hasPermi('frequency:platformanswer:remove')") + @Log(title = "平台有问必答", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}/{delFlag}") + public AjaxResult remove(@PathVariable("ids") Long[] ids,@PathVariable("delFlag") Integer delFlag) + { + return toAjax(platformAnswerService.deletePlatformAnswerByIds(ids,delFlag)); + } +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/platformanswer/entity/PlatformAnswer.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/platformanswer/entity/PlatformAnswer.java new file mode 100644 index 0000000..838e176 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/platformanswer/entity/PlatformAnswer.java @@ -0,0 +1,69 @@ +package com.ruoyi.frequency.platformanswer.entity; + +import lombok.Data; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.experimental.Accessors; +import com.ruoyi.common.annotation.Excel; +import io.swagger.annotations.ApiModelProperty; +import com.baomidou.mybatisplus.annotation.TableField; +import com.ruoyi.vo.UserInfo; +import com.ruoyi.common.core.domain.BaseEntity; + +import java.util.Date; + +/** + * 平台有问必答对象 t_platform_answer + * + * @author liwenlong + * @date 2024-01-24 + */ +@Data +@Accessors(chain = true) +@TableName("t_platform_answer") +public class PlatformAnswer extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + + @ApiModelProperty("主键ID") + private Long id; + + @ApiModelProperty("删除标志 1正常 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("标题") + @Excel(name = "标题") + private String title; + + @ApiModelProperty("内容") + @Excel(name = "内容") + private String content; + + @ApiModelProperty("排序") + @Excel(name = "排序") + private Long sort; + + @ApiModelProperty("浏览数") + @Excel(name = "浏览数") + private Long browseNum; + + @ApiModelProperty("1设计师 2表现师") + @Excel(name = "1设计师 2表现师") + private Integer userType; + + @ApiModelProperty("分类id") + private Long platformAnswerTypeId; + + @ApiModelProperty("分类名称") + @TableField(exist = false) + private String platformAnswerTypeName; + + @ApiModelProperty("开始时间") + @TableField(exist = false) + private Date beginTime; + + @ApiModelProperty("结束时间") + @TableField(exist = false) + private Date endTime; + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/platformanswer/mapper/PlatformAnswerMapper.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/platformanswer/mapper/PlatformAnswerMapper.java new file mode 100644 index 0000000..fa73b74 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/platformanswer/mapper/PlatformAnswerMapper.java @@ -0,0 +1,47 @@ +package com.ruoyi.frequency.platformanswer.mapper; + +import java.util.List; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.ruoyi.frequency.platformanswer.entity.PlatformAnswer; + +/** + * 平台有问必答Mapper接口 + * + * @author liwenlong + * @date 2024-01-24 + */ +public interface PlatformAnswerMapper extends BaseMapper +{ + /** + * 查询平台有问必答 + * + * @param id 平台有问必答主键 + * @return 平台有问必答 + */ + public PlatformAnswer selectPlatformAnswerById(Long id); + + /** + * 查询平台有问必答列表 + * + * @param platformAnswer 平台有问必答 + * @return 平台有问必答集合 + */ + public List selectPlatformAnswerList(PlatformAnswer platformAnswer); + + /** + * 新增平台有问必答 + * + * @param platformAnswer 平台有问必答 + * @return 结果 + */ + public int insertPlatformAnswer(PlatformAnswer platformAnswer); + + /** + * 修改平台有问必答 + * + * @param platformAnswer 平台有问必答 + * @return 结果 + */ + public int updatePlatformAnswer(PlatformAnswer platformAnswer); + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/platformanswer/mapper/mapping/PlatformAnswerMapper.xml b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/platformanswer/mapper/mapping/PlatformAnswerMapper.xml new file mode 100644 index 0000000..cda6411 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/platformanswer/mapper/mapping/PlatformAnswerMapper.xml @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + select + t.id , + t.del_flag , + t.create_by , + t.create_time , + t.update_by , + t.update_time , + t.title , + t.content , + t.sort , + t.browse_num , + t.user_type, + tl.name platformAnswerTypeName, + t.platform_answer_type_id + from t_platform_answer AS t + left join t_platform_answer_type tl on t.platform_answer_type_id = tl.id + + + + + + + + insert into t_platform_answer + + id, + del_flag, + create_by, + create_time, + update_by, + update_time, + title, + content, + sort, + browse_num, + user_type, + + + #{id}, + #{delFlag}, + #{createBy}, + #{createTime}, + #{updateBy}, + #{updateTime}, + #{title}, + #{content}, + #{sort}, + #{browseNum}, + #{userType}, + + + + + update t_platform_answer + + del_flag = #{delFlag}, + create_by = #{createBy}, + create_time = #{createTime}, + update_by = #{updateBy}, + update_time = #{updateTime}, + title = #{title}, + content = #{content}, + sort = #{sort}, + browse_num = #{browseNum}, + user_type = #{userType}, + platform_answer_type_id = #{platformAnswerTypeId}, + + where id = #{id} + + diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/platformanswer/model/param/PlatformAnswerParam.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/platformanswer/model/param/PlatformAnswerParam.java new file mode 100644 index 0000000..40fc20f --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/platformanswer/model/param/PlatformAnswerParam.java @@ -0,0 +1,55 @@ +package com.ruoyi.frequency.platformanswer.model.param; + +import lombok.Data; +import lombok.experimental.Accessors; +import com.ruoyi.common.annotation.Excel; +import io.swagger.annotations.ApiModelProperty; +import com.ruoyi.common.core.domain.BaseEntity; + +/** + * 平台有问必答对象 t_platform_answer + * + * @author liwenlong + * @date 2024-01-24 + */ +@Data +@Accessors(chain = true) +public class PlatformAnswerParam extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + @ApiModelProperty("主键ID") + private Long id; + + @ApiModelProperty("删除标志 1正常 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("标题") + @Excel(name = "标题") + private String title; + + @ApiModelProperty("内容") + @Excel(name = "内容") + private String content; + + @ApiModelProperty("排序") + @Excel(name = "排序") + private Long sort; + + @ApiModelProperty("浏览数") + @Excel(name = "浏览数") + private Long browseNum; + + @ApiModelProperty("1设计师 2表现师") + @Excel(name = "1设计师 2表现师") + private Integer userType; + + + + + + + + + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/platformanswer/model/result/PlatformAnswerResult.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/platformanswer/model/result/PlatformAnswerResult.java new file mode 100644 index 0000000..b4e5b3c --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/platformanswer/model/result/PlatformAnswerResult.java @@ -0,0 +1,48 @@ +package com.ruoyi.frequency.platformanswer.model.result; + +import lombok.Data; +import lombok.experimental.Accessors; +import com.ruoyi.common.annotation.Excel; +import io.swagger.annotations.ApiModelProperty; +import com.ruoyi.common.core.domain.BaseEntity; + +/** + * 平台有问必答对象 t_platform_answer + * + * @author liwenlong + * @date 2024-01-24 + */ +@Data +@Accessors(chain = true) +public class PlatformAnswerResult extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + @ApiModelProperty("主键ID") + private Long id; + + @ApiModelProperty("删除标志 1正常 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("标题") + @Excel(name = "标题") + private String title; + + @ApiModelProperty("内容") + @Excel(name = "内容") + private String content; + + @ApiModelProperty("排序") + @Excel(name = "排序") + private Long sort; + + @ApiModelProperty("浏览数") + @Excel(name = "浏览数") + private Long browseNum; + + @ApiModelProperty("1设计师 2表现师") + @Excel(name = "1设计师 2表现师") + private Integer userType; + + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/platformanswer/service/PlatformAnswerService.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/platformanswer/service/PlatformAnswerService.java new file mode 100644 index 0000000..4f8ab52 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/platformanswer/service/PlatformAnswerService.java @@ -0,0 +1,55 @@ +package com.ruoyi.frequency.platformanswer.service; + +import java.util.List; +import com.ruoyi.frequency.platformanswer.entity.PlatformAnswer; +import com.baomidou.mybatisplus.extension.service.IService; + +/** + * 平台有问必答Service接口 + * + * @author liwenlong + * @date 2024-01-24 + */ +public interface PlatformAnswerService extends IService +{ + /** + * 查询平台有问必答 + * + * @param id 平台有问必答主键 + * @return 平台有问必答 + */ + public PlatformAnswer selectPlatformAnswerById(Long id); + + /** + * 查询平台有问必答列表 + * + * @param platformAnswer 平台有问必答 + * @return 平台有问必答集合 + */ + public List selectPlatformAnswerList(PlatformAnswer platformAnswer); + + /** + * 新增平台有问必答 + * + * @param platformAnswer 平台有问必答 + * @return 结果 + */ + public int insertPlatformAnswer(PlatformAnswer platformAnswer); + + /** + * 修改平台有问必答 + * + * @param platformAnswer 平台有问必答 + * @return 结果 + */ + public int updatePlatformAnswer(PlatformAnswer platformAnswer); + + /** + * 批量删除平台有问必答 + * + * @param ids 需要删除的平台有问必答主键集合 + * @return 结果 + */ + public int deletePlatformAnswerByIds(Long[] ids,Integer delFlag); + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/platformanswer/service/impl/PlatformAnswerServiceImpl.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/platformanswer/service/impl/PlatformAnswerServiceImpl.java new file mode 100644 index 0000000..bc9168e --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/platformanswer/service/impl/PlatformAnswerServiceImpl.java @@ -0,0 +1,88 @@ +package com.ruoyi.frequency.platformanswer.service.impl; + +import java.util.List; +import com.ruoyi.common.utils.DateUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.ruoyi.code.PublicCommon; +import com.ruoyi.frequency.platformanswer.mapper.PlatformAnswerMapper; +import com.ruoyi.frequency.platformanswer.entity.PlatformAnswer; +import com.ruoyi.frequency.platformanswer.service.PlatformAnswerService; + +/** + * 平台有问必答Service业务层处理 + * + * @author liwenlong + * @date 2024-01-24 + */ +@Service +public class PlatformAnswerServiceImpl extends ServiceImpl implements PlatformAnswerService +{ + @Autowired + private PlatformAnswerMapper platformAnswerMapper; + + /** + * 查询平台有问必答 + * + * @param id 平台有问必答主键 + * @return 平台有问必答 + */ + @Override + public PlatformAnswer selectPlatformAnswerById(Long id) + { + return platformAnswerMapper.selectPlatformAnswerById(id); + } + + /** + * 查询平台有问必答列表 + * + * @param platformAnswer 平台有问必答 + * @return 平台有问必答 + */ + @Override + public List selectPlatformAnswerList(PlatformAnswer platformAnswer) + { + return platformAnswerMapper.selectPlatformAnswerList(platformAnswer); + } + + /** + * 新增平台有问必答 + * + * @param platformAnswer 平台有问必答 + * @return 结果 + */ + @Override + public int insertPlatformAnswer(PlatformAnswer platformAnswer) + { + platformAnswer.setCreateData(); + return platformAnswerMapper.insert(platformAnswer); + } + + /** + * 修改平台有问必答 + * + * @param platformAnswer 平台有问必答 + * @return 结果 + */ + @Override + public int updatePlatformAnswer(PlatformAnswer platformAnswer) + { + platformAnswer.setUpdateData(); + return platformAnswerMapper.updatePlatformAnswer(platformAnswer); + } + + /** + * 批量删除平台有问必答 + * + * @param ids 需要删除的平台有问必答主键 + * @return 结果 + */ + @Override + public int deletePlatformAnswerByIds(Long[] ids,Integer delFlag) + { + this.lambdaUpdate().set(PlatformAnswer::getDelFlag,delFlag).in(PlatformAnswer::getId,ids).update(); + return ids.length; + } + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/platformanswertype/controller/PlatformAnswerTypeController.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/platformanswertype/controller/PlatformAnswerTypeController.java new file mode 100644 index 0000000..d22211e --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/platformanswertype/controller/PlatformAnswerTypeController.java @@ -0,0 +1,103 @@ +package com.ruoyi.frequency.platformanswertype.controller; + +import java.util.List; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.frequency.platformanswertype.entity.PlatformAnswerType; +import com.ruoyi.frequency.platformanswertype.service.PlatformAnswerTypeService; +import com.ruoyi.common.utils.poi.ExcelUtil; +import com.ruoyi.common.core.page.TableDataInfo; + +/** + * 平台有问必答类型Controller + * + * @author liwenlong + * @date 2024-02-21 + */ +@RestController +@RequestMapping("/frequency/platformanswertype") +public class PlatformAnswerTypeController extends BaseController +{ + @Autowired + private PlatformAnswerTypeService platformAnswerTypeService; + + /** + * 查询平台有问必答类型列表 + */ + //@PreAuthorize("@ss.hasPermi('frequency:platformanswertype:list')") + @PostMapping("/list") + public TableDataInfo list(@RequestBody PlatformAnswerType platformAnswerType) + { + startPage(); + List list = platformAnswerTypeService.selectPlatformAnswerTypeList(platformAnswerType); + return getDataTable(list); + } + + /** + * 导出平台有问必答类型列表 + */ + //@PreAuthorize("@ss.hasPermi('frequency:platformanswertype:export')") + @Log(title = "平台有问必答类型", businessType = BusinessType.EXPORT) + @GetMapping("/export") + public AjaxResult export(PlatformAnswerType platformAnswerType) + { + List list = platformAnswerTypeService.selectPlatformAnswerTypeList(platformAnswerType); + ExcelUtil util = new ExcelUtil(PlatformAnswerType.class); + return util.exportExcel(list, "平台有问必答类型数据"); + } + + /** + * 获取平台有问必答类型详细信息 + */ + //@PreAuthorize("@ss.hasPermi('frequency:platformanswertype:query')") + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") Long id) + { + return AjaxResult.success(platformAnswerTypeService.selectPlatformAnswerTypeById(id)); + } + + /** + * 新增平台有问必答类型 + */ + //@PreAuthorize("@ss.hasPermi('frequency:platformanswertype:add')") + @Log(title = "平台有问必答类型", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody PlatformAnswerType platformAnswerType) + { + return toAjax(platformAnswerTypeService.insertPlatformAnswerType(platformAnswerType)); + } + + /** + * 修改平台有问必答类型 + */ + //@PreAuthorize("@ss.hasPermi('frequency:platformanswertype:edit')") + @Log(title = "平台有问必答类型", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody PlatformAnswerType platformAnswerType) + { + return toAjax(platformAnswerTypeService.updatePlatformAnswerType(platformAnswerType)); + } + + /** + * 删除平台有问必答类型 + */ + //@PreAuthorize("@ss.hasPermi('frequency:platformanswertype:remove')") + @Log(title = "平台有问必答类型", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}/{delFlag}") + public AjaxResult remove(@PathVariable("ids") Long[] ids,@PathVariable("delFlag") Integer delFlag) + { + return toAjax(platformAnswerTypeService.deletePlatformAnswerTypeByIds(ids,delFlag)); + } +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/platformanswertype/entity/PlatformAnswerType.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/platformanswertype/entity/PlatformAnswerType.java new file mode 100644 index 0000000..4f66b47 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/platformanswertype/entity/PlatformAnswerType.java @@ -0,0 +1,46 @@ +package com.ruoyi.frequency.platformanswertype.entity; + +import lombok.Data; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.experimental.Accessors; +import com.ruoyi.common.annotation.Excel; +import io.swagger.annotations.ApiModelProperty; +import com.baomidou.mybatisplus.annotation.TableField; +import com.ruoyi.vo.UserInfo; +import com.ruoyi.common.core.domain.BaseEntity; + +/** + * 平台有问必答类型对象 t_platform_answer_type + * + * @author liwenlong + * @date 2024-02-21 + */ +@Data +@Accessors(chain = true) +@TableName("t_platform_answer_type") +public class PlatformAnswerType extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + + @ApiModelProperty("主键ID") + private Long id; + + @ApiModelProperty("删除标志 1正常 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("名称") + @Excel(name = "名称") + private String name; + + @ApiModelProperty("排序") + @Excel(name = "排序") + private Integer sort; + + @ApiModelProperty("1设计师 2表现师") + @Excel(name = "1设计师 2表现师") + private Integer userType; + + + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/platformanswertype/mapper/PlatformAnswerTypeMapper.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/platformanswertype/mapper/PlatformAnswerTypeMapper.java new file mode 100644 index 0000000..1cfc9bf --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/platformanswertype/mapper/PlatformAnswerTypeMapper.java @@ -0,0 +1,47 @@ +package com.ruoyi.frequency.platformanswertype.mapper; + +import java.util.List; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.ruoyi.frequency.platformanswertype.entity.PlatformAnswerType; + +/** + * 平台有问必答类型Mapper接口 + * + * @author liwenlong + * @date 2024-02-21 + */ +public interface PlatformAnswerTypeMapper extends BaseMapper +{ + /** + * 查询平台有问必答类型 + * + * @param id 平台有问必答类型主键 + * @return 平台有问必答类型 + */ + public PlatformAnswerType selectPlatformAnswerTypeById(Long id); + + /** + * 查询平台有问必答类型列表 + * + * @param platformAnswerType 平台有问必答类型 + * @return 平台有问必答类型集合 + */ + public List selectPlatformAnswerTypeList(PlatformAnswerType platformAnswerType); + + /** + * 新增平台有问必答类型 + * + * @param platformAnswerType 平台有问必答类型 + * @return 结果 + */ + public int insertPlatformAnswerType(PlatformAnswerType platformAnswerType); + + /** + * 修改平台有问必答类型 + * + * @param platformAnswerType 平台有问必答类型 + * @return 结果 + */ + public int updatePlatformAnswerType(PlatformAnswerType platformAnswerType); + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/platformanswertype/mapper/mapping/PlatformAnswerTypeMapper.xml b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/platformanswertype/mapper/mapping/PlatformAnswerTypeMapper.xml new file mode 100644 index 0000000..a2d58cf --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/platformanswertype/mapper/mapping/PlatformAnswerTypeMapper.xml @@ -0,0 +1,92 @@ + + + + + + + + + + + + + + + + + + + + select + t.id , + t.del_flag , + t.create_by , + t.create_time , + t.update_by , + t.update_time , + t.name , + t.sort , + t.user_type + from t_platform_answer_type AS t + + + + + + + + + insert into t_platform_answer_type + + id, + del_flag, + create_by, + create_time, + update_by, + update_time, + name, + sort, + user_type, + + + #{id}, + #{delFlag}, + #{createBy}, + #{createTime}, + #{updateBy}, + #{updateTime}, + #{name}, + #{sort}, + #{userType}, + + + + + update t_platform_answer_type + + del_flag = #{delFlag}, + create_by = #{createBy}, + create_time = #{createTime}, + update_by = #{updateBy}, + update_time = #{updateTime}, + name = #{name}, + sort = #{sort}, + user_type = #{userType}, + + where id = #{id} + + \ No newline at end of file diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/platformanswertype/model/param/PlatformAnswerTypeParam.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/platformanswertype/model/param/PlatformAnswerTypeParam.java new file mode 100644 index 0000000..c5cfb86 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/platformanswertype/model/param/PlatformAnswerTypeParam.java @@ -0,0 +1,45 @@ +package com.ruoyi.frequency.platformanswertype.model.param; + +import lombok.Data; +import lombok.experimental.Accessors; +import com.ruoyi.common.annotation.Excel; +import io.swagger.annotations.ApiModelProperty; +import com.ruoyi.common.core.domain.BaseEntity; + +/** + * 平台有问必答类型对象 t_platform_answer_type + * + * @author liwenlong + * @date 2024-02-21 + */ +@Data +@Accessors(chain = true) +public class PlatformAnswerTypeParam extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + @ApiModelProperty("主键ID") + private Long id; + + @ApiModelProperty("删除标志 1正常 删除 3 禁用") + private Long delFlag; + + @ApiModelProperty("名称") + @Excel(name = "名称") + private String name; + + @ApiModelProperty("排序") + @Excel(name = "排序") + private Long sort; + + @ApiModelProperty("1设计师 2表现师") + @Excel(name = "1设计师 2表现师") + private Long userType; + + + + + + + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/platformanswertype/model/result/PlatformAnswerTypeResult.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/platformanswertype/model/result/PlatformAnswerTypeResult.java new file mode 100644 index 0000000..f793c30 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/platformanswertype/model/result/PlatformAnswerTypeResult.java @@ -0,0 +1,40 @@ +package com.ruoyi.frequency.platformanswertype.model.result; + +import lombok.Data; +import lombok.experimental.Accessors; +import com.ruoyi.common.annotation.Excel; +import io.swagger.annotations.ApiModelProperty; +import com.ruoyi.common.core.domain.BaseEntity; + +/** + * 平台有问必答类型对象 t_platform_answer_type + * + * @author liwenlong + * @date 2024-02-21 + */ +@Data +@Accessors(chain = true) +public class PlatformAnswerTypeResult extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + @ApiModelProperty("主键ID") + private Long id; + + @ApiModelProperty("删除标志 1正常 删除 3 禁用") + private Long delFlag; + + @ApiModelProperty("名称") + @Excel(name = "名称") + private String name; + + @ApiModelProperty("排序") + @Excel(name = "排序") + private Long sort; + + @ApiModelProperty("1设计师 2表现师") + @Excel(name = "1设计师 2表现师") + private Long userType; + + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/platformanswertype/service/PlatformAnswerTypeService.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/platformanswertype/service/PlatformAnswerTypeService.java new file mode 100644 index 0000000..03c2560 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/platformanswertype/service/PlatformAnswerTypeService.java @@ -0,0 +1,55 @@ +package com.ruoyi.frequency.platformanswertype.service; + +import java.util.List; +import com.ruoyi.frequency.platformanswertype.entity.PlatformAnswerType; +import com.baomidou.mybatisplus.extension.service.IService; + +/** + * 平台有问必答类型Service接口 + * + * @author liwenlong + * @date 2024-02-21 + */ +public interface PlatformAnswerTypeService extends IService +{ + /** + * 查询平台有问必答类型 + * + * @param id 平台有问必答类型主键 + * @return 平台有问必答类型 + */ + public PlatformAnswerType selectPlatformAnswerTypeById(Long id); + + /** + * 查询平台有问必答类型列表 + * + * @param platformAnswerType 平台有问必答类型 + * @return 平台有问必答类型集合 + */ + public List selectPlatformAnswerTypeList(PlatformAnswerType platformAnswerType); + + /** + * 新增平台有问必答类型 + * + * @param platformAnswerType 平台有问必答类型 + * @return 结果 + */ + public int insertPlatformAnswerType(PlatformAnswerType platformAnswerType); + + /** + * 修改平台有问必答类型 + * + * @param platformAnswerType 平台有问必答类型 + * @return 结果 + */ + public int updatePlatformAnswerType(PlatformAnswerType platformAnswerType); + + /** + * 批量删除平台有问必答类型 + * + * @param ids 需要删除的平台有问必答类型主键集合 + * @return 结果 + */ + public int deletePlatformAnswerTypeByIds(Long[] ids,Integer delFlag); + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/platformanswertype/service/impl/PlatformAnswerTypeServiceImpl.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/platformanswertype/service/impl/PlatformAnswerTypeServiceImpl.java new file mode 100644 index 0000000..4e402dd --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/platformanswertype/service/impl/PlatformAnswerTypeServiceImpl.java @@ -0,0 +1,89 @@ +package com.ruoyi.frequency.platformanswertype.service.impl; + +import java.util.List; +import com.ruoyi.common.utils.DateUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.ruoyi.code.PublicCommon; +import com.ruoyi.frequency.platformanswertype.mapper.PlatformAnswerTypeMapper; +import com.ruoyi.frequency.platformanswertype.entity.PlatformAnswerType; +import com.ruoyi.frequency.platformanswertype.service.PlatformAnswerTypeService; + +/** + * 平台有问必答类型Service业务层处理 + * + * @author liwenlong + * @date 2024-02-21 + */ +@Service +public class PlatformAnswerTypeServiceImpl extends ServiceImpl implements PlatformAnswerTypeService +{ + @Autowired + private PlatformAnswerTypeMapper platformAnswerTypeMapper; + + /** + * 查询平台有问必答类型 + * + * @param id 平台有问必答类型主键 + * @return 平台有问必答类型 + */ + @Override + public PlatformAnswerType selectPlatformAnswerTypeById(Long id) + { + return platformAnswerTypeMapper.selectPlatformAnswerTypeById(id); + } + + /** + * 查询平台有问必答类型列表 + * + * @param platformAnswerType 平台有问必答类型 + * @return 平台有问必答类型 + */ + @Override + public List selectPlatformAnswerTypeList(PlatformAnswerType platformAnswerType) + { + return platformAnswerTypeMapper.selectPlatformAnswerTypeList(platformAnswerType); + } + + /** + * 新增平台有问必答类型 + * + * @param platformAnswerType 平台有问必答类型 + * @return 结果 + */ + @Override + public int insertPlatformAnswerType(PlatformAnswerType platformAnswerType) + { + platformAnswerType.setCreateData(); + platformAnswerType.setUpdateData(); + return platformAnswerTypeMapper.insert(platformAnswerType); + } + + /** + * 修改平台有问必答类型 + * + * @param platformAnswerType 平台有问必答类型 + * @return 结果 + */ + @Override + public int updatePlatformAnswerType(PlatformAnswerType platformAnswerType) + { + platformAnswerType.setUpdateData(); + return platformAnswerTypeMapper.updatePlatformAnswerType(platformAnswerType); + } + + /** + * 批量删除平台有问必答类型 + * + * @param ids 需要删除的平台有问必答类型主键 + * @return 结果 + */ + @Override + public int deletePlatformAnswerTypeByIds(Long[] ids,Integer delFlag) + { + this.lambdaUpdate().set(PlatformAnswerType::getDelFlag,delFlag).in(PlatformAnswerType::getId,ids).update(); + return ids.length; + } + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/platformrules/controller/PlatformRulesController.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/platformrules/controller/PlatformRulesController.java new file mode 100644 index 0000000..4d5b552 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/platformrules/controller/PlatformRulesController.java @@ -0,0 +1,103 @@ +package com.ruoyi.frequency.platformrules.controller; + +import java.util.List; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.frequency.platformrules.entity.PlatformRules; +import com.ruoyi.frequency.platformrules.service.PlatformRulesService; +import com.ruoyi.common.utils.poi.ExcelUtil; +import com.ruoyi.common.core.page.TableDataInfo; + +/** + * 平台规则Controller + * + * @author liwenlong + * @date 2024-01-24 + */ +@RestController +@RequestMapping("/frequency/platformrules") +public class PlatformRulesController extends BaseController +{ + @Autowired + private PlatformRulesService platformRulesService; + + /** + * 查询平台规则列表 + */ + @PreAuthorize("@ss.hasPermi('frequency:platformrules:list')") + @PostMapping("/list") + public TableDataInfo list(@RequestBody PlatformRules platformRules) + { + startPage(); + List list = platformRulesService.selectPlatformRulesList(platformRules); + return getDataTable(list); + } + + /** + * 导出平台规则列表 + */ + @PreAuthorize("@ss.hasPermi('frequency:platformrules:export')") + @Log(title = "平台规则", businessType = BusinessType.EXPORT) + @GetMapping("/export") + public AjaxResult export(PlatformRules platformRules) + { + List list = platformRulesService.selectPlatformRulesList(platformRules); + ExcelUtil util = new ExcelUtil(PlatformRules.class); + return util.exportExcel(list, "平台规则数据"); + } + + /** + * 获取平台规则详细信息 + */ + @PreAuthorize("@ss.hasPermi('frequency:platformrules:query')") + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") Long id) + { + return AjaxResult.success(platformRulesService.selectPlatformRulesById(id)); + } + + /** + * 新增平台规则 + */ + @PreAuthorize("@ss.hasPermi('frequency:platformrules:add')") + @Log(title = "平台规则", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody PlatformRules platformRules) + { + return toAjax(platformRulesService.insertPlatformRules(platformRules)); + } + + /** + * 修改平台规则 + */ + @PreAuthorize("@ss.hasPermi('frequency:platformrules:edit')") + @Log(title = "平台规则", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody PlatformRules platformRules) + { + return toAjax(platformRulesService.updatePlatformRules(platformRules)); + } + + /** + * 删除平台规则 + */ + @PreAuthorize("@ss.hasPermi('frequency:platformrules:remove')") + @Log(title = "平台规则", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}/{delFlag}") + public AjaxResult remove(@PathVariable("ids") Long[] ids,@PathVariable("delFlag") Integer delFlag) + { + return toAjax(platformRulesService.deletePlatformRulesByIds(ids,delFlag)); + } +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/platformrules/entity/PlatformRules.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/platformrules/entity/PlatformRules.java new file mode 100644 index 0000000..90672ea --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/platformrules/entity/PlatformRules.java @@ -0,0 +1,64 @@ +package com.ruoyi.frequency.platformrules.entity; + +import lombok.Data; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.experimental.Accessors; +import com.ruoyi.common.annotation.Excel; +import io.swagger.annotations.ApiModelProperty; +import com.baomidou.mybatisplus.annotation.TableField; +import com.ruoyi.vo.UserInfo; +import com.ruoyi.common.core.domain.BaseEntity; + +import java.util.Date; + +/** + * 平台规则对象 t_platform_rules + * + * @author liwenlong + * @date 2024-01-24 + */ +@Data +@Accessors(chain = true) +@TableName("t_platform_rules") +public class PlatformRules extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + + @ApiModelProperty("主键ID") + private Long id; + + @ApiModelProperty("删除标志 1正常 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("标题") + @Excel(name = "标题") + private String title; + + @ApiModelProperty("内容") + @Excel(name = "内容") + private String content; + + @ApiModelProperty("1设计师 2表现师") + @Excel(name = "1设计师 2表现师") + private Integer userType; + + @ApiModelProperty("排序") + @Excel(name = "排序") + private Integer sort; + + + @ApiModelProperty("分类id") + private Long platformRulesTypeId; + + @ApiModelProperty("分类名称") + @TableField(exist = false) + private String platformRulesTypeName; + + @TableField(exist = false) + private Date beginTime; + + @TableField(exist = false) + private Date endTime; + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/platformrules/mapper/PlatformRulesMapper.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/platformrules/mapper/PlatformRulesMapper.java new file mode 100644 index 0000000..9b6fcaa --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/platformrules/mapper/PlatformRulesMapper.java @@ -0,0 +1,47 @@ +package com.ruoyi.frequency.platformrules.mapper; + +import java.util.List; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.ruoyi.frequency.platformrules.entity.PlatformRules; + +/** + * 平台规则Mapper接口 + * + * @author liwenlong + * @date 2024-01-24 + */ +public interface PlatformRulesMapper extends BaseMapper +{ + /** + * 查询平台规则 + * + * @param id 平台规则主键 + * @return 平台规则 + */ + public PlatformRules selectPlatformRulesById(Long id); + + /** + * 查询平台规则列表 + * + * @param platformRules 平台规则 + * @return 平台规则集合 + */ + public List selectPlatformRulesList(PlatformRules platformRules); + + /** + * 新增平台规则 + * + * @param platformRules 平台规则 + * @return 结果 + */ + public int insertPlatformRules(PlatformRules platformRules); + + /** + * 修改平台规则 + * + * @param platformRules 平台规则 + * @return 结果 + */ + public int updatePlatformRules(PlatformRules platformRules); + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/platformrules/mapper/mapping/PlatformRulesMapper.xml b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/platformrules/mapper/mapping/PlatformRulesMapper.xml new file mode 100644 index 0000000..a6cd226 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/platformrules/mapper/mapping/PlatformRulesMapper.xml @@ -0,0 +1,111 @@ + + + + + + + + + + + + + + + + + + + + + + + select + t.id , + t.del_flag , + t.create_by , + t.create_time , + t.update_by , + t.update_time , + t.title , + t.content , + t.user_type , + t.sort, + tl.name as platform_rules_type_name, + t.platform_rules_type_id + from t_platform_rules AS t + left join t_platform_rules_type tl on t.platform_rules_type_id = tl.id + + + + + + + + insert into t_platform_rules + + id, + del_flag, + create_by, + create_time, + update_by, + update_time, + title, + content, + user_type, + sort, + + + #{id}, + #{delFlag}, + #{createBy}, + #{createTime}, + #{updateBy}, + #{updateTime}, + #{title}, + #{content}, + #{userType}, + #{sort}, + + + + + update t_platform_rules + + del_flag = #{delFlag}, + create_by = #{createBy}, + create_time = #{createTime}, + update_by = #{updateBy}, + update_time = #{updateTime}, + title = #{title}, + content = #{content}, + user_type = #{userType}, + sort = #{sort}, + platform_rules_type_id = #{platformRulesTypeId}, + + where id = #{id} + + diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/platformrules/model/param/PlatformRulesParam.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/platformrules/model/param/PlatformRulesParam.java new file mode 100644 index 0000000..e950cc7 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/platformrules/model/param/PlatformRulesParam.java @@ -0,0 +1,50 @@ +package com.ruoyi.frequency.platformrules.model.param; + +import lombok.Data; +import lombok.experimental.Accessors; +import com.ruoyi.common.annotation.Excel; +import io.swagger.annotations.ApiModelProperty; +import com.ruoyi.common.core.domain.BaseEntity; + +/** + * 平台规则对象 t_platform_rules + * + * @author liwenlong + * @date 2024-01-24 + */ +@Data +@Accessors(chain = true) +public class PlatformRulesParam extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + @ApiModelProperty("主键ID") + private Long id; + + @ApiModelProperty("删除标志 1正常 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("标题") + @Excel(name = "标题") + private String title; + + @ApiModelProperty("内容") + @Excel(name = "内容") + private String content; + + @ApiModelProperty("1设计师 2表现师") + @Excel(name = "1设计师 2表现师") + private Integer userType; + + @ApiModelProperty("排序") + @Excel(name = "排序") + private Long sort; + + + + + + + + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/platformrules/model/result/PlatformRulesResult.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/platformrules/model/result/PlatformRulesResult.java new file mode 100644 index 0000000..9f5c3a1 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/platformrules/model/result/PlatformRulesResult.java @@ -0,0 +1,44 @@ +package com.ruoyi.frequency.platformrules.model.result; + +import lombok.Data; +import lombok.experimental.Accessors; +import com.ruoyi.common.annotation.Excel; +import io.swagger.annotations.ApiModelProperty; +import com.ruoyi.common.core.domain.BaseEntity; + +/** + * 平台规则对象 t_platform_rules + * + * @author liwenlong + * @date 2024-01-24 + */ +@Data +@Accessors(chain = true) +public class PlatformRulesResult extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + @ApiModelProperty("主键ID") + private Long id; + + @ApiModelProperty("删除标志 1正常 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("标题") + @Excel(name = "标题") + private String title; + + @ApiModelProperty("内容") + @Excel(name = "内容") + private String content; + + @ApiModelProperty("1设计师 2表现师") + @Excel(name = "1设计师 2表现师") + private Integer userType; + + @ApiModelProperty("排序") + @Excel(name = "排序") + private Long sort; + + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/platformrules/service/PlatformRulesService.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/platformrules/service/PlatformRulesService.java new file mode 100644 index 0000000..9b5bd42 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/platformrules/service/PlatformRulesService.java @@ -0,0 +1,55 @@ +package com.ruoyi.frequency.platformrules.service; + +import java.util.List; +import com.ruoyi.frequency.platformrules.entity.PlatformRules; +import com.baomidou.mybatisplus.extension.service.IService; + +/** + * 平台规则Service接口 + * + * @author liwenlong + * @date 2024-01-24 + */ +public interface PlatformRulesService extends IService +{ + /** + * 查询平台规则 + * + * @param id 平台规则主键 + * @return 平台规则 + */ + public PlatformRules selectPlatformRulesById(Long id); + + /** + * 查询平台规则列表 + * + * @param platformRules 平台规则 + * @return 平台规则集合 + */ + public List selectPlatformRulesList(PlatformRules platformRules); + + /** + * 新增平台规则 + * + * @param platformRules 平台规则 + * @return 结果 + */ + public int insertPlatformRules(PlatformRules platformRules); + + /** + * 修改平台规则 + * + * @param platformRules 平台规则 + * @return 结果 + */ + public int updatePlatformRules(PlatformRules platformRules); + + /** + * 批量删除平台规则 + * + * @param ids 需要删除的平台规则主键集合 + * @return 结果 + */ + public int deletePlatformRulesByIds(Long[] ids,Integer delFlag); + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/platformrules/service/impl/PlatformRulesServiceImpl.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/platformrules/service/impl/PlatformRulesServiceImpl.java new file mode 100644 index 0000000..9ee37da --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/platformrules/service/impl/PlatformRulesServiceImpl.java @@ -0,0 +1,89 @@ +package com.ruoyi.frequency.platformrules.service.impl; + +import java.util.List; +import com.ruoyi.common.utils.DateUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.ruoyi.code.PublicCommon; +import com.ruoyi.frequency.platformrules.mapper.PlatformRulesMapper; +import com.ruoyi.frequency.platformrules.entity.PlatformRules; +import com.ruoyi.frequency.platformrules.service.PlatformRulesService; + +/** + * 平台规则Service业务层处理 + * + * @author liwenlong + * @date 2024-01-24 + */ +@Service +public class PlatformRulesServiceImpl extends ServiceImpl implements PlatformRulesService +{ + @Autowired + private PlatformRulesMapper platformRulesMapper; + + /** + * 查询平台规则 + * + * @param id 平台规则主键 + * @return 平台规则 + */ + @Override + public PlatformRules selectPlatformRulesById(Long id) + { + return platformRulesMapper.selectPlatformRulesById(id); + } + + /** + * 查询平台规则列表 + * + * @param platformRules 平台规则 + * @return 平台规则 + */ + @Override + public List selectPlatformRulesList(PlatformRules platformRules) + { + return platformRulesMapper.selectPlatformRulesList(platformRules); + } + + /** + * 新增平台规则 + * + * @param platformRules 平台规则 + * @return 结果 + */ + @Override + public int insertPlatformRules(PlatformRules platformRules) + { + platformRules.setCreateData(); + platformRules.setUpdateData(); + return platformRulesMapper.insert(platformRules); + } + + /** + * 修改平台规则 + * + * @param platformRules 平台规则 + * @return 结果 + */ + @Override + public int updatePlatformRules(PlatformRules platformRules) + { + platformRules.setUpdateData(); + return platformRulesMapper.updatePlatformRules(platformRules); + } + + /** + * 批量删除平台规则 + * + * @param ids 需要删除的平台规则主键 + * @return 结果 + */ + @Override + public int deletePlatformRulesByIds(Long[] ids,Integer delFlag) + { + this.lambdaUpdate().set(PlatformRules::getDelFlag,delFlag).in(PlatformRules::getId,ids).update(); + return ids.length; + } + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/platformrulestype/controller/PlatformRulesTypeController.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/platformrulestype/controller/PlatformRulesTypeController.java new file mode 100644 index 0000000..ba1efd5 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/platformrulestype/controller/PlatformRulesTypeController.java @@ -0,0 +1,103 @@ +package com.ruoyi.frequency.platformrulestype.controller; + +import java.util.List; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.frequency.platformrulestype.entity.PlatformRulesType; +import com.ruoyi.frequency.platformrulestype.service.PlatformRulesTypeService; +import com.ruoyi.common.utils.poi.ExcelUtil; +import com.ruoyi.common.core.page.TableDataInfo; + +/** + * 平台规则类型Controller + * + * @author liwenlong + * @date 2024-02-23 + */ +@RestController +@RequestMapping("/frequency/platformrulestype") +public class PlatformRulesTypeController extends BaseController +{ + @Autowired + private PlatformRulesTypeService platformRulesTypeService; + + /** + * 查询平台规则类型列表 + */ + @PreAuthorize("@ss.hasPermi('frequency:platformrulestype:list')") + @PostMapping("/list") + public TableDataInfo list(@RequestBody PlatformRulesType platformRulesType) + { + startPage(); + List list = platformRulesTypeService.selectPlatformRulesTypeList(platformRulesType); + return getDataTable(list); + } + + /** + * 导出平台规则类型列表 + */ + @PreAuthorize("@ss.hasPermi('frequency:platformrulestype:export')") + @Log(title = "平台规则类型", businessType = BusinessType.EXPORT) + @GetMapping("/export") + public AjaxResult export(PlatformRulesType platformRulesType) + { + List list = platformRulesTypeService.selectPlatformRulesTypeList(platformRulesType); + ExcelUtil util = new ExcelUtil(PlatformRulesType.class); + return util.exportExcel(list, "平台规则类型数据"); + } + + /** + * 获取平台规则类型详细信息 + */ + @PreAuthorize("@ss.hasPermi('frequency:platformrulestype:query')") + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") Long id) + { + return AjaxResult.success(platformRulesTypeService.selectPlatformRulesTypeById(id)); + } + + /** + * 新增平台规则类型 + */ + @PreAuthorize("@ss.hasPermi('frequency:platformrulestype:add')") + @Log(title = "平台规则类型", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody PlatformRulesType platformRulesType) + { + return toAjax(platformRulesTypeService.insertPlatformRulesType(platformRulesType)); + } + + /** + * 修改平台规则类型 + */ + @PreAuthorize("@ss.hasPermi('frequency:platformrulestype:edit')") + @Log(title = "平台规则类型", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody PlatformRulesType platformRulesType) + { + return toAjax(platformRulesTypeService.updatePlatformRulesType(platformRulesType)); + } + + /** + * 删除平台规则类型 + */ + @PreAuthorize("@ss.hasPermi('frequency:platformrulestype:remove')") + @Log(title = "平台规则类型", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}/{delFlag}") + public AjaxResult remove(@PathVariable("ids") Long[] ids,@PathVariable("delFlag") Integer delFlag) + { + return toAjax(platformRulesTypeService.deletePlatformRulesTypeByIds(ids,delFlag)); + } +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/platformrulestype/entity/PlatformRulesType.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/platformrulestype/entity/PlatformRulesType.java new file mode 100644 index 0000000..171008a --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/platformrulestype/entity/PlatformRulesType.java @@ -0,0 +1,46 @@ +package com.ruoyi.frequency.platformrulestype.entity; + +import lombok.Data; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.experimental.Accessors; +import com.ruoyi.common.annotation.Excel; +import io.swagger.annotations.ApiModelProperty; +import com.baomidou.mybatisplus.annotation.TableField; +import com.ruoyi.vo.UserInfo; +import com.ruoyi.common.core.domain.BaseEntity; + +/** + * 平台规则类型对象 t_platform_rules_type + * + * @author liwenlong + * @date 2024-02-23 + */ +@Data +@Accessors(chain = true) +@TableName("t_platform_rules_type") +public class PlatformRulesType extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + + @ApiModelProperty("主键ID") + private Long id; + + @ApiModelProperty("删除标志 1正常 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("名称") + @Excel(name = "名称") + private String name; + + @ApiModelProperty("排序") + @Excel(name = "排序") + private Integer sort; + + @ApiModelProperty("1设计师 2表现师") + @Excel(name = "1设计师 2表现师") + private Integer userType; + + + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/platformrulestype/mapper/PlatformRulesTypeMapper.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/platformrulestype/mapper/PlatformRulesTypeMapper.java new file mode 100644 index 0000000..1e46d81 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/platformrulestype/mapper/PlatformRulesTypeMapper.java @@ -0,0 +1,47 @@ +package com.ruoyi.frequency.platformrulestype.mapper; + +import java.util.List; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.ruoyi.frequency.platformrulestype.entity.PlatformRulesType; + +/** + * 平台规则类型Mapper接口 + * + * @author liwenlong + * @date 2024-02-23 + */ +public interface PlatformRulesTypeMapper extends BaseMapper +{ + /** + * 查询平台规则类型 + * + * @param id 平台规则类型主键 + * @return 平台规则类型 + */ + public PlatformRulesType selectPlatformRulesTypeById(Long id); + + /** + * 查询平台规则类型列表 + * + * @param platformRulesType 平台规则类型 + * @return 平台规则类型集合 + */ + public List selectPlatformRulesTypeList(PlatformRulesType platformRulesType); + + /** + * 新增平台规则类型 + * + * @param platformRulesType 平台规则类型 + * @return 结果 + */ + public int insertPlatformRulesType(PlatformRulesType platformRulesType); + + /** + * 修改平台规则类型 + * + * @param platformRulesType 平台规则类型 + * @return 结果 + */ + public int updatePlatformRulesType(PlatformRulesType platformRulesType); + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/platformrulestype/mapper/mapping/PlatformRulesTypeMapper.xml b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/platformrulestype/mapper/mapping/PlatformRulesTypeMapper.xml new file mode 100644 index 0000000..ee2b1c0 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/platformrulestype/mapper/mapping/PlatformRulesTypeMapper.xml @@ -0,0 +1,92 @@ + + + + + + + + + + + + + + + + + + + + select + t.id , + t.del_flag , + t.create_by , + t.create_time , + t.update_by , + t.update_time , + t.name , + t.sort , + t.user_type + from t_platform_rules_type AS t + + + + + + + + + insert into t_platform_rules_type + + id, + del_flag, + create_by, + create_time, + update_by, + update_time, + name, + sort, + user_type, + + + #{id}, + #{delFlag}, + #{createBy}, + #{createTime}, + #{updateBy}, + #{updateTime}, + #{name}, + #{sort}, + #{userType}, + + + + + update t_platform_rules_type + + del_flag = #{delFlag}, + create_by = #{createBy}, + create_time = #{createTime}, + update_by = #{updateBy}, + update_time = #{updateTime}, + name = #{name}, + sort = #{sort}, + user_type = #{userType}, + + where id = #{id} + + \ No newline at end of file diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/platformrulestype/model/param/PlatformRulesTypeParam.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/platformrulestype/model/param/PlatformRulesTypeParam.java new file mode 100644 index 0000000..c137b64 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/platformrulestype/model/param/PlatformRulesTypeParam.java @@ -0,0 +1,45 @@ +package com.ruoyi.frequency.platformrulestype.model.param; + +import lombok.Data; +import lombok.experimental.Accessors; +import com.ruoyi.common.annotation.Excel; +import io.swagger.annotations.ApiModelProperty; +import com.ruoyi.common.core.domain.BaseEntity; + +/** + * 平台规则类型对象 t_platform_rules_type + * + * @author liwenlong + * @date 2024-02-23 + */ +@Data +@Accessors(chain = true) +public class PlatformRulesTypeParam extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + @ApiModelProperty("主键ID") + private Long id; + + @ApiModelProperty("删除标志 1正常 删除 3 禁用") + private Long delFlag; + + @ApiModelProperty("名称") + @Excel(name = "名称") + private String name; + + @ApiModelProperty("排序") + @Excel(name = "排序") + private Long sort; + + @ApiModelProperty("1设计师 2表现师") + @Excel(name = "1设计师 2表现师") + private Long userType; + + + + + + + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/platformrulestype/model/result/PlatformRulesTypeResult.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/platformrulestype/model/result/PlatformRulesTypeResult.java new file mode 100644 index 0000000..b58ea1b --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/platformrulestype/model/result/PlatformRulesTypeResult.java @@ -0,0 +1,40 @@ +package com.ruoyi.frequency.platformrulestype.model.result; + +import lombok.Data; +import lombok.experimental.Accessors; +import com.ruoyi.common.annotation.Excel; +import io.swagger.annotations.ApiModelProperty; +import com.ruoyi.common.core.domain.BaseEntity; + +/** + * 平台规则类型对象 t_platform_rules_type + * + * @author liwenlong + * @date 2024-02-23 + */ +@Data +@Accessors(chain = true) +public class PlatformRulesTypeResult extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + @ApiModelProperty("主键ID") + private Long id; + + @ApiModelProperty("删除标志 1正常 删除 3 禁用") + private Long delFlag; + + @ApiModelProperty("名称") + @Excel(name = "名称") + private String name; + + @ApiModelProperty("排序") + @Excel(name = "排序") + private Long sort; + + @ApiModelProperty("1设计师 2表现师") + @Excel(name = "1设计师 2表现师") + private Long userType; + + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/platformrulestype/service/PlatformRulesTypeService.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/platformrulestype/service/PlatformRulesTypeService.java new file mode 100644 index 0000000..e784468 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/platformrulestype/service/PlatformRulesTypeService.java @@ -0,0 +1,55 @@ +package com.ruoyi.frequency.platformrulestype.service; + +import java.util.List; +import com.ruoyi.frequency.platformrulestype.entity.PlatformRulesType; +import com.baomidou.mybatisplus.extension.service.IService; + +/** + * 平台规则类型Service接口 + * + * @author liwenlong + * @date 2024-02-23 + */ +public interface PlatformRulesTypeService extends IService +{ + /** + * 查询平台规则类型 + * + * @param id 平台规则类型主键 + * @return 平台规则类型 + */ + public PlatformRulesType selectPlatformRulesTypeById(Long id); + + /** + * 查询平台规则类型列表 + * + * @param platformRulesType 平台规则类型 + * @return 平台规则类型集合 + */ + public List selectPlatformRulesTypeList(PlatformRulesType platformRulesType); + + /** + * 新增平台规则类型 + * + * @param platformRulesType 平台规则类型 + * @return 结果 + */ + public int insertPlatformRulesType(PlatformRulesType platformRulesType); + + /** + * 修改平台规则类型 + * + * @param platformRulesType 平台规则类型 + * @return 结果 + */ + public int updatePlatformRulesType(PlatformRulesType platformRulesType); + + /** + * 批量删除平台规则类型 + * + * @param ids 需要删除的平台规则类型主键集合 + * @return 结果 + */ + public int deletePlatformRulesTypeByIds(Long[] ids,Integer delFlag); + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/platformrulestype/service/impl/PlatformRulesTypeServiceImpl.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/platformrulestype/service/impl/PlatformRulesTypeServiceImpl.java new file mode 100644 index 0000000..21733e6 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/platformrulestype/service/impl/PlatformRulesTypeServiceImpl.java @@ -0,0 +1,89 @@ +package com.ruoyi.frequency.platformrulestype.service.impl; + +import java.util.List; +import com.ruoyi.common.utils.DateUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.ruoyi.code.PublicCommon; +import com.ruoyi.frequency.platformrulestype.mapper.PlatformRulesTypeMapper; +import com.ruoyi.frequency.platformrulestype.entity.PlatformRulesType; +import com.ruoyi.frequency.platformrulestype.service.PlatformRulesTypeService; + +/** + * 平台规则类型Service业务层处理 + * + * @author liwenlong + * @date 2024-02-23 + */ +@Service +public class PlatformRulesTypeServiceImpl extends ServiceImpl implements PlatformRulesTypeService +{ + @Autowired + private PlatformRulesTypeMapper platformRulesTypeMapper; + + /** + * 查询平台规则类型 + * + * @param id 平台规则类型主键 + * @return 平台规则类型 + */ + @Override + public PlatformRulesType selectPlatformRulesTypeById(Long id) + { + return platformRulesTypeMapper.selectPlatformRulesTypeById(id); + } + + /** + * 查询平台规则类型列表 + * + * @param platformRulesType 平台规则类型 + * @return 平台规则类型 + */ + @Override + public List selectPlatformRulesTypeList(PlatformRulesType platformRulesType) + { + return platformRulesTypeMapper.selectPlatformRulesTypeList(platformRulesType); + } + + /** + * 新增平台规则类型 + * + * @param platformRulesType 平台规则类型 + * @return 结果 + */ + @Override + public int insertPlatformRulesType(PlatformRulesType platformRulesType) + { + platformRulesType.setCreateData(); + platformRulesType.setUpdateData(); + return platformRulesTypeMapper.insert(platformRulesType); + } + + /** + * 修改平台规则类型 + * + * @param platformRulesType 平台规则类型 + * @return 结果 + */ + @Override + public int updatePlatformRulesType(PlatformRulesType platformRulesType) + { + platformRulesType.setUpdateData(); + return platformRulesTypeMapper.updatePlatformRulesType(platformRulesType); + } + + /** + * 批量删除平台规则类型 + * + * @param ids 需要删除的平台规则类型主键 + * @return 结果 + */ + @Override + public int deletePlatformRulesTypeByIds(Long[] ids,Integer delFlag) + { + this.lambdaUpdate().set(PlatformRulesType::getDelFlag,delFlag).in(PlatformRulesType::getId,ids).update(); + return ids.length; + } + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/vote/controller/VoteController.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/vote/controller/VoteController.java new file mode 100644 index 0000000..5f84a4b --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/vote/controller/VoteController.java @@ -0,0 +1,125 @@ +package com.ruoyi.frequency.vote.controller; + +import com.ruoyi.code.PublicCommon; +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.page.TableDataInfo; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.common.utils.poi.ExcelUtil; +import com.ruoyi.frequency.vote.entity.Vote; +import com.ruoyi.frequency.vote.model.result.VoteCount; +import com.ruoyi.frequency.vote.service.VoteService; +import com.ruoyi.frequency.works.entity.Works; +import com.ruoyi.frequency.works.model.result.WorksCount; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +/** + * 投票活动Controller + * + * @author liwenlong + * @date 2023-10-12 + */ +@RestController +@RequestMapping("/frequency/vote") +public class VoteController extends BaseController +{ + @Autowired + private VoteService voteService; + + /** + * 查询投票活动列表 + */ + //@PreAuthorize("@ss.hasPermi('frequency:vote:list')") + @PostMapping("/list") + public TableDataInfo list(@RequestBody Vote vote) + { + startPage(); + List list = voteService.selectVoteList(vote); + return getDataTable(list); + } + + /** + * 统计 + */ + @PostMapping("/statistics") + public AjaxResult statistics(@RequestBody Vote vote) + { + VoteCount count = voteService.statistics(vote); + return AjaxResult.success(count); + } + + /** + * 导出投票活动列表 + */ + //@PreAuthorize("@ss.hasPermi('frequency:vote:export')") + @Log(title = "投票活动", businessType = BusinessType.EXPORT) + @GetMapping("/export") + public AjaxResult export(Vote vote) + { + List list = voteService.selectVoteList(vote); + ExcelUtil util = new ExcelUtil(Vote.class); + return util.exportExcel(list, "投票活动数据"); + } + + /** + * 获取投票活动详细信息 + */ + //@PreAuthorize("@ss.hasPermi('frequency:vote:query')") + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") Long id) + { + return AjaxResult.success(voteService.selectVoteById(id)); + } + + /** + * 新增投票活动 + */ + //@PreAuthorize("@ss.hasPermi('frequency:vote:add')") + @Log(title = "投票活动", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody Vote vote) + { + return toAjax(voteService.insertVote(vote)); + } + + /** + * 修改投票活动 + */ + //@PreAuthorize("@ss.hasPermi('frequency:vote:edit')") + @Log(title = "投票活动", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody Vote vote) + { + return toAjax(voteService.updateVote(vote)); + } + + /** + * 删除投票活动 + */ + //@PreAuthorize("@ss.hasPermi('frequency:vote:remove')") + @Log(title = "投票活动", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}/{delFlag}") + public AjaxResult remove(@PathVariable("ids") Long[] ids,@PathVariable("delFlag") Integer delFlag) + { + return toAjax(voteService.deleteVoteByIds(ids,delFlag)); + } + + /** + * 终止活动 + */ + @Log(title = "终止活动", businessType = BusinessType.UPDATE) + //@PreAuthorize("@ss.hasPermi('frequency:vote:stop')") + @PutMapping("/stop/{id}") + public AjaxResult stop(@PathVariable Long id) + { + Vote vote = new Vote(); + vote.setId(id); + vote.setDelFlag(PublicCommon.禁用); + return toAjax(voteService.updateVote(vote)); + } +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/vote/entity/Vote.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/vote/entity/Vote.java new file mode 100644 index 0000000..2175878 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/vote/entity/Vote.java @@ -0,0 +1,98 @@ +package com.ruoyi.frequency.vote.entity; + +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableName; +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import com.ruoyi.frequency.voteoption.entity.VoteOption; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; + +import java.util.Date; +import java.util.List; + +/** + * 投票活动对象 t_vote + * + * @author liwenlong + * @date 2023-10-12 + */ +@Data +@Accessors(chain = true) +@TableName("t_vote") +public class Vote extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + + @ApiModelProperty("租户号") + private Long id; + + @ApiModelProperty("删除标志;1 正常 2 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("标题") + @Excel(name = "标题") + private String title; + + @ApiModelProperty("内容") + @Excel(name = "内容") + private String content; + + @ApiModelProperty("活动截止日期") + @Excel(name = "活动截止日期", width = 30, dateFormat = "yyyy-MM-dd") + private Date cutoffDate; + + @ApiModelProperty("投票发起人;默认官方") + @Excel(name = "投票发起人;默认官方") + private String initiator; + + @ApiModelProperty("1单选 2多选") + private Integer type; + + @ApiModelProperty("选择数量") + private Integer pickNum; + + @ApiModelProperty(value = "点赞数") + private Integer likeNum; + + @ApiModelProperty(value = "浏览数") + private Integer browseNum; + + @ApiModelProperty(value = "评论数") + private Integer commentNum; + + @ApiModelProperty(value = "精彩评论ID") + private Long commentId; + + @ApiModelProperty("累计参与人数") + @Excel(name = "累计参与人数") + @TableField(exist = false) + private Integer num; + + @ApiModelProperty("开始时间") + @TableField(exist = false) + private Date beginTime; + + @ApiModelProperty("结束时间") + @TableField(exist = false) + private Date endTime; + + + @ApiModelProperty("截至时间开始时间") + @TableField(exist = false) + private Date cutoffBeginTime; + + @ApiModelProperty("截至时间结束时间") + @TableField(exist = false) + private Date cutoffEndTime; + + + + @ApiModelProperty("投票选项") + @TableField(exist = false) + private List voteOptionList; + + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/vote/mapper/VoteMapper.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/vote/mapper/VoteMapper.java new file mode 100644 index 0000000..191660d --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/vote/mapper/VoteMapper.java @@ -0,0 +1,75 @@ +package com.ruoyi.frequency.vote.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.ruoyi.controller.resp.VoteDetailResp; +import com.ruoyi.controller.resp.VotePageResp; +import com.ruoyi.frequency.vote.entity.Vote; +import com.ruoyi.frequency.vote.model.result.VoteCount; +import com.ruoyi.vo.UserVo; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * 投票活动Mapper接口 + * + * @author liwenlong + * @date 2023-10-12 + */ +public interface VoteMapper extends BaseMapper +{ + /** + * 查询投票活动 + * + * @param id 投票活动主键 + * @return 投票活动 + */ + public Vote selectVoteById(Long id); + + /** + * 查询投票活动列表 + * + * @param vote 投票活动 + * @return 投票活动集合 + */ + public List selectVoteList(Vote vote); + + /** + * 新增投票活动 + * + * @param vote 投票活动 + * @return 结果 + */ + public int insertVote(Vote vote); + + /** + * 修改投票活动 + * + * @param vote 投票活动 + * @return 结果 + */ + public int updateVote(Vote vote); + + /** + * 删除投票活动 + * + * @param id 投票活动主键 + * @return 结果 + */ + public int deleteVoteById(Long id); + + /** + * 批量删除投票活动 + * + * @param ids 需要删除的数据主键集合 + * @return 结果 + */ + public int deleteVoteByIds(Long[] ids); + + Page votePage(@Param("page") Page objectPage, @Param("userVo") UserVo userVo,@Param("isSelf") boolean isSelf); + + VoteDetailResp voteDetail(@Param("voteId") Long voteId,@Param("userVo") UserVo userVo); + + VoteCount statistics( @Param("list") List voteIdList ); +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/vote/mapper/mapping/VoteMapper.xml b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/vote/mapper/mapping/VoteMapper.xml new file mode 100644 index 0000000..1cbb011 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/vote/mapper/mapping/VoteMapper.xml @@ -0,0 +1,286 @@ + + + + + + + + + + + + + + + + + + + + + + + + + SELECT + t.id, + t.create_by, + t.create_time, + t.update_by, + case when t.del_flag = 1 and t.cutoff_date < now() then 4 else t.del_flag end as del_flag, + t.update_time, + t.title, + t.content, + t.cutoff_date, + t.initiator, + ( + SELECT + count(1) + FROM + ( + SELECT DISTINCT + user_id, + user_type + FROM + t_vote_record vr + WHERE + vr.del_flag = 1 + AND vr.vote_id = t.id + ) rec + ) AS num, + t.type, + t.pick_num, + t.like_num, + t.comment_num, + t.browse_num + FROM + t_vote AS t + + + + + + + + + + + insert into t_vote + + id, + create_by, + create_time, + update_by, + update_time, + del_flag, + title, + content, + cutoff_date, + initiator, + like_num, + browse_num, + + + #{id}, + #{createBy}, + #{createTime}, + #{updateBy}, + #{updateTime}, + #{delFlag}, + #{title}, + #{content}, + #{cutoffDate}, + #{initiator}, + #{likeNum}, + #{browseNum}, + + + + + update t_vote + + create_by = #{createBy}, + create_time = #{createTime}, + update_by = #{updateBy}, + update_time = #{updateTime}, + del_flag = #{delFlag}, + title = #{title}, + content = #{content}, + cutoff_date = #{cutoffDate}, + initiator = #{initiator}, + pick_num = #{pickNum}, + like_num = like_num + #{likeNum}, + browse_num = browse_num + #{browseNum}, + comment_num = comment_num + #{commentNum}, + + where id = #{id} + and like_num + #{likeNum} >= 0 + and browse_num + #{browseNum} >= 0 + and comment_num + #{commentNum} >= 0 + + + + delete from t_vote where id = #{id} + + + + delete from t_vote where id in + + #{id} + + + + + + + + diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/vote/model/param/VoteParam.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/vote/model/param/VoteParam.java new file mode 100644 index 0000000..8514740 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/vote/model/param/VoteParam.java @@ -0,0 +1,53 @@ +package com.ruoyi.frequency.vote.model.param; + +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; + +import java.util.Date; + +/** + * 投票活动对象 t_vote + * + * @author liwenlong + * @date 2023-10-12 + */ +@Data +@Accessors(chain = true) +public class VoteParam extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + @ApiModelProperty("租户号") + private Long id; + + @ApiModelProperty("删除标志;1 正常 2 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("标题") + @Excel(name = "标题") + private String title; + + @ApiModelProperty("内容") + @Excel(name = "内容") + private String content; + + @ApiModelProperty("活动截止日期") + @Excel(name = "活动截止日期", width = 30, dateFormat = "yyyy-MM-dd") + private Date cutoffDate; + + @ApiModelProperty("投票发起人;默认官方") + @Excel(name = "投票发起人;默认官方") + private String initiator; + + + + + + + + + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/vote/model/result/VoteCount.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/vote/model/result/VoteCount.java new file mode 100644 index 0000000..ce231d2 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/vote/model/result/VoteCount.java @@ -0,0 +1,18 @@ +package com.ruoyi.frequency.vote.model.result; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + * @author a + * @date 2024/2/22 8:48 + */ +@Data +public class VoteCount { + + @ApiModelProperty("数量") + private Integer num; + + @ApiModelProperty("累计人数") + private Integer accumulativeNumber; +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/vote/model/result/VoteResult.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/vote/model/result/VoteResult.java new file mode 100644 index 0000000..3a27057 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/vote/model/result/VoteResult.java @@ -0,0 +1,47 @@ +package com.ruoyi.frequency.vote.model.result; + +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; + +import java.util.Date; + +/** + * 投票活动对象 t_vote + * + * @author liwenlong + * @date 2023-10-12 + */ +@Data +@Accessors(chain = true) +public class VoteResult extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + @ApiModelProperty("租户号") + private Long id; + + + @ApiModelProperty("删除标志;1 正常 2 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("标题") + @Excel(name = "标题") + private String title; + + @ApiModelProperty("内容") + @Excel(name = "内容") + private String content; + + @ApiModelProperty("活动截止日期") + @Excel(name = "活动截止日期", width = 30, dateFormat = "yyyy-MM-dd") + private Date cutoffDate; + + @ApiModelProperty("投票发起人;默认官方") + @Excel(name = "投票发起人;默认官方") + private String initiator; + + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/vote/service/VoteService.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/vote/service/VoteService.java new file mode 100644 index 0000000..9bf4332 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/vote/service/VoteService.java @@ -0,0 +1,99 @@ +package com.ruoyi.frequency.vote.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.ruoyi.controller.req.VoteReq; +import com.ruoyi.frequency.vote.entity.Vote; +import com.ruoyi.frequency.vote.model.result.VoteCount; +import com.ruoyi.response.ResponseData; +import com.ruoyi.vo.PageBasic; +import com.ruoyi.vo.UserVo; + +import java.util.List; + +/** + * 投票活动Service接口 + * + * @author liwenlong + * @date 2023-10-12 + */ +public interface VoteService extends IService +{ + /** + * 查询投票活动 + * + * @param id 投票活动主键 + * @return 投票活动 + */ + public Vote selectVoteById(Long id); + + /** + * 查询投票活动列表 + * + * @param vote 投票活动 + * @return 投票活动集合 + */ + public List selectVoteList(Vote vote); + + VoteCount statistics(Vote vote); + + /** + * 新增投票活动 + * + * @param vote 投票活动 + * @return 结果 + */ + public int insertVote(Vote vote); + + /** + * 修改投票活动 + * + * @param vote 投票活动 + * @return 结果 + */ + public int updateVote(Vote vote); + + /** + * 批量删除投票活动 + * + * @param ids 需要删除的投票活动主键集合 + * @return 结果 + */ + public int deleteVoteByIds(Long[] ids, Integer delFlag); + + /** + * 删除投票活动信息 + * + * @param id 投票活动主键 + * @return 结果 + */ + public int deleteVoteById(Long id); + + + /** + * 投票列表 + * @param req + * @param userVo + * @param isSelf 是否查询自己投票 + * @return + */ + ResponseData votePage(PageBasic req, UserVo userVo,boolean isSelf); + + + /** + * 投票 + * @param req + * @param userVo + * @return + */ + ResponseData vote(VoteReq req, UserVo userVo); + + + /** + * 投票详情 + * @param req + * @param userVo + * @return + */ + ResponseData voteDetail(Long voteId, Integer isAddBrowseNum,UserVo userVo); + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/vote/service/impl/VoteServiceImpl.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/vote/service/impl/VoteServiceImpl.java new file mode 100644 index 0000000..29f05f7 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/vote/service/impl/VoteServiceImpl.java @@ -0,0 +1,288 @@ +package com.ruoyi.frequency.vote.service.impl; + +import cn.hutool.core.collection.CollectionUtil; +import cn.hutool.core.date.DateUtil; +import cn.hutool.core.util.ObjectUtil; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.ruoyi.code.DictConstant; +import com.ruoyi.code.PublicCommon; +import com.ruoyi.common.core.domain.entity.SysDictData; +import com.ruoyi.common.exception.ServiceException; +import com.ruoyi.common.page.PageResult; +import com.ruoyi.controller.req.VoteReq; +import com.ruoyi.controller.resp.VoteDetailResp; +import com.ruoyi.controller.resp.VotePageResp; +import com.ruoyi.frequency.vote.entity.Vote; +import com.ruoyi.frequency.vote.mapper.VoteMapper; +import com.ruoyi.frequency.vote.model.result.VoteCount; +import com.ruoyi.frequency.vote.service.VoteService; +import com.ruoyi.frequency.voteoption.entity.VoteOption; +import com.ruoyi.frequency.voteoption.service.VoteOptionService; +import com.ruoyi.frequency.voterecord.entity.VoteRecord; +import com.ruoyi.frequency.voterecord.service.VoteRecordService; +import com.ruoyi.frequency.works.entity.Works; +import com.ruoyi.post.frequency.post.mapper.PostMapper; +import com.ruoyi.response.ResponseData; +import com.ruoyi.utils.BusinessUtil; +import com.ruoyi.utils.SnowIdUtils; +import com.ruoyi.vo.PageBasic; +import com.ruoyi.vo.UserVo; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.Date; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +/** + * 投票活动Service业务层处理 + * + * @author liwenlong + * @date 2023-10-12 + */ +@Service +@Transactional(rollbackFor = Exception.class) +public class VoteServiceImpl extends ServiceImpl implements VoteService +{ + @Autowired + private VoteMapper voteMapper; + + /** + * 查询投票活动 + * + * @param id 投票活动主键 + * @return 投票活动 + */ + @Override + public Vote selectVoteById(Long id) + { + + Vote vote = voteMapper.selectVoteById(id); + + //投票选项 + List voteOptions = voteOptionService.getList(CollectionUtil.toList(id),null); + + Map> map = voteOptions.stream().collect(Collectors.groupingBy(VoteOption::getVoteId)); + + vote.setVoteOptionList(map.get(vote.getId())); + + return vote; + } + + /** + * 查询投票活动列表 + * + * @param vote 投票活动 + * @return 投票活动 + */ + @Override + public List selectVoteList(Vote vote) + { + + List votes = voteList(vote); + + if (votes != null && votes.size() > 0){ + + List voteIds = votes.stream().map(Vote::getId).collect(Collectors.toList()); + + //投票选项 + List voteOptions = voteOptionService.getList(voteIds,null); + + Map> map = voteOptions.stream().collect(Collectors.groupingBy(VoteOption::getVoteId)); + + votes.stream().forEach(s->{ + s.setVoteOptionList(map.get(s.getId())); + }); + } + + + return votes; + } + + private List voteList(Vote vote){ + List votes = voteMapper.selectVoteList(vote); + return votes; + } + + @Override + public VoteCount statistics(Vote vote) { + List votes = voteList(vote); + List voteIdList = votes.stream().map(x -> x.getId()).collect(Collectors.toList()); + voteIdList.add(-1L); + return voteMapper.statistics(voteIdList); + } + + /** + * 新增投票活动 + * + * @param vote 投票活动 + * @return 结果 + */ + @Override + public int insertVote(Vote vote) + { + + this.save(vote); + + if (vote.getVoteOptionList() != null && vote.getVoteOptionList().size() > 0) { + + vote.getVoteOptionList().stream().forEach(s->{ + s.setVoteId(vote.getId()); + s.setSort(vote.getVoteOptionList().indexOf(s) + 1); + }); + //关联选项 + voteOptionService.saveBatch(vote.getVoteOptionList()); + } + + return 1; + } + + /** + * 修改投票活动 + * + * @param vote 投票活动 + * @return 结果 + */ + @Override + public int updateVote(Vote vote) + { + + int i = voteMapper.updateVote(vote); + + voteOptionService.remove(new QueryWrapper().lambda().eq(VoteOption::getVoteId, vote.getId())); + + if (vote.getVoteOptionList() != null && vote.getVoteOptionList().size() > 0) { + + vote.getVoteOptionList().stream().forEach(s->{ + s.setVoteId(vote.getId()); + s.setSort(vote.getVoteOptionList().indexOf(s) + 1); + }); + //关联选项 + voteOptionService.saveBatch(vote.getVoteOptionList()); + } + + return 1; + } + + /** + * 批量删除投票活动 + * + * @param ids 需要删除的投票活动主键 + * @return 结果 + */ + @Override + public int deleteVoteByIds(Long[] ids ,Integer delFlag) + { + this.lambdaUpdate().set(Vote::getDelFlag,delFlag).in(Vote::getId,ids).update(); + return ids.length; + } + + /** + * 删除投票活动信息 + * + * @param id 投票活动主键 + * @return 结果 + */ + @Override + public int deleteVoteById(Long id) + { + this.lambdaUpdate().set(Vote::getDelFlag,PublicCommon.删除).eq(Vote::getId,id).update(); + return 1; + } + + @Autowired + private VoteOptionService voteOptionService; + + @Autowired + private BusinessUtil businessUtil; + + @Override + public ResponseData votePage(PageBasic req, UserVo userVo,boolean isSelf) { + //查询官方头像 + String avatar = businessUtil.getDict(DictConstant.官方头像).getImages(); + Page page = voteMapper.votePage(new Page<>(req.getPageNo(),req.getPageSize()),userVo,isSelf); + + if (!page.getRecords().isEmpty()){ + + //投票活动ids + List voteIds = page.getRecords().stream().map(VotePageResp::getId).collect(Collectors.toList()); + + //投票选项 + List voteOptions = voteOptionService.getList(voteIds,userVo); + + Map> map = voteOptions.stream().collect(Collectors.groupingBy(VoteOption::getVoteId)); + + page.getRecords().stream().forEach(vote ->{ + vote.setAvatar(avatar); + vote.setVoteOptionList(map.get(vote.getId())); + }); + } + + return ResponseData.success(new PageResult<>(page)); + } + + @Autowired + private VoteRecordService voteRecordService; + + @Override + @Transactional(rollbackFor = Exception.class) + public ResponseData vote(VoteReq req, UserVo userVo) { + Vote vote = voteMapper.selectById(req.getVoteId()); + //判断投票时间是否在有效期内 + if (vote == null || ObjectUtil.notEqual(PublicCommon.启用,vote.getDelFlag()) || DateUtil.endOfDay(vote.getCutoffDate()).getTime() < System.currentTimeMillis()){ + throw new ServiceException("投票活动已截止"); + } + + //判断用户是否已经投票 + int count = voteRecordService.count(new QueryWrapper().lambda() + .eq(VoteRecord::getDelFlag,PublicCommon.启用) + .eq(VoteRecord::getVoteId, req.getVoteId()) + .eq(VoteRecord::getUserType,userVo.getUserType()) + .eq(VoteRecord::getUserId, userVo.getUserId())); + if (count > 0){ + throw new ServiceException("您已经投过票了"); + } + + //生成投票记录 + voteRecordService.addVoteRecord(req.getVoteId(),req.getVoteOptionIds(),userVo); + + return ResponseData.success(); + } + + @Autowired + private PostMapper postMapper; + + @Override + public ResponseData voteDetail(Long voteId,Integer isAddBrowseNum, UserVo userVo) { + + //查询官方头像 + String avatar = businessUtil.getDict(DictConstant.官方头像).getImages(); + + VoteDetailResp voteDetailResp = voteMapper.voteDetail(voteId,userVo); + + if (voteDetailResp != null){ + //投票选项 + List voteOptions = voteOptionService.getList(CollectionUtil.toList(voteId),userVo); + + Map> map = voteOptions.stream().collect(Collectors.groupingBy(VoteOption::getVoteId)); + + voteDetailResp.setAvatar(avatar); + voteDetailResp.setVoteOptionList(map.get(voteId)); + + //是否增加浏览数 1不增加 2 加 + if (ObjectUtil.equal(2,isAddBrowseNum)) { + //增加浏览数 + this.baseMapper.updateVote(new Vote().setId(voteId).setBrowseNum(1)); + + //type: 类型 1作品 2 帖子 3投票 + postMapper.updateBrowseRecord(SnowIdUtils.uniqueLong(), 3, new Date(), voteId, userVo); + } + } + + return ResponseData.success(voteDetailResp); + } +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/votecomment/controller/VoteCommentController.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/votecomment/controller/VoteCommentController.java new file mode 100644 index 0000000..7803ab8 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/votecomment/controller/VoteCommentController.java @@ -0,0 +1,90 @@ +package com.ruoyi.frequency.votecomment.controller; + +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.page.TableDataInfo; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.common.utils.poi.ExcelUtil; +import com.ruoyi.frequency.votecomment.entity.VoteComment; +import com.ruoyi.frequency.votecomment.service.VoteCommentService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +/** + * 帖子评论Controller + * + * @author liwenlong + * @date 2023-10-09 + */ +@RestController +@RequestMapping("/frequency/votecomment") +public class VoteCommentController extends BaseController { + @Autowired + private VoteCommentService voteCommentService; + + /** + * 查询投票评论列表 + */ +// @PreAuthorize("@ss.hasPermi('frequency:poscomment:list')") + @PostMapping("/list") + public TableDataInfo list(@RequestBody VoteComment voteComment) { + startPage(); + List list = voteCommentService.selectVoteCommentList(voteComment); + return getDataTable(list); + } + + /** + * 导出投票评论列表 + */ + @Log(title = "投票评论", businessType = BusinessType.EXPORT) + @GetMapping("/export") + public AjaxResult export(VoteComment voteComment) { + List list = voteCommentService.selectVoteCommentList(voteComment); + ExcelUtil util = new ExcelUtil(VoteComment.class); + return util.exportExcel(list, "投票评论数据"); + } + + /** + * 获取投票评论详细信息 + */ + @PreAuthorize("@ss.hasPermi('frequency:votecomment:query')") + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") Long id) { + return AjaxResult.success(voteCommentService.selectVoteCommentById(id)); + } + + /** + * 新增投票评论 + */ + @PreAuthorize("@ss.hasPermi('frequency:votecomment:add')") + @Log(title = "投票评论", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody VoteComment voteComment) { + return toAjax(voteCommentService.insertVoteComment(voteComment)); + } + + /** + * 修改投票评论 + */ + @PreAuthorize("@ss.hasPermi('frequency:votecomment:edit')") + @Log(title = "投票评论", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody VoteComment voteComment) { + return toAjax(voteCommentService.updateVoteComment(voteComment)); + } + + /** + * 删除投票评论 + */ + @PreAuthorize("@ss.hasPermi('frequency:votecomment:remove')") + @Log(title = "投票评论", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}/{delFlag}") + public AjaxResult remove(@PathVariable("ids") Long[] ids,@PathVariable("delFlag") Integer delFlag) + { + return toAjax(voteCommentService.deleteCommentByIds(ids,delFlag)); + } +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/votecomment/entity/VoteComment.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/votecomment/entity/VoteComment.java new file mode 100644 index 0000000..529c238 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/votecomment/entity/VoteComment.java @@ -0,0 +1,104 @@ +package com.ruoyi.frequency.votecomment.entity; + +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableName; +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import com.ruoyi.controller.req.VoteCommentReq; +import com.ruoyi.post.controller.req.PostCommentReq; +import com.ruoyi.utils.SnowIdUtils; +import com.ruoyi.vo.UserInfo; +import com.ruoyi.vo.UserVo; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; + +/** + * 帖子评论对象 t_post_comment + * + * @author liwenlong + * @date 2023-10-09 + */ +@Data +@Accessors(chain = true) +@TableName("t_vote_comment") +public class VoteComment extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + + @ApiModelProperty("租户号") + private Long id; + + @ApiModelProperty("删除状态 1 正常 2 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("用户类型") + @Excel(name = "用户类型") + private Integer userType; + + @ApiModelProperty("评论用户id") + @Excel(name = "评论用户id") + private Long userId; + + @ApiModelProperty("投票id") + @Excel(name = "投票id") + private Long voteId; + + @ApiModelProperty("顶级评论id(对主体的直接评论)") + @Excel(name = "顶级评论id(对主体的直接评论)") + private Long topId; + + @ApiModelProperty("上级评论id 默认0") + @Excel(name = "上级评论id 默认0") + private Long parentId; + + @ApiModelProperty("用户类型") + @Excel(name = "用户类型") + private Integer parentUserType; + + @ApiModelProperty("上级评论用户id") + @Excel(name = "上级评论用户id") + private Long parentUserId; + + @ApiModelProperty("评论内容") + @Excel(name = "评论内容") + private String content; + + @ApiModelProperty("图片") + @Excel(name = "图片") + private String image; + + @ApiModelProperty("点赞数") + @Excel(name = "点赞数") + private Integer likeNum; + + @ApiModelProperty("评论数") + @Excel(name = "评论数") + private Integer commentNum; + + @ApiModelProperty("上级评论id集合,逗号拼接") + @Excel(name = "上级评论id集合,逗号拼接") + private String parentIds; + + @ApiModelProperty(value = "用户信息") + @TableField(exist = false) + private UserInfo userInfo; + + @ApiModelProperty(value = "上级用户用户昵称") + @TableField(exist = false) + private UserInfo parentUserInfo; + + public VoteComment() { + } + + public VoteComment(VoteCommentReq req, UserVo userVo) { + this.id = SnowIdUtils.uniqueLong(); + this.userType = userVo.getUserType(); + this.userId = userVo.getUserId(); + this.voteId = req.getVoteId(); + this.content = req.getContent(); + this.image = req.getImage(); + this.parentId = req.getParentId(); + } +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/votecomment/mapper/VoteCommentMapper.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/votecomment/mapper/VoteCommentMapper.java new file mode 100644 index 0000000..a675e4a --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/votecomment/mapper/VoteCommentMapper.java @@ -0,0 +1,106 @@ +package com.ruoyi.frequency.votecomment.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.ruoyi.controller.req.DialoguePageReq; +import com.ruoyi.controller.req.VoteCommentPageReq; +import com.ruoyi.controller.resp.CommentNum; +import com.ruoyi.controller.resp.VoteCommentPageResp; +import com.ruoyi.controller.resp.VoteCommentResp; +import com.ruoyi.frequency.votecomment.entity.VoteComment; +import com.ruoyi.vo.UserVo; +import org.apache.ibatis.annotations.Param; +import org.apache.ibatis.annotations.Update; + +import java.util.List; + +/** + * 帖子评论Mapper接口 + * + * @author liwenlong + * @date 2023-10-09 + */ +public interface VoteCommentMapper extends BaseMapper { + /** + * 查询帖子评论 + * + * @param id 帖子评论主键 + * @return 帖子评论 + */ + public VoteComment selectVoteCommentById(Long id); + + /** + * 查询帖子评论列表 + * + * @param voteComment 帖子评论 + * @return 帖子评论集合 + */ + public List selectVoteCommentList(VoteComment voteComment); + + /** + * 新增帖子评论 + * + * @param voteComment 帖子评论 + * @return 结果 + */ + public int insertVoteComment(VoteComment voteComment); + + /** + * 修改帖子评论 + * + * @param voteComment 帖子评论 + * @return 结果 + */ + public int updateVoteComment(VoteComment voteComment); + + /** + * 删除帖子评论 + * + * @param id 帖子评论主键 + * @return 结果 + */ + public int deleteVoteCommentById(Long id); + + /** + * 批量删除帖子评论 + * + * @param ids 需要删除的数据主键集合 + * @return 结果 + */ + public int deleteVoteCommentByIds(Long[] ids); + + + /** + * 获取评论后数据 + * + * @param id + * @return + */ + VoteCommentResp getVoteCommentResp(@Param("id")Long id, @Param("userVo") UserVo userVo); + + + /** + * 帖子评论列表 + * + * @param objectPage + * @param req + * @param userVo + * @return + */ + Page voteCommentPage(@Param("page") Page objectPage, @Param("req") VoteCommentPageReq req, @Param("userVo") UserVo userVo); + + List selectVoteCommentNumList(@Param("voteIds") List voteIds, @Param("userVoList") List userVoList, @Param("parentId") Long parentId); + + List selectCommentNumList(@Param("commentIds") List commentIds, @Param("userVoList") List userVoList); + + List selectedNewCommentList(@Param("voteIds") List voteIds); + + @Update("update t_vote_comment set like_num = like_num + #{num} , update_time=now() where id = #{id}") + int updateVoteCommentLikeNum(@Param("id") Long id, @Param("num") Integer num); + + List voteCommentList(@Param("req") VoteCommentPageReq req, @Param("userVo") UserVo userVo, @Param("list") List parentIds); + + Page voteCommentDialoguePage(@Param("page") Page objectPage, @Param("req") DialoguePageReq req, @Param("userVo") UserVo userVo); + + void updateVoteCommentBatch(@Param("list")List voteComments); +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/votecomment/mapper/mapping/VoteCommentMapper.xml b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/votecomment/mapper/mapping/VoteCommentMapper.xml new file mode 100644 index 0000000..898a4f3 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/votecomment/mapper/mapping/VoteCommentMapper.xml @@ -0,0 +1,617 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + select id, del_flag, create_by, create_time, update_by, update_time, user_type, user_id, vote_id, top_id, parent_id, parent_user_type, parent_user_id, content, image, like_num, comment_num from t_vote_comment + + + + + + + + insert into t_vote_comment + + id, + del_flag, + create_by, + create_time, + update_by, + update_time, + user_type, + user_id, + vote_id, + top_id, + parent_id, + parent_user_type, + parent_user_id, + content, + image, + like_num, + comment_num, + + + #{id}, + #{delFlag}, + #{createBy}, + #{createTime}, + #{updateBy}, + #{updateTime}, + #{userType}, + #{userId}, + #{voteId}, + #{topId}, + #{parentId}, + #{parentUserType}, + #{parentUserId}, + #{content}, + #{image}, + #{likeNum}, + #{commentNum}, + + + + + update t_vote_comment + + del_flag = #{delFlag}, + create_by = #{createBy}, + create_time = #{createTime}, + update_by = #{updateBy}, + update_time = #{updateTime}, + user_type = #{userType}, + user_id = #{userId}, + vote_id = #{voteId}, + top_id = #{topId}, + parent_id = #{parentId}, + parent_user_type = #{parentUserType}, + parent_user_id = #{parentUserId}, + content = #{content}, + image = #{image}, + like_num = like_num + #{likeNum}, + comment_num = comment_num + #{commentNum}, + + where id = #{id} + and like_num + #{likeNum}>=0 + and comment_num + #{commentNum} >= 0 + + + + delete from t_vote_comment where id = #{id} + + + + delete from t_vote_comment where id in + + #{id} + + + + + + + + + + + + + + + + + + + + + update t_vote_comment + + like_num = like_num + #{item.likeNum}, + comment_num = comment_num + #{item.commentNum}, + + where id = #{item.id} + and like_num + #{item.likeNum}>=0 + and comment_num + #{item.commentNum} >= 0 + + + diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/votecomment/model/param/VoteCommentParam.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/votecomment/model/param/VoteCommentParam.java new file mode 100644 index 0000000..5203057 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/votecomment/model/param/VoteCommentParam.java @@ -0,0 +1,88 @@ +package com.ruoyi.frequency.votecomment.model.param; + +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; + +/** + * 帖子评论对象 t_post_comment + * + * @author liwenlong + * @date 2023-10-09 + */ +@Data +@Accessors(chain = true) +public class VoteCommentParam extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + @ApiModelProperty("租户号") + private Long id; + + @ApiModelProperty("删除状态 1 正常 2 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("用户类型") + @Excel(name = "用户类型") + private Integer userType; + + @ApiModelProperty("评论用户id") + @Excel(name = "评论用户id") + private Long userId; + + @ApiModelProperty("投票id") + @Excel(name = "投票id") + private Long voteId; + + @ApiModelProperty("顶级评论id(对主体的直接评论)") + @Excel(name = "顶级评论id(对主体的直接评论)") + private Long topId; + + @ApiModelProperty("上级评论id 默认0") + @Excel(name = "上级评论id 默认0") + private Long parentId; + + @ApiModelProperty("用户类型") + @Excel(name = "用户类型") + private Integer parentUserType; + + @ApiModelProperty("上级评论用户id") + @Excel(name = "上级评论用户id") + private Long parentUserId; + + @ApiModelProperty("评论内容") + @Excel(name = "评论内容") + private String content; + + @ApiModelProperty("图片") + @Excel(name = "图片") + private String image; + + @ApiModelProperty("点赞数") + @Excel(name = "点赞数") + private Long likeNum; + + @ApiModelProperty("评论数") + @Excel(name = "评论数") + private Long commentNum; + + @ApiModelProperty("上级评论id集合,逗号拼接") + @Excel(name = "上级评论id集合,逗号拼接") + private String parentIds; + + + + + + + + + + + + + + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/votecomment/model/result/VoteCommentResult.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/votecomment/model/result/VoteCommentResult.java new file mode 100644 index 0000000..1fca8cf --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/votecomment/model/result/VoteCommentResult.java @@ -0,0 +1,75 @@ +package com.ruoyi.frequency.votecomment.model.result; + +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; + +/** + * 帖子评论对象 t_post_comment + * + * @author liwenlong + * @date 2023-10-09 + */ +@Data +@Accessors(chain = true) +public class VoteCommentResult extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + @ApiModelProperty("租户号") + private Long id; + + @ApiModelProperty("删除状态 1 正常 2 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("用户类型") + @Excel(name = "用户类型") + private Integer userType; + + @ApiModelProperty("评论用户id") + @Excel(name = "评论用户id") + private Long userId; + + @ApiModelProperty("投票id") + @Excel(name = "投票id") + private Long voteId; + + @ApiModelProperty("顶级评论id(对主体的直接评论)") + @Excel(name = "顶级评论id(对主体的直接评论)") + private Long topId; + + @ApiModelProperty("上级评论id 默认0") + @Excel(name = "上级评论id 默认0") + private Long parentId; + + @ApiModelProperty("用户类型") + @Excel(name = "用户类型") + private Integer parentUserType; + + @ApiModelProperty("上级评论用户id") + @Excel(name = "上级评论用户id") + private Long parentUserId; + + @ApiModelProperty("评论内容") + @Excel(name = "评论内容") + private String content; + + @ApiModelProperty("图片") + @Excel(name = "图片") + private String image; + + @ApiModelProperty("点赞数") + @Excel(name = "点赞数") + private Long likeNum; + + @ApiModelProperty("评论数") + @Excel(name = "评论数") + private Long commentNum; + + @ApiModelProperty("上级评论id集合,逗号拼接") + @Excel(name = "上级评论id集合,逗号拼接") + private String parentIds; + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/votecomment/service/VoteCommentService.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/votecomment/service/VoteCommentService.java new file mode 100644 index 0000000..e3ba6e8 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/votecomment/service/VoteCommentService.java @@ -0,0 +1,112 @@ +package com.ruoyi.frequency.votecomment.service; + +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.IService; +import com.ruoyi.common.page.PageResult; +import com.ruoyi.controller.req.DialoguePageReq; +import com.ruoyi.controller.req.VoteCommentPageReq; +import com.ruoyi.controller.req.VoteCommentReq; +import com.ruoyi.controller.resp.VoteCommentPageResp; +import com.ruoyi.controller.resp.VoteCommentResp; +import com.ruoyi.frequency.votecomment.entity.VoteComment; +import com.ruoyi.post.controller.req.DeleteCommentReq; +import com.ruoyi.post.controller.vo.SelectedComment; +import com.ruoyi.response.ResponseData; +import com.ruoyi.vo.UserVo; + +import java.util.List; +import java.util.Map; + +/** + * 帖子评论Service接口 + * + * @author liwenlong + * @date 2023-10-09 + */ +public interface VoteCommentService extends IService +{ + /** + * 查询帖子评论 + * + * @param id 帖子评论主键 + * @return 帖子评论 + */ + public VoteComment selectVoteCommentById(Long id); + + /** + * 查询帖子评论列表 + * + * @param voteComment 帖子评论 + * @return 帖子评论集合 + */ + public List selectVoteCommentList(VoteComment voteComment); + + /** + * 新增帖子评论 + * + * @param voteComment 帖子评论 + * @return 结果 + */ + public int insertVoteComment(VoteComment voteComment); + + /** + * 修改帖子评论 + * + * @param voteComment 帖子评论 + * @return 结果 + */ + public int updateVoteComment(VoteComment voteComment); + + int updateVoteCommentLikeNum(VoteComment voteComment, Integer num); + + /** + * 批量删除帖子评论 + * + * @param ids 需要删除的帖子评论主键集合 + * @return 结果 + */ + public int deleteVoteCommentByIds(Long[] ids); + + /** + * 删除帖子评论信息 + * + * @param id 帖子评论主键 + * @return 结果 + */ + public int deleteVoteCommentById(Long id); + + + /** + * 帖子评论 + * @param req + * @param userVo 登入用户 + * @return + */ + ResponseData voteComment(VoteCommentReq req, UserVo userVo); + + + /** + * 帖子评论列表 + * @param req + * @param userVo 登入用户 + * @return + */ + ResponseData voteCommentPage(VoteCommentPageReq req, UserVo userVo); + + /** + * 删除评论 + * @param req + * @param userVo 登入用户 + * @return + */ + ResponseData deleteComment(DeleteCommentReq req, UserVo userVo); + + + Map commentNumMap(List voteIds, List userVoList, Long parentId); + + ResponseData voteCommentDetail(Long id, UserVo userVo); + + ResponseData>> voteCommentDialoguePage(DialoguePageReq req, UserVo userVo); + + int deleteCommentByIds(Long[] ids, Integer delFlag); +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/votecomment/service/impl/VoteCommentServiceImpl.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/votecomment/service/impl/VoteCommentServiceImpl.java new file mode 100644 index 0000000..8cb090d --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/votecomment/service/impl/VoteCommentServiceImpl.java @@ -0,0 +1,528 @@ +package com.ruoyi.frequency.votecomment.service.impl; + +import cn.hutool.core.collection.CollectionUtil; +import cn.hutool.core.util.ObjectUtil; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.ruoyi.code.PublicCommon; +import com.ruoyi.common.page.PageResult; +import com.ruoyi.common.utils.DateUtils; +import com.ruoyi.controller.req.DialoguePageReq; +import com.ruoyi.controller.req.VoteCommentPageReq; +import com.ruoyi.controller.req.VoteCommentReq; +import com.ruoyi.controller.resp.CommentNum; +import com.ruoyi.controller.resp.VoteCommentPageResp; +import com.ruoyi.controller.resp.VoteCommentResp; +import com.ruoyi.enums.message.InteractionMessageEnums; +import com.ruoyi.frequency.customer.service.UserService; +import com.ruoyi.frequency.vote.entity.Vote; +import com.ruoyi.frequency.vote.mapper.VoteMapper; +import com.ruoyi.frequency.vote.service.VoteService; +import com.ruoyi.frequency.votecomment.entity.VoteComment; +import com.ruoyi.frequency.votecomment.mapper.VoteCommentMapper; +import com.ruoyi.frequency.votecomment.service.VoteCommentService; +import com.ruoyi.message.frequency.interactionmessagerecord.service.InteractionMessageRecordService; +import com.ruoyi.post.controller.req.DeleteCommentReq; +import com.ruoyi.response.ResponseData; +import com.ruoyi.utils.BusinessUtil; +import com.ruoyi.vo.UserInfo; +import com.ruoyi.vo.UserVo; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.*; +import java.util.stream.Collectors; + +/** + * 帖子评论Service业务层处理 + * + * @author liwenlong + * @date 2023-10-09 + */ +@Service +@Transactional(rollbackFor = Exception.class) +public class VoteCommentServiceImpl extends ServiceImpl implements VoteCommentService { + @Autowired + private VoteCommentMapper voteCommentMapper; + + /** + * 查询帖子评论 + * + * @param id 帖子评论主键 + * @return 帖子评论 + */ + @Override + public VoteComment selectVoteCommentById(Long id) { + VoteComment voteComment = voteCommentMapper.selectVoteCommentById(id); + + if (voteComment != null) { + Set userVoSet = new HashSet<>(); + userVoSet.add(new UserVo(voteComment.getUserType(), voteComment.getUserId())); + userVoSet.add(new UserVo(voteComment.getParentUserType(), voteComment.getParentUserId())); + + //查询用户信息 + Map userMap = userService.selectUserInfoMap(userVoSet, null); + + voteComment.setUserInfo(userMap.get(new UserVo(voteComment.getUserType(), voteComment.getUserId()))); + voteComment.setParentUserInfo(userMap.get(new UserVo(voteComment.getParentUserType(), voteComment.getParentUserId()))); + } + + return voteComment; + } + + /** + * 查询帖子评论列表 + * + * @param voteComment 帖子评论 + * @return 帖子评论 + */ + @Override + public List selectVoteCommentList(VoteComment voteComment) { + List voteComments = voteCommentMapper.selectVoteCommentList(voteComment); + + if (!voteComments.isEmpty()) { + Set userVoSet = voteComments.stream().map(s -> new UserVo(s.getUserType(), s.getUserId())).collect(Collectors.toSet()); + Set parentUserVoSet = voteComments.stream().map(s -> new UserVo(s.getParentUserType(), s.getParentUserId())).collect(Collectors.toSet()); + + userVoSet.addAll(parentUserVoSet); + + //查询用户信息 + Map userMap = userService.selectUserInfoMap(userVoSet, null); + + voteComments.stream().forEach(s -> { + s.setUserInfo(userMap.get(new UserVo(s.getUserType(), s.getUserId()))); + s.setParentUserInfo(userMap.get(new UserVo(s.getParentUserType(), s.getParentUserId()))); + }); + } + + return voteComments; + } + + /** + * 新增帖子评论 + * + * @param voteComment 帖子评论 + * @return 结果 + */ + @Override + public int insertVoteComment(VoteComment voteComment) { + voteComment.setCreateTime(DateUtils.getNowDate()); + return voteCommentMapper.insertVoteComment(voteComment); + } + + /** + * 修改帖子评论 + * + * @param voteComment 帖子评论 + * @return 结果 + */ + @Override + public int updateVoteComment(VoteComment voteComment) { + voteComment.setUpdateTime(DateUtils.getNowDate()); + return voteCommentMapper.updateVoteComment(voteComment); + } + + /** + * 修改帖子评论 + * + * @param voteComment 帖子评论 + * @return 结果 + */ + @Override + public int updateVoteCommentLikeNum(VoteComment voteComment, Integer num) { + return voteCommentMapper.updateVoteCommentLikeNum(voteComment.getId(), num); + } + + /** + * 批量删除帖子评论 + * + * @param ids 需要删除的帖子评论主键 + * @return 结果 + */ + @Override + public int deleteVoteCommentByIds(Long[] ids) { + this.lambdaUpdate().set(VoteComment::getDelFlag, PublicCommon.删除).in(VoteComment::getId, ids).update(); + return ids.length; + } + + /** + * 删除帖子评论信息 + * + * @param id 帖子评论主键 + * @return 结果 + */ + @Override + public int deleteVoteCommentById(Long id) { + this.lambdaUpdate().set(VoteComment::getDelFlag, PublicCommon.删除).eq(VoteComment::getId, id).update(); + return 1; + } + + @Autowired + private UserService userService; + + @Autowired + private VoteService voteService; + + @Override + public ResponseData voteComment(VoteCommentReq req, UserVo userVo) { + + //帖子评论 + VoteComment voteComment = new VoteComment(req, userVo); + + + //帖子-->评论 + if (ObjectUtil.isEmpty(req.getParentId()) || ObjectUtil.equal(0L, req.getParentId())) { + //顶级评论id + voteComment.setTopId(voteComment.getId()); + + } else { + //查询上级评论 + VoteComment parentVoteComment = this.getById(req.getParentId()); + + //评论用户 + voteComment.setParentUserId(parentVoteComment.getUserId()) + .setParentUserType(parentVoteComment.getUserType()); + + voteComment.setTopId(parentVoteComment.getTopId()); + + //上级id + if (ObjectUtil.isNotEmpty(parentVoteComment.getParentIds())) { + voteComment.setParentIds(parentVoteComment.getParentIds() + "," + parentVoteComment.getId()); + } else { + voteComment.setParentIds(parentVoteComment.getId() + ""); + } + + } + + this.save(voteComment); + + //1 帖子 2 帖子评论 + Integer type = ObjectUtil.equal(0L, req.getParentId()) || ObjectUtil.isEmpty(req.getParentId()) ? 1 : 2; + + //修改评论数(只要针对这个投票下的评论 投票评论数都要+1) + voteMapper.updateVote(new Vote().setId(voteComment.getVoteId()).setCommentNum(1)); + //投票评论 所有上级评论数+1 + if (ObjectUtil.equal(2, type)) { + //上级评论ids + List pids = Arrays.stream(voteComment.getParentIds().split(",")).collect(Collectors.toList()); + + List voteComments = pids.stream().map(id -> { + VoteComment comment = new VoteComment().setId(Long.valueOf(id)).setCommentNum(1); + comment.setUpdateTime(DateUtils.getNowDate()); + return comment; + } + ).collect(Collectors.toList()); + + this.baseMapper.updateVoteCommentBatch(voteComments); + } + + + //返回结果 + VoteCommentResp commentResp = baseMapper.getVoteCommentResp(voteComment.getId(), userVo); + + if (commentResp != null) { + + UserVo parentUserVo = new UserVo(voteComment.getParentUserType(), voteComment.getParentUserId()); + + Set userVoSet = CollectionUtil.newHashSet(userVo, parentUserVo); + //查询用户信息 + Map userMap = userService.selectUserInfoMap(userVoSet, userVo); + + commentResp.setUserInfo(userMap.get(userVo)); + + commentResp.setParentUserInfo(userMap.get(parentUserVo)); + } + + //推送消息 + pushMessage(req, userVo, true); + return ResponseData.success(commentResp); + } + + @Autowired + private InteractionMessageRecordService interactionMessageRecordService; + + /** + * 推送消息 + * + * @param req + * @param userVo + * @param isPush + */ + private void pushMessage(VoteCommentReq req, UserVo userVo, Boolean isPush) { + + InteractionMessageEnums enums = ObjectUtil.equal(0L, req.getParentId()) ? InteractionMessageEnums.COMMENT_POST : InteractionMessageEnums.REPLY_POST_COMMENT; + + //帖子id + Long voteId = null; + + //接收消息用户 + UserVo sendUserVo = null; + + if (ObjectUtil.equal(0L, req.getParentId())) { + //评论帖子 + voteId = req.getVoteId(); + //帖子 + Vote vote = voteService.getById(voteId); + } else { + //回复评论 + VoteComment voteComment = this.getById(req.getParentId()); + voteId = voteComment.getVoteId(); + sendUserVo = new UserVo(voteComment.getUserType(), voteComment.getUserId()); + } + //互动消息 + interactionMessageRecordService.addInteractionMessage(userVo, sendUserVo, PublicCommon.InteractionMessage.评论, voteId, isPush, enums); + + } + + @Override + public ResponseData voteCommentPage(VoteCommentPageReq req, UserVo userVo) { + + //筛去拉黑与被拉黑用户 + List blockUserList = userService.blockUserList(userVo); + req.setBlockUserList(blockUserList); + + //筛去屏蔽用户 + List shieldUserList = userService.shieldUserList(userVo); + req.setShieldUserList(shieldUserList); + + Page page = this.baseMapper.voteCommentPage(new Page<>(req.getPageNo(), req.getPageSize()), req, userVo); + + if (!page.getRecords().isEmpty()) { + Set userVoSet = page.getRecords().stream().map(votePageResp -> new UserVo(votePageResp.getUserType(), votePageResp.getUserId())).collect(Collectors.toSet()); + Set parentUserVoSet = page.getRecords().stream().map(votePageResp -> new UserVo(votePageResp.getParentUserType(), votePageResp.getParentUserId())).collect(Collectors.toSet()); + + userVoSet.addAll(parentUserVoSet); + + List voteCommentList = twoCommentList(req, userVo, page); + + voteCommentList.stream().forEach(votePageResp -> { + userVoSet.add(new UserVo(votePageResp.getUserType(), votePageResp.getUserId())); + userVoSet.add(new UserVo(votePageResp.getParentUserType(), votePageResp.getParentUserId())); + }); + + + //查询用户信息 + Map userMap = userService.selectUserInfoMap(userVoSet, userVo); + + List userVoList = CollectionUtil.addAllIfNotContains(blockUserList, shieldUserList); + + Map commentNumMap = getCommentNumMap(userVoList, page.getRecords()); + + voteCommentList.stream().forEach(resp -> { + resp.setUserInfo(userMap.get(new UserVo(resp.getUserType(), resp.getUserId()))); + resp.setParentUserInfo(userMap.get(new UserVo(resp.getParentUserType(), resp.getParentUserId()))); + }); + //获取二级评论 + Map> map = voteCommentList.stream().collect(Collectors.groupingBy(VoteCommentPageResp::getParentId)); + ; + + + page.getRecords().stream().forEach(resp -> { + resp.setUserInfo(userMap.get(new UserVo(resp.getUserType(), resp.getUserId()))); + resp.setParentUserInfo(userMap.get(new UserVo(resp.getParentUserType(), resp.getParentUserId()))); + if (commentNumMap.get(resp.getId()) != null) { + resp.setCommentNum(resp.getCommentNum() - commentNumMap.get(resp.getId())); + } + + //二级评论 + resp.setChildrenList(map.get(resp.getId())); + }); + } + + return ResponseData.success(new PageResult<>(page)); + } + + /** + * 获取二级评论ID + * + * @param req + * @param userVo + * @param page + * @return + */ + private List twoCommentList(VoteCommentPageReq req, UserVo userVo, Page page) { + + Map> map = new HashMap<>(); + + if (ObjectUtil.isEmpty(req.getParentId())) { + //一级评论ID + List parentIds = page.getRecords().stream().map(VoteCommentPageResp::getId).collect(Collectors.toList()); + + if (CollectionUtil.isEmpty(parentIds)) { + return new ArrayList<>(); + } + //查询二级评论 + List voteCommentList = this.baseMapper.voteCommentList(req, userVo, parentIds); + + return voteCommentList; + } + return new ArrayList<>(); + } + + private Map getCommentNumMap(List userVoList, List respList) { + + if (userVoList.size() == 0) { + return new HashMap<>(); + } + List commentIds = respList.stream().map(VoteCommentPageResp::getId).collect(Collectors.toList()); + //查询用户对应评论的数量 key一级评论id value 隐藏数量 + List commentNums = voteCommentMapper.selectCommentNumList(commentIds, userVoList); + + Map commentNumMap = new HashMap<>(); + commentNums.stream().forEach(s -> { + commentNumMap.put(s.getVoteId(), s.getCommentNum()); + }); + return commentNumMap; + } + + @Override + public ResponseData deleteComment(DeleteCommentReq req, UserVo userVo) { + + boolean update = this.lambdaUpdate().set(VoteComment::getDelFlag, PublicCommon.删除) + .eq(VoteComment::getUserType, userVo.getUserType()) + .eq(VoteComment::getUserId, userVo.getUserId()) + .eq(VoteComment::getId, req.getId()) + .eq(VoteComment::getDelFlag, PublicCommon.启用).update(); + + if (update) { + afterDeleteComment(req.getId()); + } + return ResponseData.success(); + } + + private void afterDeleteComment(Long objectId) { + + VoteComment voteComment = this.getById(objectId); + + //1 投票 2 评论 + Integer type = ObjectUtil.equal(0L, voteComment.getParentId()) ? 1 : 2; + + Integer num = -(voteComment.getCommentNum() + 1); + //帖子评论 上级数量 + if (ObjectUtil.equal(2, type)) { + //当前评论上级ids + List pids = Arrays.stream(voteComment.getParentIds() + .split(",")).collect(Collectors.toList()); + num = -1 * pids.size(); + + //上级评论数都要减去当前删除评论数 + 1(本身评论) + List voteComments = pids.stream().map(id -> { + VoteComment comment = new VoteComment().setId(Long.valueOf(id)).setCommentNum(-1 * (voteComment.getCommentNum() + 1)); + comment.setUpdateTime(DateUtils.getNowDate()); + return comment; + }).collect(Collectors.toList()); + + this.baseMapper.updateVoteCommentBatch(voteComments); + + } + this.lambdaUpdate().set(VoteComment::getDelFlag, PublicCommon.删除) + .like(VoteComment::getParentIds, objectId) + .eq(VoteComment::getDelFlag, PublicCommon.启用).update(); + + + //修改评论数 + voteMapper.updateVote(new Vote().setId(voteComment.getVoteId()).setCommentNum(num)); + } + + @Override + public int deleteCommentByIds(Long[] ids, Integer delFlag) { + + if (PublicCommon.删除.equals(delFlag)) { + for (Long objectId : ids) { + afterDeleteComment(objectId); + } + } + + this.lambdaUpdate().set(VoteComment::getDelFlag, delFlag).in(VoteComment::getId, ids).update(); + return 1; + } + + @Autowired + private BusinessUtil businessUtil; + + + @Autowired + private VoteMapper voteMapper; + + /** + * 修改评论数 + * + * @param objectId 评论主体id + * @param type 1投票 2 投票评论 + * @param num + */ + private void updateVoteCommentNum(Long objectId, Integer type, Integer num) { + + switch (type) { + case 1: + voteMapper.updateVote(new Vote().setId(objectId).setCommentNum(num)); + break; + case 2: + this.updateVoteComment(new VoteComment().setId(objectId).setCommentNum(num)); + break; + default: + throw new IllegalStateException("Unexpected value: " + type); + } + } + + + @Override + public Map commentNumMap(List voteIds, List userVoList, Long parentId) { + + List commentNums = voteCommentMapper.selectVoteCommentNumList(voteIds, userVoList, parentId); + + Map commentNumMap = new HashMap<>(); + commentNums.stream().forEach(s -> { + commentNumMap.put(s.getVoteId(), s.getCommentNum()); + }); + + return commentNumMap; + } + + @Override + public ResponseData voteCommentDetail(Long id, UserVo userVo) { + //返回结果 + VoteCommentResp commentResp = baseMapper.getVoteCommentResp(id, userVo); + + if (commentResp != null) { + + UserVo parentUserVo = new UserVo(commentResp.getParentUserType(), commentResp.getParentUserId()); + UserVo user = new UserVo(commentResp.getUserType(), commentResp.getUserId()); + + Set userVoSet = CollectionUtil.newHashSet(user, parentUserVo); + //查询用户信息 + Map userMap = userService.selectUserInfoMap(userVoSet, userVo); + + commentResp.setUserInfo(userMap.get(user)); + + commentResp.setParentUserInfo(userMap.get(parentUserVo)); + } + + return ResponseData.success(commentResp); + } + + @Override + public ResponseData>> voteCommentDialoguePage(DialoguePageReq req, UserVo userVo) { + Page page = this.baseMapper.voteCommentDialoguePage(new Page<>(req.getPageNo(), req.getPageSize()), req, userVo); + + if (!page.getRecords().isEmpty()) { + Set userVoSet = page.getRecords().stream().map(votePageResp -> new UserVo(votePageResp.getUserType(), votePageResp.getUserId())).collect(Collectors.toSet()); + Set parentUserVoSet = page.getRecords().stream().map(votePageResp -> new UserVo(votePageResp.getParentUserType(), votePageResp.getParentUserId())).collect(Collectors.toSet()); + + userVoSet.addAll(parentUserVoSet); + + //查询用户信息 + Map userMap = userService.selectUserInfoMap(userVoSet, userVo); + + page.getRecords().stream().forEach(resp -> { + resp.setUserInfo(userMap.get(new UserVo(resp.getUserType(), resp.getUserId()))); + resp.setParentUserInfo(userMap.get(new UserVo(resp.getParentUserType(), resp.getParentUserId()))); + }); + } + + return ResponseData.success(new PageResult<>(page)); + } + + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/votelike/controller/VoteLikeController.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/votelike/controller/VoteLikeController.java new file mode 100644 index 0000000..91720d2 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/votelike/controller/VoteLikeController.java @@ -0,0 +1,103 @@ +package com.ruoyi.frequency.votelike.controller; + +import java.util.List; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.frequency.votelike.entity.VoteLike; +import com.ruoyi.frequency.votelike.service.VoteLikeService; +import com.ruoyi.common.utils.poi.ExcelUtil; +import com.ruoyi.common.core.page.TableDataInfo; + +/** + * 投票点赞Controller + * + * @author liwenlong + * @date 2024-04-10 + */ +@RestController +@RequestMapping("/frequency/votelike") +public class VoteLikeController extends BaseController +{ + @Autowired + private VoteLikeService voteLikeService; + + /** + * 查询投票点赞列表 + */ + @PreAuthorize("@ss.hasPermi('frequency:votelike:list')") + @GetMapping("/list") + public TableDataInfo list(VoteLike voteLike) + { + startPage(); + List list = voteLikeService.selectVoteLikeList(voteLike); + return getDataTable(list); + } + + /** + * 导出投票点赞列表 + */ + @PreAuthorize("@ss.hasPermi('frequency:votelike:export')") + @Log(title = "投票点赞", businessType = BusinessType.EXPORT) + @GetMapping("/export") + public AjaxResult export(VoteLike voteLike) + { + List list = voteLikeService.selectVoteLikeList(voteLike); + ExcelUtil util = new ExcelUtil(VoteLike.class); + return util.exportExcel(list, "投票点赞数据"); + } + + /** + * 获取投票点赞详细信息 + */ + @PreAuthorize("@ss.hasPermi('frequency:votelike:query')") + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") Long id) + { + return AjaxResult.success(voteLikeService.selectVoteLikeById(id)); + } + + /** + * 新增投票点赞 + */ + @PreAuthorize("@ss.hasPermi('frequency:votelike:add')") + @Log(title = "投票点赞", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody VoteLike voteLike) + { + return toAjax(voteLikeService.insertVoteLike(voteLike)); + } + + /** + * 修改投票点赞 + */ + @PreAuthorize("@ss.hasPermi('frequency:votelike:edit')") + @Log(title = "投票点赞", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody VoteLike voteLike) + { + return toAjax(voteLikeService.updateVoteLike(voteLike)); + } + + /** + * 删除投票点赞 + */ + @PreAuthorize("@ss.hasPermi('frequency:votelike:remove')") + @Log(title = "投票点赞", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}/{delFlag}") + public AjaxResult remove(@PathVariable("ids") Long[] ids,@PathVariable("delFlag") Integer delFlag) + { + return toAjax(voteLikeService.deleteVoteLikeByIds(ids,delFlag)); + } +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/votelike/entity/VoteLike.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/votelike/entity/VoteLike.java new file mode 100644 index 0000000..a0adf86 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/votelike/entity/VoteLike.java @@ -0,0 +1,64 @@ +package com.ruoyi.frequency.votelike.entity; + +import com.ruoyi.controller.req.VoteLikeReq; +import com.ruoyi.controller.req.WorksLikeReq; +import com.ruoyi.utils.SnowIdUtils; +import lombok.Data; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.experimental.Accessors; +import com.ruoyi.common.annotation.Excel; +import io.swagger.annotations.ApiModelProperty; +import com.baomidou.mybatisplus.annotation.TableField; +import com.ruoyi.vo.UserInfo; +import com.ruoyi.common.core.domain.BaseEntity; + +/** + * 投票点赞对象 t_vote_like + * + * @author liwenlong + * @date 2024-04-10 + */ +@Data +@Accessors(chain = true) +@TableName("t_vote_like") +public class VoteLike extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + + @ApiModelProperty("主键id") + private Long id; + + @ApiModelProperty("删除标志 1正常 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("类型 1投票 2评论") + @Excel(name = "类型 1投票 2评论") + private Integer type; + + @ApiModelProperty("用户类型 1 用户 2 商家") + @Excel(name = "用户类型 1 用户 2 商家") + private Integer userType; + + @ApiModelProperty("用户id") + @Excel(name = "用户id") + private Long userId; + + @ApiModelProperty("投票id") + @Excel(name = "投票id") + private Long objectId; + + @ApiModelProperty("用户信息") + @TableField(exist = false) + private UserInfo userInfo; + + + public VoteLike() { + } + + public VoteLike(VoteLikeReq req) { + this.id = SnowIdUtils.uniqueLong(); + this.objectId = req.getObjectId(); + this.type = req.getType(); + } +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/votelike/mapper/VoteLikeMapper.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/votelike/mapper/VoteLikeMapper.java new file mode 100644 index 0000000..7d5774e --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/votelike/mapper/VoteLikeMapper.java @@ -0,0 +1,50 @@ +package com.ruoyi.frequency.votelike.mapper; + +import java.util.List; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.ruoyi.frequency.votelike.entity.VoteLike; +import com.ruoyi.vo.UserVo; +import org.apache.ibatis.annotations.Param; + +/** + * 投票点赞Mapper接口 + * + * @author liwenlong + * @date 2024-04-10 + */ +public interface VoteLikeMapper extends BaseMapper +{ + /** + * 查询投票点赞 + * + * @param id 投票点赞主键 + * @return 投票点赞 + */ + public VoteLike selectVoteLikeById(Long id); + + /** + * 查询投票点赞列表 + * + * @param voteLike 投票点赞 + * @return 投票点赞集合 + */ + public List selectVoteLikeList(VoteLike voteLike); + + /** + * 新增投票点赞 + * + * @param voteLike 投票点赞 + * @return 结果 + */ + public int insertVoteLike(VoteLike voteLike); + + /** + * 修改投票点赞 + * + * @param voteLike 投票点赞 + * @return 结果 + */ + public int updateVoteLike(VoteLike voteLike); + + void voteLike(@Param("req")VoteLike voteLike, @Param("userVo")UserVo userVo); +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/votelike/mapper/mapping/VoteLikeMapper.xml b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/votelike/mapper/mapping/VoteLikeMapper.xml new file mode 100644 index 0000000..f9cf23f --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/votelike/mapper/mapping/VoteLikeMapper.xml @@ -0,0 +1,123 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + select + t.id , + t.create_by , + t.create_time , + t.update_by , + t.update_time , + t.del_flag , + t.type , + t.user_type , + t.user_id , + t.object_id , + u.user_type, + u.id_no, + u.mobile, + u.avatar, + u.nickname + from t_vote_like AS t + LEFT JOIN t_user AS u ON t.user_id = u.id + + + + + + + + insert into t_vote_like + + id, + create_by, + create_time, + update_by, + update_time, + del_flag, + type, + user_type, + user_id, + object_id, + + + #{id}, + #{createBy}, + #{createTime}, + #{updateBy}, + #{updateTime}, + #{delFlag}, + #{type}, + #{userType}, + #{userId}, + #{objectId}, + + + + + update t_vote_like + + create_by = #{createBy}, + create_time = #{createTime}, + update_by = #{updateBy}, + update_time = #{updateTime}, + del_flag = #{delFlag}, + type = #{type}, + user_type = #{userType}, + user_id = #{userId}, + object_id = #{objectId}, + + where id = #{id} + + + + insert into t_vote_like + (id, create_by, create_time, update_by, update_time, type, user_type, user_id, object_id) + values + (#{req.id},#{req.updateBy},#{req.updateTime},#{req.updateBy},#{req.updateTime},#{req.type},#{userVo.userType}, #{userVo.userId}, #{req.objectId}) + ON DUPLICATE KEY UPDATE + del_flag = IF( del_flag = 1, 3, 1 ), + update_time = #{req.updateTime}, + update_by = #{req.updateBy}; + + \ No newline at end of file diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/votelike/model/param/VoteLikeParam.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/votelike/model/param/VoteLikeParam.java new file mode 100644 index 0000000..9057e4d --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/votelike/model/param/VoteLikeParam.java @@ -0,0 +1,50 @@ +package com.ruoyi.frequency.votelike.entity.model.param; + +import lombok.Data; +import lombok.experimental.Accessors; +import com.ruoyi.common.annotation.Excel; +import io.swagger.annotations.ApiModelProperty; +import com.ruoyi.common.core.domain.BaseEntity; + +/** + * 投票点赞对象 t_vote_like + * + * @author liwenlong + * @date 2024-04-10 + */ +@Data +@Accessors(chain = true) +public class VoteLikeParam extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + @ApiModelProperty("主键id") + private Long id; + + @ApiModelProperty("删除标志 1正常 删除 3 禁用") + private Long delFlag; + + @ApiModelProperty("类型 1投票") + @Excel(name = "类型 1投票") + private Long type; + + @ApiModelProperty("用户类型 1 用户 2 商家") + @Excel(name = "用户类型 1 用户 2 商家") + private Long userType; + + @ApiModelProperty("用户id") + @Excel(name = "用户id") + private Long userId; + + @ApiModelProperty("投票id") + @Excel(name = "投票id") + private Long objectId; + + + + + + + + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/votelike/model/result/VoteLikeResult.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/votelike/model/result/VoteLikeResult.java new file mode 100644 index 0000000..db770a4 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/votelike/model/result/VoteLikeResult.java @@ -0,0 +1,44 @@ +package com.ruoyi.frequency.votelike.entity.model.result; + +import lombok.Data; +import lombok.experimental.Accessors; +import com.ruoyi.common.annotation.Excel; +import io.swagger.annotations.ApiModelProperty; +import com.ruoyi.common.core.domain.BaseEntity; + +/** + * 投票点赞对象 t_vote_like + * + * @author liwenlong + * @date 2024-04-10 + */ +@Data +@Accessors(chain = true) +public class VoteLikeResult extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + @ApiModelProperty("主键id") + private Long id; + + @ApiModelProperty("删除标志 1正常 删除 3 禁用") + private Long delFlag; + + @ApiModelProperty("类型 1投票") + @Excel(name = "类型 1投票") + private Long type; + + @ApiModelProperty("用户类型 1 用户 2 商家") + @Excel(name = "用户类型 1 用户 2 商家") + private Long userType; + + @ApiModelProperty("用户id") + @Excel(name = "用户id") + private Long userId; + + @ApiModelProperty("投票id") + @Excel(name = "投票id") + private Long objectId; + + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/votelike/service/VoteLikeService.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/votelike/service/VoteLikeService.java new file mode 100644 index 0000000..27999bb --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/votelike/service/VoteLikeService.java @@ -0,0 +1,66 @@ +package com.ruoyi.frequency.votelike.service; + +import java.util.List; + +import com.ruoyi.controller.req.VoteLikeReq; +import com.ruoyi.frequency.votelike.entity.VoteLike; +import com.baomidou.mybatisplus.extension.service.IService; +import com.ruoyi.response.ResponseData; +import com.ruoyi.vo.UserVo; + +/** + * 投票点赞Service接口 + * + * @author liwenlong + * @date 2024-04-10 + */ +public interface VoteLikeService extends IService +{ + /** + * 查询投票点赞 + * + * @param id 投票点赞主键 + * @return 投票点赞 + */ + public VoteLike selectVoteLikeById(Long id); + + /** + * 查询投票点赞列表 + * + * @param voteLike 投票点赞 + * @return 投票点赞集合 + */ + public List selectVoteLikeList(VoteLike voteLike); + + /** + * 新增投票点赞 + * + * @param voteLike 投票点赞 + * @return 结果 + */ + public int insertVoteLike(VoteLike voteLike); + + /** + * 修改投票点赞 + * + * @param voteLike 投票点赞 + * @return 结果 + */ + public int updateVoteLike(VoteLike voteLike); + + /** + * 批量删除投票点赞 + * + * @param ids 需要删除的投票点赞主键集合 + * @return 结果 + */ + public int deleteVoteLikeByIds(Long[] ids,Integer delFlag); + + /** + * 投票点赞 + * @param req + * @param userVo + * @return + */ + ResponseData voteLike(VoteLikeReq req, UserVo userVo); +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/votelike/service/impl/VoteLikeServiceImpl.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/votelike/service/impl/VoteLikeServiceImpl.java new file mode 100644 index 0000000..12e1532 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/votelike/service/impl/VoteLikeServiceImpl.java @@ -0,0 +1,197 @@ +package com.ruoyi.frequency.votelike.service.impl; + +import cn.hutool.core.util.ObjectUtil; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.ruoyi.code.DictConstant; +import com.ruoyi.code.PublicCommon; +import com.ruoyi.common.utils.DateUtils; +import com.ruoyi.controller.req.VoteLikeReq; +import com.ruoyi.enums.message.InteractionMessageEnums; +import com.ruoyi.frequency.vote.entity.Vote; +import com.ruoyi.frequency.vote.mapper.VoteMapper; +import com.ruoyi.frequency.vote.service.VoteService; +import com.ruoyi.frequency.votecomment.entity.VoteComment; +import com.ruoyi.frequency.votecomment.service.VoteCommentService; +import com.ruoyi.frequency.votelike.entity.VoteLike; +import com.ruoyi.frequency.votelike.mapper.VoteLikeMapper; +import com.ruoyi.frequency.votelike.service.VoteLikeService; +import com.ruoyi.message.frequency.interactionmessagerecord.service.InteractionMessageRecordService; +import com.ruoyi.response.ResponseData; +import com.ruoyi.utils.BusinessUtil; +import com.ruoyi.vo.UserVo; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * 投票点赞Service业务层处理 + * + * @author liwenlong + * @date 2024-04-10 + */ +@Service +public class VoteLikeServiceImpl extends ServiceImpl implements VoteLikeService { + @Autowired + private VoteLikeMapper voteLikeMapper; + + /** + * 查询投票点赞 + * + * @param id 投票点赞主键 + * @return 投票点赞 + */ + @Override + public VoteLike selectVoteLikeById(Long id) { + return voteLikeMapper.selectVoteLikeById(id); + } + + /** + * 查询投票点赞列表 + * + * @param voteLike 投票点赞 + * @return 投票点赞 + */ + @Override + public List selectVoteLikeList(VoteLike voteLike) { + return voteLikeMapper.selectVoteLikeList(voteLike); + } + + /** + * 新增投票点赞 + * + * @param voteLike 投票点赞 + * @return 结果 + */ + @Override + public int insertVoteLike(VoteLike voteLike) { + voteLike.setCreateData(); + return voteLikeMapper.insert(voteLike); + } + + /** + * 修改投票点赞 + * + * @param voteLike 投票点赞 + * @return 结果 + */ + @Override + public int updateVoteLike(VoteLike voteLike) { + voteLike.setUpdateData(); + return voteLikeMapper.updateVoteLike(voteLike); + } + + /** + * 批量删除投票点赞 + * + * @param ids 需要删除的投票点赞主键 + * @return 结果 + */ + @Override + public int deleteVoteLikeByIds(Long[] ids, Integer delFlag) { + this.lambdaUpdate().set(VoteLike::getDelFlag, delFlag).in(VoteLike::getId, ids).update(); + return ids.length; + } + + @Autowired + private BusinessUtil businessUtil; + + @Autowired + private VoteCommentService voteCommentService; + + + @Override + public ResponseData voteLike(VoteLikeReq req, UserVo userVo) { + + VoteLike voteLike = new VoteLike(req); + + //更新帖子点赞记录 + voteLikeMapper.voteLike(voteLike, userVo); + + voteLike = voteLikeMapper.selectOne(new QueryWrapper().lambda() + .eq(VoteLike::getObjectId, req.getObjectId()) + .eq(VoteLike::getType, req.getType()) + .eq(VoteLike::getUserType, userVo.getUserType()) + .eq(VoteLike::getUserId, userVo.getUserId()) + ); + //是否点赞 + Boolean isLike = voteLike.getDelFlag().equals(PublicCommon.启用); + + //是否是对自己的点赞或者踩 + + //精彩评论 1 投票 2 投票评论 + if (isLike && req.getType() == 2) { + //点赞量基础量(超过) + Integer likeNum = Integer.valueOf(businessUtil.getDict(DictConstant.点赞好评基础量).getDictValue()); + + VoteComment voteComment = voteCommentService.getById(req.getObjectId()); + + Vote vote = voteService.getById(voteComment.getVoteId()); + + if (ObjectUtil.isEmpty(vote.getCommentId()) && voteComment.getParentId() == 0L && voteComment.getLikeNum() >= likeNum) { + voteService.lambdaUpdate().set(Vote::getCommentId, voteComment.getId()) + .eq(Vote::getId, voteComment.getVoteId()).update(); + } + + } + + //更新数量 + switch (req.getType()) { + case 1: + Vote vote = new Vote().setId(req.getObjectId()); + vote.setUpdateTime(DateUtils.getNowDate()); + voteService.updateById(vote); + + //修改点赞数量 + voteMapper.updateVote(new Vote().setId(req.getObjectId()).setLikeNum(isLike ? 1 : -1)); + + break; + case 2: + voteCommentService.updateVoteComment(new VoteComment().setId(req.getObjectId()).setLikeNum(isLike ? 1 : -1)); + break; + } + + //推送消息 + pushMessage(req, userVo, isLike); + return ResponseData.success(); + } + + + /** + * 推送消息 + * + * @param req + * @param userVo + * @param isPush + */ + private void pushMessage(VoteLikeReq req, UserVo userVo, Boolean isPush) { + if (!isPush || req.getType() == 1) { + return; + } + InteractionMessageEnums enums = InteractionMessageEnums.LIKE_VOTE_COMMENT; + + + //接收消息用户 + UserVo sendUserVo = null; + + //评论点赞 + VoteComment voteComment = voteCommentService.getById(req.getObjectId()); + Long voteId = voteComment.getVoteId(); + sendUserVo = new UserVo(voteComment.getUserType(), voteComment.getUserId()); + + //互动消息 + interactionMessageRecordService.addInteractionMessage(userVo, sendUserVo, PublicCommon.InteractionMessage.点赞, voteId, isPush, enums); + } + + @Autowired + private InteractionMessageRecordService interactionMessageRecordService; + + @Autowired + private VoteService voteService; + + @Autowired + private VoteMapper voteMapper; + + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/voteoption/controller/VoteOptionController.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/voteoption/controller/VoteOptionController.java new file mode 100644 index 0000000..6e805c0 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/voteoption/controller/VoteOptionController.java @@ -0,0 +1,97 @@ +package com.ruoyi.frequency.voteoption.controller; + +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.page.TableDataInfo; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.common.utils.poi.ExcelUtil; +import com.ruoyi.frequency.voteoption.entity.VoteOption; +import com.ruoyi.frequency.voteoption.service.VoteOptionService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +/** + * 投票选项Controller + * + * @author liwenlong + * @date 2023-10-12 + */ +@RestController +@RequestMapping("/frequency/voteoption") +public class VoteOptionController extends BaseController +{ + @Autowired + private VoteOptionService voteOptionService; + + /** + * 查询投票选项列表 + */ + @PreAuthorize("@ss.hasPermi('frequency:voteoption:list')") + @GetMapping("/list") + public TableDataInfo list(VoteOption voteOption) + { + startPage(); + List list = voteOptionService.selectVoteOptionList(voteOption); + return getDataTable(list); + } + + /** + * 导出投票选项列表 + */ + @PreAuthorize("@ss.hasPermi('frequency:voteoption:export')") + @Log(title = "投票选项", businessType = BusinessType.EXPORT) + @GetMapping("/export") + public AjaxResult export(VoteOption voteOption) + { + List list = voteOptionService.selectVoteOptionList(voteOption); + ExcelUtil util = new ExcelUtil(VoteOption.class); + return util.exportExcel(list, "投票选项数据"); + } + + /** + * 获取投票选项详细信息 + */ + @PreAuthorize("@ss.hasPermi('frequency:voteoption:query')") + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") Long id) + { + return AjaxResult.success(voteOptionService.selectVoteOptionById(id)); + } + + /** + * 新增投票选项 + */ + @PreAuthorize("@ss.hasPermi('frequency:voteoption:add')") + @Log(title = "投票选项", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody VoteOption voteOption) + { + return toAjax(voteOptionService.insertVoteOption(voteOption)); + } + + /** + * 修改投票选项 + */ + @PreAuthorize("@ss.hasPermi('frequency:voteoption:edit')") + @Log(title = "投票选项", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody VoteOption voteOption) + { + return toAjax(voteOptionService.updateVoteOption(voteOption)); + } + + /** + * 删除投票选项 + */ + @PreAuthorize("@ss.hasPermi('frequency:voteoption:remove')") + @Log(title = "投票选项", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}") + public AjaxResult remove(@PathVariable Long[] ids) + { + return toAjax(voteOptionService.deleteVoteOptionByIds(ids)); + } +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/voteoption/entity/VoteOption.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/voteoption/entity/VoteOption.java new file mode 100644 index 0000000..13ed199 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/voteoption/entity/VoteOption.java @@ -0,0 +1,51 @@ +package com.ruoyi.frequency.voteoption.entity; + +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableName; +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; + +/** + * 投票选项对象 t_vote_option + * + * @author liwenlong + * @date 2023-10-12 + */ +@Data +@Accessors(chain = true) +@TableName("t_vote_option") +public class VoteOption extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + + @ApiModelProperty("租户号") + private Long id; + + @ApiModelProperty("删除标志;1 正常 2 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("投票活动id") + @Excel(name = "投票活动id") + private Long voteId; + + @ApiModelProperty("选项名称") + @Excel(name = "选项名称") + private String name; + + @ApiModelProperty("排序") + private Integer sort; + + @ApiModelProperty("投票人数") + @TableField(exist = false) + private Integer num; + + + @ApiModelProperty("是否投票 1没有 2已投") + @TableField(exist = false) + private Integer isVote; + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/voteoption/mapper/VoteOptionMapper.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/voteoption/mapper/VoteOptionMapper.java new file mode 100644 index 0000000..3fd9e6c --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/voteoption/mapper/VoteOptionMapper.java @@ -0,0 +1,67 @@ +package com.ruoyi.frequency.voteoption.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.ruoyi.frequency.voteoption.entity.VoteOption; +import com.ruoyi.vo.UserVo; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * 投票选项Mapper接口 + * + * @author liwenlong + * @date 2023-10-12 + */ +public interface VoteOptionMapper extends BaseMapper +{ + /** + * 查询投票选项 + * + * @param id 投票选项主键 + * @return 投票选项 + */ + public VoteOption selectVoteOptionById(Long id); + + /** + * 查询投票选项列表 + * + * @param voteOption 投票选项 + * @return 投票选项集合 + */ + public List selectVoteOptionList(VoteOption voteOption); + + /** + * 新增投票选项 + * + * @param voteOption 投票选项 + * @return 结果 + */ + public int insertVoteOption(VoteOption voteOption); + + /** + * 修改投票选项 + * + * @param voteOption 投票选项 + * @return 结果 + */ + public int updateVoteOption(VoteOption voteOption); + + /** + * 删除投票选项 + * + * @param id 投票选项主键 + * @return 结果 + */ + public int deleteVoteOptionById(Long id); + + /** + * 批量删除投票选项 + * + * @param ids 需要删除的数据主键集合 + * @return 结果 + */ + public int deleteVoteOptionByIds(Long[] ids); + + List getList(@Param("voteIds") List voteIds,@Param("userVo") UserVo userVo); +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/voteoption/mapper/mapping/VoteOptionMapper.xml b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/voteoption/mapper/mapping/VoteOptionMapper.xml new file mode 100644 index 0000000..95d44a2 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/voteoption/mapper/mapping/VoteOptionMapper.xml @@ -0,0 +1,124 @@ + + + + + + + + + + + + + + + + + select id, create_by, create_time, update_by, update_time, del_flag, vote_id, name from t_vote_option + + + + + + + + insert into t_vote_option + + id, + create_by, + create_time, + update_by, + update_time, + del_flag, + vote_id, + name, + + + #{id}, + #{createBy}, + #{createTime}, + #{updateBy}, + #{updateTime}, + #{delFlag}, + #{voteId}, + #{name}, + + + + + update t_vote_option + + create_by = #{createBy}, + create_time = #{createTime}, + update_by = #{updateBy}, + update_time = #{updateTime}, + del_flag = #{delFlag}, + vote_id = #{voteId}, + name = #{name}, + + where id = #{id} + + + + delete from t_vote_option where id = #{id} + + + + delete from t_vote_option where id in + + #{id} + + + + + diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/voteoption/model/param/VoteOptionParam.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/voteoption/model/param/VoteOptionParam.java new file mode 100644 index 0000000..0313a61 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/voteoption/model/param/VoteOptionParam.java @@ -0,0 +1,42 @@ +package com.ruoyi.frequency.voteoption.model.param; + +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; + +/** + * 投票选项对象 t_vote_option + * + * @author liwenlong + * @date 2023-10-12 + */ +@Data +@Accessors(chain = true) +public class VoteOptionParam extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + @ApiModelProperty("租户号") + private Long id; + + + @ApiModelProperty("删除标志;1 正常 2 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("投票活动id") + @Excel(name = "投票活动id") + private Long voteId; + + @ApiModelProperty("选项名称") + @Excel(name = "选项名称") + private String name; + + + + + + + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/voteoption/model/result/VoteOptionResult.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/voteoption/model/result/VoteOptionResult.java new file mode 100644 index 0000000..440f2db --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/voteoption/model/result/VoteOptionResult.java @@ -0,0 +1,37 @@ +package com.ruoyi.frequency.voteoption.model.result; + +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; + +/** + * 投票选项对象 t_vote_option + * + * @author liwenlong + * @date 2023-10-12 + */ +@Data +@Accessors(chain = true) +public class VoteOptionResult extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + @ApiModelProperty("租户号") + private Long id; + + + @ApiModelProperty("删除标志;1 正常 2 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("投票活动id") + @Excel(name = "投票活动id") + private Long voteId; + + @ApiModelProperty("选项名称") + @Excel(name = "选项名称") + private String name; + + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/voteoption/service/VoteOptionService.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/voteoption/service/VoteOptionService.java new file mode 100644 index 0000000..2547070 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/voteoption/service/VoteOptionService.java @@ -0,0 +1,67 @@ +package com.ruoyi.frequency.voteoption.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.ruoyi.frequency.voteoption.entity.VoteOption; +import com.ruoyi.vo.UserVo; + +import java.util.List; + +/** + * 投票选项Service接口 + * + * @author liwenlong + * @date 2023-10-12 + */ +public interface VoteOptionService extends IService +{ + /** + * 查询投票选项 + * + * @param id 投票选项主键 + * @return 投票选项 + */ + public VoteOption selectVoteOptionById(Long id); + + /** + * 查询投票选项列表 + * + * @param voteOption 投票选项 + * @return 投票选项集合 + */ + public List selectVoteOptionList(VoteOption voteOption); + + /** + * 新增投票选项 + * + * @param voteOption 投票选项 + * @return 结果 + */ + public int insertVoteOption(VoteOption voteOption); + + /** + * 修改投票选项 + * + * @param voteOption 投票选项 + * @return 结果 + */ + public int updateVoteOption(VoteOption voteOption); + + /** + * 批量删除投票选项 + * + * @param ids 需要删除的投票选项主键集合 + * @return 结果 + */ + public int deleteVoteOptionByIds(Long[] ids); + + /** + * 删除投票选项信息 + * + * @param id 投票选项主键 + * @return 结果 + */ + public int deleteVoteOptionById(Long id); + + List getList(List voteIds,UserVo userVo); + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/voteoption/service/impl/VoteOptionServiceImpl.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/voteoption/service/impl/VoteOptionServiceImpl.java new file mode 100644 index 0000000..8376301 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/voteoption/service/impl/VoteOptionServiceImpl.java @@ -0,0 +1,109 @@ +package com.ruoyi.frequency.voteoption.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.ruoyi.code.PublicCommon; +import com.ruoyi.common.utils.DateUtils; +import com.ruoyi.frequency.voteoption.entity.VoteOption; +import com.ruoyi.frequency.voteoption.mapper.VoteOptionMapper; +import com.ruoyi.frequency.voteoption.service.VoteOptionService; +import com.ruoyi.vo.UserVo; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.List; + +/** + * 投票选项Service业务层处理 + * + * @author liwenlong + * @date 2023-10-12 + */ +@Service +@Transactional(rollbackFor = Exception.class) +public class VoteOptionServiceImpl extends ServiceImpl implements VoteOptionService +{ + @Autowired + private VoteOptionMapper voteOptionMapper; + + /** + * 查询投票选项 + * + * @param id 投票选项主键 + * @return 投票选项 + */ + @Override + public VoteOption selectVoteOptionById(Long id) + { + return voteOptionMapper.selectVoteOptionById(id); + } + + /** + * 查询投票选项列表 + * + * @param voteOption 投票选项 + * @return 投票选项 + */ + @Override + public List selectVoteOptionList(VoteOption voteOption) + { + return voteOptionMapper.selectVoteOptionList(voteOption); + } + + /** + * 新增投票选项 + * + * @param voteOption 投票选项 + * @return 结果 + */ + @Override + public int insertVoteOption(VoteOption voteOption) + { + return voteOptionMapper.insertVoteOption(voteOption); + } + + /** + * 修改投票选项 + * + * @param voteOption 投票选项 + * @return 结果 + */ + @Override + public int updateVoteOption(VoteOption voteOption) + { + voteOption.setUpdateTime(DateUtils.getNowDate()); + return voteOptionMapper.updateVoteOption(voteOption); + } + + /** + * 批量删除投票选项 + * + * @param ids 需要删除的投票选项主键 + * @return 结果 + */ + @Override + public int deleteVoteOptionByIds(Long[] ids) + { + this.lambdaUpdate().set(VoteOption::getDelFlag,PublicCommon.删除).in(VoteOption::getId,ids).update(); + return ids.length; + } + + /** + * 删除投票选项信息 + * + * @param id 投票选项主键 + * @return 结果 + */ + @Override + public int deleteVoteOptionById(Long id) + { + this.lambdaUpdate().set(VoteOption::getDelFlag,PublicCommon.删除).eq(VoteOption::getId,id).update(); + return 1; + } + + @Override + public List getList(List voteIds, UserVo userVo) { + return voteOptionMapper.getList(voteIds,userVo); + } + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/voterecord/controller/VoteRecordController.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/voterecord/controller/VoteRecordController.java new file mode 100644 index 0000000..5cb050f --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/voterecord/controller/VoteRecordController.java @@ -0,0 +1,97 @@ +package com.ruoyi.frequency.voterecord.controller; + +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.page.TableDataInfo; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.common.utils.poi.ExcelUtil; +import com.ruoyi.frequency.voterecord.entity.VoteRecord; +import com.ruoyi.frequency.voterecord.service.VoteRecordService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +/** + * 投票记录Controller + * + * @author liwenlong + * @date 2023-10-12 + */ +@RestController +@RequestMapping("/frequency/voterecord") +public class VoteRecordController extends BaseController +{ + @Autowired + private VoteRecordService voteRecordService; + + /** + * 查询投票记录列表 + */ + @PreAuthorize("@ss.hasPermi('frequency:voterecord:list')") + @PostMapping("/list") + public TableDataInfo list(@RequestBody VoteRecord voteRecord) + { + startPage(); + List list = voteRecordService.selectVoteRecordList(voteRecord); + return getDataTable(list); + } + + /** + * 导出投票记录列表 + */ + @PreAuthorize("@ss.hasPermi('frequency:voterecord:export')") + @Log(title = "投票记录", businessType = BusinessType.EXPORT) + @GetMapping("/export") + public AjaxResult export(VoteRecord voteRecord) + { + List list = voteRecordService.selectVoteRecordList(voteRecord); + ExcelUtil util = new ExcelUtil(VoteRecord.class); + return util.exportExcel(list, "投票记录数据"); + } + + /** + * 获取投票记录详细信息 + */ + @PreAuthorize("@ss.hasPermi('frequency:voterecord:query')") + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") Long id) + { + return AjaxResult.success(voteRecordService.selectVoteRecordById(id)); + } + + /** + * 新增投票记录 + */ + @PreAuthorize("@ss.hasPermi('frequency:voterecord:add')") + @Log(title = "投票记录", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody VoteRecord voteRecord) + { + return toAjax(voteRecordService.insertVoteRecord(voteRecord)); + } + + /** + * 修改投票记录 + */ + @PreAuthorize("@ss.hasPermi('frequency:voterecord:edit')") + @Log(title = "投票记录", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody VoteRecord voteRecord) + { + return toAjax(voteRecordService.updateVoteRecord(voteRecord)); + } + + /** + * 删除投票记录 + */ + @PreAuthorize("@ss.hasPermi('frequency:voterecord:remove')") + @Log(title = "投票记录", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}") + public AjaxResult remove(@PathVariable Long[] ids) + { + return toAjax(voteRecordService.deleteVoteRecordByIds(ids)); + } +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/voterecord/entity/VoteRecord.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/voterecord/entity/VoteRecord.java new file mode 100644 index 0000000..157b7fc --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/voterecord/entity/VoteRecord.java @@ -0,0 +1,74 @@ +package com.ruoyi.frequency.voterecord.entity; + +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableName; +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import com.ruoyi.vo.UserInfo; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; + +import java.util.Date; + +/** + * 投票记录对象 t_vote_record + * + * @author liwenlong + * @date 2023-10-12 + */ +@Data +@Accessors(chain = true) +@TableName("t_vote_record") +public class VoteRecord extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + + @ApiModelProperty("租户号") + private Long id; + + @ApiModelProperty("删除标志;1 正常 2 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("投票活动id") + @Excel(name = "投票活动id") + private Long voteId; + + @ApiModelProperty("投票人id;设计师和表现师的id") + @Excel(name = "投票人id;设计师和表现师的id") + private Long userId; + + @ApiModelProperty("$column.columnComment") + @Excel(name = "投票人id;设计师和表现师的id") + private Integer userType; + + @ApiModelProperty("选项ID") + private Long optionId; + + @ApiModelProperty("选项") + @Excel(name = "选项") + private String optionName; + + @ApiModelProperty(value = "用户信息") + @TableField(exist = false) + private UserInfo userInfo; + + + @ApiModelProperty("标题") + @Excel(name = "标题") + @TableField(exist = false) + private String title; + + @ApiModelProperty("内容") + @Excel(name = "内容") + @TableField(exist = false) + private String content; + + @ApiModelProperty("活动截止日期") + @Excel(name = "活动截止日期", width = 30, dateFormat = "yyyy-MM-dd") + @TableField(exist = false) + private Date cutoffDate; + + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/voterecord/mapper/VoteRecordMapper.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/voterecord/mapper/VoteRecordMapper.java new file mode 100644 index 0000000..efa8127 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/voterecord/mapper/VoteRecordMapper.java @@ -0,0 +1,67 @@ +package com.ruoyi.frequency.voterecord.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.ruoyi.frequency.voterecord.entity.VoteRecord; +import com.ruoyi.vo.UserVo; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * 投票记录Mapper接口 + * + * @author liwenlong + * @date 2023-10-12 + */ +public interface VoteRecordMapper extends BaseMapper +{ + /** + * 查询投票记录 + * + * @param id 投票记录主键 + * @return 投票记录 + */ + public VoteRecord selectVoteRecordById(Long id); + + /** + * 查询投票记录列表 + * + * @param voteRecord 投票记录 + * @return 投票记录集合 + */ + public List selectVoteRecordList(VoteRecord voteRecord); + + /** + * 新增投票记录 + * + * @param voteRecord 投票记录 + * @return 结果 + */ + public int insertVoteRecord(VoteRecord voteRecord); + + /** + * 修改投票记录 + * + * @param voteRecord 投票记录 + * @return 结果 + */ + public int updateVoteRecord(VoteRecord voteRecord); + + /** + * 删除投票记录 + * + * @param id 投票记录主键 + * @return 结果 + */ + public int deleteVoteRecordById(Long id); + + /** + * 批量删除投票记录 + * + * @param ids 需要删除的数据主键集合 + * @return 结果 + */ + public int deleteVoteRecordByIds(Long[] ids); + + void addVoteRecord(@Param("req") VoteRecord voteRecord,@Param("userVo") UserVo userVo); +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/voterecord/mapper/mapping/VoteRecordMapper.xml b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/voterecord/mapper/mapping/VoteRecordMapper.xml new file mode 100644 index 0000000..115854c --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/voterecord/mapper/mapping/VoteRecordMapper.xml @@ -0,0 +1,132 @@ + + + + + + + + + + + + + + + + + + + + + + + SELECT + t.id, + t.create_by, + t.create_time, + t.update_by, + t.update_time, + t.del_flag, + t.vote_id, + t.user_id, + t.user_type, + t.option_id, + t2.`name` optionName, + t3.title, + t3.content, + t3.cutoff_date + FROM + t_vote_record AS t + LEFT JOIN t_vote_option AS t2 ON t.option_id = t2.id + LEFT JOIN t_vote AS t3 ON t2.vote_id = t3.id + + + + + + + + insert into t_vote_record + + id, + create_by, + create_time, + update_by, + update_time, + del_flag, + vote_id, + user_id, + user_type, + option_id, + + + #{id}, + #{createBy}, + #{createTime}, + #{updateBy}, + #{updateTime}, + #{delFlag}, + #{voteId}, + #{userId}, + #{userType}, + #{optionId}, + + + + + update t_vote_record + + create_by = #{createBy}, + create_time = #{createTime}, + update_by = #{updateBy}, + update_time = #{updateTime}, + del_flag = #{delFlag}, + vote_id = #{voteId}, + user_id = #{userId}, + user_type = #{userType}, + option_id = #{optionId}, + + where id = #{id} + + + + delete from t_vote_record where id = #{id} + + + + delete from t_vote_record where id in + + #{id} + + + + + insert into t_vote_record + (id, vote_id, create_time,update_time,user_id, user_type, option_id) + values + (#{req.id}, #{req.voteId},#{req.createTime},#{req.updateTime}, #{userVo.userId}, #{userVo.userType}, #{req.optionId}) + ON DUPLICATE KEY UPDATE + del_flag = IF(option_id = #{req.optionId} , + IF( del_flag = 1 and option_id = #{req.optionId} , 3, 1 ), + 1 + ), + option_id = #{req.optionId} + + + \ No newline at end of file diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/voterecord/model/param/VoteRecordParam.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/voterecord/model/param/VoteRecordParam.java new file mode 100644 index 0000000..9fae27a --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/voterecord/model/param/VoteRecordParam.java @@ -0,0 +1,52 @@ +package com.ruoyi.frequency.voterecord.model.param; + +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; + +/** + * 投票记录对象 t_vote_record + * + * @author liwenlong + * @date 2023-10-12 + */ +@Data +@Accessors(chain = true) +public class VoteRecordParam extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + @ApiModelProperty("租户号") + private Long id; + + + @ApiModelProperty("删除标志;1 正常 2 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("投票活动id") + @Excel(name = "投票活动id") + private String voteId; + + @ApiModelProperty("投票人id;设计师和表现师的id") + @Excel(name = "投票人id;设计师和表现师的id") + private Long userId; + + @ApiModelProperty("$column.columnComment") + @Excel(name = "投票人id;设计师和表现师的id") + private Integer userType; + + @ApiModelProperty("选项ID") + @Excel(name = "选项ID") + private Long optionId; + + + + + + + + + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/voterecord/model/result/VoteRecordResult.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/voterecord/model/result/VoteRecordResult.java new file mode 100644 index 0000000..2308a3b --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/voterecord/model/result/VoteRecordResult.java @@ -0,0 +1,45 @@ +package com.ruoyi.frequency.voterecord.model.result; + +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; + +/** + * 投票记录对象 t_vote_record + * + * @author liwenlong + * @date 2023-10-12 + */ +@Data +@Accessors(chain = true) +public class VoteRecordResult extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + @ApiModelProperty("租户号") + private Long id; + + + @ApiModelProperty("删除标志;1 正常 2 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("投票活动id") + @Excel(name = "投票活动id") + private String voteId; + + @ApiModelProperty("投票人id;设计师和表现师的id") + @Excel(name = "投票人id;设计师和表现师的id") + private Long userId; + + @ApiModelProperty("$column.columnComment") + @Excel(name = "投票人id;设计师和表现师的id") + private Integer userType; + + @ApiModelProperty("选项ID") + @Excel(name = "选项ID") + private Long optionId; + + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/voterecord/service/VoteRecordService.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/voterecord/service/VoteRecordService.java new file mode 100644 index 0000000..b79ef89 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/voterecord/service/VoteRecordService.java @@ -0,0 +1,73 @@ +package com.ruoyi.frequency.voterecord.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.ruoyi.frequency.voterecord.entity.VoteRecord; +import com.ruoyi.vo.UserVo; + +import java.util.List; + +/** + * 投票记录Service接口 + * + * @author liwenlong + * @date 2023-10-12 + */ +public interface VoteRecordService extends IService +{ + /** + * 查询投票记录 + * + * @param id 投票记录主键 + * @return 投票记录 + */ + public VoteRecord selectVoteRecordById(Long id); + + /** + * 查询投票记录列表 + * + * @param voteRecord 投票记录 + * @return 投票记录集合 + */ + public List selectVoteRecordList(VoteRecord voteRecord); + + /** + * 新增投票记录 + * + * @param voteRecord 投票记录 + * @return 结果 + */ + public int insertVoteRecord(VoteRecord voteRecord); + + /** + * 修改投票记录 + * + * @param voteRecord 投票记录 + * @return 结果 + */ + public int updateVoteRecord(VoteRecord voteRecord); + + /** + * 批量删除投票记录 + * + * @param ids 需要删除的投票记录主键集合 + * @return 结果 + */ + public int deleteVoteRecordByIds(Long[] ids); + + /** + * 删除投票记录信息 + * + * @param id 投票记录主键 + * @return 结果 + */ + public int deleteVoteRecordById(Long id); + + + /** + * 生成投票记录 + * @param voteId + * @param voteOptionIds + * @param userVo + */ + void addVoteRecord(Long voteId, List voteOptionIds, UserVo userVo); +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/voterecord/service/impl/VoteRecordServiceImpl.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/voterecord/service/impl/VoteRecordServiceImpl.java new file mode 100644 index 0000000..fb08b7e --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/voterecord/service/impl/VoteRecordServiceImpl.java @@ -0,0 +1,146 @@ +package com.ruoyi.frequency.voterecord.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.ruoyi.code.PublicCommon; +import com.ruoyi.common.utils.DateUtils; +import com.ruoyi.frequency.customer.service.UserService; +import com.ruoyi.frequency.voterecord.entity.VoteRecord; +import com.ruoyi.frequency.voterecord.mapper.VoteRecordMapper; +import com.ruoyi.frequency.voterecord.service.VoteRecordService; +import com.ruoyi.utils.SnowIdUtils; +import com.ruoyi.vo.UserInfo; +import com.ruoyi.vo.UserVo; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.*; +import java.util.stream.Collectors; + +/** + * 投票记录Service业务层处理 + * + * @author liwenlong + * @date 2023-10-12 + */ +@Service +@Transactional(rollbackFor = Exception.class) +public class VoteRecordServiceImpl extends ServiceImpl implements VoteRecordService +{ + @Autowired + private VoteRecordMapper voteRecordMapper; + + /** + * 查询投票记录 + * + * @param id 投票记录主键 + * @return 投票记录 + */ + @Override + public VoteRecord selectVoteRecordById(Long id) + { + return voteRecordMapper.selectVoteRecordById(id); + } + + + @Autowired + private UserService userService; + + /** + * 查询投票记录列表 + * + * @param voteRecord 投票记录 + * @return 投票记录 + */ + @Override + public List selectVoteRecordList(VoteRecord voteRecord) + { + List voteRecords = voteRecordMapper.selectVoteRecordList(voteRecord); + + if (voteRecords.size() > 0){ + Set userVoSet = voteRecords.stream().map(s -> new UserVo(s.getUserType(), s.getUserId())).collect(Collectors.toSet()); + + //查询用户信息 + Map userMap = userService.selectUserInfoMap(userVoSet,null); + + voteRecords.stream().forEach(s ->{ + s.setUserInfo(userMap.get(new UserVo(s.getUserType(), s.getUserId()))); + }); + } + + return voteRecords; + } + + /** + * 新增投票记录 + * + * @param voteRecord 投票记录 + * @return 结果 + */ + @Override + public int insertVoteRecord(VoteRecord voteRecord) + { + return voteRecordMapper.insertVoteRecord(voteRecord); + } + + /** + * 修改投票记录 + * + * @param voteRecord 投票记录 + * @return 结果 + */ + @Override + public int updateVoteRecord(VoteRecord voteRecord) + { + voteRecord.setUpdateTime(DateUtils.getNowDate()); + return voteRecordMapper.updateVoteRecord(voteRecord); + } + + /** + * 批量删除投票记录 + * + * @param ids 需要删除的投票记录主键 + * @return 结果 + */ + @Override + public int deleteVoteRecordByIds(Long[] ids) + { + this.lambdaUpdate().set(VoteRecord::getDelFlag,PublicCommon.删除).in(VoteRecord::getId,ids).update(); + return ids.length; + } + + /** + * 删除投票记录信息 + * + * @param id 投票记录主键 + * @return 结果 + */ + @Override + public int deleteVoteRecordById(Long id) + { + this.lambdaUpdate().set(VoteRecord::getDelFlag,PublicCommon.删除).eq(VoteRecord::getId,id).update(); + return 1; + } + + @Override + public void addVoteRecord(Long voteId, List voteOptionIds, UserVo userVo) { + + if (voteOptionIds.isEmpty()){ + return; + } + + List voteRecords = new ArrayList<>(); + + voteOptionIds.stream().forEach(voteOptionId->{ + VoteRecord voteRecord = new VoteRecord(); + + voteRecord.setOptionId(voteOptionId) + .setUserId(userVo.getUserId()) + .setUserType(userVo.getUserType()) + .setVoteId(voteId); + voteRecords.add(voteRecord); + }); + + this.saveBatch(voteRecords); + } +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/worklike/controller/WorkLikeController.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/worklike/controller/WorkLikeController.java new file mode 100644 index 0000000..6ccc37b --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/worklike/controller/WorkLikeController.java @@ -0,0 +1,97 @@ +package com.ruoyi.frequency.worklike.controller; + +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.page.TableDataInfo; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.common.utils.poi.ExcelUtil; +import com.ruoyi.frequency.worklike.entity.WorkLike; +import com.ruoyi.frequency.worklike.service.WorkLikeService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +/** + * 作品点赞Controller + * + * @author liwenlong + * @date 2023-10-12 + */ +@RestController +@RequestMapping("/frequency/worklike") +public class WorkLikeController extends BaseController +{ + @Autowired + private WorkLikeService workLikeService; + + /** + * 查询作品点赞列表 + */ + @PreAuthorize("@ss.hasPermi('frequency:worklike:list')") + @GetMapping("/list") + public TableDataInfo list(WorkLike workLike) + { + startPage(); + List list = workLikeService.selectWorkLikeList(workLike); + return getDataTable(list); + } + + /** + * 导出作品点赞列表 + */ + @PreAuthorize("@ss.hasPermi('frequency:worklike:export')") + @Log(title = "作品点赞", businessType = BusinessType.EXPORT) + @GetMapping("/export") + public AjaxResult export(WorkLike workLike) + { + List list = workLikeService.selectWorkLikeList(workLike); + ExcelUtil util = new ExcelUtil(WorkLike.class); + return util.exportExcel(list, "作品点赞数据"); + } + + /** + * 获取作品点赞详细信息 + */ + @PreAuthorize("@ss.hasPermi('frequency:worklike:query')") + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") Long id) + { + return AjaxResult.success(workLikeService.selectWorkLikeById(id)); + } + + /** + * 新增作品点赞 + */ + @PreAuthorize("@ss.hasPermi('frequency:worklike:add')") + @Log(title = "作品点赞", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody WorkLike workLike) + { + return toAjax(workLikeService.insertWorkLike(workLike)); + } + + /** + * 修改作品点赞 + */ + @PreAuthorize("@ss.hasPermi('frequency:worklike:edit')") + @Log(title = "作品点赞", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody WorkLike workLike) + { + return toAjax(workLikeService.updateWorkLike(workLike)); + } + + /** + * 删除作品点赞 + */ + @PreAuthorize("@ss.hasPermi('frequency:worklike:remove')") + @Log(title = "作品点赞", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}") + public AjaxResult remove(@PathVariable Long[] ids) + { + return toAjax(workLikeService.deleteWorkLikeByIds(ids)); + } +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/worklike/entity/WorkLike.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/worklike/entity/WorkLike.java new file mode 100644 index 0000000..ea6fad7 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/worklike/entity/WorkLike.java @@ -0,0 +1,56 @@ +package com.ruoyi.frequency.worklike.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import com.ruoyi.controller.req.WorksLikeReq; +import com.ruoyi.utils.SnowIdUtils; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; + +/** + * 作品点赞对象 t_work_like + * + * @author liwenlong + * @date 2023-10-12 + */ +@Data +@Accessors(chain = true) +@TableName("t_work_like") +public class WorkLike extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + + @ApiModelProperty("主键id") + private Long id; + + @ApiModelProperty("删除标志 1正常 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("类型 1 作品 ") + @Excel(name = "类型 1 作品 ") + private Integer type; + + @ApiModelProperty("用户类型 1 用户 2 商家") + @Excel(name = "用户类型 1 用户 2 商家") + private Integer userType; + + @ApiModelProperty("用户id") + @Excel(name = "用户id") + private Long userId; + + @ApiModelProperty("作品id") + @Excel(name = "作品id") + private Long workId; + + public WorkLike() { + } + + public WorkLike(WorksLikeReq req) { + this.id = SnowIdUtils.uniqueLong(); + this.workId = req.getObjectId(); + this.type = req.getType(); + } +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/worklike/mapper/WorkLikeMapper.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/worklike/mapper/WorkLikeMapper.java new file mode 100644 index 0000000..e43fe95 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/worklike/mapper/WorkLikeMapper.java @@ -0,0 +1,72 @@ +package com.ruoyi.frequency.worklike.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.ruoyi.frequency.worklike.entity.WorkLike; +import com.ruoyi.vo.UserVo; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * 作品点赞Mapper接口 + * + * @author liwenlong + * @date 2023-10-12 + */ +public interface WorkLikeMapper extends BaseMapper +{ + /** + * 查询作品点赞 + * + * @param id 作品点赞主键 + * @return 作品点赞 + */ + public WorkLike selectWorkLikeById(Long id); + + /** + * 查询作品点赞列表 + * + * @param workLike 作品点赞 + * @return 作品点赞集合 + */ + public List selectWorkLikeList(WorkLike workLike); + + /** + * 新增作品点赞 + * + * @param workLike 作品点赞 + * @return 结果 + */ + public int insertWorkLike(WorkLike workLike); + + /** + * 修改作品点赞 + * + * @param workLike 作品点赞 + * @return 结果 + */ + public int updateWorkLike(WorkLike workLike); + + /** + * 删除作品点赞 + * + * @param id 作品点赞主键 + * @return 结果 + */ + public int deleteWorkLikeById(Long id); + + /** + * 批量删除作品点赞 + * + * @param ids 需要删除的数据主键集合 + * @return 结果 + */ + public int deleteWorkLikeByIds(Long[] ids); + + /** + * 点赞 + * @param workLike + * @param userVo + */ + void workLike(@Param("req") WorkLike workLike,@Param("userVo") UserVo userVo); +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/worklike/mapper/mapping/WorkLikeMapper.xml b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/worklike/mapper/mapping/WorkLikeMapper.xml new file mode 100644 index 0000000..5863735 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/worklike/mapper/mapping/WorkLikeMapper.xml @@ -0,0 +1,104 @@ + + + + + + + + + + + + + + + + + + + select id, create_by, create_time, update_by, update_time, del_flag, type, user_type, user_id, work_id from t_work_like + + + + + + + + insert into t_work_like + + id, + create_by, + create_time, + update_by, + update_time, + del_flag, + type, + user_type, + user_id, + work_id, + + + #{id}, + #{createBy}, + #{createTime}, + #{updateBy}, + #{updateTime}, + #{delFlag}, + #{type}, + #{userType}, + #{userId}, + #{workId}, + + + + + update t_work_like + + create_by = #{createBy}, + create_time = #{createTime}, + update_by = #{updateBy}, + update_time = #{updateTime}, + del_flag = #{delFlag}, + type = #{type}, + user_type = #{userType}, + user_id = #{userId}, + work_id = #{workId}, + + where id = #{id} + + + + delete from t_work_like where id = #{id} + + + + delete from t_work_like where id in + + #{id} + + + + + insert into t_work_like + (id, create_by, create_time, update_by, update_time, type, user_type, user_id, work_id) + values + (#{req.id},#{req.updateBy},#{req.updateTime},#{req.updateBy},#{req.updateTime},#{req.type},#{userVo.userType}, #{userVo.userId}, #{req.workId}) + ON DUPLICATE KEY UPDATE + del_flag = IF( del_flag = 1, 3, 1 ), + update_time = #{req.updateTime}, + update_by = #{req.updateBy}; + + \ No newline at end of file diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/worklike/model/param/WorkLikeParam.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/worklike/model/param/WorkLikeParam.java new file mode 100644 index 0000000..a0cfe90 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/worklike/model/param/WorkLikeParam.java @@ -0,0 +1,50 @@ +package com.ruoyi.frequency.worklike.model.param; + +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; + +/** + * 作品点赞对象 t_work_like + * + * @author liwenlong + * @date 2023-10-12 + */ +@Data +@Accessors(chain = true) +public class WorkLikeParam extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + @ApiModelProperty("主键id") + private Long id; + + @ApiModelProperty("删除标志 1正常 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("类型 1 论坛 2 论坛评论 3 论坛回答 4 回答评论") + @Excel(name = "类型 1 论坛 2 论坛评论 3 论坛回答 4 回答评论") + private Integer type; + + @ApiModelProperty("用户类型 1 用户 2 商家") + @Excel(name = "用户类型 1 用户 2 商家") + private Integer userType; + + @ApiModelProperty("用户id") + @Excel(name = "用户id") + private Long userId; + + @ApiModelProperty("论坛id/论坛评论id/论坛回答id/回答评论id") + @Excel(name = "论坛id/论坛评论id/论坛回答id/回答评论id") + private Long workId; + + + + + + + + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/worklike/model/result/WorkLikeResult.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/worklike/model/result/WorkLikeResult.java new file mode 100644 index 0000000..044f8c7 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/worklike/model/result/WorkLikeResult.java @@ -0,0 +1,44 @@ +package com.ruoyi.frequency.worklike.model.result; + +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; + +/** + * 作品点赞对象 t_work_like + * + * @author liwenlong + * @date 2023-10-12 + */ +@Data +@Accessors(chain = true) +public class WorkLikeResult extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + @ApiModelProperty("主键id") + private Long id; + + @ApiModelProperty("删除标志 1正常 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("类型 1 论坛 2 论坛评论 3 论坛回答 4 回答评论") + @Excel(name = "类型 1 论坛 2 论坛评论 3 论坛回答 4 回答评论") + private Integer type; + + @ApiModelProperty("用户类型 1 用户 2 商家") + @Excel(name = "用户类型 1 用户 2 商家") + private Integer userType; + + @ApiModelProperty("用户id") + @Excel(name = "用户id") + private Long userId; + + @ApiModelProperty("论坛id/论坛评论id/论坛回答id/回答评论id") + @Excel(name = "论坛id/论坛评论id/论坛回答id/回答评论id") + private Long workId; + + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/worklike/service/WorkLikeService.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/worklike/service/WorkLikeService.java new file mode 100644 index 0000000..4a8e213 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/worklike/service/WorkLikeService.java @@ -0,0 +1,77 @@ +package com.ruoyi.frequency.worklike.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.ruoyi.controller.req.WorksLikeReq; +import com.ruoyi.frequency.worklike.entity.WorkLike; +import com.ruoyi.response.ResponseData; +import com.ruoyi.vo.BodyIdReq; +import com.ruoyi.vo.UserVo; + +import java.util.List; + +/** + * 作品点赞Service接口 + * + * @author liwenlong + * @date 2023-10-12 + */ +public interface WorkLikeService extends IService +{ + /** + * 查询作品点赞 + * + * @param id 作品点赞主键 + * @return 作品点赞 + */ + public WorkLike selectWorkLikeById(Long id); + + /** + * 查询作品点赞列表 + * + * @param workLike 作品点赞 + * @return 作品点赞集合 + */ + public List selectWorkLikeList(WorkLike workLike); + + /** + * 新增作品点赞 + * + * @param workLike 作品点赞 + * @return 结果 + */ + public int insertWorkLike(WorkLike workLike); + + /** + * 修改作品点赞 + * + * @param workLike 作品点赞 + * @return 结果 + */ + public int updateWorkLike(WorkLike workLike); + + /** + * 批量删除作品点赞 + * + * @param ids 需要删除的作品点赞主键集合 + * @return 结果 + */ + public int deleteWorkLikeByIds(Long[] ids); + + /** + * 删除作品点赞信息 + * + * @param id 作品点赞主键 + * @return 结果 + */ + public int deleteWorkLikeById(Long id); + + + /** + * 作品点赞 + * @param req + * @param userVo + * @return + */ + ResponseData worksLike(WorksLikeReq req, UserVo userVo); + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/worklike/service/impl/WorkLikeServiceImpl.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/worklike/service/impl/WorkLikeServiceImpl.java new file mode 100644 index 0000000..ea92729 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/worklike/service/impl/WorkLikeServiceImpl.java @@ -0,0 +1,245 @@ +package com.ruoyi.frequency.worklike.service.impl; + +import cn.hutool.core.util.ObjectUtil; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.ruoyi.code.DictConstant; +import com.ruoyi.code.PublicCommon; +import com.ruoyi.common.utils.DateUtils; +import com.ruoyi.controller.req.WorksLikeReq; +import com.ruoyi.enums.message.InteractionMessageEnums; +import com.ruoyi.enums.user.UserEnums; +import com.ruoyi.frequency.order.entity.Order; +import com.ruoyi.frequency.worklike.entity.WorkLike; +import com.ruoyi.frequency.worklike.mapper.WorkLikeMapper; +import com.ruoyi.frequency.worklike.service.WorkLikeService; +import com.ruoyi.frequency.works.entity.Works; +import com.ruoyi.frequency.works.mapper.WorksMapper; +import com.ruoyi.frequency.works.service.WorksService; +import com.ruoyi.frequency.workscomment.entity.WorksComment; +import com.ruoyi.frequency.workscomment.service.WorksCommentService; +import com.ruoyi.frequency.workstep.entity.WorkStep; +import com.ruoyi.frequency.workstep.mapper.WorkStepMapper; +import com.ruoyi.message.frequency.interactionmessagerecord.service.InteractionMessageRecordService; +import com.ruoyi.response.ResponseData; +import com.ruoyi.utils.BusinessUtil; +import com.ruoyi.vo.BodyIdReq; +import com.ruoyi.vo.UserVo; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.List; + +/** + * 作品点赞Service业务层处理 + * + * @author liwenlong + * @date 2023-10-12 + */ +@Service +@Transactional(rollbackFor = Exception.class) +public class WorkLikeServiceImpl extends ServiceImpl implements WorkLikeService { + @Autowired + private WorkLikeMapper workLikeMapper; + + /** + * 查询作品点赞 + * + * @param id 作品点赞主键 + * @return 作品点赞 + */ + @Override + public WorkLike selectWorkLikeById(Long id) { + return workLikeMapper.selectWorkLikeById(id); + } + + /** + * 查询作品点赞列表 + * + * @param workLike 作品点赞 + * @return 作品点赞 + */ + @Override + public List selectWorkLikeList(WorkLike workLike) { + return workLikeMapper.selectWorkLikeList(workLike); + } + + /** + * 新增作品点赞 + * + * @param workLike 作品点赞 + * @return 结果 + */ + @Override + public int insertWorkLike(WorkLike workLike) { + workLike.setCreateTime(DateUtils.getNowDate()); + return workLikeMapper.insertWorkLike(workLike); + } + + /** + * 修改作品点赞 + * + * @param workLike 作品点赞 + * @return 结果 + */ + @Override + public int updateWorkLike(WorkLike workLike) { + workLike.setUpdateTime(DateUtils.getNowDate()); + return workLikeMapper.updateWorkLike(workLike); + } + + /** + * 批量删除作品点赞 + * + * @param ids 需要删除的作品点赞主键 + * @return 结果 + */ + @Override + public int deleteWorkLikeByIds(Long[] ids) { + this.lambdaUpdate().set(WorkLike::getDelFlag, PublicCommon.删除).in(WorkLike::getId, ids).update(); + return ids.length; + } + + /** + * 删除作品点赞信息 + * + * @param id 作品点赞主键 + * @return 结果 + */ + @Override + public int deleteWorkLikeById(Long id) { + this.lambdaUpdate().set(WorkLike::getDelFlag, PublicCommon.删除).eq(WorkLike::getId, id).update(); + return 1; + } + + @Autowired + private WorkStepMapper workStepMapper; + + + @Autowired + private WorksService worksService; + + @Autowired + private BusinessUtil businessUtil; + + @Autowired + private WorksCommentService worksCommentService; + + @Autowired + private WorksMapper worksMapper; + + + @Override + public ResponseData worksLike(WorksLikeReq req, UserVo userVo) { + + WorkLike workLike = new WorkLike(req); + + //更新帖子点赞记录 + workLikeMapper.workLike(workLike, userVo); + + workLike = workLikeMapper.selectOne(new QueryWrapper().lambda() + .eq(WorkLike::getWorkId, req.getObjectId()) + .eq(WorkLike::getType, req.getType()) + .eq(WorkLike::getUserType, userVo.getUserType()) + .eq(WorkLike::getUserId, userVo.getUserId()) + ); + //是否点赞 + Boolean isLike = workLike.getDelFlag().equals(PublicCommon.启用); + + //精彩评论 1 作品 2 作品评论 + if (isLike && req.getType() == 2) { + //点赞量基础量(超过) + Integer likeNum = Integer.valueOf(businessUtil.getDict(DictConstant.点赞好评基础量).getDictValue()); + + WorksComment worksComment = worksCommentService.getById(req.getObjectId()); + + Works work = worksService.getById(worksComment.getWorksId()); + + if (ObjectUtil.isEmpty(work.getCommentId()) && worksComment.getParentId() == 0L && worksComment.getLikeNum() >= likeNum) { + worksService.lambdaUpdate().set(Works::getCommentId, worksComment.getId()) + .eq(Works::getId, worksComment.getWorksId()).update(); + } + } else { + //只有作品有踩赞 + if (isLike) { + WorkStep workStep = workStepMapper.selectOne(new QueryWrapper().lambda() + .eq(WorkStep::getWorkId, req.getObjectId()) + .eq(WorkStep::getUserType, userVo.getUserType()) + .eq(WorkStep::getUserId, userVo.getUserId()) + ); + if (workStep != null && workStep.getDelFlag().equals(PublicCommon.启用)) { + + workStep.setDelFlag(PublicCommon.禁用); + //更新作品踩记录 + workStepMapper.workStep(workStep, userVo); + //修改踩数量 + worksMapper.updateWorks(new Works().setId(req.getObjectId()).setLikeNum(-1)); + } + } + } + + //更新数量 + switch (req.getType()) { + case 1: + Works works = new Works().setId(req.getObjectId()); + works.setUpdateTime(DateUtils.getNowDate()); + works.setLikeNum(isLike ? 1 : -1); + worksMapper.updateWorks(works); + + break; + case 2: + worksCommentService.updateWorksComment(new WorksComment().setId(req.getObjectId()).setLikeNum(isLike ? 1 : -1)); + break; + } + + //推送消息 + pushMessage(req, userVo, isLike); + return ResponseData.success(); + } + + + + @Autowired + private InteractionMessageRecordService interactionMessageRecordService; + + /** + * 推送消息 + * + * @param req + * @param userVo + * @param isPush + */ + private void pushMessage(WorksLikeReq req, UserVo userVo, Boolean isPush) { + if (!isPush) { + return; + } + + InteractionMessageEnums enums = ObjectUtil.equal(1, req.getType()) ? InteractionMessageEnums.LIKE_WORKS : InteractionMessageEnums.LIKE_WORKS_COMMENT; + + //作品id + Long worksId = null; + + //接收消息用户 + UserVo sendUserVo = null; + + switch (req.getType()) { + case 1: + //作品点赞 + worksId = req.getObjectId(); + Works works = worksService.getById(worksId); + sendUserVo = new UserVo(works.getUserType(), works.getStoreId()); + break; + case 2: + //评论点赞 + WorksComment worksComment = worksCommentService.getById(req.getObjectId()); + worksId = worksComment.getWorksId(); + sendUserVo = new UserVo(worksComment.getUserType(), worksComment.getUserId()); + break; + } + + //互动消息 + interactionMessageRecordService.addInteractionMessage(userVo, sendUserVo, PublicCommon.InteractionMessage.点赞, worksId, isPush, enums); + } + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/works/controller/WorksController.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/works/controller/WorksController.java new file mode 100644 index 0000000..5ff8da3 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/works/controller/WorksController.java @@ -0,0 +1,109 @@ +package com.ruoyi.frequency.works.controller; + +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.page.TableDataInfo; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.common.utils.poi.ExcelUtil; +import com.ruoyi.frequency.works.entity.Works; +import com.ruoyi.frequency.works.model.result.WorksCount; +import com.ruoyi.frequency.works.service.WorksService; +import com.ruoyi.post.frequency.post.entity.Post; +import com.ruoyi.post.frequency.post.model.result.PostCount; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +/** + * 作品Controller + * + * @author zj + * @date 2023-09-22 + */ +@RestController +@RequestMapping("/frequency/works") +public class WorksController extends BaseController +{ + @Autowired + private WorksService worksService; + + /** + * 查询作品列表 + */ +// @PreAuthorize("@ss.hasPermi('frequency:works:list')") + @PostMapping("/list") + public TableDataInfo list(@RequestBody Works works) + { + List list = worksService.selectWorksList(works); + return getDataTable(list); + } + + /** + * 统计 + */ + @PostMapping("/statistics") + public AjaxResult statistics(@RequestBody Works works) + { + WorksCount count = worksService.statistics(works); + return AjaxResult.success(count); + } + + /** + * 导出作品列表 + */ + @PreAuthorize("@ss.hasPermi('frequency:works:export')") + @Log(title = "作品", businessType = BusinessType.EXPORT) + @GetMapping("/export") + public AjaxResult export(Works works) + { + List list = worksService.selectWorksList(works); + ExcelUtil util = new ExcelUtil(Works.class); + return util.exportExcel(list, "作品数据"); + } + + /** + * 获取作品详细信息 + */ +// @PreAuthorize("@ss.hasPermi('frequency:works:query')") + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") Long id) + { + return AjaxResult.success(worksService.selectWorksById(id)); + } + + /** + * 新增作品 + */ +// @PreAuthorize("@ss.hasPermi('frequency:works:add')") + @Log(title = "作品", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody Works works) + { + return toAjax(worksService.insertWorks(works)); + } + + /** + * 修改作品 + */ +// @PreAuthorize("@ss.hasPermi('frequency:works:edit')") + @Log(title = "作品", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody Works works) + { + return toAjax(worksService.updateWorks(works)); + } + + /** + * 删除作品 + */ +// @PreAuthorize("@ss.hasPermi('frequency:works:remove')") + @Log(title = "作品", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}") + public AjaxResult remove(@PathVariable Long[] ids) + { + return toAjax(worksService.deleteWorksByIds(ids)); + } +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/works/entity/Works.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/works/entity/Works.java new file mode 100644 index 0000000..2b5a571 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/works/entity/Works.java @@ -0,0 +1,153 @@ +package com.ruoyi.frequency.works.entity; + +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableName; +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import com.ruoyi.controller.req.WorksReleaseReq; +import com.ruoyi.frequency.workspanorama.entity.WorksPanorama; +import com.ruoyi.vo.UserInfo; +import com.ruoyi.vo.UserVo; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; + +import java.math.BigDecimal; +import java.util.Date; +import java.util.List; + +/** + * 作品对象 t_works + * + * @author zj + * @date 2023-09-22 + */ +@Data +@Accessors(chain = true) +@TableName("t_works") +public class Works extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** 租户号 */ + private Long id; + + + /** 删除标志;1 正常 2 删除 3 禁用 */ + private Integer delFlag; + + /** 作品类型ID */ + @Excel(name = "作品类型ID") + private Long worksTypeId; + + /** 标题 */ + @Excel(name = "标题") + private String title; + + /** 封面图 */ + @Excel(name = "封面图") + private String coverImage; + + /** 作品图片 */ + @Excel(name = "作品图片") + private String images; + + /** 价格(订单来源的作品) */ + @Excel(name = "价格(订单来源的作品)") + private BigDecimal price; + + /** 表现师id */ + @Excel(name = "表现师id") + private Long storeId; + + /** 设计师id */ + @Excel(name = "设计师id") + private Long customerId; + + private Integer userType; + + /** 来源 1 手动创建 2 订单同步 */ + @Excel(name = "来源 1 手动创建 2 订单同步") + private Integer source; + + /** $column.columnComment */ + @Excel(name = "来源 1 手动创建 2 订单同步") + private Long orderId; + + /** 点赞数 */ + @Excel(name = "点赞数") + private Integer likeNum; + + /** 踩的数量 */ + @Excel(name = "踩的数量") + private Integer stepNum; + + /** 评论数 */ + @Excel(name = "评论数") + private Integer commentNum; + + /** 收藏数 */ + @Excel(name = "收藏数") + private Integer collectNum; + + /** 浏览数 */ + @Excel(name = "浏览数") + private Integer browseNum; + + @ApiModelProperty("是否是高端客户 1普通 2 高端 ") + private Integer ifHighend; + + @ApiModelProperty("精彩评论id") + private Long commentId; + + @ApiModelProperty("是否隐藏 1 否 2 是 ") + private Integer isHide; + + @ApiModelProperty("热度时间") + private Date trendsTime; + + @ApiModelProperty("订单编号") + @TableField(exist = false) + private String orderNo; + + @ApiModelProperty("开始时间") + @TableField(exist = false) + private UserInfo storeInfo; + + @ApiModelProperty(value = "3D 全景图") + @TableField(exist = false) + private List worksPanoramaList; + + @ApiModelProperty("开始时间") + @TableField(exist = false) + private Date beginTime; + + @ApiModelProperty("结束时间") + @TableField(exist = false) + private Date endTime; + + @ApiModelProperty("作品类型名称") + @TableField(exist = false) + private String worksTypeName; + + @ApiModelProperty("企业id") + @TableField(exist = false) + private Long enterpriseId; + + public Works() { + } + + public Works(WorksReleaseReq req, UserVo userVo) { + this.title = req.getTitle(); + this.coverImage=req.getCoverImage(); + this.images = req.getImages(); + this.price = req.getPrice(); + this.userType = userVo.getUserType(); + this.storeId = userVo.getUserId(); + this.customerId=req.getCustomerId(); + this.source = req.getSource(); + this.orderId = req.getOrderId(); + this.worksTypeId = req.getWorksTypeId(); + this.ifHighend = req.getIfHighend(); + } +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/works/mapper/WorksMapper.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/works/mapper/WorksMapper.java new file mode 100644 index 0000000..c2b0be4 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/works/mapper/WorksMapper.java @@ -0,0 +1,79 @@ +package com.ruoyi.frequency.works.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.ruoyi.controller.req.WorksPageReq; +import com.ruoyi.controller.resp.OrderWorksPricePage; +import com.ruoyi.controller.resp.WorksDetailResp; +import com.ruoyi.controller.resp.WorksPageResp; +import com.ruoyi.frequency.works.entity.Works; +import com.ruoyi.frequency.works.model.result.WorksCount; +import com.ruoyi.vo.UserVo; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * 作品Mapper接口 + * + * @author zj + * @date 2023-09-22 + */ +public interface WorksMapper extends BaseMapper +{ + /** + * 查询作品 + * + * @param id 作品主键 + * @return 作品 + */ + public Works selectWorksById(Long id); + + /** + * 查询作品列表 + * + * @param works 作品 + * @return 作品集合 + */ + public List selectWorksList(Works works); + + /** + * 新增作品 + * + * @param works 作品 + * @return 结果 + */ + public int insertWorks(Works works); + + /** + * 修改作品 + * + * @param works 作品 + * @return 结果 + */ + public int updateWorks(Works works); + + /** + * 删除作品 + * + * @param id 作品主键 + * @return 结果 + */ + public int deleteWorksById(Long id); + + /** + * 批量删除作品 + * + * @param ids 需要删除的数据主键集合 + * @return 结果 + */ + public int deleteWorksByIds(Long[] ids); + + Page worksPage(@Param("page") Page objectPage,@Param("req") WorksPageReq req,@Param("userVo") UserVo userVo); + + WorksDetailResp worksDetail(@Param("id") Long id, @Param("userVo") UserVo userVo); + + Page orderWorksPriceList(@Param("page") Page objectPage,@Param("orderId") Long orderId); + + WorksCount statistics(@Param("list") List workIdList); +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/works/mapper/mapping/WorksMapper.xml b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/works/mapper/mapping/WorksMapper.xml new file mode 100644 index 0000000..79348da --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/works/mapper/mapping/WorksMapper.xml @@ -0,0 +1,426 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + SELECT + t.id, + t.create_by, + t.create_time, + t.update_by, + t.update_time, + t.del_flag, + t.works_type_id, + t.title, + t.cover_image, + t.images, + t.price, + t.user_type, + t.store_id, + t.source, + t.order_id, + t.like_num, + t.step_num, + t.comment_num, + t.collect_num, + t.browse_num, + t.remark, + o.order_no, + if(t.user_type = 4, d.dict_label, CONCAT(t3.`name`, '-', t2.`name` )) worksTypeName, + t.if_highend + FROM + t_works AS t + LEFT JOIN t_works_type AS t2 ON t.works_type_id = t2.id + LEFT JOIN t_works_type AS t3 ON t2.pid = t3.id + LEFT JOIN t_order AS o ON t.order_id = o.id + LEFT JOIN t_store AS s ON t.store_id = s.id and t.user_type = 2 + LEFT JOIN t_enterprise AS e ON t.store_id = e.id and t.user_type = 4 + LEFT JOIN t_store AS s2 ON s2.bind_enterprise_id = e.id and t.user_type = 4 + LEFT JOIN sys_dict_data AS d ON d.dict_code = t.works_type_id and t.user_type = 4 + + + + + + + + + + + insert into t_works + + id, + create_by, + create_time, + update_by, + update_time, + del_flag, + works_type_id, + title, + cover_image, + images, + price, + store_id, + source, + order_id, + like_num, + step_num, + comment_num, + collect_num, + browse_num, + + + #{id}, + #{createBy}, + #{createTime}, + #{updateBy}, + #{updateTime}, + #{delFlag}, + #{worksTypeId}, + #{title}, + #{coverImage}, + #{images}, + #{price}, + #{storeId}, + #{source}, + #{orderId}, + #{likeNum}, + #{stepNum}, + #{commentNum}, + #{collectNum}, + #{browseNum}, + + + + + update t_works + + create_by = #{createBy}, + create_time = #{createTime}, + update_by = #{updateBy}, + update_time = #{updateTime}, + del_flag = #{delFlag}, + works_type_id = #{worksTypeId}, + title = #{title}, + cover_image = #{coverImage}, + images = #{images}, + price = #{price}, + store_id = #{storeId}, + source = #{source}, + order_id = #{orderId}, + like_num = like_num + #{likeNum}, + step_num = step_num + #{stepNum}, + comment_num = comment_num + #{commentNum}, + collect_num = collect_num + #{collectNum}, + browse_num = browse_num + #{browseNum}, + trends_time = #{trendsTime}, + + where id = #{id} + and like_num + #{likeNum} >= 0 + and step_num + #{stepNum} >= 0 + and comment_num + #{commentNum} >= 0 + and collect_num + #{collectNum} >= 0 + and browse_num + #{browseNum} >= 0 + + + + delete from t_works where id = #{id} + + + + delete from t_works where id in + + #{id} + + + + + + + + + + diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/works/model/param/WorksParam.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/works/model/param/WorksParam.java new file mode 100644 index 0000000..20c2bb4 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/works/model/param/WorksParam.java @@ -0,0 +1,96 @@ +package com.ruoyi.frequency.works.model.param; + +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import lombok.Data; +import lombok.experimental.Accessors; + +import java.math.BigDecimal; + +/** + * 作品对象 t_works + * + * @author zj + * @date 2023-09-22 + */ +@Data +@Accessors(chain = true) +public class WorksParam extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** 租户号 */ + private Long id; + + + /** 删除标志;1 正常 2 删除 3 禁用 */ + private Integer delFlag; + + /** 作品类型ID */ + @Excel(name = "作品类型ID") + private Long worksTypeId; + + /** 标题 */ + @Excel(name = "标题") + private String title; + + /** 封面图 */ + @Excel(name = "封面图") + private String coverImage; + /** 作品图片 */ + @Excel(name = "作品图片") + private String images; + + /** 价格(订单来源的作品) */ + @Excel(name = "价格(订单来源的作品)") + private BigDecimal price; + + /** 表现师id */ + @Excel(name = "表现师id") + private Long storeId; + + /** 来源 1 手动创建 2 订单同步 */ + @Excel(name = "来源 1 手动创建 2 订单同步") + private Integer source; + + /** $column.columnComment */ + @Excel(name = "来源 1 手动创建 2 订单同步") + private Long orderId; + + /** 点赞数 */ + @Excel(name = "点赞数") + private Long likeNum; + + /** 踩的数量 */ + @Excel(name = "踩的数量") + private Long stepNum; + + /** 评论数 */ + @Excel(name = "评论数") + private Long commentNum; + + /** 收藏数 */ + @Excel(name = "收藏数") + private Long collectNum; + + /** 浏览数 */ + @Excel(name = "浏览数") + private Long browseNum; + + + + + + + + + + + + + + + + + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/works/model/result/WorksCount.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/works/model/result/WorksCount.java new file mode 100644 index 0000000..ed135ac --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/works/model/result/WorksCount.java @@ -0,0 +1,34 @@ +package com.ruoyi.frequency.works.model.result; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + * @author a + * @date 2024/2/19 10:27 + */ +@Data +public class WorksCount { + + @ApiModelProperty("人数") + private Integer number; + + @ApiModelProperty("作品数量") + private Integer worksNum; + + @ApiModelProperty("浏览量") + private Integer browseNum; + + @ApiModelProperty("点赞量") + private Integer likeNum; + + @ApiModelProperty("踩赞量") + private Integer stepNum; + + @ApiModelProperty("收藏数") + private Integer collectNum; + + @ApiModelProperty("评论数") + private Integer commentNum; + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/works/model/result/WorksResult.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/works/model/result/WorksResult.java new file mode 100644 index 0000000..4c6771d --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/works/model/result/WorksResult.java @@ -0,0 +1,81 @@ +package com.ruoyi.frequency.works.model.result; + +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import lombok.Data; +import lombok.experimental.Accessors; + +import java.math.BigDecimal; + +/** + * 作品对象 t_works + * + * @author zj + * @date 2023-09-22 + */ +@Data +@Accessors(chain = true) +public class WorksResult extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** 租户号 */ + private Long id; + + + /** 删除标志;1 正常 2 删除 3 禁用 */ + private Integer delFlag; + + /** 作品类型ID */ + @Excel(name = "作品类型ID") + private Long worksTypeId; + + /** 标题 */ + @Excel(name = "标题") + private String title; + + /** 封面图 */ + @Excel(name = "封面图") + private String coverImage; + /** 作品图片 */ + @Excel(name = "作品图片") + private String images; + + /** 价格(订单来源的作品) */ + @Excel(name = "价格(订单来源的作品)") + private BigDecimal price; + + /** 表现师id */ + @Excel(name = "表现师id") + private Long storeId; + + /** 来源 1 手动创建 2 订单同步 */ + @Excel(name = "来源 1 手动创建 2 订单同步") + private Integer source; + + /** $column.columnComment */ + @Excel(name = "来源 1 手动创建 2 订单同步") + private Long orderId; + + /** 点赞数 */ + @Excel(name = "点赞数") + private Long likeNum; + + /** 踩的数量 */ + @Excel(name = "踩的数量") + private Long stepNum; + + /** 评论数 */ + @Excel(name = "评论数") + private Long commentNum; + + /** 收藏数 */ + @Excel(name = "收藏数") + private Long collectNum; + + /** 浏览数 */ + @Excel(name = "浏览数") + private Long browseNum; + + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/works/service/WorksService.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/works/service/WorksService.java new file mode 100644 index 0000000..1f81edd --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/works/service/WorksService.java @@ -0,0 +1,113 @@ +package com.ruoyi.frequency.works.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.ruoyi.common.core.domain.entity.SysDictData; +import com.ruoyi.controller.req.DrawingDetailsPageReq; +import com.ruoyi.controller.req.WorksPageReq; +import com.ruoyi.controller.req.WorksReleaseReq; +import com.ruoyi.controller.resp.OrderWorksPricePage; +import com.ruoyi.controller.resp.WorksDetailResp; +import com.ruoyi.frequency.works.entity.Works; +import com.ruoyi.frequency.works.model.result.WorksCount; +import com.ruoyi.response.ResponseData; +import com.ruoyi.vo.BodyIdReq; +import com.ruoyi.vo.UserVo; + +import java.util.List; +import java.util.Map; +import java.util.Set; + +/** + * 作品Service接口 + * + * @author zj + * @date 2023-09-22 + */ +public interface WorksService extends IService +{ + /** + * 查询作品 + * + * @param id 作品主键 + * @return 作品 + */ + public Works selectWorksById(Long id); + + /** + * 查询作品列表 + * + * @param works 作品 + * @return 作品集合 + */ + public List selectWorksList(Works works); + + + WorksCount statistics(Works works); + + /** + * 新增作品 + * + * @param works 作品 + * @return 结果 + */ + public int insertWorks(Works works); + + /** + * 修改作品 + * + * @param works 作品 + * @return 结果 + */ + public int updateWorks(Works works); + + /** + * 批量删除作品 + * + * @param ids 需要删除的作品主键集合 + * @return 结果 + */ + public int deleteWorksByIds(Long[] ids); + + /** + * 删除作品信息 + * + * @param id 作品主键 + * @return 结果 + */ + public int deleteWorksById(Long id); + + + /** + * 作品发布 + * @param req + * @param userVo + * @return + */ + ResponseData worksRelease(WorksReleaseReq req, UserVo userVo); + + /** + * 作品列表 + * @param req + * @param userVo + * @return + */ + ResponseData worksPage(WorksPageReq req, UserVo userVo); + + + /** + * 作品详情 + * @param id + * @param userVo + * @param isAddBrowseNum 是否增加浏览数 1不增加 2 加 + * @return + */ + ResponseData worksDetail(Long id,Integer isAddBrowseNum,UserVo userVo); + + Map selectWorksMap(Set worksIds); + + ResponseData drawingDetailsPage(DrawingDetailsPageReq req, UserVo userVo); + + ResponseData hideWork(BodyIdReq req, UserVo userVo); + + ResponseData> getHaveWorkCategory(WorksPageReq req); +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/works/service/impl/WorksServiceImpl.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/works/service/impl/WorksServiceImpl.java new file mode 100644 index 0000000..084d5ac --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/works/service/impl/WorksServiceImpl.java @@ -0,0 +1,461 @@ +package com.ruoyi.frequency.works.service.impl; + +import cn.hutool.core.collection.CollectionUtil; +import cn.hutool.core.util.ObjectUtil; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.github.pagehelper.PageHelper; +import com.ruoyi.code.PublicCommon; +import com.ruoyi.common.core.domain.entity.SysDictData; +import com.ruoyi.common.core.page.PageDomain; +import com.ruoyi.common.core.page.TableSupport; +import com.ruoyi.common.page.PageResult; +import com.ruoyi.common.utils.DateUtils; +import com.ruoyi.common.utils.SecurityUtils; +import com.ruoyi.common.utils.StringUtils; +import com.ruoyi.common.utils.sql.SqlUtil; +import com.ruoyi.controller.req.DrawingDetailsPageReq; +import com.ruoyi.controller.req.WorksPageReq; +import com.ruoyi.controller.req.WorksReleaseReq; +import com.ruoyi.controller.resp.OrderWorksPricePage; +import com.ruoyi.controller.resp.WorksDetailResp; +import com.ruoyi.controller.resp.WorksPageResp; +import com.ruoyi.enums.user.UserEnums; +import com.ruoyi.frequency.customer.service.UserService; +import com.ruoyi.frequency.enterprise.entity.Enterprise; +import com.ruoyi.frequency.enterprise.service.EnterpriseService; +import com.ruoyi.frequency.order.entity.Order; +import com.ruoyi.frequency.order.service.OrderService; +import com.ruoyi.frequency.works.entity.Works; +import com.ruoyi.frequency.works.mapper.WorksMapper; +import com.ruoyi.frequency.works.model.result.WorksCount; +import com.ruoyi.frequency.works.service.WorksService; +import com.ruoyi.frequency.workspanorama.entity.WorksPanorama; +import com.ruoyi.frequency.workspanorama.service.WorksPanoramaService; +import com.ruoyi.frequency.worksshield.service.WorksShieldService; +import com.ruoyi.frequency.workstype.service.WorksTypeService; +import com.ruoyi.post.frequency.post.mapper.PostMapper; +import com.ruoyi.response.ResponseData; +import com.ruoyi.system.service.ISysDictDataService; +import com.ruoyi.utils.SnowIdUtils; +import com.ruoyi.vo.BodyIdReq; +import com.ruoyi.vo.UserInfo; +import com.ruoyi.vo.UserVo; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.*; +import java.util.function.Function; +import java.util.stream.Collectors; + +/** + * 作品Service业务层处理 + * + * @author zj + * @date 2023-09-22 + */ +@Service +public class WorksServiceImpl extends ServiceImpl implements WorksService { + @Autowired + private WorksMapper worksMapper; + + /** + * 查询作品 + * + * @param id 作品主键 + * @return 作品 + */ + @Override + public Works selectWorksById(Long id) { + + Works works = worksMapper.selectWorksById(id); + + if (works != null) { + Set userVoSet = new HashSet<>(); + userVoSet.add(new UserVo(works.getUserType(), works.getStoreId())); + + //查询用户信息 + Map userMap = userService.selectUserInfoMap(userVoSet, null); + + //查询3D图 + List worksPanoramaList = worksPanoramaService.list(new QueryWrapper().lambda().eq(WorksPanorama::getWorksId, id).orderByDesc(WorksPanorama::getCreateTime)); + + works.setStoreInfo(userMap.get(new UserVo(works.getUserType(), works.getStoreId()))); + works.setWorksPanoramaList(worksPanoramaList); + } + + return works; + } + + @Autowired + private EnterpriseService enterpriseService; + + /** + * 查询作品列表 + * + * @param works 作品 + * @return 作品 + */ + @Override + public List selectWorksList(Works works) { + + + List worksList = worksList(works); + + if (!worksList.isEmpty()) { + + Set userVoSet = worksList.stream().map(s -> new UserVo(s.getUserType(), s.getStoreId())).collect(Collectors.toSet()); + //查询用户信息 + Map userMap = userService.selectUserInfoMap(userVoSet, null); + + //作品ids + List worksIds = worksList.stream().map(Works::getId).collect(Collectors.toList()); + //查询3D图 + List worksPanoramaList = worksPanoramaService.list(new QueryWrapper().lambda().in(WorksPanorama::getWorksId, worksIds).orderByDesc(WorksPanorama::getCreateTime)); + + Map> map = worksPanoramaList.stream().collect(Collectors.groupingBy(WorksPanorama::getWorksId)); + + worksList.stream().forEach(s -> { + s.setStoreInfo(userMap.get(new UserVo(s.getUserType(), s.getStoreId()))); + s.setWorksPanoramaList(map.get(s.getId())); + }); + } + + return worksList; + } + + private List worksList(Works works) { + if (SecurityUtils.hasRoleKey("enterprise")) { + Enterprise enterprise = enterpriseService.getOne(new QueryWrapper().lambda() + .ne(Enterprise::getDelFlag, PublicCommon.删除) + .eq(Enterprise::getSysUserId, SecurityUtils.getUserId())); + if (enterprise == null) { + return null; + } + works.setEnterpriseId(enterprise.getId()); + } + startPage(); + List worksList = worksMapper.selectWorksList(works); + return worksList; + } + + protected void startPage() + { + PageDomain pageDomain = TableSupport.buildPageRequest(); + Integer pageNum = pageDomain.getPageNum(); + Integer pageSize = pageDomain.getPageSize(); + if (StringUtils.isNotNull(pageNum) && StringUtils.isNotNull(pageSize)) + { + String orderBy = SqlUtil.escapeOrderBySql(pageDomain.getOrderBy()); + Boolean reasonable = pageDomain.getReasonable(); + PageHelper.startPage(pageNum, pageSize, orderBy).setReasonable(reasonable); + } + } + + @Override + public WorksCount statistics(Works works) { + List worksList = worksList(works); + List workIdList = worksList.stream().map(x -> x.getId()).collect(Collectors.toList()); + workIdList.add(-1L); + return worksMapper.statistics(workIdList); + } + + /** + * 新增作品 + * + * @param works 作品 + * @return 结果 + */ + @Override + public int insertWorks(Works works) { + if (SecurityUtils.hasRoleKey("enterprise")) { + Enterprise enterprise = enterpriseService.getOne(new QueryWrapper().lambda() + .ne(Enterprise::getDelFlag, PublicCommon.删除) + .eq(Enterprise::getSysUserId, SecurityUtils.getUserId())); + works.setStoreId(enterprise.getId()); + + works.setUserType(UserEnums.enterprise.getCode()); + } else { + return 1; + } + + int insert = worksMapper.insert(works); + //关联3D图 + if (insert > 0 && works.getWorksPanoramaList() != null && !works.getWorksPanoramaList().isEmpty()) { + + List saveList = works.getWorksPanoramaList().stream().filter(s -> ObjectUtil.isAllNotEmpty(s.getPanorama(), s.getPanoramaImage())).collect(Collectors.toList()); + + if (saveList.size() > 0) { + saveList.stream().forEach(w -> w.setWorksId(works.getId())); + worksPanoramaService.saveBatch(saveList); + } + } + + return insert; + } + + /** + * 修改作品 + * + * @param works 作品 + * @return 结果 + */ + @Override + public int updateWorks(Works works) { + works.setUpdateTime(DateUtils.getNowDate()); + int i = worksMapper.updateWorks(works); + + //删除关联 3D图 + worksPanoramaService.remove(new QueryWrapper().lambda().eq(WorksPanorama::getWorksId, works.getId())); + //关联3D图 + if (i > 0 && works.getWorksPanoramaList() != null && !works.getWorksPanoramaList().isEmpty()) { + + List saveList = works.getWorksPanoramaList().stream().filter(s -> ObjectUtil.isAllNotEmpty(s.getPanorama(), s.getPanoramaImage())).collect(Collectors.toList()); + + if (saveList.size() > 0) { + saveList.stream().forEach(w -> w.setWorksId(works.getId())); + worksPanoramaService.saveBatch(saveList); + } + } + return i; + } + + + /** + * 批量删除作品 + * + * @param ids 需要删除的作品主键 + * @return 结果 + */ + @Override + public int deleteWorksByIds(Long[] ids) { + this.lambdaUpdate().set(Works::getDelFlag, PublicCommon.删除).in(Works::getId, ids).update(); + return ids.length; + } + + /** + * 删除作品信息 + * + * @param id 作品主键 + * @return 结果 + */ + @Override + public int deleteWorksById(Long id) { + return worksMapper.deleteWorksById(id); + } + + + @Autowired + private WorksPanoramaService worksPanoramaService; + + @Override + public ResponseData worksRelease(WorksReleaseReq req, UserVo userVo) { + + Works works = new Works(req, userVo); + + this.save(works); + + //关联3D图 + if (req.getWorksPanoramaList() != null && !req.getWorksPanoramaList().isEmpty()) { + + List saveList = req.getWorksPanoramaList().stream().filter(s -> ObjectUtil.isAllNotEmpty(s.getPanorama(), s.getPanoramaImage())).collect(Collectors.toList()); + + if (saveList.size() > 0) { + saveList.stream().forEach(w -> w.setWorksId(works.getId())); + worksPanoramaService.saveBatch(saveList); + } + } + + return ResponseData.success(works.getId()); + } + + + + @Autowired + private UserService userService; + + @Autowired + private WorksTypeService worksTypeService; + + @Autowired + private WorksShieldService worksShieldService; + + @Override + public ResponseData worksPage(WorksPageReq req, UserVo userVo) { + + if (ObjectUtil.isNotEmpty(req.getTypeId()) && ObjectUtil.notEqual(UserEnums.enterprise.getCode(), req.getUserType())) { + + //根据类型id获取所有作品关联id + List typeIdList = new ArrayList<>(); + + if (req.getTypeIds() != null && req.getTypeIds().size() > 0) { + typeIdList = req.getTypeIds(); + } else { + //根据类型id获取三级id + typeIdList = worksTypeService.getIdsByTypeId(req.getTypeId()); + } + + if (typeIdList.isEmpty()) { + return ResponseData.success(new PageResult<>(new Page<>(req.getPageNo(), req.getPageSize()))); + } + req.setTypeIds(typeIdList); + } + + //是否是查看自己的 1 是 2 否 + if (req.getIsSelf() == 2) { + + //筛去拉黑与被拉黑用户 + List blockUserList = userService.blockUserList(userVo); + req.setBlockUserList(blockUserList); + + //筛去屏蔽用户 + List shieldUserList = userService.shieldUserList(userVo); + req.setShieldUserList(shieldUserList); + + //筛去屏蔽的作品 + List shieldWorksIdList = worksShieldService.shieldWorksList(userVo); + req.setShieldWorksIdList(shieldWorksIdList); + + } + + Page page = this.baseMapper.worksPage(new Page<>(req.getPageNo(), req.getPageSize()), req, userVo); + + if (!page.getRecords().isEmpty()) { + + Set userVoSet = page.getRecords().stream().map(worksPageResp -> new UserVo(worksPageResp.getUserType(), worksPageResp.getStoreId())).collect(Collectors.toSet()); + //查询用户信息 + Map userMap = userService.selectUserInfoMap(userVoSet, userVo); + + //作品ids + List worksIds = page.getRecords().stream().map(WorksPageResp::getId).collect(Collectors.toList()); + //查询3D图 + List worksPanoramaList = worksPanoramaService.list(new QueryWrapper().lambda().in(WorksPanorama::getWorksId, worksIds).orderByDesc(WorksPanorama::getCreateTime)); + + Map> map = worksPanoramaList.stream().collect(Collectors.groupingBy(WorksPanorama::getWorksId)); + + page.getRecords().stream().forEach(worksPageResp -> { + worksPageResp.setUserInfo(userMap.get(new UserVo(worksPageResp.getUserType(), worksPageResp.getStoreId()))); + worksPageResp.setWorksPanoramaList(map.get(worksPageResp.getId())); + }); + } + + + return ResponseData.success(new PageResult<>(page)); + } + + @Override + public ResponseData worksDetail(Long id, Integer isAddBrowseNum, UserVo userVo) { + + WorksDetailResp worksDetailResp = this.baseMapper.worksDetail(id, userVo); + + if (worksDetailResp != null) { + + Set userVoSet = new HashSet<>(); + userVoSet.add(new UserVo(worksDetailResp.getUserType(), worksDetailResp.getStoreId())); + + //查询用户信息 + Map userMap = userService.selectUserInfoMap(userVoSet, userVo); + + //查询3D图 + List worksPanoramaList = worksPanoramaService.list(new QueryWrapper().lambda().eq(WorksPanorama::getWorksId, id).orderByDesc(WorksPanorama::getCreateTime)); + + worksDetailResp.setUserInfo(userMap.get(new UserVo(worksDetailResp.getUserType(), worksDetailResp.getStoreId()))); + worksDetailResp.setWorksPanoramaList(worksPanoramaList); + + //是否增加浏览数 1不增加 2 加 + if (ObjectUtil.equal(2, isAddBrowseNum)) { + //增加浏览数 + this.baseMapper.updateWorks(new Works().setId(id).setBrowseNum(1)); + + postMapper.updateBrowseRecord(SnowIdUtils.uniqueLong(), 1, new Date(), id, userVo); + } + + //企业查询企业信息 + if (ObjectUtil.equal(UserEnums.enterprise.getCode(), worksDetailResp.getUserType())) { + Enterprise byId = enterpriseService.getById(worksDetailResp.getStoreId()); + worksDetailResp.setEnterprise(byId); + } + + //作品是否是我的订单里产生的(设计师可隐藏该作品) + if (worksDetailResp.getOrderId() != null) { + Order order = orderService.getById(worksDetailResp.getOrderId()); + if (order.getCustomerId().equals(userVo.getUserId()) && ObjectUtil.equal(UserEnums.customer.getCode(), userVo.getUserType())) { + worksDetailResp.setIsCustomerSelf(2); + } else { + worksDetailResp.setIsCustomerSelf(1); + } + } + } + return ResponseData.success(worksDetailResp); + } + + @Autowired + private OrderService orderService; + + @Autowired + private PostMapper postMapper; + + @Override + public Map selectWorksMap(Set worksIds) { + List works = this.list(new QueryWrapper().lambda().in(Works::getId, worksIds)); + + return works.stream().collect(Collectors.toMap(Works::getId, Function.identity())); + } + + @Override + public ResponseData drawingDetailsPage(DrawingDetailsPageReq req, UserVo userVo) { + + Page page = worksMapper.orderWorksPriceList(new Page<>(req.getPageNo(), req.getPageSize()), req.getOrderId()); + + return ResponseData.success(new PageResult<>(page)); + } + + @Override + public ResponseData hideWork(BodyIdReq req, UserVo userVo) { + Works works = baseMapper.selectById(req.getId()); + if (works.getOrderId() == null) { + return ResponseData.error("您无权隐藏该作品"); + } + Order order = orderService.getById(works.getOrderId()); + if (!order.getCustomerId().equals(userVo.getUserId()) || !ObjectUtil.equal(UserEnums.customer.getCode(), userVo.getUserType())) { + return ResponseData.error("您无权隐藏该作品"); + } + works.setIsHide(2); + updateById(works); + return ResponseData.success(); + } + + @Autowired + private ISysDictDataService iSysDictDataService; + + @Override + public ResponseData> getHaveWorkCategory(WorksPageReq req) { + SysDictData sysDictData = new SysDictData(); + sysDictData.setDictType("ENTERPRISES_WORK_TYPE"); + sysDictData.setStatus("0"); + List list = iSysDictDataService.selectDictDataList(sysDictData); + + if (CollectionUtil.isEmpty(list)) { + return ResponseData.success(new ArrayList<>()); + } + + // 过滤只要有作品的分类信息 + List dictCodeList = list.stream().map(SysDictData::getDictCode).collect(Collectors.toList()); + + List worksList = worksMapper.selectList(new LambdaQueryWrapper() + .eq(Works::getDelFlag, PublicCommon.启用) + .eq(Works::getStoreId, req.getUserId()) + .eq(Works::getUserType, req.getUserType()) + .in(Works::getWorksTypeId, dictCodeList)); + if (CollectionUtil.isEmpty(worksList)) { + return ResponseData.success(new ArrayList<>()); + } + + List workTypeIdList = worksList.stream().map(Works::getWorksTypeId).collect(Collectors.toList()); + + return ResponseData.success(list.stream().filter(s -> workTypeIdList.contains(s.getDictCode())) + .collect(Collectors.toList())); + } +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/workscomment/controller/WorksCommentController.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/workscomment/controller/WorksCommentController.java new file mode 100644 index 0000000..a9d5352 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/workscomment/controller/WorksCommentController.java @@ -0,0 +1,103 @@ +package com.ruoyi.frequency.workscomment.controller; + +import java.util.List; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.frequency.workscomment.entity.WorksComment; +import com.ruoyi.frequency.workscomment.service.WorksCommentService; +import com.ruoyi.common.utils.poi.ExcelUtil; +import com.ruoyi.common.core.page.TableDataInfo; + +/** + * 作品评论Controller + * + * @author liwenlong + * @date 2024-04-11 + */ +@RestController +@RequestMapping("/frequency/workscomment") +public class WorksCommentController extends BaseController +{ + @Autowired + private WorksCommentService worksCommentService; + + /** + * 查询作品评论列表 + */ + @PreAuthorize("@ss.hasPermi('frequency:workscomment:list')") + @PostMapping("/list") + public TableDataInfo list(@RequestBody WorksComment worksComment) + { + startPage(); + List list = worksCommentService.selectWorksCommentList(worksComment); + return getDataTable(list); + } + + /** + * 导出作品评论列表 + */ + @PreAuthorize("@ss.hasPermi('frequency:workscomment:export')") + @Log(title = "作品评论", businessType = BusinessType.EXPORT) + @GetMapping("/export") + public AjaxResult export(WorksComment worksComment) + { + List list = worksCommentService.selectWorksCommentList(worksComment); + ExcelUtil util = new ExcelUtil(WorksComment.class); + return util.exportExcel(list, "作品评论数据"); + } + + /** + * 获取作品评论详细信息 + */ + @PreAuthorize("@ss.hasPermi('frequency:workscomment:query')") + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") Long id) + { + return AjaxResult.success(worksCommentService.selectWorksCommentById(id)); + } + + /** + * 新增作品评论 + */ + @PreAuthorize("@ss.hasPermi('frequency:workscomment:add')") + @Log(title = "作品评论", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody WorksComment worksComment) + { + return toAjax(worksCommentService.insertWorksComment(worksComment)); + } + + /** + * 修改作品评论 + */ + @PreAuthorize("@ss.hasPermi('frequency:workscomment:edit')") + @Log(title = "作品评论", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody WorksComment worksComment) + { + return toAjax(worksCommentService.updateWorksComment(worksComment)); + } + + /** + * 删除作品评论 + */ + @PreAuthorize("@ss.hasPermi('frequency:workscomment:remove')") + @Log(title = "作品评论", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}/{delFlag}") + public AjaxResult remove(@PathVariable("ids") Long[] ids,@PathVariable("delFlag") Integer delFlag) + { + return toAjax(worksCommentService.deleteWorksCommentByIds(ids,delFlag)); + } +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/workscomment/entity/WorksComment.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/workscomment/entity/WorksComment.java new file mode 100644 index 0000000..8b4f2e0 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/workscomment/entity/WorksComment.java @@ -0,0 +1,103 @@ +package com.ruoyi.frequency.workscomment.entity; + +import com.ruoyi.controller.req.WorksCommentReq; +import com.ruoyi.utils.SnowIdUtils; +import com.ruoyi.vo.UserVo; +import lombok.Data; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.experimental.Accessors; +import com.ruoyi.common.annotation.Excel; +import io.swagger.annotations.ApiModelProperty; +import com.baomidou.mybatisplus.annotation.TableField; +import com.ruoyi.vo.UserInfo; +import com.ruoyi.common.core.domain.BaseEntity; + +/** + * 作品评论对象 t_works_comment + * + * @author liwenlong + * @date 2024-04-11 + */ +@Data +@Accessors(chain = true) +@TableName("t_works_comment") +public class WorksComment extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + + @ApiModelProperty("租户号") + private Long id; + + @ApiModelProperty("删除状态 1 正常 2 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("用户类型") + @Excel(name = "用户类型") + private Integer userType; + + @ApiModelProperty("评论用户id") + @Excel(name = "评论用户id") + private Long userId; + + @ApiModelProperty("作品id") + @Excel(name = "作品id") + private Long worksId; + + @ApiModelProperty("顶级评论id(对主体的直接评论)") + @Excel(name = "顶级评论id(对主体的直接评论)") + private Long topId; + + @ApiModelProperty("上级评论id 默认-1") + @Excel(name = "上级评论id 默认-1") + private Long parentId; + + @ApiModelProperty("用户类型") + @Excel(name = "用户类型") + private Integer parentUserType; + + @ApiModelProperty("上级评论用户id") + @Excel(name = "上级评论用户id") + private Long parentUserId; + + @ApiModelProperty("评论内容") + @Excel(name = "评论内容") + private String content; + + @ApiModelProperty("点赞数") + @Excel(name = "点赞数") + private Integer likeNum; + + @ApiModelProperty("评论数") + @Excel(name = "评论数") + private Integer commentNum; + + @ApiModelProperty("图片") + @Excel(name = "图片") + private String image; + + @ApiModelProperty("上级评论id集合,逗号拼接") + @Excel(name = "上级评论id集合,逗号拼接") + private String parentIds; + + @ApiModelProperty("用户信息") + @TableField(exist = false) + private UserInfo userInfo; + + @ApiModelProperty(value = "上级用户用户昵称") + @TableField(exist = false) + private UserInfo parentUserInfo; + + + public WorksComment() { + } + public WorksComment(WorksCommentReq req, UserVo userVo) { + this.id = SnowIdUtils.uniqueLong(); + this.userType = userVo.getUserType(); + this.userId = userVo.getUserId(); + this.worksId = req.getWorksId(); + this.content = req.getContent(); + this.image = req.getImage(); + this.parentId = req.getParentId(); + } +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/workscomment/mapper/WorksCommentMapper.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/workscomment/mapper/WorksCommentMapper.java new file mode 100644 index 0000000..4b43bd2 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/workscomment/mapper/WorksCommentMapper.java @@ -0,0 +1,68 @@ +package com.ruoyi.frequency.workscomment.mapper; + +import java.util.List; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.ruoyi.controller.req.DialoguePageReq; +import com.ruoyi.controller.req.WorksCommentPageReq; +import com.ruoyi.controller.resp.CommentNum; +import com.ruoyi.controller.resp.WorksCommentPageResp; +import com.ruoyi.controller.resp.WorksCommentResp; +import com.ruoyi.frequency.workscomment.entity.WorksComment; +import com.ruoyi.post.controller.req.PostCommentPageReq; +import com.ruoyi.post.controller.resp.PostCommentPageResp; +import com.ruoyi.vo.UserVo; +import org.apache.ibatis.annotations.Param; + +/** + * 作品评论Mapper接口 + * + * @author liwenlong + * @date 2024-04-11 + */ +public interface WorksCommentMapper extends BaseMapper +{ + /** + * 查询作品评论 + * + * @param id 作品评论主键 + * @return 作品评论 + */ + public WorksComment selectWorksCommentById(Long id); + + /** + * 查询作品评论列表 + * + * @param worksComment 作品评论 + * @return 作品评论集合 + */ + public List selectWorksCommentList(WorksComment worksComment); + + /** + * 新增作品评论 + * + * @param worksComment 作品评论 + * @return 结果 + */ + public int insertWorksComment(WorksComment worksComment); + + /** + * 修改作品评论 + * + * @param worksComment 作品评论 + * @return 结果 + */ + public int updateWorksComment(WorksComment worksComment); + + WorksCommentResp getWorksCommentResp(@Param("id") Long id); + + Page worksCommentPage(@Param("page") Page objectPage, @Param("req") WorksCommentPageReq req,@Param("userVo") UserVo userVo); + + List worksCommentList(@Param("req") WorksCommentPageReq req, @Param("userVo") UserVo userVo, @Param("list") List parentIds); + + List selectCommentNumList(@Param("commentIds") List commentIds, @Param("userVoList") List userVoList); + + Page worksCommentDialoguePage(@Param("page") Page objectPage, @Param("req")DialoguePageReq req,@Param("userVo") UserVo userVo); + + void updateWorksCommentBatch(@Param("list")List worksComments); +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/workscomment/mapper/mapping/WorksCommentMapper.xml b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/workscomment/mapper/mapping/WorksCommentMapper.xml new file mode 100644 index 0000000..ab38d63 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/workscomment/mapper/mapping/WorksCommentMapper.xml @@ -0,0 +1,550 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + select + t.id , + t.del_flag , + t.create_by , + t.create_time , + t.update_by , + t.update_time , + t.user_type , + t.user_id , + t.works_id , + t.top_id , + t.parent_id , + t.parent_user_type , + t.parent_user_id , + t.content , + t.like_num , + t.comment_num , + t.image , + t.remark + from t_works_comment AS t + + + + + + + + insert into t_works_comment + + id, + del_flag, + create_by, + create_time, + update_by, + update_time, + user_type, + user_id, + works_id, + top_id, + parent_id, + parent_user_type, + parent_user_id, + content, + like_num, + comment_num, + image, + remark, + + + #{id}, + #{delFlag}, + #{createBy}, + #{createTime}, + #{updateBy}, + #{updateTime}, + #{userType}, + #{userId}, + #{worksId}, + #{topId}, + #{parentId}, + #{parentUserType}, + #{parentUserId}, + #{content}, + #{likeNum}, + #{commentNum}, + #{image}, + #{remark}, + + + + + update t_works_comment + + del_flag = #{delFlag}, + create_by = #{createBy}, + create_time = #{createTime}, + update_by = #{updateBy}, + update_time = #{updateTime}, + user_type = #{userType}, + user_id = #{userId}, + works_id = #{worksId}, + top_id = #{topId}, + parent_id = #{parentId}, + parent_user_type = #{parentUserType}, + parent_user_id = #{parentUserId}, + content = #{content}, + like_num = like_num + #{likeNum}, + comment_num = comment_num + #{commentNum}, + image = #{image}, + remark = #{remark}, + + where id = #{id} + and like_num + #{likeNum}>=0 + and comment_num + #{commentNum} >= 0 + + + + + + + + + + + + + + + update t_works_comment + + like_num = like_num + #{item.likeNum}, + comment_num = comment_num + #{item.commentNum}, + + where id = #{item.id} + and like_num + #{item.likeNum}>=0 + and comment_num + #{item.commentNum} >= 0 + + + \ No newline at end of file diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/workscomment/model/param/WorksCommentParam.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/workscomment/model/param/WorksCommentParam.java new file mode 100644 index 0000000..7433ab0 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/workscomment/model/param/WorksCommentParam.java @@ -0,0 +1,88 @@ +package com.ruoyi.frequency.workscomment.model.param; + +import lombok.Data; +import lombok.experimental.Accessors; +import com.ruoyi.common.annotation.Excel; +import io.swagger.annotations.ApiModelProperty; +import com.ruoyi.common.core.domain.BaseEntity; + +/** + * 作品评论对象 t_works_comment + * + * @author liwenlong + * @date 2024-04-11 + */ +@Data +@Accessors(chain = true) +public class WorksCommentParam extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + @ApiModelProperty("租户号") + private Long id; + + @ApiModelProperty("删除状态 1 正常 2 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("用户类型") + @Excel(name = "用户类型") + private Integer userType; + + @ApiModelProperty("评论用户id") + @Excel(name = "评论用户id") + private Long userId; + + @ApiModelProperty("作品id") + @Excel(name = "作品id") + private Long worksId; + + @ApiModelProperty("顶级评论id(对主体的直接评论)") + @Excel(name = "顶级评论id(对主体的直接评论)") + private Long topId; + + @ApiModelProperty("上级评论id 默认-1") + @Excel(name = "上级评论id 默认-1") + private Long parentId; + + @ApiModelProperty("用户类型") + @Excel(name = "用户类型") + private Integer parentUserType; + + @ApiModelProperty("上级评论用户id") + @Excel(name = "上级评论用户id") + private Long parentUserId; + + @ApiModelProperty("评论内容") + @Excel(name = "评论内容") + private String content; + + @ApiModelProperty("点赞数") + @Excel(name = "点赞数") + private Integer likeNum; + + @ApiModelProperty("评论数") + @Excel(name = "评论数") + private Integer commentNum; + + @ApiModelProperty("图片") + @Excel(name = "图片") + private String image; + + @ApiModelProperty("上级评论id集合,逗号拼接") + @Excel(name = "上级评论id集合,逗号拼接") + private String parentIds; + + + + + + + + + + + + + + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/workscomment/model/result/WorksCommentResult.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/workscomment/model/result/WorksCommentResult.java new file mode 100644 index 0000000..d71dd3f --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/workscomment/model/result/WorksCommentResult.java @@ -0,0 +1,75 @@ +package com.ruoyi.frequency.workscomment.model.result; + +import lombok.Data; +import lombok.experimental.Accessors; +import com.ruoyi.common.annotation.Excel; +import io.swagger.annotations.ApiModelProperty; +import com.ruoyi.common.core.domain.BaseEntity; + +/** + * 作品评论对象 t_works_comment + * + * @author liwenlong + * @date 2024-04-11 + */ +@Data +@Accessors(chain = true) +public class WorksCommentResult extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + @ApiModelProperty("租户号") + private Long id; + + @ApiModelProperty("删除状态 1 正常 2 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("用户类型") + @Excel(name = "用户类型") + private Integer userType; + + @ApiModelProperty("评论用户id") + @Excel(name = "评论用户id") + private Long userId; + + @ApiModelProperty("作品id") + @Excel(name = "作品id") + private Long worksId; + + @ApiModelProperty("顶级评论id(对主体的直接评论)") + @Excel(name = "顶级评论id(对主体的直接评论)") + private Long topId; + + @ApiModelProperty("上级评论id 默认-1") + @Excel(name = "上级评论id 默认-1") + private Long parentId; + + @ApiModelProperty("用户类型") + @Excel(name = "用户类型") + private Integer parentUserType; + + @ApiModelProperty("上级评论用户id") + @Excel(name = "上级评论用户id") + private Long parentUserId; + + @ApiModelProperty("评论内容") + @Excel(name = "评论内容") + private String content; + + @ApiModelProperty("点赞数") + @Excel(name = "点赞数") + private Integer likeNum; + + @ApiModelProperty("评论数") + @Excel(name = "评论数") + private Integer commentNum; + + @ApiModelProperty("图片") + @Excel(name = "图片") + private String image; + + @ApiModelProperty("上级评论id集合,逗号拼接") + @Excel(name = "上级评论id集合,逗号拼接") + private String parentIds; + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/workscomment/service/WorksCommentService.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/workscomment/service/WorksCommentService.java new file mode 100644 index 0000000..43a04cd --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/workscomment/service/WorksCommentService.java @@ -0,0 +1,81 @@ +package com.ruoyi.frequency.workscomment.service; + +import java.util.List; + +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.ruoyi.common.page.PageResult; +import com.ruoyi.controller.req.DialoguePageReq; +import com.ruoyi.controller.req.WorksCommentPageReq; +import com.ruoyi.controller.req.WorksCommentReq; +import com.ruoyi.controller.resp.WorksCommentPageResp; +import com.ruoyi.controller.resp.WorksCommentResp; +import com.ruoyi.frequency.workscomment.entity.WorksComment; +import com.baomidou.mybatisplus.extension.service.IService; +import com.ruoyi.post.controller.req.DeleteCommentReq; +import com.ruoyi.response.ResponseData; +import com.ruoyi.vo.UserVo; + +/** + * 作品评论Service接口 + * + * @author liwenlong + * @date 2024-04-11 + */ +public interface WorksCommentService extends IService +{ + /** + * 查询作品评论 + * + * @param id 作品评论主键 + * @return 作品评论 + */ + public WorksComment selectWorksCommentById(Long id); + + /** + * 查询作品评论列表 + * + * @param worksComment 作品评论 + * @return 作品评论集合 + */ + public List selectWorksCommentList(WorksComment worksComment); + + /** + * 新增作品评论 + * + * @param worksComment 作品评论 + * @return 结果 + */ + public int insertWorksComment(WorksComment worksComment); + + /** + * 修改作品评论 + * + * @param worksComment 作品评论 + * @return 结果 + */ + public int updateWorksComment(WorksComment worksComment); + + /** + * 批量删除作品评论 + * + * @param ids 需要删除的作品评论主键集合 + * @return 结果 + */ + public int deleteWorksCommentByIds(Long[] ids,Integer delFlag); + + ResponseData worksComment(WorksCommentReq req, UserVo userVo); + + ResponseData> worksCommentPage(WorksCommentPageReq req, UserVo userVo); + + ResponseData deleteComment(DeleteCommentReq req, UserVo userVo); + + ResponseData worksCommentDetail(Long id, UserVo userVo); + + /** + * 作品对话评论列表 + * @param req + * @param userVo + * @return + */ + ResponseData>> worksCommentDialoguePage(DialoguePageReq req, UserVo userVo); +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/workscomment/service/impl/WorksCommentServiceImpl.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/workscomment/service/impl/WorksCommentServiceImpl.java new file mode 100644 index 0000000..ff7b279 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/workscomment/service/impl/WorksCommentServiceImpl.java @@ -0,0 +1,464 @@ +package com.ruoyi.frequency.workscomment.service.impl; + +import cn.hutool.core.collection.CollectionUtil; +import cn.hutool.core.util.ObjectUtil; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.ruoyi.code.PublicCommon; +import com.ruoyi.common.page.PageResult; +import com.ruoyi.common.utils.DateUtils; +import com.ruoyi.controller.req.DialoguePageReq; +import com.ruoyi.controller.req.WorksCommentPageReq; +import com.ruoyi.controller.req.WorksCommentReq; +import com.ruoyi.controller.resp.CommentNum; +import com.ruoyi.controller.resp.WorksCommentPageResp; +import com.ruoyi.controller.resp.WorksCommentResp; +import com.ruoyi.enums.message.InteractionMessageEnums; +import com.ruoyi.frequency.customer.service.UserService; +import com.ruoyi.frequency.works.entity.Works; +import com.ruoyi.frequency.works.mapper.WorksMapper; +import com.ruoyi.frequency.works.service.WorksService; +import com.ruoyi.frequency.workscomment.entity.WorksComment; +import com.ruoyi.frequency.workscomment.mapper.WorksCommentMapper; +import com.ruoyi.frequency.workscomment.service.WorksCommentService; +import com.ruoyi.message.frequency.interactionmessagerecord.service.InteractionMessageRecordService; +import com.ruoyi.post.controller.req.DeleteCommentReq; +import com.ruoyi.response.ResponseData; +import com.ruoyi.vo.UserInfo; +import com.ruoyi.vo.UserVo; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.*; +import java.util.stream.Collectors; + +/** + * 作品评论Service业务层处理 + * + * @author liwenlong + * @date 2024-04-11 + */ +@Service +public class WorksCommentServiceImpl extends ServiceImpl implements WorksCommentService { + @Autowired + private WorksCommentMapper worksCommentMapper; + + /** + * 查询作品评论 + * + * @param id 作品评论主键 + * @return 作品评论 + */ + @Override + public WorksComment selectWorksCommentById(Long id) { + return worksCommentMapper.selectWorksCommentById(id); + } + + /** + * 查询作品评论列表 + * + * @param worksComment 作品评论 + * @return 作品评论 + */ + @Override + public List selectWorksCommentList(WorksComment worksComment) { + List worksComments = worksCommentMapper.selectWorksCommentList(worksComment); + if (!worksComments.isEmpty()) { + Set userVoSet = worksComments.stream().map(s -> new UserVo(s.getUserType(), s.getUserId())).collect(Collectors.toSet()); + Set parentUserVoSet = worksComments.stream().map(s -> new UserVo(s.getParentUserType(), s.getParentUserId())).collect(Collectors.toSet()); + + userVoSet.addAll(parentUserVoSet); + + //查询用户信息 + Map userMap = userService.selectUserInfoMap(userVoSet, null); + + worksComments.stream().forEach(s -> { + s.setUserInfo(userMap.get(new UserVo(s.getUserType(), s.getUserId()))); + s.setParentUserInfo(userMap.get(new UserVo(s.getParentUserType(), s.getParentUserId()))); + }); + } + return worksComments; + } + + /** + * 新增作品评论 + * + * @param worksComment 作品评论 + * @return 结果 + */ + @Override + public int insertWorksComment(WorksComment worksComment) { + worksComment.setCreateData(); + return worksCommentMapper.insert(worksComment); + } + + /** + * 修改作品评论 + * + * @param worksComment 作品评论 + * @return 结果 + */ + @Override + public int updateWorksComment(WorksComment worksComment) { + worksComment.setUpdateData(); + return worksCommentMapper.updateWorksComment(worksComment); + } + + + @Autowired + private UserService userService; + + @Override + public ResponseData worksComment(WorksCommentReq req, UserVo userVo) { + //作品评论 + WorksComment worksComment = new WorksComment(req, userVo); + + //帖子-->评论 + if (ObjectUtil.isEmpty(req.getParentId()) || ObjectUtil.equal(0L, req.getParentId())) { + //顶级评论id + worksComment.setTopId(worksComment.getId()); + } else { + //查询上级评论 + WorksComment parentWorksComment = this.getById(req.getParentId()); + + //评论用户 + worksComment.setParentUserId(parentWorksComment.getUserId()) + .setParentUserType(parentWorksComment.getUserType()); + + worksComment.setTopId(parentWorksComment.getTopId()); + + //上级id + if (ObjectUtil.isNotEmpty(parentWorksComment.getParentIds())) { + worksComment.setParentIds(parentWorksComment.getParentIds() + "," + parentWorksComment.getId()); + } else { + worksComment.setParentIds(parentWorksComment.getId() + ""); + } + } + + this.save(worksComment); + + //1 帖子 2 帖子评论 + Integer type = ObjectUtil.equal(0L, req.getParentId()) || ObjectUtil.isEmpty(req.getParentId()) ? 1 : 2; + + //修改评论数(只要针对这个作品下的评论 作品评论数都要+1) + Works works = new Works().setId(worksComment.getWorksId()).setCommentNum(1).setTrendsTime(new Date()); + works.setUpdateData(); + worksMapper.updateWorks(works); + //作品评论 所有上级评论数+1 + if (ObjectUtil.equal(2, type)) { + //上级评论ids + List pids = Arrays.stream(worksComment.getParentIds().split(",")).collect(Collectors.toList()); + + List worksComments = pids.stream().map(id -> { + WorksComment comment = new WorksComment().setId(Long.valueOf(id)).setCommentNum(1); + comment.setUpdateTime(DateUtils.getNowDate()); + return comment; + } + ).collect(Collectors.toList()); + + this.baseMapper.updateWorksCommentBatch(worksComments); + } + + //返回结果 + WorksCommentResp commentResp = baseMapper.getWorksCommentResp(worksComment.getId()); + + if (commentResp != null) { + + UserVo parentUserVo = new UserVo(worksComment.getParentUserType(), worksComment.getParentUserId()); + + Set userVoSet = CollectionUtil.newHashSet(userVo, parentUserVo); + //查询用户信息 + Map userMap = userService.selectUserInfoMap(userVoSet, userVo); + + commentResp.setUserInfo(userMap.get(userVo)); + + commentResp.setParentUserInfo(userMap.get(parentUserVo)); + } + + //推送消息 + pushMessage(req, userVo, true); + + return ResponseData.success(commentResp); + } + + @Autowired + private WorksMapper worksMapper; + + /** + * 修改评论数 + * + * @param objectId 评论主体id + * @param type 1作品 2 作品评论 + * @param num + */ + private void updateWorksCommentNum(Long objectId, Integer type, Integer num) { + + switch (type) { + case 1: + worksMapper.updateWorks(new Works().setId(objectId).setCommentNum(num)); + break; + case 2: + this.updateWorksComment(new WorksComment().setId(objectId).setCommentNum(num)); + break; + default: + throw new IllegalStateException("Unexpected value: " + type); + } + } + + @Autowired + private InteractionMessageRecordService interactionMessageRecordService; + + @Autowired + private WorksService worksService; + + /** + * 推送消息 + * + * @param req + * @param userVo + * @param isPush + */ + private void pushMessage(WorksCommentReq req, UserVo userVo, Boolean isPush) { + + InteractionMessageEnums enums = ObjectUtil.equal(0L, req.getParentId()) ? InteractionMessageEnums.COMMENT_WORKS : InteractionMessageEnums.REPLY_WORKS_COMMENT; + + //作品id + Long worksId = null; + + //接收消息用户 + UserVo sendUserVo = null; + + if (ObjectUtil.equal(0L, req.getParentId())) { + //评论作品 + worksId = req.getWorksId(); + //作品 + Works works = worksService.getById(worksId); + sendUserVo = new UserVo(works.getUserType(), works.getStoreId()); + } else { + //回复评论 + WorksComment worksComment = this.getById(req.getParentId()); + worksId = worksComment.getWorksId(); + sendUserVo = new UserVo(worksComment.getUserType(), worksComment.getUserId()); + } + //互动消息 + interactionMessageRecordService.addInteractionMessage(userVo, sendUserVo, PublicCommon.InteractionMessage.评论, worksId, isPush, enums); + + } + + @Override + public ResponseData> worksCommentPage(WorksCommentPageReq req, UserVo userVo) { + //筛去拉黑与被拉黑用户 + List blockUserList = userService.blockUserList(userVo); + req.setBlockUserList(blockUserList); + + //筛去屏蔽用户 + List shieldUserList = userService.shieldUserList(userVo); + req.setShieldUserList(shieldUserList); + + Page page = this.baseMapper.worksCommentPage(new Page<>(req.getPageNo(), req.getPageSize()), req, userVo); + + if (!page.getRecords().isEmpty()) { + Set userVoSet = page.getRecords().stream().map(postPageResp -> new UserVo(postPageResp.getUserType(), postPageResp.getUserId())).collect(Collectors.toSet()); + Set parentUserVoSet = page.getRecords().stream().map(postPageResp -> new UserVo(postPageResp.getParentUserType(), postPageResp.getParentUserId())).collect(Collectors.toSet()); + + userVoSet.addAll(parentUserVoSet); + + List postCommentList = twoCommentList(req, userVo, page); + + postCommentList.stream().forEach(resp -> { + userVoSet.add(new UserVo(resp.getUserType(), resp.getUserId())); + userVoSet.add(new UserVo(resp.getParentUserType(), resp.getParentUserId())); + }); + + + //查询用户信息 + Map userMap = userService.selectUserInfoMap(userVoSet, userVo); + + List userVoList = CollectionUtil.addAllIfNotContains(blockUserList, shieldUserList); + + Map commentNumMap = getCommentNumMap(userVoList, page.getRecords()); + + postCommentList.stream().forEach(resp -> { + resp.setUserInfo(userMap.get(new UserVo(resp.getUserType(), resp.getUserId()))); + resp.setParentUserInfo(userMap.get(new UserVo(resp.getParentUserType(), resp.getParentUserId()))); + }); + //获取二级评论 + Map> map = postCommentList.stream().collect(Collectors.groupingBy(WorksCommentPageResp::getParentId)); + ; + + + page.getRecords().stream().forEach(resp -> { + resp.setUserInfo(userMap.get(new UserVo(resp.getUserType(), resp.getUserId()))); + resp.setParentUserInfo(userMap.get(new UserVo(resp.getParentUserType(), resp.getParentUserId()))); + if (commentNumMap.get(resp.getId()) != null) { + resp.setCommentNum(resp.getCommentNum() - commentNumMap.get(resp.getId())); + } + + //二级评论 + resp.setChildrenList(map.get(resp.getId())); + }); + } + + return ResponseData.success(new PageResult<>(page)); + } + + /** + * 获取二级评论ID + * + * @param req + * @param userVo + * @param page + * @return + */ + private List twoCommentList(WorksCommentPageReq req, UserVo userVo, Page page) { + + Map> map = new HashMap<>(); + + if (ObjectUtil.isEmpty(req.getParentId())) { + //一级评论ID + List parentIds = page.getRecords().stream().map(WorksCommentPageResp::getId).collect(Collectors.toList()); + + if (CollectionUtil.isEmpty(parentIds)) { + return new ArrayList<>(); + } + //查询二级评论 + List worksCommentList = this.baseMapper.worksCommentList(req, userVo, parentIds); + + return worksCommentList; + } + return new ArrayList<>(); + } + + private Map getCommentNumMap(List userVoList, List respList) { + + if (userVoList.size() == 0) { + return new HashMap<>(); + } + List commentIds = respList.stream().map(WorksCommentPageResp::getId).collect(Collectors.toList()); + //查询用户对应评论的数量 key一级评论id value 隐藏数量 + List commentNums = worksCommentMapper.selectCommentNumList(commentIds, userVoList); + + Map commentNumMap = new HashMap<>(); + commentNums.stream().forEach(s -> { + commentNumMap.put(s.getWorksId(), s.getCommentNum()); + }); + return commentNumMap; + } + + @Override + public ResponseData deleteComment(DeleteCommentReq req, UserVo userVo) { + boolean update = this.lambdaUpdate().set(WorksComment::getDelFlag, PublicCommon.删除) + .eq(WorksComment::getUserType, userVo.getUserType()) + .eq(WorksComment::getUserId, userVo.getUserId()) + .eq(WorksComment::getId, req.getId()) + .eq(WorksComment::getDelFlag, PublicCommon.启用).update(); + + if (update) { + afterDeleteComment(req.getId()); + } + return ResponseData.success(); + } + + private void afterDeleteComment(Long objectId) { + + WorksComment worksComment = this.getById(objectId); + + //删除当前评论所有下级评论 + this.lambdaUpdate().set(WorksComment::getDelFlag, PublicCommon.删除) + .like(WorksComment::getParentId, objectId) + .eq(WorksComment::getDelFlag, PublicCommon.启用).update(); + + + //1 作品 2 作品评论 + Integer type = ObjectUtil.equal(0L, worksComment.getParentId()) ? 1 : 2; + + Integer num = -(worksComment.getCommentNum() + 1); + //帖子评论 上级数量 + if (ObjectUtil.equal(2, type)) { + //当前评论上级ids + List pids = Arrays.stream(worksComment.getParentIds() + .split(",")).collect(Collectors.toList()); + num = -1 * pids.size(); + + //上级评论数都要减去当前删除评论数 + 1(本身评论) + List worksComments = pids.stream().map(id -> { + WorksComment comment = new WorksComment().setId(Long.valueOf(id)).setCommentNum(-1 * (worksComment.getCommentNum() + 1)); + comment.setUpdateTime(DateUtils.getNowDate()); + return comment; + }).collect(Collectors.toList()); + + this.baseMapper.updateWorksCommentBatch(worksComments); + + } + //删除当前评论所有下级评论 + this.lambdaUpdate().set(WorksComment::getDelFlag, PublicCommon.删除) + .like(WorksComment::getParentIds, objectId) + .eq(WorksComment::getDelFlag, PublicCommon.启用).update(); + + + //修改评论数 + worksMapper.updateWorks(new Works().setId(worksComment.getWorksId()).setCommentNum(num)); + } + + + /** + * 批量删除作品评论 + * + * @param ids 需要删除的作品评论主键 + * @return 结果 + */ + @Override + public int deleteWorksCommentByIds(Long[] ids, Integer delFlag) { + if (PublicCommon.删除.equals(delFlag)) { + for (Long objectId : ids) { + afterDeleteComment(objectId); + } + } + + this.lambdaUpdate().set(WorksComment::getDelFlag, delFlag).in(WorksComment::getId, ids).update(); + return 1; + } + + @Override + public ResponseData worksCommentDetail(Long id, UserVo userVo) { + WorksCommentResp commentResp = baseMapper.getWorksCommentResp(id); + + if (commentResp != null) { + + UserVo parentUserVo = new UserVo(commentResp.getParentUserType(), commentResp.getParentUserId()); + UserVo user = new UserVo(commentResp.getUserType(), commentResp.getUserId()); + + Set userVoSet = CollectionUtil.newHashSet(user, parentUserVo); + //查询用户信息 + Map userMap = userService.selectUserInfoMap(userVoSet, userVo); + + commentResp.setUserInfo(userMap.get(user)); + + commentResp.setParentUserInfo(userMap.get(parentUserVo)); + } + return ResponseData.success(commentResp); + } + + @Override + public ResponseData>> worksCommentDialoguePage(DialoguePageReq req, UserVo userVo) { + + Page page = this.baseMapper.worksCommentDialoguePage(new Page<>(req.getPageNo(), req.getPageSize()), req, userVo); + + if (!page.getRecords().isEmpty()) { + Set userVoSet = page.getRecords().stream().map(postPageResp -> new UserVo(postPageResp.getUserType(), postPageResp.getUserId())).collect(Collectors.toSet()); + Set parentUserVoSet = page.getRecords().stream().map(postPageResp -> new UserVo(postPageResp.getParentUserType(), postPageResp.getParentUserId())).collect(Collectors.toSet()); + + userVoSet.addAll(parentUserVoSet); + + //查询用户信息 + Map userMap = userService.selectUserInfoMap(userVoSet, userVo); + + page.getRecords().stream().forEach(resp -> { + resp.setUserInfo(userMap.get(new UserVo(resp.getUserType(), resp.getUserId()))); + resp.setParentUserInfo(userMap.get(new UserVo(resp.getParentUserType(), resp.getParentUserId()))); + }); + } + + return ResponseData.success(new PageResult<>(page)); + } +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/workspanorama/controller/WorksPanoramaController.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/workspanorama/controller/WorksPanoramaController.java new file mode 100644 index 0000000..7fd7b27 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/workspanorama/controller/WorksPanoramaController.java @@ -0,0 +1,97 @@ +package com.ruoyi.frequency.workspanorama.controller; + +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.page.TableDataInfo; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.common.utils.poi.ExcelUtil; +import com.ruoyi.frequency.workspanorama.entity.WorksPanorama; +import com.ruoyi.frequency.workspanorama.service.WorksPanoramaService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +/** + * 作品和全景图关联Controller + * + * @author zj + * @date 2023-09-22 + */ +@RestController +@RequestMapping("/frequency/workspanorama") +public class WorksPanoramaController extends BaseController +{ + @Autowired + private WorksPanoramaService worksPanoramaService; + + /** + * 查询作品和全景图关联列表 + */ + @PreAuthorize("@ss.hasPermi('frequency:workspanorama:list')") + @GetMapping("/list") + public TableDataInfo list(WorksPanorama worksPanorama) + { + startPage(); + List list = worksPanoramaService.selectWorksPanoramaList(worksPanorama); + return getDataTable(list); + } + + /** + * 导出作品和全景图关联列表 + */ + @PreAuthorize("@ss.hasPermi('frequency:workspanorama:export')") + @Log(title = "作品和全景图关联", businessType = BusinessType.EXPORT) + @GetMapping("/export") + public AjaxResult export(WorksPanorama worksPanorama) + { + List list = worksPanoramaService.selectWorksPanoramaList(worksPanorama); + ExcelUtil util = new ExcelUtil(WorksPanorama.class); + return util.exportExcel(list, "作品和全景图关联数据"); + } + + /** + * 获取作品和全景图关联详细信息 + */ + @PreAuthorize("@ss.hasPermi('frequency:workspanorama:query')") + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") Long id) + { + return AjaxResult.success(worksPanoramaService.selectWorksPanoramaById(id)); + } + + /** + * 新增作品和全景图关联 + */ + @PreAuthorize("@ss.hasPermi('frequency:workspanorama:add')") + @Log(title = "作品和全景图关联", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody WorksPanorama worksPanorama) + { + return toAjax(worksPanoramaService.insertWorksPanorama(worksPanorama)); + } + + /** + * 修改作品和全景图关联 + */ + @PreAuthorize("@ss.hasPermi('frequency:workspanorama:edit')") + @Log(title = "作品和全景图关联", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody WorksPanorama worksPanorama) + { + return toAjax(worksPanoramaService.updateWorksPanorama(worksPanorama)); + } + + /** + * 删除作品和全景图关联 + */ + @PreAuthorize("@ss.hasPermi('frequency:workspanorama:remove')") + @Log(title = "作品和全景图关联", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}") + public AjaxResult remove(@PathVariable Long[] ids) + { + return toAjax(worksPanoramaService.deleteWorksPanoramaByIds(ids)); + } +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/workspanorama/entity/WorksPanorama.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/workspanorama/entity/WorksPanorama.java new file mode 100644 index 0000000..2a1604d --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/workspanorama/entity/WorksPanorama.java @@ -0,0 +1,59 @@ +package com.ruoyi.frequency.workspanorama.entity; + +import cn.hutool.core.bean.BeanUtil; +import com.baomidou.mybatisplus.annotation.TableName; +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import com.ruoyi.frequency.orderpanorama.entity.OrderPanorama; +import lombok.Data; +import lombok.experimental.Accessors; + +/** + * 作品和全景图关联对象 t_works_panorama + * + * @author zj + * @date 2023-09-22 + */ +@Data +@Accessors(chain = true) +@TableName("t_works_panorama") +public class WorksPanorama extends BaseEntity { + private static final long serialVersionUID = 1L; + + /** + * 租户号 + */ + private Long id; + + + /** + * 删除标志;1 正常 2 删除 3 禁用 + */ + private Integer delFlag; + + /** + * 作品ID + */ + @Excel(name = "作品ID") + private Long worksId; + + /** + * 全景图链接 + */ + @Excel(name = "全景图链接") + private String panoramaImage; + + /** + * 全景图链接封面 + */ + @Excel(name = "全景图链接封面") + private String panorama; + + public WorksPanorama() { + } + + public WorksPanorama(OrderPanorama s) { + BeanUtil.copyProperties(s, this); + this.setId(null); + } +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/workspanorama/mapper/WorksPanoramaMapper.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/workspanorama/mapper/WorksPanoramaMapper.java new file mode 100644 index 0000000..8aeb914 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/workspanorama/mapper/WorksPanoramaMapper.java @@ -0,0 +1,62 @@ +package com.ruoyi.frequency.workspanorama.mapper; + +import java.util.List; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.ruoyi.frequency.workspanorama.entity.WorksPanorama; + +/** + * 作品和全景图关联Mapper接口 + * + * @author zj + * @date 2023-09-22 + */ +public interface WorksPanoramaMapper extends BaseMapper +{ + /** + * 查询作品和全景图关联 + * + * @param id 作品和全景图关联主键 + * @return 作品和全景图关联 + */ + public WorksPanorama selectWorksPanoramaById(Long id); + + /** + * 查询作品和全景图关联列表 + * + * @param worksPanorama 作品和全景图关联 + * @return 作品和全景图关联集合 + */ + public List selectWorksPanoramaList(WorksPanorama worksPanorama); + + /** + * 新增作品和全景图关联 + * + * @param worksPanorama 作品和全景图关联 + * @return 结果 + */ + public int insertWorksPanorama(WorksPanorama worksPanorama); + + /** + * 修改作品和全景图关联 + * + * @param worksPanorama 作品和全景图关联 + * @return 结果 + */ + public int updateWorksPanorama(WorksPanorama worksPanorama); + + /** + * 删除作品和全景图关联 + * + * @param id 作品和全景图关联主键 + * @return 结果 + */ + public int deleteWorksPanoramaById(Long id); + + /** + * 批量删除作品和全景图关联 + * + * @param ids 需要删除的数据主键集合 + * @return 结果 + */ + public int deleteWorksPanoramaByIds(Long[] ids); +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/workspanorama/mapper/mapping/WorksPanoramaMapper.xml b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/workspanorama/mapper/mapping/WorksPanoramaMapper.xml new file mode 100644 index 0000000..efa3df3 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/workspanorama/mapper/mapping/WorksPanoramaMapper.xml @@ -0,0 +1,89 @@ + + + + + + + + + + + + + + + + + + select id, create_by, create_time, update_by, update_time, del_flag, works_id, panorama_image, panorama from t_works_panorama + + + + + + + + insert into t_works_panorama + + id, + create_by, + create_time, + update_by, + update_time, + del_flag, + works_id, + panorama_image, + panorama, + + + #{id}, + #{createBy}, + #{createTime}, + #{updateBy}, + #{updateTime}, + #{delFlag}, + #{worksId}, + #{panoramaImage}, + #{panorama}, + + + + + update t_works_panorama + + create_by = #{createBy}, + create_time = #{createTime}, + update_by = #{updateBy}, + update_time = #{updateTime}, + del_flag = #{delFlag}, + works_id = #{worksId}, + panorama_image = #{panoramaImage}, + panorama = #{panorama}, + + where id = #{id} + + + + delete from t_works_panorama where id = #{id} + + + + delete from t_works_panorama where id in + + #{id} + + + \ No newline at end of file diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/workspanorama/model/param/WorksPanoramaParam.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/workspanorama/model/param/WorksPanoramaParam.java new file mode 100644 index 0000000..5f233e6 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/workspanorama/model/param/WorksPanoramaParam.java @@ -0,0 +1,50 @@ +package com.ruoyi.frequency.workspanorama.model.param; + +import java.util.Date; +import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.Data; +import lombok.experimental.Accessors; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; + +/** + * 作品和全景图关联对象 t_works_panorama + * + * @author zj + * @date 2023-09-22 + */ +@Data +@Accessors(chain = true) +public class WorksPanoramaParam extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** 租户号 */ + private Long id; + + + /** 删除标志;1 正常 2 删除 3 禁用 */ + private Integer delFlag; + + /** 作品ID */ + @Excel(name = "作品ID") + private Long worksId; + + /** 全景图链接 */ + @Excel(name = "全景图链接") + private String panoramaImage; + + /** 全景图链接封面 */ + @Excel(name = "全景图链接封面") + private String panorama; + + + + + + + + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/workspanorama/model/result/WorksPanoramaResult.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/workspanorama/model/result/WorksPanoramaResult.java new file mode 100644 index 0000000..afdad25 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/workspanorama/model/result/WorksPanoramaResult.java @@ -0,0 +1,44 @@ +package com.ruoyi.frequency.workspanorama.model.result; + +import java.util.Date; +import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.Data; +import lombok.experimental.Accessors; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; + +/** + * 作品和全景图关联对象 t_works_panorama + * + * @author zj + * @date 2023-09-22 + */ +@Data +@Accessors(chain = true) +public class WorksPanoramaResult extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** 租户号 */ + private Long id; + + + /** 删除标志;1 正常 2 删除 3 禁用 */ + private Integer delFlag; + + /** 作品ID */ + @Excel(name = "作品ID") + private Long worksId; + + /** 全景图链接 */ + @Excel(name = "全景图链接") + private String panoramaImage; + + /** 全景图链接封面 */ + @Excel(name = "全景图链接封面") + private String panorama; + + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/workspanorama/service/WorksPanoramaService.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/workspanorama/service/WorksPanoramaService.java new file mode 100644 index 0000000..1d80c6d --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/workspanorama/service/WorksPanoramaService.java @@ -0,0 +1,63 @@ +package com.ruoyi.frequency.workspanorama.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.ruoyi.frequency.workspanorama.entity.WorksPanorama; + +import java.util.List; + +/** + * 作品和全景图关联Service接口 + * + * @author zj + * @date 2023-09-22 + */ +public interface WorksPanoramaService extends IService +{ + /** + * 查询作品和全景图关联 + * + * @param id 作品和全景图关联主键 + * @return 作品和全景图关联 + */ + public WorksPanorama selectWorksPanoramaById(Long id); + + /** + * 查询作品和全景图关联列表 + * + * @param worksPanorama 作品和全景图关联 + * @return 作品和全景图关联集合 + */ + public List selectWorksPanoramaList(WorksPanorama worksPanorama); + + /** + * 新增作品和全景图关联 + * + * @param worksPanorama 作品和全景图关联 + * @return 结果 + */ + public int insertWorksPanorama(WorksPanorama worksPanorama); + + /** + * 修改作品和全景图关联 + * + * @param worksPanorama 作品和全景图关联 + * @return 结果 + */ + public int updateWorksPanorama(WorksPanorama worksPanorama); + + /** + * 批量删除作品和全景图关联 + * + * @param ids 需要删除的作品和全景图关联主键集合 + * @return 结果 + */ + public int deleteWorksPanoramaByIds(Long[] ids); + + /** + * 删除作品和全景图关联信息 + * + * @param id 作品和全景图关联主键 + * @return 结果 + */ + public int deleteWorksPanoramaById(Long id); +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/workspanorama/service/impl/WorksPanoramaServiceImpl.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/workspanorama/service/impl/WorksPanoramaServiceImpl.java new file mode 100644 index 0000000..683003c --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/workspanorama/service/impl/WorksPanoramaServiceImpl.java @@ -0,0 +1,96 @@ +package com.ruoyi.frequency.workspanorama.service.impl; + +import java.util.List; +import com.ruoyi.common.utils.DateUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.ruoyi.frequency.workspanorama.mapper.WorksPanoramaMapper; +import com.ruoyi.frequency.workspanorama.entity.WorksPanorama; +import com.ruoyi.frequency.workspanorama.service.WorksPanoramaService; + +/** + * 作品和全景图关联Service业务层处理 + * + * @author zj + * @date 2023-09-22 + */ +@Service +public class WorksPanoramaServiceImpl extends ServiceImpl implements WorksPanoramaService +{ + @Autowired + private WorksPanoramaMapper worksPanoramaMapper; + + /** + * 查询作品和全景图关联 + * + * @param id 作品和全景图关联主键 + * @return 作品和全景图关联 + */ + @Override + public WorksPanorama selectWorksPanoramaById(Long id) + { + return worksPanoramaMapper.selectWorksPanoramaById(id); + } + + /** + * 查询作品和全景图关联列表 + * + * @param worksPanorama 作品和全景图关联 + * @return 作品和全景图关联 + */ + @Override + public List selectWorksPanoramaList(WorksPanorama worksPanorama) + { + return worksPanoramaMapper.selectWorksPanoramaList(worksPanorama); + } + + /** + * 新增作品和全景图关联 + * + * @param worksPanorama 作品和全景图关联 + * @return 结果 + */ + @Override + public int insertWorksPanorama(WorksPanorama worksPanorama) + { + return worksPanoramaMapper.insertWorksPanorama(worksPanorama); + } + + /** + * 修改作品和全景图关联 + * + * @param worksPanorama 作品和全景图关联 + * @return 结果 + */ + @Override + public int updateWorksPanorama(WorksPanorama worksPanorama) + { + worksPanorama.setUpdateTime(DateUtils.getNowDate()); + return worksPanoramaMapper.updateWorksPanorama(worksPanorama); + } + + /** + * 批量删除作品和全景图关联 + * + * @param ids 需要删除的作品和全景图关联主键 + * @return 结果 + */ + @Override + public int deleteWorksPanoramaByIds(Long[] ids) + { + return worksPanoramaMapper.deleteWorksPanoramaByIds(ids); + } + + /** + * 删除作品和全景图关联信息 + * + * @param id 作品和全景图关联主键 + * @return 结果 + */ + @Override + public int deleteWorksPanoramaById(Long id) + { + return worksPanoramaMapper.deleteWorksPanoramaById(id); + } +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/worksreport/controller/WorksReportController.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/worksreport/controller/WorksReportController.java new file mode 100644 index 0000000..ef34774 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/worksreport/controller/WorksReportController.java @@ -0,0 +1,103 @@ +package com.ruoyi.frequency.worksreport.controller; + +import java.util.List; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.frequency.worksreport.entity.WorksReport; +import com.ruoyi.frequency.worksreport.service.WorksReportService; +import com.ruoyi.common.utils.poi.ExcelUtil; +import com.ruoyi.common.core.page.TableDataInfo; + +/** + * 作品举报Controller + * + * @author liwenlong + * @date 2023-11-30 + */ +@RestController +@RequestMapping("/frequency/worksreport") +public class WorksReportController extends BaseController +{ + @Autowired + private WorksReportService worksReportService; + + /** + * 查询作品举报列表 + */ + @PreAuthorize("@ss.hasPermi('frequency:worksreport:list')") + @PostMapping("/list") + public TableDataInfo list(@RequestBody WorksReport worksReport) + { + startPage(); + List list = worksReportService.selectWorksReportList(worksReport); + return getDataTable(list); + } + + /** + * 导出作品举报列表 + */ + @PreAuthorize("@ss.hasPermi('frequency:worksreport:export')") + @Log(title = "作品举报", businessType = BusinessType.EXPORT) + @GetMapping("/export") + public AjaxResult export(WorksReport worksReport) + { + List list = worksReportService.selectWorksReportList(worksReport); + ExcelUtil util = new ExcelUtil(WorksReport.class); + return util.exportExcel(list, "作品举报数据"); + } + + /** + * 获取作品举报详细信息 + */ + @PreAuthorize("@ss.hasPermi('frequency:worksreport:query')") + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") Long id) + { + return AjaxResult.success(worksReportService.selectWorksReportById(id)); + } + + /** + * 新增作品举报 + */ + @PreAuthorize("@ss.hasPermi('frequency:worksreport:add')") + @Log(title = "作品举报", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody WorksReport worksReport) + { + return toAjax(worksReportService.insertWorksReport(worksReport)); + } + + /** + * 修改作品举报 + */ + @PreAuthorize("@ss.hasPermi('frequency:worksreport:edit')") + @Log(title = "作品举报", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody WorksReport worksReport) + { + return toAjax(worksReportService.updateWorksReport(worksReport)); + } + + /** + * 删除作品举报 + */ + @PreAuthorize("@ss.hasPermi('frequency:worksreport:remove')") + @Log(title = "作品举报", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}/{delFlag}") + public AjaxResult remove(@PathVariable("ids") Long[] ids,@PathVariable("delFlag") Integer delFlag) + { + return toAjax(worksReportService.deleteWorksReportByIds(ids,delFlag)); + } +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/worksreport/entity/WorksReport.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/worksreport/entity/WorksReport.java new file mode 100644 index 0000000..df8cc4d --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/worksreport/entity/WorksReport.java @@ -0,0 +1,80 @@ +package com.ruoyi.frequency.worksreport.entity; + +import com.ruoyi.frequency.works.entity.Works; +import lombok.Data; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.experimental.Accessors; +import com.ruoyi.common.annotation.Excel; +import io.swagger.annotations.ApiModelProperty; +import com.baomidou.mybatisplus.annotation.TableField; +import com.ruoyi.vo.UserInfo; +import com.ruoyi.common.core.domain.BaseEntity; + +import java.util.Date; + +/** + * 作品举报对象 t_works_report + * + * @author liwenlong + * @date 2023-11-30 + */ +@Data +@Accessors(chain = true) +@TableName("t_works_report") +public class WorksReport extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + + @ApiModelProperty("租户号") + private Long id; + + @ApiModelProperty("删除状态 1 正常 2 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("用户类型") + @Excel(name = "用户类型") + private Integer userType; + + @ApiModelProperty("用户id") + @Excel(name = "用户id") + private Long userId; + + @ApiModelProperty("作品id") + @Excel(name = "作品id") + private Long worksId; + + @ApiModelProperty("举报原因") + @Excel(name = "举报原因") + private String reason; + + @ApiModelProperty("内容") + @Excel(name = "内容") + private String content; + + @ApiModelProperty("图片") + @Excel(name = "图片") + private String images; + + @ApiModelProperty("处理结果 1 未处理 2 已处理 3拒绝处理") + @Excel(name = "处理结果 1 未处理 2 已处理 3拒绝处理") + private Integer result; + + @ApiModelProperty("用户信息") + @TableField(exist = false) + private UserInfo userInfo; + + @ApiModelProperty("开始时间") + @TableField(exist = false) + private Date beginTime; + + @ApiModelProperty("结束时间") + @TableField(exist = false) + private Date endTime; + + @ApiModelProperty("作品信息") + @TableField(exist = false) + private Works works; + + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/worksreport/mapper/WorksReportMapper.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/worksreport/mapper/WorksReportMapper.java new file mode 100644 index 0000000..0d4e645 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/worksreport/mapper/WorksReportMapper.java @@ -0,0 +1,47 @@ +package com.ruoyi.frequency.worksreport.mapper; + +import java.util.List; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.ruoyi.frequency.worksreport.entity.WorksReport; + +/** + * 作品举报Mapper接口 + * + * @author liwenlong + * @date 2023-11-30 + */ +public interface WorksReportMapper extends BaseMapper +{ + /** + * 查询作品举报 + * + * @param id 作品举报主键 + * @return 作品举报 + */ + public WorksReport selectWorksReportById(Long id); + + /** + * 查询作品举报列表 + * + * @param worksReport 作品举报 + * @return 作品举报集合 + */ + public List selectWorksReportList(WorksReport worksReport); + + /** + * 新增作品举报 + * + * @param worksReport 作品举报 + * @return 结果 + */ + public int insertWorksReport(WorksReport worksReport); + + /** + * 修改作品举报 + * + * @param worksReport 作品举报 + * @return 结果 + */ + public int updateWorksReport(WorksReport worksReport); + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/worksreport/mapper/mapping/WorksReportMapper.xml b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/worksreport/mapper/mapping/WorksReportMapper.xml new file mode 100644 index 0000000..26f6d67 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/worksreport/mapper/mapping/WorksReportMapper.xml @@ -0,0 +1,153 @@ + + + + + + + + + + + + + + + + + + + + + + + + select + t.id , + t.create_by , + t.create_time , + t.update_by , + t.update_time , + t.del_flag , + t.user_type , + t.user_id , + t.works_id , + t.reason , + t.content , + t.images , + t.result , + t.remark + from t_works_report AS t + LEFT JOIN t_store s on t.user_id = s.id and t.user_type = 2 + LEFT JOIN t_customer c on t.user_id = c.id and t.user_type = 1 + LEFT JOIN t_sale sa on t.user_id = sa.id and t.user_type = 3 + LEFT JOIN t_works w on t.works_id = w.id + + + + + + + + insert into t_works_report + + id, + create_by, + create_time, + update_by, + update_time, + del_flag, + user_type, + user_id, + works_id, + reason, + content, + images, + result, + remark, + + + #{id}, + #{createBy}, + #{createTime}, + #{updateBy}, + #{updateTime}, + #{delFlag}, + #{userType}, + #{userId}, + #{worksId}, + #{reason}, + #{content}, + #{images}, + #{result}, + #{remark}, + + + + + update t_works_report + + create_by = #{createBy}, + create_time = #{createTime}, + update_by = #{updateBy}, + update_time = #{updateTime}, + del_flag = #{delFlag}, + user_type = #{userType}, + user_id = #{userId}, + works_id = #{worksId}, + reason = #{reason}, + content = #{content}, + images = #{images}, + result = #{result}, + remark = #{remark}, + + where id = #{id} + + + \ No newline at end of file diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/worksreport/model/param/WorksReportParam.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/worksreport/model/param/WorksReportParam.java new file mode 100644 index 0000000..70d9237 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/worksreport/model/param/WorksReportParam.java @@ -0,0 +1,65 @@ +package com.ruoyi.frequency.worksreport.model.param; + +import lombok.Data; +import lombok.experimental.Accessors; +import com.ruoyi.common.annotation.Excel; +import io.swagger.annotations.ApiModelProperty; +import com.ruoyi.common.core.domain.BaseEntity; + +/** + * 作品举报对象 t_works_report + * + * @author liwenlong + * @date 2023-11-30 + */ +@Data +@Accessors(chain = true) +public class WorksReportParam extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + @ApiModelProperty("租户号") + private Long id; + + @ApiModelProperty("删除状态 1 正常 2 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("用户类型") + @Excel(name = "用户类型") + private Integer userType; + + @ApiModelProperty("用户id") + @Excel(name = "用户id") + private Long userId; + + @ApiModelProperty("作品id") + @Excel(name = "作品id") + private Long worksId; + + @ApiModelProperty("举报原因") + @Excel(name = "举报原因") + private String reason; + + @ApiModelProperty("内容") + @Excel(name = "内容") + private String content; + + @ApiModelProperty("图片") + @Excel(name = "图片") + private String images; + + @ApiModelProperty("处理结果 1 未处理 2 已处理 3拒绝处理") + @Excel(name = "处理结果 1 未处理 2 已处理 3拒绝处理") + private Integer result; + + + + + + + + + + + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/worksreport/model/result/WorksReportResult.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/worksreport/model/result/WorksReportResult.java new file mode 100644 index 0000000..de1cfa2 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/worksreport/model/result/WorksReportResult.java @@ -0,0 +1,56 @@ +package com.ruoyi.frequency.worksreport.model.result; + +import lombok.Data; +import lombok.experimental.Accessors; +import com.ruoyi.common.annotation.Excel; +import io.swagger.annotations.ApiModelProperty; +import com.ruoyi.common.core.domain.BaseEntity; + +/** + * 作品举报对象 t_works_report + * + * @author liwenlong + * @date 2023-11-30 + */ +@Data +@Accessors(chain = true) +public class WorksReportResult extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + @ApiModelProperty("租户号") + private Long id; + + @ApiModelProperty("删除状态 1 正常 2 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("用户类型") + @Excel(name = "用户类型") + private Integer userType; + + @ApiModelProperty("用户id") + @Excel(name = "用户id") + private Long userId; + + @ApiModelProperty("作品id") + @Excel(name = "作品id") + private Long worksId; + + @ApiModelProperty("举报原因") + @Excel(name = "举报原因") + private String reason; + + @ApiModelProperty("内容") + @Excel(name = "内容") + private String content; + + @ApiModelProperty("图片") + @Excel(name = "图片") + private String images; + + @ApiModelProperty("处理结果 1 未处理 2 已处理 3拒绝处理") + @Excel(name = "处理结果 1 未处理 2 已处理 3拒绝处理") + private Integer result; + + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/worksreport/service/WorksReportService.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/worksreport/service/WorksReportService.java new file mode 100644 index 0000000..188ff6f --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/worksreport/service/WorksReportService.java @@ -0,0 +1,60 @@ +package com.ruoyi.frequency.worksreport.service; + +import java.util.List; + +import com.ruoyi.controller.req.WorksReportReq; +import com.ruoyi.frequency.worksreport.entity.WorksReport; +import com.baomidou.mybatisplus.extension.service.IService; +import com.ruoyi.response.ResponseData; +import com.ruoyi.vo.UserVo; + +/** + * 作品举报Service接口 + * + * @author liwenlong + * @date 2023-11-30 + */ +public interface WorksReportService extends IService +{ + /** + * 查询作品举报 + * + * @param id 作品举报主键 + * @return 作品举报 + */ + public WorksReport selectWorksReportById(Long id); + + /** + * 查询作品举报列表 + * + * @param worksReport 作品举报 + * @return 作品举报集合 + */ + public List selectWorksReportList(WorksReport worksReport); + + /** + * 新增作品举报 + * + * @param worksReport 作品举报 + * @return 结果 + */ + public int insertWorksReport(WorksReport worksReport); + + /** + * 修改作品举报 + * + * @param worksReport 作品举报 + * @return 结果 + */ + public int updateWorksReport(WorksReport worksReport); + + /** + * 批量删除作品举报 + * + * @param ids 需要删除的作品举报主键集合 + * @return 结果 + */ + public int deleteWorksReportByIds(Long[] ids,Integer delFlag); + + ResponseData worksReport(WorksReportReq req, UserVo userVo); +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/worksreport/service/impl/WorksReportServiceImpl.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/worksreport/service/impl/WorksReportServiceImpl.java new file mode 100644 index 0000000..349b30f --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/worksreport/service/impl/WorksReportServiceImpl.java @@ -0,0 +1,150 @@ +package com.ruoyi.frequency.worksreport.service.impl; + +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.stream.Collectors; + +import cn.hutool.core.collection.CollectionUtil; +import com.ruoyi.common.utils.DateUtils; +import com.ruoyi.controller.req.WorksReportReq; +import com.ruoyi.frequency.customer.service.UserService; +import com.ruoyi.frequency.works.entity.Works; +import com.ruoyi.frequency.works.service.WorksService; +import com.ruoyi.post.frequency.posreport.entity.PostReport; +import com.ruoyi.post.frequency.post.entity.Post; +import com.ruoyi.response.ResponseData; +import com.ruoyi.vo.UserInfo; +import com.ruoyi.vo.UserVo; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.ruoyi.code.PublicCommon; +import com.ruoyi.frequency.worksreport.mapper.WorksReportMapper; +import com.ruoyi.frequency.worksreport.entity.WorksReport; +import com.ruoyi.frequency.worksreport.service.WorksReportService; + +/** + * 作品举报Service业务层处理 + * + * @author liwenlong + * @date 2023-11-30 + */ +@Service +public class WorksReportServiceImpl extends ServiceImpl implements WorksReportService +{ + @Autowired + private WorksReportMapper worksReportMapper; + + @Autowired + private UserService userService; + + @Autowired + private WorksService worksService; + + /** + * 查询作品举报 + * + * @param id 作品举报主键 + * @return 作品举报 + */ + @Override + public WorksReport selectWorksReportById(Long id) + { + WorksReport report = worksReportMapper.selectWorksReportById(id); + if (report != null){ + Set userVoSet = CollectionUtil.newHashSet(new UserVo(report.getUserType(), report.getUserId())); + + //查询用户信息 + Map userMap = userService.selectUserInfoMap(userVoSet,null); + + report.setUserInfo(userMap.get(new UserVo(report.getUserType(), report.getUserId()))); + + //作品信息 + Works works = worksService.selectWorksById(report.getWorksId()); + report.setWorks(works); + } + return report; + } + + /** + * 查询作品举报列表 + * + * @param worksReport 作品举报 + * @return 作品举报 + */ + @Override + public List selectWorksReportList(WorksReport worksReport) + { + List reports = worksReportMapper.selectWorksReportList(worksReport); + + if (reports.size() > 0){ + Set userVoSet = reports.stream().map(s -> new UserVo(s.getUserType(), s.getUserId())).collect(Collectors.toSet()); + + //查询用户信息 + Map userMap = userService.selectUserInfoMap(userVoSet,null); + + Set worksIds = reports.stream().map(WorksReport::getWorksId).collect(Collectors.toSet()); + + //查询作品信息 + Map worksMap = worksService.selectWorksMap(worksIds); + + reports.stream().forEach(s ->{ + s.setUserInfo(userMap.get(new UserVo(s.getUserType(), s.getUserId()))); + s.setWorks(worksMap.get(s.getWorksId())); + }); + } + + return reports; + } + + /** + * 新增作品举报 + * + * @param worksReport 作品举报 + * @return 结果 + */ + @Override + public int insertWorksReport(WorksReport worksReport) + { + return worksReportMapper.insert(worksReport); + } + + /** + * 修改作品举报 + * + * @param worksReport 作品举报 + * @return 结果 + */ + @Override + public int updateWorksReport(WorksReport worksReport) + { + return worksReportMapper.updateWorksReport(worksReport); + } + + /** + * 批量删除作品举报 + * + * @param ids 需要删除的作品举报主键 + * @return 结果 + */ + @Override + public int deleteWorksReportByIds(Long[] ids,Integer delFlag) + { + this.lambdaUpdate().set(WorksReport::getDelFlag,delFlag).in(WorksReport::getId,ids).update(); + return ids.length; + } + + @Override + public ResponseData worksReport(WorksReportReq req, UserVo userVo) { + WorksReport worksReport = new WorksReport().setWorksId(req.getWorksId()) + .setUserType(userVo.getUserType()) + .setUserId(userVo.getUserId()) + .setReason(req.getReason()) + .setContent(req.getContent()) + .setImages(req.getImages()); + this.save(worksReport); + + return ResponseData.success(); + } +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/worksshield/controller/WorksShieldController.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/worksshield/controller/WorksShieldController.java new file mode 100644 index 0000000..4b6c917 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/worksshield/controller/WorksShieldController.java @@ -0,0 +1,103 @@ +package com.ruoyi.frequency.worksshield.controller; + +import java.util.List; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.frequency.worksshield.entity.WorksShield; +import com.ruoyi.frequency.worksshield.service.WorksShieldService; +import com.ruoyi.common.utils.poi.ExcelUtil; +import com.ruoyi.common.core.page.TableDataInfo; + +/** + * 作品屏蔽Controller + * + * @author liwenlong + * @date 2023-11-30 + */ +@RestController +@RequestMapping("/frequency/worksshield") +public class WorksShieldController extends BaseController +{ + @Autowired + private WorksShieldService worksShieldService; + + /** + * 查询作品屏蔽列表 + */ + @PreAuthorize("@ss.hasPermi('frequency:worksshield:list')") + @PostMapping("/list") + public TableDataInfo list(@RequestBody WorksShield worksShield) + { + startPage(); + List list = worksShieldService.selectWorksShieldList(worksShield); + return getDataTable(list); + } + + /** + * 导出作品屏蔽列表 + */ + @PreAuthorize("@ss.hasPermi('frequency:worksshield:export')") + @Log(title = "作品屏蔽", businessType = BusinessType.EXPORT) + @GetMapping("/export") + public AjaxResult export(WorksShield worksShield) + { + List list = worksShieldService.selectWorksShieldList(worksShield); + ExcelUtil util = new ExcelUtil(WorksShield.class); + return util.exportExcel(list, "作品屏蔽数据"); + } + + /** + * 获取作品屏蔽详细信息 + */ + @PreAuthorize("@ss.hasPermi('frequency:worksshield:query')") + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") Long id) + { + return AjaxResult.success(worksShieldService.selectWorksShieldById(id)); + } + + /** + * 新增作品屏蔽 + */ + @PreAuthorize("@ss.hasPermi('frequency:worksshield:add')") + @Log(title = "作品屏蔽", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody WorksShield worksShield) + { + return toAjax(worksShieldService.insertWorksShield(worksShield)); + } + + /** + * 修改作品屏蔽 + */ + @PreAuthorize("@ss.hasPermi('frequency:worksshield:edit')") + @Log(title = "作品屏蔽", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody WorksShield worksShield) + { + return toAjax(worksShieldService.updateWorksShield(worksShield)); + } + + /** + * 删除作品屏蔽 + */ + @PreAuthorize("@ss.hasPermi('frequency:worksshield:remove')") + @Log(title = "作品屏蔽", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}/{delFlag}") + public AjaxResult remove(@PathVariable("ids") Long[] ids,@PathVariable("delFlag") Integer delFlag) + { + return toAjax(worksShieldService.deleteWorksShieldByIds(ids,delFlag)); + } +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/worksshield/entity/WorksShield.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/worksshield/entity/WorksShield.java new file mode 100644 index 0000000..fdcd1d3 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/worksshield/entity/WorksShield.java @@ -0,0 +1,49 @@ +package com.ruoyi.frequency.worksshield.entity; + +import lombok.Data; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.experimental.Accessors; +import com.ruoyi.common.annotation.Excel; +import io.swagger.annotations.ApiModelProperty; +import com.baomidou.mybatisplus.annotation.TableField; +import com.ruoyi.vo.UserInfo; +import com.ruoyi.common.core.domain.BaseEntity; + +/** + * 作品屏蔽对象 t_works_shield + * + * @author liwenlong + * @date 2023-11-30 + */ +@Data +@Accessors(chain = true) +@TableName("t_works_shield") +public class WorksShield extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + + @ApiModelProperty("租户号") + private Long id; + + @ApiModelProperty("删除状态 1 正常 2 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("用户类型") + @Excel(name = "用户类型") + private Integer userType; + + @ApiModelProperty("用户id") + @Excel(name = "用户id") + private Long userId; + + @ApiModelProperty("作品id") + @Excel(name = "作品id") + private Long worksId; + + @ApiModelProperty("用户信息") + @TableField(exist = false) + private UserInfo userInfo; + + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/worksshield/mapper/WorksShieldMapper.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/worksshield/mapper/WorksShieldMapper.java new file mode 100644 index 0000000..425e430 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/worksshield/mapper/WorksShieldMapper.java @@ -0,0 +1,50 @@ +package com.ruoyi.frequency.worksshield.mapper; + +import java.util.List; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.ruoyi.frequency.worksshield.entity.WorksShield; +import com.ruoyi.vo.UserVo; +import org.apache.ibatis.annotations.Param; + +/** + * 作品屏蔽Mapper接口 + * + * @author liwenlong + * @date 2023-11-30 + */ +public interface WorksShieldMapper extends BaseMapper +{ + /** + * 查询作品屏蔽 + * + * @param id 作品屏蔽主键 + * @return 作品屏蔽 + */ + public WorksShield selectWorksShieldById(Long id); + + /** + * 查询作品屏蔽列表 + * + * @param worksShield 作品屏蔽 + * @return 作品屏蔽集合 + */ + public List selectWorksShieldList(WorksShield worksShield); + + /** + * 新增作品屏蔽 + * + * @param worksShield 作品屏蔽 + * @return 结果 + */ + public int insertWorksShield(WorksShield worksShield); + + /** + * 修改作品屏蔽 + * + * @param worksShield 作品屏蔽 + * @return 结果 + */ + public int updateWorksShield(WorksShield worksShield); + + void worksShield(@Param("req") WorksShield worksShield,@Param("userVo") UserVo userVo); +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/worksshield/mapper/mapping/WorksShieldMapper.xml b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/worksshield/mapper/mapping/WorksShieldMapper.xml new file mode 100644 index 0000000..25f0485 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/worksshield/mapper/mapping/WorksShieldMapper.xml @@ -0,0 +1,123 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + select + t.id , + t.del_flag , + t.create_by , + t.create_time , + t.update_by , + t.update_time , + t.user_type , + t.user_id , + t.works_id , + t.remark , + u.user_type, + u.id_no, + u.mobile, + u.avatar, + u.nickname + from t_works_shield AS t + LEFT JOIN t_user AS u ON t.user_id = u.id + + + + + + + + insert into t_works_shield + + id, + del_flag, + create_by, + create_time, + update_by, + update_time, + user_type, + user_id, + works_id, + remark, + + + #{id}, + #{delFlag}, + #{createBy}, + #{createTime}, + #{updateBy}, + #{updateTime}, + #{userType}, + #{userId}, + #{worksId}, + #{remark}, + + + + + update t_works_shield + + del_flag = #{delFlag}, + create_by = #{createBy}, + create_time = #{createTime}, + update_by = #{updateBy}, + update_time = #{updateTime}, + user_type = #{userType}, + user_id = #{userId}, + works_id = #{worksId}, + remark = #{remark}, + + where id = #{id} + + + + insert into t_works_shield + (id, create_by, create_time, update_by, update_time, user_type, user_id, works_id) + values + (#{req.id},#{req.updateBy},#{req.updateTime},#{req.updateBy},#{req.updateTime},#{userVo.userType}, #{userVo.userId}, #{req.worksId}) + ON DUPLICATE KEY UPDATE + del_flag = IF( del_flag = 1, 3, 1 ), + update_time = #{req.updateTime}, + update_by = #{req.updateBy}; + + + \ No newline at end of file diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/worksshield/model/param/WorksShieldParam.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/worksshield/model/param/WorksShieldParam.java new file mode 100644 index 0000000..773a187 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/worksshield/model/param/WorksShieldParam.java @@ -0,0 +1,45 @@ +package com.ruoyi.frequency.worksshield.model.param; + +import lombok.Data; +import lombok.experimental.Accessors; +import com.ruoyi.common.annotation.Excel; +import io.swagger.annotations.ApiModelProperty; +import com.ruoyi.common.core.domain.BaseEntity; + +/** + * 作品屏蔽对象 t_works_shield + * + * @author liwenlong + * @date 2023-11-30 + */ +@Data +@Accessors(chain = true) +public class WorksShieldParam extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + @ApiModelProperty("租户号") + private Long id; + + @ApiModelProperty("删除状态 1 正常 2 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("用户类型") + @Excel(name = "用户类型") + private Integer userType; + + @ApiModelProperty("用户id") + @Excel(name = "用户id") + private Long userId; + + @ApiModelProperty("作品id") + @Excel(name = "作品id") + private Long worksId; + + + + + + + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/worksshield/model/result/WorksShieldResult.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/worksshield/model/result/WorksShieldResult.java new file mode 100644 index 0000000..df84c48 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/worksshield/model/result/WorksShieldResult.java @@ -0,0 +1,40 @@ +package com.ruoyi.frequency.worksshield.model.result; + +import lombok.Data; +import lombok.experimental.Accessors; +import com.ruoyi.common.annotation.Excel; +import io.swagger.annotations.ApiModelProperty; +import com.ruoyi.common.core.domain.BaseEntity; + +/** + * 作品屏蔽对象 t_works_shield + * + * @author liwenlong + * @date 2023-11-30 + */ +@Data +@Accessors(chain = true) +public class WorksShieldResult extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + @ApiModelProperty("租户号") + private Long id; + + @ApiModelProperty("删除状态 1 正常 2 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("用户类型") + @Excel(name = "用户类型") + private Integer userType; + + @ApiModelProperty("用户id") + @Excel(name = "用户id") + private Long userId; + + @ApiModelProperty("作品id") + @Excel(name = "作品id") + private Long worksId; + + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/worksshield/service/WorksShieldService.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/worksshield/service/WorksShieldService.java new file mode 100644 index 0000000..55163a4 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/worksshield/service/WorksShieldService.java @@ -0,0 +1,65 @@ +package com.ruoyi.frequency.worksshield.service; + +import java.util.List; +import com.ruoyi.frequency.worksshield.entity.WorksShield; +import com.baomidou.mybatisplus.extension.service.IService; +import com.ruoyi.response.ResponseData; +import com.ruoyi.vo.UserVo; + +/** + * 作品屏蔽Service接口 + * + * @author liwenlong + * @date 2023-11-30 + */ +public interface WorksShieldService extends IService +{ + /** + * 查询作品屏蔽 + * + * @param id 作品屏蔽主键 + * @return 作品屏蔽 + */ + public WorksShield selectWorksShieldById(Long id); + + /** + * 查询作品屏蔽列表 + * + * @param worksShield 作品屏蔽 + * @return 作品屏蔽集合 + */ + public List selectWorksShieldList(WorksShield worksShield); + + /** + * 新增作品屏蔽 + * + * @param worksShield 作品屏蔽 + * @return 结果 + */ + public int insertWorksShield(WorksShield worksShield); + + /** + * 修改作品屏蔽 + * + * @param worksShield 作品屏蔽 + * @return 结果 + */ + public int updateWorksShield(WorksShield worksShield); + + /** + * 批量删除作品屏蔽 + * + * @param ids 需要删除的作品屏蔽主键集合 + * @return 结果 + */ + public int deleteWorksShieldByIds(Long[] ids,Integer delFlag); + + ResponseData worksShield(Long id, UserVo userVo); + + /** + * 用户屏蔽的作品ids + * @param userVo + * @return + */ + List shieldWorksList(UserVo userVo); +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/worksshield/service/impl/WorksShieldServiceImpl.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/worksshield/service/impl/WorksShieldServiceImpl.java new file mode 100644 index 0000000..69f1c6b --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/worksshield/service/impl/WorksShieldServiceImpl.java @@ -0,0 +1,119 @@ +package com.ruoyi.frequency.worksshield.service.impl; + +import java.util.List; +import java.util.stream.Collectors; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.ruoyi.common.utils.DateUtils; +import com.ruoyi.post.frequency.posshield.entity.PostShield; +import com.ruoyi.response.ResponseData; +import com.ruoyi.utils.SnowIdUtils; +import com.ruoyi.vo.UserVo; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.ruoyi.code.PublicCommon; +import com.ruoyi.frequency.worksshield.mapper.WorksShieldMapper; +import com.ruoyi.frequency.worksshield.entity.WorksShield; +import com.ruoyi.frequency.worksshield.service.WorksShieldService; + +/** + * 作品屏蔽Service业务层处理 + * + * @author liwenlong + * @date 2023-11-30 + */ +@Service +public class WorksShieldServiceImpl extends ServiceImpl implements WorksShieldService +{ + @Autowired + private WorksShieldMapper worksShieldMapper; + + /** + * 查询作品屏蔽 + * + * @param id 作品屏蔽主键 + * @return 作品屏蔽 + */ + @Override + public WorksShield selectWorksShieldById(Long id) + { + return worksShieldMapper.selectWorksShieldById(id); + } + + /** + * 查询作品屏蔽列表 + * + * @param worksShield 作品屏蔽 + * @return 作品屏蔽 + */ + @Override + public List selectWorksShieldList(WorksShield worksShield) + { + return worksShieldMapper.selectWorksShieldList(worksShield); + } + + /** + * 新增作品屏蔽 + * + * @param worksShield 作品屏蔽 + * @return 结果 + */ + @Override + public int insertWorksShield(WorksShield worksShield) + { + return worksShieldMapper.insert(worksShield); + } + + /** + * 修改作品屏蔽 + * + * @param worksShield 作品屏蔽 + * @return 结果 + */ + @Override + public int updateWorksShield(WorksShield worksShield) + { + return worksShieldMapper.updateWorksShield(worksShield); + } + + /** + * 批量删除作品屏蔽 + * + * @param ids 需要删除的作品屏蔽主键 + * @return 结果 + */ + @Override + public int deleteWorksShieldByIds(Long[] ids,Integer delFlag) + { + this.lambdaUpdate().set(WorksShield::getDelFlag,delFlag).in(WorksShield::getId,ids).update(); + return ids.length; + } + + @Override + public ResponseData worksShield(Long id, UserVo userVo) { + WorksShield worksShield = new WorksShield() + .setId(SnowIdUtils.uniqueLong()) + .setWorksId(id) + .setUserType(userVo.getUserType()) + .setUserId(userVo.getUserId()); + + worksShield.setUpdateData(); + + //作品屏蔽 + worksShieldMapper.worksShield(worksShield,userVo); + + return ResponseData.success(); + } + + @Override + public List shieldWorksList(UserVo userVo) { + //查询屏蔽帖子记录 + List list = this.list(new QueryWrapper().lambda() + .eq(WorksShield::getDelFlag, PublicCommon.启用) + .eq(WorksShield::getUserType, userVo.getUserType()) + .eq(WorksShield::getUserId, userVo.getUserId())); + + return list.stream().map(WorksShield::getWorksId).collect(Collectors.toList()); + } +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/workstep/controller/WorkStepController.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/workstep/controller/WorkStepController.java new file mode 100644 index 0000000..4362072 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/workstep/controller/WorkStepController.java @@ -0,0 +1,97 @@ +package com.ruoyi.frequency.workstep.controller; + +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.page.TableDataInfo; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.common.utils.poi.ExcelUtil; +import com.ruoyi.frequency.workstep.entity.WorkStep; +import com.ruoyi.frequency.workstep.service.WorkStepService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +/** + * 作品踩Controller + * + * @author liwenlong + * @date 2023-10-12 + */ +@RestController +@RequestMapping("/frequency/workstep") +public class WorkStepController extends BaseController +{ + @Autowired + private WorkStepService workStepService; + + /** + * 查询作品踩列表 + */ + @PreAuthorize("@ss.hasPermi('frequency:workstep:list')") + @GetMapping("/list") + public TableDataInfo list(WorkStep workStep) + { + startPage(); + List list = workStepService.selectWorkStepList(workStep); + return getDataTable(list); + } + + /** + * 导出作品踩列表 + */ + @PreAuthorize("@ss.hasPermi('frequency:workstep:export')") + @Log(title = "作品踩", businessType = BusinessType.EXPORT) + @GetMapping("/export") + public AjaxResult export(WorkStep workStep) + { + List list = workStepService.selectWorkStepList(workStep); + ExcelUtil util = new ExcelUtil(WorkStep.class); + return util.exportExcel(list, "作品踩数据"); + } + + /** + * 获取作品踩详细信息 + */ + @PreAuthorize("@ss.hasPermi('frequency:workstep:query')") + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") Long id) + { + return AjaxResult.success(workStepService.selectWorkStepById(id)); + } + + /** + * 新增作品踩 + */ + @PreAuthorize("@ss.hasPermi('frequency:workstep:add')") + @Log(title = "作品踩", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody WorkStep workStep) + { + return toAjax(workStepService.insertWorkStep(workStep)); + } + + /** + * 修改作品踩 + */ + @PreAuthorize("@ss.hasPermi('frequency:workstep:edit')") + @Log(title = "作品踩", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody WorkStep workStep) + { + return toAjax(workStepService.updateWorkStep(workStep)); + } + + /** + * 删除作品踩 + */ + @PreAuthorize("@ss.hasPermi('frequency:workstep:remove')") + @Log(title = "作品踩", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}") + public AjaxResult remove(@PathVariable Long[] ids) + { + return toAjax(workStepService.deleteWorkStepByIds(ids)); + } +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/workstep/entity/WorkStep.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/workstep/entity/WorkStep.java new file mode 100644 index 0000000..6aa9e49 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/workstep/entity/WorkStep.java @@ -0,0 +1,52 @@ +package com.ruoyi.frequency.workstep.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import com.ruoyi.controller.req.WorksStepReq; +import com.ruoyi.utils.SnowIdUtils; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; + +/** + * 作品踩对象 t_work_step + * + * @author liwenlong + * @date 2023-10-12 + */ +@Data +@Accessors(chain = true) +@TableName("t_work_step") +public class WorkStep extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + + @ApiModelProperty("主键id") + private Long id; + + @ApiModelProperty("删除标志 1正常 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("用户类型 1 用户 2 商家") + @Excel(name = "用户类型 1 用户 2 商家") + private Integer userType; + + @ApiModelProperty("用户id") + @Excel(name = "用户id") + private Long userId; + + @ApiModelProperty("作品ID") + @Excel(name = "作品ID") + private Long workId; + + + public WorkStep() { + } + + public WorkStep(WorksStepReq req) { + this.id = SnowIdUtils.uniqueLong(); + this.workId = req.getWorkId(); + } +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/workstep/mapper/WorkStepMapper.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/workstep/mapper/WorkStepMapper.java new file mode 100644 index 0000000..2100c3b --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/workstep/mapper/WorkStepMapper.java @@ -0,0 +1,67 @@ +package com.ruoyi.frequency.workstep.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.ruoyi.frequency.workstep.entity.WorkStep; +import com.ruoyi.vo.UserVo; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * 作品踩Mapper接口 + * + * @author liwenlong + * @date 2023-10-12 + */ +public interface WorkStepMapper extends BaseMapper +{ + /** + * 查询作品踩 + * + * @param id 作品踩主键 + * @return 作品踩 + */ + public WorkStep selectWorkStepById(Long id); + + /** + * 查询作品踩列表 + * + * @param workStep 作品踩 + * @return 作品踩集合 + */ + public List selectWorkStepList(WorkStep workStep); + + /** + * 新增作品踩 + * + * @param workStep 作品踩 + * @return 结果 + */ + public int insertWorkStep(WorkStep workStep); + + /** + * 修改作品踩 + * + * @param workStep 作品踩 + * @return 结果 + */ + public int updateWorkStep(WorkStep workStep); + + /** + * 删除作品踩 + * + * @param id 作品踩主键 + * @return 结果 + */ + public int deleteWorkStepById(Long id); + + /** + * 批量删除作品踩 + * + * @param ids 需要删除的数据主键集合 + * @return 结果 + */ + public int deleteWorkStepByIds(Long[] ids); + + void workStep(@Param("req")WorkStep workStep, @Param("userVo")UserVo userVo); +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/workstep/mapper/mapping/WorkStepMapper.xml b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/workstep/mapper/mapping/WorkStepMapper.xml new file mode 100644 index 0000000..2e6c8e6 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/workstep/mapper/mapping/WorkStepMapper.xml @@ -0,0 +1,99 @@ + + + + + + + + + + + + + + + + + + select id, create_by, create_time, update_by, update_time, del_flag, user_type, user_id, work_id from t_work_step + + + + + + + + insert into t_work_step + + id, + create_by, + create_time, + update_by, + update_time, + del_flag, + user_type, + user_id, + work_id, + + + #{id}, + #{createBy}, + #{createTime}, + #{updateBy}, + #{updateTime}, + #{delFlag}, + #{userType}, + #{userId}, + #{workId}, + + + + + update t_work_step + + create_by = #{createBy}, + create_time = #{createTime}, + update_by = #{updateBy}, + update_time = #{updateTime}, + del_flag = #{delFlag}, + user_type = #{userType}, + user_id = #{userId}, + work_id = #{workId}, + + where id = #{id} + + + + delete from t_work_step where id = #{id} + + + + delete from t_work_step where id in + + #{id} + + + + + insert into t_work_step + (id, create_by, create_time, update_by, update_time, user_type, user_id,work_id) + values + (#{req.id},#{req.updateBy},#{req.updateTime},#{req.updateBy},#{req.updateTime},#{userVo.userType}, #{userVo.userId}, #{req.workId}) + ON DUPLICATE KEY UPDATE + del_flag = IF( del_flag = 1, 3, 1 ), + update_time = #{req.updateTime}, + update_by = #{req.updateBy}; + + \ No newline at end of file diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/workstep/model/param/WorkStepParam.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/workstep/model/param/WorkStepParam.java new file mode 100644 index 0000000..6bae68d --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/workstep/model/param/WorkStepParam.java @@ -0,0 +1,45 @@ +package com.ruoyi.frequency.workstep.model.param; + +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; + +/** + * 作品踩对象 t_work_step + * + * @author liwenlong + * @date 2023-10-12 + */ +@Data +@Accessors(chain = true) +public class WorkStepParam extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + @ApiModelProperty("主键id") + private Long id; + + @ApiModelProperty("删除标志 1正常 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("用户类型 1 用户 2 商家") + @Excel(name = "用户类型 1 用户 2 商家") + private Integer userType; + + @ApiModelProperty("用户id") + @Excel(name = "用户id") + private Long userId; + + @ApiModelProperty("作品ID") + @Excel(name = "作品ID") + private Long workId; + + + + + + + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/workstep/model/result/WorkStepResult.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/workstep/model/result/WorkStepResult.java new file mode 100644 index 0000000..ca8f353 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/workstep/model/result/WorkStepResult.java @@ -0,0 +1,40 @@ +package com.ruoyi.frequency.workstep.model.result; + +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; + +/** + * 作品踩对象 t_work_step + * + * @author liwenlong + * @date 2023-10-12 + */ +@Data +@Accessors(chain = true) +public class WorkStepResult extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + @ApiModelProperty("主键id") + private Long id; + + @ApiModelProperty("删除标志 1正常 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("用户类型 1 用户 2 商家") + @Excel(name = "用户类型 1 用户 2 商家") + private Integer userType; + + @ApiModelProperty("用户id") + @Excel(name = "用户id") + private Long userId; + + @ApiModelProperty("作品ID") + @Excel(name = "作品ID") + private Long workId; + + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/workstep/service/WorkStepService.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/workstep/service/WorkStepService.java new file mode 100644 index 0000000..fc00019 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/workstep/service/WorkStepService.java @@ -0,0 +1,75 @@ +package com.ruoyi.frequency.workstep.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.ruoyi.controller.req.WorksStepReq; +import com.ruoyi.frequency.workstep.entity.WorkStep; +import com.ruoyi.response.ResponseData; +import com.ruoyi.vo.UserVo; + +import java.util.List; + +/** + * 作品踩Service接口 + * + * @author liwenlong + * @date 2023-10-12 + */ +public interface WorkStepService extends IService +{ + /** + * 查询作品踩 + * + * @param id 作品踩主键 + * @return 作品踩 + */ + public WorkStep selectWorkStepById(Long id); + + /** + * 查询作品踩列表 + * + * @param workStep 作品踩 + * @return 作品踩集合 + */ + public List selectWorkStepList(WorkStep workStep); + + /** + * 新增作品踩 + * + * @param workStep 作品踩 + * @return 结果 + */ + public int insertWorkStep(WorkStep workStep); + + /** + * 修改作品踩 + * + * @param workStep 作品踩 + * @return 结果 + */ + public int updateWorkStep(WorkStep workStep); + + /** + * 批量删除作品踩 + * + * @param ids 需要删除的作品踩主键集合 + * @return 结果 + */ + public int deleteWorkStepByIds(Long[] ids); + + /** + * 删除作品踩信息 + * + * @param id 作品踩主键 + * @return 结果 + */ + public int deleteWorkStepById(Long id); + + + /** + * 作品踩 + * @param req + * @param userVo + * @return + */ + ResponseData worksStep(WorksStepReq req, UserVo userVo); +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/workstep/service/impl/WorkStepServiceImpl.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/workstep/service/impl/WorkStepServiceImpl.java new file mode 100644 index 0000000..77dea09 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/workstep/service/impl/WorkStepServiceImpl.java @@ -0,0 +1,162 @@ +package com.ruoyi.frequency.workstep.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.ruoyi.code.PublicCommon; +import com.ruoyi.common.utils.DateUtils; +import com.ruoyi.controller.req.WorksStepReq; +import com.ruoyi.frequency.worklike.entity.WorkLike; +import com.ruoyi.frequency.worklike.mapper.WorkLikeMapper; +import com.ruoyi.frequency.works.entity.Works; +import com.ruoyi.frequency.works.mapper.WorksMapper; +import com.ruoyi.frequency.works.service.WorksService; +import com.ruoyi.frequency.workstep.entity.WorkStep; +import com.ruoyi.frequency.workstep.mapper.WorkStepMapper; +import com.ruoyi.frequency.workstep.service.WorkStepService; +import com.ruoyi.response.ResponseData; +import com.ruoyi.vo.UserVo; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.List; + +/** + * 作品踩Service业务层处理 + * + * @author liwenlong + * @date 2023-10-12 + */ +@Service +@Transactional(rollbackFor = Exception.class) +public class WorkStepServiceImpl extends ServiceImpl implements WorkStepService +{ + @Autowired + private WorkStepMapper workStepMapper; + + /** + * 查询作品踩 + * + * @param id 作品踩主键 + * @return 作品踩 + */ + @Override + public WorkStep selectWorkStepById(Long id) + { + return workStepMapper.selectWorkStepById(id); + } + + /** + * 查询作品踩列表 + * + * @param workStep 作品踩 + * @return 作品踩 + */ + @Override + public List selectWorkStepList(WorkStep workStep) + { + return workStepMapper.selectWorkStepList(workStep); + } + + /** + * 新增作品踩 + * + * @param workStep 作品踩 + * @return 结果 + */ + @Override + public int insertWorkStep(WorkStep workStep) + { + workStep.setCreateTime(DateUtils.getNowDate()); + return workStepMapper.insertWorkStep(workStep); + } + + /** + * 修改作品踩 + * + * @param workStep 作品踩 + * @return 结果 + */ + @Override + public int updateWorkStep(WorkStep workStep) + { + workStep.setUpdateTime(DateUtils.getNowDate()); + return workStepMapper.updateWorkStep(workStep); + } + + /** + * 批量删除作品踩 + * + * @param ids 需要删除的作品踩主键 + * @return 结果 + */ + @Override + public int deleteWorkStepByIds(Long[] ids) + { + this.lambdaUpdate().set(WorkStep::getDelFlag,PublicCommon.删除).in(WorkStep::getId,ids).update(); + return ids.length; + } + + /** + * 删除作品踩信息 + * + * @param id 作品踩主键 + * @return 结果 + */ + @Override + public int deleteWorkStepById(Long id) + { + this.lambdaUpdate().set(WorkStep::getDelFlag,PublicCommon.删除).eq(WorkStep::getId,id).update(); + return 1; + } + + @Autowired + private WorkLikeMapper workLikeMapper; + + @Autowired + private WorksMapper worksMapper; + + @Override + public ResponseData worksStep(WorksStepReq req, UserVo userVo) { + WorkStep workStep = new WorkStep(req); + + //更新帖子点赞记录 + workStepMapper.workStep(workStep,userVo); + + workStep = workStepMapper.selectOne(new QueryWrapper().lambda() + .eq(WorkStep::getWorkId, req.getWorkId()) + .eq(WorkStep::getUserType, userVo.getUserType()) + .eq(WorkStep::getUserId, userVo.getUserId()) + ); + + workStep = workStepMapper.selectById(workStep.getId()); + + //是否踩 + Boolean isStep = workStep.getDelFlag().equals(PublicCommon.启用); + + + Works works = new Works().setId(req.getWorkId()).setStepNum(isStep?1:-1); + + if (isStep){ + WorkLike workLike = workLikeMapper.selectOne(new QueryWrapper().lambda() + .eq(WorkLike::getWorkId, req.getWorkId()) + .eq(WorkLike::getUserType, userVo.getUserType()) + .eq(WorkLike::getUserId, userVo.getUserId()) + ); + if (workLike != null && workLike.getDelFlag().equals(PublicCommon.启用)){ + + workLike.setDelFlag(PublicCommon.禁用); + //更新作品踩记录 + workLikeMapper.workLike(workLike,userVo); + + works.setLikeNum(-1); + } + } + + //更新数量 + works.setUpdateData(); + worksMapper.updateWorks(works); + + return ResponseData.success(); + } +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/workstype/controller/WorksTypeController.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/workstype/controller/WorksTypeController.java new file mode 100644 index 0000000..44c66d4 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/workstype/controller/WorksTypeController.java @@ -0,0 +1,107 @@ +package com.ruoyi.frequency.workstype.controller; + +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.page.TableDataInfo; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.common.utils.poi.ExcelUtil; +import com.ruoyi.frequency.workstype.entity.WorksType; +import com.ruoyi.frequency.workstype.service.WorksTypeService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +/** + * 作品类型Controller + * + * @author zj + * @date 2023-09-22 + */ +@RestController +@RequestMapping("/frequency/workstype") +public class WorksTypeController extends BaseController +{ + @Autowired + private WorksTypeService worksTypeService; + + /** + * 查询作品类型列表 + */ +// @PreAuthorize("@ss.hasPermi('frequency:workstype:list')") + @PostMapping("/list") + public TableDataInfo list(@RequestBody WorksType worksType) + { + startPage(); + List list = worksTypeService.selectWorksTypeList(worksType); + return getDataTable(list); + } + + /** + * 导出作品类型列表 + */ + @PreAuthorize("@ss.hasPermi('frequency:workstype:export')") + @Log(title = "作品类型", businessType = BusinessType.EXPORT) + @GetMapping("/export") + public AjaxResult export(WorksType worksType) + { + List list = worksTypeService.selectWorksTypeList(worksType); + ExcelUtil util = new ExcelUtil(WorksType.class); + return util.exportExcel(list, "作品类型数据"); + } + + /** + * 获取作品类型详细信息 + */ + @PreAuthorize("@ss.hasPermi('frequency:workstype:query')") + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") Long id) + { + return AjaxResult.success(worksTypeService.selectWorksTypeById(id)); + } + + /** + * 新增作品类型 + */ + @PreAuthorize("@ss.hasPermi('frequency:workstype:add')") + @Log(title = "作品类型", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody WorksType worksType) + { + return toAjax(worksTypeService.insertWorksType(worksType)); + } + + /** + * 修改作品类型 + */ + @PreAuthorize("@ss.hasPermi('frequency:workstype:edit')") + @Log(title = "作品类型", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody WorksType worksType) + { + return toAjax(worksTypeService.updateWorksType(worksType)); + } + + /** + * 删除作品类型 + */ + @PreAuthorize("@ss.hasPermi('frequency:workstype:remove')") + @Log(title = "作品类型", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}/{delFlag}") + public AjaxResult remove(@PathVariable Long[] ids,@PathVariable Integer delFlag) + { + return toAjax(worksTypeService.deleteWorksTypeByIds(ids,delFlag)); + } + + /** + * 查询二级分类 + */ + @PreAuthorize("@ss.hasPermi('frequency:workstype:twoWorksTypeList')") + @PostMapping("/twoLevelList") + public AjaxResult twoLevelList() + { + return worksTypeService.twoLevelList(); + } +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/workstype/entity/WorksType.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/workstype/entity/WorksType.java new file mode 100644 index 0000000..64fe9ec --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/workstype/entity/WorksType.java @@ -0,0 +1,59 @@ +package com.ruoyi.frequency.workstype.entity; + +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableName; +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; + +import java.util.ArrayList; +import java.util.List; + +/** + * 作品类型对象 t_works_type + * + * @author zj + * @date 2023-09-22 + */ +@Data +@Accessors(chain = true) +@TableName("t_works_type") +public class WorksType extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** 租户号 */ + private Long id; + + /** 删除标志;1 正常 2 删除 3 禁用 */ + private Integer delFlag; + + /** 类型名称 */ + @Excel(name = "类型名称") + private String name; + + /** 类型编码 */ + @Excel(name = "类型编码") + private String code; + + /** 父id;上级id */ + @Excel(name = "父id;上级id") + private Long pid; + + /** 等级 */ + @Excel(name = "等级") + private Integer level; + + /** 排序 */ + private Integer sort; + + /** 标签(一级分类才有) */ + private String label; + + + @ApiModelProperty(value = "子类列表") + @TableField(exist = false) + private List childList; +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/workstype/mapper/WorksTypeMapper.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/workstype/mapper/WorksTypeMapper.java new file mode 100644 index 0000000..e7fa6fd --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/workstype/mapper/WorksTypeMapper.java @@ -0,0 +1,70 @@ +package com.ruoyi.frequency.workstype.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.ruoyi.controller.req.StorePageReq; +import com.ruoyi.controller.resp.StorePageResp; +import com.ruoyi.frequency.workstype.entity.WorksType; +import com.ruoyi.vo.UserVo; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * 作品类型Mapper接口 + * + * @author zj + * @date 2023-09-22 + */ +public interface WorksTypeMapper extends BaseMapper +{ + /** + * 查询作品类型 + * + * @param id 作品类型主键 + * @return 作品类型 + */ + public WorksType selectWorksTypeById(Long id); + + /** + * 查询作品类型列表 + * + * @param worksType 作品类型 + * @return 作品类型集合 + */ + public List selectWorksTypeList(WorksType worksType); + + /** + * 新增作品类型 + * + * @param worksType 作品类型 + * @return 结果 + */ + public int insertWorksType(WorksType worksType); + + /** + * 修改作品类型 + * + * @param worksType 作品类型 + * @return 结果 + */ + public int updateWorksType(WorksType worksType); + + /** + * 删除作品类型 + * + * @param id 作品类型主键 + * @return 结果 + */ + public int deleteWorksTypeById(Long id); + + /** + * 批量删除作品类型 + * + * @param ids 需要删除的数据主键集合 + * @return 结果 + */ + public int deleteWorksTypeByIds(Long[] ids); + + Page storePage(@Param("page") Page objectPage, @Param("req")StorePageReq req, @Param("userVo") UserVo userVo); +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/workstype/mapper/mapping/WorksTypeMapper.xml b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/workstype/mapper/mapping/WorksTypeMapper.xml new file mode 100644 index 0000000..c3b4989 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/workstype/mapper/mapping/WorksTypeMapper.xml @@ -0,0 +1,309 @@ + + + + + + + + + + + + + + + + + + + + select id, create_by, create_time, update_by, update_time, del_flag, name, code, pid, level,sort from t_works_type + + + + + + + + insert into t_works_type + + id, + create_by, + create_time, + update_by, + update_time, + del_flag, + name, + code, + pid, + level, + + + #{id}, + #{createBy}, + #{createTime}, + #{updateBy}, + #{updateTime}, + #{delFlag}, + #{name}, + #{code}, + #{pid}, + #{level}, + + + + + update t_works_type + + create_by = #{createBy}, + create_time = #{createTime}, + update_by = #{updateBy}, + update_time = #{updateTime}, + del_flag = #{delFlag}, + name = #{name}, + code = #{code}, + pid = #{pid}, + level = #{level}, + + where id = #{id} + + + + delete from t_works_type where id = #{id} + + + + delete from t_works_type where id in + + #{id} + + + + + diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/workstype/model/param/WorksTypeParam.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/workstype/model/param/WorksTypeParam.java new file mode 100644 index 0000000..fb0a5af --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/workstype/model/param/WorksTypeParam.java @@ -0,0 +1,51 @@ +package com.ruoyi.frequency.workstype.model.param; + +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import lombok.Data; +import lombok.experimental.Accessors; + +/** + * 作品类型对象 t_works_type + * + * @author zj + * @date 2023-09-22 + */ +@Data +@Accessors(chain = true) +public class WorksTypeParam extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** 租户号 */ + private Long id; + + + /** 删除标志;1 正常 2 删除 3 禁用 */ + private Integer delFlag; + + /** 类型名称 */ + @Excel(name = "类型名称") + private String name; + + /** 类型编码 */ + @Excel(name = "类型编码") + private String code; + + /** 父id;上级id */ + @Excel(name = "父id;上级id") + private Long pid; + + /** 等级 */ + @Excel(name = "等级") + private Integer level; + + + + + + + + + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/workstype/model/result/WorksTypeResult.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/workstype/model/result/WorksTypeResult.java new file mode 100644 index 0000000..18567f6 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/workstype/model/result/WorksTypeResult.java @@ -0,0 +1,44 @@ +package com.ruoyi.frequency.workstype.model.result; + +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import lombok.Data; +import lombok.experimental.Accessors; + +/** + * 作品类型对象 t_works_type + * + * @author zj + * @date 2023-09-22 + */ +@Data +@Accessors(chain = true) +public class WorksTypeResult extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** 租户号 */ + private Long id; + + + /** 删除标志;1 正常 2 删除 3 禁用 */ + private Integer delFlag; + + /** 类型名称 */ + @Excel(name = "类型名称") + private String name; + + /** 类型编码 */ + @Excel(name = "类型编码") + private String code; + + /** 父id;上级id */ + @Excel(name = "父id;上级id") + private Long pid; + + /** 等级 */ + @Excel(name = "等级") + private Integer level; + + +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/workstype/service/WorksTypeService.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/workstype/service/WorksTypeService.java new file mode 100644 index 0000000..ca46dc0 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/workstype/service/WorksTypeService.java @@ -0,0 +1,97 @@ +package com.ruoyi.frequency.workstype.service; + +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.IService; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.page.PageResult; +import com.ruoyi.controller.req.StorePageReq; +import com.ruoyi.controller.resp.StorePageResp; +import com.ruoyi.frequency.workstype.entity.WorksType; +import com.ruoyi.response.ResponseData; +import com.ruoyi.vo.UserVo; + +import java.util.List; + +/** + * 作品类型Service接口 + * + * @author zj + * @date 2023-09-22 + */ +public interface WorksTypeService extends IService +{ + /** + * 查询作品类型 + * + * @param id 作品类型主键 + * @return 作品类型 + */ + public WorksType selectWorksTypeById(Long id); + + /** + * 查询作品类型列表 + * + * @param worksType 作品类型 + * @return 作品类型集合 + */ + public List selectWorksTypeList(WorksType worksType); + + /** + * 新增作品类型 + * + * @param worksType 作品类型 + * @return 结果 + */ + public int insertWorksType(WorksType worksType); + + /** + * 修改作品类型 + * + * @param worksType 作品类型 + * @return 结果 + */ + public int updateWorksType(WorksType worksType); + + /** + * 批量删除作品类型 + * + * @param ids 需要删除的作品类型主键集合 + * @return 结果 + */ + public int deleteWorksTypeByIds(Long[] ids, Integer delFlag); + + /** + * 删除作品类型信息 + * + * @param id 作品类型主键 + * @return 结果 + */ + public int deleteWorksTypeById(Long id); + + + + /** + * 二级分类 + * @return + */ + AjaxResult twoLevelList(); + + + List worksTypeList(); + + /** + * 根据分类id 查询 3级分类ids + * @param typeId + * @return + */ + List getIdsByTypeId(Long typeId); + + + /** + * 表现师(技术)列表 + * @param req + * @param userVo + * @return + */ + ResponseData>> storePage(StorePageReq req, UserVo userVo); +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/workstype/service/impl/WorksTypeServiceImpl.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/workstype/service/impl/WorksTypeServiceImpl.java new file mode 100644 index 0000000..d7fc804 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/frequency/workstype/service/impl/WorksTypeServiceImpl.java @@ -0,0 +1,443 @@ +package com.ruoyi.frequency.workstype.service.impl; + +import cn.hutool.core.util.ObjectUtil; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.ruoyi.code.DictConstant; +import com.ruoyi.code.PublicCommon; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.domain.entity.SysDictData; +import com.ruoyi.common.core.redis.RedisService; +import com.ruoyi.common.exception.ServiceException; +import com.ruoyi.common.page.PageResult; +import com.ruoyi.common.utils.StringUtils; +import com.ruoyi.controller.req.StorePageReq; +import com.ruoyi.controller.resp.StorePageResp; +import com.ruoyi.enums.user.UserEnums; +import com.ruoyi.frequency.customer.service.UserService; +import com.ruoyi.frequency.works.service.WorksService; +import com.ruoyi.frequency.workstype.entity.WorksType; +import com.ruoyi.frequency.workstype.mapper.WorksTypeMapper; +import com.ruoyi.frequency.workstype.service.WorksTypeService; +import com.ruoyi.response.ResponseData; +import com.ruoyi.utils.BusinessUtil; +import com.ruoyi.vo.UserInfo; +import com.ruoyi.vo.UserVo; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.redis.core.RedisTemplate; +import org.springframework.stereotype.Service; + +import java.math.BigDecimal; +import java.util.*; +import java.util.stream.Collectors; + +/** + * 作品类型Service业务层处理 + * + * @author zj + * @date 2023-09-22 + */ +@Service +public class WorksTypeServiceImpl extends ServiceImpl implements WorksTypeService { + @Autowired + private WorksTypeMapper worksTypeMapper; + + /** + * 查询作品类型 + * + * @param id 作品类型主键 + * @return 作品类型 + */ + @Override + public WorksType selectWorksTypeById(Long id) { + return worksTypeMapper.selectWorksTypeById(id); + } + + /** + * 查询作品类型列表 + * + * @param worksType 作品类型 + * @return 作品类型 + */ + @Override + public List selectWorksTypeList(WorksType worksType) { + List worksTypes = worksTypeMapper.selectWorksTypeList(worksType); + + if (worksTypes.size() > 0) { + Map> workTypeMap = getWorkTypeMap(); + worksTypes.forEach(s -> { + s.setChildList(getChildList(workTypeMap, s.getId())); + }); + } + + return worksTypes; + } + + /** + * 新增作品类型 + * + * @param worksType 作品类型 + * @return 结果 + */ + @Override + public int insertWorksType(WorksType worksType) { + +// checkParam(worksType,false); + + if (ObjectUtil.isEmpty(worksType.getPid()) || worksType.getPid() == 0L) { + worksType.setPid(0L); + worksType.setLevel(1); + } else { + WorksType parent = worksTypeMapper.selectById(worksType.getPid()); + worksType.setLevel(parent.getLevel() + 1); + } + + return worksTypeMapper.insert(worksType); + } + + /** + * 校验参数,检查是否存在重复的编码或者名称, + * + * @param worksType + * @param isUpdate 是否排除当前添加的这条记录 + */ + private void checkParam(WorksType worksType, boolean isUpdate) { + + //编码不能为空 + if (StringUtils.isEmpty(worksType.getCode())) { + throw new ServiceException("编码不能为空"); + } + + WorksType worksTypeExist = new WorksType(); + worksTypeExist.setCode(worksType.getCode()); + if (isUpdate) { + worksTypeExist.setCode(worksType.getCode()); + } + List list = worksTypeMapper.selectWorksTypeList(worksTypeExist); + if (list != null && list.size() > 0) { + throw new ServiceException("字典编码重复"); + } + } + + /** + * 修改作品类型 + * + * @param worksType 作品类型 + * @return 结果 + */ + @Override + public int updateWorksType(WorksType worksType) { + +// checkParam(worksType,true); + + if (ObjectUtil.isEmpty(worksType.getPid()) || worksType.getPid() == 0L) { + worksType.setPid(0L); + worksType.setLevel(1); + } else { + WorksType parent = worksTypeMapper.selectById(worksType.getPid()); + worksType.setLevel(parent.getLevel() + 1); + } + + worksType.setUpdateData(); + return worksTypeMapper.updateById(worksType); + } + + @Autowired + private WorksService worksService; + + /** + * 批量删除作品类型 + * + * @param ids 需要删除的作品类型主键 + * @return 结果 + */ + @Override + public int deleteWorksTypeByIds(Long[] ids, Integer delFlag) { + this.lambdaUpdate().set(WorksType::getDelFlag, delFlag).in(WorksType::getId, ids).update(); + return ids.length; + } + + /** + * 删除作品类型信息 + * + * @param id 作品类型主键 + * @return 结果 + */ + @Override + public int deleteWorksTypeById(Long id) { + return worksTypeMapper.deleteWorksTypeById(id); + } + + @Override + public AjaxResult twoLevelList() { + //查询分类 + Map> map = getWorkTypeMap(); + + List worksTypes = map.get(0L); + + if (worksTypes != null) { + worksTypes.stream().forEach(s -> { + s.setChildList(map.get(s.getId())); + }); + } + return AjaxResult.success(worksTypes); + } + + + @Override + public List worksTypeList() { + //查询分类 + Map> map = getWorkTypeMap(); + + List worksTypes = map.get(0L); + + List worksTypeList = new ArrayList<>(); + + worksTypes.stream().forEach(s -> { + List typeList = map.get(s.getId()); + if (typeList == null || typeList.size() == 0) { + return; + } + s.setChildList(typeList); + worksTypeList.add(s); + }); + + return worksTypeList; + } + + @Override + public List getIdsByTypeId(Long typeId) { + + //查询分类 + Map> map = getWorkTypeMap(); + + List ids = new ArrayList<>(); + + WorksType worksType = this.getById(typeId); + + if (worksType.getLevel() == 2) { + ids.add(typeId); + return ids; + } + + return getThreeIdList(map, typeId, ids); + } + + @Autowired + private BusinessUtil businessUtil; + + @Autowired + private UserService userService; + + @Autowired + private RedisTemplate redisTemplate; + + @Autowired + private RedisService redisService; + + @Override + public ResponseData>> storePage(StorePageReq req, UserVo userVo) { + + + //筛去拉黑与被拉黑用户 + List blockUserList = userService.blockUserList(userVo); + req.setBlockUserList(blockUserList); + + //筛去屏蔽用户 + List shieldUserList = userService.shieldUserList(userVo); + req.setShieldUserList(shieldUserList); + + if (req.getType() == 1) { + //拼接排序 + List dictList = businessUtil.getDictList(DictConstant.技术列表排序权重); + + dictList = dictList.stream().sorted(Comparator.comparing(SysDictData::getDictValue)).collect(Collectors.toList()); + + String sortSql = ""; + + if (dictList != null && dictList.size() > 0) { + + for (SysDictData dictData : dictList) { + if (dictData.getCode().equals(DictConstant.TechnologySort.在线时长)) { + sortSql = sortSql.concat(" tt.online_duration DESC,"); + } else if (dictData.getCode().equals(DictConstant.TechnologySort.订单数量)) { + sortSql = sortSql.concat(" tt.orderNum DESC,"); + } else if (dictData.getCode().equals(DictConstant.TechnologySort.订单金额)) { + sortSql = sortSql.concat(" tt.orderAmount DESC,"); + } else if (dictData.getCode().equals(DictConstant.TechnologySort.好评率)) { + sortSql = sortSql.concat(" tt.star DESC"); + } + } + req.setSortSql(sortSql); + } + } + + //从业年限筛选 + if (ObjectUtil.isNotEmpty(req.getYearRange())) { + String[] split = req.getYearRange().split("-"); + if (split.length == 1) { + req.setMaxYear(Integer.valueOf(split[0])); + } + if (split.length == 2) { + req.setMinYear(Integer.valueOf(split[0])); + req.setMaxYear(Integer.valueOf(split[1])); + } + } + + //在线状态筛选;1:在线,2离线 + if (ObjectUtil.isNotEmpty(req.getOnlineStatus())) { + + Integer userType = 2; + if (req.getIsWorkingDrawing() == 2) { + userType = 4; + } + //上次调用此接口的时间 + String last_time_map_key = "last_time_" + userType; + + List userIds = new ArrayList<>(); + + if (redisTemplate.hasKey(last_time_map_key)) { + + Map cacheMap = redisService.getCacheMap(last_time_map_key); + + cacheMap.forEach((key, value) -> { + + long lastTimes = Long.valueOf(value.toString()); + + if (System.currentTimeMillis() - lastTimes < (6 * 60 * 1000)) { + userIds.add(Long.valueOf(key)); + } + }); + + //userIds为空 直接返回 + if (userIds.size() == 0) { + if (ObjectUtil.equal(1, req.getOnlineStatus())) { + return ResponseData.success(new PageResult<>(new Page<>(req.getPageNo(), req.getPageSize()))); + } else { + req.setOnlineStatus(null); + } + } else { + req.setUserIds(userIds); + } + + } else { + if (ObjectUtil.equal(1, req.getOnlineStatus())) { + return ResponseData.success(new PageResult<>(new Page<>(req.getPageNo(), req.getPageSize()))); + } else { + req.setOnlineStatus(null); + } + } + + + } + + + Page page = worksTypeMapper.storePage(new Page<>(req.getPageNo(), req.getPageSize()), req, userVo); + + if (!page.getRecords().isEmpty()) { + + //累计服务金额基数 + BigDecimal orderAmount = new BigDecimal(businessUtil.getDict(DictConstant.OrderDict.累计服务金额基数).getDictValue()); + + //当月服务单数基数 + Integer orderMonthNum = Integer.valueOf(businessUtil.getDict(DictConstant.OrderDict.当月服务单数基数).getDictValue()); + + //累计服务单数基数 + Integer orderNum = Integer.valueOf(businessUtil.getDict(DictConstant.OrderDict.累计服务单数基数).getDictValue()); + + Integer userType = 2; + if (req.getIsWorkingDrawing() == 2) { + userType = 4; + } + //上次调用此接口的时间 + String last_time_map_key = "last_time_" + userType; + + //用户id + Set userVoSet = page.getRecords().stream().map(s -> new UserVo(s.getUserType(), s.getId())).collect(Collectors.toSet()); + + //获取用户信息 + Map userMap = userService.selectUserInfoMap(userVoSet, userVo); + + page.getRecords().stream().forEach(s -> { + + //获取在线状态 + Integer onlineStatus = businessUtil.getOnlineStatus(req.getIsWorkingDrawing() == 2 ? s.getBindEnterpriseId() : s.getId(), last_time_map_key); + s.setOnlineStatus(onlineStatus); + + if (req.getIsWorkingDrawing() == 2) { + s.setUserType(UserEnums.enterprise.getCode()); + } + + //isWorkingDrawing 是否是企业: 1不是 2是 + if (req.getIsWorkingDrawing() == 1) { + //累计服务金额基数 + s.setOrderAmount(orderAmount.add(s.getOrderAmount())); + + //当月服务单数基数 + s.setOrderMonthNum(orderMonthNum + s.getOrderMonthNum()); + + //累计服务单数基数 + s.setOrderNum(orderNum + s.getOrderNum()); + } + s.setUserInfo(userMap.get(new UserVo(s.getUserType(), s.getId()))); + }); + } + + return ResponseData.success(new PageResult<>(page)); + } + + + private Map> getWorkTypeMap() { + List list = this.list(new QueryWrapper().lambda() + .eq(WorksType::getDelFlag, PublicCommon.启用) + .orderByAsc(WorksType::getSort) + ); + + Map> map = new HashMap<>(); + + list.stream().forEach(worksType -> { + if (!map.containsKey(worksType.getPid())) { + map.put(worksType.getPid(), new ArrayList<>()); + } + map.get(worksType.getPid()).add(worksType); + }); + return map; + } + + private List getChildList(Map> map, Long pid) { + + if (!map.containsKey(pid)) { + return new ArrayList<>(); + } + + List worksTypes = map.get(pid); + + worksTypes.stream().forEach(worksType -> { + List list = map.get(worksType.getId()); + worksType.setChildList(list); + }); + + return worksTypes; + } + + + private List getThreeIdList(Map> map, Long pid, List ids) { + + if (!map.containsKey(pid)) { + return ids; + } + + List worksTypes = map.get(pid); + + worksTypes.stream().forEach(worksType -> { + if (worksType.getLevel() == 2) { + ids.add(worksType.getId()); + } else { + getThreeIdList(map, worksType.getId(), ids); + } + }); + + return ids; + } +} diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/service/MessageService.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/service/MessageService.java new file mode 100644 index 0000000..c588fe5 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/service/MessageService.java @@ -0,0 +1,27 @@ +package com.ruoyi.service; + +import com.ruoyi.controller.req.IsNeedGetOrderDetailReq2; +import com.ruoyi.controller.req.MessageReadOrDeleteReq; +import com.ruoyi.response.ResponseData; +import com.ruoyi.vo.UserVo; +import org.springframework.stereotype.Component; + +/** + * 消息 + * + * @author liwenlong + * @date 2023-04-18 + */ +@Component +public interface MessageService { + + /** + * 消息中心 + * @param userVo + */ + ResponseData messageCenter(UserVo userVo); + + ResponseData messageReadOrDelete(MessageReadOrDeleteReq req, UserVo userVo); + + ResponseData isNeedGetMessageCenter(IsNeedGetOrderDetailReq2 req, UserVo userVo); +} \ No newline at end of file diff --git a/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/service/impl/MessageServiceImpl.java b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/service/impl/MessageServiceImpl.java new file mode 100644 index 0000000..4e51284 --- /dev/null +++ b/ruoyi-main/ruoyi-admin-core/src/main/java/com/ruoyi/service/impl/MessageServiceImpl.java @@ -0,0 +1,134 @@ +package com.ruoyi.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.ruoyi.code.PublicCommon; +import com.ruoyi.controller.req.IsNeedGetOrderDetailReq2; +import com.ruoyi.controller.req.MessageReadOrDeleteReq; +import com.ruoyi.frequency.appmessage.entity.AppMessage; +import com.ruoyi.frequency.appmessage.service.AppMessageService; +import com.ruoyi.frequency.ordermessage.entity.OrderMessage; +import com.ruoyi.frequency.ordermessage.service.OrderMessageService; +import com.ruoyi.message.frequency.interactionmessagerecord.entity.InteractionMessageRecord; +import com.ruoyi.message.frequency.interactionmessagerecord.service.InteractionMessageRecordService; +import com.ruoyi.response.ResponseData; +import com.ruoyi.service.MessageService; +import com.ruoyi.vo.UserVo; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * 消息 服务实现类 + * + * @author liwenlong + * @date 2023-04-18 + */ +@Service +@Transactional(rollbackFor = Exception.class) +public class MessageServiceImpl implements MessageService { + + + @Autowired + private AppMessageService appMessageService; + + @Autowired + private OrderMessageService orderMessageService; + + @Autowired + private InteractionMessageRecordService interactionMessageRecordService; + + @Override + public ResponseData messageCenter(UserVo userVo) { + //返回值 + Map result = new HashMap<>(); + + //未读的系统消息数量 + Integer systemMessageCount = appMessageService.systemMessageCount(userVo); + result.put("systemMessageCount", systemMessageCount); + + //未读的系统消息 + AppMessage newAppMessage = appMessageService.systemMessageNew(userVo); + result.put("newAppMessage", newAppMessage); + + List orderMessageList = orderMessageService.list(new QueryWrapper().lambda().eq(OrderMessage::getUserId, userVo.getUserId()) + .eq(OrderMessage::getUserType, userVo.getUserType()).eq(OrderMessage::getIsShow, PublicCommon.Message.未清空). + eq(OrderMessage::getIsRead, PublicCommon.Message.未读).eq(OrderMessage::getDelFlag, PublicCommon.启用)); + Map orderMessageMap = new HashMap<>(); + orderMessageList.stream().forEach(x -> { + orderMessageMap.put(x.getOrderType() + "," + x.getOrderId(), "1"); + }); + + result.put("orderMessageCount", orderMessageMap.size()); + + //最新订单消息 + OrderMessage newOrderMessage = orderMessageService.getOne(new QueryWrapper().lambda() + .eq(OrderMessage::getUserId, userVo.getUserId()) + .eq(OrderMessage::getUserType, userVo.getUserType()) + .eq(OrderMessage::getIsShow, PublicCommon.Message.未清空) + .eq(OrderMessage::getDelFlag, PublicCommon.启用) + .orderByDesc(OrderMessage::getCreateTime) + .last("limit 1") + ); + result.put("newOrderMessage", newOrderMessage); + result.put("orderMessageDate", newOrderMessage == null ? null : newOrderMessage.getCreateTime()); + + + //未读的互动消息数量 + Integer interactionMessageCount = interactionMessageRecordService.count(new QueryWrapper().lambda().eq(InteractionMessageRecord::getUserId, userVo.getUserId()) + .eq(InteractionMessageRecord::getUserType, userVo.getUserType()).eq(InteractionMessageRecord::getIsShow, PublicCommon.Message.未清空). + eq(InteractionMessageRecord::getIsRead, PublicCommon.Message.未读).eq(InteractionMessageRecord::getDelFlag, PublicCommon.启用)); + result.put("interactionMessageCount", interactionMessageCount); + + //最新互动消息 + InteractionMessageRecord newInteractionMessage = interactionMessageRecordService.getOne(new QueryWrapper().lambda() + .eq(InteractionMessageRecord::getUserId, userVo.getUserId()) + .eq(InteractionMessageRecord::getUserType, userVo.getUserType()) + .eq(InteractionMessageRecord::getIsShow, PublicCommon.Message.未清空) + .eq(InteractionMessageRecord::getDelFlag, PublicCommon.启用) + .orderByDesc(InteractionMessageRecord::getCreateTime) + .last("limit 1") + ); + result.put("newInteractionMessage", newInteractionMessage); + + + return ResponseData.success(result); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public ResponseData messageReadOrDelete(MessageReadOrDeleteReq req, UserVo userVo) { + //订单 + orderMessageService.orderMessageReadOrDelete(req, userVo); + //系统 + appMessageService.appMessageReadOrDelete(req, userVo); + //互动 + interactionMessageRecordService.interactionMessageReadOrDelete(req, userVo); + return ResponseData.success(); + } + + @Override + public ResponseData isNeedGetMessageCenter(IsNeedGetOrderDetailReq2 req, UserVo userVo) { + OrderMessage newOrderMessage = orderMessageService.getOne(new QueryWrapper().lambda() + .eq(OrderMessage::getUserId, userVo.getUserId()) + .eq(OrderMessage::getUserType, userVo.getUserType()) + .eq(OrderMessage::getIsShow, PublicCommon.Message.未清空) + .eq(OrderMessage::getDelFlag, PublicCommon.启用) + .orderByDesc(OrderMessage::getCreateTime) + .last("limit 1") + ); + if (newOrderMessage != null) { + if (req.getDate() == null) { + return ResponseData.success(true); + } + if (newOrderMessage.getCreateTime().getTime() > req.getDate().getTime()) { + return ResponseData.success(true); + } + } + + return ResponseData.success(false); + } +} diff --git a/ruoyi-main/ruoyi-custom/pom.xml b/ruoyi-main/ruoyi-custom/pom.xml new file mode 100644 index 0000000..944fd80 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/pom.xml @@ -0,0 +1,28 @@ + + + 4.0.0 + + com.ruoyi + ruoyi-main + 3.7.0 + + + ruoyi-custom + + + 8 + 8 + UTF-8 + + + + + org.apache.poi + poi-ooxml + 5.2.5 + + + + \ No newline at end of file diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/annotations/UserLoginToken.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/annotations/UserLoginToken.java new file mode 100644 index 0000000..0028b06 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/annotations/UserLoginToken.java @@ -0,0 +1,22 @@ +package com.ruoyi.annotations; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * 自定义一个注解 凡是标注这个注解的都需要验证身份Token + */ +@Target({ElementType.METHOD, ElementType.TYPE}) +@Retention(RetentionPolicy.RUNTIME) +public @interface UserLoginToken { + boolean required() default true; + + /** + * 拥有这个角色的用户,有权限访问该接口,默认为空不限制 值为 Token 类中 用户token前缀 + * @return + */ + String[] userTokenPre() default {}; + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/aspect/ApiOperationAspect.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/aspect/ApiOperationAspect.java new file mode 100644 index 0000000..32d11bb --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/aspect/ApiOperationAspect.java @@ -0,0 +1,50 @@ +package com.ruoyi.aspect; + +import io.swagger.annotations.ApiOperation; +import lombok.extern.slf4j.Slf4j; +import org.aspectj.lang.ProceedingJoinPoint; +import org.aspectj.lang.annotation.Around; +import org.aspectj.lang.annotation.Aspect; +import org.aspectj.lang.annotation.Pointcut; +import org.aspectj.lang.reflect.MethodSignature; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.core.annotation.Order; +import org.springframework.stereotype.Component; + +import java.lang.reflect.Method; + +/** + * 多数据源处理 + * + * @author ruoyi + */ +@Aspect +@Order(1) +@Component +@Slf4j +public class ApiOperationAspect +{ + protected Logger logger = LoggerFactory.getLogger(getClass()); + + @Pointcut("@annotation(io.swagger.annotations.ApiOperation)") + public void dsPointCut() + { + + } + + @Around("dsPointCut()") + public Object around(ProceedingJoinPoint point) throws Throwable + { + //开始时间 + long start = System.currentTimeMillis(); + Object result = point.proceed(); + + MethodSignature methodSignature = (MethodSignature) point.getSignature(); + Method method = methodSignature.getMethod(); + ApiOperation annotation = method.getAnnotation(ApiOperation.class); + + logger.info("执行方法 method: {}【{}】 耗时:{} 毫秒" , method.getName(), annotation.value(), System.currentTimeMillis() - start); + return result; + } +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/cache/RedisOperation.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/cache/RedisOperation.java new file mode 100644 index 0000000..4b6bb1b --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/cache/RedisOperation.java @@ -0,0 +1,97 @@ +package com.ruoyi.cache; + +import org.apache.commons.lang3.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.data.redis.core.RedisTemplate; +import org.springframework.stereotype.Component; + +import javax.annotation.Resource; +import java.util.concurrent.TimeUnit; + +/** + * 基于 Redisson的 redis操作,包含lock和自增,基于stream的mq
+ * 要求:redis 5.0+ ,springBoot 2.3+ + * + * @author springrain + */ + +@Component("redisOperation") +public class RedisOperation { + private final Logger logger = LoggerFactory.getLogger(getClass()); + + + @Resource + private RedisTemplate redisTemplate; + + + /** + * 根据Key 和超时时间加锁 + * + * @param key 锁的key + * @param expireMilli 超时时间毫秒数 + * @return + */ + public boolean lock(String key, long expireMilli) { + if (StringUtils.isBlank(key)) { + return false; + } + + try { + Boolean lock = redisTemplate.opsForValue().setIfAbsent(key, System.currentTimeMillis() + expireMilli, expireMilli, TimeUnit.MILLISECONDS); + return lock; + } catch (Exception e) { + logger.error("locking error", e); + return false; + } + + + } + + /** + * 根据Key解锁 + * + * @param key 锁的key + */ + public boolean unlock(String key) { + + if (StringUtils.isBlank(key)) { + return false; + } + try { + redisTemplate.delete(key); + return true; + + } catch (Throwable e) { + logger.error("unlock error", e); + return false; + } + } + + + /** + * 原子自增 + * + * @param name 自增的名称 + * @return + */ + public Long getAtomicLong(String name) { + Long increment = redisTemplate.opsForValue().increment(name); + return increment; + } + + /** + * 原子自增 + * + * @param name 自增的名称 + * @param initValue 自增的初始值 + * @return + */ + public Long getAtomicLong(String name, Long initValue) { + Long increment = redisTemplate.opsForValue().increment(name, initValue); + return increment; + + } + + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/code/BuiltDictConstant.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/code/BuiltDictConstant.java new file mode 100644 index 0000000..a4e9a82 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/code/BuiltDictConstant.java @@ -0,0 +1,24 @@ +package com.ruoyi.code; + + +/** + * 字典类型 + * @author liwenlong + * @date 2023/2/11 15:36 + */ +public class BuiltDictConstant { + + /** + * 支付失效时间 + */ + public static final String 支付失效时间 = "PAY_INVALID_TIME"; + + public static final String 是否直接分佣 = "IS_DIRECT"; + + + public static final String 取消订单时间 = "CANCEL_ORDER"; + + public static final String 短信验证码间隔时间 = "RESEND_SMS_CODE_TIME"; + +} + diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/code/DictConstant.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/code/DictConstant.java new file mode 100644 index 0000000..48e9a0e --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/code/DictConstant.java @@ -0,0 +1,241 @@ +package com.ruoyi.code; + + +/** + * 字典类型 + * @author liwenlong + * @date 2023/2/11 15:36 + */ +public class DictConstant { + + /** + * 默认头像 + */ + public static final String 默认头像 = "DEFAULT_AVATAR"; + + + /** + * 设计师默认昵称前缀 + */ + public static final String SJS_name_pre = "SJS_name_pre"; + + + /** + * 表现师默认昵称前缀 + */ + public static final String BXS_name_pre = "BXS_name_pre"; + + /** + * 平台头像 + */ + public static final String 官方头像 = "PLATFORM_AVATAR"; + + /** + * 提现手续费 + */ + public static final String 提现手续费 = "WITHDRAWAL_COMM"; + + /** + * 推广员提现手续费 + */ + public static final String 推广员提现手续费 = "SALE_WITHDRAWAL_COMM"; + + /** + * 提现日期 + */ + public static final String 提现日期 = "WITHDRAWAL_DATE"; + + /** + * 论坛审核 + */ + public static final String 帖子审核 = "POST_IS_PROCESS"; + + + + /** + * 质量评分占比 + */ + public static final String 质量评分占比 = "quality_ratio"; + + + /** + * 效率评分占比 + */ + public static final String 效率评分占比 = "efficiency_ratio"; + + + /** + * 服务评分占比 + */ + public static final String 服务评分占比 = "service_ratio"; + + /** + * 平台设置比例系数 + */ + public static final String 平台设置比例系数 = "scale"; + + /** + * 技术擅长领域 + */ + public static final String 技术擅长领域 = "speciality_area"; + + + /** + * 技术列表排序权重 + */ + public static final String 技术列表排序权重 = "technology_sort"; + + + /** + * 技术列表排序权重 + */ + public static class TechnologySort { + /** + * 技术擅长领域 + */ + public static final String 在线时长 = "online_duration"; + + /** + * 技术擅长领域 + */ + public static final String 订单数量 = "order_number"; + + /** + * 技术擅长领域 + */ + public static final String 订单金额 = "order_amount"; + /** + * 技术擅长领域 + */ + public static final String 好评率 = "good_rate"; + + } + + + /** + * 普通认证缴纳金额 + */ + public static final String 普通认证缴纳金额 = "AUTH_AMOUNT"; + + + /** + *酷家乐认证缴纳金额 + */ + public static final String 酷家乐认证缴纳金额 = "KUJIALE_AUTH_AMOUNT"; + + /** + * 高端认证缴纳金额 + */ + public static final String 高端认证缴纳金额 = "HIGHEND_AUTH_AMOUNT"; + + + /** + * 注册赠送抵用金 + */ + public static final String 注册赠送抵用金 = "register_send_balance"; + + + /** + * 注册赠送抵用金 + */ + public static final String 注册赠送积分 = "register_send_integral"; + + /** + * 订单相关 + */ + public static class OrderDict { + /** + * 首款支付占比 + */ + public static final String 首款支付占比 = "frist_pay_ratio"; + + /** + * 累计服务金额基数 + */ + public static final String 累计服务金额基数 = "order_amount_base"; + + /** + * 当月服务单数基数 + */ + public static final String 当月服务单数基数 = "order_month_num_base"; + + /** + * 累计服务单数基数 + */ + public static final String 累计服务单数基数 = "order_num_base"; + + + /** + * 赠送金额支付占比 + */ + public static final String 赠送金额支付占比 = "send_price_pay_ratio"; + + /** + * 邀请用户下单获取积分与消费额的比例 + */ + public static final String 邀请用户下单获取积分与消费额的比例 = "integral_ratio"; + + + } + + /** + * 推广员分佣比例 + */ + public static final String 推广师分佣比例 = "commission_ratio"; + + /** + * 表现师分佣比例 + */ + public static final String 表现师分佣比例 = "store_Commission_Ratio"; + + /** + * 点赞好评基础量 + */ + public static final String 点赞好评基础量 = "like_good_base_num"; + + + /** + * 作品最大数量 + */ + public static final String 作品最大数量 = "works_max_num"; + + + /** + * 订单取消时间(单位:分钟) + */ + public static final String 订单自动取消时间 = "auto_order_cancel_time"; + + /** + * 订单自动确认几天前发送消息(单位:天) + */ + public static final String 订单自动确认前发送消息 = "auto_order_cancel_time"; + + + /** + * 绑定账户协议图片 + */ + public static final String 表现师绑定账户协议图片 = "BIND_AGREEMENT"; + + /** + * 绑定账户协议图片 + */ + public static final String 推荐官绑定账户协议图片 = "BIND_AGREEMENT_SALE"; + /** + * 充值赠送金额比例 + */ + public static final String 充值赠送金额比例 = "give_amount"; + + + + + /** + * 商城订单相关 + */ + public static class MallOrderDict { + public static final String 售后天数 = "AFTER_SALES_DAYS"; + + public static final String 平台发货后X天自动确认收货 = "confirm_days"; + + } +} + diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/code/PublicCommon.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/code/PublicCommon.java new file mode 100644 index 0000000..9eab6a9 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/code/PublicCommon.java @@ -0,0 +1,303 @@ +package com.ruoyi.code; + + +public class PublicCommon { + + + + /** + * 删除标识 + */ + public static final Integer 启用 = 1; + public static final Integer 删除 = 2; + public static final Integer 禁用 = 3; + + /** + * 审核状态 + */ + public static final Integer 待审核 = 1; + public static final Integer 审核通过 = 2; + public static final Integer 审核失败 = 3; + + + /** + * 是否在线 + */ + public static final Integer 在线 = 1; + public static final Integer 离线 = 2; + + /** + * 用户类型 + */ + public static final Integer 设计师 = 1; + public static final Integer 表现师 = 2; + public static final Integer 销售 = 3; + public static final Integer 企业 = 4; + + + /** + * 是否默认 + */ + public static final Integer 非默认 = 1; + public static final Integer 默认 = 2; + + + /** + * 互动消息类型 + */ + public static class InteractionMessage { + /** + * 互动消息类型 + */ + public static final Integer 点赞 = 1; + public static final Integer 评论 = 2; + public static final Integer 关注 = 3; + + } + + /** + * 表现师接单 + */ + public static class OrderReceiving { + /** + * 接单状态 + */ + public static final Integer 等待接单 = 1; + public static final Integer 接单成功 = 2; + + public static final Integer 接单失败 = 3; + + } + + /** + * 申诉 + */ + public static class Appeal { + /** + * 申诉状态 + */ + public static final Integer 无申诉 = 1; + public static final Integer 申诉中 = 2; + public static final Integer 申诉完成 = 3; + + } + + /** + * 调价 + */ + public static class OrderChange { + /** + * 调价状态1 待确认 2 已确认 + */ + public static final Integer 待确认 = 1; + public static final Integer 已确认 = 2; + public static final Integer 拒绝 = 3; + + } + + /** + * 延期 + */ + public static class Extension { + /** + * 延期状态1 待确认 2 已确认 + */ + public static final Integer 取消 = -1; + public static final Integer 待确认 = 1; + public static final Integer 已确认 = 2; + public static final Integer 拒绝 = 3; + + } + + /** + * 消息 + */ + public static class Message { + /** + * 消息是否清空 + */ + public static final Integer 未清空 = 1; + public static final Integer 清空 = 2; + + + /** + * 是否已读 + */ + public static final Integer 未读 = 1; + public static final Integer 已读 = 2; + + /** + * 系统消息是否发布 + */ + public static final Integer 未发布 = 1; + public static final Integer 发布 = 2; + + /** + * 推送是否关闭 + */ + public static final Integer 未关闭 = 1; + public static final Integer 关闭 = 2; + + } + + + /** + * 帖子 + */ + public static class Post { + public static final Integer 分享数 = 1; + public static final Integer 点赞数 = 2; + public static final Integer 评论数 = 3; + public static final Integer 收藏数 = 4; + public static final Integer 浏览数 = 5; + } + + /** + * 帖子评论 + */ + public static class PostComment { + + public static final Integer 点赞数 = 1; + public static final Integer 评论数 = 2; + } + + /** + * 审核相关 + */ + public static class Process{ + /** + * 是否审核 + */ + public static final String 不用审核 = "1"; + public static final String 需要审核 = "2"; + + /** + * 是否是当前审批流程 + */ + public static final Integer 不是 = 1; + public static final Integer 是 = 2; + + + + /** + * 审核流程记录表中 is_end 字段 审批人类型 + */ + public static final Integer 发起人 = 0; + public static final Integer 中间审批人 = 1; + public static final Integer 最终审核人 = 2; + } + + + /** + * 优惠券 + */ + public static class Coupon { + + /** + * 1指定时间范围内有效;2 领取n天有效,3 不限时 + */ + public static final Integer 指定时间 = 1; + public static final Integer 领取几天有效= 2; + public static final Integer 不限时 = 3; + + + /** + * 是否使用优惠券 + */ + public static final Integer 未使用 = 1; + public static final Integer 使用= 2; + } + + + /** + * 商品 + */ + public static class Goods { + + /** + * 规格类型 + */ + public static final Integer 单规格 = 1; + public static final Integer 多规格= 2; + + } + + + + /** + * 支付 + */ + public static class Pay { + + /** + * 支付状态 + */ + public static final Integer 未支付 = 1; + public static final Integer 已支付 = 2; + + public static final Integer 支付失败 = 3; + + } + + + /** + * 钱包 + */ + public static class Wallet { + + /** + * 资金可提现状态 + */ + public static final Integer 可提现=1; + public static final Integer 不可提现=2; + public static final Integer 到账取消=3; + + } + + /** + * 保证金金额来源类型 + */ + public static class BondWith { + + /** + * 保证金金额来源类型 + */ + public static final Integer 缴纳=1; + public static final Integer 提现=2; + public static final Integer 提现返还=3; + public static final Integer 平台扣除=4; + public static final Integer 平台赠与=5; + + } + + + /** + * 售后 + */ + public static class Refund { + + /** + * 售后类型 + */ + public static final Integer 退款=1; + public static final Integer 退款退货=2; + + } + + + /** + * 订单 + */ + public static class Order { + + /** + * 订单类型 + */ + public static final Integer 订单=1; + + public static final Integer 商城订单=2; + + } + + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/code/PushConstant.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/code/PushConstant.java new file mode 100644 index 0000000..bd58354 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/code/PushConstant.java @@ -0,0 +1,28 @@ +package com.ruoyi.code; + +/** + * 推送类型 + * @author liwenlong + * @date 2023/2/11 15:36 + */ +public class PushConstant { + + + /** + * 系统消息 + */ + public static final Integer 系统消息 = 1; + + /** + * 商城订单消息 + */ + public static final Integer 商城订单消息 = 2; + + /** + * 互动消息 + */ + public static final Integer 互动消息 = 3; + + + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/code/Token.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/code/Token.java new file mode 100644 index 0000000..5ed7a46 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/code/Token.java @@ -0,0 +1,40 @@ +package com.ruoyi.code; + +/** + * @author liwenlong + * @date 2023/2/11 15:42 + */ + +public class Token { + + /** + * token 过期时间 + */ + public static long EXPIRE_SECOND = 7; + + /** + * redis里存储token信息 + */ + public static final String TOKEN_MAP = "TOKEN_MAP"; + + /** + * 用户 token 前缀 + */ + public static final String customer = "customer_"; + + /** + * 表现师 token 前缀 + */ + public static final String store = "store_"; + + /** + * 销售 token 前缀 + */ + public static final String sale = "sale_"; + + /** + * 企业 token 前缀 + */ + public static final String enterprise = "enterprise_"; + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/config/APPWebMvcConfig.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/config/APPWebMvcConfig.java new file mode 100644 index 0000000..851ee93 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/config/APPWebMvcConfig.java @@ -0,0 +1,29 @@ +//package com.ruoyi.config; +// +//import com.ruoyi.interceptor.LoginInterceptor; +//import org.springframework.context.annotation.Bean; +//import org.springframework.context.annotation.Configuration; +//import org.springframework.web.servlet.HandlerInterceptor; +//import org.springframework.web.servlet.config.annotation.InterceptorRegistry; +//import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; +// +//@Configuration +//public class APPWebMvcConfig implements WebMvcConfigurer { +// +// /** +// * 解决拦截器添加注解 +// * +// * @return +// */ +// @Bean +// public HandlerInterceptor getLoginInterceptor() { +// return new LoginInterceptor(); +// } +// +// @Override +// public void addInterceptors(InterceptorRegistry registry) { +// registry.addInterceptor(getLoginInterceptor()) +// .addPathPatterns("/api/**") +// .excludePathPatterns("/static/login.html"); +// } +//} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/config/WebMvcConfig.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/config/WebMvcConfig.java new file mode 100644 index 0000000..355a356 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/config/WebMvcConfig.java @@ -0,0 +1,82 @@ +/* +Copyright [2020] [https://www.stylefeng.cn] + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +Guns采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点: + +1.请不要删除和修改根目录下的LICENSE文件。 +2.请不要删除和修改Guns源码头部的版权声明。 +3.请保留源码和相关描述文件的项目出处,作者声明等。 +4.分发源码时候,请注明软件出处 https://gitee.com/stylefeng/guns-separation +5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://gitee.com/stylefeng/guns-separation +6.若您的项目无法满足以上几点,可申请商业授权,获取Guns商业授权许可,请在官网购买授权,地址为 https://www.stylefeng.cn + */ +package com.ruoyi.config; + +import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; +import com.ruoyi.interceptor.LoginInterceptor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.boot.autoconfigure.jackson.Jackson2ObjectMapperBuilderCustomizer; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Import; +import org.springframework.web.servlet.HandlerInterceptor; +import org.springframework.web.servlet.config.annotation.InterceptorRegistry; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; + +/** + * web配置 + * + * @author stylefeng + * @date 2020/4/11 10:23 + */ +@Configuration +@Slf4j +@Import({cn.hutool.extra.spring.SpringUtil.class}) +public class WebMvcConfig implements WebMvcConfigurer { + + /** + * 解决拦截器添加注解 + * + * @return + */ + @Bean + public HandlerInterceptor getLoginInterceptor() { + return new LoginInterceptor(); + } + + @Override + public void addInterceptors(InterceptorRegistry registry) { + registry.addInterceptor(getLoginInterceptor()) + .addPathPatterns("/api/**") + .excludePathPatterns("/static/login.html"); + } + + + /** + * json自定义序列化工具,long转string + * + * @author stylefeng + * @date 2020/5/28 14:48 + */ + @Bean + public Jackson2ObjectMapperBuilderCustomizer jackson2ObjectMapperBuilderCustomizer() { + return jacksonObjectMapperBuilder -> + jacksonObjectMapperBuilder + .serializerByType(Long.class, ToStringSerializer.instance) + .serializerByType(Long.TYPE, ToStringSerializer.instance); + } + + +} \ No newline at end of file diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/ApiAgreementController.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/ApiAgreementController.java new file mode 100644 index 0000000..577d95a --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/ApiAgreementController.java @@ -0,0 +1,61 @@ +package com.ruoyi.controller; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.ruoyi.common.core.domain.BaseEntity; +import com.ruoyi.common.core.domain.entity.SysDictData; +import com.ruoyi.frequency.agreement.entity.Agreement; +import com.ruoyi.frequency.agreement.service.AgreementService; +import com.ruoyi.response.ResponseData; +import com.ruoyi.vo.RyController; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +/** + * 协议 + * + * @author a + * @date 2023/8/18 15:28 + */ +@RestController +@RequestMapping("/api/agreement") +@Api(tags = "协议") +public class ApiAgreementController extends RyController { + + @Autowired + private AgreementService agreementService; + + @PostMapping("/getAgreement/{code}") + @ApiOperation(value = "获取协议", notes = "获取协议") + public ResponseData getAgreement(@PathVariable String code) { + Agreement agreement = agreementService.getOne(new QueryWrapper().lambda() + .eq(Agreement::getCode, code) + .orderByDesc(BaseEntity::getCreateTime).last("limit 1")); + return ResponseData.success(agreement); + } + + + @ResponseBody + @RequestMapping(value = "/getAgreementList/{codes}", method = RequestMethod.POST) + @ApiOperation(value = "获取协议多个") + public ResponseData> getAgreementList(@PathVariable String[] codes) { + List list = agreementService.list(new QueryWrapper().lambda() + .in(Agreement::getCode, codes) + .orderByDesc(BaseEntity::getCreateTime)); + return ResponseData.success(list); + } + + + @GetMapping("/agreementRichText/{code}") + @ApiOperation(value = "获取协议富文本", notes = "获取协议富文本") + public String agreementRichText(@PathVariable String code) { + Agreement agreement = agreementService.getOne(new QueryWrapper().lambda() + .eq(Agreement::getCode, code) + .orderByDesc(BaseEntity::getCreateTime).last("limit 1")); + return agreement == null? null : agreement.getContent(); + } + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/ApiAppMessageController.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/ApiAppMessageController.java new file mode 100644 index 0000000..5933ddc --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/ApiAppMessageController.java @@ -0,0 +1,58 @@ +package com.ruoyi.controller; + +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.ruoyi.annotations.UserLoginToken; +import com.ruoyi.common.page.PageResult; +import com.ruoyi.controller.req.AppMessageReadOrDeleteReq; +import com.ruoyi.controller.req.MessageReadOrDeleteReq; +import com.ruoyi.frequency.appmessage.entity.AppMessage; +import com.ruoyi.frequency.appmessage.service.AppMessageService; +import com.ruoyi.response.ResponseData; +import com.ruoyi.vo.BodyIdReq; +import com.ruoyi.vo.PageBasic; +import com.ruoyi.vo.RyController; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import javax.validation.Valid; + + +/** + * 消息中心 + * @author liwenlong + * + */ +@CrossOrigin +@RestController +@RequestMapping("/api/message") +@Api(tags = "消息中心") +public class ApiAppMessageController extends RyController { + + + @Autowired + private AppMessageService appMessageService; + + @UserLoginToken + @PostMapping("/messagePage") + @ApiOperation(value = "系统消息列表" , notes = "系统消息列表") + public ResponseData>> messagePage(@RequestBody @Valid PageBasic req) { + return this.appMessageService.messagePage(getUserVo(),req); + } + + @UserLoginToken + @PostMapping("/messageDetail") + @ApiOperation(value = "系统消息详情" , notes = "系统消息详情") + public ResponseData messageDetail(@RequestBody @Valid BodyIdReq req) { + return this.appMessageService.messageDetail(req.getId(),getUserVo()); + } + + @UserLoginToken + @PostMapping("/appMessageReadOrDelete") + @ApiOperation(value = "系统消息列表_已读,删除消息" , notes = "系统消息列表_已读,删除消息") + public ResponseData appMessageReadOrDelete(@RequestBody @Valid MessageReadOrDeleteReq req) { + return appMessageService.appMessageReadOrDelete(req, getUserVo()); + } + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/ApiAppVersionController.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/ApiAppVersionController.java new file mode 100644 index 0000000..92df96a --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/ApiAppVersionController.java @@ -0,0 +1,33 @@ +package com.ruoyi.controller; + +import com.ruoyi.frequency.appversion.service.AppVersionService; +import com.ruoyi.response.ResponseData; +import com.ruoyi.vo.RyController; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +/** + * 版本更新 + * + * @author a + * @date 2023/8/18 15:28 + */ + +@RestController +@CrossOrigin +@RequestMapping("/api/appVersion") +@Api(tags = "版本更新") +public class ApiAppVersionController extends RyController { + + @Autowired + private AppVersionService appVersionService; + + @PostMapping("/isUpgrade/{appType}") + @ApiOperation(value = "版本更新", notes = "版本更新") + public ResponseData isUpgrade(@PathVariable Integer appType) { + return appVersionService.isUpgrade(appType); + } + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/ApiBannerController.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/ApiBannerController.java new file mode 100644 index 0000000..6cdd722 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/ApiBannerController.java @@ -0,0 +1,76 @@ +package com.ruoyi.controller; + +import cn.hutool.core.util.ObjectUtil; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.ruoyi.code.PublicCommon; +import com.ruoyi.enums.user.UserEnums; +import com.ruoyi.frequency.banner.entity.Banner; +import com.ruoyi.frequency.banner.service.BannerService; +import com.ruoyi.frequency.customer.service.UserService; +import com.ruoyi.response.ResponseData; +import com.ruoyi.vo.BodyIdReq; +import com.ruoyi.vo.RyController; +import com.ruoyi.vo.UserInfo; +import com.ruoyi.vo.UserVo; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import javax.validation.Valid; +import javax.validation.constraints.NotNull; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.stream.Collectors; + +/** + * 轮播图 + */ +@CrossOrigin +@RestController +@RequestMapping("/api/banner") +@Api(tags = "轮播图") +public class ApiBannerController extends RyController { + + + @Autowired + private BannerService bannerService; + + @Autowired + private UserService userService; + + @PostMapping("/bannerList") + @ApiOperation(value = "轮播图", notes = "轮播图") + public ResponseData> bannerList(@RequestBody(required = false) Integer position) { + + List banners = bannerService.list(new QueryWrapper().lambda() + .eq(Banner::getDelFlag, PublicCommon.启用) + .eq(ObjectUtil.isNotEmpty(position), Banner::getPosition, position) + .orderByAsc(Banner::getSort) + ); + + if (!banners.isEmpty()){ + Set userVoSet = banners.stream().filter(s->s.getType() == 4 || s.getType() == 5) + .map(s -> new UserVo(s.getType() == 4? UserEnums.customer.getCode():UserEnums.store.getCode(), Long.valueOf(s.getContent()))) + .collect(Collectors.toSet()); + //查询用户信息 + Map userMap = userService.selectUserInfoMap(userVoSet,null); + + banners.stream().forEach(s ->{ + if (s.getType() == 4 || s.getType() == 5) { + s.setUserInfo(userMap.get(new UserVo(s.getType() == 4 ? UserEnums.customer.getCode() : UserEnums.store.getCode(), Long.valueOf(s.getContent())))); + } + }); + } + + return ResponseData.success(banners); + } + + @PostMapping("/detail") + @ApiOperation(value = "轮播图详情", notes = "轮播图详情") + public ResponseData detail(@Valid @NotNull(message = "id不能为空") @RequestBody BodyIdReq req) { + return ResponseData.success(this.bannerService.getById(req.getId())); + } + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/ApiBlockController.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/ApiBlockController.java new file mode 100644 index 0000000..5e72db6 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/ApiBlockController.java @@ -0,0 +1,84 @@ +package com.ruoyi.controller; + +import com.ruoyi.annotations.UserLoginToken; +import com.ruoyi.common.page.PageResult; +import com.ruoyi.controller.req.BlockPageReq; +import com.ruoyi.controller.req.BlockUserReq; +import com.ruoyi.controller.resp.BlockPageResp; +import com.ruoyi.frequency.block.service.BlockService; +import com.ruoyi.response.ResponseData; +import com.ruoyi.vo.RyController; +import io.swagger.annotations.Api; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import javax.validation.Valid; + +/** + * 拉黑用户 + */ +@CrossOrigin +@RestController +@RequestMapping("/api/block") +@Api(tags = "拉黑用户") +public class ApiBlockController extends RyController { + + @Autowired + private BlockService blockService; + + /** + * 拉黑 + * + * @return + */ + @PostMapping("/blockUser") + @UserLoginToken + public ResponseData blockUser(@Valid @RequestBody BlockUserReq req) { + return blockService.blockUser(req, getUserVo()); + } + + /** + * 拉黑(只用于拉黑) + * + * @return + */ + @PostMapping("/blockUserVersion2") + @UserLoginToken + public ResponseData blockUserVersion2(@Valid @RequestBody BlockUserReq req) { + return blockService.blockUserVersion2(req, getUserVo()); + } + + /** + * 取消拉黑(只用于取消拉黑) + * + * @return + */ + @PostMapping("/cancelBlockUserVersion2") + @UserLoginToken + public ResponseData cancelBlockUserVersion2(@Valid @RequestBody BlockUserReq req) { + return blockService.cancelBlockUserVersion2(req, getUserVo()); + } + + /** + * 拉黑列表 + * + * @param req + * @return + */ + @PostMapping("/blockPage") + public ResponseData> blockPage(@RequestBody BlockPageReq req) { + return blockService.blockPage(req, getUserVo()); + } + + /** + * 拉黑列表(别人查看) + * + * @param req + * @return + */ + @PostMapping("/otherBlockPage") + public ResponseData> otherBlockPage(@RequestBody BlockPageReq req) { + return blockService.otherBlockPage(req,getUserVo()); + } + +} \ No newline at end of file diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/ApiCLoginController.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/ApiCLoginController.java new file mode 100644 index 0000000..e5e82dd --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/ApiCLoginController.java @@ -0,0 +1,503 @@ +package com.ruoyi.controller; + +import cn.hutool.core.collection.CollectionUtil; +import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.StrUtil; +import cn.hutool.http.HttpRequest; +import cn.hutool.http.HttpUtil; +import com.alibaba.fastjson.JSONObject; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.ruoyi.annotations.UserLoginToken; +import com.ruoyi.code.PublicCommon; +import com.ruoyi.common.exception.enums.CoreExceptionEnum; +import com.ruoyi.controller.req.*; +import com.ruoyi.controller.resp.UserResultInfo; +import com.ruoyi.enums.user.UserEnums; +import com.ruoyi.frequency.customer.entity.Customer; +import com.ruoyi.frequency.customer.service.CustomerService; +import com.ruoyi.frequency.customer.service.UserService; +import com.ruoyi.frequency.enterprise.service.EnterpriseService; +import com.ruoyi.frequency.sale.entity.Sale; +import com.ruoyi.frequency.sale.service.SaleService; +import com.ruoyi.frequency.store.entity.Store; +import com.ruoyi.frequency.store.service.StoreService; +import com.ruoyi.response.ResponseData; +import com.ruoyi.utils.LoginUtil; +import com.ruoyi.vo.RyController; +import com.ruoyi.vo.UserInfo; +import com.ruoyi.vo.UserVo; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.web.bind.annotation.*; + +import javax.validation.Valid; +import javax.validation.constraints.NotEmpty; +import java.util.HashMap; +import java.util.Map; + +/** + * 登入相关 + * + * @author liwenlong + */ +@Slf4j +@CrossOrigin +@RestController +@RequestMapping("/api") +@Api(tags = "登入相关") +public class ApiCLoginController extends RyController { + + @Autowired + private LoginUtil loginUtil; + + @Autowired + private CustomerService customerService; + + @Autowired + private StoreService storeService; + + @Autowired + private SaleService saleService; + + + /** + * 注册 + * + * @param req + * @return + */ + @PostMapping("/register") + @ApiOperation(value = "注册") + public ResponseData register(@Valid @RequestBody RegisterUserReq req) { + return loginUtil.register(req); + } + + /** + * 忘记密码 + * + * @param req + * @return + */ + @RequestMapping(value = "/forgetPwd", method = RequestMethod.POST) + @ApiOperation(value = "忘记密码") + public ResponseData forgetPwd(@RequestBody @Valid UserForgetPwdLoginReq req) { + return loginUtil.forgetPwd(req); + } + + /** + * 修改密码 + * + * @param req + * @return + */ + @UserLoginToken + @RequestMapping(value = "/editPwd", method = RequestMethod.POST) + @ApiOperation(value = "修改密码") + public ResponseData editPwd(@RequestBody UserEditPwdLoginReq req) { + return loginUtil.editPwd(req, getUserVo()); + } + + /** + * 忘记支付密码 + * + * @param req + * @return + */ + @UserLoginToken + @RequestMapping(value = "/forgetPayPwd", method = RequestMethod.POST) + @ApiOperation(value = "忘记支付密码") + public ResponseData forgetPayPwd(@RequestBody @Valid UserForgetPwdLoginReq req) { + return loginUtil.forgetPayPwd(req, getUserVo()); + } + + /** + * 校验支付密码 + * + * @param pwd + * @return + */ + @UserLoginToken + @RequestMapping(value = "/checkPayPwd", method = RequestMethod.POST) + @ApiOperation(value = "校验支付密码") + public ResponseData checkPayPwd(@NotEmpty(message = "密码不能为空") @RequestBody String pwd) { + return loginUtil.checkPayPwd(pwd, getUserVo()); + } + + /** + * 修改支付密码 + * + * @param pwd + * @return + */ + @UserLoginToken + @RequestMapping(value = "/editPayPwd", method = RequestMethod.POST) + @ApiOperation(value = "修改支付密码") + public ResponseData editPayPwd(@NotEmpty(message = "密码不能为空") @RequestBody String pwd) { + return loginUtil.editPayPwd(pwd, getUserVo()); + } + + /** + * 退出 + * + * @return + */ + @UserLoginToken + @PostMapping("/logout") + @ApiOperation(value = "退出") + public ResponseData logout() { + return loginUtil.logout(getUserVo()); + } + + + /** + * 注销 + * + * @return + */ + @PostMapping("/cancellation") + @UserLoginToken + @ApiOperation(value = "注销") + public ResponseData cancellation() { + UserVo userVo = getUserVo(); + //判断是否可以注销 + if (UserEnums.customer.getCode().equals(userVo.getUserType())) { + customerService.canCancellation(userVo.getUserId()); + } else if (UserEnums.store.getCode().equals(userVo.getUserType())) { + storeService.canCancellation(userVo.getUserId()); + } + + return loginUtil.cancellation(userVo); + } + + /** + * 校验旧手机号 + * + * @param req + * @return + */ + @RequestMapping(value = "/checkOldMobile", method = RequestMethod.POST) + @ApiOperation(value = "校验旧手机号") + @UserLoginToken + public ResponseData checkOldMobile(@RequestBody @Valid CheckOldMobileReq req) { + return loginUtil.checkOldMobile(req, getUserVo()); + } + + + /** + * 换绑手机号 + * + * @param req + * @return + */ + @RequestMapping(value = "/changeBindingMobile", method = RequestMethod.POST) + @ApiOperation(value = "换绑手机号") + @UserLoginToken + public ResponseData changeBindingMobile(@RequestBody @Valid ChangeBindingMobileReq req) { + return loginUtil.changeBindingMobile(req, getUserVo()); + } + + + /** + * 对方 + * + * @param otherUserVo + * @return + */ + @RequestMapping(value = "/userRelationship", method = RequestMethod.POST) + @ApiOperation(value = "获取两个用户之间的关系") + @UserLoginToken + public ResponseData userRelationship(@RequestBody @Valid UserVo otherUserVo) { + return userService.userRelationship(otherUserVo, getUserVo()); + } + + + /** + * 修改用户信息 + * + * @return + */ + @UserLoginToken + @RequestMapping(value = "/editInfo", method = RequestMethod.POST) + @ApiOperation(value = "修改用户信息") + public ResponseData editInfo(@RequestBody UserEditReqVo req) { + + UserVo userVo = getUserVo(); + + //用户类型 1设计师 2表现师 3销售(推广员) + + if (ObjectUtil.equal(userVo.getUserType(), PublicCommon.设计师)) { + return customerService.editInfo(req, userVo); + } else if (ObjectUtil.equal(userVo.getUserType(), PublicCommon.表现师)) { + return storeService.editInfo(req, userVo); + } else if (ObjectUtil.equal(userVo.getUserType(), PublicCommon.销售)) { + return saleService.editInfo(req, userVo); + } else if (ObjectUtil.equal(userVo.getUserType(), PublicCommon.企业)) { + return enterpriseService.editInfo(req, userVo); + } + return ResponseData.error(CoreExceptionEnum.ERROR_PARAM); + + } + + + /** + * 个人信息 + * + * @return + */ + @UserLoginToken + @PostMapping("/info") + @ApiOperation(value = "个人信息", notes = "个人信息") + public ResponseData info() { + + UserVo userVo = getUserVo(); + + Map userVoUserInfoMap = userService.selectUserInfoMap(CollectionUtil.newHashSet(userVo), userVo); + + //用户类型 1设计师 2表现师 3销售(推广员) + if (ObjectUtil.equal(userVo.getUserType(), PublicCommon.设计师)) { + UserResultInfo userResultInfo = (UserResultInfo) customerService.info(userVo).getData(); + userResultInfo.setUserInfo(userVoUserInfoMap.get(userVo)); + return ResponseData.success(userResultInfo); + } else if (ObjectUtil.equal(userVo.getUserType(), PublicCommon.表现师)) { + Store store = (Store) storeService.info(userVo).getData(); + store.setUserInfo(userVoUserInfoMap.get(userVo)); + return ResponseData.success(store); + } else if (ObjectUtil.equal(userVo.getUserType(), PublicCommon.销售)) { + Sale sale = (Sale) saleService.info(userVo).getData(); + sale.setUserInfo(userVoUserInfoMap.get(userVo)); + return ResponseData.success(sale); + } else if (ObjectUtil.equal(userVo.getUserType(), PublicCommon.企业)) { + Store one = storeService.getOne(new QueryWrapper().lambda().eq(Store::getBindEnterpriseId, userVo.getUserId())); + + if (one == null) { + return ResponseData.error(700, "token过期"); + } + Store store = (Store) storeService.info(new UserVo(UserEnums.store.getCode(), one.getId())).getData(); + store.setUserInfo(userVoUserInfoMap.get(userVo)); + return ResponseData.success(store); + } + + return ResponseData.error(CoreExceptionEnum.ERROR_PARAM); + } + + @Autowired + private UserService userService; + + @Autowired + private EnterpriseService enterpriseService; + + /** + * 查看他人信息 + * + * @return + */ + @PostMapping("/otherInfo") + @ApiOperation(value = "查看他人信息", notes = "查看他人信息") + public ResponseData otherInfo(@RequestBody UserVo userVo) { + + UserVo userVo1 = getUserVo(); + Map userVoUserInfoMap = userService.selectUserInfoMap(CollectionUtil.newHashSet(userVo), userVo1); + //用户类型 1设计师 2表现师 3销售(推广员) + if (ObjectUtil.equal(userVo.getUserType(), PublicCommon.设计师)) { + UserResultInfo userResultInfo = (UserResultInfo) customerService.info(userVo).getData(); + userResultInfo.setUserInfo(userVoUserInfoMap.get(userVo)); + return ResponseData.success(userResultInfo); + } else if (ObjectUtil.equal(userVo.getUserType(), PublicCommon.表现师)) { + Store store = (Store) storeService.info(userVo).getData(); + store.setUserInfo(userVoUserInfoMap.get(userVo)); + return ResponseData.success(store); + } else if (ObjectUtil.equal(userVo.getUserType(), PublicCommon.销售)) { + Sale sale = (Sale) saleService.info(userVo).getData(); + sale.setUserInfo(userVoUserInfoMap.get(userVo)); + return ResponseData.success(sale); + } else if (ObjectUtil.equal(userVo.getUserType(), PublicCommon.企业)) { + Store one = storeService.getOne(new QueryWrapper().lambda().eq(Store::getBindEnterpriseId, userVo.getUserId())); + Store store = new Store(); + if (one != null) { + store = (Store) storeService.info(new UserVo(UserEnums.store.getCode(), one.getId())).getData(); + } else { + store.setEnterprise(enterpriseService.getById(userVo.getUserId())); + } + + store.setUserInfo(userVoUserInfoMap.get(userVo)); + return ResponseData.success(store); + } + + return ResponseData.error(CoreExceptionEnum.ERROR_PARAM); + } + + @Value("${wxpay.appid}") + private String appId; + + @Value("${wxpay.app-secret}") + private String appSecret; + + /** + * 获取wxopenId + * + * @return + */ + @PostMapping("/getWxOpenId") + @ApiOperation(value = "获取wxopenId", notes = "获取wxopenId") + public ResponseData getWxOpenId(@RequestBody String code) { + //2.判断是否授权成功 + if (StrUtil.isBlank(code)) { + log.info("-----------no shou quan!-------------------"); + return ResponseData.error("授权失败"); + } + + //4.获取access_token,以及通过token获取openid + String url = "https://api.weixin.qq.com/sns/oauth2/access_token" + + "?appid=" + appId + + "&secret=" + appSecret + + "&code=" + code + + "&grant_type=authorization_code"; + String result = HttpUtil.get(url); + log.info("请求获取的access_token值是:" + result); + JSONObject resultObject = JSONObject.parseObject(result); + System.out.println("-----" + JSONObject.toJSONString(resultObject)); + //获取openid + String unionid = (String) resultObject.get("unionid"); + return ResponseData.success(unionid); + } + + + @PostMapping("/getAppletOpenId/{type}") + @ApiOperation(value = "获取小程序openId", notes = "获取小程序openId") + public ResponseData getAppletOpenId(@PathVariable("type") String type, @RequestBody String code) { + if (code == null) { + return ResponseData.error("暂未授权!"); + } + + String appid = ""; + + String secret = ""; + + //type : DD_drawing DD画图, DD_co_creation DD共创 + if (ObjectUtil.equal(type, "DD_drawing")) { + appid = DD_drawingAppId; + + secret = DD_drawingSecret; + } else { + appid = DD_co_creationAppId; + + secret = DD_co_creationSecret; + } + + //1.通过code获取openId + String str = "https://api.weixin.qq.com/sns/jscode2session?appid=" + + appid + + "&secret=" + + secret + + "&js_code=" + + code + + "&grant_type=authorization_code"; + String result = HttpUtil.get(str); + + //判断是否获取成功 + if (ObjectUtil.isEmpty(result)) { + return ResponseData.error("获取参数错误"); + } + JSONObject jsonObject = JSONObject.parseObject(result); + //System.out.println("-----" + JSONObject.toJSONString(jsonObject)); + //String unionid = (String) jsonObject.get("unionid"); + return ResponseData.success(jsonObject); + } + + @PostMapping("/getAppletMobile/{type}") + @ApiOperation(value = "获取小程序手机号", notes = "获取小程序手机号") + public ResponseData getAppletMobile(@PathVariable("type") String type, @RequestBody String code) { + if (code == null) { + return ResponseData.error("暂未授权!"); + } + + //1.通过code获取手机号 + String str = "https://api.weixin.qq.com/wxa/business/getuserphonenumber?access_token=" + getToken(type); + Map bodyMap = new HashMap<>(); + bodyMap.put("code", code); + String result = HttpUtil.createPost(str).body(JSONObject.toJSONString(bodyMap)).execute().body(); + + System.out.println(result); + //判断是否获取成功 + if (ObjectUtil.isEmpty(result)) { + return ResponseData.error("获取参数错误"); + } + JSONObject jsonObject = JSONObject.parseObject(result); + Map map = (Map) jsonObject.get("phone_info"); + return ResponseData.success(map); + } + + + //https://api.weixin.qq.com/wxa/business/getuserphonenumber?access_token=ACCESS_TOKEN + + @Value("${DD_drawing.appid}") + private String DD_drawingAppId; + + @Value("${DD_drawing.secret}") + private String DD_drawingSecret; + + @Value("${DD_co_creation.appid}") + private String DD_co_creationAppId; + + @Value("${DD_co_creation.secret}") + private String DD_co_creationSecret; + + /** + * 获取access_token + * + * @return + */ + public String getToken(String type) { + + String appid = ""; + + String secret = ""; + + //type : DD_drawing DD画图, DD_co_creation DD共创 + if (ObjectUtil.equal(type, "DD_drawing")) { + appid = DD_drawingAppId; + + secret = DD_drawingSecret; + } else { + appid = DD_co_creationAppId; + + secret = DD_co_creationSecret; + } + + String url = "https://api.weixin.qq.com/cgi-bin/token" + "?grant_type=" + "client_credential" + "&appid=" + appid + "&secret=" + secret; + String result = HttpRequest.get(url).execute().body(); + System.err.println(result); + JSONObject jsonObject = JSONObject.parseObject(result); + //服务断了status会有值 + Integer errcode = (Integer) jsonObject.get("errcode"); + if (errcode == null) { + String access_token = (String) jsonObject.get("access_token"); + return access_token; + } else { + log.info("获取access_token失败:{}", jsonObject.toJSONString()); + } + return ""; + } + + public static void main(String[] args) { + //Map map = new HashMap<>(); + //map.put("code", "554547887"); + //System.out.println(JSONObject.toJSONString(map)); + + String url = "https://api.weixin.qq.com/cgi-bin/token" + "?grant_type=" + "client_credential" + "&appid=" + "wxed96e8fe10ea8992" + "&secret=" + "5a1da24f97e49aa5762897045dd593b6"; + String result = HttpRequest.get(url).execute().body(); + System.err.println(result); + JSONObject jsonObject = JSONObject.parseObject(result); + //服务断了status会有值 + Integer errcode = (Integer) jsonObject.get("errcode"); + if (errcode == null) { + String access_token = (String) jsonObject.get("access_token"); + System.out.printf(access_token); + } else { + log.info("获取access_token失败:{}", jsonObject.toJSONString()); + } + } +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/ApiDictController.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/ApiDictController.java new file mode 100644 index 0000000..aa8b30b --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/ApiDictController.java @@ -0,0 +1,72 @@ +package com.ruoyi.controller; + +import cn.hutool.core.collection.CollectionUtil; +import com.ruoyi.common.core.domain.entity.SysDictData; +import com.ruoyi.controller.req.WorksPageReq; +import com.ruoyi.response.ResponseData; +import com.ruoyi.system.service.ISysDictDataService; +import com.ruoyi.vo.RyController; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import javax.validation.Valid; +import javax.validation.constraints.NotBlank; +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Collectors; + + +/** + * 字典值查询 + */ +@Slf4j +@RestController +@RequestMapping("/api/dict") +@Api(tags = "字典值查询") +public class ApiDictController extends RyController { + + @Autowired + private ISysDictDataService iSysDictDataService; + + /** + * 字典表详情 + * @param code + * @return + */ + @ResponseBody + @RequestMapping(value = "/fineOne", method = RequestMethod.POST) + @ApiOperation(value = "字典表详情") + public ResponseData fineOne(@RequestParam("code") @Valid @NotBlank(message = "code值不能为空") String code) { + + SysDictData sysDictData = new SysDictData(); + sysDictData.setCode(code); + sysDictData.setStatus("0"); + List list = iSysDictDataService.selectDictDataList(sysDictData); + return ResponseData.success(list.isEmpty()?null:list.get(0)); + } + + /** + * 字典表下级 + * @param code + * @return + */ + @ResponseBody + @RequestMapping(value = "/fineList", method = RequestMethod.POST) + @ApiOperation(value = "字典表下级") + public ResponseData> fineList(@RequestParam("code") @Valid @NotBlank(message = "code值不能为空") String code) { + SysDictData sysDictData = new SysDictData(); + sysDictData.setDictType(code); + sysDictData.setStatus("0"); + List list = iSysDictDataService.selectDictDataList(sysDictData); + return ResponseData.success(list); + } + + + + +} + + diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/ApiIllegalDeductionRecordController.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/ApiIllegalDeductionRecordController.java new file mode 100644 index 0000000..38b542e --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/ApiIllegalDeductionRecordController.java @@ -0,0 +1,49 @@ +package com.ruoyi.controller; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.ruoyi.annotations.UserLoginToken; +import com.ruoyi.common.core.domain.BaseEntity; +import com.ruoyi.common.core.domain.entity.SysDictData; +import com.ruoyi.controller.req.MonthReq; +import com.ruoyi.frequency.agreement.entity.Agreement; +import com.ruoyi.frequency.agreement.service.AgreementService; +import com.ruoyi.frequency.illegaldeductionrecord.entity.IllegalDeductionRecord; +import com.ruoyi.frequency.illegaldeductionrecord.service.IllegalDeductionRecordService; +import com.ruoyi.response.ResponseData; +import com.ruoyi.vo.BodyIdReq; +import com.ruoyi.vo.RyController; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +/** + * 扣款 + * + * @author a + * @date 2023/8/18 15:28 + */ +@RestController +@RequestMapping("/api/illegalDeductionRecord") +@Api(tags = "扣款") +public class ApiIllegalDeductionRecordController extends RyController { + + @Autowired + private IllegalDeductionRecordService illegalDeductionRecordService; + + @PostMapping("/getPage") + @UserLoginToken + @ApiOperation(value = "扣款列表", notes = "扣款列表") + public ResponseData getPage(@RequestBody MonthReq req) { + return ResponseData.success(illegalDeductionRecordService.getPage(req,getUserVo())); + } + + @PostMapping("/detail") + @UserLoginToken + @ApiOperation(value = "扣款详情", notes = "扣款详情") + public ResponseData detail(@RequestBody BodyIdReq req) { + return ResponseData.success(illegalDeductionRecordService.detail(req,getUserVo())); + } +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/ApiIntegralController.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/ApiIntegralController.java new file mode 100644 index 0000000..f8437a8 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/ApiIntegralController.java @@ -0,0 +1,40 @@ +package com.ruoyi.controller; + +import com.ruoyi.annotations.UserLoginToken; +import com.ruoyi.common.page.PageResult; +import com.ruoyi.controller.resp.IntegralPageResp; +import com.ruoyi.frequency.integralrecord.service.IntegralRecordService; +import com.ruoyi.response.ResponseData; +import com.ruoyi.vo.PageBasic; +import com.ruoyi.vo.RyController; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RestController; + + +/** + * 积分 + */ +@Slf4j +@RestController +@RequestMapping("/api/integral") +@Api(tags = "积分") +public class ApiIntegralController extends RyController { + + @Autowired + private IntegralRecordService integralRecordService; + + @UserLoginToken + @RequestMapping(value = "/integralPage", method = RequestMethod.POST) + @ApiOperation(value = "积分明细") + public ResponseData> integralPage(@RequestBody PageBasic req) { + return integralRecordService.integralPage(req, getUserVo()); + } +} + + diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/ApiLoginController.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/ApiLoginController.java new file mode 100644 index 0000000..bd12ccf --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/ApiLoginController.java @@ -0,0 +1,283 @@ +package com.ruoyi.controller; + + +import cn.hutool.core.util.ObjectUtil; +import com.alibaba.fastjson.JSONObject; +import com.ruoyi.common.exception.enums.CoreExceptionEnum; +import com.ruoyi.controller.req.LoginReqVo; +import com.ruoyi.enums.LoginEnums; +import com.ruoyi.enums.sms.SmsEnums; +import com.ruoyi.response.ResponseData; +import com.ruoyi.utils.BusinessUtil; +import com.ruoyi.utils.JudgeLogicUtil; +import com.ruoyi.vo.UserVo; +import io.swagger.annotations.Api; +import lombok.extern.slf4j.Slf4j; +import org.apache.http.HttpEntity; +import org.apache.http.HttpStatus; +import org.apache.http.StatusLine; +import org.apache.http.client.methods.CloseableHttpResponse; +import org.apache.http.client.methods.HttpPost; +import org.apache.http.entity.StringEntity; +import org.apache.http.impl.client.CloseableHttpClient; +import org.apache.http.impl.client.HttpClients; +import org.apache.http.util.EntityUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.data.redis.core.StringRedisTemplate; +import org.springframework.web.bind.annotation.*; + +import javax.crypto.Cipher; +import java.io.IOException; +import java.security.KeyFactory; +import java.security.PrivateKey; +import java.security.spec.PKCS8EncodedKeySpec; +import java.util.Base64; + +/** + * 登陆类 + * @author liwenlong + */ +@Slf4j +@CrossOrigin +@RestController +@RequestMapping("/api") +@Api(tags = "登录类") +public class ApiLoginController { + + + @Value("${decryptPhone.url}") + private String url; + + @Value("${decryptPhone.app_key}") + private String app_key; + + @Value("${decryptPhone.master_Key}") + private String master_Key; + + @Value("${decryptPhone.private_key}") + private String private_key; + + + @Autowired + private BusinessUtil businessUtil; + + @Autowired + private JudgeLogicUtil judgeLogicUtil; + + @Autowired + private StringRedisTemplate redisTemplate; + + + /** + * 登陆 + * + * @return + */ + @PostMapping("/login") + public ResponseData login(@RequestBody LoginReqVo loginReqVo) { + + //登录方式 1 验证码 2 密码 3 一键登录 4 微信登录 5 小程序登录 6 苹果登录 + switch (LoginEnums.getLoginEnums(loginReqVo.getType())) { + case code_login: + return codeLogin(loginReqVo); + case pwd_login: + return pwdLogin(loginReqVo); + case one_click_login: + return oneClickLogin(loginReqVo); + case wechat_login: + return wxChatOpenidLogin(loginReqVo); + case applet_login: + return wechatAppletOpenid(loginReqVo); + case apple_login: + return appleOpenidLogin(loginReqVo); + default: + return ResponseData.error(CoreExceptionEnum.ERROR_PARAM); + } + } + + /** + * 验证码登入 + * + * @param loginReqVo + * @return + */ + private ResponseData codeLogin(LoginReqVo loginReqVo) { + + //验证码——验证 + businessUtil.checkCode(loginReqVo.getCode(), SmsEnums.LOGIN, loginReqVo.getAreaCode(),loginReqVo.getAccount(), loginReqVo.getUserType()); + + //验证登入账号 + Long userId = judgeLogicUtil.checkLoginUser(loginReqVo); + + return businessUtil.getToken(userId, loginReqVo.getUserType()); + } + + + /** + * 密码 + * + * @param loginReqVo + * @return + */ + private ResponseData pwdLogin(LoginReqVo loginReqVo) { + //验证登入账号 + Long userId = judgeLogicUtil.checkLoginUser(loginReqVo); + + //验证密码 + if (!businessUtil.loginPwdTrue(new UserVo(loginReqVo.getUserType(),userId), loginReqVo.getPassword())) { + return ResponseData.error(CoreExceptionEnum.PWD_ERROR); + } + return businessUtil.getToken(userId, loginReqVo.getUserType()); + } + + + /** + * 一键登入 + * + * @param loginReqVo + * @return + */ + private ResponseData oneClickLogin(LoginReqVo loginReqVo) { + + // 获取并解密手机号 + String phone = decryptPhone(loginReqVo.getLoginToken()); + loginReqVo.setMobile(phone); + + //验证登入账号 + Long userId = judgeLogicUtil.checkLoginUser(loginReqVo); + + return businessUtil.getToken(userId, loginReqVo.getUserType()); + } + + + /** + * 微信登入 + * + * @param loginReqVo + * @return + */ + private ResponseData wxChatOpenidLogin(LoginReqVo loginReqVo) { + + if (ObjectUtil.isNotEmpty(loginReqVo.getCode())) { + //验证码——验证 + businessUtil.checkCode(loginReqVo.getCode(), SmsEnums.WX_LOGIN_BIND, loginReqVo.getAreaCode(),loginReqVo.getMobile(), loginReqVo.getUserType()); + } + + //验证登入账号, + Long userId = judgeLogicUtil.checkLoginUser(loginReqVo); + + return businessUtil.getToken(userId, loginReqVo.getUserType()); + } + + /** + * 微信小程序登入 + * + * @param loginReqVo + * @return + */ + private ResponseData wechatAppletOpenid(LoginReqVo loginReqVo) { + + if (ObjectUtil.isNotEmpty(loginReqVo.getAccount())) { + //验证码——验证 + businessUtil.checkCode(loginReqVo.getCode(), SmsEnums.WX_APPLET_LOGIN_BIND, loginReqVo.getAreaCode(),loginReqVo.getMobile(), loginReqVo.getUserType()); + } + + //验证登入账号, + Long userId = judgeLogicUtil.checkLoginUser(loginReqVo); + + return businessUtil.getToken(userId, loginReqVo.getUserType()); + } + + /** + * 苹果登入 + * + * @param loginReqVo + * @return + */ + private ResponseData appleOpenidLogin(LoginReqVo loginReqVo) { + + if (ObjectUtil.isNotEmpty(loginReqVo.getAccount())) { + //验证码——验证 + businessUtil.checkCode(loginReqVo.getCode(), SmsEnums.LOGIN, loginReqVo.getAreaCode(),loginReqVo.getMobile(), loginReqVo.getUserType()); + } + + //验证登入账号, + Long userId = judgeLogicUtil.checkLoginUser(loginReqVo); + + + + return businessUtil.getToken(userId, loginReqVo.getUserType()); + } + + + /** + * 获取并解密手机号 + * + * @param loginToken + * @return + */ + private String decryptPhone(String loginToken) { + try { + JSONObject jsonObject = new JSONObject(); + jsonObject.put("loginToken", loginToken); + JSONObject jsonObject1 = JSONObject.parseObject((doPostForJpush(jsonObject.toString()))); + System.out.println("code==" + jsonObject1.getInteger("code")); + System.out.println("phone==" + jsonObject1.getString("phone")); + if (8000 == jsonObject1.getInteger("code")) { + PKCS8EncodedKeySpec keySpec = new PKCS8EncodedKeySpec(Base64.getDecoder().decode(private_key)); + PrivateKey privateKey = KeyFactory.getInstance("RSA").generatePrivate(keySpec); + Cipher cipher = Cipher.getInstance("RSA"); + cipher.init(Cipher.DECRYPT_MODE, privateKey); + byte[] b = Base64.getDecoder().decode(jsonObject1.getString("phone")); + System.out.println("解密后phone==" + new String(cipher.doFinal(b))); + return new String(cipher.doFinal(b)); + } + } catch (Exception e) { + e.printStackTrace(); + } + + return null; + } + + private String doPostForJpush(String JSONBody) { + CloseableHttpClient httpClient = HttpClients.createDefault(); + HttpPost httpPost = new HttpPost(url); + httpPost.setHeader("Authorization", "Basic " + new String(Base64.getEncoder().encode((app_key + ":" + master_Key).getBytes()))); + StringEntity entity = new StringEntity(JSONBody, "UTF-8"); + entity.setContentType("application/json"); + httpPost.setEntity(entity); + CloseableHttpResponse response = null; + try { + response = httpClient.execute(httpPost); + StatusLine status = response.getStatusLine(); + int state = status.getStatusCode(); + if (state == HttpStatus.SC_OK) { + HttpEntity responseEntity = response.getEntity(); + String jsonString = EntityUtils.toString(responseEntity, "UTF-8"); + return jsonString; + } else { + HttpEntity responseEntity = response.getEntity(); + String jsonString = EntityUtils.toString(responseEntity); + System.out.println(jsonString); + } + } catch (IOException e) { + e.printStackTrace(); + } finally { + if (response != null) { + try { + response.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + try { + httpClient.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + return null; + } + +} \ No newline at end of file diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/ApiOcsController.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/ApiOcsController.java new file mode 100644 index 0000000..96b60ef --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/ApiOcsController.java @@ -0,0 +1,324 @@ +package com.ruoyi.controller; + +import com.ruoyi.common.core.domain.entity.SysDictData; +import com.ruoyi.common.cos.auth.COSSigner; +import com.ruoyi.response.ResponseData; +import com.ruoyi.system.service.ISysDictDataService; +import com.tencent.cloud.CosStsClient; +import com.tencent.cloud.Policy; +import com.tencent.cloud.Response; +import com.tencent.cloud.Statement; +import com.tencent.cloud.cos.util.Jackson; +import io.swagger.annotations.Api; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.codec.binary.Base64; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import javax.validation.constraints.NotBlank; +import java.text.SimpleDateFormat; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.TreeMap; + +/** + * @Author OCS + * @Date 2022/2/8 16:40 + */ +@CrossOrigin +@RestController +@Slf4j +@RequestMapping("/api/cos") +@Api(tags = "OCS") +public class ApiOcsController { + + + @Autowired + private ISysDictDataService iSysDictDataService; + + // 根据 github 提供的 maven 集成方法导入 java sts sdk,使用 3.1.1 及更高版本 + public static void main(String[] args) { + TreeMap config = new TreeMap(); + try { + //这里的 SecretId 和 SecretKey 代表了用于申请临时密钥的永久身份(主账号、子账号等),子账号需要具有操作存储桶的权限。 + String secretKey = "VXZWQPYaedvMC6vovAU3gJ1ogXXdvO1n"; + String secretId = "AKIDSBQuX5mAZvHa2jNwSzWE0lNvNuMjA9gC"; + + String region = "ap-shanghai"; + String bucket = "ddht-1324395003"; + // 替换为您的云 api 密钥 SecretId + config.put("secretId", secretId); + // 替换为您的云 api 密钥 SecretKey + config.put("secretKey", secretKey); + + // 初始化 policy + Policy policy = new Policy(); + + // 设置域名: + // 如果您使用了腾讯云 cvm,可以设置内部域名 + //config.put("host", "sts.internal.tencentcloudapi.com"); + + // 临时密钥有效时长,单位是秒,默认 1800 秒,目前主账号最长 2 小时(即 7200 秒),子账号最长 36 小时(即 129600)秒 + config.put("durationSeconds", 1800); + // 换成您的 bucket + config.put("bucket", bucket); + // 换成 bucket 所在地区 + config.put("region", region); + + // 开始构建一条 statement + Statement statement = new Statement(); + // 声明设置的结果是允许操作 + statement.setEffect("allow"); + /** + * 密钥的权限列表。必须在这里指定本次临时密钥所需要的权限。 + * 权限列表请参见 https://cloud.tencent.com/document/product/436/31923 + * 规则为 {project}:{interfaceName} + * project : 产品缩写 cos相关授权为值为cos,数据万象(数据处理)相关授权值为ci + * 授权所有接口用*表示,例如 cos:*,ci:* + * 添加一批操作权限 : + */ + statement.addActions(new String[]{ + "cos:PutObject", + // 表单上传、小程序上传 + "cos:PostObject", + // 分块上传 + "cos:InitiateMultipartUpload", + "cos:ListMultipartUploads", + "cos:ListParts", + "cos:UploadPart", + "cos:CompleteMultipartUpload", + // 处理相关接口一般为数据万象产品 权限中以ci开头 + // 创建媒体处理任务 + "ci:CreateMediaJobs", + // 文件压缩 + "ci:CreateFileProcessJobs" + }); + + /** + * 这里改成允许的路径前缀,可以根据自己网站的用户登录态判断允许上传的具体路径 + * 资源表达式规则分对象存储(cos)和数据万象(ci)两种 + * 数据处理、审核相关接口需要授予ci资源权限 + * cos : qcs::cos:{region}:uid/{appid}:{bucket}/{path} + * ci : qcs::ci:{region}:uid/{appid}:bucket/{bucket}/{path} + * 列举几种典型的{path}授权场景: + * 1、允许访问所有对象:"*" + * 2、允许访问指定的对象:"a/a1.txt", "b/b1.txt" + * 3、允许访问指定前缀的对象:"a*", "a/*", "b/*" + * 如果填写了“*”,将允许用户访问所有资源;除非业务需要,否则请按照最小权限原则授予用户相应的访问权限范围。 + * + * 示例:授权examplebucket-1250000000 bucket目录下的所有资源给cos和ci 授权两条Resource + */ + statement.addResources(new String[]{ + "qcs::cos:" + region + ":uid/" + bucket.split("-")[1] + ":" + bucket + "/*", + "qcs::ci:" + region + ":uid/" + bucket.split("-")[1] + ":bucket/" + bucket + "/*"}); + +// String secretKey = "VXZWQPYaedvMC6vovAU3gJ1ogXXdvO1n"; +// String secretId = "AKIDSBQuX5mAZvHa2jNwSzWE0lNvNuMjA9gC"; +// +// String region = "ap-shanghai"; +// String bucket = "ddht-1324395003"; + statement.addResources(new String[]{ + "qcs::cos:ap-shanghai:uid/1324395003:ddht-1324395003/*", + "qcs::ci:ap-shanghai:uid/1324395003:bucket/ddht-1324395003/*"}); + + // 把一条 statement 添加到 policy + // 可以添加多条 + policy.addStatement(statement); + // 将 Policy 示例转化成 String,可以使用任何 json 转化方式,这里是本 SDK 自带的推荐方式 + config.put("policy", Jackson.toJsonPrettyString(policy)); + + Response response = CosStsClient.getCredential(config); + System.out.println(response.credentials.tmpSecretId); + System.out.println(response.credentials.tmpSecretKey); + System.out.println(response.credentials.sessionToken); + } catch (Exception e) { + e.printStackTrace(); + throw new IllegalArgumentException("no valid secret !"); + } + } + + + + // 根据 github 提供的 maven 集成方法导入 java sts sdk,使用 3.1.1 及更高版本 + @PostMapping("/signNew") + public ResponseData signNew() { + + TreeMap config = new TreeMap(); + try { + + String secretKey = "VXZWQPYaedvMC6vovAU3gJ1ogXXdvO1n"; + String secretId = "AKIDSBQuX5mAZvHa2jNwSzWE0lNvNuMjA9gC"; + + String region = "ap-shanghai"; + String bucket = "ddht-1324395003"; + + SysDictData sysDictData = new SysDictData(); + sysDictData.setDictType("storing_param"); + List list = iSysDictDataService.selectDictDataList(sysDictData); + for (SysDictData data : list) { + if ("Region".equals(data.getCode())) { + region = data.getDictValue(); + } + if ("Bucket".equals(data.getCode())) { + bucket = data.getDictValue(); + } + if ("SecretKey".equals(data.getCode())) { + secretKey = data.getDictValue(); + } + if ("SecretId".equals(data.getCode())) { + secretId = data.getDictValue(); + } + } + // 替换为您的云 api 密钥 SecretId + config.put("secretId", secretId); + // 替换为您的云 api 密钥 SecretKey + config.put("secretKey", secretKey); + + // 初始化 policy + Policy policy = new Policy(); + + // 设置域名: + // 如果您使用了腾讯云 cvm,可以设置内部域名 + //config.put("host", "sts.internal.tencentcloudapi.com"); + + // 临时密钥有效时长,单位是秒,默认 1800 秒,目前主账号最长 2 小时(即 7200 秒),子账号最长 36 小时(即 129600)秒 + config.put("durationSeconds", 1800); + // 换成您的 bucket + config.put("bucket", bucket); + // 换成 bucket 所在地区 + config.put("region", region); + + // 开始构建一条 statement + Statement statement = new Statement(); + // 声明设置的结果是允许操作 + statement.setEffect("allow"); + /** + * 密钥的权限列表。必须在这里指定本次临时密钥所需要的权限。 + * 权限列表请参见 https://cloud.tencent.com/document/product/436/31923 + * 规则为 {project}:{interfaceName} + * project : 产品缩写 cos相关授权为值为cos,数据万象(数据处理)相关授权值为ci + * 授权所有接口用*表示,例如 cos:*,ci:* + * 添加一批操作权限 : + */ + statement.addActions(new String[]{ + "cos:PutObject", + // 表单上传、小程序上传 + "cos:PostObject", + // 分块上传 + "cos:InitiateMultipartUpload", + "cos:ListMultipartUploads", + "cos:ListParts", + "cos:UploadPart", + "cos:CompleteMultipartUpload", + // 处理相关接口一般为数据万象产品 权限中以ci开头 + // 创建媒体处理任务 + "ci:CreateMediaJobs", + // 文件压缩 + "ci:CreateFileProcessJobs" + }); + + /** + * 这里改成允许的路径前缀,可以根据自己网站的用户登录态判断允许上传的具体路径 + * 资源表达式规则分对象存储(cos)和数据万象(ci)两种 + * 数据处理、审核相关接口需要授予ci资源权限 + * cos : qcs::cos:{region}:uid/{appid}:{bucket}/{path} + * ci : qcs::ci:{region}:uid/{appid}:bucket/{bucket}/{path} + * 列举几种典型的{path}授权场景: + * 1、允许访问所有对象:"*" + * 2、允许访问指定的对象:"a/a1.txt", "b/b1.txt" + * 3、允许访问指定前缀的对象:"a*", "a/*", "b/*" + * 如果填写了“*”,将允许用户访问所有资源;除非业务需要,否则请按照最小权限原则授予用户相应的访问权限范围。 + * + * 示例:授权examplebucket-1250000000 bucket目录下的所有资源给cos和ci 授权两条Resource + */ + statement.addResources(new String[]{ + "qcs::cos:" + region + ":uid/" + bucket.split("-")[1] + ":" + bucket + "/*", + "qcs::ci:" + region + ":uid/" + bucket.split("-")[1] + ":bucket/" + bucket + "/*"}); + + // 把一条 statement 添加到 policy + // 可以添加多条 + policy.addStatement(statement); + // 将 Policy 示例转化成 String,可以使用任何 json 转化方式,这里是本 SDK 自带的推荐方式 + config.put("policy", Jackson.toJsonPrettyString(policy)); + + Response response = CosStsClient.getCredential(config); + System.out.println(response.credentials.tmpSecretId); + System.out.println(response.credentials.tmpSecretKey); + System.out.println(response.credentials.sessionToken); + return ResponseData.success(response); + } catch (Exception e) { + e.printStackTrace(); + throw new IllegalArgumentException("no valid secret !"); + } + + } + + @PostMapping("/sign") + public ResponseData sign(@RequestParam(value = "name") @NotBlank(message = "文件名称不能为空") String name) { + + String region = "ap-shanghai"; + String bucket = "ddht-1324395003"; + String secretKey = "VXZWQPYaedvMC6vovAU3gJ1ogXXdvO1n"; + String secretId = "AKIDSBQuX5mAZvHa2jNwSzWE0lNvNuMjA9gC"; + + SysDictData sysDictData = new SysDictData(); + sysDictData.setDictType("storing_param"); + List list = iSysDictDataService.selectDictDataList(sysDictData); + for (SysDictData data : list) { + if ("Region".equals(data.getCode())) { + region = data.getDictValue(); + } + if ("Bucket".equals(data.getCode())) { + bucket = data.getDictValue(); + } + if ("SecretKey".equals(data.getCode())) { + secretKey = data.getDictValue(); + } + if ("SecretId".equals(data.getCode())) { + secretId = data.getDictValue(); + } + } + + long startTimestamp = System.currentTimeMillis() / 1000; + long endTimestamp = startTimestamp + 30 * 60; + String endTimestampStr = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"). + format(endTimestamp * 1000); + String keyTime = startTimestamp + ";" + endTimestamp; + String boundary = "----WebKitFormBoundaryZBPbaoYE2gqeB21N"; + // 设置表单的body字段值 + Map formFields = new HashMap<>(); + formFields.put("q-sign-algorithm", "sha1"); + formFields.put("key", name); + formFields.put("q-ak", secretId); + formFields.put("q-key-time", keyTime); + // 构造policy,参考文档: https://cloud.tencent.com/document/product/436/14690 + String policy = "{\n" + + " \"expiration\": \"" + endTimestampStr + "\",\n" + + " \"conditions\": [\n" + + " { \"bucket\": \"" + bucket + "\" },\n" + + " { \"q-sign-algorithm\": \"sha1\" },\n" + + " { \"q-ak\": \"" + secretId + "\" },\n" + + " { \"q-sign-time\":\"" + keyTime + "\" }\n" + + " ]\n" + + "}"; + // policy需要base64后算放入表单中 + String encodedPolicy = new String(Base64.encodeBase64(policy.getBytes())); + // 设置policy + formFields.put("policy", encodedPolicy); + // 根据编码后的policy和secretKey计算签名 + COSSigner cosSigner = new COSSigner(); + String signature = cosSigner.buildPostObjectSignature(secretKey, + keyTime, policy); + // 设置签名 + formFields.put("q-signature", signature); + String urlStr = "https://" + bucket + ".cos." + region + ".myqcloud.com"; + formFields.put("host", urlStr); + formFields.put("bucket", bucket); + formFields.put("region", region); + formFields.put("secretId", secretId); + formFields.put("secretKey", secretKey); + return ResponseData.success(formFields); + } + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/ApiRefereeUserController.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/ApiRefereeUserController.java new file mode 100644 index 0000000..d1489ca --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/ApiRefereeUserController.java @@ -0,0 +1,33 @@ +package com.ruoyi.controller; + +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.ruoyi.common.page.PageResult; +import com.ruoyi.controller.resp.RefereeUserPageResp; +import com.ruoyi.frequency.refereeuser.service.RefereeUserService; +import com.ruoyi.response.ResponseData; +import com.ruoyi.vo.PageBasic; +import com.ruoyi.vo.RyController; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +/** + * 邀请用户 + */ +@CrossOrigin +@RestController +@RequestMapping("/api/refereeUser") +@Api(tags = "邀请用户") +public class ApiRefereeUserController extends RyController { + + @Autowired + private RefereeUserService refereeUserService; + + @PostMapping("/refereeUserPage") + @ApiOperation(value = "邀请用户列表", notes = "邀请用户列表") + public ResponseData>> refereeUserPage(@RequestBody PageBasic req) { + return refereeUserService.refereeUserPage(req, getUserVo()); + } + +} \ No newline at end of file diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/ApiReportController.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/ApiReportController.java new file mode 100644 index 0000000..e98f145 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/ApiReportController.java @@ -0,0 +1,34 @@ +package com.ruoyi.controller; + +import com.ruoyi.annotations.UserLoginToken; +import com.ruoyi.controller.req.ReportReq; +import com.ruoyi.frequency.report.service.ReportService; +import com.ruoyi.response.ResponseData; +import com.ruoyi.vo.RyController; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + + +/** + * 举报用户相关 + * @author liwenlong + * + */ +@CrossOrigin +@RestController +@RequestMapping("/api/postReport") +@Api(tags = "举报用户相关") +public class ApiReportController extends RyController { + + @Autowired + private ReportService reportService; + + @PostMapping("/report") + @UserLoginToken + @ApiOperation(value = "举报", notes = "举报") + public ResponseData report(@RequestBody ReportReq req) { + return reportService.report(req,getUserVo()); + } +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/ApiShieldController.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/ApiShieldController.java new file mode 100644 index 0000000..1e90569 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/ApiShieldController.java @@ -0,0 +1,82 @@ +package com.ruoyi.controller; + +import com.ruoyi.annotations.UserLoginToken; +import com.ruoyi.controller.req.ShieldPageReq; +import com.ruoyi.controller.req.ShieldUserReq; +import com.ruoyi.frequency.shield.service.ShieldService; +import com.ruoyi.response.ResponseData; +import com.ruoyi.vo.RyController; +import io.swagger.annotations.Api; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import javax.validation.Valid; + +/** + * 屏蔽用户 + */ +@CrossOrigin +@RestController +@RequestMapping("/api/shield") +@Api(tags = "屏蔽用户") +public class ApiShieldController extends RyController { + + @Autowired + private ShieldService shieldService; + + /** + * 屏蔽 + * + * @return + */ + @PostMapping("/shieldUser") + @UserLoginToken + public ResponseData shieldUser(@Valid @RequestBody ShieldUserReq req) { + return shieldService.shieldUser(req, getUserVo()); + } + + /** + * 屏蔽 + * + * @return + */ + @PostMapping("/shieldUserVersion2") + @UserLoginToken + public ResponseData shieldUserVersion2(@Valid @RequestBody ShieldUserReq req) { + return shieldService.shieldUserVersion2(req, getUserVo()); + } + + /** + * 取消屏蔽 + * + * @return + */ + @PostMapping("/cancelShieldUserVersion2") + @UserLoginToken + public ResponseData cancelShieldUserVersion2(@Valid @RequestBody ShieldUserReq req) { + return shieldService.cancelShieldUserVersion2(req, getUserVo()); + } + + + /** + * 屏蔽列表 + * + * @param req + * @return + */ + @PostMapping("/shieldPage") + public ResponseData shieldPage(@RequestBody ShieldPageReq req) { + return shieldService.shieldPage(req, getUserVo()); + } + + /** + * 屏蔽列表(别人查看) + * + * @param req + * @return + */ + @PostMapping("/otherShieldPage") + public ResponseData otherShieldPage(@RequestBody ShieldPageReq req) { + return shieldService.otherShieldPage(req,getUserVo()); + } +} \ No newline at end of file diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/ApiWeComController.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/ApiWeComController.java new file mode 100644 index 0000000..264a128 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/ApiWeComController.java @@ -0,0 +1,163 @@ +package com.ruoyi.controller; + +import cn.hutool.http.HttpRequest; +import com.alibaba.fastjson.JSONObject; +import com.ruoyi.utils.wx.wecom.AesException; +import com.ruoyi.utils.wx.wecom.ConstantUtil; +import com.ruoyi.utils.wx.wecom.WXBizMsgCrypt; +import com.ruoyi.vo.RyController; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.extern.slf4j.Slf4j; +import org.springframework.web.bind.annotation.*; + +import javax.servlet.http.HttpServletRequest; +import java.util.HashMap; +import java.util.Map; + +@CrossOrigin +@RestController +@RequestMapping("/api") +@Api(tags = "企业微信") +@Slf4j +public class ApiWeComController extends RyController { + + public static void main(String[] args) { + sendMessage(); + } + + /** + * 获取access_token + * + * @return + */ + public static String getToken() { + String url = "https://qyapi.weixin.qq.com/cgi-bin/gettoken" + "?corpid=" + "ww45fb4d72c735ee1d" + "&corpsecret=" + "5x3F-AHQMO9VwpXH9_lOUX8887sqb1fUx0-5goN6U_Y"; + String result = HttpRequest.get(url).execute().body(); + System.err.println(result); + JSONObject jsonObject = JSONObject.parseObject(result); + //服务断了status会有值 + Integer errcode = (Integer) jsonObject.get("errcode"); + if (errcode == 0) { + String access_token = (String) jsonObject.get("access_token"); + return access_token; + } + return ""; + } + + /** + * 发送消息 + */ + public static void sendMessage() { +// Map map = new HashMap(); +// map.put("touser", "liwenlong"); +// map.put("toparty", "@all"); +// map.put("totag", "@all"); +// map.put("msgtype", "text"); +// map.put("agentid", "1000003"); +// Map map1 = new HashMap(); +// map1.put("content", "测试消息同步肯定接口接口的肌肤的接口的加快进度看即可当借款方的接口接口对接付款即可 肯德基咖啡机 就连接口对接发空间打开健康的风景\n软云"); +// map.put("text", map1); +// String s = JSONObject.toJSONString(map); +// String result = HttpRequest.post("https://qyapi.weixin.qq.com/cgi-bin/message/send?access_token=" + getToken()+"&debug=1") +// .header("Content-Type", "application/json;charset=utf-8") +// .body(s).execute().body(); +// System.err.println(result); +// JSONObject jsonObject = JSONObject.parseObject(result); +// Integer errcode = (Integer) jsonObject.get("errcode"); +// if (errcode == 0) { +// System.out.println("消息发送成功"); +// } + +// //根据手机号获取userid + Map map = new HashMap(); + map.put("mobile", "15855540307"); + String body = HttpRequest.post("https://qyapi.weixin.qq.com/cgi-bin/user/getuserid?access_token=" + getToken() + "&debug=1") + .header("Content-Type", "application/json;charset=utf-8") + .body(JSONObject.toJSONString(map)).execute().body(); + System.out.println(body); + +// //根据邮箱获取userid +// Map map = new HashMap(); +// map.put("email", "3350632748@qq.com"); +// map.put("email_type", 1); +// String body = HttpRequest.post("https://qyapi.weixin.qq.com/cgi-bin/user/get_userid_by_email?access_token=" + getToken() + "&debug=1") +// .header("Content-Type", "application/json;charset=utf-8") +// .body(JSONObject.toJSONString(map)).execute().body(); +// System.out.println(body); + + +// //获取用户列表 +// Map map = new HashMap(); +// map.put("cursor", ""); +// map.put("limit", 10000); +// String body = HttpRequest.post("https://qyapi.weixin.qq.com/cgi-bin/user/list_id?access_token=" + getToken() + "&debug=1") +// .header("Content-Type", "application/json;charset=utf-8") +// .body(JSONObject.toJSONString(map)).execute().body(); +// System.out.println(body); + + + + } + + + @GetMapping("/weCom") + @ApiOperation(value = "企业微信回调地址", notes = "企业微信回调地址") + public Object weCom(HttpServletRequest request, @RequestBody(required = false) String body) { + Map parameterMap = request.getParameterMap(); + String jsonstring = JSONObject.toJSONString(parameterMap); + log.info("企业微信回调参数:{}, 解析参数:{}", jsonstring, body); + if (body == null) { + return verificationUrl(request); + } + Map resultMap = getRequestParameter(request, body); + System.out.println(resultMap); + return "success"; + } + + + public Object verificationUrl(HttpServletRequest request) { + String signature = request.getParameter("msg_signature"); + String timestamp = request.getParameter("timestamp"); + String nonce = request.getParameter("nonce"); + String echostr = request.getParameter("echostr"); + // 验证完整性 + log.info("=========验证URL有效性开始========="); + String sEchostr; //需要返回的明文 + try { + WXBizMsgCrypt wxcpt = new WXBizMsgCrypt("token", "aeskey", "id"); + log.info("企业微信加密签名:{},时间戳:{},随机数:{},加密的字符串:{}", signature, timestamp, nonce, echostr); + sEchostr = wxcpt.VerifyURL(signature, timestamp, nonce, echostr); + log.info("给企业微信返回的明文,{}", sEchostr); + log.info("=========验证URL有效性结束========="); + return sEchostr; + } catch (AesException e) { + log.error("验证URL失败,错误原因请査看异常:{}", e.getCode()); + e.printStackTrace(); + return "error"; + } + + } + + + public Map getRequestParameter(HttpServletRequest request, String body) { + log.info("=========参数解析开始====="); + Map resultMap = new HashMap<>(16); + try { + WXBizMsgCrypt wxcpt = new WXBizMsgCrypt("token", "aesKey", "id"); + String msgSignature = request.getParameter("msg_signature"); + String timestamp = request.getParameter("timestamp"); + String nonce = request.getParameter("nonce"); + log.info("企业微信加密签名:{},时间戳:{},随机数:{}", msgSignature, timestamp, nonce); + String sMsg = wxcpt.DecryptMsg(msgSignature, timestamp, nonce, body); + ConstantUtil.parseXmlToMap(sMsg, resultMap); + log.info("decrypt密文转为map结果为{}", resultMap); + log.info("=========参数解析结束========="); + } catch (AesException e) { + log.error("密文参数解析失败,错误原因请査看异常:{}", e.getMessage()); + } + return resultMap; + } + + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/AppCaptchaController.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/AppCaptchaController.java new file mode 100644 index 0000000..65fcbaa --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/AppCaptchaController.java @@ -0,0 +1,43 @@ +package com.ruoyi.controller; + +import com.ruoyi.utils.captcha.ImgVerifyCode; +import io.swagger.annotations.Api; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.redis.core.StringRedisTemplate; +import org.springframework.web.bind.annotation.*; + +import javax.servlet.http.HttpServletResponse; +import javax.validation.constraints.NotNull; +import java.awt.image.BufferedImage; +import java.util.concurrent.TimeUnit; + +/** + * 图形验证码 + * @author funcong + * @create 2021/5/4 + */ +@CrossOrigin +@RestController +@RequestMapping("/api/captcha") +@Api(tags = "图形验证码") +public class AppCaptchaController { + + + @Autowired + private StringRedisTemplate redisTemplate; + + /** + * 获取图形验证码 + * @param response + * @param key + * @throws Exception + */ + @RequestMapping(value = "/captcha", method = RequestMethod.POST) + public void appCaptcha(HttpServletResponse response, + @RequestParam("key") @NotNull(message = "key不能为空") String key) throws Exception { + ImgVerifyCode ivc = new ImgVerifyCode(); //使用验证码类,生成验证码类对象 + BufferedImage image = ivc.getImage(); //获取验证码 + ivc.output(image, response.getOutputStream());//将验证码图片响应给客户端 + redisTemplate.opsForValue().set(key, ivc.getText(), 3, TimeUnit.MINUTES); + } +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/req/AddUserWithdrawalWayReq.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/req/AddUserWithdrawalWayReq.java new file mode 100644 index 0000000..006700b --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/req/AddUserWithdrawalWayReq.java @@ -0,0 +1,57 @@ +package com.ruoyi.controller.req; + +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; + +/** + * @Author 刘耀 + * @Date 2020/9/17 10:32 + */ +@Data +public class AddUserWithdrawalWayReq { + + + /** + * 平台提现方式Id + */ + @NotNull(message = "平台提现方式不可为空") + private Long pfWayId; + + + /** + * 联系人 + */ + @NotBlank(message = "联系人不可为空") + private String linkman; + + /** + * 联系方式 + */ + @NotBlank(message = "联系方式不可为空") + private String contactWay; + + /** + * 提现账户 + */ + @NotBlank(message = "提现账户不可为空") + private String cashAccount; + + /** + * 是否默认1:非默认 2:默认, + */ + @NotNull(message = "请确认是否为默认选中") + private Integer isDefault; + + /** + * 区号 + */ + private String areaCode; + + + /** + * 开户支行 + */ + private String accountOpeningSubBranch; +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/req/AddressInsertReq.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/req/AddressInsertReq.java new file mode 100644 index 0000000..683ba4e --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/req/AddressInsertReq.java @@ -0,0 +1,66 @@ +package com.ruoyi.controller.req; + +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; + +@Data +public class AddressInsertReq { + + /** + * 收货人姓名 + */ + @NotBlank(message = "收货人姓名不能为空") + private String username; + + /** + * 收货人联系方式 + */ + @NotBlank(message = "收货人联系方式不能为空") + private String mobile; + + /** + * 省份名称 + */ + @NotBlank(message = "省份不能为空") + private String province; + + /** + * 城市名称 + */ + @NotBlank(message = "城市不能为空") + private String city; + + /** + * 区域名称 + */ + @NotBlank(message = "区域不能为空") + private String area; + + /** + * 地址 + */ + private String address; + + /** + * 详细地址 + */ + private String detail; + + /** + * 经度 + */ + private String longitude; + /** + * 纬度 + */ + private String latitude; + + + /** + * 是否默认 1不是 2 默认 + */ + @NotNull(message = "是否默认不能为空") + private Integer isDefault; +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/req/AddressUpdateReq.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/req/AddressUpdateReq.java new file mode 100644 index 0000000..bb4625d --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/req/AddressUpdateReq.java @@ -0,0 +1,68 @@ +package com.ruoyi.controller.req; + +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; + +@Data +public class AddressUpdateReq { + + private Long id; + + /** + * 收货人姓名 + */ + @NotBlank(message = "收货人姓名不能为空") + private String username; + + /** + * 收货人联系方式 + */ + @NotBlank(message = "收货人联系方式不能为空") + private String mobile; + + /** + * 省份名称 + */ + @NotBlank(message = "省份不能为空") + private String province; + + /** + * 城市名称 + */ + @NotBlank(message = "城市不能为空") + private String city; + + /** + * 区域名称 + */ + @NotBlank(message = "区域不能为空") + private String area; + + /** + * 地址 + */ + private String address; + + /** + * 详细地址 + */ + private String detail; + + /** + * 经度 + */ + private String longitude; + /** + * 纬度 + */ + private String latitude; + + + /** + * 是否默认 + */ + @NotNull(message = "是否默认不能为空") + private Integer isDefault; +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/req/AppMessageReadOrDeleteReq.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/req/AppMessageReadOrDeleteReq.java new file mode 100644 index 0000000..7604020 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/req/AppMessageReadOrDeleteReq.java @@ -0,0 +1,23 @@ +package com.ruoyi.controller.req; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import javax.validation.constraints.NotNull; +import java.util.List; + +/** + * @author liwenlong + * @date 2023/4/11 10:07 + */ +@Data +public class AppMessageReadOrDeleteReq { + + @NotNull(message = "类型不能为空") + @ApiModelProperty(value = "1 标记已读 2 删除消息") + private Integer type; + + @NotNull(message = "系统消息id不能为空") + @ApiModelProperty(value = "系统消息id 集合 为空删除全部") + private List ids; +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/req/BankCardAddReq.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/req/BankCardAddReq.java new file mode 100644 index 0000000..277f5e5 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/req/BankCardAddReq.java @@ -0,0 +1,23 @@ +package com.ruoyi.controller.req; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +@Data +public class BankCardAddReq { + + @ApiModelProperty("开户行") + private String bank; + + @ApiModelProperty("开户支行") + private String openingBranch; + + @ApiModelProperty("姓名") + private String fullName; + + @ApiModelProperty("银行卡号") + private String bankCard; + + @ApiModelProperty("是否默认1否;2 是 目前不用") + private Long isDefault; +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/req/BankCardEditReq.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/req/BankCardEditReq.java new file mode 100644 index 0000000..236684c --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/req/BankCardEditReq.java @@ -0,0 +1,26 @@ +package com.ruoyi.controller.req; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +@Data +public class BankCardEditReq { + + @ApiModelProperty("租户号") + private Long id; + + @ApiModelProperty("开户行") + private String bank; + + @ApiModelProperty("开户支行") + private String openingBranch; + + @ApiModelProperty("姓名") + private String fullName; + + @ApiModelProperty("银行卡号") + private String bankCard; + + @ApiModelProperty("是否默认1否;2 是 目前不用") + private Long isDefault; +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/req/BankCardPageReq.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/req/BankCardPageReq.java new file mode 100644 index 0000000..b22cde1 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/req/BankCardPageReq.java @@ -0,0 +1,8 @@ +package com.ruoyi.controller.req; + +import com.ruoyi.vo.PageBasic; +import lombok.Data; + +@Data +public class BankCardPageReq extends PageBasic { +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/req/BlockPageReq.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/req/BlockPageReq.java new file mode 100644 index 0000000..c696439 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/req/BlockPageReq.java @@ -0,0 +1,29 @@ +package com.ruoyi.controller.req; + +import com.ruoyi.vo.PageBasic; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + * @author liwenlong + * @date 2023/4/3 9:02 + */ +@Data +public class BlockPageReq extends PageBasic { + + + /** + * 1 用户 2 商家 + */ + private Integer otherUserType; + + + /** + * 用户id + */ + private Long otherUserId; + + @ApiModelProperty("关键字") + private String keyword; + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/req/BlockUserReq.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/req/BlockUserReq.java new file mode 100644 index 0000000..c3dd480 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/req/BlockUserReq.java @@ -0,0 +1,26 @@ +package com.ruoyi.controller.req; + +import lombok.Data; + +import javax.validation.constraints.NotNull; + +/** + * @Author 刘耀 + * @Date 2022/1/14 9:19 + */ +@Data +public class BlockUserReq { + + /** + * 拉黑用户类型 + */ + @NotNull(message = "拉黑用户类型不能为空") + private Integer userType; + + /** + * 拉黑用户id + */ + @NotNull(message = "拉黑用户id不能为空") + private Long userId; + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/req/CanReceivePageReq.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/req/CanReceivePageReq.java new file mode 100644 index 0000000..785a811 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/req/CanReceivePageReq.java @@ -0,0 +1,16 @@ +package com.ruoyi.controller.req; + +import com.ruoyi.vo.PageBasic; +import lombok.Data; + +@Data +public class CanReceivePageReq extends PageBasic { + + + private Integer type;//优惠券状态类型 1 待领取 2 已领取 + + private Integer couponType;//优惠券类型 1 平台 2 商家 + + private Long storeId;//商家id + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/req/CertiApplyReq.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/req/CertiApplyReq.java new file mode 100644 index 0000000..4a7a172 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/req/CertiApplyReq.java @@ -0,0 +1,54 @@ +package com.ruoyi.controller.req; + +import lombok.Data; + +import java.util.Date; + +/** + * @author liwenlong + * @date 2023/1/10 14:59 + */ +@Data +public class CertiApplyReq { + + private Integer type;// 1代理认证 2 企业代理认证 + + + /** + * 代理认证 + */ + private String name;//真实姓名 + + private String idcardNo;//身份证号 + + private String mobile;//手机号码 + + private String idFront;//身份证正面 + + private String idBack;//身份证反面 + + private Date hrBeginTime;//从事HR时间 + + private String goodIndustry;//擅长行业 + + private String address;//所在地 + + + /** + * 企业代理认证 + */ + private String enterpriseName;//企业名称 + + private String linkname;//联系人 + + private String linkMobile;//电话 + + private String businessLicense;//营业执照 + + private String incumbencyCertificate;//在职证明 + + private String certificationContract;//认证合同 + + + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/req/ChangeBindingMobileReq.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/req/ChangeBindingMobileReq.java new file mode 100644 index 0000000..4b223c2 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/req/ChangeBindingMobileReq.java @@ -0,0 +1,23 @@ +package com.ruoyi.controller.req; + +import lombok.Data; + +import javax.validation.constraints.NotEmpty; + +/** + * @Author liwenlong + */ +@Data +public class ChangeBindingMobileReq { + + @NotEmpty(message = "旧手机号不能为空") + private String oldMobile; //旧手机号 + + + private String areaCode = "+86"; + @NotEmpty(message = "新手机号不能为空") + private String newMobile;//新手机号 + + @NotEmpty(message = "验证码不能为空") + private String newCode; +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/req/CheckOldMobileReq.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/req/CheckOldMobileReq.java new file mode 100644 index 0000000..349c944 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/req/CheckOldMobileReq.java @@ -0,0 +1,21 @@ +package com.ruoyi.controller.req; + +import lombok.Data; + +import javax.validation.constraints.NotEmpty; + +/** + * @Author liwenlong + */ +@Data +public class CheckOldMobileReq { + + + private String areaCode = "+86"; + + @NotEmpty(message = "手机号不能为空") + private String oldMobile;//旧手机号 + + @NotEmpty(message = "验证码不能为空") + private String oldCode; +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/req/CollectObjectReq.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/req/CollectObjectReq.java new file mode 100644 index 0000000..c5d4d5c --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/req/CollectObjectReq.java @@ -0,0 +1,18 @@ +package com.ruoyi.controller.req; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + * @author a + * @date 2023/10/16 14:10 + */ +@Data +public class CollectObjectReq { + + @ApiModelProperty("收藏类型 1作品 2 动态 3资讯 4新闻") + private Integer type; + + @ApiModelProperty("收藏对象id") + private Long objectId; +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/req/CollectPageReq.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/req/CollectPageReq.java new file mode 100644 index 0000000..d91a681 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/req/CollectPageReq.java @@ -0,0 +1,49 @@ +package com.ruoyi.controller.req; + +import com.ruoyi.vo.PageBasic; +import com.ruoyi.vo.UserVo; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.List; + +/** + * @author a + * @date 2023/10/16 14:09 + */ +@Data +public class CollectPageReq extends PageBasic { + + @ApiModelProperty("收藏类型 1作品 2 动态") + private Integer type; + + @ApiModelProperty("分类id") + private Long typeId; + + + @ApiModelProperty(value = "用户类型 1 用户 对应枚举 UserEnums") + private Integer userType; + + @ApiModelProperty(value = "用户id") + private Long userId; + + @ApiModelProperty("排序方式 1 最新 2 点赞最多 3 评论最多") + private Integer orderSort; + + @ApiModelProperty(value = "作品绑定的分类ids") + private List typeIds; + + + @ApiModelProperty(value = "拉黑用户") + private List blockUserList; + + @ApiModelProperty(value = "屏蔽用户") + private List shieldUserList; + + @ApiModelProperty(value = "屏蔽的帖子") + private List shieldPostIdList; + + @ApiModelProperty(value = "屏蔽的作品") + private List shieldWorksIdList; + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/req/CustomerPageReq.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/req/CustomerPageReq.java new file mode 100644 index 0000000..ecb9260 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/req/CustomerPageReq.java @@ -0,0 +1,29 @@ +package com.ruoyi.controller.req; + +import com.ruoyi.vo.PageBasic; +import com.ruoyi.vo.UserVo; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.List; + +/** + * @author a + * @date 2023/10/20 17:11 + */ +@Data +public class CustomerPageReq extends PageBasic { + + + @ApiModelProperty(value = "1粉丝") + private Integer type; + + @ApiModelProperty(value = "关键字") + private String keyword; + + @ApiModelProperty(value = "拉黑用户") + private List blockUserList; + + @ApiModelProperty(value = "屏蔽用户") + private List shieldUserList; +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/req/DialoguePageReq.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/req/DialoguePageReq.java new file mode 100644 index 0000000..63fde26 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/req/DialoguePageReq.java @@ -0,0 +1,21 @@ +package com.ruoyi.controller.req; + +import com.ruoyi.vo.PageBasic; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +@Data +public class DialoguePageReq extends PageBasic { + + @ApiModelProperty("评论id") + private Long commentId; + + @ApiModelProperty("上级评论id") + private Long parentId; + + @ApiModelProperty("排序 1时间 2热度") + private Integer sortType; + + @ApiModelProperty(value = "1升序 2 降序") + private Integer isAsc; +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/req/EditUserWithdrawalWayReq.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/req/EditUserWithdrawalWayReq.java new file mode 100644 index 0000000..05e74a7 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/req/EditUserWithdrawalWayReq.java @@ -0,0 +1,39 @@ +package com.ruoyi.controller.req; + +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; + +/** + * @Author 刘耀 + * @Date 2020/9/17 10:32 + */ +@Data +public class EditUserWithdrawalWayReq { + @NotNull(message = "用户提现方式不可为空") + private Long id; + + @NotNull(message = "平台提现方式不可为空") + private Long pfWayId; + + @NotBlank(message = "联系人不可为空") + private String linkman; + + @NotBlank(message = "联系方式不可为空") + private String contactWay; + + @NotBlank(message = "提现账户不可为空") + private String cashAccount; + /** + * 是否默认2:默认,1:非默认 + */ + @NotNull(message = "请确认是否为默认选中") + private Integer isDefault; + + /** + * 开户支行 + */ + @NotNull(message = "开户支行不可为空") + private String accountOpeningSubBranch; +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/req/EvaluatePageReq.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/req/EvaluatePageReq.java new file mode 100644 index 0000000..bf84268 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/req/EvaluatePageReq.java @@ -0,0 +1,17 @@ +package com.ruoyi.controller.req; + +import com.ruoyi.vo.PageBasic; +import lombok.Data; + +/** + * @Author 刘耀 + * @Date 2022/1/14 9:19 + */ +@Data +public class EvaluatePageReq extends PageBasic { + private Integer hasImage;//1有图 2 无图 + + private Integer objectType;//查询主体类型 1 商家 2 商品 + + private Long objectId; +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/req/FollowUserReq.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/req/FollowUserReq.java new file mode 100644 index 0000000..f5ef623 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/req/FollowUserReq.java @@ -0,0 +1,27 @@ +package com.ruoyi.controller.req; + +import lombok.Data; + +import javax.validation.constraints.NotNull; + +/** + * @Author liwenlong + * @Date 2022/1/14 9:19 + */ +@Data +public class FollowUserReq { + + + /** + * 关注用户类型 + */ + @NotNull(message = "关注用户类型不能为空") + private Integer userType; + + /** + * 关注用户id + */ + @NotNull(message = "关注用户id不能为空") + private Long userId; + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/req/FollowerPageByOther.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/req/FollowerPageByOther.java new file mode 100644 index 0000000..2f84380 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/req/FollowerPageByOther.java @@ -0,0 +1,37 @@ +package com.ruoyi.controller.req; + +import com.ruoyi.vo.PageBasic; +import com.ruoyi.vo.UserVo; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.List; + +/** + * @Author 刘耀 + * @Date 2022/1/15 14:02 + */ +@Data +public class FollowerPageByOther extends PageBasic { + /** + * 用户类型 + */ + private Integer userType; + + /** + * 用户id + */ + private Long userId; + + @ApiModelProperty("关键字") + private String keyword; + + @ApiModelProperty("排序类型 1最新发布广场 2") + private Integer sortType; + + @ApiModelProperty(value = "拉黑用户") + private List blockUserList; + + @ApiModelProperty(value = "屏蔽用户") + private List shieldUserList; +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/req/IllegalDeductionPageReq.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/req/IllegalDeductionPageReq.java new file mode 100644 index 0000000..788f829 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/req/IllegalDeductionPageReq.java @@ -0,0 +1,14 @@ +package com.ruoyi.controller.req; + +import com.ruoyi.vo.PageBasic; +import lombok.Data; + +/** + * @author a + * @date 2023/11/8 17:08 + */ +@Data +public class IllegalDeductionPageReq extends PageBasic { + + private Integer type; +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/req/LoginReqVo.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/req/LoginReqVo.java new file mode 100644 index 0000000..5c9cb53 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/req/LoginReqVo.java @@ -0,0 +1,63 @@ +package com.ruoyi.controller.req; + +import lombok.Data; + +import javax.validation.constraints.NotNull; + +@Data +public class LoginReqVo { + + /** + * 登录方式 1 验证码 2 密码 3 一键登录 4 微信登录 5 小程序登录 6 苹果登录 + */ + @NotNull(message = "登入方式不能为空") + private Integer type; + + + /** + * 用户类型 1设计师 2表现师 3销售(推广员) + */ + @NotNull(message = "用户类型不能为空") + private Integer userType; + + /** + *账号 + */ + private String account; + + + /** + * 区号(选填 默认 +86) + */ + private String areaCode = "+86"; + + /** + *手机号(选填 账号与手机号一致时,不用传) + */ + private String mobile; + + /** + * 密码登录 + */ + private String password; + /** + * 验证码 + */ + private String code; + /** + * 微信openid + */ + private String openid; + + private String unionid; + + /** + * 一键登录时手机号加密字符串 + */ + private String loginToken; + + private String clientId; //个推 + + private String invitationCode;//邀请码 + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/req/MessageReadOrDeleteReq.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/req/MessageReadOrDeleteReq.java new file mode 100644 index 0000000..dd4a952 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/req/MessageReadOrDeleteReq.java @@ -0,0 +1,35 @@ +package com.ruoyi.controller.req; + +import lombok.Data; + +import javax.validation.constraints.NotNull; +import java.util.List; + +/** + * @author liwenlong + * @date 2023/4/11 10:08 + */ +@Data +public class MessageReadOrDeleteReq { + + /** + * 1 标记已读 2 删除消息 + */ + @NotNull(message = "类型不能为空") + private Integer type; + + /** + * 消息id 集合 为空删除全部 + */ + private List ids; + + /** + * 订单ID + */ + private Long orderId; + + /** + * 订单类型 + */ + private Integer orderType; +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/req/MonthReq.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/req/MonthReq.java new file mode 100644 index 0000000..0e946a2 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/req/MonthReq.java @@ -0,0 +1,21 @@ +package com.ruoyi.controller.req; + +import com.ruoyi.vo.PageBasic; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.Date; + +/** + * @author a + * @date 2023/10/18 18:21 + */ +@Data +public class MonthReq extends PageBasic { + + @ApiModelProperty("开始时间") + private Date beginTime; + + @ApiModelProperty("结束时间") + private Date endTime; +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/req/PageVO.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/req/PageVO.java new file mode 100644 index 0000000..0672368 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/req/PageVO.java @@ -0,0 +1,23 @@ +package com.ruoyi.controller.req; + +import lombok.Data; +import lombok.experimental.Accessors; + +import javax.validation.constraints.NotNull; + +/** + * @Author 刘耀 + * @Date 2022/1/14 9:17 + */ +@Data +@Accessors(chain = true) +public class PageVO { + + + @NotNull(message = "分页参数不能为空") + private Integer pageSize; + + + @NotNull(message = "分页参数不能为空") + private Integer pageNo; +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/req/RechargeBondReq.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/req/RechargeBondReq.java new file mode 100644 index 0000000..3348f35 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/req/RechargeBondReq.java @@ -0,0 +1,17 @@ +package com.ruoyi.controller.req; + +import lombok.Data; + +import java.math.BigDecimal; + +/** + * @author a + * @date 2022/8/5 13:38 + */ +@Data +public class RechargeBondReq { + + private Integer payType; + + private BigDecimal price; +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/req/RechargeCoinReq.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/req/RechargeCoinReq.java new file mode 100644 index 0000000..a0eacab --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/req/RechargeCoinReq.java @@ -0,0 +1,22 @@ +package com.ruoyi.controller.req; + +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; + +/** + * @author liuyao + */ +@Data +public class RechargeCoinReq { + + @NotBlank(message = "充值金额不能为空") + private String rechargeId; + + /** + * 支付方式 1 支付宝 2 微信 3 苹果 + */ + @NotNull(message = "支付方式不能为空") + private Integer payType; +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/req/RechargeOrderReq.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/req/RechargeOrderReq.java new file mode 100644 index 0000000..8738112 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/req/RechargeOrderReq.java @@ -0,0 +1,23 @@ +package com.ruoyi.controller.req; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.math.BigDecimal; + +@Data +public class RechargeOrderReq { + + + /** + * @see com.ruoyi.pay.enums.PayEnums + */ + @ApiModelProperty(value = "支付类型") + private Integer payType; + + @ApiModelProperty(value = "充值包id") + private Long rechargeCoinId; + + @ApiModelProperty(value = "充值金额(自定义)") + private BigDecimal amount; +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/req/RegisterUserReq.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/req/RegisterUserReq.java new file mode 100644 index 0000000..12630cf --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/req/RegisterUserReq.java @@ -0,0 +1,77 @@ +package com.ruoyi.controller.req; + +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; + +@Data +public class RegisterUserReq { + + + /** + * 用户类型 1设计师 2表现师 3销售(推广员) + */ + @NotNull(message = "用户类型不能为空") + private Integer userType; + + + /** + * 账号 + */ + @NotBlank(message = "账号不能为空") + private String account; + + + /** + * 验证码 + */ + private String code; + + + /** + * 密码 + */ + @NotBlank(message = "密码不能为空") + private String pwd; + + + /** + * 手机id + */ + private String clientId; + + + /** + * 区号 + */ + private String areaCode = "+86"; + + + /** + * 手机号 + */ + private String mobile; + + /** + * 邀请码 + */ + private String invitationCode; + + /** + * 邀请码来源 1 设计师 2表现师 3 销售 + */ + private Integer inviteSource; + + public RegisterUserReq(){ + } + + public RegisterUserReq(LoginReqVo req){ + this.userType = req.getUserType(); + this.areaCode = req.getAreaCode(); + this.mobile = req.getMobile(); + this.clientId = req.getClientId(); + this.account = req.getAccount(); + } + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/req/ReportReq.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/req/ReportReq.java new file mode 100644 index 0000000..50f062d --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/req/ReportReq.java @@ -0,0 +1,28 @@ +package com.ruoyi.controller.req; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + * @author a + * @date 2023/11/17 14:30 + */ +@Data +public class ReportReq { + + + @ApiModelProperty(value = "用户类型 1 用户 对应枚举 UserEnums") + private Integer userType; + + @ApiModelProperty(value = "用户id") + private String userId; + + @ApiModelProperty(value = "举报原因") + private String reason; + + @ApiModelProperty(value = "内容") + private String content; + + @ApiModelProperty(value = "图片") + private String images; +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/req/SaleDetailPageReq.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/req/SaleDetailPageReq.java new file mode 100644 index 0000000..559ff21 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/req/SaleDetailPageReq.java @@ -0,0 +1,24 @@ +package com.ruoyi.controller.req; + +import com.ruoyi.vo.PageBasic; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.Date; + +/** + * @author a + * @date 2023/10/20 9:33 + */ +@Data +public class SaleDetailPageReq extends PageBasic { + + @ApiModelProperty(value = "关键字") + private String keyword; + + @ApiModelProperty("开始时间") + private Date beginTime; + + @ApiModelProperty("结束时间") + private Date endTime; +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/req/SaleUserPageReq.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/req/SaleUserPageReq.java new file mode 100644 index 0000000..9d6cf27 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/req/SaleUserPageReq.java @@ -0,0 +1,12 @@ +package com.ruoyi.controller.req; + +import com.ruoyi.vo.PageBasic; +import lombok.Data; + +/** + * @author a + * @date 2023/10/19 10:06 + */ +@Data +public class SaleUserPageReq extends PageBasic { +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/req/ShieldPageReq.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/req/ShieldPageReq.java new file mode 100644 index 0000000..3878d8f --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/req/ShieldPageReq.java @@ -0,0 +1,28 @@ +package com.ruoyi.controller.req; + +import com.ruoyi.vo.PageBasic; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + * @author a + * @date 2023/4/3 9:36 + */ +@Data +public class ShieldPageReq extends PageBasic { + + /** + * 1 用户 2 商家 + */ + private Integer otherUserType; + + + /** + * 用户id + */ + private Long otherUserId; + + @ApiModelProperty("关键字") + private String keyword; + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/req/ShieldUserReq.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/req/ShieldUserReq.java new file mode 100644 index 0000000..9cb3e2d --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/req/ShieldUserReq.java @@ -0,0 +1,26 @@ +package com.ruoyi.controller.req; + +import lombok.Data; + +import javax.validation.constraints.NotNull; + +/** + * @author a + * @date 2023/4/3 9:34 + */ +@Data +public class ShieldUserReq { + + /** + * 屏蔽用户类型 + */ + @NotNull(message = "屏蔽用户类型不能为空") + private Integer userType; + + /** + * 屏蔽用户id + */ + @NotNull(message = "屏蔽用户id不能为空") + private Long userId; + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/req/StorePageReq.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/req/StorePageReq.java new file mode 100644 index 0000000..edbc0eb --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/req/StorePageReq.java @@ -0,0 +1,73 @@ +package com.ruoyi.controller.req; + +import com.baomidou.mybatisplus.annotation.TableField; +import com.ruoyi.vo.PageBasic; +import com.ruoyi.vo.UserVo; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.List; + +/** + * @author a + * @date 2023/10/17 18:27 + */ +@Data +public class StorePageReq extends PageBasic { + + + @ApiModelProperty("类型 1推荐榜(默认) 2订单数量榜 3金额榜 4好评榜") + private Integer type = 1; + + @ApiModelProperty("是否是企业: 1不是 2是") + private Integer isWorkingDrawing = 1; + + @ApiModelProperty("类型 1施工图 2景观 3 设计") + private Integer enterpriseType; + + @ApiModelProperty("擅长领域") + private String specialityArea ; + + @ApiModelProperty("是否高端认证:1:普通技术 2高端技术") + private Integer ifHighend; + + @ApiModelProperty("在线状态;1:在线,2离线") + private Integer onlineStatus; + + @ApiModelProperty("所属区域") + private String area; + + @ApiModelProperty("从业年限范围") + private String yearRange; + + @ApiModelProperty("从业年限范围") + private Integer minYear; + + @ApiModelProperty("从业年限范围") + private Integer maxYear; + + + @ApiModelProperty("type=1 时 按照字典配置权重进行先后排序sql") + private String sortSql; + + + @ApiModelProperty(value = "拉黑用户") + private List blockUserList; + + @ApiModelProperty(value = "屏蔽用户") + private List shieldUserList; + + @ApiModelProperty(value = "关键字") + private String keyword; + + @ApiModelProperty(value = "性别") + private String sex; + + @ApiModelProperty("用户ids") + @TableField(exist = false) + private List userIds; + + @ApiModelProperty("工种") + private String branchWork; + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/req/UserEditPwdLoginReq.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/req/UserEditPwdLoginReq.java new file mode 100644 index 0000000..073349d --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/req/UserEditPwdLoginReq.java @@ -0,0 +1,22 @@ +package com.ruoyi.controller.req; + +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; + +/** + * @Author 刘耀 + * @Date 2020/9/16 11:16 + */ +@Data +public class UserEditPwdLoginReq { + + @NotNull(message = "用户类型不能为空") + private Integer userType;//用户类型 1 用户 2 代理商 3 企业 + + @NotBlank(message = "密码不可为空") + private String pwd; + + private String oldPwd; +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/req/UserEditReqVo.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/req/UserEditReqVo.java new file mode 100644 index 0000000..d72cbd5 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/req/UserEditReqVo.java @@ -0,0 +1,59 @@ +package com.ruoyi.controller.req; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.Date; + +/** + * @author liwenlong + * @date 2023/1/6 10:15 + */ +@Data +public class UserEditReqVo { + + private String nickname;//编号 + + private String avatar;//头像 + + private String name;//昵称 + + @ApiModelProperty("性别") + private String sex; + + + private String enterDate;//入行时间 + + + private String workYear;//从业年限 + + private String area;//所属区域 + + + private String mobile;//手机号 + + private String signature;//个签 + + + + private Date workTime;//参加工作时间 + + private Date birthday;//出生年月 + + private String education;//学历 + + private Integer closeMessage; //推送是否关闭 1 关闭 2 不关闭 + + + @ApiModelProperty(value = "背景图") + private String backgroundImage; + + + @ApiModelProperty(value = "曾经任职公司") + private String onceWorkCompanys; + + + @ApiModelProperty("擅长领域") + private String specialityArea; + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/req/UserForgetPwdLoginReq.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/req/UserForgetPwdLoginReq.java new file mode 100644 index 0000000..95a51bc --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/req/UserForgetPwdLoginReq.java @@ -0,0 +1,26 @@ +package com.ruoyi.controller.req; + +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; + +/** + * @Author 刘耀 + * @Date 2020/9/16 11:16 + */ +@Data +public class UserForgetPwdLoginReq { + + @NotNull(message = "用户类型不能为空") + private Integer userType;//用户类型 1 用户 2 商家 + + private String areaCode = "+86"; + + @NotBlank(message = "手机号不可为空") + private String mobile; + @NotBlank(message = "密码不可为空") + private String pwd; + @NotBlank(message = "验证码不可为空") + private String code; +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/req/WalletPageReq.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/req/WalletPageReq.java new file mode 100644 index 0000000..abf520a --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/req/WalletPageReq.java @@ -0,0 +1,24 @@ +package com.ruoyi.controller.req; + +import com.ruoyi.vo.PageBasic; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.Date; + +/** + * @author a + * @date 2023/10/18 18:21 + */ +@Data +public class WalletPageReq extends PageBasic { + + @ApiModelProperty(value = "类型 1收入 2支出 3充值 4 抵扣金") + private Integer type; + + @ApiModelProperty("开始时间") + private Date beginTime; + + @ApiModelProperty("结束时间") + private Date endTime; +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/req/WithApplyReq.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/req/WithApplyReq.java new file mode 100644 index 0000000..da0e237 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/req/WithApplyReq.java @@ -0,0 +1,49 @@ +package com.ruoyi.controller.req; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import javax.validation.constraints.NotNull; +import java.math.BigDecimal; + +/** + * @Author 刘耀 + * @Date 2020/9/17 10:32 + */ +@Data +public class WithApplyReq { + + + @NotNull(message = "提现金额不可为空") + @ApiModelProperty(value = "提现金额", required = true) + private BigDecimal amount; + +// @NotNull(message = "提现方式不可为空") +// @ApiModelProperty(value = "提现方式", required = true) + private Long userWWayId; + + @ApiModelProperty(value = "提现密码") + private String payPwd; + + @ApiModelProperty(value = "备注") + private String remark; + + @ApiModelProperty("用户银行卡id") + private Long bankCardId; + + @ApiModelProperty("开户行") + private String bank; + + @ApiModelProperty("开户支行") + private String subbranch; + + @ApiModelProperty("银行卡") + private String bankCard; + + @ApiModelProperty("姓名") + private String fullName; + + @ApiModelProperty("用户类型") + private Integer userType; + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/req/WithdrawalRecordPageReq.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/req/WithdrawalRecordPageReq.java new file mode 100644 index 0000000..c73ed10 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/req/WithdrawalRecordPageReq.java @@ -0,0 +1,17 @@ +package com.ruoyi.controller.req; + +import com.ruoyi.vo.PageBasic; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.Date; + +@Data +public class WithdrawalRecordPageReq { + + @ApiModelProperty("开始时间") + private Date beginTime; + + @ApiModelProperty("结束时间") + private Date endTime; +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/req/WorksPageReq.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/req/WorksPageReq.java new file mode 100644 index 0000000..778fb86 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/req/WorksPageReq.java @@ -0,0 +1,26 @@ +package com.ruoyi.controller.req; + +import lombok.Data; + +@Data +public class WorksPageReq { + + + + /** + * 作品分类id + */ + private Long postClassifyId; + + /** + * 关键字搜索 (技术称呼 - 技术的名称, 作品名称 , 论坛标题) + */ + private String keyword; + + /** + * 表现师id + */ + private Long storeId; + + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/resp/BankCardDetailResp.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/resp/BankCardDetailResp.java new file mode 100644 index 0000000..802ff32 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/resp/BankCardDetailResp.java @@ -0,0 +1,42 @@ +package com.ruoyi.controller.resp; + +import com.fasterxml.jackson.annotation.JsonFormat; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.Date; + +@Data +public class BankCardDetailResp { + + @ApiModelProperty("租户号") + private Long id; + + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @ApiModelProperty("创建时间") + private Date createTime; + + @ApiModelProperty("删除状态 1 正常 2 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("用户类型") + private Integer userType; + + @ApiModelProperty("用户id") + private Long userId; + + @ApiModelProperty("开户行") + private String bank; + + @ApiModelProperty("开户支行") + private String openingBranch; + + @ApiModelProperty("姓名") + private String fullName; + + @ApiModelProperty("银行卡号") + private String bankCard; + + @ApiModelProperty("是否默认1否;2 是 目前不用") + private Long isDefault; +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/resp/BankCardPageResp.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/resp/BankCardPageResp.java new file mode 100644 index 0000000..33f26ba --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/resp/BankCardPageResp.java @@ -0,0 +1,46 @@ +package com.ruoyi.controller.resp; + +import com.baomidou.mybatisplus.annotation.TableField; +import com.fasterxml.jackson.annotation.JsonFormat; +import com.ruoyi.common.annotation.CreateTime; +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.vo.UserInfo; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.Date; + +@Data +public class BankCardPageResp { + + @ApiModelProperty("租户号") + private Long id; + + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @ApiModelProperty("创建时间") + private Date createTime; + + @ApiModelProperty("删除状态 1 正常 2 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("用户类型") + private Integer userType; + + @ApiModelProperty("用户id") + private Long userId; + + @ApiModelProperty("开户行") + private String bank; + + @ApiModelProperty("开户支行") + private String openingBranch; + + @ApiModelProperty("姓名") + private String fullName; + + @ApiModelProperty("银行卡号") + private String bankCard; + + @ApiModelProperty("是否默认1否;2 是 目前不用") + private Long isDefault; +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/resp/BlockPageResp.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/resp/BlockPageResp.java new file mode 100644 index 0000000..829795a --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/resp/BlockPageResp.java @@ -0,0 +1,50 @@ +package com.ruoyi.controller.resp; + +import com.ruoyi.vo.UserInfo; +import lombok.Data; + +import java.util.Date; + +/** + * @author liwenlong + * @date 2023/4/3 9:16 + */ +@Data +public class BlockPageResp { + + + /** + * 主键id + */ + private Long id; + /** + * 被拉黑用户id + */ + private Long blockUserId; + /** + * 被拉黑用户类型 1 用户 2 商家 + */ + private Integer blockUserType; + /** + * 创建时间 + */ + private Date createTime; + + /** + * 拉黑用户昵称 + */ + private String nickname; + + /** + * 拉黑用户头像 + */ + private String avatar; + + /** + * 是否拉黑 1 没有 2 拉黑 + */ + private Integer isBlock; + + private UserInfo userInfo; + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/resp/CanReceivePageVO.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/resp/CanReceivePageVO.java new file mode 100644 index 0000000..2b4c6e7 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/resp/CanReceivePageVO.java @@ -0,0 +1,27 @@ +package com.ruoyi.controller.resp; + +import lombok.Data; + +import java.math.BigDecimal; +import java.util.Date; + +/** + * @Author 刘耀 + * @Date 2022/1/15 15:03 + */ +@Data +public class CanReceivePageVO { + private Long couponId;//平台优惠券id + private Long customerCouponId;//用户优惠券id + private String title;//优惠券名称 + private Date beginTime; + private Date endTime; + private Integer hasReceive;//是否已经领取 1 领取了 2 没有 + private Integer canReceiveTimes;//还可以领取几次 + private Integer type;//优惠券类型 1 满减 2 打折,3 直减和4 直接打折【不需要满足什么条件】 + private BigDecimal fullPrice;//满xx + private BigDecimal minusPrice;//减xx + private BigDecimal ratio; + private Integer timeType; + private Integer days; +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/resp/CommentNum.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/resp/CommentNum.java new file mode 100644 index 0000000..b2be0c1 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/resp/CommentNum.java @@ -0,0 +1,21 @@ +package com.ruoyi.controller.resp; + +import lombok.Data; + +/** + * @author a + * @date 2023/11/29 20:01 + */ +@Data +public class CommentNum { + + private Long linkId; + + private Long postId; + + private Long worksId; + + private Long voteId; + + private Integer commentNum; +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/resp/CommentResp.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/resp/CommentResp.java new file mode 100644 index 0000000..7de41b4 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/resp/CommentResp.java @@ -0,0 +1,102 @@ +package com.ruoyi.controller.resp; + +import lombok.Data; + +import java.util.Date; + +/** + * @author a + * + */ +@Data +public class CommentResp { + + + /** + * 评论id + */ + private Long id; + + + /** + * 上级评论id + */ + private Long parentId; + + /** + * 评论内容 + */ + private String content; + + + /** + * 点赞数 + */ + private Integer likeNum; + + /** + * 评论数 + */ + private Integer commentNum; + + /** + * 是否点赞1没有 2点赞 + */ + private Integer isLike; + + /** + * 评论人昵称 + */ + private String nickname; + + /** + * 评论人用户id + */ + private Long userId; + + + /** + * 评论人用户类型 1 设计师 2 表现师 + */ + private Integer userType; + + /** + * 评论人头像 + */ + private String avatar; + + /** + * 上级评论用户id + */ + private Long parentUserId; + + /** + * 评论人用户类型 1 设计师 2 表现师 + */ + private Integer parentUserType; + + /** + * 上级评论用户名称 + */ + private String parentUserName; + + + /** + * 上级评论用户头像 + */ + private String parentAvatar; + + + /** + * 评论时间 + */ + private Date createTime; + + + /** + * 图片 + */ + private String image; + + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/resp/FollowPageResp.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/resp/FollowPageResp.java new file mode 100644 index 0000000..41b9239 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/resp/FollowPageResp.java @@ -0,0 +1,37 @@ +package com.ruoyi.controller.resp; + +import com.ruoyi.vo.UserInfo; +import lombok.Data; + +import java.util.Date; + +/** + * @Author liwenlong + * @Date 2022/1/15 14:04 + */ +@Data +public class FollowPageResp { + + /** + * 关注id + */ + private Long id; + + /** + * 被关注用户类型 + */ + private Integer userType; + + /** + * 被关注用户id + */ + private Long userId; + + /** + * 关注时间 + */ + private Date createTime; + + private UserInfo userInfo; + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/resp/GoeasyResult.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/resp/GoeasyResult.java new file mode 100644 index 0000000..ee7ff06 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/resp/GoeasyResult.java @@ -0,0 +1,30 @@ +package com.ruoyi.controller.resp; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.experimental.Accessors; + +import java.util.Date; + +@Data +@Accessors(chain = true) +public class GoeasyResult { + + private Integer code; + + private String content; + + public GoeasyResult() { + } + + public GoeasyResult(Integer code,String content) { + this.content = content; + this.code = code; + } + + public static GoeasyResult success() { + return new GoeasyResult(200,"success"); + } +} + + diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/resp/IllegalDeductionPageResp.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/resp/IllegalDeductionPageResp.java new file mode 100644 index 0000000..3b708ac --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/resp/IllegalDeductionPageResp.java @@ -0,0 +1,41 @@ +package com.ruoyi.controller.resp; + +import com.ruoyi.common.annotation.Excel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.math.BigDecimal; + +/** + * @author a + * @date 2023/11/8 17:08 + */ +@Data +public class IllegalDeductionPageResp { + + @ApiModelProperty("主键id") + private Long id; + + @ApiModelProperty("删除标志 1正常 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("提现记录id") + @Excel(name = "提现记录id") + private Long withdrawalRecordId; + + @ApiModelProperty("表现师id") + @Excel(name = "表现师id") + private Long storeId; + + @ApiModelProperty("类型 1平台手动添加 2 平台手动扣除 3提现抵消 4提现失败返还") + private Integer type; + + @ApiModelProperty("数值") + private BigDecimal price; + + @ApiModelProperty("当前扣款金额") + private BigDecimal currentPrice; + + @ApiModelProperty("类型 1平台手动添加 2 平台手动扣除 3提现抵消 4提现失败返还") + private String record; +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/resp/IntegralPageResp.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/resp/IntegralPageResp.java new file mode 100644 index 0000000..ace7a9a --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/resp/IntegralPageResp.java @@ -0,0 +1,33 @@ +package com.ruoyi.controller.resp; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.math.BigDecimal; +import java.util.Date; + +/** + * @author a + * @date 2024/1/29 17:32 + */ +@Data +public class IntegralPageResp { + + @ApiModelProperty("租户号") + private Long id; + + @ApiModelProperty("积分") + private BigDecimal integral; + + @ApiModelProperty("积分余额") + private BigDecimal currentBalance; + + @ApiModelProperty("记录类型") + private Integer record; + + @ApiModelProperty("记录类型") + private String recordName; + + @ApiModelProperty("创建时间") + private Date createTime; +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/resp/RankingResp.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/resp/RankingResp.java new file mode 100644 index 0000000..937a2b1 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/resp/RankingResp.java @@ -0,0 +1,37 @@ +package com.ruoyi.controller.resp; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.math.BigDecimal; + +/** + * @author a + * @date 2023/10/19 9:51 + */ +@Data +public class RankingResp { + + + @ApiModelProperty(value = "推广员id") + private Long id; + + @ApiModelProperty(value = "姓名") + private String name; + + @ApiModelProperty(value = "用户昵称") + private String nickname; + + @ApiModelProperty(value = "用户头像") + private String avatar; + + + @ApiModelProperty(value = "排名") + private Integer ranking; + + @ApiModelProperty(value = "佣金收益") + private BigDecimal income; + + @ApiModelProperty(value = "推广人数") + private Integer inviteNum; +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/resp/RefereeUserPageResp.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/resp/RefereeUserPageResp.java new file mode 100644 index 0000000..17a0b6a --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/resp/RefereeUserPageResp.java @@ -0,0 +1,58 @@ +package com.ruoyi.controller.resp; + +import com.ruoyi.vo.UserInfo; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.math.BigDecimal; +import java.util.Date; + +/** + * @author a + * @date 2023/4/17 10:42 + */ +@Data +public class RefereeUserPageResp { + + private Long id; + + @ApiModelProperty(value = "头像") + private String avatar; + + @ApiModelProperty(value = " 昵称") + private String nickname; + + @ApiModelProperty(value = "创建时间") + private Date createTime; + + @ApiModelProperty(value = "用户类型") + private Integer userType; + + @ApiModelProperty(value = "用户id") + private Long userId; + + + @ApiModelProperty(value = "等级图标") + private String icon; + + @ApiModelProperty(value = "镶边类型 1 不镶边 2 镶银边 3 镶金边") + private Integer edgePipingType; + + @ApiModelProperty("从业时间") + private Date practiceDate; + + @ApiModelProperty("擅长领域") + private String specialityArea; + + @ApiModelProperty("区域") + private String area; + + @ApiModelProperty("用户信息") + private UserInfo userInfo; + + @ApiModelProperty(value = "排名") + private Integer ranking; + + @ApiModelProperty(value = "累计积分收益") + private BigDecimal integral; +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/resp/SaleDataResp.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/resp/SaleDataResp.java new file mode 100644 index 0000000..76d400a --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/resp/SaleDataResp.java @@ -0,0 +1,32 @@ +package com.ruoyi.controller.resp; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.math.BigDecimal; + +/** + * @author a + * @date 2023/11/28 18:57 + */ +@Data +public class SaleDataResp { + + @ApiModelProperty(value = "客户数") + private Integer num; + + @ApiModelProperty(value = "累计金额") + private BigDecimal amount; + + @ApiModelProperty(value = "累计佣金") + private BigDecimal income; + + @ApiModelProperty(value = "余额") + private BigDecimal balance; + + @ApiModelProperty(value = "可提现金额") + private BigDecimal withdrawableAmount; + + @ApiModelProperty(value = "已提现金额") + private BigDecimal withdrawnAmount; +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/resp/SaleDetailPageResp.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/resp/SaleDetailPageResp.java new file mode 100644 index 0000000..0c7c436 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/resp/SaleDetailPageResp.java @@ -0,0 +1,105 @@ +package com.ruoyi.controller.resp; + +import com.fasterxml.jackson.annotation.JsonFormat; +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.vo.UserInfo; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.math.BigDecimal; +import java.util.Date; + +/** + * @author a + * @date 2023/10/20 9:34 + */ +@Data +public class SaleDetailPageResp { + + + @ApiModelProperty("租户号") + private Long id; + + @ApiModelProperty("创建时间") + private Date createTime; + + @ApiModelProperty("删除标志;1 正常 2 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("订单标题") + private String title; + + @ApiModelProperty("素材") + private String sourceMaterial; + + @ApiModelProperty("订单金额") + private BigDecimal amount; + + @ApiModelProperty("实际支付金额") + private BigDecimal payAmount; + + @ApiModelProperty("提出改价的用户身份 1 设计师 2 表现师") + private Integer changeUserType; + + @ApiModelProperty("改价状态 1 待确认 2 已确认") + @Excel(name = "改价状态 1 待确认 2 已确认") + private Integer changeStatus; + + @ApiModelProperty("对图时间") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm") + private Date confirmDate; + + @ApiModelProperty("设计师id") + private Long customerId; + + @ApiModelProperty("表现师id") + private Long storeId; + + @ApiModelProperty("内容") + @Excel(name = "内容") + private String content; + + @ApiModelProperty("订单状态;-1 已取消 1待确认 2进行中 3待收图 4待评价 5已评价 ") + private Integer status; + + @ApiModelProperty("首款") + private BigDecimal firstPrice; + @ApiModelProperty("支付状态 1 未支付 2 已支付") + private Integer firstStatus; + + @ApiModelProperty("图纸张数") + private Integer drawingNum; + + @ApiModelProperty("订单来源 1 设计师自己下单 2 表现师帮设计师下单") + private Integer sourceUserType; + + @ApiModelProperty("作品类型名称") + private String worksTypeName; + + @ApiModelProperty("用户(设计师)信息") + private UserInfo customerInfo; + + @ApiModelProperty("表现师信息") + private UserInfo storeInfo; + + @ApiModelProperty("申诉状态;1无申诉 2申诉中 3申诉完成") + private String appealStatus; + + @ApiModelProperty("申诉id") + private Long appealId; + + @ApiModelProperty("申请用户类型 1 设计师 2 表现师") + @Excel(name = "申请用户类型 1 设计师 2 表现师") + private Integer appealUserType; + + @ApiModelProperty("是否可以接单 1 不可以 2 可以") + private Integer isReceivingOrder = 1; + + @ApiModelProperty("1 普通 2 高端 3酷家乐") + private Integer ifHighend; + + + @ApiModelProperty("收益") + private BigDecimal saleAmount; + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/resp/SaleUserPageResp.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/resp/SaleUserPageResp.java new file mode 100644 index 0000000..f1336e5 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/resp/SaleUserPageResp.java @@ -0,0 +1,27 @@ +package com.ruoyi.controller.resp; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + * @author a + * @date 2023/10/19 10:06 + */ +@Data +public class SaleUserPageResp { + + @ApiModelProperty(value = "用户昵称") + private String nickname; + + @ApiModelProperty(value = "用户头像") + private String avatar; + + @ApiModelProperty(value = "是否高端认证 1 没有 2认证") + private Integer ifHighend; + + @ApiModelProperty(value = "等级图标") + private String icon; + + @ApiModelProperty(value = "镶边类型 1 不镶边 2 镶银边 3 镶金边") + private Integer edgePipingType; +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/resp/ShieldPageResp.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/resp/ShieldPageResp.java new file mode 100644 index 0000000..cc3b400 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/resp/ShieldPageResp.java @@ -0,0 +1,49 @@ +package com.ruoyi.controller.resp; + +import com.ruoyi.vo.UserInfo; +import lombok.Data; + +import java.util.Date; + +/** + * @author a + * @date 2023/4/3 9:41 + */ +@Data +public class ShieldPageResp { + + /** + * 主键id + */ + private Long id; + /** + * 被屏蔽用户id + */ + private Long shieldUserId; + /** + * 被屏蔽用户类型 1 用户 2 商家 + */ + private Integer shieldUserType; + /** + * 创建时间 + */ + private Date createTime; + + /** + * 屏蔽用户昵称 + */ + private String nickname; + + /** + * 屏蔽用户头像 + */ + private String avatar; + + /** + * 是否屏蔽 1 没有 2 屏蔽 + */ + private Integer isShield; + + private UserInfo userInfo; + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/resp/StorePageResp.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/resp/StorePageResp.java new file mode 100644 index 0000000..efb6918 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/resp/StorePageResp.java @@ -0,0 +1,98 @@ +package com.ruoyi.controller.resp; + +import com.fasterxml.jackson.annotation.JsonFormat; +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.vo.UserInfo; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.math.BigDecimal; +import java.util.Date; + +/** + * @author a + * @date 2023/10/17 18:52 + */ +@Data +public class StorePageResp { + + @ApiModelProperty(value = "主键id") + private Long id; + + @ApiModelProperty(value = "用户类型") + private Integer userType = 2; + + @ApiModelProperty(value = "昵称") + private String nickname; + + @ApiModelProperty(value = "头像") + private String avatar; + + @ApiModelProperty(value = "绑定企业id") + private Long bindEnterpriseId; + + @ApiModelProperty(value = "入行时间") + @JsonFormat(pattern = "yyyy") + private Date enterDate; + + @ApiModelProperty(value = "所属区域") + private String area; + + @ApiModelProperty(value = "在线状态;1:在线,2离线") + private Integer onlineStatus; + + @ApiModelProperty(value = "在线时长(单位:分钟)") + private Integer onlineDuration; + + + @ApiModelProperty(value = "等级名称") + private String levelName; + + @ApiModelProperty(value = "等级图标") + private String icon; + + @ApiModelProperty(value = "镶边类型 1 不镶边 2 镶银边 3 镶金边") + private String edgePipingType; + + @ApiModelProperty(value = "评分") + private BigDecimal star; + + + @ApiModelProperty(value = "累计订单数量") + private Integer orderNum; + + @ApiModelProperty(value = "累计服务金额") + private BigDecimal orderAmount; + + @ApiModelProperty(value = "当月订单数量") + private Integer orderMonthNum; + + + @ApiModelProperty("是否是高端客户 1普通 2 高端 ") + private Integer ifHighend; + + @ApiModelProperty("是否关注 1没有 2 关注 ") + private Integer isFollow; + + @ApiModelProperty("擅长领域") + private String specialityArea; + + @ApiModelProperty(value = "用户信息") + private UserInfo userInfo; + + @ApiModelProperty(value = "报价单图片") + private String quotationImage; + + @ApiModelProperty(value = "制作周期") + private String productionCycle; + + @ApiModelProperty(value = "人数") + private String numberPeople; + + @ApiModelProperty(value = "价格定位") + private String pricePosition; + + @ApiModelProperty("企业微信号") + private String wecom; + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/resp/UserResultInfo.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/resp/UserResultInfo.java new file mode 100644 index 0000000..afe8844 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/resp/UserResultInfo.java @@ -0,0 +1,118 @@ +package com.ruoyi.controller.resp; + +import com.fasterxml.jackson.annotation.JsonFormat; +import com.ruoyi.vo.UserInfo; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; +import java.math.BigDecimal; +import java.util.Date; + +/** + * app用户表 + * + * @author 李文龙 + * @date 2022/01/13 14:17 + */ +@Data +public class UserResultInfo implements Serializable { + + @ApiModelProperty(value = "用户id") + private Long userId; + + @ApiModelProperty(value = "用户类型 1 用户 2 代理商 3 企业") + private Integer userType; + + @ApiModelProperty(value = "用户状态 1 正常 2 禁用") + private Date createTime; + + @ApiModelProperty(value = "更新时间") + private Date updateTime; + + @ApiModelProperty(value = "删除标识 1 正常 2 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty(value = "用户名") + private String nickname; + + @ApiModelProperty(value = "头像") + private String avatar; + + @ApiModelProperty(value = "手机号") + private String mobile; + + @ApiModelProperty(value = "登录密码") + private String loginPwd; + + @ApiModelProperty(value = "支付密码") + private String payPwd; + + @ApiModelProperty(value = "注销时间") + private Date cancellationTime; + + @ApiModelProperty(value = "手机id") + private String clientId; + + @ApiModelProperty(value = "微信openid") + private String wxOpenid; + + @ApiModelProperty(value = "apple_openid") + private String appleOpenid; + + @ApiModelProperty(value = "余额") + private BigDecimal balance; + + @ApiModelProperty(value = "是否推送关闭 1 关闭 2 不关闭") + private Integer closeMessage; + + @ApiModelProperty(value = "性别 S:未知,M:男,F:女") + private String sex; + + @ApiModelProperty(value = "评分") + private BigDecimal star; + + @ApiModelProperty("是否认证 1 未认证 2 已认证") + private Integer isAuth; + + @ApiModelProperty("是否认证 1 未认证高端 2 已认证") + private Integer ifHighend; + + @ApiModelProperty(value = "等级名称") + private String levelName; + + @ApiModelProperty(value = "等级图标") + private String icon; + + @ApiModelProperty(value = "镶边类型 1 不镶边 2 镶银边 3 镶金边") + private String edgePipingType; + + + @ApiModelProperty(value = "在线状态;1:在线,2离线") + private Integer onlineStatus; + + @ApiModelProperty(value = "在线时长;分钟") + private Integer onlineDuration; + + @ApiModelProperty(value = "背景图") + private String backgroundImage; + + @ApiModelProperty(value = "用户信息") + private UserInfo userInfo; + + @ApiModelProperty(value = "区域") + private String area; + + @ApiModelProperty(value = "入行时间") + @JsonFormat(pattern = "yyyy") + private Date enterDate; + + @ApiModelProperty(value = "邀请码") + private String invitationCode; + + @ApiModelProperty(value = "充值抵用金") + private BigDecimal giveBalance; + + @ApiModelProperty(value = "积分") + private BigDecimal integral; +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/resp/UserWithdrawalWayResp.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/resp/UserWithdrawalWayResp.java new file mode 100644 index 0000000..9436ed0 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/resp/UserWithdrawalWayResp.java @@ -0,0 +1,56 @@ +package com.ruoyi.controller.resp; + +import lombok.Data; + +/** + * @Author liwenlong + */ +@Data +public class UserWithdrawalWayResp { + + /** + * 用户提现方式id + */ + private Long id; + + /** + * 平台提现id + */ + private Long ptId; + + /** + * 提现账户 + */ + private String cashAccount; + + /** + * 联系方式 + */ + private String contactWay; + + /** + * 联系人 + */ + private String linkman; + + /** + * 提现方式 + */ + private String name; + + /** + * 是否默认1否 2 是 + */ + private Integer isDefault; + + /** + * + */ + private String logo; + + private String areaCode; + + private Integer isBank; + + private String accountOpeningSubBranch; +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/resp/WalletPageResp.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/resp/WalletPageResp.java new file mode 100644 index 0000000..a2f8a17 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/resp/WalletPageResp.java @@ -0,0 +1,71 @@ +package com.ruoyi.controller.resp; + +import lombok.Data; + +import java.math.BigDecimal; + +/** + * @author liwenlong + * @date 2023/3/28 15:42 + */ +@Data +public class WalletPageResp { + + + /** + * 钱包记录id + */ + private Long id; + + /** + * 类型 具体看 WalletDetailEnums 枚举类 + */ + private Integer recordType; + + /** + * 类型名称 + */ + private String record; + + /** + * 来源id + */ + private Long objectId; + + /** + * 金额 + */ + private BigDecimal price; + + /** + * 余额 + */ + private BigDecimal currentBalance; + + /** + * 创建时间 + */ + private String createTime; + + /** + * 可提现状态 1 不可提现 2 可提现 + */ + private Integer isWithdrawal; + + /** + * 订单号 + */ + private String orderNo; + + /** + * 是否是快捷支付 1是 2 否 + */ + private Integer isOnline; + + /** + * 是否是抵用金记录 1是 2 否 + */ + private Integer isGivePay; + + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/resp/WithdrawalRecordPageResp.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/resp/WithdrawalRecordPageResp.java new file mode 100644 index 0000000..c746485 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/resp/WithdrawalRecordPageResp.java @@ -0,0 +1,85 @@ +package com.ruoyi.controller.resp; + +import com.baomidou.mybatisplus.annotation.TableField; +import com.ruoyi.frequency.klkwithdrawalrecord.entity.KlkWithdrawalRecord; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.math.BigDecimal; +import java.util.Date; + +/** + * @Author liwenlong + * @Date 2022/1/17 11:33 + */ +@Data +public class WithdrawalRecordPageResp { + + /** + * 提现记录id + */ + private Long id; + + /** + * 提现列表标题 + */ + private String title; + + /** + * + */ + private String name; + + private Date createTime; + + private BigDecimal amount; + + private Integer status; + + private BigDecimal serviceCharge; + + private BigDecimal totalAmount; + + /** + * 用户备注 + */ + private String remarks; + + /** + * 转账凭证 + */ + private String transferVoucher; + + + private String refuseReason; + + + @ApiModelProperty("开户行") + private String bank; + + @ApiModelProperty("开户支行") + private String subbranch; + + @ApiModelProperty("银行卡") + private String bankCard; + + @ApiModelProperty("姓名") + private String fullName; + + @ApiModelProperty("申请时间") + private Date applyTime; + + @ApiModelProperty("审核通过时间") + private Date processTime; + + @ApiModelProperty("转账完成时间") + private Date transferFinishTime; + + + @ApiModelProperty(value = "扣款金额") + private BigDecimal violationDeduction; + + @ApiModelProperty(value = "拉卡拉提现记录") + private KlkWithdrawalRecord klkWithdrawalRecord; + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/resp/WithdrawalRecordPageTimeResp.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/resp/WithdrawalRecordPageTimeResp.java new file mode 100644 index 0000000..1ee767f --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/controller/resp/WithdrawalRecordPageTimeResp.java @@ -0,0 +1,20 @@ +package com.ruoyi.controller.resp; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.math.BigDecimal; +import java.util.List; + +@Data +public class WithdrawalRecordPageTimeResp { + + @ApiModelProperty("时间日期") + private String time; + + @ApiModelProperty("收入金额") + private BigDecimal totalAmount; + + @ApiModelProperty("提现记录") + private List withdrawalRecordPageRespList; +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/enums/IntegralDetailEnums.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/enums/IntegralDetailEnums.java new file mode 100644 index 0000000..3c154fb --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/enums/IntegralDetailEnums.java @@ -0,0 +1,60 @@ +package com.ruoyi.enums; + +import java.util.Arrays; + +/** + * 积分记录枚举 + * @Author liwenlong + */ +public enum IntegralDetailEnums { + + /** + * 商城订单支付 + */ + ORDER_PAY(1, "订单支付"), + /** + * 用户分享佣金收益 + */ + SHARE_TEAM_COMMISSION(2, "订单积分"), + + + /** + * 平台转入 + */ + PLAT_ADD(6, "平台转入"), + + /** + * 平台扣除 + */ + PLAT_SUB(7, "平台扣除"), + + /** + * 邀请注册赠送积分 + */ + REFEREE_SEND(8, "邀请注册赠送积分"), + ; + + private final Integer code; + private final String name; + + public static String getName(Integer code) { + return getIntegralDetailEnums(code).getName(); + } + + public static IntegralDetailEnums getIntegralDetailEnums(Integer code) { + return Arrays.stream(IntegralDetailEnums.values()).filter(c->c.getCode().equals(code)).findFirst().get(); + } + + IntegralDetailEnums(Integer code, String name) { + this.code = code; + this.name = name; + } + + public Integer getCode() { + return code; + } + + public String getName() { + return name; + } +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/enums/LoginEnums.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/enums/LoginEnums.java new file mode 100644 index 0000000..db930fa --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/enums/LoginEnums.java @@ -0,0 +1,70 @@ +package com.ruoyi.enums; + +import java.util.Arrays; + +/** + * 登陆类型枚举 + * @Author liwenlong + */ +public enum LoginEnums { + + /** + * 验证码 + */ + code_login(1, "验证码"), + + /** + * 密码 + */ + pwd_login(2, "密码"), + + + /** + * 一键登录 + */ + one_click_login(3, "一键登录"), + + /** + * 微信登录 + */ + wechat_login(4, "微信登录"), + + /** + * 小程序登录 + */ + applet_login(5, "小程序登录"), + + /** + * 苹果登录 + */ + apple_login(6, "苹果登录"), + + ; + + private final Integer code; + private final String name; + + public static String getName(Integer code) { + return getLoginEnums(code).name; + } + + + public static LoginEnums getLoginEnums(Integer code) { + return Arrays.stream(LoginEnums.values()).filter(c->c.getCode().equals(code)).findAny().get(); + } + + LoginEnums(Integer code, String name) { + this.code = code; + this.name = name; + } + + public Integer getCode() { + return code; + } + + public String getName() { + return name; + } + + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/enums/MallExceptionEnum.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/enums/MallExceptionEnum.java new file mode 100644 index 0000000..8fcc22c --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/enums/MallExceptionEnum.java @@ -0,0 +1,58 @@ +package com.ruoyi.enums; + + +import com.ruoyi.common.exception.enums.abs.AbstractBaseExceptionEnum; + +/** + * @author liwenlong + * @date 2021/11/1 19:34 + */ +public enum MallExceptionEnum implements AbstractBaseExceptionEnum { + + COUPON_RECEIVE_FINISH("优惠券已被领取完"), + COUPON_NOT_EXIST("优惠券已被领取完"), + + DELETER_SHOPPING_CAR_ERROR("删除购物车失败"), + GOODS_DEL_FLAG("商品已下架"), + NOT_STOCK("库存不足"), + + ORDER_STATUS_ERROR( "订单状态错误 请刷新数据"), + ORDER_NOT_SEND( "商品未发货 无需申请退货"), + + ORDER_REPEAT_APPLY( "请勿重复申请"), + UPDATE_STOREK_ERROR( "修改库存错误"), + UPDATE_SALES_ERROR( "修改销量错误"), + + CREATE_ORDER_ERROR( "创建订单失败"), + + ORDER_BE_ROBBED( "订单已被抢"), + + ORDER_NOT_RESERVATION_TIME( "预约时间未到,请勿操作"), + + ORDER_NOT_AUTH_EXCEPTION( "无权限抢单"), + + ; + + private Integer code; + private String message; + + private MallExceptionEnum(int code, String message) { + this.code = code; + this.message = message; + } + + private MallExceptionEnum(String message) { + this.code = 500; + this.message = message; + } + + @Override + public Integer getCode() { + return this.code; + } + + @Override + public String getMessage() { + return this.message; + } +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/enums/PlatformRecordEnums.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/enums/PlatformRecordEnums.java new file mode 100644 index 0000000..2712708 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/enums/PlatformRecordEnums.java @@ -0,0 +1,60 @@ +package com.ruoyi.enums; + +import java.util.Arrays; + +/** + * 平台流水 + * @Author liwenlong + */ +public enum PlatformRecordEnums { + + + PLAT_BASE(0, "资金原始金额"), + ORDER_PAY(1, "订单首款支付"), + + ORDER_RETURN(2, "订单首款退款"), + ORDER_SECOND_PAY(3, "订单尾款支付"), + TEAM_COMMISSION(4, "推广员分佣"), + STORE_ORDER_INCOME(5, "表现师收益扣除"), + PLATFORM_AUTH_PAY(6, "表现师平台认证"), + HEIGHT_AUTH_PAY(7, "表现师高端认证"), + BOND_PAY(8, "保证金缴纳"), + BOND_WITHDRAWAL(9, "保证金提现"), + BOND_WITHDRAWAL_RETURN(10, "保证金提现返还"), + RECHARGE_BALANCE(11, "设计师充值"), + WITH_DEDU(12, "表现师提现"), + WITH_FAIL_RETURN(13, "表现师提现返还"), + VIOLATION_DEDUCTION(14, "表现师扣款"), + VIOLATION_DEDUCTION_RETURN(15, "表现师扣款退回"), + PLAT_ADD(16, "平台手动调整余额"), + PLAT_SUB(17, "平台手动调整余额"), + + MALL_ORDER_PAY(18, "商城订单支付"), + + + ; + + private final Integer code; + private final String name; + + public static String getName(Integer code) { + return getPlatformRecordEnums(code).name; + } + + public static PlatformRecordEnums getPlatformRecordEnums(Integer code) { + return Arrays.stream(PlatformRecordEnums.values()).filter(c->c.getCode().equals(code)).findFirst().get(); + } + + PlatformRecordEnums(Integer code, String name) { + this.code = code; + this.name = name; + } + + public Integer getCode() { + return code; + } + + public String getName() { + return name; + } +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/enums/WalletDetailEnums.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/enums/WalletDetailEnums.java new file mode 100644 index 0000000..4c7c381 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/enums/WalletDetailEnums.java @@ -0,0 +1,116 @@ +package com.ruoyi.enums; + +import java.util.Arrays; + +/** + * 提现记录枚举 + * @Author liwenlong + */ +public enum WalletDetailEnums { + + /** + * 佣金收益(销售佣金) + */ + TEAM_COMMISSION(1, "佣金收益"), + + /** + * 提现申请扣除 + */ + WITH_DEDU(2, "提现申请扣除"), + + /** + * 提现失败返还 + */ + WITH_FAIL_RETURN(3, "提现失败返还"), + + /** + * 充值余额 + */ + RECHARGE_BALANCE(4, "充值余额"), + + /** + * 订单支付 + */ + ORDER_PAY(5, "订单支付"), + + /** + * 平台转入 + */ + PLAT_ADD(6, "平台转入"), + + /** + * 平台扣除 + */ + PLAT_SUB(7, "平台扣除"), + + + /** + * 订单收入(表现师) + */ + ORDER_INCOME(8, "订单收入"), + + /** + * 订单退款 + */ + ORDER_RETURN(9, "订单退款"), + + /** + * 订单支付 + */ + PLATFORM_AUTH_PAY(10, "平台认证支付"), + + HEIGHT_AUTH_PAY(11, "高端认证支付"), + + BOND_PAY(12, "保证金支付"), + + RECHARGE_GIVE_BALANCE(13, "充值赠送抵用金"), + + ADJUST_PRICE_PAY(14, "订单调价"), + + DEPOSIT_REFUND(15, "定金退还"), + + + GIVE_ORDER_PAY(16, "抵用金支付"), + + MALL_ORDER_PAY(17, "商城订单支付"), + + /** + * 订单退款 + */ + GIVE_ORDER_RETURN(18, "订单退款"), + + /** + * 设计师邀请注册赠送抵用金 + */ + GIVE_BALANCE(19, "邀请注册赠送抵用金"), + + BOND_WITHDRAWAL(20, "保证金提现"), + + + BOND_RECHARGE(21, "保证金充值"), + ; + + private final Integer code; + private final String name; + + public static String getName(Integer code) { + return getWalletDetailEnums(code).name; + } + + public static WalletDetailEnums getWalletDetailEnums(Integer code) { + return Arrays.stream(WalletDetailEnums.values()).filter(c->c.getCode().equals(code)).findFirst().get(); + } + + WalletDetailEnums(Integer code, String name) { + this.code = code; + this.name = name; + } + + public Integer getCode() { + return code; + } + + public String getName() { + return name; + } +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/enums/mallorder/MallOrderStatusEnums.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/enums/mallorder/MallOrderStatusEnums.java new file mode 100644 index 0000000..4c0595d --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/enums/mallorder/MallOrderStatusEnums.java @@ -0,0 +1,55 @@ +package com.ruoyi.enums.mallorder; + +import java.util.Arrays; + +/** + * 商城订单状态枚举 + * @Author liwenlong + */ +public enum MallOrderStatusEnums { + + + 已取消(-1, "取消"), + + 待付款(1, "待付款"), + + 待发货(2, "待发货"), + + 已发货(3, "已发货"), + + 已完成(4, "已完成"), + + 已到账(5, "已到账"), + + 已评价(6, "已评价"), + + + ; + + private final Integer code; + private final String name; + + public static String getName(Integer code) { + return getPayEnums(code).name; + } + + + public static MallOrderStatusEnums getPayEnums(Integer code) { + return Arrays.stream(MallOrderStatusEnums.values()).filter(c->c.getCode().equals(code)).findFirst().get(); + } + + MallOrderStatusEnums(Integer code, String name) { + this.code = code; + this.name = name; + } + + public Integer getCode() { + return code; + } + + public String getName() { + return name; + } + + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/enums/mallorder/RefundStatusEnums.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/enums/mallorder/RefundStatusEnums.java new file mode 100644 index 0000000..3d1804d --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/enums/mallorder/RefundStatusEnums.java @@ -0,0 +1,45 @@ +package com.ruoyi.enums.mallorder; + +/** + * 商城订单状态枚举 + * @Author liwenlong + */ +public enum RefundStatusEnums { + + 待审核(1, "申请退款退货"), + + 商家同意退款退货(2, "商家同意退款退货"), + + 用户发货(3, "用户发货"), + + 商家确认收货(4, "商家确认收货"), + + 商家拒绝退款退货(5, "商家拒绝退款退货"), + + ; + + private Integer code; + private String name; + + public static String getName(Integer code) { + for (RefundStatusEnums c : RefundStatusEnums.values()) { + if (c.getCode().equals(code)) { + return c.name; + } + } + return null; + } + + RefundStatusEnums(Integer code, String name) { + this.code = code; + this.name = name; + } + + public Integer getCode() { + return code; + } + + public String getName() { + return name; + } +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/enums/message/AppMessageEnums.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/enums/message/AppMessageEnums.java new file mode 100644 index 0000000..791d302 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/enums/message/AppMessageEnums.java @@ -0,0 +1,87 @@ +package com.ruoyi.enums.message; + +import java.util.Arrays; + +/** + * 系统消息枚举 + * @Author liwenlong + */ +public enum AppMessageEnums { + + /** + * 系统消息 + */ + APP_MESSAGE(1, "您有新的系统消息",""), + + /** + * 平台认证 + */ + AUTH_MESSAGE_SUSESS(2, "平台认证","您的平台认证审核通过"), + + /** + * 平台认证 + */ + AUTH_MESSAGE_FAIL(3, "平台认证","您的平台认证审核失败"), + + /** + * 提现审核 + */ + WITHDRAWAL_SUCCESS(4, "提现审核","您的提现审核通过"), + + /** + * 提现审核 + */ + WITHDRAWAL_FAIL(5, "提现审核","您的提现审核失败"), + + /** + * 保证金提现审核 + */ + BOND_WITHDRAWAL_SUCCESS(6, "保证金退还审核","您的保证金退还审核通过"), + + /** + * 保证金提现审核 + */ + BOND_WITHDRAWAL_FAIL(7, "保证金退还审核","您的保证金退还审核失败"), + ; + + private Integer code; + private String title; + private final String content; + + public static String getTitle(Integer code) { + return getAppMessageEnums(code).title; + } + + public static String getContent(Integer code) { + return getAppMessageEnums(code).content; + } + + public static AppMessageEnums getAppMessageEnums(Integer code) { + return Arrays.stream(AppMessageEnums.values()).filter(c->c.getCode().equals(code)).findFirst().get(); + } + + AppMessageEnums(Integer code, String title, String content) { + this.code = code; + this.title = title; + this.content = content; + } + + AppMessageEnums(String content) { + this.content = content; + } + + public Integer getCode() { + return code; + } + + public String getTitle() { + return title; + } + + + public String getContent() { + return content; + } + + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/enums/message/InteractionMessageEnums.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/enums/message/InteractionMessageEnums.java new file mode 100644 index 0000000..4ae387c --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/enums/message/InteractionMessageEnums.java @@ -0,0 +1,88 @@ +package com.ruoyi.enums.message; + +import io.swagger.annotations.ApiModelProperty; + +import java.util.Arrays; + +/** + * 互动消息枚举 + * @Author liwenlong + */ +public enum InteractionMessageEnums { + + @ApiModelProperty(value = "点赞帖子",example = "LIKE_POST") + LIKE_POST(1, "赞了你的动态","赞了你的动态"), + + @ApiModelProperty(value = "点赞作品",example = "LIKE_WORKS") + LIKE_WORKS(2, "赞了你的作品","赞了你的作品"), + + @ApiModelProperty(value = "点赞帖子评论",example = "LIKE_COMMENT") + LIKE_POST_COMMENT(3, "赞了你的评论","赞了你的评论"), + + @ApiModelProperty(value = "评论帖子",example = "COMMENT_POST") + COMMENT_POST(4, "评论了你的动态","评论了你的动态"), + + @ApiModelProperty(value = "评论作品",example = "COMMENT_WORKS") + COMMENT_WORKS(5, "评论了你的作品","评论了你的作品"), + + @ApiModelProperty(value = "关注用户",example = "FOLLOW") + FOLLOW(6, "关注了你","关注了你"), + + @ApiModelProperty(value = "回复帖子评论",example = "REPLY_POST_COMMENT") + REPLY_POST_COMMENT(7, "回复了你的评论","回复了你的评论"), + + @ApiModelProperty(value = "回复作品",example = "REPLY_WORKS_COMMENT") + REPLY_WORKS_COMMENT(8, "回复了你的评论","回复了你的评论"), + + @ApiModelProperty(value = "评论新闻",example = "COMMENT_NEWS") + COMMENT_NEWS(9, "评论了你的新闻","评论了你的新闻"), + + @ApiModelProperty(value = "回复新闻",example = "REPLY_NEWS_COMMENT") + REPLY_NEWS_COMMENT(10, "回复了你的评论","回复了你的评论"), + + + @ApiModelProperty(value = "点赞作品评论",example = "LIKE_COMMENT") + LIKE_WORKS_COMMENT(11, "赞了你的评论","赞了你的评论"), + + @ApiModelProperty(value = "点赞投票评论",example = "VOTE_COMMENT") + LIKE_VOTE_COMMENT(12, "赞了你的评论","赞了你的评论"), + ; + + private final Integer code; + + private final String title; + private final String content; + + public static String getTitle(Integer code) { + return getInteractionMessageEnums(code).title; + } + + public static String getContent(Integer code) { + return getInteractionMessageEnums(code).content; + } + + public static InteractionMessageEnums getInteractionMessageEnums(Integer code) { + return Arrays.stream(InteractionMessageEnums.values()).filter(c->c.getCode().equals(code)).findFirst().get(); + } + + InteractionMessageEnums(Integer code, String title, String content) { + this.code = code; + this.title = title; + this.content = content; + } + + public Integer getCode() { + return code; + } + + public String getTitle() { + return title; + } + + + public String getContent() { + return content; + } + + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/enums/message/OrderMessageEnums.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/enums/message/OrderMessageEnums.java new file mode 100644 index 0000000..aa0bb45 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/enums/message/OrderMessageEnums.java @@ -0,0 +1,104 @@ +package com.ruoyi.enums.message; + +import java.util.Arrays; + +/** + * 订单消息枚举 + * @Author liwenlong + */ +public enum OrderMessageEnums { + + STORE_RELEASE_ORDER(1, "表现师发布订单","您有新的订单 请及时查看"), + RECEIVING_ORDER(2, "订单确认提醒","您发布的orderNo订单已经有表现师接单"), + CONFIRM(3, "客户已确定表现师","orderNo订单,您已接单成功"), + + NOT_CONFIRM(4, "未确认提醒","您接取的orderNo订单,未被确认"), + + APPEAL(5, "申诉提醒","您的orderNo订单已被投诉,请尽快处理"), + + CANCEL_APPEAL(501, "取消申诉提醒","您的orderNo订单投诉已取消"), + + ADJUST_PRICE(6, "申请调价提醒","您的orderNo订单有调价申请,请及时查看"), + + ADJUST_PRICE_CONFIRM(7, "调价确认","您的orderNo订单的调价申请已通过"), + + ADJUST_PRICE_REFUSE(8, "调价拒绝","您的orderNo订单的调价申请已被拒绝"), + + FINAL_PAY(9, "客户已支付尾款","客户已支付尾款,请及时上传大图"), + + EXTENSION(10, "延期提醒","您的orderNo订单有延期申请,请及时查看 "), + + EXTENSION_CONFIRM(11, "延期确认","您的orderNo订单的延期申请已通过"), + + EXTENSION_REFUSE(12, "延期拒绝","您的orderNo订单的延期申请已被拒绝"), + + ORDER_AUTO_CONFIRM_DELIVER(13, "对图时间已超时","您的orderNo订单对图时间已超时"), + + + APPEAL_RESULT(14, "申诉结果提醒","申诉结果提醒"), + + UPLOAD_LARGE_IMAGES(15, "大图上传提醒","表现师已上传大图"), + + + + + + MALL_PAY_ORDER(16, "您已下单成功!","您已下单成功,我们将尽快为您发货"), + + MALL_ORDER_SEND(17, "订单发货","您的商品已发货,请及时关注物流信息"), + + MALL_ORDER_REFUND(18, "售后申请成功!","亲,您已售后申请成功,等待平台审核中......"), + + + APPEAL_MESSAGE(19, "申诉消息","%1s发送了一条申诉消息"), + + FIRST_PRICE_PAY(20, "定金支付提醒","您的orderNo订单定金已支付"), + + CUSTOMER_CHOOSE_STORE(21, "设计师指定表现师发布订单","您有新的订单 请及时查看"), + + EVALUATE_ORDER(22, "订单评分提醒","您的orderNo订单评分已完成,请注意查看"), + + ORDER_STORE_CANCEL(23, "订单取消提醒","您的orderNo订单被表现师取消"), + + ORDER_ILLEGAL_DEDUCTION(24, "订单扣款提醒","你因订单%s被扣款%s元;扣款原因:%s"), + + ORDER_ILLEGAL_DEDUCTION_CANCEL(25, "订单扣款退回提醒","您的orderNo订单平台扣款amount元已退回"), + ; + + private final Integer code; + private final String title; + private final String content; + + public static String getTitle(Integer code) { + return getOrderMessageEnums(code).title; + } + + public static String getContent(Integer code) { + return getOrderMessageEnums(code).content; + } + + public static OrderMessageEnums getOrderMessageEnums(Integer code) { + return Arrays.stream(OrderMessageEnums.values()).filter(c->c.getCode().equals(code)).findFirst().get(); + } + + OrderMessageEnums(Integer code, String title, String content) { + this.code = code; + this.title = title; + this.content = content; + } + + public Integer getCode() { + return code; + } + + public String getTitle() { + return title; + } + + + public String getContent() { + return content; + } + + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/enums/message/PushEnums.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/enums/message/PushEnums.java new file mode 100644 index 0000000..013f724 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/enums/message/PushEnums.java @@ -0,0 +1,50 @@ +package com.ruoyi.enums.message; + +import java.util.Arrays; + +/** + * 推送类型枚举 + * @Author liwenlong + */ +public enum PushEnums { + + /** + * goeasy推送 + */ + goeasy(1, "goeasy推送"), + + + /** + * uniapp推送 + */ + uniapp(2, "uniapp推送"), + + + ; + + private final Integer code; + private final String name; + + public static String getName(Integer code) { + return getPushEnums(code).name; + } + + public static PushEnums getPushEnums(Integer code) { + return Arrays.stream(PushEnums.values()).filter(c->c.getCode().equals(code)).findFirst().get(); + } + + PushEnums(Integer code, String name) { + this.code = code; + this.name = name; + } + + public Integer getCode() { + return code; + } + + public String getName() { + return name; + } + + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/enums/order/OrderPriceEnums.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/enums/order/OrderPriceEnums.java new file mode 100644 index 0000000..60d5814 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/enums/order/OrderPriceEnums.java @@ -0,0 +1,46 @@ +package com.ruoyi.enums.order; + +import java.util.Arrays; + +/** + * 订单支付金额流水枚举 + * @Author liwenlong + */ +public enum OrderPriceEnums { + + first_pay(1, "定金支付"), + second_pay(2, "尾款支付"), + appeal_add(3, "申诉加款"), + appeal_sub(4, "申诉扣款"), + change(5, "调价"), + + + ; + + private final Integer code; + private final String name; + + public static String getName(Integer code) { + return getOrderPriceEnums(code).name; + } + + + public static OrderPriceEnums getOrderPriceEnums(Integer code) { + return Arrays.stream(OrderPriceEnums.values()).filter(c->c.getCode().equals(code)).findFirst().get(); + } + + OrderPriceEnums(Integer code, String name) { + this.code = code; + this.name = name; + } + + public Integer getCode() { + return code; + } + + public String getName() { + return name; + } + + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/enums/order/OrderStatusEnums.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/enums/order/OrderStatusEnums.java new file mode 100644 index 0000000..5c7f74b --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/enums/order/OrderStatusEnums.java @@ -0,0 +1,46 @@ +package com.ruoyi.enums.order; + +import java.util.Arrays; + +/** + * 订单状态枚举 + * @Author liwenlong + */ +public enum OrderStatusEnums { + + to_be_confirm(1, "待确认"), + ongoing(2, "进行中(待支付尾款)"), + pending_drawings(3, "待上传大图"), + to_be_evaluated(4, "待评价"), + cancel(-1, "取消"), + + + ; + + private final Integer code; + private final String name; + + public static String getName(Integer code) { + return getPayEnums(code).name; + } + + + public static OrderStatusEnums getPayEnums(Integer code) { + return Arrays.stream(OrderStatusEnums.values()).filter(c->c.getCode().equals(code)).findFirst().get(); + } + + OrderStatusEnums(Integer code, String name) { + this.code = code; + this.name = name; + } + + public Integer getCode() { + return code; + } + + public String getName() { + return name; + } + + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/enums/process/ProcessConfigEnums.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/enums/process/ProcessConfigEnums.java new file mode 100644 index 0000000..f5b4c4c --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/enums/process/ProcessConfigEnums.java @@ -0,0 +1,68 @@ +package com.ruoyi.enums.process; + +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; + +/** + * 审批流程配置类型枚举 + * @Author liwenlong + */ +public enum ProcessConfigEnums { + + /** + * 测试审核 + */ + Test(false,1, "测试审核"), + + /** + * 提现申请 + */ + WITHDRAWAL_PROCESS(false,2, "提现申请"), + + + ; + + /** + * 是否是后台 + */ + private final Boolean isBackend; + private final Integer code; + private final String name; + + public static String getName(Integer code) { + return getProcessConfigEnums(code).name; + } + + + public static List getProcessConfigEnumsList() { + return Arrays.stream(ProcessConfigEnums.values()).collect(Collectors.toList()); + } + + public static ProcessConfigEnums getProcessConfigEnums(Integer code) { + return Arrays.stream(ProcessConfigEnums.values()).filter(c->c.getCode().equals(code)).findFirst().get(); + } + + ProcessConfigEnums(Boolean isBackend, Integer code, String name) { + this.isBackend = isBackend; + this.code = code; + this.name = name; + } + + + public Boolean getIsBackend() { + return isBackend; + } + + public Integer getCode() { + return code; + } + + public String getName() { + return name; + } + + + + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/enums/process/ProcessResultEnums.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/enums/process/ProcessResultEnums.java new file mode 100644 index 0000000..2fd14ae --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/enums/process/ProcessResultEnums.java @@ -0,0 +1,51 @@ +package com.ruoyi.enums.process; + +import java.util.Arrays; + +/** + * 审核状态枚举 + * @Author liwenlong + */ +public enum ProcessResultEnums { + + PENDING(1, "待审核"), + + APPROVED(2, "审核通过"), + + REJECTED(3, "审核拒绝"), + + IN_PROGRESS(4, "审核中"), + + CANCELLED(5, "已取消"), + + + + ; + + private final Integer code; + private final String name; + + public static String getName(Integer code) { + return getProcessResultEnums(code).name; + } + + + public static ProcessResultEnums getProcessResultEnums(Integer code) { + return Arrays.stream(ProcessResultEnums.values()).filter(c->c.getCode().equals(code)).findFirst().get(); + } + + ProcessResultEnums(Integer code, String name) { + this.code = code; + this.name = name; + } + + public Integer getCode() { + return code; + } + + public String getName() { + return name; + } + + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/enums/sms/SmsEnums.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/enums/sms/SmsEnums.java new file mode 100644 index 0000000..e9bb61e --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/enums/sms/SmsEnums.java @@ -0,0 +1,52 @@ +package com.ruoyi.enums.sms; + +import lombok.Getter; + +import java.util.Arrays; + +/** + * 短信枚举 + * @Author liwenlong + */ +@Getter +public enum SmsEnums { + + REGISTER(1, "用户注册"), + LOGIN(2, "用户登录"), + CHANGE_PWD(3, "修改密码"), + FORGET_PWD(4, "忘记密码"), + WX_APPLET_LOGIN_BIND(5, "小程序登录绑定手机号"), + WX_LOGIN_BIND(6, "微信登录绑定手机号"), + APPLE_BIND(7, "苹果登录绑定手机号"), + PAY_PWD(8, "支付密码校验"), + OLD_MOBILE_BIND(9, "换绑手机号-验证原有手机号"), + NEW_MOBILE_BIND(10, "换绑手机号-验证新手机号"), + + ; + + private final Integer code; + private final String name; + + public static String getName(Integer code) { + return getSmsEnums(code).name; + } + + public static SmsEnums getSmsEnums(Integer code) { + return Arrays.stream(SmsEnums.values()).filter(c->c.getCode().equals(code)).findFirst().get(); + } + + SmsEnums(Integer code, String name) { + this.code = code; + this.name = name; + } + + public Integer getCode() { + return code; + } + + public String getName() { + return name; + } + + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/enums/user/UserEnums.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/enums/user/UserEnums.java new file mode 100644 index 0000000..f840437 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/enums/user/UserEnums.java @@ -0,0 +1,67 @@ +package com.ruoyi.enums.user; + +import java.util.Arrays; + +/** + * 用户类型枚举 + * @Author liwenlong + */ +public enum UserEnums { + + + /** + * 平台 + */ + platform(0, "平台"), + + /** + * 用户(设计师) + */ + customer(1, "用户"), + + + /** + * 表现师 + */ + store(2, "表现师"), + + /** + * 销售 + */ + sale(3, "销售"), + + /** + * 企业 + */ + enterprise(4, "企业"), + + + ; + + private final Integer code; + private final String name; + + public static String getName(Integer code) { + return getUserEnums(code).name; + } + + + public static UserEnums getUserEnums(Integer code) { + return Arrays.stream(UserEnums.values()).filter(c->c.getCode().equals(code)).findFirst().get(); + } + + UserEnums(Integer code, String name) { + this.code = code; + this.name = name; + } + + public Integer getCode() { + return code; + } + + public String getName() { + return name; + } + + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/agreement/controller/AgreementController.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/agreement/controller/AgreementController.java new file mode 100644 index 0000000..98ea536 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/agreement/controller/AgreementController.java @@ -0,0 +1,97 @@ +package com.ruoyi.frequency.agreement.controller; + +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.page.TableDataInfo; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.common.utils.poi.ExcelUtil; +import com.ruoyi.frequency.agreement.entity.Agreement; +import com.ruoyi.frequency.agreement.service.AgreementService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +/** + * 协议Controller + * + * @author liwenlong + * @date 2023-10-26 + */ +@RestController +@RequestMapping("/frequency/agreement") +public class AgreementController extends BaseController +{ + @Autowired + private AgreementService agreementService; + + /** + * 查询协议列表 + */ + @PreAuthorize("@ss.hasPermi('frequency:agreement:list')") + @PostMapping("/list") + public TableDataInfo list(@RequestBody Agreement agreement) + { + startPage(); + List list = agreementService.selectAgreementList(agreement); + return getDataTable(list); + } + + /** + * 导出协议列表 + */ + @PreAuthorize("@ss.hasPermi('frequency:agreement:export')") + @Log(title = "协议", businessType = BusinessType.EXPORT) + @GetMapping("/export") + public AjaxResult export(Agreement agreement) + { + List list = agreementService.selectAgreementList(agreement); + ExcelUtil util = new ExcelUtil(Agreement.class); + return util.exportExcel(list, "协议数据"); + } + + /** + * 获取协议详细信息 + */ + @PreAuthorize("@ss.hasPermi('frequency:agreement:query')") + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") Long id) + { + return AjaxResult.success(agreementService.selectAgreementById(id)); + } + + /** + * 新增协议 + */ + @PreAuthorize("@ss.hasPermi('frequency:agreement:add')") + @Log(title = "协议", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody Agreement agreement) + { + return toAjax(agreementService.insertAgreement(agreement)); + } + + /** + * 修改协议 + */ + @PreAuthorize("@ss.hasPermi('frequency:agreement:edit')") + @Log(title = "协议", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody Agreement agreement) + { + return toAjax(agreementService.updateAgreement(agreement)); + } + + /** + * 删除协议 + */ + @PreAuthorize("@ss.hasPermi('frequency:agreement:remove')") + @Log(title = "协议", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}/{delFlag}") + public AjaxResult remove(@PathVariable("ids") Long[] ids,@PathVariable("delFlag") Integer delFalg) + { + return toAjax(agreementService.deleteAgreementByIds(ids,delFalg)); + } +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/agreement/entity/Agreement.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/agreement/entity/Agreement.java new file mode 100644 index 0000000..78cdd06 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/agreement/entity/Agreement.java @@ -0,0 +1,43 @@ +package com.ruoyi.frequency.agreement.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; + +/** + * 协议对象 t_agreement + * + * @author liwenlong + * @date 2023-10-26 + */ +@Data +@Accessors(chain = true) +@TableName("t_agreement") +public class Agreement extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + + @ApiModelProperty("主键ID") + private Long id; + + @ApiModelProperty("删除标志 1正常 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("标题") + @Excel(name = "标题") + private String title; + + @ApiModelProperty("内容") + @Excel(name = "内容") + private String content; + + @ApiModelProperty("code值") + @Excel(name = "code值") + private String code; + + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/agreement/mapper/AgreementMapper.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/agreement/mapper/AgreementMapper.java new file mode 100644 index 0000000..f0529bd --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/agreement/mapper/AgreementMapper.java @@ -0,0 +1,48 @@ +package com.ruoyi.frequency.agreement.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.ruoyi.frequency.agreement.entity.Agreement; + +import java.util.List; + +/** + * 协议Mapper接口 + * + * @author liwenlong + * @date 2023-10-26 + */ +public interface AgreementMapper extends BaseMapper +{ + /** + * 查询协议 + * + * @param id 协议主键 + * @return 协议 + */ + public Agreement selectAgreementById(Long id); + + /** + * 查询协议列表 + * + * @param agreement 协议 + * @return 协议集合 + */ + public List selectAgreementList(Agreement agreement); + + /** + * 新增协议 + * + * @param agreement 协议 + * @return 结果 + */ + public int insertAgreement(Agreement agreement); + + /** + * 修改协议 + * + * @param agreement 协议 + * @return 结果 + */ + public int updateAgreement(Agreement agreement); + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/agreement/mapper/mapping/AgreementMapper.xml b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/agreement/mapper/mapping/AgreementMapper.xml new file mode 100644 index 0000000..8570f07 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/agreement/mapper/mapping/AgreementMapper.xml @@ -0,0 +1,79 @@ + + + + + + + + + + + + + + + + + + select id, del_flag, create_by, create_time, update_by, update_time, title, content, code from t_agreement + + + + + + + + insert into t_agreement + + id, + del_flag, + create_by, + create_time, + update_by, + update_time, + title, + content, + code, + + + #{id}, + #{delFlag}, + #{createBy}, + #{createTime}, + #{updateBy}, + #{updateTime}, + #{title}, + #{content}, + #{code}, + + + + + update t_agreement + + del_flag = #{delFlag}, + create_by = #{createBy}, + create_time = #{createTime}, + update_by = #{updateBy}, + update_time = #{updateTime}, + title = #{title}, + content = #{content}, + code = #{code}, + + where id = #{id} + + + \ No newline at end of file diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/agreement/model/param/AgreementParam.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/agreement/model/param/AgreementParam.java new file mode 100644 index 0000000..fa398dc --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/agreement/model/param/AgreementParam.java @@ -0,0 +1,45 @@ +package com.ruoyi.frequency.agreement.model.param; + +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; + +/** + * 协议对象 t_agreement + * + * @author liwenlong + * @date 2023-10-26 + */ +@Data +@Accessors(chain = true) +public class AgreementParam extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + @ApiModelProperty("主键ID") + private Long id; + + @ApiModelProperty("删除标志 1正常 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("标题") + @Excel(name = "标题") + private String title; + + @ApiModelProperty("内容") + @Excel(name = "内容") + private String content; + + @ApiModelProperty("code值") + @Excel(name = "code值") + private String code; + + + + + + + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/agreement/model/result/AgreementResult.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/agreement/model/result/AgreementResult.java new file mode 100644 index 0000000..5779fd5 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/agreement/model/result/AgreementResult.java @@ -0,0 +1,40 @@ +package com.ruoyi.frequency.agreement.model.result; + +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; + +/** + * 协议对象 t_agreement + * + * @author liwenlong + * @date 2023-10-26 + */ +@Data +@Accessors(chain = true) +public class AgreementResult extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + @ApiModelProperty("主键ID") + private Long id; + + @ApiModelProperty("删除标志 1正常 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("标题") + @Excel(name = "标题") + private String title; + + @ApiModelProperty("内容") + @Excel(name = "内容") + private String content; + + @ApiModelProperty("code值") + @Excel(name = "code值") + private String code; + + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/agreement/service/AgreementService.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/agreement/service/AgreementService.java new file mode 100644 index 0000000..b2c17bb --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/agreement/service/AgreementService.java @@ -0,0 +1,56 @@ +package com.ruoyi.frequency.agreement.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.ruoyi.frequency.agreement.entity.Agreement; + +import java.util.List; + +/** + * 协议Service接口 + * + * @author liwenlong + * @date 2023-10-26 + */ +public interface AgreementService extends IService +{ + /** + * 查询协议 + * + * @param id 协议主键 + * @return 协议 + */ + public Agreement selectAgreementById(Long id); + + /** + * 查询协议列表 + * + * @param agreement 协议 + * @return 协议集合 + */ + public List selectAgreementList(Agreement agreement); + + /** + * 新增协议 + * + * @param agreement 协议 + * @return 结果 + */ + public int insertAgreement(Agreement agreement); + + /** + * 修改协议 + * + * @param agreement 协议 + * @return 结果 + */ + public int updateAgreement(Agreement agreement); + + /** + * 批量删除协议 + * + * @param ids 需要删除的协议主键集合 + * @return 结果 + */ + public int deleteAgreementByIds(Long[] ids,Integer delFalg); + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/agreement/service/impl/AgreementServiceImpl.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/agreement/service/impl/AgreementServiceImpl.java new file mode 100644 index 0000000..d07310a --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/agreement/service/impl/AgreementServiceImpl.java @@ -0,0 +1,88 @@ +package com.ruoyi.frequency.agreement.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.ruoyi.common.utils.DateUtils; +import com.ruoyi.frequency.agreement.entity.Agreement; +import com.ruoyi.frequency.agreement.mapper.AgreementMapper; +import com.ruoyi.frequency.agreement.service.AgreementService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * 协议Service业务层处理 + * + * @author liwenlong + * @date 2023-10-26 + */ +@Service +public class AgreementServiceImpl extends ServiceImpl implements AgreementService +{ + @Autowired + private AgreementMapper agreementMapper; + + /** + * 查询协议 + * + * @param id 协议主键 + * @return 协议 + */ + @Override + public Agreement selectAgreementById(Long id) + { + return agreementMapper.selectAgreementById(id); + } + + /** + * 查询协议列表 + * + * @param agreement 协议 + * @return 协议 + */ + @Override + public List selectAgreementList(Agreement agreement) + { + return agreementMapper.selectAgreementList(agreement); + } + + /** + * 新增协议 + * + * @param agreement 协议 + * @return 结果 + */ + @Override + public int insertAgreement(Agreement agreement) + { + agreement.setCreateTime(DateUtils.getNowDate()); + return agreementMapper.insert(agreement); + } + + /** + * 修改协议 + * + * @param agreement 协议 + * @return 结果 + */ + @Override + public int updateAgreement(Agreement agreement) + { + agreement.setUpdateTime(DateUtils.getNowDate()); + return agreementMapper.updateById(agreement); + } + + /** + * 批量删除协议 + * + * @param ids 需要删除的协议主键 + * @return 结果 + */ + @Override + public int deleteAgreementByIds(Long[] ids,Integer delFalg) + { + this.lambdaUpdate().set(Agreement::getDelFlag,delFalg).in(Agreement::getId,ids).update(); + return ids.length; + } + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/appmessage/controller/AppMessageController.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/appmessage/controller/AppMessageController.java new file mode 100644 index 0000000..d94294a --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/appmessage/controller/AppMessageController.java @@ -0,0 +1,112 @@ +package com.ruoyi.frequency.appmessage.controller; + +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.page.TableDataInfo; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.common.utils.poi.ExcelUtil; +import com.ruoyi.frequency.appmessage.entity.AppMessage; +import com.ruoyi.frequency.appmessage.service.AppMessageService; +import com.ruoyi.vo.UserInfo; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +/** + * app端消息Controller + * + * @author liwenlong + * @date 2023-07-20 + */ +@RestController +@RequestMapping("/frequency/appmessage") +public class AppMessageController extends BaseController +{ + @Autowired + private AppMessageService appMessageService; + + /** + * 查询app端消息列表 + */ + @PreAuthorize("@ss.hasPermi('frequency:appmessage:list')") + @PostMapping("/list") + public TableDataInfo list(@RequestBody AppMessage appMessage) + { + startPage(); + List list = appMessageService.selectAppMessageList(appMessage); + return getDataTable(list); + } + + /** + * 导出app端消息列表 + */ + @PreAuthorize("@ss.hasPermi('frequency:appmessage:export')") + @Log(title = "app端消息", businessType = BusinessType.EXPORT) + @GetMapping("/export") + public AjaxResult export(AppMessage appMessage) + { + List list = appMessageService.selectAppMessageList(appMessage); + ExcelUtil util = new ExcelUtil(AppMessage.class); + return util.exportExcel(list, "app端消息数据"); + } + + /** + * 获取app端消息详细信息 + */ + @PreAuthorize("@ss.hasPermi('frequency:appmessage:query')") + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") Long id) + { + return AjaxResult.success(appMessageService.selectAppMessageById(id)); + } + + /** + * 新增app端消息 + */ + @PreAuthorize("@ss.hasPermi('frequency:appmessage:add')") + @Log(title = "app端消息", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody AppMessage appMessage) + { + return toAjax(appMessageService.insertAppMessage(appMessage)); + } + + /** + * 修改app端消息 + */ + @PreAuthorize("@ss.hasPermi('frequency:appmessage:edit')") + @Log(title = "app端消息", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody AppMessage appMessage) + { + return toAjax(appMessageService.updateAppMessage(appMessage)); + } + + /** + * 删除app端消息 + */ + @PreAuthorize("@ss.hasPermi('frequency:appmessage:remove')") + @Log(title = "app端消息", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}/{delFlag}") + public AjaxResult remove(@PathVariable("ids") Long[] ids ,@PathVariable("delFlag") Integer delFlag) + { + return toAjax(appMessageService.deleteAppMessageByIds(ids,delFlag)); + } + + /** + * 消息用户列表 + */ + @PreAuthorize("@ss.hasPermi('frequency:appmessage:messageUserPage')") + @Log(title = "app端消息", businessType = BusinessType.DELETE) + @DeleteMapping("/messageUserPage") + public TableDataInfo messageUserPage(@RequestBody AppMessage appMessage) + { + startPage(); + List list = appMessageService.messageUserPage(appMessage); + return getDataTable(list); + } + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/appmessage/entity/AppMessage.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/appmessage/entity/AppMessage.java new file mode 100644 index 0000000..db73991 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/appmessage/entity/AppMessage.java @@ -0,0 +1,97 @@ +package com.ruoyi.frequency.appmessage.entity; + +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableName; +import com.fasterxml.jackson.annotation.JsonFormat; +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import com.ruoyi.vo.UserInfo; +import lombok.Data; +import lombok.experimental.Accessors; + +import java.util.Date; +import java.util.List; + +/** + * app端消息对象 t_app_message + * + * @author liwenlong + * @date 2023-07-20 + */ +@Data +@Accessors(chain = true) +@TableName("t_app_message") +public class AppMessage extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** 主键id */ + private Long id; + + + + /** 删除标志 1正常 删除 3 禁用 */ + private Integer delFlag; + + /** 消息针对群体 1 用户 2 表现师 3 全部 */ + @Excel(name = "消息针对群体 -1 全部 1 用户 2 表现师 3 销售") + private Integer userType; + + /** 消息标题 */ + @Excel(name = "消息标题") + private String title; + + /** 消息内容 */ + @Excel(name = "消息内容") + private String content; + + /** 消息类型 1 群体 2 个人 */ + @Excel(name = "消息类型 1 群体 2 个人") + private Integer messageType; + + /** 用户id(表现师id) */ + @Excel(name = "用户id(表现师id)") + private String userIds; + + /** 是否发布 1 否2 是 */ + @Excel(name = "是否发布 1 否2 是") + private Integer hasRelease; + + /** 发布时间 */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @Excel(name = "发布时间", width = 30, dateFormat = "yyyy-MM-dd") + private Date releaseTime; + + /** 1 平台发布 2 系统生成 */ + @Excel(name = "1 平台发布 2 系统生成") + private Integer isSystem; + + + /** + * 用户读取系统消息id + */ + @TableField(exist = false) + private Long userAppMessageId; + + @TableField(exist = false) + private Integer isRead; + + @TableField(exist = false) + List userInfoList; + + public AppMessage(){ + + } + + public AppMessage(String title, String content, Integer messageType, Integer userType,String userIds){ + this.title=title; + this.content=content; + this.messageType=messageType; + this.userType=userType; + this.hasRelease=2; + this.delFlag=1; + this.releaseTime= new Date(); + } + + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/appmessage/mapper/AppMessageMapper.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/appmessage/mapper/AppMessageMapper.java new file mode 100644 index 0000000..794172b --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/appmessage/mapper/AppMessageMapper.java @@ -0,0 +1,75 @@ +package com.ruoyi.frequency.appmessage.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.ruoyi.frequency.appmessage.entity.AppMessage; +import com.ruoyi.vo.UserVo; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * app端消息Mapper接口 + * + * @author liwenlong + * @date 2023-07-20 + */ +public interface AppMessageMapper extends BaseMapper +{ + /** + * 查询app端消息 + * + * @param id app端消息主键 + * @return app端消息 + */ + AppMessage selectAppMessageById(Long id); + + /** + * 查询app端消息列表 + * + * @param appMessage app端消息 + * @return app端消息集合 + */ + List selectAppMessageList(AppMessage appMessage); + + /** + * 新增app端消息 + * + * @param appMessage app端消息 + * @return 结果 + */ + int insertAppMessage(AppMessage appMessage); + + /** + * 修改app端消息 + * + * @param appMessage app端消息 + * @return 结果 + */ + int updateAppMessage(AppMessage appMessage); + + /** + * 删除app端消息 + * + * @param id app端消息主键 + * @return 结果 + */ + int deleteAppMessageById(Long id); + + /** + * 批量删除app端消息 + * + * @param ids 需要删除的数据主键集合 + * @return 结果 + */ + int deleteAppMessageByIds(Long[] ids); + + Page messagePage(@Param("page") Page objectPage, @Param("list") List ids, @Param("userVo") UserVo userVo); + Integer messageCenter(@Param("userVo") UserVo userVo); + + List messagePage(@Param("list") List ids,@Param("userVo") UserVo userVo); + + AppMessage systemMessageNew(@Param("userVo") UserVo userVo); + + AppMessage messageDetail(@Param("id") Long id, @Param("userVo") UserVo userVo); +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/appmessage/mapper/mapping/AppMessageMapper.xml b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/appmessage/mapper/mapping/AppMessageMapper.xml new file mode 100644 index 0000000..db3581c --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/appmessage/mapper/mapping/AppMessageMapper.xml @@ -0,0 +1,267 @@ + + + + + + + + + + + + + + + + + + + + + + select id, create_by, create_time, update_by, update_time, del_flag, user_type, title, content, message_type, user_ids, has_release, release_time from t_app_message + + + + + + + + insert into t_app_message + + id, + create_by, + create_time, + update_by, + update_time, + del_flag, + user_type, + title, + content, + message_type, + user_ids, + has_release, + release_time, + + + #{id}, + #{createBy}, + #{createTime}, + #{updateBy}, + #{updateTime}, + #{delFlag}, + #{userType}, + #{title}, + #{content}, + #{messageType}, + #{userIds}, + #{hasRelease}, + #{releaseTime}, + + + + + update t_app_message + + create_by = #{createBy}, + create_time = #{createTime}, + update_by = #{updateBy}, + update_time = #{updateTime}, + del_flag = #{delFlag}, + user_type = #{userType}, + title = #{title}, + content = #{content}, + message_type = #{messageType}, + user_ids = #{userIds}, + has_release = #{hasRelease}, + release_time = #{releaseTime}, + + where id = #{id} + + + + delete from t_app_message where id = #{id} + + + + delete from t_app_message where id in + + #{id} + + + + + + + + + + + + diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/appmessage/model/param/AppMessageParam.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/appmessage/model/param/AppMessageParam.java new file mode 100644 index 0000000..e59d0f5 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/appmessage/model/param/AppMessageParam.java @@ -0,0 +1,72 @@ +package com.ruoyi.frequency.appmessage.model.param; + +import com.fasterxml.jackson.annotation.JsonFormat; +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import lombok.Data; +import lombok.experimental.Accessors; + +import java.util.Date; + +/** + * app端消息对象 t_app_message + * + * @author liwenlong + * @date 2023-07-20 + */ +@Data +@Accessors(chain = true) +public class AppMessageParam extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** 主键id */ + private Long id; + + + + /** 删除标志 1正常 删除 3 禁用 */ + private Integer delFlag; + + /** 消息针对群体 1 用户 2 表现师 3 全部 */ + @Excel(name = "消息针对群体 1 用户 2 表现师 3 全部") + private Integer userType; + + /** 消息标题 */ + @Excel(name = "消息标题") + private String title; + + /** 消息内容 */ + @Excel(name = "消息内容") + private String content; + + /** 消息类型 1 群体 2 个人 */ + @Excel(name = "消息类型 1 群体 2 个人") + private Integer messageType; + + /** 用户id(表现师id) */ + @Excel(name = "用户id(表现师id)") + private Long userId; + + /** 是否发布 1 否2 是 */ + @Excel(name = "是否发布 1 否2 是") + private Integer hasRelease; + + /** 发布时间 */ + @JsonFormat(pattern = "yyyy-MM-dd") + @Excel(name = "发布时间", width = 30, dateFormat = "yyyy-MM-dd") + private Date releaseTime; + + + + + + + + + + + + + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/appmessage/model/result/AppMessageResult.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/appmessage/model/result/AppMessageResult.java new file mode 100644 index 0000000..863307f --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/appmessage/model/result/AppMessageResult.java @@ -0,0 +1,61 @@ +package com.ruoyi.frequency.appmessage.model.result; + +import com.fasterxml.jackson.annotation.JsonFormat; +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import lombok.Data; +import lombok.experimental.Accessors; + +import java.util.Date; + +/** + * app端消息对象 t_app_message + * + * @author liwenlong + * @date 2023-07-20 + */ +@Data +@Accessors(chain = true) +public class AppMessageResult extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** 主键id */ + private Long id; + + + + /** 删除标志 1正常 删除 3 禁用 */ + private Integer delFlag; + + /** 消息针对群体 1 用户 2 表现师 3 全部 */ + @Excel(name = "消息针对群体 1 用户 2 表现师 3 全部") + private Integer userType; + + /** 消息标题 */ + @Excel(name = "消息标题") + private String title; + + /** 消息内容 */ + @Excel(name = "消息内容") + private String content; + + /** 消息类型 1 群体 2 个人 */ + @Excel(name = "消息类型 1 群体 2 个人") + private Integer messageType; + + /** 用户id(表现师id) */ + @Excel(name = "用户id(表现师id)") + private Long userId; + + /** 是否发布 1 否2 是 */ + @Excel(name = "是否发布 1 否2 是") + private Integer hasRelease; + + /** 发布时间 */ + @JsonFormat(pattern = "yyyy-MM-dd") + @Excel(name = "发布时间", width = 30, dateFormat = "yyyy-MM-dd") + private Date releaseTime; + + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/appmessage/service/AppMessageService.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/appmessage/service/AppMessageService.java new file mode 100644 index 0000000..82af990 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/appmessage/service/AppMessageService.java @@ -0,0 +1,131 @@ +package com.ruoyi.frequency.appmessage.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.ruoyi.controller.req.AppMessageReadOrDeleteReq; +import com.ruoyi.controller.req.MessageReadOrDeleteReq; +import com.ruoyi.enums.message.AppMessageEnums; +import com.ruoyi.frequency.appmessage.entity.AppMessage; +import com.ruoyi.frequency.appmessage.model.param.AppMessageParam; +import com.ruoyi.response.ResponseData; +import com.ruoyi.vo.PageBasic; +import com.ruoyi.vo.UserInfo; +import com.ruoyi.vo.UserVo; + +import java.util.List; + +/** + * app端消息Service接口 + * + * @author liwenlong + * @date 2023-07-20 + */ +public interface AppMessageService extends IService +{ + /** + * 查询app端消息 + * + * @param id app端消息主键 + * @return app端消息 + */ + AppMessage selectAppMessageById(Long id); + + /** + * 查询app端消息列表 + * + * @param appMessage app端消息 + * @return app端消息集合 + */ + List selectAppMessageList(AppMessage appMessage); + + /** + * 新增app端消息 + * + * @param appMessage app端消息 + * @return 结果 + */ + int insertAppMessage(AppMessage appMessage); + + /** + * 修改app端消息 + * + * @param appMessage app端消息 + * @return 结果 + */ + int updateAppMessage(AppMessage appMessage); + + /** + * 批量删除app端消息 + * + * @param ids 需要删除的app端消息主键集合 + * @return 结果 + */ + int deleteAppMessageByIds(Long[] ids,Integer delFlag); + + /** + * 删除app端消息信息 + * + * @param id app端消息主键 + * @return 结果 + */ + int deleteAppMessageById(Long id); + + /** + * 消息发布 + * @param appMessageParam + */ + void publish(AppMessageParam appMessageParam); + + + List messageUserPage(AppMessage appMessage); + + /** + * 统计未读系统消息数量 + * @param userVo + * @return + */ + Integer systemMessageCount(UserVo userVo); + + + /** + * 查询最新一条系统消息 + * @param userVo + * @return + */ + AppMessage systemMessageNew(UserVo userVo); + + + /** + * api-查询系统消息列表 + * @param userVo + * @param req + * @return + */ + ResponseData messagePage(UserVo userVo, PageBasic req); + + + /** + * 已读/删除 + * @param req + * @param userVo + * @return + */ + ResponseData appMessageReadOrDelete(MessageReadOrDeleteReq req, UserVo userVo); + + + /** + * 系统消息 + * @param userVo + * @param objectId + * @param authMessageSusess + */ + void addAppMessage(UserVo userVo, Long objectId, AppMessageEnums authMessageSusess); + + /** + * 系统消息详情 + * @param id + * @param userVo + * @return + */ + ResponseData messageDetail(Long id, UserVo userVo); + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/appmessage/service/impl/AppMessageServiceImpl.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/appmessage/service/impl/AppMessageServiceImpl.java new file mode 100644 index 0000000..9b3a349 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/appmessage/service/impl/AppMessageServiceImpl.java @@ -0,0 +1,537 @@ +package com.ruoyi.frequency.appmessage.service.impl; + +import cn.hutool.core.collection.CollectionUtil; +import cn.hutool.core.util.ObjectUtil; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.ruoyi.code.PublicCommon; +import com.ruoyi.common.exception.ServiceException; +import com.ruoyi.common.page.PageResult; +import com.ruoyi.controller.req.MessageReadOrDeleteReq; +import com.ruoyi.enums.message.AppMessageEnums; +import com.ruoyi.enums.user.UserEnums; +import com.ruoyi.frequency.appmessage.entity.AppMessage; +import com.ruoyi.frequency.appmessage.mapper.AppMessageMapper; +import com.ruoyi.frequency.appmessage.model.param.AppMessageParam; +import com.ruoyi.frequency.appmessage.service.AppMessageService; +import com.ruoyi.frequency.customer.entity.Customer; +import com.ruoyi.frequency.customer.mapper.UserMapper; +import com.ruoyi.frequency.customer.service.CustomerService; +import com.ruoyi.frequency.customer.service.UserService; +import com.ruoyi.frequency.sale.entity.Sale; +import com.ruoyi.frequency.sale.service.SaleService; +import com.ruoyi.frequency.store.entity.Store; +import com.ruoyi.frequency.store.service.StoreService; +import com.ruoyi.frequency.userappmessage.entity.UserAppMessage; +import com.ruoyi.frequency.userappmessage.service.UserAppMessageService; +import com.ruoyi.push.service.PushService; +import com.ruoyi.response.ResponseData; +import com.ruoyi.vo.PageBasic; +import com.ruoyi.vo.UserInfo; +import com.ruoyi.vo.UserVo; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.scheduling.annotation.Async; +import org.springframework.stereotype.Service; + +import java.util.*; + +/** + * app端消息Service业务层处理 + * + * @author liwenlong + * @date 2023-07-20 + */ +@Service +public class AppMessageServiceImpl extends ServiceImpl implements AppMessageService { + @Autowired + private AppMessageMapper appMessageMapper; + + @Autowired + private UserService userService; + + /** + * 查询app端消息 + * + * @param id app端消息主键 + * @return app端消息 + */ + @Override + public AppMessage selectAppMessageById(Long id) { + AppMessage appMessage = appMessageMapper.selectAppMessageById(id); + + if (appMessage != null) { + //查询用户 + if (ObjectUtil.isNotEmpty(appMessage.getUserIds())) { + + Set userVoSet = CollectionUtil.newHashSet(); + Arrays.asList(appMessage.getUserIds().split(",")).stream().forEach(userId -> { + userVoSet.add(new UserVo(appMessage.getUserType(), Long.valueOf(userId))); + }); + + Map userVoUserInfoMap = userService.selectUserInfoMap(userVoSet, null); + + appMessage.setUserInfoList(CollectionUtil.newArrayList(userVoUserInfoMap.values())); + } + } + + return appMessage; + } + + /** + * 查询app端消息列表 + * + * @param appMessage app端消息 + * @return app端消息 + */ + @Override + public List selectAppMessageList(AppMessage appMessage) { + return appMessageMapper.selectAppMessageList(appMessage); + } + + /** + * 新增app端消息 + * + * @param appMessage app端消息 + * @return 结果 + */ + @Override + public int insertAppMessage(AppMessage appMessage) { + //发布消息 + if (ObjectUtil.equal(2, appMessage.getHasRelease())) { + appMessage.setReleaseTime(new Date()); + } + appMessageMapper.insert(appMessage); + + //发布消息 + if (ObjectUtil.equal(2, appMessage.getHasRelease())) { + sendMessage(appMessage); + } + + return 1; + } + + /** + * 修改app端消息 + * + * @param appMessage app端消息 + * @return 结果 + */ + @Override + public int updateAppMessage(AppMessage appMessage) { + + //判断消息是否发布 + AppMessage appMessage2 = this.getById(appMessage.getId()); + + //发布消息 + if (ObjectUtil.equal(2, appMessage2.getHasRelease())) { + throw new ServiceException("消息已发布,不能修改"); + } + + appMessage.setUpdateData(); + //发布消息 + if (ObjectUtil.equal(2, appMessage.getHasRelease())) { + appMessage.setReleaseTime(new Date()); + } + + int i = appMessageMapper.updateAppMessage(appMessage); + + if (i > 0 && ObjectUtil.equal(2, appMessage.getHasRelease())) { + //发送消息 + sendMessage(appMessage2); + } + return i; + } + + /** + * 批量删除app端消息 + * + * @param ids 需要删除的app端消息主键 + * @return 结果 + */ + @Override + public int deleteAppMessageByIds(Long[] ids, Integer delFlag) { + this.lambdaUpdate().set(AppMessage::getDelFlag, delFlag).in(AppMessage::getId, ids).update(); + return ids.length; + } + + /** + * 删除app端消息信息 + * + * @param id app端消息主键 + * @return 结果 + */ + @Override + public int deleteAppMessageById(Long id) { + return appMessageMapper.deleteAppMessageById(id); + } + + + @Override + public void publish(AppMessageParam appMessageParam) { + + boolean update = this.lambdaUpdate() + .set(AppMessage::getHasRelease, PublicCommon.Message.发布) + .set(AppMessage::getReleaseTime, new Date()) + .eq(AppMessage::getId, appMessageParam.getId()) + .eq(AppMessage::getHasRelease, PublicCommon.Message.未发布).update(); + + if (update) { + AppMessage appMessage = this.getById(appMessageParam.getId()); + //发送消息 + sendMessage(appMessage); + } + } + + @Autowired + private UserMapper userMapper; + + @Override + public List messageUserPage(AppMessage appMessage) { + AppMessage appMessage2 = appMessageMapper.selectAppMessageById(appMessage.getId()); + + if (appMessage2 == null || ObjectUtil.isEmpty(appMessage2.getUserIds())) { + return new ArrayList<>(); + } + Set userVoSet = CollectionUtil.newHashSet(); + Arrays.asList(appMessage2.getUserIds().split(",")).stream().forEach(userId -> { + userVoSet.add(new UserVo(appMessage2.getUserType(), Long.valueOf(userId))); + }); + + //设计师 + List customerIds = CollectionUtil.toList(); + + //表现师 + List storeIds = CollectionUtil.toList(); + + //销售 + List saleIds = CollectionUtil.toList(); + + //企业 + List enterpriseIds = CollectionUtil.toList(); + + userVoSet.stream().forEach(user -> { + if (user == null || user.getUserId() == null) { + return; + } + if (user.getUserType() == 1) { + customerIds.add(user.getUserId()); + } else if (user.getUserType() == 2) { + storeIds.add(user.getUserId()); + } else if (user.getUserType() == 3) { + saleIds.add(user.getUserId()); + } else { + enterpriseIds.add(user.getUserId()); + } + }); + + List userInfos = userMapper.selectUserInfoList(customerIds, storeIds, saleIds, enterpriseIds, null); + + return userInfos; + } + + @Autowired + private CustomerService customerService; + + @Autowired + private StoreService storeService; + + @Autowired + private SaleService saleService; + + private void sendMessage(AppMessage entity) { + + List sendUserList = new ArrayList<>(); + + switch (entity.getUserType()) { + case -1: + List customers = customerService.list(new QueryWrapper().lambda() + .eq(Customer::getCloseMessage, PublicCommon.Message.未关闭) + .ne(Customer::getDelFlag, PublicCommon.删除)); + if (customers.size() > 0) { + customers.stream().forEach(s -> { + sendUserList.add(new UserVo(UserEnums.customer.getCode(), s.getId())); + }); + } + + List stores = storeService.list(new QueryWrapper().lambda() + .eq(Store::getCloseMessage, PublicCommon.Message.未关闭) + .ne(Store::getDelFlag, PublicCommon.删除)); + if (stores.size() > 0) { + stores.stream().forEach(s -> { + sendUserList.add(new UserVo(UserEnums.store.getCode(), s.getId())); + }); + } + + List sales = saleService.list(new QueryWrapper().lambda() + .eq(Sale::getCloseMessage, PublicCommon.Message.未关闭) + .ne(Sale::getDelFlag, PublicCommon.删除)); + if (sales.size() > 0) { + sales.stream().forEach(s -> { + sendUserList.add(new UserVo(UserEnums.sale.getCode(), s.getId())); + }); + } + + break; + case 1: + //推送是否关闭;1 不关闭2 关闭 + LambdaQueryWrapper ne1 = new QueryWrapper().lambda() + .eq(Customer::getCloseMessage, PublicCommon.Message.未关闭) + .ne(Customer::getDelFlag, PublicCommon.删除); + + if (ObjectUtil.isNotEmpty(entity.getUserIds())) { + ne1.in(Customer::getId, entity.getUserIds().split(",")); + } + + customers = customerService.list(ne1); + if (!customers.isEmpty()) { + customers.stream().forEach(s -> { + sendUserList.add(new UserVo(UserEnums.customer, s.getId())); + }); + } + + break; + case 2: + + LambdaQueryWrapper ne = new QueryWrapper().lambda() + .eq(Store::getCloseMessage, PublicCommon.Message.未关闭) + .ne(Store::getDelFlag, PublicCommon.删除); + + if (ObjectUtil.isNotEmpty(entity.getUserIds())) { + ne.in(Store::getId, entity.getUserIds().split(",")); + } + + List stores2 = storeService.list(ne); + if (stores2.size() > 0) { + stores2.stream().forEach(s -> { + sendUserList.add(new UserVo(UserEnums.store.getCode(), s.getId())); + }); + } + + break; + case 3: + + LambdaQueryWrapper queryWrapper = new QueryWrapper().lambda() + .eq(Sale::getCloseMessage, PublicCommon.Message.未关闭) + .ne(Sale::getDelFlag, PublicCommon.删除); + if (ObjectUtil.isNotEmpty(entity.getUserIds())) { + queryWrapper.in(Sale::getId, entity.getUserIds().split(",")); + } + List sales2 = saleService.list(queryWrapper); + if (sales2.size() > 0) { + sales2.stream().forEach(s -> { + sendUserList.add(new UserVo(UserEnums.sale.getCode(), s.getId())); + }); + } + + break; + + default: + throw new IllegalStateException("Unexpected value: " + entity.getUserType()); + } + //推送消息 + sendThreadMessage(sendUserList, entity.getTitle(), entity.getContent(), entity.getId()); + } + + + @Autowired + private PushService pushService; + + // @Async("sendToAlias") + public void sendThreadMessage(List sendUserList, String title, String content, Long messageId) { + if (sendUserList.size() > 0) { + sendUserList.stream().forEach(s -> { + //推送 + pushService.push(s, title, content, s.getUserId(), messageId, AppMessageEnums.APP_MESSAGE); + }); + } + + } + + + @Override + public Integer systemMessageCount(UserVo userVo) { + + //未读的系统消息数量 + Integer systemMessageCount = baseMapper.messageCenter(userVo); + + return systemMessageCount; + } + + @Override + public AppMessage systemMessageNew(UserVo userVo) { + AppMessage appMessage = baseMapper.systemMessageNew(userVo); + + return appMessage; + } + + @Autowired + private UserAppMessageService userAppMessageService; + + @Override + public ResponseData messagePage(UserVo userVo, PageBasic req) { + + Page appMessagePage = baseMapper.messagePage(new Page<>(req.getPageNo(), req.getPageSize()), null, userVo); + if (appMessagePage.getRecords().size() > 0) { + //系统消息 + List userAppMessages = new ArrayList<>(); + + for (AppMessage appMessage : appMessagePage.getRecords()) { + //组装消息 + userAppMessages = assembleUserMessage(null, appMessage, userVo, userAppMessages); + } + + if (userAppMessages.size() > 0) { + userAppMessageService.saveBatch(userAppMessages); + } + } + return ResponseData.success(new PageResult<>(appMessagePage)); + } + + @Override + public ResponseData appMessageReadOrDelete(MessageReadOrDeleteReq req, UserVo userVo) { + //查询消息 + List appMessageList = baseMapper.messagePage(req.getIds(), userVo); + + if (appMessageList.size() == 0) { + return ResponseData.success(); + } + //添加用户系统信息集合 + List addUserAppMessages = new ArrayList<>(); + + //添加用户系统信息需要删除的集合 + List userMessageIds = new ArrayList<>(); + + for (AppMessage appMessage : appMessageList) { + if (ObjectUtil.isNotEmpty(appMessage.getUserAppMessageId())) { + userMessageIds.add(appMessage.getUserAppMessageId()); + continue; + } + //组装消息 + addUserAppMessages = assembleUserMessage(req.getType(), appMessage, userVo, addUserAppMessages); + } + + // 异步添加消息 + if (CollectionUtil.isNotEmpty(addUserAppMessages)) { + addUserAppMessage(addUserAppMessages); + } + + //修改已存在用户系统消息记录 + if (CollectionUtil.isNotEmpty(userMessageIds)) { + deleteOrRead(req, userVo, userMessageIds); + } + + return ResponseData.success(); + } + + /** + * 修改 + * + * @param req + * @param userVo + * @param userMessageIds + */ + private void deleteOrRead(MessageReadOrDeleteReq req, UserVo userVo, List userMessageIds) { + //1 标记已读 2 删除消息 + switch (req.getType()) { + case 1: + userAppMessageService.lambdaUpdate().set(UserAppMessage::getIsRead, PublicCommon.Message.已读) + .eq(UserAppMessage::getUserType, userVo.getUserType()) + .eq(UserAppMessage::getUserId, userVo.getUserId()) + .eq(UserAppMessage::getIsRead, PublicCommon.Message.未读) + .in(UserAppMessage::getId, userMessageIds).update(); + break; + case 2: + userAppMessageService.lambdaUpdate().set(UserAppMessage::getIsShow, PublicCommon.Message.清空) + .set(UserAppMessage::getIsRead, PublicCommon.Message.已读) + .eq(UserAppMessage::getUserType, userVo.getUserType()) + .eq(UserAppMessage::getUserId, userVo.getUserId()) + .eq(UserAppMessage::getIsShow, PublicCommon.Message.未清空) + .in(UserAppMessage::getId, userMessageIds).update(); + break; + + default: + throw new IllegalStateException("Unexpected value: " + req.getType()); + } + + } + + @Async("addUserAppMessage") + public void addUserAppMessage(List addUserAppMessages) { + userAppMessageService.saveBatch(addUserAppMessages); + + } + + /** + * 组装系统用户消息 + * + * @param appMessage + * @param userVo + * @param userAppMessages + * @return + */ + private List assembleUserMessage(Integer type, AppMessage appMessage, UserVo userVo, List userAppMessages) { + + if (ObjectUtil.isNotEmpty(appMessage.getUserAppMessageId())) { + return userAppMessages; + } + + //组装用户系统消息 + UserAppMessage userAppMessage = new UserAppMessage() + .setUserId(userVo.getUserId()) + .setUserType(userVo.getUserType()) + .setMessageId(appMessage.getId()); + + if (ObjectUtil.isNotEmpty(type)) { + switch (type) { + case 1: + userAppMessage.setIsRead(PublicCommon.Message.已读); + break; + case 2: + userAppMessage.setIsRead(PublicCommon.Message.已读) + .setIsShow(PublicCommon.Message.清空); + break; + default: + throw new IllegalStateException("Unexpected value: " + type); + } + } + userAppMessages.add(userAppMessage); + return userAppMessages; + + } + + @Override + public void addAppMessage(UserVo userVo, Long objectId, AppMessageEnums appMessageEnums) { + + //组装用户系统消息 + AppMessage appMessage = new AppMessage() + .setMessageType(2)//消息类型 1 群体 2 个人 + .setHasRelease(PublicCommon.Message.发布) + .setIsSystem(2)//1 平台发布 2 系统生成 + .setReleaseTime(new Date()) + .setUserIds(userVo.getUserId().toString()) + .setUserType(userVo.getUserType()) + .setTitle(appMessageEnums.getTitle()) + .setContent(appMessageEnums.getContent()); + + this.save(appMessage); + + //推送 + pushService.push(userVo, objectId, appMessage.getId(), appMessageEnums); + } + + @Override + public ResponseData messageDetail(Long id, UserVo userVo) { + AppMessage appMessage = baseMapper.messageDetail(id, userVo); + + //已读 + userAppMessageService.lambdaUpdate().set(UserAppMessage::getIsRead, PublicCommon.Message.已读) + .eq(UserAppMessage::getUserType, userVo.getUserType()) + .eq(UserAppMessage::getUserId, userVo.getUserId()) + .eq(UserAppMessage::getIsRead, PublicCommon.Message.未读) + .eq(UserAppMessage::getId, appMessage.getUserAppMessageId()).update(); + + return ResponseData.success(appMessage); + } +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/appversion/controller/AppVersionController.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/appversion/controller/AppVersionController.java new file mode 100644 index 0000000..55e64ca --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/appversion/controller/AppVersionController.java @@ -0,0 +1,97 @@ +package com.ruoyi.frequency.appversion.controller; + +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.page.TableDataInfo; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.common.utils.poi.ExcelUtil; +import com.ruoyi.frequency.appversion.entity.AppVersion; +import com.ruoyi.frequency.appversion.service.AppVersionService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +/** + * 版本Controller + * + * @author liwenlong + * @date 2023-11-27 + */ +@RestController +@RequestMapping("/frequency/appversion") +public class AppVersionController extends BaseController +{ + @Autowired + private AppVersionService appVersionService; + + /** + * 查询版本列表 + */ + @PreAuthorize("@ss.hasPermi('frequency:appversion:list')") + @PostMapping("/list") + public TableDataInfo list(@RequestBody AppVersion appVersion) + { + startPage(); + List list = appVersionService.selectAppVersionList(appVersion); + return getDataTable(list); + } + + /** + * 导出版本列表 + */ + @PreAuthorize("@ss.hasPermi('frequency:appversion:export')") + @Log(title = "版本", businessType = BusinessType.EXPORT) + @GetMapping("/export") + public AjaxResult export(AppVersion appVersion) + { + List list = appVersionService.selectAppVersionList(appVersion); + ExcelUtil util = new ExcelUtil(AppVersion.class); + return util.exportExcel(list, "版本数据"); + } + + /** + * 获取版本详细信息 + */ + @PreAuthorize("@ss.hasPermi('frequency:appversion:query')") + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") Long id) + { + return AjaxResult.success(appVersionService.selectAppVersionById(id)); + } + + /** + * 新增版本 + */ + @PreAuthorize("@ss.hasPermi('frequency:appversion:add')") + @Log(title = "版本", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody AppVersion appVersion) + { + return toAjax(appVersionService.insertAppVersion(appVersion)); + } + + /** + * 修改版本 + */ + @PreAuthorize("@ss.hasPermi('frequency:appversion:edit')") + @Log(title = "版本", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody AppVersion appVersion) + { + return toAjax(appVersionService.updateAppVersion(appVersion)); + } + + /** + * 删除版本 + */ + @PreAuthorize("@ss.hasPermi('frequency:appversion:remove')") + @Log(title = "版本", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}/{delFlag}") + public AjaxResult remove(@PathVariable("ids") Long[] ids,@PathVariable("delFlag") Integer delFlag) + { + return toAjax(appVersionService.deleteAppVersionByIds(ids,delFlag)); + } +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/appversion/entity/AppVersion.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/appversion/entity/AppVersion.java new file mode 100644 index 0000000..dbbe0fd --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/appversion/entity/AppVersion.java @@ -0,0 +1,60 @@ +package com.ruoyi.frequency.appversion.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; + +/** + * 版本对象 t_app_version + * + * @author liwenlong + * @date 2023-11-27 + */ +@Data +@Accessors(chain = true) +@TableName("t_app_version") +public class AppVersion extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + + @ApiModelProperty("租户号") + private Long id; + + @ApiModelProperty("删除标志 1正常 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("版本号") + @Excel(name = "版本号") + private String version; + + @ApiModelProperty("是否强制 1强制 2不强制") + @Excel(name = "是否强制 1强制 2不强制") + private Integer isForce; + + @ApiModelProperty("版本地址") + @Excel(name = "版本地址") + private String url; + + @ApiModelProperty("$column.columnComment") + @Excel(name = "版本地址") + private String sort; + + @ApiModelProperty("1 用户端 2 推广员") + @Excel(name = "1 用户端 2 推广员") + private Integer appType; + + @ApiModelProperty("更新内容") + @Excel(name = "更新内容") + private String content; + + @ApiModelProperty("标题") + @Excel(name = "标题") + private String title; + + + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/appversion/mapper/AppVersionMapper.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/appversion/mapper/AppVersionMapper.java new file mode 100644 index 0000000..bcb48ac --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/appversion/mapper/AppVersionMapper.java @@ -0,0 +1,48 @@ +package com.ruoyi.frequency.appversion.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.ruoyi.frequency.appversion.entity.AppVersion; + +import java.util.List; + +/** + * 版本Mapper接口 + * + * @author liwenlong + * @date 2023-11-27 + */ +public interface AppVersionMapper extends BaseMapper +{ + /** + * 查询版本 + * + * @param id 版本主键 + * @return 版本 + */ + public AppVersion selectAppVersionById(Long id); + + /** + * 查询版本列表 + * + * @param appVersion 版本 + * @return 版本集合 + */ + public List selectAppVersionList(AppVersion appVersion); + + /** + * 新增版本 + * + * @param appVersion 版本 + * @return 结果 + */ + public int insertAppVersion(AppVersion appVersion); + + /** + * 修改版本 + * + * @param appVersion 版本 + * @return 结果 + */ + public int updateAppVersion(AppVersion appVersion); + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/appversion/mapper/mapping/AppVersionMapper.xml b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/appversion/mapper/mapping/AppVersionMapper.xml new file mode 100644 index 0000000..353cc4b --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/appversion/mapper/mapping/AppVersionMapper.xml @@ -0,0 +1,116 @@ + + + + + + + + + + + + + + + + + + + + + + + + select + t.id , + t.del_flag , + t.create_by , + t.create_time , + t.update_by , + t.update_time , + t.version , + t.is_force , + t.url , + t.sort , + t.app_type , + t.content , + t.title + from t_app_version AS t + + + + + + + + + insert into t_app_version + + id, + del_flag, + create_by, + create_time, + update_by, + update_time, + version, + is_force, + url, + sort, + app_type, + content, + title, + + + #{id}, + #{delFlag}, + #{createBy}, + #{createTime}, + #{updateBy}, + #{updateTime}, + #{version}, + #{isForce}, + #{url}, + #{sort}, + #{appType}, + #{content}, + #{title}, + + + + + update t_app_version + + del_flag = #{delFlag}, + create_by = #{createBy}, + create_time = #{createTime}, + update_by = #{updateBy}, + update_time = #{updateTime}, + version = #{version}, + is_force = #{isForce}, + url = #{url}, + sort = #{sort}, + app_type = #{appType}, + content = #{content}, + title = #{title}, + + where id = #{id} + + \ No newline at end of file diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/appversion/model/param/AppVersionParam.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/appversion/model/param/AppVersionParam.java new file mode 100644 index 0000000..3d14621 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/appversion/model/param/AppVersionParam.java @@ -0,0 +1,65 @@ +package com.ruoyi.frequency.appversion.model.param; + +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; + +/** + * 版本对象 t_app_version + * + * @author liwenlong + * @date 2023-11-27 + */ +@Data +@Accessors(chain = true) +public class AppVersionParam extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + @ApiModelProperty("租户号") + private Long id; + + @ApiModelProperty("删除标志 1正常 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("版本号") + @Excel(name = "版本号") + private String version; + + @ApiModelProperty("是否强制 1强制 2不强制") + @Excel(name = "是否强制 1强制 2不强制") + private Integer isForce; + + @ApiModelProperty("版本地址") + @Excel(name = "版本地址") + private String url; + + @ApiModelProperty("$column.columnComment") + @Excel(name = "版本地址") + private String sort; + + @ApiModelProperty("1 用户端 2 推广员") + @Excel(name = "1 用户端 2 推广员") + private Integer appType; + + @ApiModelProperty("更新内容") + @Excel(name = "更新内容") + private String content; + + @ApiModelProperty("标题") + @Excel(name = "标题") + private String title; + + + + + + + + + + + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/appversion/model/result/AppVersionResult.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/appversion/model/result/AppVersionResult.java new file mode 100644 index 0000000..865e56b --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/appversion/model/result/AppVersionResult.java @@ -0,0 +1,56 @@ +package com.ruoyi.frequency.appversion.model.result; + +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; + +/** + * 版本对象 t_app_version + * + * @author liwenlong + * @date 2023-11-27 + */ +@Data +@Accessors(chain = true) +public class AppVersionResult extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + @ApiModelProperty("租户号") + private Long id; + + @ApiModelProperty("删除标志 1正常 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("版本号") + @Excel(name = "版本号") + private String version; + + @ApiModelProperty("是否强制 1强制 2不强制") + @Excel(name = "是否强制 1强制 2不强制") + private Integer isForce; + + @ApiModelProperty("版本地址") + @Excel(name = "版本地址") + private String url; + + @ApiModelProperty("$column.columnComment") + @Excel(name = "版本地址") + private String sort; + + @ApiModelProperty("1 用户端 2 推广员") + @Excel(name = "1 用户端 2 推广员") + private Integer appType; + + @ApiModelProperty("更新内容") + @Excel(name = "更新内容") + private String content; + + @ApiModelProperty("标题") + @Excel(name = "标题") + private String title; + + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/appversion/service/AppVersionService.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/appversion/service/AppVersionService.java new file mode 100644 index 0000000..839d11a --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/appversion/service/AppVersionService.java @@ -0,0 +1,63 @@ +package com.ruoyi.frequency.appversion.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.ruoyi.frequency.appversion.entity.AppVersion; +import com.ruoyi.response.ResponseData; + +import java.util.List; + +/** + * 版本Service接口 + * + * @author liwenlong + * @date 2023-11-27 + */ +public interface AppVersionService extends IService +{ + /** + * 查询版本 + * + * @param id 版本主键 + * @return 版本 + */ + public AppVersion selectAppVersionById(Long id); + + /** + * 查询版本列表 + * + * @param appVersion 版本 + * @return 版本集合 + */ + public List selectAppVersionList(AppVersion appVersion); + + /** + * 新增版本 + * + * @param appVersion 版本 + * @return 结果 + */ + public int insertAppVersion(AppVersion appVersion); + + /** + * 修改版本 + * + * @param appVersion 版本 + * @return 结果 + */ + public int updateAppVersion(AppVersion appVersion); + + /** + * 批量删除版本 + * + * @param ids 需要删除的版本主键集合 + * @return 结果 + */ + public int deleteAppVersionByIds(Long[] ids,Integer delFlag); + + /** + * 版本更新 + * @param appType + * @return + */ + ResponseData isUpgrade(Integer appType); +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/appversion/service/impl/AppVersionServiceImpl.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/appversion/service/impl/AppVersionServiceImpl.java new file mode 100644 index 0000000..c97ef8f --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/appversion/service/impl/AppVersionServiceImpl.java @@ -0,0 +1,101 @@ +package com.ruoyi.frequency.appversion.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.ruoyi.code.PublicCommon; +import com.ruoyi.frequency.appversion.entity.AppVersion; +import com.ruoyi.frequency.appversion.mapper.AppVersionMapper; +import com.ruoyi.frequency.appversion.service.AppVersionService; +import com.ruoyi.response.ResponseData; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * 版本Service业务层处理 + * + * @author liwenlong + * @date 2023-11-27 + */ +@Service +public class AppVersionServiceImpl extends ServiceImpl implements AppVersionService +{ + @Autowired + private AppVersionMapper appVersionMapper; + + /** + * 查询版本 + * + * @param id 版本主键 + * @return 版本 + */ + @Override + public AppVersion selectAppVersionById(Long id) + { + return appVersionMapper.selectAppVersionById(id); + } + + /** + * 查询版本列表 + * + * @param appVersion 版本 + * @return 版本 + */ + @Override + public List selectAppVersionList(AppVersion appVersion) + { + return appVersionMapper.selectAppVersionList(appVersion); + } + + /** + * 新增版本 + * + * @param appVersion 版本 + * @return 结果 + */ + @Override + public int insertAppVersion(AppVersion appVersion) + { + appVersion.setCreateData(); + return appVersionMapper.insert(appVersion); + } + + /** + * 修改版本 + * + * @param appVersion 版本 + * @return 结果 + */ + @Override + public int updateAppVersion(AppVersion appVersion) + { + appVersion.setUpdateData(); + return appVersionMapper.updateAppVersion(appVersion); + } + + /** + * 批量删除版本 + * + * @param ids 需要删除的版本主键 + * @return 结果 + */ + @Override + public int deleteAppVersionByIds(Long[] ids,Integer delFlag) + { + this.lambdaUpdate().set(AppVersion::getDelFlag,delFlag).in(AppVersion::getId,ids).update(); + return ids.length; + } + + @Override + public ResponseData isUpgrade(Integer appType) { + + AppVersion version = this.getOne(new QueryWrapper().lambda() + .eq(AppVersion::getDelFlag, PublicCommon.启用) + .eq(AppVersion::getAppType, appType) + .orderByDesc(AppVersion::getVersion) + .last("limit 1") + ); + return ResponseData.success(version); + } +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/bankcard/controller/BankCardController.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/bankcard/controller/BankCardController.java new file mode 100644 index 0000000..b7df683 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/bankcard/controller/BankCardController.java @@ -0,0 +1,103 @@ +package com.ruoyi.frequency.bankcard.controller; + +import java.util.List; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.frequency.bankcard.entity.BankCard; +import com.ruoyi.frequency.bankcard.service.BankCardService; +import com.ruoyi.common.utils.poi.ExcelUtil; +import com.ruoyi.common.core.page.TableDataInfo; + +/** + * 银行卡Controller + * + * @author liwenlong + * @date 2024-04-10 + */ +@RestController +@RequestMapping("/frequency/bankcard") +public class BankCardController extends BaseController +{ + @Autowired + private BankCardService bankCardService; + + /** + * 查询银行卡列表 + */ + @PreAuthorize("@ss.hasPermi('frequency:bankcard:list')") + @GetMapping("/list") + public TableDataInfo list(BankCard bankCard) + { + startPage(); + List list = bankCardService.selectBankCardList(bankCard); + return getDataTable(list); + } + + /** + * 导出银行卡列表 + */ + @PreAuthorize("@ss.hasPermi('frequency:bankcard:export')") + @Log(title = "银行卡", businessType = BusinessType.EXPORT) + @GetMapping("/export") + public AjaxResult export(BankCard bankCard) + { + List list = bankCardService.selectBankCardList(bankCard); + ExcelUtil util = new ExcelUtil(BankCard.class); + return util.exportExcel(list, "银行卡数据"); + } + + /** + * 获取银行卡详细信息 + */ + @PreAuthorize("@ss.hasPermi('frequency:bankcard:query')") + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") Long id) + { + return AjaxResult.success(bankCardService.selectBankCardById(id)); + } + + /** + * 新增银行卡 + */ + @PreAuthorize("@ss.hasPermi('frequency:bankcard:add')") + @Log(title = "银行卡", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody BankCard bankCard) + { + return toAjax(bankCardService.insertBankCard(bankCard)); + } + + /** + * 修改银行卡 + */ + @PreAuthorize("@ss.hasPermi('frequency:bankcard:edit')") + @Log(title = "银行卡", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody BankCard bankCard) + { + return toAjax(bankCardService.updateBankCard(bankCard)); + } + + /** + * 删除银行卡 + */ + @PreAuthorize("@ss.hasPermi('frequency:bankcard:remove')") + @Log(title = "银行卡", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}/{delFlag}") + public AjaxResult remove(@PathVariable("ids") Long[] ids,@PathVariable("delFlag") Integer delFlag) + { + return toAjax(bankCardService.deleteBankCardByIds(ids,delFlag)); + } +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/bankcard/entity/BankCard.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/bankcard/entity/BankCard.java new file mode 100644 index 0000000..2510db2 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/bankcard/entity/BankCard.java @@ -0,0 +1,65 @@ +package com.ruoyi.frequency.bankcard.entity; + +import lombok.Data; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.experimental.Accessors; +import com.ruoyi.common.annotation.Excel; +import io.swagger.annotations.ApiModelProperty; +import com.baomidou.mybatisplus.annotation.TableField; +import com.ruoyi.vo.UserInfo; +import com.ruoyi.common.core.domain.BaseEntity; + +/** + * 银行卡对象 t_bank_card + * + * @author liwenlong + * @date 2024-04-10 + */ +@Data +@Accessors(chain = true) +@TableName("t_bank_card") +public class BankCard extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + + @ApiModelProperty("租户号") + private Long id; + + @ApiModelProperty("删除状态 1 正常 2 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("用户类型") + @Excel(name = "用户类型") + private Integer userType; + + @ApiModelProperty("用户id") + @Excel(name = "用户id") + private Long userId; + + @ApiModelProperty("开户行") + @Excel(name = "开户行") + private String bank; + + @ApiModelProperty("开户支行") + @Excel(name = "开户支行") + private String openingBranch; + + @ApiModelProperty("姓名") + @Excel(name = "姓名") + private String fullName; + + @ApiModelProperty("银行卡号") + @Excel(name = "银行卡号") + private String bankCard; + + @ApiModelProperty("是否默认1否;2 是") + @Excel(name = "是否默认1否;2 是") + private Integer isDefault; + + @ApiModelProperty("用户信息") + @TableField(exist = false) + private UserInfo userInfo; + + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/bankcard/mapper/BankCardMapper.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/bankcard/mapper/BankCardMapper.java new file mode 100644 index 0000000..079db9f --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/bankcard/mapper/BankCardMapper.java @@ -0,0 +1,56 @@ +package com.ruoyi.frequency.bankcard.mapper; + +import java.util.List; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.ruoyi.controller.req.BankCardPageReq; +import com.ruoyi.controller.resp.BankCardDetailResp; +import com.ruoyi.controller.resp.BankCardPageResp; +import com.ruoyi.frequency.bankcard.entity.BankCard; +import com.ruoyi.vo.UserVo; +import org.apache.ibatis.annotations.Param; + +/** + * 银行卡Mapper接口 + * + * @author liwenlong + * @date 2024-04-10 + */ +public interface BankCardMapper extends BaseMapper +{ + /** + * 查询银行卡 + * + * @param id 银行卡主键 + * @return 银行卡 + */ + public BankCard selectBankCardById(Long id); + + /** + * 查询银行卡列表 + * + * @param bankCard 银行卡 + * @return 银行卡集合 + */ + public List selectBankCardList(BankCard bankCard); + + /** + * 新增银行卡 + * + * @param bankCard 银行卡 + * @return 结果 + */ + public int insertBankCard(BankCard bankCard); + + /** + * 修改银行卡 + * + * @param bankCard 银行卡 + * @return 结果 + */ + public int updateBankCard(BankCard bankCard); + + Page bankCardPage(@Param("page") Page objectPage, @Param("item")BankCardPageReq req,@Param("userVo") UserVo userVo); + + BankCardDetailResp bankCardDetail(@Param("bankCardId") Long bankCardId,@Param("userVo") UserVo userVo); +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/bankcard/mapper/mapping/BankCardMapper.xml b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/bankcard/mapper/mapping/BankCardMapper.xml new file mode 100644 index 0000000..ca13dff --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/bankcard/mapper/mapping/BankCardMapper.xml @@ -0,0 +1,165 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + select + t.id , + t.create_by , + t.create_time , + t.update_by , + t.update_time , + t.del_flag , + t.user_type , + t.user_id , + t.bank , + t.opening_branch , + t.full_name , + t.bank_card , + t.is_default + from t_bank_card AS t + + + + + + + + insert into t_bank_card + + id, + create_by, + create_time, + update_by, + update_time, + del_flag, + user_type, + user_id, + bank, + opening_branch, + full_name, + bank_card, + is_default, + + + #{id}, + #{createBy}, + #{createTime}, + #{updateBy}, + #{updateTime}, + #{delFlag}, + #{userType}, + #{userId}, + #{bank}, + #{openingBranch}, + #{fullName}, + #{bankCard}, + #{isDefault}, + + + + + update t_bank_card + + create_by = #{createBy}, + create_time = #{createTime}, + update_by = #{updateBy}, + update_time = #{updateTime}, + del_flag = #{delFlag}, + user_type = #{userType}, + user_id = #{userId}, + bank = #{bank}, + opening_branch = #{openingBranch}, + full_name = #{fullName}, + bank_card = #{bankCard}, + is_default = #{isDefault}, + + where id = #{id} + + + + + + \ No newline at end of file diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/bankcard/model/param/BankCardParam.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/bankcard/model/param/BankCardParam.java new file mode 100644 index 0000000..3ea1660 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/bankcard/model/param/BankCardParam.java @@ -0,0 +1,65 @@ +package com.ruoyi.frequency.bankcard.model.param; + +import lombok.Data; +import lombok.experimental.Accessors; +import com.ruoyi.common.annotation.Excel; +import io.swagger.annotations.ApiModelProperty; +import com.ruoyi.common.core.domain.BaseEntity; + +/** + * 银行卡对象 t_bank_card + * + * @author liwenlong + * @date 2024-04-10 + */ +@Data +@Accessors(chain = true) +public class BankCardParam extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + @ApiModelProperty("租户号") + private Long id; + + @ApiModelProperty("删除状态 1 正常 2 删除 3 禁用") + private Long delFlag; + + @ApiModelProperty("用户类型") + @Excel(name = "用户类型") + private Long userType; + + @ApiModelProperty("用户id") + @Excel(name = "用户id") + private Long userId; + + @ApiModelProperty("开户行") + @Excel(name = "开户行") + private String bank; + + @ApiModelProperty("开户支行") + @Excel(name = "开户支行") + private String openingBranch; + + @ApiModelProperty("姓名") + @Excel(name = "姓名") + private String fullName; + + @ApiModelProperty("银行卡号") + @Excel(name = "银行卡号") + private String bankCard; + + @ApiModelProperty("是否默认1否;2 是") + @Excel(name = "是否默认1否;2 是") + private Long isDefault; + + + + + + + + + + + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/bankcard/model/result/BankCardResult.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/bankcard/model/result/BankCardResult.java new file mode 100644 index 0000000..502d9c3 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/bankcard/model/result/BankCardResult.java @@ -0,0 +1,56 @@ +package com.ruoyi.frequency.bankcard.model.result; + +import lombok.Data; +import lombok.experimental.Accessors; +import com.ruoyi.common.annotation.Excel; +import io.swagger.annotations.ApiModelProperty; +import com.ruoyi.common.core.domain.BaseEntity; + +/** + * 银行卡对象 t_bank_card + * + * @author liwenlong + * @date 2024-04-10 + */ +@Data +@Accessors(chain = true) +public class BankCardResult extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + @ApiModelProperty("租户号") + private Long id; + + @ApiModelProperty("删除状态 1 正常 2 删除 3 禁用") + private Long delFlag; + + @ApiModelProperty("用户类型") + @Excel(name = "用户类型") + private Long userType; + + @ApiModelProperty("用户id") + @Excel(name = "用户id") + private Long userId; + + @ApiModelProperty("开户行") + @Excel(name = "开户行") + private String bank; + + @ApiModelProperty("开户支行") + @Excel(name = "开户支行") + private String openingBranch; + + @ApiModelProperty("姓名") + @Excel(name = "姓名") + private String fullName; + + @ApiModelProperty("银行卡号") + @Excel(name = "银行卡号") + private String bankCard; + + @ApiModelProperty("是否默认1否;2 是") + @Excel(name = "是否默认1否;2 是") + private Long isDefault; + + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/bankcard/service/BankCardService.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/bankcard/service/BankCardService.java new file mode 100644 index 0000000..8ba08c2 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/bankcard/service/BankCardService.java @@ -0,0 +1,104 @@ +package com.ruoyi.frequency.bankcard.service; + +import java.util.List; + +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.ruoyi.common.page.PageResult; +import com.ruoyi.controller.req.BankCardAddReq; +import com.ruoyi.controller.req.BankCardEditReq; +import com.ruoyi.controller.req.BankCardPageReq; +import com.ruoyi.controller.resp.BankCardDetailResp; +import com.ruoyi.controller.resp.BankCardPageResp; +import com.ruoyi.frequency.bankcard.entity.BankCard; +import com.baomidou.mybatisplus.extension.service.IService; +import com.ruoyi.response.ResponseData; +import com.ruoyi.vo.UserVo; + +/** + * 银行卡Service接口 + * + * @author liwenlong + * @date 2024-04-10 + */ +public interface BankCardService extends IService +{ + /** + * 查询银行卡 + * + * @param id 银行卡主键 + * @return 银行卡 + */ + public BankCard selectBankCardById(Long id); + + /** + * 查询银行卡列表 + * + * @param bankCard 银行卡 + * @return 银行卡集合 + */ + public List selectBankCardList(BankCard bankCard); + + /** + * 新增银行卡 + * + * @param bankCard 银行卡 + * @return 结果 + */ + public int insertBankCard(BankCard bankCard); + + /** + * 修改银行卡 + * + * @param bankCard 银行卡 + * @return 结果 + */ + public int updateBankCard(BankCard bankCard); + + /** + * 批量删除银行卡 + * + * @param ids 需要删除的银行卡主键集合 + * @return 结果 + */ + public int deleteBankCardByIds(Long[] ids,Integer delFlag); + + /** + * 银行卡列表 + * @param req + * @param userVo + * @return + */ + ResponseData>> bankCardPage(BankCardPageReq req, UserVo userVo); + + /** + * 银行卡新增 + * @param req + * @param userVo + * @return + */ + ResponseData bankCardAdd(BankCardAddReq req, UserVo userVo); + + /** + * 银行卡编辑 + * @param req + * @param userVo + * @return + */ + ResponseData bankCardEdit(BankCardEditReq req, UserVo userVo); + + /** + * 银行卡详情 + * @param bankCardId + * @param userVo + * @return + */ + ResponseData bankCardDetail(Long bankCardId, UserVo userVo); + + /** + * 银行卡删除 + * @param bankCardId + * @param userVo + * @return + */ + ResponseData bankCardDel(Long bankCardId, UserVo userVo); +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/bankcard/service/impl/BankCardServiceImpl.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/bankcard/service/impl/BankCardServiceImpl.java new file mode 100644 index 0000000..e1e151c --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/bankcard/service/impl/BankCardServiceImpl.java @@ -0,0 +1,141 @@ +package com.ruoyi.frequency.bankcard.service.impl; + +import java.util.List; + +import cn.hutool.core.bean.BeanUtil; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.ruoyi.common.page.PageResult; +import com.ruoyi.common.utils.DateUtils; +import com.ruoyi.controller.req.BankCardAddReq; +import com.ruoyi.controller.req.BankCardEditReq; +import com.ruoyi.controller.req.BankCardPageReq; +import com.ruoyi.controller.resp.BankCardDetailResp; +import com.ruoyi.controller.resp.BankCardPageResp; +import com.ruoyi.response.ResponseData; +import com.ruoyi.vo.UserVo; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.ruoyi.code.PublicCommon; +import com.ruoyi.frequency.bankcard.mapper.BankCardMapper; +import com.ruoyi.frequency.bankcard.entity.BankCard; +import com.ruoyi.frequency.bankcard.service.BankCardService; + +/** + * 银行卡Service业务层处理 + * + * @author liwenlong + * @date 2024-04-10 + */ +@Service +public class BankCardServiceImpl extends ServiceImpl implements BankCardService +{ + @Autowired + private BankCardMapper bankCardMapper; + + /** + * 查询银行卡 + * + * @param id 银行卡主键 + * @return 银行卡 + */ + @Override + public BankCard selectBankCardById(Long id) + { + return bankCardMapper.selectBankCardById(id); + } + + /** + * 查询银行卡列表 + * + * @param bankCard 银行卡 + * @return 银行卡 + */ + @Override + public List selectBankCardList(BankCard bankCard) + { + return bankCardMapper.selectBankCardList(bankCard); + } + + /** + * 新增银行卡 + * + * @param bankCard 银行卡 + * @return 结果 + */ + @Override + public int insertBankCard(BankCard bankCard) + { + bankCard.setCreateData(); + return bankCardMapper.insert(bankCard); + } + + /** + * 修改银行卡 + * + * @param bankCard 银行卡 + * @return 结果 + */ + @Override + public int updateBankCard(BankCard bankCard) + { + bankCard.setUpdateData(); + return bankCardMapper.updateBankCard(bankCard); + } + + /** + * 批量删除银行卡 + * + * @param ids 需要删除的银行卡主键 + * @return 结果 + */ + @Override + public int deleteBankCardByIds(Long[] ids,Integer delFlag) + { + this.lambdaUpdate().set(BankCard::getDelFlag,delFlag).in(BankCard::getId,ids).update(); + return ids.length; + } + + @Override + public ResponseData>> bankCardPage(BankCardPageReq req, UserVo userVo) { + + Page page = this.baseMapper.bankCardPage(new Page<>(req.getPageNo(),req.getPageSize()),req,userVo); + return ResponseData.success(new PageResult<>(page)); + } + + @Override + public ResponseData bankCardAdd(BankCardAddReq req, UserVo userVo) { + BankCard bankCard = new BankCard(); + BeanUtil.copyProperties(req,bankCard); + bankCard.setCreateData(); + bankCard.setUserId(userVo.getUserId()) + .setUserType(userVo.getUserType()); + this.save(bankCard); + return ResponseData.success(); + } + + @Override + public ResponseData bankCardEdit(BankCardEditReq req, UserVo userVo) { + BankCard bankCard = new BankCard(); + BeanUtil.copyProperties(req,bankCard); + bankCard.setUpdateData(); + this.updateById(bankCard); + + return ResponseData.success(); + } + + @Override + public ResponseData bankCardDetail(Long bankCardId, UserVo userVo) { + BankCardDetailResp bankCardDetail = this.baseMapper.bankCardDetail(bankCardId,userVo); + return ResponseData.success(bankCardDetail); + } + + @Override + public ResponseData bankCardDel(Long bankCardId, UserVo userVo) { + this.lambdaUpdate().set(BankCard::getDelFlag,PublicCommon.删除) + .eq(BankCard::getUserId,userVo.getUserId()) + .eq(BankCard::getUserType,userVo.getUserType()) + .eq(BankCard::getId,bankCardId).update(); + return ResponseData.success(); + } +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/banner/controller/BannerController.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/banner/controller/BannerController.java new file mode 100644 index 0000000..f20ae05 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/banner/controller/BannerController.java @@ -0,0 +1,97 @@ +package com.ruoyi.frequency.banner.controller; + +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.page.TableDataInfo; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.common.utils.poi.ExcelUtil; +import com.ruoyi.frequency.banner.entity.Banner; +import com.ruoyi.frequency.banner.service.BannerService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +/** + * 轮播图Controller + * + * @author liwenlong + * @date 2023-07-20 + */ +@RestController +@RequestMapping("/frequency/banner") +public class BannerController extends BaseController +{ + @Autowired + private BannerService bannerService; + + /** + * 查询轮播图列表 + */ + @PreAuthorize("@ss.hasPermi('frequency:banner:list')") + @PostMapping("/list") + public TableDataInfo list(@RequestBody Banner banner) + { + startPage(); + List list = bannerService.selectBannerList(banner); + return getDataTable(list); + } + + /** + * 导出轮播图列表 + */ + @PreAuthorize("@ss.hasPermi('frequency:banner:export')") + @Log(title = "轮播图", businessType = BusinessType.EXPORT) + @GetMapping("/export") + public AjaxResult export(Banner banner) + { + List list = bannerService.selectBannerList(banner); + ExcelUtil util = new ExcelUtil(Banner.class); + return util.exportExcel(list, "轮播图数据"); + } + + /** + * 获取轮播图详细信息 + */ + @PreAuthorize("@ss.hasPermi('frequency:banner:query')") + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") Long id) + { + return AjaxResult.success(bannerService.selectBannerById(id)); + } + + /** + * 新增轮播图 + */ + @PreAuthorize("@ss.hasPermi('frequency:banner:add')") + @Log(title = "轮播图", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody Banner banner) + { + return toAjax(bannerService.insertBanner(banner)); + } + + /** + * 修改轮播图 + */ + @PreAuthorize("@ss.hasPermi('frequency:banner:edit')") + @Log(title = "轮播图", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody Banner banner) + { + return toAjax(bannerService.updateBanner(banner)); + } + + /** + * 删除轮播图 + */ + @PreAuthorize("@ss.hasPermi('frequency:banner:remove')") + @Log(title = "轮播图", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}/{delFlag}") + public AjaxResult remove(@PathVariable("ids") Long[] ids,@PathVariable("delFlag") Integer delFlag) + { + return toAjax(bannerService.deleteBannerByIds(ids,delFlag)); + } +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/banner/entity/Banner.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/banner/entity/Banner.java new file mode 100644 index 0000000..d8238b3 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/banner/entity/Banner.java @@ -0,0 +1,71 @@ +package com.ruoyi.frequency.banner.entity; + +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableName; +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import com.ruoyi.vo.UserInfo; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; + +import java.util.Date; + +/** + * 轮播图对象 t_banner + * + * @author liwenlong + * @date 2023-07-20 + */ +@Data +@Accessors(chain = true) +@TableName("t_banner") +public class Banner extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** 租户号 */ + private Long id; + + + + /** 删除标识 1 正常 2 删除 3 禁用 */ + private Integer delFlag; + + /** 展示图 */ + @Excel(name = "展示图") + private String image; + + /** 内容 */ + @Excel(name = "内容") + private String content; + + /** 类型 1 富文本 2 外部链接 3 图片 4 用户 5 表现师 */ + @Excel(name = "类型 1 富文本 2 外部链接 3 图片 4 用户 5 表现师") + private Integer type; + + /** 1 用户端首页上方 2 用户端首页中间 3 表现师端首页上方 4 表现师端首页中间 5 销售端首页上方 */ + @Excel(name = "1 用户端首页上方 2 用户端首页中间 3 表现师端首页上方 4 表现师端首页中间 5 销售端首页上方 ") + private Integer position; + + /** 排序 */ + @Excel(name = "排序") + private Integer sort; + + + /** 用户信息 */ + + @TableField(exist = false) + private UserInfo userInfo; + + @TableField(exist = false) + private String goodsName; + + @ApiModelProperty("开始时间") + @TableField(exist = false) + private Date beginTime; + + @ApiModelProperty("结束时间") + @TableField(exist = false) + private Date endTime; +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/banner/mapper/BannerMapper.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/banner/mapper/BannerMapper.java new file mode 100644 index 0000000..34cd630 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/banner/mapper/BannerMapper.java @@ -0,0 +1,66 @@ +package com.ruoyi.frequency.banner.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.ruoyi.frequency.banner.entity.Banner; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * 轮播图Mapper接口 + * + * @author liwenlong + * @date 2023-07-20 + */ +public interface BannerMapper extends BaseMapper +{ + /** + * 查询轮播图 + * + * @param id 轮播图主键 + * @return 轮播图 + */ + Banner selectBannerById(Long id); + + /** + * 查询轮播图列表 + * + * @param banner 轮播图 + * @return 轮播图集合 + */ + List selectBannerList(Banner banner); + + /** + * 新增轮播图 + * + * @param banner 轮播图 + * @return 结果 + */ + int insertBanner(Banner banner); + + /** + * 修改轮播图 + * + * @param banner 轮播图 + * @return 结果 + */ + int updateBanner(Banner banner); + + /** + * 删除轮播图 + * + * @param id 轮播图主键 + * @return 结果 + */ + int deleteBannerById(Long id); + + /** + * 批量删除轮播图 + * + * @param ids 需要删除的数据主键集合 + * @return 结果 + */ + int deleteBannerByIds(Long[] ids); + + String getMallGoodsDetail(@Param("goodsId") String goodsId); +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/banner/mapper/mapping/BannerMapper.xml b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/banner/mapper/mapping/BannerMapper.xml new file mode 100644 index 0000000..e2c7458 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/banner/mapper/mapping/BannerMapper.xml @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + select id, create_by, create_time, update_by, update_time, del_flag, image, content, type, position, sort from t_banner t + + + + + + + + + insert into t_banner + + id, + create_by, + create_time, + update_by, + update_time, + del_flag, + image, + content, + type, + position, + sort, + + + #{id}, + #{createBy}, + #{createTime}, + #{updateBy}, + #{updateTime}, + #{delFlag}, + #{image}, + #{content}, + #{type}, + #{position}, + #{sort}, + + + + + update t_banner + + create_by = #{createBy}, + create_time = #{createTime}, + update_by = #{updateBy}, + update_time = #{updateTime}, + del_flag = #{delFlag}, + image = #{image}, + content = #{content}, + type = #{type}, + position = #{position}, + sort = #{sort}, + + where id = #{id} + + + + delete from t_banner where id = #{id} + + + + delete from t_banner where id in + + #{id} + + + \ No newline at end of file diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/banner/model/param/BannerParam.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/banner/model/param/BannerParam.java new file mode 100644 index 0000000..633e9ec --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/banner/model/param/BannerParam.java @@ -0,0 +1,58 @@ +package com.ruoyi.frequency.banner.model.param; + +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import lombok.Data; +import lombok.experimental.Accessors; + +/** + * 轮播图对象 t_banner + * + * @author liwenlong + * @date 2023-07-20 + */ +@Data +@Accessors(chain = true) +public class BannerParam extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** 租户号 */ + private Long id; + + + + /** 删除标识 1 正常 2 删除 3 禁用 */ + private Integer delFlag; + + /** 展示图 */ + @Excel(name = "展示图") + private String image; + + /** 内容 */ + @Excel(name = "内容") + private String content; + + /** 类型 1 富文本 2 外部链接 3 图片 4 用户 5 表现师 */ + @Excel(name = "类型 1 富文本 2 外部链接 3 图片 4 用户 5 表现师") + private Integer type; + + /** 1 用户端首页上方 2 用户端首页中间 3 表现师端首页上方 4 表现师端首页中间 5 销售端首页上方 */ + @Excel(name = "1 用户端首页上方 2 用户端首页中间 3 表现师端首页上方 4 表现师端首页中间 5 销售端首页上方 ") + private Integer position; + + /** 排序 */ + @Excel(name = "排序") + private Integer sort; + + + + + + + + + + + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/banner/model/result/BannerResult.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/banner/model/result/BannerResult.java new file mode 100644 index 0000000..3f04ab0 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/banner/model/result/BannerResult.java @@ -0,0 +1,49 @@ +package com.ruoyi.frequency.banner.model.result; + +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import lombok.Data; +import lombok.experimental.Accessors; + +/** + * 轮播图对象 t_banner + * + * @author liwenlong + * @date 2023-07-20 + */ +@Data +@Accessors(chain = true) +public class BannerResult extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** 租户号 */ + private Long id; + + + + /** 删除标识 1 正常 2 删除 3 禁用 */ + private Integer delFlag; + + /** 展示图 */ + @Excel(name = "展示图") + private String image; + + /** 内容 */ + @Excel(name = "内容") + private String content; + + /** 类型 1 富文本 2 外部链接 3 图片 4 用户 5 表现师 */ + @Excel(name = "类型 1 富文本 2 外部链接 3 图片 4 用户 5 表现师") + private Integer type; + + /** 1 用户端首页上方 2 用户端首页中间 3 表现师端首页上方 4 表现师端首页中间 5 销售端首页上方 */ + @Excel(name = "1 用户端首页上方 2 用户端首页中间 3 表现师端首页上方 4 表现师端首页中间 5 销售端首页上方 ") + private Integer position; + + /** 排序 */ + @Excel(name = "排序") + private Integer sort; + + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/banner/service/BannerService.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/banner/service/BannerService.java new file mode 100644 index 0000000..5bc4176 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/banner/service/BannerService.java @@ -0,0 +1,63 @@ +package com.ruoyi.frequency.banner.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.ruoyi.frequency.banner.entity.Banner; + +import java.util.List; + +/** + * 轮播图Service接口 + * + * @author liwenlong + * @date 2023-07-20 + */ +public interface BannerService extends IService +{ + /** + * 查询轮播图 + * + * @param id 轮播图主键 + * @return 轮播图 + */ + Banner selectBannerById(Long id); + + /** + * 查询轮播图列表 + * + * @param banner 轮播图 + * @return 轮播图集合 + */ + List selectBannerList(Banner banner); + + /** + * 新增轮播图 + * + * @param banner 轮播图 + * @return 结果 + */ + int insertBanner(Banner banner); + + /** + * 修改轮播图 + * + * @param banner 轮播图 + * @return 结果 + */ + int updateBanner(Banner banner); + + /** + * 批量删除轮播图 + * + * @param ids 需要删除的轮播图主键集合 + * @return 结果 + */ + int deleteBannerByIds(Long[] ids,Integer delFlag); + + /** + * 删除轮播图信息 + * + * @param id 轮播图主键 + * @return 结果 + */ + int deleteBannerById(Long id); +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/banner/service/impl/BannerServiceImpl.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/banner/service/impl/BannerServiceImpl.java new file mode 100644 index 0000000..2016ddd --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/banner/service/impl/BannerServiceImpl.java @@ -0,0 +1,146 @@ +package com.ruoyi.frequency.banner.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.ruoyi.common.utils.DateUtils; +import com.ruoyi.enums.user.UserEnums; +import com.ruoyi.frequency.banner.entity.Banner; +import com.ruoyi.frequency.banner.mapper.BannerMapper; +import com.ruoyi.frequency.banner.service.BannerService; +import com.ruoyi.frequency.customer.service.UserService; +import com.ruoyi.vo.UserInfo; +import com.ruoyi.vo.UserVo; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.stream.Collectors; + +/** + * 轮播图Service业务层处理 + * + * @author liwenlong + * @date 2023-07-20 + */ +@Service +public class BannerServiceImpl extends ServiceImpl implements BannerService { + @Autowired + private BannerMapper bannerMapper; + + + /** + * 查询轮播图 + * + * @param id 轮播图主键 + * @return 轮播图 + */ + @Override + public Banner selectBannerById(Long id) { + + Banner banner = bannerMapper.selectBannerById(id); + + if (banner.getType() == 4 || banner.getType() == 5) { + Set userVoSet = new HashSet<>(); + + UserVo userVo = new UserVo(banner.getType() == 4 ? UserEnums.customer.getCode() : UserEnums.store.getCode(), Long.valueOf(banner.getContent())); + + userVoSet.add(userVo); + + //查询用户信息 + Map userMap = userService.selectUserInfoMap(userVoSet, null); + + banner.setUserInfo(userMap.get(userVo)); + } else if (banner.getType() == 6) { + String goodsName = bannerMapper.getMallGoodsDetail(banner.getContent()); + banner.setGoodsName(goodsName); + } + + + return banner; + } + + + @Autowired + private UserService userService; + + public static void main(String[] args) { + System.out.println(); + } + + /** + * 查询轮播图列表 + * + * @param banner 轮播图 + * @return 轮播图 + */ + @Override + public List selectBannerList(Banner banner) { + + List banners = bannerMapper.selectBannerList(banner); + + if (!banners.isEmpty()) { + Set userVoSet = banners.stream().filter(s -> s.getType() == 4 || s.getType() == 5) + .map(s -> new UserVo(s.getType() == 4 ? UserEnums.customer.getCode() : UserEnums.store.getCode(), Long.valueOf(s.getContent()))) + .collect(Collectors.toSet()); + //查询用户信息 + Map userMap = userService.selectUserInfoMap(userVoSet, null); + + banners.stream().forEach(s -> { + if (s.getType() == 4 || s.getType() == 5) { + s.setUserInfo(userMap.get(new UserVo(s.getType() == 4 ? UserEnums.customer.getCode() : UserEnums.store.getCode(), Long.valueOf(s.getContent())))); + } + }); + } + + return banners; + } + + /** + * 新增轮播图 + * + * @param banner 轮播图 + * @return 结果 + */ + @Override + public int insertBanner(Banner banner) { + banner.setCreateTime(DateUtils.getNowDate()); + return bannerMapper.insert(banner); + } + + /** + * 修改轮播图 + * + * @param banner 轮播图 + * @return 结果 + */ + @Override + public int updateBanner(Banner banner) { + banner.setUpdateTime(DateUtils.getNowDate()); + return bannerMapper.updateById(banner); + } + + /** + * 批量删除轮播图 + * + * @param ids 需要删除的轮播图主键 + * @return 结果 + */ + @Override + public int deleteBannerByIds(Long[] ids, Integer delFlag) { + this.lambdaUpdate().set(Banner::getDelFlag, delFlag).in(Banner::getId, ids).update(); + return ids.length; + } + + /** + * 删除轮播图信息 + * + * @param id 轮播图主键 + * @return 结果 + */ + @Override + public int deleteBannerById(Long id) { + return bannerMapper.deleteBannerById(id); + } +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/block/controller/BlockController.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/block/controller/BlockController.java new file mode 100644 index 0000000..68fe173 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/block/controller/BlockController.java @@ -0,0 +1,97 @@ +package com.ruoyi.frequency.block.controller; + +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.page.TableDataInfo; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.common.utils.poi.ExcelUtil; +import com.ruoyi.frequency.block.entity.Block; +import com.ruoyi.frequency.block.service.BlockService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +/** + * 拉黑Controller + * + * @author liwenlong + * @date 2023-07-22 + */ +@RestController +@RequestMapping("/frequency/block") +public class BlockController extends BaseController +{ + @Autowired + private BlockService blockService; + + /** + * 查询拉黑列表 + */ + @PreAuthorize("@ss.hasPermi('frequency:block:list')") + @GetMapping("/list") + public TableDataInfo list(Block block) + { + startPage(); + List list = blockService.selectBlockList(block); + return getDataTable(list); + } + + /** + * 导出拉黑列表 + */ + @PreAuthorize("@ss.hasPermi('frequency:block:export')") + @Log(title = "拉黑", businessType = BusinessType.EXPORT) + @GetMapping("/export") + public AjaxResult export(Block block) + { + List list = blockService.selectBlockList(block); + ExcelUtil util = new ExcelUtil(Block.class); + return util.exportExcel(list, "拉黑数据"); + } + + /** + * 获取拉黑详细信息 + */ + @PreAuthorize("@ss.hasPermi('frequency:block:query')") + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") Long id) + { + return AjaxResult.success(blockService.selectBlockById(id)); + } + + /** + * 新增拉黑 + */ + @PreAuthorize("@ss.hasPermi('frequency:block:add')") + @Log(title = "拉黑", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody Block block) + { + return toAjax(blockService.insertBlock(block)); + } + + /** + * 修改拉黑 + */ + @PreAuthorize("@ss.hasPermi('frequency:block:edit')") + @Log(title = "拉黑", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody Block block) + { + return toAjax(blockService.updateBlock(block)); + } + + /** + * 删除拉黑 + */ + @PreAuthorize("@ss.hasPermi('frequency:block:remove')") + @Log(title = "拉黑", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}") + public AjaxResult remove(@PathVariable Long[] ids) + { + return toAjax(blockService.deleteBlockByIds(ids)); + } +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/block/entity/Block.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/block/entity/Block.java new file mode 100644 index 0000000..c67f2e9 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/block/entity/Block.java @@ -0,0 +1,45 @@ +package com.ruoyi.frequency.block.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import lombok.Data; +import lombok.experimental.Accessors; + +/** + * 拉黑对象 t_block + * + * @author liwenlong + * @date 2023-07-22 + */ +@Data +@Accessors(chain = true) +@TableName("t_block") +public class Block extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** 主键id */ + private Long id; + + /** 删除标志 1正常 删除 3 禁用 */ + private Integer delFlag; + + /** 用户id */ + @Excel(name = "用户id") + private Long userId; + + /** 被拉黑用户id */ + @Excel(name = "被拉黑用户id") + private Long blockUserId; + + /** 用户类型 1 用户 2 表现师 */ + @Excel(name = "用户类型 1 用户 2 表现师") + private Integer userType; + + /** 被拉黑用户类型 1 用户 2 表现师 */ + @Excel(name = "被拉黑用户类型 1 用户 2 表现师") + private Integer blockUserType; + + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/block/mapper/BlockMapper.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/block/mapper/BlockMapper.java new file mode 100644 index 0000000..55e558f --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/block/mapper/BlockMapper.java @@ -0,0 +1,70 @@ +package com.ruoyi.frequency.block.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.ruoyi.controller.req.BlockPageReq; +import com.ruoyi.controller.resp.BlockPageResp; +import com.ruoyi.frequency.block.entity.Block; +import com.ruoyi.vo.UserVo; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * 拉黑Mapper接口 + * + * @author liwenlong + * @date 2023-07-22 + */ +public interface BlockMapper extends BaseMapper +{ + /** + * 查询拉黑 + * + * @param id 拉黑主键 + * @return 拉黑 + */ + public Block selectBlockById(Long id); + + /** + * 查询拉黑列表 + * + * @param block 拉黑 + * @return 拉黑集合 + */ + public List selectBlockList(Block block); + + /** + * 新增拉黑 + * + * @param block 拉黑 + * @return 结果 + */ + public int insertBlock(Block block); + + /** + * 修改拉黑 + * + * @param block 拉黑 + * @return 结果 + */ + public int updateBlock(Block block); + + /** + * 删除拉黑 + * + * @param id 拉黑主键 + * @return 结果 + */ + public int deleteBlockById(Long id); + + /** + * 批量删除拉黑 + * + * @param ids 需要删除的数据主键集合 + * @return 结果 + */ + public int deleteBlockByIds(Long[] ids); + + Page blockPage(@Param("page") Page objectPage, @Param("req") BlockPageReq req, @Param("userVo") UserVo userVo); +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/block/mapper/mapping/BlockMapper.xml b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/block/mapper/mapping/BlockMapper.xml new file mode 100644 index 0000000..5048cd5 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/block/mapper/mapping/BlockMapper.xml @@ -0,0 +1,141 @@ + + + + + + + + + + + + + + + + + + + select id, create_by, create_time, update_by, update_time, del_flag, user_id, block_user_id, user_type, block_user_type + from t_block + + + + + + + + insert into t_block + + id, + create_by, + create_time, + update_by, + update_time, + del_flag, + user_id, + block_user_id, + user_type, + block_user_type, + + + #{id}, + #{createBy}, + #{createTime}, + #{updateBy}, + #{updateTime}, + #{delFlag}, + #{userId}, + #{blockUserId}, + #{userType}, + #{blockUserType}, + + + + + update t_block + + create_by = #{createBy}, + create_time = #{createTime}, + update_by = #{updateBy}, + update_time = #{updateTime}, + del_flag = #{delFlag}, + user_id = #{userId}, + block_user_id = #{blockUserId}, + user_type = #{userType}, + block_user_type = #{blockUserType}, + + where id = #{id} + + + + delete from t_block where id = #{id} + + + + delete from t_block where id in + + #{id} + + + + + \ No newline at end of file diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/block/model/param/BlockParam.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/block/model/param/BlockParam.java new file mode 100644 index 0000000..1652139 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/block/model/param/BlockParam.java @@ -0,0 +1,49 @@ +package com.ruoyi.frequency.block.model.param; + +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import lombok.Data; +import lombok.experimental.Accessors; + +/** + * 拉黑对象 t_block + * + * @author liwenlong + * @date 2023-07-22 + */ +@Data +@Accessors(chain = true) +public class BlockParam extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** 主键id */ + private Long id; + + /** 删除标志 1正常 删除 3 禁用 */ + private Integer delFlag; + + /** 用户id */ + @Excel(name = "用户id") + private Long userId; + + /** 被拉黑用户id */ + @Excel(name = "被拉黑用户id") + private Long blockUserId; + + /** 用户类型 1 用户 2 表现师 */ + @Excel(name = "用户类型 1 用户 2 表现师") + private Integer userType; + + /** 被拉黑用户类型 1 用户 2 表现师 */ + @Excel(name = "被拉黑用户类型 1 用户 2 表现师") + private Integer blockUserType; + + + + + + + + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/block/model/result/BlockResult.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/block/model/result/BlockResult.java new file mode 100644 index 0000000..17a6742 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/block/model/result/BlockResult.java @@ -0,0 +1,43 @@ +package com.ruoyi.frequency.block.model.result; + +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import lombok.Data; +import lombok.experimental.Accessors; + +/** + * 拉黑对象 t_block + * + * @author liwenlong + * @date 2023-07-22 + */ +@Data +@Accessors(chain = true) +public class BlockResult extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** 主键id */ + private Long id; + + /** 删除标志 1正常 删除 3 禁用 */ + private Integer delFlag; + + /** 用户id */ + @Excel(name = "用户id") + private Long userId; + + /** 被拉黑用户id */ + @Excel(name = "被拉黑用户id") + private Long blockUserId; + + /** 用户类型 1 用户 2 表现师 */ + @Excel(name = "用户类型 1 用户 2 表现师") + private Integer userType; + + /** 被拉黑用户类型 1 用户 2 表现师 */ + @Excel(name = "被拉黑用户类型 1 用户 2 表现师") + private Integer blockUserType; + + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/block/service/BlockService.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/block/service/BlockService.java new file mode 100644 index 0000000..2559d5d --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/block/service/BlockService.java @@ -0,0 +1,94 @@ +package com.ruoyi.frequency.block.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.ruoyi.controller.req.BlockPageReq; +import com.ruoyi.controller.req.BlockUserReq; +import com.ruoyi.frequency.block.entity.Block; +import com.ruoyi.response.ResponseData; +import com.ruoyi.vo.UserVo; + +import java.util.List; + +/** + * 拉黑Service接口 + * + * @author liwenlong + * @date 2023-07-22 + */ +public interface BlockService extends IService +{ + /** + * 查询拉黑 + * + * @param id 拉黑主键 + * @return 拉黑 + */ + public Block selectBlockById(Long id); + + /** + * 查询拉黑列表 + * + * @param block 拉黑 + * @return 拉黑集合 + */ + public List selectBlockList(Block block); + + /** + * 新增拉黑 + * + * @param block 拉黑 + * @return 结果 + */ + public int insertBlock(Block block); + + /** + * 修改拉黑 + * + * @param block 拉黑 + * @return 结果 + */ + public int updateBlock(Block block); + + /** + * 批量删除拉黑 + * + * @param ids 需要删除的拉黑主键集合 + * @return 结果 + */ + public int deleteBlockByIds(Long[] ids); + + /** + * 删除拉黑信息 + * + * @param id 拉黑主键 + * @return 结果 + */ + public int deleteBlockById(Long id); + + /** + * 拉黑用户 + * @param req + * @param userVo + * @return + */ + ResponseData blockUser(BlockUserReq req, UserVo userVo); + + /** + * 拉黑用户列表(自己查看) + * @param req + * @param userVo + * @return + */ + ResponseData blockPage(BlockPageReq req, UserVo userVo); + + /** + * 拉黑用户列表(他人查看) + * @param req + * @return + */ + ResponseData otherBlockPage(BlockPageReq req,UserVo userVo); + + ResponseData blockUserVersion2(BlockUserReq req, UserVo userVo); + + ResponseData cancelBlockUserVersion2(BlockUserReq req, UserVo userVo); +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/block/service/impl/BlockServiceImpl.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/block/service/impl/BlockServiceImpl.java new file mode 100644 index 0000000..347f8bd --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/block/service/impl/BlockServiceImpl.java @@ -0,0 +1,210 @@ +package com.ruoyi.frequency.block.service.impl; + +import cn.hutool.core.util.ObjectUtil; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.ruoyi.code.PublicCommon; +import com.ruoyi.common.page.PageResult; +import com.ruoyi.common.utils.DateUtils; +import com.ruoyi.controller.req.BlockPageReq; +import com.ruoyi.controller.req.BlockUserReq; +import com.ruoyi.controller.resp.BlockPageResp; +import com.ruoyi.frequency.block.entity.Block; +import com.ruoyi.frequency.block.mapper.BlockMapper; +import com.ruoyi.frequency.block.service.BlockService; +import com.ruoyi.frequency.customer.service.UserService; +import com.ruoyi.response.ResponseData; +import com.ruoyi.vo.UserInfo; +import com.ruoyi.vo.UserVo; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.stream.Collectors; + +/** + * 拉黑Service业务层处理 + * + * @author liwenlong + * @date 2023-07-22 + */ +@Service +public class BlockServiceImpl extends ServiceImpl implements BlockService { + @Autowired + private BlockMapper blockMapper; + + /** + * 查询拉黑 + * + * @param id 拉黑主键 + * @return 拉黑 + */ + @Override + public Block selectBlockById(Long id) { + return blockMapper.selectBlockById(id); + } + + /** + * 查询拉黑列表 + * + * @param block 拉黑 + * @return 拉黑 + */ + @Override + public List selectBlockList(Block block) { + return blockMapper.selectBlockList(block); + } + + /** + * 新增拉黑 + * + * @param block 拉黑 + * @return 结果 + */ + @Override + public int insertBlock(Block block) { + block.setCreateTime(DateUtils.getNowDate()); + return blockMapper.insertBlock(block); + } + + /** + * 修改拉黑 + * + * @param block 拉黑 + * @return 结果 + */ + @Override + public int updateBlock(Block block) { + block.setUpdateTime(DateUtils.getNowDate()); + return blockMapper.updateBlock(block); + } + + /** + * 批量删除拉黑 + * + * @param ids 需要删除的拉黑主键 + * @return 结果 + */ + @Override + public int deleteBlockByIds(Long[] ids) { + return blockMapper.deleteBlockByIds(ids); + } + + /** + * 删除拉黑信息 + * + * @param id 拉黑主键 + * @return 结果 + */ + @Override + public int deleteBlockById(Long id) { + return blockMapper.deleteBlockById(id); + } + + + @Override + public ResponseData blockUser(BlockUserReq req, UserVo userVo) { + + Block block = this.getOne(new QueryWrapper().lambda() + .eq(Block::getUserType, userVo.getUserType()) + .eq(Block::getUserId, userVo.getUserId()) + .eq(Block::getBlockUserType, req.getUserType()) + .eq(Block::getBlockUserId, req.getUserId())); + boolean isBlock = false; + if (block == null) { + block = new Block() + .setUserId(userVo.getUserId()) + .setUserType(userVo.getUserType()) + .setBlockUserType(req.getUserType()) + .setBlockUserId(req.getUserId()); + this.save(block); + //拉黑 + isBlock = true; + } else { + //是否拉黑 + isBlock = ObjectUtil.notEqual(PublicCommon.启用, block.getDelFlag()); + + this.lambdaUpdate().set(Block::getDelFlag, isBlock ? PublicCommon.启用 : PublicCommon.删除) + .eq(Block::getId, block.getId()).update(); + } + + return ResponseData.success(); + } + + @Autowired + private UserService userService; + + @Override + public ResponseData blockPage(BlockPageReq req, UserVo userVo) { + Page page = this.baseMapper.blockPage(new Page<>(req.getPageNo(), req.getPageSize()), req, userVo); + + if (!page.getRecords().isEmpty()) { + Set userVoSet = page.getRecords().stream().map(resp -> new UserVo(resp.getBlockUserType(), resp.getBlockUserId())).collect(Collectors.toSet()); + //查询用户信息 + Map userMap = userService.selectUserInfoMap(userVoSet, userVo); + + page.getRecords().stream().forEach(resp -> { + resp.setUserInfo(userMap.get(new UserVo(resp.getBlockUserType(), resp.getBlockUserId()))); + }); + } + return ResponseData.success(new PageResult<>(page)); + } + + @Override + public ResponseData otherBlockPage(BlockPageReq req, UserVo userVo) { + + Page page = this.baseMapper.blockPage(new Page<>(req.getPageNo(), req.getPageSize()), req, new UserVo(req.getOtherUserType(), req.getOtherUserId())); + + if (!page.getRecords().isEmpty()) { + Set userVoSet = page.getRecords().stream().map(resp -> new UserVo(resp.getBlockUserType(), resp.getBlockUserId())).collect(Collectors.toSet()); + //查询用户信息 + Map userMap = userService.selectUserInfoMap(userVoSet, userVo); + + page.getRecords().stream().forEach(resp -> { + resp.setUserInfo(userMap.get(new UserVo(resp.getBlockUserType(), resp.getBlockUserId()))); + }); + } + return ResponseData.success(new PageResult<>(page)); + } + + @Override + public ResponseData blockUserVersion2(BlockUserReq req, UserVo userVo) { + Block block = this.getOne(new QueryWrapper().lambda() + .eq(Block::getUserType, userVo.getUserType()) + .eq(Block::getUserId, userVo.getUserId()) + .eq(Block::getBlockUserType, req.getUserType()) + .eq(Block::getBlockUserId, req.getUserId())); + if (block == null) { + block = new Block() + .setUserId(userVo.getUserId()) + .setUserType(userVo.getUserType()) + .setBlockUserType(req.getUserType()) + .setBlockUserId(req.getUserId()); + this.save(block); + } else { + this.lambdaUpdate().set(Block::getDelFlag, PublicCommon.启用) + .eq(Block::getId, block.getId()).update(); + } + + return ResponseData.success(); + } + + @Override + public ResponseData cancelBlockUserVersion2(BlockUserReq req, UserVo userVo) { + Block block = this.getOne(new QueryWrapper().lambda() + .eq(Block::getUserType, userVo.getUserType()) + .eq(Block::getUserId, userVo.getUserId()) + .eq(Block::getBlockUserType, req.getUserType()) + .eq(Block::getBlockUserId, req.getUserId()) + .eq(Block::getDelFlag, PublicCommon.启用)); + if (block != null) { + this.lambdaUpdate().set(Block::getDelFlag, PublicCommon.删除) + .eq(Block::getId, block.getId()).update(); + } + + return ResponseData.success(); + } +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/customer/controller/CustomerController.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/customer/controller/CustomerController.java new file mode 100644 index 0000000..1832fd5 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/customer/controller/CustomerController.java @@ -0,0 +1,107 @@ +package com.ruoyi.frequency.customer.controller; + +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.page.TableDataInfo; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.common.utils.poi.ExcelUtil; +import com.ruoyi.frequency.customer.entity.Customer; +import com.ruoyi.frequency.customer.model.result.CustomerCount; +import com.ruoyi.frequency.customer.service.CustomerService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +/** + * 用户Controller + * + * @author liwenlong + * @date 2023-09-22 + */ +@RestController +@RequestMapping("/frequency/customer") +public class CustomerController extends BaseController +{ + @Autowired + private CustomerService customerService; + + /** + * 查询用户列表 + */ + @PreAuthorize("@ss.hasPermi('frequency:customer:list')") + @PostMapping("/list") + public TableDataInfo list(@RequestBody Customer customer) + { + startPage(); + List list = customerService.selectCustomerList(customer); + return getDataTable(list); + } + + /** + * 统计 + */ + @PostMapping("/statistics") + public AjaxResult statistics(@RequestBody Customer customer) + { + CustomerCount count = customerService.statistics(customer); + return AjaxResult.success(count); + } + + /** + * 导出用户列表 + */ + @PreAuthorize("@ss.hasPermi('frequency:customer:export')") + @Log(title = "用户", businessType = BusinessType.EXPORT) + @GetMapping("/export") + public AjaxResult export(Customer customer) + { + List list = customerService.selectCustomerList(customer); + ExcelUtil util = new ExcelUtil(Customer.class); + return util.exportExcel(list, "用户数据"); + } + + /** + * 获取用户详细信息 + */ + @PreAuthorize("@ss.hasPermi('frequency:customer:query')") + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") Long id) + { + return AjaxResult.success(customerService.selectCustomerById(id)); + } + + /** + * 删除用户 + */ + @PreAuthorize("@ss.hasPermi('frequency:customer:remove')") + @Log(title = "用户", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}/{delFlag}") + public AjaxResult remove(@PathVariable("ids") Long[] ids,@PathVariable("delFlag") Integer delFlag) + { + return toAjax(customerService.deleteCustomerByIds(ids,delFlag)); + } + + /** + * 修改余额 + */ + @Log(title = "设计师", businessType = BusinessType.UPDATE) + @PostMapping("/updateBalance") + public AjaxResult updateBalance(@RequestBody Customer customer) + { + return customerService.updateBalance(customer); + } + + /** + * 修改积分 + */ + @Log(title = "设计师", businessType = BusinessType.UPDATE) + @PostMapping("/updateIntegral") + public AjaxResult updateIntegral(@RequestBody Customer customer) + { + return customerService.updateIntegral(customer); + } + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/customer/entity/Customer.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/customer/entity/Customer.java new file mode 100644 index 0000000..a8edb55 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/customer/entity/Customer.java @@ -0,0 +1,194 @@ +package com.ruoyi.frequency.customer.entity; + +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableName; +import com.fasterxml.jackson.annotation.JsonFormat; +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import com.ruoyi.vo.UserInfo; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; + +import java.math.BigDecimal; +import java.util.Date; +import java.util.List; + +/** + * 用户对象 t_customer + * + * @author liwenlong + * @date 2023-07-20 + */ +@Data +@Accessors(chain = true) +@TableName("t_customer") +public class Customer extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** 唯一标识 */ + private Long id; + + /** 删除标识;1正常 2 删除 3 禁用 */ + private Integer delFlag; + + /** 登录账号 */ + @Excel(name = "登录账号") + private String account; + + /** 手机号 */ + @Excel(name = "手机号") + private String mobile; + + /** 昵称 */ + @Excel(name = "昵称") + private String nickname; + + /** 头像 */ + @Excel(name = "头像") + private String avatar; + + /** 区号 */ + @Excel(name = "区号") + private String areaCode; + + /** 登录密码 */ + @Excel(name = "登录密码") + private String loginPwd; + + /** 支付密码 */ + @Excel(name = "支付密码") + private String payPwd; + + /** 注销时间 */ + @Excel(name = "注销时间", width = 30, dateFormat = "yyyy-MM-dd") + private Date cancellationTime; + + /** 手机id */ + @Excel(name = "手机id") + private String clientId; + + /** 微信id */ + @Excel(name = "微信id") + private String wechatOpenid; + + /** 小程序id */ + @Excel(name = "小程序id") + private String wechatAppletOpenid; + + /** 小程序unionId*/ + @Excel(name = "小程序unionId") + private String unionId; + + /** 苹果id */ + @Excel(name = "苹果id") + private String appleOpenid; + + /** 推送是否关闭;1不关闭2 关闭 */ + @Excel(name = "推送是否关闭;1不关闭2 关闭") + private Integer closeMessage; + + /** 邀请码 */ + @Excel(name = "邀请码") + private String invitationCode; + + /** 余额 */ + @Excel(name = "余额") + private BigDecimal balance; + + + /** 入行时间 */ + @Excel(name = "入行时间", width = 30, dateFormat = "yyyy-MM-dd") + @JsonFormat(pattern = "yyyy") + private Date enterDate; + + /** 在线状态;1:在线,2离线 */ + @Excel(name = "在线状态;1:在线,2离线") + private Integer onlineStatus; + + /** 在线时长;分钟 */ + @Excel(name = "在线时长;分钟") + private Integer onlineDuration; + + /** 等级,VIP1 - VIP10 */ + @Excel(name = "等级,VIP1 - VIP10") + private Long levelId; + + private BigDecimal star; + + @ApiModelProperty(value = "消费金额") + private BigDecimal consumptionAmount; + + @ApiModelProperty(value = "区域") + private String area; + + @ApiModelProperty(value = "等级") + @TableField(exist = false) + private String levelName; + + @ApiModelProperty(value = "背景图") + private String backgroundImage; + + @ApiModelProperty(value = "充值抵用金") + private BigDecimal giveBalance; + + @ApiModelProperty(value = "积分") + private BigDecimal integral; + + @ApiModelProperty(value = "累计积分") + private BigDecimal accumulateIntegral; + + @ApiModelProperty("昵称") + private String name; + + @ApiModelProperty("性别") + private String sex; + + @ApiModelProperty("开始时间") + @TableField(exist = false) + private Date beginTime; + + @ApiModelProperty("结束时间") + @TableField(exist = false) + private Date endTime; + + + @ApiModelProperty("排序 1在线时长降序 2 在线时长升序") + @TableField(exist = false) + private Integer sortType; + + /** 用户粉丝基数 */ + @TableField(exist = false) + private Long fansNum; + + /** 用户关注基数 */ + @Excel(name = "用户关注基数") + @TableField(exist = false) + private Long followNum; + + @ApiModelProperty("用户ids") + @TableField(exist = false) + private List userIds; + + + @TableField(exist = false) + private UserInfo userInfo; + + @ApiModelProperty("订单数量") + @TableField(exist = false) + private Integer orderCount; + + @ApiModelProperty("订单单价") + @TableField(exist = false) + private BigDecimal unitPrice; + + @ApiModelProperty("最近交易时间") + @TableField(exist = false) + private Date lastTransactionTime; + + @ApiModelProperty("当月金额、业绩") + @TableField(exist = false) + private BigDecimal monthAmount; + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/customer/mapper/CustomerMapper.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/customer/mapper/CustomerMapper.java new file mode 100644 index 0000000..8b5fcbd --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/customer/mapper/CustomerMapper.java @@ -0,0 +1,112 @@ +package com.ruoyi.frequency.customer.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.ruoyi.controller.req.CustomerPageReq; +import com.ruoyi.controller.resp.UserResultInfo; +import com.ruoyi.frequency.customer.entity.Customer; +import com.ruoyi.frequency.customer.model.result.CustomerCount; +import com.ruoyi.frequency.illegaldeductionrecord.model.result.OrderInfoResp; +import com.ruoyi.vo.UserVo; +import org.apache.ibatis.annotations.Param; +import org.apache.ibatis.annotations.Update; + +import java.math.BigDecimal; +import java.util.List; + +/** + * 用户Mapper接口 + * + * @author liwenlong + * @date 2023-09-22 + */ +public interface CustomerMapper extends BaseMapper +{ + /** + * 查询用户 + * + * @param id 用户主键 + * @return 用户 + */ + public Customer selectCustomerById(Long id); + + /** + * 查询用户列表 + * + * @param customer 用户 + * @return 用户集合 + */ + public List selectCustomerList(Customer customer); + + /** + * 新增用户 + * + * @param customer 用户 + * @return 结果 + */ + public int insertCustomer(Customer customer); + + /** + * 修改用户 + * + * @param customer 用户 + * @return 结果 + */ + public int updateCustomer(Customer customer); + + /** + * 删除用户 + * + * @param id 用户主键 + * @return 结果 + */ + public int deleteCustomerById(Long id); + + /** + * 批量删除用户 + * + * @param ids 需要删除的数据主键集合 + * @return 结果 + */ + public int deleteCustomerByIds(Long[] ids); + + UserResultInfo info(@Param("userId") Long userId); + + @Update("update t_customer set balance=balance + #{price} where id = #{customerId}") + boolean addBalance(@Param("customerId") Long customerId, @Param("price") BigDecimal price); + + @Update("update t_customer set balance=balance - #{price} where id = #{customerId} and balance >=#{price}") + boolean subBalance(@Param("customerId") Long customerId, @Param("price") BigDecimal price); + + @Update("update t_customer set give_balance=give_balance + #{price} where id = #{customerId}") + boolean addGiveBalance(@Param("customerId") Long customerId, @Param("price") BigDecimal price); + + @Update("update t_customer set give_balance=give_balance - #{price} where id = #{customerId} and give_balance >=#{price}") + boolean subGiveBalance(@Param("customerId") Long customerId, @Param("price") BigDecimal price); + + + @Update("update t_customer set integral=integral + #{price} where id = #{customerId}") + boolean addIntegral(@Param("customerId") Long customerId, @Param("price") BigDecimal price); + + @Update("update t_customer set integral=integral - #{price} where id = #{customerId} and integral >=#{price}") + boolean subIntegral(@Param("customerId") Long customerId, @Param("price") BigDecimal price); + + @Update("update t_customer set consumption_amount=consumption_amount + #{price} where id = #{customerId}") + boolean addConsumptionAmount(@Param("customerId") Long customerId, @Param("price") BigDecimal price); + + String longestIdNo(); + + void saveIdNo(@Param("id") Long id); + + Page customerPage(@Param("page") Page objectPage,@Param("req") CustomerPageReq req, @Param("userVo")UserVo userVo); + + CustomerCount statistics(@Param("list") List customerIdList); + + Integer onlineNumber(Customer customer); + + Integer canCancellation(@Param("userId")Long userId); + + OrderInfoResp getOrderInfo(@Param("orderId")Long orderId); + + void insertOnlineLog(@Param("userVo") UserVo userVo); +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/customer/mapper/UserMapper.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/customer/mapper/UserMapper.java new file mode 100644 index 0000000..a806dc3 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/customer/mapper/UserMapper.java @@ -0,0 +1,43 @@ +package com.ruoyi.frequency.customer.mapper; + +import com.ruoyi.vo.UserInfo; +import com.ruoyi.vo.UserVo; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * 用户Mapper接口 + * + * @author liwenlong + * @date 2023-07-20 + */ +public interface UserMapper +{ + + /** + * 查询用户信息 + * @param cusomerIds 设计师ids + * @param storeIds 表现师ids + * @param saleIds 销售ids + * @param userVo + * @return + */ + List selectUserInfoList(@Param("customerIds") List cusomerIds,@Param("storeIds") List storeIds,@Param("saleIds") List saleIds,@Param("enterpriseIds") List enterpriseIds,@Param("userVo") UserVo userVo); + + + /** + * 拉黑用户集合 + * @param userVo + * @return + */ + List blockUserList(@Param("userVo") UserVo userVo); + + + /** + * 屏蔽用户集合 + * @param userVo + * @return + */ + List shieldUserList(@Param("userVo") UserVo userVo); +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/customer/mapper/mapping/CustomerMapper.xml b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/customer/mapper/mapping/CustomerMapper.xml new file mode 100644 index 0000000..9bd0e41 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/customer/mapper/mapping/CustomerMapper.xml @@ -0,0 +1,529 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + SELECT + t.id, + t.create_by, + t.create_time, + t.update_by, + t.update_time, + t.del_flag, + t.account, + t.mobile, + t.nickname, + t.name, + t.avatar, + t.area_code, + t.login_pwd, + t.pay_pwd, + t.cancellation_time, + t.client_id, + t.wechat_openid, + t.wechat_applet_openid, + t.apple_openid, + t.close_message, + t.invitation_code, + t.balance, + t.give_balance, + t.enter_date, + t.online_status, + t.online_duration, + t.level_id, + t.remark, + t.star, + t.consumption_amount, + t.area, + t.integral, + l.`name` levelName, + (SELECT count( 1 ) FROM t_follow f WHERE f.del_flag = 1 AND f.user_type = 1 AND f.user_id = t.id) fansNum, + (SELECT count( 1 ) FROM t_follow f WHERE f.del_flag = 1 AND f.follower_user_type = 1 AND f.follower_user_id = t.id) followNum, + (SELECT count(1) + FROM t_order o + WHERE o.first_status = 2 AND o.customer_id = t.id ) orderCount, + ( + SELECT + IFNULL(ROUND(AVG(o.amount), 2) , 0) + FROM + t_order o + WHERE + o.first_status = 2 + AND o.customer_id = t.id + ) unitPrice + , ( + SELECT + create_time + FROM + t_order o + WHERE + o.first_status = 2 + AND o.customer_id = t.id + ORDER BY + o.create_time DESC + LIMIT 1 + ) lastTransactionTime, + ( + SELECT + IFNULL(sum (o.amount), 0) + FROM + t_order o + WHERE + o.first_status = 2 + AND o.customer_id = t.id + AND DATE_FORMAT(o.create_time + , '%Y-%m-01') >= DATE_FORMAT(CURDATE() + , '%Y-%m-01') + ) monthAmount + FROM + t_customer AS t + LEFT JOIN t_level l ON l.type = 1 and l.id = ( + SELECT + l2.id + FROM + t_level l2 + WHERE + l2.del_flag = 1 + and l2.type =1 + and l2.compliance <= t.consumption_amount + ORDER BY + l2.compliance DESC + LIMIT 1 + ) + + + + + + + + + + + + insert into t_customer + + id, + create_by, + create_time, + update_by, + update_time, + del_flag, + account, + mobile, + nickname, + avatar, + area_code, + login_pwd, + pay_pwd, + cancellation_time, + client_id, + wechat_openid, + wechat_applet_openid, + apple_openid, + close_message, + invitation_code, + balance, + enter_date, + online_status, + online_duration, + level_id, + star, + + + #{id}, + #{createUser}, + #{createTime}, + #{updateUser}, + #{updateTime}, + #{delFlag}, + #{account}, + #{mobile}, + #{nickname}, + #{avatar}, + #{areaCode}, + #{loginPwd}, + #{payPwd}, + #{cancellationTime}, + #{clientId}, + #{wechatOpenid}, + #{wechatAppletOpenid}, + #{appleOpenid}, + #{closeMessage}, + #{invitationCode}, + #{balance}, + #{enterDate}, + #{onlineStatus}, + #{onlineDuration}, + #{levelId}, + #{star}, + + + + insert into t_online_log (user_id,user_type,create_time) + values (#{userVo.userId},#{userVo.userType},NOW()); + + + + update t_customer + + create_by = #{createUser}, + create_time = #{createTime}, + update_by = #{updateUser}, + update_time = #{updateTime}, + del_flag = #{delFlag}, + account = #{account}, + mobile = #{mobile}, + nickname = #{nickname}, + avatar = #{avatar}, + area_code = #{areaCode}, + login_pwd = #{loginPwd}, + pay_pwd = #{payPwd}, + cancellation_time = #{cancellationTime}, + client_id = #{clientId}, + wechat_openid = #{wechatOpenid}, + wechat_applet_openid = #{wechatAppletOpenid}, + apple_openid = #{appleOpenid}, + close_message = #{closeMessage}, + invitation_code = #{invitationCode}, + balance = #{balance}, + enter_date = #{enterDate}, + online_status = #{onlineStatus}, + online_duration = #{onlineDuration}, + level_id = #{levelId}, + star = #{star}, + + where id = #{id} + + + UPDATE t_customer + SET nickname = ( + SELECT + tt.num + FROM + ( + SELECT + count(*) AS num + FROM + t_customer + WHERE + create_time <= ( + SELECT + create_time + FROM + t_customer + WHERE + id = #{id} + ) + ) tt + ) + WHERE + id = #{id} + + + + delete from t_customer where id = #{id} + + + + delete from t_customer where id in + + #{id} + + + + + + + + + + + + + diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/customer/mapper/mapping/UserMapper.xml b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/customer/mapper/mapping/UserMapper.xml new file mode 100644 index 0000000..70c55c0 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/customer/mapper/mapping/UserMapper.xml @@ -0,0 +1,358 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/customer/model/param/CustomerParam.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/customer/model/param/CustomerParam.java new file mode 100644 index 0000000..2b8503f --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/customer/model/param/CustomerParam.java @@ -0,0 +1,138 @@ +package com.ruoyi.frequency.customer.model.param; + +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import lombok.Data; +import lombok.experimental.Accessors; + +import java.math.BigDecimal; +import java.util.Date; + +/** + * 用户对象 t_customer + * + * @author liwenlong + * @date 2023-09-22 + */ +@Data +@Accessors(chain = true) +public class CustomerParam extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** 唯一标识 */ + private Long id; + + /** 创建人 */ + @Excel(name = "创建人") + private Long createUser; + + /** 更新人 */ + @Excel(name = "更新人") + private Long updateUser; + + /** 删除标识;1正常 2 删除 3 禁用 */ + private Integer delFlag; + + /** 登录账号 */ + @Excel(name = "登录账号") + private String account; + + /** 手机号 */ + @Excel(name = "手机号") + private String mobile; + + /** 昵称 */ + @Excel(name = "昵称") + private String nickname; + + /** 头像 */ + @Excel(name = "头像") + private String avatar; + + /** 区号 */ + @Excel(name = "区号") + private String areaCode; + + /** 登录密码 */ + @Excel(name = "登录密码") + private String loginPwd; + + /** 支付密码 */ + @Excel(name = "支付密码") + private String payPwd; + + /** 注销时间 */ + @Excel(name = "注销时间", width = 30, dateFormat = "yyyy-MM-dd") + private Date cancellationTime; + + /** 手机id */ + @Excel(name = "手机id") + private String clientId; + + /** 微信id */ + @Excel(name = "微信id") + private String wechatOpenid; + + /** 小程序id */ + @Excel(name = "小程序id") + private String wechatAppletOpenid; + + /** 苹果id */ + @Excel(name = "苹果id") + private String appleOpenid; + + /** 推送是否关闭;1不关闭2 关闭 */ + @Excel(name = "推送是否关闭;1不关闭2 关闭") + private Integer closeMessage; + + /** 邀请码 */ + @Excel(name = "邀请码") + private String invitationCode; + + /** 余额 */ + @Excel(name = "余额") + private BigDecimal balance; + + /** 入行时间 */ + @Excel(name = "入行时间", width = 30, dateFormat = "yyyy-MM-dd") + private Date enterDate; + + /** 在线状态;1:在线,2离线 */ + @Excel(name = "在线状态;1:在线,2离线") + private Integer onlineStatus; + + /** 在线时长;分钟 */ + @Excel(name = "在线时长;分钟") + private Integer onlineDuration; + + /** 等级,VIP1 - VIP10 */ + @Excel(name = "等级,VIP1 - VIP10") + private Long levelId; + + + + + + + + + + + + + + + + + + + + + + + + + + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/customer/model/result/CustomerCount.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/customer/model/result/CustomerCount.java new file mode 100644 index 0000000..cb2238c --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/customer/model/result/CustomerCount.java @@ -0,0 +1,38 @@ +package com.ruoyi.frequency.customer.model.result; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.math.BigDecimal; + +/** + * @author a + * @date 2024/2/22 11:42 + */ +@Data +public class CustomerCount { + + @ApiModelProperty("总人数") + private Integer number; + + @ApiModelProperty("在线人数") + private Integer onlineNumber; + + @ApiModelProperty("总在线时长") + private Integer onlineDuration; + + @ApiModelProperty("余额") + private BigDecimal balance; + + @ApiModelProperty("抵用金") + private BigDecimal giveBalance; + + @ApiModelProperty("累计消费") + private BigDecimal consumptionAmount; + + @ApiModelProperty("粉丝数") + private Integer fansNum; + + @ApiModelProperty("关注数") + private Integer followNum; +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/customer/model/result/CustomerResult.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/customer/model/result/CustomerResult.java new file mode 100644 index 0000000..fd74025 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/customer/model/result/CustomerResult.java @@ -0,0 +1,115 @@ +package com.ruoyi.frequency.customer.model.result; + +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import lombok.Data; +import lombok.experimental.Accessors; + +import java.math.BigDecimal; +import java.util.Date; + +/** + * 用户对象 t_customer + * + * @author liwenlong + * @date 2023-09-22 + */ +@Data +@Accessors(chain = true) +public class CustomerResult extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** 唯一标识 */ + private Long id; + + /** 创建人 */ + @Excel(name = "创建人") + private Long createUser; + + /** 更新人 */ + @Excel(name = "更新人") + private Long updateUser; + + /** 删除标识;1正常 2 删除 3 禁用 */ + private Integer delFlag; + + /** 登录账号 */ + @Excel(name = "登录账号") + private String account; + + /** 手机号 */ + @Excel(name = "手机号") + private String mobile; + + /** 昵称 */ + @Excel(name = "昵称") + private String nickname; + + + /** 头像 */ + @Excel(name = "头像") + private String avatar; + + /** 区号 */ + @Excel(name = "区号") + private String areaCode; + + /** 登录密码 */ + @Excel(name = "登录密码") + private String loginPwd; + + /** 支付密码 */ + @Excel(name = "支付密码") + private String payPwd; + + /** 注销时间 */ + @Excel(name = "注销时间", width = 30, dateFormat = "yyyy-MM-dd") + private Date cancellationTime; + + /** 手机id */ + @Excel(name = "手机id") + private String clientId; + + /** 微信id */ + @Excel(name = "微信id") + private String wechatOpenid; + + /** 小程序id */ + @Excel(name = "小程序id") + private String wechatAppletOpenid; + + /** 苹果id */ + @Excel(name = "苹果id") + private String appleOpenid; + + /** 推送是否关闭;1不关闭2 关闭 */ + @Excel(name = "推送是否关闭;1不关闭2 关闭") + private Integer closeMessage; + + /** 邀请码 */ + @Excel(name = "邀请码") + private String invitationCode; + + /** 余额 */ + @Excel(name = "余额") + private BigDecimal balance; + + /** 入行时间 */ + @Excel(name = "入行时间", width = 30, dateFormat = "yyyy-MM-dd") + private Date enterDate; + + /** 在线状态;1:在线,2离线 */ + @Excel(name = "在线状态;1:在线,2离线") + private Integer onlineStatus; + + /** 在线时长;分钟 */ + @Excel(name = "在线时长;分钟") + private Integer onlineDuration; + + /** 等级,VIP1 - VIP10 */ + @Excel(name = "等级,VIP1 - VIP10") + private Long levelId; + + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/customer/service/CustomerService.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/customer/service/CustomerService.java new file mode 100644 index 0000000..1861383 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/customer/service/CustomerService.java @@ -0,0 +1,146 @@ +package com.ruoyi.frequency.customer.service; + +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.IService; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.page.PageResult; +import com.ruoyi.controller.req.CustomerPageReq; +import com.ruoyi.controller.req.RegisterUserReq; +import com.ruoyi.controller.req.UserEditReqVo; +import com.ruoyi.frequency.customer.entity.Customer; +import com.ruoyi.frequency.customer.model.param.CustomerParam; +import com.ruoyi.frequency.customer.model.result.CustomerCount; +import com.ruoyi.response.ResponseData; +import com.ruoyi.vo.UserVo; + +import java.util.List; + +/** + * 用户Service接口 + * + * @author liwenlong + * @date 2023-09-22 + */ +public interface CustomerService extends IService +{ + /** + * 查询用户 + * + * @param id 用户主键 + * @return 用户 + */ + public Customer selectCustomerById(Long id); + + /** + * 查询用户列表 + * + * @param customer 用户 + * @return 用户集合 + */ + public List selectCustomerList(Customer customer); + + CustomerCount statistics(Customer customer); + + /** + * 新增用户 + * + * @param customer 用户 + * @return 结果 + */ + public int insertCustomer(Customer customer); + + /** + * 修改用户 + * + * @param customer 用户 + * @return 结果 + */ + public int updateCustomer(Customer customer); + + /** + * 批量删除用户 + * + * @param ids 需要删除的用户主键集合 + * @return 结果 + */ + public int deleteCustomerByIds(Long[] ids,Integer delFlag); + + /** + * 删除用户信息 + * + * @param id 用户主键 + * @return 结果 + */ + public int deleteCustomerById(Long id); + + + /** + * 修改用户余额 + * @param customer + * @return + */ + AjaxResult updateBalance(Customer customer); + + /** + * 组装用户 + * @param req + * @param md5Pwd + * @return + */ + Customer assembleCustomer(RegisterUserReq req, String md5Pwd); + + + /** + * 用户个人信息 + * @param userVo + * @return + */ + ResponseData info(UserVo userVo); + + + /** + * 编辑用户信息 + * @param req + * @param userVo + * @return + */ + ResponseData editInfo(UserEditReqVo req, UserVo userVo); + + + /** + * 后台编辑用户的启用禁用状态 + */ + void switchEnable(CustomerParam customerParam); + + + /** + * 根据账号查询用户 + * @param account 账号 + * @return 用户 + */ + Customer getCustomerByAccount(String account); + + /** + * 根据手机号查询用户 + * @param areaCode 区号 + * @param mobile 手机号 + * @return 用户 + */ + Customer getCustomerByMobile(String areaCode,String mobile); + + + void saveIdNo(Long id); + + + /** + * 设计师列表 + * @param req + * @param userVo + * @return + */ + ResponseData>> customerPage(CustomerPageReq req, UserVo userVo); + + void canCancellation(Long userId); + + AjaxResult updateIntegral(Customer customer); +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/customer/service/UserService.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/customer/service/UserService.java new file mode 100644 index 0000000..efc0793 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/customer/service/UserService.java @@ -0,0 +1,38 @@ +package com.ruoyi.frequency.customer.service; + +import com.ruoyi.response.ResponseData; +import com.ruoyi.vo.UserInfo; +import com.ruoyi.vo.UserVo; + +import java.util.List; +import java.util.Map; +import java.util.Set; + +public interface UserService { + + /** + * 根据用户id 查询用户基本信息 + * @param set + * @return + */ + Map selectUserInfoMap(Set set,UserVo userVo); + + + /** + * 拉黑用户集合 + * @param userVo + * @return + */ + List blockUserList(UserVo userVo); + + /** + * 屏蔽用户集合 + * @param userVo + * @return + */ + List shieldUserList(UserVo userVo); + + void storeByEnterprise(UserVo userVo); + + ResponseData userRelationship(UserVo otherUserVo, UserVo userVo); +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/customer/service/impl/CustomerServiceImpl.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/customer/service/impl/CustomerServiceImpl.java new file mode 100644 index 0000000..2b0094c --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/customer/service/impl/CustomerServiceImpl.java @@ -0,0 +1,536 @@ +package com.ruoyi.frequency.customer.service.impl; + +import cn.hutool.core.date.DateUtil; +import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.StrUtil; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; +import com.baomidou.mybatisplus.extension.conditions.update.LambdaUpdateChainWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.ruoyi.code.DictConstant; +import com.ruoyi.code.PublicCommon; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.domain.entity.SysDictData; +import com.ruoyi.common.core.redis.RedisService; +import com.ruoyi.common.exception.CustomException; +import com.ruoyi.common.exception.ServiceException; +import com.ruoyi.common.exception.enums.CoreExceptionEnum; +import com.ruoyi.common.page.PageResult; +import com.ruoyi.common.utils.DateUtils; +import com.ruoyi.controller.req.CustomerPageReq; +import com.ruoyi.controller.req.RegisterUserReq; +import com.ruoyi.controller.req.UserEditReqVo; +import com.ruoyi.controller.resp.UserResultInfo; +import com.ruoyi.enums.IntegralDetailEnums; +import com.ruoyi.enums.PlatformRecordEnums; +import com.ruoyi.enums.WalletDetailEnums; +import com.ruoyi.enums.user.UserEnums; +import com.ruoyi.frequency.customer.entity.Customer; +import com.ruoyi.frequency.customer.mapper.CustomerMapper; +import com.ruoyi.frequency.customer.model.param.CustomerParam; +import com.ruoyi.frequency.customer.model.result.CustomerCount; +import com.ruoyi.frequency.customer.service.CustomerService; +import com.ruoyi.frequency.customer.service.UserService; +import com.ruoyi.frequency.integralrecord.service.IntegralRecordService; +import com.ruoyi.frequency.level.service.LevelService; +import com.ruoyi.frequency.platformrecord.service.PlatformRecordService; +import com.ruoyi.frequency.store.entity.Store; +import com.ruoyi.frequency.store.mapper.StoreMapper; +import com.ruoyi.frequency.wallerecord.service.WalletRecordService; +import com.ruoyi.response.ResponseData; +import com.ruoyi.utils.BusinessUtil; +import com.ruoyi.utils.SnowIdUtils; +import com.ruoyi.vo.UserInfo; +import com.ruoyi.vo.UserVo; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.redis.core.RedisTemplate; +import org.springframework.stereotype.Service; + +import java.math.BigDecimal; +import java.util.*; +import java.util.stream.Collectors; + +/** + * 用户Service业务层处理 + * + * @author liwenlong + * @date 2023-09-22 + */ +@Service +public class CustomerServiceImpl extends ServiceImpl implements CustomerService { + @Autowired + private CustomerMapper customerMapper; + + @Autowired + private BusinessUtil businessUtil; + + /** + * 查询用户 + * + * @param id 用户主键 + * @return 用户 + */ + @Override + public Customer selectCustomerById(Long id) { + return customerMapper.selectCustomerById(id); + } + + @Autowired + private RedisService redisService; + + /** + * 查询用户列表 + * + * @param customer 用户 + * @return 用户 + */ + @Override + public List selectCustomerList(Customer customer) { + + //上次调用此接口的时间 + String last_time_map_key = "last_time_" + 1; + + List customers = customerList(customer); + if (customers.size() > 0) { + customers.stream().forEach(s -> { + + //在线状态;1:在线,2离线 + Integer onlineStatus = 2; + + if (redisTemplate.opsForHash().hasKey(last_time_map_key, s.getId().toString())) { + long lastTimes = Long.valueOf(redisTemplate.opsForHash().get(last_time_map_key, s.getId().toString()).toString()); + + //判断当前时间和上次时间是否超过6分钟(考虑到网络延时和程序卡顿,多1分钟) + if (System.currentTimeMillis() - lastTimes < (6 * 60 * 1000)) { + onlineStatus = 1; + } + } + + s.setOnlineStatus(onlineStatus); + }); + } + return customers; + } + + private List customerList(Customer customer) { + + //上次调用此接口的时间 + String last_time_map_key = "last_time_" + 1; + + //在线状态;1:在线,2离线 + if (ObjectUtil.isNotEmpty(customer.getOnlineStatus())) { + + List userIds = new ArrayList<>(); + + if (redisTemplate.hasKey(last_time_map_key)) { + + Map cacheMap = redisService.getCacheMap(last_time_map_key); + + cacheMap.forEach((key, value) -> { + + long lastTimes = Long.valueOf(value.toString()); + + if (ObjectUtil.equal(1, customer.getOnlineStatus()) && System.currentTimeMillis() - lastTimes < (6 * 60 * 1000)) { + userIds.add(Long.valueOf(key)); + } + }); + //userIds为空 直接返回 + if (userIds.size() == 0) { + if (ObjectUtil.equal(1, customer.getOnlineStatus())) { + return new ArrayList<>(); + } else { + customer.setOnlineStatus(null); + } + } else { + customer.setUserIds(userIds); + } + + } else { + if (ObjectUtil.equal(1, customer.getOnlineStatus())) { + return new ArrayList<>(); + } else { + customer.setOnlineStatus(null); + } + } + + + } + + List customers = customerMapper.selectCustomerList(customer); + return customers; + } + + @Override + public CustomerCount statistics(Customer customer) { + + List customerList = customerList(customer); + List customerIdList = customerList.stream().map(x -> x.getId()).collect(Collectors.toList()); + customerIdList.add(-1L); + + CustomerCount statistics = customerMapper.statistics(customerIdList); + + if (ObjectUtil.isNotEmpty(customer.getOnlineStatus()) && customer.getOnlineStatus() == 2) { + statistics.setOnlineNumber(0); + return statistics; + } + + //在线设计师数 + String last_time_map_key = "last_time_" + 1; + + Map cacheMap = redisService.getCacheMap(last_time_map_key); + + List userIds = new ArrayList<>(); + + cacheMap.forEach((key, value) -> { + + long lastTimes = Long.valueOf(value.toString()); + + if (System.currentTimeMillis() - lastTimes < (6 * 60 * 1000)) { + userIds.add(Long.valueOf(key)); + } + }); + + Integer onlineNumber = 0; + if (userIds.size() > 0) { + customer.setOnlineStatus(1); + customer.setUserIds(userIds); + onlineNumber = customerMapper.onlineNumber(customer); + } + statistics.setOnlineNumber(onlineNumber); + + + return statistics; + } + + /** + * 新增用户 + * + * @param customer 用户 + * @return 结果 + */ + @Override + public int insertCustomer(Customer customer) { + customer.setCreateTime(DateUtils.getNowDate()); + return customerMapper.insert(customer); + } + + /** + * 修改用户 + * + * @param customer 用户 + * @return 结果 + */ + @Override + public int updateCustomer(Customer customer) { + customer.setUpdateTime(DateUtils.getNowDate()); + return customerMapper.updateById(customer); + } + + /** + * 批量删除用户 + * + * @param ids 需要删除的用户主键 + * @return 结果 + */ + @Override + public int deleteCustomerByIds(Long[] ids, Integer delFlag) { + this.lambdaUpdate().set(Customer::getDelFlag, delFlag).in(Customer::getId, ids).update(); + return ids.length; + } + + /** + * 删除用户信息 + * + * @param id 用户主键 + * @return 结果 + */ + @Override + public int deleteCustomerById(Long id) { + this.lambdaUpdate().set(Customer::getDelFlag, PublicCommon.删除).eq(Customer::getId, id).update(); + return 1; + } + + @Autowired + private WalletRecordService walletRecordService; + + @Autowired + private IntegralRecordService integralRecordService; + + @Autowired + private PlatformRecordService platformRecordService; + + @Override + public AjaxResult updateBalance(Customer customer) { + + BigDecimal balanceSub = customer.getBalance(); + if (balanceSub != null) { + //修改余额 + if (balanceSub.compareTo(BigDecimal.ZERO) > 0) { + walletRecordService.updateBalance(new UserVo(UserEnums.customer.getCode(), customer.getId()), WalletDetailEnums.PLAT_ADD, customer.getRemark(), customer.getId(), balanceSub, PublicCommon.Wallet.可提现); + //平台流水 + platformRecordService.addPlatformRecord(new UserVo(UserEnums.customer.getCode(), customer.getId()), customer.getId(), balanceSub.negate(), PlatformRecordEnums.PLAT_ADD); + + } + if (balanceSub.compareTo(BigDecimal.ZERO) < 0) { + walletRecordService.updateBalance(new UserVo(UserEnums.customer.getCode(), customer.getId()), WalletDetailEnums.PLAT_SUB, customer.getRemark(), customer.getId(), balanceSub, PublicCommon.Wallet.可提现); + //平台流水 + platformRecordService.addPlatformRecord(new UserVo(UserEnums.customer.getCode(), customer.getId()), customer.getId(), balanceSub, PlatformRecordEnums.PLAT_ADD); + } + } + return AjaxResult.success(); + } + + + @Override + public AjaxResult updateIntegral(Customer customer) { + + BigDecimal integral = customer.getIntegral(); + if (integral != null) { + + //修改积分 + if (integral.compareTo(BigDecimal.ZERO) > 0) { + integralRecordService.updateIntegral(new UserVo(UserEnums.customer.getCode(), customer.getId()), customer.getId(), integral, IntegralDetailEnums.PLAT_ADD,customer.getRemark()); + + } else if (integral.compareTo(BigDecimal.ZERO) < 0) { + integralRecordService.updateIntegral(new UserVo(UserEnums.customer.getCode(), customer.getId()), customer.getId(), integral, IntegralDetailEnums.PLAT_SUB,customer.getRemark()); + } + } + + return AjaxResult.success(); + } + + + /** + * 组装用户 + * + * @param req 账号 + * @param md5Pwd 登录密码 + * @return + */ + @Override + public Customer assembleCustomer(RegisterUserReq req, String md5Pwd) { + + Customer customer = new Customer(); + customer.setId(SnowIdUtils.uniqueLong()); + + //账号 + customer.setAccount(ObjectUtil.isNotEmpty(req.getAccount()) ? req.getAccount() : req.getMobile()); + + //手机号 + customer.setMobile(ObjectUtil.isNotEmpty(req.getMobile()) ? req.getMobile() : req.getAccount()); + + + //默认头像 + SysDictData dict = businessUtil.getDict(DictConstant.默认头像); + customer.setAvatar(dict.getImages()); + + Customer maxCustomer = this.getOne(new QueryWrapper().lambda().orderByDesc(Customer::getNickname).last("limit 1")); + + Integer num = maxCustomer == null ? 0 : Integer.valueOf(maxCustomer.getNickname().replace("SJS", "")); + + //默认昵称 + SysDictData sjs_dict = businessUtil.getDict(DictConstant.SJS_name_pre); + String name = sjs_dict.getDictValue(); + if (ObjectUtil.isNotEmpty(name)) { + + String str = customer.getMobile(); + String lastFour = ""; + if (ObjectUtil.isNotEmpty(str)) { + int length = str.length(); + lastFour = (length > 4) ? str.substring(length - 4) : str; + } + name = name.concat(lastFour); + } + customer.setName(name); + + customer.setNickname(getNickname(num)); + customer.setLoginPwd(md5Pwd); + customer.setClientId(req.getClientId()); + customer.setCreateTime(new Date()); + customer.setUpdateTime(new Date()); + customer.setAreaCode(req.getAreaCode()); + + return customer; + } + + @Autowired + private LevelService levelService; + + private String getNickname(Integer num) { + String template = "SJS%06d"; + num++; + String id = String.format(template, num); + return id; + } + + @Autowired + private RedisTemplate redisTemplate; + + @Override + public ResponseData info(UserVo userVo) { + + UserResultInfo info = baseMapper.info(userVo.getUserId()); + + //上次调用此接口的时间 + String last_time_map_key = "last_time_" + userVo.getUserType(); + + //在线状态;1:在线,2离线 + Integer onlineStatus = 2; + + if (redisTemplate.opsForHash().hasKey(last_time_map_key, info.getUserId().toString())) { + long lastTimes = Long.valueOf(redisTemplate.opsForHash().get(last_time_map_key, info.getUserId().toString()).toString()); + + //判断当前时间和上次时间是否超过6分钟(考虑到网络延时和程序卡顿,多1分钟) + if (System.currentTimeMillis() - lastTimes < (6 * 60 * 1000)) { + onlineStatus = 1; + } + } + + info.setOnlineStatus(onlineStatus); + + return ResponseData.success(info); + } + + @Autowired + private UserService userService; + + @Override + public ResponseData>> customerPage(CustomerPageReq req, UserVo userVo) { + + //筛去拉黑与被拉黑用户 +// if (req.getType() != null && req.getType() == 1) { +// List blockUserList = userService.blockUserList(userVo); +// req.setBlockUserList(blockUserList); +// +// //筛去屏蔽用户 +// List shieldUserList = userService.shieldUserList(userVo); +// req.setShieldUserList(shieldUserList); +// } + + Page page = customerMapper.customerPage(new Page<>(req.getPageNo(), req.getPageSize()), req, userVo); + + if (page.getRecords().size() > 0) { + Set userVoSet = page.getRecords().stream().map(resp -> new UserVo(UserEnums.customer.getCode(), resp.getId())).collect(Collectors.toSet()); + //查询用户信息 + Map userMap = userService.selectUserInfoMap(userVoSet, userVo); + + page.getRecords().stream().forEach(resp -> { + resp.setUserInfo(userMap.get(new UserVo(UserEnums.customer.getCode(), resp.getId()))); + }); + } + + return ResponseData.success(new PageResult<>(page)); + } + + @Override + public void canCancellation(Long userId) { + Integer orderCount = baseMapper.canCancellation(userId); + if (orderCount > 0) { + throw new ServiceException("您有未完成的订单,不可注销"); + } + } + + @Override + public ResponseData editInfo(UserEditReqVo vo, UserVo userVo) { + + + LambdaUpdateChainWrapper lambdaUpdate = this.lambdaUpdate(); + lambdaUpdate.set(Customer::getId,userVo.getUserId()); + //头像 + if (ObjectUtil.isNotEmpty(vo.getAvatar())) { + lambdaUpdate.set(Customer::getAvatar, vo.getAvatar()); + } + //所属区域 + if (ObjectUtil.isNotEmpty(vo.getArea())) { + lambdaUpdate.set(Customer::getArea, vo.getArea()); + } + + //性别 + if (ObjectUtil.isNotEmpty(vo.getSex())) { + lambdaUpdate.set(Customer::getSex, vo.getSex()); + } + + //入行时间 + if (ObjectUtil.isNotEmpty(vo.getEnterDate())) { + lambdaUpdate.set(Customer::getEnterDate, DateUtil.parse(vo.getEnterDate(), "yyyy")); + } + //背景图 + if (ObjectUtil.isNotEmpty(vo.getBackgroundImage())) { + lambdaUpdate.set(Customer::getBackgroundImage, vo.getBackgroundImage()); + } + + //推送是否关闭;1不关闭2 关闭 + if (ObjectUtil.isNotEmpty(vo.getCloseMessage())) { + lambdaUpdate.set(Customer::getCloseMessage, vo.getCloseMessage()); + } + + //昵称 + if (ObjectUtil.isNotEmpty(vo.getName())) { + lambdaUpdate.set(Customer::getName, vo.getName()); + } + + //条件 + lambdaUpdate.eq(Customer::getId, userVo.getUserId()).update(); + + if (ObjectUtil.isNotEmpty(vo.getName())) { + Integer count = baseMapper.selectCount(new QueryWrapper().lambda().eq(Customer::getDelFlag, PublicCommon.启用) + .eq(Customer::getName, vo.getName())); + Integer count1 = storeMapper.selectCount(new QueryWrapper().lambda().eq(Store::getDelFlag, PublicCommon.启用) + .eq(Store::getName, vo.getName())); + if (count + count1 > 1) { + return ResponseData.error("昵称重复"); + } + + //判断敏感词 + businessUtil.checkSensitiveWord(vo.getName()); + } + + + return ResponseData.success(); + } + + @Autowired + private StoreMapper storeMapper; + + + @Override + public void switchEnable(CustomerParam customerParam) { + if (ObjectUtil.equal(customerParam.getDelFlag(), PublicCommon.删除)) { + throw new CustomException(CoreExceptionEnum.ERROR_PARAM); + } + LambdaUpdateWrapper queryWrapper = new LambdaUpdateWrapper<>(); + queryWrapper.eq(Customer::getId, customerParam.getId()); + queryWrapper.set(Customer::getDelFlag, customerParam.getDelFlag()); + update(queryWrapper); + } + + @Override + public Customer getCustomerByAccount(String account) { + return this.getOne(new QueryWrapper().lambda() + .ne(Customer::getDelFlag, PublicCommon.删除) + .eq(Customer::getAccount, account)); + } + + + /** + * 根据手机号查询用户 + * + * @param areaCode 区号 + * @param mobile 手机号 + * @return 用户 + */ + @Override + public Customer getCustomerByMobile(String areaCode, String mobile) { + return this.getOne(new QueryWrapper().lambda() + .ne(Customer::getDelFlag, PublicCommon.删除) + .eq(StrUtil.isNotEmpty(areaCode), Customer::getAreaCode, areaCode) + .eq(Customer::getMobile, mobile)); + } + + + @Override + public void saveIdNo(Long id) { + baseMapper.saveIdNo(id); + } +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/customer/service/impl/UserServiceImpl.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/customer/service/impl/UserServiceImpl.java new file mode 100644 index 0000000..1261450 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/customer/service/impl/UserServiceImpl.java @@ -0,0 +1,194 @@ +package com.ruoyi.frequency.customer.service.impl; + +import cn.hutool.core.collection.CollectionUtil; +import cn.hutool.core.util.ObjectUtil; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.ruoyi.code.DictConstant; +import com.ruoyi.code.PublicCommon; +import com.ruoyi.common.exception.CustomException; +import com.ruoyi.enums.user.UserEnums; +import com.ruoyi.frequency.block.entity.Block; +import com.ruoyi.frequency.block.service.BlockService; +import com.ruoyi.frequency.customer.mapper.UserMapper; +import com.ruoyi.frequency.customer.service.UserService; +import com.ruoyi.frequency.store.entity.Store; +import com.ruoyi.frequency.store.service.StoreService; +import com.ruoyi.response.ResponseData; +import com.ruoyi.utils.BusinessUtil; +import com.ruoyi.vo.UserInfo; +import com.ruoyi.vo.UserVo; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.redis.core.RedisTemplate; +import org.springframework.stereotype.Service; + +import java.math.BigDecimal; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; + +/** + * @author a + * @date 2023/9/25 14:55 + */ +@Service +public class UserServiceImpl implements UserService { + + @Autowired + private UserMapper userMapper; + + @Autowired + private BusinessUtil businessUtil; + + + @Override + public Map selectUserInfoMap(Set userVoSet, UserVo userVo) { + + Map userInfoMap = new HashMap<>(); + + if (userVoSet == null || userVoSet.isEmpty()) { + return userInfoMap; + } + + //设计师 + List customerIds = CollectionUtil.toList(); + + //表现师 + List storeIds = CollectionUtil.toList(); + + //销售 + List saleIds = CollectionUtil.toList(); + + //企业 + List enterpriseIds = CollectionUtil.toList(); + + userVoSet.stream().forEach(user -> { + if (user == null || user.getUserId() == null) { + return; + } + if (user.getUserType() == 1) { + customerIds.add(user.getUserId()); + } else if (user.getUserType() == 2) { + storeIds.add(user.getUserId()); + } else if (user.getUserType() == 3) { + saleIds.add(user.getUserId()); + } else { + enterpriseIds.add(user.getUserId()); + } + }); + + List userInfos = userMapper.selectUserInfoList(customerIds, storeIds, saleIds, enterpriseIds, userVo); + + //累计服务金额基数 + BigDecimal orderAmount = new BigDecimal(businessUtil.getDict(DictConstant.OrderDict.累计服务金额基数).getDictValue()); + + //当月服务单数基数 + Integer orderMonthNum = Integer.valueOf(businessUtil.getDict(DictConstant.OrderDict.当月服务单数基数).getDictValue()); + + //累计服务单数基数 + Integer orderNum = Integer.valueOf(businessUtil.getDict(DictConstant.OrderDict.累计服务单数基数).getDictValue()); + + userInfos.stream().forEach(userInfo -> { + + Integer userType = userInfo.getUserType(); + //上次调用此接口的时间 + String last_time_map_key = "last_time_" + userType; + + //获取在线状态 + userInfo.setOnlineStatus(getOnlineStatus(userInfo.getUserId(), last_time_map_key)); + + if (ObjectUtil.equal(UserEnums.store.getCode(), userInfo.getUserType())) { + //累计服务金额基数 + userInfo.setOrderAmount(orderAmount.add(userInfo.getOrderAmount())); + + //当月服务单数基数 + userInfo.setOrderMonthNum(orderMonthNum + userInfo.getOrderMonthNum()); + + //累计服务单数基数 + userInfo.setOrderNum(orderNum + userInfo.getOrderNum()); + } + + userInfoMap.put(new UserVo(userInfo.getUserType(), userInfo.getUserId()), userInfo); + }); + + return userInfoMap; + } + + @Autowired + private RedisTemplate redisTemplate; + + /** + * 获取在线状态 + * + * @param id + * @param lastTimeMapKey + * @return + */ + private Integer getOnlineStatus(Long id, String lastTimeMapKey) { + + //在线状态;1:在线,2离线 + Integer onlineStatus = 2; + + if (redisTemplate.opsForHash().hasKey(lastTimeMapKey, id.toString())) { + long lastTimes = Long.valueOf(redisTemplate.opsForHash().get(lastTimeMapKey, id.toString()).toString()); + + //判断当前时间和上次时间是否超过6分钟(考虑到网络延时和程序卡顿,多1分钟) + if (System.currentTimeMillis() - lastTimes < (6 * 60 * 1000)) { + onlineStatus = 1; + } + } + + return onlineStatus; + } + + @Override + public List blockUserList(UserVo userVo) { + return userMapper.blockUserList(userVo); + } + + @Override + public List shieldUserList(UserVo userVo) { + return userMapper.shieldUserList(userVo); + } + + + @Autowired + private StoreService storeService; + + @Override + public void storeByEnterprise(UserVo userVo) { + if (UserEnums.enterprise.getCode().equals(userVo.getUserType())) { + Store one = storeService.getOne(new QueryWrapper().lambda().eq(Store::getBindEnterpriseId, userVo.getUserId())); + if (one == null) { + throw new CustomException(700, "token过期"); + } else { + userVo.setUserType(UserEnums.store.getCode()); + userVo.setUserId(one.getId()); + } + } + } + + @Autowired + private BlockService blockService; + + @Override + public ResponseData userRelationship(UserVo otherUserVo, UserVo userVo) { + + List userVos = blockService.list(new QueryWrapper().lambda().eq(Block::getUserId, userVo.getUserId()) + .eq(Block::getUserType, userVo.getUserType()).eq(Block::getDelFlag, PublicCommon.启用)); + + for (Block cur : userVos) { + if (cur.getBlockUserId().equals(otherUserVo.getUserId()) && cur.getBlockUserType().equals(otherUserVo.getUserType())) { + return ResponseData.error("你已将对方拉黑"); + } + } + userVos = blockService.list(new QueryWrapper().lambda().eq(Block::getUserId, otherUserVo.getUserId()) + .eq(Block::getUserType, otherUserVo.getUserType()).eq(Block::getDelFlag, PublicCommon.启用)); + for (Block cur : userVos) { + if (cur.getBlockUserId().equals(userVo.getUserId()) && cur.getBlockUserType().equals(userVo.getUserType())) { + return ResponseData.error("对方已将你拉黑"); + } + } + return ResponseData.success(); + } +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/enterprise/controller/EnterpriseController.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/enterprise/controller/EnterpriseController.java new file mode 100644 index 0000000..e0ce562 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/enterprise/controller/EnterpriseController.java @@ -0,0 +1,125 @@ +package com.ruoyi.frequency.enterprise.controller; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.page.TableDataInfo; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.common.utils.SecurityUtils; +import com.ruoyi.common.utils.poi.ExcelUtil; +import com.ruoyi.frequency.enterprise.entity.Enterprise; +import com.ruoyi.frequency.enterprise.model.result.EnterpriseCount; +import com.ruoyi.frequency.enterprise.service.EnterpriseService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +/** + * 企业信息Controller + * + * @author liwenlong + * @date 2023-10-26 + */ +@RestController +@RequestMapping("/frequency/enterprise") +public class EnterpriseController extends BaseController +{ + @Autowired + private EnterpriseService enterpriseService; + + /** + * 查询企业信息列表 + */ + @PreAuthorize("@ss.hasPermi('frequency:enterprise:list')") + @PostMapping("/list") + public TableDataInfo list(@RequestBody Enterprise enterprise) + { + startPage(); + List list = enterpriseService.selectEnterpriseList(enterprise); + return getDataTable(list); + } + + /** + * 统计 + */ + @PostMapping("/statistics") + public AjaxResult statistics(@RequestBody Enterprise enterprise) + { + EnterpriseCount count = enterpriseService.statistics(enterprise); + return AjaxResult.success(count); + } + + /** + * 导出企业信息列表 + */ + @PreAuthorize("@ss.hasPermi('frequency:enterprise:export')") + @Log(title = "企业信息", businessType = BusinessType.EXPORT) + @GetMapping("/export") + public AjaxResult export(Enterprise enterprise) + { + List list = enterpriseService.selectEnterpriseList(enterprise); + ExcelUtil util = new ExcelUtil(Enterprise.class); + return util.exportExcel(list, "企业信息数据"); + } + + /** + * 获取企业信息详细信息 + */ + @PreAuthorize("@ss.hasPermi('frequency:enterprise:query')") + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") Long id) + { + return AjaxResult.success(enterpriseService.selectEnterpriseById(id)); + } + + /** + * 新增企业信息 + */ + @PreAuthorize("@ss.hasPermi('frequency:enterprise:add')") + @Log(title = "企业信息", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody Enterprise enterprise) + { + return toAjax(enterpriseService.insertEnterprise(enterprise)); + } + + /** + * 修改企业信息 + */ +// @PreAuthorize("@ss.hasPermi('frequency:enterprise:edit')") + @Log(title = "企业信息", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody Enterprise enterprise) + { + return toAjax(enterpriseService.updateEnterprise(enterprise)); + } + + /** + * 删除企业信息 + */ + @PreAuthorize("@ss.hasPermi('frequency:enterprise:remove')") + @Log(title = "企业信息", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}/{delFlag}") + public AjaxResult remove(@PathVariable("ids") Long[] ids,@PathVariable("delFlag") Integer delFlag) + { + return toAjax(enterpriseService.deleteEnterpriseByIds(ids,delFlag)); + } + + /** + * 企业端--获取企业信息 + */ + @PostMapping("/enterpriseInfo") + public AjaxResult enterpriseInfo() + { + Long userId = SecurityUtils.getUserId(); + Enterprise one = enterpriseService.getOne(new QueryWrapper().lambda().eq(Enterprise::getSysUserId, userId)); + + if (one == null){ + return AjaxResult.error("当前登入账号错误"); + } + return AjaxResult.success(enterpriseService.selectEnterpriseById(one.getId())); + } +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/enterprise/entity/Enterprise.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/enterprise/entity/Enterprise.java new file mode 100644 index 0000000..bbfe471 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/enterprise/entity/Enterprise.java @@ -0,0 +1,147 @@ +package com.ruoyi.frequency.enterprise.entity; + +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableName; +import com.fasterxml.jackson.annotation.JsonFormat; +import com.ruoyi.common.annotation.CreateTime; +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import com.ruoyi.vo.UserInfo; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; + +import java.math.BigDecimal; +import java.util.Date; + +/** + * 企业信息对象 t_enterprise + * + * @author liwenlong + * @date 2023-10-26 + */ +@Data +@Accessors(chain = true) +@TableName("t_enterprise") +public class Enterprise extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + + @ApiModelProperty("租户号") + private Long id; + + @ApiModelProperty("删除标志;1 正常 2 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("类型 1施工图 2景观 3 设计") + private Integer type; + + @ApiModelProperty("企业名称") + @Excel(name = "企业名称") + private String name; + + @ApiModelProperty("头像") + @Excel(name = "头像") + private String avatar; + + @ApiModelProperty("企业简介") + @Excel(name = "企业简介") + private String sketch; + + @ApiModelProperty("企业地址") + @Excel(name = "企业地址") + private String address; + + @ApiModelProperty("经度") + @Excel(name = "经度") + private String longitude; + + @ApiModelProperty("纬度") + @Excel(name = "纬度") + private String latitude; + + @ApiModelProperty("企业微信号") + @Excel(name = "企业微信号") + private String wecom; + + @ApiModelProperty("擅长") + @Excel(name = "擅长") + private String goodAt; + + @ApiModelProperty("累计服务金额") + @Excel(name = "累计服务金额") + private BigDecimal serviceAmount; + + @ApiModelProperty("服务单数") + @Excel(name = "服务单数") + private Integer serviceOrderNum; + + @ApiModelProperty("好评率") + @Excel(name = "好评率") + private BigDecimal star; + + @ApiModelProperty("系统用户ID") + @Excel(name = "系统用户ID") + private Long sysUserId; + + @ApiModelProperty("本月服务单数") + private Integer monthServiceOrderNum; + + /** 在线状态;1:在线,2离线 */ + @Excel(name = "在线状态;1:在线,2离线") + private Integer onlineStatus; + + /** 在线时长;分钟 */ + @Excel(name = "在线时长;分钟") + private Integer onlineDuration; + + @ApiModelProperty(value = "区域") + private String area; + + @ApiModelProperty(value = "报价单图片") + private String quotationImage; + + @ApiModelProperty(value = "制作周期") + private String productionCycle; + + @ApiModelProperty(value = "人数") + private String numberPeople; + + @ApiModelProperty(value = "价格定位") + private String pricePosition; + + @ApiModelProperty(value = "保证金额") + private BigDecimal bondAmount; + + @ApiModelProperty(value = "当月服务金额") + private BigDecimal monthServiceAmount; + + /** 企业创建时间 */ + @JsonFormat(pattern = "yyyy-MM-dd") + private Date enterpriseCreateTime; + + @TableField(exist = false) + private UserInfo userInfo; + + @TableField(exist = false) + private Integer userType; + + @TableField(exist = false) + private Long userId; + + @TableField(exist = false) + @ApiModelProperty("后台登录账号") + private String account; + + @TableField(exist = false) + @ApiModelProperty("后台登录密码") + private String loginPwd; + + @TableField(exist = false) + @ApiModelProperty("作品数量") + private Integer worksNum; + + + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/enterprise/mapper/EnterpriseMapper.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/enterprise/mapper/EnterpriseMapper.java new file mode 100644 index 0000000..428c2e1 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/enterprise/mapper/EnterpriseMapper.java @@ -0,0 +1,73 @@ +package com.ruoyi.frequency.enterprise.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.ruoyi.controller.req.StorePageReq; +import com.ruoyi.controller.resp.StorePageResp; +import com.ruoyi.frequency.enterprise.entity.Enterprise; +import com.ruoyi.frequency.enterprise.model.result.EnterpriseCount; +import com.ruoyi.vo.UserVo; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * 企业信息Mapper接口 + * + * @author liwenlong + * @date 2023-10-26 + */ +public interface EnterpriseMapper extends BaseMapper +{ + /** + * 查询企业信息 + * + * @param id 企业信息主键 + * @return 企业信息 + */ + public Enterprise selectEnterpriseById(Long id); + + /** + * 查询企业信息列表 + * + * @param enterprise 企业信息 + * @return 企业信息集合 + */ + public List selectEnterpriseList(Enterprise enterprise); + + /** + * 新增企业信息 + * + * @param enterprise 企业信息 + * @return 结果 + */ + public int insertEnterprise(Enterprise enterprise); + + /** + * 修改企业信息 + * + * @param enterprise 企业信息 + * @return 结果 + */ + public int updateEnterprise(Enterprise enterprise); + + /** + * 删除企业信息 + * + * @param id 企业信息主键 + * @return 结果 + */ + public int deleteEnterpriseById(Long id); + + /** + * 批量删除企业信息 + * + * @param ids 需要删除的数据主键集合 + * @return 结果 + */ + public int deleteEnterpriseByIds(Long[] ids); + + EnterpriseCount statistics(@Param("list") List enterpriseList ); + + Page enterprisePage(@Param("page") Page objectPage,@Param("req") StorePageReq req,@Param("userVo") UserVo userVo); +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/enterprise/mapper/mapping/EnterpriseMapper.xml b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/enterprise/mapper/mapping/EnterpriseMapper.xml new file mode 100644 index 0000000..083518e --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/enterprise/mapper/mapping/EnterpriseMapper.xml @@ -0,0 +1,374 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + SELECT + t.id, + t.create_by, + t.create_time, + t.update_by, + t.update_time, + t.`name`, + t.del_flag, + t.avatar, + t.sketch, + t.address, + t.longitude, + t.latitude, + t.wecom, + t.good_at, + t.service_amount, + t.service_order_num, + t.star, + t.sys_user_id, + t.month_service_order_num, + 2 user_type, + s.id user_id, + su.user_name account, + su. PASSWORD login_pwd, + t.quotation_image, + t.production_cycle, + t.number_people, + t.price_position, + t.type, + t.bond_amount, + t.month_service_amount, + t.enterprise_create_time, + ( + SELECT + count(*) + FROM + t_works w + WHERE + w.store_id = t.id + AND w.del_flag != 2 + ) worksNum + FROM + t_enterprise AS t + LEFT JOIN t_store AS s ON t.id = s.bind_enterprise_id + LEFT JOIN sys_user AS su ON su.user_id = t.sys_user_id + + + + + + + + + + insert into t_enterprise + + id, + create_by, + created_time, + update_by, + update_time, + del_flag, + name, + avatar, + sketch, + address, + longitude, + latitude, + wecom, + good_at, + service_amount, + service_order_num, + star, + sys_user_id, + + + #{id}, + #{createBy}, + #{createdTime}, + #{updateBy}, + #{updateTime}, + #{delFlag}, + #{name}, + #{avatar}, + #{sketch}, + #{address}, + #{longitude}, + #{latitude}, + #{wecom}, + #{goodAt}, + #{serviceAmount}, + #{serviceOrderNum}, + #{star}, + #{sysUserId}, + + + + + update t_enterprise + + create_by = #{createBy}, + created_time = #{createdTime}, + update_by = #{updateBy}, + update_time = #{updateTime}, + del_flag = #{delFlag}, + name = #{name}, + avatar = #{avatar}, + sketch = #{sketch}, + address = #{address}, + longitude = #{longitude}, + latitude = #{latitude}, + wecom = #{wecom}, + good_at = #{goodAt}, + service_amount = #{serviceAmount}, + service_order_num = #{serviceOrderNum}, + star = #{star}, + sys_user_id = #{sysUserId}, + bond_amount = #{bondAmount}, + month_service_amount = #{monthServiceAmount}, + enterprise_create_time = #{enterpriseCreateTime}, + + where id = #{id} + + + + delete from t_enterprise where id = #{id} + + + + delete from t_enterprise where id in + + #{id} + + + + + diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/enterprise/model/param/EnterpriseParam.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/enterprise/model/param/EnterpriseParam.java new file mode 100644 index 0000000..bd316b9 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/enterprise/model/param/EnterpriseParam.java @@ -0,0 +1,98 @@ +package com.ruoyi.frequency.enterprise.model.param; + +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; + +import java.math.BigDecimal; +import java.util.Date; + +/** + * 企业信息对象 t_enterprise + * + * @author liwenlong + * @date 2023-10-26 + */ +@Data +@Accessors(chain = true) +public class EnterpriseParam extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + @ApiModelProperty("租户号") + private Long id; + + @ApiModelProperty("创建时间") + @Excel(name = "创建时间", width = 30, dateFormat = "yyyy-MM-dd") + private Date createdTime; + + @ApiModelProperty("删除标志;1 正常 2 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("企业名称") + @Excel(name = "企业名称") + private String name; + + @ApiModelProperty("头像") + @Excel(name = "头像") + private String avatar; + + @ApiModelProperty("企业简介") + @Excel(name = "企业简介") + private String sketch; + + @ApiModelProperty("企业地址") + @Excel(name = "企业地址") + private String address; + + @ApiModelProperty("经度") + @Excel(name = "经度") + private String longitude; + + @ApiModelProperty("纬度") + @Excel(name = "纬度") + private String latitude; + + @ApiModelProperty("企业微信号") + @Excel(name = "企业微信号") + private String wecom; + + @ApiModelProperty("擅长") + @Excel(name = "擅长") + private String goodAt; + + @ApiModelProperty("累计服务金额") + @Excel(name = "累计服务金额") + private BigDecimal serviceAmount; + + @ApiModelProperty("服务单数") + @Excel(name = "服务单数") + private Long serviceOrderNum; + + @ApiModelProperty("好评率") + @Excel(name = "好评率") + private BigDecimal star; + + @ApiModelProperty("系统用户ID") + @Excel(name = "系统用户ID") + private Long sysUserId; + + + + + + + + + + + + + + + + + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/enterprise/model/result/EnterpriseCount.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/enterprise/model/result/EnterpriseCount.java new file mode 100644 index 0000000..6cb0472 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/enterprise/model/result/EnterpriseCount.java @@ -0,0 +1,27 @@ +package com.ruoyi.frequency.enterprise.model.result; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.math.BigDecimal; + +/** + * @author a + * @date 2024/2/22 14:38 + */ +@Data +public class EnterpriseCount { + + @ApiModelProperty("总人数") + private Integer number; + + @ApiModelProperty("服务金额") + private BigDecimal serviceAmount; + + @ApiModelProperty("服务数") + private Integer serviceOrderNum; + + @ApiModelProperty("作品数量") + private Integer worksNum; + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/enterprise/model/result/EnterpriseResult.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/enterprise/model/result/EnterpriseResult.java new file mode 100644 index 0000000..8c85eba --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/enterprise/model/result/EnterpriseResult.java @@ -0,0 +1,83 @@ +package com.ruoyi.frequency.enterprise.model.result; + +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; + +import java.math.BigDecimal; +import java.util.Date; + +/** + * 企业信息对象 t_enterprise + * + * @author liwenlong + * @date 2023-10-26 + */ +@Data +@Accessors(chain = true) +public class EnterpriseResult extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + @ApiModelProperty("租户号") + private Long id; + + @ApiModelProperty("创建时间") + @Excel(name = "创建时间", width = 30, dateFormat = "yyyy-MM-dd") + private Date createdTime; + + @ApiModelProperty("删除标志;1 正常 2 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("企业名称") + @Excel(name = "企业名称") + private String name; + + @ApiModelProperty("头像") + @Excel(name = "头像") + private String avatar; + + @ApiModelProperty("企业简介") + @Excel(name = "企业简介") + private String sketch; + + @ApiModelProperty("企业地址") + @Excel(name = "企业地址") + private String address; + + @ApiModelProperty("经度") + @Excel(name = "经度") + private String longitude; + + @ApiModelProperty("纬度") + @Excel(name = "纬度") + private String latitude; + + @ApiModelProperty("企业微信号") + @Excel(name = "企业微信号") + private String wecom; + + @ApiModelProperty("擅长") + @Excel(name = "擅长") + private String goodAt; + + @ApiModelProperty("累计服务金额") + @Excel(name = "累计服务金额") + private BigDecimal serviceAmount; + + @ApiModelProperty("服务单数") + @Excel(name = "服务单数") + private Long serviceOrderNum; + + @ApiModelProperty("好评率") + @Excel(name = "好评率") + private BigDecimal star; + + @ApiModelProperty("系统用户ID") + @Excel(name = "系统用户ID") + private Long sysUserId; + + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/enterprise/service/EnterpriseService.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/enterprise/service/EnterpriseService.java new file mode 100644 index 0000000..98831a4 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/enterprise/service/EnterpriseService.java @@ -0,0 +1,77 @@ +package com.ruoyi.frequency.enterprise.service; + +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.IService; +import com.ruoyi.common.page.PageResult; +import com.ruoyi.controller.req.StorePageReq; +import com.ruoyi.controller.req.UserEditReqVo; +import com.ruoyi.controller.resp.StorePageResp; +import com.ruoyi.frequency.enterprise.entity.Enterprise; +import com.ruoyi.frequency.enterprise.model.result.EnterpriseCount; +import com.ruoyi.response.ResponseData; +import com.ruoyi.vo.UserVo; + +import java.util.List; + +/** + * 企业信息Service接口 + * + * @author liwenlong + * @date 2023-10-26 + */ +public interface EnterpriseService extends IService +{ + /** + * 查询企业信息 + * + * @param id 企业信息主键 + * @return 企业信息 + */ + public Enterprise selectEnterpriseById(Long id); + + /** + * 查询企业信息列表 + * + * @param enterprise 企业信息 + * @return 企业信息集合 + */ + public List selectEnterpriseList(Enterprise enterprise); + + EnterpriseCount statistics(Enterprise enterprise); + + /** + * 新增企业信息 + * + * @param enterprise 企业信息 + * @return 结果 + */ + public int insertEnterprise(Enterprise enterprise); + + /** + * 修改企业信息 + * + * @param enterprise 企业信息 + * @return 结果 + */ + public int updateEnterprise(Enterprise enterprise); + + /** + * 批量删除企业信息 + * + * @param ids 需要删除的企业信息主键集合 + * @return 结果 + */ + public int deleteEnterpriseByIds(Long[] ids,Integer delFlag); + + /** + * 删除企业信息信息 + * + * @param id 企业信息主键 + * @return 结果 + */ + public int deleteEnterpriseById(Long id); + + ResponseData editInfo(UserEditReqVo req, UserVo userVo); + + ResponseData>> enterprisePage(StorePageReq req, UserVo userVo); +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/enterprise/service/impl/EnterpriseServiceImpl.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/enterprise/service/impl/EnterpriseServiceImpl.java new file mode 100644 index 0000000..d1acc99 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/enterprise/service/impl/EnterpriseServiceImpl.java @@ -0,0 +1,400 @@ +package com.ruoyi.frequency.enterprise.service.impl; + +import cn.hutool.core.collection.CollectionUtil; +import cn.hutool.core.util.ObjectUtil; +import com.baomidou.mybatisplus.extension.conditions.update.LambdaUpdateChainWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.ruoyi.code.DictConstant; +import com.ruoyi.code.PublicCommon; +import com.ruoyi.common.constant.UserConstants; +import com.ruoyi.common.core.domain.entity.SysDictData; +import com.ruoyi.common.core.domain.entity.SysRole; +import com.ruoyi.common.core.domain.entity.SysUser; +import com.ruoyi.common.core.redis.RedisService; +import com.ruoyi.common.exception.CustomException; +import com.ruoyi.common.page.PageResult; +import com.ruoyi.common.utils.DateUtils; +import com.ruoyi.common.utils.SecurityUtils; +import com.ruoyi.common.utils.StringUtils; +import com.ruoyi.controller.req.StorePageReq; +import com.ruoyi.controller.req.UserEditReqVo; +import com.ruoyi.controller.resp.StorePageResp; +import com.ruoyi.enums.user.UserEnums; +import com.ruoyi.frequency.customer.service.UserService; +import com.ruoyi.frequency.enterprise.entity.Enterprise; +import com.ruoyi.frequency.enterprise.mapper.EnterpriseMapper; +import com.ruoyi.frequency.enterprise.model.result.EnterpriseCount; +import com.ruoyi.frequency.enterprise.service.EnterpriseService; +import com.ruoyi.frequency.store.service.StoreService; +import com.ruoyi.response.ResponseData; +import com.ruoyi.system.service.ISysConfigService; +import com.ruoyi.system.service.ISysRoleService; +import com.ruoyi.system.service.ISysUserService; +import com.ruoyi.utils.BusinessUtil; +import com.ruoyi.vo.UserInfo; +import com.ruoyi.vo.UserVo; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.redis.core.RedisTemplate; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.math.BigDecimal; +import java.util.*; +import java.util.stream.Collectors; + +/** + * 企业信息Service业务层处理 + * + * @author liwenlong + * @date 2023-10-26 + */ +@Service +@Transactional(rollbackFor = Exception.class) +public class EnterpriseServiceImpl extends ServiceImpl implements EnterpriseService +{ + @Autowired + private EnterpriseMapper enterpriseMapper; + + /** + * 查询企业信息 + * + * @param id 企业信息主键 + * @return 企业信息 + */ + @Override + public Enterprise selectEnterpriseById(Long id) + { + + Enterprise enterprise = enterpriseMapper.selectEnterpriseById(id); + + if (enterprise != null){ + Set userVoSet = CollectionUtil.newHashSet(new UserVo(enterprise.getUserType(), enterprise.getUserId())); + //查询用户信息 + Map userMap = userService.selectUserInfoMap(userVoSet,null); + + enterprise.setUserInfo(userMap.get(new UserVo(enterprise.getUserType(), enterprise.getUserId()))); + } + + return enterprise; + } + + + @Autowired + private UserService userService; + + /** + * 查询企业信息列表 + * + * @param enterprise 企业信息 + * @return 企业信息 + */ + @Override + public List selectEnterpriseList(Enterprise enterprise) + { + + List enterprises = enterpriseList(enterprise); + + if (enterprises.size() > 0){ + Set userVoSet = enterprises.stream().map(s -> new UserVo(s.getUserType(), s.getUserId())).collect(Collectors.toSet()); + //查询用户信息 + Map userMap = userService.selectUserInfoMap(userVoSet,null); + + enterprises.stream().forEach(s ->{ + s.setUserInfo(userMap.get(new UserVo(s.getUserType(), s.getUserId()))); + }); + } + + return enterprises; + } + + private List enterpriseList(Enterprise enterprise){ + List enterprises = enterpriseMapper.selectEnterpriseList(enterprise); + return enterprises; + } + + @Override + public EnterpriseCount statistics(Enterprise enterprise) { + List enterprises = enterpriseList(enterprise); + List enterpriseList = enterprises.stream().map(x -> x.getId()).collect(Collectors.toList()); + enterpriseList.add(-1L); + + return enterpriseMapper.statistics(enterpriseList); + } + + + + @Autowired + private ISysRoleService sysRoleService; + + @Autowired + private ISysConfigService configService; + + @Autowired + private ISysUserService sysUserService; + /** + * 新增企业信息 + * + * @param enterprise 企业信息 + * @return 结果 + */ + @Override + public int insertEnterprise(Enterprise enterprise) + { + + //生成企业后台账号 + SysUser user = new SysUser(); + user.setUserName(enterprise.getAccount()); +// user.setPhonenumber(s.getAccount()); + String password = configService.selectConfigByKey("sys.user.initPassword"); + user.setPassword(SecurityUtils.encryptPassword(ObjectUtil.isNotEmpty(enterprise.getLoginPwd())?enterprise.getLoginPwd():password)); + user.setNickName(enterprise.getName()); + user.setUserType("01"); + if (UserConstants.NOT_UNIQUE.equals(sysUserService.checkUserNameUnique(user.getUserName()))) + { + + throw new CustomException("新增用户'" + user.getUserName() + "'失败,登录账号已存在"); + } + else if (StringUtils.isNotEmpty(user.getPhonenumber()) + && UserConstants.NOT_UNIQUE.equals(sysUserService.checkPhoneUnique(user))) + { + throw new CustomException("新增用户'" + user.getUserName() + "'失败,手机号码已存在"); + } + SysRole sysRole = new SysRole(); + sysRole.setRoleKey("enterprise"); + List sysRoles = sysRoleService.selectRoleList(sysRole); + + //角色 + user.setRoleIds(new Long[]{sysRoles.get(0).getRoleId()}); + + sysUserService.insertUser(user); + + //表现师关联企业 + enterprise.setSysUserId(user.getUserId()); + this.save(enterprise); + + return 1; + + } + + /** + * 修改企业信息 + * + * @param enterprise 企业信息 + * @return 结果 + */ + @Override + public int updateEnterprise(Enterprise enterprise) + { + enterprise.setUpdateTime(DateUtils.getNowDate()); + int i = enterpriseMapper.updateById(enterprise); + if (ObjectUtil.isNotEmpty(enterprise.getLoginPwd())){ + Enterprise enterprise1 = enterpriseMapper.selectEnterpriseById(enterprise.getId()); + String password = SecurityUtils.encryptPassword(enterprise.getLoginPwd()); + SysUser sysUser = new SysUser(); + sysUser.setUserId(enterprise1.getSysUserId()); + sysUser.setPassword(password); + sysUserService.updateUser(sysUser); + } + return i; + } + + + @Autowired + private StoreService storeService; + /** + * 批量删除企业信息 + * + * @param ids 需要删除的企业信息主键 + * @return 结果 + */ + @Override + public int deleteEnterpriseByIds(Long[] ids,Integer delFlag) + { + this.lambdaUpdate().set(Enterprise::getDelFlag,delFlag).in(Enterprise::getId,ids).update(); + + //修改对应后台企业账号状态 + if(ObjectUtil.equal(PublicCommon.删除,delFlag)){ +// storeService.lambdaUpdate().set(Store::getBindEnterpriseId,null).in(Store::getBindEnterpriseId,ids).update(); + + List enterprises = enterpriseMapper.selectBatchIds(Arrays.asList(ids)); + + Long[] sysUserIds = enterprises.stream().map(Enterprise::getSysUserId).toArray(Long[]::new); + //删除对应后台企业账号 + sysUserService.deleteUserByIds(sysUserIds); + }else if(ObjectUtil.equal(PublicCommon.禁用,delFlag)){ +// storeService.lambdaUpdate().set(Store::getBindEnterpriseId,null).in(Store::getBindEnterpriseId,ids).update(); + } + + return ids.length; + } + + /** + * 删除企业信息信息 + * + * @param id 企业信息主键 + * @return 结果 + */ + @Override + public int deleteEnterpriseById(Long id) + { + this.lambdaUpdate().set(Enterprise::getDelFlag,PublicCommon.删除).eq(Enterprise::getId,id).update(); + return 1; + } + + @Override + public ResponseData editInfo(UserEditReqVo req, UserVo userVo) { + + LambdaUpdateChainWrapper lambdaUpdate = this.lambdaUpdate(); + //头像 + if (ObjectUtil.isNotEmpty(req.getAvatar())){ + lambdaUpdate.set(Enterprise::getAvatar, req.getAvatar()); + } + + //区域 + if (ObjectUtil.isNotEmpty(req.getArea())){ + lambdaUpdate.set(Enterprise::getArea, req.getArea()); + } + + //条件 + lambdaUpdate.eq(Enterprise::getId, userVo.getUserId()).update(); + + if (ObjectUtil.isNotEmpty(req.getEnterDate())){ + userService.storeByEnterprise(userVo); + UserEditReqVo userEditReqVo = new UserEditReqVo(); + userEditReqVo.setEnterDate(req.getEnterDate()); + return storeService.editInfo(userEditReqVo, userVo); + } + + return ResponseData.success(); + } + + @Autowired + private RedisService redisService; + + @Autowired + private BusinessUtil businessUtil; + + @Autowired + private RedisTemplate redisTemplate; + + @Override + public ResponseData>> enterprisePage(StorePageReq req, UserVo userVo) { + //筛去拉黑与被拉黑用户 + List blockUserList = userService.blockUserList(userVo); + req.setBlockUserList(blockUserList); + + //筛去屏蔽用户 + List shieldUserList = userService.shieldUserList(userVo); + req.setShieldUserList(shieldUserList); + + if (req.getType() == 1) { + //拼接排序 + List dictList = businessUtil.getDictList(DictConstant.技术列表排序权重); + + dictList = dictList.stream().sorted(Comparator.comparing(SysDictData::getDictValue)).collect(Collectors.toList()); + + String sortSql = ""; + + if (dictList != null && dictList.size() > 0) { + + for (SysDictData dictData : dictList) { + if (dictData.getCode().equals(DictConstant.TechnologySort.在线时长)) { + sortSql = sortSql.concat(" tt.online_duration DESC,"); + } else if (dictData.getCode().equals(DictConstant.TechnologySort.订单数量)) { + sortSql = sortSql.concat(" tt.orderNum DESC,"); + } else if (dictData.getCode().equals(DictConstant.TechnologySort.订单金额)) { + sortSql = sortSql.concat(" tt.orderAmount DESC,"); + } else if (dictData.getCode().equals(DictConstant.TechnologySort.好评率)) { + sortSql = sortSql.concat(" tt.star DESC"); + } + } + req.setSortSql(sortSql); + } + } + + //从业年限筛选 + if (ObjectUtil.isNotEmpty(req.getYearRange())){ + String[] split = req.getYearRange().split("-"); + if (split.length == 1){ + req.setMaxYear(Integer.valueOf(split[0])); + } + if (split.length == 2){ + req.setMinYear(Integer.valueOf(split[0])); + req.setMaxYear(Integer.valueOf(split[1])); + } + } + + //在线状态筛选;1:在线,2离线 + if (ObjectUtil.isNotEmpty(req.getOnlineStatus())){ + + //企业 + Integer userType = UserEnums.enterprise.getCode(); + + //上次调用此接口的时间 + String last_time_map_key = "last_time_" + userType; + + List userIds = new ArrayList<>(); + + if (redisTemplate.hasKey(last_time_map_key)) { + + Map cacheMap = redisService.getCacheMap(last_time_map_key); + + cacheMap.forEach((key,value)->{ + + long lastTimes = Long.valueOf(value.toString()); + + if (System.currentTimeMillis() - lastTimes < (6 * 60 * 1000)){ + userIds.add(Long.valueOf(key)); + } + }); + + //userIds为空 直接返回 + if (userIds.size() == 0){ + if (ObjectUtil.equal(1,req.getOnlineStatus())){ + return ResponseData.success(new PageResult<>(new Page<>(req.getPageNo(),req.getPageSize()))); + }else { + req.setOnlineStatus(null); + } + }else { + req.setUserIds(userIds); + } + + }else { + if (ObjectUtil.equal(1,req.getOnlineStatus())){ + return ResponseData.success(new PageResult<>(new Page<>(req.getPageNo(),req.getPageSize()))); + }else { + req.setOnlineStatus(null); + } + } + + + } + + + Page page = enterpriseMapper.enterprisePage(new Page<>(req.getPageNo(), req.getPageSize()), req, userVo); + + if (!page.getRecords().isEmpty()){ + + //上次调用此接口的时间 + String last_time_map_key = "last_time_" + UserEnums.enterprise.getCode(); + + //用户id + Set userVoSet = page.getRecords().stream().map(s -> new UserVo(s.getUserType(), s.getId())).collect(Collectors.toSet()); + + //获取用户信息 + Map userMap = userService.selectUserInfoMap(userVoSet,userVo); + + page.getRecords().stream().forEach(s->{ + + //获取在线状态 + Integer onlineStatus = businessUtil.getOnlineStatus(req.getIsWorkingDrawing() ==2?s.getBindEnterpriseId():s.getId(), last_time_map_key); + s.setOnlineStatus(onlineStatus); + + s.setUserInfo(userMap.get(new UserVo(s.getUserType(), s.getId()))); + }); + } + + return ResponseData.success(new PageResult<>(page)); + } +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/givewallerecord/controller/GiveWalletRecordController.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/givewallerecord/controller/GiveWalletRecordController.java new file mode 100644 index 0000000..27bd954 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/givewallerecord/controller/GiveWalletRecordController.java @@ -0,0 +1,103 @@ +package com.ruoyi.frequency.givewallerecord.controller; + +import java.util.List; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.frequency.givewallerecord.entity.GiveWalletRecord; +import com.ruoyi.frequency.givewallerecord.service.GiveWalletRecordService; +import com.ruoyi.common.utils.poi.ExcelUtil; +import com.ruoyi.common.core.page.TableDataInfo; + +/** + * 抵用金钱包记录Controller + * + * @author liwenlong + * @date 2024-05-18 + */ +@RestController +@RequestMapping("/frequency/givewallerecord") +public class GiveWalletRecordController extends BaseController +{ + @Autowired + private GiveWalletRecordService giveWalletRecordService; + + /** + * 查询抵用金钱包记录列表 + */ + @PreAuthorize("@ss.hasPermi('frequency:givewallerecord:list')") + @GetMapping("/list") + public TableDataInfo list(GiveWalletRecord giveWalletRecord) + { + startPage(); + List list = giveWalletRecordService.selectGiveWalletRecordList(giveWalletRecord); + return getDataTable(list); + } + + /** + * 导出抵用金钱包记录列表 + */ + @PreAuthorize("@ss.hasPermi('frequency:givewallerecord:export')") + @Log(title = "抵用金钱包记录", businessType = BusinessType.EXPORT) + @GetMapping("/export") + public AjaxResult export(GiveWalletRecord giveWalletRecord) + { + List list = giveWalletRecordService.selectGiveWalletRecordList(giveWalletRecord); + ExcelUtil util = new ExcelUtil(GiveWalletRecord.class); + return util.exportExcel(list, "抵用金钱包记录数据"); + } + + /** + * 获取抵用金钱包记录详细信息 + */ + @PreAuthorize("@ss.hasPermi('frequency:givewallerecord:query')") + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") Long id) + { + return AjaxResult.success(giveWalletRecordService.selectGiveWalletRecordById(id)); + } + + /** + * 新增抵用金钱包记录 + */ + @PreAuthorize("@ss.hasPermi('frequency:givewallerecord:add')") + @Log(title = "抵用金钱包记录", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody GiveWalletRecord giveWalletRecord) + { + return toAjax(giveWalletRecordService.insertGiveWalletRecord(giveWalletRecord)); + } + + /** + * 修改抵用金钱包记录 + */ + @PreAuthorize("@ss.hasPermi('frequency:givewallerecord:edit')") + @Log(title = "抵用金钱包记录", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody GiveWalletRecord giveWalletRecord) + { + return toAjax(giveWalletRecordService.updateGiveWalletRecord(giveWalletRecord)); + } + + /** + * 删除抵用金钱包记录 + */ + @PreAuthorize("@ss.hasPermi('frequency:givewallerecord:remove')") + @Log(title = "抵用金钱包记录", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}/{delFlag}") + public AjaxResult remove(@PathVariable("ids") Long[] ids,@PathVariable("delFlag") Integer delFlag) + { + return toAjax(giveWalletRecordService.deleteGiveWalletRecordByIds(ids,delFlag)); + } +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/givewallerecord/entity/GiveWalletRecord.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/givewallerecord/entity/GiveWalletRecord.java new file mode 100644 index 0000000..ed5b407 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/givewallerecord/entity/GiveWalletRecord.java @@ -0,0 +1,80 @@ +package com.ruoyi.frequency.givewallerecord.entity; + +import java.math.BigDecimal; +import java.util.Date; +import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.Data; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.experimental.Accessors; +import com.ruoyi.common.annotation.Excel; +import io.swagger.annotations.ApiModelProperty; +import com.baomidou.mybatisplus.annotation.TableField; +import com.ruoyi.vo.UserInfo; +import com.ruoyi.common.core.domain.BaseEntity; + +/** + * 抵用金钱包记录对象 t_give_wallet_record + * + * @author liwenlong + * @date 2024-05-18 + */ +@Data +@Accessors(chain = true) +@TableName("t_give_wallet_record") +public class GiveWalletRecord extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + + @ApiModelProperty("主键id") + private Long id; + + @ApiModelProperty("删除标志 1正常 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("用户类型 1 用户 2 商家") + @Excel(name = "用户类型 1 用户 2 商家") + private Integer userType; + + @ApiModelProperty("记录类型 具体看代码") + @Excel(name = "记录类型 具体看代码") + private Integer recordType; + + @ApiModelProperty("数值") + @Excel(name = "数值") + private BigDecimal price; + + @ApiModelProperty("用户id(商家关联t_store 用户关联t_customer)") + @Excel(name = "用户id(商家关联t_store 用户关联t_customer)") + private Long userId; + + @ApiModelProperty("记录来源id(如订单,则关联t_order)") + @Excel(name = "记录来源id(如订单,则关联t_order)") + private Long objectId; + + @ApiModelProperty("可提现状态 1 可提现 2 不可提现 3 到账取消") + @Excel(name = "可提现状态 1 可提现 2 不可提现 3 到账取消") + private Integer status; + + @ApiModelProperty("可提现时间") + @Excel(name = "可提现时间", width = 30, dateFormat = "yyyy-MM-dd") + private Date canWithTime; + + @ApiModelProperty("不可提现时间") + @Excel(name = "不可提现时间", width = 30, dateFormat = "yyyy-MM-dd") + private Date noWithTime; + + @ApiModelProperty("取消到账时间") + @Excel(name = "取消到账时间", width = 30, dateFormat = "yyyy-MM-dd") + private Date cancelTime; + + @ApiModelProperty("当前余额") + @Excel(name = "当前余额") + private BigDecimal currentBalance; + + @ApiModelProperty("用户信息") + @TableField(exist = false) + private UserInfo userInfo; + + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/givewallerecord/mapper/GiveWalletRecordMapper.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/givewallerecord/mapper/GiveWalletRecordMapper.java new file mode 100644 index 0000000..6e95c8a --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/givewallerecord/mapper/GiveWalletRecordMapper.java @@ -0,0 +1,53 @@ +package com.ruoyi.frequency.givewallerecord.mapper; + +import java.util.List; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.ruoyi.controller.req.WalletPageReq; +import com.ruoyi.controller.resp.WalletPageResp; +import com.ruoyi.frequency.givewallerecord.entity.GiveWalletRecord; +import com.ruoyi.vo.UserVo; +import org.apache.ibatis.annotations.Param; + +/** + * 抵用金钱包记录Mapper接口 + * + * @author liwenlong + * @date 2024-05-18 + */ +public interface GiveWalletRecordMapper extends BaseMapper +{ + /** + * 查询抵用金钱包记录 + * + * @param id 抵用金钱包记录主键 + * @return 抵用金钱包记录 + */ + public GiveWalletRecord selectGiveWalletRecordById(Long id); + + /** + * 查询抵用金钱包记录列表 + * + * @param giveWalletRecord 抵用金钱包记录 + * @return 抵用金钱包记录集合 + */ + public List selectGiveWalletRecordList(GiveWalletRecord giveWalletRecord); + + /** + * 新增抵用金钱包记录 + * + * @param giveWalletRecord 抵用金钱包记录 + * @return 结果 + */ + public int insertGiveWalletRecord(GiveWalletRecord giveWalletRecord); + + /** + * 修改抵用金钱包记录 + * + * @param giveWalletRecord 抵用金钱包记录 + * @return 结果 + */ + public int updateGiveWalletRecord(GiveWalletRecord giveWalletRecord); + + Page giveWalletPage(@Param("page") Page objectPage, @Param("req") WalletPageReq req, @Param("userVo") UserVo userVo); +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/givewallerecord/mapper/mapping/GiveWalletRecordMapper.xml b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/givewallerecord/mapper/mapping/GiveWalletRecordMapper.xml new file mode 100644 index 0000000..b90d855 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/givewallerecord/mapper/mapping/GiveWalletRecordMapper.xml @@ -0,0 +1,194 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + select + t.id , + t.create_by , + t.create_time , + t.update_by , + t.update_time , + t.del_flag , + t.user_type , + t.record_type , + t.price , + t.user_id , + t.object_id , + t.status , + t.can_with_time , + t.no_with_time , + t.cancel_time , + t.current_balance , + t.remark , + u.user_type, + u.id_no, + u.mobile, + u.avatar, + u.nickname + from t_give_wallet_record AS t + LEFT JOIN t_user AS u ON t.user_id = u.id + + + + + + + + + insert into t_give_wallet_record + + id, + create_by, + create_time, + update_by, + update_time, + del_flag, + user_type, + record_type, + price, + user_id, + object_id, + status, + can_with_time, + no_with_time, + cancel_time, + current_balance, + remark, + + + #{id}, + #{createBy}, + #{createTime}, + #{updateBy}, + #{updateTime}, + #{delFlag}, + #{userType}, + #{recordType}, + #{price}, + #{userId}, + #{objectId}, + #{status}, + #{canWithTime}, + #{noWithTime}, + #{cancelTime}, + #{currentBalance}, + #{remark}, + + + + + update t_give_wallet_record + + create_by = #{createBy}, + create_time = #{createTime}, + update_by = #{updateBy}, + update_time = #{updateTime}, + del_flag = #{delFlag}, + user_type = #{userType}, + record_type = #{recordType}, + price = #{price}, + user_id = #{userId}, + object_id = #{objectId}, + status = #{status}, + can_with_time = #{canWithTime}, + no_with_time = #{noWithTime}, + cancel_time = #{cancelTime}, + current_balance = #{currentBalance}, + remark = #{remark}, + + where id = #{id} + + + + \ No newline at end of file diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/givewallerecord/model/param/GiveWalletRecordParam.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/givewallerecord/model/param/GiveWalletRecordParam.java new file mode 100644 index 0000000..3efd951 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/givewallerecord/model/param/GiveWalletRecordParam.java @@ -0,0 +1,83 @@ +package com.ruoyi.frequency.givewallerecord.model.param; + +import java.math.BigDecimal; +import java.util.Date; +import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.Data; +import lombok.experimental.Accessors; +import com.ruoyi.common.annotation.Excel; +import io.swagger.annotations.ApiModelProperty; +import com.ruoyi.common.core.domain.BaseEntity; + +/** + * 抵用金钱包记录对象 t_give_wallet_record + * + * @author liwenlong + * @date 2024-05-18 + */ +@Data +@Accessors(chain = true) +public class GiveWalletRecordParam extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + @ApiModelProperty("主键id") + private Long id; + + @ApiModelProperty("删除标志 1正常 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("用户类型 1 用户 2 商家") + @Excel(name = "用户类型 1 用户 2 商家") + private Integer userType; + + @ApiModelProperty("记录类型 具体看代码") + @Excel(name = "记录类型 具体看代码") + private Integer recordType; + + @ApiModelProperty("数值") + @Excel(name = "数值") + private BigDecimal price; + + @ApiModelProperty("用户id(商家关联t_store 用户关联t_customer)") + @Excel(name = "用户id(商家关联t_store 用户关联t_customer)") + private Long userId; + + @ApiModelProperty("记录来源id(如订单,则关联t_order)") + @Excel(name = "记录来源id(如订单,则关联t_order)") + private Long objectId; + + @ApiModelProperty("可提现状态 1 可提现 2 不可提现 3 到账取消") + @Excel(name = "可提现状态 1 可提现 2 不可提现 3 到账取消") + private Integer status; + + @ApiModelProperty("可提现时间") + @Excel(name = "可提现时间", width = 30, dateFormat = "yyyy-MM-dd") + private Date canWithTime; + + @ApiModelProperty("不可提现时间") + @Excel(name = "不可提现时间", width = 30, dateFormat = "yyyy-MM-dd") + private Date noWithTime; + + @ApiModelProperty("取消到账时间") + @Excel(name = "取消到账时间", width = 30, dateFormat = "yyyy-MM-dd") + private Date cancelTime; + + @ApiModelProperty("当前余额") + @Excel(name = "当前余额") + private BigDecimal currentBalance; + + + + + + + + + + + + + + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/givewallerecord/model/result/GiveWalletRecordResult.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/givewallerecord/model/result/GiveWalletRecordResult.java new file mode 100644 index 0000000..12684a5 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/givewallerecord/model/result/GiveWalletRecordResult.java @@ -0,0 +1,71 @@ +package com.ruoyi.frequency.givewallerecord.model.result; + +import java.math.BigDecimal; +import java.util.Date; +import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.Data; +import lombok.experimental.Accessors; +import com.ruoyi.common.annotation.Excel; +import io.swagger.annotations.ApiModelProperty; +import com.ruoyi.common.core.domain.BaseEntity; + +/** + * 抵用金钱包记录对象 t_give_wallet_record + * + * @author liwenlong + * @date 2024-05-18 + */ +@Data +@Accessors(chain = true) +public class GiveWalletRecordResult extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + @ApiModelProperty("主键id") + private Long id; + + @ApiModelProperty("删除标志 1正常 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("用户类型 1 用户 2 商家") + @Excel(name = "用户类型 1 用户 2 商家") + private Integer userType; + + @ApiModelProperty("记录类型 具体看代码") + @Excel(name = "记录类型 具体看代码") + private Integer recordType; + + @ApiModelProperty("数值") + @Excel(name = "数值") + private BigDecimal price; + + @ApiModelProperty("用户id(商家关联t_store 用户关联t_customer)") + @Excel(name = "用户id(商家关联t_store 用户关联t_customer)") + private Long userId; + + @ApiModelProperty("记录来源id(如订单,则关联t_order)") + @Excel(name = "记录来源id(如订单,则关联t_order)") + private Long objectId; + + @ApiModelProperty("可提现状态 1 可提现 2 不可提现 3 到账取消") + @Excel(name = "可提现状态 1 可提现 2 不可提现 3 到账取消") + private Integer status; + + @ApiModelProperty("可提现时间") + @Excel(name = "可提现时间", width = 30, dateFormat = "yyyy-MM-dd") + private Date canWithTime; + + @ApiModelProperty("不可提现时间") + @Excel(name = "不可提现时间", width = 30, dateFormat = "yyyy-MM-dd") + private Date noWithTime; + + @ApiModelProperty("取消到账时间") + @Excel(name = "取消到账时间", width = 30, dateFormat = "yyyy-MM-dd") + private Date cancelTime; + + @ApiModelProperty("当前余额") + @Excel(name = "当前余额") + private BigDecimal currentBalance; + + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/givewallerecord/service/GiveWalletRecordService.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/givewallerecord/service/GiveWalletRecordService.java new file mode 100644 index 0000000..8caaf38 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/givewallerecord/service/GiveWalletRecordService.java @@ -0,0 +1,65 @@ +package com.ruoyi.frequency.givewallerecord.service; + +import java.math.BigDecimal; +import java.util.List; + +import com.ruoyi.controller.req.WalletPageReq; +import com.ruoyi.controller.resp.WalletPageResp; +import com.ruoyi.enums.WalletDetailEnums; +import com.ruoyi.frequency.givewallerecord.entity.GiveWalletRecord; +import com.baomidou.mybatisplus.extension.service.IService; +import com.ruoyi.response.ResponseData; +import com.ruoyi.vo.UserVo; + +/** + * 抵用金钱包记录Service接口 + * + * @author liwenlong + * @date 2024-05-18 + */ +public interface GiveWalletRecordService extends IService +{ + /** + * 查询抵用金钱包记录 + * + * @param id 抵用金钱包记录主键 + * @return 抵用金钱包记录 + */ + public GiveWalletRecord selectGiveWalletRecordById(Long id); + + /** + * 查询抵用金钱包记录列表 + * + * @param giveWalletRecord 抵用金钱包记录 + * @return 抵用金钱包记录集合 + */ + public List selectGiveWalletRecordList(GiveWalletRecord giveWalletRecord); + + /** + * 新增抵用金钱包记录 + * + * @param giveWalletRecord 抵用金钱包记录 + * @return 结果 + */ + public int insertGiveWalletRecord(GiveWalletRecord giveWalletRecord); + + /** + * 修改抵用金钱包记录 + * + * @param giveWalletRecord 抵用金钱包记录 + * @return 结果 + */ + public int updateGiveWalletRecord(GiveWalletRecord giveWalletRecord); + + /** + * 批量删除抵用金钱包记录 + * + * @param ids 需要删除的抵用金钱包记录主键集合 + * @return 结果 + */ + public int deleteGiveWalletRecordByIds(Long[] ids,Integer delFlag); + + void updateGiveBalance(UserVo userVo, WalletDetailEnums walletDetailEnums, Long objectId, BigDecimal updatePrice, Integer status); + + ResponseData giveWalletPage(WalletPageReq req, UserVo userVo); +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/givewallerecord/service/impl/GiveWalletRecordServiceImpl.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/givewallerecord/service/impl/GiveWalletRecordServiceImpl.java new file mode 100644 index 0000000..524fb56 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/givewallerecord/service/impl/GiveWalletRecordServiceImpl.java @@ -0,0 +1,189 @@ +package com.ruoyi.frequency.givewallerecord.service.impl; + +import java.math.BigDecimal; +import java.util.Date; +import java.util.List; + +import cn.hutool.core.util.ObjectUtil; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.ruoyi.common.exception.CustomException; +import com.ruoyi.common.page.PageResult; +import com.ruoyi.controller.req.WalletPageReq; +import com.ruoyi.controller.resp.WalletPageResp; +import com.ruoyi.enums.WalletDetailEnums; +import com.ruoyi.enums.user.UserEnums; +import com.ruoyi.frequency.customer.mapper.CustomerMapper; +import com.ruoyi.response.ResponseData; +import com.ruoyi.utils.BusinessUtil; +import com.ruoyi.vo.UserVo; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.ruoyi.code.PublicCommon; +import com.ruoyi.frequency.givewallerecord.mapper.GiveWalletRecordMapper; +import com.ruoyi.frequency.givewallerecord.entity.GiveWalletRecord; +import com.ruoyi.frequency.givewallerecord.service.GiveWalletRecordService; + +/** + * 抵用金钱包记录Service业务层处理 + * + * @author liwenlong + * @date 2024-05-18 + */ +@Service +public class GiveWalletRecordServiceImpl extends ServiceImpl implements GiveWalletRecordService +{ + @Autowired + private GiveWalletRecordMapper giveWalletRecordMapper; + + /** + * 查询抵用金钱包记录 + * + * @param id 抵用金钱包记录主键 + * @return 抵用金钱包记录 + */ + @Override + public GiveWalletRecord selectGiveWalletRecordById(Long id) + { + return giveWalletRecordMapper.selectGiveWalletRecordById(id); + } + + /** + * 查询抵用金钱包记录列表 + * + * @param giveWalletRecord 抵用金钱包记录 + * @return 抵用金钱包记录 + */ + @Override + public List selectGiveWalletRecordList(GiveWalletRecord giveWalletRecord) + { + return giveWalletRecordMapper.selectGiveWalletRecordList(giveWalletRecord); + } + + /** + * 新增抵用金钱包记录 + * + * @param giveWalletRecord 抵用金钱包记录 + * @return 结果 + */ + @Override + public int insertGiveWalletRecord(GiveWalletRecord giveWalletRecord) + { + giveWalletRecord.setCreateData(); + return giveWalletRecordMapper.insert(giveWalletRecord); + } + + /** + * 修改抵用金钱包记录 + * + * @param giveWalletRecord 抵用金钱包记录 + * @return 结果 + */ + @Override + public int updateGiveWalletRecord(GiveWalletRecord giveWalletRecord) + { + giveWalletRecord.setUpdateData(); + return giveWalletRecordMapper.updateGiveWalletRecord(giveWalletRecord); + } + + /** + * 批量删除抵用金钱包记录 + * + * @param ids 需要删除的抵用金钱包记录主键 + * @return 结果 + */ + @Override + public int deleteGiveWalletRecordByIds(Long[] ids,Integer delFlag) + { + this.lambdaUpdate().set(GiveWalletRecord::getDelFlag,delFlag).in(GiveWalletRecord::getId,ids).update(); + return ids.length; + } + + @Autowired + private CustomerMapper customerMapper; + + + @Override + public void updateGiveBalance(UserVo userVo, WalletDetailEnums walletDetailEnums, Long objectId, BigDecimal updatePrice, Integer status) { + if (updatePrice.compareTo(BigDecimal.ZERO) == 0 || ObjectUtil.equal(PublicCommon.Wallet.到账取消, status)) { + return; + } + + switch (userVo.getUserType()) { + case 1: + if (updatePrice.compareTo(BigDecimal.ZERO) == 1) { + customerMapper.addGiveBalance(userVo.getUserId(), updatePrice); + } else { + boolean subBalance = customerMapper.subGiveBalance(userVo.getUserId(), updatePrice.negate()); + if (!subBalance) { + throw new CustomException(220, "抵用金不足"); + } + } + break; + case 2: + break; + case 3: + break; + default: + throw new IllegalStateException("Unexpected value: " + userVo.getUserType()); + } + //添加钱包记录 + addGiveWalletRecord(userVo, objectId, updatePrice, walletDetailEnums, null, status); + } + + @Override + public ResponseData giveWalletPage(WalletPageReq req, UserVo userVo) { + Page page = this.baseMapper.giveWalletPage(new Page<>(req.getPageNo(), req.getPageSize()), req, userVo); + + if (page.getRecords().size() > 0) { + page.getRecords().stream().forEach(s -> { + if (ObjectUtil.isNotEmpty(s.getRecordType())) { + s.setRecord(WalletDetailEnums.getName(s.getRecordType())); + } + }); + } + + // 查询分页结果 + return ResponseData.success(new PageResult<>(page)); + } + + @Autowired + private BusinessUtil businessUtil; + + /** + * 增加余额记录 + * + * @param userVo 用户 + * @param walletDetailEnums 类型名称 + * @param orderId 订单id + * @param price 金额 + */ + public void addGiveWalletRecord(UserVo userVo, Long orderId, BigDecimal price, WalletDetailEnums walletDetailEnums, String remark, Integer status) { + if (price.setScale(2, BigDecimal.ROUND_HALF_UP).compareTo(new BigDecimal(0)) != 0) { + GiveWalletRecord giveWalletRecord = new GiveWalletRecord(); + giveWalletRecord.setUserId(userVo.getUserId()); + giveWalletRecord.setUserType(userVo.getUserType()); + giveWalletRecord.setObjectId(orderId); + giveWalletRecord.setStatus(status); + giveWalletRecord.setRecordType(walletDetailEnums.getCode()); + giveWalletRecord.setPrice(price); + + if (ObjectUtil.equal(PublicCommon.Wallet.可提现, status)) { + giveWalletRecord.setCanWithTime(new Date()); + } else if (ObjectUtil.equal(PublicCommon.Wallet.不可提现, status)) { + giveWalletRecord.setNoWithTime(new Date()); + } + + //获取用户当前余额 + BigDecimal userGiveBalance = businessUtil.getUserGiveBalance(userVo); + + giveWalletRecord.setCurrentBalance(userGiveBalance); + giveWalletRecord.setRemark(remark); + + this.save(giveWalletRecord); + } + } + + + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/illegaldeductionrecord/controller/IllegalDeductionRecordController.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/illegaldeductionrecord/controller/IllegalDeductionRecordController.java new file mode 100644 index 0000000..e2c2d24 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/illegaldeductionrecord/controller/IllegalDeductionRecordController.java @@ -0,0 +1,98 @@ +package com.ruoyi.frequency.illegaldeductionrecord.controller; + +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.page.TableDataInfo; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.common.utils.poi.ExcelUtil; +import com.ruoyi.frequency.illegaldeductionrecord.entity.IllegalDeductionRecord; +import com.ruoyi.frequency.illegaldeductionrecord.service.IllegalDeductionRecordService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +/** + * 扣款记录Controller + * + * @author liwenlong + * @date 2023-11-08 + */ +@RestController +@RequestMapping("/frequency/illegaldeductionrecord") +public class IllegalDeductionRecordController extends BaseController +{ + @Autowired + private IllegalDeductionRecordService illegalDeductionRecordService; + + /** + * 查询扣款记录列表 + */ + @PreAuthorize("@ss.hasPermi('frequency:illegaldeductionrecord:list')") + @PostMapping("/list") + public TableDataInfo list(@RequestBody IllegalDeductionRecord illegalDeductionRecord) + { + startPage(); + List list = illegalDeductionRecordService.selectIllegalDeductionRecordList(illegalDeductionRecord); + return getDataTable(list); + } + + /** + * 导出扣款记录列表 + */ + @PreAuthorize("@ss.hasPermi('frequency:illegaldeductionrecord:export')") + @Log(title = "扣款记录", businessType = BusinessType.EXPORT) + @GetMapping("/export") + public AjaxResult export(IllegalDeductionRecord illegalDeductionRecord) + { + List list = illegalDeductionRecordService.selectIllegalDeductionRecordList(illegalDeductionRecord); + ExcelUtil util = new ExcelUtil(IllegalDeductionRecord.class); + return util.exportExcel(list, "扣款记录数据"); + } + + /** + * 获取扣款记录详细信息 + */ + @PreAuthorize("@ss.hasPermi('frequency:illegaldeductionrecord:query')") + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") Long id) + { + return AjaxResult.success(illegalDeductionRecordService.selectIllegalDeductionRecordById(id)); + } + + /** + * 新增扣款记录 + */ + @PreAuthorize("@ss.hasPermi('frequency:illegaldeductionrecord:add')") + @Log(title = "扣款记录", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody IllegalDeductionRecord illegalDeductionRecord) + { + return toAjax(illegalDeductionRecordService.insertIllegalDeductionRecord(illegalDeductionRecord)); + } + + /** + * 修改扣款记录 + */ + @PreAuthorize("@ss.hasPermi('frequency:illegaldeductionrecord:edit')") + @Log(title = "扣款记录", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody IllegalDeductionRecord illegalDeductionRecord) + { + return toAjax(illegalDeductionRecordService.updateIllegalDeductionRecord(illegalDeductionRecord)); + } + + /** + * 删除扣款记录 + */ + @PreAuthorize("@ss.hasPermi('frequency:illegaldeductionrecord:remove')") + @Log(title = "扣款记录", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}/{delFlag}") + public AjaxResult remove(@PathVariable("ids") Long[] ids,@PathVariable("delFlag") Integer delFlag) + { + return toAjax(illegalDeductionRecordService.deleteIllegalDeductionRecordByIds(ids,delFlag)); + } + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/illegaldeductionrecord/entity/IllegalDeductionRecord.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/illegaldeductionrecord/entity/IllegalDeductionRecord.java new file mode 100644 index 0000000..b9b6b52 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/illegaldeductionrecord/entity/IllegalDeductionRecord.java @@ -0,0 +1,79 @@ +package com.ruoyi.frequency.illegaldeductionrecord.entity; + +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableName; +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; + +import java.math.BigDecimal; +import java.util.Date; + +/** + * 扣款记录对象 t_illegal_deduction_record + * + * @author liwenlong + * @date 2023-11-08 + */ +@Data +@Accessors(chain = true) +@TableName("t_illegal_deduction_record") +public class IllegalDeductionRecord extends BaseEntity { + private static final long serialVersionUID = 1L; + + + @ApiModelProperty("主键id") + private Long id; + + @ApiModelProperty("删除标志 1正常 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("提现记录id") + @Excel(name = "提现记录id") + private Long withdrawalRecordId; + + @ApiModelProperty("表现师id") + @Excel(name = "表现师id") + private Long storeId; + + @ApiModelProperty("类型 1平台手动添加 2 平台手动扣除 3提现抵消 4提现失败返还") + @Excel(name = "类型 1平台手动添加 2 平台手动扣除 3提现抵消 4提现失败返还") + private Integer type; + + @ApiModelProperty("数值") + @Excel(name = "数值") + private BigDecimal price; + + @ApiModelProperty("当前扣款金额") + @Excel(name = "当前扣款金额") + private BigDecimal currentPrice; + + @ApiModelProperty("订单id") + @Excel(name = "订单id") + private Long orderId; + + @ApiModelProperty("扣款类型") + @Excel(name = "扣款类型") + private String deductionType; + + + @ApiModelProperty("备注") + @Excel(name = "备注") + private String remark; + + @ApiModelProperty("订单号") + @Excel(name = "订单号") + @TableField(exist = false) + private String orderNo; + + + @ApiModelProperty("开始时间") + @TableField(exist = false) + private Date beginTime; + + @ApiModelProperty("结束时间") + @TableField(exist = false) + private Date endTime; +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/illegaldeductionrecord/mapper/IllegalDeductionRecordMapper.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/illegaldeductionrecord/mapper/IllegalDeductionRecordMapper.java new file mode 100644 index 0000000..c05599c --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/illegaldeductionrecord/mapper/IllegalDeductionRecordMapper.java @@ -0,0 +1,60 @@ +package com.ruoyi.frequency.illegaldeductionrecord.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.ruoyi.controller.req.IllegalDeductionPageReq; +import com.ruoyi.controller.req.MonthReq; +import com.ruoyi.controller.resp.IllegalDeductionPageResp; +import com.ruoyi.frequency.illegaldeductionrecord.entity.IllegalDeductionRecord; +import com.ruoyi.frequency.illegaldeductionrecord.model.result.IllegalDeductionResp; +import com.ruoyi.frequency.illegaldeductionrecord.model.result.OrderInfoResp; +import com.ruoyi.vo.UserVo; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * 扣款记录Mapper接口 + * + * @author liwenlong + * @date 2023-11-08 + */ +public interface IllegalDeductionRecordMapper extends BaseMapper +{ + /** + * 查询扣款记录 + * + * @param id 扣款记录主键 + * @return 扣款记录 + */ + public IllegalDeductionRecord selectIllegalDeductionRecordById(Long id); + + /** + * 查询扣款记录列表 + * + * @param illegalDeductionRecord 扣款记录 + * @return 扣款记录集合 + */ + public List selectIllegalDeductionRecordList(IllegalDeductionRecord illegalDeductionRecord); + + /** + * 新增扣款记录 + * + * @param illegalDeductionRecord 扣款记录 + * @return 结果 + */ + public int insertIllegalDeductionRecord(IllegalDeductionRecord illegalDeductionRecord); + + /** + * 修改扣款记录 + * + * @param illegalDeductionRecord 扣款记录 + * @return 结果 + */ + public int updateIllegalDeductionRecord(IllegalDeductionRecord illegalDeductionRecord); + + Page illegalDeductionPage(@Param("page") Page objectPage, @Param("req")IllegalDeductionPageReq req,@Param("userVo") UserVo userVo); + + + OrderInfoResp getOrderInfo(@Param("orderId") Long orderId); +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/illegaldeductionrecord/mapper/mapping/IllegalDeductionRecordMapper.xml b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/illegaldeductionrecord/mapper/mapping/IllegalDeductionRecordMapper.xml new file mode 100644 index 0000000..b9c80f1 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/illegaldeductionrecord/mapper/mapping/IllegalDeductionRecordMapper.xml @@ -0,0 +1,161 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + select + t.id , + t.create_by , + t.create_time , + t.update_by , + t.update_time , + t.del_flag , + t.withdrawal_record_id , + t.store_id , + t.type , + t.remark , + t.price , + t.current_price, + t.deduction_type, + t.order_id, + t2.order_no + from t_illegal_deduction_record AS t + LEFT JOIN t_order t2 on t.order_id = t2.id + + + + + + + + + insert into t_illegal_deduction_record + + id, + create_by, + create_time, + update_by, + update_time, + del_flag, + withdrawal_record_id, + store_id, + type, + remark, + price, + current_price, + + + #{id}, + #{createBy}, + #{createTime}, + #{updateBy}, + #{updateTime}, + #{delFlag}, + #{withdrawalRecordId}, + #{storeId}, + #{type}, + #{remark}, + #{price}, + #{currentPrice}, + + + + + update t_illegal_deduction_record + + create_by = #{createBy}, + create_time = #{createTime}, + update_by = #{updateBy}, + update_time = #{updateTime}, + del_flag = #{delFlag}, + withdrawal_record_id = #{withdrawalRecordId}, + store_id = #{storeId}, + type = #{type}, + remark = #{remark}, + price = #{price}, + current_price = #{currentPrice}, + + where id = #{id} + + + + + \ No newline at end of file diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/illegaldeductionrecord/model/param/IllegalDeductionRecordParam.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/illegaldeductionrecord/model/param/IllegalDeductionRecordParam.java new file mode 100644 index 0000000..ba2fedf --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/illegaldeductionrecord/model/param/IllegalDeductionRecordParam.java @@ -0,0 +1,57 @@ +package com.ruoyi.frequency.illegaldeductionrecord.model.param; + +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; + +import java.math.BigDecimal; + +/** + * 扣款记录对象 t_illegal_deduction_record + * + * @author liwenlong + * @date 2023-11-08 + */ +@Data +@Accessors(chain = true) +public class IllegalDeductionRecordParam extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + @ApiModelProperty("主键id") + private Long id; + + @ApiModelProperty("删除标志 1正常 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("提现记录id") + @Excel(name = "提现记录id") + private Long withdrawalRecordId; + + @ApiModelProperty("表现师id") + @Excel(name = "表现师id") + private Long storeId; + + @ApiModelProperty("类型 1平台手动添加 2 平台手动扣除 3提现抵消 4提现失败返还") + @Excel(name = "类型 1平台手动添加 2 平台手动扣除 3提现抵消 4提现失败返还") + private Integer type; + + @ApiModelProperty("数值") + @Excel(name = "数值") + private BigDecimal price; + + @ApiModelProperty("当前扣款金额") + @Excel(name = "当前扣款金额") + private BigDecimal currentPrice; + + + + + + + + + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/illegaldeductionrecord/model/result/IllegalDeductionRecordResult.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/illegaldeductionrecord/model/result/IllegalDeductionRecordResult.java new file mode 100644 index 0000000..fc29c3a --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/illegaldeductionrecord/model/result/IllegalDeductionRecordResult.java @@ -0,0 +1,50 @@ +package com.ruoyi.frequency.illegaldeductionrecord.model.result; + +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; + +import java.math.BigDecimal; + +/** + * 扣款记录对象 t_illegal_deduction_record + * + * @author liwenlong + * @date 2023-11-08 + */ +@Data +@Accessors(chain = true) +public class IllegalDeductionRecordResult extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + @ApiModelProperty("主键id") + private Long id; + + @ApiModelProperty("删除标志 1正常 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("提现记录id") + @Excel(name = "提现记录id") + private Long withdrawalRecordId; + + @ApiModelProperty("表现师id") + @Excel(name = "表现师id") + private Long storeId; + + @ApiModelProperty("类型 1平台手动添加 2 平台手动扣除 3提现抵消 4提现失败返还") + @Excel(name = "类型 1平台手动添加 2 平台手动扣除 3提现抵消 4提现失败返还") + private Integer type; + + @ApiModelProperty("数值") + @Excel(name = "数值") + private BigDecimal price; + + @ApiModelProperty("当前扣款金额") + @Excel(name = "当前扣款金额") + private BigDecimal currentPrice; + + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/illegaldeductionrecord/model/result/IllegalDeductionResp.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/illegaldeductionrecord/model/result/IllegalDeductionResp.java new file mode 100644 index 0000000..f3a8d5a --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/illegaldeductionrecord/model/result/IllegalDeductionResp.java @@ -0,0 +1,8 @@ +package com.ruoyi.frequency.illegaldeductionrecord.model.result; + +import lombok.Data; + +@Data +public class IllegalDeductionResp { + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/illegaldeductionrecord/model/result/OrderInfoResp.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/illegaldeductionrecord/model/result/OrderInfoResp.java new file mode 100644 index 0000000..6c0068d --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/illegaldeductionrecord/model/result/OrderInfoResp.java @@ -0,0 +1,11 @@ +package com.ruoyi.frequency.illegaldeductionrecord.model.result; + +import lombok.Data; + +import java.util.Date; + +@Data +public class OrderInfoResp { + private String orderNo; + private Date createTime; +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/illegaldeductionrecord/service/IllegalDeductionRecordService.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/illegaldeductionrecord/service/IllegalDeductionRecordService.java new file mode 100644 index 0000000..14ee8a6 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/illegaldeductionrecord/service/IllegalDeductionRecordService.java @@ -0,0 +1,83 @@ +package com.ruoyi.frequency.illegaldeductionrecord.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.ruoyi.controller.req.IllegalDeductionPageReq; +import com.ruoyi.controller.req.MonthReq; +import com.ruoyi.controller.resp.IllegalDeductionPageResp; +import com.ruoyi.frequency.illegaldeductionrecord.entity.IllegalDeductionRecord; +import com.ruoyi.response.ResponseData; +import com.ruoyi.vo.BodyIdReq; +import com.ruoyi.vo.UserVo; + +import java.math.BigDecimal; +import java.util.List; + +/** + * 扣款记录Service接口 + * + * @author liwenlong + * @date 2023-11-08 + */ +public interface IllegalDeductionRecordService extends IService +{ + /** + * 查询扣款记录 + * + * @param id 扣款记录主键 + * @return 扣款记录 + */ + public IllegalDeductionRecord selectIllegalDeductionRecordById(Long id); + + /** + * 查询扣款记录列表 + * + * @param illegalDeductionRecord 扣款记录 + * @return 扣款记录集合 + */ + public List selectIllegalDeductionRecordList(IllegalDeductionRecord illegalDeductionRecord); + + /** + * 新增扣款记录 + * + * @param illegalDeductionRecord 扣款记录 + * @return 结果 + */ + public int insertIllegalDeductionRecord(IllegalDeductionRecord illegalDeductionRecord); + + /** + * 修改扣款记录 + * + * @param illegalDeductionRecord 扣款记录 + * @return 结果 + */ + public int updateIllegalDeductionRecord(IllegalDeductionRecord illegalDeductionRecord); + + /** + * 批量删除扣款记录 + * + * @param ids 需要删除的扣款记录主键集合 + * @return 结果 + */ + public int deleteIllegalDeductionRecordByIds(Long[] ids,Integer delFlag); + + /** + * 违规扣除明细 + * @param req + * @param userVo + * @return + */ + ResponseData illegalDeductionPage(IllegalDeductionPageReq req, UserVo userVo); + + /** + * 修改扣款 + * @param storeId + * @param withId + * @param price + * @param type 类型 1平台手动添加 2 平台手动扣除 3提现抵消 4提现失败返还 5订单申诉 + */ + void updateViolationDeduction(Long storeId,Long withId, BigDecimal price, int type,Long orderId,String deductionType,String remark); + + Object getPage(MonthReq req, UserVo userVo); + + Object detail(BodyIdReq req, UserVo userVo); +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/illegaldeductionrecord/service/impl/IllegalDeductionRecordServiceImpl.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/illegaldeductionrecord/service/impl/IllegalDeductionRecordServiceImpl.java new file mode 100644 index 0000000..7239ed8 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/illegaldeductionrecord/service/impl/IllegalDeductionRecordServiceImpl.java @@ -0,0 +1,252 @@ +package com.ruoyi.frequency.illegaldeductionrecord.service.impl; + +import cn.hutool.core.collection.CollectionUtil; +import cn.hutool.core.date.DateUtil; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.ruoyi.code.PublicCommon; +import com.ruoyi.common.core.domain.BaseEntity; +import com.ruoyi.common.exception.CustomException; +import com.ruoyi.common.exception.ServiceException; +import com.ruoyi.common.page.PageResult; +import com.ruoyi.controller.req.IllegalDeductionPageReq; +import com.ruoyi.controller.req.MonthReq; +import com.ruoyi.controller.resp.IllegalDeductionPageResp; +import com.ruoyi.enums.message.OrderMessageEnums; +import com.ruoyi.enums.user.UserEnums; +import com.ruoyi.frequency.illegaldeductionrecord.entity.IllegalDeductionRecord; +import com.ruoyi.frequency.illegaldeductionrecord.mapper.IllegalDeductionRecordMapper; +import com.ruoyi.frequency.illegaldeductionrecord.model.result.OrderInfoResp; +import com.ruoyi.frequency.illegaldeductionrecord.service.IllegalDeductionRecordService; +import com.ruoyi.frequency.ordermessage.service.OrderMessageUtilService; +import com.ruoyi.frequency.store.entity.Store; +import com.ruoyi.frequency.store.mapper.StoreMapper; +import com.ruoyi.frequency.store.model.result.OrderResult; +import com.ruoyi.frequency.withdrawalrecord.entity.WithdrawalRecord; +import com.ruoyi.frequency.withdrawalrecord.service.WithdrawalRecordService; +import com.ruoyi.response.ResponseData; +import com.ruoyi.vo.BodyIdReq; +import com.ruoyi.vo.UserVo; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.math.BigDecimal; +import java.util.*; + +/** + * 扣款记录Service业务层处理 + * + * @author liwenlong + * @date 2023-11-08 + */ +@Service +public class IllegalDeductionRecordServiceImpl extends ServiceImpl implements IllegalDeductionRecordService { + @Autowired + private IllegalDeductionRecordMapper illegalDeductionRecordMapper; + + /** + * 查询扣款记录 + * + * @param id 扣款记录主键 + * @return 扣款记录 + */ + @Override + public IllegalDeductionRecord selectIllegalDeductionRecordById(Long id) { + return illegalDeductionRecordMapper.selectIllegalDeductionRecordById(id); + } + + /** + * 查询扣款记录列表 + * + * @param illegalDeductionRecord 扣款记录 + * @return 扣款记录 + */ + @Override + public List selectIllegalDeductionRecordList(IllegalDeductionRecord illegalDeductionRecord) { + return illegalDeductionRecordMapper.selectIllegalDeductionRecordList(illegalDeductionRecord); + } + + /** + * 新增扣款记录 + * + * @param illegalDeductionRecord 扣款记录 + * @return 结果 + */ + @Override + public int insertIllegalDeductionRecord(IllegalDeductionRecord illegalDeductionRecord) { + illegalDeductionRecord.setCreateData(); + return illegalDeductionRecordMapper.insert(illegalDeductionRecord); + } + + /** + * 修改扣款记录 + * + * @param illegalDeductionRecord 扣款记录 + * @return 结果 + */ + @Override + public int updateIllegalDeductionRecord(IllegalDeductionRecord illegalDeductionRecord) { + illegalDeductionRecord.setUpdateData(); + return illegalDeductionRecordMapper.updateIllegalDeductionRecord(illegalDeductionRecord); + } + + @Autowired + private WithdrawalRecordService withdrawalRecordService; + + @Autowired + private OrderMessageUtilService orderMessageService; + + /** + * 批量删除扣款记录 + * + * @param ids 需要删除的扣款记录主键 + * @return 结果 + */ + @Override + public int deleteIllegalDeductionRecordByIds(Long[] ids, Integer delFlag) { + + IllegalDeductionRecord illegalDeductionRecord = getById(ids[0]); + + //查询要删除的记录是否是最近一次提现之前,是的话,不可取消 + if (PublicCommon.删除.equals(delFlag)) { + WithdrawalRecord withdrawalRecord = withdrawalRecordService.getOne(new QueryWrapper().lambda().eq(WithdrawalRecord::getUserId, illegalDeductionRecord.getStoreId()) + .orderByDesc(BaseEntity::getCreateTime).last(" limit 1")); + + BigDecimal price = BigDecimal.ZERO; + + for (Long id : ids) { + IllegalDeductionRecord cur = getById(id); + if (withdrawalRecord != null) { + if (withdrawalRecord.getCreateTime().getTime() > cur.getCreateTime().getTime()) { + throw new ServiceException("存在扣款被抵消,不可删除扣款记录"); + } + } + price = price.add(cur.getPrice()); + + } + for (Long id : ids) { + IllegalDeductionRecord cur = getById(id); + OrderResult orderResult = storeMapper.getOrderInfo(cur.getOrderId()); + if (orderResult != null) { + //添加订单消息 + orderMessageService.addOrderMessage(new UserVo(UserEnums.customer.getCode(), cur.getStoreId()), cur.getOrderId(), orderResult.getOrderNo(), cur.getPrice() + "", PublicCommon.Order.订单, OrderMessageEnums.ORDER_ILLEGAL_DEDUCTION_CANCEL); + + } + } + if (price.compareTo(BigDecimal.ZERO) != 0) { + if (price.compareTo(BigDecimal.ZERO) > 0) { + storeMapper.subViolationDeduction(illegalDeductionRecord.getStoreId(), price); + } else { + storeMapper.addViolationDeduction(illegalDeductionRecord.getStoreId(), price.negate()); + } + } + + } + + + this.lambdaUpdate().set(IllegalDeductionRecord::getDelFlag, delFlag).in(IllegalDeductionRecord::getId, ids).update(); + return ids.length; + } + + + @Autowired + private StoreMapper storeMapper; + + @Override + public void updateViolationDeduction(Long storeId, Long withId, BigDecimal price, int type, Long orderId, String deductionType, String remark) { + if (price.compareTo(BigDecimal.ZERO) == 0) { + return; + } + + if (price.compareTo(BigDecimal.ZERO) > 0) { + storeMapper.addViolationDeduction(storeId, price); + } else { + boolean b = storeMapper.subViolationDeduction(storeId, price.negate()); + if (!b) { + throw new CustomException("扣款金额错误"); + } + } + + Store store = storeMapper.selectById(storeId); + //添加违规款记录 + IllegalDeductionRecord illegalDeductionRecord = new IllegalDeductionRecord(); + illegalDeductionRecord.setStoreId(storeId) + .setWithdrawalRecordId(withId) + .setPrice(price) + .setCurrentPrice(store.getViolationDeduction()) + .setType(type) + .setOrderId(orderId) + .setDeductionType(deductionType) + .setRemark(remark); + this.insertIllegalDeductionRecord(illegalDeductionRecord); + + } + + @Override + public Object getPage(MonthReq req, UserVo userVo) { + LambdaUpdateWrapper lambdaUpdateWrapper = new LambdaUpdateWrapper<>(); + lambdaUpdateWrapper.eq(IllegalDeductionRecord::getStoreId, userVo.getUserId()); + if (req.getBeginTime() != null) { + lambdaUpdateWrapper.ge(BaseEntity::getCreateTime, req.getBeginTime()); + } + if (req.getEndTime() != null) { + lambdaUpdateWrapper.le(BaseEntity::getCreateTime, req.getEndTime()); + } + lambdaUpdateWrapper.eq(IllegalDeductionRecord::getDelFlag, PublicCommon.启用); + lambdaUpdateWrapper.eq(IllegalDeductionRecord::getType,1); + lambdaUpdateWrapper.orderByDesc(BaseEntity::getCreateTime); + + List illegalDeductionRecords = this.baseMapper.selectList(lambdaUpdateWrapper); + //按月筛选 + Map> illegalDeductionMap = new LinkedHashMap<>(); + + if (CollectionUtil.isNotEmpty(illegalDeductionRecords)) { + for (IllegalDeductionRecord cur : illegalDeductionRecords) { + String yearMonth = DateUtil.year(cur.getCreateTime()) + "年" + (DateUtil.month(cur.getCreateTime())+1) + "月"; + if (!illegalDeductionMap.containsKey(yearMonth)) { + illegalDeductionMap.put(yearMonth, new ArrayList<>()); + } + illegalDeductionMap.get(yearMonth).add(cur); + } + + } + List resultList = new ArrayList<>(); + Iterator>> iterator = illegalDeductionMap.entrySet().iterator(); + while (iterator.hasNext()) { + Map.Entry> next = iterator.next(); + Map map = new HashMap(); + map.put("date", next.getKey()); + map.put("list", next.getValue()); + resultList.add(map); + } + + return resultList; + } + + @Override + public Object detail(BodyIdReq req, UserVo userVo) { + IllegalDeductionRecord illegalDeductionRecord = getById(req.getId()); + if (illegalDeductionRecord.getOrderId() != null) { + OrderInfoResp orderInfoResp = baseMapper.getOrderInfo(illegalDeductionRecord.getOrderId()); + illegalDeductionRecord.setOrderNo(orderInfoResp.getOrderNo()); + } + + return illegalDeductionRecord; + } + + + public static void main(String[] args) { + Date date = new Date(); + String s = DateUtil.formatDate(new Date()); + System.out.println(DateUtil.year(date) + "年" + DateUtil.month(date) + "月"); + } + + @Override + public ResponseData illegalDeductionPage(IllegalDeductionPageReq req, UserVo userVo) { + Page page = this.baseMapper.illegalDeductionPage(new Page<>(req.getPageNo(), req.getPageSize()), req, userVo); + // 查询分页结果 + return ResponseData.success(new PageResult<>(page)); + } +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/integralrecord/controller/IntegralRecordController.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/integralrecord/controller/IntegralRecordController.java new file mode 100644 index 0000000..66740f4 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/integralrecord/controller/IntegralRecordController.java @@ -0,0 +1,111 @@ +package com.ruoyi.frequency.integralrecord.controller; + +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.page.TableDataInfo; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.common.utils.poi.ExcelUtil; +import com.ruoyi.frequency.integralrecord.entity.IntegralRecord; +import com.ruoyi.frequency.integralrecord.service.IntegralRecordService; +import com.ruoyi.frequency.wallerecord.entity.WalletRecord; +import com.ruoyi.frequency.wallerecord.model.result.WalletRecordCount; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +/** + * 积分记录Controller + * + * @author liwenlong + * @date 2024-01-29 + */ +@RestController +@RequestMapping("/frequency/integralrecord") +public class IntegralRecordController extends BaseController +{ + @Autowired + private IntegralRecordService integralRecordService; + + /** + * 查询积分记录列表 + */ +// @PreAuthorize("@ss.hasPermi('frequency:integralrecord:list')") + @PostMapping("/list") + public TableDataInfo list(@RequestBody IntegralRecord integralRecord) + { + startPage(); + List list = integralRecordService.selectIntegralRecordList(integralRecord); + return getDataTable(list); + } + + + /** + * 统计 + */ + @PostMapping("/statistics") + public AjaxResult statistics(@RequestBody IntegralRecord integralRecord) + { + WalletRecordCount count = integralRecordService.statistics(integralRecord); + return AjaxResult.success(count); + } + + + /** + * 导出积分记录列表 + */ + @PreAuthorize("@ss.hasPermi('frequency:integralrecord:export')") + @Log(title = "积分记录", businessType = BusinessType.EXPORT) + @GetMapping("/export") + public AjaxResult export(IntegralRecord integralRecord) + { + List list = integralRecordService.selectIntegralRecordList(integralRecord); + ExcelUtil util = new ExcelUtil(IntegralRecord.class); + return util.exportExcel(list, "积分记录数据"); + } + + /** + * 获取积分记录详细信息 + */ + @PreAuthorize("@ss.hasPermi('frequency:integralrecord:query')") + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") Long id) + { + return AjaxResult.success(integralRecordService.selectIntegralRecordById(id)); + } + + /** + * 新增积分记录 + */ + @PreAuthorize("@ss.hasPermi('frequency:integralrecord:add')") + @Log(title = "积分记录", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody IntegralRecord integralRecord) + { + return toAjax(integralRecordService.insertIntegralRecord(integralRecord)); + } + + /** + * 修改积分记录 + */ + @PreAuthorize("@ss.hasPermi('frequency:integralrecord:edit')") + @Log(title = "积分记录", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody IntegralRecord integralRecord) + { + return toAjax(integralRecordService.updateIntegralRecord(integralRecord)); + } + + /** + * 删除积分记录 + */ + @PreAuthorize("@ss.hasPermi('frequency:integralrecord:remove')") + @Log(title = "积分记录", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}/{delFlag}") + public AjaxResult remove(@PathVariable("ids") Long[] ids,@PathVariable("delFlag") Integer delFlag) + { + return toAjax(integralRecordService.deleteIntegralRecordByIds(ids,delFlag)); + } +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/integralrecord/entity/IntegralRecord.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/integralrecord/entity/IntegralRecord.java new file mode 100644 index 0000000..19fdce3 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/integralrecord/entity/IntegralRecord.java @@ -0,0 +1,86 @@ +package com.ruoyi.frequency.integralrecord.entity; + +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableName; +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import com.ruoyi.vo.UserInfo; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; + +import java.math.BigDecimal; +import java.util.Date; +import java.util.List; + +/** + * 积分记录对象 t_integral_record + * + * @author liwenlong + * @date 2024-01-29 + */ +@Data +@Accessors(chain = true) +@TableName("t_integral_record") +public class IntegralRecord extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + + @ApiModelProperty("租户号") + private Long id; + + @ApiModelProperty("乐观锁") + private Integer delFlag; + + @ApiModelProperty("积分") + @Excel(name = "积分") + private BigDecimal integral; + + @ApiModelProperty("积分余额") + @Excel(name = "积分余额") + private BigDecimal currentBalance; + + @ApiModelProperty("记录类型") + @Excel(name = "记录类型") + private Integer record; + + @ApiModelProperty("记录类型") + @Excel(name = "记录类型") + private String recordName; + + @ApiModelProperty("用户类型 1设计师 2表现师") + @Excel(name = "用户类型 1设计师 2表现师") + private Integer userType; + + @ApiModelProperty("用户id") + @Excel(name = "用户id") + private Long userId; + + @ApiModelProperty("来源id") + @Excel(name = "来源id") + private Long objectId; + + @ApiModelProperty("备注") + @Excel(name = "备注") + private String remark; + + @ApiModelProperty("用户信息") + @TableField(exist = false) + private UserInfo userInfo; + + @ApiModelProperty("开始时间") + @TableField(exist = false) + private Date beginTime; + + @ApiModelProperty("结束时间") + @TableField(exist = false) + private Date endTime; + + /** + * 记录类型 具体看代码 + */ + @Excel(name = "记录类型 具体看代码") + @TableField(exist = false) + private List recordTypeList; +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/integralrecord/mapper/IntegralRecordMapper.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/integralrecord/mapper/IntegralRecordMapper.java new file mode 100644 index 0000000..91ce3ee --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/integralrecord/mapper/IntegralRecordMapper.java @@ -0,0 +1,53 @@ +package com.ruoyi.frequency.integralrecord.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.ruoyi.controller.resp.IntegralPageResp; +import com.ruoyi.frequency.integralrecord.entity.IntegralRecord; +import com.ruoyi.vo.UserVo; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * 积分记录Mapper接口 + * + * @author liwenlong + * @date 2024-01-29 + */ +public interface IntegralRecordMapper extends BaseMapper +{ + /** + * 查询积分记录 + * + * @param id 积分记录主键 + * @return 积分记录 + */ + public IntegralRecord selectIntegralRecordById(Long id); + + /** + * 查询积分记录列表 + * + * @param integralRecord 积分记录 + * @return 积分记录集合 + */ + public List selectIntegralRecordList(IntegralRecord integralRecord); + + /** + * 新增积分记录 + * + * @param integralRecord 积分记录 + * @return 结果 + */ + public int insertIntegralRecord(IntegralRecord integralRecord); + + /** + * 修改积分记录 + * + * @param integralRecord 积分记录 + * @return 结果 + */ + public int updateIntegralRecord(IntegralRecord integralRecord); + + Page integralPage(@Param("page") Page objectPage, @Param("userVo") UserVo userVo); +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/integralrecord/mapper/mapping/IntegralRecordMapper.xml b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/integralrecord/mapper/mapping/IntegralRecordMapper.xml new file mode 100644 index 0000000..0631165 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/integralrecord/mapper/mapping/IntegralRecordMapper.xml @@ -0,0 +1,157 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + SELECT + t.id, + t.del_flag, + t.create_by, + t.create_time, + t.update_by, + t.update_time, + t.integral, + t.current_balance, + t.record, + t.user_type, + t.user_id, + t.object_id, + t.remark, + u.id, + u.mobile, + u.avatar, + u.nickname + FROM + t_integral_record AS t + LEFT JOIN t_customer AS u ON t.user_id = u.id + + + + + + + + insert into t_integral_record + + id, + del_flag, + create_by, + create_time, + update_by, + update_time, + integral, + current_balance, + record, + user_type, + user_id, + object_id, + + + #{id}, + #{delFlag}, + #{createBy}, + #{createTime}, + #{updateBy}, + #{updateTime}, + #{integral}, + #{currentBalance}, + #{record}, + #{userType}, + #{userId}, + #{objectId}, + + + + + update t_integral_record + + del_flag = #{delFlag}, + create_by = #{createBy}, + create_time = #{createTime}, + update_by = #{updateBy}, + update_time = #{updateTime}, + integral = #{integral}, + current_balance = #{currentBalance}, + record = #{record}, + user_type = #{userType}, + user_id = #{userId}, + object_id = #{objectId}, + + where id = #{id} + + + + diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/integralrecord/model/param/IntegralRecordParam.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/integralrecord/model/param/IntegralRecordParam.java new file mode 100644 index 0000000..688dc0f --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/integralrecord/model/param/IntegralRecordParam.java @@ -0,0 +1,62 @@ +package com.ruoyi.frequency.integralrecord.model.param; + +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; + +import java.math.BigDecimal; + +/** + * 积分记录对象 t_integral_record + * + * @author liwenlong + * @date 2024-01-29 + */ +@Data +@Accessors(chain = true) +public class IntegralRecordParam extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + @ApiModelProperty("租户号") + private Long id; + + @ApiModelProperty("乐观锁") + private Integer delFlag; + + @ApiModelProperty("积分") + @Excel(name = "积分") + private BigDecimal integral; + + @ApiModelProperty("积分余额") + @Excel(name = "积分余额") + private BigDecimal currentBalance; + + @ApiModelProperty("记录类型") + @Excel(name = "记录类型") + private Integer record; + + @ApiModelProperty("用户类型 1设计师 2表现师") + @Excel(name = "用户类型 1设计师 2表现师") + private Integer userType; + + @ApiModelProperty("用户id") + @Excel(name = "用户id") + private Long userId; + + @ApiModelProperty("来源id") + @Excel(name = "来源id") + private Long objectId; + + + + + + + + + + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/integralrecord/model/result/IntegralRecordResult.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/integralrecord/model/result/IntegralRecordResult.java new file mode 100644 index 0000000..a56c543 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/integralrecord/model/result/IntegralRecordResult.java @@ -0,0 +1,54 @@ +package com.ruoyi.frequency.integralrecord.model.result; + +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; + +import java.math.BigDecimal; + +/** + * 积分记录对象 t_integral_record + * + * @author liwenlong + * @date 2024-01-29 + */ +@Data +@Accessors(chain = true) +public class IntegralRecordResult extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + @ApiModelProperty("租户号") + private Long id; + + @ApiModelProperty("乐观锁") + private Integer delFlag; + + @ApiModelProperty("积分") + @Excel(name = "积分") + private BigDecimal integral; + + @ApiModelProperty("积分余额") + @Excel(name = "积分余额") + private BigDecimal currentBalance; + + @ApiModelProperty("记录类型") + @Excel(name = "记录类型") + private Integer record; + + @ApiModelProperty("用户类型 1设计师 2表现师") + @Excel(name = "用户类型 1设计师 2表现师") + private Integer userType; + + @ApiModelProperty("用户id") + @Excel(name = "用户id") + private Long userId; + + @ApiModelProperty("来源id") + @Excel(name = "来源id") + private Long objectId; + + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/integralrecord/service/IntegralRecordService.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/integralrecord/service/IntegralRecordService.java new file mode 100644 index 0000000..d801f93 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/integralrecord/service/IntegralRecordService.java @@ -0,0 +1,80 @@ +package com.ruoyi.frequency.integralrecord.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.ruoyi.enums.IntegralDetailEnums; +import com.ruoyi.frequency.integralrecord.entity.IntegralRecord; +import com.ruoyi.frequency.wallerecord.model.result.WalletRecordCount; +import com.ruoyi.response.ResponseData; +import com.ruoyi.vo.PageBasic; +import com.ruoyi.vo.UserVo; + +import java.math.BigDecimal; +import java.util.List; + +/** + * 积分记录Service接口 + * + * @author liwenlong + * @date 2024-01-29 + */ +public interface IntegralRecordService extends IService +{ + /** + * 查询积分记录 + * + * @param id 积分记录主键 + * @return 积分记录 + */ + public IntegralRecord selectIntegralRecordById(Long id); + + /** + * 查询积分记录列表 + * + * @param integralRecord 积分记录 + * @return 积分记录集合 + */ + public List selectIntegralRecordList(IntegralRecord integralRecord); + + /** + * 新增积分记录 + * + * @param integralRecord 积分记录 + * @return 结果 + */ + public int insertIntegralRecord(IntegralRecord integralRecord); + + /** + * 修改积分记录 + * + * @param integralRecord 积分记录 + * @return 结果 + */ + public int updateIntegralRecord(IntegralRecord integralRecord); + + /** + * 批量删除积分记录 + * + * @param ids 需要删除的积分记录主键集合 + * @return 结果 + */ + public int deleteIntegralRecordByIds(Long[] ids,Integer delFlag); + + /** + * 修改积分 + * @param userVo + * @param id + * @param integral + * @param integralDetailEnums + */ + void updateIntegral(UserVo userVo, Long id, BigDecimal integral, IntegralDetailEnums integralDetailEnums,String remark); + + /** + * 积分明细 + * @param req + * @param userVo + * @return + */ + ResponseData integralPage(PageBasic req, UserVo userVo); + + WalletRecordCount statistics(IntegralRecord integralRecord); +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/integralrecord/service/impl/IntegralRecordServiceImpl.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/integralrecord/service/impl/IntegralRecordServiceImpl.java new file mode 100644 index 0000000..6b41164 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/integralrecord/service/impl/IntegralRecordServiceImpl.java @@ -0,0 +1,227 @@ +package com.ruoyi.frequency.integralrecord.service.impl; + +import cn.hutool.core.util.ObjectUtil; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.ruoyi.code.PublicCommon; +import com.ruoyi.common.exception.CustomException; +import com.ruoyi.common.exception.enums.CoreExceptionEnum; +import com.ruoyi.common.page.PageResult; +import com.ruoyi.controller.resp.IntegralPageResp; +import com.ruoyi.enums.IntegralDetailEnums; +import com.ruoyi.frequency.customer.entity.Customer; +import com.ruoyi.frequency.customer.mapper.CustomerMapper; +import com.ruoyi.frequency.customer.service.CustomerService; +import com.ruoyi.frequency.integralrecord.entity.IntegralRecord; +import com.ruoyi.frequency.integralrecord.mapper.IntegralRecordMapper; +import com.ruoyi.frequency.integralrecord.service.IntegralRecordService; +import com.ruoyi.frequency.store.entity.Store; +import com.ruoyi.frequency.store.mapper.StoreMapper; +import com.ruoyi.frequency.store.service.StoreService; +import com.ruoyi.frequency.wallerecord.model.result.WalletRecordCount; +import com.ruoyi.response.ResponseData; +import com.ruoyi.utils.BusinessUtil; +import com.ruoyi.vo.PageBasic; +import com.ruoyi.vo.UserVo; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.math.BigDecimal; +import java.util.List; + +/** + * 积分记录Service业务层处理 + * + * @author liwenlong + * @date 2024-01-29 + */ +@Service +public class IntegralRecordServiceImpl extends ServiceImpl implements IntegralRecordService { + @Autowired + private IntegralRecordMapper integralRecordMapper; + + /** + * 查询积分记录 + * + * @param id 积分记录主键 + * @return 积分记录 + */ + @Override + public IntegralRecord selectIntegralRecordById(Long id) { + return integralRecordMapper.selectIntegralRecordById(id); + } + + /** + * 查询积分记录列表 + * + * @param integralRecord 积分记录 + * @return 积分记录 + */ + @Override + public List selectIntegralRecordList(IntegralRecord integralRecord) { + List integralRecords = integralRecordList(integralRecord); + + return integralRecords; + } + + private List integralRecordList(IntegralRecord integralRecord){ + List integralRecords = integralRecordMapper.selectIntegralRecordList(integralRecord); + + if (integralRecords.size() > 0) { + integralRecords.stream().forEach(s -> { + s.setRecordName(IntegralDetailEnums.getName(s.getRecord())); + }); + } + return integralRecords; + } + + /** + * 新增积分记录 + * + * @param integralRecord 积分记录 + * @return 结果 + */ + @Override + public int insertIntegralRecord(IntegralRecord integralRecord) { + integralRecord.setCreateData(); + return integralRecordMapper.insert(integralRecord); + } + + /** + * 修改积分记录 + * + * @param integralRecord 积分记录 + * @return 结果 + */ + @Override + public int updateIntegralRecord(IntegralRecord integralRecord) { + integralRecord.setUpdateData(); + return integralRecordMapper.updateIntegralRecord(integralRecord); + } + + /** + * 批量删除积分记录 + * + * @param ids 需要删除的积分记录主键 + * @return 结果 + */ + @Override + public int deleteIntegralRecordByIds(Long[] ids, Integer delFlag) { + this.lambdaUpdate().set(IntegralRecord::getDelFlag, delFlag).in(IntegralRecord::getId, ids).update(); + return ids.length; + } + + @Autowired + private CustomerMapper customerMapper; + + @Autowired + private StoreMapper storeMapper; + + @Override + public void updateIntegral(UserVo userVo, Long objectId, BigDecimal integral, IntegralDetailEnums integralDetailEnums,String remark) { + if (integral.compareTo(BigDecimal.ZERO) == 0) { + throw new CustomException(CoreExceptionEnum.ERROR_PARAM); + } + + switch (userVo.getUserType()) { + case 1: + if (integral.compareTo(BigDecimal.ZERO) == 1) { + customerMapper.addIntegral(userVo.getUserId(), integral); + } else { + boolean subBalance = customerMapper.subIntegral(userVo.getUserId(), integral.negate()); + if (!subBalance) { + throw new CustomException(CoreExceptionEnum.BALANCE_INSUFFICIENT); + } + } + break; + case 2: + if (integral.compareTo(BigDecimal.ZERO) == 1) { + storeMapper.addIntegral(userVo.getUserId(), integral); + } else { + boolean subBalance = storeMapper.subIntegral(userVo.getUserId(), integral.negate()); + if (!subBalance) { + throw new CustomException(CoreExceptionEnum.BALANCE_INSUFFICIENT); + } + } + break; + default: + throw new IllegalStateException("Unexpected value: " + userVo.getUserType()); + } + + //添加积分记录 + addIntegralRecord(userVo, objectId, integral, integralDetailEnums,remark); + } + + @Autowired + private BusinessUtil businessUtil; + + @Autowired + private CustomerService customerService; + + @Autowired + private StoreService storeService; + + private void addIntegralRecord(UserVo userVo, Long objectId, BigDecimal integral, IntegralDetailEnums integralDetailEnums,String remark) { + IntegralRecord integralRecord = new IntegralRecord(); + integralRecord.setUserType(userVo.getUserType()); + integralRecord.setUserId(userVo.getUserId()); + integralRecord.setDelFlag(PublicCommon.启用); + integralRecord.setRecord(integralDetailEnums.getCode()); + integralRecord.setIntegral(integral); + integralRecord.setRemark(remark); + if (objectId != null) { + integralRecord.setObjectId(objectId); + } + + //获取当前积分余额 + BigDecimal userIntegral = businessUtil.getUserIntegral(userVo); + + integralRecord.setCurrentBalance(userIntegral); + this.save(integralRecord); + + //收益添加用户累计积分 + if (ObjectUtil.equal(IntegralDetailEnums.SHARE_TEAM_COMMISSION, integralDetailEnums) || ObjectUtil.equal(IntegralDetailEnums.REFEREE_SEND, integralDetailEnums)) { + switch (userVo.getUserType()) { + case 1: + customerService.lambdaUpdate().setSql("accumulate_integral = accumulate_integral + " + integral) + .eq(Customer::getId, userVo.getUserId()) + .update(); + break; + case 2: + storeService.lambdaUpdate().setSql("accumulate_integral = accumulate_integral + " + integral) + .eq(Store::getId, userVo.getUserId()) + .update(); + break; + } + } + } + + @Override + public ResponseData integralPage(PageBasic req, UserVo userVo) { + Page page = this.baseMapper.integralPage(new Page<>(req.getPageNo(), req.getPageSize()), userVo); + + if (page.getRecords().size() > 0) { + page.getRecords().stream().forEach(s -> { + s.setRecordName(IntegralDetailEnums.getName(s.getRecord())); + }); + } + + return ResponseData.success(new PageResult<>(page)); + } + + @Override + public WalletRecordCount statistics(IntegralRecord integralRecord) { + List integralRecords = integralRecordList(integralRecord); + WalletRecordCount count = new WalletRecordCount(); + + integralRecords.stream().forEach(x -> { + if (x.getIntegral().compareTo(BigDecimal.ZERO) == 1) { + count.setIncome(count.getIncome().add(x.getIntegral())); + } else if (x.getIntegral().compareTo(BigDecimal.ZERO) == -1) { + count.setExpenditure(count.getExpenditure().add(x.getIntegral())); + } + }); + + return count; + } +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/klkaccounattach/controller/KlkAccountAttachController.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/klkaccounattach/controller/KlkAccountAttachController.java new file mode 100644 index 0000000..0ef8a0e --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/klkaccounattach/controller/KlkAccountAttachController.java @@ -0,0 +1,103 @@ +package com.ruoyi.frequency.klkaccounattach.controller; + +import java.util.List; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.frequency.klkaccounattach.entity.KlkAccountAttach; +import com.ruoyi.frequency.klkaccounattach.service.KlkAccountAttachService; +import com.ruoyi.common.utils.poi.ExcelUtil; +import com.ruoyi.common.core.page.TableDataInfo; + +/** + * 拉卡拉平台账号信息附件Controller + * + * @author liwenlong + * @date 2024-05-07 + */ +@RestController +@RequestMapping("/frequency/klkaccounattach") +public class KlkAccountAttachController extends BaseController +{ + @Autowired + private KlkAccountAttachService klkAccountAttachService; + + /** + * 查询拉卡拉平台账号信息附件列表 + */ + @PreAuthorize("@ss.hasPermi('frequency:klkaccounattach:list')") + @GetMapping("/list") + public TableDataInfo list(KlkAccountAttach klkAccountAttach) + { + startPage(); + List list = klkAccountAttachService.selectKlkAccountAttachList(klkAccountAttach); + return getDataTable(list); + } + + /** + * 导出拉卡拉平台账号信息附件列表 + */ + @PreAuthorize("@ss.hasPermi('frequency:klkaccounattach:export')") + @Log(title = "拉卡拉平台账号信息附件", businessType = BusinessType.EXPORT) + @GetMapping("/export") + public AjaxResult export(KlkAccountAttach klkAccountAttach) + { + List list = klkAccountAttachService.selectKlkAccountAttachList(klkAccountAttach); + ExcelUtil util = new ExcelUtil(KlkAccountAttach.class); + return util.exportExcel(list, "拉卡拉平台账号信息附件数据"); + } + + /** + * 获取拉卡拉平台账号信息附件详细信息 + */ + @PreAuthorize("@ss.hasPermi('frequency:klkaccounattach:query')") + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") Long id) + { + return AjaxResult.success(klkAccountAttachService.selectKlkAccountAttachById(id)); + } + + /** + * 新增拉卡拉平台账号信息附件 + */ + @PreAuthorize("@ss.hasPermi('frequency:klkaccounattach:add')") + @Log(title = "拉卡拉平台账号信息附件", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody KlkAccountAttach klkAccountAttach) + { + return toAjax(klkAccountAttachService.insertKlkAccountAttach(klkAccountAttach)); + } + + /** + * 修改拉卡拉平台账号信息附件 + */ + @PreAuthorize("@ss.hasPermi('frequency:klkaccounattach:edit')") + @Log(title = "拉卡拉平台账号信息附件", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody KlkAccountAttach klkAccountAttach) + { + return toAjax(klkAccountAttachService.updateKlkAccountAttach(klkAccountAttach)); + } + + /** + * 删除拉卡拉平台账号信息附件 + */ + @PreAuthorize("@ss.hasPermi('frequency:klkaccounattach:remove')") + @Log(title = "拉卡拉平台账号信息附件", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}/{delFlag}") + public AjaxResult remove(@PathVariable("ids") Long[] ids,@PathVariable("delFlag") Integer delFlag) + { + return toAjax(klkAccountAttachService.deleteKlkAccountAttachByIds(ids,delFlag)); + } +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/klkaccounattach/entity/KlkAccountAttach.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/klkaccounattach/entity/KlkAccountAttach.java new file mode 100644 index 0000000..57b25e8 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/klkaccounattach/entity/KlkAccountAttach.java @@ -0,0 +1,54 @@ +package com.ruoyi.frequency.klkaccounattach.entity; + +import lombok.Data; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.experimental.Accessors; +import com.ruoyi.common.annotation.Excel; +import io.swagger.annotations.ApiModelProperty; +import com.baomidou.mybatisplus.annotation.TableField; +import com.ruoyi.vo.UserInfo; +import com.ruoyi.common.core.domain.BaseEntity; + +/** + * 拉卡拉平台账号信息附件对象 t_klk_account_attach + * + * @author liwenlong + * @date 2024-05-07 + */ +@Data +@Accessors(chain = true) +@TableName("t_klk_account_attach") +public class KlkAccountAttach extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + + @ApiModelProperty("租户号") + private Long id; + + @ApiModelProperty("删除状态 1 正常 2 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("拉卡拉平台账号信息表id") + @Excel(name = "拉卡拉平台账号信息表id") + private Long lakalaAccountId; + + @ApiModelProperty("附件名称") + @Excel(name = "附件名称") + private String attachName; + + @ApiModelProperty("附件路径-卡拉卡平台路径") + @Excel(name = "附件路径-卡拉卡平台路径") + private String attachStorePath; + + @ApiModelProperty("附件地址") + @Excel(name = "附件地址") + private String httpPath; + + @ApiModelProperty("附件类型: 1-身份证正面 2-身份证反面 3-银行卡 4-营业执照 5-合作协议-纸质版 6-合作协议-电子版") + @Excel(name = "附件类型: 1-身份证正面 2-身份证反面 3-银行卡 4-营业执照 5-合作协议-纸质版 6-合作协议-电子版") + private String attachType; + + + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/klkaccounattach/mapper/KlkAccountAttachMapper.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/klkaccounattach/mapper/KlkAccountAttachMapper.java new file mode 100644 index 0000000..1a81ecc --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/klkaccounattach/mapper/KlkAccountAttachMapper.java @@ -0,0 +1,47 @@ +package com.ruoyi.frequency.klkaccounattach.mapper; + +import java.util.List; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.ruoyi.frequency.klkaccounattach.entity.KlkAccountAttach; + +/** + * 拉卡拉平台账号信息附件Mapper接口 + * + * @author liwenlong + * @date 2024-05-07 + */ +public interface KlkAccountAttachMapper extends BaseMapper +{ + /** + * 查询拉卡拉平台账号信息附件 + * + * @param id 拉卡拉平台账号信息附件主键 + * @return 拉卡拉平台账号信息附件 + */ + public KlkAccountAttach selectKlkAccountAttachById(Long id); + + /** + * 查询拉卡拉平台账号信息附件列表 + * + * @param klkAccountAttach 拉卡拉平台账号信息附件 + * @return 拉卡拉平台账号信息附件集合 + */ + public List selectKlkAccountAttachList(KlkAccountAttach klkAccountAttach); + + /** + * 新增拉卡拉平台账号信息附件 + * + * @param klkAccountAttach 拉卡拉平台账号信息附件 + * @return 结果 + */ + public int insertKlkAccountAttach(KlkAccountAttach klkAccountAttach); + + /** + * 修改拉卡拉平台账号信息附件 + * + * @param klkAccountAttach 拉卡拉平台账号信息附件 + * @return 结果 + */ + public int updateKlkAccountAttach(KlkAccountAttach klkAccountAttach); + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/klkaccounattach/mapper/mapping/KlkAccountAttachMapper.xml b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/klkaccounattach/mapper/mapping/KlkAccountAttachMapper.xml new file mode 100644 index 0000000..d70cdc7 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/klkaccounattach/mapper/mapping/KlkAccountAttachMapper.xml @@ -0,0 +1,104 @@ + + + + + + + + + + + + + + + + + + + + + + select + t.id , + t.del_flag , + t.create_by , + t.create_time , + t.update_by , + t.update_time , + t.lakala_account_id , + t.attach_name , + t.attach_store_path , + t.http_path , + t.attach_type + from t_klk_account_attach AS t + + + + + + + + + insert into t_klk_account_attach + + id, + del_flag, + create_by, + create_time, + update_by, + update_time, + lakala_account_id, + attach_name, + attach_store_path, + http_path, + attach_type, + + + #{id}, + #{delFlag}, + #{createBy}, + #{createTime}, + #{updateBy}, + #{updateTime}, + #{lakalaAccountId}, + #{attachName}, + #{attachStorePath}, + #{httpPath}, + #{attachType}, + + + + + update t_klk_account_attach + + del_flag = #{delFlag}, + create_by = #{createBy}, + create_time = #{createTime}, + update_by = #{updateBy}, + update_time = #{updateTime}, + lakala_account_id = #{lakalaAccountId}, + attach_name = #{attachName}, + attach_store_path = #{attachStorePath}, + http_path = #{httpPath}, + attach_type = #{attachType}, + + where id = #{id} + + \ No newline at end of file diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/klkaccounattach/model/param/KlkAccountAttachParam.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/klkaccounattach/model/param/KlkAccountAttachParam.java new file mode 100644 index 0000000..2a8f89e --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/klkaccounattach/model/param/KlkAccountAttachParam.java @@ -0,0 +1,55 @@ +package com.ruoyi.frequency.klkaccounattach.model.param; + +import lombok.Data; +import lombok.experimental.Accessors; +import com.ruoyi.common.annotation.Excel; +import io.swagger.annotations.ApiModelProperty; +import com.ruoyi.common.core.domain.BaseEntity; + +/** + * 拉卡拉平台账号信息附件对象 t_klk_account_attach + * + * @author liwenlong + * @date 2024-05-07 + */ +@Data +@Accessors(chain = true) +public class KlkAccountAttachParam extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + @ApiModelProperty("租户号") + private Long id; + + @ApiModelProperty("删除状态 1 正常 2 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("拉卡拉平台账号信息表id") + @Excel(name = "拉卡拉平台账号信息表id") + private Long lakalaAccountId; + + @ApiModelProperty("附件名称") + @Excel(name = "附件名称") + private String attachName; + + @ApiModelProperty("附件路径-卡拉卡平台路径") + @Excel(name = "附件路径-卡拉卡平台路径") + private String attachStorePath; + + @ApiModelProperty("附件地址") + @Excel(name = "附件地址") + private String httpPath; + + @ApiModelProperty("附件类型: 1-身份证正面 2-身份证反面 3-银行卡 4-营业执照 5-合作协议-纸质版 6-合作协议-电子版") + @Excel(name = "附件类型: 1-身份证正面 2-身份证反面 3-银行卡 4-营业执照 5-合作协议-纸质版 6-合作协议-电子版") + private String attachType; + + + + + + + + + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/klkaccounattach/model/result/KlkAccountAttachResult.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/klkaccounattach/model/result/KlkAccountAttachResult.java new file mode 100644 index 0000000..f612bba --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/klkaccounattach/model/result/KlkAccountAttachResult.java @@ -0,0 +1,48 @@ +package com.ruoyi.frequency.klkaccounattach.model.result; + +import lombok.Data; +import lombok.experimental.Accessors; +import com.ruoyi.common.annotation.Excel; +import io.swagger.annotations.ApiModelProperty; +import com.ruoyi.common.core.domain.BaseEntity; + +/** + * 拉卡拉平台账号信息附件对象 t_klk_account_attach + * + * @author liwenlong + * @date 2024-05-07 + */ +@Data +@Accessors(chain = true) +public class KlkAccountAttachResult extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + @ApiModelProperty("租户号") + private Long id; + + @ApiModelProperty("删除状态 1 正常 2 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("拉卡拉平台账号信息表id") + @Excel(name = "拉卡拉平台账号信息表id") + private Long lakalaAccountId; + + @ApiModelProperty("附件名称") + @Excel(name = "附件名称") + private String attachName; + + @ApiModelProperty("附件路径-卡拉卡平台路径") + @Excel(name = "附件路径-卡拉卡平台路径") + private String attachStorePath; + + @ApiModelProperty("附件地址") + @Excel(name = "附件地址") + private String httpPath; + + @ApiModelProperty("附件类型: 1-身份证正面 2-身份证反面 3-银行卡 4-营业执照 5-合作协议-纸质版 6-合作协议-电子版") + @Excel(name = "附件类型: 1-身份证正面 2-身份证反面 3-银行卡 4-营业执照 5-合作协议-纸质版 6-合作协议-电子版") + private String attachType; + + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/klkaccounattach/service/KlkAccountAttachService.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/klkaccounattach/service/KlkAccountAttachService.java new file mode 100644 index 0000000..5f1c1ba --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/klkaccounattach/service/KlkAccountAttachService.java @@ -0,0 +1,55 @@ +package com.ruoyi.frequency.klkaccounattach.service; + +import java.util.List; +import com.ruoyi.frequency.klkaccounattach.entity.KlkAccountAttach; +import com.baomidou.mybatisplus.extension.service.IService; + +/** + * 拉卡拉平台账号信息附件Service接口 + * + * @author liwenlong + * @date 2024-05-07 + */ +public interface KlkAccountAttachService extends IService +{ + /** + * 查询拉卡拉平台账号信息附件 + * + * @param id 拉卡拉平台账号信息附件主键 + * @return 拉卡拉平台账号信息附件 + */ + public KlkAccountAttach selectKlkAccountAttachById(Long id); + + /** + * 查询拉卡拉平台账号信息附件列表 + * + * @param klkAccountAttach 拉卡拉平台账号信息附件 + * @return 拉卡拉平台账号信息附件集合 + */ + public List selectKlkAccountAttachList(KlkAccountAttach klkAccountAttach); + + /** + * 新增拉卡拉平台账号信息附件 + * + * @param klkAccountAttach 拉卡拉平台账号信息附件 + * @return 结果 + */ + public int insertKlkAccountAttach(KlkAccountAttach klkAccountAttach); + + /** + * 修改拉卡拉平台账号信息附件 + * + * @param klkAccountAttach 拉卡拉平台账号信息附件 + * @return 结果 + */ + public int updateKlkAccountAttach(KlkAccountAttach klkAccountAttach); + + /** + * 批量删除拉卡拉平台账号信息附件 + * + * @param ids 需要删除的拉卡拉平台账号信息附件主键集合 + * @return 结果 + */ + public int deleteKlkAccountAttachByIds(Long[] ids,Integer delFlag); + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/klkaccounattach/service/impl/KlkAccountAttachServiceImpl.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/klkaccounattach/service/impl/KlkAccountAttachServiceImpl.java new file mode 100644 index 0000000..f07f598 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/klkaccounattach/service/impl/KlkAccountAttachServiceImpl.java @@ -0,0 +1,87 @@ +package com.ruoyi.frequency.klkaccounattach.service.impl; + +import java.util.List; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.ruoyi.frequency.klkaccounattach.mapper.KlkAccountAttachMapper; +import com.ruoyi.frequency.klkaccounattach.entity.KlkAccountAttach; +import com.ruoyi.frequency.klkaccounattach.service.KlkAccountAttachService; + +/** + * 拉卡拉平台账号信息附件Service业务层处理 + * + * @author liwenlong + * @date 2024-05-07 + */ +@Service +public class KlkAccountAttachServiceImpl extends ServiceImpl implements KlkAccountAttachService +{ + @Autowired + private KlkAccountAttachMapper klkAccountAttachMapper; + + /** + * 查询拉卡拉平台账号信息附件 + * + * @param id 拉卡拉平台账号信息附件主键 + * @return 拉卡拉平台账号信息附件 + */ + @Override + public KlkAccountAttach selectKlkAccountAttachById(Long id) + { + return klkAccountAttachMapper.selectKlkAccountAttachById(id); + } + + /** + * 查询拉卡拉平台账号信息附件列表 + * + * @param klkAccountAttach 拉卡拉平台账号信息附件 + * @return 拉卡拉平台账号信息附件 + */ + @Override + public List selectKlkAccountAttachList(KlkAccountAttach klkAccountAttach) + { + return klkAccountAttachMapper.selectKlkAccountAttachList(klkAccountAttach); + } + + /** + * 新增拉卡拉平台账号信息附件 + * + * @param klkAccountAttach 拉卡拉平台账号信息附件 + * @return 结果 + */ + @Override + public int insertKlkAccountAttach(KlkAccountAttach klkAccountAttach) + { + klkAccountAttach.setCreateData(); + return klkAccountAttachMapper.insert(klkAccountAttach); + } + + /** + * 修改拉卡拉平台账号信息附件 + * + * @param klkAccountAttach 拉卡拉平台账号信息附件 + * @return 结果 + */ + @Override + public int updateKlkAccountAttach(KlkAccountAttach klkAccountAttach) + { + klkAccountAttach.setUpdateData(); + return klkAccountAttachMapper.updateKlkAccountAttach(klkAccountAttach); + } + + /** + * 批量删除拉卡拉平台账号信息附件 + * + * @param ids 需要删除的拉卡拉平台账号信息附件主键 + * @return 结果 + */ + @Override + public int deleteKlkAccountAttachByIds(Long[] ids,Integer delFlag) + { + this.lambdaUpdate().set(KlkAccountAttach::getDelFlag,delFlag).in(KlkAccountAttach::getId,ids).update(); + return ids.length; + } + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/klkaccount/controller/KlkAccountController.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/klkaccount/controller/KlkAccountController.java new file mode 100644 index 0000000..dd15513 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/klkaccount/controller/KlkAccountController.java @@ -0,0 +1,103 @@ +package com.ruoyi.frequency.klkaccount.controller; + +import java.util.List; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.frequency.klkaccount.entity.KlkAccount; +import com.ruoyi.frequency.klkaccount.service.KlkAccountService; +import com.ruoyi.common.utils.poi.ExcelUtil; +import com.ruoyi.common.core.page.TableDataInfo; + +/** + * 拉卡拉平台账号信息Controller + * + * @author liwenlong + * @date 2024-05-07 + */ +@RestController +@RequestMapping("/frequency/klkaccount") +public class KlkAccountController extends BaseController +{ + @Autowired + private KlkAccountService klkAccountService; + + /** + * 查询拉卡拉平台账号信息列表 + */ + @PreAuthorize("@ss.hasPermi('frequency:klkaccount:list')") + @GetMapping("/list") + public TableDataInfo list(KlkAccount klkAccount) + { + startPage(); + List list = klkAccountService.selectKlkAccountList(klkAccount); + return getDataTable(list); + } + + /** + * 导出拉卡拉平台账号信息列表 + */ + @PreAuthorize("@ss.hasPermi('frequency:klkaccount:export')") + @Log(title = "拉卡拉平台账号信息", businessType = BusinessType.EXPORT) + @GetMapping("/export") + public AjaxResult export(KlkAccount klkAccount) + { + List list = klkAccountService.selectKlkAccountList(klkAccount); + ExcelUtil util = new ExcelUtil(KlkAccount.class); + return util.exportExcel(list, "拉卡拉平台账号信息数据"); + } + + /** + * 获取拉卡拉平台账号信息详细信息 + */ + @PreAuthorize("@ss.hasPermi('frequency:klkaccount:query')") + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") Long id) + { + return AjaxResult.success(klkAccountService.selectKlkAccountById(id)); + } + + /** + * 新增拉卡拉平台账号信息 + */ + @PreAuthorize("@ss.hasPermi('frequency:klkaccount:add')") + @Log(title = "拉卡拉平台账号信息", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody KlkAccount klkAccount) + { + return toAjax(klkAccountService.insertKlkAccount(klkAccount)); + } + + /** + * 修改拉卡拉平台账号信息 + */ + @PreAuthorize("@ss.hasPermi('frequency:klkaccount:edit')") + @Log(title = "拉卡拉平台账号信息", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody KlkAccount klkAccount) + { + return toAjax(klkAccountService.updateKlkAccount(klkAccount)); + } + + /** + * 删除拉卡拉平台账号信息 + */ + @PreAuthorize("@ss.hasPermi('frequency:klkaccount:remove')") + @Log(title = "拉卡拉平台账号信息", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}/{delFlag}") + public AjaxResult remove(@PathVariable("ids") Long[] ids,@PathVariable("delFlag") Integer delFlag) + { + return toAjax(klkAccountService.deleteKlkAccountByIds(ids,delFlag)); + } +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/klkaccount/entity/KlkAccount.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/klkaccount/entity/KlkAccount.java new file mode 100644 index 0000000..3805db5 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/klkaccount/entity/KlkAccount.java @@ -0,0 +1,129 @@ +package com.ruoyi.frequency.klkaccount.entity; + +import lombok.Data; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.experimental.Accessors; +import com.ruoyi.common.annotation.Excel; +import io.swagger.annotations.ApiModelProperty; +import com.baomidou.mybatisplus.annotation.TableField; +import com.ruoyi.vo.UserInfo; +import com.ruoyi.common.core.domain.BaseEntity; + +/** + * 拉卡拉平台账号信息对象 t_klk_account + * + * @author liwenlong + * @date 2024-05-07 + */ +@Data +@Accessors(chain = true) +@TableName("t_klk_account") +public class KlkAccount extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + + @ApiModelProperty("租户号") + private Long id; + + @ApiModelProperty("删除状态 1 正常 2 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("拉卡拉平台账号") + @Excel(name = "拉卡拉平台账号") + private String receiverNo; + + @ApiModelProperty("绑定状态:1-未绑定 2-绑定中 3-已绑定 4-绑定失败") + @Excel(name = "绑定状态:1-未绑定 2-绑定中 3-已绑定 4-绑定失败") + private Integer bindStatus; + + @ApiModelProperty("绑定失败原因") + @Excel(name = "绑定失败原因") + private String bindFailReason; + + @ApiModelProperty("用户id") + @Excel(name = "用户id") + private Long userId; + + @ApiModelProperty("用户类型") + @Excel(name = "用户类型") + private Integer userType; + + @ApiModelProperty("分账接收方创建申请订单编号") + @Excel(name = "分账接收方创建申请订单编号") + private String createOrderNo; + + @ApiModelProperty("分账接收方名称") + @Excel(name = "分账接收方名称") + private String receiverName; + + @ApiModelProperty("联系手机号") + @Excel(name = "联系手机号") + private String contactMobile; + + @ApiModelProperty("营业执照号码") + @Excel(name = "营业执照号码") + private String licenseNo; + + @ApiModelProperty("营业执照名称") + @Excel(name = "营业执照名称") + private String licenseName; + + @ApiModelProperty("法人姓名") + @Excel(name = "法人姓名") + private String legalPersonName; + + @ApiModelProperty("法人证件类型 17 身份证,18 护照,19 港澳居民来往内地通行证 20 台湾居民来往内地通行证") + @Excel(name = "法人证件类型 17 身份证,18 护照,19 港澳居民来往内地通行证 20 台湾居民来往内地通行证") + private String legalPersonCertificateType; + + @ApiModelProperty("法人证件号") + @Excel(name = "法人证件号") + private String legalPersonCertificateNo; + + @ApiModelProperty("收款账户卡号") + @Excel(name = "收款账户卡号") + private String acctNo; + + @ApiModelProperty("收款账户名称") + @Excel(name = "收款账户名称") + private String acctName; + + @ApiModelProperty("收款账户账户类型: 57:对公 58:对私") + @Excel(name = "收款账户账户类型: 57:对公 58:对私") + private String acctTypeCode; + + @ApiModelProperty("收款账户证件类型 17 身份证,18 护照,19 港澳居民来往内地通行证 20 台湾居民来往内地通行证") + @Excel(name = "收款账户证件类型 17 身份证,18 护照,19 港澳居民来往内地通行证 20 台湾居民来往内地通行证") + private String acctCertificateType; + + @ApiModelProperty("收款账户证件号") + @Excel(name = "收款账户证件号") + private String acctCertificateNo; + + @ApiModelProperty("收款账户开户行号") + @Excel(name = "收款账户开户行号") + private String acctOpenBankCode; + + @ApiModelProperty("收款账户开户名称") + @Excel(name = "收款账户开户名称") + private String acctOpenBankName; + + @ApiModelProperty("收款账户清算行行号") + @Excel(name = "收款账户清算行行号") + private String acctClearBankCode; + + @ApiModelProperty("分账关系绑定申请订单编号") + @Excel(name = "分账关系绑定申请订单编号") + private String bindOrderNo; + + @ApiModelProperty("手动审核参数") + @Excel(name = "手动审核参数") + private String applyId; + + @ApiModelProperty("用户信息") + @TableField(exist = false) + private UserInfo userInfo; + + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/klkaccount/mapper/KlkAccountMapper.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/klkaccount/mapper/KlkAccountMapper.java new file mode 100644 index 0000000..f079533 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/klkaccount/mapper/KlkAccountMapper.java @@ -0,0 +1,47 @@ +package com.ruoyi.frequency.klkaccount.mapper; + +import java.util.List; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.ruoyi.frequency.klkaccount.entity.KlkAccount; + +/** + * 拉卡拉平台账号信息Mapper接口 + * + * @author liwenlong + * @date 2024-05-07 + */ +public interface KlkAccountMapper extends BaseMapper +{ + /** + * 查询拉卡拉平台账号信息 + * + * @param id 拉卡拉平台账号信息主键 + * @return 拉卡拉平台账号信息 + */ + public KlkAccount selectKlkAccountById(Long id); + + /** + * 查询拉卡拉平台账号信息列表 + * + * @param klkAccount 拉卡拉平台账号信息 + * @return 拉卡拉平台账号信息集合 + */ + public List selectKlkAccountList(KlkAccount klkAccount); + + /** + * 新增拉卡拉平台账号信息 + * + * @param klkAccount 拉卡拉平台账号信息 + * @return 结果 + */ + public int insertKlkAccount(KlkAccount klkAccount); + + /** + * 修改拉卡拉平台账号信息 + * + * @param klkAccount 拉卡拉平台账号信息 + * @return 结果 + */ + public int updateKlkAccount(KlkAccount klkAccount); + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/klkaccount/mapper/mapping/KlkAccountMapper.xml b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/klkaccount/mapper/mapping/KlkAccountMapper.xml new file mode 100644 index 0000000..12fa493 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/klkaccount/mapper/mapping/KlkAccountMapper.xml @@ -0,0 +1,208 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + select + t.id , + t.del_flag , + t.create_by , + t.create_time , + t.update_by , + t.update_time , + t.receiver_no , + t.bind_status , + t.user_id , + t.create_order_no , + t.receiver_name , + t.contact_mobile , + t.license_no , + t.license_name , + t.legal_person_name , + t.legal_person_certificate_type , + t.legal_person_certificate_no , + t.acct_no , + t.acct_name , + t.acct_type_code , + t.acct_certificate_type , + t.acct_certificate_no , + t.acct_open_bank_code , + t.acct_open_bank_name , + t.acct_clear_bank_code , + t.bind_order_no , + u.user_type, + u.id_no, + u.mobile, + u.avatar, + u.nickname + from t_klk_account AS t + LEFT JOIN t_user AS u ON t.user_id = u.id + + + + + + + + insert into t_klk_account + + id, + del_flag, + create_by, + create_time, + update_by, + update_time, + receiver_no, + bind_status, + user_id, + create_order_no, + receiver_name, + contact_mobile, + license_no, + license_name, + legal_person_name, + legal_person_certificate_type, + legal_person_certificate_no, + acct_no, + acct_name, + acct_type_code, + acct_certificate_type, + acct_certificate_no, + acct_open_bank_code, + acct_open_bank_name, + acct_clear_bank_code, + bind_order_no, + + + #{id}, + #{delFlag}, + #{createBy}, + #{createTime}, + #{updateBy}, + #{updateTime}, + #{receiverNo}, + #{bindStatus}, + #{userId}, + #{createOrderNo}, + #{receiverName}, + #{contactMobile}, + #{licenseNo}, + #{licenseName}, + #{legalPersonName}, + #{legalPersonCertificateType}, + #{legalPersonCertificateNo}, + #{acctNo}, + #{acctName}, + #{acctTypeCode}, + #{acctCertificateType}, + #{acctCertificateNo}, + #{acctOpenBankCode}, + #{acctOpenBankName}, + #{acctClearBankCode}, + #{bindOrderNo}, + + + + + update t_klk_account + + del_flag = #{delFlag}, + create_by = #{createBy}, + create_time = #{createTime}, + update_by = #{updateBy}, + update_time = #{updateTime}, + receiver_no = #{receiverNo}, + bind_status = #{bindStatus}, + user_id = #{userId}, + create_order_no = #{createOrderNo}, + receiver_name = #{receiverName}, + contact_mobile = #{contactMobile}, + license_no = #{licenseNo}, + license_name = #{licenseName}, + legal_person_name = #{legalPersonName}, + legal_person_certificate_type = #{legalPersonCertificateType}, + legal_person_certificate_no = #{legalPersonCertificateNo}, + acct_no = #{acctNo}, + acct_name = #{acctName}, + acct_type_code = #{acctTypeCode}, + acct_certificate_type = #{acctCertificateType}, + acct_certificate_no = #{acctCertificateNo}, + acct_open_bank_code = #{acctOpenBankCode}, + acct_open_bank_name = #{acctOpenBankName}, + acct_clear_bank_code = #{acctClearBankCode}, + bind_order_no = #{bindOrderNo}, + + where id = #{id} + + \ No newline at end of file diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/klkaccount/model/param/KlkAccountParam.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/klkaccount/model/param/KlkAccountParam.java new file mode 100644 index 0000000..96cac7d --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/klkaccount/model/param/KlkAccountParam.java @@ -0,0 +1,130 @@ +package com.ruoyi.frequency.klkaccount.model.param; + +import lombok.Data; +import lombok.experimental.Accessors; +import com.ruoyi.common.annotation.Excel; +import io.swagger.annotations.ApiModelProperty; +import com.ruoyi.common.core.domain.BaseEntity; + +/** + * 拉卡拉平台账号信息对象 t_klk_account + * + * @author liwenlong + * @date 2024-05-07 + */ +@Data +@Accessors(chain = true) +public class KlkAccountParam extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + @ApiModelProperty("租户号") + private Long id; + + @ApiModelProperty("删除状态 1 正常 2 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("拉卡拉平台账号") + @Excel(name = "拉卡拉平台账号") + private String receiverNo; + + @ApiModelProperty("绑定状态:1-未绑定 2-绑定中 3-已绑定") + @Excel(name = "绑定状态:1-未绑定 2-绑定中 3-已绑定") + private Integer bindStatus; + + @ApiModelProperty("用户id") + @Excel(name = "用户id") + private Long userId; + + @ApiModelProperty("分账接收方创建申请订单编号") + @Excel(name = "分账接收方创建申请订单编号") + private String createOrderNo; + + @ApiModelProperty("分账接收方名称") + @Excel(name = "分账接收方名称") + private String receiverName; + + @ApiModelProperty("联系手机号") + @Excel(name = "联系手机号") + private String contactMobile; + + @ApiModelProperty("营业执照号码") + @Excel(name = "营业执照号码") + private String licenseNo; + + @ApiModelProperty("营业执照名称") + @Excel(name = "营业执照名称") + private String licenseName; + + @ApiModelProperty("法人姓名") + @Excel(name = "法人姓名") + private String legalPersonName; + + @ApiModelProperty("法人证件类型 17 身份证,18 护照,19 港澳居民来往内地通行证 20 台湾居民来往内地通行证") + @Excel(name = "法人证件类型 17 身份证,18 护照,19 港澳居民来往内地通行证 20 台湾居民来往内地通行证") + private String legalPersonCertificateType; + + @ApiModelProperty("法人证件号") + @Excel(name = "法人证件号") + private String legalPersonCertificateNo; + + @ApiModelProperty("收款账户卡号") + @Excel(name = "收款账户卡号") + private String acctNo; + + @ApiModelProperty("收款账户名称") + @Excel(name = "收款账户名称") + private String acctName; + + @ApiModelProperty("收款账户账户类型: 57:对公 58:对私") + @Excel(name = "收款账户账户类型: 57:对公 58:对私") + private String acctTypeCode; + + @ApiModelProperty("收款账户证件类型 17 身份证,18 护照,19 港澳居民来往内地通行证 20 台湾居民来往内地通行证") + @Excel(name = "收款账户证件类型 17 身份证,18 护照,19 港澳居民来往内地通行证 20 台湾居民来往内地通行证") + private String acctCertificateType; + + @ApiModelProperty("收款账户证件号") + @Excel(name = "收款账户证件号") + private String acctCertificateNo; + + @ApiModelProperty("收款账户开户行号") + @Excel(name = "收款账户开户行号") + private String acctOpenBankCode; + + @ApiModelProperty("收款账户开户名称") + @Excel(name = "收款账户开户名称") + private String acctOpenBankName; + + @ApiModelProperty("收款账户清算行行号") + @Excel(name = "收款账户清算行行号") + private String acctClearBankCode; + + @ApiModelProperty("分账关系绑定申请订单编号") + @Excel(name = "分账关系绑定申请订单编号") + private String bindOrderNo; + + + + + + + + + + + + + + + + + + + + + + + + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/klkaccount/model/result/KlkAccountResult.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/klkaccount/model/result/KlkAccountResult.java new file mode 100644 index 0000000..9065b88 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/klkaccount/model/result/KlkAccountResult.java @@ -0,0 +1,108 @@ +package com.ruoyi.frequency.klkaccount.model.result; + +import lombok.Data; +import lombok.experimental.Accessors; +import com.ruoyi.common.annotation.Excel; +import io.swagger.annotations.ApiModelProperty; +import com.ruoyi.common.core.domain.BaseEntity; + +/** + * 拉卡拉平台账号信息对象 t_klk_account + * + * @author liwenlong + * @date 2024-05-07 + */ +@Data +@Accessors(chain = true) +public class KlkAccountResult extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + @ApiModelProperty("租户号") + private Long id; + + @ApiModelProperty("删除状态 1 正常 2 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("拉卡拉平台账号") + @Excel(name = "拉卡拉平台账号") + private String receiverNo; + + @ApiModelProperty("绑定状态:1-未绑定 2-绑定中 3-已绑定") + @Excel(name = "绑定状态:1-未绑定 2-绑定中 3-已绑定") + private Integer bindStatus; + + @ApiModelProperty("用户id") + @Excel(name = "用户id") + private Long userId; + + @ApiModelProperty("分账接收方创建申请订单编号") + @Excel(name = "分账接收方创建申请订单编号") + private String createOrderNo; + + @ApiModelProperty("分账接收方名称") + @Excel(name = "分账接收方名称") + private String receiverName; + + @ApiModelProperty("联系手机号") + @Excel(name = "联系手机号") + private String contactMobile; + + @ApiModelProperty("营业执照号码") + @Excel(name = "营业执照号码") + private String licenseNo; + + @ApiModelProperty("营业执照名称") + @Excel(name = "营业执照名称") + private String licenseName; + + @ApiModelProperty("法人姓名") + @Excel(name = "法人姓名") + private String legalPersonName; + + @ApiModelProperty("法人证件类型 17 身份证,18 护照,19 港澳居民来往内地通行证 20 台湾居民来往内地通行证") + @Excel(name = "法人证件类型 17 身份证,18 护照,19 港澳居民来往内地通行证 20 台湾居民来往内地通行证") + private String legalPersonCertificateType; + + @ApiModelProperty("法人证件号") + @Excel(name = "法人证件号") + private String legalPersonCertificateNo; + + @ApiModelProperty("收款账户卡号") + @Excel(name = "收款账户卡号") + private String acctNo; + + @ApiModelProperty("收款账户名称") + @Excel(name = "收款账户名称") + private String acctName; + + @ApiModelProperty("收款账户账户类型: 57:对公 58:对私") + @Excel(name = "收款账户账户类型: 57:对公 58:对私") + private String acctTypeCode; + + @ApiModelProperty("收款账户证件类型 17 身份证,18 护照,19 港澳居民来往内地通行证 20 台湾居民来往内地通行证") + @Excel(name = "收款账户证件类型 17 身份证,18 护照,19 港澳居民来往内地通行证 20 台湾居民来往内地通行证") + private String acctCertificateType; + + @ApiModelProperty("收款账户证件号") + @Excel(name = "收款账户证件号") + private String acctCertificateNo; + + @ApiModelProperty("收款账户开户行号") + @Excel(name = "收款账户开户行号") + private String acctOpenBankCode; + + @ApiModelProperty("收款账户开户名称") + @Excel(name = "收款账户开户名称") + private String acctOpenBankName; + + @ApiModelProperty("收款账户清算行行号") + @Excel(name = "收款账户清算行行号") + private String acctClearBankCode; + + @ApiModelProperty("分账关系绑定申请订单编号") + @Excel(name = "分账关系绑定申请订单编号") + private String bindOrderNo; + + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/klkaccount/service/KlkAccountService.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/klkaccount/service/KlkAccountService.java new file mode 100644 index 0000000..9a5e7bb --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/klkaccount/service/KlkAccountService.java @@ -0,0 +1,55 @@ +package com.ruoyi.frequency.klkaccount.service; + +import java.util.List; +import com.ruoyi.frequency.klkaccount.entity.KlkAccount; +import com.baomidou.mybatisplus.extension.service.IService; + +/** + * 拉卡拉平台账号信息Service接口 + * + * @author liwenlong + * @date 2024-05-07 + */ +public interface KlkAccountService extends IService +{ + /** + * 查询拉卡拉平台账号信息 + * + * @param id 拉卡拉平台账号信息主键 + * @return 拉卡拉平台账号信息 + */ + public KlkAccount selectKlkAccountById(Long id); + + /** + * 查询拉卡拉平台账号信息列表 + * + * @param klkAccount 拉卡拉平台账号信息 + * @return 拉卡拉平台账号信息集合 + */ + public List selectKlkAccountList(KlkAccount klkAccount); + + /** + * 新增拉卡拉平台账号信息 + * + * @param klkAccount 拉卡拉平台账号信息 + * @return 结果 + */ + public int insertKlkAccount(KlkAccount klkAccount); + + /** + * 修改拉卡拉平台账号信息 + * + * @param klkAccount 拉卡拉平台账号信息 + * @return 结果 + */ + public int updateKlkAccount(KlkAccount klkAccount); + + /** + * 批量删除拉卡拉平台账号信息 + * + * @param ids 需要删除的拉卡拉平台账号信息主键集合 + * @return 结果 + */ + public int deleteKlkAccountByIds(Long[] ids,Integer delFlag); + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/klkaccount/service/impl/KlkAccountServiceImpl.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/klkaccount/service/impl/KlkAccountServiceImpl.java new file mode 100644 index 0000000..777b726 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/klkaccount/service/impl/KlkAccountServiceImpl.java @@ -0,0 +1,87 @@ +package com.ruoyi.frequency.klkaccount.service.impl; + +import java.util.List; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.ruoyi.frequency.klkaccount.mapper.KlkAccountMapper; +import com.ruoyi.frequency.klkaccount.entity.KlkAccount; +import com.ruoyi.frequency.klkaccount.service.KlkAccountService; + +/** + * 拉卡拉平台账号信息Service业务层处理 + * + * @author liwenlong + * @date 2024-05-07 + */ +@Service +public class KlkAccountServiceImpl extends ServiceImpl implements KlkAccountService +{ + @Autowired + private KlkAccountMapper klkAccountMapper; + + /** + * 查询拉卡拉平台账号信息 + * + * @param id 拉卡拉平台账号信息主键 + * @return 拉卡拉平台账号信息 + */ + @Override + public KlkAccount selectKlkAccountById(Long id) + { + return klkAccountMapper.selectKlkAccountById(id); + } + + /** + * 查询拉卡拉平台账号信息列表 + * + * @param klkAccount 拉卡拉平台账号信息 + * @return 拉卡拉平台账号信息 + */ + @Override + public List selectKlkAccountList(KlkAccount klkAccount) + { + return klkAccountMapper.selectKlkAccountList(klkAccount); + } + + /** + * 新增拉卡拉平台账号信息 + * + * @param klkAccount 拉卡拉平台账号信息 + * @return 结果 + */ + @Override + public int insertKlkAccount(KlkAccount klkAccount) + { + klkAccount.setCreateData(); + return klkAccountMapper.insert(klkAccount); + } + + /** + * 修改拉卡拉平台账号信息 + * + * @param klkAccount 拉卡拉平台账号信息 + * @return 结果 + */ + @Override + public int updateKlkAccount(KlkAccount klkAccount) + { + klkAccount.setUpdateData(); + return klkAccountMapper.updateKlkAccount(klkAccount); + } + + /** + * 批量删除拉卡拉平台账号信息 + * + * @param ids 需要删除的拉卡拉平台账号信息主键 + * @return 结果 + */ + @Override + public int deleteKlkAccountByIds(Long[] ids,Integer delFlag) + { + this.lambdaUpdate().set(KlkAccount::getDelFlag,delFlag).in(KlkAccount::getId,ids).update(); + return ids.length; + } + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/klkwithdrawalrecord/controller/KlkWithdrawalRecordController.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/klkwithdrawalrecord/controller/KlkWithdrawalRecordController.java new file mode 100644 index 0000000..c7bdc06 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/klkwithdrawalrecord/controller/KlkWithdrawalRecordController.java @@ -0,0 +1,103 @@ +package com.ruoyi.frequency.klkwithdrawalrecord.controller; + +import java.util.List; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.frequency.klkwithdrawalrecord.entity.KlkWithdrawalRecord; +import com.ruoyi.frequency.klkwithdrawalrecord.service.KlkWithdrawalRecordService; +import com.ruoyi.common.utils.poi.ExcelUtil; +import com.ruoyi.common.core.page.TableDataInfo; + +/** + * 卡拉卡平台提现记录Controller + * + * @author liwenlong + * @date 2024-05-07 + */ +@RestController +@RequestMapping("/frequency/klkwithdrawalrecord") +public class KlkWithdrawalRecordController extends BaseController +{ + @Autowired + private KlkWithdrawalRecordService klkWithdrawalRecordService; + + /** + * 查询卡拉卡平台提现记录列表 + */ + @PreAuthorize("@ss.hasPermi('frequency:klkwithdrawalrecord:list')") + @GetMapping("/list") + public TableDataInfo list(KlkWithdrawalRecord klkWithdrawalRecord) + { + startPage(); + List list = klkWithdrawalRecordService.selectKlkWithdrawalRecordList(klkWithdrawalRecord); + return getDataTable(list); + } + + /** + * 导出卡拉卡平台提现记录列表 + */ + @PreAuthorize("@ss.hasPermi('frequency:klkwithdrawalrecord:export')") + @Log(title = "卡拉卡平台提现记录", businessType = BusinessType.EXPORT) + @GetMapping("/export") + public AjaxResult export(KlkWithdrawalRecord klkWithdrawalRecord) + { + List list = klkWithdrawalRecordService.selectKlkWithdrawalRecordList(klkWithdrawalRecord); + ExcelUtil util = new ExcelUtil(KlkWithdrawalRecord.class); + return util.exportExcel(list, "卡拉卡平台提现记录数据"); + } + + /** + * 获取卡拉卡平台提现记录详细信息 + */ + @PreAuthorize("@ss.hasPermi('frequency:klkwithdrawalrecord:query')") + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") Long id) + { + return AjaxResult.success(klkWithdrawalRecordService.selectKlkWithdrawalRecordById(id)); + } + + /** + * 新增卡拉卡平台提现记录 + */ + @PreAuthorize("@ss.hasPermi('frequency:klkwithdrawalrecord:add')") + @Log(title = "卡拉卡平台提现记录", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody KlkWithdrawalRecord klkWithdrawalRecord) + { + return toAjax(klkWithdrawalRecordService.insertKlkWithdrawalRecord(klkWithdrawalRecord)); + } + + /** + * 修改卡拉卡平台提现记录 + */ + @PreAuthorize("@ss.hasPermi('frequency:klkwithdrawalrecord:edit')") + @Log(title = "卡拉卡平台提现记录", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody KlkWithdrawalRecord klkWithdrawalRecord) + { + return toAjax(klkWithdrawalRecordService.updateKlkWithdrawalRecord(klkWithdrawalRecord)); + } + + /** + * 删除卡拉卡平台提现记录 + */ + @PreAuthorize("@ss.hasPermi('frequency:klkwithdrawalrecord:remove')") + @Log(title = "卡拉卡平台提现记录", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}/{delFlag}") + public AjaxResult remove(@PathVariable("ids") Long[] ids,@PathVariable("delFlag") Integer delFlag) + { + return toAjax(klkWithdrawalRecordService.deleteKlkWithdrawalRecordByIds(ids,delFlag)); + } +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/klkwithdrawalrecord/entity/KlkWithdrawalRecord.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/klkwithdrawalrecord/entity/KlkWithdrawalRecord.java new file mode 100644 index 0000000..cc194c1 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/klkwithdrawalrecord/entity/KlkWithdrawalRecord.java @@ -0,0 +1,94 @@ +package com.ruoyi.frequency.klkwithdrawalrecord.entity; + +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableName; +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import com.ruoyi.vo.UserInfo; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; + +import java.util.Date; + +/** + * 卡拉卡平台提现记录对象 t_klk_withdrawal_record + * + * @author liwenlong + * @date 2024-05-07 + */ +@Data +@Accessors(chain = true) +@TableName("t_klk_withdrawal_record") +public class KlkWithdrawalRecord extends BaseEntity { + private static final long serialVersionUID = 1L; + + + @ApiModelProperty("租户号") + private Long id; + + @ApiModelProperty("删除状态 1 正常 2 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("用户id") + @Excel(name = "用户id") + private Long userId; + + @ApiModelProperty("用户类型") + @Excel(name = "用户类型") + private Integer userType; + + @ApiModelProperty("体现金额,单位:分") + @Excel(name = "体现金额,单位:分") + private String totalAmt; + + @ApiModelProperty("余额分账状态:1-处理中 2-已受理 3-成功 4-失败 -1-未关联卡拉卡平台") + @Excel(name = "余额分账状态:1-处理中 2-已受理 3-成功 4-失败 -1-未关联卡拉卡平台") + private Integer balanceSplitStatus; + + @ApiModelProperty("余额分账备注信息") + @Excel(name = "余额分账备注信息") + private String balanceSplitRemark; + + @ApiModelProperty("提现卡号") + @Excel(name = "提现卡号") + private String acctNo; + + @ApiModelProperty("提现状态:1-处理中 2-已受理 3-成功 4-失败 5-冻结 -1-未关联卡拉卡平台") + @Excel(name = "提现状态:1-处理中 2-已受理 3-成功 4-失败 5-冻结 -1-未关联卡拉卡平台") + private Integer withdrawalStatus; + + @ApiModelProperty("提现备注信息") + @Excel(name = "提现备注信息") + private String withdrawalRemark; + + @ApiModelProperty("银行开户名称") + @Excel(name = "银行开户名称") + private String acctOpenBankName; + + @ApiModelProperty("开户名") + @Excel(name = "开户名") + private String acctName; + + @ApiModelProperty("转账完成时间") + @Excel(name = "转账完成时间", width = 30, dateFormat = "yyyy-MM-dd") + private Date transferFinishTime; + + @ApiModelProperty("提现表id") + @Excel(name = "提现表id") + private Long withdrawalRecordId; + + @ApiModelProperty("分账指令流水号") + @Excel(name = "分账指令流水号") + private String outSeparateNo; + + @ApiModelProperty("提款流水号") + @Excel(name = "提款流水号") + private String drawJnl; + + @ApiModelProperty("用户信息") + @TableField(exist = false) + private UserInfo userInfo; + + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/klkwithdrawalrecord/mapper/KlkWithdrawalRecordMapper.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/klkwithdrawalrecord/mapper/KlkWithdrawalRecordMapper.java new file mode 100644 index 0000000..ba22778 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/klkwithdrawalrecord/mapper/KlkWithdrawalRecordMapper.java @@ -0,0 +1,47 @@ +package com.ruoyi.frequency.klkwithdrawalrecord.mapper; + +import java.util.List; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.ruoyi.frequency.klkwithdrawalrecord.entity.KlkWithdrawalRecord; + +/** + * 卡拉卡平台提现记录Mapper接口 + * + * @author liwenlong + * @date 2024-05-07 + */ +public interface KlkWithdrawalRecordMapper extends BaseMapper +{ + /** + * 查询卡拉卡平台提现记录 + * + * @param id 卡拉卡平台提现记录主键 + * @return 卡拉卡平台提现记录 + */ + public KlkWithdrawalRecord selectKlkWithdrawalRecordById(Long id); + + /** + * 查询卡拉卡平台提现记录列表 + * + * @param klkWithdrawalRecord 卡拉卡平台提现记录 + * @return 卡拉卡平台提现记录集合 + */ + public List selectKlkWithdrawalRecordList(KlkWithdrawalRecord klkWithdrawalRecord); + + /** + * 新增卡拉卡平台提现记录 + * + * @param klkWithdrawalRecord 卡拉卡平台提现记录 + * @return 结果 + */ + public int insertKlkWithdrawalRecord(KlkWithdrawalRecord klkWithdrawalRecord); + + /** + * 修改卡拉卡平台提现记录 + * + * @param klkWithdrawalRecord 卡拉卡平台提现记录 + * @return 结果 + */ + public int updateKlkWithdrawalRecord(KlkWithdrawalRecord klkWithdrawalRecord); + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/klkwithdrawalrecord/mapper/mapping/KlkWithdrawalRecordMapper.xml b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/klkwithdrawalrecord/mapper/mapping/KlkWithdrawalRecordMapper.xml new file mode 100644 index 0000000..0c51939 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/klkwithdrawalrecord/mapper/mapping/KlkWithdrawalRecordMapper.xml @@ -0,0 +1,154 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + select + t.id , + t.del_flag , + t.create_by , + t.create_time , + t.update_by , + t.update_time , + t.user_id , + t.total_amt , + t.balance_split_status , + t.balance_split_remark , + t.acct_no , + t.withdrawal_status , + t.withdrawal_remark , + t.acct_open_bank_name , + t.acct_name , + t.transfer_finish_time , + t.withdrawal_record_id , + u.user_type, + u.id_no, + u.mobile, + u.avatar, + u.nickname + from t_klk_withdrawal_record AS t + LEFT JOIN t_user AS u ON t.user_id = u.id + + + + + + + + insert into t_klk_withdrawal_record + + id, + del_flag, + create_by, + create_time, + update_by, + update_time, + user_id, + total_amt, + balance_split_status, + balance_split_remark, + acct_no, + withdrawal_status, + withdrawal_remark, + acct_open_bank_name, + acct_name, + transfer_finish_time, + withdrawal_record_id, + + + #{id}, + #{delFlag}, + #{createBy}, + #{createTime}, + #{updateBy}, + #{updateTime}, + #{userId}, + #{totalAmt}, + #{balanceSplitStatus}, + #{balanceSplitRemark}, + #{acctNo}, + #{withdrawalStatus}, + #{withdrawalRemark}, + #{acctOpenBankName}, + #{acctName}, + #{transferFinishTime}, + #{withdrawalRecordId}, + + + + + update t_klk_withdrawal_record + + del_flag = #{delFlag}, + create_by = #{createBy}, + create_time = #{createTime}, + update_by = #{updateBy}, + update_time = #{updateTime}, + user_id = #{userId}, + total_amt = #{totalAmt}, + balance_split_status = #{balanceSplitStatus}, + balance_split_remark = #{balanceSplitRemark}, + acct_no = #{acctNo}, + withdrawal_status = #{withdrawalStatus}, + withdrawal_remark = #{withdrawalRemark}, + acct_open_bank_name = #{acctOpenBankName}, + acct_name = #{acctName}, + transfer_finish_time = #{transferFinishTime}, + withdrawal_record_id = #{withdrawalRecordId}, + + where id = #{id} + + \ No newline at end of file diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/klkwithdrawalrecord/model/param/KlkWithdrawalRecordParam.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/klkwithdrawalrecord/model/param/KlkWithdrawalRecordParam.java new file mode 100644 index 0000000..5c486ac --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/klkwithdrawalrecord/model/param/KlkWithdrawalRecordParam.java @@ -0,0 +1,87 @@ +package com.ruoyi.frequency.klkwithdrawalrecord.model.param; + +import java.util.Date; +import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.Data; +import lombok.experimental.Accessors; +import com.ruoyi.common.annotation.Excel; +import io.swagger.annotations.ApiModelProperty; +import com.ruoyi.common.core.domain.BaseEntity; + +/** + * 卡拉卡平台提现记录对象 t_klk_withdrawal_record + * + * @author liwenlong + * @date 2024-05-07 + */ +@Data +@Accessors(chain = true) +public class KlkWithdrawalRecordParam extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + @ApiModelProperty("租户号") + private Long id; + + @ApiModelProperty("删除状态 1 正常 2 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("用户id") + @Excel(name = "用户id") + private Long userId; + + @ApiModelProperty("体现金额,单位:分") + @Excel(name = "体现金额,单位:分") + private String totalAmt; + + @ApiModelProperty("余额分账状态:1-处理中 2-已受理 3-成功 4-失败 -1-未关联卡拉卡平台") + @Excel(name = "余额分账状态:1-处理中 2-已受理 3-成功 4-失败 -1-未关联卡拉卡平台") + private Integer balanceSplitStatus; + + @ApiModelProperty("余额分账备注信息") + @Excel(name = "余额分账备注信息") + private String balanceSplitRemark; + + @ApiModelProperty("提现卡号") + @Excel(name = "提现卡号") + private String acctNo; + + @ApiModelProperty("提现状态:1-处理中 2-已受理 3-成功 4-失败 5-冻结 -1-未关联卡拉卡平台") + @Excel(name = "提现状态:1-处理中 2-已受理 3-成功 4-失败 5-冻结 -1-未关联卡拉卡平台") + private Integer withdrawalStatus; + + @ApiModelProperty("提现备注信息") + @Excel(name = "提现备注信息") + private String withdrawalRemark; + + @ApiModelProperty("银行开户名称") + @Excel(name = "银行开户名称") + private String acctOpenBankName; + + @ApiModelProperty("开户名") + @Excel(name = "开户名") + private String acctName; + + @ApiModelProperty("转账完成时间") + @Excel(name = "转账完成时间", width = 30, dateFormat = "yyyy-MM-dd") + private Date transferFinishTime; + + @ApiModelProperty("提现表id") + @Excel(name = "提现表id") + private Long withdrawalRecordId; + + + + + + + + + + + + + + + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/klkwithdrawalrecord/model/result/KlkWithdrawalRecordResult.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/klkwithdrawalrecord/model/result/KlkWithdrawalRecordResult.java new file mode 100644 index 0000000..56cf444 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/klkwithdrawalrecord/model/result/KlkWithdrawalRecordResult.java @@ -0,0 +1,74 @@ +package com.ruoyi.frequency.klkwithdrawalrecord.model.result; + +import java.util.Date; +import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.Data; +import lombok.experimental.Accessors; +import com.ruoyi.common.annotation.Excel; +import io.swagger.annotations.ApiModelProperty; +import com.ruoyi.common.core.domain.BaseEntity; + +/** + * 卡拉卡平台提现记录对象 t_klk_withdrawal_record + * + * @author liwenlong + * @date 2024-05-07 + */ +@Data +@Accessors(chain = true) +public class KlkWithdrawalRecordResult extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + @ApiModelProperty("租户号") + private Long id; + + @ApiModelProperty("删除状态 1 正常 2 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("用户id") + @Excel(name = "用户id") + private Long userId; + + @ApiModelProperty("体现金额,单位:分") + @Excel(name = "体现金额,单位:分") + private String totalAmt; + + @ApiModelProperty("余额分账状态:1-处理中 2-已受理 3-成功 4-失败 -1-未关联卡拉卡平台") + @Excel(name = "余额分账状态:1-处理中 2-已受理 3-成功 4-失败 -1-未关联卡拉卡平台") + private Integer balanceSplitStatus; + + @ApiModelProperty("余额分账备注信息") + @Excel(name = "余额分账备注信息") + private String balanceSplitRemark; + + @ApiModelProperty("提现卡号") + @Excel(name = "提现卡号") + private String acctNo; + + @ApiModelProperty("提现状态:1-处理中 2-已受理 3-成功 4-失败 5-冻结 -1-未关联卡拉卡平台") + @Excel(name = "提现状态:1-处理中 2-已受理 3-成功 4-失败 5-冻结 -1-未关联卡拉卡平台") + private Integer withdrawalStatus; + + @ApiModelProperty("提现备注信息") + @Excel(name = "提现备注信息") + private String withdrawalRemark; + + @ApiModelProperty("银行开户名称") + @Excel(name = "银行开户名称") + private String acctOpenBankName; + + @ApiModelProperty("开户名") + @Excel(name = "开户名") + private String acctName; + + @ApiModelProperty("转账完成时间") + @Excel(name = "转账完成时间", width = 30, dateFormat = "yyyy-MM-dd") + private Date transferFinishTime; + + @ApiModelProperty("提现表id") + @Excel(name = "提现表id") + private Long withdrawalRecordId; + + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/klkwithdrawalrecord/service/KlkWithdrawalRecordService.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/klkwithdrawalrecord/service/KlkWithdrawalRecordService.java new file mode 100644 index 0000000..c5fcebb --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/klkwithdrawalrecord/service/KlkWithdrawalRecordService.java @@ -0,0 +1,55 @@ +package com.ruoyi.frequency.klkwithdrawalrecord.service; + +import java.util.List; +import com.ruoyi.frequency.klkwithdrawalrecord.entity.KlkWithdrawalRecord; +import com.baomidou.mybatisplus.extension.service.IService; + +/** + * 卡拉卡平台提现记录Service接口 + * + * @author liwenlong + * @date 2024-05-07 + */ +public interface KlkWithdrawalRecordService extends IService +{ + /** + * 查询卡拉卡平台提现记录 + * + * @param id 卡拉卡平台提现记录主键 + * @return 卡拉卡平台提现记录 + */ + public KlkWithdrawalRecord selectKlkWithdrawalRecordById(Long id); + + /** + * 查询卡拉卡平台提现记录列表 + * + * @param klkWithdrawalRecord 卡拉卡平台提现记录 + * @return 卡拉卡平台提现记录集合 + */ + public List selectKlkWithdrawalRecordList(KlkWithdrawalRecord klkWithdrawalRecord); + + /** + * 新增卡拉卡平台提现记录 + * + * @param klkWithdrawalRecord 卡拉卡平台提现记录 + * @return 结果 + */ + public int insertKlkWithdrawalRecord(KlkWithdrawalRecord klkWithdrawalRecord); + + /** + * 修改卡拉卡平台提现记录 + * + * @param klkWithdrawalRecord 卡拉卡平台提现记录 + * @return 结果 + */ + public int updateKlkWithdrawalRecord(KlkWithdrawalRecord klkWithdrawalRecord); + + /** + * 批量删除卡拉卡平台提现记录 + * + * @param ids 需要删除的卡拉卡平台提现记录主键集合 + * @return 结果 + */ + public int deleteKlkWithdrawalRecordByIds(Long[] ids,Integer delFlag); + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/klkwithdrawalrecord/service/impl/KlkWithdrawalRecordServiceImpl.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/klkwithdrawalrecord/service/impl/KlkWithdrawalRecordServiceImpl.java new file mode 100644 index 0000000..a919694 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/klkwithdrawalrecord/service/impl/KlkWithdrawalRecordServiceImpl.java @@ -0,0 +1,87 @@ +package com.ruoyi.frequency.klkwithdrawalrecord.service.impl; + +import java.util.List; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.ruoyi.frequency.klkwithdrawalrecord.mapper.KlkWithdrawalRecordMapper; +import com.ruoyi.frequency.klkwithdrawalrecord.entity.KlkWithdrawalRecord; +import com.ruoyi.frequency.klkwithdrawalrecord.service.KlkWithdrawalRecordService; + +/** + * 卡拉卡平台提现记录Service业务层处理 + * + * @author liwenlong + * @date 2024-05-07 + */ +@Service +public class KlkWithdrawalRecordServiceImpl extends ServiceImpl implements KlkWithdrawalRecordService +{ + @Autowired + private KlkWithdrawalRecordMapper klkWithdrawalRecordMapper; + + /** + * 查询卡拉卡平台提现记录 + * + * @param id 卡拉卡平台提现记录主键 + * @return 卡拉卡平台提现记录 + */ + @Override + public KlkWithdrawalRecord selectKlkWithdrawalRecordById(Long id) + { + return klkWithdrawalRecordMapper.selectKlkWithdrawalRecordById(id); + } + + /** + * 查询卡拉卡平台提现记录列表 + * + * @param klkWithdrawalRecord 卡拉卡平台提现记录 + * @return 卡拉卡平台提现记录 + */ + @Override + public List selectKlkWithdrawalRecordList(KlkWithdrawalRecord klkWithdrawalRecord) + { + return klkWithdrawalRecordMapper.selectKlkWithdrawalRecordList(klkWithdrawalRecord); + } + + /** + * 新增卡拉卡平台提现记录 + * + * @param klkWithdrawalRecord 卡拉卡平台提现记录 + * @return 结果 + */ + @Override + public int insertKlkWithdrawalRecord(KlkWithdrawalRecord klkWithdrawalRecord) + { + klkWithdrawalRecord.setCreateData(); + return klkWithdrawalRecordMapper.insert(klkWithdrawalRecord); + } + + /** + * 修改卡拉卡平台提现记录 + * + * @param klkWithdrawalRecord 卡拉卡平台提现记录 + * @return 结果 + */ + @Override + public int updateKlkWithdrawalRecord(KlkWithdrawalRecord klkWithdrawalRecord) + { + klkWithdrawalRecord.setUpdateData(); + return klkWithdrawalRecordMapper.updateKlkWithdrawalRecord(klkWithdrawalRecord); + } + + /** + * 批量删除卡拉卡平台提现记录 + * + * @param ids 需要删除的卡拉卡平台提现记录主键 + * @return 结果 + */ + @Override + public int deleteKlkWithdrawalRecordByIds(Long[] ids,Integer delFlag) + { + this.lambdaUpdate().set(KlkWithdrawalRecord::getDelFlag,delFlag).in(KlkWithdrawalRecord::getId,ids).update(); + return ids.length; + } + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/level/controller/LevelController.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/level/controller/LevelController.java new file mode 100644 index 0000000..7d667ab --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/level/controller/LevelController.java @@ -0,0 +1,97 @@ +package com.ruoyi.frequency.level.controller; + +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.page.TableDataInfo; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.common.utils.poi.ExcelUtil; +import com.ruoyi.frequency.level.entity.Level; +import com.ruoyi.frequency.level.service.LevelService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +/** + * 等级Controller + * + * @author liwenlong + * @date 2023-10-19 + */ +@RestController +@RequestMapping("/frequency/level") +public class LevelController extends BaseController +{ + @Autowired + private LevelService levelService; + + /** + * 查询等级列表 + */ + @PreAuthorize("@ss.hasPermi('frequency:level:list')") + @PostMapping("/list") + public TableDataInfo list(@RequestBody Level level) + { + startPage(); + List list = levelService.selectLevelList(level); + return getDataTable(list); + } + + /** + * 导出等级列表 + */ + @PreAuthorize("@ss.hasPermi('frequency:level:export')") + @Log(title = "等级", businessType = BusinessType.EXPORT) + @GetMapping("/export") + public AjaxResult export(Level level) + { + List list = levelService.selectLevelList(level); + ExcelUtil util = new ExcelUtil(Level.class); + return util.exportExcel(list, "等级数据"); + } + + /** + * 获取等级详细信息 + */ + @PreAuthorize("@ss.hasPermi('frequency:level:query')") + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") Long id) + { + return AjaxResult.success(levelService.selectLevelById(id)); + } + + /** + * 新增等级 + */ + @PreAuthorize("@ss.hasPermi('frequency:level:add')") + @Log(title = "等级", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody Level level) + { + return toAjax(levelService.insertLevel(level)); + } + + /** + * 修改等级 + */ + @PreAuthorize("@ss.hasPermi('frequency:level:edit')") + @Log(title = "等级", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody Level level) + { + return toAjax(levelService.updateLevel(level)); + } + + /** + * 删除等级 + */ + @PreAuthorize("@ss.hasPermi('frequency:level:remove')") + @Log(title = "等级", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}") + public AjaxResult remove(@PathVariable Long[] ids) + { + return toAjax(levelService.deleteLevelByIds(ids)); + } +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/level/entity/Level.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/level/entity/Level.java new file mode 100644 index 0000000..ef6f190 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/level/entity/Level.java @@ -0,0 +1,62 @@ +package com.ruoyi.frequency.level.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; + +import java.math.BigDecimal; + +/** + * 等级对象 t_level + * + * @author liwenlong + * @date 2023-10-19 + */ +@Data +@Accessors(chain = true) +@TableName("t_level") +public class Level extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + + @ApiModelProperty("租户号") + private Long id; + + + @ApiModelProperty("删除标志;1 正常 2 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("等级名称") + @Excel(name = "等级名称") + private String name; + + @ApiModelProperty("等级图标") + @Excel(name = "等级图标") + private String icon; + + @ApiModelProperty("最低标准") + @Excel(name = "最低标准") + private BigDecimal compliance; + + @ApiModelProperty("排序") + @Excel(name = "排序") + private Integer sort; + + @ApiModelProperty("等级类型;1 设计师等级,2 表现师等级") + @Excel(name = "等级类型;1 设计师等级,2 表现师等级") + private Integer type; + + @ApiModelProperty("镶边类型 1 不镶边 2 镶银边 3 镶金边") + @Excel(name = "镶边类型 1 不镶边 2 镶银边 3 镶金边") + private Integer edgePipingType; + + @ApiModelProperty("等级说明") + @Excel(name = "等级说明") + private String illustrate; + + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/level/mapper/LevelMapper.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/level/mapper/LevelMapper.java new file mode 100644 index 0000000..6e09031 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/level/mapper/LevelMapper.java @@ -0,0 +1,63 @@ +package com.ruoyi.frequency.level.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.ruoyi.frequency.level.entity.Level; + +import java.util.List; + +/** + * 等级Mapper接口 + * + * @author liwenlong + * @date 2023-10-19 + */ +public interface LevelMapper extends BaseMapper +{ + /** + * 查询等级 + * + * @param id 等级主键 + * @return 等级 + */ + public Level selectLevelById(Long id); + + /** + * 查询等级列表 + * + * @param level 等级 + * @return 等级集合 + */ + public List selectLevelList(Level level); + + /** + * 新增等级 + * + * @param level 等级 + * @return 结果 + */ + public int insertLevel(Level level); + + /** + * 修改等级 + * + * @param level 等级 + * @return 结果 + */ + public int updateLevel(Level level); + + /** + * 删除等级 + * + * @param id 等级主键 + * @return 结果 + */ + public int deleteLevelById(Long id); + + /** + * 批量删除等级 + * + * @param ids 需要删除的数据主键集合 + * @return 结果 + */ + public int deleteLevelByIds(Long[] ids); +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/level/mapper/mapping/LevelMapper.xml b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/level/mapper/mapping/LevelMapper.xml new file mode 100644 index 0000000..c16cea3 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/level/mapper/mapping/LevelMapper.xml @@ -0,0 +1,107 @@ + + + + + + + + + + + + + + + + + + + + + + select id, create_by, create_time, update_by, update_time, del_flag, name, icon, compliance, sort, type, edge_piping_type,illustrate from t_level + + + + + + + + insert into t_level + + id, + create_by, + create_time, + update_by, + update_time, + del_flag, + name, + icon, + compliance, + sort, + type, + edge_piping_type, + + + #{id}, + #{createBy}, + #{createTime}, + #{updateBy}, + #{updateTime}, + #{delFlag}, + #{name}, + #{icon}, + #{compliance}, + #{sort}, + #{type}, + #{edgePipingType}, + + + + + update t_level + + create_by = #{createBy}, + create_time = #{createTime}, + update_by = #{updateBy}, + update_time = #{updateTime}, + del_flag = #{delFlag}, + name = #{name}, + icon = #{icon}, + compliance = #{compliance}, + sort = #{sort}, + type = #{type}, + edge_piping_type = #{edgePipingType}, + + where id = #{id} + + + + delete from t_level where id = #{id} + + + + delete from t_level where id in + + #{id} + + + \ No newline at end of file diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/level/model/param/LevelParam.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/level/model/param/LevelParam.java new file mode 100644 index 0000000..9d55588 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/level/model/param/LevelParam.java @@ -0,0 +1,63 @@ +package com.ruoyi.frequency.level.model.param; + +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; + +/** + * 等级对象 t_level + * + * @author liwenlong + * @date 2023-10-19 + */ +@Data +@Accessors(chain = true) +public class LevelParam extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + @ApiModelProperty("租户号") + private Long id; + + + + @ApiModelProperty("删除标志;1 正常 2 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("等级名称") + @Excel(name = "等级名称") + private String name; + + @ApiModelProperty("等级图标") + @Excel(name = "等级图标") + private String icon; + + @ApiModelProperty("最低标准") + @Excel(name = "最低标准") + private String compliance; + + @ApiModelProperty("排序") + @Excel(name = "排序") + private Integer sort; + + @ApiModelProperty("等级类型;1 设计师等级,2 表现师等级") + @Excel(name = "等级类型;1 设计师等级,2 表现师等级") + private Integer type; + + @ApiModelProperty("镶边类型 1 不镶边 2 镶银边 3 镶金边") + @Excel(name = "镶边类型 1 不镶边 2 镶银边 3 镶金边") + private Integer edgePipingType; + + + + + + + + + + + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/level/model/result/LevelResult.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/level/model/result/LevelResult.java new file mode 100644 index 0000000..099e82d --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/level/model/result/LevelResult.java @@ -0,0 +1,54 @@ +package com.ruoyi.frequency.level.model.result; + +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; + +/** + * 等级对象 t_level + * + * @author liwenlong + * @date 2023-10-19 + */ +@Data +@Accessors(chain = true) +public class LevelResult extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + @ApiModelProperty("租户号") + private Long id; + + + + @ApiModelProperty("删除标志;1 正常 2 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("等级名称") + @Excel(name = "等级名称") + private String name; + + @ApiModelProperty("等级图标") + @Excel(name = "等级图标") + private String icon; + + @ApiModelProperty("最低标准") + @Excel(name = "最低标准") + private String compliance; + + @ApiModelProperty("排序") + @Excel(name = "排序") + private Integer sort; + + @ApiModelProperty("等级类型;1 设计师等级,2 表现师等级") + @Excel(name = "等级类型;1 设计师等级,2 表现师等级") + private Integer type; + + @ApiModelProperty("镶边类型 1 不镶边 2 镶银边 3 镶金边") + @Excel(name = "镶边类型 1 不镶边 2 镶银边 3 镶金边") + private Integer edgePipingType; + + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/level/service/LevelService.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/level/service/LevelService.java new file mode 100644 index 0000000..83f4b76 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/level/service/LevelService.java @@ -0,0 +1,63 @@ +package com.ruoyi.frequency.level.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.ruoyi.frequency.level.entity.Level; + +import java.util.List; + +/** + * 等级Service接口 + * + * @author liwenlong + * @date 2023-10-19 + */ +public interface LevelService extends IService +{ + /** + * 查询等级 + * + * @param id 等级主键 + * @return 等级 + */ + public Level selectLevelById(Long id); + + /** + * 查询等级列表 + * + * @param level 等级 + * @return 等级集合 + */ + public List selectLevelList(Level level); + + /** + * 新增等级 + * + * @param level 等级 + * @return 结果 + */ + public int insertLevel(Level level); + + /** + * 修改等级 + * + * @param level 等级 + * @return 结果 + */ + public int updateLevel(Level level); + + /** + * 批量删除等级 + * + * @param ids 需要删除的等级主键集合 + * @return 结果 + */ + public int deleteLevelByIds(Long[] ids); + + /** + * 删除等级信息 + * + * @param id 等级主键 + * @return 结果 + */ + public int deleteLevelById(Long id); +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/level/service/impl/LevelServiceImpl.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/level/service/impl/LevelServiceImpl.java new file mode 100644 index 0000000..50bfe1d --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/level/service/impl/LevelServiceImpl.java @@ -0,0 +1,102 @@ +package com.ruoyi.frequency.level.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.ruoyi.code.PublicCommon; +import com.ruoyi.common.utils.DateUtils; +import com.ruoyi.frequency.level.entity.Level; +import com.ruoyi.frequency.level.mapper.LevelMapper; +import com.ruoyi.frequency.level.service.LevelService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.List; + +/** + * 等级Service业务层处理 + * + * @author liwenlong + * @date 2023-10-19 + */ +@Service +@Transactional(rollbackFor = Exception.class) +public class LevelServiceImpl extends ServiceImpl implements LevelService +{ + @Autowired + private LevelMapper levelMapper; + + /** + * 查询等级 + * + * @param id 等级主键 + * @return 等级 + */ + @Override + public Level selectLevelById(Long id) + { + return levelMapper.selectLevelById(id); + } + + /** + * 查询等级列表 + * + * @param level 等级 + * @return 等级 + */ + @Override + public List selectLevelList(Level level) + { + return levelMapper.selectLevelList(level); + } + + /** + * 新增等级 + * + * @param level 等级 + * @return 结果 + */ + @Override + public int insertLevel(Level level) + { + return levelMapper.insert(level); + } + + /** + * 修改等级 + * + * @param level 等级 + * @return 结果 + */ + @Override + public int updateLevel(Level level) + { + level.setUpdateTime(DateUtils.getNowDate()); + return levelMapper.updateById(level); + } + + /** + * 批量删除等级 + * + * @param ids 需要删除的等级主键 + * @return 结果 + */ + @Override + public int deleteLevelByIds(Long[] ids) + { + this.lambdaUpdate().set(Level::getDelFlag,PublicCommon.删除).in(Level::getId,ids).update(); + return ids.length; + } + + /** + * 删除等级信息 + * + * @param id 等级主键 + * @return 结果 + */ + @Override + public int deleteLevelById(Long id) + { + this.lambdaUpdate().set(Level::getDelFlag,PublicCommon.删除).eq(Level::getId,id).update(); + return 1; + } +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/onlinerecord/controller/OnlineRecordController.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/onlinerecord/controller/OnlineRecordController.java new file mode 100644 index 0000000..40aa006 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/onlinerecord/controller/OnlineRecordController.java @@ -0,0 +1,103 @@ +package com.ruoyi.frequency.onlinerecord.controller; + +import java.util.List; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.frequency.onlinerecord.entity.OnlineRecord; +import com.ruoyi.frequency.onlinerecord.service.OnlineRecordService; +import com.ruoyi.common.utils.poi.ExcelUtil; +import com.ruoyi.common.core.page.TableDataInfo; + +/** + * 在线支付记录Controller + * + * @author liwenlong + * @date 2024-05-18 + */ +@RestController +@RequestMapping("/frequency/onlinerecord") +public class OnlineRecordController extends BaseController +{ + @Autowired + private OnlineRecordService onlineRecordService; + + /** + * 查询在线支付记录列表 + */ + @PreAuthorize("@ss.hasPermi('frequency:onlinerecord:list')") + @GetMapping("/list") + public TableDataInfo list(OnlineRecord onlineRecord) + { + startPage(); + List list = onlineRecordService.selectOnlineRecordList(onlineRecord); + return getDataTable(list); + } + + /** + * 导出在线支付记录列表 + */ + @PreAuthorize("@ss.hasPermi('frequency:onlinerecord:export')") + @Log(title = "在线支付记录", businessType = BusinessType.EXPORT) + @GetMapping("/export") + public AjaxResult export(OnlineRecord onlineRecord) + { + List list = onlineRecordService.selectOnlineRecordList(onlineRecord); + ExcelUtil util = new ExcelUtil(OnlineRecord.class); + return util.exportExcel(list, "在线支付记录数据"); + } + + /** + * 获取在线支付记录详细信息 + */ + @PreAuthorize("@ss.hasPermi('frequency:onlinerecord:query')") + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") Long id) + { + return AjaxResult.success(onlineRecordService.selectOnlineRecordById(id)); + } + + /** + * 新增在线支付记录 + */ + @PreAuthorize("@ss.hasPermi('frequency:onlinerecord:add')") + @Log(title = "在线支付记录", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody OnlineRecord onlineRecord) + { + return toAjax(onlineRecordService.insertOnlineRecord(onlineRecord)); + } + + /** + * 修改在线支付记录 + */ + @PreAuthorize("@ss.hasPermi('frequency:onlinerecord:edit')") + @Log(title = "在线支付记录", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody OnlineRecord onlineRecord) + { + return toAjax(onlineRecordService.updateOnlineRecord(onlineRecord)); + } + + /** + * 删除在线支付记录 + */ + @PreAuthorize("@ss.hasPermi('frequency:onlinerecord:remove')") + @Log(title = "在线支付记录", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}/{delFlag}") + public AjaxResult remove(@PathVariable("ids") Long[] ids,@PathVariable("delFlag") Integer delFlag) + { + return toAjax(onlineRecordService.deleteOnlineRecordByIds(ids,delFlag)); + } +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/onlinerecord/entity/OnlineRecord.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/onlinerecord/entity/OnlineRecord.java new file mode 100644 index 0000000..6f521ba --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/onlinerecord/entity/OnlineRecord.java @@ -0,0 +1,62 @@ +package com.ruoyi.frequency.onlinerecord.entity; + +import java.math.BigDecimal; +import lombok.Data; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.experimental.Accessors; +import com.ruoyi.common.annotation.Excel; +import io.swagger.annotations.ApiModelProperty; +import com.baomidou.mybatisplus.annotation.TableField; +import com.ruoyi.vo.UserInfo; +import com.ruoyi.common.core.domain.BaseEntity; + +/** + * 在线支付记录对象 t_online_record + * + * @author liwenlong + * @date 2024-05-18 + */ +@Data +@Accessors(chain = true) +@TableName("t_online_record") +public class OnlineRecord extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + + @ApiModelProperty("主键id") + private Long id; + + @ApiModelProperty("删除标志 1正常 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("数值") + @Excel(name = "数值") + private BigDecimal price; + + @ApiModelProperty("主体id") + @Excel(name = "主体id") + private Long objectId; + + @ApiModelProperty("支付方式 :目前只有快捷支付") + @Excel(name = "支付方式 :目前只有快捷支付") + private Integer payType; + + @ApiModelProperty("来源类型") + @Excel(name = "来源类型") + private Integer objectType; + + @ApiModelProperty("交易用户") + @Excel(name = "交易用户") + private Long userId; + + @ApiModelProperty("交易用户类型") + @Excel(name = "交易用户类型") + private Integer userType; + + @ApiModelProperty("用户信息") + @TableField(exist = false) + private UserInfo userInfo; + + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/onlinerecord/mapper/OnlineRecordMapper.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/onlinerecord/mapper/OnlineRecordMapper.java new file mode 100644 index 0000000..1a4f77c --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/onlinerecord/mapper/OnlineRecordMapper.java @@ -0,0 +1,47 @@ +package com.ruoyi.frequency.onlinerecord.mapper; + +import java.util.List; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.ruoyi.frequency.onlinerecord.entity.OnlineRecord; + +/** + * 在线支付记录Mapper接口 + * + * @author liwenlong + * @date 2024-05-18 + */ +public interface OnlineRecordMapper extends BaseMapper +{ + /** + * 查询在线支付记录 + * + * @param id 在线支付记录主键 + * @return 在线支付记录 + */ + public OnlineRecord selectOnlineRecordById(Long id); + + /** + * 查询在线支付记录列表 + * + * @param onlineRecord 在线支付记录 + * @return 在线支付记录集合 + */ + public List selectOnlineRecordList(OnlineRecord onlineRecord); + + /** + * 新增在线支付记录 + * + * @param onlineRecord 在线支付记录 + * @return 结果 + */ + public int insertOnlineRecord(OnlineRecord onlineRecord); + + /** + * 修改在线支付记录 + * + * @param onlineRecord 在线支付记录 + * @return 结果 + */ + public int updateOnlineRecord(OnlineRecord onlineRecord); + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/onlinerecord/mapper/mapping/OnlineRecordMapper.xml b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/onlinerecord/mapper/mapping/OnlineRecordMapper.xml new file mode 100644 index 0000000..d36b3b6 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/onlinerecord/mapper/mapping/OnlineRecordMapper.xml @@ -0,0 +1,124 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + select + t.id , + t.create_by , + t.create_time , + t.update_by , + t.update_time , + t.del_flag , + t.price , + t.object_id , + t.pay_type , + t.object_type , + t.user_id , + t.user_type , + u.user_type, + u.id_no, + u.mobile, + u.avatar, + u.nickname + from t_online_record AS t + LEFT JOIN t_user AS u ON t.user_id = u.id + + + + + + + + insert into t_online_record + + id, + create_by, + create_time, + update_by, + update_time, + del_flag, + price, + object_id, + pay_type, + object_type, + user_id, + user_type, + + + #{id}, + #{createBy}, + #{createTime}, + #{updateBy}, + #{updateTime}, + #{delFlag}, + #{price}, + #{objectId}, + #{payType}, + #{objectType}, + #{userId}, + #{userType}, + + + + + update t_online_record + + create_by = #{createBy}, + create_time = #{createTime}, + update_by = #{updateBy}, + update_time = #{updateTime}, + del_flag = #{delFlag}, + price = #{price}, + object_id = #{objectId}, + pay_type = #{payType}, + object_type = #{objectType}, + user_id = #{userId}, + user_type = #{userType}, + + where id = #{id} + + \ No newline at end of file diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/onlinerecord/model/param/OnlineRecordParam.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/onlinerecord/model/param/OnlineRecordParam.java new file mode 100644 index 0000000..b76063d --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/onlinerecord/model/param/OnlineRecordParam.java @@ -0,0 +1,61 @@ +package com.ruoyi.frequency.onlinerecord.model.param; + +import java.math.BigDecimal; +import lombok.Data; +import lombok.experimental.Accessors; +import com.ruoyi.common.annotation.Excel; +import io.swagger.annotations.ApiModelProperty; +import com.ruoyi.common.core.domain.BaseEntity; + +/** + * 在线支付记录对象 t_online_record + * + * @author liwenlong + * @date 2024-05-18 + */ +@Data +@Accessors(chain = true) +public class OnlineRecordParam extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + @ApiModelProperty("主键id") + private Long id; + + @ApiModelProperty("删除标志 1正常 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("数值") + @Excel(name = "数值") + private BigDecimal price; + + @ApiModelProperty("主体id") + @Excel(name = "主体id") + private Long objectId; + + @ApiModelProperty("支付方式 :目前只有快捷支付") + @Excel(name = "支付方式 :目前只有快捷支付") + private Integer payType; + + @ApiModelProperty("来源类型") + @Excel(name = "来源类型") + private Integer objectType; + + @ApiModelProperty("交易用户") + @Excel(name = "交易用户") + private Long userId; + + @ApiModelProperty("交易用户类型") + @Excel(name = "交易用户类型") + private Integer userType; + + + + + + + + + + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/onlinerecord/model/result/OnlineRecordResult.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/onlinerecord/model/result/OnlineRecordResult.java new file mode 100644 index 0000000..abb5b9c --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/onlinerecord/model/result/OnlineRecordResult.java @@ -0,0 +1,53 @@ +package com.ruoyi.frequency.onlinerecord.model.result; + +import java.math.BigDecimal; +import lombok.Data; +import lombok.experimental.Accessors; +import com.ruoyi.common.annotation.Excel; +import io.swagger.annotations.ApiModelProperty; +import com.ruoyi.common.core.domain.BaseEntity; + +/** + * 在线支付记录对象 t_online_record + * + * @author liwenlong + * @date 2024-05-18 + */ +@Data +@Accessors(chain = true) +public class OnlineRecordResult extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + @ApiModelProperty("主键id") + private Long id; + + @ApiModelProperty("删除标志 1正常 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("数值") + @Excel(name = "数值") + private BigDecimal price; + + @ApiModelProperty("主体id") + @Excel(name = "主体id") + private Long objectId; + + @ApiModelProperty("支付方式 :目前只有快捷支付") + @Excel(name = "支付方式 :目前只有快捷支付") + private Integer payType; + + @ApiModelProperty("来源类型") + @Excel(name = "来源类型") + private Integer objectType; + + @ApiModelProperty("交易用户") + @Excel(name = "交易用户") + private Long userId; + + @ApiModelProperty("交易用户类型") + @Excel(name = "交易用户类型") + private Integer userType; + + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/onlinerecord/service/OnlineRecordService.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/onlinerecord/service/OnlineRecordService.java new file mode 100644 index 0000000..427ac80 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/onlinerecord/service/OnlineRecordService.java @@ -0,0 +1,60 @@ +package com.ruoyi.frequency.onlinerecord.service; + +import java.math.BigDecimal; +import java.util.List; + +import com.ruoyi.enums.WalletDetailEnums; +import com.ruoyi.frequency.onlinerecord.entity.OnlineRecord; +import com.baomidou.mybatisplus.extension.service.IService; +import com.ruoyi.vo.UserVo; + +/** + * 在线支付记录Service接口 + * + * @author liwenlong + * @date 2024-05-18 + */ +public interface OnlineRecordService extends IService +{ + /** + * 查询在线支付记录 + * + * @param id 在线支付记录主键 + * @return 在线支付记录 + */ + public OnlineRecord selectOnlineRecordById(Long id); + + /** + * 查询在线支付记录列表 + * + * @param onlineRecord 在线支付记录 + * @return 在线支付记录集合 + */ + public List selectOnlineRecordList(OnlineRecord onlineRecord); + + /** + * 新增在线支付记录 + * + * @param onlineRecord 在线支付记录 + * @return 结果 + */ + public int insertOnlineRecord(OnlineRecord onlineRecord); + + /** + * 修改在线支付记录 + * + * @param onlineRecord 在线支付记录 + * @return 结果 + */ + public int updateOnlineRecord(OnlineRecord onlineRecord); + + /** + * 批量删除在线支付记录 + * + * @param ids 需要删除的在线支付记录主键集合 + * @return 结果 + */ + public int deleteOnlineRecordByIds(Long[] ids,Integer delFlag); + + void addOnlineRecord(UserVo userVo, Long orderId, BigDecimal price, WalletDetailEnums walletDetailEnums); +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/onlinerecord/service/impl/OnlineRecordServiceImpl.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/onlinerecord/service/impl/OnlineRecordServiceImpl.java new file mode 100644 index 0000000..02b45c5 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/onlinerecord/service/impl/OnlineRecordServiceImpl.java @@ -0,0 +1,112 @@ +package com.ruoyi.frequency.onlinerecord.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.ruoyi.enums.WalletDetailEnums; +import com.ruoyi.frequency.onlinerecord.entity.OnlineRecord; +import com.ruoyi.frequency.onlinerecord.mapper.OnlineRecordMapper; +import com.ruoyi.frequency.onlinerecord.service.OnlineRecordService; +import com.ruoyi.vo.UserVo; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.math.BigDecimal; +import java.util.List; + +/** + * 在线支付记录Service业务层处理 + * + * @author liwenlong + * @date 2024-05-18 + */ +@Service +public class OnlineRecordServiceImpl extends ServiceImpl implements OnlineRecordService { + @Autowired + private OnlineRecordMapper onlineRecordMapper; + + /** + * 查询在线支付记录 + * + * @param id 在线支付记录主键 + * @return 在线支付记录 + */ + @Override + public OnlineRecord selectOnlineRecordById(Long id) { + return onlineRecordMapper.selectOnlineRecordById(id); + } + + /** + * 查询在线支付记录列表 + * + * @param onlineRecord 在线支付记录 + * @return 在线支付记录 + */ + @Override + public List selectOnlineRecordList(OnlineRecord onlineRecord) { + return onlineRecordMapper.selectOnlineRecordList(onlineRecord); + } + + /** + * 新增在线支付记录 + * + * @param onlineRecord 在线支付记录 + * @return 结果 + */ + @Override + public int insertOnlineRecord(OnlineRecord onlineRecord) { + onlineRecord.setCreateData(); + return onlineRecordMapper.insert(onlineRecord); + } + + /** + * 修改在线支付记录 + * + * @param onlineRecord 在线支付记录 + * @return 结果 + */ + @Override + public int updateOnlineRecord(OnlineRecord onlineRecord) { + onlineRecord.setUpdateData(); + return onlineRecordMapper.updateOnlineRecord(onlineRecord); + } + + /** + * 批量删除在线支付记录 + * + * @param ids 需要删除的在线支付记录主键 + * @return 结果 + */ + @Override + public int deleteOnlineRecordByIds(Long[] ids, Integer delFlag) { + this.lambdaUpdate().set(OnlineRecord::getDelFlag, delFlag).in(OnlineRecord::getId, ids).update(); + return ids.length; + } + + + /** + * 增加余额记录 + * + * @param userVo 用户 + * @param walletDetailEnums 类型名称 + * @param orderId 订单id + * @param price 金额 + */ + @Override + public void addOnlineRecord(UserVo userVo, Long orderId, BigDecimal price, WalletDetailEnums walletDetailEnums) { + if (price.setScale(2, BigDecimal.ROUND_HALF_UP).compareTo(new BigDecimal(0)) != 0) { + OnlineRecord onlineRecord = new OnlineRecord(); + onlineRecord.setUserId(userVo.getUserId()); + onlineRecord.setUserType(userVo.getUserType()); + onlineRecord.setObjectId(orderId); + onlineRecord.setObjectType(walletDetailEnums.getCode()); + if (price.compareTo(BigDecimal.ZERO) == 1) { + onlineRecord.setPrice(price.negate()); + } else { + onlineRecord.setPrice(price); + } + + + this.save(onlineRecord); + } + } + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/ordermessage/entity/OrderMessageUtil.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/ordermessage/entity/OrderMessageUtil.java new file mode 100644 index 0000000..ec75333 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/ordermessage/entity/OrderMessageUtil.java @@ -0,0 +1,66 @@ +package com.ruoyi.frequency.ordermessage.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; + +/** + * 订单消息对象 t_order_message + * + * @author zj + * @date 2023-10-13 + */ +@Data +@Accessors(chain = true) +@TableName("t_order_message") +public class OrderMessageUtil extends BaseEntity { + private static final long serialVersionUID = 1L; + + + @ApiModelProperty("主键id") + private Long id; + + @ApiModelProperty("删除标志 1正常 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("订单id") + @Excel(name = "订单id") + private Long orderId; + + @ApiModelProperty("订单类型 1 普通订单 ") + @Excel(name = "订单类型 1 普通订单 ") + private Integer orderType; + + @ApiModelProperty("标题") + @Excel(name = "标题") + private String title; + + @ApiModelProperty("内容") + @Excel(name = "内容") + private String content; + + @ApiModelProperty("1未读 2 已读") + @Excel(name = "1未读 2 已读") + private Integer isRead; + + @ApiModelProperty("用户id") + @Excel(name = "用户id") + private Long userId; + + @ApiModelProperty("$column.columnComment") + @Excel(name = "用户id") + private Integer userType; + + @ApiModelProperty("是否清空 1 不清空 2 清空") + @Excel(name = "是否清空 1 不清空 2 清空") + private Integer isShow; + + @ApiModelProperty("消息类型") + @Excel(name = "消息类型") + private Integer messageType; + + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/ordermessage/mapper/OrderMessageUtilMapper.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/ordermessage/mapper/OrderMessageUtilMapper.java new file mode 100644 index 0000000..65f8de4 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/ordermessage/mapper/OrderMessageUtilMapper.java @@ -0,0 +1,49 @@ +package com.ruoyi.frequency.ordermessage.mapper; + +import java.util.List; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.ruoyi.frequency.ordermessage.entity.OrderMessageUtil; + +/** + * 订单消息Mapper接口 + * + * @author zj + * @date 2023-10-13 + */ +public interface OrderMessageUtilMapper extends BaseMapper +{ + + + /** + * 新增订单消息 + * + * @param orderMessageUtil 订单消息 + * @return 结果 + */ + public int insertOrderMessage(OrderMessageUtil orderMessageUtil); + + /** + * 修改订单消息 + * + * @param orderMessageUtil 订单消息 + * @return 结果 + */ + public int updateOrderMessage(OrderMessageUtil orderMessageUtil); + + /** + * 删除订单消息 + * + * @param id 订单消息主键 + * @return 结果 + */ + public int deleteOrderMessageById(Long id); + + /** + * 批量删除订单消息 + * + * @param ids 需要删除的数据主键集合 + * @return 结果 + */ + public int deleteOrderMessageByIds(Long[] ids); + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/ordermessage/mapper/mapping/OrderMessageUtilMapper.xml b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/ordermessage/mapper/mapping/OrderMessageUtilMapper.xml new file mode 100644 index 0000000..64ab613 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/ordermessage/mapper/mapping/OrderMessageUtilMapper.xml @@ -0,0 +1,77 @@ + + + + + + + insert into t_order_message + + id, + create_by, + create_time, + update_by, + update_time, + del_flag, + order_id, + order_type, + title, + content, + is_read, + user_id, + user_type, + is_show, + message_type, + + + #{id}, + #{createBy}, + #{createTime}, + #{updateBy}, + #{updateTime}, + #{delFlag}, + #{orderId}, + #{orderType}, + #{title}, + #{content}, + #{isRead}, + #{userId}, + #{userType}, + #{isShow}, + #{messageType}, + + + + + update t_order_message + + create_by = #{createBy}, + create_time = #{createTime}, + update_by = #{updateBy}, + update_time = #{updateTime}, + del_flag = #{delFlag}, + order_id = #{orderId}, + order_type = #{orderType}, + title = #{title}, + content = #{content}, + is_read = #{isRead}, + user_id = #{userId}, + user_type = #{userType}, + is_show = #{isShow}, + message_type = #{messageType}, + + where id = #{id} + + + + delete from t_order_message where id = #{id} + + + + delete from t_order_message where id in + + #{id} + + + \ No newline at end of file diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/ordermessage/model/param/OrderMessageUtilParam.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/ordermessage/model/param/OrderMessageUtilParam.java new file mode 100644 index 0000000..655a8d9 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/ordermessage/model/param/OrderMessageUtilParam.java @@ -0,0 +1,75 @@ +package com.ruoyi.frequency.ordermessage.model.param; + +import lombok.Data; +import lombok.experimental.Accessors; +import com.ruoyi.common.annotation.Excel; +import io.swagger.annotations.ApiModelProperty; +import com.ruoyi.common.core.domain.BaseEntity; + +/** + * 订单消息对象 t_order_message + * + * @author zj + * @date 2023-10-13 + */ +@Data +@Accessors(chain = true) +public class OrderMessageUtilParam extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + @ApiModelProperty("主键id") + private Long id; + + @ApiModelProperty("删除标志 1正常 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("订单id") + @Excel(name = "订单id") + private Long orderId; + + @ApiModelProperty("订单类型 1 普通订单 ") + @Excel(name = "订单类型 1 普通订单 ") + private Integer orderType; + + @ApiModelProperty("标题") + @Excel(name = "标题") + private String title; + + @ApiModelProperty("内容") + @Excel(name = "内容") + private String content; + + @ApiModelProperty("1未读 2 已读") + @Excel(name = "1未读 2 已读") + private Integer isRead; + + @ApiModelProperty("用户id") + @Excel(name = "用户id") + private Long userId; + + @ApiModelProperty("$column.columnComment") + @Excel(name = "用户id") + private Integer userType; + + @ApiModelProperty("是否清空 1 不清空 2 清空") + @Excel(name = "是否清空 1 不清空 2 清空") + private Integer isShow; + + @ApiModelProperty("消息类型") + @Excel(name = "消息类型") + private Integer messageType; + + + + + + + + + + + + + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/ordermessage/model/result/OrderMessageUtilResult.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/ordermessage/model/result/OrderMessageUtilResult.java new file mode 100644 index 0000000..ce09a79 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/ordermessage/model/result/OrderMessageUtilResult.java @@ -0,0 +1,64 @@ +package com.ruoyi.frequency.ordermessage.model.result; + +import lombok.Data; +import lombok.experimental.Accessors; +import com.ruoyi.common.annotation.Excel; +import io.swagger.annotations.ApiModelProperty; +import com.ruoyi.common.core.domain.BaseEntity; + +/** + * 订单消息对象 t_order_message + * + * @author zj + * @date 2023-10-13 + */ +@Data +@Accessors(chain = true) +public class OrderMessageUtilResult extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + @ApiModelProperty("主键id") + private Long id; + + @ApiModelProperty("删除标志 1正常 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("订单id") + @Excel(name = "订单id") + private Long orderId; + + @ApiModelProperty("订单类型 1 普通订单 ") + @Excel(name = "订单类型 1 普通订单 ") + private Integer orderType; + + @ApiModelProperty("标题") + @Excel(name = "标题") + private String title; + + @ApiModelProperty("内容") + @Excel(name = "内容") + private String content; + + @ApiModelProperty("1未读 2 已读") + @Excel(name = "1未读 2 已读") + private Integer isRead; + + @ApiModelProperty("用户id") + @Excel(name = "用户id") + private Long userId; + + @ApiModelProperty("$column.columnComment") + @Excel(name = "用户id") + private Integer userType; + + @ApiModelProperty("是否清空 1 不清空 2 清空") + @Excel(name = "是否清空 1 不清空 2 清空") + private Integer isShow; + + @ApiModelProperty("消息类型") + @Excel(name = "消息类型") + private Integer messageType; + + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/ordermessage/service/OrderMessageUtilService.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/ordermessage/service/OrderMessageUtilService.java new file mode 100644 index 0000000..9fd643f --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/ordermessage/service/OrderMessageUtilService.java @@ -0,0 +1,40 @@ +package com.ruoyi.frequency.ordermessage.service; + +import java.util.List; + +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.ruoyi.controller.req.MessageReadOrDeleteReq; +import com.ruoyi.enums.message.OrderMessageEnums; +import com.ruoyi.frequency.ordermessage.entity.OrderMessageUtil; +import com.baomidou.mybatisplus.extension.service.IService; +import com.ruoyi.response.ResponseData; +import com.ruoyi.vo.PageBasic; +import com.ruoyi.vo.UserVo; + +/** + * 订单消息Service接口 + * + * @author zj + * @date 2023-10-13 + */ +public interface OrderMessageUtilService extends IService +{ + + /** + * 添加订单消息 + * @param userVo + * @param orderId + * @param orderType + * @param orderMessageEnums + */ + void addOrderMessage(UserVo userVo, Long orderId, String orderNo,String amount, Integer orderType, OrderMessageEnums orderMessageEnums); + + /** + * 添加订单消息 + * @param userVo + * @param orderId + * @param orderType + * @param orderMessageEnums + */ + void addOrderMessage(UserVo userVo, Long orderId, String orderNo, Integer orderType, OrderMessageEnums orderMessageEnums,String... content); +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/ordermessage/service/impl/OrderMessageUtilServiceImpl.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/ordermessage/service/impl/OrderMessageUtilServiceImpl.java new file mode 100644 index 0000000..f096add --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/ordermessage/service/impl/OrderMessageUtilServiceImpl.java @@ -0,0 +1,79 @@ +package com.ruoyi.frequency.ordermessage.service.impl; + +import cn.hutool.core.collection.CollectionUtil; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.ruoyi.code.PublicCommon; +import com.ruoyi.common.utils.DateUtils; +import com.ruoyi.controller.req.MessageReadOrDeleteReq; +import com.ruoyi.enums.message.OrderMessageEnums; +import com.ruoyi.frequency.ordermessage.entity.OrderMessageUtil; +import com.ruoyi.frequency.ordermessage.mapper.OrderMessageUtilMapper; +import com.ruoyi.frequency.ordermessage.service.OrderMessageUtilService; +import com.ruoyi.push.service.PushService; +import com.ruoyi.response.ResponseData; +import com.ruoyi.vo.PageBasic; +import com.ruoyi.vo.UserVo; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.List; + +/** + * 订单消息Service业务层处理 + * + * @author zj + * @date 2023-10-13 + */ +@Service +@Transactional(rollbackFor = Exception.class) +public class OrderMessageUtilServiceImpl extends ServiceImpl implements OrderMessageUtilService +{ + + @Autowired + private PushService pushService; + + /** + * 添加订单消息 + * @param userVo + * @param orderId + * @param orderType + */ + @Override + public void addOrderMessage(UserVo userVo, Long orderId, String orderNo,String amount, Integer orderType, OrderMessageEnums orderMessageEnums) { + + OrderMessageUtil orderMessageUtil = new OrderMessageUtil() + .setMessageType(orderMessageEnums.getCode()) + .setTitle(orderMessageEnums.getTitle()) + .setContent(orderMessageEnums.getContent().replace("orderNo",orderNo).replace("amount",amount)) + .setUserId(userVo.getUserId()) + .setUserType(userVo.getUserType()) + .setOrderId(orderId) + .setOrderType(orderType); + this.baseMapper.insert(orderMessageUtil); + + //推送 + pushService.push(userVo,orderId,orderNo, orderMessageUtil.getId(), orderMessageEnums); + + } + + + @Override + public void addOrderMessage(UserVo userVo, Long orderId, String orderNo, Integer orderType, OrderMessageEnums orderMessageEnums, String... content) { + OrderMessageUtil orderMessageUtil = new OrderMessageUtil() + .setMessageType(orderMessageEnums.getCode()) + .setTitle(orderMessageEnums.getTitle()) + .setContent(String.format(orderMessageEnums.getContent(),content)) + .setUserId(userVo.getUserId()) + .setUserType(userVo.getUserType()) + .setOrderId(orderId) + .setOrderType(orderType); + + this.baseMapper.insert(orderMessageUtil); + + //推送 + pushService.push(userVo,orderId,orderNo, orderMessageUtil.getId(), orderMessageEnums); + } +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/pfwithdrawalway/controller/PfWithdrawalWayController.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/pfwithdrawalway/controller/PfWithdrawalWayController.java new file mode 100644 index 0000000..373226f --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/pfwithdrawalway/controller/PfWithdrawalWayController.java @@ -0,0 +1,97 @@ +package com.ruoyi.frequency.pfwithdrawalway.controller; + +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.page.TableDataInfo; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.common.utils.poi.ExcelUtil; +import com.ruoyi.frequency.pfwithdrawalway.entity.PfWithdrawalWay; +import com.ruoyi.frequency.pfwithdrawalway.service.PfWithdrawalWayService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +/** + * 后台提现方式Controller + * + * @author liwenlong + * @date 2023-07-20 + */ +@RestController +@RequestMapping("/frequency/pfwithdrawalway") +public class PfWithdrawalWayController extends BaseController +{ + @Autowired + private PfWithdrawalWayService pfWithdrawalWayService; + + /** + * 查询后台提现方式列表 + */ + @PreAuthorize("@ss.hasPermi('frequency:pfwithdrawalway:list')") + @GetMapping("/list") + public TableDataInfo list(PfWithdrawalWay pfWithdrawalWay) + { + startPage(); + List list = pfWithdrawalWayService.selectPfWithdrawalWayList(pfWithdrawalWay); + return getDataTable(list); + } + + /** + * 导出后台提现方式列表 + */ + @PreAuthorize("@ss.hasPermi('frequency:pfwithdrawalway:export')") + @Log(title = "后台提现方式", businessType = BusinessType.EXPORT) + @GetMapping("/export") + public AjaxResult export(PfWithdrawalWay pfWithdrawalWay) + { + List list = pfWithdrawalWayService.selectPfWithdrawalWayList(pfWithdrawalWay); + ExcelUtil util = new ExcelUtil(PfWithdrawalWay.class); + return util.exportExcel(list, "后台提现方式数据"); + } + + /** + * 获取后台提现方式详细信息 + */ + @PreAuthorize("@ss.hasPermi('frequency:pfwithdrawalway:query')") + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") Long id) + { + return AjaxResult.success(pfWithdrawalWayService.selectPfWithdrawalWayById(id)); + } + + /** + * 新增后台提现方式 + */ + @PreAuthorize("@ss.hasPermi('frequency:pfwithdrawalway:add')") + @Log(title = "后台提现方式", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody PfWithdrawalWay pfWithdrawalWay) + { + return toAjax(pfWithdrawalWayService.insertPfWithdrawalWay(pfWithdrawalWay)); + } + + /** + * 修改后台提现方式 + */ + @PreAuthorize("@ss.hasPermi('frequency:pfwithdrawalway:edit')") + @Log(title = "后台提现方式", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody PfWithdrawalWay pfWithdrawalWay) + { + return toAjax(pfWithdrawalWayService.updatePfWithdrawalWay(pfWithdrawalWay)); + } + + /** + * 删除后台提现方式 + */ + @PreAuthorize("@ss.hasPermi('frequency:pfwithdrawalway:remove')") + @Log(title = "后台提现方式", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}") + public AjaxResult remove(@PathVariable Long[] ids) + { + return toAjax(pfWithdrawalWayService.deletePfWithdrawalWayByIds(ids)); + } +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/pfwithdrawalway/entity/PfWithdrawalWay.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/pfwithdrawalway/entity/PfWithdrawalWay.java new file mode 100644 index 0000000..cb66ec8 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/pfwithdrawalway/entity/PfWithdrawalWay.java @@ -0,0 +1,45 @@ +package com.ruoyi.frequency.pfwithdrawalway.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import lombok.Data; +import lombok.experimental.Accessors; + +/** + * 后台提现方式对象 t_pf_withdrawal_way + * + * @author liwenlong + * @date 2023-07-20 + */ +@Data +@Accessors(chain = true) +@TableName("t_pf_withdrawal_way") +public class PfWithdrawalWay extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** $column.columnComment */ + private Long id; + + /** 提现方式名称 */ + @Excel(name = "提现方式名称") + private String name; + + /** $column.columnComment */ + @Excel(name = "提现方式名称") + private String logo; + + /** 是否是银行卡提现方式;1 不是 2 是 */ + @Excel(name = "是否是银行卡提现方式;1 不是 2 是") + private Integer isBank; + + /** 1 */ + private Integer delFlag; + + /** $column.columnComment */ + @Excel(name = "是否是银行卡提现方式;1 不是 2 是") + private Integer sort; + + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/pfwithdrawalway/mapper/PfWithdrawalWayMapper.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/pfwithdrawalway/mapper/PfWithdrawalWayMapper.java new file mode 100644 index 0000000..af49f00 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/pfwithdrawalway/mapper/PfWithdrawalWayMapper.java @@ -0,0 +1,63 @@ +package com.ruoyi.frequency.pfwithdrawalway.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.ruoyi.frequency.pfwithdrawalway.entity.PfWithdrawalWay; + +import java.util.List; + +/** + * 后台提现方式Mapper接口 + * + * @author liwenlong + * @date 2023-07-20 + */ +public interface PfWithdrawalWayMapper extends BaseMapper +{ + /** + * 查询后台提现方式 + * + * @param id 后台提现方式主键 + * @return 后台提现方式 + */ + PfWithdrawalWay selectPfWithdrawalWayById(Long id); + + /** + * 查询后台提现方式列表 + * + * @param pfWithdrawalWay 后台提现方式 + * @return 后台提现方式集合 + */ + List selectPfWithdrawalWayList(PfWithdrawalWay pfWithdrawalWay); + + /** + * 新增后台提现方式 + * + * @param pfWithdrawalWay 后台提现方式 + * @return 结果 + */ + int insertPfWithdrawalWay(PfWithdrawalWay pfWithdrawalWay); + + /** + * 修改后台提现方式 + * + * @param pfWithdrawalWay 后台提现方式 + * @return 结果 + */ + int updatePfWithdrawalWay(PfWithdrawalWay pfWithdrawalWay); + + /** + * 删除后台提现方式 + * + * @param id 后台提现方式主键 + * @return 结果 + */ + int deletePfWithdrawalWayById(Long id); + + /** + * 批量删除后台提现方式 + * + * @param ids 需要删除的数据主键集合 + * @return 结果 + */ + int deletePfWithdrawalWayByIds(Long[] ids); +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/pfwithdrawalway/mapper/mapping/PfWithdrawalWayMapper.xml b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/pfwithdrawalway/mapper/mapping/PfWithdrawalWayMapper.xml new file mode 100644 index 0000000..cb2cd04 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/pfwithdrawalway/mapper/mapping/PfWithdrawalWayMapper.xml @@ -0,0 +1,95 @@ + + + + + + + + + + + + + + + + + + + select id, create_time, update_time, name, logo, is_bank, del_flag, sort, create_by, update_by from t_pf_withdrawal_way + + + + + + + + insert into t_pf_withdrawal_way + + id, + create_time, + update_time, + name, + logo, + is_bank, + del_flag, + sort, + create_by, + update_by, + + + #{id}, + #{createTime}, + #{updateTime}, + #{name}, + #{logo}, + #{isBank}, + #{delFlag}, + #{sort}, + #{createBy}, + #{updateBy}, + + + + + update t_pf_withdrawal_way + + create_time = #{createTime}, + update_time = #{updateTime}, + name = #{name}, + logo = #{logo}, + is_bank = #{isBank}, + del_flag = #{delFlag}, + sort = #{sort}, + create_by = #{createBy}, + update_by = #{updateBy}, + + where id = #{id} + + + + delete from t_pf_withdrawal_way where id = #{id} + + + + delete from t_pf_withdrawal_way where id in + + #{id} + + + \ No newline at end of file diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/pfwithdrawalway/model/param/PfWithdrawalWayParam.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/pfwithdrawalway/model/param/PfWithdrawalWayParam.java new file mode 100644 index 0000000..3cbc7b3 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/pfwithdrawalway/model/param/PfWithdrawalWayParam.java @@ -0,0 +1,43 @@ +package com.ruoyi.frequency.pfwithdrawalway.model.param; + +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import lombok.Data; +import lombok.experimental.Accessors; + +/** + * 后台提现方式对象 t_pf_withdrawal_way + * + * @author liwenlong + * @date 2023-07-20 + */ +@Data +@Accessors(chain = true) +public class PfWithdrawalWayParam extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** $column.columnComment */ + private Long id; + + /** 提现方式名称 */ + @Excel(name = "提现方式名称") + private String name; + + /** $column.columnComment */ + @Excel(name = "提现方式名称") + private String logo; + + /** 是否是银行卡提现方式;1 不是 2 是 */ + @Excel(name = "是否是银行卡提现方式;1 不是 2 是") + private Integer isBank; + + /** 1 */ + private Integer delFlag; + + /** $column.columnComment */ + @Excel(name = "是否是银行卡提现方式;1 不是 2 是") + private Integer sort; + + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/pfwithdrawalway/model/result/PfWithdrawalWayResult.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/pfwithdrawalway/model/result/PfWithdrawalWayResult.java new file mode 100644 index 0000000..b477ebc --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/pfwithdrawalway/model/result/PfWithdrawalWayResult.java @@ -0,0 +1,42 @@ +package com.ruoyi.frequency.pfwithdrawalway.model.result; + +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import lombok.Data; +import lombok.experimental.Accessors; + +/** + * 后台提现方式对象 t_pf_withdrawal_way + * + * @author liwenlong + * @date 2023-07-20 + */ +@Data +@Accessors(chain = true) +public class PfWithdrawalWayResult extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** $column.columnComment */ + private Long id; + + /** 提现方式名称 */ + @Excel(name = "提现方式名称") + private String name; + + /** $column.columnComment */ + @Excel(name = "提现方式名称") + private String logo; + + /** 是否是银行卡提现方式;1 不是 2 是 */ + @Excel(name = "是否是银行卡提现方式;1 不是 2 是") + private Integer isBank; + + /** 1 */ + private Integer delFlag; + + /** $column.columnComment */ + @Excel(name = "是否是银行卡提现方式;1 不是 2 是") + private Integer sort; + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/pfwithdrawalway/service/PfWithdrawalWayService.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/pfwithdrawalway/service/PfWithdrawalWayService.java new file mode 100644 index 0000000..8a07908 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/pfwithdrawalway/service/PfWithdrawalWayService.java @@ -0,0 +1,70 @@ +package com.ruoyi.frequency.pfwithdrawalway.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.ruoyi.frequency.pfwithdrawalway.entity.PfWithdrawalWay; +import com.ruoyi.response.ResponseData; + +import java.util.List; + +/** + * 后台提现方式Service接口 + * + * @author liwenlong + * @date 2023-07-20 + */ +public interface PfWithdrawalWayService extends IService +{ + /** + * 查询后台提现方式 + * + * @param id 后台提现方式主键 + * @return 后台提现方式 + */ + PfWithdrawalWay selectPfWithdrawalWayById(Long id); + + /** + * 查询后台提现方式列表 + * + * @param pfWithdrawalWay 后台提现方式 + * @return 后台提现方式集合 + */ + List selectPfWithdrawalWayList(PfWithdrawalWay pfWithdrawalWay); + + /** + * 新增后台提现方式 + * + * @param pfWithdrawalWay 后台提现方式 + * @return 结果 + */ + int insertPfWithdrawalWay(PfWithdrawalWay pfWithdrawalWay); + + /** + * 修改后台提现方式 + * + * @param pfWithdrawalWay 后台提现方式 + * @return 结果 + */ + int updatePfWithdrawalWay(PfWithdrawalWay pfWithdrawalWay); + + /** + * 批量删除后台提现方式 + * + * @param ids 需要删除的后台提现方式主键集合 + * @return 结果 + */ + int deletePfWithdrawalWayByIds(Long[] ids); + + /** + * 删除后台提现方式信息 + * + * @param id 后台提现方式主键 + * @return 结果 + */ + int deletePfWithdrawalWayById(Long id); + + /** + * 查询平台提现配置列表 + * @return + */ + ResponseData pfList(); +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/pfwithdrawalway/service/impl/PfWithdrawalWayServiceImpl.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/pfwithdrawalway/service/impl/PfWithdrawalWayServiceImpl.java new file mode 100644 index 0000000..47eb76b --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/pfwithdrawalway/service/impl/PfWithdrawalWayServiceImpl.java @@ -0,0 +1,111 @@ +package com.ruoyi.frequency.pfwithdrawalway.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.ruoyi.code.PublicCommon; +import com.ruoyi.common.utils.DateUtils; +import com.ruoyi.frequency.pfwithdrawalway.entity.PfWithdrawalWay; +import com.ruoyi.frequency.pfwithdrawalway.mapper.PfWithdrawalWayMapper; +import com.ruoyi.frequency.pfwithdrawalway.service.PfWithdrawalWayService; +import com.ruoyi.response.ResponseData; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * 后台提现方式Service业务层处理 + * + * @author liwenlong + * @date 2023-07-20 + */ +@Service +public class PfWithdrawalWayServiceImpl extends ServiceImpl implements PfWithdrawalWayService +{ + @Autowired + private PfWithdrawalWayMapper pfWithdrawalWayMapper; + + /** + * 查询后台提现方式 + * + * @param id 后台提现方式主键 + * @return 后台提现方式 + */ + @Override + public PfWithdrawalWay selectPfWithdrawalWayById(Long id) + { + return pfWithdrawalWayMapper.selectPfWithdrawalWayById(id); + } + + /** + * 查询后台提现方式列表 + * + * @param pfWithdrawalWay 后台提现方式 + * @return 后台提现方式 + */ + @Override + public List selectPfWithdrawalWayList(PfWithdrawalWay pfWithdrawalWay) + { + return pfWithdrawalWayMapper.selectPfWithdrawalWayList(pfWithdrawalWay); + } + + /** + * 新增后台提现方式 + * + * @param pfWithdrawalWay 后台提现方式 + * @return 结果 + */ + @Override + public int insertPfWithdrawalWay(PfWithdrawalWay pfWithdrawalWay) + { + pfWithdrawalWay.setCreateTime(DateUtils.getNowDate()); + return pfWithdrawalWayMapper.insertPfWithdrawalWay(pfWithdrawalWay); + } + + /** + * 修改后台提现方式 + * + * @param pfWithdrawalWay 后台提现方式 + * @return 结果 + */ + @Override + public int updatePfWithdrawalWay(PfWithdrawalWay pfWithdrawalWay) + { + pfWithdrawalWay.setUpdateTime(DateUtils.getNowDate()); + return pfWithdrawalWayMapper.updatePfWithdrawalWay(pfWithdrawalWay); + } + + /** + * 批量删除后台提现方式 + * + * @param ids 需要删除的后台提现方式主键 + * @return 结果 + */ + @Override + public int deletePfWithdrawalWayByIds(Long[] ids) + { + return pfWithdrawalWayMapper.deletePfWithdrawalWayByIds(ids); + } + + /** + * 删除后台提现方式信息 + * + * @param id 后台提现方式主键 + * @return 结果 + */ + @Override + public int deletePfWithdrawalWayById(Long id) + { + return pfWithdrawalWayMapper.deletePfWithdrawalWayById(id); + } + + + @Override + public ResponseData pfList() { + List pfWithdrawalWays = this.list(new QueryWrapper().lambda(). + eq(PfWithdrawalWay::getDelFlag, PublicCommon.启用) + .orderByAsc(PfWithdrawalWay::getSort)); + + return ResponseData.success(pfWithdrawalWays); + } +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/platformrecord/controller/PlatformRecordController.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/platformrecord/controller/PlatformRecordController.java new file mode 100644 index 0000000..4a0921a --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/platformrecord/controller/PlatformRecordController.java @@ -0,0 +1,107 @@ +package com.ruoyi.frequency.platformrecord.controller; + +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.page.TableDataInfo; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.common.utils.poi.ExcelUtil; +import com.ruoyi.frequency.platformrecord.entity.PlatformRecord; +import com.ruoyi.frequency.platformrecord.model.result.PlatformRecordCount; +import com.ruoyi.frequency.platformrecord.service.PlatformRecordService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +/** + * 平台流水记录Controller + * + * @author liwenlong + * @date 2023-12-01 + */ +@RestController +@RequestMapping("/frequency/platformrecord") +public class PlatformRecordController extends BaseController +{ + @Autowired + private PlatformRecordService platformRecordService; + + /** + * 查询平台流水记录列表 + */ + //@PreAuthorize("@ss.hasPermi('frequency:platformrecord:list')") + @PostMapping("/list") + public TableDataInfo list(@RequestBody PlatformRecord platformRecord) + { + startPage(); + List list = platformRecordService.selectPlatformRecordList(platformRecord); + return getDataTable(list); + } + + /** + * 统计 + */ + @PostMapping("/statistics") + public AjaxResult statistics(@RequestBody PlatformRecord platformRecord) + { + PlatformRecordCount count = platformRecordService.statistics(platformRecord); + return AjaxResult.success(count); + } + + /** + * 导出平台流水记录列表 + */ + //@PreAuthorize("@ss.hasPermi('frequency:platformrecord:export')") + @Log(title = "平台流水记录", businessType = BusinessType.EXPORT) + @GetMapping("/export") + public AjaxResult export(PlatformRecord platformRecord) + { + List list = platformRecordService.selectPlatformRecordList(platformRecord); + ExcelUtil util = new ExcelUtil(PlatformRecord.class); + return util.exportExcel(list, "平台流水记录数据"); + } + + /** + * 获取平台流水记录详细信息 + */ + //@PreAuthorize("@ss.hasPermi('frequency:platformrecord:query')") + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") Long id) + { + return AjaxResult.success(platformRecordService.selectPlatformRecordById(id)); + } + + /** + * 新增平台流水记录 + */ + //@PreAuthorize("@ss.hasPermi('frequency:platformrecord:add')") + @Log(title = "平台流水记录", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody PlatformRecord platformRecord) + { + return toAjax(platformRecordService.insertPlatformRecord(platformRecord)); + } + + /** + * 修改平台流水记录 + */ + //@PreAuthorize("@ss.hasPermi('frequency:platformrecord:edit')") + @Log(title = "平台流水记录", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody PlatformRecord platformRecord) + { + return toAjax(platformRecordService.updatePlatformRecord(platformRecord)); + } + + /** + * 删除平台流水记录 + */ + //@PreAuthorize("@ss.hasPermi('frequency:platformrecord:remove')") + @Log(title = "平台流水记录", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}/{delFlag}") + public AjaxResult remove(@PathVariable("ids") Long[] ids,@PathVariable("delFlag") Integer delFlag) + { + return toAjax(platformRecordService.deletePlatformRecordByIds(ids,delFlag)); + } +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/platformrecord/entity/PlatformRecord.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/platformrecord/entity/PlatformRecord.java new file mode 100644 index 0000000..bc76d4b --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/platformrecord/entity/PlatformRecord.java @@ -0,0 +1,81 @@ +package com.ruoyi.frequency.platformrecord.entity; + +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableName; +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import com.ruoyi.vo.UserInfo; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; + +import java.math.BigDecimal; +import java.util.Date; + +/** + * 平台流水记录对象 t_platform_record + * + * @author liwenlong + * @date 2023-12-01 + */ +@Data +@Accessors(chain = true) +@TableName("t_platform_record") +public class PlatformRecord extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + + @ApiModelProperty("主键id") + private Long id; + + @ApiModelProperty("删除标志 1正常 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("数值") + @Excel(name = "数值") + private BigDecimal price; + + @ApiModelProperty("主体id") + @Excel(name = "主体id") + private Long objectId; + + @ApiModelProperty("来源类型") + @Excel(name = "来源类型") + private Integer objectType; + + @ApiModelProperty("交易用户") + @Excel(name = "交易用户") + private Long userId; + + @ApiModelProperty("交易用户类型") + @Excel(name = "交易用户类型") + private Integer userType; + + @ApiModelProperty("余额") + @Excel(name = "余额") + private BigDecimal balance; + + @ApiModelProperty("入账前余额") + @Excel(name = "入账前余额") + private BigDecimal beforeBalance; + + @ApiModelProperty("用户信息") + @TableField(exist = false) + private UserInfo userInfo; + + @ApiModelProperty("类型") + private String objectTypeName; + + @ApiModelProperty("类型") + @TableField(exist = false) + private Integer type; + + @ApiModelProperty("开始时间") + @TableField(exist = false) + private Date beginTime; + + @ApiModelProperty("结束时间") + @TableField(exist = false) + private Date endTime; +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/platformrecord/mapper/PlatformRecordMapper.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/platformrecord/mapper/PlatformRecordMapper.java new file mode 100644 index 0000000..5ab8764 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/platformrecord/mapper/PlatformRecordMapper.java @@ -0,0 +1,53 @@ +package com.ruoyi.frequency.platformrecord.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.ruoyi.frequency.platformrecord.entity.PlatformRecord; +import com.ruoyi.frequency.platformrecord.model.result.PlatformRecordCount; +import org.apache.ibatis.annotations.Param; + +import java.math.BigDecimal; +import java.util.List; + +/** + * 平台流水记录Mapper接口 + * + * @author liwenlong + * @date 2023-12-01 + */ +public interface PlatformRecordMapper extends BaseMapper { + /** + * 查询平台流水记录 + * + * @param id 平台流水记录主键 + * @return 平台流水记录 + */ + public PlatformRecord selectPlatformRecordById(Long id); + + /** + * 查询平台流水记录列表 + * + * @param platformRecord 平台流水记录 + * @return 平台流水记录集合 + */ + public List selectPlatformRecordList(PlatformRecord platformRecord); + + /** + * 新增平台流水记录 + * + * @param platformRecord 平台流水记录 + * @return 结果 + */ + public int insertPlatformRecord(PlatformRecord platformRecord); + + /** + * 修改平台流水记录 + * + * @param platformRecord 平台流水记录 + * @return 结果 + */ + public int updatePlatformRecord(PlatformRecord platformRecord); + + BigDecimal platformAmountCount(); + + PlatformRecordCount statistics(@Param("list") List platformRecordList); +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/platformrecord/mapper/mapping/PlatformRecordMapper.xml b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/platformrecord/mapper/mapping/PlatformRecordMapper.xml new file mode 100644 index 0000000..8fddb90 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/platformrecord/mapper/mapping/PlatformRecordMapper.xml @@ -0,0 +1,166 @@ + + + + + + + + + + + + + + + + + + + + + + select + t.id , + t.create_by , + t.create_time , + t.update_by , + t.update_time , + t.del_flag , + t.price , + t.object_id , + t.object_type , + t.user_id , + t.user_type , + t.balance , + t.before_balance + from t_platform_record AS t + LEFT JOIN t_store s on t.user_id = s.id + LEFT JOIN t_customer c on t.user_id = c.id + LEFT JOIN t_sale sa on t.user_id = sa.id + + + + + + + + + + insert into t_platform_record + + id, + create_by, + create_time, + update_by, + update_time, + del_flag, + price, + object_id, + object_type, + user_id, + user_type, + balance, + before_balance, + + + #{id}, + #{createBy}, + #{createTime}, + #{updateBy}, + #{updateTime}, + #{delFlag}, + #{price}, + #{objectId}, + #{objectType}, + #{userId}, + #{userType}, + #{balance}, + #{beforeBalance}, + + + + + update t_platform_record + + create_by = #{createBy}, + create_time = #{createTime}, + update_by = #{updateBy}, + update_time = #{updateTime}, + del_flag = #{delFlag}, + price = #{price}, + object_id = #{objectId}, + object_type = #{objectType}, + user_id = #{userId}, + user_type = #{userType}, + balance = #{balance}, + before_balance = #{beforeBalance}, + + where id = #{id} + + + + + diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/platformrecord/model/param/PlatformRecordParam.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/platformrecord/model/param/PlatformRecordParam.java new file mode 100644 index 0000000..78b1122 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/platformrecord/model/param/PlatformRecordParam.java @@ -0,0 +1,67 @@ +package com.ruoyi.frequency.platformrecord.model.param; + +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; + +import java.math.BigDecimal; + +/** + * 平台流水记录对象 t_platform_record + * + * @author liwenlong + * @date 2023-12-01 + */ +@Data +@Accessors(chain = true) +public class PlatformRecordParam extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + @ApiModelProperty("主键id") + private Long id; + + @ApiModelProperty("删除标志 1正常 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("数值") + @Excel(name = "数值") + private BigDecimal price; + + @ApiModelProperty("主体id") + @Excel(name = "主体id") + private Long objectId; + + @ApiModelProperty("来源类型") + @Excel(name = "来源类型") + private Integer objectType; + + @ApiModelProperty("交易用户") + @Excel(name = "交易用户") + private Long userId; + + @ApiModelProperty("交易用户类型") + @Excel(name = "交易用户类型") + private Integer userType; + + @ApiModelProperty("余额") + @Excel(name = "余额") + private BigDecimal balance; + + @ApiModelProperty("入账前余额") + @Excel(name = "入账前余额") + private BigDecimal beforeBalance; + + + + + + + + + + + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/platformrecord/model/result/PlatformRecordCount.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/platformrecord/model/result/PlatformRecordCount.java new file mode 100644 index 0000000..43fa50d --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/platformrecord/model/result/PlatformRecordCount.java @@ -0,0 +1,19 @@ +package com.ruoyi.frequency.platformrecord.model.result; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.math.BigDecimal; + +/** + * @author a + * @date 2024/2/22 14:46 + */ +@Data +public class PlatformRecordCount { + + @ApiModelProperty("总金额") + private BigDecimal price; + + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/platformrecord/model/result/PlatformRecordResult.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/platformrecord/model/result/PlatformRecordResult.java new file mode 100644 index 0000000..2f3a910 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/platformrecord/model/result/PlatformRecordResult.java @@ -0,0 +1,58 @@ +package com.ruoyi.frequency.platformrecord.model.result; + +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; + +import java.math.BigDecimal; + +/** + * 平台流水记录对象 t_platform_record + * + * @author liwenlong + * @date 2023-12-01 + */ +@Data +@Accessors(chain = true) +public class PlatformRecordResult extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + @ApiModelProperty("主键id") + private Long id; + + @ApiModelProperty("删除标志 1正常 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("数值") + @Excel(name = "数值") + private BigDecimal price; + + @ApiModelProperty("主体id") + @Excel(name = "主体id") + private Long objectId; + + @ApiModelProperty("来源类型") + @Excel(name = "来源类型") + private Integer objectType; + + @ApiModelProperty("交易用户") + @Excel(name = "交易用户") + private Long userId; + + @ApiModelProperty("交易用户类型") + @Excel(name = "交易用户类型") + private Integer userType; + + @ApiModelProperty("余额") + @Excel(name = "余额") + private BigDecimal balance; + + @ApiModelProperty("入账前余额") + @Excel(name = "入账前余额") + private BigDecimal beforeBalance; + + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/platformrecord/service/PlatformRecordService.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/platformrecord/service/PlatformRecordService.java new file mode 100644 index 0000000..9deb3ea --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/platformrecord/service/PlatformRecordService.java @@ -0,0 +1,64 @@ +package com.ruoyi.frequency.platformrecord.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.ruoyi.enums.PlatformRecordEnums; +import com.ruoyi.frequency.platformrecord.entity.PlatformRecord; +import com.ruoyi.frequency.platformrecord.model.result.PlatformRecordCount; +import com.ruoyi.vo.UserVo; + +import java.math.BigDecimal; +import java.util.List; + +/** + * 平台流水记录Service接口 + * + * @author liwenlong + * @date 2023-12-01 + */ +public interface PlatformRecordService extends IService +{ + /** + * 查询平台流水记录 + * + * @param id 平台流水记录主键 + * @return 平台流水记录 + */ + public PlatformRecord selectPlatformRecordById(Long id); + + /** + * 查询平台流水记录列表 + * + * @param platformRecord 平台流水记录 + * @return 平台流水记录集合 + */ + public List selectPlatformRecordList(PlatformRecord platformRecord); + + PlatformRecordCount statistics(PlatformRecord platformRecord); + + /** + * 新增平台流水记录 + * + * @param platformRecord 平台流水记录 + * @return 结果 + */ + public int insertPlatformRecord(PlatformRecord platformRecord); + + /** + * 修改平台流水记录 + * + * @param platformRecord 平台流水记录 + * @return 结果 + */ + public int updatePlatformRecord(PlatformRecord platformRecord); + + /** + * 批量删除平台流水记录 + * + * @param ids 需要删除的平台流水记录主键集合 + * @return 结果 + */ + public int deletePlatformRecordByIds(Long[] ids,Integer delFlag); + + void addPlatformRecord(UserVo userVo, Long objectId, BigDecimal price, PlatformRecordEnums enums); + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/platformrecord/service/impl/PlatformRecordServiceImpl.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/platformrecord/service/impl/PlatformRecordServiceImpl.java new file mode 100644 index 0000000..7d2b6c1 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/platformrecord/service/impl/PlatformRecordServiceImpl.java @@ -0,0 +1,148 @@ +package com.ruoyi.frequency.platformrecord.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.ruoyi.enums.PlatformRecordEnums; +import com.ruoyi.frequency.customer.service.UserService; +import com.ruoyi.frequency.platformrecord.entity.PlatformRecord; +import com.ruoyi.frequency.platformrecord.mapper.PlatformRecordMapper; +import com.ruoyi.frequency.platformrecord.model.result.PlatformRecordCount; +import com.ruoyi.frequency.platformrecord.service.PlatformRecordService; +import com.ruoyi.vo.UserInfo; +import com.ruoyi.vo.UserVo; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.math.BigDecimal; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.stream.Collectors; + +/** + * 平台流水记录Service业务层处理 + * + * @author liwenlong + * @date 2023-12-01 + */ +@Service +public class PlatformRecordServiceImpl extends ServiceImpl implements PlatformRecordService +{ + @Autowired + private PlatformRecordMapper platformRecordMapper; + + /** + * 查询平台流水记录 + * + * @param id 平台流水记录主键 + * @return 平台流水记录 + */ + @Override + public PlatformRecord selectPlatformRecordById(Long id) + { + return platformRecordMapper.selectPlatformRecordById(id); + } + + @Autowired + private UserService userService; + + /** + * 查询平台流水记录列表 + * + * @param platformRecord 平台流水记录 + * @return 平台流水记录 + */ + @Override + public List selectPlatformRecordList(PlatformRecord platformRecord) + { + + List platformRecords = platformRecordList(platformRecord); + + if (platformRecords.size() > 0){ + + Set userVoSet = platformRecords.stream().map(s -> new UserVo(s.getUserType(), s.getUserId())).collect(Collectors.toSet()); + //查询用户信息 + Map userMap = userService.selectUserInfoMap(userVoSet,null); + + platformRecords.stream().forEach(s->{ + s.setObjectTypeName(PlatformRecordEnums.getName(s.getObjectType())); + s.setUserInfo(userMap.get(new UserVo(s.getUserType(), s.getUserId()))); + }); + } + + return platformRecords; + } + + private List platformRecordList(PlatformRecord platformRecord){ + List platformRecords = platformRecordMapper.selectPlatformRecordList(platformRecord); + return platformRecords; + } + + @Override + public PlatformRecordCount statistics(PlatformRecord platformRecord) { + List platformRecords = platformRecordList(platformRecord); + List platformRecordList = platformRecords.stream().map(x -> x.getId()).collect(Collectors.toList()); + platformRecordList.add(-1L); + + return platformRecordMapper.statistics(platformRecordList); + } + + /** + * 新增平台流水记录 + * + * @param platformRecord 平台流水记录 + * @return 结果 + */ + @Override + public int insertPlatformRecord(PlatformRecord platformRecord) + { + platformRecord.setCreateData(); + return platformRecordMapper.insert(platformRecord); + } + + /** + * 修改平台流水记录 + * + * @param platformRecord 平台流水记录 + * @return 结果 + */ + @Override + public int updatePlatformRecord(PlatformRecord platformRecord) + { + platformRecord.setUpdateData(); + return platformRecordMapper.updatePlatformRecord(platformRecord); + } + + /** + * 批量删除平台流水记录 + * + * @param ids 需要删除的平台流水记录主键 + * @return 结果 + */ + @Override + public int deletePlatformRecordByIds(Long[] ids,Integer delFlag) + { + this.lambdaUpdate().set(PlatformRecord::getDelFlag,delFlag).in(PlatformRecord::getId,ids).update(); + return ids.length; + } + + @Override + public void addPlatformRecord(UserVo userVo, Long objectId, BigDecimal price, PlatformRecordEnums enums) { + if (price.setScale(2, BigDecimal.ROUND_HALF_UP).compareTo(new BigDecimal(0)) != 0) { + + PlatformRecord platformRecord = new PlatformRecord() + .setObjectId(objectId) + .setUserType(userVo.getUserType()) + .setUserId(userVo.getUserId()) + .setPrice(price) + .setObjectType(enums.getCode()); + + //获取平台资金池金额 + BigDecimal balance = platformRecordMapper.platformAmountCount(); + platformRecord.setBeforeBalance(balance); + platformRecord.setBalance(balance.add(price)); + + this.save(platformRecord); + } + } + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/rechargecoin/controller/RechargeCoinController.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/rechargecoin/controller/RechargeCoinController.java new file mode 100644 index 0000000..6e954c0 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/rechargecoin/controller/RechargeCoinController.java @@ -0,0 +1,97 @@ +package com.ruoyi.frequency.rechargecoin.controller; + +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.page.TableDataInfo; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.common.utils.poi.ExcelUtil; +import com.ruoyi.frequency.rechargecoin.entity.RechargeCoin; +import com.ruoyi.frequency.rechargecoin.service.RechargeCoinService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +/** + * 充值包Controller + * + * @author liwenlong + * @date 2023-10-25 + */ +@RestController +@RequestMapping("/frequency/rechargecoin") +public class RechargeCoinController extends BaseController +{ + @Autowired + private RechargeCoinService rechargeCoinService; + + /** + * 查询充值包列表 + */ + @PreAuthorize("@ss.hasPermi('frequency:rechargecoin:list')") + @PostMapping("/list") + public TableDataInfo list(@RequestBody RechargeCoin rechargeCoin) + { + startPage(); + List list = rechargeCoinService.selectRechargeCoinList(rechargeCoin); + return getDataTable(list); + } + + /** + * 导出充值包列表 + */ + @PreAuthorize("@ss.hasPermi('frequency:rechargecoin:export')") + @Log(title = "充值包", businessType = BusinessType.EXPORT) + @GetMapping("/export") + public AjaxResult export(RechargeCoin rechargeCoin) + { + List list = rechargeCoinService.selectRechargeCoinList(rechargeCoin); + ExcelUtil util = new ExcelUtil(RechargeCoin.class); + return util.exportExcel(list, "充值包数据"); + } + + /** + * 获取充值包详细信息 + */ + @PreAuthorize("@ss.hasPermi('frequency:rechargecoin:query')") + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") String id) + { + return AjaxResult.success(rechargeCoinService.selectRechargeCoinById(id)); + } + + /** + * 新增充值包 + */ + @PreAuthorize("@ss.hasPermi('frequency:rechargecoin:add')") + @Log(title = "充值包", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody RechargeCoin rechargeCoin) + { + return toAjax(rechargeCoinService.insertRechargeCoin(rechargeCoin)); + } + + /** + * 修改充值包 + */ + @PreAuthorize("@ss.hasPermi('frequency:rechargecoin:edit')") + @Log(title = "充值包", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody RechargeCoin rechargeCoin) + { + return toAjax(rechargeCoinService.updateRechargeCoin(rechargeCoin)); + } + + /** + * 删除充值包 + */ + @PreAuthorize("@ss.hasPermi('frequency:rechargecoin:remove')") + @Log(title = "充值包", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}/{delFlag}") + public AjaxResult remove(@PathVariable("ids") String[] ids,@PathVariable("delFlag") Integer delFlag) + { + return toAjax(rechargeCoinService.deleteRechargeCoinByIds(ids,delFlag)); + } +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/rechargecoin/entity/RechargeCoin.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/rechargecoin/entity/RechargeCoin.java new file mode 100644 index 0000000..83685bd --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/rechargecoin/entity/RechargeCoin.java @@ -0,0 +1,45 @@ +package com.ruoyi.frequency.rechargecoin.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; + +import java.math.BigDecimal; + +/** + * 充值包对象 t_recharge_coin + * + * @author liwenlong + * @date 2023-10-25 + */ +@Data +@Accessors(chain = true) +@TableName("t_recharge_coin") +public class RechargeCoin extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + + @ApiModelProperty("主键id") + private String id; + + @ApiModelProperty("删除标志 1正常 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("金币") + @Excel(name = "金币") + private BigDecimal coin; + + @ApiModelProperty("价格") + @Excel(name = "价格") + private BigDecimal price; + + @ApiModelProperty("1安卓 2 苹果") + @Excel(name = "1安卓 2 苹果") + private Integer phoneType; + + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/rechargecoin/mapper/RechargeCoinMapper.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/rechargecoin/mapper/RechargeCoinMapper.java new file mode 100644 index 0000000..d656805 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/rechargecoin/mapper/RechargeCoinMapper.java @@ -0,0 +1,63 @@ +package com.ruoyi.frequency.rechargecoin.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.ruoyi.frequency.rechargecoin.entity.RechargeCoin; + +import java.util.List; + +/** + * 充值包Mapper接口 + * + * @author liwenlong + * @date 2023-10-25 + */ +public interface RechargeCoinMapper extends BaseMapper +{ + /** + * 查询充值包 + * + * @param id 充值包主键 + * @return 充值包 + */ + public RechargeCoin selectRechargeCoinById(String id); + + /** + * 查询充值包列表 + * + * @param rechargeCoin 充值包 + * @return 充值包集合 + */ + public List selectRechargeCoinList(RechargeCoin rechargeCoin); + + /** + * 新增充值包 + * + * @param rechargeCoin 充值包 + * @return 结果 + */ + public int insertRechargeCoin(RechargeCoin rechargeCoin); + + /** + * 修改充值包 + * + * @param rechargeCoin 充值包 + * @return 结果 + */ + public int updateRechargeCoin(RechargeCoin rechargeCoin); + + /** + * 删除充值包 + * + * @param id 充值包主键 + * @return 结果 + */ + public int deleteRechargeCoinById(String id); + + /** + * 批量删除充值包 + * + * @param ids 需要删除的数据主键集合 + * @return 结果 + */ + public int deleteRechargeCoinByIds(String[] ids); +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/rechargecoin/mapper/mapping/RechargeCoinMapper.xml b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/rechargecoin/mapper/mapping/RechargeCoinMapper.xml new file mode 100644 index 0000000..42cab16 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/rechargecoin/mapper/mapping/RechargeCoinMapper.xml @@ -0,0 +1,89 @@ + + + + + + + + + + + + + + + + + + select id, create_by, create_time, update_by, update_time, del_flag, coin, price, phone_type from t_recharge_coin + + + + + + + + insert into t_recharge_coin + + id, + create_by, + create_time, + update_by, + update_time, + del_flag, + coin, + price, + phone_type, + + + #{id}, + #{createBy}, + #{createTime}, + #{updateBy}, + #{updateTime}, + #{delFlag}, + #{coin}, + #{price}, + #{phoneType}, + + + + + update t_recharge_coin + + create_by = #{createBy}, + create_time = #{createTime}, + update_by = #{updateBy}, + update_time = #{updateTime}, + del_flag = #{delFlag}, + coin = #{coin}, + price = #{price}, + phone_type = #{phoneType}, + + where id = #{id} + + + + delete from t_recharge_coin where id = #{id} + + + + delete from t_recharge_coin where id in + + #{id} + + + \ No newline at end of file diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/rechargecoin/model/param/RechargeCoinParam.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/rechargecoin/model/param/RechargeCoinParam.java new file mode 100644 index 0000000..756b303 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/rechargecoin/model/param/RechargeCoinParam.java @@ -0,0 +1,47 @@ +package com.ruoyi.frequency.rechargecoin.model.param; + +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; + +import java.math.BigDecimal; + +/** + * 充值包对象 t_recharge_coin + * + * @author liwenlong + * @date 2023-10-25 + */ +@Data +@Accessors(chain = true) +public class RechargeCoinParam extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + @ApiModelProperty("主键id") + private String id; + + @ApiModelProperty("删除标志 1正常 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("金币") + @Excel(name = "金币") + private BigDecimal coin; + + @ApiModelProperty("价格") + @Excel(name = "价格") + private BigDecimal price; + + @ApiModelProperty("1安卓 2 苹果") + @Excel(name = "1安卓 2 苹果") + private Integer phoneType; + + + + + + + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/rechargecoin/model/result/RechargeCoinResult.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/rechargecoin/model/result/RechargeCoinResult.java new file mode 100644 index 0000000..1d259c3 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/rechargecoin/model/result/RechargeCoinResult.java @@ -0,0 +1,42 @@ +package com.ruoyi.frequency.rechargecoin.model.result; + +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; + +import java.math.BigDecimal; + +/** + * 充值包对象 t_recharge_coin + * + * @author liwenlong + * @date 2023-10-25 + */ +@Data +@Accessors(chain = true) +public class RechargeCoinResult extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + @ApiModelProperty("主键id") + private String id; + + @ApiModelProperty("删除标志 1正常 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("金币") + @Excel(name = "金币") + private BigDecimal coin; + + @ApiModelProperty("价格") + @Excel(name = "价格") + private BigDecimal price; + + @ApiModelProperty("1安卓 2 苹果") + @Excel(name = "1安卓 2 苹果") + private Integer phoneType; + + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/rechargecoin/service/RechargeCoinService.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/rechargecoin/service/RechargeCoinService.java new file mode 100644 index 0000000..8fdd32a --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/rechargecoin/service/RechargeCoinService.java @@ -0,0 +1,63 @@ +package com.ruoyi.frequency.rechargecoin.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.ruoyi.frequency.rechargecoin.entity.RechargeCoin; + +import java.util.List; + +/** + * 充值包Service接口 + * + * @author liwenlong + * @date 2023-10-25 + */ +public interface RechargeCoinService extends IService +{ + /** + * 查询充值包 + * + * @param id 充值包主键 + * @return 充值包 + */ + public RechargeCoin selectRechargeCoinById(String id); + + /** + * 查询充值包列表 + * + * @param rechargeCoin 充值包 + * @return 充值包集合 + */ + public List selectRechargeCoinList(RechargeCoin rechargeCoin); + + /** + * 新增充值包 + * + * @param rechargeCoin 充值包 + * @return 结果 + */ + public int insertRechargeCoin(RechargeCoin rechargeCoin); + + /** + * 修改充值包 + * + * @param rechargeCoin 充值包 + * @return 结果 + */ + public int updateRechargeCoin(RechargeCoin rechargeCoin); + + /** + * 批量删除充值包 + * + * @param ids 需要删除的充值包主键集合 + * @return 结果 + */ + public int deleteRechargeCoinByIds(String[] ids,Integer delFlag); + + /** + * 删除充值包信息 + * + * @param id 充值包主键 + * @return 结果 + */ + public int deleteRechargeCoinById(String id); +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/rechargecoin/service/impl/RechargeCoinServiceImpl.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/rechargecoin/service/impl/RechargeCoinServiceImpl.java new file mode 100644 index 0000000..4dff7de --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/rechargecoin/service/impl/RechargeCoinServiceImpl.java @@ -0,0 +1,103 @@ +package com.ruoyi.frequency.rechargecoin.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.ruoyi.code.PublicCommon; +import com.ruoyi.common.utils.DateUtils; +import com.ruoyi.frequency.rechargecoin.entity.RechargeCoin; +import com.ruoyi.frequency.rechargecoin.mapper.RechargeCoinMapper; +import com.ruoyi.frequency.rechargecoin.service.RechargeCoinService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.List; + +/** + * 充值包Service业务层处理 + * + * @author liwenlong + * @date 2023-10-25 + */ +@Service +@Transactional(rollbackFor = Exception.class) +public class RechargeCoinServiceImpl extends ServiceImpl implements RechargeCoinService +{ + @Autowired + private RechargeCoinMapper rechargeCoinMapper; + + /** + * 查询充值包 + * + * @param id 充值包主键 + * @return 充值包 + */ + @Override + public RechargeCoin selectRechargeCoinById(String id) + { + return rechargeCoinMapper.selectRechargeCoinById(id); + } + + /** + * 查询充值包列表 + * + * @param rechargeCoin 充值包 + * @return 充值包 + */ + @Override + public List selectRechargeCoinList(RechargeCoin rechargeCoin) + { + return rechargeCoinMapper.selectRechargeCoinList(rechargeCoin); + } + + /** + * 新增充值包 + * + * @param rechargeCoin 充值包 + * @return 结果 + */ + @Override + public int insertRechargeCoin(RechargeCoin rechargeCoin) + { + rechargeCoin.setCreateTime(DateUtils.getNowDate()); + return rechargeCoinMapper.insert(rechargeCoin); + } + + /** + * 修改充值包 + * + * @param rechargeCoin 充值包 + * @return 结果 + */ + @Override + public int updateRechargeCoin(RechargeCoin rechargeCoin) + { + rechargeCoin.setUpdateTime(DateUtils.getNowDate()); + return rechargeCoinMapper.updateById(rechargeCoin); + } + + /** + * 批量删除充值包 + * + * @param ids 需要删除的充值包主键 + * @return 结果 + */ + @Override + public int deleteRechargeCoinByIds(String[] ids,Integer delFlag) + { + this.lambdaUpdate().set(RechargeCoin::getDelFlag,delFlag).in(RechargeCoin::getId,ids).update(); + return ids.length; + } + + /** + * 删除充值包信息 + * + * @param id 充值包主键 + * @return 结果 + */ + @Override + public int deleteRechargeCoinById(String id) + { + this.lambdaUpdate().set(RechargeCoin::getDelFlag,PublicCommon.删除).eq(RechargeCoin::getId,id).update(); + return 1; + } +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/rechargeorder/controller/RechargeOrderController.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/rechargeorder/controller/RechargeOrderController.java new file mode 100644 index 0000000..ce3f39f --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/rechargeorder/controller/RechargeOrderController.java @@ -0,0 +1,108 @@ +package com.ruoyi.frequency.rechargeorder.controller; + +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.page.TableDataInfo; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.common.utils.poi.ExcelUtil; +import com.ruoyi.frequency.rechargeorder.entity.RechargeOrder; +import com.ruoyi.frequency.rechargeorder.model.result.RechargeOrderCount; +import com.ruoyi.frequency.rechargeorder.service.RechargeOrderService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +/** + * 充值余额订单Controller + * + * @author liwenlong + * @date 2023-10-25 + */ +@RestController +@RequestMapping("/frequency/rechargeorder") +public class RechargeOrderController extends BaseController +{ + @Autowired + private RechargeOrderService rechargeOrderService; + + /** + * 查询充值余额订单列表 + */ + @PreAuthorize("@ss.hasPermi('frequency:rechargeorder:list')") + @PostMapping("/list") + public TableDataInfo list(@RequestBody RechargeOrder rechargeOrder) + { + startPage(); + List list = rechargeOrderService.selectRechargeOrderList(rechargeOrder); + return getDataTable(list); + } + + /** + * 统计 + */ + @PostMapping("/statistics") + public AjaxResult statistics(@RequestBody RechargeOrder rechargeOrder) + { + RechargeOrderCount count = rechargeOrderService.statistics(rechargeOrder); + return AjaxResult.success(count); + } + + /** + * 导出充值余额订单列表 + */ + @PreAuthorize("@ss.hasPermi('frequency:rechargeorder:export')") + @Log(title = "充值余额订单", businessType = BusinessType.EXPORT) + @GetMapping("/export") + public AjaxResult export(RechargeOrder rechargeOrder) + { + List list = rechargeOrderService.selectRechargeOrderList(rechargeOrder); + ExcelUtil util = new ExcelUtil(RechargeOrder.class); + return util.exportExcel(list, "充值余额订单数据"); + } + + /** + * 获取充值余额订单详细信息 + */ + @PreAuthorize("@ss.hasPermi('frequency:rechargeorder:query')") + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") Long id) + { + return AjaxResult.success(rechargeOrderService.selectRechargeOrderById(id)); + } + + /** + * 新增充值余额订单 + */ + @PreAuthorize("@ss.hasPermi('frequency:rechargeorder:add')") + @Log(title = "充值余额订单", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody RechargeOrder rechargeOrder) + { + return toAjax(rechargeOrderService.insertRechargeOrder(rechargeOrder)); + } + + /** + * 修改充值余额订单 + */ + @PreAuthorize("@ss.hasPermi('frequency:rechargeorder:edit')") + @Log(title = "充值余额订单", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody RechargeOrder rechargeOrder) + { + return toAjax(rechargeOrderService.updateRechargeOrder(rechargeOrder)); + } + + /** + * 删除充值余额订单 + */ + @PreAuthorize("@ss.hasPermi('frequency:rechargeorder:remove')") + @Log(title = "充值余额订单", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}") + public AjaxResult remove(@PathVariable Long[] ids) + { + return toAjax(rechargeOrderService.deleteRechargeOrderByIds(ids)); + } +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/rechargeorder/entity/RechargeOrder.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/rechargeorder/entity/RechargeOrder.java new file mode 100644 index 0000000..05a76bf --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/rechargeorder/entity/RechargeOrder.java @@ -0,0 +1,74 @@ +package com.ruoyi.frequency.rechargeorder.entity; + +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableName; +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import com.ruoyi.vo.UserInfo; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; + +import java.math.BigDecimal; +import java.util.Date; + +/** + * 充值余额订单对象 t_recharge_order + * + * @author liwenlong + * @date 2023-10-25 + */ +@Data +@Accessors(chain = true) +@TableName("t_recharge_order") +public class RechargeOrder extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + + @ApiModelProperty("主键id") + private Long id; + + @ApiModelProperty("删除标志 1正常 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("用户id") + @Excel(name = "用户id") + private Long customerId; + + @ApiModelProperty("充值金额") + @Excel(name = "充值金额") + private BigDecimal price; + + @ApiModelProperty("支付订单号") + @Excel(name = "支付订单号") + private String orderNo; + + @ApiModelProperty("支付方式 1 支付宝 2 微信 3 余额") + @Excel(name = "支付方式 1 支付宝 2 微信 3 余额") + private Integer payType; + + @ApiModelProperty("1待支付 2 支付成功 3 支付失败") + @Excel(name = "1待支付 2 支付成功 3 支付失败") + private Integer payStatus; + + @ApiModelProperty("支付宝支付订单号") + @Excel(name = "支付宝支付订单号") + private String aliPayOrder; + + @ApiModelProperty("支付金额") + @Excel(name = "支付金额") + private BigDecimal payPrice; + + @ApiModelProperty("用户信息") + @TableField(exist = false) + private UserInfo userInfo; + + @ApiModelProperty("开始时间") + @TableField(exist = false) + private Date beginTime; + + @ApiModelProperty("结束时间") + @TableField(exist = false) + private Date endTime; +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/rechargeorder/mapper/RechargeOrderMapper.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/rechargeorder/mapper/RechargeOrderMapper.java new file mode 100644 index 0000000..a57f089 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/rechargeorder/mapper/RechargeOrderMapper.java @@ -0,0 +1,67 @@ +package com.ruoyi.frequency.rechargeorder.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.ruoyi.frequency.rechargeorder.entity.RechargeOrder; +import com.ruoyi.frequency.rechargeorder.model.result.RechargeOrderCount; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * 充值余额订单Mapper接口 + * + * @author liwenlong + * @date 2023-10-25 + */ +public interface RechargeOrderMapper extends BaseMapper +{ + /** + * 查询充值余额订单 + * + * @param id 充值余额订单主键 + * @return 充值余额订单 + */ + public RechargeOrder selectRechargeOrderById(Long id); + + /** + * 查询充值余额订单列表 + * + * @param rechargeOrder 充值余额订单 + * @return 充值余额订单集合 + */ + public List selectRechargeOrderList(RechargeOrder rechargeOrder); + + /** + * 新增充值余额订单 + * + * @param rechargeOrder 充值余额订单 + * @return 结果 + */ + public int insertRechargeOrder(RechargeOrder rechargeOrder); + + /** + * 修改充值余额订单 + * + * @param rechargeOrder 充值余额订单 + * @return 结果 + */ + public int updateRechargeOrder(RechargeOrder rechargeOrder); + + /** + * 删除充值余额订单 + * + * @param id 充值余额订单主键 + * @return 结果 + */ + public int deleteRechargeOrderById(Long id); + + /** + * 批量删除充值余额订单 + * + * @param ids 需要删除的数据主键集合 + * @return 结果 + */ + public int deleteRechargeOrderByIds(Long[] ids); + + RechargeOrderCount statistics(@Param("list") List rechargeOrderIdList ); +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/rechargeorder/mapper/mapping/RechargeOrderMapper.xml b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/rechargeorder/mapper/mapping/RechargeOrderMapper.xml new file mode 100644 index 0000000..0e61a10 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/rechargeorder/mapper/mapping/RechargeOrderMapper.xml @@ -0,0 +1,152 @@ + + + + + + + + + + + + + + + + + + + + + + SELECT + t.id, + t.create_by, + t.create_time, + t.update_by, + t.update_time, + t.del_flag, + t.customer_id, + t.price, + t.order_no, + t.pay_type, + t.pay_status, + t.ali_pay_order, + t.pay_price + FROM + t_recharge_order AS t + LEFT JOIN t_customer AS c ON t.customer_id = c.id + + + + + + + + + + insert into t_recharge_order + + id, + create_by, + create_time, + update_by, + update_time, + del_flag, + customer_id, + price, + order_no, + pay_type, + pay_status, + ali_pay_order, + pay_price, + + + #{id}, + #{createBy}, + #{createTime}, + #{updateBy}, + #{updateTime}, + #{delFlag}, + #{customerId}, + #{price}, + #{orderNo}, + #{payType}, + #{payStatus}, + #{aliPayOrder}, + #{payPrice}, + + + + + update t_recharge_order + + create_by = #{createBy}, + create_time = #{createTime}, + update_by = #{updateBy}, + update_time = #{updateTime}, + del_flag = #{delFlag}, + customer_id = #{customerId}, + price = #{price}, + order_no = #{orderNo}, + pay_type = #{payType}, + pay_status = #{payStatus}, + ali_pay_order = #{aliPayOrder}, + pay_price = #{payPrice}, + + where id = #{id} + + + + delete from t_recharge_order where id = #{id} + + + + delete from t_recharge_order where id in + + #{id} + + + diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/rechargeorder/model/param/RechargeOrderParam.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/rechargeorder/model/param/RechargeOrderParam.java new file mode 100644 index 0000000..ebeec55 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/rechargeorder/model/param/RechargeOrderParam.java @@ -0,0 +1,67 @@ +package com.ruoyi.frequency.rechargeorder.model.param; + +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; + +import java.math.BigDecimal; + +/** + * 充值余额订单对象 t_recharge_order + * + * @author liwenlong + * @date 2023-10-25 + */ +@Data +@Accessors(chain = true) +public class RechargeOrderParam extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + @ApiModelProperty("主键id") + private Long id; + + @ApiModelProperty("删除标志 1正常 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("用户id") + @Excel(name = "用户id") + private Long customerId; + + @ApiModelProperty("充值金额") + @Excel(name = "充值金额") + private BigDecimal price; + + @ApiModelProperty("支付订单号") + @Excel(name = "支付订单号") + private String orderNo; + + @ApiModelProperty("支付方式 1 支付宝 2 微信 3 余额") + @Excel(name = "支付方式 1 支付宝 2 微信 3 余额") + private Integer payType; + + @ApiModelProperty("1待支付 2 支付成功 3 支付失败") + @Excel(name = "1待支付 2 支付成功 3 支付失败") + private Integer payStatus; + + @ApiModelProperty("支付宝支付订单号") + @Excel(name = "支付宝支付订单号") + private String aliPayOrder; + + @ApiModelProperty("支付金额") + @Excel(name = "支付金额") + private BigDecimal payPrice; + + + + + + + + + + + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/rechargeorder/model/result/RechargeOrderCount.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/rechargeorder/model/result/RechargeOrderCount.java new file mode 100644 index 0000000..c9cbf19 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/rechargeorder/model/result/RechargeOrderCount.java @@ -0,0 +1,23 @@ +package com.ruoyi.frequency.rechargeorder.model.result; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.math.BigDecimal; + +/** + * @author a + * @date 2024/2/22 14:55 + */ +@Data +public class RechargeOrderCount { + + @ApiModelProperty("总人数") + private Integer number; + + @ApiModelProperty("充值金额") + private BigDecimal payPrice; + + @ApiModelProperty("到账金额") + private BigDecimal price; +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/rechargeorder/model/result/RechargeOrderResult.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/rechargeorder/model/result/RechargeOrderResult.java new file mode 100644 index 0000000..2e5740c --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/rechargeorder/model/result/RechargeOrderResult.java @@ -0,0 +1,58 @@ +package com.ruoyi.frequency.rechargeorder.model.result; + +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; + +import java.math.BigDecimal; + +/** + * 充值余额订单对象 t_recharge_order + * + * @author liwenlong + * @date 2023-10-25 + */ +@Data +@Accessors(chain = true) +public class RechargeOrderResult extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + @ApiModelProperty("主键id") + private Long id; + + @ApiModelProperty("删除标志 1正常 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("用户id") + @Excel(name = "用户id") + private Long customerId; + + @ApiModelProperty("充值金额") + @Excel(name = "充值金额") + private BigDecimal price; + + @ApiModelProperty("支付订单号") + @Excel(name = "支付订单号") + private String orderNo; + + @ApiModelProperty("支付方式 1 支付宝 2 微信 3 余额") + @Excel(name = "支付方式 1 支付宝 2 微信 3 余额") + private Integer payType; + + @ApiModelProperty("1待支付 2 支付成功 3 支付失败") + @Excel(name = "1待支付 2 支付成功 3 支付失败") + private Integer payStatus; + + @ApiModelProperty("支付宝支付订单号") + @Excel(name = "支付宝支付订单号") + private String aliPayOrder; + + @ApiModelProperty("支付金额") + @Excel(name = "支付金额") + private BigDecimal payPrice; + + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/rechargeorder/service/RechargeOrderService.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/rechargeorder/service/RechargeOrderService.java new file mode 100644 index 0000000..fea47a4 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/rechargeorder/service/RechargeOrderService.java @@ -0,0 +1,100 @@ +package com.ruoyi.frequency.rechargeorder.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.ruoyi.controller.req.RechargeOrderReq; +import com.ruoyi.frequency.rechargeorder.entity.RechargeOrder; +import com.ruoyi.frequency.rechargeorder.model.result.RechargeOrderCount; +import com.ruoyi.response.ResponseData; +import com.ruoyi.vo.UserVo; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.util.List; +import java.util.Map; + +/** + * 充值余额订单Service接口 + * + * @author liwenlong + * @date 2023-10-25 + */ +public interface RechargeOrderService extends IService +{ + /** + * 查询充值余额订单 + * + * @param id 充值余额订单主键 + * @return 充值余额订单 + */ + public RechargeOrder selectRechargeOrderById(Long id); + + /** + * 查询充值余额订单列表 + * + * @param rechargeOrder 充值余额订单 + * @return 充值余额订单集合 + */ + public List selectRechargeOrderList(RechargeOrder rechargeOrder); + + RechargeOrderCount statistics(RechargeOrder rechargeOrder); + /** + * 新增充值余额订单 + * + * @param rechargeOrder 充值余额订单 + * @return 结果 + */ + public int insertRechargeOrder(RechargeOrder rechargeOrder); + + /** + * 修改充值余额订单 + * + * @param rechargeOrder 充值余额订单 + * @return 结果 + */ + public int updateRechargeOrder(RechargeOrder rechargeOrder); + + /** + * 批量删除充值余额订单 + * + * @param ids 需要删除的充值余额订单主键集合 + * @return 结果 + */ + public int deleteRechargeOrderByIds(Long[] ids); + + /** + * 删除充值余额订单信息 + * + * @param id 充值余额订单主键 + * @return 结果 + */ + public int deleteRechargeOrderById(Long id); + + + /** + * 充值 + * @param req + * @param userVo + * @return + */ + ResponseData rechargeOrder(RechargeOrderReq req, UserVo userVo); + + + /** + * 支付宝回调 + * @param request + * @param response + * @return + */ + ResponseData rechargeAliNotify(HttpServletRequest request, HttpServletResponse response); + + + /** + * 微信回调 + * @param request + * @param response + * @return + */ + ResponseData rechargeWxNotify(HttpServletRequest request, HttpServletResponse response); + + ResponseData rechargeLakalaNotify(Map paramMap); +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/rechargeorder/service/impl/RechargeOrderServiceImpl.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/rechargeorder/service/impl/RechargeOrderServiceImpl.java new file mode 100644 index 0000000..b0d9410 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/rechargeorder/service/impl/RechargeOrderServiceImpl.java @@ -0,0 +1,408 @@ +package com.ruoyi.frequency.rechargeorder.service.impl; + +import cn.hutool.core.collection.CollectionUtil; +import cn.hutool.core.date.DateUtil; +import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.RandomUtil; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.ruoyi.code.DictConstant; +import com.ruoyi.code.PublicCommon; +import com.ruoyi.common.core.domain.entity.SysDictData; +import com.ruoyi.common.utils.DateUtils; +import com.ruoyi.controller.req.RechargeOrderReq; +import com.ruoyi.enums.PlatformRecordEnums; +import com.ruoyi.enums.WalletDetailEnums; +import com.ruoyi.enums.user.UserEnums; +import com.ruoyi.frequency.customer.service.UserService; +import com.ruoyi.frequency.givewallerecord.service.GiveWalletRecordService; +import com.ruoyi.frequency.onlinerecord.service.OnlineRecordService; +import com.ruoyi.frequency.platformrecord.service.PlatformRecordService; +import com.ruoyi.frequency.rechargecoin.entity.RechargeCoin; +import com.ruoyi.frequency.rechargecoin.service.RechargeCoinService; +import com.ruoyi.frequency.rechargeorder.entity.RechargeOrder; +import com.ruoyi.frequency.rechargeorder.mapper.RechargeOrderMapper; +import com.ruoyi.frequency.rechargeorder.model.result.RechargeOrderCount; +import com.ruoyi.frequency.rechargeorder.service.RechargeOrderService; +import com.ruoyi.frequency.wallerecord.service.WalletRecordService; +import com.ruoyi.pay.enums.PayEnums; +import com.ruoyi.pay.enums.PaySourceEnums; +import com.ruoyi.pay.utils.AlipayCore; +import com.ruoyi.pay.utils.HttpRequestUtil; +import com.ruoyi.pay.utils.PayUtil; +import com.ruoyi.response.ResponseData; +import com.ruoyi.utils.BusinessUtil; +import com.ruoyi.vo.UserInfo; +import com.ruoyi.vo.UserVo; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.math.BigDecimal; +import java.util.Date; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.stream.Collectors; + +/** + * 充值余额订单Service业务层处理 + * + * @author liwenlong + * @date 2023-10-25 + */ +@Service +@Transactional(rollbackFor = Exception.class) +@Slf4j +public class RechargeOrderServiceImpl extends ServiceImpl implements RechargeOrderService { + @Autowired + private RechargeOrderMapper rechargeOrderMapper; + + /** + * 查询充值余额订单 + * + * @param id 充值余额订单主键 + * @return 充值余额订单 + */ + @Override + public RechargeOrder selectRechargeOrderById(Long id) { + RechargeOrder rechargeOrder = rechargeOrderMapper.selectRechargeOrderById(id); + + if (rechargeOrder != null) { + Set userVoSet = CollectionUtil.newHashSet(new UserVo(UserEnums.customer.getCode(), rechargeOrder.getCustomerId())); + //查询用户信息 + Map userMap = userService.selectUserInfoMap(userVoSet, null); + + rechargeOrder.setUserInfo(userMap.get(new UserVo(UserEnums.customer.getCode(), rechargeOrder.getCustomerId()))); + } + + return rechargeOrder; + } + + @Autowired + private UserService userService; + + /** + * 查询充值余额订单列表 + * + * @param rechargeOrder 充值余额订单 + * @return 充值余额订单 + */ + @Override + public List selectRechargeOrderList(RechargeOrder rechargeOrder) { + List rechargeOrders = rechargeOrderList(rechargeOrder); + + if (rechargeOrders != null && rechargeOrders.size() > 0) { + Set userVoSet = rechargeOrders.stream().map(s -> new UserVo(UserEnums.customer.getCode(), s.getCustomerId())).collect(Collectors.toSet()); + //查询用户信息 + Map userMap = userService.selectUserInfoMap(userVoSet, null); + + rechargeOrders.stream().forEach(s -> { + s.setUserInfo(userMap.get(new UserVo(UserEnums.customer.getCode(), s.getCustomerId()))); + }); + } + return rechargeOrders; + } + + private List rechargeOrderList(RechargeOrder rechargeOrder) { + List rechargeOrders = rechargeOrderMapper.selectRechargeOrderList(rechargeOrder); + return rechargeOrders; + } + + @Override + public RechargeOrderCount statistics(RechargeOrder rechargeOrder) { + List rechargeOrders = rechargeOrderList(rechargeOrder); + List rechargeOrderIdList = rechargeOrders.stream().map(x -> x.getId()).collect(Collectors.toList()); + rechargeOrderIdList.add(-1L); + return rechargeOrderMapper.statistics(rechargeOrderIdList); + } + + /** + * 新增充值余额订单 + * + * @param rechargeOrder 充值余额订单 + * @return 结果 + */ + @Override + public int insertRechargeOrder(RechargeOrder rechargeOrder) { + rechargeOrder.setCreateTime(DateUtils.getNowDate()); + return rechargeOrderMapper.insertRechargeOrder(rechargeOrder); + } + + /** + * 修改充值余额订单 + * + * @param rechargeOrder 充值余额订单 + * @return 结果 + */ + @Override + public int updateRechargeOrder(RechargeOrder rechargeOrder) { + rechargeOrder.setUpdateTime(DateUtils.getNowDate()); + return rechargeOrderMapper.updateRechargeOrder(rechargeOrder); + } + + /** + * 批量删除充值余额订单 + * + * @param ids 需要删除的充值余额订单主键 + * @return 结果 + */ + @Override + public int deleteRechargeOrderByIds(Long[] ids) { + this.lambdaUpdate().set(RechargeOrder::getDelFlag, PublicCommon.删除).in(RechargeOrder::getId, ids).update(); + return ids.length; + } + + /** + * 删除充值余额订单信息 + * + * @param id 充值余额订单主键 + * @return 结果 + */ + @Override + public int deleteRechargeOrderById(Long id) { + this.lambdaUpdate().set(RechargeOrder::getDelFlag, PublicCommon.删除).eq(RechargeOrder::getId, id).update(); + return 1; + } + + @Autowired + private RechargeCoinService rechargeCoinService; + + @Autowired + private PayUtil payUtil; + + @Override + public ResponseData rechargeOrder(RechargeOrderReq req, UserVo userVo) { + + RechargeOrder rechargeOrder = new RechargeOrder(); + + //分为两种情况 1使用充值包 2 自定义金额 + if (ObjectUtil.isNotEmpty(req.getRechargeCoinId())) { + RechargeCoin rechargeCoin = rechargeCoinService.getById(req.getRechargeCoinId()); + rechargeOrder.setPayPrice(rechargeCoin.getPrice()); + rechargeOrder.setPrice(rechargeCoin.getPrice().add(rechargeCoin.getCoin())); + } else { + + SysDictData 充值赠送金额比例 = businessUtil.getDict(DictConstant.充值赠送金额比例); + + BigDecimal ratio = BigDecimal.ZERO; + if (充值赠送金额比例 != null) { + ratio = new BigDecimal(充值赠送金额比例.getDictValue()); + } + + rechargeOrder.setPayPrice(req.getAmount()); + rechargeOrder.setPrice(req.getAmount().add(req.getAmount().multiply(ratio))); + } + rechargeOrder.setCustomerId(userVo.getUserId()); + rechargeOrder.setPayType(req.getPayType()); + rechargeOrder.setOrderNo(generateOrderNo()); + this.save(rechargeOrder); + + ResponseData responseData = payUtil.pay(userVo, rechargeOrder.getId(), req.getPayType(), rechargeOrder.getPayPrice(), BigDecimal.ZERO, rechargeOrder.getOrderNo(), PaySourceEnums.recharge_pay, WalletDetailEnums.ORDER_PAY); + + if (responseData.getSuccess() || responseData.getCode().equals(210)) { + //支付后操作 + if (req.getPayType().equals(PayEnums.balance.getCode()) || req.getPayType().equals(PayEnums.apple.getCode())) { + after(rechargeOrder); + } + } + + return responseData; + + } + + @Autowired + private PlatformRecordService platformRecordService; + + /** + * 支付后操作 + * + * @param order + */ + private void after(RechargeOrder order) { + + boolean update = this.lambdaUpdate().set(RechargeOrder::getPayStatus, PublicCommon.Pay.已支付) + .eq(RechargeOrder::getPayStatus, PublicCommon.Pay.未支付) + .eq(RechargeOrder::getId, order.getId()).update(); + + if (update) { + //充值余额 + walletRecordService.updateBalance(new UserVo(UserEnums.customer.getCode(), order.getCustomerId()), WalletDetailEnums.RECHARGE_BALANCE, order.getId(), order.getPayPrice(), PublicCommon.Wallet.可提现); + + //充值抵用金 + giveWalletRecordService.updateGiveBalance(new UserVo(UserEnums.customer.getCode(), order.getCustomerId()), WalletDetailEnums.RECHARGE_GIVE_BALANCE, order.getId(), order.getPrice().subtract(order.getPayPrice()), PublicCommon.Wallet.可提现); + + //平台流水 + platformRecordService.addPlatformRecord(new UserVo(UserEnums.customer.getCode(), order.getCustomerId()), order.getId(), order.getPrice(), PlatformRecordEnums.RECHARGE_BALANCE); + + } + } + + @Autowired + private GiveWalletRecordService giveWalletRecordService; + + /** + * 生成订单号 + * + * @return + */ + private String generateOrderNo() { + String orderNo; + String prefix = "CZ"; + while (true) { + orderNo = prefix + DateUtil.format(new Date(), "MMdd" + RandomUtil.randomNumbers(6)); + RechargeOrder old = this.getBaseMapper().selectOne(new QueryWrapper().lambda() + .eq(RechargeOrder::getOrderNo, orderNo) + + ); + if (old == null) { + break; + } + } + return orderNo; + } + + @Autowired + private WalletRecordService walletRecordService; + + @Override + public ResponseData rechargeAliNotify(HttpServletRequest request, HttpServletResponse response) { + log.info("******************************进入支付宝支付回调"); + //接收参数进行校验 + Map paramsMap = AlipayCore.updateMap(request); + //流水号 + String payId = paramsMap.get("out_trade_no"); + // 支付宝订单号 + String orderNo = paramsMap.get("trade_no"); + //付款状态 + String tradeStatus = paramsMap.get("trade_status"); + log.info("******************************payId=" + payId); + + RechargeOrder cur = baseMapper.selectOne(new QueryWrapper().lambda().eq(RechargeOrder::getOrderNo, payId)); + if (cur == null) { + log.error("支付信息丢失"); + return ResponseData.error("支付信息丢失"); + } + if (cur.getPayStatus() == 2) { + log.error("支付宝回调已经开始 回去吧"); + return ResponseData.error("支付宝回调已经开始 回去吧"); + } + if (cur.getPayStatus() == 3) { + //退款 + ResponseData responseData = payUtil.refund(new UserVo(UserEnums.customer.getCode(), cur.getCustomerId()), cur.getId(), cur.getPayType(), cur.getPayPrice(), cur.getPrice(), cur.getOrderNo(), cur.getAliPayOrder(), BigDecimal.ZERO); + if (!responseData.getSuccess()) { + log.error("退款失败:" + cur.getOrderNo()); + } + return responseData; + } + if ("TRADE_SUCCESS".equalsIgnoreCase(tradeStatus)) { + + this.lambdaUpdate().set(RechargeOrder::getAliPayOrder, orderNo).eq(RechargeOrder::getId, cur.getId()).update(); + + after(cur);//支付后逻辑处理 + log.info("正常"); + return ResponseData.success(); + } else { + cur.setPayStatus(3); + baseMapper.updateById(cur); + log.error("支付失败"); + } + return ResponseData.error(""); + } + + @Override + public ResponseData rechargeWxNotify(HttpServletRequest request, HttpServletResponse response) { + Map requestMap = HttpRequestUtil.parseXml(request); + System.out.println("requestMap:" + requestMap.toString()); + // 微信中的订单号 + String transactionId = requestMap.get("transaction_id"); + // 用户唯一标识 + String openid = requestMap.get("openid"); + //流水号 + String payId = requestMap.get("out_trade_no"); + + RechargeOrder cur = baseMapper.selectOne(new QueryWrapper().lambda().eq(RechargeOrder::getOrderNo, payId)); + if (cur == null) { + log.error("支付信息丢失"); + return ResponseData.error("支付信息丢失"); + } + if (cur.getPayStatus() == 2) { + log.error("微信回调已经开始 回去吧"); + return ResponseData.error("支付宝回调已经开始 回去吧"); + } + if (cur.getPayStatus() == 3) { + //退款 + ResponseData responseData = payUtil.refund(new UserVo(UserEnums.customer.getCode(), cur.getCustomerId()), cur.getId(), cur.getPayType(), cur.getPayPrice(), cur.getPayPrice(), cur.getOrderNo(), cur.getAliPayOrder(), BigDecimal.ZERO); + if (!responseData.getSuccess()) { + log.error("退款失败:" + cur.getOrderNo()); + } + return responseData; + } + + if ("SUCCESS".equals(requestMap.get("result_code"))) { + after(cur);//支付后逻辑处理 + log.info("正常"); + return ResponseData.success(); + } else { + cur.setPayStatus(3); + baseMapper.updateById(cur); + log.error("支付失败"); + } + + return ResponseData.error(""); + } + + @Override + public ResponseData rechargeLakalaNotify(Map requestMap) { + System.out.println("requestMap:" + requestMap.toString()); + //流水号 + String payId = requestMap.get("out_order_no"); + + RechargeOrder cur = baseMapper.selectOne(new QueryWrapper().lambda().eq(RechargeOrder::getOrderNo, payId)); + if (cur == null) { + log.error("支付信息丢失"); + return ResponseData.error("支付信息丢失"); + } + if (cur.getPayStatus() == 2) { + log.error("拉卡拉回调已经开始 回去吧"); + return ResponseData.error("拉卡拉回调已经开始 回去吧"); + } + if (cur.getPayStatus() == 3) { + //退款 + ResponseData responseData = payUtil.refund(new UserVo(UserEnums.customer.getCode(), cur.getCustomerId()), cur.getId(), cur.getPayType(), cur.getPayPrice(), cur.getPayPrice(), cur.getOrderNo(), cur.getAliPayOrder(), BigDecimal.ZERO); + if (!responseData.getSuccess()) { + log.error("退款失败:" + cur.getOrderNo()); + } + return responseData; + } + + //order_status 聚合收银台订单状态 0:待支付 1:支付中 2:支付成功 3:支付失败 4:已过期 5:已取消 6:部分退款或者全部退款 + if (("2").equals(requestMap.get("order_status"))) { + after(cur);//支付后逻辑处理 + log.info("正常"); + + //设置成功标识 + businessUtil.setOutTradeNo(payId); + + //添加支付记录 + onlineRecordService.addOnlineRecord(new UserVo(UserEnums.customer.getCode(), cur.getCustomerId()), cur.getId(), cur.getPayPrice(), WalletDetailEnums.RECHARGE_BALANCE); + + return ResponseData.success(); + } else { + cur.setPayStatus(3); + baseMapper.updateById(cur); + log.error("支付失败"); + } + + return ResponseData.error(""); + } + + @Autowired + private OnlineRecordService onlineRecordService; + + @Autowired + private BusinessUtil businessUtil; +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/rechargerecord/controller/RechargeRecordController.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/rechargerecord/controller/RechargeRecordController.java new file mode 100644 index 0000000..0a4c599 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/rechargerecord/controller/RechargeRecordController.java @@ -0,0 +1,97 @@ +package com.ruoyi.frequency.rechargerecord.controller; + +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.page.TableDataInfo; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.common.utils.poi.ExcelUtil; +import com.ruoyi.frequency.rechargerecord.entity.RechargeRecord; +import com.ruoyi.frequency.rechargerecord.service.RechargeRecordService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +/** + * 充值记录Controller + * + * @author liwenlong + * @date 2023-10-25 + */ +@RestController +@RequestMapping("/frequency/rechargerecord") +public class RechargeRecordController extends BaseController +{ + @Autowired + private RechargeRecordService rechargeRecordService; + + /** + * 查询充值记录列表 + */ + @PreAuthorize("@ss.hasPermi('frequency:rechargerecord:list')") + @PostMapping("/list") + public TableDataInfo list(@RequestBody RechargeRecord rechargeRecord) + { + startPage(); + List list = rechargeRecordService.selectRechargeRecordList(rechargeRecord); + return getDataTable(list); + } + + /** + * 导出充值记录列表 + */ + @PreAuthorize("@ss.hasPermi('frequency:rechargerecord:export')") + @Log(title = "充值记录", businessType = BusinessType.EXPORT) + @GetMapping("/export") + public AjaxResult export(RechargeRecord rechargeRecord) + { + List list = rechargeRecordService.selectRechargeRecordList(rechargeRecord); + ExcelUtil util = new ExcelUtil(RechargeRecord.class); + return util.exportExcel(list, "充值记录数据"); + } + + /** + * 获取充值记录详细信息 + */ + @PreAuthorize("@ss.hasPermi('frequency:rechargerecord:query')") + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") Long id) + { + return AjaxResult.success(rechargeRecordService.selectRechargeRecordById(id)); + } + + /** + * 新增充值记录 + */ + @PreAuthorize("@ss.hasPermi('frequency:rechargerecord:add')") + @Log(title = "充值记录", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody RechargeRecord rechargeRecord) + { + return toAjax(rechargeRecordService.insertRechargeRecord(rechargeRecord)); + } + + /** + * 修改充值记录 + */ + @PreAuthorize("@ss.hasPermi('frequency:rechargerecord:edit')") + @Log(title = "充值记录", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody RechargeRecord rechargeRecord) + { + return toAjax(rechargeRecordService.updateRechargeRecord(rechargeRecord)); + } + + /** + * 删除充值记录 + */ + @PreAuthorize("@ss.hasPermi('frequency:rechargerecord:remove')") + @Log(title = "充值记录", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}") + public AjaxResult remove(@PathVariable Long[] ids) + { + return toAjax(rechargeRecordService.deleteRechargeRecordByIds(ids)); + } +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/rechargerecord/entity/RechargeRecord.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/rechargerecord/entity/RechargeRecord.java new file mode 100644 index 0000000..c0667da --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/rechargerecord/entity/RechargeRecord.java @@ -0,0 +1,65 @@ +package com.ruoyi.frequency.rechargerecord.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; + +import java.math.BigDecimal; + +/** + * 充值记录对象 t_recharge_record + * + * @author liwenlong + * @date 2023-10-25 + */ +@Data +@Accessors(chain = true) +@TableName("t_recharge_record") +public class RechargeRecord extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + + @ApiModelProperty("主键id") + private Long id; + + @ApiModelProperty("删除标志 1正常 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("充值金币表id") + @Excel(name = "充值金币表id") + private String rechargeCoinId; + + @ApiModelProperty("支付价格") + @Excel(name = "支付价格") + private BigDecimal payPrice; + + @ApiModelProperty("金币") + @Excel(name = "金币") + private BigDecimal coin; + + @ApiModelProperty("支付订单号") + @Excel(name = "支付订单号") + private String payOrderNo; + + @ApiModelProperty("支付宝支付订单号") + @Excel(name = "支付宝支付订单号") + private String aliBusinessId; + + @ApiModelProperty("支付状态 1 待支付 2 支付成功 3 支付失败") + @Excel(name = "支付状态 1 待支付 2 支付成功 3 支付失败") + private Integer status; + + @ApiModelProperty("用户id") + @Excel(name = "用户id") + private Long customerId; + + @ApiModelProperty("支付方式 1 支付宝 2 微信") + @Excel(name = "支付方式 1 支付宝 2 微信") + private Integer payType; + + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/rechargerecord/mapper/RechargeRecordMapper.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/rechargerecord/mapper/RechargeRecordMapper.java new file mode 100644 index 0000000..e5c8940 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/rechargerecord/mapper/RechargeRecordMapper.java @@ -0,0 +1,63 @@ +package com.ruoyi.frequency.rechargerecord.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.ruoyi.frequency.rechargerecord.entity.RechargeRecord; + +import java.util.List; + +/** + * 充值记录Mapper接口 + * + * @author liwenlong + * @date 2023-10-25 + */ +public interface RechargeRecordMapper extends BaseMapper +{ + /** + * 查询充值记录 + * + * @param id 充值记录主键 + * @return 充值记录 + */ + public RechargeRecord selectRechargeRecordById(Long id); + + /** + * 查询充值记录列表 + * + * @param rechargeRecord 充值记录 + * @return 充值记录集合 + */ + public List selectRechargeRecordList(RechargeRecord rechargeRecord); + + /** + * 新增充值记录 + * + * @param rechargeRecord 充值记录 + * @return 结果 + */ + public int insertRechargeRecord(RechargeRecord rechargeRecord); + + /** + * 修改充值记录 + * + * @param rechargeRecord 充值记录 + * @return 结果 + */ + public int updateRechargeRecord(RechargeRecord rechargeRecord); + + /** + * 删除充值记录 + * + * @param id 充值记录主键 + * @return 结果 + */ + public int deleteRechargeRecordById(Long id); + + /** + * 批量删除充值记录 + * + * @param ids 需要删除的数据主键集合 + * @return 结果 + */ + public int deleteRechargeRecordByIds(Long[] ids); +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/rechargerecord/mapper/mapping/RechargeRecordMapper.xml b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/rechargerecord/mapper/mapping/RechargeRecordMapper.xml new file mode 100644 index 0000000..a5b06bc --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/rechargerecord/mapper/mapping/RechargeRecordMapper.xml @@ -0,0 +1,113 @@ + + + + + + + + + + + + + + + + + + + + + + + select id, create_by, create_time, update_by, update_time, del_flag, recharge_coin_id, pay_price, coin, pay_order_no, ali_business_id, status, customer_id, pay_type from t_recharge_record + + + + + + + + insert into t_recharge_record + + id, + create_by, + create_time, + update_by, + update_time, + del_flag, + recharge_coin_id, + pay_price, + coin, + pay_order_no, + ali_business_id, + status, + customer_id, + pay_type, + + + #{id}, + #{createBy}, + #{createTime}, + #{updateBy}, + #{updateTime}, + #{delFlag}, + #{rechargeCoinId}, + #{payPrice}, + #{coin}, + #{payOrderNo}, + #{aliBusinessId}, + #{status}, + #{customerId}, + #{payType}, + + + + + update t_recharge_record + + create_by = #{createBy}, + create_time = #{createTime}, + update_by = #{updateBy}, + update_time = #{updateTime}, + del_flag = #{delFlag}, + recharge_coin_id = #{rechargeCoinId}, + pay_price = #{payPrice}, + coin = #{coin}, + pay_order_no = #{payOrderNo}, + ali_business_id = #{aliBusinessId}, + status = #{status}, + customer_id = #{customerId}, + pay_type = #{payType}, + + where id = #{id} + + + + delete from t_recharge_record where id = #{id} + + + + delete from t_recharge_record where id in + + #{id} + + + \ No newline at end of file diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/rechargerecord/model/param/RechargeRecordParam.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/rechargerecord/model/param/RechargeRecordParam.java new file mode 100644 index 0000000..0c531c0 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/rechargerecord/model/param/RechargeRecordParam.java @@ -0,0 +1,72 @@ +package com.ruoyi.frequency.rechargerecord.model.param; + +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; + +import java.math.BigDecimal; + +/** + * 充值记录对象 t_recharge_record + * + * @author liwenlong + * @date 2023-10-25 + */ +@Data +@Accessors(chain = true) +public class RechargeRecordParam extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + @ApiModelProperty("主键id") + private Long id; + + @ApiModelProperty("删除标志 1正常 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("充值金币表id") + @Excel(name = "充值金币表id") + private String rechargeCoinId; + + @ApiModelProperty("支付价格") + @Excel(name = "支付价格") + private BigDecimal payPrice; + + @ApiModelProperty("金币") + @Excel(name = "金币") + private BigDecimal coin; + + @ApiModelProperty("支付订单号") + @Excel(name = "支付订单号") + private String payOrderNo; + + @ApiModelProperty("支付宝支付订单号") + @Excel(name = "支付宝支付订单号") + private String aliBusinessId; + + @ApiModelProperty("支付状态 1 待支付 2 支付成功 3 支付失败") + @Excel(name = "支付状态 1 待支付 2 支付成功 3 支付失败") + private Integer status; + + @ApiModelProperty("用户id") + @Excel(name = "用户id") + private Long customerId; + + @ApiModelProperty("支付方式 1 支付宝 2 微信") + @Excel(name = "支付方式 1 支付宝 2 微信") + private Integer payType; + + + + + + + + + + + + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/rechargerecord/model/result/RechargeRecordResult.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/rechargerecord/model/result/RechargeRecordResult.java new file mode 100644 index 0000000..b6ca356 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/rechargerecord/model/result/RechargeRecordResult.java @@ -0,0 +1,62 @@ +package com.ruoyi.frequency.rechargerecord.model.result; + +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; + +import java.math.BigDecimal; + +/** + * 充值记录对象 t_recharge_record + * + * @author liwenlong + * @date 2023-10-25 + */ +@Data +@Accessors(chain = true) +public class RechargeRecordResult extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + @ApiModelProperty("主键id") + private Long id; + + @ApiModelProperty("删除标志 1正常 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("充值金币表id") + @Excel(name = "充值金币表id") + private String rechargeCoinId; + + @ApiModelProperty("支付价格") + @Excel(name = "支付价格") + private BigDecimal payPrice; + + @ApiModelProperty("金币") + @Excel(name = "金币") + private BigDecimal coin; + + @ApiModelProperty("支付订单号") + @Excel(name = "支付订单号") + private String payOrderNo; + + @ApiModelProperty("支付宝支付订单号") + @Excel(name = "支付宝支付订单号") + private String aliBusinessId; + + @ApiModelProperty("支付状态 1 待支付 2 支付成功 3 支付失败") + @Excel(name = "支付状态 1 待支付 2 支付成功 3 支付失败") + private Integer status; + + @ApiModelProperty("用户id") + @Excel(name = "用户id") + private Long customerId; + + @ApiModelProperty("支付方式 1 支付宝 2 微信") + @Excel(name = "支付方式 1 支付宝 2 微信") + private Integer payType; + + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/rechargerecord/service/RechargeRecordService.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/rechargerecord/service/RechargeRecordService.java new file mode 100644 index 0000000..d0824e7 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/rechargerecord/service/RechargeRecordService.java @@ -0,0 +1,84 @@ +package com.ruoyi.frequency.rechargerecord.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.ruoyi.frequency.rechargerecord.entity.RechargeRecord; +import com.ruoyi.response.ResponseData; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.util.List; + +/** + * 充值记录Service接口 + * + * @author liwenlong + * @date 2023-10-25 + */ +public interface RechargeRecordService extends IService +{ + /** + * 查询充值记录 + * + * @param id 充值记录主键 + * @return 充值记录 + */ + public RechargeRecord selectRechargeRecordById(Long id); + + /** + * 查询充值记录列表 + * + * @param rechargeRecord 充值记录 + * @return 充值记录集合 + */ + public List selectRechargeRecordList(RechargeRecord rechargeRecord); + + /** + * 新增充值记录 + * + * @param rechargeRecord 充值记录 + * @return 结果 + */ + public int insertRechargeRecord(RechargeRecord rechargeRecord); + + /** + * 修改充值记录 + * + * @param rechargeRecord 充值记录 + * @return 结果 + */ + public int updateRechargeRecord(RechargeRecord rechargeRecord); + + /** + * 批量删除充值记录 + * + * @param ids 需要删除的充值记录主键集合 + * @return 结果 + */ + public int deleteRechargeRecordByIds(Long[] ids); + + /** + * 删除充值记录信息 + * + * @param id 充值记录主键 + * @return 结果 + */ + public int deleteRechargeRecordById(Long id); + + + /** + * 支付宝回调 + * @param request + * @param response + * @return + */ + ResponseData rechargeAliNotify(HttpServletRequest request, HttpServletResponse response); + + + /** + * 微信回调 + * @param request + * @param response + * @return + */ + ResponseData rechargeWxNotify(HttpServletRequest request, HttpServletResponse response); +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/rechargerecord/service/impl/RechargeRecordServiceImpl.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/rechargerecord/service/impl/RechargeRecordServiceImpl.java new file mode 100644 index 0000000..e04da20 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/rechargerecord/service/impl/RechargeRecordServiceImpl.java @@ -0,0 +1,116 @@ +package com.ruoyi.frequency.rechargerecord.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.ruoyi.code.PublicCommon; +import com.ruoyi.common.utils.DateUtils; +import com.ruoyi.frequency.rechargerecord.entity.RechargeRecord; +import com.ruoyi.frequency.rechargerecord.mapper.RechargeRecordMapper; +import com.ruoyi.frequency.rechargerecord.service.RechargeRecordService; +import com.ruoyi.response.ResponseData; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.util.List; + +/** + * 充值记录Service业务层处理 + * + * @author liwenlong + * @date 2023-10-25 + */ +@Service +@Transactional(rollbackFor = Exception.class) +public class RechargeRecordServiceImpl extends ServiceImpl implements RechargeRecordService +{ + @Autowired + private RechargeRecordMapper rechargeRecordMapper; + + /** + * 查询充值记录 + * + * @param id 充值记录主键 + * @return 充值记录 + */ + @Override + public RechargeRecord selectRechargeRecordById(Long id) + { + return rechargeRecordMapper.selectRechargeRecordById(id); + } + + /** + * 查询充值记录列表 + * + * @param rechargeRecord 充值记录 + * @return 充值记录 + */ + @Override + public List selectRechargeRecordList(RechargeRecord rechargeRecord) + { + return rechargeRecordMapper.selectRechargeRecordList(rechargeRecord); + } + + /** + * 新增充值记录 + * + * @param rechargeRecord 充值记录 + * @return 结果 + */ + @Override + public int insertRechargeRecord(RechargeRecord rechargeRecord) + { + rechargeRecord.setCreateTime(DateUtils.getNowDate()); + return rechargeRecordMapper.insertRechargeRecord(rechargeRecord); + } + + /** + * 修改充值记录 + * + * @param rechargeRecord 充值记录 + * @return 结果 + */ + @Override + public int updateRechargeRecord(RechargeRecord rechargeRecord) + { + rechargeRecord.setUpdateTime(DateUtils.getNowDate()); + return rechargeRecordMapper.updateRechargeRecord(rechargeRecord); + } + + /** + * 批量删除充值记录 + * + * @param ids 需要删除的充值记录主键 + * @return 结果 + */ + @Override + public int deleteRechargeRecordByIds(Long[] ids) + { + this.lambdaUpdate().set(RechargeRecord::getDelFlag,PublicCommon.删除).in(RechargeRecord::getId,ids).update(); + return ids.length; + } + + /** + * 删除充值记录信息 + * + * @param id 充值记录主键 + * @return 结果 + */ + @Override + public int deleteRechargeRecordById(Long id) + { + this.lambdaUpdate().set(RechargeRecord::getDelFlag,PublicCommon.删除).eq(RechargeRecord::getId,id).update(); + return 1; + } + + @Override + public ResponseData rechargeAliNotify(HttpServletRequest request, HttpServletResponse response) { + return null; + } + + @Override + public ResponseData rechargeWxNotify(HttpServletRequest request, HttpServletResponse response) { + return null; + } +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/recommend/controller/RecommendController.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/recommend/controller/RecommendController.java new file mode 100644 index 0000000..8bc6e13 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/recommend/controller/RecommendController.java @@ -0,0 +1,97 @@ +package com.ruoyi.frequency.recommend.controller; + +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.page.TableDataInfo; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.common.utils.poi.ExcelUtil; +import com.ruoyi.frequency.recommend.entity.Recommend; +import com.ruoyi.frequency.recommend.service.RecommendService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +/** + * 推荐Controller + * + * @author liwenlong + * @date 2023-10-20 + */ +@RestController +@RequestMapping("/frequency/recommend") +public class RecommendController extends BaseController +{ + @Autowired + private RecommendService recommendService; + + /** + * 查询推荐列表 + */ + @PreAuthorize("@ss.hasPermi('frequency:recommend:list')") + @GetMapping("/list") + public TableDataInfo list(Recommend recommend) + { + startPage(); + List list = recommendService.selectRecommendList(recommend); + return getDataTable(list); + } + + /** + * 导出推荐列表 + */ + @PreAuthorize("@ss.hasPermi('frequency:recommend:export')") + @Log(title = "推荐", businessType = BusinessType.EXPORT) + @GetMapping("/export") + public AjaxResult export(Recommend recommend) + { + List list = recommendService.selectRecommendList(recommend); + ExcelUtil util = new ExcelUtil(Recommend.class); + return util.exportExcel(list, "推荐数据"); + } + + /** + * 获取推荐详细信息 + */ + @PreAuthorize("@ss.hasPermi('frequency:recommend:query')") + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") Long id) + { + return AjaxResult.success(recommendService.selectRecommendById(id)); + } + + /** + * 新增推荐 + */ + @PreAuthorize("@ss.hasPermi('frequency:recommend:add')") + @Log(title = "推荐", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody Recommend recommend) + { + return toAjax(recommendService.insertRecommend(recommend)); + } + + /** + * 修改推荐 + */ + @PreAuthorize("@ss.hasPermi('frequency:recommend:edit')") + @Log(title = "推荐", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody Recommend recommend) + { + return toAjax(recommendService.updateRecommend(recommend)); + } + + /** + * 删除推荐 + */ + @PreAuthorize("@ss.hasPermi('frequency:recommend:remove')") + @Log(title = "推荐", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}") + public AjaxResult remove(@PathVariable Long[] ids) + { + return toAjax(recommendService.deleteRecommendByIds(ids)); + } +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/recommend/entity/Recommend.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/recommend/entity/Recommend.java new file mode 100644 index 0000000..f66e082 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/recommend/entity/Recommend.java @@ -0,0 +1,43 @@ +package com.ruoyi.frequency.recommend.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; + +/** + * 推荐对象 t_recommend + * + * @author liwenlong + * @date 2023-10-20 + */ +@Data +@Accessors(chain = true) +@TableName("t_recommend") +public class Recommend extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + + @ApiModelProperty("主键id") + private Long id; + + @ApiModelProperty("删除标志 1正常 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("对应的推荐对象id") + @Excel(name = "对应的推荐对象id") + private Long objectId; + + @ApiModelProperty("排序") + @Excel(name = "排序") + private Long sort; + + @ApiModelProperty("1 帖子 2作品") + @Excel(name = "1 帖子 2作品") + private Integer type; + + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/recommend/mapper/RecommendMapper.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/recommend/mapper/RecommendMapper.java new file mode 100644 index 0000000..0f5de9f --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/recommend/mapper/RecommendMapper.java @@ -0,0 +1,66 @@ +package com.ruoyi.frequency.recommend.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.ruoyi.frequency.recommend.entity.Recommend; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * 推荐Mapper接口 + * + * @author liwenlong + * @date 2023-10-20 + */ +public interface RecommendMapper extends BaseMapper +{ + /** + * 查询推荐 + * + * @param id 推荐主键 + * @return 推荐 + */ + public Recommend selectRecommendById(Long id); + + /** + * 查询推荐列表 + * + * @param recommend 推荐 + * @return 推荐集合 + */ + public List selectRecommendList(Recommend recommend); + + /** + * 新增推荐 + * + * @param recommend 推荐 + * @return 结果 + */ + public int insertRecommend(Recommend recommend); + + /** + * 修改推荐 + * + * @param recommend 推荐 + * @return 结果 + */ + public int updateRecommend(Recommend recommend); + + /** + * 删除推荐 + * + * @param id 推荐主键 + * @return 结果 + */ + public int deleteRecommendById(Long id); + + /** + * 批量删除推荐 + * + * @param ids 需要删除的数据主键集合 + * @return 结果 + */ + public int deleteRecommendByIds(Long[] ids); + + void topping(@Param("req") Recommend recommend); +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/recommend/mapper/mapping/RecommendMapper.xml b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/recommend/mapper/mapping/RecommendMapper.xml new file mode 100644 index 0000000..1e239b6 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/recommend/mapper/mapping/RecommendMapper.xml @@ -0,0 +1,99 @@ + + + + + + + + + + + + + + + + + + select id, create_by, create_time, update_by, update_time, del_flag, object_id, sort, type from t_recommend + + + + + + + + insert into t_recommend + + id, + create_by, + create_time, + update_by, + update_time, + del_flag, + object_id, + sort, + type, + + + #{id}, + #{createBy}, + #{createTime}, + #{updateBy}, + #{updateTime}, + #{delFlag}, + #{objectId}, + #{sort}, + #{type}, + + + + + update t_recommend + + create_by = #{createBy}, + create_time = #{createTime}, + update_by = #{updateBy}, + update_time = #{updateTime}, + del_flag = #{delFlag}, + object_id = #{objectId}, + sort = #{sort}, + type = #{type}, + + where id = #{id} + + + + delete from t_recommend where id = #{id} + + + + delete from t_recommend where id in + + #{id} + + + + + insert into t_recommend + (id, create_by, create_time, update_by, update_time, type, object_id) + values + (#{req.id},#{req.updateBy},#{req.updateTime},#{req.updateBy},#{req.updateTime},#{req.type}, #{req.objectId}) + ON DUPLICATE KEY UPDATE + del_flag = IF( del_flag = 1, 3, 1 ), + update_time = #{req.updateTime}, + update_by = #{req.updateBy}; + + diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/recommend/model/param/RecommendParam.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/recommend/model/param/RecommendParam.java new file mode 100644 index 0000000..f9c46b8 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/recommend/model/param/RecommendParam.java @@ -0,0 +1,45 @@ +package com.ruoyi.frequency.recommend.model.param; + +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; + +/** + * 推荐对象 t_recommend + * + * @author liwenlong + * @date 2023-10-20 + */ +@Data +@Accessors(chain = true) +public class RecommendParam extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + @ApiModelProperty("主键id") + private Long id; + + @ApiModelProperty("删除标志 1正常 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("对应的推荐对象id") + @Excel(name = "对应的推荐对象id") + private Long objectId; + + @ApiModelProperty("排序") + @Excel(name = "排序") + private Long sort; + + @ApiModelProperty("1 帖子 2作品") + @Excel(name = "1 帖子 2作品") + private Integer type; + + + + + + + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/recommend/model/result/RecommendResult.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/recommend/model/result/RecommendResult.java new file mode 100644 index 0000000..1aa0a03 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/recommend/model/result/RecommendResult.java @@ -0,0 +1,40 @@ +package com.ruoyi.frequency.recommend.model.result; + +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; + +/** + * 推荐对象 t_recommend + * + * @author liwenlong + * @date 2023-10-20 + */ +@Data +@Accessors(chain = true) +public class RecommendResult extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + @ApiModelProperty("主键id") + private Long id; + + @ApiModelProperty("删除标志 1正常 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("对应的推荐对象id") + @Excel(name = "对应的推荐对象id") + private Long objectId; + + @ApiModelProperty("排序") + @Excel(name = "排序") + private Long sort; + + @ApiModelProperty("1 帖子 2作品") + @Excel(name = "1 帖子 2作品") + private Integer type; + + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/recommend/service/RecommendService.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/recommend/service/RecommendService.java new file mode 100644 index 0000000..f5d59e3 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/recommend/service/RecommendService.java @@ -0,0 +1,70 @@ +package com.ruoyi.frequency.recommend.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.ruoyi.frequency.recommend.entity.Recommend; + +import java.util.List; + +/** + * 推荐Service接口 + * + * @author liwenlong + * @date 2023-10-20 + */ +public interface RecommendService extends IService +{ + /** + * 查询推荐 + * + * @param id 推荐主键 + * @return 推荐 + */ + public Recommend selectRecommendById(Long id); + + /** + * 查询推荐列表 + * + * @param recommend 推荐 + * @return 推荐集合 + */ + public List selectRecommendList(Recommend recommend); + + /** + * 新增推荐 + * + * @param recommend 推荐 + * @return 结果 + */ + public int insertRecommend(Recommend recommend); + + /** + * 修改推荐 + * + * @param recommend 推荐 + * @return 结果 + */ + public int updateRecommend(Recommend recommend); + + /** + * 批量删除推荐 + * + * @param ids 需要删除的推荐主键集合 + * @return 结果 + */ + public int deleteRecommendByIds(Long[] ids); + + /** + * 删除推荐信息 + * + * @param id 推荐主键 + * @return 结果 + */ + public int deleteRecommendById(Long id); + + /** + * 置顶 + * @param type 1作品 2帖子 + * @param objectId + */ + void topping(Integer type, Long objectId); +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/recommend/service/impl/RecommendServiceImpl.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/recommend/service/impl/RecommendServiceImpl.java new file mode 100644 index 0000000..7e2d565 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/recommend/service/impl/RecommendServiceImpl.java @@ -0,0 +1,115 @@ +package com.ruoyi.frequency.recommend.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.ruoyi.code.PublicCommon; +import com.ruoyi.common.utils.DateUtils; +import com.ruoyi.frequency.recommend.entity.Recommend; +import com.ruoyi.frequency.recommend.mapper.RecommendMapper; +import com.ruoyi.frequency.recommend.service.RecommendService; +import com.ruoyi.utils.SnowIdUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.List; + +/** + * 推荐Service业务层处理 + * + * @author liwenlong + * @date 2023-10-20 + */ +@Service +@Transactional(rollbackFor = Exception.class) +public class RecommendServiceImpl extends ServiceImpl implements RecommendService +{ + @Autowired + private RecommendMapper recommendMapper; + + /** + * 查询推荐 + * + * @param id 推荐主键 + * @return 推荐 + */ + @Override + public Recommend selectRecommendById(Long id) + { + return recommendMapper.selectRecommendById(id); + } + + /** + * 查询推荐列表 + * + * @param recommend 推荐 + * @return 推荐 + */ + @Override + public List selectRecommendList(Recommend recommend) + { + return recommendMapper.selectRecommendList(recommend); + } + + /** + * 新增推荐 + * + * @param recommend 推荐 + * @return 结果 + */ + @Override + public int insertRecommend(Recommend recommend) + { + recommend.setCreateTime(DateUtils.getNowDate()); + return recommendMapper.insertRecommend(recommend); + } + + /** + * 修改推荐 + * + * @param recommend 推荐 + * @return 结果 + */ + @Override + public int updateRecommend(Recommend recommend) + { + recommend.setUpdateTime(DateUtils.getNowDate()); + return recommendMapper.updateRecommend(recommend); + } + + /** + * 批量删除推荐 + * + * @param ids 需要删除的推荐主键 + * @return 结果 + */ + @Override + public int deleteRecommendByIds(Long[] ids) + { + this.lambdaUpdate().set(Recommend::getDelFlag,PublicCommon.删除).in(Recommend::getId,ids).update(); + return ids.length; + } + + /** + * 删除推荐信息 + * + * @param id 推荐主键 + * @return 结果 + */ + @Override + public int deleteRecommendById(Long id) + { + this.lambdaUpdate().set(Recommend::getDelFlag,PublicCommon.删除).eq(Recommend::getId,id).update(); + return 1; + } + + @Override + public void topping(Integer type, Long objectId) { + + Recommend recommend = new Recommend() + .setId(SnowIdUtils.uniqueLong()) + .setType(type) + .setObjectId(objectId); + recommend.setUpdateData(); + recommendMapper.topping(recommend); + } +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/refereeuser/controller/RefereeUserController.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/refereeuser/controller/RefereeUserController.java new file mode 100644 index 0000000..9481011 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/refereeuser/controller/RefereeUserController.java @@ -0,0 +1,97 @@ +package com.ruoyi.frequency.refereeuser.controller; + +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.page.TableDataInfo; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.common.utils.poi.ExcelUtil; +import com.ruoyi.frequency.refereeuser.entity.RefereeUser; +import com.ruoyi.frequency.refereeuser.service.RefereeUserService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +/** + * 用户邀请Controller + * + * @author liwenlong + * @date 2023-07-20 + */ +@RestController +@RequestMapping("/frequency/refereeuser") +public class RefereeUserController extends BaseController +{ + @Autowired + private RefereeUserService refereeUserService; + + /** + * 查询用户邀请列表 + */ + @PreAuthorize("@ss.hasPermi('frequency:refereeuser:list')") + @PostMapping("/list") + public TableDataInfo list(@RequestBody RefereeUser refereeUser) + { + startPage(); + List list = refereeUserService.selectRefereeUserList(refereeUser); + return getDataTable(list); + } + + /** + * 导出用户邀请列表 + */ + @PreAuthorize("@ss.hasPermi('frequency:refereeuser:export')") + @Log(title = "用户邀请", businessType = BusinessType.EXPORT) + @GetMapping("/export") + public AjaxResult export(RefereeUser refereeUser) + { + List list = refereeUserService.selectRefereeUserList(refereeUser); + ExcelUtil util = new ExcelUtil(RefereeUser.class); + return util.exportExcel(list, "用户邀请数据"); + } + + /** + * 获取用户邀请详细信息 + */ + @PreAuthorize("@ss.hasPermi('frequency:refereeuser:query')") + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") Long id) + { + return AjaxResult.success(refereeUserService.selectRefereeUserById(id)); + } + + /** + * 新增用户邀请 + */ + @PreAuthorize("@ss.hasPermi('frequency:refereeuser:add')") + @Log(title = "用户邀请", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody RefereeUser refereeUser) + { + return toAjax(refereeUserService.insertRefereeUser(refereeUser)); + } + + /** + * 修改用户邀请 + */ + @PreAuthorize("@ss.hasPermi('frequency:refereeuser:edit')") + @Log(title = "用户邀请", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody RefereeUser refereeUser) + { + return toAjax(refereeUserService.updateRefereeUser(refereeUser)); + } + + /** + * 删除用户邀请 + */ + @PreAuthorize("@ss.hasPermi('frequency:refereeuser:remove')") + @Log(title = "用户邀请", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}") + public AjaxResult remove(@PathVariable Long[] ids) + { + return toAjax(refereeUserService.deleteRefereeUserByIds(ids)); + } +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/refereeuser/entity/RefereeUser.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/refereeuser/entity/RefereeUser.java new file mode 100644 index 0000000..6b93602 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/refereeuser/entity/RefereeUser.java @@ -0,0 +1,54 @@ +package com.ruoyi.frequency.refereeuser.entity; + +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableName; +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import com.ruoyi.vo.UserInfo; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; + +/** + * 用户邀请对象 t_referee_user + * + * @author liwenlong + * @date 2023-07-20 + */ +@Data +@Accessors(chain = true) +@TableName("t_referee_user") +public class RefereeUser extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** 主键id */ + private Long id; + + + + /** 删除标志;1正常;删除 3 禁用 */ + private Integer delFlag; + + /** 用户类型;1用户 */ + @Excel(name = "用户类型;1用户") + private Integer userType; + + /** 用户id */ + @Excel(name = "用户id") + private Long userId; + + /** 上级用户类型;1用户 */ + @Excel(name = "上级用户类型;1用户") + private Integer parentUserType; + + /** 邀请用户上级id */ + @Excel(name = "邀请用户上级id") + private Long parentUserId; + + + @ApiModelProperty(value = "邀请用户信息") + @TableField(exist = false) + private UserInfo userInfo; + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/refereeuser/mapper/RefereeUserMapper.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/refereeuser/mapper/RefereeUserMapper.java new file mode 100644 index 0000000..02053af --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/refereeuser/mapper/RefereeUserMapper.java @@ -0,0 +1,69 @@ +package com.ruoyi.frequency.refereeuser.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.ruoyi.controller.resp.RefereeUserPageResp; +import com.ruoyi.frequency.refereeuser.entity.RefereeUser; +import com.ruoyi.vo.UserVo; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * 用户邀请Mapper接口 + * + * @author liwenlong + * @date 2023-07-20 + */ +public interface RefereeUserMapper extends BaseMapper +{ + /** + * 查询用户邀请 + * + * @param id 用户邀请主键 + * @return 用户邀请 + */ + RefereeUser selectRefereeUserById(Long id); + + /** + * 查询用户邀请列表 + * + * @param refereeUser 用户邀请 + * @return 用户邀请集合 + */ + List selectRefereeUserList(RefereeUser refereeUser); + + /** + * 新增用户邀请 + * + * @param refereeUser 用户邀请 + * @return 结果 + */ + int insertRefereeUser(RefereeUser refereeUser); + + /** + * 修改用户邀请 + * + * @param refereeUser 用户邀请 + * @return 结果 + */ + int updateRefereeUser(RefereeUser refereeUser); + + /** + * 删除用户邀请 + * + * @param id 用户邀请主键 + * @return 结果 + */ + int deleteRefereeUserById(Long id); + + /** + * 批量删除用户邀请 + * + * @param ids 需要删除的数据主键集合 + * @return 结果 + */ + int deleteRefereeUserByIds(Long[] ids); + + Page refereeUserPage(@Param("page") Page objectPage, @Param("userVo") UserVo userVo); +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/refereeuser/mapper/mapping/RefereeUserMapper.xml b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/refereeuser/mapper/mapping/RefereeUserMapper.xml new file mode 100644 index 0000000..1325f1a --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/refereeuser/mapper/mapping/RefereeUserMapper.xml @@ -0,0 +1,137 @@ + + + + + + + + + + + + + + + + + + + select id, create_by, create_time, update_by, update_time, del_flag, user_type, user_id, parent_user_type, parent_user_id from t_referee_user + + + + + + + + insert into t_referee_user + + id, + create_by, + create_time, + update_by, + update_time, + del_flag, + user_type, + user_id, + parent_user_type, + parent_user_id, + + + #{id}, + #{createBy}, + #{createTime}, + #{updateBy}, + #{updateTime}, + #{delFlag}, + #{userType}, + #{userId}, + #{parentUserType}, + #{parentUserId}, + + + + + update t_referee_user + + create_by = #{createBy}, + create_time = #{createTime}, + update_by = #{updateBy}, + update_time = #{updateTime}, + del_flag = #{delFlag}, + user_type = #{userType}, + user_id = #{userId}, + parent_user_type = #{parentUserType}, + parent_user_id = #{parentUserId}, + + where id = #{id} + + + + delete from t_referee_user where id = #{id} + + + + delete from t_referee_user where id in + + #{id} + + + + + diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/refereeuser/model/param/RefereeUserParam.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/refereeuser/model/param/RefereeUserParam.java new file mode 100644 index 0000000..7f074ae --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/refereeuser/model/param/RefereeUserParam.java @@ -0,0 +1,53 @@ +package com.ruoyi.frequency.refereeuser.model.param; + +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import lombok.Data; +import lombok.experimental.Accessors; + +/** + * 用户邀请对象 t_referee_user + * + * @author liwenlong + * @date 2023-07-20 + */ +@Data +@Accessors(chain = true) +public class RefereeUserParam extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** 主键id */ + private Long id; + + + + /** 删除标志;1正常;删除 3 禁用 */ + private Integer delFlag; + + /** 用户类型;1用户 */ + @Excel(name = "用户类型;1用户") + private Integer userType; + + /** 用户id */ + @Excel(name = "用户id") + private Long userId; + + /** 上级用户类型;1用户 */ + @Excel(name = "上级用户类型;1用户") + private Integer parentUserType; + + /** 邀请用户上级id */ + @Excel(name = "邀请用户上级id") + private Long parentUserId; + + + + + + + + + + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/refereeuser/model/result/RefereeUserResult.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/refereeuser/model/result/RefereeUserResult.java new file mode 100644 index 0000000..94b6de3 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/refereeuser/model/result/RefereeUserResult.java @@ -0,0 +1,45 @@ +package com.ruoyi.frequency.refereeuser.model.result; + +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import lombok.Data; +import lombok.experimental.Accessors; + +/** + * 用户邀请对象 t_referee_user + * + * @author liwenlong + * @date 2023-07-20 + */ +@Data +@Accessors(chain = true) +public class RefereeUserResult extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** 主键id */ + private Long id; + + + + /** 删除标志;1正常;删除 3 禁用 */ + private Integer delFlag; + + /** 用户类型;1用户 */ + @Excel(name = "用户类型;1用户") + private Integer userType; + + /** 用户id */ + @Excel(name = "用户id") + private Long userId; + + /** 上级用户类型;1用户 */ + @Excel(name = "上级用户类型;1用户") + private Integer parentUserType; + + /** 邀请用户上级id */ + @Excel(name = "邀请用户上级id") + private Long parentUserId; + + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/refereeuser/service/RefereeUserService.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/refereeuser/service/RefereeUserService.java new file mode 100644 index 0000000..370d6c1 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/refereeuser/service/RefereeUserService.java @@ -0,0 +1,75 @@ +package com.ruoyi.frequency.refereeuser.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.ruoyi.frequency.refereeuser.entity.RefereeUser; +import com.ruoyi.response.ResponseData; +import com.ruoyi.vo.PageBasic; +import com.ruoyi.vo.UserVo; + +import java.util.List; + +/** + * 用户邀请Service接口 + * + * @author liwenlong + * @date 2023-07-20 + */ +public interface RefereeUserService extends IService +{ + /** + * 查询用户邀请 + * + * @param id 用户邀请主键 + * @return 用户邀请 + */ + RefereeUser selectRefereeUserById(Long id); + + /** + * 查询用户邀请列表 + * + * @param refereeUser 用户邀请 + * @return 用户邀请集合 + */ + List selectRefereeUserList(RefereeUser refereeUser); + + /** + * 新增用户邀请 + * + * @param refereeUser 用户邀请 + * @return 结果 + */ + int insertRefereeUser(RefereeUser refereeUser); + + /** + * 修改用户邀请 + * + * @param refereeUser 用户邀请 + * @return 结果 + */ + int updateRefereeUser(RefereeUser refereeUser); + + /** + * 批量删除用户邀请 + * + * @param ids 需要删除的用户邀请主键集合 + * @return 结果 + */ + int deleteRefereeUserByIds(Long[] ids); + + /** + * 删除用户邀请信息 + * + * @param id 用户邀请主键 + * @return 结果 + */ + int deleteRefereeUserById(Long id); + + + /** + * 邀请用户列表 + * @param req + * @param userVo + * @return + */ + ResponseData refereeUserPage(PageBasic req, UserVo userVo); +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/refereeuser/service/impl/RefereeUserServiceImpl.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/refereeuser/service/impl/RefereeUserServiceImpl.java new file mode 100644 index 0000000..bb199e4 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/refereeuser/service/impl/RefereeUserServiceImpl.java @@ -0,0 +1,149 @@ +package com.ruoyi.frequency.refereeuser.service.impl; + +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.ruoyi.common.page.PageResult; +import com.ruoyi.common.utils.DateUtils; +import com.ruoyi.controller.resp.RefereeUserPageResp; +import com.ruoyi.frequency.customer.service.UserService; +import com.ruoyi.frequency.refereeuser.entity.RefereeUser; +import com.ruoyi.frequency.refereeuser.mapper.RefereeUserMapper; +import com.ruoyi.frequency.refereeuser.service.RefereeUserService; +import com.ruoyi.response.ResponseData; +import com.ruoyi.vo.PageBasic; +import com.ruoyi.vo.UserInfo; +import com.ruoyi.vo.UserVo; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.stream.Collectors; + +/** + * 用户邀请Service业务层处理 + * + * @author liwenlong + * @date 2023-07-20 + */ +@Service +public class RefereeUserServiceImpl extends ServiceImpl implements RefereeUserService +{ + @Autowired + private RefereeUserMapper refereeUserMapper; + + /** + * 查询用户邀请 + * + * @param id 用户邀请主键 + * @return 用户邀请 + */ + @Override + public RefereeUser selectRefereeUserById(Long id) + { + return refereeUserMapper.selectRefereeUserById(id); + } + + @Autowired + private UserService userService; + /** + * 查询用户邀请列表 + * + * @param refereeUser 用户邀请 + * @return 用户邀请 + */ + @Override + public List selectRefereeUserList(RefereeUser refereeUser) + { + + List refereeUsers = refereeUserMapper.selectRefereeUserList(refereeUser); + + if (refereeUsers.size() > 0){ + Set userVoSet = refereeUsers.stream().map(s->new UserVo(s.getUserType(), s.getUserId())).collect(Collectors.toSet()); + + //查询用户信息 + Map userMap = userService.selectUserInfoMap(userVoSet,null); + + refereeUsers.stream().forEach(s->{ + s.setUserInfo(userMap.get(new UserVo(s.getUserType(), s.getUserId()))); + }); + } + + return refereeUsers; + } + + /** + * 新增用户邀请 + * + * @param refereeUser 用户邀请 + * @return 结果 + */ + @Override + public int insertRefereeUser(RefereeUser refereeUser) + { + refereeUser.setCreateTime(DateUtils.getNowDate()); + return refereeUserMapper.insertRefereeUser(refereeUser); + } + + /** + * 修改用户邀请 + * + * @param refereeUser 用户邀请 + * @return 结果 + */ + @Override + public int updateRefereeUser(RefereeUser refereeUser) + { + refereeUser.setUpdateTime(DateUtils.getNowDate()); + return refereeUserMapper.updateRefereeUser(refereeUser); + } + + /** + * 批量删除用户邀请 + * + * @param ids 需要删除的用户邀请主键 + * @return 结果 + */ + @Override + public int deleteRefereeUserByIds(Long[] ids) + { + return refereeUserMapper.deleteRefereeUserByIds(ids); + } + + /** + * 删除用户邀请信息 + * + * @param id 用户邀请主键 + * @return 结果 + */ + @Override + public int deleteRefereeUserById(Long id) + { + return refereeUserMapper.deleteRefereeUserById(id); + } + + + @Override + public ResponseData refereeUserPage(PageBasic req, UserVo userVo) { + userService.storeByEnterprise(userVo); + + Page page = this.baseMapper.refereeUserPage(new Page<>(req.getPageNo(),req.getPageSize()),userVo); + + if (!page.getRecords().isEmpty()){ + + Set userVoSet = page.getRecords().stream().map(resp -> new UserVo(resp.getUserType(), resp.getUserId())).collect(Collectors.toSet()); + //查询用户信息 + Map userMap = userService.selectUserInfoMap(userVoSet,userVo); + + Integer i = (req.getPageNo() - 1) * req.getPageSize() + 1; + + for (RefereeUserPageResp resp : page.getRecords()) { + resp.setUserInfo(userMap.get(new UserVo(resp.getUserType(), resp.getUserId()))); + resp.setRanking(i++); + } + } + + return ResponseData.success(new PageResult<>(page)); + } +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/relationaddress/controller/RelationAddressController.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/relationaddress/controller/RelationAddressController.java new file mode 100644 index 0000000..ec9d929 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/relationaddress/controller/RelationAddressController.java @@ -0,0 +1,97 @@ +package com.ruoyi.frequency.relationaddress.controller; + +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.page.TableDataInfo; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.common.utils.poi.ExcelUtil; +import com.ruoyi.frequency.relationaddress.entity.RelationAddress; +import com.ruoyi.frequency.relationaddress.service.RelationAddressService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +/** + * 地址与相关对象关联;如订单关联地址等Controller + * + * @author liwenlong + * @date 2023-07-20 + */ +@RestController +@RequestMapping("/frequency/relationaddress") +public class RelationAddressController extends BaseController +{ + @Autowired + private RelationAddressService relationAddressService; + + /** + * 查询地址与相关对象关联;如订单关联地址等列表 + */ + @PreAuthorize("@ss.hasPermi('frequency:relationaddress:list')") + @GetMapping("/list") + public TableDataInfo list(RelationAddress relationAddress) + { + startPage(); + List list = relationAddressService.selectRelationAddressList(relationAddress); + return getDataTable(list); + } + + /** + * 导出地址与相关对象关联;如订单关联地址等列表 + */ + @PreAuthorize("@ss.hasPermi('frequency:relationaddress:export')") + @Log(title = "地址与相关对象关联;如订单关联地址等", businessType = BusinessType.EXPORT) + @GetMapping("/export") + public AjaxResult export(RelationAddress relationAddress) + { + List list = relationAddressService.selectRelationAddressList(relationAddress); + ExcelUtil util = new ExcelUtil(RelationAddress.class); + return util.exportExcel(list, "地址与相关对象关联;如订单关联地址等数据"); + } + + /** + * 获取地址与相关对象关联;如订单关联地址等详细信息 + */ + @PreAuthorize("@ss.hasPermi('frequency:relationaddress:query')") + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") Long id) + { + return AjaxResult.success(relationAddressService.selectRelationAddressById(id)); + } + + /** + * 新增地址与相关对象关联;如订单关联地址等 + */ + @PreAuthorize("@ss.hasPermi('frequency:relationaddress:add')") + @Log(title = "地址与相关对象关联;如订单关联地址等", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody RelationAddress relationAddress) + { + return toAjax(relationAddressService.insertRelationAddress(relationAddress)); + } + + /** + * 修改地址与相关对象关联;如订单关联地址等 + */ + @PreAuthorize("@ss.hasPermi('frequency:relationaddress:edit')") + @Log(title = "地址与相关对象关联;如订单关联地址等", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody RelationAddress relationAddress) + { + return toAjax(relationAddressService.updateRelationAddress(relationAddress)); + } + + /** + * 删除地址与相关对象关联;如订单关联地址等 + */ + @PreAuthorize("@ss.hasPermi('frequency:relationaddress:remove')") + @Log(title = "地址与相关对象关联;如订单关联地址等", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}") + public AjaxResult remove(@PathVariable Long[] ids) + { + return toAjax(relationAddressService.deleteRelationAddressByIds(ids)); + } +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/relationaddress/entity/RelationAddress.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/relationaddress/entity/RelationAddress.java new file mode 100644 index 0000000..284ee56 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/relationaddress/entity/RelationAddress.java @@ -0,0 +1,79 @@ +package com.ruoyi.frequency.relationaddress.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import lombok.Data; +import lombok.experimental.Accessors; + +/** + * 地址与相关对象关联;如订单关联地址等对象 t_relation_address + * + * @author liwenlong + * @date 2023-07-20 + */ +@Data +@Accessors(chain = true) +@TableName("t_relation_address") +public class RelationAddress extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** 租户号 */ + private Long id; + + /** 删除标识 1 正常 2 删除 3 禁用 */ + private Integer delFlag; + + + + /** 用户id */ + @Excel(name = "用户id") + private Long customerId; + + /** 用户名 */ + @Excel(name = "用户名") + private String username; + + /** 手机号 */ + @Excel(name = "手机号") + private String mobile; + + /** 省 */ + @Excel(name = "省") + private String province; + + /** 市 */ + @Excel(name = "市") + private String city; + + /** 区 */ + @Excel(name = "区") + private String area; + + /** 地址 */ + @Excel(name = "地址") + private String address; + + /** 详细地址 */ + @Excel(name = "详细地址") + private String detail; + + /** 经度 */ + @Excel(name = "经度") + private String longitude; + + /** 纬度 */ + @Excel(name = "纬度") + private String latitude; + + /** 关联类型;请根据具体项目 */ + @Excel(name = "关联类型;请根据具体项目") + private Integer relationType; + + /** 关联对象id */ + @Excel(name = "关联对象id") + private Long relationId; + + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/relationaddress/mapper/RelationAddressMapper.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/relationaddress/mapper/RelationAddressMapper.java new file mode 100644 index 0000000..6cc8983 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/relationaddress/mapper/RelationAddressMapper.java @@ -0,0 +1,63 @@ +package com.ruoyi.frequency.relationaddress.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.ruoyi.frequency.relationaddress.entity.RelationAddress; + +import java.util.List; + +/** + * 地址与相关对象关联;如订单关联地址等Mapper接口 + * + * @author liwenlong + * @date 2023-07-20 + */ +public interface RelationAddressMapper extends BaseMapper +{ + /** + * 查询地址与相关对象关联;如订单关联地址等 + * + * @param id 地址与相关对象关联;如订单关联地址等主键 + * @return 地址与相关对象关联;如订单关联地址等 + */ + RelationAddress selectRelationAddressById(Long id); + + /** + * 查询地址与相关对象关联;如订单关联地址等列表 + * + * @param relationAddress 地址与相关对象关联;如订单关联地址等 + * @return 地址与相关对象关联;如订单关联地址等集合 + */ + List selectRelationAddressList(RelationAddress relationAddress); + + /** + * 新增地址与相关对象关联;如订单关联地址等 + * + * @param relationAddress 地址与相关对象关联;如订单关联地址等 + * @return 结果 + */ + int insertRelationAddress(RelationAddress relationAddress); + + /** + * 修改地址与相关对象关联;如订单关联地址等 + * + * @param relationAddress 地址与相关对象关联;如订单关联地址等 + * @return 结果 + */ + int updateRelationAddress(RelationAddress relationAddress); + + /** + * 删除地址与相关对象关联;如订单关联地址等 + * + * @param id 地址与相关对象关联;如订单关联地址等主键 + * @return 结果 + */ + int deleteRelationAddressById(Long id); + + /** + * 批量删除地址与相关对象关联;如订单关联地址等 + * + * @param ids 需要删除的数据主键集合 + * @return 结果 + */ + int deleteRelationAddressByIds(Long[] ids); +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/relationaddress/mapper/mapping/RelationAddressMapper.xml b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/relationaddress/mapper/mapping/RelationAddressMapper.xml new file mode 100644 index 0000000..2e5cf76 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/relationaddress/mapper/mapping/RelationAddressMapper.xml @@ -0,0 +1,135 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + select id, del_flag, create_by, create_time, update_by, update_time, customer_id, username, mobile, province, city, area, address, detail, longitude, latitude, relation_type, relation_id from t_relation_address + + + + + + + + insert into t_relation_address + + id, + del_flag, + create_by, + create_time, + update_by, + update_time, + customer_id, + username, + mobile, + province, + city, + area, + address, + detail, + longitude, + latitude, + relation_type, + relation_id, + + + #{id}, + #{delFlag}, + #{createBy}, + #{createTime}, + #{updateBy}, + #{updateTime}, + #{customerId}, + #{username}, + #{mobile}, + #{province}, + #{city}, + #{area}, + #{address}, + #{detail}, + #{longitude}, + #{latitude}, + #{relationType}, + #{relationId}, + + + + + update t_relation_address + + del_flag = #{delFlag}, + create_by = #{createBy}, + create_time = #{createTime}, + update_by = #{updateBy}, + update_time = #{updateTime}, + customer_id = #{customerId}, + username = #{username}, + mobile = #{mobile}, + province = #{province}, + city = #{city}, + area = #{area}, + address = #{address}, + detail = #{detail}, + longitude = #{longitude}, + latitude = #{latitude}, + relation_type = #{relationType}, + relation_id = #{relationId}, + + where id = #{id} + + + + delete from t_relation_address where id = #{id} + + + + delete from t_relation_address where id in + + #{id} + + + \ No newline at end of file diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/relationaddress/model/param/RelationAddressParam.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/relationaddress/model/param/RelationAddressParam.java new file mode 100644 index 0000000..933099a --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/relationaddress/model/param/RelationAddressParam.java @@ -0,0 +1,93 @@ +package com.ruoyi.frequency.relationaddress.model.param; + +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import lombok.Data; +import lombok.experimental.Accessors; + +/** + * 地址与相关对象关联;如订单关联地址等对象 t_relation_address + * + * @author liwenlong + * @date 2023-07-20 + */ +@Data +@Accessors(chain = true) +public class RelationAddressParam extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** 租户号 */ + private Long id; + + /** 删除标识 1 正常 2 删除 3 禁用 */ + private Integer delFlag; + + + + /** 用户id */ + @Excel(name = "用户id") + private Long customerId; + + /** 用户名 */ + @Excel(name = "用户名") + private String username; + + /** 手机号 */ + @Excel(name = "手机号") + private String mobile; + + /** 省 */ + @Excel(name = "省") + private String province; + + /** 市 */ + @Excel(name = "市") + private String city; + + /** 区 */ + @Excel(name = "区") + private String area; + + /** 地址 */ + @Excel(name = "地址") + private String address; + + /** 详细地址 */ + @Excel(name = "详细地址") + private String detail; + + /** 经度 */ + @Excel(name = "经度") + private String longitude; + + /** 纬度 */ + @Excel(name = "纬度") + private String latitude; + + /** 关联类型;请根据具体项目 */ + @Excel(name = "关联类型;请根据具体项目") + private Integer relationType; + + /** 关联对象id */ + @Excel(name = "关联对象id") + private Long relationId; + + + + + + + + + + + + + + + + + + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/relationaddress/model/result/RelationAddressResult.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/relationaddress/model/result/RelationAddressResult.java new file mode 100644 index 0000000..ddc3222 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/relationaddress/model/result/RelationAddressResult.java @@ -0,0 +1,77 @@ +package com.ruoyi.frequency.relationaddress.model.result; + +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import lombok.Data; +import lombok.experimental.Accessors; + +/** + * 地址与相关对象关联;如订单关联地址等对象 t_relation_address + * + * @author liwenlong + * @date 2023-07-20 + */ +@Data +@Accessors(chain = true) +public class RelationAddressResult extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** 租户号 */ + private Long id; + + /** 删除标识 1 正常 2 删除 3 禁用 */ + private Integer delFlag; + + + + /** 用户id */ + @Excel(name = "用户id") + private Long customerId; + + /** 用户名 */ + @Excel(name = "用户名") + private String username; + + /** 手机号 */ + @Excel(name = "手机号") + private String mobile; + + /** 省 */ + @Excel(name = "省") + private String province; + + /** 市 */ + @Excel(name = "市") + private String city; + + /** 区 */ + @Excel(name = "区") + private String area; + + /** 地址 */ + @Excel(name = "地址") + private String address; + + /** 详细地址 */ + @Excel(name = "详细地址") + private String detail; + + /** 经度 */ + @Excel(name = "经度") + private String longitude; + + /** 纬度 */ + @Excel(name = "纬度") + private String latitude; + + /** 关联类型;请根据具体项目 */ + @Excel(name = "关联类型;请根据具体项目") + private Integer relationType; + + /** 关联对象id */ + @Excel(name = "关联对象id") + private Long relationId; + + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/relationaddress/service/RelationAddressService.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/relationaddress/service/RelationAddressService.java new file mode 100644 index 0000000..c8d37ef --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/relationaddress/service/RelationAddressService.java @@ -0,0 +1,63 @@ +package com.ruoyi.frequency.relationaddress.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.ruoyi.frequency.relationaddress.entity.RelationAddress; + +import java.util.List; + +/** + * 地址与相关对象关联;如订单关联地址等Service接口 + * + * @author liwenlong + * @date 2023-07-20 + */ +public interface RelationAddressService extends IService +{ + /** + * 查询地址与相关对象关联;如订单关联地址等 + * + * @param id 地址与相关对象关联;如订单关联地址等主键 + * @return 地址与相关对象关联;如订单关联地址等 + */ + RelationAddress selectRelationAddressById(Long id); + + /** + * 查询地址与相关对象关联;如订单关联地址等列表 + * + * @param relationAddress 地址与相关对象关联;如订单关联地址等 + * @return 地址与相关对象关联;如订单关联地址等集合 + */ + List selectRelationAddressList(RelationAddress relationAddress); + + /** + * 新增地址与相关对象关联;如订单关联地址等 + * + * @param relationAddress 地址与相关对象关联;如订单关联地址等 + * @return 结果 + */ + int insertRelationAddress(RelationAddress relationAddress); + + /** + * 修改地址与相关对象关联;如订单关联地址等 + * + * @param relationAddress 地址与相关对象关联;如订单关联地址等 + * @return 结果 + */ + int updateRelationAddress(RelationAddress relationAddress); + + /** + * 批量删除地址与相关对象关联;如订单关联地址等 + * + * @param ids 需要删除的地址与相关对象关联;如订单关联地址等主键集合 + * @return 结果 + */ + int deleteRelationAddressByIds(Long[] ids); + + /** + * 删除地址与相关对象关联;如订单关联地址等信息 + * + * @param id 地址与相关对象关联;如订单关联地址等主键 + * @return 结果 + */ + int deleteRelationAddressById(Long id); +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/relationaddress/service/impl/RelationAddressServiceImpl.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/relationaddress/service/impl/RelationAddressServiceImpl.java new file mode 100644 index 0000000..b3e5f83 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/relationaddress/service/impl/RelationAddressServiceImpl.java @@ -0,0 +1,98 @@ +package com.ruoyi.frequency.relationaddress.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.ruoyi.common.utils.DateUtils; +import com.ruoyi.frequency.relationaddress.entity.RelationAddress; +import com.ruoyi.frequency.relationaddress.mapper.RelationAddressMapper; +import com.ruoyi.frequency.relationaddress.service.RelationAddressService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * 地址与相关对象关联;如订单关联地址等Service业务层处理 + * + * @author liwenlong + * @date 2023-07-20 + */ +@Service +public class RelationAddressServiceImpl extends ServiceImpl implements RelationAddressService +{ + @Autowired + private RelationAddressMapper relationAddressMapper; + + /** + * 查询地址与相关对象关联;如订单关联地址等 + * + * @param id 地址与相关对象关联;如订单关联地址等主键 + * @return 地址与相关对象关联;如订单关联地址等 + */ + @Override + public RelationAddress selectRelationAddressById(Long id) + { + return relationAddressMapper.selectRelationAddressById(id); + } + + /** + * 查询地址与相关对象关联;如订单关联地址等列表 + * + * @param relationAddress 地址与相关对象关联;如订单关联地址等 + * @return 地址与相关对象关联;如订单关联地址等 + */ + @Override + public List selectRelationAddressList(RelationAddress relationAddress) + { + return relationAddressMapper.selectRelationAddressList(relationAddress); + } + + /** + * 新增地址与相关对象关联;如订单关联地址等 + * + * @param relationAddress 地址与相关对象关联;如订单关联地址等 + * @return 结果 + */ + @Override + public int insertRelationAddress(RelationAddress relationAddress) + { + relationAddress.setCreateTime(DateUtils.getNowDate()); + return relationAddressMapper.insertRelationAddress(relationAddress); + } + + /** + * 修改地址与相关对象关联;如订单关联地址等 + * + * @param relationAddress 地址与相关对象关联;如订单关联地址等 + * @return 结果 + */ + @Override + public int updateRelationAddress(RelationAddress relationAddress) + { + relationAddress.setUpdateTime(DateUtils.getNowDate()); + return relationAddressMapper.updateRelationAddress(relationAddress); + } + + /** + * 批量删除地址与相关对象关联;如订单关联地址等 + * + * @param ids 需要删除的地址与相关对象关联;如订单关联地址等主键 + * @return 结果 + */ + @Override + public int deleteRelationAddressByIds(Long[] ids) + { + return relationAddressMapper.deleteRelationAddressByIds(ids); + } + + /** + * 删除地址与相关对象关联;如订单关联地址等信息 + * + * @param id 地址与相关对象关联;如订单关联地址等主键 + * @return 结果 + */ + @Override + public int deleteRelationAddressById(Long id) + { + return relationAddressMapper.deleteRelationAddressById(id); + } +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/report/controller/ReportController.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/report/controller/ReportController.java new file mode 100644 index 0000000..e0b0be9 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/report/controller/ReportController.java @@ -0,0 +1,108 @@ +package com.ruoyi.frequency.report.controller; + +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.page.TableDataInfo; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.common.utils.poi.ExcelUtil; +import com.ruoyi.frequency.report.entity.Report; +import com.ruoyi.frequency.report.service.ReportService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +/** + * 举报用户Controller + * + * @author liwenlong + * @date 2023-11-17 + */ +@RestController +@RequestMapping("/frequency/report") +public class ReportController extends BaseController +{ + @Autowired + private ReportService reportService; + + /** + * 查询举报用户列表 + */ + @PreAuthorize("@ss.hasPermi('frequency:report:list')") + @PostMapping("/list") + public TableDataInfo list(@RequestBody Report report) + { + startPage(); + List list = reportService.selectReportList(report); + return getDataTable(list); + } + + /** + * 导出举报用户列表 + */ + @PreAuthorize("@ss.hasPermi('frequency:report:export')") + @Log(title = "举报用户", businessType = BusinessType.EXPORT) + @GetMapping("/export") + public AjaxResult export(Report report) + { + List list = reportService.selectReportList(report); + ExcelUtil util = new ExcelUtil(Report.class); + return util.exportExcel(list, "举报用户数据"); + } + + /** + * 获取举报用户详细信息 + */ + @PreAuthorize("@ss.hasPermi('frequency:report:query')") + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") Long id) + { + return AjaxResult.success(reportService.selectReportById(id)); + } + + /** + * 新增举报用户 + */ + @PreAuthorize("@ss.hasPermi('frequency:report:add')") + @Log(title = "举报用户", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody Report report) + { + return toAjax(reportService.insertReport(report)); + } + + /** + * 修改举报用户 + */ + @PreAuthorize("@ss.hasPermi('frequency:report:edit')") + @Log(title = "举报用户", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody Report report) + { + return toAjax(reportService.updateReport(report)); + } + + /** + * 删除举报用户 + */ + @PreAuthorize("@ss.hasPermi('frequency:report:remove')") + @Log(title = "举报用户", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}/{delFlag}") + public AjaxResult remove(@PathVariable("ids") Long[] ids,@PathVariable("delFlag") Integer delFlag) + { + return toAjax(reportService.deleteReportByIds(ids,delFlag)); + } + + /** + * 举报处理 + */ + @PreAuthorize("@ss.hasPermi('frequency:report:handle')") + @Log(title = "举报用户", businessType = BusinessType.UPDATE) + @PostMapping("/handle") + public AjaxResult handle(@RequestBody Report report) + { + return reportService.handle(report); + } +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/report/entity/Report.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/report/entity/Report.java new file mode 100644 index 0000000..757b97f --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/report/entity/Report.java @@ -0,0 +1,84 @@ +package com.ruoyi.frequency.report.entity; + +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableName; +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import com.ruoyi.vo.UserInfo; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; + +import java.util.Date; + +/** + * 举报用户对象 t_report + * + * @author liwenlong + * @date 2023-11-17 + */ +@Data +@Accessors(chain = true) +@TableName("t_report") +public class Report extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + + @ApiModelProperty("租户号") + private Long id; + + @ApiModelProperty("删除状态 1 正常 2 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("用户类型") + @Excel(name = "用户类型") + private Integer userType; + + @ApiModelProperty("用户id") + @Excel(name = "用户id") + private Long userId; + + @ApiModelProperty("举报原因") + @Excel(name = "举报原因") + private String reason; + + @ApiModelProperty("内容") + @Excel(name = "内容") + private String content; + + @ApiModelProperty("图片") + @Excel(name = "图片") + private String images; + + @ApiModelProperty("被举报用户类型") + @Excel(name = "被举报用户类型") + private Integer reportUserType; + + @ApiModelProperty("被举报用户id") + @Excel(name = "被举报用户id") + private Long reportUserId; + + @ApiModelProperty("处理结果 1 未处理 2 已处理 3拒绝处理") + @Excel(name = "处理结果 1 未处理 2 已处理 3拒绝处理") + private Integer result; + + @ApiModelProperty("用户信息") + @TableField(exist = false) + private UserInfo userInfo; + + @ApiModelProperty("被举报用户信息") + @TableField(exist = false) + private UserInfo reportUserInfo; + + + @ApiModelProperty("开始时间") + @TableField(exist = false) + private Date beginTime; + + @ApiModelProperty("结束时间") + @TableField(exist = false) + private Date endTime; + + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/report/mapper/ReportMapper.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/report/mapper/ReportMapper.java new file mode 100644 index 0000000..c42a0ed --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/report/mapper/ReportMapper.java @@ -0,0 +1,48 @@ +package com.ruoyi.frequency.report.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.ruoyi.frequency.report.entity.Report; + +import java.util.List; + +/** + * 举报用户Mapper接口 + * + * @author liwenlong + * @date 2023-11-17 + */ +public interface ReportMapper extends BaseMapper +{ + /** + * 查询举报用户 + * + * @param id 举报用户主键 + * @return 举报用户 + */ + public Report selectReportById(Long id); + + /** + * 查询举报用户列表 + * + * @param report 举报用户 + * @return 举报用户集合 + */ + public List selectReportList(Report report); + + /** + * 新增举报用户 + * + * @param report 举报用户 + * @return 结果 + */ + public int insertReport(Report report); + + /** + * 修改举报用户 + * + * @param report 举报用户 + * @return 结果 + */ + public int updateReport(Report report); + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/report/mapper/mapping/ReportMapper.xml b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/report/mapper/mapping/ReportMapper.xml new file mode 100644 index 0000000..bead789 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/report/mapper/mapping/ReportMapper.xml @@ -0,0 +1,177 @@ + + + + + + + + + + + + + + + + + + + + + + + + + select + t.id , + t.create_by , + t.create_time , + t.update_by , + t.update_time , + t.del_flag , + t.user_type , + t.user_id , + t.reason , + t.content , + t.images , + t.report_user_type , + t.report_user_id , + t.result , + t.remark + from t_report AS t + LEFT JOIN t_store s on t.user_id = s.id and t.user_type = 2 + LEFT JOIN t_customer c on t.user_id = c.id and t.user_type = 1 + LEFT JOIN t_sale sa on t.user_id = sa.id and t.user_type = 3 + LEFT JOIN t_store s2 on t.report_user_id = s2.id and t.report_user_type = 2 + LEFT JOIN t_customer c2 on t.report_user_id = c2.id and t.report_user_type = 1 + LEFT JOIN t_sale sa2 on t.report_user_id = sa2.id and t.report_user_type = 3 + + + + + + + + insert into t_report + + id, + create_by, + create_time, + update_by, + update_time, + del_flag, + user_type, + user_id, + reason, + content, + images, + report_user_type, + report_user_id, + result, + remark, + + + #{id}, + #{createBy}, + #{createTime}, + #{updateBy}, + #{updateTime}, + #{delFlag}, + #{userType}, + #{userId}, + #{reason}, + #{content}, + #{images}, + #{reportUserType}, + #{reportUserId}, + #{result}, + #{remark}, + + + + + update t_report + + create_by = #{createBy}, + create_time = #{createTime}, + update_by = #{updateBy}, + update_time = #{updateTime}, + del_flag = #{delFlag}, + user_type = #{userType}, + user_id = #{userId}, + reason = #{reason}, + content = #{content}, + images = #{images}, + report_user_type = #{reportUserType}, + report_user_id = #{reportUserId}, + result = #{result}, + remark = #{remark}, + + where id = #{id} + + \ No newline at end of file diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/report/model/param/ReportParam.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/report/model/param/ReportParam.java new file mode 100644 index 0000000..513f0f7 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/report/model/param/ReportParam.java @@ -0,0 +1,70 @@ +package com.ruoyi.frequency.report.model.param; + +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; + +/** + * 举报用户对象 t_report + * + * @author liwenlong + * @date 2023-11-17 + */ +@Data +@Accessors(chain = true) +public class ReportParam extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + @ApiModelProperty("租户号") + private Long id; + + @ApiModelProperty("删除状态 1 正常 2 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("用户类型") + @Excel(name = "用户类型") + private Integer userType; + + @ApiModelProperty("用户id") + @Excel(name = "用户id") + private Long userId; + + @ApiModelProperty("举报原因") + @Excel(name = "举报原因") + private String reason; + + @ApiModelProperty("内容") + @Excel(name = "内容") + private String content; + + @ApiModelProperty("图片") + @Excel(name = "图片") + private String images; + + @ApiModelProperty("被举报用户类型") + @Excel(name = "被举报用户类型") + private Integer reportUserType; + + @ApiModelProperty("被举报用户id") + @Excel(name = "被举报用户id") + private Long reportUserId; + + @ApiModelProperty("处理结果 1 未处理 2 已处理 3拒绝处理") + @Excel(name = "处理结果 1 未处理 2 已处理 3拒绝处理") + private Integer result; + + + + + + + + + + + + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/report/model/result/ReportResult.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/report/model/result/ReportResult.java new file mode 100644 index 0000000..0bf8e73 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/report/model/result/ReportResult.java @@ -0,0 +1,60 @@ +package com.ruoyi.frequency.report.model.result; + +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; + +/** + * 举报用户对象 t_report + * + * @author liwenlong + * @date 2023-11-17 + */ +@Data +@Accessors(chain = true) +public class ReportResult extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + @ApiModelProperty("租户号") + private Long id; + + @ApiModelProperty("删除状态 1 正常 2 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("用户类型") + @Excel(name = "用户类型") + private Integer userType; + + @ApiModelProperty("用户id") + @Excel(name = "用户id") + private Long userId; + + @ApiModelProperty("举报原因") + @Excel(name = "举报原因") + private String reason; + + @ApiModelProperty("内容") + @Excel(name = "内容") + private String content; + + @ApiModelProperty("图片") + @Excel(name = "图片") + private String images; + + @ApiModelProperty("被举报用户类型") + @Excel(name = "被举报用户类型") + private Integer reportUserType; + + @ApiModelProperty("被举报用户id") + @Excel(name = "被举报用户id") + private Long reportUserId; + + @ApiModelProperty("处理结果 1 未处理 2 已处理 3拒绝处理") + @Excel(name = "处理结果 1 未处理 2 已处理 3拒绝处理") + private Integer result; + + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/report/service/ReportService.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/report/service/ReportService.java new file mode 100644 index 0000000..17446af --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/report/service/ReportService.java @@ -0,0 +1,75 @@ +package com.ruoyi.frequency.report.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.controller.req.ReportReq; +import com.ruoyi.frequency.report.entity.Report; +import com.ruoyi.response.ResponseData; +import com.ruoyi.vo.UserVo; + +import java.util.List; + +/** + * 举报用户Service接口 + * + * @author liwenlong + * @date 2023-11-17 + */ +public interface ReportService extends IService +{ + /** + * 查询举报用户 + * + * @param id 举报用户主键 + * @return 举报用户 + */ + public Report selectReportById(Long id); + + /** + * 查询举报用户列表 + * + * @param report 举报用户 + * @return 举报用户集合 + */ + public List selectReportList(Report report); + + /** + * 新增举报用户 + * + * @param report 举报用户 + * @return 结果 + */ + public int insertReport(Report report); + + /** + * 修改举报用户 + * + * @param report 举报用户 + * @return 结果 + */ + public int updateReport(Report report); + + /** + * 批量删除举报用户 + * + * @param ids 需要删除的举报用户主键集合 + * @return 结果 + */ + public int deleteReportByIds(Long[] ids,Integer delFlag); + + /** + * 举报处理 + * @param report + * @return + */ + AjaxResult handle(Report report); + + /** + * 举报用户 + * @param req + * @param userVo + * @return + */ + ResponseData report(ReportReq req, UserVo userVo); + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/report/service/impl/ReportServiceImpl.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/report/service/impl/ReportServiceImpl.java new file mode 100644 index 0000000..adccd93 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/report/service/impl/ReportServiceImpl.java @@ -0,0 +1,206 @@ +package com.ruoyi.frequency.report.service.impl; + +import cn.hutool.core.collection.CollectionUtil; +import cn.hutool.core.util.ObjectUtil; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.ruoyi.code.PublicCommon; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.controller.req.ReportReq; +import com.ruoyi.enums.process.ProcessResultEnums; +import com.ruoyi.enums.user.UserEnums; +import com.ruoyi.frequency.customer.entity.Customer; +import com.ruoyi.frequency.customer.service.CustomerService; +import com.ruoyi.frequency.customer.service.UserService; +import com.ruoyi.frequency.report.entity.Report; +import com.ruoyi.frequency.report.mapper.ReportMapper; +import com.ruoyi.frequency.report.service.ReportService; +import com.ruoyi.frequency.store.entity.Store; +import com.ruoyi.frequency.store.service.StoreService; +import com.ruoyi.response.ResponseData; +import com.ruoyi.vo.UserInfo; +import com.ruoyi.vo.UserVo; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; +import java.util.Map; +import java.util.Set; + +/** + * 举报用户Service业务层处理 + * + * @author liwenlong + * @date 2023-11-17 + */ +@Service +public class ReportServiceImpl extends ServiceImpl implements ReportService +{ + @Autowired + private ReportMapper reportMapper; + + @Autowired + private UserService userService; + /** + * 查询举报用户 + * + * @param id 举报用户主键 + * @return 举报用户 + */ + @Override + public Report selectReportById(Long id) + { + Report report = reportMapper.selectReportById(id); + if (report != null){ + Set userVoSet = CollectionUtil.newHashSet(new UserVo(report.getUserType(), report.getUserId()),new UserVo(report.getReportUserType(), report.getReportUserId())); + + //查询用户信息 + Map userMap = userService.selectUserInfoMap(userVoSet,null); + + report.setUserInfo(userMap.get(new UserVo(report.getUserType(), report.getUserId()))); + report.setReportUserInfo(userMap.get(new UserVo(report.getReportUserType(), report.getReportUserId()))); + } + + return report; + } + + /** + * 查询举报用户列表 + * + * @param report 举报用户 + * @return 举报用户 + */ + @Override + public List selectReportList(Report report) + { + List reports = reportMapper.selectReportList(report); + + if (reports.size() > 0){ + Set userVoSet = CollectionUtil.newHashSet(); + reports.stream().forEach(s->{ + userVoSet.add(new UserVo(s.getUserType(), s.getUserId())); + userVoSet.add(new UserVo(s.getReportUserType(), s.getReportUserId())); + }); + + //查询用户信息 + Map userMap = userService.selectUserInfoMap(userVoSet,null); + + reports.stream().forEach(s ->{ + s.setUserInfo(userMap.get(new UserVo(s.getUserType(), s.getUserId()))); + s.setReportUserInfo(userMap.get(new UserVo(s.getReportUserType(), s.getReportUserId()))); + }); + } + return reports; + } + + /** + * 新增举报用户 + * + * @param report 举报用户 + * @return 结果 + */ + @Override + public int insertReport(Report report) + { + report.setCreateData(); + return reportMapper.insert(report); + } + + /** + * 修改举报用户 + * + * @param report 举报用户 + * @return 结果 + */ + @Override + public int updateReport(Report report) + { + report.setUpdateData(); + return reportMapper.updateReport(report); + } + + /** + * 批量删除举报用户 + * + * @param ids 需要删除的举报用户主键 + * @return 结果 + */ + @Override + public int deleteReportByIds(Long[] ids,Integer delFlag) + { + this.lambdaUpdate().set(Report::getDelFlag,delFlag).in(Report::getId,ids).update(); + return ids.length; + } + + + @Override + public AjaxResult handle(Report report) { + + boolean update = this.lambdaUpdate().set(Report::getResult, report.getResult()) + .eq(Report::getResult, ProcessResultEnums.PENDING.getCode()) + .eq(Report::getId, report.getId()).update(); + //处理(审核通过) + if (update && ObjectUtil.equal(ProcessResultEnums.APPROVED.getCode(), report.getResult())) { +// Report byId = this.getById(report.getId()); + } + return AjaxResult.success(); + } + + @Autowired + private CustomerService customerService; + + @Autowired + private StoreService storeService; + + + @Override + public ResponseData report(ReportReq req, UserVo userVo) { + + userService.storeByEnterprise(userVo); + + Long userId = null; + + if (req.getUserId().startsWith("SJS")){ + //判断设计师是否存在 + Customer customer = customerService.getOne(new QueryWrapper().lambda().ne(Customer::getDelFlag, PublicCommon.删除) + .eq(Customer::getNickname, req.getUserId()) + ); + if (ObjectUtil.isNull(customer)){ + return ResponseData.error("设计师不存在"); + } else if (customer.getDelFlag().equals(PublicCommon.禁用)) { + return ResponseData.error("设计师已被禁用"); + } + + userId = customer.getId(); + req.setUserType(UserEnums.customer.getCode()); + + }else if (req.getUserId().startsWith("BXS")){ + //判断设计师是否存在 + Store store = storeService.getOne(new QueryWrapper().lambda().ne(Store::getDelFlag, PublicCommon.删除) + .eq(Store::getNickname, req.getUserId()) + ); + if (ObjectUtil.isNull(store)){ + return ResponseData.error("表现师不存在"); + } else if (store.getDelFlag().equals(PublicCommon.禁用)) { + return ResponseData.error("表现师已被禁用"); + } + + userId = store.getId(); + req.setUserType(UserEnums.store.getCode()); + }else { + return ResponseData.error("用户不存在"); + } + + Report report = new Report() + .setReportUserType(req.getUserType()) + .setReportUserId(userId) + .setUserType(userVo.getUserType()) + .setUserId(userVo.getUserId()) + .setReason(req.getReason()) + .setContent(req.getContent()) + .setImages(req.getImages()); + this.save(report); + + return ResponseData.success(); + } +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/sale/controller/SaleController.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/sale/controller/SaleController.java new file mode 100644 index 0000000..be3e8db --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/sale/controller/SaleController.java @@ -0,0 +1,120 @@ +package com.ruoyi.frequency.sale.controller; + +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.page.TableDataInfo; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.common.utils.poi.ExcelUtil; +import com.ruoyi.frequency.sale.entity.Sale; +import com.ruoyi.frequency.sale.model.result.SaleCount; +import com.ruoyi.frequency.sale.service.SaleService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +/** + * 销售账号Controller + * + * @author zj + * @date 2023-09-22 + */ +@RestController +@RequestMapping("/frequency/sale") +public class SaleController extends BaseController +{ + @Autowired + private SaleService saleService; + + /** + * 查询销售账号列表 + */ + @PreAuthorize("@ss.hasPermi('frequency:sale:list')") + @PostMapping("/list") + public TableDataInfo list(@RequestBody Sale sale) + { + startPage(); + List list = saleService.selectSaleList(sale); + return getDataTable(list); + } + + /** + * 统计 + */ + @PostMapping("/statistics") + public AjaxResult statistics(@RequestBody Sale sale) + { + SaleCount count = saleService.statistics(sale); + return AjaxResult.success(count); + } + + /** + * 导出销售账号列表 + */ + @PreAuthorize("@ss.hasPermi('frequency:sale:export')") + @Log(title = "销售账号", businessType = BusinessType.EXPORT) + @GetMapping("/export") + public AjaxResult export(Sale sale) + { + List list = saleService.selectSaleList(sale); + ExcelUtil util = new ExcelUtil(Sale.class); + return util.exportExcel(list, "销售账号数据"); + } + + /** + * 获取销售账号详细信息 + */ + @PreAuthorize("@ss.hasPermi('frequency:sale:query')") + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") Long id) + { + return AjaxResult.success(saleService.selectSaleById(id)); + } + + /** + * 新增销售账号 + */ + @PreAuthorize("@ss.hasPermi('frequency:sale:add')") + @Log(title = "销售账号", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody Sale sale) + { + return toAjax(saleService.insertSale(sale)); + } + + /** + * 修改销售账号 + */ + @PreAuthorize("@ss.hasPermi('frequency:sale:edit')") + @Log(title = "销售账号", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody Sale sale) + { + return toAjax(saleService.updateSale(sale)); + } + + /** + * 删除销售账号 + */ + @PreAuthorize("@ss.hasPermi('frequency:sale:remove')") + @Log(title = "销售账号", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}/{delFlag}") + public AjaxResult remove(@PathVariable("ids") Long[] ids,@PathVariable("delFlag") Integer delFlag) + { + return toAjax(saleService.deleteSaleByIds(ids,delFlag)); + } + + + /** + * 修改余额 + */ + @PreAuthorize("@ss.hasPermi('frequency:sale:updateBalance')") + @Log(title = "销售", businessType = BusinessType.UPDATE) + @PostMapping("/updateBalance") + public AjaxResult updateBalance(@RequestBody Sale sale) + { + return saleService.updateBalance(sale); + } +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/sale/entity/Sale.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/sale/entity/Sale.java new file mode 100644 index 0000000..4a86465 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/sale/entity/Sale.java @@ -0,0 +1,135 @@ +package com.ruoyi.frequency.sale.entity; + +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableName; +import com.fasterxml.jackson.annotation.JsonFormat; +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import com.ruoyi.vo.UserInfo; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; + +import java.math.BigDecimal; +import java.util.Date; + +/** + * 销售账号对象 t_sale + * + * @author zj + * @date 2023-09-22 + */ +@Data +@Accessors(chain = true) +@TableName("t_sale") +public class Sale extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** 租户号 */ +// @TableId("INPUT") + private Long id; + + + /** 删除标志;1 正常 2 删除 3 禁用 */ + private Integer delFlag; + + /** 头像 */ + @Excel(name = "头像") + private String avatar; + + /** 手机 */ + @Excel(name = "手机") + private String mobile; + + /** 微信id */ + @Excel(name = "微信id") + private String wechatOpenid; + + /** 小程序id */ + @Excel(name = "小程序id") + private String wechatAppletOpenid; + + /** 小程序unionId*/ + @Excel(name = "小程序unionId") + private String unionId; + + /** 苹果id */ + @Excel(name = "苹果id") + private String appleOpenid; + + private String nickname; + + private String name; + /** 入行时间 */ + @Excel(name = "入行时间", width = 30, dateFormat = "yyyy-MM-dd") + @JsonFormat(pattern = "yyyy") + private Date enterDate; + + /** 微信openID */ + @Excel(name = "微信openID") + private String openId; + + /** 密码 */ + @Excel(name = "密码") + private String loginPwd; + + /** 个人签名 */ + @Excel(name = "个人签名") + private String signature; + + /** 余额 */ + @Excel(name = "余额") + private BigDecimal balance; + + /** 总收益 */ + @Excel(name = "总收益") + private BigDecimal income; + + /** 邀请码 */ + @Excel(name = "邀请码") + private String inviteCode; + + /** 推广人数 */ + @Excel(name = "推广人数") + private Integer inviteNum; + + @ApiModelProperty(value = "背景图") + private String backgroundImage; + + /** 推送是否关闭;1不关闭2 关闭 */ + @Excel(name = "推送是否关闭;1不关闭2 关闭") + private Integer closeMessage; + + @ApiModelProperty("开户行") + @Excel(name = "开户行") + private String bank; + + @ApiModelProperty("开户支行") + @Excel(name = "开户支行") + private String subbranch; + + @ApiModelProperty("银行卡") + @Excel(name = "银行卡") + private String bankCard; + + @ApiModelProperty("使用余额支付时 支付密码") + private String payPwd; + + @ApiModelProperty(value = "用户信息") + @TableField(exist = false) + private UserInfo userInfo; + + + @ApiModelProperty(value = "佣金排名") + @TableField(exist = false) + private Integer commissionRanking; + + @ApiModelProperty(value = "推广人数排名") + @TableField(exist = false) + private Integer saleRanking; + + @ApiModelProperty("排序 1降序 2升序") + @TableField(exist = false) + private Integer sortType; +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/sale/mapper/SaleMapper.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/sale/mapper/SaleMapper.java new file mode 100644 index 0000000..ffe600e --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/sale/mapper/SaleMapper.java @@ -0,0 +1,99 @@ +package com.ruoyi.frequency.sale.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.ruoyi.controller.req.SaleDetailPageReq; +import com.ruoyi.controller.resp.RankingResp; +import com.ruoyi.controller.resp.SaleDataResp; +import com.ruoyi.controller.resp.SaleDetailPageResp; +import com.ruoyi.frequency.sale.entity.Sale; +import com.ruoyi.frequency.sale.model.result.SaleCount; +import org.apache.ibatis.annotations.Param; +import org.apache.ibatis.annotations.Update; + +import java.math.BigDecimal; +import java.util.List; + +/** + * 销售账号Mapper接口 + * + * @author zj + * @date 2023-09-22 + */ +public interface SaleMapper extends BaseMapper +{ + /** + * 查询销售账号 + * + * @param id 销售账号主键 + * @return 销售账号 + */ + public Sale selectSaleById(Long id); + + /** + * 查询销售账号列表 + * + * @param sale 销售账号 + * @return 销售账号集合 + */ + public List selectSaleList(Sale sale); + + /** + * 新增销售账号 + * + * @param sale 销售账号 + * @return 结果 + */ + public int insertSale(Sale sale); + + /** + * 修改销售账号 + * + * @param sale 销售账号 + * @return 结果 + */ + public int updateSale(Sale sale); + + /** + * 删除销售账号 + * + * @param id 销售账号主键 + * @return 结果 + */ + public int deleteSaleById(Long id); + + /** + * 批量删除销售账号 + * + * @param ids 需要删除的数据主键集合 + * @return 结果 + */ + public int deleteSaleByIds(Long[] ids); + + @Update("update t_sale set balance=balance + #{price} where id = #{saleId}") + boolean addBalance(@Param("saleId") Long saleId, @Param("price") BigDecimal price); + + @Update("update t_sale set balance=balance - #{price} where id = #{saleId} and balance >=#{price}") + boolean subBalance(@Param("saleId") Long saleId, @Param("price") BigDecimal price); + + @Update("update t_sale set income=income + #{income} where id = #{saleId}") + boolean addIncome(@Param("saleId") Long saleId, @Param("income") BigDecimal income); + + @Update("update t_sale set income=income - #{income} where id = #{saleId} and income >=#{income}") + boolean subIncome(@Param("saleId") Long saleId, @Param("income") BigDecimal income); + + + Integer commissionRanking(@Param("userId") Long userId); + + Integer saleRanking(@Param("userId") Long userId); + + Page commissionRankingPage(@Param("page") Page page,@Param("userId")Long userId); + + Page saleRankingPage(@Param("page") Page page,@Param("userId")Long userId); + + Page saleDetailPage(@Param("page") Page objectPage, @Param("req") SaleDetailPageReq req,@Param("userId") Long userId); + + SaleDataResp saleOrderAmount( @Param("userId") Long userId); + + SaleCount statistics(@Param("list") List saleIdList); +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/sale/mapper/mapping/SaleMapper.xml b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/sale/mapper/mapping/SaleMapper.xml new file mode 100644 index 0000000..87b5cfc --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/sale/mapper/mapping/SaleMapper.xml @@ -0,0 +1,344 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + SELECT + tt.id, + tt.create_by, + tt.create_time, + tt.update_by, + tt.update_time, + tt.del_flag, + tt.avatar, + tt.mobile, + tt.nickname, + tt.name, + tt.enter_date, + tt.open_id, + tt.login_pwd, + tt.signature, + tt.balance, + tt.income, + tt.invite_code, + tt.invite_num, + tt.remark, + tt.background_image, + tt.close_message, + (SELECT + COUNT( 1 ) + FROM + t_sale t + WHERE + t.del_flag != 2 + AND ( + ( t.income = ( SELECT s.income FROM t_sale s WHERE s.id = tt.id ) AND t.id <= tt.id ) + OR ( t.income > ( SELECT s.income FROM t_sale s WHERE s.id = tt.id ) ) + )) commissionRanking, + (SELECT + COUNT( 1 ) + FROM + t_sale t + WHERE + t.del_flag != 2 + AND ( + ( t.invite_num = ( SELECT s.invite_num FROM t_sale s WHERE s.id =tt.id ) AND t.id <= tt.id ) + OR ( t.invite_num > ( SELECT s.invite_num FROM t_sale s WHERE s.id = tt.id ) ) + )) saleRanking, + tt.bank, + tt.subbranch, + tt.bank_card, + tt.pay_pwd + from t_sale tt + + + + + + + + + + insert into t_sale + + id, + create_by, + create_time, + update_by, + update_time, + del_flag, + avatar, + mobile, + enter_date, + open_id, + login_pwd, + signature, + balance, + income, + invite_code, + invite_num, + nickname, + + + #{id}, + #{createBy}, + #{createTime}, + #{updateBy}, + #{updateTime}, + #{delFlag}, + #{avatar}, + #{mobile}, + #{enterDate}, + #{openId}, + #{loginPwd}, + #{signature}, + #{balance}, + #{income}, + #{inviteCode}, + #{inviteNum}, + #{nickname}, + + + + + update t_sale + + create_by = #{createBy}, + create_time = #{createTime}, + update_by = #{updateBy}, + update_time = #{updateTime}, + del_flag = #{delFlag}, + avatar = #{avatar}, + mobile = #{mobile}, + enter_date = #{enterDate}, + open_id = #{openId}, + login_pwd = #{loginPwd}, + signature = #{signature}, + balance = #{balance}, + income = #{income}, + invite_code = #{inviteCode}, + invite_num = #{inviteNum}, + nickname = #{nickname}, + + where id = #{id} + + + + delete from t_sale where id = #{id} + + + + delete from t_sale where id in + + #{id} + + + + + + + + + + + + + + + diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/sale/model/param/SaleParam.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/sale/model/param/SaleParam.java new file mode 100644 index 0000000..ba475b9 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/sale/model/param/SaleParam.java @@ -0,0 +1,88 @@ +package com.ruoyi.frequency.sale.model.param; + +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import lombok.Data; +import lombok.experimental.Accessors; + +import java.math.BigDecimal; +import java.util.Date; + +/** + * 销售账号对象 t_sale + * + * @author zj + * @date 2023-09-22 + */ +@Data +@Accessors(chain = true) +public class SaleParam extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** 租户号 */ + private Long id; + + + /** 删除标志;1 正常 2 删除 3 禁用 */ + private Integer delFlag; + + /** 头像 */ + @Excel(name = "头像") + private String avatar; + + /** 手机 */ + @Excel(name = "手机") + private String mobile; + + private String nickname; + + private String name; + /** 入行时间 */ + @Excel(name = "入行时间", width = 30, dateFormat = "yyyy-MM-dd") + private Date enterDate; + + /** 微信openID */ + @Excel(name = "微信openID") + private String openId; + + /** 密码 */ + @Excel(name = "密码") + private String password; + + /** 个人签名 */ + @Excel(name = "个人签名") + private String signature; + + /** 余额 */ + @Excel(name = "余额") + private BigDecimal balance; + + /** 总收益 */ + @Excel(name = "总收益") + private BigDecimal income; + + /** 邀请码 */ + @Excel(name = "邀请码") + private String inviteCode; + + /** 推广人数 */ + @Excel(name = "推广人数") + private Long inviteNum; + + + + + + + + + + + + + + + + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/sale/model/result/SaleCount.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/sale/model/result/SaleCount.java new file mode 100644 index 0000000..52c8ae4 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/sale/model/result/SaleCount.java @@ -0,0 +1,24 @@ +package com.ruoyi.frequency.sale.model.result; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.math.BigDecimal; + +/** + * @author a + * @date 2024/2/22 14:30 + */ +@Data +public class SaleCount { + + @ApiModelProperty("总人数") + private Integer number =0; + + @ApiModelProperty("客户数") + private Integer inviteNum =0; + + @ApiModelProperty("佣金") + private BigDecimal income = new BigDecimal(0); + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/sale/model/result/SaleResult.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/sale/model/result/SaleResult.java new file mode 100644 index 0000000..d877408 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/sale/model/result/SaleResult.java @@ -0,0 +1,76 @@ +package com.ruoyi.frequency.sale.model.result; + +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import lombok.Data; +import lombok.experimental.Accessors; + +import java.math.BigDecimal; +import java.util.Date; + +/** + * 销售账号对象 t_sale + * + * @author zj + * @date 2023-09-22 + */ +@Data +@Accessors(chain = true) +public class SaleResult extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** 租户号 */ + private Long id; + + + /** 删除标志;1 正常 2 删除 3 禁用 */ + private Integer delFlag; + + /** 头像 */ + @Excel(name = "头像") + private String avatar; + + /** 手机 */ + @Excel(name = "手机") + private String mobile; + + /** id号;账号唯一标识 */ + @Excel(name = "id号;账号唯一标识") + private String nickname; + + private String name; + /** 入行时间 */ + @Excel(name = "入行时间", width = 30, dateFormat = "yyyy-MM-dd") + private Date enterDate; + + /** 微信openID */ + @Excel(name = "微信openID") + private String openId; + + /** 密码 */ + @Excel(name = "密码") + private String password; + + /** 个人签名 */ + @Excel(name = "个人签名") + private String signature; + + /** 余额 */ + @Excel(name = "余额") + private BigDecimal balance; + + /** 总收益 */ + @Excel(name = "总收益") + private BigDecimal income; + + /** 邀请码 */ + @Excel(name = "邀请码") + private String inviteCode; + + /** 推广人数 */ + @Excel(name = "推广人数") + private Long inviteNum; + + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/sale/service/SaleService.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/sale/service/SaleService.java new file mode 100644 index 0000000..bbe5f5d --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/sale/service/SaleService.java @@ -0,0 +1,140 @@ +package com.ruoyi.frequency.sale.service; + +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.IService; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.page.PageResult; +import com.ruoyi.controller.req.RegisterUserReq; +import com.ruoyi.controller.req.SaleDetailPageReq; +import com.ruoyi.controller.req.UserEditReqVo; +import com.ruoyi.controller.resp.RankingResp; +import com.ruoyi.controller.resp.SaleDetailPageResp; +import com.ruoyi.frequency.sale.entity.Sale; +import com.ruoyi.frequency.sale.model.result.SaleCount; +import com.ruoyi.response.ResponseData; +import com.ruoyi.vo.PageBasic; +import com.ruoyi.vo.UserVo; + +import java.util.List; + +/** + * 销售账号Service接口 + * + * @author zj + * @date 2023-09-22 + */ +public interface SaleService extends IService +{ + /** + * 查询销售账号 + * + * @param id 销售账号主键 + * @return 销售账号 + */ + public Sale selectSaleById(Long id); + + /** + * 查询销售账号列表 + * + * @param sale 销售账号 + * @return 销售账号集合 + */ + public List selectSaleList(Sale sale); + + SaleCount statistics(Sale sale); + + /** + * 新增销售账号 + * + * @param sale 销售账号 + * @return 结果 + */ + public int insertSale(Sale sale); + + /** + * 修改销售账号 + * + * @param sale 销售账号 + * @return 结果 + */ + public int updateSale(Sale sale); + + /** + * 批量删除销售账号 + * + * @param ids 需要删除的销售账号主键集合 + * @return 结果 + */ + public int deleteSaleByIds(Long[] ids,Integer delFlag); + + /** + * 删除销售账号信息 + * + * @param id 销售账号主键 + * @return 结果 + */ + public int deleteSaleById(Long id); + + /** + * 修改余额 + * @param sale + * @return + */ + AjaxResult updateBalance(Sale sale); + + /** + * 编辑用户信息 + * @param req + * @param userVo + * @return + */ + ResponseData editInfo(UserEditReqVo req, UserVo userVo); + + /** + * 用户个人信息 + * @param userVo + * @return + */ + ResponseData info(UserVo userVo); + + Sale assembleSale(RegisterUserReq req, String md5Pwd); + + /** + * 佣金排名 + * @param userVo + * @return + */ + Integer commissionRanking(UserVo userVo); + + + /** + * 推广排名 + * @param userVo + * @return + */ + Integer saleRanking(UserVo userVo); + + /** + * 佣金排名列表 + * @param userVo + * @return + */ + ResponseData>> commissionRankingPage(PageBasic req,UserVo userVo); + + + /** + * 推广排名列表 + * @param userVo + * @return + */ + ResponseData>> saleRankingPage(PageBasic req,UserVo userVo); + + /** + * 明细 + * @param req + * @param userVo + * @return + */ + ResponseData>> saleDetailPage(SaleDetailPageReq req, UserVo userVo); + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/sale/service/impl/SaleServiceImpl.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/sale/service/impl/SaleServiceImpl.java new file mode 100644 index 0000000..ab391d9 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/sale/service/impl/SaleServiceImpl.java @@ -0,0 +1,390 @@ +package com.ruoyi.frequency.sale.service.impl; + +import cn.hutool.core.date.DateUtil; +import cn.hutool.core.util.ObjectUtil; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.baomidou.mybatisplus.extension.conditions.update.LambdaUpdateChainWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.ruoyi.code.DictConstant; +import com.ruoyi.code.PublicCommon; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.domain.entity.SysDictData; +import com.ruoyi.common.exception.CustomException; +import com.ruoyi.common.exception.enums.CoreExceptionEnum; +import com.ruoyi.common.page.PageResult; +import com.ruoyi.common.utils.DateUtils; +import com.ruoyi.controller.req.RegisterUserReq; +import com.ruoyi.controller.req.SaleDetailPageReq; +import com.ruoyi.controller.req.UserEditReqVo; +import com.ruoyi.controller.resp.RankingResp; +import com.ruoyi.controller.resp.SaleDetailPageResp; +import com.ruoyi.enums.PlatformRecordEnums; +import com.ruoyi.enums.WalletDetailEnums; +import com.ruoyi.enums.user.UserEnums; +import com.ruoyi.frequency.customer.service.UserService; +import com.ruoyi.frequency.platformrecord.service.PlatformRecordService; +import com.ruoyi.frequency.sale.entity.Sale; +import com.ruoyi.frequency.sale.mapper.SaleMapper; +import com.ruoyi.frequency.sale.model.result.SaleCount; +import com.ruoyi.frequency.sale.service.SaleService; +import com.ruoyi.frequency.wallerecord.service.WalletRecordService; +import com.ruoyi.response.ResponseData; +import com.ruoyi.system.service.ISysConfigService; +import com.ruoyi.utils.BusinessUtil; +import com.ruoyi.utils.SnowIdUtils; +import com.ruoyi.utils.pwd.MD5EncryptionPwdUtil; +import com.ruoyi.vo.PageBasic; +import com.ruoyi.vo.UserInfo; +import com.ruoyi.vo.UserVo; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.math.BigDecimal; +import java.util.*; +import java.util.stream.Collectors; + +/** + * 销售账号Service业务层处理 + * + * @author zj + * @date 2023-09-22 + */ +@Service +public class SaleServiceImpl extends ServiceImpl implements SaleService { + @Autowired + private SaleMapper saleMapper; + + @Autowired + private BusinessUtil businessUtil; + + /** + * 查询销售账号 + * + * @param id 销售账号主键 + * @return 销售账号 + */ + @Override + public Sale selectSaleById(Long id) { + return saleMapper.selectSaleById(id); + } + + /** + * 查询销售账号列表 + * + * @param sale 销售账号 + * @return 销售账号 + */ + @Override + public List selectSaleList(Sale sale) { + return saleList(sale); + } + + private List saleList(Sale sale) { + return saleMapper.selectSaleList(sale); + } + + @Override + public SaleCount statistics(Sale sale) { + List sales = selectSaleList(sale); + List saleIdList = sales.stream().map(x -> x.getId()).collect(Collectors.toList()); + saleIdList.add(-1L); + + return saleMapper.statistics(saleIdList); + } + + @Autowired + private ISysConfigService configService; + + /** + * 新增销售账号 + * + * @param sale 销售账号 + * @return 结果 + */ + @Override + public int insertSale(Sale sale) { + + if (ObjectUtil.isEmpty(sale.getLoginPwd())) { + String password = configService.selectConfigByKey("sys.user.initPassword"); + sale.setLoginPwd(password); + } + //MD5加密 + String md5Pwd = MD5EncryptionPwdUtil.encryptionMd5(sale.getLoginPwd()); + + //账号验证 + Sale saleExit = this.getBaseMapper().selectOne(Wrappers.lambdaQuery(). + eq(Sale::getMobile, sale.getMobile()).ne(Sale::getDelFlag, PublicCommon.删除)); + if (saleExit != null) { + throw new CustomException(CoreExceptionEnum.PHONE_HAS_EXIST); + } + //组装用户 + RegisterUserReq req = new RegisterUserReq(); + req.setMobile(sale.getMobile()); + Sale insertSale = this.assembleSale(req, md5Pwd); + insertSale.setAvatar(sale.getAvatar()); + insertSale.setName(sale.getName()); + //生成邀请码 + String saleInvitationCode = refereeUserCode(6); + insertSale.setInviteCode(saleInvitationCode); + insertSale.setSignature(sale.getSignature()); + insertSale.setEnterDate(sale.getEnterDate()); + insertSale.setBank(sale.getBank()); + insertSale.setSubbranch(sale.getSubbranch()); + insertSale.setBankCard(sale.getBankCard()); + + return saleMapper.insert(insertSale); + } + + /** + * 生成普通用户验证码 + * + * @param codeLength 编码长度 + * @return 验证码字符窜 + */ + private String refereeUserCode(int codeLength) { + int i; + int count = 0; +// char[] str = {'0', '1', '2', '3', '4', '5', '6', '7', '8', +// '9', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', +// 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', +// 'Z'}; + char[] str = {'0', '1', '2', '3', '4', '5', '6', '7', '8', + '9'}; + StringBuffer pwd = new StringBuffer(""); + Random r = new Random(); + boolean isHave = true; + while (isHave) { + while (count < codeLength) { + i = Math.abs(r.nextInt(str.length)); + if (i >= 0 && i < str.length) { + pwd.append(str[i]); + count++; + } + } + Sale sale = this.getBaseMapper().selectOne(new QueryWrapper().lambda() + .eq(Sale::getInviteCode, pwd.toString())); + if (sale == null) { + isHave = false; + } + count = 0; + } + return pwd.toString(); + } + + + /** + * 修改销售账号 + * + * @param sale 销售账号 + * @return 结果 + */ + @Override + public int updateSale(Sale sale) { + + //账号验证 + Sale saleExit = this.getBaseMapper().selectOne(Wrappers.lambdaQuery(). + eq(Sale::getMobile, sale.getMobile()) + .ne(Sale::getId, sale.getId()) + .ne(Sale::getDelFlag, PublicCommon.删除)); + if (saleExit != null) { + throw new CustomException(CoreExceptionEnum.PHONE_HAS_EXIST); + } + + sale.setUpdateTime(DateUtils.getNowDate()); + + if (ObjectUtil.isNotEmpty(sale.getLoginPwd())) { + sale.setLoginPwd(MD5EncryptionPwdUtil.encryptionMd5(sale.getLoginPwd())); + } + return saleMapper.updateById(sale); + } + + /** + * 批量删除销售账号 + * + * @param ids 需要删除的销售账号主键 + * @return 结果 + */ + @Override + public int deleteSaleByIds(Long[] ids, Integer delFlag) { + this.lambdaUpdate().set(Sale::getDelFlag, delFlag).in(Sale::getId, ids).update(); + return ids.length; + } + + /** + * 删除销售账号信息 + * + * @param id 销售账号主键 + * @return 结果 + */ + @Override + public int deleteSaleById(Long id) { + return saleMapper.deleteSaleById(id); + } + + @Autowired + private WalletRecordService walletRecordService; + + @Autowired + private PlatformRecordService platformRecordService; + + @Override + public AjaxResult updateBalance(Sale sale) { + + BigDecimal price = sale.getBalance(); + + //修改余额 + if (price.compareTo(BigDecimal.ZERO) > 0) { + walletRecordService.updateBalance(new UserVo(UserEnums.sale.getCode(), sale.getId()), WalletDetailEnums.PLAT_ADD, sale.getRemark(), sale.getId(), price, PublicCommon.Wallet.可提现); + + //平台流水 + platformRecordService.addPlatformRecord(new UserVo(UserEnums.sale.getCode(), sale.getId()), sale.getId(), price.negate(), PlatformRecordEnums.PLAT_ADD); + + } else if (price.compareTo(BigDecimal.ZERO) < 0) { + walletRecordService.updateBalance(new UserVo(UserEnums.sale.getCode(), sale.getId()), WalletDetailEnums.PLAT_SUB, sale.getRemark(), sale.getId(), price, PublicCommon.Wallet.可提现); + + //平台流水 + platformRecordService.addPlatformRecord(new UserVo(UserEnums.sale.getCode(), sale.getId()), sale.getId(), price, PlatformRecordEnums.PLAT_ADD); + + } + + + return AjaxResult.success(); + } + + @Override + public ResponseData editInfo(UserEditReqVo vo, UserVo userVo) { + + LambdaUpdateChainWrapper lambdaUpdate = this.lambdaUpdate(); + lambdaUpdate.set(Sale::getId, userVo.getUserId()); + //头像 + if (ObjectUtil.isNotEmpty(vo.getAvatar())) { + lambdaUpdate.set(Sale::getAvatar, vo.getAvatar()); + } + //入行时间 + if (ObjectUtil.isNotEmpty(vo.getEnterDate())) { + lambdaUpdate.set(Sale::getEnterDate, DateUtil.parse(vo.getEnterDate(), "yyyy")); + } + //背景图 + if (ObjectUtil.isNotEmpty(vo.getBackgroundImage())) { + lambdaUpdate.set(Sale::getBackgroundImage, vo.getBackgroundImage()); + } + + if (ObjectUtil.isNotEmpty(vo.getSignature())) { + lambdaUpdate.set(Sale::getSignature, vo.getSignature()); + } + + //推送是否关闭;1不关闭2 关闭 + if (ObjectUtil.isNotEmpty(vo.getCloseMessage())) { + lambdaUpdate.set(Sale::getCloseMessage, vo.getCloseMessage()); + } + + //条件 + lambdaUpdate.eq(Sale::getId, userVo.getUserId()).update(); + + return ResponseData.success(); + } + + @Override + public ResponseData info(UserVo userVo) { + + final Sale sale = this.baseMapper.selectSaleById(userVo.getUserId()); + + return ResponseData.success(sale); + } + + @Override + public Sale assembleSale(RegisterUserReq req, String md5Pwd) { + Sale sale = new Sale(); + sale.setId(SnowIdUtils.uniqueLong()); + + //手机号 + sale.setMobile(req.getMobile()); + + //默认头像 + SysDictData dict = businessUtil.getDict(DictConstant.默认头像); + sale.setAvatar(dict.getImages()); + + Sale maxSale = this.getOne(new QueryWrapper().lambda().orderByDesc(Sale::getNickname).last("limit 1")); + + Integer num = maxSale == null ? 0 : Integer.valueOf(maxSale.getNickname().replace("TGY", "")); + + sale.setNickname(getNickname(num)); + sale.setLoginPwd(md5Pwd); + sale.setCreateTime(new Date()); + sale.setUpdateTime(new Date()); + + return sale; + } + + private String getNickname(Integer num) { + String template = "TGY%06d"; + num++; + String id = String.format(template, num); + return id; + } + + @Override + public Integer commissionRanking(UserVo userVo) { + return saleMapper.commissionRanking(userVo.getUserId()); + } + + @Override + public Integer saleRanking(UserVo userVo) { + return saleMapper.saleRanking(userVo.getUserId()); + } + + @Override + public ResponseData>> commissionRankingPage(PageBasic req, UserVo userVo) { + Page page = saleMapper.commissionRankingPage(new Page<>(req.getPageNo(), req.getPageSize()), userVo.getUserId()); + if (!page.getRecords().isEmpty()) { + Integer i = (req.getPageNo() - 1) * req.getPageSize() + 1; + for (RankingResp record : page.getRecords()) { + record.setRanking(i++); + } + } + + return ResponseData.success(new PageResult<>(page)); + } + + @Override + public ResponseData>> saleRankingPage(PageBasic req, UserVo userVo) { + Page page = saleMapper.saleRankingPage(new Page<>(req.getPageNo(), req.getPageSize()), userVo.getUserId()); + if (!page.getRecords().isEmpty()) { + Integer i = (req.getPageNo() - 1) * req.getPageSize() + 1; + for (RankingResp record : page.getRecords()) { + record.setRanking(i++); + } + } + return ResponseData.success(new PageResult<>(page)); + } + + @Autowired + private UserService userService; + + @Override + public ResponseData>> saleDetailPage(SaleDetailPageReq req, UserVo userVo) { + Page page = saleMapper.saleDetailPage(new Page<>(req.getPageNo(), req.getPageSize()), req, userVo.getUserId()); + + if (!page.getRecords().isEmpty()) { + + Set userVoSet = new HashSet<>(); + page.getRecords().stream().forEach(orderPageResp -> { + userVoSet.add(new UserVo(UserEnums.customer.getCode(), orderPageResp.getCustomerId())); + userVoSet.add(new UserVo(UserEnums.store.getCode(), orderPageResp.getStoreId())); + }); + + //查询用户信息 + Map userMap = userService.selectUserInfoMap(userVoSet, userVo); + + page.getRecords().stream().forEach(orderPageResp -> { + orderPageResp.setCustomerInfo(userMap.get(new UserVo(UserEnums.customer.getCode(), orderPageResp.getCustomerId()))); + orderPageResp.setStoreInfo(userMap.get(new UserVo(UserEnums.store.getCode(), orderPageResp.getStoreId()))); + }); + + } + + return ResponseData.success(new PageResult<>(page)); + } +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/sensitiveword/controller/SensitiveWordController.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/sensitiveword/controller/SensitiveWordController.java new file mode 100644 index 0000000..c5034a4 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/sensitiveword/controller/SensitiveWordController.java @@ -0,0 +1,103 @@ +package com.ruoyi.frequency.sensitiveword.controller; + +import java.util.List; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.frequency.sensitiveword.entity.SensitiveWord; +import com.ruoyi.frequency.sensitiveword.service.SensitiveWordService; +import com.ruoyi.common.utils.poi.ExcelUtil; +import com.ruoyi.common.core.page.TableDataInfo; + +/** + * 敏感词Controller + * + * @author liwenlong + * @date 2024-05-07 + */ +@RestController +@RequestMapping("/frequency/sensitiveword") +public class SensitiveWordController extends BaseController +{ + @Autowired + private SensitiveWordService sensitiveWordService; + + /** + * 查询敏感词列表 + */ +// @PreAuthorize("@ss.hasPermi('frequency:sensitiveword:list')") + @PostMapping("/list") + public TableDataInfo list(@RequestBody SensitiveWord sensitiveWord) + { + startPage(); + List list = sensitiveWordService.selectSensitiveWordList(sensitiveWord); + return getDataTable(list); + } + + /** + * 导出敏感词列表 + */ +// @PreAuthorize("@ss.hasPermi('frequency:sensitiveword:export')") + @Log(title = "敏感词", businessType = BusinessType.EXPORT) + @GetMapping("/export") + public AjaxResult export(SensitiveWord sensitiveWord) + { + List list = sensitiveWordService.selectSensitiveWordList(sensitiveWord); + ExcelUtil util = new ExcelUtil(SensitiveWord.class); + return util.exportExcel(list, "敏感词数据"); + } + + /** + * 获取敏感词详细信息 + */ +// @PreAuthorize("@ss.hasPermi('frequency:sensitiveword:query')") + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") Long id) + { + return AjaxResult.success(sensitiveWordService.selectSensitiveWordById(id)); + } + + /** + * 新增敏感词 + */ +// @PreAuthorize("@ss.hasPermi('frequency:sensitiveword:add')") + @Log(title = "敏感词", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody SensitiveWord sensitiveWord) + { + return toAjax(sensitiveWordService.insertSensitiveWord(sensitiveWord)); + } + + /** + * 修改敏感词 + */ +// @PreAuthorize("@ss.hasPermi('frequency:sensitiveword:edit')") + @Log(title = "敏感词", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody SensitiveWord sensitiveWord) + { + return toAjax(sensitiveWordService.updateSensitiveWord(sensitiveWord)); + } + + /** + * 删除敏感词 + */ +// @PreAuthorize("@ss.hasPermi('frequency:sensitiveword:remove')") + @Log(title = "敏感词", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}/{delFlag}") + public AjaxResult remove(@PathVariable("ids") Long[] ids,@PathVariable("delFlag") Integer delFlag) + { + return toAjax(sensitiveWordService.deleteSensitiveWordByIds(ids,delFlag)); + } +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/sensitiveword/entity/SensitiveWord.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/sensitiveword/entity/SensitiveWord.java new file mode 100644 index 0000000..a9afc46 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/sensitiveword/entity/SensitiveWord.java @@ -0,0 +1,46 @@ +package com.ruoyi.frequency.sensitiveword.entity; + +import lombok.Data; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.experimental.Accessors; +import com.ruoyi.common.annotation.Excel; +import io.swagger.annotations.ApiModelProperty; +import com.baomidou.mybatisplus.annotation.TableField; +import com.ruoyi.vo.UserInfo; +import com.ruoyi.common.core.domain.BaseEntity; + +import java.util.Date; + +/** + * 敏感词对象 t_sensitive_word + * + * @author liwenlong + * @date 2024-05-07 + */ +@Data +@Accessors(chain = true) +@TableName("t_sensitive_word") +public class SensitiveWord extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + + @ApiModelProperty("租户号") + private Long id; + + @ApiModelProperty("删除状态 1 正常 2 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("敏感词") + @Excel(name = "敏感词") + private String name; + + @ApiModelProperty("开始时间") + @TableField(exist = false) + private Date beginTime; + + @ApiModelProperty("结束时间") + @TableField(exist = false) + private Date endTime; + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/sensitiveword/mapper/SensitiveWordMapper.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/sensitiveword/mapper/SensitiveWordMapper.java new file mode 100644 index 0000000..7932bc6 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/sensitiveword/mapper/SensitiveWordMapper.java @@ -0,0 +1,47 @@ +package com.ruoyi.frequency.sensitiveword.mapper; + +import java.util.List; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.ruoyi.frequency.sensitiveword.entity.SensitiveWord; + +/** + * 敏感词Mapper接口 + * + * @author liwenlong + * @date 2024-05-07 + */ +public interface SensitiveWordMapper extends BaseMapper +{ + /** + * 查询敏感词 + * + * @param id 敏感词主键 + * @return 敏感词 + */ + public SensitiveWord selectSensitiveWordById(Long id); + + /** + * 查询敏感词列表 + * + * @param sensitiveWord 敏感词 + * @return 敏感词集合 + */ + public List selectSensitiveWordList(SensitiveWord sensitiveWord); + + /** + * 新增敏感词 + * + * @param sensitiveWord 敏感词 + * @return 结果 + */ + public int insertSensitiveWord(SensitiveWord sensitiveWord); + + /** + * 修改敏感词 + * + * @param sensitiveWord 敏感词 + * @return 结果 + */ + public int updateSensitiveWord(SensitiveWord sensitiveWord); + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/sensitiveword/mapper/mapping/SensitiveWordMapper.xml b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/sensitiveword/mapper/mapping/SensitiveWordMapper.xml new file mode 100644 index 0000000..366aa0a --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/sensitiveword/mapper/mapping/SensitiveWordMapper.xml @@ -0,0 +1,87 @@ + + + + + + + + + + + + + + + + + + select + t.id , + t.del_flag , + t.create_by , + t.create_time , + t.update_by , + t.update_time , + t.name + from t_sensitive_word AS t + + + + + + + + + insert into t_sensitive_word + + id, + del_flag, + create_by, + create_time, + update_by, + update_time, + name, + + + #{id}, + #{delFlag}, + #{createBy}, + #{createTime}, + #{updateBy}, + #{updateTime}, + #{name}, + + + + + update t_sensitive_word + + del_flag = #{delFlag}, + create_by = #{createBy}, + create_time = #{createTime}, + update_by = #{updateBy}, + update_time = #{updateTime}, + name = #{name}, + + where id = #{id} + + \ No newline at end of file diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/sensitiveword/model/param/SensitiveWordParam.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/sensitiveword/model/param/SensitiveWordParam.java new file mode 100644 index 0000000..3b9680d --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/sensitiveword/model/param/SensitiveWordParam.java @@ -0,0 +1,35 @@ +package com.ruoyi.frequency.sensitiveword.model.param; + +import lombok.Data; +import lombok.experimental.Accessors; +import com.ruoyi.common.annotation.Excel; +import io.swagger.annotations.ApiModelProperty; +import com.ruoyi.common.core.domain.BaseEntity; + +/** + * 敏感词对象 t_sensitive_word + * + * @author liwenlong + * @date 2024-05-07 + */ +@Data +@Accessors(chain = true) +public class SensitiveWordParam extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + @ApiModelProperty("租户号") + private Long id; + + @ApiModelProperty("删除状态 1 正常 2 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("敏感词") + @Excel(name = "敏感词") + private String name; + + + + + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/sensitiveword/model/result/SensitiveWordResult.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/sensitiveword/model/result/SensitiveWordResult.java new file mode 100644 index 0000000..91287c8 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/sensitiveword/model/result/SensitiveWordResult.java @@ -0,0 +1,32 @@ +package com.ruoyi.frequency.sensitiveword.model.result; + +import lombok.Data; +import lombok.experimental.Accessors; +import com.ruoyi.common.annotation.Excel; +import io.swagger.annotations.ApiModelProperty; +import com.ruoyi.common.core.domain.BaseEntity; + +/** + * 敏感词对象 t_sensitive_word + * + * @author liwenlong + * @date 2024-05-07 + */ +@Data +@Accessors(chain = true) +public class SensitiveWordResult extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + @ApiModelProperty("租户号") + private Long id; + + @ApiModelProperty("删除状态 1 正常 2 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("敏感词") + @Excel(name = "敏感词") + private String name; + + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/sensitiveword/service/SensitiveWordService.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/sensitiveword/service/SensitiveWordService.java new file mode 100644 index 0000000..992bddd --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/sensitiveword/service/SensitiveWordService.java @@ -0,0 +1,55 @@ +package com.ruoyi.frequency.sensitiveword.service; + +import java.util.List; +import com.ruoyi.frequency.sensitiveword.entity.SensitiveWord; +import com.baomidou.mybatisplus.extension.service.IService; + +/** + * 敏感词Service接口 + * + * @author liwenlong + * @date 2024-05-07 + */ +public interface SensitiveWordService extends IService +{ + /** + * 查询敏感词 + * + * @param id 敏感词主键 + * @return 敏感词 + */ + public SensitiveWord selectSensitiveWordById(Long id); + + /** + * 查询敏感词列表 + * + * @param sensitiveWord 敏感词 + * @return 敏感词集合 + */ + public List selectSensitiveWordList(SensitiveWord sensitiveWord); + + /** + * 新增敏感词 + * + * @param sensitiveWord 敏感词 + * @return 结果 + */ + public int insertSensitiveWord(SensitiveWord sensitiveWord); + + /** + * 修改敏感词 + * + * @param sensitiveWord 敏感词 + * @return 结果 + */ + public int updateSensitiveWord(SensitiveWord sensitiveWord); + + /** + * 批量删除敏感词 + * + * @param ids 需要删除的敏感词主键集合 + * @return 结果 + */ + public int deleteSensitiveWordByIds(Long[] ids,Integer delFlag); + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/sensitiveword/service/impl/SensitiveWordServiceImpl.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/sensitiveword/service/impl/SensitiveWordServiceImpl.java new file mode 100644 index 0000000..b788233 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/sensitiveword/service/impl/SensitiveWordServiceImpl.java @@ -0,0 +1,87 @@ +package com.ruoyi.frequency.sensitiveword.service.impl; + +import java.util.List; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.ruoyi.frequency.sensitiveword.mapper.SensitiveWordMapper; +import com.ruoyi.frequency.sensitiveword.entity.SensitiveWord; +import com.ruoyi.frequency.sensitiveword.service.SensitiveWordService; + +/** + * 敏感词Service业务层处理 + * + * @author liwenlong + * @date 2024-05-07 + */ +@Service +public class SensitiveWordServiceImpl extends ServiceImpl implements SensitiveWordService +{ + @Autowired + private SensitiveWordMapper sensitiveWordMapper; + + /** + * 查询敏感词 + * + * @param id 敏感词主键 + * @return 敏感词 + */ + @Override + public SensitiveWord selectSensitiveWordById(Long id) + { + return sensitiveWordMapper.selectSensitiveWordById(id); + } + + /** + * 查询敏感词列表 + * + * @param sensitiveWord 敏感词 + * @return 敏感词 + */ + @Override + public List selectSensitiveWordList(SensitiveWord sensitiveWord) + { + return sensitiveWordMapper.selectSensitiveWordList(sensitiveWord); + } + + /** + * 新增敏感词 + * + * @param sensitiveWord 敏感词 + * @return 结果 + */ + @Override + public int insertSensitiveWord(SensitiveWord sensitiveWord) + { + sensitiveWord.setCreateData(); + return sensitiveWordMapper.insert(sensitiveWord); + } + + /** + * 修改敏感词 + * + * @param sensitiveWord 敏感词 + * @return 结果 + */ + @Override + public int updateSensitiveWord(SensitiveWord sensitiveWord) + { + sensitiveWord.setUpdateData(); + return sensitiveWordMapper.updateSensitiveWord(sensitiveWord); + } + + /** + * 批量删除敏感词 + * + * @param ids 需要删除的敏感词主键 + * @return 结果 + */ + @Override + public int deleteSensitiveWordByIds(Long[] ids,Integer delFlag) + { + this.lambdaUpdate().set(SensitiveWord::getDelFlag,delFlag).in(SensitiveWord::getId,ids).update(); + return ids.length; + } + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/shield/controller/ShieldController.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/shield/controller/ShieldController.java new file mode 100644 index 0000000..e27878e --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/shield/controller/ShieldController.java @@ -0,0 +1,97 @@ +package com.ruoyi.frequency.shield.controller; + +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.page.TableDataInfo; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.common.utils.poi.ExcelUtil; +import com.ruoyi.frequency.shield.entity.Shield; +import com.ruoyi.frequency.shield.service.ShieldService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +/** + * 屏蔽用户Controller + * + * @author liwenlong + * @date 2023-07-22 + */ +@RestController +@RequestMapping("/frequency/shield") +public class ShieldController extends BaseController +{ + @Autowired + private ShieldService shieldService; + + /** + * 查询屏蔽用户列表 + */ + @PreAuthorize("@ss.hasPermi('frequency:shield:list')") + @GetMapping("/list") + public TableDataInfo list(Shield shield) + { + startPage(); + List list = shieldService.selectShieldList(shield); + return getDataTable(list); + } + + /** + * 导出屏蔽用户列表 + */ + @PreAuthorize("@ss.hasPermi('frequency:shield:export')") + @Log(title = "屏蔽用户", businessType = BusinessType.EXPORT) + @GetMapping("/export") + public AjaxResult export(Shield shield) + { + List list = shieldService.selectShieldList(shield); + ExcelUtil util = new ExcelUtil(Shield.class); + return util.exportExcel(list, "屏蔽用户数据"); + } + + /** + * 获取屏蔽用户详细信息 + */ + @PreAuthorize("@ss.hasPermi('frequency:shield:query')") + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") Long id) + { + return AjaxResult.success(shieldService.selectShieldById(id)); + } + + /** + * 新增屏蔽用户 + */ + @PreAuthorize("@ss.hasPermi('frequency:shield:add')") + @Log(title = "屏蔽用户", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody Shield shield) + { + return toAjax(shieldService.insertShield(shield)); + } + + /** + * 修改屏蔽用户 + */ + @PreAuthorize("@ss.hasPermi('frequency:shield:edit')") + @Log(title = "屏蔽用户", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody Shield shield) + { + return toAjax(shieldService.updateShield(shield)); + } + + /** + * 删除屏蔽用户 + */ + @PreAuthorize("@ss.hasPermi('frequency:shield:remove')") + @Log(title = "屏蔽用户", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}") + public AjaxResult remove(@PathVariable Long[] ids) + { + return toAjax(shieldService.deleteShieldByIds(ids)); + } +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/shield/entity/Shield.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/shield/entity/Shield.java new file mode 100644 index 0000000..3902218 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/shield/entity/Shield.java @@ -0,0 +1,45 @@ +package com.ruoyi.frequency.shield.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import lombok.Data; +import lombok.experimental.Accessors; + +/** + * 屏蔽用户对象 t_shield + * + * @author liwenlong + * @date 2023-07-22 + */ +@Data +@Accessors(chain = true) +@TableName("t_shield") +public class Shield extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** 主键id */ + private Long id; + + /** 删除标志 1正常 删除 3 禁用 */ + private Integer delFlag; + + /** 用户id */ + @Excel(name = "用户id") + private Long userId; + + /** 被屏蔽用户id */ + @Excel(name = "被屏蔽用户id") + private Long shieldUserId; + + /** 用户类型 1 用户 2 表现师 */ + @Excel(name = "用户类型 1 用户 2 表现师") + private Integer userType; + + /** 被屏蔽用户类型 1 用户 2 表现师 */ + @Excel(name = "被屏蔽用户类型 1 用户 2 表现师") + private Integer shieldUserType; + + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/shield/mapper/ShieldMapper.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/shield/mapper/ShieldMapper.java new file mode 100644 index 0000000..644dced --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/shield/mapper/ShieldMapper.java @@ -0,0 +1,70 @@ +package com.ruoyi.frequency.shield.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.ruoyi.controller.req.ShieldPageReq; +import com.ruoyi.controller.resp.ShieldPageResp; +import com.ruoyi.frequency.shield.entity.Shield; +import com.ruoyi.vo.UserVo; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * 屏蔽用户Mapper接口 + * + * @author liwenlong + * @date 2023-07-22 + */ +public interface ShieldMapper extends BaseMapper +{ + /** + * 查询屏蔽用户 + * + * @param id 屏蔽用户主键 + * @return 屏蔽用户 + */ + public Shield selectShieldById(Long id); + + /** + * 查询屏蔽用户列表 + * + * @param shield 屏蔽用户 + * @return 屏蔽用户集合 + */ + public List selectShieldList(Shield shield); + + /** + * 新增屏蔽用户 + * + * @param shield 屏蔽用户 + * @return 结果 + */ + public int insertShield(Shield shield); + + /** + * 修改屏蔽用户 + * + * @param shield 屏蔽用户 + * @return 结果 + */ + public int updateShield(Shield shield); + + /** + * 删除屏蔽用户 + * + * @param id 屏蔽用户主键 + * @return 结果 + */ + public int deleteShieldById(Long id); + + /** + * 批量删除屏蔽用户 + * + * @param ids 需要删除的数据主键集合 + * @return 结果 + */ + public int deleteShieldByIds(Long[] ids); + + Page shieldPage(@Param("page") Page objectPage, @Param("req") ShieldPageReq req, @Param("userVo") UserVo userVo); +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/shield/mapper/mapping/ShieldMapper.xml b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/shield/mapper/mapping/ShieldMapper.xml new file mode 100644 index 0000000..56d80a3 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/shield/mapper/mapping/ShieldMapper.xml @@ -0,0 +1,138 @@ + + + + + + + + + + + + + + + + + + + select id, create_by, create_time, update_by, update_time, del_flag, user_id, shield_user_id, user_type, shield_user_type from t_shield + + + + + + + + insert into t_shield + + id, + create_by, + create_time, + update_by, + update_time, + del_flag, + user_id, + shield_user_id, + user_type, + shield_user_type, + + + #{id}, + #{createBy}, + #{createTime}, + #{updateBy}, + #{updateTime}, + #{delFlag}, + #{userId}, + #{shieldUserId}, + #{userType}, + #{shieldUserType}, + + + + + update t_shield + + create_by = #{createBy}, + create_time = #{createTime}, + update_by = #{updateBy}, + update_time = #{updateTime}, + del_flag = #{delFlag}, + user_id = #{userId}, + shield_user_id = #{shieldUserId}, + user_type = #{userType}, + shield_user_type = #{shieldUserType}, + + where id = #{id} + + + + delete from t_shield where id = #{id} + + + + delete from t_shield where id in + + #{id} + + + + + \ No newline at end of file diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/shield/model/param/ShieldParam.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/shield/model/param/ShieldParam.java new file mode 100644 index 0000000..9550248 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/shield/model/param/ShieldParam.java @@ -0,0 +1,49 @@ +package com.ruoyi.frequency.shield.model.param; + +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import lombok.Data; +import lombok.experimental.Accessors; + +/** + * 屏蔽用户对象 t_shield + * + * @author liwenlong + * @date 2023-07-22 + */ +@Data +@Accessors(chain = true) +public class ShieldParam extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** 主键id */ + private Long id; + + /** 删除标志 1正常 删除 3 禁用 */ + private Integer delFlag; + + /** 用户id */ + @Excel(name = "用户id") + private Long userId; + + /** 被屏蔽用户id */ + @Excel(name = "被屏蔽用户id") + private Long shieldUserId; + + /** 用户类型 1 用户 2 表现师 */ + @Excel(name = "用户类型 1 用户 2 表现师") + private Integer userType; + + /** 被屏蔽用户类型 1 用户 2 表现师 */ + @Excel(name = "被屏蔽用户类型 1 用户 2 表现师") + private Integer shieldUserType; + + + + + + + + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/shield/model/result/ShieldResult.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/shield/model/result/ShieldResult.java new file mode 100644 index 0000000..f217767 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/shield/model/result/ShieldResult.java @@ -0,0 +1,43 @@ +package com.ruoyi.frequency.shield.model.result; + +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import lombok.Data; +import lombok.experimental.Accessors; + +/** + * 屏蔽用户对象 t_shield + * + * @author liwenlong + * @date 2023-07-22 + */ +@Data +@Accessors(chain = true) +public class ShieldResult extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** 主键id */ + private Long id; + + /** 删除标志 1正常 删除 3 禁用 */ + private Integer delFlag; + + /** 用户id */ + @Excel(name = "用户id") + private Long userId; + + /** 被屏蔽用户id */ + @Excel(name = "被屏蔽用户id") + private Long shieldUserId; + + /** 用户类型 1 用户 2 表现师 */ + @Excel(name = "用户类型 1 用户 2 表现师") + private Integer userType; + + /** 被屏蔽用户类型 1 用户 2 表现师 */ + @Excel(name = "被屏蔽用户类型 1 用户 2 表现师") + private Integer shieldUserType; + + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/shield/service/ShieldService.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/shield/service/ShieldService.java new file mode 100644 index 0000000..79dfd17 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/shield/service/ShieldService.java @@ -0,0 +1,77 @@ +package com.ruoyi.frequency.shield.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.ruoyi.controller.req.ShieldPageReq; +import com.ruoyi.controller.req.ShieldUserReq; +import com.ruoyi.frequency.shield.entity.Shield; +import com.ruoyi.response.ResponseData; +import com.ruoyi.vo.UserVo; + +import java.util.List; + +/** + * 屏蔽用户Service接口 + * + * @author liwenlong + * @date 2023-07-22 + */ +public interface ShieldService extends IService +{ + /** + * 查询屏蔽用户 + * + * @param id 屏蔽用户主键 + * @return 屏蔽用户 + */ + public Shield selectShieldById(Long id); + + /** + * 查询屏蔽用户列表 + * + * @param shield 屏蔽用户 + * @return 屏蔽用户集合 + */ + public List selectShieldList(Shield shield); + + /** + * 新增屏蔽用户 + * + * @param shield 屏蔽用户 + * @return 结果 + */ + public int insertShield(Shield shield); + + /** + * 修改屏蔽用户 + * + * @param shield 屏蔽用户 + * @return 结果 + */ + public int updateShield(Shield shield); + + /** + * 批量删除屏蔽用户 + * + * @param ids 需要删除的屏蔽用户主键集合 + * @return 结果 + */ + public int deleteShieldByIds(Long[] ids); + + /** + * 删除屏蔽用户信息 + * + * @param id 屏蔽用户主键 + * @return 结果 + */ + public int deleteShieldById(Long id); + + ResponseData shieldUser(ShieldUserReq req, UserVo userVo); + + ResponseData shieldPage(ShieldPageReq req, UserVo userVo); + + ResponseData otherShieldPage(ShieldPageReq req,UserVo userVo); + + ResponseData shieldUserVersion2(ShieldUserReq req, UserVo userVo); + + ResponseData cancelShieldUserVersion2(ShieldUserReq req, UserVo userVo); +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/shield/service/impl/ShieldServiceImpl.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/shield/service/impl/ShieldServiceImpl.java new file mode 100644 index 0000000..6a672ad --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/shield/service/impl/ShieldServiceImpl.java @@ -0,0 +1,208 @@ +package com.ruoyi.frequency.shield.service.impl; + +import cn.hutool.core.util.ObjectUtil; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.ruoyi.code.PublicCommon; +import com.ruoyi.common.page.PageResult; +import com.ruoyi.common.utils.DateUtils; +import com.ruoyi.controller.req.ShieldPageReq; +import com.ruoyi.controller.req.ShieldUserReq; +import com.ruoyi.controller.resp.ShieldPageResp; +import com.ruoyi.frequency.customer.service.UserService; +import com.ruoyi.frequency.shield.entity.Shield; +import com.ruoyi.frequency.shield.mapper.ShieldMapper; +import com.ruoyi.frequency.shield.service.ShieldService; +import com.ruoyi.response.ResponseData; +import com.ruoyi.vo.UserInfo; +import com.ruoyi.vo.UserVo; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.stream.Collectors; + +/** + * 屏蔽用户Service业务层处理 + * + * @author liwenlong + * @date 2023-07-22 + */ +@Service +public class ShieldServiceImpl extends ServiceImpl implements ShieldService { + @Autowired + private ShieldMapper shieldMapper; + + /** + * 查询屏蔽用户 + * + * @param id 屏蔽用户主键 + * @return 屏蔽用户 + */ + @Override + public Shield selectShieldById(Long id) { + return shieldMapper.selectShieldById(id); + } + + /** + * 查询屏蔽用户列表 + * + * @param shield 屏蔽用户 + * @return 屏蔽用户 + */ + @Override + public List selectShieldList(Shield shield) { + return shieldMapper.selectShieldList(shield); + } + + /** + * 新增屏蔽用户 + * + * @param shield 屏蔽用户 + * @return 结果 + */ + @Override + public int insertShield(Shield shield) { + shield.setCreateTime(DateUtils.getNowDate()); + return shieldMapper.insertShield(shield); + } + + /** + * 修改屏蔽用户 + * + * @param shield 屏蔽用户 + * @return 结果 + */ + @Override + public int updateShield(Shield shield) { + shield.setUpdateTime(DateUtils.getNowDate()); + return shieldMapper.updateShield(shield); + } + + /** + * 批量删除屏蔽用户 + * + * @param ids 需要删除的屏蔽用户主键 + * @return 结果 + */ + @Override + public int deleteShieldByIds(Long[] ids) { + return shieldMapper.deleteShieldByIds(ids); + } + + /** + * 删除屏蔽用户信息 + * + * @param id 屏蔽用户主键 + * @return 结果 + */ + @Override + public int deleteShieldById(Long id) { + return shieldMapper.deleteShieldById(id); + } + + @Override + public ResponseData shieldUser(ShieldUserReq req, UserVo userVo) { + Shield shield = this.getOne(new QueryWrapper().lambda() + .eq(Shield::getUserType, userVo.getUserType()) + .eq(Shield::getUserId, userVo.getUserId()) + .eq(Shield::getShieldUserType, req.getUserType()) + .eq(Shield::getShieldUserId, req.getUserId())); + boolean isShield = false; + if (shield == null) { + shield = new Shield() + .setUserId(userVo.getUserId()) + .setUserType(userVo.getUserType()) + .setShieldUserType(req.getUserType()) + .setShieldUserId(req.getUserId()); + //屏蔽 + isShield = true; + + this.save(shield); + } else { + //是否屏蔽 + isShield = ObjectUtil.notEqual(PublicCommon.启用, shield.getDelFlag()); + + this.lambdaUpdate().set(Shield::getDelFlag, isShield ? PublicCommon.启用 : PublicCommon.删除) + .eq(Shield::getId, shield.getId()).update(); + } + + return ResponseData.success(); + } + + @Autowired + private UserService userService; + + @Override + public ResponseData shieldPage(ShieldPageReq req, UserVo userVo) { + Page page = this.baseMapper.shieldPage(new Page<>(req.getPageNo(), req.getPageSize()), req, userVo); + + if (!page.getRecords().isEmpty()) { + Set userVoSet = page.getRecords().stream().map(resp -> new UserVo(resp.getShieldUserType(), resp.getShieldUserId())).collect(Collectors.toSet()); + //查询用户信息 + Map userMap = userService.selectUserInfoMap(userVoSet, userVo); + + page.getRecords().stream().forEach(resp -> { + resp.setUserInfo(userMap.get(new UserVo(resp.getShieldUserType(), resp.getShieldUserId()))); + }); + } + + return ResponseData.success(new PageResult<>(page)); + } + + @Override + public ResponseData otherShieldPage(ShieldPageReq req, UserVo userVo) { + Page page = this.baseMapper.shieldPage(new Page<>(req.getPageNo(), req.getPageSize()), req, new UserVo(req.getOtherUserType(), req.getOtherUserId())); + + if (!page.getRecords().isEmpty()) { + Set userVoSet = page.getRecords().stream().map(resp -> new UserVo(resp.getShieldUserType(), resp.getShieldUserId())).collect(Collectors.toSet()); + //查询用户信息 + Map userMap = userService.selectUserInfoMap(userVoSet, userVo); + + page.getRecords().stream().forEach(resp -> { + resp.setUserInfo(userMap.get(new UserVo(resp.getShieldUserType(), resp.getShieldUserId()))); + }); + } + return ResponseData.success(new PageResult<>(page)); + } + + @Override + public ResponseData shieldUserVersion2(ShieldUserReq req, UserVo userVo) { + Shield shield = this.getOne(new QueryWrapper().lambda() + .eq(Shield::getUserType, userVo.getUserType()) + .eq(Shield::getUserId, userVo.getUserId()) + .eq(Shield::getShieldUserType, req.getUserType()) + .eq(Shield::getShieldUserId, req.getUserId())); + if (shield == null) { + shield = new Shield() + .setUserId(userVo.getUserId()) + .setUserType(userVo.getUserType()) + .setShieldUserType(req.getUserType()) + .setShieldUserId(req.getUserId()); + this.save(shield); + } else { + this.lambdaUpdate().set(Shield::getDelFlag, PublicCommon.启用) + .eq(Shield::getId, shield.getId()).update(); + } + + return ResponseData.success(); + } + + @Override + public ResponseData cancelShieldUserVersion2(ShieldUserReq req, UserVo userVo) { + Shield shield = this.getOne(new QueryWrapper().lambda() + .eq(Shield::getUserType, userVo.getUserType()) + .eq(Shield::getUserId, userVo.getUserId()) + .eq(Shield::getShieldUserType, req.getUserType()) + .eq(Shield::getShieldUserId, req.getUserId())); + if (shield != null) { + this.lambdaUpdate().set(Shield::getDelFlag, PublicCommon.删除) + .eq(Shield::getId, shield.getId()).update(); + } + + return ResponseData.success(); + } +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/store/controller/StoreController.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/store/controller/StoreController.java new file mode 100644 index 0000000..a2ff623 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/store/controller/StoreController.java @@ -0,0 +1,172 @@ +package com.ruoyi.frequency.store.controller; + +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.page.TableDataInfo; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.common.utils.poi.ExcelUtil; +import com.ruoyi.frequency.store.entity.Store; +import com.ruoyi.frequency.store.model.result.StoreCount; +import com.ruoyi.frequency.store.service.StoreService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +/** + * 表现师Controller + * + * @author liwenlong + * @date 2023-09-22 + */ +@RestController +@RequestMapping("/frequency/store") +public class StoreController extends BaseController +{ + @Autowired + private StoreService storeService; + + /** + * 查询商户列表 + */ + //@PreAuthorize("@ss.hasPermi('frequency:store:list')") + @PostMapping("/list") + public TableDataInfo list(@RequestBody Store store) + { + startPage(); + List list = storeService.selectStoreList(store); + return getDataTable(list); + } + + /** + * 统计 + */ + @PostMapping("/statistics") + public AjaxResult statistics(@RequestBody Store store) + { + StoreCount count = storeService.statistics(store); + return AjaxResult.success(count); + } + + /** + * 导出商户列表 + */ + //@PreAuthorize("@ss.hasPermi('frequency:store:export')") + @Log(title = "商户", businessType = BusinessType.EXPORT) + @GetMapping("/export") + public AjaxResult export(Store store) + { + List list = storeService.selectStoreList(store); + ExcelUtil util = new ExcelUtil(Store.class); + return util.exportExcel(list, "商户数据"); + } + + /** + * 获取商户详细信息 + */ + //@PreAuthorize("@ss.hasPermi('frequency:store:query')") + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") Long id) + { + return AjaxResult.success(storeService.selectStoreById(id)); + } + + /** + * 新增商户 + */ + //@PreAuthorize("@ss.hasPermi('frequency:store:add')") + @Log(title = "商户", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody Store store) + { + return toAjax(storeService.insertStore(store)); + } + + /** + * 修改商户 + */ + //@PreAuthorize("@ss.hasPermi('frequency:store:edit')") + @Log(title = "商户", businessType = BusinessType.UPDATE) + @PostMapping("/edit") + public AjaxResult edit(@RequestBody Store store) + { + return toAjax(storeService.updateStore(store)); + } + + /** + * 删除商户 + */ + //@PreAuthorize("@ss.hasPermi('frequency:store:remove')") + @Log(title = "商户", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}/{delFlag}") + public AjaxResult remove(@PathVariable("ids") Long[] ids,@PathVariable("delFlag")Integer delFlag) + { + return toAjax(storeService.deleteStoreByIds(ids,delFlag)); + } + + + /** + * 修改扣款金额 + */ + //@PreAuthorize("@ss.hasPermi('frequency:store:updateViolationDeduction')") + @Log(title = "表现师", businessType = BusinessType.UPDATE) + @PostMapping("/updateViolationDeduction") + public AjaxResult updateViolationDeduction(@RequestBody Store store) + { + return toAjax(storeService.updateViolationDeduction(store)); + } + + + /** + * 修改余额 + */ + //@PreAuthorize("@ss.hasPermi('frequency:store:updateBalance')") + @Log(title = "表现师", businessType = BusinessType.UPDATE) + @PostMapping("/updateBalance") + public AjaxResult updateBalance(@RequestBody Store store) + { + return storeService.updateBalance(store); + } + /** + * 设置为企业 + */ + //@PreAuthorize("@ss.hasPermi('frequency:store:setUpEnterprise')") + @Log(title = "表现师", businessType = BusinessType.UPDATE) + @PostMapping("/setUpEnterprise") + public AjaxResult setUpEnterprise(@RequestBody Store store) + { + return storeService.setUpEnterprise(store); + } + + + /** + * 设置为官方账号 + */ + @Log(title = "表现师", businessType = BusinessType.UPDATE) + @PostMapping("/setUpPlatform") + public AjaxResult setUpPlatform(@RequestBody Store store) + { + return storeService.setUpPlatform(store); + } + + /** + * 设置为DD认证 + */ + @Log(title = "表现师", businessType = BusinessType.UPDATE) + @PostMapping("/setDDAuth") + public AjaxResult setDDAuth(@RequestBody Store store) + { + return storeService.setDDAuth(store); + } + + /** + * 修改提成比例 + */ + @Log(title = "表现师", businessType = BusinessType.UPDATE) + @PostMapping("/setCommissionRatio") + public AjaxResult setCommissionRatio(@RequestBody Store store) + { + return storeService.setCommissionRatio(store); + } +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/store/entity/Store.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/store/entity/Store.java new file mode 100644 index 0000000..b8a2be6 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/store/entity/Store.java @@ -0,0 +1,315 @@ +package com.ruoyi.frequency.store.entity; + +import cn.hutool.core.date.DateUtil; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableName; +import com.fasterxml.jackson.annotation.JsonFormat; +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import com.ruoyi.frequency.enterprise.entity.Enterprise; +import com.ruoyi.vo.UserInfo; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; + +import java.math.BigDecimal; +import java.util.Date; +import java.util.List; + +/** + * 商户对象 t_store (表现师) + * + * @author liwenlong + * @date 2023-09-22 + */ +@Data +@Accessors(chain = true) +@TableName("t_store") +public class Store extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** 主键id */ + private Long id; + + + /** 删除标志 1正常 删除 3 禁用 */ + private Integer delFlag; + + /** 用户id */ + @Excel(name = "用户id") + private Long customerId; + + /** 系统用户id */ + @Excel(name = "系统用户id") + private Long sysUserId; + + /** 售后天数 */ + @Excel(name = "售后天数") + private Long afterSaleDays; + + /** 昵称 */ + @Excel(name = "昵称") + private String nickname; + + /** 头像 */ + @Excel(name = "头像") + private String avatar; + + /** 账号 */ + @Excel(name = "账号") + private String account; + + /** 手机号(账号) */ + @Excel(name = "手机号(账号)") + private String mobile; + + /** 个签 */ + @Excel(name = "个签") + private String signature; + + /** 登录密码 */ + @Excel(name = "登录密码") + private String loginPwd; + + /** 支付密码 */ + @Excel(name = "支付密码") + private String payPwd; + + + /** 注销时间 */ + @Excel(name = "注销时间", width = 30, dateFormat = "yyyy-MM-dd") + private Date cancellationTime; + + /** 用户粉丝基数 */ + @Excel(name = "用户粉丝基数") + private Long fansNum; + + /** 用户关注基数 */ + @Excel(name = "用户关注基数") + private Long followNum; + + /** 余额 */ + @Excel(name = "余额") + private BigDecimal balance; + + /** 获赞量 */ + @Excel(name = "获赞量") + private Long likeNum; + + /** 是否缴纳保证金 1没有 2 已缴纳 */ + @Excel(name = "是否缴纳保证金 1没有 2 已缴纳") + private Integer isBond; + + /** 保证金额 */ + @Excel(name = "保证金额") + private BigDecimal bondAmount; + + /** 邀请码 */ + @Excel(name = "邀请码") + private String invitationCode; + + /** 绑定企业id */ + @Excel(name = "绑定企业id") + private Long bindEnterpriseId; + + /** 企业微信二维码 */ + @Excel(name = "企业微信二维码") + private String wecomQrcode; + + /** 入行时间 */ + @Excel(name = "入行时间", width = 30, dateFormat = "yyyy-MM-dd") + @JsonFormat(pattern = "yyyy") + private Date enterDate; + + /** 所属区域 */ + @Excel(name = "所属区域") + private String area; + + /** 在线状态;1:在线,2离线 */ + @Excel(name = "在线状态;1:在线,2离线") + private Integer onlineStatus; + + /** 在线时长;分钟 */ + @Excel(name = "在线时长;分钟") + private Integer onlineDuration; + + /** 微信openID */ + @Excel(name = "微信openID") + private String wechatOpenid; + + /** 小程序id */ + @Excel(name = "小程序id") + private String wechatAppletOpenid; + + /** 小程序unionId*/ + @Excel(name = "小程序unionId") + private String unionId; + + /** 苹果id */ + @Excel(name = "苹果id") + private String appleOpenid; + + /** 累计收益 */ + @Excel(name = "累计收益") + private BigDecimal income; + + /** 扣款 */ + @Excel(name = "扣款") + private BigDecimal violationDeduction; + + /** 等级id */ + @Excel(name = "等级id") + private Long levelId; + + /** 评分 */ + @Excel(name = "评分") + private BigDecimal star; + + /** 推送是否关闭;1不关闭2 关闭 */ + @Excel(name = "推送是否关闭;1不关闭2 关闭") + private Integer closeMessage; + + /** 是否是官方账号: 1不是 2 是 */ + private Integer isPlatform; + + + @ApiModelProperty(value = "积分") + private BigDecimal integral; + + @ApiModelProperty(value = "累计积分") + private BigDecimal accumulateIntegral; + + @ApiModelProperty(value = "曾经任职公司") + private String onceWorkCompanys; + + @ApiModelProperty(value = "是否是dd认证 1不是 2是") + private Integer isDdAuth; + + @ApiModelProperty(value = "用户类型 1 用户 2 代理商 3 企业") + @TableField(exist = false) + private Integer userType = 2; + + /** 等级名称 */ + @Excel(name = "等级名称") + @TableField(exist = false) + private String levelName; + + /** 认证状态 1未认证 2普通认证 3高端认证 */ + @Excel(name = "认证状态 1未认证 2普通认证 3高端认证") + @TableField(exist = false) + private Integer authStatus; + + @ApiModelProperty(value = "是否高端认证 1 没有 2认证") + @TableField(exist = false) + private Integer ifHighend; + + @ApiModelProperty(value = "高端认证 0 未认证 1 待完善 2待付款 3待上传企业微信二维码") + @TableField(exist = false) + private Integer isHighendAuth; + + @ApiModelProperty("擅长领域") + @Excel(name = "擅长领域") + private String specialityArea; + + @ApiModelProperty("昵称") + private String name; + + @ApiModelProperty("企业微信userid") + private String wecomUserid; + + @ApiModelProperty("表现师订单提成比例") + private BigDecimal commissionRatio; + + @ApiModelProperty(value = "是否普通认证 1 没有 2认证") + @TableField(exist = false) + private Integer isAuth; + + @ApiModelProperty(value = "企业信息") + @TableField(exist = false) + private Enterprise enterprise; + + + @ApiModelProperty(value = "背景图") + private String backgroundImage; + + @ApiModelProperty(value = "用户信息") + @TableField(exist = false) + private UserInfo userInfo = new UserInfo(); + + @ApiModelProperty("开始时间") + @TableField(exist = false) + private Date beginTime; + + @ApiModelProperty("结束时间") + @TableField(exist = false) + private Date endTime; + + + @ApiModelProperty("排序 1在线时长降序 2 在线时长升序") + @TableField(exist = false) + private Integer sortType; + + + @ApiModelProperty("用户ids") + @TableField(exist = false) + private List userIds; + + @ApiModelProperty("从业年限范围") + @TableField(exist = false) + private String yearRange; + + @ApiModelProperty("从业年限范围") + @TableField(exist = false) + private Integer minYear; + + @ApiModelProperty("从业年限范围") + @TableField(exist = false) + private Integer maxYear; + + @ApiModelProperty(value = "可提现金额") + @TableField(exist = false) + private BigDecimal withdrawableAmount; + + @ApiModelProperty(value = "待提现金额") + @TableField(exist = false) + private BigDecimal toBeWithdrawnAmount; + + @ApiModelProperty("从业年限范围") + @TableField(exist = false) + private Date beginOfMonth = DateUtil.beginOfMonth(new Date()); + + @ApiModelProperty("筛选 1未创建高端认证") + @TableField(exist = false) + private Integer screen; + + @ApiModelProperty("性别") + @TableField(exist = false) + private String sex; + + @ApiModelProperty("订单数量") + @TableField(exist = false) + private Integer orderCount; + + @ApiModelProperty("订单单价") + @TableField(exist = false) + private BigDecimal unitPrice; + + @ApiModelProperty("最近交易时间") + @TableField(exist = false) + private Date lastTransactionTime; + + @ApiModelProperty("当月金额、业绩") + @TableField(exist = false) + private BigDecimal monthAmount; + + @ApiModelProperty("订单id") + @Excel(name = "订单id") + @TableField(exist = false) + private Long orderId; + + @ApiModelProperty("扣款类型") + @Excel(name = "扣款类型") + @TableField(exist = false) + private String deductionType; +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/store/mapper/StoreMapper.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/store/mapper/StoreMapper.java new file mode 100644 index 0000000..5549a9d --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/store/mapper/StoreMapper.java @@ -0,0 +1,115 @@ +package com.ruoyi.frequency.store.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.ruoyi.frequency.store.entity.Store; +import com.ruoyi.frequency.store.model.result.OrderResult; +import com.ruoyi.frequency.store.model.result.StoreCount; +import org.apache.ibatis.annotations.Param; +import org.apache.ibatis.annotations.Update; + +import java.math.BigDecimal; +import java.util.Date; +import java.util.List; + +/** + * 商户Mapper接口 + * + * @author liwenlong + * @date 2023-09-22 + */ +public interface StoreMapper extends BaseMapper +{ + /** + * 查询商户 + * + * @param id 商户主键 + * @return 商户 + */ + public Store selectStoreById(Long id); + + /** + * 查询商户列表 + * + * @param store 商户 + * @return 商户集合 + */ + public List selectStoreList(Store store); + + /** + * 新增商户 + * + * @param store 商户 + * @return 结果 + */ + public int insertStore(Store store); + + /** + * 修改商户 + * + * @param store 商户 + * @return 结果 + */ + public int updateStore(Store store); + + /** + * 删除商户 + * + * @param id 商户主键 + * @return 结果 + */ + public int deleteStoreById(Long id); + + /** + * 批量删除商户 + * + * @param ids 需要删除的数据主键集合 + * @return 结果 + */ + public int deleteStoreByIds(Long[] ids); + + @Update("update t_store set balance=balance + #{price} where id = #{storeId}") + boolean addBalance(@Param("storeId") Long storeId, @Param("price") BigDecimal price); + + @Update("update t_store set balance=balance - #{price} where id = #{storeId} and balance >=#{price}") + boolean subBalance(@Param("storeId") Long storeId, @Param("price") BigDecimal price); + + @Update("update t_store set violation_deduction=violation_deduction + #{price} where id = #{storeId}") + boolean addViolationDeduction(@Param("storeId") Long storeId, @Param("price") BigDecimal price); + + @Update("update t_store set violation_deduction=violation_deduction - #{price} where id = #{storeId} and violation_deduction >=#{price}") + boolean subViolationDeduction(@Param("storeId") Long storeId, @Param("price") BigDecimal price); + + + @Update("update t_store set bond_amount=bond_amount + #{price} where id = #{storeId}") + boolean addBondAmount(@Param("storeId") Long storeId, @Param("price") BigDecimal price); + + @Update("update t_store set bond_amount=bond_amount - #{price} where id = #{storeId} and bond_amount >=#{price}") + boolean subBondAmount(@Param("storeId") Long storeId, @Param("price") BigDecimal price); + + void saveIdNo(@Param("id") Long id); + + @Update("update t_store set income=income + #{price} where id = #{storeId}") + boolean addIncome(@Param("storeId") Long storeId, @Param("price") BigDecimal price); + + + @Update("update t_store set integral=integral + #{price} where id = #{storeId}") + boolean addIntegral(@Param("storeId") Long storeId, @Param("price") BigDecimal price); + + @Update("update t_store set integral=integral - #{price} where id = #{storeId} and integral >=#{price}") + boolean subIntegral(@Param("storeId") Long storeId, @Param("price") BigDecimal price); + + int getAuthStore(@Param("list") List userIds); + + int getCommonAuthStore(@Param("list") List userIds); + + int getHighAuthStore(@Param("list") List userIds); + + int getKujialeAuthStore(@Param("list") List userIds); + StoreCount statistics(@Param("list") List storeIdList,@Param("beginOfMonth") Date beginOfMonth); + + Integer onlineNumber(Store store); + + OrderResult getOrderInfo(@Param("orderId") Long orderId); + + Integer canCancellation(@Param("userId") Long userId); +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/store/mapper/mapping/StoreMapper.xml b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/store/mapper/mapping/StoreMapper.xml new file mode 100644 index 0000000..96bc1c5 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/store/mapper/mapping/StoreMapper.xml @@ -0,0 +1,659 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + SELECT t.id, + t.create_by, + t.create_time, + t.update_by, + t.update_time, + t.del_flag, + t.customer_id, + t.sys_user_id, + t.after_sale_days, + t.nickname, + t.name, + t.avatar, + t.account, + t.mobile, + t.signature, + t.login_pwd, + t.pay_pwd, + t.cancellation_time, + (SELECT count(1) FROM t_follow f WHERE f.del_flag = 1 AND f.user_type = 2 AND f.user_id = t.id) fansNum, + (SELECT count(1) + FROM t_follow f + WHERE f.del_flag = 1 + AND f.follower_user_type = 2 + AND f.follower_user_id = t.id) followNum, + t.balance, + t.like_num, + t.is_bond, + t.bond_amount, + t.invitation_code, + t.bind_enterprise_id, + t.wecom_qrcode, + t.enter_date, + t.area, + t.online_status, + t.online_duration, + t.wechat_openid, + t.income, + t.violation_deduction, + t.level_id, + t.remark, + t.star, + l.`name` levelName, + t.close_message, + t.is_platform, + t.is_dd_auth, + t.commission_ratio, + case + when t3.id is not null and t3.type = 1 then t3.result + else 0 + end as isAuth, + case when t4.id is not null then t4.status else 0 end isHighendAuth, + case when t4.id is not null AND t4.`status` >= 3 then 2 else 1 end ifHighend, + t.speciality_area, + (SELECT + sum(IFNULL(wt.price,0)) + FROM + t_wallet_record wt + WHERE + wt.del_flag = 1 + AND ( + ( + wt.record_type IN (6, 8) + AND wt.create_time < #{beginOfMonth} + ) + OR wt.record_type IN (2, 3, 7, 10, 11, 12, 17, 20) + ) + AND wt.user_type = 2 + AND wt.user_id = t.id) withdrawableAmount, + t.integral, + t.once_work_companys, + t.accumulate_integral, + t3.sex, + (SELECT count(1) + FROM t_order o + WHERE o.first_status = 2 AND o.store_id = t.id ) orderCount, + ( + SELECT + IFNULL(ROUND(AVG(o.amount), 2) , 0) + FROM + t_order o + WHERE + o.first_status = 2 + AND o.store_id = t.id + ) unitPrice + , ( + SELECT + create_time + FROM + t_order o + WHERE + o.first_status = 2 + AND o.store_id = t.id + ORDER BY + o.create_time DESC + LIMIT 1 + ) lastTransactionTime, + ( + SELECT + IFNULL(sum (o.amount), 0) + FROM + t_order o + WHERE + o.first_status = 2 + AND o.store_id = t.id + AND DATE_FORMAT(o.create_time + , '%Y-%m-01') >= DATE_FORMAT(CURDATE() + , '%Y-%m-01') + ) monthAmount + FROM + t_store AS t + LEFT JOIN t_level l + ON l.type = 2 and l.id = ( + SELECT + l2.id + FROM + t_level l2 + WHERE + l2.del_flag = 1 + and l2.type = 2 + and l2.compliance <= t.income + ORDER BY + l2.compliance DESC + LIMIT 1 + ) + LEFT JOIN t_auth AS t3 ON t3.store_id = t.id + AND t3.del_flag = 1 + AND t3.result = 2 + AND t3.pay_status = 2 + LEFT JOIN t_highend_auth AS t4 ON t4.store_id = t.id + AND t4.del_flag = 1 + + + + + + + + + + + + insert into t_store + + id, + create_by, + create_time, + update_by, + update_time, + del_flag, + customer_id, + sys_user_id, + after_sale_days, + nickname, + avatar, + account, + mobile, + signature, + login_pwd, + pay_pwd, + cancellation_time, + fans_num, + follow_num, + balance, + like_num, + is_bond, + bond_amount, + invitation_code, + bind_enterprise_id, + wecom_qrcode, + enter_date, + area, + online_status, + online_duration, + wechat_openid, + income, + violation_deduction, + level_id, + star, + + + #{id}, + #{createUser}, + #{createTime}, + #{updateUser}, + #{updateTime}, + #{delFlag}, + #{customerId}, + #{sysUserId}, + #{afterSaleDays}, + #{nickname}, + #{avatar}, + #{account}, + #{mobile}, + #{signature}, + #{loginPwd}, + #{payPwd}, + #{cancellationTime}, + #{fansNum}, + #{followNum}, + #{balance}, + #{likeNum}, + #{isBond}, + #{bondAmount}, + #{invitationCode}, + #{bindEnterpriseId}, + #{wecomQrcode}, + #{enterDate}, + #{area}, + #{onlineStatus}, + #{onlineDuration}, + #{wechatOpenid}, + #{income}, + #{violationDeduction}, + #{levelId}, + #{star}, + + + + + update t_store + + create_time = #{createTime}, + update_time = #{updateTime}, + del_flag = #{delFlag}, + customer_id = #{customerId}, + sys_user_id = #{sysUserId}, + after_sale_days = #{afterSaleDays}, + nickname = #{nickname}, + avatar = #{avatar}, + account = #{account}, + mobile = #{mobile}, + signature = #{signature}, + login_pwd = #{loginPwd}, + pay_pwd = #{payPwd}, + cancellation_time = #{cancellationTime}, + fans_num = #{fansNum}, + follow_num = #{followNum}, + balance = #{balance}, + like_num = #{likeNum}, + is_bond = #{isBond}, + bond_amount = #{bondAmount}, + invitation_code = #{invitationCode}, + bind_enterprise_id = #{bindEnterpriseId}, + wecom_qrcode = #{wecomQrcode}, + enter_date = #{enterDate}, + area = #{area}, + online_status = #{onlineStatus}, + online_duration = #{onlineDuration}, + wechat_openid = #{wechatOpenid}, + income = #{income}, + violation_deduction = #{violationDeduction}, + level_id = #{levelId}, + star = #{star}, + + where id = #{id} + + + UPDATE t_store + SET nickname = ( + SELECT + tt.num + FROM + ( + SELECT + count(*) AS num + FROM + t_store + WHERE + create_time <= ( + SELECT + create_time + FROM + t_store + WHERE + id = #{id} + ) + ) tt + ) + WHERE + id = #{id} + + + + delete from t_store where id = #{id} + + + + delete from t_store where id in + + #{id} + + + + + + + + + + + + + + + + + + diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/store/model/param/StoreParam.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/store/model/param/StoreParam.java new file mode 100644 index 0000000..cef01a3 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/store/model/param/StoreParam.java @@ -0,0 +1,183 @@ +package com.ruoyi.frequency.store.model.param; + +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import lombok.Data; +import lombok.experimental.Accessors; + +import java.math.BigDecimal; +import java.util.Date; + +/** + * 商户对象 t_store + * + * @author liwenlong + * @date 2023-09-22 + */ +@Data +@Accessors(chain = true) +public class StoreParam extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** 主键id */ + private Long id; + + /** 创建人 */ + @Excel(name = "创建人") + private Long createUser; + + /** 更新人 */ + @Excel(name = "更新人") + private Long updateUser; + + /** 删除标志 1正常 删除 3 禁用 */ + private Integer delFlag; + + /** 用户id */ + @Excel(name = "用户id") + private Long customerId; + + /** 系统用户id */ + @Excel(name = "系统用户id") + private Long sysUserId; + + /** 售后天数 */ + @Excel(name = "售后天数") + private Long afterSaleDays; + + /** 昵称 */ + @Excel(name = "昵称") + private String nickname; + + /** 头像 */ + @Excel(name = "头像") + private String avatar; + + /** 账号 */ + @Excel(name = "账号") + private String account; + + /** 手机号(账号) */ + @Excel(name = "手机号(账号)") + private String mobile; + + /** 个签 */ + @Excel(name = "个签") + private String signature; + + /** 登录密码 */ + @Excel(name = "登录密码") + private String loginPwd; + + /** 支付密码 */ + @Excel(name = "支付密码") + private String payPwd; + + /** 注销时间 */ + @Excel(name = "注销时间", width = 30, dateFormat = "yyyy-MM-dd") + private Date cancellationTime; + + /** 用户粉丝基数 */ + @Excel(name = "用户粉丝基数") + private Long fansNum; + + /** 用户关注基数 */ + @Excel(name = "用户关注基数") + private Long followNum; + + /** 余额 */ + @Excel(name = "余额") + private BigDecimal balance; + + /** 获赞量 */ + @Excel(name = "获赞量") + private Long likeNum; + + /** 是否缴纳保证金 1没有 2 已缴纳 */ + @Excel(name = "是否缴纳保证金 1没有 2 已缴纳") + private Integer isBond; + + /** 保证金额 */ + @Excel(name = "保证金额") + private BigDecimal bondAmount; + + /** 邀请码 */ + @Excel(name = "邀请码") + private String invitationCode; + + /** 绑定企业id */ + @Excel(name = "绑定企业id") + private Long bindEnterpriseId; + + /** 企业微信二维码 */ + @Excel(name = "企业微信二维码") + private String wecomQrcode; + + /** 入行时间 */ + @Excel(name = "入行时间", width = 30, dateFormat = "yyyy-MM-dd") + private Date enterDate; + + /** 所属区域 */ + @Excel(name = "所属区域") + private String area; + + /** 在线状态;1:在线,2离线 */ + @Excel(name = "在线状态;1:在线,2离线") + private Integer onlineStatus; + + /** 在线时长;分钟 */ + @Excel(name = "在线时长;分钟") + private Integer onlineDuration; + + /** 微信openID */ + @Excel(name = "微信openID") + private String wechatOpenid; + + /** 累计收益 */ + @Excel(name = "累计收益") + private BigDecimal income; + + /** 扣款 */ + @Excel(name = "扣款") + private BigDecimal violationDeduction; + + /** 等级id */ + @Excel(name = "等级id") + private Long levelId; + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/store/model/result/OrderResult.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/store/model/result/OrderResult.java new file mode 100644 index 0000000..8dc96d1 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/store/model/result/OrderResult.java @@ -0,0 +1,247 @@ +package com.ruoyi.frequency.store.model.result; + +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableName; +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import com.ruoyi.vo.UserInfo; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; + +import java.math.BigDecimal; +import java.util.Date; +import java.util.List; + +/** + * 订单主对象 t_order + * + * @author zj + * @date 2023-10-13 + */ +@Data +@Accessors(chain = true) +public class OrderResult extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + + @ApiModelProperty("租户号") + private Long id; + + @ApiModelProperty("删除标志;1 正常 2 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("订单标题") + @Excel(name = "订单标题") + private String title; + + @ApiModelProperty("素材") + @Excel(name = "素材") + private String sourceMaterial; + + @ApiModelProperty("原价") + @Excel(name = "原价") + private BigDecimal originAmount; + + @ApiModelProperty("订单金额") + @Excel(name = "订单金额") + private BigDecimal amount; + + @ApiModelProperty("改价后金额(客户确认后,改价后金额同步到amount中)") + @Excel(name = "改价后金额(客户确认后,改价后金额同步到amount中)") + private BigDecimal changeAmount; + + @ApiModelProperty("提出改价的用户身份 1 设计师 2 表现师") + @Excel(name = "提出改价的用户身份 1 设计师 2 表现师") + private Integer changeUserType; + + @ApiModelProperty("改价状态 1 待确认 2 已确认") + @Excel(name = "改价状态 1 待确认 2 已确认") + private Integer changeStatus; + + @ApiModelProperty("价格调整备注") + @Excel(name = "价格调整备注") + private String changeRemark; + + @ApiModelProperty("交付时间") + @Excel(name = "交付时间", width = 30, dateFormat = "yyyy-MM-dd") + private Date confirmDate; + + @ApiModelProperty("设计师id") + @Excel(name = "设计师id") + private Long customerId; + + @ApiModelProperty("表现师id") + @Excel(name = "表现师id") + private Long storeId; + + @ApiModelProperty("销售从中拿到的佣金") + @Excel(name = "销售从中拿到的佣金") + private BigDecimal saleAmount; + + @ApiModelProperty("销售id") + @Excel(name = "销售id") + private Long saleId; + + @ApiModelProperty("内容") + @Excel(name = "内容") + private String content; + + @ApiModelProperty("订单状态;-1 已取消 1待确认 2进行中 3待收图 4待评价 5已评价 ") + @Excel(name = "订单状态;-1 已取消 1待确认 2进行中 3待收图 4待评价 5已评价 ") + private Integer status; + + @ApiModelProperty("申诉状态;1无申诉 2申诉中 3申诉完成") + @Excel(name = "申诉状态;1无申诉 2申诉中 3申诉完成") + private Integer appealStatus; + + @ApiModelProperty("申请用户类型 1 设计师 2 表现师") + @Excel(name = "申请用户类型 1 设计师 2 表现师") + private Integer appealUserType; + + @ApiModelProperty("订单来源 1 设计师自己下单 2 表现师帮设计师下单") + @Excel(name = "订单来源 1 设计师自己下单 2 表现师帮设计师下单") + private Integer sourceUserType; + + @ApiModelProperty("封面图") + @Excel(name = "封面图") + private String coverImage; + + @ApiModelProperty("作品图片") + @Excel(name = "作品图片") + private String images; + + @ApiModelProperty("首款") + @Excel(name = "首款") + private BigDecimal firstPrice; + + @ApiModelProperty("首款支付状态 1 未支付 2 已支付") + @Excel(name = "首款支付状态 1 未支付 2 已支付") + private Integer firstStatus; + + @ApiModelProperty("首款支付方式 1app支付宝 2 h5支付宝 3 app微信 4 h5微信 5 小程序 6 苹果支付 7 余额") + @Excel(name = "首款支付方式 1app支付宝 2 h5支付宝 3 app微信 4 h5微信 5 小程序 6 苹果支付 7 余额") + private Integer firstPayType; + + + @ApiModelProperty("尾款支付状态 1 未支付 2 已支付") + @Excel(name = "尾款支付状态 1 未支付 2 已支付") + private Integer secondStatus; + + @ApiModelProperty("尾款支付方式 1app支付宝 2 h5支付宝 3 app微信 4 h5微信 5 小程序 6 苹果支付 7 余额") + @Excel(name = "尾款支付方式 1app支付宝 2 h5支付宝 3 app微信 4 h5微信 5 小程序 6 苹果支付 7 余额") + private Integer secondPayType; + + @ApiModelProperty("订单号") + @Excel(name = "订单号") + private String orderNo; + + @ApiModelProperty("支付宝支付返回的订单号") + @Excel(name = "支付宝支付返回的订单号") + private String aliBusinessId; + + @ApiModelProperty("首款支付时间") + @Excel(name = "首款支付时间", width = 30, dateFormat = "yyyy-MM-dd") + private Date firstPayTime; + + @ApiModelProperty("尾款支付时间") + @Excel(name = "尾款支付时间", width = 30, dateFormat = "yyyy-MM-dd") + private Date secondPayTime; + + @ApiModelProperty("作品类型ID") + private Long worksTypeId; + + + @ApiModelProperty("首款支付单号") + private String firstPayOrderNo; + + @ApiModelProperty("尾款支付单号") + private String secondPayOrderNo; + + @ApiModelProperty("设计师是否评价 1 没有 2 评价") + private Integer isCustomerEvaluate; + + + @ApiModelProperty("表现师是否评价1 没有 2 评价") + private Integer isStoreEvaluate; + + @ApiModelProperty("图纸张数") + private Integer drawingNum; + + @ApiModelProperty("是否同步到作品库 1不同步 2同步") + private Integer isAgree; + + + @ApiModelProperty("尾款支付宝支付返回的订单号") + private String secondAliBusinessId; + + + + @ApiModelProperty("原始对图时间") + @Excel(name = "原始对图时间", width = 30, dateFormat = "yyyy-MM-dd") + private Date originDeliverTime; + + @ApiModelProperty("对图时间") + @Excel(name = "对图时间", width = 30, dateFormat = "yyyy-MM-dd") + private Date deliverTime; + + @ApiModelProperty("延期后时间 表现师确认后 更新对图时间") + @Excel(name = "延期后时间 表现师确认后 更新对图时间", width = 30, dateFormat = "yyyy-MM-dd") + private Date extensionDeliverTime; + + @ApiModelProperty("延期用户身份 1 设计师 2 表现师") + @Excel(name = "延期用户身份 1 设计师 2 表现师") + private Integer extensionUserType; + + @ApiModelProperty("延期状态 1 待确认 2 已确认") + @Excel(name = "延期状态 1 待确认 2 已确认") + private Integer extensionStatus; + + @ApiModelProperty("延期备注") + @Excel(name = "延期备注") + private String extensionRemark; + + + @ApiModelProperty("是否到交付时间发送消息 1没有 2 发送") + private Integer isPushMessage; + + + @ApiModelProperty("是否高端认证:1:普通技术 2高端技术") + private Integer ifHighend; + + @ApiModelProperty("首款赠送支付金额") + private BigDecimal firstGivePrice; + + @ApiModelProperty("尾款赠送支付金额") + private BigDecimal secondGivePrice; + + @ApiModelProperty("首款三方支付金额") + private BigDecimal firstTripartitePrice; + + @ApiModelProperty("尾款三方支付金额") + private BigDecimal secondTripartitePrice; + + + @ApiModelProperty("作品类型名称") + @TableField(exist = false) + private String worksTypeName; + + + @ApiModelProperty("开始时间") + @TableField(exist = false) + private Date beginTime; + + @ApiModelProperty("结束时间") + @TableField(exist = false) + private Date endTime; + + @ApiModelProperty("开始时间") + @TableField(exist = false) + private Date confirmBeginTime; + + @ApiModelProperty("结束时间") + @TableField(exist = false) + private Date confirmEndTime; + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/store/model/result/StoreCount.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/store/model/result/StoreCount.java new file mode 100644 index 0000000..1ba0b25 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/store/model/result/StoreCount.java @@ -0,0 +1,36 @@ +package com.ruoyi.frequency.store.model.result; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.math.BigDecimal; + +/** + * @author a + * @date 2024/2/22 11:42 + */ +@Data +public class StoreCount { + + @ApiModelProperty("总人数") + private Integer number =0; + + @ApiModelProperty("在线人数") + private Integer onlineNumber = 0; + + @ApiModelProperty("总在线时长") + private Integer onlineDuration = 0; + + @ApiModelProperty("余额") + private BigDecimal balance = new BigDecimal("0"); + + @ApiModelProperty("提现金额") + private BigDecimal withdrawableAmount = new BigDecimal("0"); + + @ApiModelProperty("累计收益") + private BigDecimal income = new BigDecimal("0"); + + @ApiModelProperty("保证金金额") + private BigDecimal bondAmount = new BigDecimal("0"); + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/store/model/result/StoreResult.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/store/model/result/StoreResult.java new file mode 100644 index 0000000..499ea6a --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/store/model/result/StoreResult.java @@ -0,0 +1,151 @@ +package com.ruoyi.frequency.store.model.result; + +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import lombok.Data; +import lombok.experimental.Accessors; + +import java.math.BigDecimal; +import java.util.Date; + +/** + * 商户对象 t_store + * + * @author liwenlong + * @date 2023-09-22 + */ +@Data +@Accessors(chain = true) +public class StoreResult extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** 主键id */ + private Long id; + + /** 创建人 */ + @Excel(name = "创建人") + private Long createUser; + + /** 更新人 */ + @Excel(name = "更新人") + private Long updateUser; + + /** 删除标志 1正常 删除 3 禁用 */ + private Integer delFlag; + + /** 用户id */ + @Excel(name = "用户id") + private Long customerId; + + /** 系统用户id */ + @Excel(name = "系统用户id") + private Long sysUserId; + + /** 售后天数 */ + @Excel(name = "售后天数") + private Long afterSaleDays; + + /** 昵称 */ + @Excel(name = "昵称") + private String nickname; + + /** 头像 */ + @Excel(name = "头像") + private String avatar; + + /** 账号 */ + @Excel(name = "账号") + private String account; + + /** 手机号(账号) */ + @Excel(name = "手机号(账号)") + private String mobile; + + /** 个签 */ + @Excel(name = "个签") + private String signature; + + /** 登录密码 */ + @Excel(name = "登录密码") + private String loginPwd; + + /** 支付密码 */ + @Excel(name = "支付密码") + private String payPwd; + + + /** 注销时间 */ + @Excel(name = "注销时间", width = 30, dateFormat = "yyyy-MM-dd") + private Date cancellationTime; + + /** 用户粉丝基数 */ + @Excel(name = "用户粉丝基数") + private Long fansNum; + + /** 用户关注基数 */ + @Excel(name = "用户关注基数") + private Long followNum; + + /** 余额 */ + @Excel(name = "余额") + private BigDecimal balance; + + /** 获赞量 */ + @Excel(name = "获赞量") + private Long likeNum; + + /** 是否缴纳保证金 1没有 2 已缴纳 */ + @Excel(name = "是否缴纳保证金 1没有 2 已缴纳") + private Integer isBond; + + /** 保证金额 */ + @Excel(name = "保证金额") + private BigDecimal bondAmount; + + /** 邀请码 */ + @Excel(name = "邀请码") + private String invitationCode; + + /** 绑定企业id */ + @Excel(name = "绑定企业id") + private Long bindEnterpriseId; + + /** 企业微信二维码 */ + @Excel(name = "企业微信二维码") + private String wecomQrcode; + + /** 入行时间 */ + @Excel(name = "入行时间", width = 30, dateFormat = "yyyy-MM-dd") + private Date enterDate; + + /** 所属区域 */ + @Excel(name = "所属区域") + private String area; + + /** 在线状态;1:在线,2离线 */ + @Excel(name = "在线状态;1:在线,2离线") + private Integer onlineStatus; + + /** 在线时长;分钟 */ + @Excel(name = "在线时长;分钟") + private Integer onlineDuration; + + /** 微信openID */ + @Excel(name = "微信openID") + private String wechatOpenid; + + /** 累计收益 */ + @Excel(name = "累计收益") + private BigDecimal income; + + /** 扣款 */ + @Excel(name = "扣款") + private BigDecimal violationDeduction; + + /** 等级id */ + @Excel(name = "等级id") + private Long levelId; + + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/store/service/StoreService.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/store/service/StoreService.java new file mode 100644 index 0000000..e171a65 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/store/service/StoreService.java @@ -0,0 +1,128 @@ +package com.ruoyi.frequency.store.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.controller.req.RegisterUserReq; +import com.ruoyi.controller.req.UserEditReqVo; +import com.ruoyi.frequency.store.entity.Store; +import com.ruoyi.frequency.store.model.result.StoreCount; +import com.ruoyi.response.ResponseData; +import com.ruoyi.vo.UserVo; + +import java.util.List; + +/** + * 商户Service接口 + * + * @author liwenlong + * @date 2023-09-22 + */ +public interface StoreService extends IService +{ + /** + * 查询商户 + * + * @param id 商户主键 + * @return 商户 + */ + public Store selectStoreById(Long id); + + /** + * 查询商户列表 + * + * @param store 商户 + * @return 商户集合 + */ + public List selectStoreList(Store store); + + + StoreCount statistics(Store store); + /** + * 新增商户 + * + * @param store 商户 + * @return 结果 + */ + public int insertStore(Store store); + + /** + * 修改商户 + * + * @param store 商户 + * @return 结果 + */ + public int updateStore(Store store); + + /** + * 批量删除商户 + * + * @param ids 需要删除的商户主键集合 + * @return 结果 + */ + public int deleteStoreByIds(Long[] ids,Integer delFlag); + + /** + * 删除商户信息 + * + * @param id 商户主键 + * @return 结果 + */ + public int deleteStoreById(Long id); + + + /** + * 修改扣款金额 + * @param store + * @return + */ + int updateViolationDeduction(Store store); + + /** + * 设置为企业 + * @param store + * @return + */ + AjaxResult setUpEnterprise(Store store); + + /** + * 修改余额 + * @param store + * @return + */ + AjaxResult updateBalance(Store store); + + + Store assembleStore(RegisterUserReq req, String md5Pwd); + + void saveIdNo(Long id); + + /** + * 编辑用户信息 + * @param req + * @param userVo + * @return + */ + ResponseData editInfo(UserEditReqVo req, UserVo userVo); + + /** + * 用户个人信息 + * @param userVo + * @return + */ + ResponseData info(UserVo userVo); + + int getAuthStore(List userIds,Integer ifHighend); + + /** + * 设置为平台 + * @param store + * @return + */ + AjaxResult setUpPlatform(Store store); + + AjaxResult setDDAuth(Store store); + + AjaxResult setCommissionRatio(Store store); + + void canCancellation(Long userId); +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/store/service/impl/StoreServiceImpl.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/store/service/impl/StoreServiceImpl.java new file mode 100644 index 0000000..b751a02 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/store/service/impl/StoreServiceImpl.java @@ -0,0 +1,666 @@ +package com.ruoyi.frequency.store.service.impl; + +import cn.hutool.core.date.DateUtil; +import cn.hutool.core.util.ObjectUtil; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.conditions.update.LambdaUpdateChainWrapper; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.ruoyi.code.DictConstant; +import com.ruoyi.code.PublicCommon; +import com.ruoyi.common.constant.UserConstants; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.domain.entity.SysDictData; +import com.ruoyi.common.core.domain.entity.SysRole; +import com.ruoyi.common.core.domain.entity.SysUser; +import com.ruoyi.common.core.redis.RedisService; +import com.ruoyi.common.exception.CustomException; +import com.ruoyi.common.exception.ServiceException; +import com.ruoyi.common.utils.DateUtils; +import com.ruoyi.common.utils.SecurityUtils; +import com.ruoyi.common.utils.StringUtils; +import com.ruoyi.controller.req.RegisterUserReq; +import com.ruoyi.controller.req.UserEditReqVo; +import com.ruoyi.enums.PlatformRecordEnums; +import com.ruoyi.enums.WalletDetailEnums; +import com.ruoyi.enums.message.OrderMessageEnums; +import com.ruoyi.enums.user.UserEnums; +import com.ruoyi.frequency.customer.entity.Customer; +import com.ruoyi.frequency.customer.mapper.CustomerMapper; +import com.ruoyi.frequency.enterprise.entity.Enterprise; +import com.ruoyi.frequency.enterprise.service.EnterpriseService; +import com.ruoyi.frequency.illegaldeductionrecord.service.IllegalDeductionRecordService; +import com.ruoyi.frequency.level.service.LevelService; +import com.ruoyi.frequency.ordermessage.service.OrderMessageUtilService; +import com.ruoyi.frequency.platformrecord.service.PlatformRecordService; +import com.ruoyi.frequency.store.entity.Store; +import com.ruoyi.frequency.store.mapper.StoreMapper; +import com.ruoyi.frequency.store.model.result.OrderResult; +import com.ruoyi.frequency.store.model.result.StoreCount; +import com.ruoyi.frequency.store.service.StoreService; +import com.ruoyi.frequency.wallerecord.service.WalletRecordService; +import com.ruoyi.response.ResponseData; +import com.ruoyi.system.service.ISysConfigService; +import com.ruoyi.system.service.ISysRoleService; +import com.ruoyi.system.service.ISysUserService; +import com.ruoyi.utils.BusinessUtil; +import com.ruoyi.utils.SnowIdUtils; +import com.ruoyi.vo.UserVo; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.redis.core.RedisTemplate; +import org.springframework.stereotype.Service; + +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.Map; +import java.util.concurrent.TimeUnit; +import java.util.stream.Collectors; + +/** + * 商户Service业务层处理 + * + * @author liwenlong + * @date 2023-09-22 + */ +@Service +public class StoreServiceImpl extends ServiceImpl implements StoreService { + @Autowired + private StoreMapper storeMapper; + + @Autowired + private BusinessUtil businessUtil; + + /** + * 查询商户 + * + * @param id 商户主键 + * @return 商户 + */ + @Override + public Store selectStoreById(Long id) { + + Store store = storeMapper.selectStoreById(id); + + if (store != null) { + //是企业查询企业信息 + if (ObjectUtil.isNotEmpty(store.getBindEnterpriseId())) { + Enterprise enterprise = enterpriseService.getById(store.getBindEnterpriseId()); + store.setEnterprise(enterprise); + } + + //上次调用此接口的时间 + String last_time_map_key = "last_time_" + 2; + + //在线状态;1:在线,2离线 + Integer onlineStatus = 2; + + if (redisTemplate.opsForHash().hasKey(last_time_map_key, store.getId().toString())) { + long lastTimes = Long.valueOf(redisTemplate.opsForHash().get(last_time_map_key, store.getId().toString()).toString()); + + //判断当前时间和上次时间是否超过6分钟(考虑到网络延时和程序卡顿,多1分钟) + if (System.currentTimeMillis() - lastTimes < (6 * 60 * 1000)) { + onlineStatus = 1; + } + } + + store.setOnlineStatus(onlineStatus); + } + + return store; + } + + @Autowired + private RedisService redisService; + + /** + * 查询商户列表 + * + * @param store 商户 + * @return 商户 + */ + @Override + public List selectStoreList(Store store) { + + //上次调用此接口的时间 + String last_time_map_key = "last_time_" + 2; + + List stores = storeList(store); + + if (stores.size() > 0) { + + stores.stream().forEach(s -> { + + //在线状态;1:在线,2离线 + Integer onlineStatus = 2; + + if (redisTemplate.opsForHash().hasKey(last_time_map_key, s.getId().toString())) { + long lastTimes = Long.valueOf(redisTemplate.opsForHash().get(last_time_map_key, s.getId().toString()).toString()); + + //判断当前时间和上次时间是否超过6分钟(考虑到网络延时和程序卡顿,多1分钟) + if (System.currentTimeMillis() - lastTimes < (6 * 60 * 1000)) { + onlineStatus = 1; + } + } + + //在线状态 + s.setOnlineStatus(onlineStatus); + + //可提现金额 + if (s.getWithdrawableAmount() == null) { + s.setWithdrawableAmount(BigDecimal.ZERO); + } + s.setWithdrawableAmount(s.getWithdrawableAmount().compareTo(BigDecimal.ZERO) == 1 ? s.getWithdrawableAmount() : BigDecimal.ZERO); + + //待提现金额 + s.setToBeWithdrawnAmount(s.getBalance().subtract(s.getWithdrawableAmount())); + }); + } + return stores; + } + + private List storeList(Store store) { + //从业年限筛选 + if (ObjectUtil.isNotEmpty(store.getYearRange())) { + String[] split = store.getYearRange().split("-"); + if (split.length == 1) { + store.setMaxYear(Integer.valueOf(split[0])); + } + if (split.length == 2) { + store.setMinYear(Integer.valueOf(split[0])); + store.setMaxYear(Integer.valueOf(split[1])); + } + } + + + //上次调用此接口的时间 + String last_time_map_key = "last_time_" + 2; + + //在线状态;1:在线,2离线 + if (ObjectUtil.isNotEmpty(store.getOnlineStatus())) { + + List userIds = new ArrayList<>(); + + if (redisTemplate.hasKey(last_time_map_key)) { + + Map cacheMap = redisService.getCacheMap(last_time_map_key); + + cacheMap.forEach((key, value) -> { + + long lastTimes = Long.valueOf(value.toString()); + + if (System.currentTimeMillis() - lastTimes < (6 * 60 * 1000)) { + userIds.add(Long.valueOf(key)); + } + }); + + //userIds为空 直接返回 + if (userIds.size() == 0) { + if (ObjectUtil.equal(1, store.getOnlineStatus())) { + return new ArrayList<>(); + } else { + store.setOnlineStatus(null); + } + } else { + store.setUserIds(userIds); + } + + } else { + if (ObjectUtil.equal(1, store.getOnlineStatus())) { + return new ArrayList<>(); + } else { + store.setOnlineStatus(null); + } + } + + + } + + + List stores = storeMapper.selectStoreList(store); + return stores; + } + + @Override + public StoreCount statistics(Store store) { + + //上次调用此接口的时间 + String last_time_map_key = "last_time_" + 2; + + List stores = storeList(store); + List storeIdList = stores.stream().map(x -> x.getId()).collect(Collectors.toList()); + storeIdList.add(-1L); + + Date beginOfMonth = DateUtil.beginOfMonth(new Date()); + + StoreCount storeCount = baseMapper.statistics(storeIdList, beginOfMonth); + + if (ObjectUtil.isNotEmpty(store.getOnlineStatus()) && store.getOnlineStatus() == 2) { + storeCount.setOnlineNumber(0); + return storeCount; + } + + Map cacheMap = redisService.getCacheMap(last_time_map_key); + + if (ObjectUtil.isEmpty(cacheMap)) { + storeCount.setOnlineNumber(0); + return storeCount; + } + + List userIds = new ArrayList<>(); + + cacheMap.forEach((key, value) -> { + + long lastTimes = Long.valueOf(value.toString()); + + if (System.currentTimeMillis() - lastTimes < (6 * 60 * 1000)) { + userIds.add(Long.valueOf(key)); + } + }); + + Integer onlineNumber = 0; + if (userIds.size() > 0) { + store.setOnlineStatus(1); + store.setUserIds(userIds); + onlineNumber = storeMapper.onlineNumber(store); + } + storeCount.setOnlineNumber(onlineNumber); + + return storeCount; + } + + /** + * 新增商户 + * + * @param store 商户 + * @return 结果 + */ + @Override + public int insertStore(Store store) { + store.setCreateTime(DateUtils.getNowDate()); + return storeMapper.insertStore(store); + } + + /** + * 修改商户 + * + * @param store 商户 + * @return 结果 + */ + @Override + public int updateStore(Store store) { + store.setUpdateTime(DateUtils.getNowDate()); + return storeMapper.updateStore(store); + } + + /** + * 批量删除商户 + * + * @param ids 需要删除的商户主键 + * @return 结果 + */ + @Override + public int deleteStoreByIds(Long[] ids, Integer delFlag) { + this.lambdaUpdate().set(Store::getDelFlag, delFlag).in(Store::getId, ids).update(); + return ids.length; + } + + /** + * 删除商户信息 + * + * @param id 商户主键 + * @return 结果 + */ + @Override + public int deleteStoreById(Long id) { + return storeMapper.deleteStoreById(id); + } + + @Autowired + private IllegalDeductionRecordService illegalDeductionRecordService; + + @Override + public int updateViolationDeduction(Store store) { + + if (store.getViolationDeduction() == null) { + throw new CustomException("金额不能为空"); + } + + if (store.getViolationDeduction().compareTo(BigDecimal.ZERO) == -1) { + throw new CustomException("扣款金额不能小于0"); + } + if (store.getOrderId() == null) { + throw new CustomException("请关联订单"); + } + //差值 + BigDecimal price = store.getViolationDeduction(); + + illegalDeductionRecordService.updateViolationDeduction(store.getId(), null, price, price.compareTo(BigDecimal.ZERO) == 1 ? 1 : 2, store.getOrderId(), store.getDeductionType(), store.getRemark()); + + OrderResult orderResult = baseMapper.getOrderInfo(store.getOrderId()); + + //添加订单消息 + orderMessageService.addOrderMessage(new UserVo(UserEnums.customer.getCode(), store.getId()), store.getOrderId(), + "", PublicCommon.Order.订单, OrderMessageEnums.ORDER_ILLEGAL_DEDUCTION, orderResult.getOrderNo(), store.getViolationDeduction() + "", store.getRemark()); + + return 1; + } + + @Autowired + private OrderMessageUtilService orderMessageService; + + + @Autowired + private EnterpriseService enterpriseService; + + @Autowired + private ISysUserService userService; + + @Autowired + private ISysRoleService sysRoleService; + + @Autowired + private ISysConfigService configService; + + @Override + public AjaxResult setUpEnterprise(Store store) { + + Enterprise enterprise = store.getEnterprise(); + + Store s = this.getById(store.getId()); + + if (ObjectUtil.isNotEmpty(s.getBindEnterpriseId())) { + return AjaxResult.error("该表现师已绑定企业"); + } + + //生成企业后台账号 + SysUser user = new SysUser(); + user.setUserName(ObjectUtil.isEmpty(store.getAccount()) ? s.getAccount() : store.getAccount()); + user.setPhonenumber(s.getAccount()); + String password = configService.selectConfigByKey("sys.user.initPassword"); + user.setPassword(SecurityUtils.encryptPassword(ObjectUtil.isNotEmpty(store.getLoginPwd()) ? store.getLoginPwd() : password)); + user.setNickName(enterprise.getName()); + user.setUserType("01"); + if (UserConstants.NOT_UNIQUE.equals(userService.checkUserNameUnique(user.getUserName()))) { + return AjaxResult.error("新增用户'" + user.getUserName() + "'失败,登录账号已存在"); + } else if (StringUtils.isNotEmpty(user.getPhonenumber()) + && UserConstants.NOT_UNIQUE.equals(userService.checkPhoneUnique(user))) { + return AjaxResult.error("新增用户'" + user.getUserName() + "'失败,手机号码已存在"); + } + SysRole sysRole = new SysRole(); + sysRole.setRoleKey("enterprise"); + List sysRoles = sysRoleService.selectRoleList(sysRole); + + //角色 + user.setRoleIds(new Long[]{sysRoles.get(0).getRoleId()}); + + userService.insertUser(user); + + //表现师关联企业 + enterprise.setSysUserId(user.getUserId()); + enterpriseService.save(enterprise); + + this.update().set("bind_enterprise_id", enterprise.getId()).eq("id", store.getId()).update(); + + return AjaxResult.success(); + } + + @Autowired + private WalletRecordService walletRecordService; + + @Autowired + private PlatformRecordService platformRecordService; + + @Override + public AjaxResult updateBalance(Store store) { + + BigDecimal price = store.getBalance(); + + //修改余额 + if (price.compareTo(BigDecimal.ZERO) > 0) { + walletRecordService.updateBalance(new UserVo(UserEnums.store.getCode(), store.getId()), WalletDetailEnums.PLAT_ADD, store.getRemark(), store.getId(), price, PublicCommon.Wallet.可提现); + + //平台流水 + platformRecordService.addPlatformRecord(new UserVo(UserEnums.store.getCode(), store.getId()), store.getId(), price.negate(), PlatformRecordEnums.PLAT_ADD); + + } else if (price.compareTo(BigDecimal.ZERO) < 0) { + walletRecordService.updateBalance(new UserVo(UserEnums.store.getCode(), store.getId()), WalletDetailEnums.PLAT_SUB, store.getRemark(), store.getId(), price, PublicCommon.Wallet.可提现); + + //平台流水 + platformRecordService.addPlatformRecord(new UserVo(UserEnums.store.getCode(), store.getId()), store.getId(), price, PlatformRecordEnums.PLAT_ADD); + + } + return AjaxResult.success(); + } + + @Autowired + private LevelService levelService; + + @Override + public Store assembleStore(RegisterUserReq req, String md5Pwd) { + Store store = new Store(); + store.setId(SnowIdUtils.uniqueLong()); + + //账号 + store.setAccount(ObjectUtil.isNotEmpty(req.getAccount()) ? req.getAccount() : req.getMobile()); + + //手机号 + store.setMobile(ObjectUtil.isNotEmpty(req.getMobile()) ? req.getMobile() : req.getAccount()); + + //默认头像 + SysDictData dict = businessUtil.getDict(DictConstant.默认头像); + store.setAvatar(dict.getImages()); + + Store maxStore = this.getOne(new QueryWrapper().lambda().orderByDesc(Store::getNickname).last("limit 1")); + + Integer num = maxStore == null ? 0 : Integer.valueOf(maxStore.getNickname().replace("BXS", "")); + + store.setNickname(getNickname(num)); + + //默认昵称 + SysDictData bxs_dict = businessUtil.getDict(DictConstant.BXS_name_pre); + String name = bxs_dict.getDictValue(); + if (ObjectUtil.isNotEmpty(name)) { + String str = store.getMobile(); + int length = str.length(); + String lastFour = (length > 4) ? str.substring(length - 4) : str; + name = name.concat(lastFour); + } + store.setName(name); + + store.setLoginPwd(md5Pwd); + store.setCreateTime(new Date()); + store.setUpdateTime(new Date()); + + return store; + } + + private String getNickname(Integer num) { + String template = "BXS%06d"; + num++; + String id = String.format(template, num); + return id; + } + + public static void main(String[] args) { + String template = "BXS%06d"; + + String id = String.format(template, 2); + System.out.println(id); + } + + @Override + public void saveIdNo(Long id) { + baseMapper.saveIdNo(id); + } + + + @Override + public ResponseData editInfo(UserEditReqVo vo, UserVo userVo) { + LambdaUpdateChainWrapper lambdaUpdate = this.lambdaUpdate(); + lambdaUpdate.set(Store::getId, userVo.getUserId()); + //头像 + if (ObjectUtil.isNotEmpty(vo.getAvatar())) { + lambdaUpdate.set(Store::getAvatar, vo.getAvatar()); + } + //所属区域 + if (ObjectUtil.isNotEmpty(vo.getArea())) { + lambdaUpdate.set(Store::getArea, vo.getArea()); + } + //性别 + if (ObjectUtil.isNotEmpty(vo.getSex())) { + + } + //入行时间 + if (ObjectUtil.isNotEmpty(vo.getEnterDate())) { + lambdaUpdate.set(Store::getEnterDate, DateUtil.parse(vo.getEnterDate(), "yyyy")); + } + //背景图 + if (ObjectUtil.isNotEmpty(vo.getBackgroundImage())) { + lambdaUpdate.set(Store::getBackgroundImage, vo.getBackgroundImage()); + } + + //推送是否关闭;1不关闭2 关闭 + if (ObjectUtil.isNotEmpty(vo.getCloseMessage())) { + lambdaUpdate.set(Store::getCloseMessage, vo.getCloseMessage()); + } + + //曾经任职公司 + if (ObjectUtil.isNotEmpty(vo.getOnceWorkCompanys())) { + lambdaUpdate.set(Store::getOnceWorkCompanys, vo.getOnceWorkCompanys()); + } + + //昵称 + if (ObjectUtil.isNotEmpty(vo.getName())) { + + String key = "store_name_" + DateUtil.format(new Date(), "yyyy-MM_") + userVo.getUserId(); + + //获取数据库中名称 + Store store = this.getById(userVo.getUserId()); + //名称每个月只能修改一次 + if (redisTemplate.hasKey(key) && ObjectUtil.notEqual(store.getName(), vo.getName())) { + return ResponseData.error("昵称每个月只能修改一次"); + } + + if (StringUtils.isNotBlank(vo.getName()) && vo.getName().length() != vo.getName().replace(" ", "").length()) { + return ResponseData.error("昵称不允许包含空格"); + } + + //不同才修改 + if (ObjectUtil.notEqual(store.getName(), vo.getName())) { + lambdaUpdate.set(Store::getName, vo.getName()); + + redisTemplate.opsForValue().set(key, userVo.getUserId(), 35, TimeUnit.DAYS); + } + } + + //擅长领域 + if (ObjectUtil.isNotEmpty(vo.getSpecialityArea())) { + lambdaUpdate.set(Store::getSpecialityArea, vo.getSpecialityArea()); + } + + //条件 + lambdaUpdate.eq(Store::getId, userVo.getUserId()).update(); + + if (ObjectUtil.isNotEmpty(vo.getName())) { + Integer count = baseMapper.selectCount(new QueryWrapper().lambda().eq(Store::getDelFlag, PublicCommon.启用) + .eq(Store::getName, vo.getName())); + Integer count1 = customerMapper.selectCount(new QueryWrapper().lambda().eq(Customer::getDelFlag, PublicCommon.启用) + .eq(Customer::getName, vo.getName())); + if (count + count1 > 1) { + return ResponseData.error("昵称重复"); + } + + //判断敏感词 + businessUtil.checkSensitiveWord(vo.getName()); + } + return ResponseData.success(); + } + + @Autowired + private CustomerMapper customerMapper; + + @Autowired + private RedisTemplate redisTemplate; + + @Override + public ResponseData info(UserVo userVo) { + + final Store store = this.selectStoreById(userVo.getUserId()); + +// //上次调用此接口的时间 +// String last_time_map_key = "last_time_" + userVo.getUserType(); +// +// //在线状态;1:在线,2离线 +// Integer onlineStatus = 2; +// +// if (redisTemplate.opsForHash().hasKey(last_time_map_key,store.getId().toString())) { +// long lastTimes = Long.valueOf(redisTemplate.opsForHash().get(last_time_map_key, store.getId().toString()).toString()); +// +// //判断当前时间和上次时间是否超过6分钟(考虑到网络延时和程序卡顿,多1分钟) +// if (System.currentTimeMillis() - lastTimes < (6 * 60 * 1000)) { +// onlineStatus = 1; +// } +// } +// +// store.setOnlineStatus(onlineStatus); + + return ResponseData.success(store); + } + + @Override + public int getAuthStore(List userIds, Integer ifHighend) { + if (ifHighend == null) { + return storeMapper.getAuthStore(userIds); + } + if (ifHighend == 1) { + return storeMapper.getCommonAuthStore(userIds); + } + if (ifHighend == 2) { + return storeMapper.getHighAuthStore(userIds); + } + if (ifHighend == 3) { + return storeMapper.getKujialeAuthStore(userIds); + } + return 0; + } + + @Override + public AjaxResult setUpPlatform(Store store) { + this.lambdaUpdate().set(Store::getIsPlatform, store.getIsPlatform()) + .eq(Store::getId, store.getId()).update(); + return AjaxResult.success(); + } + + @Override + public AjaxResult setDDAuth(Store store) { + this.lambdaUpdate().set(Store::getIsDdAuth, store.getIsDdAuth()) + .eq(Store::getId, store.getId()).update(); + return AjaxResult.success(); + } + + @Override + public AjaxResult setCommissionRatio(Store store) { + + if (store.getCommissionRatio() != null) { + if (store.getCommissionRatio().compareTo(BigDecimal.ZERO) == -1) { + throw new ServiceException("提成比例不可小于0"); + } + if (store.getCommissionRatio().compareTo(BigDecimal.ONE) == 1) { + throw new ServiceException("提成比例不可大于1"); + } + } + + this.lambdaUpdate().set(Store::getCommissionRatio, store.getCommissionRatio()) + .eq(Store::getId, store.getId()).update(); + return AjaxResult.success(); + } + + @Override + public void canCancellation(Long userId) { + Integer orderCount = baseMapper.canCancellation(userId); + if (orderCount > 0) { + throw new ServiceException("您有未完成的订单,不可注销"); + } + } +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/userappmessage/controller/UserAppMessageController.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/userappmessage/controller/UserAppMessageController.java new file mode 100644 index 0000000..d4ac670 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/userappmessage/controller/UserAppMessageController.java @@ -0,0 +1,97 @@ +package com.ruoyi.frequency.userappmessage.controller; + +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.page.TableDataInfo; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.common.utils.poi.ExcelUtil; +import com.ruoyi.frequency.userappmessage.entity.UserAppMessage; +import com.ruoyi.frequency.userappmessage.service.UserAppMessageService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +/** + * 用户已读消息Controller + * + * @author liwenlong + * @date 2023-07-20 + */ +@RestController +@RequestMapping("/frequency/userappmessage") +public class UserAppMessageController extends BaseController +{ + @Autowired + private UserAppMessageService userAppMessageService; + + /** + * 查询用户已读消息列表 + */ + @PreAuthorize("@ss.hasPermi('frequency:userappmessage:list')") + @GetMapping("/list") + public TableDataInfo list(UserAppMessage userAppMessage) + { + startPage(); + List list = userAppMessageService.selectUserAppMessageList(userAppMessage); + return getDataTable(list); + } + + /** + * 导出用户已读消息列表 + */ + @PreAuthorize("@ss.hasPermi('frequency:userappmessage:export')") + @Log(title = "用户已读消息", businessType = BusinessType.EXPORT) + @GetMapping("/export") + public AjaxResult export(UserAppMessage userAppMessage) + { + List list = userAppMessageService.selectUserAppMessageList(userAppMessage); + ExcelUtil util = new ExcelUtil(UserAppMessage.class); + return util.exportExcel(list, "用户已读消息数据"); + } + + /** + * 获取用户已读消息详细信息 + */ + @PreAuthorize("@ss.hasPermi('frequency:userappmessage:query')") + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") Long id) + { + return AjaxResult.success(userAppMessageService.selectUserAppMessageById(id)); + } + + /** + * 新增用户已读消息 + */ + @PreAuthorize("@ss.hasPermi('frequency:userappmessage:add')") + @Log(title = "用户已读消息", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody UserAppMessage userAppMessage) + { + return toAjax(userAppMessageService.insertUserAppMessage(userAppMessage)); + } + + /** + * 修改用户已读消息 + */ + @PreAuthorize("@ss.hasPermi('frequency:userappmessage:edit')") + @Log(title = "用户已读消息", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody UserAppMessage userAppMessage) + { + return toAjax(userAppMessageService.updateUserAppMessage(userAppMessage)); + } + + /** + * 删除用户已读消息 + */ + @PreAuthorize("@ss.hasPermi('frequency:userappmessage:remove')") + @Log(title = "用户已读消息", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}") + public AjaxResult remove(@PathVariable Long[] ids) + { + return toAjax(userAppMessageService.deleteUserAppMessageByIds(ids)); + } +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/userappmessage/entity/UserAppMessage.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/userappmessage/entity/UserAppMessage.java new file mode 100644 index 0000000..ed3cc55 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/userappmessage/entity/UserAppMessage.java @@ -0,0 +1,51 @@ +package com.ruoyi.frequency.userappmessage.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import lombok.Data; +import lombok.experimental.Accessors; + +/** + * 用户已读消息对象 t_user_app_message + * + * @author liwenlong + * @date 2023-07-20 + */ +@Data +@Accessors(chain = true) +@TableName("t_user_app_message") +public class UserAppMessage extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** 主键id */ + private Long id; + + + + /** 删除标志 1正常 删除 3 禁用 */ + private Integer delFlag; + + /** 用户id(表现师id) */ + @Excel(name = "用户id(表现师id)") + private Long userId; + + /** 用户类型 1 用户 2 表现师 */ + @Excel(name = "用户类型 1 用户 2 表现师") + private Integer userType; + + /** 消息id */ + @Excel(name = "消息id") + private Long messageId; + + /** 是否清空 1 不清空 2 清空 */ + @Excel(name = "是否清空 1 不清空 2 清空") + private Integer isShow; + + /** 是否已读 1 没有 2 已读 */ + @Excel(name = "是否已读 1 没有 2 已读") + private Integer isRead; + + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/userappmessage/mapper/UserAppMessageMapper.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/userappmessage/mapper/UserAppMessageMapper.java new file mode 100644 index 0000000..e97a3bd --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/userappmessage/mapper/UserAppMessageMapper.java @@ -0,0 +1,63 @@ +package com.ruoyi.frequency.userappmessage.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.ruoyi.frequency.userappmessage.entity.UserAppMessage; + +import java.util.List; + +/** + * 用户已读消息Mapper接口 + * + * @author liwenlong + * @date 2023-07-20 + */ +public interface UserAppMessageMapper extends BaseMapper +{ + /** + * 查询用户已读消息 + * + * @param id 用户已读消息主键 + * @return 用户已读消息 + */ + UserAppMessage selectUserAppMessageById(Long id); + + /** + * 查询用户已读消息列表 + * + * @param userAppMessage 用户已读消息 + * @return 用户已读消息集合 + */ + List selectUserAppMessageList(UserAppMessage userAppMessage); + + /** + * 新增用户已读消息 + * + * @param userAppMessage 用户已读消息 + * @return 结果 + */ + int insertUserAppMessage(UserAppMessage userAppMessage); + + /** + * 修改用户已读消息 + * + * @param userAppMessage 用户已读消息 + * @return 结果 + */ + int updateUserAppMessage(UserAppMessage userAppMessage); + + /** + * 删除用户已读消息 + * + * @param id 用户已读消息主键 + * @return 结果 + */ + int deleteUserAppMessageById(Long id); + + /** + * 批量删除用户已读消息 + * + * @param ids 需要删除的数据主键集合 + * @return 结果 + */ + int deleteUserAppMessageByIds(Long[] ids); +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/userappmessage/mapper/mapping/UserAppMessageMapper.xml b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/userappmessage/mapper/mapping/UserAppMessageMapper.xml new file mode 100644 index 0000000..bed071c --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/userappmessage/mapper/mapping/UserAppMessageMapper.xml @@ -0,0 +1,100 @@ + + + + + + + + + + + + + + + + + + + + select id, create_by, create_time, update_by, update_time, del_flag, user_id, user_type, message_id, is_show, is_read from t_user_app_message + + + + + + + + insert into t_user_app_message + + id, + create_by, + create_time, + update_by, + update_time, + del_flag, + user_id, + user_type, + message_id, + is_show, + is_read, + + + #{id}, + #{createBy}, + #{createTime}, + #{updateBy}, + #{updateTime}, + #{delFlag}, + #{userId}, + #{userType}, + #{messageId}, + #{isShow}, + #{isRead}, + + + + + update t_user_app_message + + create_by = #{createBy}, + create_time = #{createTime}, + update_by = #{updateBy}, + update_time = #{updateTime}, + del_flag = #{delFlag}, + user_id = #{userId}, + user_type = #{userType}, + message_id = #{messageId}, + is_show = #{isShow}, + is_read = #{isRead}, + + where id = #{id} + + + + delete from t_user_app_message where id = #{id} + + + + delete from t_user_app_message where id in + + #{id} + + + \ No newline at end of file diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/userappmessage/model/param/UserAppMessageParam.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/userappmessage/model/param/UserAppMessageParam.java new file mode 100644 index 0000000..8952fa6 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/userappmessage/model/param/UserAppMessageParam.java @@ -0,0 +1,58 @@ +package com.ruoyi.frequency.userappmessage.model.param; + +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import lombok.Data; +import lombok.experimental.Accessors; + +/** + * 用户已读消息对象 t_user_app_message + * + * @author liwenlong + * @date 2023-07-20 + */ +@Data +@Accessors(chain = true) +public class UserAppMessageParam extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** 主键id */ + private Long id; + + + + /** 删除标志 1正常 删除 3 禁用 */ + private Integer delFlag; + + /** 用户id(表现师id) */ + @Excel(name = "用户id(表现师id)") + private Long userId; + + /** 用户类型 1 用户 2 表现师 */ + @Excel(name = "用户类型 1 用户 2 表现师") + private Integer userType; + + /** 消息id */ + @Excel(name = "消息id") + private Long messageId; + + /** 是否清空 1 不清空 2 清空 */ + @Excel(name = "是否清空 1 不清空 2 清空") + private Integer isShow; + + /** 是否已读 1 没有 2 已读 */ + @Excel(name = "是否已读 1 没有 2 已读") + private Integer isRead; + + + + + + + + + + + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/userappmessage/model/result/UserAppMessageResult.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/userappmessage/model/result/UserAppMessageResult.java new file mode 100644 index 0000000..e1302bd --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/userappmessage/model/result/UserAppMessageResult.java @@ -0,0 +1,49 @@ +package com.ruoyi.frequency.userappmessage.model.result; + +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import lombok.Data; +import lombok.experimental.Accessors; + +/** + * 用户已读消息对象 t_user_app_message + * + * @author liwenlong + * @date 2023-07-20 + */ +@Data +@Accessors(chain = true) +public class UserAppMessageResult extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** 主键id */ + private Long id; + + + + /** 删除标志 1正常 删除 3 禁用 */ + private Integer delFlag; + + /** 用户id(表现师id) */ + @Excel(name = "用户id(表现师id)") + private Long userId; + + /** 用户类型 1 用户 2 表现师 */ + @Excel(name = "用户类型 1 用户 2 表现师") + private Integer userType; + + /** 消息id */ + @Excel(name = "消息id") + private Long messageId; + + /** 是否清空 1 不清空 2 清空 */ + @Excel(name = "是否清空 1 不清空 2 清空") + private Integer isShow; + + /** 是否已读 1 没有 2 已读 */ + @Excel(name = "是否已读 1 没有 2 已读") + private Integer isRead; + + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/userappmessage/service/UserAppMessageService.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/userappmessage/service/UserAppMessageService.java new file mode 100644 index 0000000..1fbac96 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/userappmessage/service/UserAppMessageService.java @@ -0,0 +1,64 @@ +package com.ruoyi.frequency.userappmessage.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.ruoyi.frequency.userappmessage.entity.UserAppMessage; + +import java.util.List; + +/** + * 用户已读消息Service接口 + * + * @author liwenlong + * @date 2023-07-20 + */ +public interface UserAppMessageService extends IService +{ + /** + * 查询用户已读消息 + * + * @param id 用户已读消息主键 + * @return 用户已读消息 + */ + UserAppMessage selectUserAppMessageById(Long id); + + /** + * 查询用户已读消息列表 + * + * @param userAppMessage 用户已读消息 + * @return 用户已读消息集合 + */ + List selectUserAppMessageList(UserAppMessage userAppMessage); + + /** + * 新增用户已读消息 + * + * @param userAppMessage 用户已读消息 + * @return 结果 + */ + int insertUserAppMessage(UserAppMessage userAppMessage); + + /** + * 修改用户已读消息 + * + * @param userAppMessage 用户已读消息 + * @return 结果 + */ + int updateUserAppMessage(UserAppMessage userAppMessage); + + /** + * 批量删除用户已读消息 + * + * @param ids 需要删除的用户已读消息主键集合 + * @return 结果 + */ + int deleteUserAppMessageByIds(Long[] ids); + + /** + * 删除用户已读消息信息 + * + * @param id 用户已读消息主键 + * @return 结果 + */ + int deleteUserAppMessageById(Long id); + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/userappmessage/service/impl/UserAppMessageServiceImpl.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/userappmessage/service/impl/UserAppMessageServiceImpl.java new file mode 100644 index 0000000..9bbbc08 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/userappmessage/service/impl/UserAppMessageServiceImpl.java @@ -0,0 +1,99 @@ +package com.ruoyi.frequency.userappmessage.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.ruoyi.common.utils.DateUtils; +import com.ruoyi.frequency.userappmessage.entity.UserAppMessage; +import com.ruoyi.frequency.userappmessage.mapper.UserAppMessageMapper; +import com.ruoyi.frequency.userappmessage.service.UserAppMessageService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * 用户已读消息Service业务层处理 + * + * @author liwenlong + * @date 2023-07-20 + */ +@Service +public class UserAppMessageServiceImpl extends ServiceImpl implements UserAppMessageService +{ + @Autowired + private UserAppMessageMapper userAppMessageMapper; + + /** + * 查询用户已读消息 + * + * @param id 用户已读消息主键 + * @return 用户已读消息 + */ + @Override + public UserAppMessage selectUserAppMessageById(Long id) + { + return userAppMessageMapper.selectUserAppMessageById(id); + } + + /** + * 查询用户已读消息列表 + * + * @param userAppMessage 用户已读消息 + * @return 用户已读消息 + */ + @Override + public List selectUserAppMessageList(UserAppMessage userAppMessage) + { + return userAppMessageMapper.selectUserAppMessageList(userAppMessage); + } + + /** + * 新增用户已读消息 + * + * @param userAppMessage 用户已读消息 + * @return 结果 + */ + @Override + public int insertUserAppMessage(UserAppMessage userAppMessage) + { + userAppMessage.setCreateTime(DateUtils.getNowDate()); + return userAppMessageMapper.insertUserAppMessage(userAppMessage); + } + + /** + * 修改用户已读消息 + * + * @param userAppMessage 用户已读消息 + * @return 结果 + */ + @Override + public int updateUserAppMessage(UserAppMessage userAppMessage) + { + userAppMessage.setUpdateTime(DateUtils.getNowDate()); + return userAppMessageMapper.updateUserAppMessage(userAppMessage); + } + + /** + * 批量删除用户已读消息 + * + * @param ids 需要删除的用户已读消息主键 + * @return 结果 + */ + @Override + public int deleteUserAppMessageByIds(Long[] ids) + { + return userAppMessageMapper.deleteUserAppMessageByIds(ids); + } + + /** + * 删除用户已读消息信息 + * + * @param id 用户已读消息主键 + * @return 结果 + */ + @Override + public int deleteUserAppMessageById(Long id) + { + return userAppMessageMapper.deleteUserAppMessageById(id); + } + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/userwithdrawalway/controller/UserWithdrawalWayController.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/userwithdrawalway/controller/UserWithdrawalWayController.java new file mode 100644 index 0000000..fd3b06c --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/userwithdrawalway/controller/UserWithdrawalWayController.java @@ -0,0 +1,97 @@ +package com.ruoyi.frequency.userwithdrawalway.controller; + +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.page.TableDataInfo; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.common.utils.poi.ExcelUtil; +import com.ruoyi.frequency.userwithdrawalway.entity.UserWithdrawalWay; +import com.ruoyi.frequency.userwithdrawalway.service.UserWithdrawalWayService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +/** + * 用户提现方式Controller + * + * @author liwenlong + * @date 2023-07-20 + */ +@RestController +@RequestMapping("/frequency/userwithdrawalway") +public class UserWithdrawalWayController extends BaseController +{ + @Autowired + private UserWithdrawalWayService userWithdrawalWayService; + + /** + * 查询用户提现方式列表 + */ + @PreAuthorize("@ss.hasPermi('frequency:userwithdrawalway:list')") + @GetMapping("/list") + public TableDataInfo list(UserWithdrawalWay userWithdrawalWay) + { + startPage(); + List list = userWithdrawalWayService.selectUserWithdrawalWayList(userWithdrawalWay); + return getDataTable(list); + } + + /** + * 导出用户提现方式列表 + */ + @PreAuthorize("@ss.hasPermi('frequency:userwithdrawalway:export')") + @Log(title = "用户提现方式", businessType = BusinessType.EXPORT) + @GetMapping("/export") + public AjaxResult export(UserWithdrawalWay userWithdrawalWay) + { + List list = userWithdrawalWayService.selectUserWithdrawalWayList(userWithdrawalWay); + ExcelUtil util = new ExcelUtil(UserWithdrawalWay.class); + return util.exportExcel(list, "用户提现方式数据"); + } + + /** + * 获取用户提现方式详细信息 + */ + @PreAuthorize("@ss.hasPermi('frequency:userwithdrawalway:query')") + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") Long id) + { + return AjaxResult.success(userWithdrawalWayService.selectUserWithdrawalWayById(id)); + } + + /** + * 新增用户提现方式 + */ + @PreAuthorize("@ss.hasPermi('frequency:userwithdrawalway:add')") + @Log(title = "用户提现方式", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody UserWithdrawalWay userWithdrawalWay) + { + return toAjax(userWithdrawalWayService.insertUserWithdrawalWay(userWithdrawalWay)); + } + + /** + * 修改用户提现方式 + */ + @PreAuthorize("@ss.hasPermi('frequency:userwithdrawalway:edit')") + @Log(title = "用户提现方式", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody UserWithdrawalWay userWithdrawalWay) + { + return toAjax(userWithdrawalWayService.updateUserWithdrawalWay(userWithdrawalWay)); + } + + /** + * 删除用户提现方式 + */ + @PreAuthorize("@ss.hasPermi('frequency:userwithdrawalway:remove')") + @Log(title = "用户提现方式", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}") + public AjaxResult remove(@PathVariable Long[] ids) + { + return toAjax(userWithdrawalWayService.deleteUserWithdrawalWayByIds(ids)); + } +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/userwithdrawalway/entity/UserWithdrawalWay.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/userwithdrawalway/entity/UserWithdrawalWay.java new file mode 100644 index 0000000..17c8664 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/userwithdrawalway/entity/UserWithdrawalWay.java @@ -0,0 +1,65 @@ +package com.ruoyi.frequency.userwithdrawalway.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import lombok.Data; +import lombok.experimental.Accessors; + +/** + * 用户提现方式对象 t_user_withdrawal_way + * + * @author liwenlong + * @date 2023-07-20 + */ +@Data +@Accessors(chain = true) +@TableName("t_user_withdrawal_way") +public class UserWithdrawalWay extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** 主键id */ + private Long id; + + /** 删除标志;1正常 删除 3 禁用 */ + private Integer delFlag; + + /** $column.columnComment */ + @Excel(name = "更新人") + private Integer userType; + + /** 用户id */ + @Excel(name = "用户id") + private Long userId; + + /** 平台提现方式id */ + @Excel(name = "平台提现方式id") + private Long pfWayId; + + /** 联系人 */ + @Excel(name = "联系人") + private String linkman; + + /** 联系方式 */ + @Excel(name = "联系方式") + private String contactWay; + + /** 提现账户 */ + @Excel(name = "提现账户") + private String cashAccount; + + /** 是否默认1否;2 是 */ + @Excel(name = "是否默认1否;2 是") + private Integer isDefault; + + /** 开户支行 */ + @Excel(name = "开户支行") + private String accountOpeningSubBranch; + + /** 区号 */ + @Excel(name = "区号") + private String areaCode; + + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/userwithdrawalway/mapper/UserWithdrawalWayMapper.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/userwithdrawalway/mapper/UserWithdrawalWayMapper.java new file mode 100644 index 0000000..67b43ad --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/userwithdrawalway/mapper/UserWithdrawalWayMapper.java @@ -0,0 +1,71 @@ +package com.ruoyi.frequency.userwithdrawalway.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.ruoyi.controller.resp.UserWithdrawalWayResp; +import com.ruoyi.frequency.userwithdrawalway.entity.UserWithdrawalWay; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * 用户提现方式Mapper接口 + * + * @author liwenlong + * @date 2023-07-20 + */ +public interface UserWithdrawalWayMapper extends BaseMapper +{ + /** + * 查询用户提现方式 + * + * @param id 用户提现方式主键 + * @return 用户提现方式 + */ + UserWithdrawalWay selectUserWithdrawalWayById(Long id); + + /** + * 查询用户提现方式列表 + * + * @param userWithdrawalWay 用户提现方式 + * @return 用户提现方式集合 + */ + List selectUserWithdrawalWayList(UserWithdrawalWay userWithdrawalWay); + + /** + * 新增用户提现方式 + * + * @param userWithdrawalWay 用户提现方式 + * @return 结果 + */ + int insertUserWithdrawalWay(UserWithdrawalWay userWithdrawalWay); + + /** + * 修改用户提现方式 + * + * @param userWithdrawalWay 用户提现方式 + * @return 结果 + */ + int updateUserWithdrawalWay(UserWithdrawalWay userWithdrawalWay); + + /** + * 删除用户提现方式 + * + * @param id 用户提现方式主键 + * @return 结果 + */ + int deleteUserWithdrawalWayById(Long id); + + /** + * 批量删除用户提现方式 + * + * @param ids 需要删除的数据主键集合 + * @return 结果 + */ + int deleteUserWithdrawalWayByIds(Long[] ids); + + List selList(@Param("userId") Long userId, @Param("userType") Integer userType); + + UserWithdrawalWayResp getDetail(@Param("id") Long id); + + UserWithdrawalWayResp defaultWay(@Param("userId") Long userId, @Param("userType") Integer userType); +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/userwithdrawalway/mapper/mapping/UserWithdrawalWayMapper.xml b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/userwithdrawalway/mapper/mapping/UserWithdrawalWayMapper.xml new file mode 100644 index 0000000..522a04f --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/userwithdrawalway/mapper/mapping/UserWithdrawalWayMapper.xml @@ -0,0 +1,191 @@ + + + + + + + + + + + + + + + + + + + + + + + + select id, create_by, create_time, update_by, update_time, del_flag, user_type, user_id, pf_way_id, linkman, contact_way, cash_account, is_default, account_opening_sub_branch, area_code from t_user_withdrawal_way + + + + + + + + insert into t_user_withdrawal_way + + id, + create_by, + create_time, + update_by, + update_time, + del_flag, + user_type, + user_id, + pf_way_id, + linkman, + contact_way, + cash_account, + is_default, + account_opening_sub_branch, + area_code, + + + #{id}, + #{createBy}, + #{createTime}, + #{updateBy}, + #{updateTime}, + #{delFlag}, + #{userType}, + #{userId}, + #{pfWayId}, + #{linkman}, + #{contactWay}, + #{cashAccount}, + #{isDefault}, + #{accountOpeningSubBranch}, + #{areaCode}, + + + + + update t_user_withdrawal_way + + create_by = #{createBy}, + create_time = #{createTime}, + update_by = #{updateBy}, + update_time = #{updateTime}, + del_flag = #{delFlag}, + user_type = #{userType}, + user_id = #{userId}, + pf_way_id = #{pfWayId}, + linkman = #{linkman}, + contact_way = #{contactWay}, + cash_account = #{cashAccount}, + is_default = #{isDefault}, + account_opening_sub_branch = #{accountOpeningSubBranch}, + area_code = #{areaCode}, + + where id = #{id} + + + + delete from t_user_withdrawal_way where id = #{id} + + + + delete from t_user_withdrawal_way where id in + + #{id} + + + + + + + + + + + \ No newline at end of file diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/userwithdrawalway/model/param/UserWithdrawalWayParam.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/userwithdrawalway/model/param/UserWithdrawalWayParam.java new file mode 100644 index 0000000..ff4e8db --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/userwithdrawalway/model/param/UserWithdrawalWayParam.java @@ -0,0 +1,78 @@ +package com.ruoyi.frequency.userwithdrawalway.model.param; + +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import lombok.Data; +import lombok.experimental.Accessors; + +/** + * 用户提现方式对象 t_user_withdrawal_way + * + * @author liwenlong + * @date 2023-07-20 + */ +@Data +@Accessors(chain = true) +public class UserWithdrawalWayParam extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** 主键id */ + private Long id; + + + + /** 删除标志;1正常 删除 3 禁用 */ + private Integer delFlag; + + /** $column.columnComment */ + @Excel(name = "更新人") + private Integer userType; + + /** 用户id */ + @Excel(name = "用户id") + private Long userId; + + /** 平台提现方式id */ + @Excel(name = "平台提现方式id") + private Long pfWayId; + + /** 联系人 */ + @Excel(name = "联系人") + private String linkman; + + /** 联系方式 */ + @Excel(name = "联系方式") + private String contactWay; + + /** 提现账户 */ + @Excel(name = "提现账户") + private String cashAccount; + + /** 是否默认1否;2 是 */ + @Excel(name = "是否默认1否;2 是") + private Integer isDefault; + + /** 开户支行 */ + @Excel(name = "开户支行") + private String accountOpeningSubBranch; + + /** 区号 */ + @Excel(name = "区号") + private String areaCode; + + + + + + + + + + + + + + + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/userwithdrawalway/model/result/UserWithdrawalWayResult.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/userwithdrawalway/model/result/UserWithdrawalWayResult.java new file mode 100644 index 0000000..d53ff85 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/userwithdrawalway/model/result/UserWithdrawalWayResult.java @@ -0,0 +1,65 @@ +package com.ruoyi.frequency.userwithdrawalway.model.result; + +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import lombok.Data; +import lombok.experimental.Accessors; + +/** + * 用户提现方式对象 t_user_withdrawal_way + * + * @author liwenlong + * @date 2023-07-20 + */ +@Data +@Accessors(chain = true) +public class UserWithdrawalWayResult extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** 主键id */ + private Long id; + + + + /** 删除标志;1正常 删除 3 禁用 */ + private Integer delFlag; + + /** $column.columnComment */ + @Excel(name = "更新人") + private Integer userType; + + /** 用户id */ + @Excel(name = "用户id") + private Long userId; + + /** 平台提现方式id */ + @Excel(name = "平台提现方式id") + private Long pfWayId; + + /** 联系人 */ + @Excel(name = "联系人") + private String linkman; + + /** 联系方式 */ + @Excel(name = "联系方式") + private String contactWay; + + /** 提现账户 */ + @Excel(name = "提现账户") + private String cashAccount; + + /** 是否默认1否;2 是 */ + @Excel(name = "是否默认1否;2 是") + private Integer isDefault; + + /** 开户支行 */ + @Excel(name = "开户支行") + private String accountOpeningSubBranch; + + /** 区号 */ + @Excel(name = "区号") + private String areaCode; + + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/userwithdrawalway/service/UserWithdrawalWayService.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/userwithdrawalway/service/UserWithdrawalWayService.java new file mode 100644 index 0000000..a86a1b4 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/userwithdrawalway/service/UserWithdrawalWayService.java @@ -0,0 +1,79 @@ +package com.ruoyi.frequency.userwithdrawalway.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.ruoyi.controller.req.AddUserWithdrawalWayReq; +import com.ruoyi.controller.req.EditUserWithdrawalWayReq; +import com.ruoyi.frequency.userwithdrawalway.entity.UserWithdrawalWay; +import com.ruoyi.response.ResponseData; +import com.ruoyi.vo.UserVo; + +import java.util.List; + +/** + * 用户提现方式Service接口 + * + * @author liwenlong + * @date 2023-07-20 + */ +public interface UserWithdrawalWayService extends IService +{ + /** + * 查询用户提现方式 + * + * @param id 用户提现方式主键 + * @return 用户提现方式 + */ + UserWithdrawalWay selectUserWithdrawalWayById(Long id); + + /** + * 查询用户提现方式列表 + * + * @param userWithdrawalWay 用户提现方式 + * @return 用户提现方式集合 + */ + List selectUserWithdrawalWayList(UserWithdrawalWay userWithdrawalWay); + + /** + * 新增用户提现方式 + * + * @param userWithdrawalWay 用户提现方式 + * @return 结果 + */ + int insertUserWithdrawalWay(UserWithdrawalWay userWithdrawalWay); + + /** + * 修改用户提现方式 + * + * @param userWithdrawalWay 用户提现方式 + * @return 结果 + */ + int updateUserWithdrawalWay(UserWithdrawalWay userWithdrawalWay); + + /** + * 批量删除用户提现方式 + * + * @param ids 需要删除的用户提现方式主键集合 + * @return 结果 + */ + int deleteUserWithdrawalWayByIds(Long[] ids); + + /** + * 删除用户提现方式信息 + * + * @param id 用户提现方式主键 + * @return 结果 + */ + int deleteUserWithdrawalWayById(Long id); + + ResponseData selList(UserVo userVo); + + ResponseData defaultWay(UserVo userVo); + + ResponseData getDetail(Long id); + + ResponseData addOne(UserVo userVo, AddUserWithdrawalWayReq req); + + ResponseData editOne(EditUserWithdrawalWayReq req, UserVo userVo); + + ResponseData deleteOne(Long id); +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/userwithdrawalway/service/impl/UserWithdrawalWayServiceImpl.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/userwithdrawalway/service/impl/UserWithdrawalWayServiceImpl.java new file mode 100644 index 0000000..bdd0713 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/userwithdrawalway/service/impl/UserWithdrawalWayServiceImpl.java @@ -0,0 +1,191 @@ +package com.ruoyi.frequency.userwithdrawalway.service.impl; + +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.util.ObjectUtil; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.ruoyi.code.PublicCommon; +import com.ruoyi.common.utils.DateUtils; +import com.ruoyi.controller.req.AddUserWithdrawalWayReq; +import com.ruoyi.controller.req.EditUserWithdrawalWayReq; +import com.ruoyi.controller.resp.UserWithdrawalWayResp; +import com.ruoyi.frequency.userwithdrawalway.entity.UserWithdrawalWay; +import com.ruoyi.frequency.userwithdrawalway.mapper.UserWithdrawalWayMapper; +import com.ruoyi.frequency.userwithdrawalway.service.UserWithdrawalWayService; +import com.ruoyi.response.ResponseData; +import com.ruoyi.vo.UserVo; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.Date; +import java.util.List; + +/** + * 用户提现方式Service业务层处理 + * + * @author liwenlong + * @date 2023-07-20 + */ +@Service +public class UserWithdrawalWayServiceImpl extends ServiceImpl implements UserWithdrawalWayService +{ + @Autowired + private UserWithdrawalWayMapper userWithdrawalWayMapper; + + /** + * 查询用户提现方式 + * + * @param id 用户提现方式主键 + * @return 用户提现方式 + */ + @Override + public UserWithdrawalWay selectUserWithdrawalWayById(Long id) + { + return userWithdrawalWayMapper.selectUserWithdrawalWayById(id); + } + + /** + * 查询用户提现方式列表 + * + * @param userWithdrawalWay 用户提现方式 + * @return 用户提现方式 + */ + @Override + public List selectUserWithdrawalWayList(UserWithdrawalWay userWithdrawalWay) + { + return userWithdrawalWayMapper.selectUserWithdrawalWayList(userWithdrawalWay); + } + + /** + * 新增用户提现方式 + * + * @param userWithdrawalWay 用户提现方式 + * @return 结果 + */ + @Override + public int insertUserWithdrawalWay(UserWithdrawalWay userWithdrawalWay) + { + userWithdrawalWay.setCreateTime(DateUtils.getNowDate()); + return userWithdrawalWayMapper.insertUserWithdrawalWay(userWithdrawalWay); + } + + /** + * 修改用户提现方式 + * + * @param userWithdrawalWay 用户提现方式 + * @return 结果 + */ + @Override + public int updateUserWithdrawalWay(UserWithdrawalWay userWithdrawalWay) + { + userWithdrawalWay.setUpdateTime(DateUtils.getNowDate()); + return userWithdrawalWayMapper.updateUserWithdrawalWay(userWithdrawalWay); + } + + /** + * 批量删除用户提现方式 + * + * @param ids 需要删除的用户提现方式主键 + * @return 结果 + */ + @Override + public int deleteUserWithdrawalWayByIds(Long[] ids) + { + return userWithdrawalWayMapper.deleteUserWithdrawalWayByIds(ids); + } + + /** + * 删除用户提现方式信息 + * + * @param id 用户提现方式主键 + * @return 结果 + */ + @Override + public int deleteUserWithdrawalWayById(Long id) + { + return userWithdrawalWayMapper.deleteUserWithdrawalWayById(id); + } + + @Override + public ResponseData selList(UserVo userVo) { + List userWithdrawalWayRespList = baseMapper.selList(userVo.getUserId(), userVo.getUserType()); + return ResponseData.success(userWithdrawalWayRespList); + } + + @Override + public ResponseData defaultWay(UserVo userVo) { + + UserWithdrawalWayResp defaultWay = baseMapper.defaultWay(userVo.getUserId(), userVo.getUserType()); + + return ResponseData.success(defaultWay); + } + + @Override + public ResponseData getDetail(Long id) { + + UserWithdrawalWayResp userWithdrawalWayVO = baseMapper.getDetail(id); + return ResponseData.success(userWithdrawalWayVO); + + } + + @Override + public ResponseData addOne(UserVo userVo, AddUserWithdrawalWayReq req) { + + //默认提现方式改为非默认 + if (ObjectUtil.equal(PublicCommon.默认,req.getIsDefault())) { + this.lambdaUpdate().set(UserWithdrawalWay::getIsDefault,PublicCommon.非默认) + .eq(UserWithdrawalWay::getDelFlag,PublicCommon.启用) + .eq(UserWithdrawalWay::getIsDefault,PublicCommon.默认) + .eq(UserWithdrawalWay::getUserType,userVo.getUserType()) + .eq(UserWithdrawalWay::getUserId,userVo.getUserId()).update(); + } + + UserWithdrawalWay userWithdrawalWay = new UserWithdrawalWay(); + BeanUtil.copyProperties(req,userWithdrawalWay); + + userWithdrawalWay.setUserId(userVo.getUserId()) + .setUserType(userVo.getUserType()); + + userWithdrawalWay.setCreateTime(new Date()) + .setUpdateTime(new Date()); + + baseMapper.insert(userWithdrawalWay); + + return ResponseData.success(); + + + } + + @Override + public ResponseData editOne(EditUserWithdrawalWayReq req, UserVo userVo) { + + UserWithdrawalWay userWithdrawalWay = baseMapper.selectById(req.getId()); + + //默认提现方式改为非默认 + if (ObjectUtil.equal(PublicCommon.默认,req.getIsDefault())) { + this.lambdaUpdate().set(UserWithdrawalWay::getIsDefault,PublicCommon.非默认) + .eq(UserWithdrawalWay::getDelFlag,PublicCommon.启用) + .eq(UserWithdrawalWay::getIsDefault,PublicCommon.默认) + .eq(UserWithdrawalWay::getUserType,userVo.getUserType()) + .eq(UserWithdrawalWay::getUserId,userVo.getUserId()).update(); + } + + userWithdrawalWay.setCashAccount(req.getCashAccount()) + .setContactWay(req.getContactWay()) + .setLinkman(req.getLinkman()) + .setDelFlag(PublicCommon.启用) + .setPfWayId(req.getPfWayId()) + .setIsDefault(req.getIsDefault()) + .setAccountOpeningSubBranch(req.getAccountOpeningSubBranch()); + + baseMapper.updateById(userWithdrawalWay); + + return ResponseData.success(); + + } + + @Override + public ResponseData deleteOne(Long id) { + this.lambdaUpdate().set(UserWithdrawalWay::getDelFlag,PublicCommon.删除).eq(UserWithdrawalWay::getId,id).update(); + return ResponseData.success(); + } +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/userwithdrawalwaywi/controller/UserWithdrawalWayWiController.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/userwithdrawalwaywi/controller/UserWithdrawalWayWiController.java new file mode 100644 index 0000000..5dc3835 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/userwithdrawalwaywi/controller/UserWithdrawalWayWiController.java @@ -0,0 +1,97 @@ +package com.ruoyi.frequency.userwithdrawalwaywi.controller; + +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.page.TableDataInfo; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.common.utils.poi.ExcelUtil; +import com.ruoyi.frequency.userwithdrawalwaywi.entity.UserWithdrawalWayWi; +import com.ruoyi.frequency.userwithdrawalwaywi.service.UserWithdrawalWayWiService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +/** + * 用户提现方式(历史提现记录关联提现方式)Controller + * + * @author liwenlong + * @date 2023-07-20 + */ +@RestController +@RequestMapping("/frequency/userwithdrawalwaywi") +public class UserWithdrawalWayWiController extends BaseController +{ + @Autowired + private UserWithdrawalWayWiService userWithdrawalWayWiService; + + /** + * 查询用户提现方式(历史提现记录关联提现方式)列表 + */ + @PreAuthorize("@ss.hasPermi('frequency:userwithdrawalwaywi:list')") + @GetMapping("/list") + public TableDataInfo list(UserWithdrawalWayWi userWithdrawalWayWi) + { + startPage(); + List list = userWithdrawalWayWiService.selectUserWithdrawalWayWiList(userWithdrawalWayWi); + return getDataTable(list); + } + + /** + * 导出用户提现方式(历史提现记录关联提现方式)列表 + */ + @PreAuthorize("@ss.hasPermi('frequency:userwithdrawalwaywi:export')") + @Log(title = "用户提现方式(历史提现记录关联提现方式)", businessType = BusinessType.EXPORT) + @GetMapping("/export") + public AjaxResult export(UserWithdrawalWayWi userWithdrawalWayWi) + { + List list = userWithdrawalWayWiService.selectUserWithdrawalWayWiList(userWithdrawalWayWi); + ExcelUtil util = new ExcelUtil(UserWithdrawalWayWi.class); + return util.exportExcel(list, "用户提现方式(历史提现记录关联提现方式)数据"); + } + + /** + * 获取用户提现方式(历史提现记录关联提现方式)详细信息 + */ + @PreAuthorize("@ss.hasPermi('frequency:userwithdrawalwaywi:query')") + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") Long id) + { + return AjaxResult.success(userWithdrawalWayWiService.selectUserWithdrawalWayWiById(id)); + } + + /** + * 新增用户提现方式(历史提现记录关联提现方式) + */ + @PreAuthorize("@ss.hasPermi('frequency:userwithdrawalwaywi:add')") + @Log(title = "用户提现方式(历史提现记录关联提现方式)", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody UserWithdrawalWayWi userWithdrawalWayWi) + { + return toAjax(userWithdrawalWayWiService.insertUserWithdrawalWayWi(userWithdrawalWayWi)); + } + + /** + * 修改用户提现方式(历史提现记录关联提现方式) + */ + @PreAuthorize("@ss.hasPermi('frequency:userwithdrawalwaywi:edit')") + @Log(title = "用户提现方式(历史提现记录关联提现方式)", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody UserWithdrawalWayWi userWithdrawalWayWi) + { + return toAjax(userWithdrawalWayWiService.updateUserWithdrawalWayWi(userWithdrawalWayWi)); + } + + /** + * 删除用户提现方式(历史提现记录关联提现方式) + */ + @PreAuthorize("@ss.hasPermi('frequency:userwithdrawalwaywi:remove')") + @Log(title = "用户提现方式(历史提现记录关联提现方式)", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}") + public AjaxResult remove(@PathVariable Long[] ids) + { + return toAjax(userWithdrawalWayWiService.deleteUserWithdrawalWayWiByIds(ids)); + } +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/userwithdrawalwaywi/entity/UserWithdrawalWayWi.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/userwithdrawalwaywi/entity/UserWithdrawalWayWi.java new file mode 100644 index 0000000..d7f5a65 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/userwithdrawalwaywi/entity/UserWithdrawalWayWi.java @@ -0,0 +1,67 @@ +package com.ruoyi.frequency.userwithdrawalwaywi.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import lombok.Data; +import lombok.experimental.Accessors; + +/** + * 用户提现方式(历史提现记录关联提现方式)对象 t_user_withdrawal_way_wi + * + * @author liwenlong + * @date 2023-07-20 + */ +@Data +@Accessors(chain = true) +@TableName("t_user_withdrawal_way_wi") +public class UserWithdrawalWayWi extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** 主键id */ + private Long id; + + + + /** 删除标志 1正常 删除 3 禁用 */ + private Integer delFlag; + + /** $column.columnComment */ + @Excel(name = "更新人") + private Integer userType; + + /** 用户id */ + @Excel(name = "用户id") + private Long userId; + + /** 平台提现方式id */ + @Excel(name = "平台提现方式id") + private Long pfWayId; + + /** 联系人 */ + @Excel(name = "联系人") + private String linkman; + + /** 联系方式 */ + @Excel(name = "联系方式") + private String contactWay; + + /** 提现账户 */ + @Excel(name = "提现账户") + private String cashAccount; + + /** 用户提现方式id */ + @Excel(name = "用户提现方式id") + private Long userWithdrawalWayId; + + /** 支行 */ + @Excel(name = "支行") + private String accountOpeningSubBranch; + + /** 区号 */ + @Excel(name = "区号") + private String areaCode; + + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/userwithdrawalwaywi/mapper/UserWithdrawalWayWiMapper.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/userwithdrawalwaywi/mapper/UserWithdrawalWayWiMapper.java new file mode 100644 index 0000000..37dd1d8 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/userwithdrawalwaywi/mapper/UserWithdrawalWayWiMapper.java @@ -0,0 +1,63 @@ +package com.ruoyi.frequency.userwithdrawalwaywi.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.ruoyi.frequency.userwithdrawalwaywi.entity.UserWithdrawalWayWi; + +import java.util.List; + +/** + * 用户提现方式(历史提现记录关联提现方式)Mapper接口 + * + * @author liwenlong + * @date 2023-07-20 + */ +public interface UserWithdrawalWayWiMapper extends BaseMapper +{ + /** + * 查询用户提现方式(历史提现记录关联提现方式) + * + * @param id 用户提现方式(历史提现记录关联提现方式)主键 + * @return 用户提现方式(历史提现记录关联提现方式) + */ + UserWithdrawalWayWi selectUserWithdrawalWayWiById(Long id); + + /** + * 查询用户提现方式(历史提现记录关联提现方式)列表 + * + * @param userWithdrawalWayWi 用户提现方式(历史提现记录关联提现方式) + * @return 用户提现方式(历史提现记录关联提现方式)集合 + */ + List selectUserWithdrawalWayWiList(UserWithdrawalWayWi userWithdrawalWayWi); + + /** + * 新增用户提现方式(历史提现记录关联提现方式) + * + * @param userWithdrawalWayWi 用户提现方式(历史提现记录关联提现方式) + * @return 结果 + */ + int insertUserWithdrawalWayWi(UserWithdrawalWayWi userWithdrawalWayWi); + + /** + * 修改用户提现方式(历史提现记录关联提现方式) + * + * @param userWithdrawalWayWi 用户提现方式(历史提现记录关联提现方式) + * @return 结果 + */ + int updateUserWithdrawalWayWi(UserWithdrawalWayWi userWithdrawalWayWi); + + /** + * 删除用户提现方式(历史提现记录关联提现方式) + * + * @param id 用户提现方式(历史提现记录关联提现方式)主键 + * @return 结果 + */ + int deleteUserWithdrawalWayWiById(Long id); + + /** + * 批量删除用户提现方式(历史提现记录关联提现方式) + * + * @param ids 需要删除的数据主键集合 + * @return 结果 + */ + int deleteUserWithdrawalWayWiByIds(Long[] ids); +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/userwithdrawalwaywi/mapper/mapping/UserWithdrawalWayWiMapper.xml b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/userwithdrawalwaywi/mapper/mapping/UserWithdrawalWayWiMapper.xml new file mode 100644 index 0000000..e59e798 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/userwithdrawalwaywi/mapper/mapping/UserWithdrawalWayWiMapper.xml @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + select id, create_by, create_time, update_by, update_time, del_flag, user_type, user_id, pf_way_id, linkman, contact_way, cash_account, user_withdrawal_way_id, account_opening_sub_branch, area_code from t_user_withdrawal_way_wi + + + + + + + + insert into t_user_withdrawal_way_wi + + id, + create_by, + create_time, + update_by, + update_time, + del_flag, + user_type, + user_id, + pf_way_id, + linkman, + contact_way, + cash_account, + user_withdrawal_way_id, + account_opening_sub_branch, + area_code, + + + #{id}, + #{createBy}, + #{createTime}, + #{updateBy}, + #{updateTime}, + #{delFlag}, + #{userType}, + #{userId}, + #{pfWayId}, + #{linkman}, + #{contactWay}, + #{cashAccount}, + #{userWithdrawalWayId}, + #{accountOpeningSubBranch}, + #{areaCode}, + + + + + update t_user_withdrawal_way_wi + + create_by = #{createBy}, + create_time = #{createTime}, + update_by = #{updateBy}, + update_time = #{updateTime}, + del_flag = #{delFlag}, + user_type = #{userType}, + user_id = #{userId}, + pf_way_id = #{pfWayId}, + linkman = #{linkman}, + contact_way = #{contactWay}, + cash_account = #{cashAccount}, + user_withdrawal_way_id = #{userWithdrawalWayId}, + account_opening_sub_branch = #{accountOpeningSubBranch}, + area_code = #{areaCode}, + + where id = #{id} + + + + delete from t_user_withdrawal_way_wi where id = #{id} + + + + delete from t_user_withdrawal_way_wi where id in + + #{id} + + + \ No newline at end of file diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/userwithdrawalwaywi/model/param/UserWithdrawalWayWiParam.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/userwithdrawalwaywi/model/param/UserWithdrawalWayWiParam.java new file mode 100644 index 0000000..4c82d3a --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/userwithdrawalwaywi/model/param/UserWithdrawalWayWiParam.java @@ -0,0 +1,78 @@ +package com.ruoyi.frequency.userwithdrawalwaywi.model.param; + +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import lombok.Data; +import lombok.experimental.Accessors; + +/** + * 用户提现方式(历史提现记录关联提现方式)对象 t_user_withdrawal_way_wi + * + * @author liwenlong + * @date 2023-07-20 + */ +@Data +@Accessors(chain = true) +public class UserWithdrawalWayWiParam extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** 主键id */ + private Long id; + + + + /** 删除标志 1正常 删除 3 禁用 */ + private Integer delFlag; + + /** $column.columnComment */ + @Excel(name = "更新人") + private String userType; + + /** 用户id */ + @Excel(name = "用户id") + private Long userId; + + /** 平台提现方式id */ + @Excel(name = "平台提现方式id") + private Long pfWayId; + + /** 联系人 */ + @Excel(name = "联系人") + private String linkman; + + /** 联系方式 */ + @Excel(name = "联系方式") + private String contactWay; + + /** 提现账户 */ + @Excel(name = "提现账户") + private String cashAccount; + + /** 用户提现方式id */ + @Excel(name = "用户提现方式id") + private Long userWithdrawalWayId; + + /** 支行 */ + @Excel(name = "支行") + private String accountOpeningSubBranch; + + /** 区号 */ + @Excel(name = "区号") + private String areaCode; + + + + + + + + + + + + + + + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/userwithdrawalwaywi/model/result/UserWithdrawalWayWiResult.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/userwithdrawalwaywi/model/result/UserWithdrawalWayWiResult.java new file mode 100644 index 0000000..694b65c --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/userwithdrawalwaywi/model/result/UserWithdrawalWayWiResult.java @@ -0,0 +1,65 @@ +package com.ruoyi.frequency.userwithdrawalwaywi.model.result; + +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import lombok.Data; +import lombok.experimental.Accessors; + +/** + * 用户提现方式(历史提现记录关联提现方式)对象 t_user_withdrawal_way_wi + * + * @author liwenlong + * @date 2023-07-20 + */ +@Data +@Accessors(chain = true) +public class UserWithdrawalWayWiResult extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** 主键id */ + private Long id; + + + + /** 删除标志 1正常 删除 3 禁用 */ + private Integer delFlag; + + /** $column.columnComment */ + @Excel(name = "更新人") + private String userType; + + /** 用户id */ + @Excel(name = "用户id") + private Long userId; + + /** 平台提现方式id */ + @Excel(name = "平台提现方式id") + private Long pfWayId; + + /** 联系人 */ + @Excel(name = "联系人") + private String linkman; + + /** 联系方式 */ + @Excel(name = "联系方式") + private String contactWay; + + /** 提现账户 */ + @Excel(name = "提现账户") + private String cashAccount; + + /** 用户提现方式id */ + @Excel(name = "用户提现方式id") + private Long userWithdrawalWayId; + + /** 支行 */ + @Excel(name = "支行") + private String accountOpeningSubBranch; + + /** 区号 */ + @Excel(name = "区号") + private String areaCode; + + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/userwithdrawalwaywi/service/UserWithdrawalWayWiService.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/userwithdrawalwaywi/service/UserWithdrawalWayWiService.java new file mode 100644 index 0000000..14c7ab6 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/userwithdrawalwaywi/service/UserWithdrawalWayWiService.java @@ -0,0 +1,66 @@ +package com.ruoyi.frequency.userwithdrawalwaywi.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.ruoyi.frequency.userwithdrawalway.entity.UserWithdrawalWay; +import com.ruoyi.frequency.userwithdrawalwaywi.entity.UserWithdrawalWayWi; + +import java.util.List; + +/** + * 用户提现方式(历史提现记录关联提现方式)Service接口 + * + * @author liwenlong + * @date 2023-07-20 + */ +public interface UserWithdrawalWayWiService extends IService +{ + /** + * 查询用户提现方式(历史提现记录关联提现方式) + * + * @param id 用户提现方式(历史提现记录关联提现方式)主键 + * @return 用户提现方式(历史提现记录关联提现方式) + */ + UserWithdrawalWayWi selectUserWithdrawalWayWiById(Long id); + + /** + * 查询用户提现方式(历史提现记录关联提现方式)列表 + * + * @param userWithdrawalWayWi 用户提现方式(历史提现记录关联提现方式) + * @return 用户提现方式(历史提现记录关联提现方式)集合 + */ + List selectUserWithdrawalWayWiList(UserWithdrawalWayWi userWithdrawalWayWi); + + /** + * 新增用户提现方式(历史提现记录关联提现方式) + * + * @param userWithdrawalWayWi 用户提现方式(历史提现记录关联提现方式) + * @return 结果 + */ + int insertUserWithdrawalWayWi(UserWithdrawalWayWi userWithdrawalWayWi); + + /** + * 修改用户提现方式(历史提现记录关联提现方式) + * + * @param userWithdrawalWayWi 用户提现方式(历史提现记录关联提现方式) + * @return 结果 + */ + int updateUserWithdrawalWayWi(UserWithdrawalWayWi userWithdrawalWayWi); + + /** + * 批量删除用户提现方式(历史提现记录关联提现方式) + * + * @param ids 需要删除的用户提现方式(历史提现记录关联提现方式)主键集合 + * @return 结果 + */ + int deleteUserWithdrawalWayWiByIds(Long[] ids); + + /** + * 删除用户提现方式(历史提现记录关联提现方式)信息 + * + * @param id 用户提现方式(历史提现记录关联提现方式)主键 + * @return 结果 + */ + int deleteUserWithdrawalWayWiById(Long id); + + UserWithdrawalWayWi addUserWithdrawalWayWi(UserWithdrawalWay userWithdrawalWay); +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/userwithdrawalwaywi/service/impl/UserWithdrawalWayWiServiceImpl.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/userwithdrawalwaywi/service/impl/UserWithdrawalWayWiServiceImpl.java new file mode 100644 index 0000000..6b24485 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/userwithdrawalwaywi/service/impl/UserWithdrawalWayWiServiceImpl.java @@ -0,0 +1,121 @@ +package com.ruoyi.frequency.userwithdrawalwaywi.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.ruoyi.code.PublicCommon; +import com.ruoyi.common.utils.DateUtils; +import com.ruoyi.frequency.userwithdrawalway.entity.UserWithdrawalWay; +import com.ruoyi.frequency.userwithdrawalwaywi.entity.UserWithdrawalWayWi; +import com.ruoyi.frequency.userwithdrawalwaywi.mapper.UserWithdrawalWayWiMapper; +import com.ruoyi.frequency.userwithdrawalwaywi.service.UserWithdrawalWayWiService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * 用户提现方式(历史提现记录关联提现方式)Service业务层处理 + * + * @author liwenlong + * @date 2023-07-20 + */ +@Service +public class UserWithdrawalWayWiServiceImpl extends ServiceImpl implements UserWithdrawalWayWiService +{ + @Autowired + private UserWithdrawalWayWiMapper userWithdrawalWayWiMapper; + + /** + * 查询用户提现方式(历史提现记录关联提现方式) + * + * @param id 用户提现方式(历史提现记录关联提现方式)主键 + * @return 用户提现方式(历史提现记录关联提现方式) + */ + @Override + public UserWithdrawalWayWi selectUserWithdrawalWayWiById(Long id) + { + return userWithdrawalWayWiMapper.selectUserWithdrawalWayWiById(id); + } + + /** + * 查询用户提现方式(历史提现记录关联提现方式)列表 + * + * @param userWithdrawalWayWi 用户提现方式(历史提现记录关联提现方式) + * @return 用户提现方式(历史提现记录关联提现方式) + */ + @Override + public List selectUserWithdrawalWayWiList(UserWithdrawalWayWi userWithdrawalWayWi) + { + return userWithdrawalWayWiMapper.selectUserWithdrawalWayWiList(userWithdrawalWayWi); + } + + /** + * 新增用户提现方式(历史提现记录关联提现方式) + * + * @param userWithdrawalWayWi 用户提现方式(历史提现记录关联提现方式) + * @return 结果 + */ + @Override + public int insertUserWithdrawalWayWi(UserWithdrawalWayWi userWithdrawalWayWi) + { + userWithdrawalWayWi.setCreateTime(DateUtils.getNowDate()); + return userWithdrawalWayWiMapper.insertUserWithdrawalWayWi(userWithdrawalWayWi); + } + + /** + * 修改用户提现方式(历史提现记录关联提现方式) + * + * @param userWithdrawalWayWi 用户提现方式(历史提现记录关联提现方式) + * @return 结果 + */ + @Override + public int updateUserWithdrawalWayWi(UserWithdrawalWayWi userWithdrawalWayWi) + { + userWithdrawalWayWi.setUpdateTime(DateUtils.getNowDate()); + return userWithdrawalWayWiMapper.updateUserWithdrawalWayWi(userWithdrawalWayWi); + } + + /** + * 批量删除用户提现方式(历史提现记录关联提现方式) + * + * @param ids 需要删除的用户提现方式(历史提现记录关联提现方式)主键 + * @return 结果 + */ + @Override + public int deleteUserWithdrawalWayWiByIds(Long[] ids) + { + return userWithdrawalWayWiMapper.deleteUserWithdrawalWayWiByIds(ids); + } + + /** + * 删除用户提现方式(历史提现记录关联提现方式)信息 + * + * @param id 用户提现方式(历史提现记录关联提现方式)主键 + * @return 结果 + */ + @Override + public int deleteUserWithdrawalWayWiById(Long id) + { + return userWithdrawalWayWiMapper.deleteUserWithdrawalWayWiById(id); + } + + + @Override + public UserWithdrawalWayWi addUserWithdrawalWayWi(UserWithdrawalWay userWithdrawalWay) { + + UserWithdrawalWayWi withdrawalWayWi = new UserWithdrawalWayWi() + .setCashAccount(userWithdrawalWay.getCashAccount()) + .setContactWay(userWithdrawalWay.getContactWay()) + .setLinkman(userWithdrawalWay.getLinkman()) + .setDelFlag(PublicCommon.启用) + .setAccountOpeningSubBranch(userWithdrawalWay.getAccountOpeningSubBranch()) + .setAreaCode(userWithdrawalWay.getAreaCode()) + .setPfWayId(userWithdrawalWay.getPfWayId()) + .setUserId(userWithdrawalWay.getUserId()) + .setUserType(userWithdrawalWay.getUserType()) + .setUserWithdrawalWayId(userWithdrawalWay.getId()); + + this.save(withdrawalWayWi); + + return withdrawalWayWi; + } +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/wallerecord/controller/WalletRecordController.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/wallerecord/controller/WalletRecordController.java new file mode 100644 index 0000000..d7a4a81 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/wallerecord/controller/WalletRecordController.java @@ -0,0 +1,152 @@ +package com.ruoyi.frequency.wallerecord.controller; + +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.page.TableDataInfo; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.common.utils.poi.ExcelUtil; +import com.ruoyi.enums.WalletDetailEnums; +import com.ruoyi.frequency.store.entity.Store; +import com.ruoyi.frequency.store.model.result.StoreCount; +import com.ruoyi.frequency.wallerecord.entity.WalletRecord; +import com.ruoyi.frequency.wallerecord.model.result.WalletRecordCount; +import com.ruoyi.frequency.wallerecord.model.result.WalletRecordTypeListResult; +import com.ruoyi.frequency.wallerecord.service.WalletRecordService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.*; + +import java.util.ArrayList; +import java.util.List; + +/** + * 钱包记录Controller + * + * @author liwenlong + * @date 2023-07-20 + */ +@RestController +@RequestMapping("/frequency/wallerecord") +public class WalletRecordController extends BaseController +{ + @Autowired + private WalletRecordService walletRecordService; + + /** + * 查询钱包记录列表 + */ + @PreAuthorize("@ss.hasPermi('frequency:wallerecord:list')") + @PostMapping("/list") + public TableDataInfo list(@RequestBody WalletRecord walletRecord) + { + startPage(); + List list = walletRecordService.selectWalletRecordList(walletRecord); + return getDataTable(list); + } + + + /** + * 统计 + */ + @PostMapping("/statistics") + public AjaxResult statistics(@RequestBody WalletRecord walletRecord) + { + WalletRecordCount count = walletRecordService.statistics(walletRecord); + return AjaxResult.success(count); + } + + + + /** + * 查询收支类型 + */ + @RequestMapping("/walletRecordTypeList") + public AjaxResult walletRecordTypeList() + { + List walletRecordTypeListResultList = new ArrayList<>(); + walletRecordTypeListResultList.add(new WalletRecordTypeListResult(WalletDetailEnums.TEAM_COMMISSION)); + walletRecordTypeListResultList.add(new WalletRecordTypeListResult(WalletDetailEnums.WITH_DEDU)); + walletRecordTypeListResultList.add(new WalletRecordTypeListResult(WalletDetailEnums.WITH_FAIL_RETURN)); + walletRecordTypeListResultList.add(new WalletRecordTypeListResult(WalletDetailEnums.RECHARGE_BALANCE)); + walletRecordTypeListResultList.add(new WalletRecordTypeListResult(WalletDetailEnums.ORDER_PAY)); + + walletRecordTypeListResultList.add(new WalletRecordTypeListResult(WalletDetailEnums.PLAT_ADD)); + walletRecordTypeListResultList.add(new WalletRecordTypeListResult(WalletDetailEnums.PLAT_SUB)); + walletRecordTypeListResultList.add(new WalletRecordTypeListResult(WalletDetailEnums.ORDER_INCOME)); + walletRecordTypeListResultList.add(new WalletRecordTypeListResult(WalletDetailEnums.ORDER_RETURN)); + walletRecordTypeListResultList.add(new WalletRecordTypeListResult(WalletDetailEnums.PLATFORM_AUTH_PAY)); + + walletRecordTypeListResultList.add(new WalletRecordTypeListResult(WalletDetailEnums.HEIGHT_AUTH_PAY)); + walletRecordTypeListResultList.add(new WalletRecordTypeListResult(WalletDetailEnums.BOND_PAY)); + walletRecordTypeListResultList.add(new WalletRecordTypeListResult(WalletDetailEnums.RECHARGE_GIVE_BALANCE)); + walletRecordTypeListResultList.add(new WalletRecordTypeListResult(WalletDetailEnums.ADJUST_PRICE_PAY)); + walletRecordTypeListResultList.add(new WalletRecordTypeListResult(WalletDetailEnums.DEPOSIT_REFUND)); + + + walletRecordTypeListResultList.add(new WalletRecordTypeListResult(WalletDetailEnums.GIVE_ORDER_PAY)); + walletRecordTypeListResultList.add(new WalletRecordTypeListResult(WalletDetailEnums.MALL_ORDER_PAY)); + walletRecordTypeListResultList.add(new WalletRecordTypeListResult(WalletDetailEnums.GIVE_ORDER_RETURN)); + walletRecordTypeListResultList.add(new WalletRecordTypeListResult(WalletDetailEnums.GIVE_BALANCE)); + walletRecordTypeListResultList.add(new WalletRecordTypeListResult(WalletDetailEnums.BOND_WITHDRAWAL)); + walletRecordTypeListResultList.add(new WalletRecordTypeListResult(WalletDetailEnums.BOND_RECHARGE)); + + return AjaxResult.success(walletRecordTypeListResultList); + } + + /** + * 导出钱包记录列表 + */ + @PreAuthorize("@ss.hasPermi('frequency:wallerecord:export')") + @Log(title = "钱包记录", businessType = BusinessType.EXPORT) + @GetMapping("/export") + public AjaxResult export(WalletRecord walletRecord) + { + List list = walletRecordService.selectWalletRecordList(walletRecord); + ExcelUtil util = new ExcelUtil(WalletRecord.class); + return util.exportExcel(list, "钱包记录数据"); + } + + /** + * 获取钱包记录详细信息 + */ + @PreAuthorize("@ss.hasPermi('frequency:wallerecord:query')") + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") Long id) + { + return AjaxResult.success(walletRecordService.selectWalletRecordById(id)); + } + + /** + * 新增钱包记录 + */ + @PreAuthorize("@ss.hasPermi('frequency:wallerecord:add')") + @Log(title = "钱包记录", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody WalletRecord walletRecord) + { + return toAjax(walletRecordService.insertWalletRecord(walletRecord)); + } + + /** + * 修改钱包记录 + */ + @PreAuthorize("@ss.hasPermi('frequency:wallerecord:edit')") + @Log(title = "钱包记录", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody WalletRecord walletRecord) + { + return toAjax(walletRecordService.updateWalletRecord(walletRecord)); + } + + /** + * 删除钱包记录 + */ + @PreAuthorize("@ss.hasPermi('frequency:wallerecord:remove')") + @Log(title = "钱包记录", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}") + public AjaxResult remove(@PathVariable Long[] ids) + { + return toAjax(walletRecordService.deleteWalletRecordByIds(ids)); + } +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/wallerecord/entity/WalletRecord.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/wallerecord/entity/WalletRecord.java new file mode 100644 index 0000000..60abb06 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/wallerecord/entity/WalletRecord.java @@ -0,0 +1,160 @@ +package com.ruoyi.frequency.wallerecord.entity; + +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableName; +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; + +import java.math.BigDecimal; +import java.util.Date; +import java.util.List; + +/** + * 钱包记录对象 t_wallet_record + * + * @author liwenlong + * @date 2023-07-20 + */ +@Data +@Accessors(chain = true) +@TableName("t_wallet_record") +public class WalletRecord extends BaseEntity { + private static final long serialVersionUID = 1L; + + /** + * 主键id + */ + private Long id; + + + /** + * 删除标志 1正常 删除 3 禁用 + */ + private Integer delFlag; + + /** + * 用户类型 1 用户 2 表现师 + */ + @Excel(name = "用户类型 1 用户 2 表现师") + private Integer userType; + + /** + * 记录类型 具体看代码 + */ + @Excel(name = "记录类型 具体看代码") + private Integer recordType; + + /** + * 数值 + */ + @Excel(name = "数值") + private BigDecimal price; + + /** + * 用户id(表现师关联t_store 用户关联t_customer) + */ + @Excel(name = "用户id(表现师关联t_store 用户关联t_customer)") + private Long userId; + + /** + * 记录来源id(如订单,则关联t_order) + */ + @Excel(name = "记录来源id(如订单,则关联t_order)") + private Long objectId; + + /** + * 可提现状态 1 可提现 2 不可提现 3 到账取消 + */ + @Excel(name = "可提现状态 1 可提现 2 不可提现 3 到账取消") + private Integer status; + + /** + * 可提现时间 + */ + @Excel(name = "可提现时间", width = 30, dateFormat = "yyyy-MM-dd") + private Date canWithTime; + + /** + * 不可提现时间 + */ + @Excel(name = "不可提现时间", width = 30, dateFormat = "yyyy-MM-dd") + private Date noWithTime; + + /** + * 取消到账时间 + */ + @Excel(name = "取消到账时间", width = 30, dateFormat = "yyyy-MM-dd") + private Date cancelTime; + + /** + * 当前余额 + */ + @Excel(name = "当前余额") + private BigDecimal currentBalance; + + /** + * 备注 + */ + private String remark; + + /** + * 类型名称 + */ + @TableField(exist = false) + private String record; + + /** + * 转账完成时间 + */ + @TableField(exist = false) + private Date transferCompletionTime; + + /** + * 订单创建时间 + */ + @TableField(exist = false) + private Date orderTime; + + /** + * 订单号 + */ + @TableField(exist = false) + private String orderNo; + + /** + * 是否是快捷支付 1是 2 否 + */ + @TableField(exist = false) + private Integer isOnline; + + /** + * 是否是抵用金记录 1是 2 否 + */ + @TableField(exist = false) + private Integer isGivePay; + + /** + * 支付方式 1 钱包支付 2 抵用金支付 3 快捷支付 + */ + @TableField(exist = false) + private Integer type; + + @ApiModelProperty("开始时间") + @TableField(exist = false) + private Date beginTime; + + @ApiModelProperty("结束时间") + @TableField(exist = false) + private Date endTime; + + + /** + * 记录类型 具体看代码 + */ + @Excel(name = "记录类型 具体看代码") + @TableField(exist = false) + private List recordTypeList; +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/wallerecord/mapper/WalletRecordMapper.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/wallerecord/mapper/WalletRecordMapper.java new file mode 100644 index 0000000..b227e25 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/wallerecord/mapper/WalletRecordMapper.java @@ -0,0 +1,75 @@ +package com.ruoyi.frequency.wallerecord.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.ruoyi.controller.req.WalletPageReq; +import com.ruoyi.controller.resp.WalletPageResp; +import com.ruoyi.frequency.wallerecord.entity.WalletRecord; +import com.ruoyi.vo.UserVo; +import org.apache.ibatis.annotations.Param; + +import java.math.BigDecimal; +import java.util.Date; +import java.util.List; + +/** + * 钱包记录Mapper接口 + * + * @author liwenlong + * @date 2023-07-20 + */ +public interface WalletRecordMapper extends BaseMapper +{ + /** + * 查询钱包记录 + * + * @param id 钱包记录主键 + * @return 钱包记录 + */ + WalletRecord selectWalletRecordById(Long id); + + + /** + * 新增钱包记录 + * + * @param walletRecord 钱包记录 + * @return 结果 + */ + int insertWalletRecord(WalletRecord walletRecord); + + /** + * 修改钱包记录 + * + * @param walletRecord 钱包记录 + * @return 结果 + */ + int updateWalletRecord(WalletRecord walletRecord); + + /** + * 删除钱包记录 + * + * @param id 钱包记录主键 + * @return 结果 + */ + int deleteWalletRecordById(Long id); + + /** + * 批量删除钱包记录 + * + * @param ids 需要删除的数据主键集合 + * @return 结果 + */ + int deleteWalletRecordByIds(Long[] ids); + + Page walletPage(@Param("page") Page objectPage, @Param("req") WalletPageReq req, @Param("userVo") UserVo userVo); + + Page walletStorePage(@Param("page") Page objectPage, @Param("req") WalletPageReq req, @Param("userVo") UserVo userVo); + + Page walletSalePage(@Param("page") Page objectPage, @Param("req") WalletPageReq req, @Param("userVo") UserVo userVo); + + BigDecimal selectMonthBeforeAmount(@Param("beginOfMonth") Date beginOfMonth, @Param("userVo") UserVo userVo); + + WalletRecord walletDetail(@Param("id") Long id); + + List selectWalletRecordList(WalletRecord walletRecord); +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/wallerecord/mapper/mapping/WalletRecordMapper.xml b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/wallerecord/mapper/mapping/WalletRecordMapper.xml new file mode 100644 index 0000000..7fb1add --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/wallerecord/mapper/mapping/WalletRecordMapper.xml @@ -0,0 +1,515 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + select id, + create_by, + create_time, + update_by, + update_time, + del_flag, + user_type, + record_type, + price, + remark, + user_id, + object_id, + status, + can_with_time, + no_with_time, + cancel_time, + current_balance + from t_wallet_record t + + + + + + insert into t_wallet_record + + id, + create_by, + create_time, + update_by, + update_time, + del_flag, + user_type, + record_type, + price, + user_id, + object_id, + status, + can_with_time, + no_with_time, + cancel_time, + current_balance, + + + #{id}, + #{createBy}, + #{createTime}, + #{updateBy}, + #{updateTime}, + #{delFlag}, + #{userType}, + #{recordType}, + #{price}, + #{userId}, + #{objectId}, + #{status}, + #{canWithTime}, + #{noWithTime}, + #{cancelTime}, + #{currentBalance}, + + + + + update t_wallet_record + + create_by = #{createBy}, + create_time = #{createTime}, + update_by = #{updateBy}, + update_time = #{updateTime}, + del_flag = #{delFlag}, + user_type = #{userType}, + record_type = #{recordType}, + price = #{price}, + user_id = #{userId}, + object_id = #{objectId}, + status = #{status}, + can_with_time = #{canWithTime}, + no_with_time = #{noWithTime}, + cancel_time = #{cancelTime}, + current_balance = #{currentBalance}, + + where id = #{id} + + + + delete + from t_wallet_record + where id = #{id} + + + + delete from t_wallet_record where id in + + #{id} + + + + + + + + + + + + + + diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/wallerecord/model/param/EditUserBalanceParam.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/wallerecord/model/param/EditUserBalanceParam.java new file mode 100644 index 0000000..6b96184 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/wallerecord/model/param/EditUserBalanceParam.java @@ -0,0 +1,30 @@ +package com.ruoyi.frequency.wallerecord.model.param; + +import lombok.Data; + +import java.math.BigDecimal; + +/** + * @author liwenlong + * @date 2023/5/27 16:54 + */ + +@Data +public class EditUserBalanceParam { + + + /** + * 用户类型 1 用户 + */ + private Integer userType; + + /** + * 用户id + */ + private Long userId; + + /** + * 余额 + */ + private BigDecimal balance; +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/wallerecord/model/param/WalletRecordParam.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/wallerecord/model/param/WalletRecordParam.java new file mode 100644 index 0000000..e2b0514 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/wallerecord/model/param/WalletRecordParam.java @@ -0,0 +1,86 @@ +package com.ruoyi.frequency.wallerecord.model.param; + +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import lombok.Data; +import lombok.experimental.Accessors; + +import java.math.BigDecimal; +import java.util.Date; + +/** + * 钱包记录对象 t_wallet_record + * + * @author liwenlong + * @date 2023-07-20 + */ +@Data +@Accessors(chain = true) +public class WalletRecordParam extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** 主键id */ + private Long id; + + + + /** 删除标志 1正常 删除 3 禁用 */ + private Integer delFlag; + + /** 用户类型 1 用户 2 表现师 */ + @Excel(name = "用户类型 1 用户 2 表现师") + private Integer userType; + + /** 记录类型 具体看代码 */ + @Excel(name = "记录类型 具体看代码") + private Integer recordType; + + /** 数值 */ + @Excel(name = "数值") + private BigDecimal price; + + /** 用户id(表现师关联t_store 用户关联t_customer) */ + @Excel(name = "用户id(表现师关联t_store 用户关联t_customer)") + private Long userId; + + /** 记录来源id(如订单,则关联t_order) */ + @Excel(name = "记录来源id(如订单,则关联t_order)") + private Long objectId; + + /** 可提现状态 1 可提现 2 不可提现 3 到账取消 */ + @Excel(name = "可提现状态 1 可提现 2 不可提现 3 到账取消") + private Integer status; + + /** 可提现时间 */ + @Excel(name = "可提现时间", width = 30, dateFormat = "yyyy-MM-dd") + private Date canWithTime; + + /** 不可提现时间 */ + @Excel(name = "不可提现时间", width = 30, dateFormat = "yyyy-MM-dd") + private Date noWithTime; + + /** 取消到账时间 */ + @Excel(name = "取消到账时间", width = 30, dateFormat = "yyyy-MM-dd") + private Date cancelTime; + + /** 当前余额 */ + @Excel(name = "当前余额") + private BigDecimal currentBalance; + + + + + + + + + + + + + + + + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/wallerecord/model/result/WalletRecordCount.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/wallerecord/model/result/WalletRecordCount.java new file mode 100644 index 0000000..a3ef4e6 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/wallerecord/model/result/WalletRecordCount.java @@ -0,0 +1,16 @@ +package com.ruoyi.frequency.wallerecord.model.result; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.math.BigDecimal; + +@Data +public class WalletRecordCount { + + @ApiModelProperty("支出") + private BigDecimal expenditure = new BigDecimal("0"); + + @ApiModelProperty("收入") + private BigDecimal income = new BigDecimal("0"); +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/wallerecord/model/result/WalletRecordResult.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/wallerecord/model/result/WalletRecordResult.java new file mode 100644 index 0000000..976dcb6 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/wallerecord/model/result/WalletRecordResult.java @@ -0,0 +1,72 @@ +package com.ruoyi.frequency.wallerecord.model.result; + +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import lombok.Data; +import lombok.experimental.Accessors; + +import java.math.BigDecimal; +import java.util.Date; + +/** + * 钱包记录对象 t_wallet_record + * + * @author liwenlong + * @date 2023-07-20 + */ +@Data +@Accessors(chain = true) +public class WalletRecordResult extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** 主键id */ + private Long id; + + + + /** 删除标志 1正常 删除 3 禁用 */ + private Integer delFlag; + + /** 用户类型 1 用户 2 表现师 */ + @Excel(name = "用户类型 1 用户 2 表现师") + private Integer userType; + + /** 记录类型 具体看代码 */ + @Excel(name = "记录类型 具体看代码") + private Integer recordType; + + /** 数值 */ + @Excel(name = "数值") + private BigDecimal price; + + /** 用户id(表现师关联t_store 用户关联t_customer) */ + @Excel(name = "用户id(表现师关联t_store 用户关联t_customer)") + private Long userId; + + /** 记录来源id(如订单,则关联t_order) */ + @Excel(name = "记录来源id(如订单,则关联t_order)") + private Long objectId; + + /** 可提现状态 1 可提现 2 不可提现 3 到账取消 */ + @Excel(name = "可提现状态 1 可提现 2 不可提现 3 到账取消") + private Integer status; + + /** 可提现时间 */ + @Excel(name = "可提现时间", width = 30, dateFormat = "yyyy-MM-dd") + private Date canWithTime; + + /** 不可提现时间 */ + @Excel(name = "不可提现时间", width = 30, dateFormat = "yyyy-MM-dd") + private Date noWithTime; + + /** 取消到账时间 */ + @Excel(name = "取消到账时间", width = 30, dateFormat = "yyyy-MM-dd") + private Date cancelTime; + + /** 当前余额 */ + @Excel(name = "当前余额") + private BigDecimal currentBalance; + + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/wallerecord/model/result/WalletRecordTypeListResult.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/wallerecord/model/result/WalletRecordTypeListResult.java new file mode 100644 index 0000000..8e8f602 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/wallerecord/model/result/WalletRecordTypeListResult.java @@ -0,0 +1,18 @@ +package com.ruoyi.frequency.wallerecord.model.result; + +import com.ruoyi.enums.WalletDetailEnums; +import lombok.Data; + +@Data +public class WalletRecordTypeListResult { + private Integer code; + private String name; + + public WalletRecordTypeListResult() { + } + + public WalletRecordTypeListResult(WalletDetailEnums walletDetailEnums) { + code = walletDetailEnums.getCode(); + name = walletDetailEnums.getName(); + } +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/wallerecord/service/WalletRecordService.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/wallerecord/service/WalletRecordService.java new file mode 100644 index 0000000..07c0977 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/wallerecord/service/WalletRecordService.java @@ -0,0 +1,109 @@ +package com.ruoyi.frequency.wallerecord.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.ruoyi.controller.req.WalletPageReq; +import com.ruoyi.controller.resp.WalletPageResp; +import com.ruoyi.enums.WalletDetailEnums; +import com.ruoyi.frequency.wallerecord.entity.WalletRecord; +import com.ruoyi.frequency.wallerecord.model.param.EditUserBalanceParam; +import com.ruoyi.frequency.wallerecord.model.result.WalletRecordCount; +import com.ruoyi.response.ResponseData; +import com.ruoyi.vo.BodyIdReq; +import com.ruoyi.vo.UserVo; + +import java.math.BigDecimal; +import java.util.List; + +/** + * 钱包记录Service接口 + * + * @author liwenlong + * @date 2023-07-20 + */ +public interface WalletRecordService extends IService +{ + /** + * 查询钱包记录 + * + * @param id 钱包记录主键 + * @return 钱包记录 + */ + WalletRecord selectWalletRecordById(Long id); + + /** + * 查询钱包记录列表 + * + * @param walletRecord 钱包记录 + * @return 钱包记录集合 + */ + List selectWalletRecordList(WalletRecord walletRecord); + + /** + * 新增钱包记录 + * + * @param walletRecord 钱包记录 + * @return 结果 + */ + int insertWalletRecord(WalletRecord walletRecord); + + /** + * 修改钱包记录 + * + * @param walletRecord 钱包记录 + * @return 结果 + */ + int updateWalletRecord(WalletRecord walletRecord); + + /** + * 批量删除钱包记录 + * + * @param ids 需要删除的钱包记录主键集合 + * @return 结果 + */ + int deleteWalletRecordByIds(Long[] ids); + + /** + * 删除钱包记录信息 + * + * @param id 钱包记录主键 + * @return 结果 + */ + int deleteWalletRecordById(Long id); + + /** + * 编辑用户余额 + * + * @author liwenlong + * @date 2023-04-27 + */ + ResponseData editUserBalance(EditUserBalanceParam param); + + + /** + * 修改余额 + * @param userVo 用户对象 + * @param walletDetailEnums 钱包类型枚举 + * @param objectId 来源id + * @param updatePrice 修改金额 正加 负减 + * @param status 状态 1可提现 2不可提现 3到账取消 + */ + void updateBalance(UserVo userVo, WalletDetailEnums walletDetailEnums, Long objectId, BigDecimal updatePrice, Integer status); + + void updateBalance(UserVo userVo, WalletDetailEnums walletDetailEnums, String remark, Long objectId, BigDecimal updatePrice, Integer status); + + + + /** + * app端用户钱包记录 + * @param req + * @param userVo 用户对象 + * @return + */ + ResponseData walletPage(WalletPageReq req, UserVo userVo); + + ResponseData expenditurePage(WalletPageReq req, UserVo userVo); + + ResponseData walletDetail(BodyIdReq req, UserVo userVo); + + WalletRecordCount statistics(WalletRecord walletRecord); +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/wallerecord/service/impl/WalletRecordServiceImpl.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/wallerecord/service/impl/WalletRecordServiceImpl.java new file mode 100644 index 0000000..f3e916a --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/wallerecord/service/impl/WalletRecordServiceImpl.java @@ -0,0 +1,473 @@ +package com.ruoyi.frequency.wallerecord.service.impl; + +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.collection.CollectionUtil; +import cn.hutool.core.date.DateUtil; +import cn.hutool.core.util.ObjectUtil; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.ruoyi.code.PublicCommon; +import com.ruoyi.common.core.domain.BaseEntity; +import com.ruoyi.common.exception.CustomException; +import com.ruoyi.common.exception.enums.CoreExceptionEnum; +import com.ruoyi.common.page.PageResult; +import com.ruoyi.common.utils.DateUtils; +import com.ruoyi.controller.req.WalletPageReq; +import com.ruoyi.controller.resp.WalletPageResp; +import com.ruoyi.enums.WalletDetailEnums; +import com.ruoyi.enums.user.UserEnums; +import com.ruoyi.frequency.customer.mapper.CustomerMapper; +import com.ruoyi.frequency.customer.service.UserService; +import com.ruoyi.frequency.illegaldeductionrecord.model.result.OrderInfoResp; +import com.ruoyi.frequency.klkwithdrawalrecord.entity.KlkWithdrawalRecord; +import com.ruoyi.frequency.klkwithdrawalrecord.service.KlkWithdrawalRecordService; +import com.ruoyi.frequency.onlinerecord.entity.OnlineRecord; +import com.ruoyi.frequency.onlinerecord.mapper.OnlineRecordMapper; +import com.ruoyi.frequency.sale.mapper.SaleMapper; +import com.ruoyi.frequency.store.mapper.StoreMapper; +import com.ruoyi.frequency.wallerecord.entity.WalletRecord; +import com.ruoyi.frequency.wallerecord.mapper.WalletRecordMapper; +import com.ruoyi.frequency.wallerecord.model.param.EditUserBalanceParam; +import com.ruoyi.frequency.wallerecord.model.result.WalletRecordCount; +import com.ruoyi.frequency.wallerecord.service.WalletRecordService; +import com.ruoyi.frequency.withdrawalrecord.entity.WithdrawalRecord; +import com.ruoyi.frequency.withdrawalrecord.service.WithdrawalRecordService; +import com.ruoyi.response.ResponseData; +import com.ruoyi.utils.BusinessUtil; +import com.ruoyi.vo.BodyIdReq; +import com.ruoyi.vo.UserVo; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.math.BigDecimal; +import java.util.*; + +/** + * 钱包记录Service业务层处理 + * + * @author liwenlong + * @date 2023-07-20 + */ +@Service +public class WalletRecordServiceImpl extends ServiceImpl implements WalletRecordService { + @Autowired + private WalletRecordMapper walletRecordMapper; + + /** + * 查询钱包记录 + * + * @param id 钱包记录主键 + * @return 钱包记录 + */ + @Override + public WalletRecord selectWalletRecordById(Long id) { + return walletRecordMapper.selectWalletRecordById(id); + } + + /** + * 查询钱包记录列表 + * + * @param walletRecord 钱包记录 + * @return 钱包记录 + */ + @Override + public List selectWalletRecordList(WalletRecord walletRecord) { + + List walletRecords = walletRecordList(walletRecord); + + if (walletRecords.size() > 0) { + walletRecords.stream().forEach(s -> { + s.setRecord(WalletDetailEnums.getName(s.getRecordType())); + }); + } + + return walletRecords; + } + + + private List walletRecordList(WalletRecord walletRecord) { + List walletRecords = baseMapper.selectWalletRecordList(walletRecord); + return walletRecords; + } + + /** + * 新增钱包记录 + * + * @param walletRecord 钱包记录 + * @return 结果 + */ + @Override + public int insertWalletRecord(WalletRecord walletRecord) { + walletRecord.setCreateTime(DateUtils.getNowDate()); + return walletRecordMapper.insertWalletRecord(walletRecord); + } + + /** + * 修改钱包记录 + * + * @param walletRecord 钱包记录 + * @return 结果 + */ + @Override + public int updateWalletRecord(WalletRecord walletRecord) { + walletRecord.setUpdateTime(DateUtils.getNowDate()); + return walletRecordMapper.updateWalletRecord(walletRecord); + } + + /** + * 批量删除钱包记录 + * + * @param ids 需要删除的钱包记录主键 + * @return 结果 + */ + @Override + public int deleteWalletRecordByIds(Long[] ids) { + return walletRecordMapper.deleteWalletRecordByIds(ids); + } + + /** + * 删除钱包记录信息 + * + * @param id 钱包记录主键 + * @return 结果 + */ + @Override + public int deleteWalletRecordById(Long id) { + return walletRecordMapper.deleteWalletRecordById(id); + } + + + @Autowired + private BusinessUtil businessUtil; + + @Override + public ResponseData editUserBalance(EditUserBalanceParam param) { + + //查询用户余额 + BigDecimal userBalance = businessUtil.getUserBalance(new UserVo(param.getUserType(), param.getUserId())); + + if (ObjectUtil.isNotEmpty(param.getBalance()) && param.getBalance().compareTo(userBalance) != 0) { + if (param.getBalance().compareTo(userBalance) == 1) { + + //充值金额 + BigDecimal addPrice = param.getBalance().subtract(userBalance); + + this.updateBalance(new UserVo(param.getUserType(), param.getUserId()), WalletDetailEnums.PLAT_ADD, param.getUserId(), addPrice, PublicCommon.Wallet.可提现); + + } else { + //扣除金额 + BigDecimal subPrice = param.getBalance().subtract(userBalance); + + this.updateBalance(new UserVo(param.getUserType(), param.getUserId()), WalletDetailEnums.PLAT_SUB, param.getUserId(), subPrice, PublicCommon.Wallet.可提现); + } + } + + return ResponseData.success(); + } + + + @Autowired + private CustomerMapper customerMapper; + + @Autowired + private StoreMapper storeMapper; + + @Autowired + private SaleMapper saleMapper; + + @Override + public void updateBalance(UserVo userVo, WalletDetailEnums walletDetailEnums, Long objectId, BigDecimal updatePrice, Integer status) { + if (updatePrice.compareTo(BigDecimal.ZERO) == 0 || ObjectUtil.equal(PublicCommon.Wallet.到账取消, status)) { + return; + } + + switch (userVo.getUserType()) { + case 1: + if (updatePrice.compareTo(BigDecimal.ZERO) == 1) { + customerMapper.addBalance(userVo.getUserId(), updatePrice); + } else { + boolean subBalance = customerMapper.subBalance(userVo.getUserId(), updatePrice.negate()); + if (!subBalance) { + throw new CustomException(CoreExceptionEnum.BALANCE_INSUFFICIENT); + } + } + break; + case 2: + if (updatePrice.compareTo(BigDecimal.ZERO) == 1) { + storeMapper.addBalance(userVo.getUserId(), updatePrice); + } else { + boolean subBalance = storeMapper.subBalance(userVo.getUserId(), updatePrice.negate()); + if (!subBalance) { + throw new CustomException(CoreExceptionEnum.BALANCE_INSUFFICIENT); + } + } + break; + case 3: + if (updatePrice.compareTo(BigDecimal.ZERO) == 1) { + saleMapper.addBalance(userVo.getUserId(), updatePrice); + //累计收益 + saleMapper.addIncome(userVo.getUserId(), updatePrice); + } else { + boolean subBalance = saleMapper.subBalance(userVo.getUserId(), updatePrice.negate()); + if (!subBalance) { + throw new CustomException(CoreExceptionEnum.BALANCE_INSUFFICIENT); + } + } + break; + default: + throw new IllegalStateException("Unexpected value: " + userVo.getUserType()); + } + + //添加钱包记录 + addWalletRecord(userVo, objectId, updatePrice, walletDetailEnums, null, status); + } + + @Override + public void updateBalance(UserVo userVo, WalletDetailEnums walletDetailEnums, String remark, Long objectId, BigDecimal updatePrice, Integer status) { + if (updatePrice.compareTo(BigDecimal.ZERO) == 0 || ObjectUtil.equal(PublicCommon.Wallet.到账取消, status)) { + throw new CustomException(CoreExceptionEnum.ERROR_PARAM); + } + + switch (userVo.getUserType()) { + case 1: + if (updatePrice.compareTo(BigDecimal.ZERO) == 1) { + customerMapper.addBalance(userVo.getUserId(), updatePrice); + } else { + boolean subBalance = customerMapper.subBalance(userVo.getUserId(), updatePrice.negate()); + if (!subBalance) { + throw new CustomException(CoreExceptionEnum.BALANCE_INSUFFICIENT); + } + } + break; + case 2: + if (updatePrice.compareTo(BigDecimal.ZERO) == 1) { + storeMapper.addBalance(userVo.getUserId(), updatePrice); + } else { + boolean subBalance = storeMapper.subBalance(userVo.getUserId(), updatePrice.negate()); + if (!subBalance) { + throw new CustomException(CoreExceptionEnum.BALANCE_INSUFFICIENT); + } + } + break; + case 3: + if (updatePrice.compareTo(BigDecimal.ZERO) == 1) { + saleMapper.addBalance(userVo.getUserId(), updatePrice); + //累计收益 + saleMapper.addIncome(userVo.getUserId(), updatePrice); + } else { + boolean subBalance = saleMapper.subBalance(userVo.getUserId(), updatePrice.negate()); + if (!subBalance) { + throw new CustomException(CoreExceptionEnum.BALANCE_INSUFFICIENT); + } + } + break; + default: + throw new IllegalStateException("Unexpected value: " + userVo.getUserType()); + } + + //添加钱包记录 + addWalletRecord(userVo, objectId, updatePrice, walletDetailEnums, remark, status); + } + + /** + * 增加余额记录 + * + * @param userVo 用户 + * @param walletDetailEnums 类型名称 + * @param orderId 订单id + * @param price 金额 + */ + public void addWalletRecord(UserVo userVo, Long orderId, BigDecimal price, WalletDetailEnums walletDetailEnums, String remark, Integer status) { + if (price.setScale(2, BigDecimal.ROUND_HALF_UP).compareTo(new BigDecimal(0)) != 0) { + WalletRecord walletRecord = new WalletRecord(); + walletRecord.setUserId(userVo.getUserId()); + walletRecord.setUserType(userVo.getUserType()); + walletRecord.setObjectId(orderId); + walletRecord.setStatus(status); + walletRecord.setRecordType(walletDetailEnums.getCode()); + walletRecord.setPrice(price); + + if (ObjectUtil.equal(PublicCommon.Wallet.可提现, status)) { + walletRecord.setCanWithTime(new Date()); + } else if (ObjectUtil.equal(PublicCommon.Wallet.不可提现, status)) { + walletRecord.setNoWithTime(new Date()); + } + + //获取用户当前余额 + BigDecimal userBalance = businessUtil.getUserBalance(userVo); + + walletRecord.setCurrentBalance(userBalance); + walletRecord.setRemark(remark); + + this.save(walletRecord); + } + } + + + @Autowired + private UserService userService; + + @Override + public ResponseData walletPage(WalletPageReq req, UserVo userVo) { + + userService.storeByEnterprise(userVo); + + Page page = null; + if (ObjectUtil.equal(UserEnums.store.getCode(), userVo.getUserType()) && ObjectUtil.isEmpty(req.getType())) { + page = this.baseMapper.walletStorePage(new Page<>(req.getPageNo(), req.getPageSize()), req, userVo); + } else if (ObjectUtil.equal(UserEnums.sale.getCode(), userVo.getUserType()) && ObjectUtil.isEmpty(req.getType())) { + page = this.baseMapper.walletSalePage(new Page<>(req.getPageNo(), req.getPageSize()), req, userVo); + } else { + page = this.baseMapper.walletPage(new Page<>(req.getPageNo(), req.getPageSize()), req, userVo); + } + + if (page.getRecords().size() > 0) { + page.getRecords().stream().forEach(s -> { + if (ObjectUtil.isNotEmpty(s.getRecordType())) { + s.setRecord(WalletDetailEnums.getName(s.getRecordType())); + } + }); + } + + // 查询分页结果 + return ResponseData.success(new PageResult<>(page)); + } + + private List getExpenditureList() { + List recordTypeList = new ArrayList<>(); + recordTypeList.add(WalletDetailEnums.WITH_DEDU.getCode()); + recordTypeList.add(WalletDetailEnums.ORDER_PAY.getCode()); + recordTypeList.add(WalletDetailEnums.PLAT_SUB.getCode()); + recordTypeList.add(WalletDetailEnums.PLATFORM_AUTH_PAY.getCode()); + recordTypeList.add(WalletDetailEnums.HEIGHT_AUTH_PAY.getCode()); + recordTypeList.add(WalletDetailEnums.BOND_PAY.getCode()); + recordTypeList.add(WalletDetailEnums.ADJUST_PRICE_PAY.getCode()); + recordTypeList.add(WalletDetailEnums.MALL_ORDER_PAY.getCode()); + recordTypeList.add(WalletDetailEnums.GIVE_BALANCE.getCode()); + return recordTypeList; + } + + @Autowired + private OnlineRecordMapper onlineRecordMapper; + + @Override + public ResponseData expenditurePage(WalletPageReq req, UserVo userVo) { + LambdaUpdateWrapper lambdaUpdateWrapper = new LambdaUpdateWrapper<>(); + lambdaUpdateWrapper.eq(WalletRecord::getUserId, userVo.getUserId()); + lambdaUpdateWrapper.eq(WalletRecord::getUserType, userVo.getUserType()); + if (req.getBeginTime() != null) { + lambdaUpdateWrapper.ge(BaseEntity::getCreateTime, req.getBeginTime()); + } + if (req.getEndTime() != null) { + lambdaUpdateWrapper.le(BaseEntity::getCreateTime, req.getEndTime()); + } + lambdaUpdateWrapper.eq(WalletRecord::getDelFlag, PublicCommon.启用); + + lambdaUpdateWrapper.in(WalletRecord::getRecordType, getExpenditureList()); + lambdaUpdateWrapper.orderByDesc(BaseEntity::getCreateTime); + + List walletRecordList = this.baseMapper.selectList(lambdaUpdateWrapper); + if (CollectionUtil.isNotEmpty(walletRecordList)) { + for (WalletRecord cur : walletRecordList) { + cur.setIsOnline(2); + } + + } + //加入在线支付记录 + + List onlineRecords = onlineRecordMapper.selectList(new QueryWrapper().lambda().eq(OnlineRecord::getUserId, userVo.getUserId()) + .eq(OnlineRecord::getUserType, userVo.getUserType())); + for (OnlineRecord onlineRecord : onlineRecords) { + WalletRecord walletRecord = new WalletRecord(); + BeanUtil.copyProperties(onlineRecord, walletRecord); + walletRecord.setIsOnline(1); + walletRecord.setRecordType(onlineRecord.getObjectType()); + + walletRecordList.add(walletRecord); + } + + + //按月筛选 + Map> walletMap = new LinkedHashMap<>(); + + if (CollectionUtil.isNotEmpty(walletRecordList)) { + for (WalletRecord cur : walletRecordList) { + cur.setRecord(WalletDetailEnums.getName(cur.getRecordType())); + String yearMonth = DateUtil.year(cur.getCreateTime()) + "年" + (DateUtil.month(cur.getCreateTime()) + 1) + "月"; + if (!walletMap.containsKey(yearMonth)) { + walletMap.put(yearMonth, new ArrayList<>()); + } + walletMap.get(yearMonth).add(cur); + } + + } + List resultList = new ArrayList<>(); + Iterator>> iterator = walletMap.entrySet().iterator(); + while (iterator.hasNext()) { + Map.Entry> next = iterator.next(); + Map map = new HashMap(); + map.put("date", next.getKey()); + map.put("list", next.getValue()); + resultList.add(map); + } + + return ResponseData.success(resultList); + } + + @Autowired + private WithdrawalRecordService withdrawalRecordService; + @Autowired + private KlkWithdrawalRecordService klkWithdrawalRecordService; + + @Override + public ResponseData walletDetail(BodyIdReq req, UserVo userVo) { + WalletRecord walletRecord = baseMapper.walletDetail(req.getId()); + walletRecord.setRecord(WalletDetailEnums.getName(walletRecord.getRecordType())); + if (walletRecord.getRecordType().equals(WalletDetailEnums.WITH_DEDU.getCode()) + || walletRecord.getRecordType().equals(WalletDetailEnums.WITH_FAIL_RETURN.getCode())) { + + WithdrawalRecord withdrawalRecord = withdrawalRecordService.getById(walletRecord.getObjectId()); + if (withdrawalRecord != null) { + KlkWithdrawalRecord klkWithdrawalRecord = klkWithdrawalRecordService.getOne(new QueryWrapper().lambda().eq(KlkWithdrawalRecord::getWithdrawalRecordId, withdrawalRecord.getId())); + if (klkWithdrawalRecord != null) { + walletRecord.setTransferCompletionTime(klkWithdrawalRecord.getTransferFinishTime()); + } + } + } else if (walletRecord.getRecordType().equals(WalletDetailEnums.ORDER_PAY.getCode()) + || walletRecord.getRecordType().equals(WalletDetailEnums.ORDER_INCOME.getCode()) + || walletRecord.getRecordType().equals(WalletDetailEnums.ORDER_RETURN.getCode()) + || walletRecord.getRecordType().equals(WalletDetailEnums.ADJUST_PRICE_PAY.getCode()) + || walletRecord.getRecordType().equals(WalletDetailEnums.DEPOSIT_REFUND.getCode()) + || walletRecord.getRecordType().equals(WalletDetailEnums.GIVE_ORDER_PAY.getCode()) + || walletRecord.getRecordType().equals(WalletDetailEnums.GIVE_ORDER_RETURN.getCode()) + ) { + OrderInfoResp orderInfo = businessUtil.getOrderInfo(walletRecord.getObjectId()); + if (orderInfo != null) { + walletRecord.setOrderTime(orderInfo.getCreateTime()); + walletRecord.setOrderNo(orderInfo.getOrderNo()); + } + } + return ResponseData.success(walletRecord); + } + + @Override + public WalletRecordCount statistics(WalletRecord walletRecord) { + List walletRecordList = walletRecordList(walletRecord); + + WalletRecordCount count = new WalletRecordCount(); + + walletRecordList.stream().forEach(x -> { + if (x.getPrice().compareTo(BigDecimal.ZERO) == 1) { + count.setIncome(count.getIncome().add(x.getPrice())); + } else if (x.getPrice().compareTo(BigDecimal.ZERO) == -1) { + count.setExpenditure(count.getExpenditure().add(x.getPrice())); + } + }); + + return count; + } + + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/withdrawalconfig/controller/WithdrawalConfigController.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/withdrawalconfig/controller/WithdrawalConfigController.java new file mode 100644 index 0000000..56036c1 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/withdrawalconfig/controller/WithdrawalConfigController.java @@ -0,0 +1,97 @@ +package com.ruoyi.frequency.withdrawalconfig.controller; + +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.page.TableDataInfo; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.common.utils.poi.ExcelUtil; +import com.ruoyi.frequency.withdrawalconfig.entity.WithdrawalConfig; +import com.ruoyi.frequency.withdrawalconfig.service.WithdrawalConfigService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +/** + * 提现配置Controller + * + * @author liwenlong + * @date 2023-07-20 + */ +@RestController +@RequestMapping("/frequency/withdrawalconfig") +public class WithdrawalConfigController extends BaseController +{ + @Autowired + private WithdrawalConfigService withdrawalConfigService; + + /** + * 查询提现配置列表 + */ + @PreAuthorize("@ss.hasPermi('frequency:withdrawalconfig:list')") + @GetMapping("/list") + public TableDataInfo list(WithdrawalConfig withdrawalConfig) + { + startPage(); + List list = withdrawalConfigService.selectWithdrawalConfigList(withdrawalConfig); + return getDataTable(list); + } + + /** + * 导出提现配置列表 + */ + @PreAuthorize("@ss.hasPermi('frequency:withdrawalconfig:export')") + @Log(title = "提现配置", businessType = BusinessType.EXPORT) + @GetMapping("/export") + public AjaxResult export(WithdrawalConfig withdrawalConfig) + { + List list = withdrawalConfigService.selectWithdrawalConfigList(withdrawalConfig); + ExcelUtil util = new ExcelUtil(WithdrawalConfig.class); + return util.exportExcel(list, "提现配置数据"); + } + + /** + * 获取提现配置详细信息 + */ + @PreAuthorize("@ss.hasPermi('frequency:withdrawalconfig:query')") + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") Long id) + { + return AjaxResult.success(withdrawalConfigService.selectWithdrawalConfigById(id)); + } + + /** + * 新增提现配置 + */ + @PreAuthorize("@ss.hasPermi('frequency:withdrawalconfig:add')") + @Log(title = "提现配置", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody WithdrawalConfig withdrawalConfig) + { + return toAjax(withdrawalConfigService.insertWithdrawalConfig(withdrawalConfig)); + } + + /** + * 修改提现配置 + */ + @PreAuthorize("@ss.hasPermi('frequency:withdrawalconfig:edit')") + @Log(title = "提现配置", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody WithdrawalConfig withdrawalConfig) + { + return toAjax(withdrawalConfigService.updateWithdrawalConfig(withdrawalConfig)); + } + + /** + * 删除提现配置 + */ + @PreAuthorize("@ss.hasPermi('frequency:withdrawalconfig:remove')") + @Log(title = "提现配置", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}") + public AjaxResult remove(@PathVariable Long[] ids) + { + return toAjax(withdrawalConfigService.deleteWithdrawalConfigByIds(ids)); + } +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/withdrawalconfig/entity/WithdrawalConfig.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/withdrawalconfig/entity/WithdrawalConfig.java new file mode 100644 index 0000000..ed1e650 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/withdrawalconfig/entity/WithdrawalConfig.java @@ -0,0 +1,77 @@ +package com.ruoyi.frequency.withdrawalconfig.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import lombok.Data; +import lombok.experimental.Accessors; + +import java.math.BigDecimal; + +/** + * 提现配置对象 t_withdrawal_config + * + * @author liwenlong + * @date 2023-07-20 + */ +@Data +@Accessors(chain = true) +@TableName("t_withdrawal_config") +public class WithdrawalConfig extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** 唯一标识 */ + private Long id; + + + + /** 删除标识 1 正常 2 删除 3 禁用 */ + private Integer delFlag; + + /** 最低提现金额(小于等于0表示不限制) */ + @Excel(name = "最低提现金额(小于等于0表示不限制)") + private BigDecimal minPrice; + + /** 一次最高提现金额(小于等于0表示不限制) */ + @Excel(name = "一次最高提现金额(小于等于0表示不限制)") + private BigDecimal maxPrice; + + /** 每日最高提现(小于等于0表示不限制) */ + @Excel(name = "每日最高提现(小于等于0表示不限制)") + private BigDecimal dayMaxPrice; + + /** 每月最高提现(小于等于0表示不限制) */ + @Excel(name = "每月最高提现(小于等于0表示不限制)") + private BigDecimal monthMaxPrice; + + /** 每年最高提现(小于等于0表示不限制) */ + @Excel(name = "每年最高提现(小于等于0表示不限制)") + private BigDecimal yearMaxPrice; + + /** 每日最多提现次数 */ + @Excel(name = "每日最多提现次数") + private Integer dayMaxTimes; + + /** 每月最多提现次数(小于等于0表示不限制) */ + @Excel(name = "每月最多提现次数(小于等于0表示不限制)") + private Integer monthMaxTimes; + + /** 每年最多提现次数(小于等于0表示不限制) */ + @Excel(name = "每年最多提现次数(小于等于0表示不限制)") + private Integer yearMaxTimes; + + /** 每月可以提现开始时间(小于等于0表示不限制) */ + @Excel(name = "每月可以提现开始时间(小于等于0表示不限制)") + private Integer monthRangeMin; + + /** 每月可以提现结束时间(小于等于0表示不限制) */ + @Excel(name = "每月可以提现结束时间(小于等于0表示不限制)") + private Integer monthRangeMax; + + /** 用户类型 1 用户 2 3 .... */ + @Excel(name = "用户类型 1 用户 2 3 ....") + private Integer userType; + + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/withdrawalconfig/mapper/WithdrawalConfigMapper.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/withdrawalconfig/mapper/WithdrawalConfigMapper.java new file mode 100644 index 0000000..2c0141b --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/withdrawalconfig/mapper/WithdrawalConfigMapper.java @@ -0,0 +1,67 @@ +package com.ruoyi.frequency.withdrawalconfig.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.ruoyi.frequency.withdrawalconfig.entity.WithdrawalConfig; +import com.ruoyi.vo.UserVo; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * 提现配置Mapper接口 + * + * @author liwenlong + * @date 2023-07-20 + */ +public interface WithdrawalConfigMapper extends BaseMapper +{ + /** + * 查询提现配置 + * + * @param id 提现配置主键 + * @return 提现配置 + */ + WithdrawalConfig selectWithdrawalConfigById(Long id); + + /** + * 查询提现配置列表 + * + * @param withdrawalConfig 提现配置 + * @return 提现配置集合 + */ + List selectWithdrawalConfigList(WithdrawalConfig withdrawalConfig); + + /** + * 新增提现配置 + * + * @param withdrawalConfig 提现配置 + * @return 结果 + */ + int insertWithdrawalConfig(WithdrawalConfig withdrawalConfig); + + /** + * 修改提现配置 + * + * @param withdrawalConfig 提现配置 + * @return 结果 + */ + int updateWithdrawalConfig(WithdrawalConfig withdrawalConfig); + + /** + * 删除提现配置 + * + * @param id 提现配置主键 + * @return 结果 + */ + int deleteWithdrawalConfigById(Long id); + + /** + * 批量删除提现配置 + * + * @param ids 需要删除的数据主键集合 + * @return 结果 + */ + int deleteWithdrawalConfigByIds(Long[] ids); + + WithdrawalConfig getWithdrawalData(@Param("userVo") UserVo userVo); +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/withdrawalconfig/mapper/mapping/WithdrawalConfigMapper.xml b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/withdrawalconfig/mapper/mapping/WithdrawalConfigMapper.xml new file mode 100644 index 0000000..8b0a976 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/withdrawalconfig/mapper/mapping/WithdrawalConfigMapper.xml @@ -0,0 +1,207 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + select id, create_by, create_time, update_by, update_time, del_flag, min_price, max_price, day_max_price, month_max_price, year_max_price, day_max_times, month_max_times, year_max_times, month_range_min, month_range_max, user_type from t_withdrawal_config + + + + + + + + insert into t_withdrawal_config + + id, + create_by, + create_time, + update_by, + update_time, + del_flag, + min_price, + max_price, + day_max_price, + month_max_price, + year_max_price, + day_max_times, + month_max_times, + year_max_times, + month_range_min, + month_range_max, + user_type, + + + #{id}, + #{createBy}, + #{createTime}, + #{updateBy}, + #{updateTime}, + #{delFlag}, + #{minPrice}, + #{maxPrice}, + #{dayMaxPrice}, + #{monthMaxPrice}, + #{yearMaxPrice}, + #{dayMaxTimes}, + #{monthMaxTimes}, + #{yearMaxTimes}, + #{monthRangeMin}, + #{monthRangeMax}, + #{userType}, + + + + + update t_withdrawal_config + + create_by = #{createBy}, + create_time = #{createTime}, + update_by = #{updateBy}, + update_time = #{updateTime}, + del_flag = #{delFlag}, + min_price = #{minPrice}, + max_price = #{maxPrice}, + day_max_price = #{dayMaxPrice}, + month_max_price = #{monthMaxPrice}, + year_max_price = #{yearMaxPrice}, + day_max_times = #{dayMaxTimes}, + month_max_times = #{monthMaxTimes}, + year_max_times = #{yearMaxTimes}, + month_range_min = #{monthRangeMin}, + month_range_max = #{monthRangeMax}, + user_type = #{userType}, + + where id = #{id} + + + + delete from t_withdrawal_config where id = #{id} + + + + delete from t_withdrawal_config where id in + + #{id} + + + + + + \ No newline at end of file diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/withdrawalconfig/model/param/WithdrawalConfigParam.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/withdrawalconfig/model/param/WithdrawalConfigParam.java new file mode 100644 index 0000000..5ef83b9 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/withdrawalconfig/model/param/WithdrawalConfigParam.java @@ -0,0 +1,90 @@ +package com.ruoyi.frequency.withdrawalconfig.model.param; + +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import lombok.Data; +import lombok.experimental.Accessors; + +import java.math.BigDecimal; + +/** + * 提现配置对象 t_withdrawal_config + * + * @author liwenlong + * @date 2023-07-20 + */ +@Data +@Accessors(chain = true) +public class WithdrawalConfigParam extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** 唯一标识 */ + private Long id; + + + + /** 删除标识 1 正常 2 删除 3 禁用 */ + private Integer delFlag; + + /** 最低提现金额(小于等于0表示不限制) */ + @Excel(name = "最低提现金额(小于等于0表示不限制)") + private BigDecimal minPrice; + + /** 一次最高提现金额(小于等于0表示不限制) */ + @Excel(name = "一次最高提现金额(小于等于0表示不限制)") + private BigDecimal maxPrice; + + /** 每日最高提现(小于等于0表示不限制) */ + @Excel(name = "每日最高提现(小于等于0表示不限制)") + private BigDecimal dayMaxPrice; + + /** 每月最高提现(小于等于0表示不限制) */ + @Excel(name = "每月最高提现(小于等于0表示不限制)") + private BigDecimal monthMaxPrice; + + /** 每年最高提现(小于等于0表示不限制) */ + @Excel(name = "每年最高提现(小于等于0表示不限制)") + private BigDecimal yearMaxPrice; + + /** 每日最多提现次数 */ + @Excel(name = "每日最多提现次数") + private Integer dayMaxTimes; + + /** 每月最多提现次数(小于等于0表示不限制) */ + @Excel(name = "每月最多提现次数(小于等于0表示不限制)") + private Integer monthMaxTimes; + + /** 每年最多提现次数(小于等于0表示不限制) */ + @Excel(name = "每年最多提现次数(小于等于0表示不限制)") + private Integer yearMaxTimes; + + /** 每月可以提现开始时间(小于等于0表示不限制) */ + @Excel(name = "每月可以提现开始时间(小于等于0表示不限制)") + private Integer monthRangeMin; + + /** 每月可以提现结束时间(小于等于0表示不限制) */ + @Excel(name = "每月可以提现结束时间(小于等于0表示不限制)") + private Integer monthRangeMax; + + /** 用户类型 1 用户 2 3 .... */ + @Excel(name = "用户类型 1 用户 2 3 ....") + private Integer userType; + + + + + + + + + + + + + + + + + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/withdrawalconfig/model/result/WithdrawalConfigResult.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/withdrawalconfig/model/result/WithdrawalConfigResult.java new file mode 100644 index 0000000..6063b4a --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/withdrawalconfig/model/result/WithdrawalConfigResult.java @@ -0,0 +1,75 @@ +package com.ruoyi.frequency.withdrawalconfig.model.result; + +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import lombok.Data; +import lombok.experimental.Accessors; + +import java.math.BigDecimal; + +/** + * 提现配置对象 t_withdrawal_config + * + * @author liwenlong + * @date 2023-07-20 + */ +@Data +@Accessors(chain = true) +public class WithdrawalConfigResult extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** 唯一标识 */ + private Long id; + + + + /** 删除标识 1 正常 2 删除 3 禁用 */ + private Integer delFlag; + + /** 最低提现金额(小于等于0表示不限制) */ + @Excel(name = "最低提现金额(小于等于0表示不限制)") + private BigDecimal minPrice; + + /** 一次最高提现金额(小于等于0表示不限制) */ + @Excel(name = "一次最高提现金额(小于等于0表示不限制)") + private BigDecimal maxPrice; + + /** 每日最高提现(小于等于0表示不限制) */ + @Excel(name = "每日最高提现(小于等于0表示不限制)") + private BigDecimal dayMaxPrice; + + /** 每月最高提现(小于等于0表示不限制) */ + @Excel(name = "每月最高提现(小于等于0表示不限制)") + private BigDecimal monthMaxPrice; + + /** 每年最高提现(小于等于0表示不限制) */ + @Excel(name = "每年最高提现(小于等于0表示不限制)") + private BigDecimal yearMaxPrice; + + /** 每日最多提现次数 */ + @Excel(name = "每日最多提现次数") + private Integer dayMaxTimes; + + /** 每月最多提现次数(小于等于0表示不限制) */ + @Excel(name = "每月最多提现次数(小于等于0表示不限制)") + private Integer monthMaxTimes; + + /** 每年最多提现次数(小于等于0表示不限制) */ + @Excel(name = "每年最多提现次数(小于等于0表示不限制)") + private Integer yearMaxTimes; + + /** 每月可以提现开始时间(小于等于0表示不限制) */ + @Excel(name = "每月可以提现开始时间(小于等于0表示不限制)") + private Integer monthRangeMin; + + /** 每月可以提现结束时间(小于等于0表示不限制) */ + @Excel(name = "每月可以提现结束时间(小于等于0表示不限制)") + private Integer monthRangeMax; + + /** 用户类型 1 用户 2 3 .... */ + @Excel(name = "用户类型 1 用户 2 3 ....") + private Integer userType; + + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/withdrawalconfig/service/WithdrawalConfigService.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/withdrawalconfig/service/WithdrawalConfigService.java new file mode 100644 index 0000000..8b9bcba --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/withdrawalconfig/service/WithdrawalConfigService.java @@ -0,0 +1,67 @@ +package com.ruoyi.frequency.withdrawalconfig.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.ruoyi.frequency.withdrawalconfig.entity.WithdrawalConfig; +import com.ruoyi.vo.UserVo; + +import java.math.BigDecimal; +import java.util.List; + +/** + * 提现配置Service接口 + * + * @author liwenlong + * @date 2023-07-20 + */ +public interface WithdrawalConfigService extends IService +{ + /** + * 查询提现配置 + * + * @param id 提现配置主键 + * @return 提现配置 + */ + WithdrawalConfig selectWithdrawalConfigById(Long id); + + /** + * 查询提现配置列表 + * + * @param withdrawalConfig 提现配置 + * @return 提现配置集合 + */ + List selectWithdrawalConfigList(WithdrawalConfig withdrawalConfig); + + /** + * 新增提现配置 + * + * @param withdrawalConfig 提现配置 + * @return 结果 + */ + int insertWithdrawalConfig(WithdrawalConfig withdrawalConfig); + + /** + * 修改提现配置 + * + * @param withdrawalConfig 提现配置 + * @return 结果 + */ + int updateWithdrawalConfig(WithdrawalConfig withdrawalConfig); + + /** + * 批量删除提现配置 + * + * @param ids 需要删除的提现配置主键集合 + * @return 结果 + */ + int deleteWithdrawalConfigByIds(Long[] ids); + + /** + * 删除提现配置信息 + * + * @param id 提现配置主键 + * @return 结果 + */ + int deleteWithdrawalConfigById(Long id); + + void withdrawalJudge(UserVo userVo, BigDecimal amount); +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/withdrawalconfig/service/impl/WithdrawalConfigServiceImpl.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/withdrawalconfig/service/impl/WithdrawalConfigServiceImpl.java new file mode 100644 index 0000000..3554a1a --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/withdrawalconfig/service/impl/WithdrawalConfigServiceImpl.java @@ -0,0 +1,145 @@ +package com.ruoyi.frequency.withdrawalconfig.service.impl; + +import cn.hutool.core.date.DateUtil; +import cn.hutool.core.util.ObjectUtil; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.ruoyi.code.DictConstant; +import com.ruoyi.common.core.domain.entity.SysDictData; +import com.ruoyi.common.exception.CustomException; +import com.ruoyi.common.utils.DateUtils; +import com.ruoyi.frequency.withdrawalconfig.entity.WithdrawalConfig; +import com.ruoyi.frequency.withdrawalconfig.mapper.WithdrawalConfigMapper; +import com.ruoyi.frequency.withdrawalconfig.service.WithdrawalConfigService; +import com.ruoyi.utils.BusinessUtil; +import com.ruoyi.vo.UserVo; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.math.BigDecimal; +import java.util.Date; +import java.util.List; + +/** + * 提现配置Service业务层处理 + * + * @author liwenlong + * @date 2023-07-20 + */ +@Service +public class WithdrawalConfigServiceImpl extends ServiceImpl implements WithdrawalConfigService +{ + @Autowired + private WithdrawalConfigMapper withdrawalConfigMapper; + + /** + * 查询提现配置 + * + * @param id 提现配置主键 + * @return 提现配置 + */ + @Override + public WithdrawalConfig selectWithdrawalConfigById(Long id) + { + return withdrawalConfigMapper.selectWithdrawalConfigById(id); + } + + /** + * 查询提现配置列表 + * + * @param withdrawalConfig 提现配置 + * @return 提现配置 + */ + @Override + public List selectWithdrawalConfigList(WithdrawalConfig withdrawalConfig) + { + return withdrawalConfigMapper.selectWithdrawalConfigList(withdrawalConfig); + } + + /** + * 新增提现配置 + * + * @param withdrawalConfig 提现配置 + * @return 结果 + */ + @Override + public int insertWithdrawalConfig(WithdrawalConfig withdrawalConfig) + { + withdrawalConfig.setCreateTime(DateUtils.getNowDate()); + return withdrawalConfigMapper.insertWithdrawalConfig(withdrawalConfig); + } + + /** + * 修改提现配置 + * + * @param withdrawalConfig 提现配置 + * @return 结果 + */ + @Override + public int updateWithdrawalConfig(WithdrawalConfig withdrawalConfig) + { + withdrawalConfig.setUpdateTime(DateUtils.getNowDate()); + return withdrawalConfigMapper.updateWithdrawalConfig(withdrawalConfig); + } + + /** + * 批量删除提现配置 + * + * @param ids 需要删除的提现配置主键 + * @return 结果 + */ + @Override + public int deleteWithdrawalConfigByIds(Long[] ids) + { + return withdrawalConfigMapper.deleteWithdrawalConfigByIds(ids); + } + + /** + * 删除提现配置信息 + * + * @param id 提现配置主键 + * @return 结果 + */ + @Override + public int deleteWithdrawalConfigById(Long id) + { + return withdrawalConfigMapper.deleteWithdrawalConfigById(id); + } + + + @Autowired + private BusinessUtil businessUtil; + + @Override + public void withdrawalJudge(UserVo userVo, BigDecimal amount) { + + SysDictData dict = businessUtil.getDict(DictConstant.提现日期); + + if (dict == null || ObjectUtil.isEmpty(dict.getDictValue())){ + return; + } + + String[] split = dict.getDictValue().split("~"); + + //每月可以提现开始时间(小于等于0表示不限制) + Integer monthRangeMin = Integer.valueOf(split[0]); + + //每月可以提现结束时间(小于等于0表示不限制) + Integer monthRangeMax = Integer.valueOf(split[1]); + + if (monthRangeMin != null && monthRangeMax != null && monthRangeMin > 0 && monthRangeMax > 0) { + //获取日期 + String minDay = monthRangeMin.toString().length()==1?"0"+monthRangeMin:monthRangeMin.toString(); + //转换时间 + Date minDate = DateUtil.parse(DateUtil.format(new Date(),"yyyy-MM-"+minDay), "yyyy-MM-dd"); + + //获取日期 + String maxDay = monthRangeMax.toString().length()==1?"0"+monthRangeMax:monthRangeMax.toString(); + //转换时间 + Date maxDate = DateUtil.parse(DateUtil.format(new Date(),"yyyy-MM-"+maxDay), "yyyy-MM-dd"); + + if (DateUtil.beginOfDay(minDate).getTime()> System.currentTimeMillis() || DateUtil.endOfDay(maxDate).getTime() < System.currentTimeMillis()){ + throw new CustomException("提现只能在每月的" +monthRangeMin+ "~"+monthRangeMax+"号申请"); + } + } + } +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/withdrawalrecord/controller/WithdrawalRecordController.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/withdrawalrecord/controller/WithdrawalRecordController.java new file mode 100644 index 0000000..f5e3f0d --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/withdrawalrecord/controller/WithdrawalRecordController.java @@ -0,0 +1,121 @@ +package com.ruoyi.frequency.withdrawalrecord.controller; + +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.page.TableDataInfo; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.common.utils.poi.ExcelUtil; +import com.ruoyi.frequency.withdrawalrecord.entity.WithdrawalRecord; +import com.ruoyi.frequency.withdrawalrecord.model.result.WithdrawalRecordCount; +import com.ruoyi.frequency.withdrawalrecord.service.WithdrawalRecordService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +/** + * 提现记录Controller + * + * @author liwenlong + * @date 2023-07-20 + */ +@RestController +@RequestMapping("/frequency/withdrawalrecord") +public class WithdrawalRecordController extends BaseController +{ + @Autowired + private WithdrawalRecordService withdrawalRecordService; + + /** + * 查询提现记录列表 + */ + @PreAuthorize("@ss.hasPermi('frequency:withdrawalrecord:list')") + @PostMapping("/list") + public TableDataInfo list(@RequestBody WithdrawalRecord withdrawalRecord) + { + startPage(); + List list = withdrawalRecordService.selectWithdrawalRecordList(withdrawalRecord); + return getDataTable(list); + } + + /** + * 统计 + */ + @PostMapping("/statistics") + public AjaxResult statistics(@RequestBody WithdrawalRecord withdrawalRecord) + { + WithdrawalRecordCount count = withdrawalRecordService.statistics(withdrawalRecord); + return AjaxResult.success(count); + } + + + /** + * 导出提现记录列表 + */ + @PreAuthorize("@ss.hasPermi('frequency:withdrawalrecord:export')") + @Log(title = "提现记录", businessType = BusinessType.EXPORT) + @GetMapping("/export") + public AjaxResult export(WithdrawalRecord withdrawalRecord) + { + List list = withdrawalRecordService.selectWithdrawalRecordList(withdrawalRecord); + ExcelUtil util = new ExcelUtil(WithdrawalRecord.class); + return util.exportExcel(list, "提现记录数据"); + } + + /** + * 获取提现记录详细信息 + */ + @PreAuthorize("@ss.hasPermi('frequency:withdrawalrecord:query')") + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") Long id) + { + return AjaxResult.success(withdrawalRecordService.selectWithdrawalRecordById(id)); + } + + /** + * 新增提现记录 + */ + @PreAuthorize("@ss.hasPermi('frequency:withdrawalrecord:add')") + @Log(title = "提现记录", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody WithdrawalRecord withdrawalRecord) + { + return toAjax(withdrawalRecordService.insertWithdrawalRecord(withdrawalRecord)); + } + + /** + * 修改提现记录 + */ + @PreAuthorize("@ss.hasPermi('frequency:withdrawalrecord:edit')") + @Log(title = "提现记录", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody WithdrawalRecord withdrawalRecord) + { + return toAjax(withdrawalRecordService.updateWithdrawalRecord(withdrawalRecord)); + } + + /** + * 删除提现记录 + */ + @PreAuthorize("@ss.hasPermi('frequency:withdrawalrecord:remove')") + @Log(title = "提现记录", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}") + public AjaxResult remove(@PathVariable Long[] ids) + { + return toAjax(withdrawalRecordService.deleteWithdrawalRecordByIds(ids)); + } + + + /** + * 提现审核 + */ + @PreAuthorize("@ss.hasPermi('frequency:withdrawalrecord:process')") + @Log(title = "提现记录", businessType = BusinessType.UPDATE) + @PostMapping("/process") + public AjaxResult process(@RequestBody WithdrawalRecord withdrawalRecord) + { + return withdrawalRecordService.process(withdrawalRecord); + } +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/withdrawalrecord/entity/WithdrawalRecord.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/withdrawalrecord/entity/WithdrawalRecord.java new file mode 100644 index 0000000..c59b3d2 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/withdrawalrecord/entity/WithdrawalRecord.java @@ -0,0 +1,140 @@ +package com.ruoyi.frequency.withdrawalrecord.entity; + +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableName; +import com.fasterxml.jackson.annotation.JsonFormat; +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import com.ruoyi.frequency.klkwithdrawalrecord.entity.KlkWithdrawalRecord; +import com.ruoyi.vo.UserInfo; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; + +import java.math.BigDecimal; +import java.util.Date; + +/** + * 提现记录对象 t_withdrawal_record + * + * @author liwenlong + * @date 2023-07-20 + */ +@Data +@Accessors(chain = true) +@TableName("t_withdrawal_record") +public class WithdrawalRecord extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** 租户号 */ + private Long id; + + + + /** 删除标识;1 正常 2 删除 3 禁用 */ + private Integer delFlag; + + /** 用户类型;1 普通用户 2 师傅 */ + @Excel(name = "用户类型;1 普通用户 2 师傅") + private Integer userType; + + /** 用户id */ + @Excel(name = "用户id") + private Long userId; + + /** 转账金额 */ + @Excel(name = "转账金额") + private BigDecimal price; + + /** 手续费 */ + @Excel(name = "手续费") + private BigDecimal serviceCharge; + + /** 用户备注 */ + @Excel(name = "用户备注") + private String remarks; + + /** 状态1审核中2审核通过3审核失败 */ + @Excel(name = "状态1审核中2审核通过3审核失败4-转账中5-已转账") + private Integer status; + + /** 转账凭证 */ + @Excel(name = "转账凭证") + private String transferVoucher; + + /** 失败原因 */ + @Excel(name = "失败原因") + private String refuseReason; + + /** 提现方式ID */ + @Excel(name = "提现方式ID") + private Long wiId; + + /** 扣款 */ + @Excel(name = "扣款") + private BigDecimal violationDeduction; + + + @ApiModelProperty("开户行") + @Excel(name = "开户行") + private String bank; + + @ApiModelProperty("开户支行") + @Excel(name = "开户支行") + private String subbranch; + + @ApiModelProperty("银行卡") + @Excel(name = "银行卡") + private String bankCard; + + @ApiModelProperty("姓名") + private String fullName; + + @ApiModelProperty("银行卡Id") + private Long bankCardId; + + @ApiModelProperty("用户信息") + @TableField(exist = false) + private UserInfo userInfo; + + + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @ApiModelProperty("审核时间") + private Date processTime; + + @ApiModelProperty("姓名") + @TableField(exist = false) + private String name; + + @ApiModelProperty("开始时间") + @TableField(exist = false) + private Date beginTime; + + @ApiModelProperty("结束时间") + @TableField(exist = false) + private Date endTime; + + + @ApiModelProperty("开始时间") + @TableField(exist = false) + private Date processBeginTime; + + @ApiModelProperty("结束时间") + @TableField(exist = false) + private Date processEndTime; + + /** 转账金额 */ + @Excel(name = "转账金额") + @TableField(exist = false) + private BigDecimal amount; + + /** 总金额 */ + @Excel(name = "总金额") + private BigDecimal totalAmount; + + @TableField(exist = false) + @ApiModelProperty("拉卡拉提现记录") + private KlkWithdrawalRecord klkWithdrawalRecord; + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/withdrawalrecord/mapper/WithdrawalRecordMapper.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/withdrawalrecord/mapper/WithdrawalRecordMapper.java new file mode 100644 index 0000000..5c56a9e --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/withdrawalrecord/mapper/WithdrawalRecordMapper.java @@ -0,0 +1,80 @@ +package com.ruoyi.frequency.withdrawalrecord.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.ruoyi.controller.req.WithdrawalRecordPageReq; +import com.ruoyi.controller.resp.WithdrawalRecordPageResp; +import com.ruoyi.controller.resp.WithdrawalRecordPageTimeResp; +import com.ruoyi.frequency.withdrawalrecord.entity.WithdrawalRecord; +import com.ruoyi.frequency.withdrawalrecord.model.result.WithdrawalRecordCount; +import com.ruoyi.vo.UserVo; +import org.apache.ibatis.annotations.Param; + +import java.math.BigDecimal; +import java.util.List; + +/** + * 提现记录Mapper接口 + * + * @author liwenlong + * @date 2023-07-20 + */ +public interface WithdrawalRecordMapper extends BaseMapper +{ + /** + * 查询提现记录 + * + * @param id 提现记录主键 + * @return 提现记录 + */ + WithdrawalRecord selectWithdrawalRecordById(Long id); + + /** + * 查询提现记录列表 + * + * @param withdrawalRecord 提现记录 + * @return 提现记录集合 + */ + List selectWithdrawalRecordList(WithdrawalRecord withdrawalRecord); + + /** + * 新增提现记录 + * + * @param withdrawalRecord 提现记录 + * @return 结果 + */ + int insertWithdrawalRecord(WithdrawalRecord withdrawalRecord); + + /** + * 修改提现记录 + * + * @param withdrawalRecord 提现记录 + * @return 结果 + */ + int updateWithdrawalRecord(WithdrawalRecord withdrawalRecord); + + /** + * 删除提现记录 + * + * @param id 提现记录主键 + * @return 结果 + */ + int deleteWithdrawalRecordById(Long id); + + /** + * 批量删除提现记录 + * + * @param ids 需要删除的数据主键集合 + * @return 结果 + */ + int deleteWithdrawalRecordByIds(Long[] ids); + + + Page withdrawalRecordTimePage(@Param("page") Page page, @Param("req") WithdrawalRecordPageReq req, @Param("userVo") UserVo userVo); + + WithdrawalRecordPageResp getDetail(@Param("id") Long id); + + BigDecimal withdrawnAmount(@Param("userVo") UserVo userVo); + + WithdrawalRecordCount statistics(@Param("list") List withdrawalRecordIdList); +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/withdrawalrecord/mapper/mapping/WithdrawalRecordMapper.xml b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/withdrawalrecord/mapper/mapping/WithdrawalRecordMapper.xml new file mode 100644 index 0000000..1278f24 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/withdrawalrecord/mapper/mapping/WithdrawalRecordMapper.xml @@ -0,0 +1,268 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + select + t.id , + t.create_by , + t.create_time , + t.update_by , + t.update_time , + t.del_flag , + t.user_type, + t.user_id , + t.price , + t.service_charge , + t.remarks , + t.status , + t.transfer_voucher , + t.refuse_reason , + t.violation_deduction, + t.wi_id, + t.bank, + t.subbranch, + t.bank_card, + t.full_name, + case when h.id is not null then h.name else a.name end as name, + t.process_time + from t_withdrawal_record AS t + LEFT JOIN t_store AS s ON s.id = t.user_id and t.user_type = 2 + LEFT JOIN t_sale AS sa ON sa.id = t.user_id and t.user_type = 3 + LEFT JOIN t_highend_auth h ON t.user_id = h.store_id and t.user_type = 2 and h.status >= 3 and h.del_flag = 1 + LEFT JOIN t_auth a ON t.user_id = a.store_id and a.del_flag = 1 and t.user_type = 2 + + + + + + + + + + insert into t_withdrawal_record + + id, + create_by, + create_time, + update_by, + update_time, + del_flag, + user_type, + user_id, + price, + service_charge, + remarks, + status, + transfer_voucher, + refuse_reason, + wi_id, + + + #{id}, + #{createBy}, + #{createTime}, + #{updateBy}, + #{updateTime}, + #{delFlag}, + #{userType}, + #{userId}, + #{price}, + #{serviceCharge}, + #{remarks}, + #{status}, + #{transferVoucher}, + #{refuseReason}, + #{wiId}, + + + + + update t_withdrawal_record + + create_by = #{createBy}, + create_time = #{createTime}, + update_by = #{updateBy}, + update_time = #{updateTime}, + del_flag = #{delFlag}, + user_type = #{userType}, + user_id = #{userId}, + price = #{price}, + service_charge = #{serviceCharge}, + remarks = #{remarks}, + status = #{status}, + transfer_voucher = #{transferVoucher}, + refuse_reason = #{refuseReason}, + wi_id = #{wiId}, + + where id = #{id} + + + + delete from t_withdrawal_record where id = #{id} + + + + delete from t_withdrawal_record where id in + + #{id} + + + + + + + + + diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/withdrawalrecord/model/param/WithdrawalRecordParam.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/withdrawalrecord/model/param/WithdrawalRecordParam.java new file mode 100644 index 0000000..cf81d30 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/withdrawalrecord/model/param/WithdrawalRecordParam.java @@ -0,0 +1,80 @@ +package com.ruoyi.frequency.withdrawalrecord.model.param; + +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import lombok.Data; +import lombok.experimental.Accessors; + +import java.math.BigDecimal; + +/** + * 提现记录对象 t_withdrawal_record + * + * @author liwenlong + * @date 2023-07-20 + */ +@Data +@Accessors(chain = true) +public class WithdrawalRecordParam extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** 租户号 */ + private Long id; + + + + /** 删除标识;1 正常 2 删除 3 禁用 */ + private Integer delFlag; + + /** 用户类型;1 普通用户 2 师傅 */ + @Excel(name = "用户类型;1 普通用户 2 师傅") + private Integer userType; + + /** 用户id */ + @Excel(name = "用户id") + private Long userId; + + /** 转账金额 */ + @Excel(name = "转账金额") + private BigDecimal price; + + /** 手续费 */ + @Excel(name = "手续费") + private BigDecimal serviceCharge; + + /** 用户备注 */ + @Excel(name = "用户备注") + private String remarks; + + /** 状态1审核中2审核通过3审核失败 */ + @Excel(name = "状态1审核中2审核通过3审核失败") + private Integer status; + + /** 转账凭证 */ + @Excel(name = "转账凭证") + private String transferVoucher; + + /** 失败原因 */ + @Excel(name = "失败原因") + private String refuseReason; + + /** 提现方式ID */ + @Excel(name = "提现方式ID") + private Long wiId; + + + + + + + + + + + + + + + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/withdrawalrecord/model/result/WithdrawalRecordCount.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/withdrawalrecord/model/result/WithdrawalRecordCount.java new file mode 100644 index 0000000..142be27 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/withdrawalrecord/model/result/WithdrawalRecordCount.java @@ -0,0 +1,30 @@ +package com.ruoyi.frequency.withdrawalrecord.model.result; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.math.BigDecimal; + +/** + * @author a + * @date 2024/2/22 10:32 + */ +@Data +public class WithdrawalRecordCount { + + @ApiModelProperty("提现记录数") + private Integer total; + + @ApiModelProperty("提现金额") + private BigDecimal amount; + + @ApiModelProperty("手续费") + private BigDecimal serviceCharge; + + @ApiModelProperty("扣款") + private BigDecimal violationDeduction; + + @ApiModelProperty("到账金额") + private BigDecimal price; + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/withdrawalrecord/model/result/WithdrawalRecordResult.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/withdrawalrecord/model/result/WithdrawalRecordResult.java new file mode 100644 index 0000000..fa648a4 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/withdrawalrecord/model/result/WithdrawalRecordResult.java @@ -0,0 +1,67 @@ +package com.ruoyi.frequency.withdrawalrecord.model.result; + +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import lombok.Data; +import lombok.experimental.Accessors; + +import java.math.BigDecimal; + +/** + * 提现记录对象 t_withdrawal_record + * + * @author liwenlong + * @date 2023-07-20 + */ +@Data +@Accessors(chain = true) +public class WithdrawalRecordResult extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** 租户号 */ + private Long id; + + + + /** 删除标识;1 正常 2 删除 3 禁用 */ + private Integer delFlag; + + /** 用户类型;1 普通用户 2 师傅 */ + @Excel(name = "用户类型;1 普通用户 2 师傅") + private Integer userType; + + /** 用户id */ + @Excel(name = "用户id") + private Long userId; + + /** 转账金额 */ + @Excel(name = "转账金额") + private BigDecimal price; + + /** 手续费 */ + @Excel(name = "手续费") + private BigDecimal serviceCharge; + + /** 用户备注 */ + @Excel(name = "用户备注") + private String remarks; + + /** 状态1审核中2审核通过3审核失败 */ + @Excel(name = "状态1审核中2审核通过3审核失败") + private Integer status; + + /** 转账凭证 */ + @Excel(name = "转账凭证") + private String transferVoucher; + + /** 失败原因 */ + @Excel(name = "失败原因") + private String refuseReason; + + /** 提现方式ID */ + @Excel(name = "提现方式ID") + private Long wiId; + + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/withdrawalrecord/service/WithdrawalRecordService.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/withdrawalrecord/service/WithdrawalRecordService.java new file mode 100644 index 0000000..99a8d1a --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/withdrawalrecord/service/WithdrawalRecordService.java @@ -0,0 +1,105 @@ +package com.ruoyi.frequency.withdrawalrecord.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.controller.req.WithApplyReq; +import com.ruoyi.controller.req.WithdrawalRecordPageReq; +import com.ruoyi.frequency.withdrawalrecord.entity.WithdrawalRecord; +import com.ruoyi.frequency.withdrawalrecord.model.result.WithdrawalRecordCount; +import com.ruoyi.response.ResponseData; +import com.ruoyi.vo.PageBasic; +import com.ruoyi.vo.UserVo; + +import java.util.List; + +/** + * 提现记录Service接口 + * + * @author liwenlong + * @date 2023-07-20 + */ +public interface WithdrawalRecordService extends IService +{ + /** + * 查询提现记录 + * + * @param id 提现记录主键 + * @return 提现记录 + */ + WithdrawalRecord selectWithdrawalRecordById(Long id); + + /** + * 查询提现记录列表 + * + * @param withdrawalRecord 提现记录 + * @return 提现记录集合 + */ + List selectWithdrawalRecordList(WithdrawalRecord withdrawalRecord); + + + WithdrawalRecordCount statistics(WithdrawalRecord withdrawalRecord); + /** + * 新增提现记录 + * + * @param withdrawalRecord 提现记录 + * @return 结果 + */ + int insertWithdrawalRecord(WithdrawalRecord withdrawalRecord); + + /** + * 修改提现记录 + * + * @param withdrawalRecord 提现记录 + * @return 结果 + */ + int updateWithdrawalRecord(WithdrawalRecord withdrawalRecord); + + /** + * 批量删除提现记录 + * + * @param ids 需要删除的提现记录主键集合 + * @return 结果 + */ + int deleteWithdrawalRecordByIds(Long[] ids); + + /** + * 删除提现记录信息 + * + * @param id 提现记录主键 + * @return 结果 + */ + int deleteWithdrawalRecordById(Long id); + + /** + * 提现审核 + * @param withdrawalRecord + * @return + */ + AjaxResult process(WithdrawalRecord withdrawalRecord); + + /** + * 申请提现 + * @param req + * @param userVo + * @return + */ + ResponseData apply(WithApplyReq req, UserVo userVo); + + + /** + * 提现记录 + * @param req + * @param userVo + * @return + */ + ResponseData withdrawalRecordPage(WithdrawalRecordPageReq req, UserVo userVo); + + + /** + * 提现详情 + * @param id 提现记录id + * @return + */ + ResponseData getDetail(Long id); + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/withdrawalrecord/service/impl/WithdrawalRecordServiceImpl.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/withdrawalrecord/service/impl/WithdrawalRecordServiceImpl.java new file mode 100644 index 0000000..866c49f --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/frequency/withdrawalrecord/service/impl/WithdrawalRecordServiceImpl.java @@ -0,0 +1,504 @@ +package com.ruoyi.frequency.withdrawalrecord.service.impl; + +import cn.hutool.core.collection.CollectionUtil; +import cn.hutool.core.date.DateUtil; +import cn.hutool.core.util.ObjectUtil; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.ruoyi.code.DictConstant; +import com.ruoyi.code.PublicCommon; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.domain.BaseEntity; +import com.ruoyi.common.core.domain.entity.SysDictData; +import com.ruoyi.common.exception.CustomException; +import com.ruoyi.common.exception.enums.CoreExceptionEnum; +import com.ruoyi.common.utils.DateUtils; +import com.ruoyi.controller.req.WithApplyReq; +import com.ruoyi.controller.req.WithdrawalRecordPageReq; +import com.ruoyi.controller.resp.WithdrawalRecordPageResp; +import com.ruoyi.enums.PlatformRecordEnums; +import com.ruoyi.enums.WalletDetailEnums; +import com.ruoyi.enums.message.AppMessageEnums; +import com.ruoyi.enums.process.ProcessResultEnums; +import com.ruoyi.enums.user.UserEnums; +import com.ruoyi.frequency.appmessage.service.AppMessageService; +import com.ruoyi.frequency.customer.service.UserService; +import com.ruoyi.frequency.illegaldeductionrecord.service.IllegalDeductionRecordService; +import com.ruoyi.frequency.klkwithdrawalrecord.entity.KlkWithdrawalRecord; +import com.ruoyi.frequency.klkwithdrawalrecord.service.KlkWithdrawalRecordService; +import com.ruoyi.frequency.platformrecord.service.PlatformRecordService; +import com.ruoyi.frequency.sale.entity.Sale; +import com.ruoyi.frequency.sale.service.SaleService; +import com.ruoyi.frequency.store.entity.Store; +import com.ruoyi.frequency.store.service.StoreService; +import com.ruoyi.frequency.userwithdrawalway.service.UserWithdrawalWayService; +import com.ruoyi.frequency.userwithdrawalwaywi.service.UserWithdrawalWayWiService; +import com.ruoyi.frequency.wallerecord.mapper.WalletRecordMapper; +import com.ruoyi.frequency.wallerecord.service.WalletRecordService; +import com.ruoyi.frequency.withdrawalconfig.service.WithdrawalConfigService; +import com.ruoyi.frequency.withdrawalrecord.entity.WithdrawalRecord; +import com.ruoyi.frequency.withdrawalrecord.mapper.WithdrawalRecordMapper; +import com.ruoyi.frequency.withdrawalrecord.model.result.WithdrawalRecordCount; +import com.ruoyi.frequency.withdrawalrecord.service.WithdrawalRecordService; +import com.ruoyi.klk.service.KlkService; +import com.ruoyi.response.ResponseData; +import com.ruoyi.utils.BusinessUtil; +import com.ruoyi.vo.UserInfo; +import com.ruoyi.vo.UserVo; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.math.BigDecimal; +import java.util.*; +import java.util.stream.Collectors; + +/** + * 提现记录Service业务层处理 + * + * @author liwenlong + * @date 2023-07-20 + */ +@Service +public class WithdrawalRecordServiceImpl extends ServiceImpl implements WithdrawalRecordService { + @Autowired + private WithdrawalRecordMapper withdrawalRecordMapper; + + /** + * 查询提现记录 + * + * @param id 提现记录主键 + * @return 提现记录 + */ + @Override + public WithdrawalRecord selectWithdrawalRecordById(Long id) { + + WithdrawalRecord withdrawalRecord = withdrawalRecordMapper.selectWithdrawalRecordById(id); + + if (withdrawalRecord != null) { + withdrawalRecord.setName(withdrawalRecord.getFullName()); + Set userVoSet = CollectionUtil.newHashSet(new UserVo(withdrawalRecord.getUserType(), withdrawalRecord.getUserId())); + + //查询用户信息 + Map userMap = userService.selectUserInfoMap(userVoSet, null); + + withdrawalRecord.setUserInfo(userMap.get(new UserVo(withdrawalRecord.getUserType(), withdrawalRecord.getUserId()))); + } + return withdrawalRecord; + } + + @Autowired + private UserService userService; + + /** + * 查询提现记录列表 + * + * @param withdrawalRecord 提现记录 + * @return 提现记录 + */ + @Override + public List selectWithdrawalRecordList(WithdrawalRecord withdrawalRecord) { + + List withdrawalRecords = withdrawalRecordList(withdrawalRecord); + + if (withdrawalRecords != null && withdrawalRecords.size() > 0) { + + Set userVoSet = withdrawalRecords.stream().map(s -> new UserVo(s.getUserType(), s.getUserId())).collect(Collectors.toSet()); + + //查询用户信息 + Map userMap = userService.selectUserInfoMap(userVoSet, null); + + withdrawalRecords.stream().forEach(s -> { + s.setUserInfo(userMap.get(new UserVo(s.getUserType(), s.getUserId()))); + }); + } + + return withdrawalRecords; + } + + private List withdrawalRecordList(WithdrawalRecord withdrawalRecord) { + List withdrawalRecords = withdrawalRecordMapper.selectWithdrawalRecordList(withdrawalRecord); + return withdrawalRecords; + } + + @Override + public WithdrawalRecordCount statistics(WithdrawalRecord withdrawalRecord) { + List withdrawalRecords = withdrawalRecordList(withdrawalRecord); + List withdrawalRecordIdList = withdrawalRecords.stream().map(x -> x.getId()).collect(Collectors.toList()); + withdrawalRecordIdList.add(-1L); + return withdrawalRecordMapper.statistics(withdrawalRecordIdList); + } + + /** + * 新增提现记录 + * + * @param withdrawalRecord 提现记录 + * @return 结果 + */ + @Override + public int insertWithdrawalRecord(WithdrawalRecord withdrawalRecord) { + withdrawalRecord.setCreateTime(DateUtils.getNowDate()); + return withdrawalRecordMapper.insertWithdrawalRecord(withdrawalRecord); + } + + /** + * 修改提现记录 + * + * @param withdrawalRecord 提现记录 + * @return 结果 + */ + @Override + public int updateWithdrawalRecord(WithdrawalRecord withdrawalRecord) { + withdrawalRecord.setUpdateTime(DateUtils.getNowDate()); + return withdrawalRecordMapper.updateWithdrawalRecord(withdrawalRecord); + } + + /** + * 批量删除提现记录 + * + * @param ids 需要删除的提现记录主键 + * @return 结果 + */ + @Override + public int deleteWithdrawalRecordByIds(Long[] ids) { + return withdrawalRecordMapper.deleteWithdrawalRecordByIds(ids); + } + + /** + * 删除提现记录信息 + * + * @param id 提现记录主键 + * @return 结果 + */ + @Override + public int deleteWithdrawalRecordById(Long id) { + return withdrawalRecordMapper.deleteWithdrawalRecordById(id); + } + + + @Autowired + private KlkService klkService; + + @Autowired + private KlkWithdrawalRecordService klkWithdrawalRecordService; + + @Override + public AjaxResult process(WithdrawalRecord withdrawalRecord) { + + this.lambdaUpdate().set(WithdrawalRecord::getStatus, withdrawalRecord.getStatus()) + .set(WithdrawalRecord::getRefuseReason, withdrawalRecord.getRefuseReason()) + .set(WithdrawalRecord::getTransferVoucher, withdrawalRecord.getTransferVoucher()) + .set(WithdrawalRecord::getProcessTime, new Date()) + .eq(WithdrawalRecord::getId, withdrawalRecord.getId()) + .update(); + + WithdrawalRecord byId = this.getById(withdrawalRecord.getId()); + + //审核失败 提现返还 + if (ObjectUtil.equal(ProcessResultEnums.REJECTED.getCode(), withdrawalRecord.getStatus())) { + + //修改用户余额,添加余额记录 + walletRecordService.updateBalance(new UserVo(byId.getUserType(), byId.getUserId()), WalletDetailEnums.WITH_FAIL_RETURN, withdrawalRecord.getId(), byId.getPrice().add(byId.getServiceCharge()).add(byId.getViolationDeduction()), PublicCommon.Wallet.可提现); + + //平台流水 + platformRecordService.addPlatformRecord(new UserVo(byId.getUserType(), byId.getUserId()), byId.getId(), byId.getPrice().add(byId.getServiceCharge()).add(byId.getViolationDeduction()), PlatformRecordEnums.WITH_FAIL_RETURN); + + if (ObjectUtil.equal(UserEnums.store.getCode(), byId.getUserType())) { + //返还扣款金额 + illegalDeductionRecordService.updateViolationDeduction(byId.getUserId(), byId.getId(), byId.getViolationDeduction(), 4, null, null, null); + + //平台流水 + platformRecordService.addPlatformRecord(new UserVo(byId.getUserType(), byId.getUserId()), byId.getId(), byId.getViolationDeduction(), PlatformRecordEnums.VIOLATION_DEDUCTION_RETURN); + } + } + + //提现结果提醒 + if (ObjectUtil.equal(ProcessResultEnums.APPROVED.getCode(), withdrawalRecord.getStatus())) { + //审核失败 提现返还 + appMessageService.addAppMessage(new UserVo(byId.getUserType(), byId.getUserId()), byId.getId(), AppMessageEnums.WITHDRAWAL_SUCCESS); + + } else { + //审核失败 提现返还 + appMessageService.addAppMessage(new UserVo(byId.getUserType(), byId.getUserId()), byId.getId(), AppMessageEnums.WITHDRAWAL_FAIL); + } + + WithdrawalRecord withdrawalRecordDB = getById(withdrawalRecord.getId()); + + if (withdrawalRecordDB.getPrice() == null || withdrawalRecordDB.getPrice().compareTo(BigDecimal.ZERO) == 0) { + // 将提现记录状态修改为4转账中 + withdrawalRecordMapper.update(null, new LambdaUpdateWrapper() + .eq(WithdrawalRecord::getDelFlag, PublicCommon.启用) + .eq(WithdrawalRecord::getId, byId.getId()) + .set(WithdrawalRecord::getStatus, 5)); + } else { + // 审核成功走下述逻辑 + if (withdrawalRecord.getStatus() == 2) { + // 审核成功,走后续的提现步骤 + klkService.withdrawal(byId); + + // 将提现记录状态修改为4转账中 + withdrawalRecordMapper.update(null, new LambdaUpdateWrapper() + .eq(WithdrawalRecord::getDelFlag, PublicCommon.启用) + .eq(WithdrawalRecord::getId, byId.getId()) + .set(WithdrawalRecord::getStatus, 4)); + } + + } + + return AjaxResult.success(); + } + + @Autowired + private AppMessageService appMessageService; + + @Autowired + private BusinessUtil businessUtil; + + @Autowired + private WithdrawalConfigService withdrawalConfigService; + + @Autowired + private WalletRecordService walletRecordService; + + + @Autowired + private WalletRecordMapper walletRecordMapper; + + @Autowired + private StoreService storeService; + + @Autowired + private IllegalDeductionRecordService illegalDeductionRecordService; + + + @Autowired + private PlatformRecordService platformRecordService; + + @Autowired + private SaleService saleService; + + + @Override + public ResponseData apply(WithApplyReq req, UserVo userVo) { + + //判断支付密码 + if (!businessUtil.payPwdTrue(userVo, req.getPayPwd())) { + return ResponseData.error(CoreExceptionEnum.PWD_ERROR); + } + + //提现判断 + withdrawalConfigService.withdrawalJudge(userVo, req.getAmount()); + + BigDecimal balance = BigDecimal.ZERO; + + switch (UserEnums.getUserEnums(userVo.getUserType())) { + case store: + //可提现用户余额 + Date beginOfMonth = DateUtil.beginOfMonth(new Date()); + balance = walletRecordMapper.selectMonthBeforeAmount(beginOfMonth, userVo); + break; + case sale: + Sale sale = saleService.getById(userVo.getUserId()); + balance = sale.getBalance(); + break; + default: + break; + } + + req.setUserType(userVo.getUserType()); + //计算手续费 + BigDecimal serviceCharge = getServiceCharge(req, balance); + + //扣款 + BigDecimal violationDeduction = BigDecimal.ZERO; + + if (ObjectUtil.equal(UserEnums.store.getCode(), userVo.getUserType())) { + + Store store = storeService.getById(userVo.getUserId()); + + //扣除手续费 金额 + BigDecimal price = req.getAmount().subtract(serviceCharge); + + violationDeduction = store.getViolationDeduction().compareTo(price) == 1 + ? price : store.getViolationDeduction(); + } + + + //提现记录 + Long withDrawlRecordId = createWithDrawlRecord(userVo, req, serviceCharge, violationDeduction); + + //修改用户余额,添加余额记录 + walletRecordService.updateBalance(userVo, WalletDetailEnums.WITH_DEDU, withDrawlRecordId, req.getAmount().negate(), PublicCommon.Wallet.可提现); + + //平台流水 + platformRecordService.addPlatformRecord(userVo, withDrawlRecordId, req.getAmount().negate(), PlatformRecordEnums.WITH_DEDU); + + if (ObjectUtil.equal(UserEnums.store.getCode(), userVo.getUserType())) { + + //扣除扣款金额 + illegalDeductionRecordService.updateViolationDeduction(userVo.getUserId(), withDrawlRecordId, violationDeduction.negate(), 3, null, null, null); + + //平台流水 + platformRecordService.addPlatformRecord(userVo, withDrawlRecordId, violationDeduction, PlatformRecordEnums.VIOLATION_DEDUCTION); + + } + + return ResponseData.success(withDrawlRecordId); + } + + public static void main(String[] args) { + System.out.println(new Date(1717171200000L)); + } + + @Override + public ResponseData withdrawalRecordPage(WithdrawalRecordPageReq req, UserVo userVo) { + + LambdaUpdateWrapper lambdaUpdateWrapper = new LambdaUpdateWrapper<>(); + lambdaUpdateWrapper.eq(WithdrawalRecord::getUserId, userVo.getUserId()); + lambdaUpdateWrapper.eq(WithdrawalRecord::getUserType, userVo.getUserType()); + if (req.getBeginTime() != null) { + lambdaUpdateWrapper.ge(BaseEntity::getCreateTime, req.getBeginTime()); + } + if (req.getEndTime() != null) { + lambdaUpdateWrapper.le(BaseEntity::getCreateTime, req.getEndTime()); + } + lambdaUpdateWrapper.eq(WithdrawalRecord::getDelFlag, PublicCommon.启用); + lambdaUpdateWrapper.orderByDesc(BaseEntity::getCreateTime); + + List withdrawalRecordList = this.baseMapper.selectList(lambdaUpdateWrapper); + //按月筛选 + Map> withdrawaMap = new LinkedHashMap<>(); + + Map klkWithdrawalRecordMap = new HashMap<>(); + + List withdrawalIdList = withdrawalRecordList.stream().map(x -> x.getId()).collect(Collectors.toList()); + if (CollectionUtil.isNotEmpty(withdrawalIdList)) { + List klkWithdrawalRecordList = klkWithdrawalRecordService.list(new QueryWrapper().lambda(). + in(KlkWithdrawalRecord::getWithdrawalRecordId, withdrawalIdList)); + + klkWithdrawalRecordList.stream().forEach(x -> { + klkWithdrawalRecordMap.put(x.getWithdrawalRecordId(), x); + }); + + } + + if (CollectionUtil.isNotEmpty(withdrawalRecordList)) { + for (WithdrawalRecord cur : withdrawalRecordList) { + cur.setAmount(cur.getPrice()); + cur.setKlkWithdrawalRecord(klkWithdrawalRecordMap.get(cur.getId())); + String yearMonth = DateUtil.year(cur.getCreateTime()) + "年" + (DateUtil.month(cur.getCreateTime()) + 1) + "月"; + if (!withdrawaMap.containsKey(yearMonth)) { + withdrawaMap.put(yearMonth, new ArrayList<>()); + } + withdrawaMap.get(yearMonth).add(cur); + } + + } + List resultList = new ArrayList<>(); + Iterator>> iterator = withdrawaMap.entrySet().iterator(); + while (iterator.hasNext()) { + Map.Entry> next = iterator.next(); + Map map = new HashMap(); + map.put("date", next.getKey()); + map.put("list", next.getValue()); + resultList.add(map); + } + + return ResponseData.success(resultList); + } + + @Override + public ResponseData getDetail(Long id) { + + WithdrawalRecordPageResp detail = baseMapper.getDetail(id); + KlkWithdrawalRecord klkWithdrawalRecord = klkWithdrawalRecordService.getOne(new QueryWrapper().lambda().eq(KlkWithdrawalRecord::getWithdrawalRecordId, id)); + detail.setKlkWithdrawalRecord(klkWithdrawalRecord); + + if (klkWithdrawalRecord != null) { + detail.setTransferFinishTime(klkWithdrawalRecord.getTransferFinishTime()); + } + return ResponseData.success(detail); + } + + + private BigDecimal getServiceCharge(WithApplyReq req, BigDecimal totalPrice) { + //提现手续费(比例) + BigDecimal commission; + + SysDictData one = null; + + switch (UserEnums.getUserEnums(req.getUserType())) { + case store: + //提现手续费字典 + one = businessUtil.getDict(DictConstant.提现手续费); + break; + case sale: + one = businessUtil.getDict(DictConstant.推广员提现手续费); + break; + default: + break; + } + + if (one == null) { + throw new CustomException(CoreExceptionEnum.NO_DICTIONARIES); + } + try { + commission = new BigDecimal(one.getDictValue()); + } catch (Exception e) { + throw new CustomException(CoreExceptionEnum.DICTIONARIES_ERROR); + } + + // 手续费 + BigDecimal subBalance = req.getAmount().multiply(commission); + + //判断余额 + if (totalPrice.compareTo(req.getAmount()) == -1) { + throw new CustomException(CoreExceptionEnum.BALANCE_INSUFFICIENT); + } + return subBalance; + } + + @Autowired + private UserWithdrawalWayService userWithdrawalWayService; + + @Autowired + private UserWithdrawalWayWiService userWithdrawalWayWiService; + + /** + * 提现记录 + * + * @param userVo + * @param req + * @param serviceCharge + * @return + */ + private Long createWithDrawlRecord(UserVo userVo, WithApplyReq req, BigDecimal serviceCharge, BigDecimal violationDeduction) { + +// //查询用户提现账号 +// UserWithdrawalWay userWithdrawalWay = userWithdrawalWayService.getById(req.getUserWWayId()); +// +// //记录这次提现的提现账号 +// UserWithdrawalWayWi withdrawalWayWi = userWithdrawalWayWiService.addUserWithdrawalWayWi(userWithdrawalWay); + + //提现记录 + WithdrawalRecord withdrawalRecord = new WithdrawalRecord() + .setUserId(userVo.getUserId()) + .setUserType(userVo.getUserType()) + .setPrice(req.getAmount().subtract(violationDeduction).subtract(serviceCharge)) + .setServiceCharge(serviceCharge) + .setTotalAmount(req.getAmount()) + .setDelFlag(PublicCommon.启用) + .setRemarks(req.getRemark()) + .setViolationDeduction(violationDeduction) + .setStatus(ProcessResultEnums.PENDING.getCode()) + .setBank(req.getBank()) + .setSubbranch(req.getSubbranch()) + .setBankCard(req.getBankCard()) + .setFullName(req.getFullName()) + .setBankCardId(req.getBankCardId()); + this.save(withdrawalRecord); + + return withdrawalRecord.getId(); + } + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/interceptor/LoginInterceptor.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/interceptor/LoginInterceptor.java new file mode 100644 index 0000000..c494e38 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/interceptor/LoginInterceptor.java @@ -0,0 +1,196 @@ +package com.ruoyi.interceptor; + +import cn.hutool.core.util.ObjectUtil; +import com.alibaba.fastjson.JSON; +import com.ruoyi.annotations.UserLoginToken; +import com.ruoyi.code.PublicCommon; +import com.ruoyi.code.Token; +import com.ruoyi.common.exception.ServiceException; +import com.ruoyi.common.exception.enums.RestExceptionEnum; +import com.ruoyi.common.utils.StringUtils; +import com.ruoyi.frequency.customer.entity.Customer; +import com.ruoyi.frequency.customer.mapper.CustomerMapper; +import com.ruoyi.frequency.sale.entity.Sale; +import com.ruoyi.frequency.sale.mapper.SaleMapper; +import com.ruoyi.frequency.store.entity.Store; +import com.ruoyi.frequency.store.mapper.StoreMapper; +import com.ruoyi.response.ErrorResponseData; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.redis.core.StringRedisTemplate; +import org.springframework.stereotype.Component; +import org.springframework.web.method.HandlerMethod; +import org.springframework.web.servlet.HandlerInterceptor; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.io.PrintWriter; +import java.lang.reflect.Method; +import java.util.Arrays; +import java.util.concurrent.TimeUnit; + + +/** + * 登陆拦截器 + */ +@Component +@Slf4j +public class LoginInterceptor implements HandlerInterceptor { + + @Autowired + private StringRedisTemplate redisTemplate; + + @Override + public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) { + + if (handler instanceof org.springframework.web.servlet.resource.ResourceHttpRequestHandler) { + return true; + } + // 如果不是映射到方法直接通过 + if (!(handler instanceof HandlerMethod)) { + return true; + } + HandlerMethod handlerMethod = (HandlerMethod) handler; + Method method = handlerMethod.getMethod(); + + //检查有没有需要用户权限的注解 + if (method.isAnnotationPresent(UserLoginToken.class)) { + return checkUserToken(request, response,method); + } + return true; + } + + /** + * 渲染json对象 + */ + private static void renderJson(HttpServletResponse response, Object jsonObject) { + try { + response.setContentType("application/json"); + response.setCharacterEncoding("UTF-8"); + PrintWriter writer = response.getWriter(); + writer.write(JSON.toJSONString(jsonObject)); + } catch (IOException e) { + throw new ServiceException(""); + } + } + + private boolean checkUserToken(HttpServletRequest request, HttpServletResponse response,Method method) { + String token = request.getHeader("token"); + + //请求头中没有token字段 + if (StringUtils.isEmpty(token)) { + renderJson(response, new ErrorResponseData( + RestExceptionEnum.TOKEN_EXPIRED.getCode(), RestExceptionEnum.TOKEN_EXPIRED.getMessage())); + return false; + } + + //根据token 获取用户id + String userId = redisTemplate.opsForValue().get(token); + + //用户id为空 + if (StringUtils.isBlank(userId)) { + renderJson(response, new ErrorResponseData( + RestExceptionEnum.TOKEN_EXPIRED.getCode(), RestExceptionEnum.TOKEN_EXPIRED.getMessage())); + return false; + } + + //判断当前接口有无权限 + Boolean verifyPermissions = verifyPermissions(method, token); + if (!verifyPermissions){ + renderJson(response, new ErrorResponseData( + RestExceptionEnum.TOKEN_EXPIRED.getCode(), RestExceptionEnum.TOKEN_EXPIRED.getMessage())); + return false; + } + + //验证登入用户是否合法 + Boolean verifyLoginUser = verifyLoginUser(token,userId); + if (!verifyLoginUser){ + renderJson(response, new ErrorResponseData( + RestExceptionEnum.TOKEN_EXPIRED.getCode(), RestExceptionEnum.TOKEN_EXPIRED.getMessage())); + return false; + } + + //验证当前token 是否有效 +// Object o = redisTemplate.opsForHash().get(Token.TOKEN_MAP, userId + ""); +// if (ObjectUtil.isNotEmpty(o)) { +// if (!token.equals(o.toString())) { +// renderJson(response, new ErrorResponseData( +// RestExceptionEnum.TOKEN_EXPIRED.getCode(), RestExceptionEnum.TOKEN_EXPIRED.getMessage())); +// return false; +// } +// } + + redisTemplate.opsForValue().set(token, userId, Token.EXPIRE_SECOND, TimeUnit.DAYS); + + return true; + } + + + @Autowired + private CustomerMapper customerMapper; + + @Autowired + private StoreMapper storeMapper; + + @Autowired + private SaleMapper saleMapper; + + /** + * 验证登入用户是否合法 + */ + private Boolean verifyLoginUser(String token,String userId) { + + if (!token.startsWith(Token.customer) && !token.startsWith(Token.store) && !token.startsWith(Token.sale)&& !token.startsWith(Token.enterprise)){ + return false; + } + + if (token.startsWith(Token.customer)) { + //验证用户有没有被禁用删除 + Customer customer = customerMapper.selectById(Long.valueOf(userId)); + return customer != null && customer.getDelFlag().equals(PublicCommon.启用); + }else if(token.startsWith(Token.store)){ + //验证商家有没有被禁用删除 + Store store = storeMapper.selectById(Long.valueOf(userId)); + return store != null && store.getDelFlag().equals(PublicCommon.启用); + }else if(token.startsWith(Token.sale)){ + //验证商家有没有被禁用删除 + Sale sale = saleMapper.selectById(Long.valueOf(userId)); + return sale != null && sale.getDelFlag().equals(PublicCommon.启用); + }else if(token.startsWith(Token.enterprise)){ +// //验证商家有没有被禁用删除 +// Store store = storeMapper.selectById(Long.valueOf(userId)); +// return store != null && store.getDelFlag().equals(PublicCommon.启用); + } + + return true; + } + + /** + * 判断当前接口有无权限 + * @param method + */ + private Boolean verifyPermissions(Method method,String token) { + String[] userTokenPres = method.getAnnotation(UserLoginToken.class).userTokenPre(); + if (userTokenPres.length > 0){ + long count = Arrays.stream(userTokenPres).filter(s -> { + //当前登入用户token前缀 + String tokenPre = ""; + if (token.startsWith(Token.customer)) { + tokenPre = Token.customer; + } else if (token.startsWith(Token.store)){ + tokenPre = Token.store; + }else if (token.startsWith(Token.sale)){ + tokenPre = Token.sale; + }else if (token.startsWith(Token.enterprise)){ + tokenPre = Token.enterprise; + } + return ObjectUtil.equal(s, tokenPre); + }).count(); + return count != 0; + } + return true; + } + +} + diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/klk/constant/KlkConstant.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/klk/constant/KlkConstant.java new file mode 100644 index 0000000..ca52a00 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/klk/constant/KlkConstant.java @@ -0,0 +1,46 @@ +package com.ruoyi.klk.constant; + +public class KlkConstant { + public static final String VERSION = "1.0"; + /** + * 机构代码:测试环境为1 + */ + public static final String ORG_CODE = "200007"; + + /** + * setOrgNo bmcp机构号 测试环境为1 + */ + public static final String ORG_NO = "200007"; + + /** + * 收款账户账户类型:57:对公 58:对私 + */ + public static final String ACC_TYPE = "58"; + + /** + * AcctCertificateType:收款账户证件类型 + * 17 身份证,18 护照,19 港澳居民来往内地通行证 20 台湾居民来往内地通行证 + */ + public static final String ACC_CERT_TYPE = "17"; + + + /** + * bindAccount 分账关系绑定结果回调地址 + */ + public static final String BIND_ACC_URL = "/api/notify/bindAccount"; + /** + * 提现结果回调地址 + */ + public static final String WITHDRAWAL = "/api/notify/withdrawal"; + + + + /** + * 分账状态 处理中:PROCESSING, 已受理:ACCEPTED, 成功:SUCCESS, 失败:FAIL + */ + public static final String PROCESSING = "PROCESSING"; + public static final String ACCEPTED = "ACCEPTED"; + public static final String SUCCESS = "SUCCESS"; + public static final String FAIL = "FAIL"; + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/klk/controller/KlkController.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/klk/controller/KlkController.java new file mode 100644 index 0000000..be1a2ff --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/klk/controller/KlkController.java @@ -0,0 +1,227 @@ +package com.ruoyi.klk.controller; + +import cn.hutool.core.date.DateUtil; +import cn.hutool.core.util.StrUtil; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.ruoyi.annotations.UserLoginToken; +import com.ruoyi.common.utils.PdfUtil; +import com.ruoyi.frequency.agreement.entity.Agreement; +import com.ruoyi.frequency.agreement.service.AgreementService; +import com.ruoyi.klk.controller.req.AddOrUpdateBankCardReq; +import com.ruoyi.klk.controller.req.AgreementReq; +import com.ruoyi.klk.controller.req.GetBankNameReq; +import com.ruoyi.klk.controller.resp.GetBankInfoResp; +import com.ruoyi.klk.service.KlkService; +import com.ruoyi.response.ResponseData; +import com.ruoyi.vo.RyController; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.apache.poi.util.Units; +import org.apache.poi.xwpf.usermodel.XWPFDocument; +import org.apache.poi.xwpf.usermodel.XWPFParagraph; +import org.apache.poi.xwpf.usermodel.XWPFRun; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.web.bind.annotation.*; + +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.util.Date; +import java.util.List; + +@CrossOrigin +@RestController +@RequestMapping("/api/klk") +@Api(tags = "拉卡拉相关") +public class KlkController extends RyController { + + @Autowired + private KlkService klkService; + + @Value("${lalkla.filePath}") + private String filePath; + + /** + * 查询开户行名称 + */ + @GetMapping("/test") + @ApiOperation(value = "查询开户行名称", notes = "查询开户行名称") + public ResponseData test() throws FileNotFoundException { + PdfUtil.doc2pdf(filePath+"1.docx", filePath+"1.pdf", filePath + "license.xml"); + return ResponseData.success(); + } + + /** + * 查询开户行名称 + */ + @PostMapping("/getBankName") + @UserLoginToken + @ApiOperation(value = "查询开户行名称", notes = "查询开户行名称") + public ResponseData getBankName(@RequestBody GetBankNameReq req) { + return klkService.getBankName(req); + } + + + /** + * 添加或修改银行卡信息 + */ + @PostMapping("/addOrUpdateBankCard") + @UserLoginToken + @ApiOperation(value = "添加或修改银行卡信息", notes = "添加或修改银行卡信息") + public ResponseData addOrUpdateBankCard(@RequestBody AddOrUpdateBankCardReq req) { + return klkService.addOrUpdateBankCard(req, getUserVo()); + } + + @Autowired + private AgreementService agreementService; + + /** + * 获取分账协议 + */ + @PostMapping("/agreement") + @UserLoginToken + @ApiOperation(value = "添加或修改银行卡信息", notes = "获取分账协议") + public ResponseData agreement(@RequestBody AgreementReq req) { + + if ("fzxy".equals(req.getCode())) { + + Agreement agreement = agreementService.getOne(new QueryWrapper().lambda().eq(Agreement::getCode, req.getCode())); + if (agreement == null) { + return ResponseData.success(); + } + String agreementStr = agreement.getContent(); + + Integer year = 5; + agreementStr = agreementStr.replace("${store.name}", (req.getAcctName() == null ? "" : req.getAcctName())); + agreementStr = agreementStr.replace("${store.idno}", (req.getAcctCertificateNo() == null ? "" : req.getAcctCertificateNo())); + agreementStr = agreementStr.replace("${year}", (year + "")); + agreementStr = agreementStr.replace("${beginYear}", (DateUtil.year(new Date()) + "")); + agreementStr = agreementStr.replace("${beginMonth}", (DateUtil.month(new Date()) + 1) + ""); + agreementStr = agreementStr.replace("${beginDay}", (DateUtil.dayOfMonth(new Date()) + "")); + + Date date = DateUtil.offsetMonth(new Date(), year * 12); + + agreementStr = agreementStr.replace("${endYear}", (DateUtil.year(date) + "")); + agreementStr = agreementStr.replace("${endMonth}", (DateUtil.month(date) + 1) + ""); + agreementStr = agreementStr.replace("${endDay}", (DateUtil.dayOfMonth(date) + "")); + + return ResponseData.success(agreementStr); + } else if ("sale_fzxy".equals(req.getCode())) { + Agreement agreement = agreementService.getOne(new QueryWrapper().lambda().eq(Agreement::getCode, req.getCode())); + if (agreement == null) { + return ResponseData.success(); + } + String agreementStr = agreement.getContent(); + Integer year = 5; + agreementStr = agreementStr.replace("${store.name}", (req.getAcctName() == null ? "" : req.getAcctName())); + agreementStr = agreementStr.replace("${store.idno}", (req.getAcctCertificateNo() == null ? "" : req.getAcctCertificateNo())); + agreementStr = agreementStr.replace("${year}", (year + "")); + agreementStr = agreementStr.replace("${beginYear}", (DateUtil.year(new Date()) + "")); + agreementStr = agreementStr.replace("${beginMonth}", (DateUtil.month(new Date()) + 1) + ""); + agreementStr = agreementStr.replace("${beginDay}", (DateUtil.dayOfMonth(new Date()) + "")); + + Date date = DateUtil.offsetMonth(new Date(), year * 12); + + agreementStr = agreementStr.replace("${endYear}", (DateUtil.year(date) + "")); + agreementStr = agreementStr.replace("${endMonth}", (DateUtil.month(date) + 1) + ""); + agreementStr = agreementStr.replace("${endDay}", (DateUtil.dayOfMonth(date) + "")); + + return ResponseData.success(agreementStr); + } else { + return ResponseData.success(); + } + } + + /** + * 获取银行卡信息 + */ + @PostMapping("/getBankInfo") + @UserLoginToken + @ApiOperation(value = "获取银行卡信息", notes = "获取银行卡信息") + public ResponseData getBankInfo() { + return klkService.getBankInfo(getUserVo()); + } + + + public static void convertHtmlToImage(String input, String outPut) throws Exception { + + // 创建XWPFDocument对象,加载Word文档 + XWPFDocument doc = new XWPFDocument(new FileInputStream(input)); + // 获取文档中的所有段落 + List paragraphs = doc.getParagraphs(); + + Integer year = 5; + + Date date = DateUtil.offsetMonth(new Date(), year * 12); + + // 遍历所有段落,找到需要修改的内容 + for (XWPFParagraph paragraph : paragraphs) { + if (StrUtil.isBlank(paragraph.getText())) { + continue; + } + List runs = paragraph.getRuns(); + for (XWPFRun run : runs) { + String text = run.text(); + if (StrUtil.isBlank(text)) { + continue; + } + String newText = text; + if (newText.contains("${store.name}")) { + newText = newText.replace("${store.name}", "张三"); + } + if (newText.contains("${store.idno}")) { + newText = newText.replace("${store.idno}", "342222199609110817"); + } + if (newText.contains("${year}")) { + newText = newText.replace("${year}", (year + "")); + } + if (newText.contains("${beginYear}")) { + newText = newText.replace("${beginYear}", (DateUtil.year(new Date()) + "")); + } + if (newText.contains("${beginMonth}")) { + newText = newText.replace("${beginMonth}", (DateUtil.month(new Date()) + 1) + ""); + } + if (newText.contains("${beginDay}")) { + newText = newText.replace("${beginDay}", (DateUtil.dayOfMonth(new Date()) + "")); + } + if (newText.contains("${endYear}")) { + newText = newText.replace("${endYear}", (DateUtil.year(date) + "")); + } + if (newText.contains("${endMonth}")) { + newText = newText.replace("${endMonth}", (DateUtil.month(date) + 1) + ""); + } + if (newText.contains("${endDay}")) { + newText = newText.replace("${endDay}", (DateUtil.dayOfMonth(date) + "")); + } + if (newText.contains("${endDay}")) { + newText = newText.replace("${endDay}", (DateUtil.dayOfMonth(date) + "")); + } + if (newText.contains("${date-qy}")) { + newText = newText.replace("${date-qy}", (DateUtil.formatDate(date) + "")); + } + run.setText(newText, 0); + } + String text = paragraph.getText(); + if (StrUtil.isNotBlank(text) && text.contains("签字/盖章")) { + // 图片文件 + FileInputStream imageStream = new FileInputStream("C:\\Users\\Administrator\\Pictures\\背.png"); + XWPFRun provincialInfoPicRun = paragraph.createRun(); + provincialInfoPicRun.addPicture(imageStream, 5, "", Units.toEMU(80), Units.toEMU(40)); + } + + } + // 保存修改后的文档 + FileOutputStream out = new FileOutputStream(outPut); + doc.write(out); + out.close(); + } + + + public static void main(String[] args) throws Exception { + String htmlFile = "G:\\input.docx"; + + String outputFile = "G:\\out.docx"; + convertHtmlToImage(htmlFile, outputFile); + } +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/klk/controller/req/AddOrUpdateBankCardReq.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/klk/controller/req/AddOrUpdateBankCardReq.java new file mode 100644 index 0000000..b2ea0b5 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/klk/controller/req/AddOrUpdateBankCardReq.java @@ -0,0 +1,74 @@ +package com.ruoyi.klk.controller.req; + +import lombok.Data; + +import java.util.List; + +/** + * 添加银行卡请求参数 + */ +@Data +public class AddOrUpdateBankCardReq { + /** + * id:用户标识是新增还是修改 + */ + private Long id; + + /** + * 姓名 + */ + private String acctName; + + /** + * 身份证号 + */ + private String acctCertificateNo; + + /** + * 卡号 + */ + private String acctNo; + + /** + * 开户行 + */ + private String acctOpenBankName; + + /** + * 签名 + */ + private String signature; + + /** + * 协议图片 + */ + private String cooperateAgreementImage; + + /** + * 附件资料 + */ + private List attachList; + + @Data + public static class Attach { + /** + * 附件类型:1-身份证正面 2-身份证反面 3-银行卡 4-营业执照 5-合作协议-纸质版 6-合作协议-电子版 + */ + private String attachType; + + /** + * 附件名称 + */ + private String attachName; + + /** + * 附件地址 + */ + private String attachStorePath; + + /** + * 前端不管 + */ + private String klkPath; + } +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/klk/controller/req/AgreementReq.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/klk/controller/req/AgreementReq.java new file mode 100644 index 0000000..321cc3e --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/klk/controller/req/AgreementReq.java @@ -0,0 +1,8 @@ +package com.ruoyi.klk.controller.req; + +import lombok.Data; + +@Data +public class AgreementReq extends AddOrUpdateBankCardReq{ + private String code; +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/klk/controller/req/GetBankNameReq.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/klk/controller/req/GetBankNameReq.java new file mode 100644 index 0000000..05169fd --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/klk/controller/req/GetBankNameReq.java @@ -0,0 +1,14 @@ +package com.ruoyi.klk.controller.req; + +import lombok.Data; + +/** + * 查询开户行名称请求参数 + */ +@Data +public class GetBankNameReq { + /** + * 卡号 + */ + private String cardNo; +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/klk/controller/req/UpdateBankCardReq.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/klk/controller/req/UpdateBankCardReq.java new file mode 100644 index 0000000..e9e6adb --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/klk/controller/req/UpdateBankCardReq.java @@ -0,0 +1,62 @@ +package com.ruoyi.klk.controller.req; + +import lombok.Data; + +import java.util.List; + +/** + * 分账接收方信息变更请求参数 + */ +@Data +public class UpdateBankCardReq { + + /** + * 姓名 + */ + private String acctName; + + /** + * 身份证号 + */ + private String acctCertificateNo; + + /** + * 卡号 + */ + private String acctNo; + + /** + * 开户行 + */ + private String acctOpenBankName; + + /** + * 附件资料 + */ + private List attachList; + + @Data + public static class Attach { + /** + * 附件类型:1-身份证正面 2-身份证反面 3-银行卡 4-营业执照 5-合作协议-纸质版 6-合作协议-电子版 + */ + private String attachType; + + /** + * 附件名称 + */ + private String attachName; + + /** + * 附件地址 + */ + private String attachStorePath; + + + + /** + * 前端不管 + */ + private String klkPath; + } +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/klk/controller/req/UploadFileReq.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/klk/controller/req/UploadFileReq.java new file mode 100644 index 0000000..85478b5 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/klk/controller/req/UploadFileReq.java @@ -0,0 +1,25 @@ +package com.ruoyi.klk.controller.req; + +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Data; + +/** + * 附件上传请求参数 + */ +@Data +public class UploadFileReq { + /** + * 1-身份证正面 2-身份证反面 3-银行卡 4-营业执照 5-合作协议-纸质版 6-合作协议-电子版 + */ + private String attType; + + /** + * 附件扩展名称:如 jpg | png | pdf + */ + private String attExtName; + + /** + * 附件内容:将文件内容转Base64字符串 + */ + private String attContext; +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/klk/controller/resp/GetBankInfoResp.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/klk/controller/resp/GetBankInfoResp.java new file mode 100644 index 0000000..a0b890a --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/klk/controller/resp/GetBankInfoResp.java @@ -0,0 +1,69 @@ +package com.ruoyi.klk.controller.resp; + +import lombok.Data; + +import java.util.List; + +/** + * 获取银行卡信息响应参数 + */ +@Data +public class GetBankInfoResp { + /** + * id + */ + private Long id; + + /** + * 姓名 + */ + private String acctName; + + /** + * 身份证号 + */ + private String acctCertificateNo; + + /** + * 卡号 + */ + private String acctNo; + + /** + * 开户行 + */ + private String acctOpenBankName; + + /** + * 绑定结果:1-审核中 2-审核失败 3-审核成功 -1-未提交审核 + */ + private Integer bindResult; + + /** + * 审核失败原因 + */ + private String auditFailReason; + + /** + * 附件资料 + */ + private List attachList; + + @Data + public static class Attach { + /** + * 附件类型:1-身份证正面 2-身份证反面 3-银行卡 4-营业执照 5-合作协议-纸质版 6-合作协议-电子版 + */ + private String attachType; + + /** + * 附件名称 + */ + private String attachName; + + /** + * 附件地址 + */ + private String attachStorePath; + } +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/klk/controller/resp/SelectBindResultResp.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/klk/controller/resp/SelectBindResultResp.java new file mode 100644 index 0000000..9f879cb --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/klk/controller/resp/SelectBindResultResp.java @@ -0,0 +1,24 @@ +package com.ruoyi.klk.controller.resp; + +import com.ruoyi.frequency.klkaccount.entity.KlkAccount; +import lombok.Data; + +/** + * 查询银行卡绑定结果响应参数 + */ +@Data +public class SelectBindResultResp { + /** + * 绑定结果:1-审核中 2-审核失败 3-审核成功 -1-未提交审核 + */ + private Integer bindResult; + + /** + * 审核失败原因 + */ + private String auditFailReason; + /** + * + */ + private KlkAccount klkAccount; +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/klk/notify/NotificationHandler.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/klk/notify/NotificationHandler.java new file mode 100644 index 0000000..455d80e --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/klk/notify/NotificationHandler.java @@ -0,0 +1,148 @@ +package com.ruoyi.klk.notify; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; +import com.lkl.laop.sdk.LKLSDK; +import com.ruoyi.code.PublicCommon; +import com.ruoyi.frequency.klkaccount.entity.KlkAccount; +import com.ruoyi.frequency.klkaccount.mapper.KlkAccountMapper; +import com.ruoyi.frequency.klkwithdrawalrecord.entity.KlkWithdrawalRecord; +import com.ruoyi.frequency.klkwithdrawalrecord.mapper.KlkWithdrawalRecordMapper; +import com.ruoyi.frequency.withdrawalrecord.entity.WithdrawalRecord; +import com.ruoyi.frequency.withdrawalrecord.mapper.WithdrawalRecordMapper; +import com.ruoyi.klk.util.CommonService; +import com.ruoyi.klk.util.InitUtil; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import javax.servlet.http.HttpServletRequest; +import java.util.Date; +import java.util.Map; + +@RestController +@RequestMapping("/api/notify") +@Slf4j +public class NotificationHandler { + + @Autowired + private KlkAccountMapper klkAccountMapper; + + @Autowired + private CommonService commonService; + + @Autowired + private InitUtil initUtil; + + /** + * 分账关系绑定结果回调处理 + * + * @param request + * @return + * @throws Exception + */ + @RequestMapping("/bindAccount") + public Map messageHandle(HttpServletRequest request) throws Exception { + log.info("分账关系绑定结果开始回调..."); + + // 1. 配置初始化 + initUtil.doInit(); + + //验签并解析请求 + String body = LKLSDK.notificationHandle(request); + + //业务处理 + JSONObject jsonObject = JSON.parseObject(body); + String receiverNo = jsonObject.getString("receiverNo"); + if ("1".equals(jsonObject.getString("auditStatus"))) { + // 绑定成功 + klkAccountMapper.update(null, new LambdaUpdateWrapper().set(KlkAccount::getBindStatus, 3) + .eq(KlkAccount::getReceiverNo, receiverNo)); + } else { + // 绑定失败 + klkAccountMapper.update(null, new LambdaUpdateWrapper().set(KlkAccount::getBindStatus, 4) + .set(KlkAccount::getBindFailReason, jsonObject.getString("remark")).eq(KlkAccount::getReceiverNo, receiverNo)); + } + + return commonService.getKlkCommonResp(); + } + + @Autowired + private KlkWithdrawalRecordMapper klkWithdrawalRecordMapper; + + @Autowired + private WithdrawalRecordMapper withdrawalRecordMapper; + + public static void main(String[] args) { + //验签并解析请求 + String body = "{\"ewalletId\":\"310031838650\",\"reqDate\":\"20240531\",\"payNo\":\"02001011010121915753\",\"payType\":\"04\",\"drawJnl\":\"240531154102568001176346\",\"drawAmt\":\"2.60\",\"drawFee\":\"0.00\",\"bankId\":\"392405317919539283\",\"acctNo\":\"621485******8533\",\"acctName\":\"*耀\",\"acctType\":\"2\",\"nbkName\":\"招商银行\",\"mercId\":\"SR2024000026603\",\"drawState\":\"DRAW.SUCCESS\",\"drawStateDesc\":\"提款成功\",\"drawMode\":\"D1\",\"batchAutoSettle\":\"01\",\"batchNo\":\"\",\"merOrgNo\":\"100012\",\"merOrderNo\":\"\",\"settleNo\":\"202406010602390002720722\",\"completeTime\":\"2024-06-01 06:02:58\",\"memo\":\"结算成功\",\"createdTime\":\"2024-05-31 15:41:02\",\"refund\":\"0\",\"bankNo\":\"03080000\",\"bankName\":\"招商银行\",\"clearingBankCode\":\"03080000\",\"remark\":\"\",\"summary\":\"\",\"skPrepayAmt\":\"2.60\",\"skDrawFee\":\"0.00\",\"zfPrepayAmt\":\"0.00\",\"zfDrawFee\":\"0.00\",\"zfPrepaySeq\":\"\",\"zfPayNo\":\"\"}"; + + + //业务处理 + JSONObject respData = JSON.parseObject(body); + String drawJnl = respData.getString("drawJnl"); + System.out.println(drawJnl); + } + + /** + * 提现结果回调处理 + * + * @param request + * @return + * @throws Exception + */ + @RequestMapping("/withdrawal") + public Map withdrawal(HttpServletRequest request) throws Exception { + log.info("提现结果开始回调..."); + + // 1. 配置初始化 + initUtil.doInit(); + + //验签并解析请求 + String body = LKLSDK.notificationHandle(request); + + //业务处理 + JSONObject respData = JSON.parseObject(body); + String drawJnl = respData.getString("drawJnl"); + Integer withdrawalStatus = getWithdrawalStatus(respData.getString("drawState")); + klkWithdrawalRecordMapper.update(null, new LambdaUpdateWrapper() + .eq(KlkWithdrawalRecord::getDelFlag, PublicCommon.启用) + .eq(KlkWithdrawalRecord::getDrawJnl, drawJnl) + .set(KlkWithdrawalRecord::getWithdrawalStatus, withdrawalStatus) + .set(KlkWithdrawalRecord::getWithdrawalRemark, respData.getString("memo"))); + // 如果提现成功则修改提现状态 + if (withdrawalStatus == 3) { + klkWithdrawalRecordMapper.update(null, new LambdaUpdateWrapper() + .set(KlkWithdrawalRecord::getTransferFinishTime, new Date()) + .eq(KlkWithdrawalRecord::getDrawJnl, drawJnl)); + KlkWithdrawalRecord klkWithdrawalRecord = klkWithdrawalRecordMapper.selectOne(new LambdaQueryWrapper() + .eq(KlkWithdrawalRecord::getDelFlag, PublicCommon.启用) + .eq(KlkWithdrawalRecord::getDrawJnl, drawJnl)); + withdrawalRecordMapper.update(null, new LambdaUpdateWrapper() + .set(WithdrawalRecord::getStatus, 5) + .eq(WithdrawalRecord::getId, klkWithdrawalRecord.getWithdrawalRecordId())); + } + + return commonService.getKlkCommonResp(); + } + + private Integer getWithdrawalStatus(String drawState) { + //提现状态:1-处理中 2-已受理 3-成功 4-失败 5-冻结 -1-未关联卡拉卡平台 + if ("DRAW.PROCESSING".equals(drawState)) { + return 1; + } else if ("DRAW.ACCEPTED".equals(drawState)) { + return 2; + } else if ("DRAW.SUCCESS".equals(drawState)) { + return 3; + } else if ("DRAW.FAILED".equals(drawState)) { + return 4; + } else if ("DRAW.FREEZE".equals(drawState)) { + return 5; + } else { + return -1; + } + } +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/klk/service/KlkService.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/klk/service/KlkService.java new file mode 100644 index 0000000..f0cfe35 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/klk/service/KlkService.java @@ -0,0 +1,41 @@ +package com.ruoyi.klk.service; + +import com.ruoyi.frequency.withdrawalrecord.entity.WithdrawalRecord; +import com.ruoyi.klk.controller.req.AddOrUpdateBankCardReq; +import com.ruoyi.klk.controller.req.GetBankNameReq; +import com.ruoyi.klk.controller.resp.GetBankInfoResp; +import com.ruoyi.klk.controller.resp.SelectBindResultResp; +import com.ruoyi.response.ResponseData; +import com.ruoyi.vo.UserVo; + +public interface KlkService { + + /** + * 添加或修改银行卡信息 + */ + ResponseData addOrUpdateBankCard(AddOrUpdateBankCardReq req, UserVo userVo); + + /** + * 查询开户行名称 + */ + ResponseData getBankName(GetBankNameReq req); + + /** + * 获取银行卡信息 + */ + ResponseData getBankInfo(UserVo userVo); + + /** + * 提现 + */ + void withdrawal(WithdrawalRecord withdrawalRecord); + + Integer getBalanceSplitStatus(String status); + + /** + * 查询银行卡是否绑定成功 + * @param userVo + * @return + */ + ResponseData selectBindResult(UserVo userVo); +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/klk/service/impl/KlkServiceImpl.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/klk/service/impl/KlkServiceImpl.java new file mode 100644 index 0000000..4716265 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/klk/service/impl/KlkServiceImpl.java @@ -0,0 +1,819 @@ +package com.ruoyi.klk.service.impl; + +import cn.hutool.core.collection.CollectionUtil; +import cn.hutool.core.date.DateUtil; +import cn.hutool.core.util.StrUtil; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; +import com.lkl.laop.sdk.LKLSDK; +import com.lkl.laop.sdk.request.*; +import com.lkl.laop.sdk.utils.CommonUtil; +import com.ruoyi.code.PublicCommon; +import com.ruoyi.common.exception.ServiceException; +import com.ruoyi.common.utils.ImageRotator; +import com.ruoyi.common.utils.PdfUtil; +import com.ruoyi.enums.user.UserEnums; +import com.ruoyi.frequency.customer.entity.Customer; +import com.ruoyi.frequency.customer.mapper.CustomerMapper; +import com.ruoyi.frequency.klkaccounattach.entity.KlkAccountAttach; +import com.ruoyi.frequency.klkaccounattach.service.KlkAccountAttachService; +import com.ruoyi.frequency.klkaccount.entity.KlkAccount; +import com.ruoyi.frequency.klkaccount.mapper.KlkAccountMapper; +import com.ruoyi.frequency.klkwithdrawalrecord.entity.KlkWithdrawalRecord; +import com.ruoyi.frequency.klkwithdrawalrecord.mapper.KlkWithdrawalRecordMapper; +import com.ruoyi.frequency.sale.entity.Sale; +import com.ruoyi.frequency.sale.mapper.SaleMapper; +import com.ruoyi.frequency.store.entity.Store; +import com.ruoyi.frequency.store.mapper.StoreMapper; +import com.ruoyi.frequency.withdrawalrecord.entity.WithdrawalRecord; +import com.ruoyi.frequency.withdrawalrecord.mapper.WithdrawalRecordMapper; +import com.ruoyi.klk.constant.KlkConstant; +import com.ruoyi.klk.controller.req.AddOrUpdateBankCardReq; +import com.ruoyi.klk.controller.req.GetBankNameReq; +import com.ruoyi.klk.controller.req.UpdateBankCardReq; +import com.ruoyi.klk.controller.req.UploadFileReq; +import com.ruoyi.klk.controller.resp.GetBankInfoResp; +import com.ruoyi.klk.controller.resp.SelectBindResultResp; +import com.ruoyi.klk.service.KlkService; +import com.ruoyi.klk.util.CommonService; +import com.ruoyi.klk.util.InitUtil; +import com.ruoyi.response.ResponseData; +import com.ruoyi.utils.BusinessUtil; +import com.ruoyi.vo.UserVo; +import lombok.SneakyThrows; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.io.FileUtils; +import org.apache.poi.util.Units; +import org.apache.poi.xwpf.usermodel.XWPFDocument; +import org.apache.poi.xwpf.usermodel.XWPFParagraph; +import org.apache.poi.xwpf.usermodel.XWPFRun; +import org.springframework.beans.BeanUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.scheduling.annotation.Async; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.math.BigDecimal; +import java.net.URL; +import java.util.*; +import java.util.stream.Collectors; + +@Service +@Transactional(rollbackFor = Exception.class) +@Slf4j +public class KlkServiceImpl implements KlkService { + + @Value("${basepath.url}") + private String urlPrefix; + + @Autowired + private CommonService commonService; + + /** + * 附件上传 + */ + public String uploadFile(UploadFileReq req) { + try { + initUtil.doInit(); + V2MmsOpenApiUploadFile v2MmsOpenApiUploadFile = new V2MmsOpenApiUploadFile(); + v2MmsOpenApiUploadFile.setVersion(KlkConstant.VERSION); + v2MmsOpenApiUploadFile.setOrderNo(CommonUtil.getOrderNo()); + v2MmsOpenApiUploadFile.setOrgCode(KlkConstant.ORG_CODE); + v2MmsOpenApiUploadFile.setAttType(req.getAttType()); + v2MmsOpenApiUploadFile.setAttExtName(req.getAttExtName()); + v2MmsOpenApiUploadFile.setAttContext(req.getAttContext()); + String response = LKLSDK.httpPost(v2MmsOpenApiUploadFile); + // 解析结果 + JSONObject jsonObject = JSON.parseObject(response); + if ("000000".equals(jsonObject.getString("retCode"))) { + JSONObject respData = jsonObject.getJSONObject("respData"); + return respData.getString("attFileId"); + } + } catch (Exception e) { + log.error("附件上传出现异常:{}", e.getMessage()); + } + throw new RuntimeException(); + } + + /** + * 添加或修改银行卡信息 + */ + @Override + public ResponseData addOrUpdateBankCard(AddOrUpdateBankCardReq req, UserVo userVo) { + + // 如果当前银行卡绑定失败,则删除数据库记录 + KlkAccount klkAccount = klkAccountMapper.selectOne(new LambdaQueryWrapper() + .eq(KlkAccount::getDelFlag, PublicCommon.启用) + .eq(KlkAccount::getUserType, userVo.getUserType()) + .eq(KlkAccount::getUserId, userVo.getUserId())); + if (klkAccount != null && klkAccount.getBindStatus() != 3) { + klkAccountAttachService.getBaseMapper().delete(new LambdaQueryWrapper() + .eq(KlkAccountAttach::getDelFlag, PublicCommon.启用) + .eq(KlkAccountAttach::getLakalaAccountId, klkAccount.getId())); + klkAccountMapper.deleteById(klkAccount.getId()); + req.setId(null); + } + + + // 根据上传id判断是新增还是修改 + if (req.getId() == null) { + //新增 + return addBankCard(req, userVo); + } else { + //修改 + UpdateBankCardReq updateReq = new UpdateBankCardReq(); + BeanUtils.copyProperties(req, updateReq); + return updateBankCard(updateReq, userVo); + } + } + + /** + * 添加银行卡信息 + * + * @param req + * @param userVo + * @return + */ + private ResponseData addBankCard(AddOrUpdateBankCardReq req, UserVo userVo) { + try { + //1、调用三方接口创建卡拉卡账号 + String account = createAccount(req, userVo); + + //2、调用三方接口绑定分账关系 + bindAccount(account, req, userVo); + + return ResponseData.success("添加银行卡已受理,请等待审核结果!"); + + } catch (Exception e) { + throw new RuntimeException("添加银行卡失败,失败原因:" + e.getMessage()); + } + } + + + @Autowired + private InitUtil initUtil; + + /** + * 分账关系绑定申请 + * + * @param account + * @param req + */ + private void bindAccount(String account, AddOrUpdateBankCardReq req, UserVo userVo) throws Exception { + initUtil.doInit(); + V2MmsLedgerApplyBindRequest request = new V2MmsLedgerApplyBindRequest(); + request.setVersion(KlkConstant.VERSION); + request.setOrderNo(CommonUtil.getOrderNo()); + + // 将orderNo存入表中 + LambdaUpdateWrapper updateWrapper = new LambdaUpdateWrapper() + .set(KlkAccount::getBindOrderNo, request.getOrderNo()) + .eq(KlkAccount::getUserType, userVo.getUserType()) + .eq(KlkAccount::getUserId, userVo.getUserId()); + + + request.setOrgCode(KlkConstant.ORG_CODE); + request.setMerCupNo(merchantNo); + request.setReceiverNo(account); + // 获取合作协议对象 + AddOrUpdateBankCardReq.Attach attach = getAgreement(userVo, req); + request.setEntrustFileName(attach.getAttachName()); + request.setEntrustFilePath(attach.getAttachStorePath()); + request.setRetUrl(urlPrefix + KlkConstant.BIND_ACC_URL); + String response = LKLSDK.httpPost(request); + JSONObject jsonObject = JSON.parseObject(response); + if (!"000000".equals(jsonObject.getString("retCode"))) { + updateWrapper.set(KlkAccount::getBindStatus, 4) + .set(KlkAccount::getBindFailReason, jsonObject.getString("retMsg")); + klkAccountMapper.update(null, updateWrapper); + throw new RuntimeException(jsonObject.getString("retMsg")); + } + JSONObject respData = jsonObject.getJSONObject("respData"); + updateWrapper.set(KlkAccount::getBindStatus, 2) + .set(KlkAccount::getApplyId, respData.getString("applyId")); + klkAccountMapper.update(null, updateWrapper); + } + + @Autowired + private BusinessUtil businessUtil; + + @Value("${lalkla.basePath}") + private String basePath; + + @Value("${lalkla.filePath}") + private String filePath; + + /** + * 获取合作协议对象 + * + * @return + */ + @SneakyThrows + private AddOrUpdateBankCardReq.Attach getAgreement(UserVo userVo, AddOrUpdateBankCardReq addOrUpdateBankCardReq) { + String targetUrl = null; + if (userVo.getUserType().equals(UserEnums.store.getCode())) { + targetUrl = filePath + "storeDivideAccountsAgreement.docx"; + } else if (userVo.getUserType().equals(UserEnums.sale.getCode())) { + targetUrl = filePath + "saleDivideAccountsAgreement.docx"; + } + + + AddOrUpdateBankCardReq.Attach attach = new AddOrUpdateBankCardReq.Attach(); + attach.setAttachName("divideAccountsAgreement.pdf"); + UploadFileReq req = new UploadFileReq(); + req.setAttType("XY"); + req.setAttExtName("pdf"); + + String outWordPath = basePath + UUID.randomUUID() + ".docx"; + convertHtmlToImage(addOrUpdateBankCardReq, targetUrl, outWordPath); + + String oupPdfPath = basePath + UUID.randomUUID() + ".pdf"; + + PdfUtil.doc2pdf(outWordPath, oupPdfPath, filePath + "license.xml"); + FileInputStream fileInputStream = new FileInputStream(oupPdfPath); + req.setAttContext(commonService.fileToBase64(fileInputStream)); + + attach.setAttachStorePath(uploadFile(req)); + return attach; + } + + + public void convertHtmlToImage(AddOrUpdateBankCardReq req, String input, String outPut) throws Exception { + + // 创建XWPFDocument对象,加载Word文档 + XWPFDocument doc = new XWPFDocument(new FileInputStream(input)); + // 获取文档中的所有段落 + List paragraphs = doc.getParagraphs(); + + Integer year = 5; + + Date date = DateUtil.offsetMonth(new Date(), year * 12); + + // 遍历所有段落,找到需要修改的内容 + for (XWPFParagraph paragraph : paragraphs) { + if (StrUtil.isBlank(paragraph.getText())) { + continue; + } + List runs = paragraph.getRuns(); + for (XWPFRun run : runs) { + String text = run.text(); + if (StrUtil.isBlank(text)) { + continue; + } + String newText = text; + if (newText.contains("${store.name}")) { + newText = newText.replace("${store.name}", req.getAcctName()); + } + if (newText.contains("${store.idno}")) { + newText = newText.replace("${store.idno}", req.getAcctCertificateNo()); + } + if (newText.contains("${year}")) { + newText = newText.replace("${year}", (year + "")); + } + if (newText.contains("${beginYear}")) { + newText = newText.replace("${beginYear}", (DateUtil.year(new Date()) + "")); + } + if (newText.contains("${beginMonth}")) { + newText = newText.replace("${beginMonth}", (DateUtil.month(new Date()) + 1) + ""); + } + if (newText.contains("${beginDay}")) { + newText = newText.replace("${beginDay}", (DateUtil.dayOfMonth(new Date()) + "")); + } + if (newText.contains("${endYear}")) { + newText = newText.replace("${endYear}", (DateUtil.year(date) + "")); + } + if (newText.contains("${endMonth}")) { + newText = newText.replace("${endMonth}", (DateUtil.month(date) + 1) + ""); + } + if (newText.contains("${endDay}")) { + newText = newText.replace("${endDay}", (DateUtil.dayOfMonth(date) + "")); + } + if (newText.contains("${endDay}")) { + newText = newText.replace("${endDay}", (DateUtil.dayOfMonth(date) + "")); + } + if (newText.contains("${date-qy}")) { + newText = newText.replace("${date-qy}", (DateUtil.formatDate(date) + "")); + } + run.setText(newText, 0); + } + String text = paragraph.getText(); + if (StrUtil.isNotBlank(text) && text.contains("签字/盖章") && StrUtil.isNotBlank(req.getSignature())) { + String targetImage = basePath + UUID.randomUUID() + ".png"; + + download(req.getSignature(), targetImage); + // 图片文件 + FileInputStream imageStream = new FileInputStream(getPositionTrueImage(targetImage)); + XWPFRun provincialInfoPicRun = paragraph.createRun(); + provincialInfoPicRun.addPicture(imageStream, 5, "", Units.toEMU(80), Units.toEMU(40)); + } + + } + // 保存修改后的文档 + FileOutputStream out = new FileOutputStream(outPut); + doc.write(out); + out.close(); + } + + private String getPositionTrueImage(String image) { + + String s = ImageRotator.rotate90DegreesCounterClockwise(image, basePath); + s = ImageRotator.rotate90DegreesCounterClockwise(s, basePath); + s = ImageRotator.rotate90DegreesCounterClockwise(s, basePath); + return s; + } + + + public static void main(String[] args) throws Exception { + + } + + + public static String getSuffix(String fileName) { + String[] split = fileName.split("\\."); + String suffix = ".jpg"; + if (split.length > 1) { + suffix = "." + split[split.length - 1]; + } + return suffix; + } + + /** + * 自动拼接后缀名 如sourceUrl:abc.jpg, targetUrl:cc 则存储的文件名为cc.jpg + * + * @param sourceUrl + * @param targetUrl + */ + public static File download(String sourceUrl, String targetUrl) throws Exception { + if (new File(targetUrl).exists()) { + new File(targetUrl).delete(); + } + URL httpUrl = new URL(sourceUrl); + File file = new File(targetUrl); + FileUtils.copyURLToFile(httpUrl, file); + + return new File(targetUrl); + } + + @Autowired + private KlkAccountMapper klkAccountMapper; + + @Autowired + private KlkAccountAttachService klkAccountAttachService; + + /** + * 创建卡拉卡账号 + * + * @param req + * @return + */ + public String createAccount(AddOrUpdateBankCardReq req, UserVo userVo) throws Exception { + // 步骤一:分账接收方创建申请 + initUtil.doInit(); + V2MmsApplyLedgerReceiverRequest request = new V2MmsApplyLedgerReceiverRequest(); + request.setVersion(KlkConstant.VERSION); + request.setOrderNo(CommonUtil.getOrderNo()); + request.setOrgCode(KlkConstant.ORG_CODE); + request.setReceiverName(req.getAcctName()); + request.setContactMobile(selectMobileByUserType(userVo)); + request.setAcctNo(req.getAcctNo()); + request.setAcctName(req.getAcctName()); + request.setAcctTypeCode(KlkConstant.ACC_TYPE); + request.setAcctCertificateType(KlkConstant.ACC_CERT_TYPE); + request.setAcctCertificateNo(req.getAcctCertificateNo()); + // 步骤二:调用卡BIN接口查询信息 + Map cardBinMap = getCardBinMap(req.getAcctNo()); + request.setAcctOpenBankCode(cardBinMap.get("acctOpenBankCode")); + request.setAcctOpenBankName(req.getAcctOpenBankName()); + request.setAcctClearBankCode(cardBinMap.get("acctClearBankCode")); + request.setAttachList(getAttachList(req.getAttachList())); + String response = LKLSDK.httpPost(request); + JSONObject jsonObject = JSON.parseObject(response); + + KlkAccount klkAccount = getKlkAccount(userVo, request); + + if ("000000".equals(jsonObject.getString("retCode"))) { + JSONObject respData = jsonObject.getJSONObject("respData"); + klkAccount.setReceiverNo(respData.getString("receiverNo")); + klkAccountMapper.insert(klkAccount); + klkAccountAttachService.saveBatch(getKlkAccountAttachList(klkAccount, req)); + return respData.getString("receiverNo"); + } + + klkAccountMapper.insert(klkAccount); + klkAccountAttachService.saveBatch(getKlkAccountAttachList(klkAccount, req)); + throw new RuntimeException(jsonObject.getString("retMsg")); + } + + private Collection getKlkAccountAttachList(KlkAccount klkAccount, AddOrUpdateBankCardReq req) { + return req.getAttachList().stream().map(s -> { + KlkAccountAttach klkAccountAttach = new KlkAccountAttach(); + klkAccountAttach.setLakalaAccountId(klkAccount.getId()); + klkAccountAttach.setAttachName(s.getAttachName()); + klkAccountAttach.setAttachStorePath(s.getKlkPath()); + klkAccountAttach.setHttpPath(s.getAttachStorePath()); + klkAccountAttach.setAttachType(s.getAttachType()); + return klkAccountAttach; + }).collect(Collectors.toList()); + } + + + private static KlkAccount getKlkAccount(UserVo userVo, V2MmsApplyLedgerReceiverRequest request) { + KlkAccount klkAccount = new KlkAccount(); + klkAccount.setUserId(userVo.getUserId()); + klkAccount.setUserType(userVo.getUserType()); + klkAccount.setCreateOrderNo(request.getOrderNo()); + klkAccount.setReceiverName(request.getAcctName()); + klkAccount.setContactMobile(request.getContactMobile()); + klkAccount.setAcctNo(request.getAcctNo()); + klkAccount.setAcctName(request.getAcctName()); + klkAccount.setAcctTypeCode(request.getAcctTypeCode()); + klkAccount.setAcctCertificateType(request.getAcctCertificateType()); + klkAccount.setAcctCertificateNo(request.getAcctCertificateNo()); + klkAccount.setAcctOpenBankCode(request.getAcctOpenBankCode()); + klkAccount.setAcctOpenBankName(request.getAcctOpenBankName()); + klkAccount.setAcctClearBankCode(request.getAcctClearBankCode()); + return klkAccount; + } + + @Autowired + private CustomerMapper customerMapper; + + @Autowired + private StoreMapper storeMapper; + + @Autowired + private SaleMapper saleMapper; + + /** + * 根据不同用户类型查询用户手机号 + * + * @param userVo + * @return + */ + private String selectMobileByUserType(UserVo userVo) { + Integer userType = userVo.getUserType(); + if (userType == 1) {//客户 + Customer customer = customerMapper.selectById(userVo.getUserId()); + return customer.getMobile(); + } else if (userType == 2) {//表现师 + Store store = storeMapper.selectById(userVo.getUserId()); + return store.getMobile(); + } else if (userType == 3) {//销售 + Sale sale = saleMapper.selectById(userVo.getUserId()); + return sale.getMobile(); + } else { + return ""; + } + } + + /** + * 获取附件信息 + * 将前端传的信息转换为三方接口需要的信息 + * + * @param attachList + * @return + */ + private List getAttachList(List attachList) { + return attachList.stream().map(s -> { + V2MmsApplyLedgerReceiverRequest.AttachInfo attachInfo = new V2MmsApplyLedgerReceiverRequest.AttachInfo(); + attachInfo.setAttachName(s.getAttachName()); + attachInfo.setAttachType(commonService.getAttType(s.getAttachType())); + UploadFileReq req = new UploadFileReq(); + req.setAttType(attachInfo.getAttachType()); + req.setAttExtName(getExtName(s.getAttachName())); + req.setAttContext(commonService.fileToBase64(s.getAttachStorePath())); + attachInfo.setAttachStorePath(uploadFile(req)); + s.setKlkPath(attachInfo.getAttachStorePath()); + return attachInfo; + }).collect(Collectors.toList()); + } + + /** + * 从文件名中获取后缀名 + * + * @param attachName + * @return + */ + private String getExtName(String attachName) { + return attachName.substring(attachName.lastIndexOf(".") + 1); + } + + + /** + * 根据卡号查询卡BIN信息 + * + * @param acctNo + * @return + */ + public Map getCardBinMap(String acctNo) throws Exception { + initUtil.doInit(); + V2MmsOpenApiCardBin cardBin = new V2MmsOpenApiCardBin(); + cardBin.setVersion(KlkConstant.VERSION); + cardBin.setOrderNo(CommonUtil.getOrderNo()); + cardBin.setOrgCode(KlkConstant.ORG_CODE); + cardBin.setCardNo(acctNo); + String cardBinResponse = LKLSDK.httpPost(cardBin); + JSONObject jsonObject = JSON.parseObject(cardBinResponse); + if ("000000".equals(jsonObject.getString("retCode"))) { + JSONObject respData = jsonObject.getJSONObject("respData"); + Map cardBinMap = new HashMap<>(); + cardBinMap.put("acctOpenBankCode", respData.getString("bankCode")); + cardBinMap.put("acctClearBankCode", respData.getString("clearingBankCode")); + cardBinMap.put("bankName", respData.getString("bankName")); + return cardBinMap; + } + throw new RuntimeException(); + } + + + /** + * 修改银行卡信息 + */ + public ResponseData updateBankCard(UpdateBankCardReq req, UserVo userVo) { + try { + initUtil.doInit(); + V2MmsModifyLedgerReceiverRequest request = new V2MmsModifyLedgerReceiverRequest(); + request.setVersion(KlkConstant.VERSION); + request.setOrderNo(CommonUtil.getOrderNo()); + request.setOrgCode(KlkConstant.ORG_CODE); + // 根据用户id查询卡拉卡账号 + request.setReceiverNo(getKlkAccByUserId(userVo.getUserId(), userVo.getUserType())); + request.setReceiverName(req.getAcctName()); + request.setContactMobile(selectMobileByUserType(userVo)); + request.setAcctNo(req.getAcctNo()); + request.setAcctTypeCode(KlkConstant.ACC_TYPE); + Map cardBinMap = getCardBinMap(req.getAcctNo()); + request.setAcctOpenBankCode(cardBinMap.get("acctOpenBankCode")); + request.setAcctOpenBankName(req.getAcctOpenBankName()); + request.setAcctClearBankCode(cardBinMap.get("acctClearBankCode")); + request.setAttachList(getUpdateAttachList(req.getAttachList())); + String response = LKLSDK.httpPost(request); + JSONObject jsonObject = JSON.parseObject(response); + if ("000000".equals(jsonObject.getString("retCode"))) { + return ResponseData.success("修改银行卡信息成功!"); + } else { + throw new RuntimeException(jsonObject.getString("retMsg")); + } + } catch (Exception e) { + log.error("修改卡拉卡账号信息出现异常:{}", e.getMessage()); + throw new RuntimeException("失败原因:" + e.getMessage()); + } + } + + /** + * 将前端传递的附件信息转换为三方修改需要的参数 + * + * @param attachList + * @return + */ + private List getUpdateAttachList(List attachList) { + return attachList.stream().map(s -> { + V2MmsModifyLedgerReceiverRequest.AttachInfo attachInfo = new V2MmsModifyLedgerReceiverRequest.AttachInfo(); + attachInfo.setAttachName(s.getAttachName()); + attachInfo.setAttachType(commonService.getAttType(s.getAttachType())); + UploadFileReq req = new UploadFileReq(); + req.setAttType(attachInfo.getAttachType()); + req.setAttExtName(getExtName(s.getAttachName())); + req.setAttContext(commonService.fileToBase64(s.getAttachStorePath())); + attachInfo.setAttachStorePath(uploadFile(req)); + return attachInfo; + }).collect(Collectors.toList()); + } + + /** + * 根据用户id查询卡拉卡账号 + * + * @param userId + * @return + */ + private String getKlkAccByUserId(Long userId, Integer userType) { + return klkAccountMapper.selectOne(new LambdaUpdateWrapper() + .eq(KlkAccount::getDelFlag, PublicCommon.启用) + .eq(KlkAccount::getUserType, userType) + .eq(KlkAccount::getUserId, userId)) + .getReceiverNo(); + } + + /** + * 查询开户行名称 + */ + @Override + public ResponseData getBankName(GetBankNameReq req) { + try { + Map cardBinMap = getCardBinMap(req.getCardNo()); + return ResponseData.success(cardBinMap.get("bankName")); + } catch (Exception e) { + log.error("查询开户行信息出现异常:{}", e.getMessage()); + return ResponseData.success(); + } + } + + /** + * 获取银行卡信息 + */ + @Override + public ResponseData getBankInfo(UserVo userVo) { + KlkAccount klkAccount = klkAccountMapper.selectOne(new LambdaUpdateWrapper() + .eq(KlkAccount::getDelFlag, PublicCommon.启用) + .eq(KlkAccount::getUserType, userVo.getUserType()) + .eq(KlkAccount::getUserId, userVo.getUserId())); + GetBankInfoResp getBankInfoResp = new GetBankInfoResp(); + if (klkAccount == null) { + getBankInfoResp.setBindResult(-1); + } else { + getBankInfoResp.setId(klkAccount.getId()); + getBankInfoResp.setAcctName(klkAccount.getAcctName()); + getBankInfoResp.setAcctCertificateNo(klkAccount.getAcctCertificateNo()); + getBankInfoResp.setAcctNo(klkAccount.getAcctNo()); + getBankInfoResp.setAcctOpenBankName(klkAccount.getAcctOpenBankName()); + List klkAccountAttachList = klkAccountAttachService.getBaseMapper().selectList(new LambdaUpdateWrapper() + .eq(KlkAccountAttach::getDelFlag, PublicCommon.启用) + .eq(KlkAccountAttach::getLakalaAccountId, klkAccount.getId())); + if (CollectionUtil.isNotEmpty(klkAccountAttachList)) { + getBankInfoResp.setAttachList(klkAccountAttachList.stream().map(s -> { + GetBankInfoResp.Attach attach = new GetBankInfoResp.Attach(); + attach.setAttachType(s.getAttachType()); + attach.setAttachName(s.getAttachName()); + attach.setAttachStorePath(s.getHttpPath()); + return attach; + }).collect(Collectors.toList())); + } + // resp.setBindResult(); 绑定结果:1-审核中 2-审核失败 3-审核成功 -1-未提交审核 + // klkAccount.getBindStatus() 绑定状态:1-未绑定 2-绑定中 3-已绑定 4-绑定失败 + if (klkAccount.getBindStatus() == 1) { + getBankInfoResp.setBindResult(-1); + } else if (klkAccount.getBindStatus() == 2) { + getBankInfoResp.setBindResult(1); + } else if (klkAccount.getBindStatus() == 3) { + getBankInfoResp.setBindResult(3); + } else if (klkAccount.getBindStatus() == 4) { + getBankInfoResp.setBindResult(2); + getBankInfoResp.setAuditFailReason(klkAccount.getBindFailReason()); + } + } + + return ResponseData.success(getBankInfoResp); + } + + @Autowired + private KlkWithdrawalRecordMapper klkWithdrawalRecordMapper; + + /** + * 提现 + */ + @Override + public void withdrawal(WithdrawalRecord withdrawalRecord) { + + KlkWithdrawalRecord klkWithdrawalRecord = getKlkWithdrawalRecord(withdrawalRecord); + + // 调用三方接口进行分账 + klkWithdrawalRecord = divideAccount(klkWithdrawalRecord); + + + klkWithdrawalRecordMapper.insert(klkWithdrawalRecord); + + if (StrUtil.isNotBlank(klkWithdrawalRecord.getBalanceSplitRemark())) { + withdrawalRecordMapper.update(null, new LambdaUpdateWrapper() + .eq(WithdrawalRecord::getId, klkWithdrawalRecord.getWithdrawalRecordId()) + .set(WithdrawalRecord::getRefuseReason, klkWithdrawalRecord.getBalanceSplitRemark())); + } + } + + @Autowired + private WithdrawalRecordMapper withdrawalRecordMapper; + + + //商户号 + @Value("${lalkla.merchantNo}") + private String merchantNo; + + /** + * 分账 + * + * @param klkWithdrawalRecord + * @return + */ + private KlkWithdrawalRecord divideAccount(KlkWithdrawalRecord klkWithdrawalRecord) { + try { + initUtil.doInit(); + V3SacsBalanceSeparateRequest request = new V3SacsBalanceSeparateRequest(); + request.setMerchantNo(merchantNo); + request.setOutSeparateNo(getOutSeparateNo()); + request.setTotalAmt(klkWithdrawalRecord.getTotalAmt()); + request.setCalType("0"); //0- 按照指定金额,1- 按照指定比例。默认 0 + request.setRecvDatas(getRecvDatas(klkWithdrawalRecord)); + + klkWithdrawalRecord.setOutSeparateNo(request.getOutSeparateNo()); + String response = LKLSDK.httpPost(request); + JSONObject jsonObject = JSON.parseObject(response); + if ("SACS0000".equals(jsonObject.getString("code"))) { + JSONObject respData = jsonObject.getJSONObject("resp_data"); + klkWithdrawalRecord.setBalanceSplitStatus(getBalanceSplitStatus(respData.getString("status"))); + } else { + throw new ServiceException(jsonObject.getString("msg")); + } + return klkWithdrawalRecord; + } catch (Exception e) { + log.error("分账出现异常:{}", e.getMessage()); + throw new ServiceException(e.getMessage()); + } + } + + /** + * 1-处理中 2-已受理 3-成功 4-失败 + * + * @param status + * @return + */ + @Override + public Integer getBalanceSplitStatus(String status) { + switch (status) { + case KlkConstant.PROCESSING: + return 1; + case KlkConstant.ACCEPTED: + return 2; + case KlkConstant.SUCCESS: + return 3; + case KlkConstant.FAIL: + return 4; + default: + return -1; + } + } + + private List getRecvDatas(KlkWithdrawalRecord klkWithdrawalRecord) { + KlkAccount klkAccount = klkAccountMapper.selectOne(new LambdaUpdateWrapper() + .eq(KlkAccount::getDelFlag, PublicCommon.启用) + .eq(KlkAccount::getUserType, klkWithdrawalRecord.getUserType()) + .eq(KlkAccount::getUserId, klkWithdrawalRecord.getUserId())); + V3SacsBalanceSeparateRequest.RecvData recvData = new V3SacsBalanceSeparateRequest.RecvData(); + recvData.setRecvNo(klkAccount.getReceiverNo()); + recvData.setSeparateValue(klkWithdrawalRecord.getTotalAmt()); + return Collections.singletonList(recvData); + } + + private KlkWithdrawalRecord getKlkWithdrawalRecord(WithdrawalRecord withdrawalRecord) { + KlkWithdrawalRecord klkWithdrawalRecord = new KlkWithdrawalRecord(); + klkWithdrawalRecord.setUserId(withdrawalRecord.getUserId()); + klkWithdrawalRecord.setUserType(withdrawalRecord.getUserType()); + klkWithdrawalRecord.setTotalAmt(transferTotalAmt(withdrawalRecord.getPrice())); + klkWithdrawalRecord.setAcctNo(withdrawalRecord.getBankCard()); + klkWithdrawalRecord.setAcctOpenBankName(withdrawalRecord.getBank()); + klkWithdrawalRecord.setAcctName(withdrawalRecord.getFullName()); + klkWithdrawalRecord.setWithdrawalRecordId(withdrawalRecord.getId()); + return klkWithdrawalRecord; + } + + /** + * 将提现金额转换为分 + * + * @param price + * @return + */ + private String transferTotalAmt(BigDecimal price) { + return price.multiply(new BigDecimal("100")).intValue() + ""; + } + + /** + * 获取分账指令流水号 + * + * @return + */ + private String getOutSeparateNo() { + return UUID.randomUUID().toString().replace("-", ""); + } + + /** + * 查询银行卡是否绑定成功 + * + * @param userVo + * @return + */ + @Override + public ResponseData selectBindResult(UserVo userVo) { + SelectBindResultResp resp = new SelectBindResultResp(); + KlkAccount klkAccount = klkAccountMapper.selectOne(new LambdaQueryWrapper() + .eq(KlkAccount::getDelFlag, PublicCommon.启用) + .eq(KlkAccount::getUserType, userVo.getUserType()) + .eq(KlkAccount::getUserId, userVo.getUserId())); + // resp.setBindResult(); 绑定结果:1-审核中 2-审核失败 3-审核成功 -1-未提交审核 + // klkAccount.getBindStatus() 绑定状态:1-未绑定 2-绑定中 3-已绑定 4-绑定失败 + if (klkAccount == null) { + resp.setBindResult(-1); + } else if (klkAccount.getBindStatus() == 2) { + resp.setBindResult(1); + } else if (klkAccount.getBindStatus() == 3) { + resp.setBindResult(3); + } else if (klkAccount.getBindStatus() == 4) { + resp.setBindResult(2); + resp.setAuditFailReason(klkAccount.getBindFailReason()); + } + return ResponseData.success(resp); + } +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/klk/util/CommonService.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/klk/util/CommonService.java new file mode 100644 index 0000000..6da2cd0 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/klk/util/CommonService.java @@ -0,0 +1,121 @@ +package com.ruoyi.klk.util; + +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.codec.binary.Base64; +import org.springframework.stereotype.Component; +import org.springframework.util.StreamUtils; + +import java.io.IOException; +import java.io.InputStream; +import java.net.HttpURLConnection; +import java.net.URL; +import java.util.HashMap; +import java.util.Map; + +@Component +@Slf4j +public class CommonService { + + + /** + * 1-身份证正面 2-身份证反面 3-银行卡 4-营业执照 5-合作协议-纸质版 6-合作协议-电子版 + * 获取附件类型 + * + * @param attType + * @return + */ + public String getAttType(String attType) { + switch (attType) { + case "1": + return "FR_ID_CARD_FRONT"; + case "2": + return "FR_ID_CARD_BEHIND"; + case "3": + return "BANK_CARD"; + case "4": + return "BUSINESS_LICENCE"; + case "5": + return "XY"; + case "6": + return "NETWORK_XY"; + default: + return ""; + } + } + + /*读取网络文件*/ + public InputStream getFileInputStream(String path) { + URL url = null; + try { + url = new URL(path); + HttpURLConnection conn = (HttpURLConnection) url.openConnection(); + //设置超时间为3秒 + conn.setConnectTimeout(3 * 1000); + //防止屏蔽程序抓取而返回403错误 + conn.setRequestProperty("User-Agent", "Mozilla/4.0 (compatible; MSIE 5.0; Windows NT; DigExt)"); + //得到输入流 + return conn.getInputStream(); + } catch (Exception e) { + + } + return null; + } + + public String fileToBase64(String path) { + String base64 = null; + InputStream in = null; + try { + in = getFileInputStream(path); + byte[] bytes = StreamUtils.copyToByteArray(in); + in.read(bytes); + base64 = new String(Base64.encodeBase64(bytes),"UTF-8"); + System.out.println("将文件["+path+"]转base64字符串:"+base64); + } catch (Exception e) { + e.printStackTrace(); + } finally { + if (in != null) { + try { + in.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + } + return base64; + } + + public String fileToBase64(InputStream is) { + String base64 = null; + try { + byte[] bytes = StreamUtils.copyToByteArray(is); + is.read(bytes); + base64 = new String(Base64.encodeBase64(bytes),"UTF-8"); + } catch (Exception e) { + e.printStackTrace(); + } finally { + if (is != null) { + try { + is.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + } + return base64; + } + + /** + * 卡拉卡回调统一响应 + * { + * "code":"SUCCESS", + * "message":"执行成功" + * } + */ + public Map getKlkCommonResp() { + Map map = new HashMap<>(); + map.put("code", "SUCCESS"); + map.put("message", "执行成功"); + return map; + } + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/klk/util/InitUtil.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/klk/util/InitUtil.java new file mode 100644 index 0000000..6518ce4 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/klk/util/InitUtil.java @@ -0,0 +1,72 @@ +package com.ruoyi.klk.util; + +import com.lkl.laop.sdk.Config; +import com.lkl.laop.sdk.LKLSDK; +import com.lkl.laop.sdk.exception.SDKException; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Component; + +/*** + * @Description 功能描述:使用Java配置方式初始化SDK + * @Date 2023/7/19 15:41 + */ +@Component +public class InitUtil { + + private static volatile boolean init = false; + + + @Value("${lalkla.appId}") + public String appId; // 拉卡拉appId + + @Value("${lalkla.serialNo}") + public String serialNo ; // 你的证书序列号 + /** + * 商户私钥信息地址 + */ + @Value("${lalkla.priKeyPath}") + public String priKeyPath; + /** + * 拉卡拉支付平台证书地址 + */ + @Value("${lalkla.lklCerPath}") + public String lklCerPath ; + /** + * 拉卡拉支付平台证书地址2(用于拉卡拉通知验签) + */ + @Value("${lalkla.lklNotifyCerPath}") + public String lklNotifyCerPath; + /** + * 拉卡拉报文加密对称性密钥 + */ + @Value("${lalkla.sm4Key}") + public String sm4Key ; + /** + * 服务地址 + */ + @Value("${lalkla.serverUrl}") + public String serverUrl; + + /*** + * @Description: 初始化设置商户公共参数(全局只需设置一次) + * @throws Exception + */ + public void doInit() throws Exception { + if (!init) { + init = initByJava(); + } + } + + private boolean initByJava() throws SDKException { + Config config = new Config(); + config.setAppId(appId); + config.setSerialNo(serialNo); + config.setPriKeyPath(priKeyPath); + config.setLklCerPath(lklCerPath); + config.setLklNotifyCerPath(lklNotifyCerPath); + config.setServerUrl(serverUrl); + config.setSm4Key(sm4Key); + return LKLSDK.init(config); + } + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/klk/util/ParamConstant.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/klk/util/ParamConstant.java new file mode 100644 index 0000000..1c3c5af --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/klk/util/ParamConstant.java @@ -0,0 +1,39 @@ +package com.ruoyi.klk.util; + +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Component; + +@Component +public class ParamConstant { + + @Value("${lalkla.appId}") + public String appId; // 拉卡拉appId + + @Value("${lalkla.serialNo}") + public String serialNo ; // 你的证书序列号 + /** + * 商户私钥信息地址 + */ + @Value("${lalkla.priKeyPath}") + public String priKeyPath; + /** + * 拉卡拉支付平台证书地址 + */ + @Value("${lalkla.lklCerPath}") + public String lklCerPath ; + /** + * 拉卡拉支付平台证书地址2(用于拉卡拉通知验签) + */ + @Value("${lalkla.lklNotifyCerPath}") + public String lklNotifyCerPath; + /** + * 拉卡拉报文加密对称性密钥 + */ + @Value("${lalkla.sm4Key}") + public String sm4Key ; + /** + * 服务地址 + */ + @Value("${lalkla.serverUrl}") + public String serverUrl; +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/pay/config/Notifyurl.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/pay/config/Notifyurl.java new file mode 100644 index 0000000..604e29c --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/pay/config/Notifyurl.java @@ -0,0 +1,173 @@ +package com.ruoyi.pay.config; + +import com.ruoyi.pay.enums.PaySourceEnums; +import lombok.Data; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.stereotype.Component; + +/** + * 回调地址 + * @author a + * @date 2023/10/25 11:36 + */ +@Component +@ConfigurationProperties(prefix = "notifyurl") +@Data +public class Notifyurl { + + /** + * 订单首款支付回调地址 + */ + private String aliOrderUrl; + private String wxOrderUrl; + private String lklOrderUrl; + + /** + * 充值支付回调地址 + */ + private String aliRechargeUrl; + + private String wxRechargeUrl; + private String lklRechargeUrl; + + /** + * 保证金支付回调地址 + */ + private String aliBondUrl; + + private String wxBondUrl; + private String lklBondUrl; + + /** + * 普通认证支付回调地址 + */ + private String aliAuthUrl; + + private String wxAuthUrl; + private String lklAuthUrl; + + + /** + * 高端认证支付回调地址 + */ + private String aliHighendAuthUrl; + + private String wxHighendAuthUrl; + private String lklHighendAuthUrl; + + + /** + * 订单尾款支付回调地址 + */ + private String aliSecondOrderUrl; + + private String wxSecondOrderUrl; + private String lklSecondOrderUrl; + + + /** + * 设计师调价回调地址 + */ + private String aliAdjustPriceAuthUrl; + + private String wxAdjustPriceAuthUrl; + private String lklAdjustPriceAuthUrl; + + + /** + * 表现师调价设计师确认回调地址 + */ + private String aliAdjustPriceConfirmAuthUrl; + + private String wxAdjustPriceConfirmAuthUrl; + private String lklAdjustPriceConfirmAuthUrl; + + + /** + * 获取回调地址 + * @param enums + * @param type 1支付宝 2微信 3拉卡拉 + * @return + */ + public String getReturnUrl(PaySourceEnums enums,Integer type){ + switch (enums){ + case order_pay: + switch (type){ + case 1: + return this.aliOrderUrl; + case 2: + return this.wxOrderUrl; + case 3: + return this.lklOrderUrl; + } + case recharge_pay: + switch (type){ + case 1: + return this.aliRechargeUrl; + case 2: + return this.wxRechargeUrl; + case 3: + return this.lklRechargeUrl; + } + case bond_pay: + switch (type){ + case 1: + return this.aliBondUrl; + case 2: + return this.wxBondUrl; + case 3: + return this.lklBondUrl; + } + case auth_pay: + switch (type){ + case 1: + return this.aliAuthUrl; + case 2: + return this.wxAuthUrl; + case 3: + return this.lklAuthUrl; + } + case highend_auth_pay: + switch (type){ + case 1: + return this.aliHighendAuthUrl; + case 2: + return this.wxHighendAuthUrl; + case 3: + return this.lklHighendAuthUrl; + } + case order_second_pay: + switch (type){ + case 1: + return this.aliSecondOrderUrl; + case 2: + return this.wxSecondOrderUrl; + case 3: + return this.lklSecondOrderUrl; + } + case adjust_price_pay: + + switch (type){ + case 1: + return this.aliAdjustPriceAuthUrl; + case 2: + return this.wxAdjustPriceAuthUrl; + case 3: + return this.lklAdjustPriceAuthUrl; + } + case store_adjust_price_pay: + switch (type){ + case 1: + return this.aliAdjustPriceConfirmAuthUrl; + case 2: + return this.wxAdjustPriceConfirmAuthUrl; + case 3: + return this.lklAdjustPriceConfirmAuthUrl; + } + default: + break; + } + return null; + } + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/pay/enums/PayEnums.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/pay/enums/PayEnums.java new file mode 100644 index 0000000..168a037 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/pay/enums/PayEnums.java @@ -0,0 +1,56 @@ +package com.ruoyi.pay.enums; + +import java.util.Arrays; + +/** + * 支付类型枚举 + * @Author liwenlong + */ +public enum PayEnums { + + app_alipay(1, "app支付宝"), + + h5_alipay(2, "h5支付宝"), + + app_weChat(3, "app微信"), + + h5_WeChat(4, "h5微信"), + + applet(5, "小程序"), + + apple (6, "苹果支付"), + + balance(7, "余额"), + + lakala_ccss(8, "拉卡拉聚合收银台"), + + + ; + + private final Integer code; + private final String name; + + public static String getName(Integer code) { + return getPayEnums(code).name; + } + + + public static PayEnums getPayEnums(Integer code) { + return Arrays.stream(PayEnums.values()).filter(c->c.getCode().equals(code)).findFirst().get(); + } + + PayEnums(Integer code, String name) { + this.code = code; + this.name = name; + } + + public Integer getCode() { + return code; + } + + public String getName() { + return name; + } + + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/pay/enums/PaySourceEnums.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/pay/enums/PaySourceEnums.java new file mode 100644 index 0000000..a80ac86 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/pay/enums/PaySourceEnums.java @@ -0,0 +1,60 @@ +package com.ruoyi.pay.enums; + +import java.util.Arrays; + +/** + * 支付来源枚举 + * @Author liwenlong + */ +public enum PaySourceEnums { + + order_pay(1, "订单首款支付"), + + order_second_pay(2, "订单尾款支付"), + + recharge_pay(3, "充值"), + + auth_pay(4, "普通认证支付"), + + highend_auth_pay(5, "高端认证支付"), + + bond_pay(6, "保证金支付"), + + + adjust_price_pay(7, "设计师调价定金支付"), + + store_adjust_price_pay(8, "表现师调价设计师定金支付"), + + + mall_order_pay(9, "商城订单支付"), + + + ; + + private final Integer code; + private final String name; + + public static String getName(Integer code) { + return getPaySourceEnums(code).name; + } + + + public static PaySourceEnums getPaySourceEnums(Integer code) { + return Arrays.stream(PaySourceEnums.values()).filter(c->c.getCode().equals(code)).findFirst().get(); + } + + PaySourceEnums(Integer code, String name) { + this.code = code; + this.name = name; + } + + public Integer getCode() { + return code; + } + + public String getName() { + return name; + } + + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/pay/type/ali/param/AlipayOrderParam.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/pay/type/ali/param/AlipayOrderParam.java new file mode 100644 index 0000000..ad43eb7 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/pay/type/ali/param/AlipayOrderParam.java @@ -0,0 +1,21 @@ +package com.ruoyi.pay.type.ali.param; + +import lombok.Data; + +import java.math.BigDecimal; + +@Data +public class AlipayOrderParam { + //商户订单号 + private String out_trade_no; + //销售产品码 + private String product_code; + //总金额 + private BigDecimal total_amount; + //订单标题 + private String subject; + //该笔订单允许的最晚付款时间,逾期将关闭交易 + private String timeout_express; + //公共校验参数 + private String passback_params; +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/pay/type/ali/service/AliPayService.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/pay/type/ali/service/AliPayService.java new file mode 100644 index 0000000..a00d85b --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/pay/type/ali/service/AliPayService.java @@ -0,0 +1,45 @@ +package com.ruoyi.pay.type.ali.service; + + +import com.ruoyi.response.ResponseData; + +import java.math.BigDecimal; + +/** + * @author liuyao + * Created by Mr.Loe on 2019-01-08 + */ +public interface AliPayService { + + + /** + * 支付宝支付 + * + * @param orderNo + * @param amount + * @param returnUrl + * @return + */ + ResponseData aliPayUserPay(String orderNo, BigDecimal amount, String returnUrl,Long orderId); + + /** + * 支付宝退款 + * @param orderNo + * @param aliReturnPayId + * @param price + * @return + */ + ResponseData alipayRefund(String orderNo, String aliReturnPayId, BigDecimal price); + + + /** + * h5支付宝支付 + * + * @param orderNo + * @param amount + * @param returnUrl + * @return + */ + ResponseData aliH5Pay(String orderNo, BigDecimal amount, String returnUrl,Long objectId); + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/pay/type/ali/service/impl/AliPayServiceImpl.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/pay/type/ali/service/impl/AliPayServiceImpl.java new file mode 100644 index 0000000..e339c64 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/pay/type/ali/service/impl/AliPayServiceImpl.java @@ -0,0 +1,197 @@ +package com.ruoyi.pay.type.ali.service.impl; + + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.alipay.api.AlipayApiException; +import com.alipay.api.AlipayClient; +import com.alipay.api.DefaultAlipayClient; +import com.alipay.api.request.AlipayTradeAppPayRequest; +import com.alipay.api.request.AlipayTradeRefundRequest; +import com.alipay.api.request.AlipayTradeWapPayRequest; +import com.alipay.api.response.AlipayTradeAppPayResponse; +import com.alipay.api.response.AlipayTradeRefundResponse; +import com.ruoyi.pay.type.ali.param.AlipayOrderParam; +import com.ruoyi.pay.type.ali.service.AliPayService; +import com.ruoyi.response.ResponseData; +import com.ruoyi.utils.BusinessUtil; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.io.UnsupportedEncodingException; +import java.math.BigDecimal; +import java.net.URLEncoder; +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; + +/** + * @author liuyao + * Created by Mr.Loe on 2019-01-08 + * 类说明:支付宝工具类 + */ +@Service +@Slf4j +@Transactional(rollbackFor = Exception.class) +public class AliPayServiceImpl implements AliPayService { + + /** + * 用户 + */ + @Value("${alipay.appid}") + private String appid; + + @Value("${alipay.private-key}") + private String privateKey; + + @Value("${alipay.ali-public-key}") + private String aliPublicKey; + + @Value("${alipay.subject}") + private String subject; + + + @Value("${alipay.sign-type}") + private String signType; + + @Value("${alipay.ali-url}") + private String aliUrl; + + @Value("${alipay.product-code}") + private String productCode; + + /** + * 用户使用支付宝支付 + * + * @return + */ + @Override + public ResponseData aliPayUserPay(String orderNo, BigDecimal amount, String returnUrl,Long orderId) { + if (amount.compareTo(new BigDecimal(0)) != 1) { + return ResponseData.error("支付金额不可小于0"); + } + AlipayClient alipayClient = new DefaultAlipayClient(aliUrl, appid + , privateKey, "json", "UTF-8" + , aliPublicKey, signType); + //向支付宝发送支付请求 + String urlEncodeOrderNum = ""; + try { + //公众参数订单号 + urlEncodeOrderNum = URLEncoder.encode(orderNo, "UTF-8"); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + //创建Alipay支付请求对象 + AlipayTradeAppPayRequest payRequest = new AlipayTradeAppPayRequest(); + //回调地址 + payRequest.setNotifyUrl(returnUrl); + AlipayOrderParam alipayOrderParam = new AlipayOrderParam(); + //流水号 + alipayOrderParam.setOut_trade_no(orderNo); + alipayOrderParam.setProduct_code(productCode); + alipayOrderParam.setSubject(subject); + alipayOrderParam.setTotal_amount(amount); + alipayOrderParam.setTimeout_express("15m"); + alipayOrderParam.setPassback_params(urlEncodeOrderNum); + log.info(JSON.toJSONString(alipayOrderParam)); + //设置参数 + payRequest.setBizContent(JSON.toJSONString(alipayOrderParam)); + //输出页面的表单 + AlipayTradeAppPayResponse alipayTradeAppPayResponse; + try { + //调用SDK生成表单 + alipayTradeAppPayResponse = alipayClient.sdkExecute(payRequest); + } catch (Exception e) { + log.info("支付请求发送失败"); + return ResponseData.error("支付请求发送失败,请联系我们客服协助处理"); + } + Map map = new HashMap<>(); + map.put("alipayTradeAppPayResponse",alipayTradeAppPayResponse); + map.put("orderId",orderId); + log.info(JSONObject.toJSONString(map)); + + return ResponseData.success(map); + } + + @Autowired + private BusinessUtil businessUtil; + + @Override + public ResponseData alipayRefund(String orderNo, String aliReturnPayId, BigDecimal price) { + final AlipayClient alipayClient = new DefaultAlipayClient(aliUrl, appid + , privateKey, "json", "UTF-8" + , aliPublicKey, signType); + + AlipayTradeRefundRequest request = new AlipayTradeRefundRequest(); + Map map = new HashMap(4); + map.put("out_trade_no", orderNo); + //支付宝返回交易流水号 + map.put("trade_no", aliReturnPayId); + map.put("out_request_no", UUID.randomUUID().toString().replace("-", "")); + //退款金额 + map.put("refund_amount", price.setScale(2, BigDecimal.ROUND_DOWN)); + //退款原因 + map.put("refund_reason", "取消订单"); + String s = JSONObject.toJSONString(map); + request.setBizContent(s); + //请求支付宝,执行退款 + AlipayTradeRefundResponse response = null; + try { + response = alipayClient.execute(request); + } catch (AlipayApiException e) { + e.printStackTrace(); + } + if (response.isSuccess()) { + log.info("支付宝退款调用成功!"); + } else { + log.info(response.getSubMsg()); + return ResponseData.error(response.getSubMsg() + ",退款失败"); + } + return ResponseData.success(); + } + + + @Value("${alipay.h5appid}") + private String h5appid; + + @Value("${alipay.h5private-key}") + private String h5privateKey; + + @Value("${alipay.h5ali-public-key}") + private String h5aliPublicKey; + + + //H5支付 + @Override + public ResponseData aliH5Pay(String orderNum, BigDecimal price, String notify,Long orderId) { + AlipayClient alipayClient = new DefaultAlipayClient(aliUrl, h5appid, h5privateKey, "json", "utf-8", h5aliPublicKey, "RSA2"); + // 创建API对应的request + AlipayTradeWapPayRequest alipayRequest = new AlipayTradeWapPayRequest(); + alipayRequest.setNotifyUrl(notify); + Map map = new HashMap(); + map.put("out_trade_no", orderNum); + map.put("total_amount", price); + map.put("subject", ""); +// map.put("seller_id", partner); + map.put("product_code", "QUICK_WAP_PAY"); + // 填充业务参数 + alipayRequest.setBizContent(JSONObject.toJSONString(map)); + // 调用SDK生成表单 + String form = null; + try { + form = alipayClient.pageExecute(alipayRequest).getBody(); + } catch (AlipayApiException e) { + e.printStackTrace(); + return ResponseData.error("支付失败"); + } + Map map2 = new HashMap<>(); + map2.put("alipayTradeAppPayResponse",form); + map2.put("orderId",orderId); + log.info(JSONObject.toJSONString(map2)); + return ResponseData.success(map2); + } + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/pay/type/weixin/config/MyWXPayConfig.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/pay/type/weixin/config/MyWXPayConfig.java new file mode 100644 index 0000000..997f555 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/pay/type/weixin/config/MyWXPayConfig.java @@ -0,0 +1,55 @@ +package com.ruoyi.pay.type.weixin.config; + + +import com.github.wxpay.sdk.WXPayConfig; +import lombok.Data; + +import java.io.InputStream; + +@Data +public class MyWXPayConfig implements WXPayConfig { + + private String appId; + private String mchId; + private String key; + + + public MyWXPayConfig(String appId, String mchId, String key) { + this.appId = appId; + this.mchId = mchId; + this.key = key; + } + + @Override + //商户账号AppID + public String getAppID() { + return appId; + } + + @Override + //商户编号 + public String getMchID() { + return mchId; + } + + @Override + //商户Key(秘钥) + public String getKey() { + return key; + } + + @Override + public InputStream getCertStream() { + return null; + } + + @Override + public int getHttpConnectTimeoutMs() { + return 0; + } + + @Override + public int getHttpReadTimeoutMs() { + return 0; + } +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/pay/type/weixin/param/WxPayReturnData.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/pay/type/weixin/param/WxPayReturnData.java new file mode 100644 index 0000000..34fb502 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/pay/type/weixin/param/WxPayReturnData.java @@ -0,0 +1,125 @@ +package com.ruoyi.pay.type.weixin.param; + + +public class WxPayReturnData { + private String appid; + private String mch_id; + private String device_info; + private String nonce_str; + private String sign; + private String result_code; + private String err_code; + private String err_code_des; + private String return_code; + private String return_msg; + private String trade_type; + private String prepay_id; + private String code_url; + + + public String getAppid() { + return appid; + } + + public void setAppid(String appid) { + this.appid = appid; + } + + public String getMch_id() { + return mch_id; + } + + public void setMch_id(String mchId) { + mch_id = mchId; + } + + public String getDevice_info() { + return device_info; + } + + public void setDevice_info(String deviceInfo) { + device_info = deviceInfo; + } + + public String getNonce_str() { + return nonce_str; + } + + public void setNonce_str(String nonceStr) { + nonce_str = nonceStr; + } + + public String getSign() { + return sign; + } + + public void setSign(String sign) { + this.sign = sign; + } + + public String getResult_code() { + return result_code; + } + + public void setResult_code(String resultCode) { + result_code = resultCode; + } + + public String getErr_code() { + return err_code; + } + + public void setErr_code(String errCode) { + err_code = errCode; + } + + public String getErr_code_des() { + return err_code_des; + } + + public void setErr_code_des(String errCodeDes) { + err_code_des = errCodeDes; + } + + public String getReturn_code() { + return return_code; + } + + public void setReturn_code(String returnCode) { + return_code = returnCode; + } + + public String getReturn_msg() { + return return_msg; + } + + public void setReturn_msg(String returnMsg) { + return_msg = returnMsg; + } + + public String getTrade_type() { + return trade_type; + } + + public void setTrade_type(String tradeType) { + trade_type = tradeType; + } + + public String getPrepay_id() { + return prepay_id; + } + + public void setPrepay_id(String prepayId) { + prepay_id = prepayId; + } + + public String getCode_url() { + return code_url; + } + + public void setCode_url(String codeUrl) { + code_url = codeUrl; + } + + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/pay/type/weixin/param/WxPaySendData.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/pay/type/weixin/param/WxPaySendData.java new file mode 100644 index 0000000..a8ecef7 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/pay/type/weixin/param/WxPaySendData.java @@ -0,0 +1,142 @@ +package com.ruoyi.pay.type.weixin.param; + +public class WxPaySendData { + private String appid; + private String attach; + private String body; + private String mch_id; + private String nonce_str; + private String notify_url; + private String openid; + private String out_trade_no; + private String spbill_create_ip; + private int total_fee; + private String trade_type; +// private String device_info; + private String sign; + private String key; + + + public WxPaySendData() { + } + public WxPaySendData(String appid, String attach, String body, + String mchId, String nonceStr, String notifyUrl, String outTradeNo, + double totalFee, String tradeType, String spbillCreateIp, + String openid/*, String deviceInfo*/) { + this.appid = appid; + this.attach = attach; + this.body = body; + this.mch_id = mchId; + this.nonce_str = nonceStr; + this.notify_url = notifyUrl; + this.out_trade_no = outTradeNo; + this.total_fee = (int)(totalFee*100); + this.trade_type = tradeType; + this.spbill_create_ip = spbillCreateIp; + this.openid = openid; +// this.device_info = deviceInfo; + } + public String getAppid() { + return appid; + } + public void setAppid(String appid) { + this.appid = appid; + } + public String getAttach() { + return attach; + } + public void setAttach(String attach) { + this.attach = attach; + } + public String getBody() { + return body; + } + public void setBody(String body) { + this.body = body; + } + public String getMch_id() { + return mch_id; + } + public void setMch_id(String mchId) { + mch_id = mchId; + } + public String getNonce_str() { + return nonce_str; + } + public void setNonce_str(String nonceStr) { + nonce_str = nonceStr; + } + public String getNotify_url() { + return notify_url; + } + public void setNotify_url(String notifyUrl) { + notify_url = notifyUrl; + } + public String getOut_trade_no() { + return out_trade_no; + } + public void setOut_trade_no(String outTradeNo) { + out_trade_no = outTradeNo; + } + public int getTotal_fee() { + return total_fee; + } + public void setTotal_fee(int totalFee) { + total_fee = totalFee; + } + public String getTrade_type() { + return trade_type; + } + public void setTrade_type(String tradeType) { + trade_type = tradeType; + } + public String getSpbill_create_ip() { + return spbill_create_ip; + } + public void setSpbill_create_ip(String spbillCreateIp) { + spbill_create_ip = spbillCreateIp; + } + public String getOpenid() { + return openid; + } + public void setOpenid(String openid) { + this.openid = openid; + } +// public String getDevice_info() { +// return device_info; +// } +// public void setDevice_info(String deviceInfo) { +// device_info = deviceInfo; +// } + public String getSign() { + return sign; + } + public void setSign(String sign) { + this.sign = sign; + } + public String getKey() { + return key; + } + public void setKey(String key) { + this.key = key; + } + + @Override + public String toString() { + return "WxPaySendData{" + + "appid='" + appid + '\'' + + ", attach='" + attach + '\'' + + ", body='" + body + '\'' + + ", mch_id='" + mch_id + '\'' + + ", nonce_str='" + nonce_str + '\'' + + ", notify_url='" + notify_url + '\'' + + ", openid='" + openid + '\'' + + ", out_trade_no='" + out_trade_no + '\'' + + ", spbill_create_ip='" + spbill_create_ip + '\'' + + ", total_fee=" + total_fee + + ", trade_type='" + trade_type + '\'' + + ", sign='" + sign + '\'' + + ", key='" + key + '\'' + + '}'; + } +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/pay/type/weixin/param/WxRefundData.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/pay/type/weixin/param/WxRefundData.java new file mode 100644 index 0000000..e57e7e1 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/pay/type/weixin/param/WxRefundData.java @@ -0,0 +1,45 @@ +package com.ruoyi.pay.type.weixin.param; + +import lombok.Data; + +@Data +public class WxRefundData { + private String appid;//微信开放平台审核通过的应用APPID + private String mch_id;//微信支付分配的商户号 + private String nonce_str;//随机字符串,不长于32位 + private String sign; + private String out_trade_no; + private String out_refund_no; + private int total_fee; + private int refund_fee; + private String op_user_id; + private String return_msg; + private String return_code; + private String refund_channel; + private String coupon_refund_fee; + private String coupon_refund_count; + private String cash_fee; + private String result_code; + private String error_code; + private String err_code_des; + private String transaction_id; + private String refund_id; + private String cash_refund_fee; + + public WxRefundData() { + } + + //org.springframework.web.util.NestedServletException: Handler processing failed; nested exception is java.lang.NoSuchMethodError: com.pay.weixin.WxRefundData. + //(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/Double;Ljava/lang/Double;Ljava/lang/String;)V + public WxRefundData(String appid, String mch_id, String nonce_str, + String out_trade_no, String out_refund_no, int total_fee, int refund_fee, String op_user_id) { + this.appid = appid; + this.mch_id = mch_id; + this.nonce_str = nonce_str; + this.out_refund_no = out_refund_no; + this.out_trade_no = out_trade_no; + this.total_fee = total_fee; + this.refund_fee = refund_fee; + this.op_user_id = op_user_id; + } +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/pay/type/weixin/service/WXPayService.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/pay/type/weixin/service/WXPayService.java new file mode 100644 index 0000000..6f1ed72 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/pay/type/weixin/service/WXPayService.java @@ -0,0 +1,67 @@ +package com.ruoyi.pay.type.weixin.service; + + +import com.ruoyi.response.ResponseData; + +import java.math.BigDecimal; + +/** + * @author liuyao + * Created by Mr.Loe on 2019-01-08 + */ +public interface WXPayService { + + + /** + * 微信支付 + * + * @param orderNo + * @param amount + * @param returnUrl + * @return + */ + ResponseData wxPayUserPay(String orderNo, BigDecimal amount, String returnUrl,Long orderId); + + + /** + * h5微信支付 + * @param orderInfoId + * @param price + * @param notify + * @return + */ + ResponseData wxH5Pay(String orderNo, BigDecimal price, String notify,Long orderId); + + + /** + * 微信小程序支付 + * @param orderNum + * @param price + * @param openId + * @param notify + * @return + */ + ResponseData wxAppletPay(String orderNo, BigDecimal price, String openId, String notify,Long orderId); + + + /** + * 微信退款 + * @param orderNo + * @param payPrice + * @param refundPrice + * @return + */ + ResponseData wxRefund(String orderNo, BigDecimal payPrice, BigDecimal refundPrice); + + + /** + * 微信小程序支付 + * + * @param orderNo + * @param amount + * @param openId + * @param returnUrl + * @return + */ + ResponseData wxPayMethodApplet(String orderNo, BigDecimal amount, String openId, String returnUrl); +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/pay/type/weixin/service/impl/WXPayServiceImpl.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/pay/type/weixin/service/impl/WXPayServiceImpl.java new file mode 100644 index 0000000..4f021fa --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/pay/type/weixin/service/impl/WXPayServiceImpl.java @@ -0,0 +1,486 @@ +package com.ruoyi.pay.type.weixin.service.impl; + + +import cn.hutool.core.util.RandomUtil; +import com.github.wxpay.sdk.WXPay; +import com.github.wxpay.sdk.WXPayUtil; +import com.ruoyi.pay.type.weixin.config.MyWXPayConfig; +import com.ruoyi.pay.type.weixin.param.WxPayReturnData; +import com.ruoyi.pay.type.weixin.param.WxPaySendData; +import com.ruoyi.pay.type.weixin.param.WxRefundData; +import com.ruoyi.pay.type.weixin.service.WXPayService; +import com.ruoyi.pay.utils.HttpRequestUtil; +import com.ruoyi.pay.utils.PaymentApi; +import com.ruoyi.pay.utils.PaymentKit; +import com.ruoyi.response.ResponseData; +import com.ruoyi.utils.pwd.MD5Util; +import com.thoughtworks.xstream.XStream; +import com.thoughtworks.xstream.io.xml.DomDriver; +import com.thoughtworks.xstream.io.xml.XmlFriendlyNameCoder; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import javax.servlet.http.HttpServletRequest; +import java.math.BigDecimal; +import java.util.*; + +/** + * @author liuyao + * Created by Mr.Loe on 2019-01-08 + * 类说明:支付宝工具类 + */ +@Service +@Slf4j +@Transactional(rollbackFor = Exception.class) +public class WXPayServiceImpl implements WXPayService { + + + /** + * 用户 + */ + @Value("${wxpay.appid}") + private String wxAppid; + + @Value("${wxpay.mchid}") + private String mchid; + + @Value("${wxpay.paykey}") + private String paykey; + + @Value("${wxpay.app-secret}") + private String userAppSecret; + + + @Value("${app.name}") + private String appName; + + @Value("${wxrefundfile.path}") + private String refundFile; + + @Autowired + private HttpServletRequest request; + + /** + * 用户使用微信支付 + * + * @param orderNo + * @param amount + * @param returnUrl + * @return + */ + @Override + public ResponseData wxPayUserPay(String orderNo, BigDecimal amount, String returnUrl,Long orderId) { + if (amount.compareTo(new BigDecimal(0)) != 1) { + return ResponseData.error("支付金额不可小于0"); + } + WxPaySendData wxPaySendData = new WxPaySendData(); + //普通用户 + wxPaySendData.setAppid(wxAppid); // 微信开放平台核通过的应用APPID + wxPaySendData.setAttach(appName); // 附加数据,在查询API和支付通知中原样返回,该字段主要用于商户携带订单的自定义数据 + //普通用户 + wxPaySendData.setMch_id(mchid); // 微信支付分配的商户号 + + wxPaySendData.setBody(appName + "-订单号:" + orderNo); //商品或支付单简要描述 + wxPaySendData.setNonce_str(RandomUtil.randomNumbers(20)); // 随机字符串,不长于32位 + wxPaySendData.setNotify_url(returnUrl);// 回调地址 + wxPaySendData.setTotal_fee(amount.multiply(new BigDecimal(100)).intValue()); + wxPaySendData.setSpbill_create_ip(request.getRemoteAddr()); + wxPaySendData.setOut_trade_no(orderNo); // 商户订单号 + wxPaySendData.setTrade_type("APP"); // 支付类型 + String returnXml = unifiedOrder(wxPaySendData, paykey); + + WxPayReturnData reData; + XStream xs1 = new XStream(new DomDriver()); + xs1.alias("xml", WxPayReturnData.class); + reData = (WxPayReturnData) xs1.fromXML(returnXml); + System.out.println("===========reData.getReturn_code()=======:" + reData.getReturn_code()); + if ("SUCCESS".equals(reData.getReturn_code()) && "SUCCESS".equals(reData.getResult_code())) { + // 时间戳 + String timeStamp = String.valueOf(System.currentTimeMillis() / 1000); + String _package = "prepay_id=" + reData.getPrepay_id(); + SortedMap signMap = new TreeMap(); + signMap.put("appid", reData.getAppid()); + signMap.put("timestamp", timeStamp); + signMap.put("noncestr", reData.getNonce_str()); + signMap.put("package", _package); + signMap.put("signtype", "MD5"); + String paySign = createSign(signMap, paykey); + wxPaySendData.setSign(paySign); + SortedMap iosSignMap = new TreeMap(); + iosSignMap.put("appid", wxPaySendData.getAppid()); + iosSignMap.put("partnerid", wxPaySendData.getMch_id()); + iosSignMap.put("prepayid", reData.getPrepay_id()); + iosSignMap.put("package", "Sign=WXPay"); + iosSignMap.put("noncestr", wxPaySendData.getNonce_str()); + iosSignMap.put("timestamp", timeStamp); + // IOS端需要的SIGN + String iosSign = createSign(iosSignMap, paykey); + System.out.println("---------------签名222------------------" + iosSign); + Map map2 = new HashMap(); + map2.put("timestamp", timeStamp); + map2.put("prepayid", reData.getPrepay_id()); + map2.put("sign", iosSign); + map2.put("noncestr", wxPaySendData.getNonce_str()); + map2.put("package", "Sign=WXPay"); + map2.put("partnerid", wxPaySendData.getMch_id()); + map2.put("appid", wxPaySendData.getAppid()); + map2.put("orderId",orderId); + System.out.println("===================nonceStr===============" + wxPaySendData.getNonce_str()); + return ResponseData.success(map2); + } + return ResponseData.error("支付失败"); + } + + + @Override + public ResponseData wxH5Pay(String orderInfoId, BigDecimal price, String notify,Long orderId) { + //微信支付:申请支付连接 + WXPay wxPay = new WXPay(new MyWXPayConfig(wxAppid, mchid, paykey)); + + + //在data集合中存储生成微信二维码的重要参数 + HashMap data = new HashMap<>(); + + data.put("body", "支付"); //支付说明 + data.put("out_trade_no", orderInfoId); //使用当前用户订单的编号作为当前支付交易的交易号 + data.put("fee_type", "CNY"); //支付模式为人民币 + data.put("total_fee", price.multiply(new BigDecimal("100")).intValue() + ""); //设置支付金额为1分 + data.put("trade_type", "MWEB"); //交易的类型 + //需要注意的是这是需要自己配置内网穿透地址 + data.put("notify_url", notify); //设置支付完成时回调方法的接口 + data.put("spbill_create_ip",getIP(request)); + + //用于储存返回给前端必要数据的map集合(按需添加但是一般订单价格,订单编号,支付二维码编号都是必须的) + HashMap map = new HashMap<>(); + //储存订单编号 + map.put("number", orderInfoId); + //储存订单价格 + map.put("price", price.multiply(new BigDecimal("100")).intValue() + ""); + + try { + //通过data集合中的重要参数请求微信服务器,然后微信服务器将参数封装到resp中 + Map resp = wxPay.unifiedOrder(data); + //通过微信服务器返回的数据得到微信支付二维码,然后通过map集合返回给前端 + map.put("resp", resp.get("mweb_url")); + map.put("orderId", orderId.toString()); + } catch (Exception e) { + e.printStackTrace(); + } + //封装返回给前端的信息 + return ResponseData.success(map); + } + + + @Override + public ResponseData wxAppletPay(String orderNum, BigDecimal price, String openId, String notify,Long orderId) { + + Map reqParams = new HashMap<>(); + //微信分配的小程序ID + reqParams.put("appid", wxAppid); + //微信支付分配的商户号 + reqParams.put("mch_id", mchid); + //随机字符串 + reqParams.put("nonce_str", RandomUtil.randomNumbers(10)); + //签名类型 + reqParams.put("sign_type", "MD5"); + //充值订单 商品描述 + reqParams.put("body", "油桃绘本订单支付"); + //商户订单号 + reqParams.put("out_trade_no", orderNum); + log.info("业务订单号是 reqParams.get(out_trade_no)=" + reqParams.get("out_trade_no")); + //订单总金额,单位为分 + reqParams.put("total_fee", String.valueOf(price.multiply(new BigDecimal(100)).intValue())); + //终端IP + reqParams.put("spbill_create_ip", "118.24.78.87"); + //通知地址 + reqParams.put("notify_url", notify); + log.info(reqParams.get("notify_url")); + //交易类型 + reqParams.put("trade_type", "JSAPI"); + //用户标识 + reqParams.put("openid", openId); + //签名 + String sign = null; + try { + sign = WXPayUtil.generateSignature(reqParams, paykey); + + } catch (Exception e) { + e.printStackTrace(); + } + reqParams.put("sign", sign); + + /* + 调用支付定义下单API,返回预付单信息 prepay_id + */ + String xmlResult = PaymentApi.pushOrder(reqParams); + log.info(xmlResult); + Map result = PaymentKit.xmlToMap(xmlResult); + //预付单信息 + String prepay_id = result.get("prepay_id"); + + /* + 小程序调起支付数据签名 + */ + Map packageParams = new HashMap<>(); + packageParams.put("appId", wxAppid); + packageParams.put("timeStamp", System.currentTimeMillis() / 1000 + ""); + packageParams.put("nonceStr", System.currentTimeMillis() + ""); + packageParams.put("package", "prepay_id=" + prepay_id); + packageParams.put("signType", "MD5"); + String packageSign = null; + try { + packageSign = WXPayUtil.generateSignature(packageParams, paykey); + } catch (Exception e) { + e.printStackTrace(); + } + packageParams.put("paySign", packageSign); + packageParams.put("orderId", orderId.toString()); + return ResponseData.success(packageParams); + } + + + + /*** + * 获取客户端ip地址 + * @param request + */ + public String getIP(final HttpServletRequest request) { + String ipStr = request.getHeader("x-forwarded-for"); + if (StringUtils.isBlank(ipStr) || "unknown".equalsIgnoreCase(ipStr)) { + ipStr = request.getHeader("Proxy-Client-IP"); + } + if (StringUtils.isBlank(ipStr) || "unknown".equalsIgnoreCase(ipStr)) { + ipStr = request.getHeader("WL-Proxy-Client-IP"); + } + if (StringUtils.isBlank(ipStr) || "unknown".equalsIgnoreCase(ipStr)) { + ipStr = request.getRemoteAddr(); + } + + // 多个路由时,取第一个非unknown的ip + final String[] arr = ipStr.split(","); + for (final String str : arr) { + if (!"unknown".equalsIgnoreCase(str)) { + ipStr = str; + break; + } + } + //目的是将localhost访问对应的ip 0:0:0:0:0:0:0:1 转成 127.0.0.1。 + return "0:0:0:0:0:0:0:1".equals(ipStr) ? "127.0.0.1" : ipStr; + } + + + /** + * 功能描述:微信支付第一步——统一下单 + * + * @param data + * @param key + * @return + * @author yanzy 2016-1-18 下午10:01:20 + */ + private String unifiedOrder(WxPaySendData data, String key) { + System.out.println("=========================data:" + data); + System.out.println("=========================key:" + key); + //统一下单支付 + String returnXml = null; + try { + //生成sign签名 + SortedMap parameters = new TreeMap(); + parameters.put("appid", data.getAppid()); + parameters.put("attach", data.getAttach()); + parameters.put("body", data.getBody()); +// parameters.put("key", data.getKey()); + parameters.put("mch_id", data.getMch_id()); + parameters.put("nonce_str", data.getNonce_str()); + parameters.put("notify_url", data.getNotify_url()); + parameters.put("openid", data.getOpenid()); + parameters.put("out_trade_no", data.getOut_trade_no()); + parameters.put("spbill_create_ip", data.getSpbill_create_ip()); + parameters.put("total_fee", data.getTotal_fee()); + parameters.put("trade_type", data.getTrade_type()); +// parameters.put("device_info", data.getDevice_info()); + // data.setSign(WeiXinUtil.createSign(characterEncoding,parameters)); + data.setSign(createSign(parameters, key)); + + XStream xs = new XStream(new DomDriver("UTF-8", new XmlFriendlyNameCoder("-_", "_"))); + xs.alias("xml", WxPaySendData.class); + String xml = xs.toXML(data); + returnXml = HttpRequestUtil.sendPostXml("https://api.mch.weixin.qq.com/pay/unifiedorder", xml); + + System.out.println("=============================返回结果:" + returnXml); + } catch (Exception e) { + } + return returnXml; + } + + private String createSign(SortedMap parameters, String key) { + StringBuffer sb = new StringBuffer(); + Set es = parameters.entrySet();//所有参与传参的参数按照accsii排序(升序) + Iterator it = es.iterator(); + while (it.hasNext()) { + Map.Entry entry = (Map.Entry) it.next(); + String k = (String) entry.getKey(); + Object v = entry.getValue(); + if (null != v && !"".equals(v) + && !"sign".equals(k) && !"key".equals(k)) { + sb.append(k + "=" + v + "&"); + } + } + sb.append("key=" + key); + String sign = MD5Util.MD5Encode(sb.toString(), "UTF-8").toUpperCase(); + return sign; + } + + /** + * @param price + * @return + * @Description TD: 2微信 + * @Return cn.hutool.json.JSONObject + * @Author sangsang + * @Date 2020/2/15 17:51 + */ + @Override + public ResponseData wxPayMethodApplet(String orderNum, BigDecimal price, String openId, String notify) { + + Map reqParams = new HashMap<>(); + //微信分配的小程序ID + reqParams.put("appid", wxAppid); + //微信支付分配的商户号 + reqParams.put("mch_id", mchid); + //随机字符串 + reqParams.put("nonce_str", RandomUtil.randomNumbers(10)); + //签名类型 + reqParams.put("sign_type", "MD5"); + //充值订单 商品描述 + reqParams.put("body", "订单支付"); + //商户订单号 + reqParams.put("out_trade_no", orderNum); + log.info("业务订单号是 reqParams.get(out_trade_no)=" + reqParams.get("out_trade_no")); + //订单总金额,单位为分 + reqParams.put("total_fee", String.valueOf(price.multiply(new BigDecimal(100)).intValue())); + //终端IP + reqParams.put("spbill_create_ip", "118.24.78.87"); + //通知地址 + reqParams.put("notify_url", notify); + log.info(reqParams.get("notify_url")); + //交易类型 + reqParams.put("trade_type", "JSAPI"); + //用户标识 + reqParams.put("openid", openId); + //签名 + String sign = null; + try { + sign = WXPayUtil.generateSignature(reqParams, paykey); + + } catch (Exception e) { + e.printStackTrace(); + } + reqParams.put("sign", sign); + + /* + 调用支付定义下单API,返回预付单信息 prepay_id + */ + String xmlResult = PaymentApi.pushOrder(reqParams); + log.info(xmlResult); + Map result = PaymentKit.xmlToMap(xmlResult); + //预付单信息 + String prepay_id = result.get("prepay_id"); + + /* + 小程序调起支付数据签名 + */ + Map packageParams = new HashMap<>(); + packageParams.put("appId", wxAppid); + packageParams.put("timeStamp", System.currentTimeMillis() / 1000 + ""); + packageParams.put("nonceStr", System.currentTimeMillis() + ""); + packageParams.put("package", "prepay_id=" + prepay_id); + packageParams.put("signType", "MD5"); + String packageSign = null; + try { + packageSign = WXPayUtil.generateSignature(packageParams, paykey); + } catch (Exception e) { + e.printStackTrace(); + } + packageParams.put("paySign", packageSign); + return ResponseData.success(packageParams); + } + + + + /** + * 微信退款 + * + * @return + */ + @Override + public ResponseData wxRefund(String orderNo, BigDecimal payPrice, BigDecimal refundPrice) { + WxRefundData wxPaySendData; + try { + wxPaySendData = new WxRefundData(wxAppid, + mchid, UUID.randomUUID().toString().replace("-", ""), + orderNo, UUID.randomUUID().toString().replace("-", ""), + payPrice.multiply(new BigDecimal(100)).intValue(), + refundPrice.multiply(new BigDecimal(100)).intValue(), mchid); + WxRefundData refund = refund(wxPaySendData, paykey); + if ("FAIL".equals(refund.getResult_code())) { + return ResponseData.error(refund.getErr_code_des()); + } + log.info("微信退款成功"); + } catch (Exception e) { + log.info("微信退款失败"); + e.printStackTrace(); + } + return ResponseData.success(null); + + } + + /** + * 功能描述:微信退款 + * + * @param data + * @param key + * @return + * @author yanzy 2016-10-25 下午01:52:19 + */ + private WxRefundData refund(WxRefundData data, String key) { + String returnXml = null; + WxRefundData reData = null; + try { + //生成sign签名 + SortedMap parameters = new TreeMap(); + parameters.put("appid", data.getAppid()); + parameters.put("mch_id", data.getMch_id()); + parameters.put("nonce_str", data.getNonce_str()); + parameters.put("out_trade_no", data.getOut_trade_no()); + parameters.put("out_refund_no", data.getOut_refund_no()); + parameters.put("total_fee", data.getTotal_fee()); + parameters.put("refund_fee", data.getRefund_fee()); + parameters.put("op_user_id", data.getOp_user_id()); + log.info("SIGN:" + createSign(parameters, key)); + data.setSign(createSign(parameters, key)); + XStream xs = new XStream(new DomDriver("UTF-8", new XmlFriendlyNameCoder("-_", "_"))); + xs.alias("xml", WxRefundData.class); + String xml = xs.toXML(data); + log.info("微信退款xml为:\n" + xml); + //防止小程序和微信用不一样的参数 此处先判断 + returnXml = HttpRequestUtil.sendCertPostXml("https://api.mch.weixin.qq.com/secapi/pay/refund", data.getMch_id(), xml, refundFile); + log.info("返回结果:" + returnXml); + + XStream xs1 = new XStream(new DomDriver()); + xs1.alias("xml", WxRefundData.class); + reData = (WxRefundData) xs1.fromXML(returnXml); + + log.info("==========解析结果==============" + reData.getResult_code()); + return reData; + + } catch (Exception e) { + e.printStackTrace(); + } + reData = new WxRefundData(); + reData.setResult_code("FAIL"); + return reData; + } +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/pay/utils/AlipayCore.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/pay/utils/AlipayCore.java new file mode 100644 index 0000000..201dbb5 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/pay/utils/AlipayCore.java @@ -0,0 +1,95 @@ +package com.ruoyi.pay.utils; + +import javax.servlet.http.HttpServletRequest; +import java.util.*; + + + + +/* * + *类名:AlipayFunction + *功能:支付宝接口公用函数类 + *详细:该类是请求、通知返回两个文件所调用的公用函数核心处理文件,不需要修改 + *版本:3.3 + *日期:2012-08-14 + *说明: + *以下代码只是为了方便商户测试而提供的样例代码,商户可以根据自己网站的需要,按照技术文档编写,并非一定要使用该代码。 + *该代码仅供学习和研究支付宝接口使用,只是提供一个参考。 + */ + +public class AlipayCore { + + /** + * 除去数组中的空值和签名参数 + * + * @param sArray 签名参数组 + * @return 去掉空值与签名参数后的新签名参数组 + */ + public static Map paraFilter(Map sArray) { + + Map result = new HashMap(); + + if (sArray == null || sArray.size() <= 0) { + return result; + } + + for (String key : sArray.keySet()) { + String value = sArray.get(key); + if (value == null || "".equals(value) || "sign".equalsIgnoreCase(key) + || "sign_type".equalsIgnoreCase(key)) { + continue; + } + result.put(key, value); + } + + return result; + } + + /** + * 把数组所有元素排序,并按照“参数=参数值”的模式用“&”字符拼接成字符串 + * + * @param params 需要排序并参与字符拼接的参数组 + * @return 拼接后字符串 + */ + public static String createLinkString(Map params) { + + List keys = new ArrayList(params.keySet()); + Collections.sort(keys); + + String prestr = ""; + + for (int i = 0; i < keys.size(); i++) { + String key = keys.get(i); + String value = params.get(key); + + if (i == keys.size() - 1) { + //拼接时,不包括最后一个&字符 + prestr = prestr + key + "=" + value; + } else { + prestr = prestr + key + "=" + value + "&"; + } + } + + return prestr; + } + + + /** + * 功能描述: 格式化参数 + * + * @param request + * @return + * @author yangliu 2016年5月9日 上午9:30:15 + */ + public static Map updateMap(HttpServletRequest request) { + Map map = request.getParameterMap(); + Map params = new HashMap(); + for (String key : map.keySet()) { + String[] str = map.get(key); + if (str != null && str.length > 0) { + params.put(key, str[0]); + } + } + return params; + } +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/pay/utils/HttpRequestUtil.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/pay/utils/HttpRequestUtil.java new file mode 100644 index 0000000..b4c5179 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/pay/utils/HttpRequestUtil.java @@ -0,0 +1,229 @@ +package com.ruoyi.pay.utils; + +import org.apache.http.HttpEntity; +import org.apache.http.client.methods.CloseableHttpResponse; +import org.apache.http.client.methods.HttpPost; +import org.apache.http.conn.ssl.SSLConnectionSocketFactory; +import org.apache.http.entity.StringEntity; +import org.apache.http.impl.client.CloseableHttpClient; +import org.apache.http.impl.client.HttpClients; +import org.apache.http.ssl.SSLContexts; +import org.apache.http.util.EntityUtils; +import org.dom4j.Document; +import org.dom4j.DocumentException; +import org.dom4j.Element; +import org.dom4j.io.SAXReader; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javax.net.ssl.SSLContext; +import javax.servlet.http.HttpServletRequest; +import java.io.*; +import java.net.HttpURLConnection; +import java.net.URL; +import java.net.URLConnection; +import java.security.KeyStore; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * #(c) IFlytek weixin
+ *

+ * 版本说明: $id:$
+ *

+ * 功能说明: java https/http 请求公共类 + *

+ *
创建说明: 2014-5-13 上午08:52:24 L H T 创建文件
+ *

+ * 修改历史:
+ */ +public class HttpRequestUtil { + private static Logger log = LoggerFactory.getLogger(HttpRequestUtil.class); + + /** + * 解析微信发来的请求(XML) + * + * @param request + * @return + * @throws Exception + */ + @SuppressWarnings("unchecked") + public static Map parseXml(HttpServletRequest request) { + // 将解析结果存储在HashMap中 + Map map = new HashMap(); + + // 从request中取得输入流 + InputStream inputStream = null; + try { + inputStream = request.getInputStream(); + } catch (IOException e) { + e.printStackTrace(); + } + // 读取输入流 + SAXReader reader = new SAXReader(); + Document document = null; + try { + document = reader.read(inputStream); + } catch (DocumentException e) { + e.printStackTrace(); + } + // 得到xml根元素 + Element root = document.getRootElement(); + // 得到根元素的所有子节点 + List elementList = root.elements(); + + // 遍历所有子节点 + for (Element e : elementList) { + map.put(e.getName(), e.getText()); + } + // 释放资源 + try { + inputStream.close(); + } catch (IOException e) { + e.printStackTrace(); + } + return map; + } + + public static String sendCertPostXml(String url, String mac_id, String data, String filePath) { + CloseableHttpResponse response = null; + try { + KeyStore keyStore = KeyStore.getInstance("PKCS12"); + FileInputStream instream = new FileInputStream(new File(filePath)); + try { + keyStore.load(instream, mac_id.toCharArray()); + } finally { + instream.close(); + } + + // Trust own CA and all self-signed certs + SSLContext sslcontext = SSLContexts.custom().loadKeyMaterial( + keyStore, mac_id.toCharArray()).build(); + // Allow TLSv1 protocol only + SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory( + sslcontext, + SSLConnectionSocketFactory.BROWSER_COMPATIBLE_HOSTNAME_VERIFIER); + CloseableHttpClient httpclient = HttpClients.custom() + .setSSLSocketFactory(sslsf).build(); + + HttpPost httpost = new HttpPost(url); // 设置响应头信息 + httpost.addHeader("Connection", "keep-alive"); + httpost.addHeader("Accept", "*/*"); + httpost.addHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8"); + httpost.addHeader("Host", "api.mch.weixin.qq.com"); + httpost.addHeader("X-Requested-With", "XMLHttpRequest"); + httpost.addHeader("Cache-Control", "max-age=0"); + httpost.addHeader("User-Agent", "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0) "); + httpost.setEntity(new StringEntity(data, "UTF-8")); + response = httpclient.execute(httpost); + HttpEntity entity = response.getEntity(); + + System.out.println("----------------------------------------"); + System.out.println(response.getStatusLine()); + if (entity != null) { + String jsonStr = EntityUtils.toString(entity, "UTF-8"); + return jsonStr; + + + } + EntityUtils.consume(entity); + + response.close(); + httpclient.close(); + } catch (Exception e) { + e.printStackTrace(); + } + return null; + } + + public static String sendPostXml(String sendUrl, String xml) { + try { + byte[] bb = xml.getBytes("UTF-8"); + //请求地址 + URL url = new URL(sendUrl); + HttpURLConnection conn = (HttpURLConnection) url.openConnection(); + conn.setRequestMethod("POST"); + conn.setConnectTimeout(5 * 1000);//设置超时的时间 + conn.setDoInput(true); + conn.setDoOutput(true);//如果通过post提交数据,必须设置允许对外输出数据 + conn.setUseCaches(false); + conn.setRequestProperty("Content-Type", "application/xml; charset=UTF-8"); + conn.setRequestProperty("Content-Length", String.valueOf(bb.length)); + conn.connect(); + DataOutputStream out = new DataOutputStream(conn.getOutputStream()); + out.write(bb); //写入请求的字符串 + out.flush(); + out.close(); + //请求返回的状态 + if (conn.getResponseCode() == 200) { + //请求返回的数据 + InputStream in = conn.getInputStream(); + String a = null; + try { + byte[] data1 = new byte[in.available()]; + in.read(data1); + //转成字符串 + a = new String(data1, "UTF-8"); +// System.out.println(a); + return a; + } catch (Exception e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + } + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return null; + } + + private final static int CONNECT_TIMEOUT = 5000; + private final static String DEFAULT_ENCODING = "UTF-8"; + + public static String postData(String urlStr, String data) { + return postData(urlStr, data, null); + } + + public static String postData(String urlStr, String data, String contentType) { + BufferedReader reader = null; + try { + URL url = new URL(urlStr); + URLConnection conn = url.openConnection(); + conn.setDoOutput(true); + conn.setConnectTimeout(CONNECT_TIMEOUT); + conn.setReadTimeout(CONNECT_TIMEOUT); + if (contentType != null) { + conn.setRequestProperty("content-type", contentType); + } + OutputStreamWriter writer = new OutputStreamWriter(conn.getOutputStream(), DEFAULT_ENCODING); + if (data == null) { + data = ""; + } + writer.write(data); + writer.flush(); + writer.close(); + reader = new BufferedReader(new InputStreamReader(conn.getInputStream(), DEFAULT_ENCODING)); + StringBuilder sb = new StringBuilder(); + String line = null; + while ((line = reader.readLine()) != null) { + sb.append(line); + sb.append("\r\n"); + } + return sb.toString(); + } catch (IOException e) { + } finally { + try { + if (reader != null) { + reader.close(); + } + } catch (IOException e) { + } + } + return null; + + } + + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/pay/utils/PayUtil.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/pay/utils/PayUtil.java new file mode 100644 index 0000000..ac7e08f --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/pay/utils/PayUtil.java @@ -0,0 +1,212 @@ +package com.ruoyi.pay.utils; + +import cn.hutool.core.util.ObjectUtil; +import com.ruoyi.code.PublicCommon; +import com.ruoyi.common.exception.enums.CoreExceptionEnum; +import com.ruoyi.enums.WalletDetailEnums; +import com.ruoyi.frequency.givewallerecord.service.GiveWalletRecordService; +import com.ruoyi.frequency.wallerecord.service.WalletRecordService; +import com.ruoyi.pay.config.Notifyurl; +import com.ruoyi.pay.enums.PayEnums; +import com.ruoyi.pay.enums.PaySourceEnums; +import com.ruoyi.pay.type.ali.service.AliPayService; +import com.ruoyi.pay.type.weixin.service.WXPayService; +import com.ruoyi.response.ResponseData; +import com.ruoyi.utils.BusinessUtil; +import com.ruoyi.utils.lakala.LakalaUtil; +import com.ruoyi.vo.UserVo; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Component; + +import java.math.BigDecimal; +import java.util.HashMap; +import java.util.Map; + +/** + * @author liwenlong + * @date 2023/2/11 13:50 + */ + +@Component +public class PayUtil { + + + @Value("${basepath.url}") + private String basePath; + + // @Value("${alipay.subject}") + private String subject; + + @Autowired + private AliPayService aliPayService; + + @Autowired + private WXPayService wxPayService; + + @Autowired + private WalletRecordService walletRecordService; + + @Autowired + private BusinessUtil businessUtil; + + @Autowired + private Notifyurl notifyurl; + + @Autowired + private LakalaUtil lakalaUtil; + + /** + * 支付 + * + * @param payType 支付类型 + * @param payPrice 支付金额 + * @param givePrice 赠送支付金额 + * @param payOrderNo 三方支付单号 + * @return + */ + public ResponseData pay(UserVo userVo, Long objectId, Integer payType, BigDecimal payPrice, BigDecimal givePrice, String payOrderNo, PaySourceEnums enums, WalletDetailEnums walletDetailEnums) { + + + //支付宝回调地址 + String aliReturnUrl = notifyurl.getReturnUrl(enums, 1); + + //微信回调地址 + String wxReturnUrl = notifyurl.getReturnUrl(enums, 2); + + //拉卡拉回调地址 + String lklReturnUrl = notifyurl.getReturnUrl(enums, 3); + + + ResponseData responseData = ResponseData.success(); + + //判断支付金额为0时 + if (payType != -1 && payPrice.compareTo(BigDecimal.ZERO) == 0) { + return responseData; + } + + switch (PayEnums.getPayEnums(payType)) { + case app_alipay: + //app支付宝 + responseData = aliPayService.aliPayUserPay(payOrderNo, payPrice, + basePath + aliReturnUrl, objectId); + break; + case h5_alipay: + //h5支付宝 + responseData = aliPayService.aliH5Pay(payOrderNo, payPrice, + basePath + aliReturnUrl, objectId); + break; + case app_weChat: + //app微信 + responseData = wxPayService.wxPayUserPay(payOrderNo, payPrice, + basePath + wxReturnUrl, objectId); + break; + case h5_WeChat: + //h5微信 + responseData = wxPayService.wxH5Pay(payOrderNo, payPrice, + basePath + wxReturnUrl, objectId); + break; + + case applet: + //获取openId + String openId = (String) businessUtil.getUserFieldValue(userVo, "openId"); + + //微信小程序 + responseData = wxPayService.wxAppletPay(payOrderNo, payPrice, openId, + basePath + wxReturnUrl, objectId); + + break; + case apple: + Map map = new HashMap<>(); + map.put("orderId", objectId); + responseData.setData(map); + break; + case balance: + walletRecordService.updateBalance(userVo, walletDetailEnums, objectId, payPrice.negate(), PublicCommon.Wallet.可提现); + map = new HashMap<>(); + map.put("orderId", objectId); + responseData.setData(map); + + //是否使用抵用金支付 + if (ObjectUtil.isNotEmpty(givePrice) && givePrice.compareTo(BigDecimal.ZERO) > 0) { + //抵用金 + giveWalletRecordService.updateGiveBalance(userVo, WalletDetailEnums.GIVE_ORDER_PAY, objectId, givePrice.negate(), PublicCommon.Wallet.可提现); + } + + break; + case lakala_ccss: + responseData = lakalaUtil.ccssCounterOrderTospecialCreate(payOrderNo, payPrice, objectId, basePath + lklReturnUrl); + break; + default: + responseData = responseData.error(CoreExceptionEnum.ERROR_PARAM); + } + + return responseData; + + } + + @Autowired + private GiveWalletRecordService giveWalletRecordService; + + /** + * 退款 + * + * @param payType 支付类型 + * @param payTotalPrice 支付总金额 + * @param returnPrice 退款金额 + * @param payOrderNo 支付订单号 + * @param aliReturnPayId + * @return + */ + public ResponseData refund(UserVo userVo, Long objectId, Integer payType, BigDecimal payTotalPrice, BigDecimal returnPrice, String payOrderNo, String aliReturnPayId, BigDecimal givePrice) { + + + ResponseData responseData = new ResponseData(); + + //判断支付金额为0时 + if (payType != -1 && returnPrice.compareTo(BigDecimal.ZERO) == 0) { + return responseData.error(CoreExceptionEnum.PRICE_ZERO); + } + + switch (PayEnums.getPayEnums(payType)) { + case app_alipay: + responseData = aliPayService.alipayRefund(payOrderNo, aliReturnPayId, returnPrice); + break; + case h5_alipay: + //h5支付宝 + responseData = aliPayService.alipayRefund(payOrderNo, aliReturnPayId, returnPrice); + break; + case app_weChat: + //app微信 + responseData = wxPayService.wxRefund(payOrderNo, payTotalPrice, returnPrice); + break; + case h5_WeChat: + responseData = wxPayService.wxRefund(payOrderNo, payTotalPrice, returnPrice); + break; + case applet: + responseData = wxPayService.wxRefund(payOrderNo, payTotalPrice, returnPrice); + break; + case apple: + break; + case balance: + walletRecordService.updateBalance(userVo, WalletDetailEnums.ORDER_RETURN, objectId, returnPrice, PublicCommon.Wallet.可提现); + break; + case lakala_ccss: + walletRecordService.updateBalance(userVo, WalletDetailEnums.ORDER_RETURN, objectId, returnPrice, PublicCommon.Wallet.可提现); + break; + default: + responseData = responseData.error(CoreExceptionEnum.ERROR_PARAM); + ; + + } + + //退还抵用金 + if (ObjectUtil.isNotEmpty(givePrice) && givePrice.compareTo(BigDecimal.ZERO) > 0) { + giveWalletRecordService.updateGiveBalance(userVo, WalletDetailEnums.GIVE_ORDER_RETURN, objectId, givePrice, PublicCommon.Wallet.可提现); + } + + return responseData; + + } + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/pay/utils/PaymentApi.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/pay/utils/PaymentApi.java new file mode 100644 index 0000000..819a75d --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/pay/utils/PaymentApi.java @@ -0,0 +1,276 @@ +package com.ruoyi.pay.utils; + +import cn.hutool.http.HttpUtil; + +import java.io.UnsupportedEncodingException; +import java.util.HashMap; +import java.util.Map; + +/** + * @program: xboot-plus + * @description: 微信支付api + * @author: fei + * @create: 2019-10-18 13:55 + **/ +public class PaymentApi { + + private PaymentApi() {} + + // 文档地址:https://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=9_1 + private static String unifiedOrderUrl = "https://api.mch.weixin.qq.com/pay/unifiedorder"; + + /** + * 交易类型枚举 + * WAP的文档:https://pay.weixin.qq.com/wiki/doc/api/wap.php?chapter=15_1 + * @author L.cm + *

+     * email: 596392912@qq.com
+     * site: http://www.dreamlu.net
+     * date: 2015年10月27日 下午9:46:27
+     * 
+ */ + public enum TradeType { + JSAPI, NATIVE, APP, WAP, MWEB + } + + /** + * 统一下单 + * @param params 参数map + * @return String + */ + public static String pushOrder(Map params) { + return HttpUtil.post(unifiedOrderUrl, PaymentKit.toXml(params)); + } + + private static Map request(String url, Map params, String paternerKey) throws UnsupportedEncodingException { + params.put("nonce_str", System.currentTimeMillis() + ""); + String sign = PaymentKit.createSign(params, paternerKey); + params.put("sign", sign); + String xmlStr = HttpUtil.post(url, PaymentKit.toXml(params)); + return PaymentKit.xmlToMap(xmlStr); + } + + /** + * 文档说明:https://pay.weixin.qq.com/wiki/doc/api/wap.php?chapter=15_4 + *
+     * @param appId 公众账号ID         是    String(32)    wx8888888888888888    微信分配的公众账号ID
+     * 随机字符串         noncestr    是    String(32)    5K8264ILTKCH16CQ2502SI8ZNMTM67VS    随机字符串,不长于32位。推荐随机数生成算法
+     * 订单详情扩展字符串    package        是    String(32)    WAP    扩展字段,固定填写WAP
+     * @param prepayId 预支付交易会话标识    是    String(64)    wx201410272009395522657a690389285100    微信统一下单接口返回的预支付回话标识,用于后续接口调用中使用,该值有效期为2小时
+     * 签名                 sign        是    String(32)    C380BEC2BFD727A4B6845133519F3AD6    签名,详见签名生成算法
+     * 时间戳            timestamp    是    String(32)    1414561699    当前的时间,其他详见时间戳规则
+     * @param paternerKey 签名密匙
+     * 
+ * @return {String} + */ + public static String getDeepLink(String appId, String prepayId, String paternerKey) throws UnsupportedEncodingException { + Map params = new HashMap(); + params.put("appid", appId); + params.put("noncestr", System.currentTimeMillis() + ""); + params.put("package", "WAP"); + params.put("prepayid", prepayId); + params.put("timestamp", System.currentTimeMillis() / 1000 + ""); + String sign = PaymentKit.createSign(params, paternerKey); + params.put("sign", sign); + + String string1 = PaymentKit.packageSign(params, true); + + String string2 = ""; + try { string2 = PaymentKit.urlEncode(string1); } catch (UnsupportedEncodingException e) {} + + return "weixin://wap/pay?" + string2; + } + + // 文档地址:https://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=9_2 + private static String orderQueryUrl = "https://api.mch.weixin.qq.com/pay/orderquery"; + + /** + * 根据商户订单号查询信息 + * @param appid 公众账号ID + * @param mch_id 商户号 + * @param paternerKey 商户密钥 + * @param transaction_id 微信订单号 + * @return 回调信息 + */ + public static Map queryByTransactionId(String appid, String mch_id, String paternerKey, String transaction_id) throws UnsupportedEncodingException { + Map params = new HashMap<>(); + params.put("appid", appid); + params.put("mch_id", mch_id); + params.put("transaction_id", transaction_id); + return request(orderQueryUrl, params, paternerKey); + } + + /** + * 根据商户订单号查询信息 + * @param appid 公众账号ID + * @param mch_id 商户号 + * @param paternerKey 商户密钥 + * @param out_trade_no 商户订单号 + * @return 回调信息 + */ + public static Map queryByOutTradeNo(String appid, String mch_id, String paternerKey, String out_trade_no) throws UnsupportedEncodingException { + Map params = new HashMap<>(); + params.put("appid", appid); + params.put("mch_id", mch_id); + params.put("out_trade_no", out_trade_no); + return request(orderQueryUrl, params, paternerKey); + } + + // 文档地址:https://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=9_3 + private static String closeOrderUrl = "https://api.mch.weixin.qq.com/pay/closeorder"; + + /** + * 关闭订单 + * @param appid 公众账号ID + * @param mch_id 商户号 + * @param paternerKey 商户密钥 + * @param out_trade_no 商户订单号 + * @return 回调信息 + */ + public static Map closeOrder(String appid, String mch_id, String paternerKey, String out_trade_no) throws UnsupportedEncodingException { + Map params = new HashMap(); + params.put("appid", appid); + params.put("mch_id", mch_id); + params.put("out_trade_no", out_trade_no); + return request(closeOrderUrl, params, paternerKey); + } + + // 申请退款文档地址:https://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=9_4 + public static String refundUrl = "https://api.mch.weixin.qq.com/secapi/pay/refund"; + + + // 查询退款文档地址:https://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=9_5 + private static String refundQueryUrl = "https://api.mch.weixin.qq.com/pay/refundquery"; + + private static Map baseRefundQuery(Map params, String appid, String mch_id, String paternerKey) throws UnsupportedEncodingException { + params.put("appid", appid); + params.put("mch_id", mch_id); + return request(refundQueryUrl, params, paternerKey); + } + + /** + * 根据微信订单号查询退款 + * @param appid 公众账号ID + * @param mch_id 商户号 + * @param paternerKey 商户密钥 + * @param transaction_id 微信订单号 + * @return map + */ + public static Map refundQueryByTransactionId(String appid, String mch_id, String paternerKey, String transaction_id) throws UnsupportedEncodingException { + Map params = new HashMap(); + params.put("transaction_id", transaction_id); + return baseRefundQuery(params, appid, mch_id, paternerKey); + } + + /** + * 根据微信订单号查询退款 + * @param appid 公众账号ID + * @param mch_id 商户号 + * @param paternerKey 商户密钥 + * @param out_trade_no 商户订单号 + * @return map + */ + public static Map refundQueryByOutTradeNo(String appid, String mch_id, String paternerKey, String out_trade_no) throws UnsupportedEncodingException { + Map params = new HashMap<>(); + params.put("out_trade_no", out_trade_no); + return baseRefundQuery(params, appid, mch_id, paternerKey); + } + + /** + * 根据微信订单号查询退款 + * @param appid 公众账号ID + * @param mch_id 商户号 + * @param paternerKey 商户密钥 + * @param out_refund_no 商户退款单号 + * @return map + */ + public static Map refundQueryByOutRefundNo(String appid, String mch_id, String paternerKey, String out_refund_no) throws UnsupportedEncodingException { + Map params = new HashMap<>(); + params.put("out_refund_no", out_refund_no); + return baseRefundQuery(params, appid, mch_id, paternerKey); + } + + /** + * 根据微信订单号查询退款 + * @param appid 公众账号ID + * @param mch_id 商户号 + * @param paternerKey 商户密钥 + * @param refund_id 微信退款单号 + * @return map + */ + public static Map refundQueryByRefundId(String appid, String mch_id, String paternerKey, String refund_id) throws UnsupportedEncodingException { + Map params = new HashMap<>(); + params.put("refund_id", refund_id); + return baseRefundQuery(params, appid, mch_id, paternerKey); + } + + private static String downloadBillUrl = "https://api.mch.weixin.qq.com/pay/downloadbill"; + + /** + *
+     * ALL,返回当日所有订单信息,默认值
+     * SUCCESS,返回当日成功支付的订单
+     * REFUND,返回当日退款订单
+     * REVOKED,已撤销的订单
+     * 
+ */ + public static enum BillType { + ALL, SUCCESS, REFUND, REVOKED + } + + /** + * 下载对账单 + *
+     * 公众账号ID    appid        是    String(32)    wx8888888888888888    微信分配的公众账号ID(企业号corpid即为此appId)
+     * 商户号        mch_id        是    String(32)    1900000109    微信支付分配的商户号
+     * 设备号        device_info    否    String(32)    013467007045764    微信支付分配的终端设备号
+     * 随机字符串    nonce_str    是    String(32)    5K8264ILTKCH16CQ2502SI8ZNMTM67VS    随机字符串,不长于32位。推荐随机数生成算法
+     * 签名        sign        是    String(32)    C380BEC2BFD727A4B6845133519F3AD6    签名,详见签名生成算法
+     * 对账单日期    bill_date    是    String(8)    20140603    下载对账单的日期,格式:20140603
+     * 账单类型        bill_type    否    String(8)
+     * 
+ * @param appid 公众账号ID + * @param mch_id 商户号 + * @param paternerKey 签名密匙 + * @param billDate 对账单日期 + * @return String + */ + public static String downloadBill(String appid, String mch_id, String paternerKey, String billDate) throws UnsupportedEncodingException { + return downloadBill(appid, mch_id, paternerKey, billDate, null); + } + + /** + * 下载对账单 + *
+     * 公众账号ID    appid        是    String(32)    wx8888888888888888    微信分配的公众账号ID(企业号corpid即为此appId)
+     * 商户号        mch_id        是    String(32)    1900000109    微信支付分配的商户号
+     * 设备号        device_info    否    String(32)    013467007045764    微信支付分配的终端设备号
+     * 随机字符串    nonce_str    是    String(32)    5K8264ILTKCH16CQ2502SI8ZNMTM67VS    随机字符串,不长于32位。推荐随机数生成算法
+     * 签名        sign        是    String(32)    C380BEC2BFD727A4B6845133519F3AD6    签名,详见签名生成算法
+     * 对账单日期    bill_date    是    String(8)    20140603    下载对账单的日期,格式:20140603
+     * 账单类型        bill_type    否    String(8)
+     * 
+ * @param appid 公众账号ID + * @param mch_id 商户号 + * @param paternerKey 签名密匙 + * @param billDate 对账单日期 + * @param billType 账单类型 + * @return String + */ + public static String downloadBill(String appid, String mch_id, String paternerKey, String billDate, BillType billType) throws UnsupportedEncodingException { + Map params = new HashMap<>(); + params.put("appid", appid); + params.put("mch_id", mch_id); + params.put("nonce_str", System.currentTimeMillis() + ""); + params.put("bill_date", billDate); + if (null != billType) { + params.put("bill_type", billType.name()); + } else { + params.put("bill_type", BillType.ALL.name()); + } + String sign = PaymentKit.createSign(params, paternerKey); + params.put("sign", sign); + return HttpUtil.post(downloadBillUrl, PaymentKit.toXml(params)); + } + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/pay/utils/PaymentKit.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/pay/utils/PaymentKit.java new file mode 100644 index 0000000..fe85dd1 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/pay/utils/PaymentKit.java @@ -0,0 +1,126 @@ +package com.ruoyi.pay.utils; + +import com.baomidou.mybatisplus.core.toolkit.StringUtils; +import com.ijpay.core.XmlHelper; +import org.apache.commons.codec.Charsets; + +import java.io.UnsupportedEncodingException; +import java.net.URLEncoder; +import java.util.Map; +import java.util.TreeMap; + + +/** + * @program: xboot-plus + * @description: 微信支付的统一下单工具类 + * @author: fei + * @create: 2019-10-18 13:56 + **/ +public class PaymentKit { + + /** + * 组装签名的字段 + * + * @param params 参数 + * @param urlEncoder 是否urlEncoder + * @return String + */ + public static String packageSign(Map params, boolean urlEncoder) throws UnsupportedEncodingException { + // 先将参数以其参数名的字典序升序进行排序 + TreeMap sortedParams = new TreeMap<>(params); + // 遍历排序后的字典,将所有参数按"key=value"格式拼接在一起 + StringBuilder sb = new StringBuilder(); + boolean first = true; + for (Map.Entry param : sortedParams.entrySet()) { + String value = param.getValue(); + if (StringUtils.isBlank(value)) { + continue; + } + if (first) { + first = false; + } else { + sb.append("&"); + } + sb.append(param.getKey()).append("="); + if (urlEncoder) { + value = urlEncode(value); + } + sb.append(value); + } + return sb.toString(); + } + + /** + * urlEncode + * + * @param src 微信参数 + * @return String + * @throws UnsupportedEncodingException 编码错误 + */ + public static String urlEncode(String src) throws UnsupportedEncodingException { + return URLEncoder.encode(src, Charsets.UTF_8.name()).replace("+", "%20"); + } + + /** + * 生成签名 + * + * @param params 参数 + * @param paternerKey 支付密钥 + * @return sign + */ + public static String createSign(Map params, String paternerKey) throws UnsupportedEncodingException { + // 生成签名前先去除sign + params.remove("sign"); + String stringA = packageSign(params, false); + String stringSignTemp = stringA + "&key=" + paternerKey; + return Tools.md5(stringSignTemp).toUpperCase(); + } + + /** + * 支付异步通知时校验sign + * + * @param params 参数 + * @param paternerKey 支付密钥 + * @return {boolean} + */ + public static boolean verifyNotify(Map params, String paternerKey) throws UnsupportedEncodingException { + String sign = params.get("sign"); + String localSign = PaymentKit.createSign(params, paternerKey); + return sign.equals(localSign); + } + + /** + * 微信下单,map to xml + * + * @param params 参数 + * @return String + */ + public static String toXml(Map params) { + StringBuilder xml = new StringBuilder(); + xml.append(""); + for (Map.Entry entry : params.entrySet()) { + String key = entry.getKey(); + String value = entry.getValue(); + // 略过空值 + if (StringUtils.isBlank(value)) { + continue; + } + xml.append("<").append(key).append(">"); + xml.append(entry.getValue()); + xml.append(""); + } + xml.append(""); + return xml.toString(); + } + + /** + * 针对支付的xml,没有嵌套节点的简单处理 + * + * @param xmlStr xml字符串 + * @return map集合 + */ + public static Map xmlToMap(String xmlStr) { + XmlHelper xmlHelper = XmlHelper.of(xmlStr); + return xmlHelper.toMap(); + } +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/pay/utils/Tools.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/pay/utils/Tools.java new file mode 100644 index 0000000..6c3979e --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/pay/utils/Tools.java @@ -0,0 +1,391 @@ +package com.ruoyi.pay.utils; + + +import com.baomidou.mybatisplus.core.toolkit.StringUtils; + +import javax.servlet.http.HttpServletRequest; +import java.io.BufferedReader; +import java.io.IOException; +import java.security.MessageDigest; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.*; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * @program: xboot-plus + * @description: + * @author: fei + * @create: 2019-10-18 14:02 + **/ +public class Tools { + /** + * 随机生成六位数验证码 + * + * @return + */ + public static int getRandomNum() { + Random r = new Random(); + return r.nextInt(900000) + 100000;//(Math.random()*(999999-100000)+100000) + } + + /** + * 字符串转换为字符串数组 + * + * @param str 字符串 + * @param splitRegex 分隔符 + * @return + */ + public static String[] str2StrArray(String str, String splitRegex) { + if (StringUtils.isBlank(str)) { + return null; + } + return str.split(splitRegex); + } + + /** + * 用默认的分隔符(,)将字符串转换为字符串数组 + * + * @param str 字符串 + * @return + */ + public static String[] str2StrArray(String str) { + return str2StrArray(str, ",\\s*"); + } + + /** + * 按照yyyy-MM-dd HH:mm:ss的格式,日期转字符串 + * + * @param date + * @return yyyy-MM-dd HH:mm:ss + */ + public static String date2Str(Date date) { + return date2Str(date, "yyyy-MM-dd HH:mm:ss"); + } + + /** + * 按照yyyy-MM-dd HH:mm:ss的格式,字符串转日期 + * + * @param date + * @return + */ + public static Date str2Date(String date) { + if (StringUtils.isNotBlank(date)) { + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + try { + return sdf.parse(date); + } catch (ParseException e) { + e.printStackTrace(); + } + return new Date(); + } else { + return null; + } + } + + /** + * 按照参数format的格式,日期转字符串 + * + * @param date + * @param format + * @return + */ + public static String date2Str(Date date, String format) { + if (date != null) { + SimpleDateFormat sdf = new SimpleDateFormat(format); + return sdf.format(date); + } else { + return ""; + } + } + + /** + * 把时间根据时、分、秒转换为时间段 + * + * @param StrDate + */ + public static String getTimes(String StrDate) { + String resultTimes = ""; + + SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + Date now; + + try { + now = new Date(); + Date date = df.parse(StrDate); + long times = now.getTime() - date.getTime(); + long day = times / (24 * 60 * 60 * 1000); + long hour = (times / (60 * 60 * 1000) - day * 24); + long min = ((times / (60 * 1000)) - day * 24 * 60 - hour * 60); + long sec = (times / 1000 - day * 24 * 60 * 60 - hour * 60 * 60 - min * 60); + + StringBuffer sb = new StringBuffer(); + //sb.append("发表于:"); + if (hour > 0) { + sb.append(hour + "小时前"); + } else if (min > 0) { + sb.append(min + "分钟前"); + } else { + sb.append(sec + "秒前"); + } + + resultTimes = sb.toString(); + } catch (ParseException e) { + e.printStackTrace(); + } + + return resultTimes; + } + + /** + * 验证邮箱 + * + * @param email + * @return + */ + public static boolean checkEmail(String email) { + boolean flag = false; + try { + String check = "^([a-z0-9A-Z]+[-|_|\\.]?)+[a-z0-9A-Z]@([a-z0-9A-Z]+(-[a-z0-9A-Z]+)?\\.)+[a-zA-Z]{2,}$"; + Pattern regex = Pattern.compile(check); + Matcher matcher = regex.matcher(email); + flag = matcher.matches(); + } catch (Exception e) { + flag = false; + } + return flag; + } + + /** + * 验证手机号码 + * + * @return + */ + public static boolean checkMobileNumber(String mobileNumber) { + Pattern p = null; + Matcher m = null; + boolean b = false; + p = Pattern.compile("^[1][3,4,5,7,8][0-9]{9}$"); // 验证手机号 + m = p.matcher(mobileNumber); + b = m.matches(); + return b; + } + + /** + * 将驼峰转下划线 + * + * @param param + * @return + */ + public static String camelToUnderline(String param) { + if (param == null || "".equals(param.trim())) { + return ""; + } + int len = param.length(); + StringBuilder sb = new StringBuilder(len); + for (int i = 0; i < len; i++) { + char c = param.charAt(i); + if (Character.isUpperCase(c)) { + sb.append("_"); + sb.append(Character.toLowerCase(c)); + } else { + sb.append(c); + } + } + return sb.toString(); + } + + /** + * 去掉下划线并将下划线后的首字母转为大写 + * + * @param str + * @return + */ + public static String transformStr(String str) { + //去掉数据库字段的下划线 + if (str.contains("_")) { + String[] names = str.split("_"); + String firstPart = names[0]; + String otherPart = ""; + for (int i = 1; i < names.length; i++) { + String word = names[i].replaceFirst(names[i].substring(0, 1), names[i].substring(0, 1).toUpperCase()); + otherPart += word; + } + str = firstPart + otherPart; + } + return str; + } + + /** + * 转换为map + * + * @param list + * @return + */ + public static List> transformMap(List> list) { + List> resultMapList = new ArrayList<>(); + + for (Map map : list) { + Map tempMap = new HashMap<>(); + for (String s : map.keySet()) { + tempMap.put(transformStr(s), map.get(s)); + } + resultMapList.add(tempMap); + } + return resultMapList; + } + + public static String clearHtml(String content, int p) { + if (null == content) { + return ""; + } + if (0 == p) { + return ""; + } + + Pattern p_script; + Matcher m_script; + Pattern p_style; + Matcher m_style; + Pattern p_html; + Matcher m_html; + + try { + String regEx_script = "<[\\s]*?script[^>]*?>[\\s\\S]*?<[\\s]*?\\/[\\s]*?script[\\s]*?>"; + //定义script的正则表达式{或]*?>[\\s\\S]*?<\\/script> } + String regEx_style = "<[\\s]*?style[^>]*?>[\\s\\S]*?<[\\s]*?\\/[\\s]*?style[\\s]*?>"; + //定义style的正则表达式{或]*?>[\\s\\S]*?<\\/style> } + String regEx_html = "<[^>]+>"; //定义HTML标签的正则表达式 + + p_script = Pattern.compile(regEx_script, Pattern.CASE_INSENSITIVE); + m_script = p_script.matcher(content); + content = m_script.replaceAll(""); //过滤script标签 + p_style = Pattern.compile(regEx_style, Pattern.CASE_INSENSITIVE); + m_style = p_style.matcher(content); + content = m_style.replaceAll(""); //过滤style标签 + + p_html = Pattern.compile(regEx_html, Pattern.CASE_INSENSITIVE); + m_html = p_html.matcher(content); + + content = m_html.replaceAll(""); //过滤html标签 + } catch (Exception e) { + return ""; + } + + if (content.length() > p) { + content = content.substring(0, p) + "..."; + } else { + content = content + "..."; + } + + return content; + } + + public static String md5(String str) { + try { + MessageDigest md = MessageDigest.getInstance("MD5"); + md.update(str.getBytes()); + byte[] b = md.digest(); + + int i; + + StringBuffer buf = new StringBuffer(""); + for (int offset = 0; offset < b.length; offset++) { + i = b[offset]; + if (i < 0) { + i += 256; + } + if (i < 16) { + buf.append("0"); + } + buf.append(Integer.toHexString(i)); + } + str = buf.toString(); + } catch (Exception e) { + e.printStackTrace(); + + } + return str; + } + + private static final String[] hexDigits = {"0", "1", "2", "3", "4", "5", + "6", "7", "8", "9", "a", "b", "c", "d", "e", "f"}; + + //这里主要是遍历8个byte,转化为16位进制的字符,即0-F + private static String byteArrayToHexString(byte[] b) { + StringBuffer resultSb = new StringBuffer(); + for (int i = 0; i < b.length; i++) { + resultSb.append(byteToHexString(b[i])); + } + + return resultSb.toString(); + } + + //这里是针对单个byte,256的byte通过16拆分为d1和d2 + private static String byteToHexString(byte b) { + int n = b; + if (n < 0) { + n += 256; + } + int d1 = n / 16; + int d2 = n % 16; + return hexDigits[d1] + hexDigits[d2]; + } + + + /** + * md5加密 + * + * @param origin + * @param charsetname + * @return + */ + private static String MD5Encode(String origin, String charsetname) { + String resultString = null; + try { + resultString = new String(origin); + MessageDigest md = MessageDigest.getInstance("MD5"); + if (charsetname == null || "".equals(charsetname)) { + resultString = byteArrayToHexString(md.digest(resultString.getBytes())); + } else { + resultString = byteArrayToHexString(md.digest(resultString.getBytes(charsetname))); + } + } catch (Exception exception) { + } + return resultString.toUpperCase(); + } + + /** + * 读取request + * + * @param request + * @return + */ + public static String readData(HttpServletRequest request) { + BufferedReader br = null; + + try { + StringBuilder e = new StringBuilder(); + br = request.getReader(); + String line = null; + + while ((line = br.readLine()) != null) { + e.append(line).append("\n"); + } + + line = e.toString(); + return line; + } catch (IOException var12) { + throw new RuntimeException(var12); + } finally { + if (br != null) { + try { + br.close(); + } catch (IOException var11) { + } + } + + } + } +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/push/PushGoeasyUtil.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/push/PushGoeasyUtil.java new file mode 100644 index 0000000..1a2db68 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/push/PushGoeasyUtil.java @@ -0,0 +1,110 @@ +package com.ruoyi.push; + +import com.alibaba.fastjson.JSONObject; +import com.ruoyi.code.Token; +import com.ruoyi.enums.user.UserEnums; +import com.ruoyi.vo.UserVo; +import io.goeasy.GoEasy; +import io.goeasy.publish.GoEasyError; +import io.goeasy.publish.PublishListener; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Component; + +import java.util.HashMap; +import java.util.Map; + +/** + * @author a + * @date 2022/5/7 9:38 + */ +@Component +@Slf4j +public class PushGoeasyUtil { + + + @Value("${push.goeasy.regionHost}") + private String regionHost; + + @Value("${push.goeasy.appkey}") + private String appkey; + + /** + * @param title 标题 + * @param content 内容 + * @param objectId + * @param type + * @param messageType + */ + public void pushMessage(UserVo userVo, Integer messageType, String title, String content, Long objectId, Long messageId, Integer type) { + + GoEasy goEasy = new GoEasy(regionHost, appkey); + Map map = new HashMap<>(); + map.put("title", title);//消息标题 + map.put("content", content + "");//消息内容 + map.put("objectId", objectId + "");//主体id + map.put("messageType", messageType+"");//对应消息列表的类型 + map.put("messageId", messageId+"");//对应消息列表的id + map.put("type", type + "");//普通推送消息类型 + + String jsonString = JSONObject.toJSONString(map); + + String channel = ""; + + switch (UserEnums.getUserEnums(userVo.getUserType())){ + case customer: + channel = Token.customer + userVo.getUserId(); + break; + case store: + channel = Token.store + userVo.getUserId(); + break; + case sale: + channel = Token.sale + userVo.getUserId(); + break; + + case enterprise: + channel = Token.enterprise + userVo.getUserId(); + break; + + default: + throw new IllegalStateException("Unexpected value: " + userVo.getUserType()); + } + goEasy.publish(channel, jsonString, title, content, new PublishListener() { + @Override + public void onSuccess() { + log.info("消息发送成功"); + } + + @Override + public void onFailed(GoEasyError error) { + log.error("消息发送失败" + error.getCode() + " , " + error.getContent()); + } + }); + + + } + + public static void main(String[] args) { + GoEasy goEasy = new GoEasy("https://rest-hangzhou.goeasy.io", "BC-d4519ea15c3f4d67a0d923dc980cbdac"); + Map map = new HashMap<>(); + map.put("title", "b标题");//消息标题 + map.put("content", "消息内容");//消息内容 + map.put("objectId", "1111");//主体id +// map.put("type", type+""); + map.put("pushType", "2");//普通推送消息类型 + + String jsonString = JSONObject.toJSONString(map); + goEasy.publish("user511346310252466176", jsonString, "title", "content", new PublishListener() { + @Override + public void onSuccess() { + log.info("消息发送成功"); + } + + @Override + public void onFailed(GoEasyError error) { + log.error("消息发送失败" + error.getCode() + " , " + error.getContent()); + } + }); + } + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/push/PushToSingle.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/push/PushToSingle.java new file mode 100644 index 0000000..212c430 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/push/PushToSingle.java @@ -0,0 +1,321 @@ +package com.ruoyi.push; + +import cn.hutool.core.util.StrUtil; +import com.alibaba.fastjson.JSONObject; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.gexin.rp.sdk.base.IBatch; +import com.gexin.rp.sdk.base.IIGtPush; +import com.gexin.rp.sdk.base.impl.SingleMessage; +import com.gexin.rp.sdk.base.impl.Target; +import com.gexin.rp.sdk.base.payload.APNPayload; +import com.gexin.rp.sdk.http.IGtPush; +import com.gexin.rp.sdk.template.NotificationTemplate; +import com.gexin.rp.sdk.template.TransmissionTemplate; +import com.gexin.rp.sdk.template.style.Style0; +import com.ruoyi.common.exception.CustomException; +import com.ruoyi.common.exception.enums.CoreExceptionEnum; +import com.ruoyi.enums.user.UserEnums; +import com.ruoyi.frequency.customer.entity.Customer; +import com.ruoyi.frequency.customer.service.CustomerService; +import com.ruoyi.utils.BusinessUtil; +import com.ruoyi.vo.UserVo; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.scheduling.annotation.Async; +import org.springframework.stereotype.Component; + +import java.util.Map; + +/** + * @Author: uniapp消息通知 + * @Description: + * @Date: Created in 2020/5/12 20:31 + */ +@Component +public class PushToSingle { + + private String appId; + private String appKey; + private String mastersecret; + + + @Value("${push.uniapp.appid}") + private String userAppId; + @Value("${push.uniapp.appkey}") + private String userAppKey; + @Value("${push.uniapp.mastersecret}") + private String userMastersecret; + + static final String host = "http://sdk.open.api.igexin.com/apiex.htm"; + + + //透传消息 + private void constructClientTransMsg(String cid, String msg, IBatch batch, Integer type) throws Exception { + + SingleMessage message = new SingleMessage(); + TransmissionTemplate template = new TransmissionTemplate(); + template.setAppId(appId); + template.setAppkey(appKey); + template.setTransmissionContent(msg); + template.setTransmissionType(2); // 透传消息接受方式设置,1:立即启动APP,2:客户端收到消息后需要自行处理 + + template.setAPNInfo(getAPNPayload(msg, null, null)); //详见【推送模板说明】iOS通知样式设置 + + message.setData(template); + message.setOffline(true); + message.setOfflineExpireTime(24 * 1000 * 3600); + // 厂商通道下发策略 + message.setStrategyJson("{\"default\":4,\"ios\":4,\"st\":4}"); + + // 设置推送目标,填入appid和clientId + Target target = new Target(); + target.setAppId(appId); + target.setClientId(cid); + batch.add(message, target); + } + + //通知消息 + private void constructClientLinkMsg(String cid, String title, String text, IBatch batch, Integer userType) throws Exception { + SingleMessage message = new SingleMessage(); + NotificationTemplate template = new NotificationTemplate(); + // 设置APPID与APPKEY + template.setAppId(appId); + template.setAppkey(appKey); + + Style0 style = new Style0(); + // 设置通知栏标题与内容 + style.setTitle(title); + style.setText(text); + // 配置通知栏图标 + style.setLogo("icon.png"); + // 配置通知栏网络图标 + style.setLogoUrl(""); + // 设置通知是否响铃,震动,或者可清除 + style.setRing(true); + style.setVibrate(true); + style.setClearable(true); + template.setStyle(style); + +// template.setAPNInfo(getAPNPayload(title,text,null,null)); //详见【推送模板说明】iOS通知样式设置 + + message.setData(template); + message.setOffline(true); + message.setOfflineExpireTime(360 * 1000); + // 厂商通道下发策略 + message.setStrategyJson("{\"default\":4,\"ios\":4,\"st\":4}"); + + // 设置推送目标,填入appid和clientId + Target target = new Target(); + target.setAppId(appId); + target.setClientId(cid); + batch.add(message, target); + } + + + /** + * IOS的APNs消息 + * + * @param body + * @param badge + * @param customMsg + * @return + */ + private static APNPayload getAPNPayload(String body, String badge, Map customMsg) { + APNPayload payload = new APNPayload(); + JSONObject json = JSONObject.parseObject(body); + payload.setContentAvailable(0); + // ios 12.0 以上可以使用 Dictionary 类型的 sound +// payload.setSound("pushsound.caf"); + payload.addCustomMsg("content", body); + payload.addCustomMsg("text", json.getString("text")); + payload.addCustomMsg("title", json.getString("title")); + payload.addCustomMsg("objectId", json.getString("objectId")); + payload.addCustomMsg("objectType", json.getString("objectType")); + payload.addCustomMsg("userType", json.getString("userType")); + payload.addCustomMsg("type", json.getString("type")); + payload.setAlertMsg(getDictionaryAlertMsg(body)); + return payload; + } + + /** + * IOS通知提示样式 + * + * @param body + * @param body + * @return + */ + private static APNPayload.DictionaryAlertMsg getDictionaryAlertMsg(String body) { + APNPayload.DictionaryAlertMsg alertMsg = new APNPayload.DictionaryAlertMsg(); + JSONObject json = JSONObject.parseObject(body); + alertMsg.setBody(json.getString("text")); +// alertMsg.setActionLocKey("显示关闭和查看两个按钮的消息"); +// alertMsg.setLocKey("loc-key1"); +// alertMsg.addLocArg("loc-ary1"); +// alertMsg.setLaunchImage("调用已经在应用程序中绑定的图形文件名"); + // iOS8.2以上版本支持 + alertMsg.setTitle(json.getString("title")); +// alertMsg.setTitleLocKey("自定义通知标题"); +// alertMsg.addTitleLocArg("自定义通知标题组"); + return alertMsg; + } + + @Autowired + private CustomerService customerService; + + + private void setConfig(Integer userType) { + + switch (UserEnums.getUserEnums(userType)){ + case customer: + this.appId = userAppId; + this.appKey = userAppKey; + this.mastersecret = userMastersecret; + break; + case store: + break; + } + } + + @Autowired + private BusinessUtil businessUtil; + + /** + * @param title + * @param content + * @param clientId + * @param objectId 业务id + * @param type + */ +// @Async("sendToAlias") + public void sendToAlias(UserVo userVo, Integer messageType, String title, String content, String clientId, Long objectId, Long messageId, Integer type) { + //判断能不能推送 + + if (StrUtil.isBlank(clientId)) { + return; + } + + Integer closeMessage = (Integer)businessUtil.getUserFieldValue(userVo,"closeMessage"); + + if ( closeMessage == 1) { + return; + } + //参数填值 + setConfig(userVo.getUserType()); + + IIGtPush push = new IGtPush(host, appKey, mastersecret); + IBatch batch = push.getBatch(); + + try { + // 透传消息 + JSONObject jsonObject = new JSONObject(); + jsonObject.put("title", title); + jsonObject.put("text", content); + jsonObject.put("objectId", objectId + ""); + jsonObject.put("type", type +""); + jsonObject.put("messageType", messageType +""); + jsonObject.put("messageId", messageId + ""); + jsonObject.put("content", jsonObject.toString()); + System.out.println(jsonObject.toString()); + //透传 不提示 + constructClientTransMsg(clientId, jsonObject.toString(), batch, type); + // 通知消息 +// constructClientLinkMsg(clientId, title, text, batch, userType); + batch.submit(); + } catch (Exception e) { + e.printStackTrace(); + } + } + + + /** + * @param clientId + * @param type + */ + @Async("sendToAlias") + public void sendToAliasImplicit(String clientId, Integer type, Integer userType) { + //判断能不能推送 + + if (StrUtil.isBlank(clientId)) { + return; + } + + //根据不同的用户类型 判断能不能推送 + switch (userType){ + case 1: + Customer customer = customerService.getOne(new QueryWrapper().lambda() + .eq(Customer::getClientId, clientId).last(" limit 1")); + if (customer == null || customer.getCloseMessage() == 1) { + return; + } + break; + default: + throw new CustomException(CoreExceptionEnum.ERROR_PARAM); + } + + //参数填值 + setConfig(userType); + + IIGtPush push = new IGtPush(host, appKey, mastersecret); + IBatch batch = push.getBatch(); + + try { + // 透传消息 + JSONObject jsonObject = new JSONObject(); + jsonObject.put("title", "title"); + jsonObject.put("text", "text"); + jsonObject.put("objectId", "objectId"); + jsonObject.put("type", type); + jsonObject.put("content", jsonObject.toString()); + System.out.println(jsonObject.toString()); + //透传 不提示 + constructClientTransMsg(clientId, jsonObject.toString(), batch, type); + // 通知消息 +// constructClientLinkMsg(clientId, title, text, batch, userType); + batch.submit(); + } catch (Exception e) { + e.printStackTrace(); + } + } + + /** + * @param title + * @param text + * @param clientId + * @param objectId 业务id + * @param objectType + * @param userType 1 用户 2 商家 + * @param type + */ + public void sendToAliasUpdateVideo(String title, String text, String clientId, Object objectId, Integer objectType, Integer userType, Integer type, Object[] params) { + IIGtPush push = new IGtPush(host, appKey, mastersecret); + IBatch batch = push.getBatch(); + + try { + // 透传消息 + JSONObject jsonObject = new JSONObject(); + jsonObject.put("title", title); + jsonObject.put("text", text); + jsonObject.put("objectId", objectId); + jsonObject.put("objectType", objectType); + jsonObject.put("userType", userType); + jsonObject.put("type", type); + jsonObject.put("likeNum", params[0]); + jsonObject.put("commentNum", params[2]); + jsonObject.put("collectNum", params[3]); + jsonObject.put("isLike", params[4]); + jsonObject.put("isCollect", params[5]); + + jsonObject.put("content", jsonObject.toString()); + System.out.println(jsonObject.toString()); + //透传 不提示 + constructClientTransMsg(clientId, jsonObject.toString(), batch, type); + // 通知消息 +// constructClientLinkMsg(clientId, title, text, batch, userType); + batch.submit(); + } catch (Exception e) { + e.printStackTrace(); + } + } + + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/push/service/PushService.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/push/service/PushService.java new file mode 100644 index 0000000..9db2d2b --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/push/service/PushService.java @@ -0,0 +1,44 @@ +package com.ruoyi.push.service; + + +import com.ruoyi.enums.message.AppMessageEnums; +import com.ruoyi.enums.message.InteractionMessageEnums; +import com.ruoyi.enums.message.OrderMessageEnums; +import com.ruoyi.vo.UserVo; + +/** + * @author liwenlong + */ +public interface PushService { + + + /** + * 推送系统消息 + * + * @return + */ + void push(UserVo userVo, Long objectId, Long messageId, AppMessageEnums appMessageEnums); + + /** + * 推送系统消息 + * + * @return + */ + void push(UserVo userVo,String title,String content, Long objectId, Long messageId, AppMessageEnums appMessageEnums); + + + /** + * 推送订单消息 + * + * @return + */ + void push(UserVo userVo, Long objectId, String orderNo, Long messageId, OrderMessageEnums orderMessageEnums); + + /** + * 推送互动消息 + * + * @return + */ + void push(UserVo userVo, Long objectId, Long messageId, InteractionMessageEnums interactionMessageEnums); + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/push/service/impl/PushServiceImpl.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/push/service/impl/PushServiceImpl.java new file mode 100644 index 0000000..4197aa9 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/push/service/impl/PushServiceImpl.java @@ -0,0 +1,93 @@ +package com.ruoyi.push.service.impl; + + +import cn.hutool.core.util.ObjectUtil; +import com.ruoyi.code.PushConstant; +import com.ruoyi.enums.message.AppMessageEnums; +import com.ruoyi.enums.message.InteractionMessageEnums; +import com.ruoyi.enums.message.OrderMessageEnums; +import com.ruoyi.enums.message.PushEnums; +import com.ruoyi.push.PushGoeasyUtil; +import com.ruoyi.push.PushToSingle; +import com.ruoyi.push.service.PushService; +import com.ruoyi.utils.BusinessUtil; +import com.ruoyi.vo.UserVo; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +/** + * @author liwenlong + * 推送 + */ +@Service +@Slf4j +@Transactional(rollbackFor = Exception.class) +public class PushServiceImpl implements PushService { + + /** + * 推送类型 + */ + @Value("${push.push_type}") + private String pushType; + + @Autowired + private PushGoeasyUtil pushGoeasyUtil; + + @Autowired + private PushToSingle pushToSingle; + + + @Autowired + private BusinessUtil businessUtil; + + @Override + public void push(UserVo userVo, Long objectId, Long messageId, AppMessageEnums appMessageEnums) { + pushMessage(userVo,appMessageEnums.getCode(),appMessageEnums.getTitle(),appMessageEnums.getContent(),objectId,messageId, PushConstant.系统消息); + } + + @Override + public void push(UserVo userVo,String title,String content, Long objectId, Long messageId, AppMessageEnums appMessageEnums) { + pushMessage(userVo,appMessageEnums.getCode(),title,content,objectId,messageId,PushConstant.系统消息); + } + + @Override + public void push(UserVo userVo, Long objectId, String orderNo, Long messageId, OrderMessageEnums orderMessageEnums) { + pushMessage(userVo,orderMessageEnums.getCode(),orderMessageEnums.getTitle(),orderMessageEnums.getContent().replace("orderNo",orderNo),objectId,messageId,PushConstant.商城订单消息); + } + + @Override + public void push(UserVo userVo, Long objectId, Long messageId, InteractionMessageEnums interactionMessageEnums) { + pushMessage(userVo,interactionMessageEnums.getCode(),interactionMessageEnums.getTitle(),interactionMessageEnums.getContent(),objectId,messageId,PushConstant.互动消息); + } + + private void pushMessage(UserVo userVo, Integer messageType, String title, String content, Long objectId, Long messageId, Integer type){ + + if (ObjectUtil.isEmpty(pushType)){ + return; + } + + switch (PushEnums.getPushEnums(Integer.valueOf(pushType))){ + + case goeasy: + pushGoeasyUtil.pushMessage(userVo,messageType,title,content,objectId,messageId,type); + break; + + case uniapp: + + //获取clientId + String client_id = (String) businessUtil.getUserFieldValue(userVo,"clientId"); + + pushToSingle.sendToAlias(userVo,messageType,title,content,client_id,objectId,messageId,type); + + break; + + default: + throw new IllegalStateException("Unexpected value: " + pushType); + } + } + + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/redis/RedisCollectUtil.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/redis/RedisCollectUtil.java new file mode 100644 index 0000000..528d779 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/redis/RedisCollectUtil.java @@ -0,0 +1,64 @@ +package com.ruoyi.redis; + +import com.ruoyi.cache.RedisOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.redis.core.StringRedisTemplate; +import org.springframework.stereotype.Component; + +/** + * @author liwenlong + * @date 2023/1/4 9:13 + */ + +@Component +public class RedisCollectUtil { + + @Autowired + private StringRedisTemplate redisTemplate; + + @Autowired + private RedisOperation redisOperation; + + + /** + * 判断是否收藏 + * @param key + * @param userId 用户id + * @return + */ + public Boolean isCollcet(String key,Long userId) { + + //判断key中是否存在value值 存在返回true + Boolean isMember = redisTemplate.opsForSet().isMember(key, userId.toString()); + + return isMember; + } + + + /** + * 收藏 + * @param key + * @param userId 用户id + * @param objectId 业务id + * @return + */ + public Boolean collcet(String key,Long userId,Long objectId) { + + //拼接key + key = key + objectId; + + //是否收藏 + Boolean isCollcet = isCollcet(key, userId); + + if (isCollcet){ + // 保存用户到 Redis 的 set 集合 + redisTemplate.opsForSet().add(key, userId.toString()); + }else { + // 把用户从 Redis 的 set 集合移除 + redisTemplate.opsForSet().remove(key, userId.toString()); + } + + return isCollcet; + } + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/redis/RedisKeys.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/redis/RedisKeys.java new file mode 100644 index 0000000..b7c0734 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/redis/RedisKeys.java @@ -0,0 +1,20 @@ +package com.ruoyi.redis; + +/** + * @author liwenlong + * @date 2023/1/4 9:13 + */ + +public class RedisKeys { + + //行业数据map + public static String INDUSTYR_MAP = "INDUSTYR_MAP"; + + //字典表数据list + public static String DICT_LIST = "DICT_LIST"; + + //收藏前缀 + public static String COLLECT = "COLLECT_"; + + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/redis/RedisUtil.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/redis/RedisUtil.java new file mode 100644 index 0000000..963867c --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/redis/RedisUtil.java @@ -0,0 +1,132 @@ +package com.ruoyi.redis; + +import com.alibaba.fastjson.JSONObject; +import com.ruoyi.cache.RedisOperation; +import com.ruoyi.common.exception.ServiceException; +import com.ruoyi.common.utils.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.redis.core.StringRedisTemplate; +import org.springframework.stereotype.Component; + +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.TimeUnit; + +import static com.ruoyi.common.exception.enums.ServerExceptionEnum.COMMON_EXCEPTION; + + +/** + * @author liwenlong + * @date 2023/1/4 9:13 + */ + +@Component +public class RedisUtil { + + @Autowired + private StringRedisTemplate redisTemplate; + + @Autowired + private RedisOperation redisOperation; + + + public T getRedisObject(String key, Class clazz) { + + T catchObject = getCatchObject(key, clazz); + + if (catchObject != null) { + return catchObject; + } + + if (redisTemplate.hasKey(key)) { + try { + return clazz.newInstance(); + } catch (Exception e) { + e.printStackTrace(); + throw new ServiceException(COMMON_EXCEPTION); + } + } + + if (!redisOperation.lock(key + "lock", 10 * 1000)) { + int loopTimes = 0; + while (loopTimes++ < 10) { + try { + Thread.sleep(100); + } catch (InterruptedException e) { + e.printStackTrace(); + } + catchObject = getCatchObject(key, clazz); + if (catchObject != null) { + return catchObject; + } + } + try { + return clazz.newInstance(); + } catch (Exception e) { + e.printStackTrace(); + throw new ServiceException(COMMON_EXCEPTION); + } + } + + return null; + } + + public List getRedisArray(String key, Class clazz) { + + List catchArray = getCatchArray(key, clazz); + + if (catchArray != null) { + return catchArray; + } + if (redisTemplate.hasKey(key)) { + return new ArrayList<>(); + } + + if (!redisOperation.lock(key + "lock", 10 * 1000)) { + int loopTimes = 0; + while (loopTimes++ < 10) { + try { + Thread.sleep(100); + } catch (InterruptedException e) { + e.printStackTrace(); + } + catchArray = getCatchArray(key, clazz); + if (catchArray != null) { + return catchArray; + } + } + return new ArrayList<>(); + } + + return null; + } + + + private T getCatchObject(String key, Class clazz) { + if (redisTemplate.hasKey(key)) { + String value = redisTemplate.opsForValue().get(key); + + if (StringUtils.isNotBlank(value)) { + return JSONObject.parseObject(value, clazz); + } + } + return null; + } + + private List getCatchArray(String key, Class clazz) { + if (redisTemplate.hasKey(key)) { + String value = redisTemplate.opsForValue().get(key); + + if (StringUtils.isNotBlank(value)) { + return JSONObject.parseArray(value, clazz); + } + } + return null; + } + + public void setCatchObj(String key, Object object, long timeout, TimeUnit unit) { + + redisTemplate.opsForValue().set(key, JSONObject.toJSONString(object), timeout, unit); + redisOperation.unlock(key + "lock"); + } +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/response/ErrorResponseData.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/response/ErrorResponseData.java new file mode 100644 index 0000000..9d59f82 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/response/ErrorResponseData.java @@ -0,0 +1,56 @@ +/* +Copyright [2020] [https://www.stylefeng.cn] + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +Guns采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点: + +1.请不要删除和修改根目录下的LICENSE文件。 +2.请不要删除和修改Guns源码头部的版权声明。 +3.请保留源码和相关描述文件的项目出处,作者声明等。 +4.分发源码时候,请注明软件出处 https://gitee.com/stylefeng/guns-separation +5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://gitee.com/stylefeng/guns-separation +6.若您的项目无法满足以上几点,可申请商业授权,获取Guns商业授权许可,请在官网购买授权,地址为 https://www.stylefeng.cn + */ +package com.ruoyi.response; + +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * 失败响应结果 + * + * @author xuyuxiang + * @date 2020/3/30 15:05 + */ +@EqualsAndHashCode(callSuper = true) +@Data +public class ErrorResponseData extends ResponseData { + + /** + * 异常的具体类名称 + */ + private String exceptionClazz; + + public ErrorResponseData(String message) { + super(false, DEFAULT_ERROR_CODE, message, null); + } + + public ErrorResponseData(Integer code, String message) { + super(false, code, message, null); + } + + ErrorResponseData(Integer code, String message, Object object) { + super(false, code, message, object); + } +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/response/FieldConfig.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/response/FieldConfig.java new file mode 100644 index 0000000..ad20a35 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/response/FieldConfig.java @@ -0,0 +1,22 @@ +package com.ruoyi.response; + +import lombok.Data; + +/** + * @author liwenlong + * @date 2023/3/4 16:47 + */ +@Data +public class FieldConfig { + + + private String field;//字段名称 + + private String comment;//注释 + + private String length;//字段展示长度 + + private Integer isShow;//是否展示 1不展示 2 展示 + + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/response/ResponseData.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/response/ResponseData.java new file mode 100644 index 0000000..ed10eda --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/response/ResponseData.java @@ -0,0 +1,125 @@ +/* +Copyright [2020] [https://www.stylefeng.cn] + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +Guns采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点: + +1.请不要删除和修改根目录下的LICENSE文件。 +2.请不要删除和修改Guns源码头部的版权声明。 +3.请保留源码和相关描述文件的项目出处,作者声明等。 +4.分发源码时候,请注明软件出处 https://gitee.com/stylefeng/guns-separation +5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://gitee.com/stylefeng/guns-separation +6.若您的项目无法满足以上几点,可申请商业授权,获取Guns商业授权许可,请在官网购买授权,地址为 https://www.stylefeng.cn + */ +package com.ruoyi.response; + +import com.ruoyi.common.exception.enums.CoreExceptionEnum; +import com.ruoyi.common.exception.enums.abs.AbstractBaseExceptionEnum; +import lombok.Data; + +import java.util.Date; + +/** + * 响应结果数据 + * + * @author xuyuxiang + * @date 2020/3/30 15:04 + */ +@Data +public class ResponseData { + + public static final String DEFAULT_SUCCESS_MESSAGE = "请求成功"; + + public static final String DEFAULT_ERROR_MESSAGE = "网络异常"; + + public static final Integer DEFAULT_SUCCESS_CODE = 200; + + public static final Integer DEFAULT_ERROR_CODE = 500; + + /** + * 请求是否成功 + */ + private Boolean success; + + /** + * 响应状态码 + */ + private Integer code; + + /** + * 响应信息 + */ + private String message; + + /** + * 响应对象 + */ + private T data; + + private Date currentTime = new Date(); + + public ResponseData() { + } + + public ResponseData(Boolean success, Integer code, String message, T data) { + this.success = success; + this.code = code; + this.message = message; + this.data = data; + this.currentTime = new Date(); + } + + public static SuccessResponseData success() { + return new SuccessResponseData(); + } + + public static SuccessResponseData success(Object object) { + return new SuccessResponseData(object); + } + + public static SuccessResponseData success(Integer code, String message, Object object) { + return new SuccessResponseData(code, message, object); + } + + public static ErrorResponseData error(String message) { + return new ErrorResponseData(message); + } + + public static ErrorResponseData error(CoreExceptionEnum exception) { + return new ErrorResponseData(exception.getCode(), exception.getMessage()); + } + + public static ErrorResponseData error(CoreExceptionEnum exception,Object object) { + return new ErrorResponseData(exception.getCode(), exception.getMessage(),object); + } + + public static ErrorResponseData error(AbstractBaseExceptionEnum exception, Object object) { + return new ErrorResponseData(exception.getCode(), exception.getMessage(),object); + } + + public static ErrorResponseData error(AbstractBaseExceptionEnum exception) { + return new ErrorResponseData(exception.getCode(), exception.getMessage()); + } + + + + + public static ErrorResponseData error(Integer code, String message) { + return new ErrorResponseData(code, message); + } + + public static ErrorResponseData error(Integer code, String message, Object object) { + return new ErrorResponseData(code, message, object); + } +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/response/SuccessResponseData.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/response/SuccessResponseData.java new file mode 100644 index 0000000..df7ebdb --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/response/SuccessResponseData.java @@ -0,0 +1,46 @@ +/* +Copyright [2020] [https://www.stylefeng.cn] + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +Guns采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点: + +1.请不要删除和修改根目录下的LICENSE文件。 +2.请不要删除和修改Guns源码头部的版权声明。 +3.请保留源码和相关描述文件的项目出处,作者声明等。 +4.分发源码时候,请注明软件出处 https://gitee.com/stylefeng/guns-separation +5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://gitee.com/stylefeng/guns-separation +6.若您的项目无法满足以上几点,可申请商业授权,获取Guns商业授权许可,请在官网购买授权,地址为 https://www.stylefeng.cn + */ +package com.ruoyi.response; + +/** + * 成功响应结果 + * + * @author xuyuxiang + * @date 2020/3/30 15:04 + */ +public class SuccessResponseData extends ResponseData { + + public SuccessResponseData() { + super(true, DEFAULT_SUCCESS_CODE, DEFAULT_SUCCESS_MESSAGE, null); + } + + public SuccessResponseData(Object object) { + super(true, DEFAULT_SUCCESS_CODE, DEFAULT_SUCCESS_MESSAGE, object); + } + + public SuccessResponseData(Integer code, String message, Object object) { + super(true, code, message, object); + } +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/sms/MessageCodeService.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/sms/MessageCodeService.java new file mode 100644 index 0000000..4c2b588 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/sms/MessageCodeService.java @@ -0,0 +1,22 @@ +package com.ruoyi.sms; + + +import com.ruoyi.response.ResponseData; +import com.ruoyi.sms.controller.vo.SendMesReq; +import com.ruoyi.vo.UserVo; + +/** + * @author liuyao + */ +public interface MessageCodeService { + + /** + * 发送短信 + * @param req + * @param userVo + * @param smsType + * @return + */ + ResponseData sendMsg(SendMesReq req, UserVo userVo, String smsType); + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/sms/controller/AppSmsController.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/sms/controller/AppSmsController.java new file mode 100644 index 0000000..b01d6c5 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/sms/controller/AppSmsController.java @@ -0,0 +1,48 @@ +package com.ruoyi.sms.controller; + + +import com.ruoyi.response.ResponseData; +import com.ruoyi.sms.MessageCodeService; +import com.ruoyi.sms.controller.vo.SendMesReq; +import com.ruoyi.vo.RyController; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.web.bind.annotation.*; + +import javax.validation.Valid; + +/** + * 发送短信 + **/ +@Slf4j +@Api(tags = "发送短信验证码") +@RequestMapping(value = "/api/sms") +@RestController +@CrossOrigin +public class AppSmsController extends RyController { + + + /** + * 短信类型 + */ + @Value("${sms.sms_type}") + private String smsType; + + + @Autowired + private MessageCodeService messageCodeService; + + + /** + * 功能描述:发送短信 + */ + @RequestMapping(value = "/send/msg", method = RequestMethod.POST) + @ApiOperation(value = "发送短信验证码") + public ResponseData sendMsg(@RequestBody @Valid SendMesReq req) { + return messageCodeService.sendMsg(req,getUserVo(),smsType); + } + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/sms/controller/vo/SendMesReq.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/sms/controller/vo/SendMesReq.java new file mode 100644 index 0000000..29d98f5 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/sms/controller/vo/SendMesReq.java @@ -0,0 +1,46 @@ +package com.ruoyi.sms.controller.vo; + +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; + +/** + * @Author 刘耀 + * @Date 2020/9/16 10:38 + */ +@Data +public class SendMesReq { + + + @NotNull(message = "用户类型不可为空") + private Integer userType; + + /** + * 账号 + */ + private String account; + + + @NotBlank(message = "区号不可为空") + private String areaCode="+86"; + + @NotBlank(message = "手机号不可为空") + private String mobile; + /** + * 1 用户注册 2 用户登录 3 修改密码 4 忘记密码 5 小程序登录绑定手机号 6 微信登录绑定手机号 7 苹果登录绑定手机号 8 支付密码校验 + * 9 换绑手机号-验证原有手机号 10 换绑手机号-验证新手机号 + */ + @NotNull(message = "类型不可为空") + private Integer type; + + /** + * 登入类型 + * @see com.ruoyi.enums.LoginEnums + */ + private Integer loginType; + + private String captcha ; //验证码 + + private String key; +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/sms/impl/AppMessageCodeServiceImpl.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/sms/impl/AppMessageCodeServiceImpl.java new file mode 100644 index 0000000..106eb5b --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/sms/impl/AppMessageCodeServiceImpl.java @@ -0,0 +1,451 @@ +package com.ruoyi.sms.impl; + +import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.StrUtil; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.ruoyi.code.PublicCommon; +import com.ruoyi.common.cos.TxApiSdkUtils; +import com.ruoyi.common.exception.enums.CoreExceptionEnum; +import com.ruoyi.enums.sms.SmsEnums; +import com.ruoyi.enums.user.UserEnums; +import com.ruoyi.frequency.customer.entity.Customer; +import com.ruoyi.frequency.customer.mapper.CustomerMapper; +import com.ruoyi.frequency.sale.entity.Sale; +import com.ruoyi.frequency.sale.mapper.SaleMapper; +import com.ruoyi.frequency.store.entity.Store; +import com.ruoyi.frequency.store.mapper.StoreMapper; +import com.ruoyi.response.ResponseData; +import com.ruoyi.sms.MessageCodeService; +import com.ruoyi.sms.controller.vo.SendMesReq; +import com.ruoyi.sms.utils.AliSmsUtil; +import com.ruoyi.sms.utils.FuseCloudSmsUtil; +import com.ruoyi.utils.BusinessUtil; +import com.ruoyi.vo.UserVo; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.data.redis.core.StringRedisTemplate; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.io.IOException; +import java.util.Map; +import java.util.Objects; +import java.util.Random; + + +/** + * @author twx + * @Description + * @Date + **/ +@Service +@Slf4j +@Transactional(rollbackFor = Exception.class) +public class AppMessageCodeServiceImpl implements MessageCodeService { + + @Autowired + private StringRedisTemplate redisTemplate; + @Autowired + private CustomerMapper customerMapper; + + + @Value("${app.name}") + private String appName; + + @Autowired + private FuseCloudSmsUtil fuseCloudSmsUtil; + + @Autowired + private AliSmsUtil aliSmsUtil; + + @Autowired + private BusinessUtil businessUtil; + + @Override + public ResponseData sendMsg(SendMesReq req, UserVo userVo, String smsType) { + + + // 获取注册短信时,先校验图形验证码 + String _code = redisTemplate.opsForValue().get(req.getKey()); + if (StrUtil.isBlankOrUndefined(_code)) { + return ResponseData.error(CoreExceptionEnum.FIGURE_CODE_NOT_EXIST); + } + if (!StrUtil.equalsIgnoreCase(_code, req.getCaptcha())) { + return ResponseData.error(CoreExceptionEnum.FIGURE_CODE_ERROR); + } + + //判断用户信息 + ResponseData responseData = judgeUser(req, userVo.getUserId()); + if (!responseData.getSuccess()){ + return responseData; + } + + //发送短信 + return this.getCode(req.getAreaCode(),req.getMobile(),req.getType(),req.getUserType(),smsType); + } + + + + private ResponseData judgeUser(SendMesReq req,Long userId){ + + /** + * 1 用户注册 2 用户登录 3 修改密码 4 忘记密码 5 小程序登录绑定手机号 6 微信登录绑定手机号 7 苹果登录绑定手机号 8 支付密码校验 + * 9 换绑手机号-验证原有手机号 10 换绑手机号-验证新手机号 + */ + Integer type = req.getType(); + + switch (SmsEnums.getSmsEnums(type)) { + case REGISTER: + ResponseData responseData = judgeAccount(req.getUserType(), req.getAccount()); + if (!responseData.getSuccess()){ + return responseData; + } + + return judgeRegisterMobile(req.getUserType(), req.getAreaCode(),req.getMobile(),null); + case LOGIN: + if (ObjectUtil.isNotEmpty(req.getLoginType())) { + return judgeMobile(req.getUserType(), req.getAreaCode(),req.getMobile(),null,req.getLoginType()); + }else { + return judgeMobile(req.getUserType(), req.getAreaCode(),req.getMobile(),null); + } + + case CHANGE_PWD: + return judgeMobile(req.getUserType(), req.getAreaCode(),req.getMobile(),userId); + case FORGET_PWD: + return judgeMobile(req.getUserType(), req.getAreaCode(),req.getMobile(),null); + case PAY_PWD: + return judgeMobile(req.getUserType(), req.getAreaCode(),req.getMobile(),userId); + case OLD_MOBILE_BIND: + return judgeMobile(req.getUserType(), req.getAreaCode(),req.getMobile(),userId); + case NEW_MOBILE_BIND: + return judgeRegisterMobile(req.getUserType(), req.getAreaCode(),req.getMobile(),userId); + } + return ResponseData.success(); + } + + @Autowired + private StoreMapper storeMapper; + + @Autowired + private SaleMapper saleMapper; + + /** + * 判断账号是否存在 + * @param userType + * @param account + * @return + */ + private ResponseData judgeAccount(Integer userType,String account){ + + if (ObjectUtil.isEmpty(account)){ + return ResponseData.success(); + } + + switch (UserEnums.getUserEnums(userType)){ + case customer: + Customer customer = customerMapper.selectOne(new QueryWrapper().lambda() + .eq(Customer::getAccount, account) + .ne(Customer::getDelFlag, PublicCommon.删除)); + if (customer != null) { + return ResponseData.error(CoreExceptionEnum.ACCOUNT_HAS_EXIST); + } + break; + case store: + Store store = storeMapper.selectOne(new QueryWrapper().lambda() + .eq(Store::getAccount, account) + .ne(Store::getDelFlag, PublicCommon.删除)); + if (store != null) { + return ResponseData.error(CoreExceptionEnum.ACCOUNT_HAS_EXIST); + } + break; + case sale: + Sale sale = saleMapper.selectOne(new QueryWrapper().lambda() + .eq(Sale::getMobile, account) + .ne(Sale::getDelFlag, PublicCommon.删除)); + if (sale != null) { + return ResponseData.error(CoreExceptionEnum.ACCOUNT_HAS_EXIST); + } + break; + default: + break; + } + + return ResponseData.success(); + } + + + /** + * 判断手机号是否存在 + * @param userType + * @param areaCode + * @param mobile + * @param userId + * @return + */ + private ResponseData judgeMobile(Integer userType,String areaCode,String mobile,Long userId){ + + + if (ObjectUtil.isEmpty(mobile)){ + return ResponseData.success(); + } + + switch (UserEnums.getUserEnums(userType)){ + case customer: + Customer customer = (Customer) businessUtil.getUserObject(UserEnums.customer, areaCode, mobile); + if (customer == null) { + return ResponseData.error(CoreExceptionEnum.ACCOUNT_NOT_EXIST); + } else if (userId != null && !customer.getId().equals(userId)) { + return ResponseData.error(CoreExceptionEnum.MOBILE_BIND_MAKE); + } else if (customer.getDelFlag().equals(PublicCommon.禁用)) { + return ResponseData.error(CoreExceptionEnum.ACCOUNT_DISABLE); + } + + break; + case store: + Store store = (Store) businessUtil.getUserObject(UserEnums.store, areaCode, mobile); + if (store == null) { + return ResponseData.error(CoreExceptionEnum.ACCOUNT_NOT_EXIST); + } else if (userId != null && !store.getId().equals(userId)) { + return ResponseData.error(CoreExceptionEnum.MOBILE_BIND_MAKE); + } else if (store.getDelFlag().equals(PublicCommon.禁用)) { + return ResponseData.error(CoreExceptionEnum.ACCOUNT_DISABLE); + } + + break; + case sale: + Sale sale = (Sale) businessUtil.getUserObject(UserEnums.sale, areaCode, mobile); + if (sale == null) { + return ResponseData.error(CoreExceptionEnum.ACCOUNT_NOT_EXIST); + } else if (userId != null && !sale.getId().equals(userId)) { + return ResponseData.error(CoreExceptionEnum.MOBILE_BIND_MAKE); + } else if (sale.getDelFlag().equals(PublicCommon.禁用)) { + return ResponseData.error(CoreExceptionEnum.ACCOUNT_DISABLE); + } + + break; + default: + break; + } + + return ResponseData.success(); + } + + /** + * 判断手机号是否存在 + * @param userType + * @param areaCode + * @param mobile + * @param userId + * @return + */ + private ResponseData judgeMobile(Integer userType,String areaCode,String mobile,Long userId,Integer loginType){ + + + if (ObjectUtil.isEmpty(mobile)){ + return ResponseData.success(); + } + + switch (UserEnums.getUserEnums(userType)){ + case customer: + Customer customer = (Customer) businessUtil.getUserObject(UserEnums.customer, areaCode, mobile); + + if (customer == null) { + break; + } + if (userId != null && !customer.getId().equals(userId)) { + return ResponseData.error(CoreExceptionEnum.MOBILE_BIND_MAKE); + } else if (customer.getDelFlag().equals(PublicCommon.禁用)) { + return ResponseData.error(CoreExceptionEnum.ACCOUNT_DISABLE); + } + + break; + case store: + Store store = (Store) businessUtil.getUserObject(UserEnums.store, areaCode, mobile); + if (store == null) { + break; + } + if (userId != null && !store.getId().equals(userId)) { + return ResponseData.error(CoreExceptionEnum.MOBILE_BIND_MAKE); + } else if (store.getDelFlag().equals(PublicCommon.禁用)) { + return ResponseData.error(CoreExceptionEnum.ACCOUNT_DISABLE); + } + + break; + case sale: + Sale sale = (Sale) businessUtil.getUserObject(UserEnums.sale, areaCode, mobile); + + if (sale == null) { + break; + } + + if (userId != null && !sale.getId().equals(userId)) { + return ResponseData.error(CoreExceptionEnum.MOBILE_BIND_MAKE); + } else if (sale.getDelFlag().equals(PublicCommon.禁用)) { + return ResponseData.error(CoreExceptionEnum.ACCOUNT_DISABLE); + } + + break; + default: + break; + } + + return ResponseData.success(); + } + + /** + * 判断手机号是否存在 + * @param userType + * @param areaCode + * @param mobile + * @param userId + * @return + */ + private ResponseData judgeRegisterMobile(Integer userType,String areaCode,String mobile,Long userId){ + + + if (ObjectUtil.isEmpty(mobile)){ + return ResponseData.success(); + } + + switch (UserEnums.getUserEnums(userType)){ + case customer: + Customer customer = (Customer) businessUtil.getUserObject(UserEnums.customer, areaCode, mobile); + if (customer == null) { + return ResponseData.success(); + } else if (userId != null && !customer.getId().equals(userId)) { + return ResponseData.error(CoreExceptionEnum.MOBILE_BIND_MAKE); + } else if (customer != null ){ + if (userId == null || !userId.equals(customer.getId())){ + return ResponseData.error(CoreExceptionEnum.PHONE_HAS_EXIST); + } + }else if (customer.getDelFlag().equals(PublicCommon.禁用)) { + return ResponseData.error(CoreExceptionEnum.ACCOUNT_DISABLE); + } + + break; + case store: + Store store = (Store) businessUtil.getUserObject(UserEnums.store, areaCode, mobile); + if (store == null) { + return ResponseData.success(); + } else if (userId != null && !store.getId().equals(userId)) { + return ResponseData.error(CoreExceptionEnum.MOBILE_BIND_MAKE); + } else if (store != null){ + return ResponseData.error(CoreExceptionEnum.PHONE_HAS_EXIST); + }else if (store.getDelFlag().equals(PublicCommon.禁用)) { + return ResponseData.error(CoreExceptionEnum.ACCOUNT_DISABLE); + } + + break; + case sale: + Sale sale = (Sale) businessUtil.getUserObject(UserEnums.sale, areaCode, mobile); + if (sale == null) { + return ResponseData.success(); + } else if (userId != null && !sale.getId().equals(userId)) { + return ResponseData.error(CoreExceptionEnum.MOBILE_BIND_MAKE); + } else if (sale != null){ + return ResponseData.error(CoreExceptionEnum.PHONE_HAS_EXIST); + }else if (sale.getDelFlag().equals(PublicCommon.禁用)) { + return ResponseData.error(CoreExceptionEnum.ACCOUNT_DISABLE); + } + + break; + default: + break; + } + + return ResponseData.success(); + } + + /** + * 发送短信方法 + * @param areaCode 手机区号 + * @param mobile 手机号 + * @param type 发送短信类型 + * @param userType 用户类型 + * @param smsType 三方短信类型 + * @return + * @throws Exception + */ + public ResponseData getCode(String areaCode,String mobile, Integer type,Integer userType,String smsType) { + //生成随机验证码 + String code = randomNumStr(6); + redisTemplate.opsForValue().set(code + type + areaCode + mobile + userType, System.currentTimeMillis() + "," + type + "," + code + "," + mobile, 15 * 60); + + //根据不同三方短信 + switch (smsType){ + case "1": + String codeResult = ""; + //助通短信 + try { + codeResult = fuseCloudSmsUtil.sendSms(areaCode + mobile, "【" + appName + "】您的验证码是" + code + " 如非本人操作,请忽略本短信!"); + } catch (IOException e) { + throw new RuntimeException(e); + } + Map map = JSONObject.parseObject(codeResult, Map.class); + //判断短信是否发送成功 + if (StringUtils.isEmpty(codeResult) || !"success".equals(map.get("msg"))) { + return ResponseData.error(map.get("msg").toString()); + } + break; + case "2": + //阿里短信 + Boolean isSendSuccess = aliSmsUtil.sendMessage(areaCode + mobile, code); + //判断短信是否发送成功 + if (!isSendSuccess) { + return ResponseData.error(CoreExceptionEnum.SMS_SEND_FAIL); + } + break; + case "3": + //腾讯云短信 + JSONObject jsonObject = TxApiSdkUtils.sendSmsMsg(mobile,code); + //判断短信是否发送成功 + if (ObjectUtil.isEmpty(jsonObject)) { + return ResponseData.error(CoreExceptionEnum.SMS_SEND_FAIL); + } + + String str = Objects.requireNonNull(jsonObject).getString("SendStatusSet"); + JSONArray jsonArray = JSONArray.parseArray(str); + String sendStatusSet = jsonArray.get(0).toString(); + JSONObject jsonObject1 = JSONObject.parseObject(sendStatusSet); + String resCode = jsonObject1.getString("Code"); + String message = jsonObject1.getString("Message"); + + if(!"Ok".equals(resCode)){ + System.err.println(message); + return ResponseData.error(CoreExceptionEnum.SMS_SEND_FAIL); + } + break; + default: + return ResponseData.success(code); + } + return ResponseData.success(); + } + + + /** + * 功能描述:产生随机字符串 + * + * @param length 长度 + * @return 产生对应长度的字符串 + * @author wangyf 2017-12-22 11:13 + */ + public static final String randomNumStr(int length) { + if (length < 1) { + return null; + } + char[] randBuffer = new char[length]; + for (int i = 0; i < randBuffer.length; i++) { + randBuffer[i] = numbers[numGen.nextInt(9)]; + } + return new String(randBuffer); + } + + private static Random numGen = new Random(); + + private static char[] numbers = ("0123456789").toCharArray(); + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/sms/utils/AliSmsUtil.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/sms/utils/AliSmsUtil.java new file mode 100644 index 0000000..e83130b --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/sms/utils/AliSmsUtil.java @@ -0,0 +1,108 @@ +package com.ruoyi.sms.utils; + +import com.alibaba.fastjson.JSONObject; +import com.aliyuncs.CommonRequest; +import com.aliyuncs.CommonResponse; +import com.aliyuncs.DefaultAcsClient; +import com.aliyuncs.IAcsClient; +import com.aliyuncs.exceptions.ClientException; +import com.aliyuncs.exceptions.ServerException; +import com.aliyuncs.http.MethodType; +import com.aliyuncs.profile.DefaultProfile; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Component; + +import java.util.HashMap; + +/** + * 阿里云验证码 + */ +@Component +public class AliSmsUtil { + + + @Value("${sms.access-key-id}") + private String accessKeyId; + + @Value("${sms.access-key-secret}") + private String secret; + + @Value("${sms.signName}") + private String signName; + + @Value("${sms.templateCode}") + private String templateCode; + + public Boolean sendMessage(String phoneNum, String code) { + //连接阿里云,第一个参数不用改变,后两个填写自己的accessKeyId和accessSecret + DefaultProfile profile = DefaultProfile.getProfile("cn-hangzhou", accessKeyId, secret); + IAcsClient client = new DefaultAcsClient(profile); + + //构建请求! + CommonRequest request = new CommonRequest(); + + HashMap map = new HashMap<>(); + //key必须为code + map.put("code",code); + + request.setSysMethod(MethodType.POST); + request.setSysDomain("dysmsapi.aliyuncs.com"); + request.setSysVersion("2017-05-25"); + request.setSysAction("SendSms"); + + //自定义参数(手机号,验证码,签名,模板) + request.putQueryParameter("RegionId", "cn-hangzhou"); + request.putQueryParameter("PhoneNumbers", phoneNum); + request.putQueryParameter("SignName", signName); + request.putQueryParameter("TemplateCode", templateCode); + //构建一个短信的验证码 + request.putQueryParameter("TemplateParam", JSONObject.toJSONString(map)); + try { + CommonResponse response = client.getCommonResponse(request); + System.out.println(response.getData()); + return response.getHttpResponse().isSuccess(); + } catch (ServerException e) { + e.printStackTrace(); + } catch (ClientException e) { + e.printStackTrace(); + } + return false; + } + + + private static void main(String[] args) { + //连接阿里云,第一个参数不用改变,后两个填写自己的accessKeyId和accessSecret + DefaultProfile profile = DefaultProfile.getProfile("cn-hangzhou", "LTAI5t5axYmuBKnzhDaXJbtc", "7V3y7x10gH6zCpx4EFqFI66HMPSJAp"); + IAcsClient client = new DefaultAcsClient(profile); + + //构建请求! + CommonRequest request = new CommonRequest(); + + request.setSysMethod(MethodType.POST); + request.setSysDomain("dysmsapi.aliyuncs.com"); + request.setSysVersion("2017-05-25"); + request.setSysAction("SendSms"); + + //自定义参数(手机号,验证码,签名,模板) + request.putQueryParameter("RegionId", "cn-hangzhou"); + request.putQueryParameter("PhoneNumbers", "+8615855540307"); + request.putQueryParameter("SignName", "猎职云"); + request.putQueryParameter("TemplateCode", "SMS_268675152"); + //构建一个短信的验证码 + + HashMap map = new HashMap<>(); + //key必须为code + map.put("code","123456"); + + request.putQueryParameter("TemplateParam", JSONObject.toJSONString(map)); + try { + CommonResponse response = client.getCommonResponse(request); + System.out.println(response.getData()); + } catch (ServerException e) { + e.printStackTrace(); + } catch (ClientException e) { + e.printStackTrace(); + } + } + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/sms/utils/FuseCloudSmsUtil.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/sms/utils/FuseCloudSmsUtil.java new file mode 100644 index 0000000..c32f55d --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/sms/utils/FuseCloudSmsUtil.java @@ -0,0 +1,209 @@ +package com.ruoyi.sms.utils; + +import cn.hutool.crypto.SecureUtil; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Component; + +import java.io.IOException; +import java.util.List; + +@Component +public class FuseCloudSmsUtil { + + + + @Value("${sms.username}") + private String username; + + @Value("${sms.password}") + private String password; + + private static final String signReportUrl = "https://api.mix2.zthysms.com/sms/v1/sign";//短信签名报备url + private static final String searchSignReport = "https://api.mix2.zthysms.com/sms/v1/sign/query";//查询短信签名报备url + private static final String templateReport = "https://api.mix2.zthysms.com/sms/v2/template";//短信模板报备url + private static final String templateReportList = "https://api.mix2.zthysms.com/sms/v2/template/list";//短信模板报备List + private static final String delTemplateReport = "https://api.mix2.zthysms.com/sms/v2/template/delete";//短信模板报备List + private static final String sendSmsTp = "https://api.mix2.zthysms.com/v2/sendSmsTp";//模板签名短信 + private static final String sendSms = "https://api.mix2.zthysms.com/v2/sendSms";//自定义短信模板 + + + /** + * 短信签名报备 + * + * @param stringList 签名必须带中文中括号【】 + * @return String + */ + public String signReport(List stringList) throws IOException { + JSONObject params = createParams(); + params.put("sign", stringList); + String s = HttpUtils.sendPost(signReportUrl, params, "UTF-8"); + return s; + } + + + /** + * 查询短信签名报备 + * + * @param sign 签名必须带中文中括号【】 + * @return String + */ + public String searchSignReport(String sign) throws IOException { + JSONObject params = createParams(); + params.put("sign", sign); + String s = HttpUtils.sendPost(searchSignReport, params, "UTF-8"); + return s; + } + + + /** + * 模板报备 + * + * @param temName 模板名称 ( 最大20字符) + * @param temType 模板类型 1 - 验证码 2 - 行业通知 3 - 营销推广 + * @param temContent 模板内容 (最大450字符),支持变量参数。 举例:尊敬的{name},您购买的是{goods}。 + * @param paramJson 验证码 valid_code 4-6位纯数字 + * 手机号 mobile_number 1-15位纯数字 + * 其他号码 other_number 1-32位字母+数字组合,支持中划线- + * 金额 amount 支持数字或数字的中文 (壹贰叁肆伍陆柒捌玖拾佰仟万亿 圆元整角分厘毫) + * 日期 date 符合时间的表达方式 也支持中文:2019年9月3日16时24分35秒 + * 中文 chinese 1-32中文,支持中文圆括号() + * 其他 others。 + * @return String + * @throws IOException + */ + public String templateReport(String temName, Integer temType, String temContent, String paramJson) throws IOException { + JSONObject params = createParams(); + params.put("temName", temName); + params.put("temType", temType); + params.put("temContent", temContent); + if (null != paramJson && "" != paramJson) { + JSONObject param = new JSONObject(); + param.put("code", paramJson); + params.put("paramJson", param); + } + System.out.println(params); + String s = HttpUtils.sendPost(templateReport, params, "UTF-8"); + return s; + } + + /** + * 模板报备 + * + * @param status 审核状态 (1.待审核 2.审核通过 3.审核不通过) + * @param page 当前页,默认从1开始 + * @param size 每页数量,默认10,最大100 + * @return String + * @throws IOException + */ + public String templateReportList(Integer status, Integer page, Integer size) throws IOException { + JSONObject params = createParams(); + params.put("status", status); + params.put("page", page); + params.put("size", size); + String s = HttpUtils.sendPost(templateReportList, params, "UTF-8"); + return s; + } + + /** + * 删除模板报备 + * + * @param temId 短信模板 + * @return String + * @throws IOException + */ + public String delTemplateReport(Long temId) throws IOException { + JSONObject params = createParams(); + params.put("temId", temId); + String s = HttpUtils.sendPost(delTemplateReport, params, "UTF-8"); + return s; + } + + /** + * 发送模板短信 || 验证码 + * + * @param signature 短信签名 + * @param temId 短信模板 + * @param mobile 手机号 + * @param code 验证码 + * @return String + * @throws IOException + */ + public String sendTemSms(String signature, Long temId, String mobile, String code) throws IOException { + JSONObject params = createParams(); + params.put("signature", signature); + params.put("tpId", String.valueOf(temId)); + //封装 + JSONArray records = new JSONArray(); + JSONObject record = new JSONObject(); + record.put("mobile", mobile); + JSONObject param = new JSONObject(); + param.put("code", code); + record.put("tpContent", param); + records.add(record); + params.put("records", records); + + System.out.println(params); + String s = HttpUtils.sendPost(sendSmsTp, params, "UTF-8"); + return s; + } + + /** + * 发送自定义短信 + * + * @param mobile 手机号 + * @param content 短信内容,最多支持1000个字符,例:【签名A】短信内容。 + * @return String + * @throws IOException + */ + public String sendSms(String mobile, String content) throws IOException { + JSONObject params = createParams(); + params.put("content", content); + params.put("mobile", mobile); + String s = HttpUtils.sendPost(sendSms, params, "UTF-8"); + System.out.println(s); + return s; + } + + private static void main(String[] args) throws IOException { + + Long tKey = System.currentTimeMillis() / 1000; + JSONObject params = new JSONObject(); + params.put("username", "tjtmyuanyuanhui"); + params.put("password", Md5Password("yyh13820969833", tKey)); + params.put("tKey", String.valueOf(tKey)); + + params.put("content", "【风水咨询】 您的验证码是 123456 如非本人操作,请忽略本短信!"); + params.put("mobile", "15855540307"); + String s = HttpUtils.sendPost(sendSms, params, "UTF-8"); + System.out.println(s); + } + + + /** + * 密码md5加密 密码采用32位小写MD5二次加密,例:md5 ( md5( password ) + tKey )) + * + * @return String` + */ + private static String Md5Password(String password, Long tKey) { + return SecureUtil.md5(SecureUtil.md5(password) + tKey); + } + + /** + * 创建参数 + * + * @return Long + */ + private JSONObject createParams() { + Long tKey = System.currentTimeMillis() / 1000; + JSONObject params = new JSONObject(); + params.put("username", username); + params.put("password", Md5Password(password, tKey)); + params.put("tKey", String.valueOf(tKey)); + + return params; + } + + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/sms/utils/HttpUtils.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/sms/utils/HttpUtils.java new file mode 100644 index 0000000..91e0f27 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/sms/utils/HttpUtils.java @@ -0,0 +1,58 @@ +package com.ruoyi.sms.utils; + +import com.alibaba.fastjson.JSONObject; +import org.apache.http.HttpEntity; +import org.apache.http.ParseException; +import org.apache.http.client.methods.CloseableHttpResponse; +import org.apache.http.client.methods.HttpPost; +import org.apache.http.entity.StringEntity; +import org.apache.http.impl.client.CloseableHttpClient; +import org.apache.http.impl.client.HttpClients; +import org.apache.http.message.BasicHeader; +import org.apache.http.protocol.HTTP; +import org.apache.http.util.EntityUtils; + +import java.io.IOException; + +public class HttpUtils { + + /** + * 发送post请求 + * @param url 路径 + * @param jsonObject 参数(json类型) + * @param encoding 编码格式 + * @return + * @throws ParseException + * @throws IOException + */ + public static String sendPost(String url, JSONObject jsonObject, String encoding) throws ParseException, IOException { + String body = ""; + + //创建httpclient对象 + CloseableHttpClient client = HttpClients.createDefault(); + //创建post方式请求对象 + HttpPost httpPost = new HttpPost(url); + + //装填参数 + StringEntity s = new StringEntity(jsonObject.toString(), "utf-8"); + s.setContentEncoding(new BasicHeader(HTTP.CONTENT_TYPE, + "application/json")); + //设置参数到请求对象中 + httpPost.setEntity(s); + httpPost.setHeader("Content-type", "application/json"); + httpPost.setHeader("User-Agent", "Mozilla/4.0 (compatible; MSIE 5.0; Windows NT; DigExt)"); + + //执行请求操作,并拿到结果(同步阻塞) + CloseableHttpResponse response = client.execute(httpPost); + //获取结果实体 + HttpEntity entity = response.getEntity(); + if (entity != null) { + //按指定编码转换结果实体为String类型 + body = EntityUtils.toString(entity, encoding); + } + EntityUtils.consume(entity); + //释放链接 + response.close(); + return body; + } +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/sms/utils/SmsCodeUtils.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/sms/utils/SmsCodeUtils.java new file mode 100644 index 0000000..6fd012e --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/sms/utils/SmsCodeUtils.java @@ -0,0 +1,305 @@ +package com.ruoyi.sms.utils; + + +import net.sf.json.JSONArray; +import net.sf.json.JSONObject; + +import java.io.*; +import java.net.HttpURLConnection; +import java.net.URL; +import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; + +/** + * @Author: micro cloud fly + * @Description: 短信API的调用示例 + * @Date: Created in 1:45 下午 2020/10/9 + */ +public class SmsCodeUtils { + //可选模板列表 + public static final String URL_ALPHA = "http://v.juhe.cn/vercodesms/optionTpl.php?key=%s"; + + //提交短信模板 + public static final String URL_BETA = "http://v.juhe.cn/vercodesms/submitTpl.php?key=%s&signature=%s&tplcode=%d"; + + //我的模板列表 + public static final String URL_GAMMA = "http://v.juhe.cn/vercodesms/myTpl.php?key=%s"; + + //发送短信 + public static final String URL_DELTA = "http://v.juhe.cn/vercodesms/send.php?key=%s&tplId=%d&tplValue=%s&mobile=%s"; + + + //申请接口的请求key + // TODO: 您需要改为自己的请求key + public static final String KEY = "0901df7db9a4f49f42e7aecd4640d5ff"; + + + public static final int tplId = 67225; + + + private static void main(String[] args) throws UnsupportedEncodingException { + //可选模版列表 + printA(); +// System.out.println("-------------------------------------分割线-------------------------------------"); + //提交短信模板 +// String signature = "金陵艺术"; +// short tplcode = 1002; +// printB(signature,tplcode); + System.out.println("-------------------------------------分割线-------------------------------------"); +// 我的模板 +// printC(); + System.out.println("-------------------------------------分割线-------------------------------------"); + //发送短信 + String tplValue = "#code#=12345"; + String mobile = "18256057064"; + printD(tplValue, mobile); + } + + /** + * 可选模版列表 + */ + public static void printA() { + //发送http请求的url + String url = String.format(URL_ALPHA, KEY); + final String response = doGet(url); + System.out.println("接口返回:" + response); + try { + JSONObject jsonObject = JSONObject.fromObject(response); + int error_code = jsonObject.getInt("error_code"); + if (error_code == 0) { + System.out.println("调用接口成功"); + JSONArray result = jsonObject.getJSONArray("result"); + result.stream().map(JSONObject::fromObject).forEach(hour -> { + System.out.println("可供选择的模板id:" + ((JSONObject) hour).getString("tplcode")); + System.out.println("模板内容示例:" + ((JSONObject) hour).getString("sms_tpl")); + System.out.println("模板规范说明:" + ((JSONObject) hour).getString("des")); + }); + + } else { + System.out.println("调用接口失败:" + jsonObject.getString("reason")); + } + } catch (Exception e) { + e.printStackTrace(); + } + } + + /** + * 提交短信模板 + */ + public static void printB(String signature, short tplcode) { + //发送http请求的url + String url = String.format(URL_BETA, KEY, signature, tplcode); + final String response = doGet(url); + System.out.println("接口返回:" + response); + try { + JSONObject jsonObject = JSONObject.fromObject(response); + int error_code = jsonObject.getInt("error_code"); + if (error_code == 0) { + System.out.println("调用接口成功"); + JSONObject result = jsonObject.getJSONObject("result"); + System.out.println("模板id:" + result.getInt("tplId")); + } else { + System.out.println("调用接口失败:" + jsonObject.getString("reason")); + } + } catch (Exception e) { + e.printStackTrace(); + } + } + + /** + * 我的模板列表 + */ + public static void printC() { + //发送http请求的url + String url = String.format(URL_GAMMA, KEY); + final String response = doGet(url); + System.out.println("接口返回:" + response); + try { + JSONObject jsonObject = JSONObject.fromObject(response); + int error_code = jsonObject.getInt("error_code"); + if (error_code == 0) { + System.out.println("调用接口成功"); + JSONArray result = jsonObject.getJSONArray("result"); + + result.stream().map(JSONObject::fromObject).forEach(hour -> { + System.out.println("模板ID:" + ((JSONObject) hour).getString("tplId")); + System.out.println("模板签名:" + ((JSONObject) hour).getString("signature")); + System.out.println("模板发送内容:" + ((JSONObject) hour).getString("sms_tpl")); + System.out.println("模板规审核状态范说明:" + ((JSONObject) hour).getString("tpl_state")); + System.out.println("是否有效:" + ((JSONObject) hour).getString("status")); + System.out.println("模板规范说明:" + ((JSONObject) hour).getString("des")); + }); + + } else { + System.out.println("调用接口失败:" + jsonObject.getString("reason")); + } + } catch (Exception e) { + e.printStackTrace(); + } + } + + + public static String printD(String tplValue, String mobile) throws UnsupportedEncodingException { + //发送http请求的url + String url = String.format(URL_DELTA, KEY, tplId, URLEncoder.encode(tplValue, "UTF-8"), mobile); + final String response = doGet(url); + System.out.println("接口返回:" + response); + try { + JSONObject jsonObject = JSONObject.fromObject(response); + int error_code = jsonObject.getInt("error_code"); + if (error_code == 0) { + System.out.println("调用接口成功"); + JSONObject result = jsonObject.getJSONObject("result"); + System.out.println("短信唯一标识:" + result.getString("sid")); + + } else { + System.out.println("调用接口失败:" + jsonObject.getString("reason")); + return com.alibaba.fastjson.JSONObject.toJSONString(jsonObject); + } + } catch (Exception e) { + e.printStackTrace(); + } + return "success"; + } + + /** + * get方式的http请求 + * + * @param httpUrl 请求地址 + * @return 返回结果 + */ + public static String doGet(String httpUrl) { + HttpURLConnection connection = null; + InputStream inputStream = null; + BufferedReader bufferedReader = null; + String result = null;// 返回结果字符串 + try { + // 创建远程url连接对象 + URL url = new URL(httpUrl); + // 通过远程url连接对象打开一个连接,强转成httpURLConnection类 + connection = (HttpURLConnection) url.openConnection(); + // 设置连接方式:get + connection.setRequestMethod("GET"); + // 设置连接主机服务器的超时时间:15000毫秒 + connection.setConnectTimeout(15000); + // 设置读取远程返回的数据时间:60000毫秒 + connection.setReadTimeout(60000); + // 发送请求 + connection.connect(); + // 通过connection连接,获取输入流 + if (connection.getResponseCode() == 200) { + inputStream = connection.getInputStream(); + // 封装输入流,并指定字符集 + bufferedReader = new BufferedReader(new InputStreamReader(inputStream, StandardCharsets.UTF_8)); + // 存放数据 + StringBuilder sbf = new StringBuilder(); + String temp; + while ((temp = bufferedReader.readLine()) != null) { + sbf.append(temp); + sbf.append(System.getProperty("line.separator")); + } + result = sbf.toString(); + } + } catch (IOException e) { + e.printStackTrace(); + } finally { + // 关闭资源 + if (null != bufferedReader) { + try { + bufferedReader.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + if (null != inputStream) { + try { + inputStream.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + if (connection != null) { + connection.disconnect();// 关闭远程连接 + } + } + return result; + } + + + /** + * post方式的http请求 + * + * @param httpUrl 请求地址 + * @param param 请求参数 + * @return 返回结果 + */ + public static String doPost(String httpUrl, String param) { + HttpURLConnection connection = null; + InputStream inputStream = null; + OutputStream outputStream = null; + BufferedReader bufferedReader = null; + String result = null; + try { + URL url = new URL(httpUrl); + // 通过远程url连接对象打开连接 + connection = (HttpURLConnection) url.openConnection(); + // 设置连接请求方式 + connection.setRequestMethod("POST"); + // 设置连接主机服务器超时时间:15000毫秒 + connection.setConnectTimeout(15000); + // 设置读取主机服务器返回数据超时时间:60000毫秒 + connection.setReadTimeout(60000); + // 默认值为:false,当向远程服务器传送数据/写数据时,需要设置为true + connection.setDoOutput(true); + // 设置传入参数的格式:请求参数应该是 name1=value1&name2=value2 的形式。 + connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded"); + // 通过连接对象获取一个输出流 + outputStream = connection.getOutputStream(); + // 通过输出流对象将参数写出去/传输出去,它是通过字节数组写出的 + outputStream.write(param.getBytes()); + // 通过连接对象获取一个输入流,向远程读取 + if (connection.getResponseCode() == 200) { + inputStream = connection.getInputStream(); + // 对输入流对象进行包装:charset根据工作项目组的要求来设置 + bufferedReader = new BufferedReader(new InputStreamReader(inputStream, StandardCharsets.UTF_8)); + StringBuilder sbf = new StringBuilder(); + String temp; + // 循环遍历一行一行读取数据 + while ((temp = bufferedReader.readLine()) != null) { + sbf.append(temp); + sbf.append(System.getProperty("line.separator")); + } + result = sbf.toString(); + } + } catch (IOException e) { + e.printStackTrace(); + } finally { + // 关闭资源 + if (null != bufferedReader) { + try { + bufferedReader.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + if (null != outputStream) { + try { + outputStream.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + if (null != inputStream) { + try { + inputStream.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + if (connection != null) { + connection.disconnect(); + } + } + return result; + } +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/sms/utils/SmsMessageUtils.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/sms/utils/SmsMessageUtils.java new file mode 100644 index 0000000..00c3c6f --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/sms/utils/SmsMessageUtils.java @@ -0,0 +1,218 @@ +package com.ruoyi.sms.utils; + + +import net.sf.json.JSONObject; + +import java.io.*; +import java.net.HttpURLConnection; +import java.net.MalformedURLException; +import java.net.URL; +import java.net.URLEncoder; + +/** + * @Author: micro cloud fly + * @Description: 短信API的调用示例 + * @Date: Created in 1:45 下午 2020/10/9 + */ +public class SmsMessageUtils { + //接口请求地址 + public static final String URL = "http://v.juhe.cn/sms/send?mobile=%s&tpl_id=%s&tpl_value=%s&key=%s"; + //申请接口的请求key + // TODO: 您需要改为自己的请求key + public static final String KEY = ""; + //此次发送短信需要使用的短信模板 + //3010模板对应的发送内容为:【聚合数据1】您的验证码是#code#.你还剩余次数#total#,如非本人操作,请忽略本短信 + //其中#code#是短信模板中的变量,用于开发者动态生成验证码 + //在运行代码的时候您需要改为自己拥有的模板 + // TODO: 您需要改为自己的模板id + public static final int TPL_ID = 1; + + private static void main(String[] args) { + //用于接收短信的手机号码,你需要修改此处 + // TODO: 改为自己手机号测试看看 + String mobile = "18256057064"; + //短信模板中的您自定义的变量 + // TODO: 改为您模板中的需要的变量 + String variable = "#name#=抢购"; + print(mobile, variable); + } + + /** + * 打印请求结果 + * + * @param mobile 手机号 + * @param variable 模板变量 + */ + public static void print(String mobile, String variable) { + //发送http请求的url + String url = null; + try { + url = String.format(URL, mobile, TPL_ID, URLEncoder.encode(variable, "utf-8"), KEY); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + String response = doGet(url); + System.out.println(response); + try { + JSONObject jsonObject = JSONObject.fromObject(response); + int error_code = jsonObject.getInt("error_code"); + if (error_code == 0) { + System.out.println("调用接口成功"); + JSONObject result = jsonObject.getJSONObject("result"); + String sid = result.getString("sid"); + int fee = result.getInt("fee"); + System.out.println("本次发送的唯一标示:" + sid); + System.out.println("本次发送消耗的次数:" + fee); + }else{ + System.out.println("调用接口失败:"+ jsonObject.getString("reason")); + } + } catch (Exception e) { + e.printStackTrace(); + } + } + + /** + * get方式的http请求 + * + * @param httpUrl 请求地址 + * @return 返回结果 + */ + public static String doGet(String httpUrl) { + HttpURLConnection connection = null; + InputStream inputStream = null; + BufferedReader bufferedReader = null; + String result = null;// 返回结果字符串 + try { + // 创建远程url连接对象 + URL url = new URL(httpUrl); + // 通过远程url连接对象打开一个连接,强转成httpURLConnection类 + connection = (HttpURLConnection) url.openConnection(); + // 设置连接方式:get + connection.setRequestMethod("GET"); + // 设置连接主机服务器的超时时间:15000毫秒 + connection.setConnectTimeout(15000); + // 设置读取远程返回的数据时间:60000毫秒 + connection.setReadTimeout(60000); + // 发送请求 + connection.connect(); + // 通过connection连接,获取输入流 + if (connection.getResponseCode() == 200) { + inputStream = connection.getInputStream(); + // 封装输入流,并指定字符集 + bufferedReader = new BufferedReader(new InputStreamReader(inputStream, "UTF-8")); + // 存放数据 + StringBuilder sbf = new StringBuilder(); + String temp; + while ((temp = bufferedReader.readLine()) != null) { + sbf.append(temp); + sbf.append(System.getProperty("line.separator")); + } + result = sbf.toString(); + } + } catch (MalformedURLException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } finally { + // 关闭资源 + if (null != bufferedReader) { + try { + bufferedReader.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + if (null != inputStream) { + try { + inputStream.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + if (connection != null) { + connection.disconnect();// 关闭远程连接 + } + } + return result; + } + + + /** + * post方式的http请求 + * + * @param httpUrl 请求地址 + * @param param 请求参数 + * @return 返回结果 + */ + public static String doPost(String httpUrl, String param) { + HttpURLConnection connection = null; + InputStream inputStream = null; + OutputStream outputStream = null; + BufferedReader bufferedReader = null; + String result = null; + try { + URL url = new URL(httpUrl); + // 通过远程url连接对象打开连接 + connection = (HttpURLConnection) url.openConnection(); + // 设置连接请求方式 + connection.setRequestMethod("POST"); + // 设置连接主机服务器超时时间:15000毫秒 + connection.setConnectTimeout(15000); + // 设置读取主机服务器返回数据超时时间:60000毫秒 + connection.setReadTimeout(60000); + // 默认值为:false,当向远程服务器传送数据/写数据时,需要设置为true + connection.setDoOutput(true); + // 设置传入参数的格式:请求参数应该是 name1=value1&name2=value2 的形式。 + connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded"); + // 通过连接对象获取一个输出流 + outputStream = connection.getOutputStream(); + // 通过输出流对象将参数写出去/传输出去,它是通过字节数组写出的 + outputStream.write(param.getBytes()); + // 通过连接对象获取一个输入流,向远程读取 + if (connection.getResponseCode() == 200) { + inputStream = connection.getInputStream(); + // 对输入流对象进行包装:charset根据工作项目组的要求来设置 + bufferedReader = new BufferedReader(new InputStreamReader(inputStream, "UTF-8")); + StringBuilder sbf = new StringBuilder(); + String temp; + // 循环遍历一行一行读取数据 + while ((temp = bufferedReader.readLine()) != null) { + sbf.append(temp); + sbf.append(System.getProperty("line.separator")); + } + result = sbf.toString(); + } + } catch (MalformedURLException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } finally { + // 关闭资源 + if (null != bufferedReader) { + try { + bufferedReader.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + if (null != outputStream) { + try { + outputStream.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + if (null != inputStream) { + try { + inputStream.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + if (connection != null) { + connection.disconnect(); + } + } + return result; + } +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/utils/BusinessUtil.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/utils/BusinessUtil.java new file mode 100644 index 0000000..8e6fd47 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/utils/BusinessUtil.java @@ -0,0 +1,674 @@ +package com.ruoyi.utils; + +import cn.hutool.core.date.DateUtil; +import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.StrUtil; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.ruoyi.code.DictConstant; +import com.ruoyi.code.PublicCommon; +import com.ruoyi.code.Token; +import com.ruoyi.common.core.domain.entity.SysDictData; +import com.ruoyi.common.exception.CustomException; +import com.ruoyi.common.exception.ServiceException; +import com.ruoyi.common.exception.enums.CoreExceptionEnum; +import com.ruoyi.enums.sms.SmsEnums; +import com.ruoyi.enums.user.UserEnums; +import com.ruoyi.frequency.customer.entity.Customer; +import com.ruoyi.frequency.customer.mapper.CustomerMapper; +import com.ruoyi.frequency.customer.service.CustomerService; +import com.ruoyi.frequency.customer.service.UserService; +import com.ruoyi.frequency.enterprise.service.EnterpriseService; +import com.ruoyi.frequency.illegaldeductionrecord.model.result.OrderInfoResp; +import com.ruoyi.frequency.illegaldeductionrecord.service.IllegalDeductionRecordService; +import com.ruoyi.frequency.sale.entity.Sale; +import com.ruoyi.frequency.sale.service.SaleService; +import com.ruoyi.frequency.sensitiveword.entity.SensitiveWord; +import com.ruoyi.frequency.sensitiveword.service.SensitiveWordService; +import com.ruoyi.frequency.store.entity.Store; +import com.ruoyi.frequency.store.service.StoreService; +import com.ruoyi.pay.enums.PayEnums; +import com.ruoyi.response.ResponseData; +import com.ruoyi.system.service.ISysDictDataService; +import com.ruoyi.utils.pwd.MD5EncryptionPwdUtil; +import com.ruoyi.vo.UserInfo; +import com.ruoyi.vo.UserVo; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.redis.core.StringRedisTemplate; +import org.springframework.stereotype.Component; + +import javax.annotation.Resource; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.io.PrintWriter; +import java.lang.reflect.Field; +import java.math.BigDecimal; +import java.math.RoundingMode; +import java.util.*; +import java.util.concurrent.TimeUnit; + +/** + * @Author 刘耀 + * @Date 2020/9/16 14:24 + */ +@Slf4j +@Component +public class BusinessUtil { + + @Autowired + private StringRedisTemplate redisTemplate; + + + @Resource + private CustomerService customerService; + @Autowired + private CustomerMapper customerMapper; + + @Resource + private StoreService storeService; + + @Autowired + private ISysDictDataService iSysDictDataService; + + public OrderInfoResp getOrderInfo(Long orderId){ + return customerMapper.getOrderInfo(orderId); + } + + /** + * 获取字典 + * + * @param code + * @return + */ + public SysDictData getDict(String code) { + SysDictData sysDictData = new SysDictData(); + sysDictData.setCode(code); + List list = iSysDictDataService.selectDictDataList(sysDictData); + return list.isEmpty() ? null : list.get(0); + } + + public List getDictList(String code) { + SysDictData sysDictData = new SysDictData(); + sysDictData.setDictType(code); + List list = iSysDictDataService.selectDictDataList(sysDictData); + return list; + } + + public void setOutTradeNo(String outTradeNo) { + redisTemplate.opsForValue().set("PaySuccess" + outTradeNo, DateUtil.formatDateTime(new Date()), 10, TimeUnit.MINUTES); + } + + public Boolean isPaySuccess(String outTradeNo) { + return redisTemplate.hasKey("PaySuccess" + outTradeNo); + } + + + /** + * 判断支付密码是否错误 + * + * @param userVo + * @param pwd + * @return + */ + public Boolean payPwdTrue(UserVo userVo, String pwd) { + + //查询用户支付密码 + String userPwd = (String) getUserFieldValue(userVo, "payPwd"); + + if (StrUtil.isBlank(userPwd)) { + throw new CustomException(CoreExceptionEnum.NO_PWD); + } + + //验证密码 + String md5Code = MD5EncryptionPwdUtil.encryptionMd5(pwd); + if (!userPwd.equals(md5Code)) { + return false; + } + + return true; + } + + /** + * 验证支付密码 + * + * @param userVo + * @param pwd + * @return + */ + public void verifyPayPwd(UserVo userVo, Integer payType, String pwd) { + + if (ObjectUtil.equal(PayEnums.balance.getCode(), payType)) { + //支付密码验证 + Boolean isTrue = payPwdTrue(userVo, pwd); + if (!isTrue) { + throw new CustomException(CoreExceptionEnum.PWD_ERROR); + } + } + } + + /** + * 判断登录密码是否错误 + * + * @param userVo + * @param pwd + * @return + */ + public Boolean loginPwdTrue(UserVo userVo, String pwd) { + + //查询用户登入密码 + String loginPwd = (String) getUserFieldValue(userVo, "loginPwd"); + + if (StrUtil.isBlank(loginPwd)) { + throw new CustomException(540, "您还未设置密码,请选择其他登录方式"); + } + + String md5Code = MD5EncryptionPwdUtil.encryptionMd5(pwd); + if (!loginPwd.equals(md5Code)) { + return false; + } + return true; + } + + /** + * 功能描述:写出文本 + * + * @param response response + * @param data + * @author yangliu 2013-8-26 上午09:08:36 + */ + public void writeText(HttpServletResponse response, Object data) { + PrintWriter out = null; + try { + response.setCharacterEncoding("UTF-8"); + response.setContentType("application/text"); + out = response.getWriter(); + out.print(data); + } catch (IOException e) { + e.printStackTrace(); + } finally { + closeOut(out); + } + } + + private void closeOut(PrintWriter out) { + if (out != null) { + out.flush(); + out.close(); + } + } + + /** + * 校验支付密码 + * + * @param pwd + * @param userVo + * @return + */ + public ResponseData checkPayPwd(String pwd, UserVo userVo) { + + Boolean isTrue = payPwdTrue(userVo, pwd); + + if (!isTrue) { + return ResponseData.error(CoreExceptionEnum.PWD_ERROR); + } + return ResponseData.success(); + } + + + /** + * 生成token + * + * @param userId 用户id + * @return + */ + public ResponseData getToken(Long userId, Integer userType) { + +// if (UserEnums.store.getCode().equals(userType)){ +// Store store = storeService.getById(userId); +// if (ObjectUtil.isNotEmpty(store.getBindEnterpriseId())){ +// userId = store.getBindEnterpriseId(); +// userType = UserEnums.enterprise.getCode(); +// } +// } + + //组装token + String token = assembleToken(userType); + + redisTemplate.opsForValue().set(token, userId.toString(), Token.EXPIRE_SECOND, TimeUnit.DAYS); + + //存储token信息 +// redisTemplate.opsForHash().put(Token.TOKEN_MAP, userId + "", token); + + Map result = new HashMap<>(); + result.put("token", token); + return ResponseData.success(result); + } + + /** + * 组装token + * + * @param userType + * @return + */ + private String assembleToken(Integer userType) { + + String token = ""; + + switch (userType) { + case 1: + token = Token.customer + UUID.randomUUID(); + break; + case 2: + token = Token.store + UUID.randomUUID(); + break; + case 3: + token = Token.sale + UUID.randomUUID(); + break; + case 4: + token = Token.enterprise + UUID.randomUUID(); + break; + default: + throw new CustomException(CoreExceptionEnum.ERROR_PARAM); + } + return token; + } + + + /** + * 获取用户余额 + * + * @param userVo + * @return + */ + public BigDecimal getUserBalance(UserVo userVo) { + return new BigDecimal(getUserFieldValue(userVo, "balance").toString()); + } + + + /** + * 获取用户抵用金余额 + * + * @param userVo + * @return + */ + public BigDecimal getUserGiveBalance(UserVo userVo) { + return new BigDecimal(getUserFieldValue(userVo, "giveBalance").toString()); + } + + /** + * 获取用户积分 + * + * @param userVo + * @return + */ + public BigDecimal getUserIntegral(UserVo userVo) { + return new BigDecimal(getUserFieldValue(userVo, "integral").toString()); + } + + /** + * 获取用户其中一个字段 + * + * @param userVo + * @param fieldName + * @return + */ + public Object getUserFieldValue(UserVo userVo, String fieldName) { + + //获取用户对象 + Object object = getUserObject(userVo); + + Object fieldValue = getFieldValue(object, fieldName); + + return fieldValue; + } + + @Autowired + private SaleService saleService; + + @Autowired + private EnterpriseService enterpriseService; + + /** + * 获取用户对象 + * + * @param userVo + * @return + */ + private Object getUserObject(UserVo userVo) { + switch (userVo.getUserType()) { + case 1: + return customerService.getById(userVo.getUserId()); + case 2: + return storeService.getById(userVo.getUserId()); + case 3: + return saleService.getById(userVo.getUserId()); + case 4: + return enterpriseService.getById(userVo.getUserId()); + default: + throw new CustomException(CoreExceptionEnum.ERROR_PARAM); + } + } + + /** + * 根据手机号查询用户对象 + * + * @return + */ + public Object getUserObject(UserEnums userEnums, String areaCode, String mobile) { + switch (userEnums) { + case customer: + Customer customer = customerService.getOne(new QueryWrapper().lambda() + .eq(ObjectUtil.isNotEmpty(areaCode), Customer::getAreaCode, areaCode) + .eq(Customer::getMobile, mobile) + .ne(Customer::getDelFlag, PublicCommon.删除)); + return customer; + case store: + Store store = storeService.getOne(new QueryWrapper().lambda() + .eq(Store::getMobile, mobile) + .ne(Store::getDelFlag, PublicCommon.删除)); + return store; + case sale: + Sale sale = saleService.getOne(new QueryWrapper().lambda() + .eq(Sale::getMobile, mobile) + .ne(Sale::getDelFlag, PublicCommon.删除)); + return sale; + } + + return null; + } + + /** + * 根据用户账号查询用户对象 + * + * @return + */ + public Object getUserObject(UserEnums userEnums, String account) { + switch (userEnums) { + case customer: + Customer customer = customerService.getOne(new QueryWrapper().lambda() + .eq(Customer::getAccount, account) + .ne(Customer::getDelFlag, PublicCommon.删除)); + return customer; + case store: + Store store = storeService.getOne(new QueryWrapper().lambda() + .eq(Store::getAccount, account) + .ne(Store::getDelFlag, PublicCommon.删除)); + return store; + case sale: + Sale sale = saleService.getOne(new QueryWrapper().lambda() + .eq(Sale::getMobile, account) + .ne(Sale::getDelFlag, PublicCommon.删除)); + return sale; + default: + return null; + } + } + + + /** + * 根据字段名称,获取字段值 + */ + public Object getFieldValue(Object object, String fieldName) { + + //根据对象反射 + Class clazz = object.getClass(); + + //根据反射机制获取对象的所有字段,包含public、private和proteced + Field[] declaredFields = clazz.getDeclaredFields(); + + Object fieldValue = null; + + for (Field field : Arrays.asList(declaredFields)) { + //设置属性可访问 + field.setAccessible(true); + + if (ObjectUtil.notEqual(field.getName(), fieldName)) { + continue; + } + + try { + //得到属性值 + fieldValue = field.get(object); + } catch (IllegalAccessException e) { + e.printStackTrace(); + } + } + + return fieldValue; + } + + + /** + * 验证码验证 + * + * @param code 验证码 + * @param smsEnums 短信类型 SmsEnums枚举 + * @param mobile 手机号 + * @param userType 用户类型 1 用户 + * @return + */ + public void checkCode(String code, SmsEnums smsEnums, String areaCode, String mobile, Integer userType) { + String s = redisTemplate.opsForValue().get(code + smsEnums.getCode() + areaCode + mobile + userType); + if (StrUtil.isBlank(s)) { + throw new CustomException("验证码错误"); + } + String[] split = s.split(","); + Long time = System.currentTimeMillis() - Long.valueOf(split[0].trim()); + if (time > 10 * 60 * 1000) { + throw new CustomException("验证码超时"); + } + if (!split[1].trim().equals(smsEnums.getCode().toString())) { + throw new CustomException("操作冲突"); + } + if (!split[2].trim().equals(code)) { + throw new CustomException("验证码错误"); + } + if (!split[3].trim().equals(mobile)) { + throw new CustomException("手机号错误"); + } + + //删除 验证码 + redisTemplate.delete(code + smsEnums.getCode() + areaCode + mobile + userType); + } + + /** + * 判断余额支付 + * + * @param userVo + * @param amount + */ + public void judgeBalancePay(UserVo userVo, BigDecimal amount, String pwd) { + //支付密码验证 + Boolean isTrue = payPwdTrue(userVo, pwd); + if (!isTrue) { + throw new CustomException(CoreExceptionEnum.PWD_ERROR); + } + //判断余额 + BigDecimal userBalance = getUserBalance(userVo); + if (userBalance.compareTo(amount) == -1) { + throw new CustomException(CoreExceptionEnum.BALANCE_INSUFFICIENT); + } + } + + /** + * 判断积分余额支付 + * + * @param userVo + * @param amount + */ + public void judgeIntegralPay(UserVo userVo, BigDecimal amount, String pwd) { + + //判断积分余额 + BigDecimal userIntegral = getUserIntegral(userVo); + if (userIntegral.compareTo(amount) == -1) { + throw new CustomException(CoreExceptionEnum.INTEGRAL_INSUFFICIENT); + } + + //支付密码验证 + Boolean isTrue = payPwdTrue(userVo, pwd); + if (!isTrue) { + throw new CustomException(CoreExceptionEnum.PWD_ERROR); + } + } + + /** + * 修改在线时长 + * + * @param userVo + * @param totalTime + */ + public void updateOnlineDuration(UserVo userVo, Long totalTime, Integer onlineStatus) { + + switch (userVo.getUserType()) { + case 1: + customerService.update().setSql("online_duration = " + totalTime / 60 / 1000 + ",online_status = " + onlineStatus).eq("id", userVo.getUserId()).update(); + break; + case 2: + storeService.update().setSql("online_duration = " + totalTime / 60 / 1000 + ",online_status = " + onlineStatus).eq("id", userVo.getUserId()).update(); + break; + case 3: +// saleService.update().setSql("online_duration = " + totalTime/60/1000 + ",online_status = "+ onlineStatus).eq("id", userVo.getUserId()).update(); + break; + case 4: + enterpriseService.update().setSql("online_duration = " + totalTime / 60 / 1000 + ",online_status = " + onlineStatus).eq("id", userVo.getUserId()).update(); + break; + default: + throw new CustomException(CoreExceptionEnum.ERROR_PARAM); + } + } + + + /** + * 修改在线状态 + * + * @param userVo + */ + public void updateOnlineStatus(UserVo userVo) { + + switch (userVo.getUserType()) { + case 1: + customerService.update().setSql("online_status = 2").eq("id", userVo.getUserId()).update(); + break; + case 2: + storeService.update().setSql("online_status = 2").eq("id", userVo.getUserId()).update(); + break; + case 3: + saleService.update().setSql("online_status = 2").eq("id", userVo.getUserId()).update(); + break; + default: + throw new CustomException(CoreExceptionEnum.ERROR_PARAM); + } + } + + public UserInfo getUserInfo(UserVo userVo) { + //用户id + Set userVoSet = new HashSet<>(); + userVoSet.add(userVo); + + //获取用户信息 + Map userMap = userService.selectUserInfoMap(userVoSet, userVo); + UserInfo userInfo = userMap.get(userVo); + return userInfo; + } + + /** + * 计算用户可使用赠送的金额 + * + * @param userVo + * @param price + * @return + */ + public BigDecimal userMaxGivePrice(UserVo userVo, BigDecimal price) { + + //只有设计师有赠送金额 + if (ObjectUtil.notEqual(UserEnums.customer.getCode(), userVo.getUserType())) { + return BigDecimal.ZERO; + } + + //查询赠送金额最大支付比例 + SysDictData dict = this.getDict(DictConstant.OrderDict.赠送金额支付占比); + BigDecimal givePriceRatio = BigDecimal.ZERO; + if (dict != null && dict.getDictValue() != null) { + givePriceRatio = new BigDecimal(dict.getDictValue()); + } + + //获取用户赠送金额 + Customer customer = customerService.getById(userVo.getUserId()); + BigDecimal givePrice = customer.getGiveBalance(); + + BigDecimal maxGivePrice = price.multiply(givePriceRatio).setScale(2, RoundingMode.HALF_UP); + return maxGivePrice.compareTo(givePrice) == 1 ? givePrice : maxGivePrice; + } + + /** + * 获取用户当前在线状态 + * + * @param id + * @param lastTimeMapKey + * @return + */ + public Integer getOnlineStatus(Long id, String lastTimeMapKey) { + + //在线状态;1:在线,2离线 + Integer onlineStatus = 2; + + if (redisTemplate.opsForHash().hasKey(lastTimeMapKey, id.toString())) { + long lastTimes = Long.valueOf(redisTemplate.opsForHash().get(lastTimeMapKey, id.toString()).toString()); + + //判断当前时间和上次时间是否超过6分钟(考虑到网络延时和程序卡顿,多1分钟) + if (System.currentTimeMillis() - lastTimes < (6 * 60 * 1000)) { + onlineStatus = 1; + } + } + + return onlineStatus; + } + + /** + * 判断是否是自己 + */ + public static Boolean isSelf(UserVo sourceUser, UserVo targetUser) { + if (sourceUser != null && sourceUser.getUserId() != null && sourceUser.getUserType() != null + && targetUser != null && targetUser.getUserId() != null && targetUser.getUserType() != null) { + return sourceUser.getUserId().equals(targetUser.getUserId()) && sourceUser.getUserType().equals(targetUser.getUserType()); + } + return false; + } + + @Autowired + private UserService userService; + + /** + * 是否可以发布互动消息 + */ + public Boolean canPushMessage(UserVo selfUserVo, UserVo otherUserVo) { + List userVos = userService.blockUserList(selfUserVo); + for (UserVo userVo : userVos) { + Boolean self = isSelf(userVo, otherUserVo); + if (self) { + return false; + } + } + userVos = userService.shieldUserList(otherUserVo); + + for (UserVo userVo : userVos) { + Boolean self = isSelf(userVo, selfUserVo); + if (self) { + return false; + } + } + return true; + } + + @Autowired + private SensitiveWordService sensitiveWordService; + + public void checkSensitiveWord(String word) { + List list = sensitiveWordService.list(new QueryWrapper().lambda().eq(SensitiveWord::getDelFlag, PublicCommon.启用)); + for (SensitiveWord sensitiveWord : list) { + if (StrUtil.isNotBlank(sensitiveWord.getName()) && word.contains(sensitiveWord.getName())) { + throw new ServiceException("禁止使用敏感词汇"); + } + } + } +} \ No newline at end of file diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/utils/JudgeLogicUtil.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/utils/JudgeLogicUtil.java new file mode 100644 index 0000000..cf90082 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/utils/JudgeLogicUtil.java @@ -0,0 +1,588 @@ +package com.ruoyi.utils; + +import cn.hutool.core.collection.CollectionUtil; +import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.StrUtil; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.ruoyi.code.DictConstant; +import com.ruoyi.code.PublicCommon; +import com.ruoyi.common.core.domain.entity.SysDictData; +import com.ruoyi.common.exception.CustomException; +import com.ruoyi.common.exception.enums.CoreExceptionEnum; +import com.ruoyi.controller.req.LoginReqVo; +import com.ruoyi.controller.req.RegisterUserReq; +import com.ruoyi.enums.IntegralDetailEnums; +import com.ruoyi.enums.LoginEnums; +import com.ruoyi.enums.WalletDetailEnums; +import com.ruoyi.enums.user.UserEnums; +import com.ruoyi.frequency.customer.entity.Customer; +import com.ruoyi.frequency.customer.service.CustomerService; +import com.ruoyi.frequency.givewallerecord.service.GiveWalletRecordService; +import com.ruoyi.frequency.integralrecord.service.IntegralRecordService; +import com.ruoyi.frequency.refereeuser.entity.RefereeUser; +import com.ruoyi.frequency.refereeuser.mapper.RefereeUserMapper; +import com.ruoyi.frequency.sale.entity.Sale; +import com.ruoyi.frequency.sale.service.SaleService; +import com.ruoyi.frequency.store.entity.Store; +import com.ruoyi.frequency.store.service.StoreService; +import com.ruoyi.utils.pwd.MD5EncryptionPwdUtil; +import com.ruoyi.vo.UserVo; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import java.math.BigDecimal; +import java.util.List; +import java.util.Random; + +/** + * @Author liwenlong + */ + +@Component +public class JudgeLogicUtil { + + @Autowired + private CustomerService customerService; + + @Autowired + private StoreService storeService; + + @Autowired + private SaleService saleService; + + /** + * 验证登入账号 + * + * @return + */ + public Long checkLoginUser(LoginReqVo loginReqVo) { + switch (UserEnums.getUserEnums(loginReqVo.getUserType())) { + case customer: + Customer customer = getCustomer(loginReqVo); + //逻辑判断 + return judgeCustomer(customer, loginReqVo); + case store: + Store store = getStore(loginReqVo); + //逻辑判断 + return judgeStore(store, loginReqVo); + case sale: + Sale sale = getSale(loginReqVo); + //逻辑判断 + return judgeSale(sale, loginReqVo); + default: + return null; + } + } + + private final List assembleEnums = CollectionUtil.toList(LoginEnums.code_login, LoginEnums.one_click_login, LoginEnums.wechat_login, LoginEnums.applet_login, LoginEnums.apple_login); + + /** + * 判断用户 + * + * @param customer + */ + private Long judgeCustomer(Customer customer, LoginReqVo loginReqVo) { + + LoginEnums loginEnums = LoginEnums.getLoginEnums(loginReqVo.getType()); + + if (customer == null && !assembleEnums.contains(loginEnums)) { + throw new CustomException(CoreExceptionEnum.ACCOUNT_NOT_EXIST); + } + + RegisterUserReq registerReq = new RegisterUserReq(loginReqVo); + + String md5Pwd = null; + //MD5加密 + if (ObjectUtil.isNotEmpty(loginReqVo.getPassword())) { + md5Pwd = MD5EncryptionPwdUtil.encryptionMd5(loginReqVo.getPassword()); + } + + if (customer == null && assembleEnums.contains(loginEnums)) { + + switch (loginEnums) { + case one_click_login: + //组装用户 + customer = customerService.assembleCustomer(registerReq, md5Pwd); + + //生成邀请码 + String invitationCode = refereeUserCode(6, UserEnums.customer.getCode()); + customer.setInvitationCode(invitationCode); + customerService.getBaseMapper().insert(customer); + //创建绑定关系 + bindParentUser(customer.getId(), UserEnums.customer.getCode(), loginReqVo.getInvitationCode()); + break; + default: + + //微信,小程序,苹果登入需要绑定手机号(排除一键登入) + if (ObjectUtil.isEmpty(loginReqVo.getMobile()) && ObjectUtil.isNotEmpty(loginReqVo.getAccount())) { + loginReqVo.setMobile(loginReqVo.getAccount()); + } + if (ObjectUtil.isEmpty(loginReqVo.getMobile())) { + throw new CustomException(710, "请绑定手机号"); + } + + //根据手机号查询用户 + customer = customerService.getOne(new QueryWrapper().lambda() + .eq(Customer::getAreaCode, loginReqVo.getAreaCode()) + .eq(Customer::getMobile, loginReqVo.getMobile()) + .ne(Customer::getDelFlag, PublicCommon.删除)); + + if (customer != null) { + Long userId = customer.getId(); + customer = new Customer().setId(userId); + } else { + //组装用户 + customer = customerService.assembleCustomer(registerReq, md5Pwd); + + //生成邀请码 + invitationCode = refereeUserCode(6, UserEnums.customer.getCode()); + customer.setInvitationCode(invitationCode); + customerService.getBaseMapper().insert(customer); + //创建绑定关系 + bindParentUser(customer.getId(), UserEnums.customer.getCode(), loginReqVo.getInvitationCode()); + } + + switch (loginEnums) { + case wechat_login: + customer.setWechatOpenid(loginReqVo.getOpenid()); + break; + case applet_login: + customer.setWechatAppletOpenid(loginReqVo.getOpenid()); + customer.setUnionId(loginReqVo.getUnionid()); + break; + case apple_login: + customer.setAppleOpenid(loginReqVo.getOpenid()); + break; + } + } + customerService.getBaseMapper().updateById(customer); + //customerService.saveOrUpdate(customer); + + } else if (customer.getDelFlag().equals(PublicCommon.禁用)) { + throw new CustomException(CoreExceptionEnum.ACCOUNT_DISABLE); + } + //修改clientId + customerService.lambdaUpdate().set(Customer::getClientId, loginReqVo.getClientId()).eq(Customer::getId, customer.getId()).update(); + return customer.getId(); + } + + /** + * 生成普通用户验证码 + * + * @param codeLength 编码长度 + * @return 验证码字符窜 + */ + public String refereeUserCode(int codeLength, Integer userType) { + int i; + int count = 0; +// char[] str = {'0', '1', '2', '3', '4', '5', '6', '7', '8', +// '9', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', +// 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', +// 'Z'}; + char[] str = {'0', '1', '2', '3', '4', '5', '6', '7', '8', + '9'}; + StringBuffer pwd = new StringBuffer(""); + Random r = new Random(); + boolean isHave = true; + while (isHave) { + while (count < codeLength) { + i = Math.abs(r.nextInt(str.length)); + if (i >= 0 && i < str.length) { + pwd.append(str[i]); + count++; + } + } + + if (ObjectUtil.equal(UserEnums.customer.getCode(), userType)) { + Customer customer = customerService.getBaseMapper().selectOne(new QueryWrapper().lambda() + .eq(Customer::getInvitationCode, pwd.toString())); + if (customer == null) { + isHave = false; + } + } else if (ObjectUtil.equal(UserEnums.store.getCode(), userType)) { + Store store = storeService.getBaseMapper().selectOne(new QueryWrapper().lambda() + .eq(Store::getInvitationCode, pwd.toString())); + if (store == null) { + isHave = false; + } + } else if (ObjectUtil.equal(UserEnums.sale.getCode(), userType)) { + Sale sale = saleService.getBaseMapper().selectOne(new QueryWrapper().lambda() + .eq(Sale::getInviteCode, pwd.toString())); + if (sale == null) { + isHave = false; + } + } else { + isHave = false; + } + + count = 0; + } + return pwd.toString(); + } + + @Autowired + private RefereeUserMapper refereeUserMapper; + + @Autowired + private BusinessUtil businessUtil; + + @Autowired + private GiveWalletRecordService giveWalletRecordService; + + @Autowired + private IntegralRecordService integralRecordService; + + /** + * @param userId + * @param userType + * @param invitationCode + */ + private void bindParentUser(Long userId, Integer userType, String invitationCode) { + if (StrUtil.isBlank(invitationCode)) { + return; + } + Customer customer = customerService.getOne(new QueryWrapper().lambda().eq(Customer::getInvitationCode, invitationCode)); + if (customer != null) { + RefereeUser refereeUser = new RefereeUser(); + refereeUser.setUserId(userId); + refereeUser.setUserType(userType); + refereeUser.setParentUserId(customer.getId()); + refereeUser.setParentUserType(UserEnums.customer.getCode()); + refereeUserMapper.insert(refereeUser); + + //被注册赠送抵用金 + sendGiveBalance(userType,userId,refereeUser.getId()); + + //查询字典配置的赠送抵积分 + SysDictData dict = businessUtil.getDict(DictConstant.注册赠送积分); + + if (dict != null) { + BigDecimal integral = new BigDecimal(dict.getDictValue()); + //积分记录 + integralRecordService.updateIntegral(new UserVo(refereeUser.getParentUserType(), refereeUser.getParentUserId()), null, integral, IntegralDetailEnums.REFEREE_SEND,null); + } + } else { + Store store = storeService.getOne(new QueryWrapper().lambda().eq(Store::getInvitationCode, invitationCode)); + if (store != null) { + RefereeUser refereeUser = new RefereeUser(); + refereeUser.setUserId(userId); + refereeUser.setUserType(userType); + refereeUser.setParentUserId(store.getId()); + refereeUser.setParentUserType(UserEnums.store.getCode()); + refereeUserMapper.insert(refereeUser); + + //被注册赠送抵用金 + sendGiveBalance(userType,userId,refereeUser.getId()); + + } else { + Sale sale = saleService.getOne(new QueryWrapper().lambda().eq(Sale::getInviteCode, invitationCode)); + if (sale != null) { + RefereeUser refereeUser = new RefereeUser(); + refereeUser.setUserId(userId); + refereeUser.setUserType(userType); + refereeUser.setParentUserId(sale.getId()); + refereeUser.setParentUserType(UserEnums.sale.getCode()); + refereeUserMapper.insert(refereeUser); + + + //被注册赠送抵用金 + sendGiveBalance(userType,userId,refereeUser.getId()); + + //销售修改邀请数量 + saleService.lambdaUpdate().setSql("invite_num=invite_num+1").eq(Sale::getId, refereeUser.getParentUserId()).update(); + } + } + } + } + + /** + * 被邀请注册赠送抵用金 + * @param userType + * @param userId + * @param refereeId + */ + private void sendGiveBalance(Integer userType,Long userId,Long refereeId){ + if(userType!=null && userType.equals(UserEnums.customer.getCode())){ + //查询字典配置的赠送抵用金 + SysDictData dict = businessUtil.getDict(DictConstant.注册赠送抵用金); + + if (dict != null) { + BigDecimal giveAmount = new BigDecimal(dict.getDictValue()); + //钱包记录 + giveWalletRecordService.updateGiveBalance(new UserVo(userType, userId), WalletDetailEnums.GIVE_BALANCE, refereeId, giveAmount, PublicCommon.Wallet.可提现); + } + } + } + + /** + * 判断用户 + * + * @param store + */ + private Long judgeStore(Store store, LoginReqVo loginReqVo) { + + LoginEnums loginEnums = LoginEnums.getLoginEnums(loginReqVo.getType()); + + if (store == null && !assembleEnums.contains(loginEnums)) { + throw new CustomException(CoreExceptionEnum.ACCOUNT_NOT_EXIST); + } + + RegisterUserReq registerReq = new RegisterUserReq(loginReqVo); + + String md5Pwd = null; + //MD5加密 + if (ObjectUtil.isNotEmpty(loginReqVo.getPassword())) { + md5Pwd = MD5EncryptionPwdUtil.encryptionMd5(loginReqVo.getPassword()); + } + + + if (store == null && assembleEnums.contains(loginEnums)) { + + switch (loginEnums) { + case one_click_login: + //组装用户 + store = storeService.assembleStore(registerReq, md5Pwd); + //生成邀请码 + String invitationCode = refereeUserCode(6, UserEnums.store.getCode()); + store.setInvitationCode(invitationCode); + //创建绑定关系 + bindParentUser(store.getId(), UserEnums.store.getCode(), loginReqVo.getInvitationCode()); + break; + default: + if (ObjectUtil.isEmpty(loginReqVo.getMobile()) && ObjectUtil.isNotEmpty(loginReqVo.getAccount())) { + loginReqVo.setMobile(loginReqVo.getAccount()); + } + //微信,小程序,苹果登入需要绑定手机号(排除一键登入) + if (ObjectUtil.isEmpty(loginReqVo.getMobile())) { + throw new CustomException(710, "请绑定手机号"); + } + + //根据手机号查询用户 + store = storeService.getOne(new QueryWrapper().lambda() + .eq(Store::getMobile, loginReqVo.getMobile()) + .ne(Store::getDelFlag, PublicCommon.删除)); + + if (store != null) { + Long userId = store.getId(); + store = new Store().setId(userId); + } else { + //组装用户 + store = storeService.assembleStore(registerReq, md5Pwd); + //生成邀请码 + invitationCode = refereeUserCode(6, UserEnums.store.getCode()); + store.setInvitationCode(invitationCode); + //创建绑定关系 + bindParentUser(store.getId(), UserEnums.store.getCode(), loginReqVo.getInvitationCode()); + } + + switch (loginEnums) { + case wechat_login: + store.setWechatOpenid(loginReqVo.getOpenid()); + break; + case applet_login: + store.setWechatAppletOpenid(loginReqVo.getOpenid()); + store.setUnionId(loginReqVo.getUnionid()); + break; + case apple_login: + store.setAppleOpenid(loginReqVo.getOpenid()); + break; + } + } + storeService.saveOrUpdate(store); + + } else if (store.getDelFlag().equals(PublicCommon.禁用)) { + throw new CustomException(CoreExceptionEnum.ACCOUNT_DISABLE); + } + //修改clientId +// storeService.lambdaUpdate().set(Store::getClientId,loginReqVo.getClientId()).eq(Store::getId,store.getId()).update(); + return store.getId(); + } + + + /** + * 判断用户 + * + * @param sale + */ + private Long judgeSale(Sale sale, LoginReqVo loginReqVo) { + + LoginEnums loginEnums = LoginEnums.getLoginEnums(loginReqVo.getType()); + + if (sale == null && !assembleEnums.contains(loginEnums)) { + throw new CustomException(CoreExceptionEnum.ACCOUNT_NOT_EXIST); + } + + RegisterUserReq registerReq = new RegisterUserReq(loginReqVo); + + String md5Pwd = null; + //MD5加密 + if (ObjectUtil.isNotEmpty(loginReqVo.getPassword())) { + md5Pwd = MD5EncryptionPwdUtil.encryptionMd5(loginReqVo.getPassword()); + } + + if (sale == null && assembleEnums.contains(loginEnums)) { + + switch (loginEnums) { + case one_click_login: + //组装用户 + sale = saleService.assembleSale(registerReq, md5Pwd); + + //生成邀请码 + String invitationCode = refereeUserCode(6, UserEnums.sale.getCode()); + sale.setInviteCode(invitationCode); + //创建绑定关系 + bindParentUser(sale.getId(), UserEnums.sale.getCode(), loginReqVo.getInvitationCode()); + break; + default: + if (ObjectUtil.isEmpty(loginReqVo.getMobile()) && ObjectUtil.isNotEmpty(loginReqVo.getAccount())) { + loginReqVo.setMobile(loginReqVo.getAccount()); + } + //微信,小程序,苹果登入需要绑定手机号(排除一键登入) + if (ObjectUtil.isEmpty(loginReqVo.getMobile())) { + throw new CustomException(710, "请绑定手机号"); + } + + //根据手机号查询用户 + sale = saleService.getOne(new QueryWrapper().lambda() + .eq(Sale::getMobile, loginReqVo.getAccount()) + .ne(Sale::getDelFlag, PublicCommon.删除)); + + if (sale != null) { + Long userId = sale.getId(); + sale = new Sale().setId(userId); + } else { + //组装用户 + sale = saleService.assembleSale(registerReq, md5Pwd); + + //生成邀请码 + invitationCode = refereeUserCode(6, UserEnums.sale.getCode()); + sale.setInviteCode(invitationCode); + //创建绑定关系 + bindParentUser(sale.getId(), UserEnums.sale.getCode(), loginReqVo.getInvitationCode()); + } + + switch (loginEnums) { + case wechat_login: + sale.setWechatOpenid(loginReqVo.getOpenid()); + break; + case applet_login: + sale.setWechatAppletOpenid(loginReqVo.getOpenid()); + sale.setUnionId(loginReqVo.getOpenid()); + break; + case apple_login: + sale.setAppleOpenid(loginReqVo.getOpenid()); + break; + } + } + saleService.saveOrUpdate(sale); + + } else if (sale.getDelFlag().equals(PublicCommon.禁用)) { + throw new CustomException(CoreExceptionEnum.ACCOUNT_DISABLE); + } + //修改clientId +// storeService.lambdaUpdate().set(Store::getClientId,loginReqVo.getClientId()).eq(Store::getId,store.getId()).update(); + return sale.getId(); + } + + + /** + * 获取用户 + * + * @return + */ + private Customer getCustomer(LoginReqVo loginReqVo) { + + LambdaQueryWrapper lambda = new QueryWrapper() + .lambda() + .ne(Customer::getDelFlag, PublicCommon.删除); + + switch (LoginEnums.getLoginEnums(loginReqVo.getType())) { + case code_login: + lambda.eq(Customer::getAccount, loginReqVo.getAccount()); + break; + case pwd_login: + lambda.eq(Customer::getMobile, loginReqVo.getAccount()); + break; + case one_click_login: + lambda.eq(Customer::getMobile, loginReqVo.getMobile()); + break; + case wechat_login: + lambda.eq(Customer::getWechatOpenid, loginReqVo.getOpenid()); + break; + case applet_login: + lambda.eq(Customer::getWechatAppletOpenid, loginReqVo.getOpenid()); + break; + case apple_login: + lambda.eq(Customer::getAppleOpenid, loginReqVo.getOpenid()); + break; + } + Customer customer = customerService.getOne(lambda); + + return customer; + } + + private Store getStore(LoginReqVo loginReqVo) { + + LambdaQueryWrapper lambda = new QueryWrapper() + .lambda() + .ne(Store::getDelFlag, PublicCommon.删除); + + switch (LoginEnums.getLoginEnums(loginReqVo.getType())) { + case code_login: + lambda.eq(Store::getAccount, loginReqVo.getAccount()); + break; + case pwd_login: + lambda.eq(Store::getAccount, loginReqVo.getAccount()); + break; + case one_click_login: + lambda.eq(Store::getMobile, loginReqVo.getMobile()); + break; + case wechat_login: + lambda.eq(Store::getWechatOpenid, loginReqVo.getOpenid()); + break; + case applet_login: + lambda.eq(Store::getWechatAppletOpenid, loginReqVo.getOpenid()); + break; + case apple_login: + lambda.eq(Store::getAppleOpenid, loginReqVo.getOpenid()); + break; + } + Store store = storeService.getOne(lambda); + + return store; + } + + private Sale getSale(LoginReqVo loginReqVo) { + + LambdaQueryWrapper lambda = new QueryWrapper() + .lambda() + .ne(Sale::getDelFlag, PublicCommon.删除); + + switch (LoginEnums.getLoginEnums(loginReqVo.getType())) { + case code_login: + lambda.eq(Sale::getMobile, loginReqVo.getAccount()); + break; + case pwd_login: + lambda.eq(Sale::getMobile, loginReqVo.getAccount()); + break; + case one_click_login: + lambda.eq(Sale::getMobile, loginReqVo.getAccount()); + break; + case wechat_login: + lambda.eq(Sale::getWechatOpenid, loginReqVo.getOpenid()); + break; + case applet_login: + lambda.eq(Sale::getWechatAppletOpenid, loginReqVo.getOpenid()); + break; + case apple_login: + lambda.eq(Sale::getAppleOpenid, loginReqVo.getOpenid()); + break; + } + Sale sale = saleService.getOne(lambda); + + return sale; + } + + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/utils/LoginUtil.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/utils/LoginUtil.java new file mode 100644 index 0000000..9cbdc79 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/utils/LoginUtil.java @@ -0,0 +1,740 @@ +package com.ruoyi.utils; + +import cn.hutool.core.util.ObjectUtil; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.ruoyi.code.DictConstant; +import com.ruoyi.code.PublicCommon; +import com.ruoyi.common.core.domain.entity.SysDictData; +import com.ruoyi.common.exception.CustomException; +import com.ruoyi.common.exception.enums.CoreExceptionEnum; +import com.ruoyi.controller.req.*; +import com.ruoyi.enums.IntegralDetailEnums; +import com.ruoyi.enums.WalletDetailEnums; +import com.ruoyi.enums.sms.SmsEnums; +import com.ruoyi.enums.user.UserEnums; +import com.ruoyi.frequency.customer.entity.Customer; +import com.ruoyi.frequency.customer.service.CustomerService; +import com.ruoyi.frequency.enterprise.service.EnterpriseService; +import com.ruoyi.frequency.givewallerecord.service.GiveWalletRecordService; +import com.ruoyi.frequency.integralrecord.service.IntegralRecordService; +import com.ruoyi.frequency.refereeuser.entity.RefereeUser; +import com.ruoyi.frequency.refereeuser.service.RefereeUserService; +import com.ruoyi.frequency.sale.entity.Sale; +import com.ruoyi.frequency.sale.service.SaleService; +import com.ruoyi.frequency.store.entity.Store; +import com.ruoyi.frequency.store.service.StoreService; +import com.ruoyi.frequency.wallerecord.service.WalletRecordService; +import com.ruoyi.response.ResponseData; +import com.ruoyi.utils.pwd.MD5EncryptionPwdUtil; +import com.ruoyi.vo.UserVo; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.redis.core.StringRedisTemplate; +import org.springframework.stereotype.Component; +import org.springframework.transaction.annotation.Transactional; + +import javax.annotation.Resource; +import javax.servlet.http.HttpServletRequest; +import java.math.BigDecimal; +import java.util.Date; +import java.util.Random; + +/** + * @Author liwenlong + * @Date 2020/9/16 14:24 + */ +@Slf4j +@Component +public class LoginUtil { + + @Autowired + private StringRedisTemplate redisTemplate; + + @Resource + private CustomerService customerService; + + @Autowired + private StoreService storeService; + + @Autowired + private SaleService saleService; + + + @Autowired + private HttpServletRequest request; + + @Autowired + private BusinessUtil businessUtil; + + @Autowired + private RefereeUserService refereeUserService; + + @Autowired + private WalletRecordService walletRecordService; + + /** + * 注册 + * + * @param req + * @return + */ + @Transactional(rollbackFor = Exception.class) + public ResponseData register(RegisterUserReq req) { + + if (ObjectUtil.isEmpty(req.getMobile())) { + req.setMobile(req.getAccount()); + } + + // 验证码校验 + businessUtil.checkCode(req.getCode(), SmsEnums.REGISTER, req.getAreaCode(), req.getMobile(), req.getUserType()); + + //MD5加密 + String md5Pwd = MD5EncryptionPwdUtil.encryptionMd5(req.getPwd()); + + Long userId = null; + + //不同用户类型 + switch (UserEnums.getUserEnums(req.getUserType())) { + case customer: + //账号验证 + Customer customer = customerService.getBaseMapper().selectOne(Wrappers.lambdaQuery(). + eq(Customer::getMobile, req.getMobile()).ne(Customer::getDelFlag, PublicCommon.删除)); + if (customer != null) { + throw new CustomException(CoreExceptionEnum.ACCOUNT_HAS_EXIST); + } + + //组装用户 + customer = customerService.assembleCustomer(req, md5Pwd); + customer.setClientId(req.getClientId()); + + //清空其他账号同clientId + if (ObjectUtil.isNotEmpty(req.getClientId())) { + customerService.lambdaUpdate().set(Customer::getClientId, null).eq(Customer::getClientId, req.getClientId()).update(); + } + + //生成邀请码 + String invitationCode = refereeUserCode(6, 1); + customer.setInvitationCode(invitationCode); + + customerService.getBaseMapper().insert(customer); + + + //用户id + userId = customer.getId(); + break; + + case store: + //账号验证 + Store store = storeService.getBaseMapper().selectOne(Wrappers.lambdaQuery(). + eq(Store::getMobile, req.getMobile()).ne(Store::getDelFlag, PublicCommon.删除)); + if (store != null) { + throw new CustomException(CoreExceptionEnum.ACCOUNT_HAS_EXIST); + } + //组装用户 + store = storeService.assembleStore(req, md5Pwd); + //清空其他账号同clientId + if (ObjectUtil.isNotEmpty(req.getClientId())) { + } + //生成邀请码 + String storeInvitationCode = refereeUserCode(6, 2); + store.setInvitationCode(storeInvitationCode); + + System.out.println("雪花id --- >" + store.getId()); + storeService.getBaseMapper().insert(store); + + //用户id + userId = store.getId(); + break; + + case sale: + //账号验证 + Sale sale = saleService.getBaseMapper().selectOne(Wrappers.lambdaQuery(). + eq(Sale::getMobile, req.getMobile()).ne(Sale::getDelFlag, PublicCommon.删除)); + if (sale != null) { + throw new CustomException(CoreExceptionEnum.ACCOUNT_HAS_EXIST); + } + //组装用户 + sale = saleService.assembleSale(req, md5Pwd); + //清空其他账号同clientId + if (ObjectUtil.isNotEmpty(req.getClientId())) { + } + //生成邀请码 + String saleInvitationCode = refereeUserCode(6, 3); + sale.setInviteCode(saleInvitationCode); + + saleService.getBaseMapper().insert(sale); + + //用户id + userId = sale.getId(); + break; + + default: + throw new CustomException(CoreExceptionEnum.ERROR_PARAM); + } + + //判断是否是他人邀请的用户 + if (ObjectUtil.isNotEmpty(req.getInvitationCode())) { + RefereeUser refereeUser = assembleRefereeUser(new UserVo(req.getUserType(), userId), req.getInvitationCode(), req.getInviteSource()); + refereeUserService.save(refereeUser); + + //销售修改邀请数量 + if (UserEnums.sale.getCode().equals(refereeUser.getParentUserType())) { + saleService.lambdaUpdate().setSql("invite_num=invite_num+1").eq(Sale::getId, refereeUser.getParentUserId()).update(); + } + + //设计师邀请设计师 赠送优惠金额 + if (UserEnums.customer.getCode().equals(refereeUser.getUserType())) { + //查询字典配置的赠送优惠金额 + SysDictData dict = businessUtil.getDict(DictConstant.注册赠送抵用金); + + if (dict != null) { + BigDecimal giveAmount = new BigDecimal(dict.getDictValue()); + + //钱包记录 + giveWalletRecordService.updateGiveBalance(new UserVo(refereeUser.getUserType(), refereeUser.getUserId()), WalletDetailEnums.GIVE_BALANCE, refereeUser.getId(), giveAmount, PublicCommon.Wallet.可提现); + + } + + //查询字典配置的赠送抵积分 + dict = businessUtil.getDict(DictConstant.注册赠送积分); + + if (dict != null) { + BigDecimal integral = new BigDecimal(dict.getDictValue()); + //积分记录 + integralRecordService.updateIntegral(new UserVo(refereeUser.getParentUserType(), refereeUser.getParentUserId()), null, integral, IntegralDetailEnums.REFEREE_SEND,null); + } + } + } + + return businessUtil.getToken(userId, req.getUserType()); + } + + @Autowired + private IntegralRecordService integralRecordService; + + + @Autowired + private GiveWalletRecordService giveWalletRecordService; + + + /** + * 组装邀请记录 + * + * @param userVo + * @return + */ + private RefereeUser assembleRefereeUser(UserVo userVo, String code, Integer inviteSource) { + + UserVo parentUserVo = new UserVo(inviteSource, null); + + switch (userVo.getUserType()) { + case 1: + //根据邀请码查询邀请人id + if (inviteSource == 1) { + Customer customer = customerService.getBaseMapper().selectOne(new QueryWrapper().lambda() + .eq(Customer::getInvitationCode, code)); + if (customer == null) { + throw new CustomException(CoreExceptionEnum.REFEREE_CODE_ERROR); + } + parentUserVo.setUserType(UserEnums.customer.getCode()); + parentUserVo.setUserId(customer.getId()); + } else if (inviteSource == 3) { + Sale sale = saleService.getBaseMapper().selectOne(new QueryWrapper().lambda() + .eq(Sale::getInviteCode, code)); + if (sale == null) { + throw new CustomException(CoreExceptionEnum.REFEREE_CODE_ERROR); + } + parentUserVo.setUserType(UserEnums.sale.getCode()); + parentUserVo.setUserId(sale.getId()); + } + break; + case 2: + //根据邀请码查询邀请人id + Store store = storeService.getBaseMapper().selectOne(new QueryWrapper().lambda() + .eq(Store::getInvitationCode, code)); + if (store == null) { + throw new CustomException(CoreExceptionEnum.REFEREE_CODE_ERROR); + } + parentUserVo.setUserType(UserEnums.store.getCode()); + parentUserVo.setUserId(store.getId()); + break; + default: + throw new IllegalStateException("Unexpected value: " + userVo.getUserType()); + } + + return new RefereeUser().setParentUserId(parentUserVo.getUserId()) + .setParentUserType(parentUserVo.getUserType()) + .setUserId(userVo.getUserId()) + .setUserType(userVo.getUserType()); + } + + + /** + * 生成普通用户验证码 + * + * @param codeLength 编码长度 + * @return 验证码字符窜 + */ + private String refereeUserCode(int codeLength, Integer userType) { + int i; + int count = 0; +// char[] str = {'0', '1', '2', '3', '4', '5', '6', '7', '8', +// '9', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', +// 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', +// 'Z'}; + char[] str = {'0', '1', '2', '3', '4', '5', '6', '7', '8', + '9'}; + StringBuffer pwd = new StringBuffer(""); + Random r = new Random(); + boolean isHave = true; + while (isHave) { + while (count < codeLength) { + i = Math.abs(r.nextInt(str.length)); + if (i >= 0 && i < str.length) { + pwd.append(str[i]); + count++; + } + } + + if (ObjectUtil.equal(UserEnums.customer.getCode(), userType)) { + Customer customer = customerService.getBaseMapper().selectOne(new QueryWrapper().lambda() + .eq(Customer::getInvitationCode, pwd.toString())); + if (customer == null) { + isHave = false; + } + } else if (ObjectUtil.equal(UserEnums.store.getCode(), userType)) { + Store store = storeService.getBaseMapper().selectOne(new QueryWrapper().lambda() + .eq(Store::getInvitationCode, pwd.toString())); + if (store == null) { + isHave = false; + } + } else if (ObjectUtil.equal(UserEnums.sale.getCode(), userType)) { + Sale sale = saleService.getBaseMapper().selectOne(new QueryWrapper().lambda() + .eq(Sale::getInviteCode, pwd.toString())); + if (sale == null) { + isHave = false; + } + } else { + isHave = false; + } + + count = 0; + } + return pwd.toString(); + } + + /** + * 修改密码 + * + * @param req + * @return + */ + public ResponseData editPwd(UserEditPwdLoginReq req, UserVo userVo) { + + if (!businessUtil.loginPwdTrue(userVo, req.getOldPwd())) { + return ResponseData.error(CoreExceptionEnum.PWD_ERROR); + } + //修改密码 + boolean update = updateLoginPwd(userVo, req.getPwd()); + if (!update) { + return ResponseData.error(CoreExceptionEnum.UPDATE_PWD_ERROR); + } + + return ResponseData.success(); + } + + /** + * 根据不同用户,修改登入密码 + * + * @param userVo + * @param pwd 修改后的密码 + * @return + */ + private boolean updateLoginPwd(UserVo userVo, String pwd) { + + //是否修改成功 + boolean update = true; + //根据不同的用户类型 修改用户的密码 + switch (UserEnums.getUserEnums(userVo.getUserType())) { + case customer: + update = customerService.lambdaUpdate().set(Customer::getLoginPwd, MD5EncryptionPwdUtil.encryptionMd5(pwd)) + .eq(Customer::getId, userVo.getUserId()).update(); + break; + case store: + update = storeService.lambdaUpdate().set(Store::getLoginPwd, MD5EncryptionPwdUtil.encryptionMd5(pwd)) + .eq(Store::getId, userVo.getUserId()).update(); + break; + case sale: + update = saleService.lambdaUpdate().set(Sale::getLoginPwd, MD5EncryptionPwdUtil.encryptionMd5(pwd)) + .eq(Sale::getId, userVo.getUserId()).update(); + break; + default: + throw new CustomException(CoreExceptionEnum.ERROR_PARAM); + } + return update; + } + + + /** + * 根据不同用户,修改支付密码 + * + * @param userVo + * @param pwd 修改后的密码 + * @return + */ + private boolean updatePayPwd(UserVo userVo, String pwd) { + + //是否修改成功 + boolean update = true; + //根据不同的用户类型 修改用户的支付密码 + switch (UserEnums.getUserEnums(userVo.getUserType())) { + case customer: + update = customerService.lambdaUpdate().set(Customer::getPayPwd, MD5EncryptionPwdUtil.encryptionMd5(pwd)) + .eq(Customer::getId, userVo.getUserId()).update(); + break; + case store: + update = storeService.lambdaUpdate().set(Store::getPayPwd, MD5EncryptionPwdUtil.encryptionMd5(pwd)) + .eq(Store::getId, userVo.getUserId()).update(); + break; + case sale: + update = saleService.lambdaUpdate().set(Sale::getPayPwd, MD5EncryptionPwdUtil.encryptionMd5(pwd)) + .eq(Sale::getId, userVo.getUserId()).update(); + break; + case enterprise: + Store one = storeService.getOne(new QueryWrapper().lambda().eq(Store::getBindEnterpriseId, userVo.getUserId())); + if (one != null) { + update = storeService.lambdaUpdate().set(Store::getPayPwd, MD5EncryptionPwdUtil.encryptionMd5(pwd)) + .eq(Store::getId, one.getId()).update(); + } + break; + default: + throw new CustomException(CoreExceptionEnum.ERROR_PARAM); + } + + + return update; + } + + /** + * 忘记密码 + * + * @param req + * @return + */ + public ResponseData forgetPwd(UserForgetPwdLoginReq req) { + + businessUtil.checkCode(req.getCode(), SmsEnums.FORGET_PWD, req.getAreaCode(), req.getMobile(), req.getUserType()); + + Long userId = getUserId(req.getUserType(), req.getMobile()); + + //修改密码 + boolean update = updateLoginPwd(new UserVo(req.getUserType(), userId), req.getPwd()); + if (!update) { + return ResponseData.error(CoreExceptionEnum.UPDATE_PWD_ERROR); + } + + return ResponseData.success(); + } + + /** + * 获取用户id + * + * @param userType + * @param account 用户账号 + * @return + */ + private Long getUserId(Integer userType, String account) { + + Long userId = null; + + //根据不同的用户类型 查询用户id + switch (userType) { + case 1: + Customer customer = customerService.getBaseMapper().selectOne(new QueryWrapper().lambda() + .eq(Customer::getMobile, account) + .ne(Customer::getDelFlag, PublicCommon.删除)); + + if (customer == null) { + throw new CustomException(CoreExceptionEnum.ACCOUNT_NOT_EXIST); + } else if (customer.getDelFlag().equals(PublicCommon.禁用)) { + throw new CustomException(CoreExceptionEnum.ACCOUNT_DISABLE); + } + + userId = customer.getId(); + break; + case 2: + Store store = storeService.getBaseMapper().selectOne(new QueryWrapper().lambda() + .eq(Store::getMobile, account) + .ne(Store::getDelFlag, PublicCommon.删除)); + + if (store == null) { + throw new CustomException(CoreExceptionEnum.ACCOUNT_NOT_EXIST); + } else if (store.getDelFlag().equals(PublicCommon.禁用)) { + throw new CustomException(CoreExceptionEnum.ACCOUNT_DISABLE); + } + + userId = store.getId(); + break; + case 3: + Sale sale = saleService.getBaseMapper().selectOne(new QueryWrapper().lambda() + .eq(Sale::getMobile, account) + .ne(Sale::getDelFlag, PublicCommon.删除)); + + if (sale == null) { + throw new CustomException(CoreExceptionEnum.ACCOUNT_NOT_EXIST); + } else if (sale.getDelFlag().equals(PublicCommon.禁用)) { + throw new CustomException(CoreExceptionEnum.ACCOUNT_DISABLE); + } + + userId = sale.getId(); + break; + case 4: + store = storeService.getBaseMapper().selectOne(new QueryWrapper().lambda() + .eq(Store::getMobile, account) + .ne(Store::getDelFlag, PublicCommon.删除)); + + if (store == null) { + throw new CustomException(CoreExceptionEnum.ACCOUNT_NOT_EXIST); + } else if (store.getDelFlag().equals(PublicCommon.禁用)) { + throw new CustomException(CoreExceptionEnum.ACCOUNT_DISABLE); + } + + userId = store.getId(); + break; + default: + throw new CustomException(CoreExceptionEnum.ERROR_PARAM); + } + + return userId; + + } + + @Autowired + private EnterpriseService enterpriseService; + + /** + * 忘记支付密码 + * + * @param req + * @param userVo + * @return + */ + public ResponseData forgetPayPwd(UserForgetPwdLoginReq req, UserVo userVo) { + + businessUtil.checkCode(req.getCode(), SmsEnums.PAY_PWD, req.getAreaCode(), req.getMobile(), userVo.getUserType()); + + //根据账号获取 用户id + Long userId = getUserId(userVo.getUserType(), req.getMobile()); + + //修改支付密码 + boolean update = updatePayPwd(new UserVo(userVo.getUserType(), userId), req.getPwd()); + if (!update) { + return ResponseData.error(CoreExceptionEnum.UPDATE_PWD_ERROR); + } + + return ResponseData.success(); + } + + + /** + * 修改支付密码 + * + * @param pwd + * @param userVo + * @return + */ + public ResponseData editPayPwd(String pwd, UserVo userVo) { + + //修改支付密码 + boolean update = updatePayPwd(userVo, pwd); + if (!update) { + return ResponseData.error(CoreExceptionEnum.UPDATE_PWD_ERROR); + } + + return ResponseData.success(); + } + + + /** + * 退出 + * + * @param userVo + * @return + */ + public ResponseData logout(UserVo userVo) { + + //根据不同的用户类型 清空client_id + switch (UserEnums.getUserEnums(userVo.getUserType())) { + case customer: + customerService.lambdaUpdate().set(Customer::getClientId, "").eq(Customer::getId, userVo.getUserId()).update(); + break; + case store: +// storeService.lambdaUpdate().set(Store::getClientId, "").eq(Store::getId, userVo.getUserId()).update(); + break; + case sale: +// saleService.lambdaUpdate().set(Sale::getClientId, "").eq(Sale::getId, userVo.getUserId()).update(); + break; + case enterprise: + break; + default: + throw new CustomException(CoreExceptionEnum.ERROR_PARAM); + } + String token = request.getHeader("token"); + redisTemplate.delete(token); + return ResponseData.success(); + } + + + /** + * 注销 + * + * @param userVo + * @return + */ + public ResponseData cancellation(UserVo userVo) { + + //根据不同的用户类型 注销用户 + switch (userVo.getUserType()) { + case 1: + customerService.lambdaUpdate().set(Customer::getClientId, "") + .set(Customer::getCancellationTime, new Date()) + .set(Customer::getDelFlag, PublicCommon.删除) + .eq(Customer::getId, userVo.getUserId()).update(); + break; + case 2: + storeService.lambdaUpdate() + .set(Store::getCancellationTime, new Date()) + .set(Store::getDelFlag, PublicCommon.删除) + .eq(Store::getId, userVo.getUserId()).update(); + break; + case 3: + break; + case 4: + + break; + default: + throw new CustomException(CoreExceptionEnum.ERROR_PARAM); + } + return ResponseData.success(); + + } + + + /** + * 校验旧手机号 + * + * @param req + * @param userVo + * @return + */ + public ResponseData checkOldMobile(CheckOldMobileReq req, UserVo userVo) { + + //验证码验证 + businessUtil.checkCode(req.getOldCode(), SmsEnums.OLD_MOBILE_BIND, req.getAreaCode(), req.getOldMobile(), userVo.getUserType()); + return ResponseData.success(); + + } + + /** + * 换绑手机号 + * + * @param req + * @param userVo + * @return + */ + public ResponseData changeBindingMobile(ChangeBindingMobileReq req, UserVo userVo) { + + //验证码验证 + businessUtil.checkCode(req.getNewCode(), SmsEnums.NEW_MOBILE_BIND, req.getAreaCode(), req.getNewMobile(), userVo.getUserType()); + + + Long userId = getUserId(userVo.getUserType(), req.getOldMobile()); + + if (!userId.equals(userVo.getUserId())) { + return ResponseData.error("请使用绑定的手机号码"); + } + + //根据不同的用户类型 判断修改后的手机号是否存在 ,修改手机号 + switch (userVo.getUserType()) { + case 1: + Customer customerDb = customerService.getBaseMapper().selectOne(new QueryWrapper().lambda() + .ne(Customer::getId, userVo.getUserId()) + .eq(Customer::getMobile, req.getNewMobile()).ne(Customer::getDelFlag, PublicCommon.删除)); + if (customerDb != null) { + throw new CustomException(CoreExceptionEnum.ACCOUNT_HAS_EXIST); + } + + //修改手机号 + boolean update = customerService.lambdaUpdate().set(Customer::getAccount, req.getNewMobile()).set(Customer::getMobile, req.getNewMobile()).eq(Customer::getId, userId).update(); + if (!update) { + throw new CustomException(CoreExceptionEnum.UPDATE_MOBILE_ERROR); + } + break; + case 2: + Store storeDb = storeService.getBaseMapper().selectOne(new QueryWrapper().lambda() + .ne(Store::getId, userVo.getUserId()) + .eq(Store::getMobile, req.getNewMobile()).ne(Store::getDelFlag, PublicCommon.删除)); + if (storeDb != null) { + throw new CustomException(CoreExceptionEnum.ACCOUNT_HAS_EXIST); + } + + //修改手机号 + boolean update2 = storeService.lambdaUpdate().set(Store::getAccount, req.getNewMobile()).set(Store::getMobile, req.getNewMobile()).eq(Store::getId, userId).update(); + if (!update2) { + throw new CustomException(CoreExceptionEnum.UPDATE_MOBILE_ERROR); + } + break; + case 3: + Sale saleDb = saleService.getBaseMapper().selectOne(new QueryWrapper().lambda() + .ne(Sale::getId, userVo.getUserId()) + .eq(Sale::getMobile, req.getNewMobile()).ne(Sale::getDelFlag, PublicCommon.删除)); + if (saleDb != null) { + throw new CustomException(CoreExceptionEnum.ACCOUNT_HAS_EXIST); + } + + //修改手机号 + boolean update3 = saleService.lambdaUpdate().set(Sale::getMobile, req.getNewMobile()).eq(Sale::getId, userId).update(); + if (!update3) { + throw new CustomException(CoreExceptionEnum.UPDATE_MOBILE_ERROR); + } + break; + case 4: + storeDb = storeService.getBaseMapper().selectOne(new QueryWrapper().lambda() + .ne(Store::getId, userVo.getUserId()) + .eq(Store::getMobile, req.getNewMobile()).ne(Store::getDelFlag, PublicCommon.删除)); + if (storeDb != null) { + throw new CustomException(CoreExceptionEnum.ACCOUNT_HAS_EXIST); + } + + //修改手机号 + update2 = storeService.lambdaUpdate().set(Store::getAccount, req.getNewMobile()).set(Store::getMobile, req.getNewMobile()).eq(Store::getId, userId).update(); + if (!update2) { + throw new CustomException(CoreExceptionEnum.UPDATE_MOBILE_ERROR); + } + break; + default: + throw new CustomException(CoreExceptionEnum.ERROR_PARAM); + } + + return ResponseData.success(); + + } + + + /** + * 校验支付密码 + * + * @param pwd + * @param userVo + * @return + */ + public ResponseData checkPayPwd(String pwd, UserVo userVo) { + + Boolean isTrue = businessUtil.payPwdTrue(userVo, pwd); + if (!isTrue) { + return ResponseData.error(CoreExceptionEnum.PWD_ERROR); + } + return ResponseData.success(); + } +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/utils/RSAEncrypt.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/utils/RSAEncrypt.java new file mode 100644 index 0000000..7598616 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/utils/RSAEncrypt.java @@ -0,0 +1,121 @@ +package com.ruoyi.utils; + + +import org.apache.commons.codec.binary.Base64; + +import javax.crypto.Cipher; +import java.security.*; +import java.security.interfaces.RSAPrivateKey; +import java.security.interfaces.RSAPublicKey; +import java.security.spec.PKCS8EncodedKeySpec; +import java.security.spec.X509EncodedKeySpec; +import java.util.HashMap; +import java.util.Map; + +public class RSAEncrypt { + private static Map keyMap = new HashMap(); //用于封装随机产生的公钥与私钥 + + public static String privateKey = "MIICdgIBADANBgkqhkiG9w0BAQEFAASCAmAwggJcAgEAAoGBAI3xFTAYiHECVuH9JQCxm7un8Ma/uroiZhgzkuaktUC7a4uxzgj+5b1mgduUBsDTBNXqyP/wRI1cw6S7kWRtK0bDKC9/d+txwsI+ks8RftYSJjrfDCmg33NJ+ywsoPIIJ0Nv9Su+XqJ91mUvFIZ3WvSRPMaFxIsg3WZ48/9WRPP5AgMBAAECgYBC+dsRksHu8Tel8xketq/RYHFQlu+5HLon+U373wRXwxgAFqotvHkTYecsgTCek/PYLK0jd3AhdAAtHwR/6rNcQANfhfafvGLAvNOvrzka1ABsGN+TxOOBPu1uMM+XJ4MCKOUyt6hHlsLBBa8ZIhapf5h7PMFOwLkZ0qx/aGQqcQJBAM7UzPsnez+woPYO3q7FOURL41aqZhFYmuYUAuYtO06Xl81CzmWB8I6S+PHZEwiHcFkqXcHS4Hg1OEtuPeuENmcCQQCvr0dJWsFuWYvg/8/pD0sJsfFVfT4kixDtiIwAPJ0Aza2XC86ne1COUij7b1D8MG+rhadW7hguZ0HIaG7TIUafAkEAs6ll5USGauyi5RpFlMr807aX49BgmPC+nN0FJ6xiuAI2erZtUv9sVmyUkoBdaCs+DDYg+xySn9ia7er1Hn/aQQJAcJ2w2oq8l5n7Gl2gzsqo1SwlgSFpZk9mqHzxEW3JTqyJa9t7usxHVRPBhXtTtHTwAEkKfaTeB1DVUDvxXpFkDQJADkaxyVKTS3sPWmfaSbEOT5ileFYfovUyq/fXhDch9zh09+eCv9GUNaels+Knt7GsDAb0Rb58l+gn7pNDDRmLig=="; + public static String publicKey = "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCN8RUwGIhxAlbh/SUAsZu7p/DGv7q6ImYYM5LmpLVAu2uLsc4I/uW9ZoHblAbA0wTV6sj/8ESNXMOku5FkbStGwygvf3frccLCPpLPEX7WEiY63wwpoN9zSfssLKDyCCdDb/Urvl6ifdZlLxSGd1r0kTzGhcSLIN1mePP/VkTz+QIDAQAB"; +// public static String privateKey ="MIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQCsMPR0bLBPWgcC" + +// "U7vwdY2jT7RQmJy2jfRShFDNsQwyGmIFkquQX/veuGdfsyMafmITcSo2zwLbiAJv" + +// "aY5bf0WBWpoqawWwotswCP7AwPqOSG1mon7m/H5ShTYgQG0h+6Phh5HyAV3OR4lV" + +// "XieWs5PZKI576FuEB3iugHiM9jlvvTgt+l5YG+5mtArvCh7Argci6Yyv491Zb36q" + +// "SIFg4jCsjYg267YZECbOZJpLPoxdf7oiEMTqkdRGHwwTiBh1Xtxo6K5IYCSccHes" + +// "hg1PlgwPAhlOwhcXinWRWwzXUyRFLf0Jr/i6KEAOjHcKDu2EXrgNWKGOh4UDOLmr" + +// "JrzM3P1fAgMBAAECggEAZ3zUrtRT8p0M8V0Z6x77jVdt67KNHTqbyKw1VCpARiyN" + +// "FQRdkFvfqK/zkRS82EN09nJhCKfJ897+d69dG6iWQXQOi8fel5aJXYlKctaIv9LP" + +// "zYuD8Zd25GmjaibOcEoo6HbuRCCGHF/qLiB0cqJjDXTOjbHMrsE+ysHzseSaCIkY" + +// "OnEFvdp9GBKi+0KQj6ZtxaWZqgr/HwGX3mbpRg5Cs0WYrtuxS8W34BGfDFpI5wK9" + +// "FDzYd+JFzLzgv1H9R1eJyWpV0TM0F7XwvElK6cm75rCfYkHWYlD+QqOyJzOl7yN2" + +// "lhR0kbv3bZhB8TGGQphrzF8CwTz8UEIgRArc267foQKBgQDWP5jKGdV5r0Oi4OFc" + +// "ZqkYmUcffLhKQAZN3+ktS88j3McJc56FY88qEk3rgwQJv0fiNm6u9qabu12PbKg/" + +// "bNSu0AWu4q4c+tf4JX6MnfztpbuBdHPGdJlmY0M8mH7YaTckFgFtyidJpqjyl1mG" + +// "c3pZTn+IfMrgmC1YgRIRYC1mywKBgQDNvzaNNIZJiyqpHYozMYwcZa8DksJ77BeX" + +// "RhPikd3hNBKkljFlzIc8SaL/mKuDrO9pv6HmMK8NFIbM4TITJ9ycFN6H8MbfIj7U" + +// "NrWCzjerDm+n+okDhq+lKd5hFg2WiF9SP1du2H+QaAv5EItkzaugnmJzJmF759Fg" + +// "CEoQLOOdPQKBgAGV5OaR/F9zKZf5/BD3/YZeFAWqoZ6DDMjkwFACgJzuVFbAkUrB" + +// "a1YPXp5AkPYVgU2uQ3FuB9udLlsSXchiYMyOY4xgxxMV1CVU+bPGs4l6sYGKwBSW" + +// "5k+4qlW3dzDYznyo4QfT+Ch2YEezUQlKr3wbtZvn+IRi++rswZp5ULyzAoGAMjou" + +// "2BPtgICv3m8usMa0vK36JrYqMlR1geGCszoG35Z1wqZD0uU2Unprh1g+7rtGCxvU" + +// "KzzRTzEmo1eKgPCnQ5c4qBkYg5p5mhbtAszS/Dhe+7QGxMyZjomFF1Bp6sjJ9Gsw" + +// "Lgg+RAOSgLAQR4CKGIDx6ciB3dy+2WHMqtw6iMUCgYBS102VHAkJ/1fZKW0ZLvo4" + +// "DW6eRQ75XMZHGS08Vz10O4LN7udPOHYQG6KnHMLU3baa0180og7YFnr+2rOe7LnU" + +// "p8fxADPPuPIIjo4d5+Y9+7oSIPfmoRXq/mLNeWadLO05BP7ad0YbYVd79stmCQyk" + +// "UGtgwo8eBvhgrg6k8bycCA=="; +//public static String publicKey = "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDCCViKycwG6xUhLsKfdvmHpATOQSA6cMV159B1Qwq8cnbEwJSdbvVeLm3Rr5QUXy2WrWc4baPVa3Ruvl5y7T9ej96JBG5qhlU730LHZRr3DqAt6uUTVGepDYpF6+bGhjoOm9VFBXf9XZt8ceKU9ahY+/bw48b9491IdS++q9+c5wIDAQAB"; + +// public static void main(String[] args) throws Exception { +// String phone = "18256057064"; +// String encrypt = encrypt(phone, publicKey); +// System.out.println("加密后"+encrypt); +// System.out.println("解密后"+decrypt(encrypt, privateKey)); +// } + + /** + * 随机生成密钥对 + * + * @throws NoSuchAlgorithmException + */ + public static void genKeyPair() throws NoSuchAlgorithmException { + // KeyPairGenerator类用于生成公钥和私钥对,基于RSA算法生成对象 + KeyPairGenerator keyPairGen = KeyPairGenerator.getInstance("RSA"); + // 初始化密钥对生成器,密钥大小为96-1024位 + keyPairGen.initialize(1024, new SecureRandom()); + // 生成一个密钥对,保存在keyPair中 + KeyPair keyPair = keyPairGen.generateKeyPair(); + RSAPrivateKey privateKey = (RSAPrivateKey) keyPair.getPrivate(); // 得到私钥 + RSAPublicKey publicKey = (RSAPublicKey) keyPair.getPublic(); // 得到公钥 + String publicKeyString = new String(Base64.encodeBase64(publicKey.getEncoded())); + // 得到私钥字符串 + String privateKeyString = new String(Base64.encodeBase64((privateKey.getEncoded()))); + // 将公钥和私钥保存到Map + keyMap.put(0, publicKeyString); //0表示公钥 + keyMap.put(1, privateKeyString); //1表示私钥 + + System.out.println("公钥:" + publicKeyString); + System.out.println("私钥:" + privateKeyString); + } + + /** + * RSA公钥加密 + * + * @param str 加密字符串 + * @param publicKey 公钥 + * @return 密文 + * @throws Exception 加密过程中的异常信息 + */ + public static String encrypt(String str, String publicKey) throws Exception { + //base64编码的公钥 + byte[] decoded = Base64.decodeBase64(publicKey); + RSAPublicKey pubKey = (RSAPublicKey) KeyFactory.getInstance("RSA").generatePublic(new X509EncodedKeySpec(decoded)); + //RSA加密 + Cipher cipher = Cipher.getInstance("RSA"); + cipher.init(Cipher.ENCRYPT_MODE, pubKey); + String outStr = Base64.encodeBase64String(cipher.doFinal(str.getBytes("UTF-8"))); + return outStr; + } + + /** + * RSA私钥解密 + * + * @param str 加密字符串 + * @param privateKey 私钥 + * @return 铭文 + * @throws Exception 解密过程中的异常信息 + */ + public static String decrypt(String str, String privateKey) throws Exception { + //64位解码加密后的字符串 + byte[] inputByte = Base64.decodeBase64(str.getBytes("UTF-8")); + //base64编码的私钥 + byte[] decoded = Base64.decodeBase64(privateKey); + RSAPrivateKey priKey = (RSAPrivateKey) KeyFactory.getInstance("RSA").generatePrivate(new PKCS8EncodedKeySpec(decoded)); + //RSA解密 + Cipher cipher = Cipher.getInstance("RSA"); + cipher.init(Cipher.DECRYPT_MODE, priKey); + String outStr = new String(cipher.doFinal(inputByte)); + return outStr; + } + + +} \ No newline at end of file diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/utils/SnowIdUtils.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/utils/SnowIdUtils.java new file mode 100644 index 0000000..05bf697 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/utils/SnowIdUtils.java @@ -0,0 +1,136 @@ +package com.ruoyi.utils; + +import java.util.Date; + +/** + * 雪花算法 + */ +public class SnowIdUtils { + /** + * 私有的 静态内部类 + */ + private static class SnowFlake { + + /** + * 内部类对象(单例模式) + */ + private static final SnowFlake SNOW_FLAKE = new SnowFlake(); + /** + * 起始的时间戳 + */ + private final long START_TIMESTAMP = 1557489395327L; + /** + * 序列号占用位数 + */ + private final long SEQUENCE_BIT = 12; + /** + * 机器标识占用位数 + */ + private final long MACHINE_BIT = 10; + /** + * 时间戳位移位数 + */ + private final long TIMESTAMP_LEFT = SEQUENCE_BIT + MACHINE_BIT; + /** + * 最大序列号 (4095) + */ + private final long MAX_SEQUENCE = ~(-1L << SEQUENCE_BIT); + /** + * 最大机器编号 (1023) + */ + private final long MAX_MACHINE_ID = ~(-1L << MACHINE_BIT); + /** + * 生成id机器标识部分 + */ + private long machineIdPart; + /** + * 序列号 + */ + private long sequence = 0L; + /** + * 上一次时间戳 + */ + private long lastStamp = -1L; + + /** + * 构造函数初始化机器编码 + */ + private SnowFlake() { + Date date = new Date(); + //模拟这里获得本机机器编码 + long localIp = 4321; + //localIp & MAX_MACHINE_ID最大不会超过1023,在左位移12位 + machineIdPart = (localIp & MAX_MACHINE_ID) << SEQUENCE_BIT; + } + + /** + * 获取雪花ID + */ + public synchronized long nextId() { + long currentStamp = timeGen(); + //避免机器时钟回拨 + while (currentStamp < lastStamp) { + // //服务器时钟被调整了,ID生成器停止服务. + throw new RuntimeException(String.format("时钟已经回拨. Refusing to generate id for %d milliseconds", lastStamp - currentStamp)); + } + if (currentStamp == lastStamp) { + // 每次+1 + sequence = (sequence + 1) & MAX_SEQUENCE; + // 毫秒内序列溢出 + if (sequence == 0) { + // 阻塞到下一个毫秒,获得新的时间戳 + currentStamp = getNextMill(); + } + } else { + //不同毫秒内,序列号置0 + sequence = 0L; + } + lastStamp = currentStamp; + //时间戳部分+机器标识部分+序列号部分 + return (currentStamp - START_TIMESTAMP) << TIMESTAMP_LEFT | machineIdPart | sequence; + } + + /** + * 阻塞到下一个毫秒,直到获得新的时间戳 + */ + private long getNextMill() { + long mill = timeGen(); + // + while (mill <= lastStamp) { + mill = timeGen(); + } + return mill; + } + + /** + * 返回以毫秒为单位的当前时间 + */ + protected long timeGen() { + return System.currentTimeMillis(); + } + } + + /** + * 获取long类型雪花ID + */ + public static long uniqueLong() { + return SnowFlake.SNOW_FLAKE.nextId(); + } + + /** + * 获取String类型雪花ID + */ + public static String uniqueLongHex() { + return String.format("%016x", uniqueLong()); + } + + /** + * 测试 + */ + public static void main(String[] args) { + while (true) { + String s = SnowIdUtils.uniqueLongHex(); + System.out.println(s); + } + } +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/utils/captcha/ImgVerifyCode.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/utils/captcha/ImgVerifyCode.java new file mode 100644 index 0000000..33a379f --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/utils/captcha/ImgVerifyCode.java @@ -0,0 +1,128 @@ +package com.ruoyi.utils.captcha; + +import javax.imageio.ImageIO; +import java.awt.*; +import java.awt.image.BufferedImage; +import java.io.IOException; +import java.io.OutputStream; +import java.util.Random; + +public class ImgVerifyCode { + + private int weight = 250; //验证码图片的长和宽 + private int height = 100; + private String text; //用来保存验证码的文本内容 + private Random r = new Random(); //获取随机数对象 + //private String[] fontNames = {"宋体", "华文楷体", "黑体", "微软雅黑", "楷体_GB2312"}; //字体数组 + //字体数组 + private String[] fontNames = {"Georgia"}; + //验证码数组 + private String codes = "23456789"; + + /** + * 获取随机的颜色 + * + * @return + */ + private Color randomColor() { + int r = this.r.nextInt(225); //这里为什么是225,因为当r,g,b都为255时,即为白色,为了好辨认,需要颜色深一点。 + int g = this.r.nextInt(225); + int b = this.r.nextInt(225); + return new Color(r, g, b); //返回一个随机颜色 + } + + /** + * 获取随机字体 + * + * @return + */ + private Font randomFont() { + int index = r.nextInt(fontNames.length); //获取随机的字体 + String fontName = fontNames[index]; + int style = r.nextInt(4); //随机获取字体的样式,0是无样式,1是加粗,2是斜体,3是加粗加斜体 + int size = 70; //随机获取字体的大小 + return new Font(fontName, style, size); //返回一个随机的字体 + } + + /** + * 获取随机字符 + * + * @return + */ + private char randomChar() { + int index = r.nextInt(codes.length()); + return codes.charAt(index); + } + + /** + * 画干扰线,验证码干扰线用来防止计算机解析图片 + * + * @param image + */ + private void drawLine(BufferedImage image) { + int num = r.nextInt(10); //定义干扰线的数量 + Graphics2D g = (Graphics2D) image.getGraphics(); + for (int i = 0; i < num; i++) { + int x1 = r.nextInt(weight); + int y1 = r.nextInt(height); + int x2 = r.nextInt(weight); + int y2 = r.nextInt(height); + g.setColor(randomColor()); + g.drawLine(x1, y1, x2, y2); + } + } + + /** + * 创建图片的方法 + * + * @return + */ + private BufferedImage createImage() { + //创建图片缓冲区 + BufferedImage image = new BufferedImage(weight, height, BufferedImage.TYPE_INT_RGB); + //获取画笔 + Graphics2D g = (Graphics2D) image.getGraphics(); + g.setColor(Color.white); + g.fillRect(0, 0, weight, height); + //返回一个图片 + return image; + } + + /** + * 获取验证码图片的方法 + * + * @return + */ + public BufferedImage getImage() { + BufferedImage image = createImage(); + Graphics2D g = (Graphics2D) image.getGraphics(); //获取画笔 + StringBuilder sb = new StringBuilder(); + for (int i = 0; i < 4; i++) //画四个字符即可 + { + String s = randomChar() + ""; //随机生成字符,因为只有画字符串的方法,没有画字符的方法,所以需要将字符变成字符串再画 + sb.append(s); //添加到StringBuilder里面 + float x = i * 1.0F * weight / 4; //定义字符的x坐标 + g.setFont(randomFont()); //设置字体,随机 + g.setColor(randomColor()); //设置颜色,随机 + g.drawString(s, x, height - 20); + } + this.text = sb.toString(); + drawLine(image); + return image; + } + + /** + * 获取验证码文本的方法 + * + * @return + */ + public String getText() { + return text; + } + + public static void output(BufferedImage image, OutputStream out) throws IOException //将验证码图片写出的方法 + { + ImageIO.write(image, "JPEG", out); + } + +} \ No newline at end of file diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/utils/excel/customexcel/ExcelFormatUtil.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/utils/excel/customexcel/ExcelFormatUtil.java new file mode 100644 index 0000000..859e0b2 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/utils/excel/customexcel/ExcelFormatUtil.java @@ -0,0 +1,133 @@ +//package com.ruoyi.utils.excel.customexcel; +// +// +//import org.apache.poi.hssf.usermodel.HSSFCellStyle; +//import org.apache.poi.hssf.usermodel.HSSFFont; +//import org.apache.poi.hssf.usermodel.HSSFWorkbook; +//import org.apache.poi.hssf.util.HSSFColor; +//import org.apache.poi.ss.usermodel.CellStyle; +//import org.apache.poi.ss.usermodel.Font; +//import org.apache.poi.xssf.streaming.SXSSFCell; +//import org.apache.poi.xssf.streaming.SXSSFRow; +//import org.apache.poi.xssf.streaming.SXSSFSheet; +//import org.apache.poi.xssf.streaming.SXSSFWorkbook; +// +//import java.util.List; +// +///** +// * excle样式工具类 +// */ +// +//public class ExcelFormatUtil { +// /** +// * 设置报表头样式 +// * @param workbook +// * @return +// */ +// public static CellStyle headSytle(SXSSFWorkbook workbook){ +// // 设置style1的样式,此样式运用在第二行 +// CellStyle style1 = workbook.createCellStyle();// cell样式 +// // 设置单元格背景色,设置单元格背景色以下两句必须同时设置 +// style1.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND);// 设置填充样式 +// style1.setFillForegroundColor(HSSFColor.GREY_25_PERCENT.index);// 设置填充色 +// // 设置单元格上、下、左、右的边框线 +// style1.setBorderBottom(HSSFCellStyle.BORDER_THIN); +// style1.setBorderLeft(HSSFCellStyle.BORDER_THIN); +// style1.setBorderRight(HSSFCellStyle.BORDER_THIN); +// style1.setBorderTop(HSSFCellStyle.BORDER_THIN); +// Font font1 = workbook.createFont();// 创建一个字体对象 +// font1.setBoldweight((short) 10);// 设置字体的宽度 +// font1.setFontHeightInPoints((short) 10);// 设置字体的高度 +// font1.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);// 粗体显示 +// style1.setFont(font1);// 设置style1的字体 +// style1.setWrapText(true);// 设置自动换行 +// style1.setAlignment(HSSFCellStyle.ALIGN_CENTER);// 设置单元格字体显示居中(左右方向) +// style1.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER);// 设置单元格字体显示居中(上下方向) +// return style1; +// } +// /** +// * 设置报表体样式 +// * @param wb +// * @return +// */ +// public static CellStyle contentStyle(SXSSFWorkbook wb){ +// // 设置style1的样式,此样式运用在第二行 +// CellStyle style1 = wb.createCellStyle();// cell样式 +// // 设置单元格上、下、左、右的边框线 +// style1.setBorderBottom(HSSFCellStyle.BORDER_THIN); +// style1.setBorderLeft(HSSFCellStyle.BORDER_THIN); +// style1.setBorderRight(HSSFCellStyle.BORDER_THIN); +// style1.setBorderTop(HSSFCellStyle.BORDER_THIN); +// style1.setWrapText(true);// 设置自动换行 +// style1.setAlignment(HSSFCellStyle.ALIGN_LEFT);// 设置单元格字体显示居中(左右方向) +// style1.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER);// 设置单元格字体显示居中(上下方向) +// return style1; +// } +// /** +// * 设置报表标题样式 +// * @param workbook +// * @return +// */ +// public static HSSFCellStyle titleSytle(HSSFWorkbook workbook, short color, short fontSize){ +// // 设置style1的样式,此样式运用在第二行 +// HSSFCellStyle style1 = workbook.createCellStyle();// cell样式 +// // 设置单元格背景色,设置单元格背景色以下两句必须同时设置 +// //style1.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND);// 设置填充样式 +// //short fcolor = color; +// if(color != HSSFColor.WHITE.index){ +// style1.setFillForegroundColor(color);// 设置填充色 +// } +// // 设置单元格上、下、左、右的边框线 +// style1.setBorderBottom(HSSFCellStyle.BORDER_THIN); +// style1.setBorderLeft(HSSFCellStyle.BORDER_THIN); +// style1.setBorderRight(HSSFCellStyle.BORDER_THIN); +// style1.setBorderTop(HSSFCellStyle.BORDER_THIN); +// HSSFFont font1 = workbook.createFont();// 创建一个字体对象 +// font1.setBoldweight(fontSize);// 设置字体的宽度 +// font1.setFontHeightInPoints(fontSize);// 设置字体的高度 +// font1.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);// 粗体显示 +// style1.setFont(font1);// 设置style1的字体 +// style1.setWrapText(true);// 设置自动换行 +// style1.setAlignment(HSSFCellStyle.ALIGN_CENTER);// 设置单元格字体显示居中(左右方向) +// style1.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER);// 设置单元格字体显示居中(上下方向) +// return style1; +// } +// /** +// *设置表头 +// * @param sheet +// */ +// public static void initTitleEX(SXSSFSheet sheet, CellStyle header, List title, List titleLength) { +// SXSSFRow row0 = sheet.createRow(0); +// row0.setHeight((short) 800); +// for(int j = 0;j excelParams = new ArrayList<>(); +// +// excelParams.add(new ExcelParam("id", "id", 5000)); +// +// excelParams.add(new ExcelParam("订单号", "orderNo", 5000)); +// +// excelParams.add(new ExcelParam("支付时间", "payTime", 5000)); +// +//// List list = new ArrayList(); +//// exportExcel(list,excelParams); +// } +// +// +// /** +// * 导出 +// * +// * @param list +// * @param excelParams +// * @return +// */ +// public ResponseEntity exportExcel(List list, List excelParams) { +// +// try { +// log.info(">>>>>>>>>>开始导出excel>>>>>>>>>>"); +// //求出导出数据 +// BaseFrontController baseFrontController = new BaseFrontController(); +// return baseFrontController.buildResponseEntity(export(list, excelParams), "导出数据.xls"); +// } catch (Exception e) { +// e.printStackTrace(); +// log.error(">>>>>>>>>>导出excel 异常,原因为:" + e.getMessage()); +// } +// +// return null; +// } +// +// +// +// private InputStream export(List list,List excelParams) { +// +// log.info(">>>>>>>>>>>>>>>>>>>>开始进入导出方法>>>>>>>>>>"); +// ByteArrayOutputStream output = null; +// InputStream inputStream1 = null; +// SXSSFWorkbook wb = new SXSSFWorkbook(1000);// 保留1000条数据在内存中 +// SXSSFSheet sheet = wb.createSheet(); +// // 设置报表头样式 +// CellStyle header = ExcelFormatUtil.headSytle(wb);// cell样式 +// CellStyle content = ExcelFormatUtil.contentStyle(wb);// 报表体样式 +// +// +// //标头 +// List keys= new ArrayList(); +// +// // 每一列字段名 +// List values = new ArrayList(); +// +// // 列宽 +// List ints = new ArrayList(); +// +// excelParams.stream().forEach(s->{ +// keys.add(s.getName()); +// values.add(s.getField()); +// ints.add(s.getWidth()); +// }); +// +// // 设置表头样式 +// ExcelFormatUtil.initTitleEX(sheet, header, keys, ints); +// log.info(">>>>>>>>>>>>>>>>>>>>表头样式设置完成>>>>>>>>>>"); +// int x = 0; +// if (list != null && list.size() > 0) { +// log.info(">>>>>>>>>>>>>>>>>>>>开始遍历数据组装单元格内容>>>>>>>>>>"); +// for (int i = 0; i < list.size(); i++) { +// +// Object t = list.get(i); +// +// SXSSFRow row = sheet.createRow(i + 1); +// x++; +// +// //根据对象反射 +// Class clazz= t.getClass(); +// +// //根据反射机制获取对象的所有字段,包含public、private和proteced +// Field[] declaredFields=clazz.getDeclaredFields(); +// +// //循环判断对象中的字段 +// Map map = new HashMap<>(); +// for (int n = 0; n < declaredFields.length; n++) { +// Field field = declaredFields[n]; +// //设置属性可访问 +// declaredFields[n].setAccessible(true); +// map.put(field.getName(), field); +// } +// int j = 0; +// for (int n = 0; n < values.size(); n++) { +// try { +// if(values.size()<=j){ +// break; +// } +// Object value =null; +// //获取字段名称 +// String s = values.get(n); +// Field field = map.get(s); +// if (field!=null){ +// //设置属性可访问 +// field.setAccessible(true); +// value = field.get(t); +// +// } +// SXSSFCell cell = row.createCell(n); +// +// //excel赋值 根据不同类型判断 +// if (field!=null && field.getType().equals(Date.class)) { +// String format = DateUtil.format((Date) value, "yyyy-MM-dd HH:mm:ss"); +// cell.setCellValue(format); +// } else { +// if (value != null) { +// cell.setCellValue(value.toString()); +// }else { +// cell.setCellValue(""); +// } +// +// } +// +// //报表体样式 +// cell.setCellStyle(content); +// +// } catch (IllegalAccessException e) { +// e.printStackTrace(); +// } +// } +// } +// log.info(">>>>>>>>>>>>>>>>>>>>结束遍历数据组装单元格内容>>>>>>>>>>"); +// } +// +// try { +// output = new ByteArrayOutputStream(); +// wb.write(output); +// inputStream1 = new ByteArrayInputStream(output.toByteArray()); +// output.flush(); +// } catch (Exception e) { +// e.printStackTrace(); +// } finally { +// try { +// if (output != null) { +// output.close(); +// if (inputStream1 != null) { +// inputStream1.close(); +// } +// } +// } catch (IOException e) { +// e.printStackTrace(); +// } +// } +// return inputStream1; +// } +// +//} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/utils/excel/customexcel/controller/BaseFrontController.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/utils/excel/customexcel/controller/BaseFrontController.java new file mode 100644 index 0000000..75bb0b8 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/utils/excel/customexcel/controller/BaseFrontController.java @@ -0,0 +1,64 @@ +package com.ruoyi.utils.excel.customexcel.controller; + +import org.apache.poi.util.IOUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.http.HttpHeaders; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.util.StringUtils; +import org.springframework.validation.annotation.Validated; + +import java.io.InputStream; +import java.net.URLEncoder; +import java.util.HashMap; +import java.util.Map; + +@Validated +public class BaseFrontController { + + /** + * slf4j 日志 logger + */ + protected final Logger logger = LoggerFactory.getLogger(this.getClass()); + + /** + * 下载文件,纯SpringMVC的API来完成 + * + * @param is 文件输入流 + * @param name 文件名称,带后缀名 + * + * @throws Exception + */ + public ResponseEntity buildResponseEntity(InputStream is, String name) throws Exception { + logger.info(">>>>>>>>>>>>>>>>>>>>开始下载文件>>>>>>>>>>"); + if (this.logger.isDebugEnabled()) { + this.logger.debug("download: " + name); + } + HttpHeaders header = new HttpHeaders(); + String fileSuffix = name.substring(name.lastIndexOf('.') + 1); + fileSuffix = fileSuffix.toLowerCase(); + + Map arguments = new HashMap(); + arguments.put("xlsx", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); + arguments.put("xls", "application/vnd.ms-excel"); + + String contentType = arguments.get(fileSuffix); + header.add("Content-Type", (StringUtils.hasText(contentType) ? contentType : "application/x-download")); + if(is!=null && is.available()!=0){ + header.add("Content-Length", String.valueOf(is.available())); + header.add("Content-Disposition", "attachment;filename*=utf-8'zh_cn'" + URLEncoder.encode(name, "UTF-8")); + byte[] bs = IOUtils.toByteArray(is); + logger.info(">>>>>>>>>>>>>>>>>>>>结束下载文件-有记录>>>>>>>>>>"); + logger.info(">>>>>>>>>>结束导出excel>>>>>>>>>>"); + return new ResponseEntity<>(bs, header, HttpStatus.OK); + }else{ + String string="数据为空"; + header.add("Content-Length", "0"); + header.add("Content-Disposition", "attachment;filename*=utf-8'zh_cn'" + URLEncoder.encode(name, "UTF-8")); + logger.info(">>>>>>>>>>>>>>>>>>>>结束下载文件-无记录>>>>>>>>>>"); + logger.info(">>>>>>>>>>结束导出excel>>>>>>>>>>"); + return new ResponseEntity<>(string.getBytes(), header, HttpStatus.OK); + } + } +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/utils/excel/easyexcel/ExcelUtil.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/utils/excel/easyexcel/ExcelUtil.java new file mode 100644 index 0000000..15c30f3 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/utils/excel/easyexcel/ExcelUtil.java @@ -0,0 +1,331 @@ +//package com.ruoyi.utils.excel.easyexcel; +// +//import cn.stylefeng.guns.modular.business.custom.util.excel.easyexcel.annotations.ExplicitConstraint; +//import cn.stylefeng.guns.modular.business.custom.util.excel.easyexcel.handler.CommentWriteHandler; +//import cn.stylefeng.guns.modular.business.custom.util.excel.easyexcel.handler.CustomSheetWriteHandler; +//import cn.stylefeng.guns.modular.business.custom.util.excel.easyexcel.handler.TemplateCellWriteHandler; +//import cn.stylefeng.guns.modular.business.custom.util.excel.easyexcel.listener.ExcelListener; +//import cn.stylefeng.guns.modular.business.custom.util.excel.easyexcel.service.ExplicitInterface; +//import com.alibaba.excel.EasyExcel; +//import com.alibaba.excel.ExcelWriter; +//import com.alibaba.excel.write.metadata.WriteSheet; +//import com.alibaba.excel.write.metadata.WriteTable; +//import com.alibaba.excel.write.metadata.style.WriteCellStyle; +//import com.alibaba.excel.write.metadata.style.WriteFont; +//import com.alibaba.excel.write.style.HorizontalCellStyleStrategy; +//import com.alipay.service.schema.util.StringUtil; +//import lombok.extern.slf4j.Slf4j; +//import org.apache.commons.lang3.StringUtils; +//import org.apache.poi.EncryptedDocumentException; +//import org.apache.poi.POIXMLDocumentPart; +//import org.apache.poi.hssf.usermodel.*; +//import org.apache.poi.ss.usermodel.HorizontalAlignment; +//import org.apache.poi.ss.usermodel.IndexedColors; +//import org.apache.poi.ss.usermodel.PictureData; +//import org.apache.poi.ss.usermodel.Workbook; +//import org.apache.poi.xssf.usermodel.*; +//import org.openxmlformats.schemas.drawingml.x2006.spreadsheetDrawing.CTMarker; +//import org.springframework.web.multipart.MultipartFile; +// +//import javax.servlet.http.HttpServletResponse; +//import java.io.*; +//import java.lang.reflect.Field; +//import java.net.URLEncoder; +//import java.util.HashMap; +//import java.util.List; +//import java.util.Map; +// +//@Slf4j +//public class ExcelUtil { +// /** +// * 导出数据为excel文件 +// * +// * @param filename 文件名称 +// * @param dataResult 集合内的bean对象类型要与clazz参数一致 +// * @param clazz 集合内的bean对象类型要与clazz参数一致 +// * @param response HttpServlet响应对象 +// */ +// public static void export(String filename, List dataResult, Class clazz, HttpServletResponse response) { +// response.setStatus(200); +// OutputStream outputStream = null; +// ExcelWriter excelWriter = null; +// try { +// if (StringUtils.isBlank(filename)) { +// throw new RuntimeException("'filename' 不能为空"); +// } +// String fileName = filename.concat(".xlsx"); +// response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(fileName, "utf-8")); +// outputStream = response.getOutputStream(); +// +// // 根据不同的策略生成不同的ExcelWriter对象 +// if (dataResult == null){ +// excelWriter = getTemplateExcelWriter(outputStream,clazz); +// } else { +// excelWriter = getExportExcelWriter(outputStream); +// } +// +// WriteTable writeTable = EasyExcel.writerTable(0).head(clazz).needHead(true).build(); +// WriteSheet writeSheet = EasyExcel.writerSheet(fileName).build(); +// // 写出数据 +// excelWriter.write(dataResult, writeSheet, writeTable); +// +// } catch (Exception e) { +// log.error("导出excel数据异常:", e); +// throw new RuntimeException(e); +// } finally { +// if (excelWriter != null) { +// excelWriter.finish(); +// } +// if (outputStream != null) { +// try { +// outputStream.flush(); +// outputStream.close(); +// } catch (IOException e) { +// log.error("导出数据关闭流异常", e); +// } +// } +// } +// } +// +// /** +// * 根据不同策略生成不同的ExcelWriter对象, 可根据实际情况修改 +// * @param outputStream 数据输出流 +// * @return 模板下载ExcelWriter对象 +// */ +// private static ExcelWriter getTemplateExcelWriter(OutputStream outputStream,Class model){ +// +//// //用来存储对应的列与值对象 +//// Map selectedMap = new HashMap<>(); +//// selectedMap.put(1,new String[]{"1","2","3"}); +// +// //下拉列表集合 +// Map selectedMap = resolveSelectedAnnotation(model); +// +// return EasyExcel.write(outputStream) +// .registerWriteHandler(new CommentWriteHandler()) //增加批注策略 +// .registerWriteHandler(new TemplateCellWriteHandler()) //样式 +// .registerWriteHandler(new CustomSheetWriteHandler(5000,selectedMap)) //增加下拉框策略 +// .build(); +// } +// +// /** +// * 根据不同策略生成不同的ExcelWriter对象, 可根据实际情况修改 +// * @param outputStream 数据输出流 +// * @return 数据导出ExcelWriter对象 +// */ +// private static ExcelWriter getExportExcelWriter(OutputStream outputStream){ +// return EasyExcel.write(outputStream) +// .registerWriteHandler(new TemplateCellWriteHandler()) //字体居中策略 +// .build(); +// } +// /** +// * 解析表头类中的下拉注解 +// * @param head 表头类 +// * @param 泛型 +// * @return Map<下拉框列索引, 下拉框内容> map +// */ +// private static Map resolveSelectedAnnotation(Class head) { +// Map selectedMap = new HashMap<>(); +// +// // getDeclaredFields(): 返回全部声明的属性;getFields(): 返回public类型的属性 +// Field[] fields = head.getDeclaredFields(); +// for (int i = 0; i < fields.length; i++) { +// Field field = fields[i]; +// //解析注解信息 +// ExplicitConstraint explicitConstraint = field.getAnnotation(ExplicitConstraint.class); +// resolveExplicitConstraint(selectedMap,explicitConstraint); +// +// } +// +// return selectedMap; +// } +// +// /** +// * 解析注解内容 获取下列表信息 +// * @param explicitConstraint +// * @return +// */ +// public static Map resolveExplicitConstraint( Map explicitListConstraintMap,ExplicitConstraint explicitConstraint){ +// if (explicitConstraint == null) { +// return null; +// } +// //固定下拉信息 +// String[] source = explicitConstraint.source(); +// if (source.length > 0) { +// explicitListConstraintMap.put(explicitConstraint.indexNum(), source); +// } +// //动态下拉信息 +// Class[] classes = explicitConstraint.sourceClass(); +// if (classes.length>0){ +// ExplicitInterface explicitInterface = null; +// try { +// +// explicitInterface = classes[0].newInstance(); +// String[] source1 = explicitInterface.source(explicitConstraint.type()); +// if (source1.length>0){ +// explicitListConstraintMap.put(explicitConstraint.indexNum(), source1); +// } +// } catch (InstantiationException e) { +// e.printStackTrace(); +// } catch (IllegalAccessException e) { +// e.printStackTrace(); +// } +// } +// return null; +// } +// +// +// /** +// * 设置表格内容居中显示策略 +// * @return +// */ +// private static HorizontalCellStyleStrategy getStyleStrategy(){ +// WriteCellStyle headWriteCellStyle = new WriteCellStyle(); +// //设置背景颜色 +// headWriteCellStyle.setFillForegroundColor(IndexedColors.RED.getIndex()); +// //设置头字体 +// WriteFont headWriteFont = new WriteFont(); +// headWriteFont.setFontHeightInPoints((short)50); +// headWriteFont.setBold(true); +// headWriteCellStyle.setWriteFont(headWriteFont); +// //设置头居中 +// headWriteCellStyle.setHorizontalAlignment(HorizontalAlignment.CENTER); +// +// // 内容策略 +// WriteCellStyle writeCellStyle = new WriteCellStyle(); +// // 设置内容水平居中 +// writeCellStyle.setHorizontalAlignment(HorizontalAlignment.CENTER); +// return new HorizontalCellStyleStrategy(headWriteCellStyle, writeCellStyle); +// } +// +// /** +// * 根据Excel模板,批量导入数据 +// * @param file 导入的Excel +// * @param clazz 解析的类型 +// * @return 解析完成的数据 +// */ +// public static List importExcel(MultipartFile file, Class clazz){ +// if (file == null || file.isEmpty()){ +// throw new RuntimeException("没有文件或者文件内容为空!"); +// } +// List dataList = null; +// BufferedInputStream ipt = null; +// try { +// InputStream is = file.getInputStream(); +// // 用缓冲流对数据流进行包装 +// ipt = new BufferedInputStream(is); +// // 数据解析监听器 +// ExcelListener listener = new ExcelListener<>(); +// // 读取数据 +// EasyExcel.read(ipt, clazz,listener).sheet().doRead(); +// // 获取去读完成之后的数据 +// dataList = listener.getDataList(); +// } catch (Exception e){ +// log.error(String.valueOf(e)); +// throw new RuntimeException("数据导入失败!" + e); +// } +// return dataList; +// } +// +// +// +// /** +// * 获取excel表中的图片 +// * +// * @return +// * @throws IOException +// * @throws EncryptedDocumentException +// * @Param fis 文件输入流 +// * @Param sheetNum Excel表中的sheet编号 +// */ +// public static Map getPictureFromExcel(File file, int sheetNum) throws EncryptedDocumentException, IOException { +// +// //获取图片PictureData集合 +// String fileName = file.getName(); +// Workbook workbook = null; +// if (StringUtil.isEmpty(fileName)) { +// return null; +// } +// FileInputStream fileInputStream = new FileInputStream(file); +// if (fileName.endsWith("xls")) { +// //2003 +// workbook = new HSSFWorkbook(fileInputStream); +// HSSFSheet sheet = (HSSFSheet) workbook.getSheetAt(sheetNum - 1); +// Map pictures = getPictures(sheet); +// return pictures; +// } else if (fileName.endsWith("xlsx")) { +// //2007 +// workbook = new XSSFWorkbook(fileInputStream); +// XSSFSheet sheet = (XSSFSheet) workbook.getSheetAt(sheetNum - 1); +// Map pictures = getPictures(sheet); +// return pictures; +// } +// return new HashMap(); +// } +// +// +// /** +// * 获取图片和位置 (xls版) +// * @param sheet +// * @return +// * @throws IOException +// */ +// public static Map getPictures (HSSFSheet sheet) throws IOException { +// Map map = new HashMap(); +// List list = sheet.getDrawingPatriarch().getChildren(); +// for (HSSFShape shape : list) { +// if (shape instanceof HSSFPicture) { +// HSSFPicture picture = (HSSFPicture) shape; +// HSSFClientAnchor cAnchor = picture.getClientAnchor(); +// PictureData pdata = picture.getPictureData(); +// String key = cAnchor.getRow1() + "-" + cAnchor.getCol1(); // 行号-列号 +// map.put(key, pdata); +// } +// } +// return map; +// } +// +// /** +// * 获取图片和位置 (xlsx版) +// * @param sheet +// * @return +// * @throws IOException +// */ +// public static Map getPictures (XSSFSheet sheet) throws IOException { +// Map map = new HashMap(); +// List list = sheet.getRelations(); +// for (POIXMLDocumentPart part : list) { +// if (part instanceof XSSFDrawing) { +// XSSFDrawing drawing = (XSSFDrawing) part; +// List shapes = drawing.getShapes(); +// for (XSSFShape shape : shapes) { +// XSSFPicture picture = (XSSFPicture) shape; +// XSSFClientAnchor anchor = picture.getPreferredSize(); +// CTMarker marker = anchor.getFrom(); +// String key = marker.getRow() + "-" + marker.getCol(); +// map.put(key, picture.getPictureData()); +// } +// } +// } +// return map; +// } +// +// public static void main(String [] args) throws IOException { +// File file = new File("C:\\Users\\a\\Downloads\\数据导出1687160619220.xlsx"); +// //获取图片数据 +// Map map = getPictureFromExcel(file, 1); +// +// //根据图片行列位置获取图片 +// PictureData picData = (PictureData)map.get(10000+"-"+"8"); +// if (picData != null) { +// //后缀名 +// String extension = picData.suggestFileExtension(); +// byte[] data = picData.getData(); +// FileOutputStream out = new FileOutputStream("C:\\Users\\a\\Pictures\\a\\" + "picture." + extension); +// out.write(data); +// out.close(); +// } +// } +// +// +//} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/utils/excel/easyexcel/annotations/ExcelRemark.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/utils/excel/easyexcel/annotations/ExcelRemark.java new file mode 100644 index 0000000..0eb9a0f --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/utils/excel/easyexcel/annotations/ExcelRemark.java @@ -0,0 +1,55 @@ +package com.ruoyi.utils.excel.easyexcel.annotations; + +import java.lang.annotation.*; + +/** + * 设置表头的批注 + * + * @author li + * @date 2022/09/24 + */ +@Target(ElementType.FIELD) +@Retention(RetentionPolicy.RUNTIME) +@Documented +public @interface ExcelRemark { + /** + * 一般使用此属性的值进行批注的填充 + * + * @return {@link String[]} + */ + String value() default ""; + + /** + * 慎用此属性,建议使用value + * 此处值应为一个SpEL,返回值需要是一个String + * 此表达式若有值(无论是否调用是否成功),则会忽略value属性 + * 使用示例:#root.getBean('userService')?.getSelectedList('2') + * 此处的使用示例中的 #root指的是applicationContext + * + * @return {@link String} + */ + String dynamicAccess() default ""; + + /** + * 批注所在行,一般不用设置,代码自动判断 + * -1表示自动获取头的最后一个行 + * + * @return int + */ + int remarkRow() default -1; + + /** + * 批注行高, 一般不用设置 + * + * @return + */ + int remarkRowHigh() default 0; + + /** + * 批注列宽, 根据导出情况调整 + * + * @return + */ + int remarkColumnWide() default 0; + +} \ No newline at end of file diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/utils/excel/easyexcel/annotations/ExplicitConstraint.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/utils/excel/easyexcel/annotations/ExplicitConstraint.java new file mode 100644 index 0000000..68c982a --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/utils/excel/easyexcel/annotations/ExplicitConstraint.java @@ -0,0 +1,18 @@ +package com.ruoyi.utils.excel.easyexcel.annotations; + +import java.lang.annotation.*; + +@Documented +@Retention(RetentionPolicy.RUNTIME) +@Target({ElementType.FIELD}) +public @interface ExplicitConstraint { + //定义固定下拉内容 + String[]source()default {}; + //定义动态下拉内容, + Class[]sourceClass()default {}; + //列标号必须和字段下标一致 + int indexNum() default 0; + //字典type + String type() default ""; + +} \ No newline at end of file diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/utils/excel/easyexcel/controller/ExcelController.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/utils/excel/easyexcel/controller/ExcelController.java new file mode 100644 index 0000000..32b17f8 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/utils/excel/easyexcel/controller/ExcelController.java @@ -0,0 +1,91 @@ +//package com.ruoyi.utils.excel.easyexcel.controller; +// +//import cn.stylefeng.guns.core.pojo.response.ResponseData; +//import cn.stylefeng.guns.modular.business.custom.util.excel.easyexcel.ExcelUtil; +//import cn.stylefeng.guns.modular.business.custom.util.excel.easyexcel.vo.ExportExcelVo; +//import lombok.extern.slf4j.Slf4j; +//import org.springframework.web.bind.annotation.RequestMapping; +//import org.springframework.web.bind.annotation.RequestMethod; +//import org.springframework.web.bind.annotation.RestController; +//import org.springframework.web.multipart.MultipartFile; +// +//import javax.servlet.http.HttpServletResponse; +//import java.net.MalformedURLException; +//import java.util.ArrayList; +//import java.util.List; +// +///** +// * 事件控制器 +// */ +//@Slf4j +//@RestController +//@RequestMapping("") +//public class ExcelController { +// +// /** +// * excel模板下载 +// */ +// @RequestMapping(value = "/api/excel/template", method = RequestMethod.GET) +// public ResponseData template(HttpServletResponse response){ +// String fileName = "导入模板下载" + System.currentTimeMillis(); +// try { +// ExcelUtil.export(fileName, null, ExportExcelVo.class, response); +// } catch (Exception e) { +// return ResponseData.error("模板下载失败" + e.getMessage()); +// } +// return ResponseData.success("模板下载成功!"); +// } +// +// /** +// * Excel批量导入数据 +// * @param file 导入文件 +// */ +// @RequestMapping(value = "/api/excel/import", method = RequestMethod.POST) +// public ResponseData importEvents(MultipartFile file){ +// try { +// List list = ExcelUtil.importExcel(file, ExportExcelVo.class); +// System.out.println(list); +// return ResponseData.success("数据导入完成"); +// } catch (Exception e) { +// return ResponseData.error("数据导入失败!" + e.getMessage()); +// } +// } +// +// +// /** +// * excel数据导出 +// * @param size 导出条数, 也可以是用户需要导出数据的条件 +// * @return +// */ +// @RequestMapping(value = "/api/excel/export", method = RequestMethod.GET) +// public ResponseData export(Long size, HttpServletResponse response) throws MalformedURLException { +// // 模拟根据条件在数据库查询数据 +// ArrayList excelVos = new ArrayList<>(); +// for (int i = 1; i <= size; i++) { +// ExportExcelVo excelVo = new ExportExcelVo(); +//// excelVo.setContact(String.valueOf(10000000000L + i)); +//// excelVo.setName("公司名称" + i); +//// excelVo.setCreditCode("社会性用代码" + i); +//// excelVo.setProvince("地区" + i); +//// excelVo.setLegalPerson("法人" + i); +//// excelVo.setFormerName("曾用名" + i); +//// excelVo.setStockholder("投资人" + i); +//// excelVo.setSex(i%3); +//// excelVo.setSex2(i%3); +//// excelVo.setCreateTime(new SimpleDateFormat("yyyy年MM月dd日 HH时mm分ss秒").format(new Date())); +//// excelVo.setInspectionReportUrl(new URL("https://cos-1311593864.cos.ap-nanjing.myqcloud.com/wxFile/YsdSF2fSB41674971124698.JPG")); +// excelVos.add(excelVo); +// } +// +// String fileName = "数据导出" + System.currentTimeMillis(); +// +// try { +// ExcelUtil.export(fileName, excelVos, ExportExcelVo.class, response); +// } catch (Exception e) { +// return ResponseData.error("数据导出成功" + e.getMessage()); +// } +// return ResponseData.success("数据导出失败!"); +// } +// +// +//} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/utils/excel/easyexcel/converter/DataIntConverter.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/utils/excel/easyexcel/converter/DataIntConverter.java new file mode 100644 index 0000000..ffc67c1 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/utils/excel/easyexcel/converter/DataIntConverter.java @@ -0,0 +1,67 @@ +//package com.ruoyi.utils.excel.easyexcel.converter; +// +//import com.alibaba.excel.converters.Converter; +//import com.alibaba.excel.enums.CellDataTypeEnum; +//import com.alibaba.excel.metadata.CellData; +//import com.alibaba.excel.metadata.GlobalConfiguration; +//import com.alibaba.excel.metadata.property.ExcelContentProperty; +// +///** +// * @author a +// * @date 2023/7/5 18:17 +// */ +// +//public class DataIntConverter implements Converter { +// +// private static final String MALE = "男"; +// private static final String FEMALE = "女"; +// +// @Override +// public Class supportJavaTypeKey() { +// return Integer.class; +// } +// +// @Override +// public CellDataTypeEnum supportExcelTypeKey() { +// return CellDataTypeEnum.STRING; +// } +// +// @Override +// public Integer convertToJavaData(CellData cellData, ExcelContentProperty excelContentProperty, GlobalConfiguration globalConfiguration) +// throws Exception { +// String cellValue = cellData.getStringValue(); +// if (MALE.equals(cellValue)) { +// return 1; +// } else if (FEMALE.equals(cellValue)) { +// return 2; +// } else { +// // 无法解析的值,直接返回原始数据 +// return Integer.parseInt(cellValue); +// } +// } +// +// @Override +// public CellData convertToExcelData(Integer value, ExcelContentProperty excelContentProperty, GlobalConfiguration globalConfiguration) +// throws Exception { +// +// excelContentProperty.getField().getName().equals("sex"); +// switch (excelContentProperty.getField().getName()){ +// case "sex": +// if (value == 1) { +// return new CellData<>(MALE); +// } else if (value == 2) { +// return new CellData<>(FEMALE); +// } +// break; +// case "sex2": +// if (value == 2) { +// return new CellData<>(MALE); +// } else if (value == 1) { +// return new CellData<>(FEMALE); +// } +// break; +// } +// // 无法解析的值,直接返回原始数据 +// return new CellData<>(String.valueOf(value)); +// } +//} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/utils/excel/easyexcel/converter/DataStrConverter.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/utils/excel/easyexcel/converter/DataStrConverter.java new file mode 100644 index 0000000..3ffb92a --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/utils/excel/easyexcel/converter/DataStrConverter.java @@ -0,0 +1,64 @@ +//package com.ruoyi.utils.excel.easyexcel.converter; +// +//import cn.hutool.core.util.ObjectUtil; +//import cn.stylefeng.guns.sys.core.enums.SexEnum; +//import com.alibaba.excel.converters.Converter; +//import com.alibaba.excel.enums.CellDataTypeEnum; +//import com.alibaba.excel.metadata.CellData; +//import com.alibaba.excel.metadata.GlobalConfiguration; +//import com.alibaba.excel.metadata.property.ExcelContentProperty; +// +///** +// * @author a +// * @date 2023/7/5 18:17 +// */ +// +//public class DataStrConverter implements Converter { +// +// private static final String MALE = "男"; +// private static final String FEMALE = "女"; +// +// @Override +// public Class supportJavaTypeKey() { +// return String.class; +// } +// +// @Override +// public CellDataTypeEnum supportExcelTypeKey() { +// return CellDataTypeEnum.STRING; +// } +// +// @Override +// public Integer convertToJavaData(CellData cellData, ExcelContentProperty excelContentProperty, GlobalConfiguration globalConfiguration) +// throws Exception { +// String cellValue = cellData.getStringValue(); +// if (MALE.equals(cellValue)) { +// return SexEnum.MAN.getCode(); +// } else if (FEMALE.equals(cellValue)) { +// return SexEnum.WOMAN.getCode(); +// } else { +// // 无法解析的值,直接返回原始数据 +// return Integer.valueOf(cellValue); +// } +// } +// +// @Override +// public CellData convertToExcelData(Integer value, ExcelContentProperty excelContentProperty, GlobalConfiguration globalConfiguration) +// throws Exception { +// +// excelContentProperty.getField().getName().equals("sex"); +// switch (excelContentProperty.getField().getName()){ +// case "sex": +// if (ObjectUtil.equal(SexEnum.MAN.getCode(),value)) { +// return new CellData<>(MALE); +// } else if (ObjectUtil.equal(SexEnum.WOMAN.getCode(),value)) { +// return new CellData<>(FEMALE); +// } +// break; +// case "sex2": +// break; +// } +// // 无法解析的值,直接返回原始数据 +// return new CellData<>(value); +// } +//} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/utils/excel/easyexcel/handler/CommentWriteHandler.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/utils/excel/easyexcel/handler/CommentWriteHandler.java new file mode 100644 index 0000000..17d79b1 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/utils/excel/easyexcel/handler/CommentWriteHandler.java @@ -0,0 +1,52 @@ +//package com.ruoyi.utils.excel.easyexcel.handler; +// +//import com.alibaba.excel.write.handler.RowWriteHandler; +//import com.alibaba.excel.write.metadata.holder.WriteSheetHolder; +//import com.alibaba.excel.write.metadata.holder.WriteTableHolder; +//import lombok.extern.slf4j.Slf4j; +//import org.apache.poi.ss.usermodel.Row; +// +///** +// * 自定义拦截器.新增注释,第一行头加批注 +// * 这个类的作用主要是给表头添加批注 +// */ +//@Slf4j +//public class CommentWriteHandler implements RowWriteHandler { +// @Override +// public void beforeRowCreate(WriteSheetHolder writeSheetHolder, WriteTableHolder writeTableHolder, Integer rowIndex, Integer relativeRowIndex, Boolean isHead) { +// +// } +// +// @Override +// public void afterRowCreate(WriteSheetHolder writeSheetHolder, WriteTableHolder writeTableHolder, Row row, Integer relativeRowIndex, Boolean isHead) { +// +// } +// +// @Override +// public void afterRowDispose(WriteSheetHolder writeSheetHolder, WriteTableHolder writeTableHolder, Row row, Integer relativeRowIndex, Boolean isHead) { +//// Sheet sheet = writeSheetHolder.getSheet(); +//// Drawing drawingPatriarch = sheet.createDrawingPatriarch(); +//// +//// // 在第一行 第二列创建一个批注 +//// Comment comment1 = +//// drawingPatriarch.createCellComment(new XSSFClientAnchor(0, 0, 0, 0, (short)0, 0, (short)1, 1)); +//// // 输入批注信息 +//// comment1.setString(new XSSFRichTextString("批注1")); +//// // 将批注添加到单元格对象中 +//// sheet.getRow(0).getCell(0).setCellComment(comment1); +//// +//// Comment comment2 = +//// drawingPatriarch.createCellComment(new XSSFClientAnchor(0, 0, 0, 0, (short)1, 0, (short)2, 1)); +//// // 输入批注信息 +//// comment2.setString(new XSSFRichTextString("批注2")); +//// // 将批注添加到单元格对象中 +//// sheet.getRow(0).getCell(1).setCellComment(comment2); +//// +//// Comment comment3 = +//// drawingPatriarch.createCellComment(new XSSFClientAnchor(0, 0, 0, 0, (short)2, 0, (short)3, 1)); +//// // 输入批注信息 +//// comment3.setString(new XSSFRichTextString("批注3")); +//// // 将批注添加到单元格对象中 +//// sheet.getRow(0).getCell(2).setCellComment(comment3); +// } +//} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/utils/excel/easyexcel/handler/CustomSheetWriteHandler.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/utils/excel/easyexcel/handler/CustomSheetWriteHandler.java new file mode 100644 index 0000000..1363585 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/utils/excel/easyexcel/handler/CustomSheetWriteHandler.java @@ -0,0 +1,107 @@ +//package com.ruoyi.utils.excel.easyexcel.handler; +// +//import com.alibaba.excel.write.handler.SheetWriteHandler; +//import com.alibaba.excel.write.metadata.holder.WriteSheetHolder; +//import com.alibaba.excel.write.metadata.holder.WriteWorkbookHolder; +//import lombok.Data; +//import org.apache.poi.ss.usermodel.*; +//import org.apache.poi.ss.util.CellRangeAddressList; +// +//import java.util.HashMap; +//import java.util.Map; +// +//@Data +//public class CustomSheetWriteHandler implements SheetWriteHandler { +// /** +// * 模板的首行行高 ,通过构造器注入 +// */ +// private int height; +// private Map explicitListConstraintMap = new HashMap<>(); +// public CustomSheetWriteHandler(int height,Map explicitListConstraintMap) { +// this.height = height; +// this.explicitListConstraintMap = explicitListConstraintMap; +// } +// /** +// * 设置阈值,避免生成的导入模板下拉值获取不到 +// */ +// private static final Integer LIMIT_NUMBER = 50; +// +// +// +// /** +// * 返回excel列标A-Z-AA-ZZ +// * +// * @param num 列数 +// * @return java.lang.String +// */ +// private String getExcelLine(int num) { +// String line = ""; +// int first = num / 26; +// int second = num % 26; +// if (first > 0) { +// line = (char) ('A' + first - 1) + ""; +// } +// line += (char) ('A' + second) + ""; +// return line; +// } +// +// @Override +// public void beforeSheetCreate(WriteWorkbookHolder writeWorkbookHolder, WriteSheetHolder writeSheetHolder) { +// // TODO Auto-generated method stub +// +// } +// +// @Override +// public void afterSheetCreate(WriteWorkbookHolder writeWorkbookHolder, WriteSheetHolder writeSheetHolder) { +// // 这里可以对cell进行任何操作 +// Sheet sheet = writeSheetHolder.getSheet(); +// DataValidationHelper helper = sheet.getDataValidationHelper(); +// +// // k 为存在下拉数据集的单元格下表 v为下拉数据集 +// explicitListConstraintMap.forEach((k, v) -> { +// // 设置下拉单元格的首行 末行 首列 末列 +// CellRangeAddressList rangeList = new CellRangeAddressList(1, 65536, k, k); +// // 如果下拉值总数大于100,则使用一个新sheet存储,避免生成的导入模板下拉值获取不到 +// if (v.length > LIMIT_NUMBER) { +// //定义sheet的名称 +// //1.创建一个隐藏的sheet 名称为 hidden + k +// String sheetName = "hidden" + k; +// Workbook workbook = writeWorkbookHolder.getWorkbook(); +// +// Sheet hiddenSheet = workbook.createSheet(sheetName); +// for (int i = 0, length = v.length; i < length; i++) { +// // 开始的行数i,列数k +// hiddenSheet.createRow(i).createCell(k).setCellValue(v[i]); +// } +// Name category1Name = workbook.createName(); +// category1Name.setNameName(sheetName); +// String excelLine = getExcelLine(k); +// // =hidden!$H:$1:$H$50 sheet为hidden的 H1列开始H50行数据获取下拉数组 +// String refers = "=" + sheetName + "!$" + excelLine + "$1:$" + excelLine + "$" + (v.length + 1); +// // 将刚才设置的sheet引用到你的下拉列表中 +// DataValidationConstraint constraint = helper.createFormulaListConstraint(refers); +// DataValidation dataValidation = helper.createValidation(constraint, rangeList); +// +// writeSheetHolder.getSheet().addValidationData(dataValidation); +// // 设置存储下拉列值得sheet为隐藏 +// int hiddenIndex = workbook.getSheetIndex(sheetName); +// if (!workbook.isSheetHidden(hiddenIndex)) { +// workbook.setSheetHidden(hiddenIndex, true); +// } +// } +// // 下拉列表约束数据 +// DataValidationConstraint constraint = helper.createExplicitListConstraint(v); +// // 设置约束 +// DataValidation validation = helper.createValidation(constraint, rangeList); +// // 阻止输入非下拉选项的值 +// validation.setErrorStyle(DataValidation.ErrorStyle.STOP); +// validation.setShowErrorBox(true); +// validation.setSuppressDropDownArrow(true); +// validation.createErrorBox("提示", "此值与单元格定义格式不一致"); +// // validation.createPromptBox("填写说明:","填写内容只能为下拉数据集中的单位,其他单位将会导致无法入仓"); +// sheet.addValidationData(validation); +// }); +// +// } +//} +// diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/utils/excel/easyexcel/handler/TemplateCellWriteHandler.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/utils/excel/easyexcel/handler/TemplateCellWriteHandler.java new file mode 100644 index 0000000..ed16cc0 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/utils/excel/easyexcel/handler/TemplateCellWriteHandler.java @@ -0,0 +1,95 @@ +//package com.ruoyi.utils.excel.easyexcel.handler; +// +//import com.alibaba.excel.metadata.CellData; +//import com.alibaba.excel.metadata.Head; +//import com.alibaba.excel.write.handler.CellWriteHandler; +//import com.alibaba.excel.write.metadata.holder.WriteSheetHolder; +//import com.alibaba.excel.write.metadata.holder.WriteTableHolder; +//import org.apache.poi.ss.usermodel.*; +// +//import java.util.HashMap; +//import java.util.List; +//import java.util.Map; +// +///** +// * excel通用单元格格式类 +// */ +//public class TemplateCellWriteHandler implements CellWriteHandler { +// +// @Override +// public void beforeCellCreate(WriteSheetHolder writeSheetHolder, WriteTableHolder writeTableHolder, Row row, Head head, Integer columnIndex, Integer relativeRowIndex, Boolean isHead) { +// +// } +// +// private final Map cellStyleMap = new HashMap<>(); +// +// @Override +// public void afterCellCreate(WriteSheetHolder writeSheetHolder, WriteTableHolder writeTableHolder, Cell cell, Head head, Integer relativeRowIndex, Boolean isHead) { +// Workbook workbooks = writeSheetHolder.getSheet().getWorkbook(); +// Sheet sheet = writeSheetHolder.getSheet(); +// sheet.setColumnWidth(cell.getColumnIndex(), 20 * 256); +// sheet.setDefaultRowHeight((short) 700); +// +// +// if (!cellStyleMap.containsKey("style1")){ +// CellStyle cellStyle = workbooks.createCellStyle(); +// cellStyle.setVerticalAlignment(VerticalAlignment.CENTER);//居中 +// cellStyle.setAlignment(HorizontalAlignment.CENTER); +// cellStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);//设置前景填充样式 +// cellStyle.setFillForegroundColor(IndexedColors.BLUE_GREY.getIndex());//前景填充色 +// +// // 设置边框样式 +// // 上边框 +// cellStyle.setBorderTop(BorderStyle.THIN); +// // 下边框 +// cellStyle.setBorderBottom(BorderStyle.THIN); +// // 左边框 +// cellStyle.setBorderLeft(BorderStyle.THIN); +// // 右边框 +// cellStyle.setBorderRight(BorderStyle.THIN); +// +// +// //设置字体 +// Font font1 = workbooks.createFont(); +// font1.setBold(true); +// font1.setColor(IndexedColors.BLACK.getIndex()); +// font1.setFontHeightInPoints((short)15); +// font1.setFontName("宋体"); +// cellStyle.setFont(font1); +// cell.setCellStyle(cellStyle); +// +// cellStyleMap.put("style1",cellStyle); +// }else { +// CellStyle cellStyle = cellStyleMap.get("style1"); +// cell.setCellStyle(cellStyle); +// } +// +// +// //其他列 +// if (!isHead){ +// if (!cellStyleMap.containsKey("style2")){ +// CellStyle style = workbooks.createCellStyle(); +// DataFormat dataFormat = workbooks.createDataFormat(); +// style.setDataFormat(dataFormat.getFormat("@")); +// style.setVerticalAlignment(VerticalAlignment.CENTER); +// style.setAlignment(HorizontalAlignment.CENTER); +// cell.setCellStyle(style); +// cellStyleMap.put("style2",style); +// }else { +// CellStyle cellStyle = cellStyleMap.get("style2"); +// cell.setCellStyle(cellStyle); +// } +// +// } +// } +// +// @Override +// public void afterCellDataConverted(WriteSheetHolder writeSheetHolder, WriteTableHolder writeTableHolder, CellData cellData, Cell cell, Head head, Integer relativeRowIndex, Boolean isHead) { +// +// } +// +// +// @Override +// public void afterCellDispose(WriteSheetHolder writeSheetHolder, WriteTableHolder writeTableHolder, List cellDataList, Cell cell, Head head, Integer relativeRowIndex, Boolean isHead) { +// } +//} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/utils/excel/easyexcel/listener/ExcelListener.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/utils/excel/easyexcel/listener/ExcelListener.java new file mode 100644 index 0000000..794a6df --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/utils/excel/easyexcel/listener/ExcelListener.java @@ -0,0 +1,93 @@ +//package com.ruoyi.utils.excel.easyexcel.listener; +// +//import com.alibaba.excel.context.AnalysisContext; +//import com.alibaba.excel.event.AnalysisEventListener; +//import lombok.Getter; +//import lombok.NoArgsConstructor; +//import lombok.Setter; +// +//import java.util.ArrayList; +//import java.util.List; +//import java.util.Map; +// +///** +// * Excel数据解析监听器, 数据解析方法异步执行 +// * @param Excel中数据的类型 +// */ +//@Getter +//@Setter +//@NoArgsConstructor +//public class +//ExcelListener extends AnalysisEventListener { +// // 加入一个判断标签,判断数据是否已经读取完 +// private volatile boolean retryLock = false; +// +// // 解析完成后的数据集合, 监听对象初始化之后,立即初始化集合对象 +// private final List dataList = new ArrayList<>(); +// +// // 每次最多导入条数 +// private final int batchSize = 2000; +// +// +// /** +// * 获取解析后的数据集合, 如果数据还没有被解析完成,会对读取该集合的线程进行阻塞,直到数据读取完成之后,进行解锁。 +// * 如果一次导入数据超过batchSize条,则以抛异常的形式阻止导入数据 +// * @return 解析后的数据集合 +// */ +// public List getDataList() { +// while (true){ +// if (retryLock){ +// if (dataList.size() > batchSize){ +// // 手动清空数据内存数据,减少内存消耗 +// dataList.clear(); +// throw new RuntimeException("一次最多导入"+ batchSize +"条数据"); +// } else { +// return dataList; +// } +// } +// } +// } +// +// /** +// * Excel每解析一行数据,就会调用一次该方法 +// * @param data +// * one row value. Is is same as {@link AnalysisContext#readRowHolder()} +// * @param context +// * analysis context +// */ +// @Override +// public void invoke(T data, AnalysisContext context) { +// dataList.add(data); +// } +// +// /** +// * 读取表头内容 +// * @param headMap 表头部数据 +// * @param context 数据解析上下文 +// */ +// @Override +// public void invokeHeadMap(Map headMap, AnalysisContext context) { +// //System.out.println("表头:" + headMap); +// } +// +// /** +// * 流中的数据解析完成之后,就会调用此方法 +// * @param context +// */ +// @Override +// public void doAfterAllAnalysed(AnalysisContext context) { +// // 数据解析完成,解锁 +// retryLock = true; +// } +// +// /** +// * 解析过程如果发生异常,会调用此方法 +// * @param exception +// * @param context +// */ +// @Override +// public void onException(Exception exception, AnalysisContext context){ +// throw new RuntimeException("Excel数据异常,请检查或联系管理员!"); +// } +//} +// diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/utils/excel/easyexcel/service/ExplicitInterface.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/utils/excel/easyexcel/service/ExplicitInterface.java new file mode 100644 index 0000000..3babef5 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/utils/excel/easyexcel/service/ExplicitInterface.java @@ -0,0 +1,10 @@ +//package com.ruoyi.utils.excel.easyexcel.service; +// +//public interface ExplicitInterface { +// /** +// * 动态下拉列表的内容数组 +// * @return +// * type 字典类型 +// */ +// String[] source(String type); +//} \ No newline at end of file diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/utils/excel/easyexcel/service/RoleNameExplicitConstraint.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/utils/excel/easyexcel/service/RoleNameExplicitConstraint.java new file mode 100644 index 0000000..3a89ee5 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/utils/excel/easyexcel/service/RoleNameExplicitConstraint.java @@ -0,0 +1,35 @@ +//package com.ruoyi.utils.excel.easyexcel.service; +// +//import cn.stylefeng.guns.modular.business.frequency.dict.entity.Dict; +//import cn.stylefeng.guns.modular.business.frequency.dict.mapper.DictMapper; +//import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +//import org.springframework.beans.factory.annotation.Autowired; +// +//import java.util.List; +//import java.util.stream.Collectors; +// +///*** +// * +// * 获取动态值 +// * +// * **/ +//public class RoleNameExplicitConstraint implements ExplicitInterface { +// +// +// @Autowired +// private DictMapper dictMapper; +// +// @Override +// public String[] source(String code) { +// QueryWrapper queryWrapper = new QueryWrapper<>(); +// queryWrapper.eq("code", code); +// queryWrapper.orderByAsc("sort"); +// List list= dictMapper.selectList(queryWrapper); +// List names = list.stream().map(dataDictionary->{ +// return dataDictionary.getName()+"@"+dataDictionary.getCode(); +// } +// ).collect(Collectors.toList()); +// String[] str=names.toArray(new String[names.size()]); +// return str; +// } +//} \ No newline at end of file diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/utils/excel/easyexcel/vo/ExportExcelVo.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/utils/excel/easyexcel/vo/ExportExcelVo.java new file mode 100644 index 0000000..cd19f7d --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/utils/excel/easyexcel/vo/ExportExcelVo.java @@ -0,0 +1,67 @@ +//package com.ruoyi.utils.excel.easyexcel.vo; +// +//import com.alibaba.excel.annotation.ExcelProperty; +//import com.alibaba.excel.annotation.write.style.ColumnWidth; +//import com.alibaba.excel.annotation.write.style.HeadRowHeight; +//import lombok.Data; +//import lombok.experimental.Accessors; +// +//import java.io.Serializable; +// +///** +// * 资质信息导出实体 +// */ +//@Data // Lombok注解,用于生成getter setter +//@Accessors(chain = true) //Lombok注解,链式赋值使用 +//@HeadRowHeight(50) +//public class ExportExcelVo implements Serializable { +// private static final long serialVersionUID = 1L; +// +// @ColumnWidth(25) +// @ExcelProperty(value = "企业名称", index = 0) +// private String name; +//// +//// @ColumnWidth(25) +//// @ExcelProperty(value = "社会统一信用代码", index = 1) +//// private String creditCode; +//// +//// @ColumnWidth(15) +//// @ExcelProperty(value = "曾用名", index = 2) +//// private String formerName; +//// +//// @ColumnWidth(15) +//// @ExcelProperty(value = "公司法人", index = 3) +//// private String legalPerson; +//// +//// @ExcelProperty(value = "区域", index = 4) +//// private String province; +//// +//// @ExcelProperty(value = "录入时间", index = 5) +//// private String createTime; +//// +//// @ColumnWidth(15) +//// @ExcelProperty(value = "公司股东", index = 6) +//// private String stockholder; +//// +//// @ExcelProperty(value = "企业联系方式", index = 7) +//// private String contact; +// +// +//// /** +//// * 检验报告url +//// */ +//// @ExcelProperty(value = "图片",index = 8,converter = UrlImageConverter.class) +//// @ColumnWidth(60) +//// private URL inspectionReportUrl; +//// +//// @ColumnWidth(15) +//// @ExcelProperty(value = "性别", index = 9,converter = DataIntConverter.class) +//// private String sex; +//// +//// @ColumnWidth(15) +//// @ExcelProperty(value = "性别2", index = 10,converter = DataIntConverter.class) +//// private String sex2; +// +// +// +//} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/utils/excel/easyexcel/vo/ImportExcelVo.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/utils/excel/easyexcel/vo/ImportExcelVo.java new file mode 100644 index 0000000..0fa447d --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/utils/excel/easyexcel/vo/ImportExcelVo.java @@ -0,0 +1,42 @@ +//package com.ruoyi.utils.excel.easyexcel.vo; +// +//import cn.stylefeng.guns.modular.business.custom.util.excel.easyexcel.annotations.ExplicitConstraint; +//import com.alibaba.excel.annotation.ExcelProperty; +//import com.alibaba.excel.annotation.write.style.ColumnWidth; +//import com.alibaba.excel.annotation.write.style.HeadRowHeight; +//import lombok.Data; +// +//import java.io.Serializable; +// +///** +// * 数据导入的Excel模板实体 +// */ +//@Data +//@HeadRowHeight(50) +//public class ImportExcelVo implements Serializable { +// private static final long serialVersionUID = 1L; +// +// @ColumnWidth(20) +// @ExcelProperty(value = "公司名称", index = 0) +// @ExplicitConstraint(source = {"从去看看的接口","的接口对接","肯德基发快递"}) +// private String name; +// +// @ColumnWidth(20) +// @ExcelProperty(value = "公司联系电话", index = 1) +// private String phone; +// +// @ColumnWidth(28) +// @ExcelProperty(value = "公司统一社会信用代码", index = 2) +// private String creditCode; +// +// @ColumnWidth(15) +// @ExcelProperty(value = "区域", index = 3) +// private String province; +// +// @ColumnWidth(15) +// @ExcelProperty(value = "公司法人", index = 4) +// private String legalPerson; +// +// @ExcelProperty(value = "备注", index = 5) +// private String remark; +//} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/utils/lakala/LakalaUtil.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/utils/lakala/LakalaUtil.java new file mode 100644 index 0000000..d5edb71 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/utils/lakala/LakalaUtil.java @@ -0,0 +1,227 @@ +package com.ruoyi.utils.lakala; + +import cn.hutool.core.date.DateUtil; +import com.alibaba.fastjson.JSONObject; +import com.lkl.laop.sdk.Config; +import com.lkl.laop.sdk.LKLSDK; +import com.lkl.laop.sdk.exception.SDKException; +import com.lkl.laop.sdk.request.V3CcssCounterOrderCreateRequest; +import com.lkl.laop.sdk.request.model.V3CcssOrderSceneFieldInfo; +import com.ruoyi.response.ResponseData; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Component; + +import java.math.BigDecimal; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.Map; + +@Slf4j +@Component +public class LakalaUtil { + + //拉卡拉开放平台进行配置开通 + @Value("${lalkla.appId}") + private String appId; + + //商户号 + @Value("${lalkla.merchantNo}") + private String merchantNo; + + //商户证书序列号,和商户私钥对应 + @Value("${lalkla.serialNo}") + private String serialNo; + + //商户私钥地址,用于请求签名 + @Value("${lalkla.priKeyPath}") + private String priKeyPath; + + //拉卡拉公钥证书地址,用于验签(测试证书为:lkl-apigw-v2.cer) + @Value("${lalkla.lklCerPath}") + private String lklCerPath; + + //拉卡拉支付平台证书地址2(用于拉卡拉通知验签,证书与lklCerPath)一致,测试证书为:lkl-apigw-v2.cer) + @Value("${lalkla.lklNotifyCerPath}") + private String lklNotifyCerPath; + + //拉卡拉开放平台服务地址 + @Value("${lalkla.serverUrl}") + private String serverUrl; + + //如果需要密文传输请申请拉卡拉SM4密钥 + @Value("${lalkla.sm4Key}") + private String sm4Key; + + +// //支付回调地址 +// @Value("${lalkla.appId}") +// private static final String notifyUrl = "http://yutongbo.natapp1.cc/api/goeasy/lakalaNotifyUrl"; + + /** + * 初始化配置 + * + * @throws SDKException + */ + public void doInit() { + //初始化配置(全局只需配置一次) + try { + LKLSDK.init(new Config(appId, serialNo, priKeyPath, lklCerPath, lklNotifyCerPath, sm4Key, serverUrl)); + } catch (SDKException e) { + throw new RuntimeException(e); + } + } + + /** + * 聚合收银台创建订单 + * + * @return + */ + public ResponseData ccssCounterOrderTospecialCreate(String orderNo, BigDecimal payPrice, Long objectId, String notifyUrl) { + doInit(); + //创建订单请求参数 + V3CcssCounterOrderCreateRequest request = new V3CcssCounterOrderCreateRequest(); + + //商户订单号 + request.setOutOrderNo(orderNo); + + //是否支持多次发起订单 0 不支持 1 支持 + request.setSupportRepeatPay(1); + + //银联商户号 + request.setMerchantNo(merchantNo); + + //订单支付金额 单位:分 + request.setTotalAmount(payPrice.multiply(new BigDecimal(100)).longValue()); + + //支付有效期 一天 + request.setOrderEfficientTime(DateUtil.format(DateUtil.offsetDay(new Date(), 1), "yyyyMMddHHmmss")); + + //回调地址 + request.setNotifyUrl(notifyUrl); + + //支付类型 +// req.setCounterParam("{\"pay_mode\":\"ALIPAY\"}"); + +// req.setBusiTypeParam("[{\"busi_type\":\"UPCARD\",\"params\":{\"crd_flg\":\"CRDFLG_D|CRDFLG_C|CRDFLG_OTH\"}},{\"busi_type\":\"SCPAY\",\"params\":{\"pay_mode\":\"WECHAT\",\"crd_flg\":\"CRDFLG_D\"}}]"); + + // 订单标题,在使用收银台扫码支付时必输入,交易时送往账户端 + request.setOrderInfo("DD画图支付"); + + List sgnInfos = new ArrayList<>(); + + sgnInfos.add("1"); + + request.setSgnInfo(sgnInfos); + + + V3CcssOrderSceneFieldInfo.HbFqSceneInfo hbFqSceneInfo = new V3CcssOrderSceneFieldInfo.HbFqSceneInfo(); + + hbFqSceneInfo.setHbFqNum("3"); + + hbFqSceneInfo.setHbFqSellerPercent("0"); + + //3. 发送请求 + String response = null; + try { + response = LKLSDK.httpPost(request); + } catch (SDKException e) { + log.error("调用拉卡拉支付接口异常", e); + throw new RuntimeException(e); + } + + //4. 响应 + System.out.println(response); + + Map map = JSONObject.parseObject(response, Map.class); + if ("000000".equals(map.get("code"))) { + map.put("orderId", objectId); + return ResponseData.success(map); + } else { + log.error("调用拉卡拉支付接口异常,返回结果:{}", response); + return ResponseData.error(map.get("msg").toString()); + } + } + + public static void main(String[] args) { + + //拉卡拉开放平台进行配置开通 + String appId = "OP00000003"; + //商户号 + String merchantNo = "822290059430BBV"; + //商户证书序列号,和商户私钥对应 + String serialNo = "00dfba8194c41b84cf"; + //商户私钥地址,用于请求签名 + String priKeyPath = "D:/OP00000003_private_key.pem"; + //拉卡拉公钥证书地址,用于验签(测试证书为:lkl-apigw-v2.cer) + String lklCerPath = "D:/lkl-apigw-v2.cer"; + //拉卡拉支付平台证书地址2(用于拉卡拉通知验签,证书与lklCerPath)一致,测试证书为:lkl-apigw-v2.cer) + String lklNotifyCerPath = "D:/lkl-apigw-v2.cer"; + //拉卡拉开放平台服务地址 + String serverUrl = "https://test.wsmsd.cn/sit"; + //如果需要密文传输请申请拉卡拉SM4密钥 + String sm4Key = "0I4M0kmwFrNUU8hZ9AFpfA=="; + //支付回调地址 + String notifyUrl = "http://yutongbo.natapp1.cc/api/goeasy/lakalaNotifyUrl"; + //初始化配置(全局只需配置一次) + try { + LKLSDK.init(new Config(appId, serialNo, priKeyPath, lklCerPath, lklNotifyCerPath, sm4Key, serverUrl)); + } catch (SDKException e) { + throw new RuntimeException(e); + } + + //创建订单请求参数 + V3CcssCounterOrderCreateRequest request = new V3CcssCounterOrderCreateRequest(); + + //商户订单号 + request.setOutOrderNo("HT" + new SimpleDateFormat("yyyyMMddHHmmss").format(new Date())); + + //银联商户号 + request.setMerchantNo(merchantNo); + + //订单支付金额 单位:分 + request.setTotalAmount(1L); + + //支付有效期 一天 + request.setOrderEfficientTime(DateUtil.format(DateUtil.offsetDay(new Date(), 1), "yyyyMMddHHmmss")); + + //回调地址 + request.setNotifyUrl(notifyUrl); + + //支付类型 +// req.setCounterParam("{\"pay_mode\":\"ALIPAY\"}"); + +// req.setBusiTypeParam("[{\"busi_type\":\"UPCARD\",\"params\":{\"crd_flg\":\"CRDFLG_D|CRDFLG_C|CRDFLG_OTH\"}},{\"busi_type\":\"SCPAY\",\"params\":{\"pay_mode\":\"WECHAT\",\"crd_flg\":\"CRDFLG_D\"}}]"); + + // 订单标题,在使用收银台扫码支付时必输入,交易时送往账户端 + request.setOrderInfo("DD画图支付"); + + List sgnInfos = new ArrayList<>(); + + sgnInfos.add("1"); + + request.setSgnInfo(sgnInfos); + + + V3CcssOrderSceneFieldInfo.HbFqSceneInfo hbFqSceneInfo = new V3CcssOrderSceneFieldInfo.HbFqSceneInfo(); + + hbFqSceneInfo.setHbFqNum("3"); + + hbFqSceneInfo.setHbFqSellerPercent("0"); + + //3. 发送请求 + String response = null; + try { + response = LKLSDK.httpPost(request); + } catch (SDKException e) { + log.error("调用拉卡拉支付接口异常", e); + throw new RuntimeException(e); + } + + //4. 响应 + System.out.println(response); + + } +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/utils/lakala/test/BaseCommonDemo.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/utils/lakala/test/BaseCommonDemo.java new file mode 100644 index 0000000..03f6d37 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/utils/lakala/test/BaseCommonDemo.java @@ -0,0 +1,125 @@ +package com.ruoyi.utils.lakala.test; + +import com.lkl.laop.sdk.Config; +import com.lkl.laop.sdk.LKLSDK; +import com.lkl.laop.sdk.exception.SDKException; +import com.lkl.laop.sdk.request.V3CcssCounterOrderQueryRequest; +import com.lkl.laop.sdk.request.V3LabsTradeQueryRequest; +import com.lkl.laop.sdk.utils.FileUtils; +import lombok.extern.slf4j.Slf4j; +import org.springframework.http.ResponseEntity; + +import javax.servlet.http.HttpServletRequest; + +@Slf4j +public class BaseCommonDemo { + + //拉卡拉开放平台进行配置开通 + private static final String appId = "OP00000003"; + + //商户证书序列号,和商户私钥对应 + private static final String serialNo = "00dfba8194c41b84cf"; + + //商户私钥地址,用于请求签名 + private static final String priKeyPath = "D:/OP00000003_private_key.pem"; + + //拉卡拉公钥证书地址,用于验签(测试证书为:lkl-apigw-v2.cer) + private static final String lklCerPath = "D:/lkl-apigw-v2.cer"; + + //拉卡拉支付平台证书地址2(用于拉卡拉通知验签,证书与lklCerPath)一致,测试证书为:lkl-apigw-v2.cer) + private static final String lklNotifyCerPath="D:/lkl-apigw-v2.cer"; + + //拉卡拉开放平台服务地址 + private static final String serverUrl = "https://test.wsmsd.cn/sit"; + + //如果需要密文传输请申请拉卡拉SM4密钥 + private static final String sm4Key = "0I4M0kmwFrNUU8hZ9AFpfA=="; + + //根据请求接口拼装参数 +// +// V3LabsTradeQueryRequest v3LabsTradeQueryRequest=new V3LabsTradeQueryRequest(); +// +// v3LabsTradeQueryRequest.setMerchantNo("xxxx"); +// +// v3LabsTradeQueryRequest.setTermNo("xxx"); +// +// v3LabsTradeQueryRequest.setOutTradeNo("xxxx"); + + + + //发起请求-正常请求 +// +// String response=LKLSDK.httpPost(v3LabsTradeQueryRequest); +// +// +// +// //发起请求2(密文传输接口)-请求报文加密,响应信息无需解密 +// +// String response2=LKLSDK.httpPost(v3LabsTradeQueryRequest,true,false); +// +// +// +// //发起请求3(密文传输接口)-请求报文加密,响应信息需解密 +// +// String response3=LKLSDK.httpPost(v3LabsTradeQueryRequest,true,true); +// +// +// +// //发起请求4-自定义接口参数实体,直接发送接口地址 +// +// String response3=LKLSDK.httpPost("url","bodyJson"); +// +// +// +// //处理响应 +// +// log.info(response); + +//以下代码向您展示了使用拉卡拉SDK for Java接收回调通知的示例 + + +//拉卡拉开放平台采用数据流传输 + + public ResponseEntity messageHandle(HttpServletRequest request) throws Exception { + + // 1. 配置初始化-全局只需要初始化一次 + doInit(); + + //验签并解析请求 + String body = LKLSDK.notificationHandle(request); + + System.out.println("验签成功,请求body:" + body); + + //业务处理 + return ResponseEntity.ok(body); + + } + + public static void doInit() throws SDKException { + //初始化配置(全局只需配置一次) + LKLSDK.init(new Config(appId,serialNo,priKeyPath,lklCerPath,lklNotifyCerPath,sm4Key,serverUrl)); + } + + public static void main(String[] args) throws SDKException { + doInit(); + + //聚合收银台 + V3CcssCounterOrderQueryRequest v3CcssCounterOrderQueryRequest = new V3CcssCounterOrderQueryRequest(); + + v3CcssCounterOrderQueryRequest.setMerchantNo("82229007392000A"); + + v3CcssCounterOrderQueryRequest.setPayOrderNo("24041911012001101011001235881"); + + v3CcssCounterOrderQueryRequest.setOutOrderNo("82229007392000A20240419134553"); + v3CcssCounterOrderQueryRequest.setChannelId("95"); + + String response=LKLSDK.httpPost(v3CcssCounterOrderQueryRequest); + + System.out.println(response); + + // + + } + + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/utils/lakala/test/V3CcssCounterOrderCreateRequestExtend.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/utils/lakala/test/V3CcssCounterOrderCreateRequestExtend.java new file mode 100644 index 0000000..58ab846 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/utils/lakala/test/V3CcssCounterOrderCreateRequestExtend.java @@ -0,0 +1,19 @@ +package com.ruoyi.utils.lakala.test; + +import com.lkl.laop.sdk.request.V3CcssCounterOrderCreateRequest; +import lombok.Data; + +@Data +public class V3CcssCounterOrderCreateRequestExtend extends V3CcssCounterOrderCreateRequest { + + private String supportPayMode= "[\n" + + " {\n" + + " \"busi_type\": \"UPCARD\",\n" + + " \"pay_mode\": \"CREDIT|DEBIT\"\n" + + " },\n" + + " {\n" + + " \"busi_type\": \"SCPAY\",\n" + + " \"pay_mode\": \"WETCHAT|ALIPAY\"\n" + + " }\n" + + " ]"; +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/utils/lakala/test/V3CcssCounterOrderCreateRequestExtendDemo.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/utils/lakala/test/V3CcssCounterOrderCreateRequestExtendDemo.java new file mode 100644 index 0000000..1561147 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/utils/lakala/test/V3CcssCounterOrderCreateRequestExtendDemo.java @@ -0,0 +1,294 @@ +package com.ruoyi.utils.lakala.test; + +import cn.hutool.core.date.DateUtil; +import com.lkl.laop.sdk.LKLSDK; +import com.lkl.laop.sdk.exception.SDKException; +import com.lkl.laop.sdk.request.V3CcssCounterOrderCreateRequest; +import com.lkl.laop.sdk.request.model.V3CcssOrderSceneFieldInfo; +import com.lkl.laop.sdk.utils.JsonUtils; + +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +public class V3CcssCounterOrderCreateRequestExtendDemo extends BaseCommonDemo { + + public static void main(String[] args) throws SDKException{ + + // 1. 配置初始化 + + doInit(); + + + //增加实体一级参数demo + + extendFirstStruct(); +// +// //增加实体二级参数demo +// +// extendSecondStruct(); +// +//// //增加调用sdk未封装接口demo +// +// extendAllStruct(); + + } + + + + /** + + * 增加实体最外层字段 + + * > 重写实体继承原实体 + + * + + * @see V3CcssCounterOrderCreateRequestExtend 继承 + + * @see V3CcssCounterOrderCreateRequest + + */ + + private static void extendFirstStruct() throws SDKException { + + // 创建自定义实体V3CcssCounterOrderCreateRequestExtend 继承V3CcssCounterOrderCreateRequest + + V3CcssCounterOrderCreateRequestExtend req = new V3CcssCounterOrderCreateRequestExtend(); + + req.setOutOrderNo("82229007392000A" + new SimpleDateFormat("yyyyMMddHHmmss").format(new Date())); + + req.setMerchantNo("82229007392000A"); + + req.setTotalAmount(10L); + + req.setOrderEfficientTime(DateUtil.format(DateUtil.offsetDay(new Date(),1),"yyyyMMddHHmmss")); + + //回调地址 + req.setNotifyUrl("http://yutongbo.natapp1.cc/api/goeasy/lakalaNotifyUrl"); + + req.setSupportRefund(1); + + req.setSupportRepeatPay(1); + + //支付类型 +// req.setCounterParam("{\"pay_mode\":\"ALIPAY\"}"); + + req.setSupportCancel(0); + +// req.setBusiTypeParam("[{\"busi_type\":\"UPCARD\",\"params\":{\"crd_flg\":\"CRDFLG_D|CRDFLG_C|CRDFLG_OTH\"}},{\"busi_type\":\"SCPAY\",\"params\":{\"pay_mode\":\"WECHAT\",\"crd_flg\":\"CRDFLG_D\"}}]"); + + req.setOrderInfo("测试12313131"); + + req.setTermNo("D9296400"); + + List sgnInfos = new ArrayList<>(); + + sgnInfos.add("1"); + + req.setSgnInfo(sgnInfos); + +// V3CcssOrderSceneFieldInfo info = new V3CcssOrderSceneFieldInfo(); + + V3CcssOrderSceneFieldInfo.HbFqSceneInfo hbFqSceneInfo = new V3CcssOrderSceneFieldInfo.HbFqSceneInfo(); + + hbFqSceneInfo.setHbFqNum("3"); + + hbFqSceneInfo.setHbFqSellerPercent("0"); + +// info.setSceneInfo(JsonUtils.toJSONString(hbFqSceneInfo)); + +// info.setOrderSceneType("HB_FQ"); + +// req.setOrderSceneField(info); + + + //3. 发送请求 + + String response = LKLSDK.httpPost(req); + + + + //4. 响应 + + System.out.println(response); + + } + + + + /** + + * 增加实体内层嵌套实体字段 + + * > 重写嵌套实体继承原实体 + + * + + * @see V3CcssOrderSceneFieldInfoExtend 继承 + + * @see V3CcssOrderSceneFieldInfo + + */ + + private static void extendSecondStruct() throws SDKException { + + + + V3CcssCounterOrderCreateRequest req = new V3CcssCounterOrderCreateRequest(); + + req.setOutOrderNo("82229007392000A" + new SimpleDateFormat("yyyyMMddHHmmss").format(new Date())); + + req.setMerchantNo("82229007392000A"); + + req.setTotalAmount(10L); + + req.setOrderEfficientTime(DateUtil.format(DateUtil.offsetDay(new Date(),1),"yyyyMMddHHmmss")); + + //回调地址 + req.setNotifyUrl("http://m8nnvt.natappfree.cc/api/goeasy/lakalaNotifyUrl"); + + req.setSupportRefund(1); + + req.setSupportRepeatPay(1); + +// req.setCounterParam("{\"pay_mode\":\"ALIPAY\"}"); + + req.setSupportCancel(0); + + req.setBusiTypeParam("[{\"busi_type\":\"UPCARD\",\"params\":{\"crd_flg\":\"CRDFLG_D|CRDFLG_C|CRDFLG_OTH\"}},{\"busi_type\":\"SCPAY\",\"params\":{\"pay_mode\":\"WECHAT\",\"crd_flg\":\"CRDFLG_D\"}}]"); + + req.setOrderInfo("测试12313131"); + + req.setTermNo("D9296400"); + + List sgnInfos = new ArrayList<>(); + + sgnInfos.add("1"); + + req.setSgnInfo(sgnInfos); + + + + //创建自定义实体继承 V3CcssOrderSceneFieldInfo + + V3CcssOrderSceneFieldInfoExtend info = new V3CcssOrderSceneFieldInfoExtend(); + + V3CcssOrderSceneFieldInfo.HbFqSceneInfo hbFqSceneInfo = new V3CcssOrderSceneFieldInfo.HbFqSceneInfo(); + + hbFqSceneInfo.setHbFqNum("3"); + + hbFqSceneInfo.setHbFqSellerPercent("0"); + + info.setSceneInfo(JsonUtils.toJSONString(hbFqSceneInfo)); + + info.setOrderSceneType("HB_FQ"); + + + + //----- 增加内部结构字段 + +// info.setSecondExtFiled1("内部扩展字段"); + + + + req.setOrderSceneField(info); + + //3. 发送请求 + + String response = LKLSDK.httpPost(req); + + + + //4. 响应 + + System.out.println(response); + + } + + + + /** + + * 增加自定义实体(sdk未封装接口) + + * > v2接口继承 + + * @see com.lkl.laop.sdk.request.V2CommRequest + + * > v3接口继承 + + * @see com.lkl.laop.sdk.request.V3CommRequest + + */ + + private static void extendAllStruct() throws SDKException { + +// //创建 V3ExtendRequest 继承 V3CommRequest +// +// V3ExtendRequest req = new V3ExtendRequest(); +// +// req.setOutOrderNo("8221210594300JY" + new SimpleDateFormat("yyyyMMddHHmmss").format(new Date())); +// +// req.setMerchantNo("8221210594300JY"); +// +// req.setTotalAmount(10L); +// +// req.setOrderEfficientTime("20230824155923"); +// +// req.setNotifyUrl("http://run.mocky.io/v3/b02c9448-20a2-4ff6-a678-38ecab30161d"); +// +// req.setSupportRefund(1); +// +// req.setSupportRepeatPay(1); +// +// req.setCounterParam("{\"pay_mode\":\"ALIPAY\"}"); +// +// req.setSupportCancel(0); +// +// req.setBusiTypeParam("[{\"busi_type\":\"UPCARD\",\"params\":{\"crd_flg\":\"CRDFLG_D|CRDFLG_C|CRDFLG_OTH\"}},{\"busi_type\":\"SCPAY\",\"params\":{\"pay_mode\":\"WECHAT\",\"crd_flg\":\"CRDFLG_D\"}}]"); +// +// req.setOrderInfo("测试12313131"); +// +// req.setTermNo("T12331234"); +// +// List sgnInfos = new ArrayList<>(); +// +// sgnInfos.add("1"); +// +// req.setSgnInfo(sgnInfos); +// +// +// +// V3CcssOrderSceneFieldInfo info = new V3CcssOrderSceneFieldInfo(); +// +// V3CcssOrderSceneFieldInfo.HbFqSceneInfo hbFqSceneInfo = new V3CcssOrderSceneFieldInfo.HbFqSceneInfo(); +// +// hbFqSceneInfo.setHbFqNum("3"); +// +// hbFqSceneInfo.setHbFqSellerPercent("0"); +// +// info.setSceneInfo(JsonUtils.toJSONString(hbFqSceneInfo)); +// +// info.setOrderSceneType("HB_FQ"); +// +// req.setOrderSceneField(info); +// +// //========================== 发送请求使用此方法 ========================== +// +// //参数需要加密时 使用 LKLSDK.sm4Encrypt(req.toBody(); 自行加密 +// +// String response = LKLSDK.httpPost("https://test.wsmsd.cn/sit/api/v3/ccss/counter/order/create",req.toBody()); +// +// //解密时 使用 LKLSDK.sm4Decrypt(response); 自行解密 +// +// +// +// //响应 +// +// System.out.println(response); + + } + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/utils/lakala/test/V3CcssOrderSceneFieldInfoExtend.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/utils/lakala/test/V3CcssOrderSceneFieldInfoExtend.java new file mode 100644 index 0000000..69e8c27 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/utils/lakala/test/V3CcssOrderSceneFieldInfoExtend.java @@ -0,0 +1,6 @@ +package com.ruoyi.utils.lakala.test; + +import com.lkl.laop.sdk.request.model.V3CcssOrderSceneFieldInfo; + +public class V3CcssOrderSceneFieldInfoExtend extends V3CcssOrderSceneFieldInfo { +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/utils/lakala/test/V3ExtendRequest.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/utils/lakala/test/V3ExtendRequest.java new file mode 100644 index 0000000..e98c4e7 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/utils/lakala/test/V3ExtendRequest.java @@ -0,0 +1,11 @@ +package com.ruoyi.utils.lakala.test; + +import com.lkl.laop.sdk.enums.FunctionCodeEnum; +import com.lkl.laop.sdk.request.V3CommRequest; + +public class V3ExtendRequest extends V3CommRequest { + @Override + public FunctionCodeEnum getFunctionCode() { + return null; + } +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/utils/pwd/MD5EncryptionPwdUtil.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/utils/pwd/MD5EncryptionPwdUtil.java new file mode 100644 index 0000000..0374d81 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/utils/pwd/MD5EncryptionPwdUtil.java @@ -0,0 +1,41 @@ +package com.ruoyi.utils.pwd; + +/** + * 加密 + */ +public class MD5EncryptionPwdUtil { + + //开头 + private final static String prefix = "ief"; + //结尾 + private final static String suffix = "itr"; + //中间 + private final static String middle = "iry"; + //中间的插入顺序是密码的长度和6的模作为插入位置 + private final static Integer indexModel = 6; + + /** + * 加密 + * + * @param inputPwd 加密字符串 + * @return 加密后字符串 + */ + public static String encryptionMd5(String inputPwd) { + int length = inputPwd.length(); + for (int i = 0; i < length; i++) { + + Integer inputIndex = inputPwd.length() % indexModel; + //加密规则 加密的字符串由 prefix+ pwd长度与indexModel取模,作为插入节点,然后把middle插入中间+suffix,之后进行加密 + String encryptionPwd = prefix + inputPwd.substring(0, inputIndex) + middle + inputPwd.substring(inputIndex) + suffix; + inputPwd = Utils_MD5.GetMD5Code(encryptionPwd); + } + return Utils_MD5.GetMD5Code(inputPwd); + } + + public static void main(String[] args) { + String pwd = "123456"; + String s = encryptionMd5(pwd); + System.out.println("加密字符串=" + s); + } + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/utils/pwd/MD5Util.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/utils/pwd/MD5Util.java new file mode 100644 index 0000000..00ca623 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/utils/pwd/MD5Util.java @@ -0,0 +1,90 @@ +package com.ruoyi.utils.pwd; + +import java.security.MessageDigest; + +public class MD5Util { + + /** + * 功能描述:字符串转换为MD5 + * + * @param str 字符串 + * @return + * @author houkun 2013-7-18 上午08:52:29 + */ + public static String encoderByMd5(String str) { + if (str == null || "".equals(str)) { + return ""; + } + byte[] unencodedPassword = str.getBytes(); + MessageDigest md = null; + try { + md = MessageDigest.getInstance("MD5"); + } catch (Exception e) { + return str; + } + md.reset(); + md.update(unencodedPassword); + byte[] encodedPassword = md.digest(); + StringBuffer buf = new StringBuffer(); + for (int i = 0; i < encodedPassword.length; i++) { + if ((encodedPassword[i] & 0xff) < 0x10) { + buf.append("0"); + } + buf.append(Long.toString(encodedPassword[i] & 0xff, 16)); + } + return buf.toString(); + } + + + public static String MD5Encode(String origin, String charsetname) { + String resultString = null; + try { + resultString = new String(origin); + MessageDigest md = MessageDigest.getInstance("MD5"); + if (charsetname == null || "".equals(charsetname)) { + resultString = byteArrayToHexString(md.digest(resultString + .getBytes())); + } else { + resultString = byteArrayToHexString(md.digest(resultString + .getBytes(charsetname))); + } + } catch (Exception exception) { + } + return resultString; + } + + public static String MD5Encode_1(String origin) { + String resultString = null; + try { + resultString = new String(origin); + MessageDigest md = MessageDigest.getInstance("MD5"); + resultString = byteArrayToHexString(md.digest(resultString + .getBytes())); + } catch (Exception ex) { + } + return resultString; + } + + private static String byteArrayToHexString(byte[] b) { + StringBuffer resultSb = new StringBuffer(); + for (int i = 0; i < b.length; i++) { + resultSb.append(byteToHexString(b[i])); + } + + return resultSb.toString(); + } + + private static String byteToHexString(byte b) { + int n = b; + if (n < 0) { + n += 256; + } + int d1 = n / 16; + int d2 = n % 16; + return hexDigits[d1] + hexDigits[d2]; + } + + private static final String[] hexDigits = {"0", "1", "2", "3", "4", "5", + "6", "7", "8", "9", "a", "b", "c", "d", "e", "f"}; + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/utils/pwd/Utils_MD5.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/utils/pwd/Utils_MD5.java new file mode 100644 index 0000000..97debe0 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/utils/pwd/Utils_MD5.java @@ -0,0 +1,84 @@ +package com.ruoyi.utils.pwd; + +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; + +/** + * MD5不可逆加密工具类 + */ +public class Utils_MD5 { + /** + * 全局数组 + **/ + private final static String[] strDigits = {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F"}; + + /** + * 返回形式为数字跟字符串 + * + * @param bByte + * @return + */ + private static String byteToArrayString(byte bByte) { + int iRet = bByte; + if (iRet < 0) { + iRet += 256; + } + int iD1 = iRet / 16; + int iD2 = iRet % 16; + return strDigits[iD1] + strDigits[iD2]; + } + + /** + * 转换字节数组为16进制字串 + * + * @param bByte + * @return + */ + private static String byteToString(byte[] bByte) { + StringBuffer sBuffer = new StringBuffer(); + for (int i = 0; i < bByte.length; i++) { + sBuffer.append(byteToArrayString(bByte[i])); + } + return sBuffer.toString(); + } + + /** + * MD5加密 + * + * @param str 待加密的字符串 + * @return + */ + public static String GetMD5Code(String str) { + String result = null; + try { + result = new String(str); + MessageDigest md = MessageDigest.getInstance("MD5"); + result = byteToString(md.digest(str.getBytes())); + } catch (NoSuchAlgorithmException ex) { + ex.printStackTrace(); + } + return result; + } + + /** + * MD5加密 + * + * @param str 待加密的字符串 + * @param lowerCase 大小写 true:不区分大小写 + * @return + */ + public static String GetMD5Code(String str, boolean lowerCase) { + String result = null; + try { + result = new String(str); + MessageDigest md = MessageDigest.getInstance("MD5"); + result = byteToString(md.digest(str.getBytes())); + if (lowerCase) { + result = result.toLowerCase(); + } + } catch (NoSuchAlgorithmException ex) { + ex.printStackTrace(); + } + return result; + } +} \ No newline at end of file diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/utils/wx/wecom/AesException.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/utils/wx/wecom/AesException.java new file mode 100644 index 0000000..5560ae5 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/utils/wx/wecom/AesException.java @@ -0,0 +1,59 @@ +package com.ruoyi.utils.wx.wecom; + +@SuppressWarnings("serial") +public class AesException extends Exception { + + public final static int OK = 0; + public final static int ValidateSignatureError = -40001; + public final static int ParseXmlError = -40002; + public final static int ComputeSignatureError = -40003; + public final static int IllegalAesKey = -40004; + public final static int ValidateCorpidError = -40005; + public final static int EncryptAESError = -40006; + public final static int DecryptAESError = -40007; + public final static int IllegalBuffer = -40008; + //public final static int EncodeBase64Error = -40009; + //public final static int DecodeBase64Error = -40010; + //public final static int GenReturnXmlError = -40011; + + private int code; + + private static String getMessage(int code) { + switch (code) { + case ValidateSignatureError: + return "签名验证错误"; + case ParseXmlError: + return "xml解析失败"; + case ComputeSignatureError: + return "sha加密生成签名失败"; + case IllegalAesKey: + return "SymmetricKey非法"; + case ValidateCorpidError: + return "corpid校验失败"; + case EncryptAESError: + return "aes加密失败"; + case DecryptAESError: + return "aes解密失败"; + case IllegalBuffer: + return "解密后得到的buffer非法"; +// case EncodeBase64Error: +// return "base64加密错误"; +// case DecodeBase64Error: +// return "base64解密错误"; +// case GenReturnXmlError: +// return "xml生成失败"; + default: + return null; + } + } + + public int getCode() { + return code; + } + + AesException(int code) { + super(getMessage(code)); + this.code = code; + } + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/utils/wx/wecom/ByteGroup.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/utils/wx/wecom/ByteGroup.java new file mode 100644 index 0000000..f9b5bc6 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/utils/wx/wecom/ByteGroup.java @@ -0,0 +1,26 @@ +package com.ruoyi.utils.wx.wecom; + +import java.util.ArrayList; + +class ByteGroup { + ArrayList byteContainer = new ArrayList(); + + public byte[] toBytes() { + byte[] bytes = new byte[byteContainer.size()]; + for (int i = 0; i < byteContainer.size(); i++) { + bytes[i] = byteContainer.get(i); + } + return bytes; + } + + public ByteGroup addBytes(byte[] bytes) { + for (byte b : bytes) { + byteContainer.add(b); + } + return this; + } + + public int size() { + return byteContainer.size(); + } +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/utils/wx/wecom/ConstantUtil.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/utils/wx/wecom/ConstantUtil.java new file mode 100644 index 0000000..d441585 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/utils/wx/wecom/ConstantUtil.java @@ -0,0 +1,49 @@ +package com.ruoyi.utils.wx.wecom; + +import org.dom4j.Document; +import org.dom4j.Element; +import org.dom4j.io.SAXReader; + +import java.io.StringReader; +import java.util.Iterator; +import java.util.Map; + + +public class ConstantUtil { + /** + * 将xml转换为Map。 支持xml标签多层嵌套,并以"."分隔多级标签(不包括根节点)。 不支持XML标签重复时的情况 + * + * @param xml + * @param map + * @return + */ + public static Map parseXmlToMap(String xml, Map map) { + try { + SAXReader reader = new SAXReader(); + Document doc = reader.read(new StringReader(xml)); + Element root = doc.getRootElement(); + String path = ""; + if (map.containsKey(root.getName().trim())) { + path = map.get(root.getName().trim()); + map.remove(root.getName().trim()); + } + for (Iterator i = root.elementIterator(); i.hasNext();) { + Element element = (Element) i.next(); + if (element.isTextOnly()) { + if (path.length() > 0) { + map.put(path + element.getName().trim(), element.getTextTrim()); + } else { + map.put(element.getName().trim(), element.getTextTrim()); + } + } else { + map.put(element.getName().trim(), path+ element.getName().trim() + "."); + parseXmlToMap(element.asXML(), map); + } + } + } catch (Exception e) { + e.printStackTrace(); + } + return map; + } +} + diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/utils/wx/wecom/PKCS7Encoder.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/utils/wx/wecom/PKCS7Encoder.java new file mode 100644 index 0000000..e88d098 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/utils/wx/wecom/PKCS7Encoder.java @@ -0,0 +1,67 @@ +/** + * 对企业微信发送给企业后台的消息加解密示例代码. + * + * @copyright Copyright (c) 1998-2014 Tencent Inc. + */ + +// ------------------------------------------------------------------------ + +package com.ruoyi.utils.wx.wecom; + +import java.nio.charset.Charset; +import java.util.Arrays; + +/** + * 提供基于PKCS7算法的加解密接口. + */ +class PKCS7Encoder { + static Charset CHARSET = Charset.forName("utf-8"); + static int BLOCK_SIZE = 32; + + /** + * 获得对明文进行补位填充的字节. + * + * @param count 需要进行填充补位操作的明文字节个数 + * @return 补齐用的字节数组 + */ + static byte[] encode(int count) { + // 计算需要填充的位数 + int amountToPad = BLOCK_SIZE - (count % BLOCK_SIZE); + if (amountToPad == 0) { + amountToPad = BLOCK_SIZE; + } + // 获得补位所用的字符 + char padChr = chr(amountToPad); + String tmp = new String(); + for (int index = 0; index < amountToPad; index++) { + tmp += padChr; + } + return tmp.getBytes(CHARSET); + } + + /** + * 删除解密后明文的补位字符 + * + * @param decrypted 解密后的明文 + * @return 删除补位字符后的明文 + */ + static byte[] decode(byte[] decrypted) { + int pad = (int) decrypted[decrypted.length - 1]; + if (pad < 1 || pad > 32) { + pad = 0; + } + return Arrays.copyOfRange(decrypted, 0, decrypted.length - pad); + } + + /** + * 将数字转化成ASCII码对应的字符,用于对明文进行补码 + * + * @param a 需要转化的数字 + * @return 转化得到的字符 + */ + static char chr(int a) { + byte target = (byte) (a & 0xFF); + return (char) target; + } + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/utils/wx/wecom/SHA1.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/utils/wx/wecom/SHA1.java new file mode 100644 index 0000000..045abb7 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/utils/wx/wecom/SHA1.java @@ -0,0 +1,61 @@ +/** + * 对企业微信发送给企业后台的消息加解密示例代码. + * + * @copyright Copyright (c) 1998-2014 Tencent Inc. + */ + +// ------------------------------------------------------------------------ + +package com.ruoyi.utils.wx.wecom; + +import java.security.MessageDigest; +import java.util.Arrays; + +/** + * SHA1 class + * + * 计算消息签名接口. + */ +class SHA1 { + + /** + * 用SHA1算法生成安全签名 + * @param token 票据 + * @param timestamp 时间戳 + * @param nonce 随机字符串 + * @param encrypt 密文 + * @return 安全签名 + * @throws AesException + */ + public static String getSHA1(String token, String timestamp, String nonce, String encrypt) throws AesException + { + try { + String[] array = new String[] { token, timestamp, nonce, encrypt }; + StringBuffer sb = new StringBuffer(); + // 字符串排序 + Arrays.sort(array); + for (int i = 0; i < 4; i++) { + sb.append(array[i]); + } + String str = sb.toString(); + // SHA1签名生成 + MessageDigest md = MessageDigest.getInstance("SHA-1"); + md.update(str.getBytes()); + byte[] digest = md.digest(); + + StringBuffer hexstr = new StringBuffer(); + String shaHex = ""; + for (int i = 0; i < digest.length; i++) { + shaHex = Integer.toHexString(digest[i] & 0xFF); + if (shaHex.length() < 2) { + hexstr.append(0); + } + hexstr.append(shaHex); + } + return hexstr.toString(); + } catch (Exception e) { + e.printStackTrace(); + throw new AesException(AesException.ComputeSignatureError); + } + } +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/utils/wx/wecom/WXBizMsgCrypt.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/utils/wx/wecom/WXBizMsgCrypt.java new file mode 100644 index 0000000..13920dc --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/utils/wx/wecom/WXBizMsgCrypt.java @@ -0,0 +1,288 @@ +/** + * 对企业微信发送给企业后台的消息加解密示例代码. + * + * @copyright Copyright (c) 1998-2014 Tencent Inc. + */ + +// ------------------------------------------------------------------------ + +/** + * 针对org.apache.commons.codec.binary.Base64, + * 需要导入架包commons-codec-1.9(或commons-codec-1.8等其他版本) + * 官方下载地址:http://commons.apache.org/proper/commons-codec/download_codec.cgi + */ +package com.ruoyi.utils.wx.wecom; + +import org.apache.commons.codec.binary.Base64; + +import javax.crypto.Cipher; +import javax.crypto.spec.IvParameterSpec; +import javax.crypto.spec.SecretKeySpec; +import java.nio.charset.Charset; +import java.util.Arrays; +import java.util.Random; + +/** + * 提供接收和推送给企业微信消息的加解密接口(UTF8编码的字符串). + *
    + *
  1. 第三方回复加密消息给企业微信
  2. + *
  3. 第三方收到企业微信发送的消息,验证消息的安全性,并对消息进行解密。
  4. + *
+ * 说明:异常java.security.InvalidKeyException:illegal Key Size的解决方案 + *
    + *
  1. 在官方网站下载JCE无限制权限策略文件(JDK7的下载地址: + * http://www.oracle.com/technetwork/java/javase/downloads/jce-7-download-432124.html
  2. + *
  3. 下载后解压,可以看到local_policy.jar和US_export_policy.jar以及readme.txt
  4. + *
  5. 如果安装了JRE,将两个jar文件放到%JRE_HOME%\lib\security目录下覆盖原来的文件
  6. + *
  7. 如果安装了JDK,将两个jar文件放到%JDK_HOME%\jre\lib\security目录下覆盖原来文件
  8. + *
+ */ +public class WXBizMsgCrypt { + static Charset CHARSET = Charset.forName("utf-8"); + Base64 base64 = new Base64(); + byte[] aesKey; + String token; + String receiveid; + + /** + * 构造函数 + * @param token 企业微信后台,开发者设置的token + * @param encodingAesKey 企业微信后台,开发者设置的EncodingAESKey + * @param receiveid, 不同场景含义不同,详见文档 + * + * @throws AesException 执行失败,请查看该异常的错误码和具体的错误信息 + */ + public WXBizMsgCrypt(String token, String encodingAesKey, String receiveid) throws AesException { + if (encodingAesKey.length() != 43) { + throw new AesException(AesException.IllegalAesKey); + } + + this.token = token; + this.receiveid = receiveid; + aesKey = Base64.decodeBase64(encodingAesKey + "="); + } + + // 生成4个字节的网络字节序 + byte[] getNetworkBytesOrder(int sourceNumber) { + byte[] orderBytes = new byte[4]; + orderBytes[3] = (byte) (sourceNumber & 0xFF); + orderBytes[2] = (byte) (sourceNumber >> 8 & 0xFF); + orderBytes[1] = (byte) (sourceNumber >> 16 & 0xFF); + orderBytes[0] = (byte) (sourceNumber >> 24 & 0xFF); + return orderBytes; + } + + // 还原4个字节的网络字节序 + int recoverNetworkBytesOrder(byte[] orderBytes) { + int sourceNumber = 0; + for (int i = 0; i < 4; i++) { + sourceNumber <<= 8; + sourceNumber |= orderBytes[i] & 0xff; + } + return sourceNumber; + } + + // 随机生成16位字符串 + String getRandomStr() { + String base = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; + Random random = new Random(); + StringBuffer sb = new StringBuffer(); + for (int i = 0; i < 16; i++) { + int number = random.nextInt(base.length()); + sb.append(base.charAt(number)); + } + return sb.toString(); + } + + /** + * 对明文进行加密. + * + * @param text 需要加密的明文 + * @return 加密后base64编码的字符串 + * @throws AesException aes加密失败 + */ + String encrypt(String randomStr, String text) throws AesException { + ByteGroup byteCollector = new ByteGroup(); + byte[] randomStrBytes = randomStr.getBytes(CHARSET); + byte[] textBytes = text.getBytes(CHARSET); + byte[] networkBytesOrder = getNetworkBytesOrder(textBytes.length); + byte[] receiveidBytes = receiveid.getBytes(CHARSET); + + // randomStr + networkBytesOrder + text + receiveid + byteCollector.addBytes(randomStrBytes); + byteCollector.addBytes(networkBytesOrder); + byteCollector.addBytes(textBytes); + byteCollector.addBytes(receiveidBytes); + + // ... + pad: 使用自定义的填充方式对明文进行补位填充 + byte[] padBytes = PKCS7Encoder.encode(byteCollector.size()); + byteCollector.addBytes(padBytes); + + // 获得最终的字节流, 未加密 + byte[] unencrypted = byteCollector.toBytes(); + + try { + // 设置加密模式为AES的CBC模式 + Cipher cipher = Cipher.getInstance("AES/CBC/NoPadding"); + SecretKeySpec keySpec = new SecretKeySpec(aesKey, "AES"); + IvParameterSpec iv = new IvParameterSpec(aesKey, 0, 16); + cipher.init(Cipher.ENCRYPT_MODE, keySpec, iv); + + // 加密 + byte[] encrypted = cipher.doFinal(unencrypted); + + // 使用BASE64对加密后的字符串进行编码 + String base64Encrypted = base64.encodeToString(encrypted); + + return base64Encrypted; + } catch (Exception e) { + e.printStackTrace(); + throw new AesException(AesException.EncryptAESError); + } + } + + /** + * 对密文进行解密. + * + * @param text 需要解密的密文 + * @return 解密得到的明文 + * @throws AesException aes解密失败 + */ + String decrypt(String text) throws AesException { + byte[] original; + try { + // 设置解密模式为AES的CBC模式 + Cipher cipher = Cipher.getInstance("AES/CBC/NoPadding"); + SecretKeySpec key_spec = new SecretKeySpec(aesKey, "AES"); + IvParameterSpec iv = new IvParameterSpec(Arrays.copyOfRange(aesKey, 0, 16)); + cipher.init(Cipher.DECRYPT_MODE, key_spec, iv); + + // 使用BASE64对密文进行解码 + byte[] encrypted = Base64.decodeBase64(text); + + // 解密 + original = cipher.doFinal(encrypted); + } catch (Exception e) { + e.printStackTrace(); + throw new AesException(AesException.DecryptAESError); + } + + String xmlContent, from_receiveid; + try { + // 去除补位字符 + byte[] bytes = PKCS7Encoder.decode(original); + + // 分离16位随机字符串,网络字节序和receiveid + byte[] networkOrder = Arrays.copyOfRange(bytes, 16, 20); + + int xmlLength = recoverNetworkBytesOrder(networkOrder); + + xmlContent = new String(Arrays.copyOfRange(bytes, 20, 20 + xmlLength), CHARSET); + from_receiveid = new String(Arrays.copyOfRange(bytes, 20 + xmlLength, bytes.length), + CHARSET); + } catch (Exception e) { + e.printStackTrace(); + throw new AesException(AesException.IllegalBuffer); + } + + // receiveid不相同的情况 + if (!from_receiveid.equals(receiveid)) { + throw new AesException(AesException.ValidateCorpidError); + } + return xmlContent; + + } + + /** + * 将企业微信回复用户的消息加密打包. + *
    + *
  1. 对要发送的消息进行AES-CBC加密
  2. + *
  3. 生成安全签名
  4. + *
  5. 将消息密文和安全签名打包成xml格式
  6. + *
+ * + * @param replyMsg 企业微信待回复用户的消息,xml格式的字符串 + * @param timeStamp 时间戳,可以自己生成,也可以用URL参数的timestamp + * @param nonce 随机串,可以自己生成,也可以用URL参数的nonce + * + * @return 加密后的可以直接回复用户的密文,包括msg_signature, timestamp, nonce, encrypt的xml格式的字符串 + * @throws AesException 执行失败,请查看该异常的错误码和具体的错误信息 + */ + public String EncryptMsg(String replyMsg, String timeStamp, String nonce) throws AesException { + // 加密 + String encrypt = encrypt(getRandomStr(), replyMsg); + + // 生成安全签名 + if (timeStamp == "") { + timeStamp = Long.toString(System.currentTimeMillis()); + } + + String signature = SHA1.getSHA1(token, timeStamp, nonce, encrypt); + + // System.out.println("发送给平台的签名是: " + signature[1].toString()); + // 生成发送的xml + String result = XMLParse.generate(encrypt, signature, timeStamp, nonce); + return result; + } + + /** + * 检验消息的真实性,并且获取解密后的明文. + *
    + *
  1. 利用收到的密文生成安全签名,进行签名验证
  2. + *
  3. 若验证通过,则提取xml中的加密消息
  4. + *
  5. 对消息进行解密
  6. + *
+ * + * @param msgSignature 签名串,对应URL参数的msg_signature + * @param timeStamp 时间戳,对应URL参数的timestamp + * @param nonce 随机串,对应URL参数的nonce + * @param postData 密文,对应POST请求的数据 + * + * @return 解密后的原文 + * @throws AesException 执行失败,请查看该异常的错误码和具体的错误信息 + */ + public String DecryptMsg(String msgSignature, String timeStamp, String nonce, String postData) + throws AesException { + + // 密钥,公众账号的app secret + // 提取密文 + Object[] encrypt = XMLParse.extract(postData); + + // 验证安全签名 + String signature = SHA1.getSHA1(token, timeStamp, nonce, encrypt[1].toString()); + + // 和URL中的签名比较是否相等 + // System.out.println("第三方收到URL中的签名:" + msg_sign); + // System.out.println("第三方校验签名:" + signature); + if (!signature.equals(msgSignature)) { + throw new AesException(AesException.ValidateSignatureError); + } + + // 解密 + String result = decrypt(encrypt[1].toString()); + return result; + } + + /** + * 验证URL + * @param msgSignature 签名串,对应URL参数的msg_signature + * @param timeStamp 时间戳,对应URL参数的timestamp + * @param nonce 随机串,对应URL参数的nonce + * @param echoStr 随机串,对应URL参数的echostr + * + * @return 解密之后的echostr + * @throws AesException 执行失败,请查看该异常的错误码和具体的错误信息 + */ + public String VerifyURL(String msgSignature, String timeStamp, String nonce, String echoStr) + throws AesException { + String signature = SHA1.getSHA1(token, timeStamp, nonce, echoStr); + + if (!signature.equals(msgSignature)) { + throw new AesException(AesException.ValidateSignatureError); + } + + String result = decrypt(echoStr); + return result; + } + +} \ No newline at end of file diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/utils/wx/wecom/WecomUtil.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/utils/wx/wecom/WecomUtil.java new file mode 100644 index 0000000..17cd333 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/utils/wx/wecom/WecomUtil.java @@ -0,0 +1,154 @@ +package com.ruoyi.utils.wx.wecom; + +import cn.hutool.http.HttpRequest; +import cn.hutool.http.HttpUtil; +import cn.hutool.http.Method; +import com.alibaba.fastjson.JSONObject; +import com.ruoyi.common.core.redis.RedisService; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.redis.core.RedisTemplate; +import org.springframework.stereotype.Component; + +import java.util.HashMap; +import java.util.Map; +import java.util.concurrent.TimeUnit; + +@Component +@Slf4j +public class WecomUtil { + + + /** + * 获取access_token的url + */ + private final String access_token_url = "https://qyapi.weixin.qq.com/cgi-bin/gettoken"; + + /** + * 根据手机号获取userid的url + */ + private final String userid_by_mobile_url = "https://qyapi.weixin.qq.com/cgi-bin/user/getuserid"; + + /** + * 发送消息的url + */ + private final String send_message_url = "https://qyapi.weixin.qq.com/cgi-bin/message/send"; + + private final String corpid = "ww45fb4d72c735ee1d"; + + private final String corpsecret = "5x3F-AHQMO9VwpXH9_lOUX8887sqb1fUx0-5goN6U_Y"; + + @Autowired + private RedisTemplate redisTemplate; + + /** + * 获取access_token + * + * @return + */ + public String getToken() { + // 参数 + Map paramMap = new HashMap<>(); + paramMap.put("corpid", corpid); + paramMap.put("corpsecret", corpsecret); + String result = HttpUtil.createRequest(Method.GET,access_token_url) + .form(paramMap).execute().body(); + System.err.println(result); + + JSONObject jsonObject = JSONObject.parseObject(result); + //服务断了status会有值 + Integer errcode = (Integer) jsonObject.get("errcode"); + if (errcode == 0) { + String access_token = (String) jsonObject.get("access_token"); + + // 设置过期时间 + redisTemplate.opsForValue().set("wecom_access_token", access_token, 5400, TimeUnit.SECONDS); + + return access_token; + } + return ""; + } + + /** + * 根据手机号获取userid + * @param mobile + * @return + */ + public String getUserid(String mobile){ + //根据手机号获取userid + Map map = new HashMap(); + map.put("mobile", mobile); + + //获取access_token + String token = getAccessToken(); + + String body = HttpUtil.createRequest(Method.POST,userid_by_mobile_url) + .form("access_token",token).form(map) + .header("Content-Type", "application/json;charset=utf-8") + .body(JSONObject.toJSONString(map)) + .execute().body(); + + System.out.println(body); + + Map resultMap = JSONObject.parseObject(body, Map.class); + + if (resultMap.get("errcode") != null && resultMap.get("errcode").equals(0)){ + return resultMap.get("userid").toString(); + } + + return null; + + } + + private String getAccessToken(){ + + //key + String key = "wecom_access_token"; + + String token = ""; + + //获取access_token + if (redisTemplate.hasKey(key)){ + token = redisTemplate.opsForValue().get(key).toString(); + }else { + token = getToken(); + } + + return token; + } + + /** + * 发送文本信息 + * @param content + * @return + */ + public String sendTextMessage(String content,String userid){ + Map map = new HashMap(); + map.put("touser", userid); + map.put("toparty", "@all"); + map.put("totag", "@all"); + map.put("msgtype", "text"); + map.put("agentid", "1000003"); + Map map1 = new HashMap(); + map1.put("content", content); + map.put("text", map1); + String s = JSONObject.toJSONString(map); + + //获取access_token + String token = getAccessToken(); + + String result = HttpUtil.createRequest(Method.POST,send_message_url) + .form("access_token",token) + .header("Content-Type", "application/json;charset=utf-8") + .body(s).execute().body(); + + System.err.println(result); + JSONObject jsonObject = JSONObject.parseObject(result); + Integer errcode = (Integer) jsonObject.get("errcode"); + if (errcode == 0) { + log.info("用户:{} 发送消息成功",userid); + } + return null; + + } +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/utils/wx/wecom/XMLParse.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/utils/wx/wecom/XMLParse.java new file mode 100644 index 0000000..54c4654 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/utils/wx/wecom/XMLParse.java @@ -0,0 +1,103 @@ +/** + * 对企业微信发送给企业后台的消息加解密示例代码. + * + * @copyright Copyright (c) 1998-2014 Tencent Inc. + */ + +// ------------------------------------------------------------------------ + +package com.ruoyi.utils.wx.wecom; + +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.w3c.dom.NodeList; +import org.xml.sax.InputSource; + +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; +import java.io.StringReader; + +/** + * XMLParse class + * + * 提供提取消息格式中的密文及生成回复消息格式的接口. + */ +class XMLParse { + + /** + * 提取出xml数据包中的加密消息 + * @param xmltext 待提取的xml字符串 + * @return 提取出的加密消息字符串 + * @throws AesException + */ + public static Object[] extract(String xmltext) throws AesException { + Object[] result = new Object[3]; + try { + DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); + + String FEATURE = null; + // This is the PRIMARY defense. If DTDs (doctypes) are disallowed, almost all XML entity attacks are prevented + // Xerces 2 only - http://xerces.apache.org/xerces2-j/features.html#disallow-doctype-decl + FEATURE = "http://apache.org/xml/features/disallow-doctype-decl"; + dbf.setFeature(FEATURE, true); + + // If you can't completely disable DTDs, then at least do the following: + // Xerces 1 - http://xerces.apache.org/xerces-j/features.html#external-general-entities + // Xerces 2 - http://xerces.apache.org/xerces2-j/features.html#external-general-entities + // JDK7+ - http://xml.org/sax/features/external-general-entities + FEATURE = "http://xml.org/sax/features/external-general-entities"; + dbf.setFeature(FEATURE, false); + + // Xerces 1 - http://xerces.apache.org/xerces-j/features.html#external-parameter-entities + // Xerces 2 - http://xerces.apache.org/xerces2-j/features.html#external-parameter-entities + // JDK7+ - http://xml.org/sax/features/external-parameter-entities + FEATURE = "http://xml.org/sax/features/external-parameter-entities"; + dbf.setFeature(FEATURE, false); + + // Disable external DTDs as well + FEATURE = "http://apache.org/xml/features/nonvalidating/load-external-dtd"; + dbf.setFeature(FEATURE, false); + + // and these as well, per Timothy Morgan's 2014 paper: "XML Schema, DTD, and Entity Attacks" + dbf.setXIncludeAware(false); + dbf.setExpandEntityReferences(false); + + // And, per Timothy Morgan: "If for some reason support for inline DOCTYPEs are a requirement, then + // ensure the entity settings are disabled (as shown above) and beware that SSRF attacks + // (http://cwe.mitre.org/data/definitions/918.html) and denial + // of service attacks (such as billion laughs or decompression bombs via "jar:") are a risk." + + // remaining parser logic + DocumentBuilder db = dbf.newDocumentBuilder(); + StringReader sr = new StringReader(xmltext); + InputSource is = new InputSource(sr); + Document document = db.parse(is); + + Element root = document.getDocumentElement(); + NodeList nodelist1 = root.getElementsByTagName("Encrypt"); + result[0] = 0; + result[1] = nodelist1.item(0).getTextContent(); + return result; + } catch (Exception e) { + e.printStackTrace(); + throw new AesException(AesException.ParseXmlError); + } + } + + /** + * 生成xml消息 + * @param encrypt 加密后的消息密文 + * @param signature 安全签名 + * @param timestamp 时间戳 + * @param nonce 随机字符串 + * @return 生成的xml字符串 + */ + public static String generate(String encrypt, String signature, String timestamp, String nonce) { + + String format = "\n" + "\n" + + "\n" + + "%3$s\n" + "\n" + ""; + return String.format(format, encrypt, signature, timestamp, nonce); + + } +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/vo/BodyIdReq.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/vo/BodyIdReq.java new file mode 100644 index 0000000..7083914 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/vo/BodyIdReq.java @@ -0,0 +1,22 @@ +package com.ruoyi.vo; + +import lombok.Data; +import lombok.experimental.Accessors; + +import javax.validation.constraints.NotNull; + +/** + * @Author liwenlong + */ +@Data +@Accessors(chain = true) +public class BodyIdReq { + + @NotNull(message = "id不能为空") + private Long id; + + /** + * 是否增加浏览数 1不增加 2 加 + */ + private Integer isAddBrowseNum ; +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/vo/PageBasic.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/vo/PageBasic.java new file mode 100644 index 0000000..9c56421 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/vo/PageBasic.java @@ -0,0 +1,43 @@ +package com.ruoyi.vo; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import javax.validation.constraints.NotNull; + +/** + * @Author 刘耀 + * @Date 2022/1/14 9:17 + */ +@Data +public class PageBasic { + + /** + * @mock 1 + */ + @NotNull(message = "pageNo分页参数不能为空") + @ApiModelProperty(value = "分页参数", required = true) + private Integer pageNo; + + + /** + * @mock 10 + */ + @NotNull(message = "pageSize分页参数不能为空") + @ApiModelProperty(value = "分页参数", required = true) + private Integer pageSize; + +// +// /** +// * @mock createTime +// */ +// @ApiModelProperty(value = "排序参数", required = true) +// private String orderByColumn; +// +// +// /** +// * @mock desc +// */ +// @ApiModelProperty(value = "排序的方向 desc 或者 asc", required = true) +// private String isAsc; +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/vo/PayVo.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/vo/PayVo.java new file mode 100644 index 0000000..af912f2 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/vo/PayVo.java @@ -0,0 +1,28 @@ +package com.ruoyi.vo; + +import io.swagger.annotations.ApiModelProperty; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.math.BigDecimal; + +/** + * @author a + * @date 2024/1/24 10:45 + */ +@Data +@AllArgsConstructor +@NoArgsConstructor +public class PayVo { + + @ApiModelProperty(value = "支付金额") + private BigDecimal price = BigDecimal.ZERO; + + @ApiModelProperty(value = "支付积分") + private BigDecimal integral = BigDecimal.ZERO; + + @ApiModelProperty(value = "最大使用赠送金额") + private BigDecimal maxGivePrice = BigDecimal.ZERO; + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/vo/RyController.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/vo/RyController.java new file mode 100644 index 0000000..f17b0e1 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/vo/RyController.java @@ -0,0 +1,183 @@ +package com.ruoyi.vo; + +import cn.hutool.core.util.StrUtil; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.github.pagehelper.PageHelper; +import com.github.pagehelper.PageInfo; +import com.ruoyi.code.PublicCommon; +import com.ruoyi.code.Token; +import com.ruoyi.common.constant.HttpStatus; +import com.ruoyi.common.core.page.PageDomain; +import com.ruoyi.common.core.page.TableDataInfo; +import com.ruoyi.common.core.page.TableSupport; +import com.ruoyi.common.utils.StringUtils; +import com.ruoyi.common.utils.sql.SqlUtil; +import com.ruoyi.enums.user.UserEnums; +import com.ruoyi.frequency.customer.service.CustomerService; +import com.ruoyi.frequency.store.entity.Store; +import com.ruoyi.frequency.store.service.StoreService; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.redis.core.StringRedisTemplate; +import org.springframework.web.bind.annotation.RestController; + +import javax.annotation.Resource; +import javax.servlet.http.HttpServletRequest; +import java.util.List; + +@Slf4j +@RestController +public class RyController { + + + @Autowired + private StringRedisTemplate redisTemplate; + + @Autowired + private HttpServletRequest request; + + @Autowired + private CustomerService customerService; + + @Resource + private StoreService storeService; + + + /** + * 获取用户Id + * + * @return + */ + protected UserVo getUserVo() { + //获取当前登录用户 + String token = request.getHeader("token"); + if (StrUtil.isBlank(token)) { + return new UserVo(-1,-1L); + } + String tokenStr = redisTemplate.opsForValue().get(token); + if (StrUtil.isBlank(tokenStr)) { + return new UserVo(-1,-1L); + } + + //获取token前缀 + String prefix = token.split("_")[0]; + + //用户类型 + Integer userType = UserEnums.valueOf(prefix).getCode(); + + //用户id + Long userId = Long.valueOf(tokenStr); + + return new UserVo(userType,userId); + } + + /** + * @param convertUserType 当前用户类型转换为 convertUserType类型 + * @return + */ + protected UserVo getUserVo(Integer convertUserType) { + UserVo userVo = new UserVo(); + //获取当前登录用户 + String token = request.getHeader("token"); + if (StrUtil.isEmpty(token)) { + userVo.setUserId(-1L); + userVo.setUserType(-1); + return userVo; + } + + String userId = redisTemplate.opsForValue().get(token); + if (StrUtil.isBlank(userId)) { + userVo.setUserId(-1L); + userVo.setUserType(-1); + return userVo; + } + + if (!token.startsWith(Token.customer) && !token.startsWith(Token.store)) { + userVo.setUserType(-1); + } else { + userVo.setUserType(convertUserType); + } + userVo.setUserId(userId(convertUserType, userId, token)); + + return userVo; + } + + /** + * 获取用户id + * + * @param convertUserType + * @param userId + * @param token + * @return + */ + private Long userId(Integer convertUserType, String userId, String token) { + switch (convertUserType) { + case 1: + //当前登入token为商家,转换为 用户id + if (token.startsWith(Token.store)) { + Store store = storeService.getById(Long.valueOf(userId)); + if (store != null) { + return store.getCustomerId(); + } + } + break; + case 2: + //当前登入token为商家,转换为 用户id + if (token.startsWith(Token.customer)) { + Store store = storeService.getOne(new QueryWrapper().lambda() + .eq(Store::getCustomerId, Long.valueOf(userId)) + .ne(Store::getDelFlag, PublicCommon.删除)); + if (store != null) { + return store.getId(); + } + } + break; + default: + throw new IllegalStateException("Unexpected value: " + convertUserType); + } + return Long.valueOf(userId); + } + + + /** + * 设置请求分页数据 + */ + protected void startPage() + { + PageDomain pageDomain = TableSupport.buildPageRequest(); + Integer pageNum = pageDomain.getPageNum(); + Integer pageSize = pageDomain.getPageSize(); + if (StringUtils.isNotNull(pageNum) && StringUtils.isNotNull(pageSize)) + { + String orderBy = SqlUtil.escapeOrderBySql(pageDomain.getOrderBy()); + Boolean reasonable = pageDomain.getReasonable(); + PageHelper.startPage(pageNum, pageSize, orderBy).setReasonable(reasonable); + } + } + + + /** + * 响应请求分页数据 + */ + @SuppressWarnings({ "rawtypes", "unchecked" }) + protected TableDataInfo getDataTable(List list) + { + TableDataInfo rspData = new TableDataInfo(); + rspData.setCode(HttpStatus.SUCCESS); + rspData.setMsg("查询成功"); + rspData.setRows(list); + rspData.setTotal(Integer.valueOf(new PageInfo(list).getTotal() + "")); + return rspData; + } + protected TableDataInfo getDataTable(Page page) + { + TableDataInfo rspData = new TableDataInfo(); + rspData.setCode(HttpStatus.SUCCESS); + rspData.setMsg("查询成功"); + rspData.setRows(page.getRecords()); + rspData.setTotal(Integer.valueOf(new PageInfo(page.getRecords()).getTotal() + "")); + return rspData; + } + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/vo/UserInfo.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/vo/UserInfo.java new file mode 100644 index 0000000..fec0d46 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/vo/UserInfo.java @@ -0,0 +1,109 @@ + +package com.ruoyi.vo; + +import com.fasterxml.jackson.annotation.JsonFormat; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.math.BigDecimal; +import java.util.Date; + +/** + * 用户信息 + * @author liwenlong + * @date 2022/1/14 11:07 + */ +@Data +public class UserInfo extends UserVo { + + + @ApiModelProperty(value = "用户昵称") + private String nickname; + + @ApiModelProperty(value = "昵称") + private String name; + + @ApiModelProperty(value = "用户头像") + private String avatar; + + @ApiModelProperty(value = "用户手机号") + private String mobile; + + @ApiModelProperty(value = "是否关注 1 没有 2关注") + private Integer isFollow; + + @ApiModelProperty(value = "是否屏蔽 1 没有 2 屏蔽") + private Integer isShield; + + @ApiModelProperty(value = "是否拉黑 1 没有 2 拉黑") + private Integer isBlock; + + @ApiModelProperty(value = "是否高端认证 1 没有 2认证") + private Integer ifHighend; + + @ApiModelProperty(value = "是否普通认证 0未提交认证 1 认证待审核 2认证 3认证失败") + private Integer isAuth; + + @ApiModelProperty(value = "等级图标") + private String icon; + + @ApiModelProperty(value = "等级名称") + private String levelName; + + @ApiModelProperty(value = "镶边类型 1 不镶边 2 镶银边 3 镶金边") + private Integer edgePipingType; + + + @ApiModelProperty(value = "区域") + private String area; + + @ApiModelProperty(value = "入行时间") + @JsonFormat(pattern = "yyyy") + private Date enterDate; + + @ApiModelProperty(value = "擅长领域") + private String specialityArea; + + @ApiModelProperty(value = "工种") + private String branchWork; + + @ApiModelProperty(value = "企业微信二维码") + private String wecomQrcode; + + @ApiModelProperty(value = "是否认证酷家乐 0未提交认证 1 认证待审核 2认证 3认证失败 ") + private Integer isKujialeAuth; + + @ApiModelProperty(value = "等级名称") + private String sex; + + @ApiModelProperty(value = "是否是dd认证 1不是 2是") + private Integer isDdAuth; + + @ApiModelProperty(value = "作品数") + private Integer worksNum; + + @ApiModelProperty(value = "保证金额") + private BigDecimal bondAmount; + + @ApiModelProperty(value = "评分") + private BigDecimal star; + + @ApiModelProperty(value = "在线状态;1:在线,2离线") + private Integer onlineStatus; + + @ApiModelProperty(value = "累计订单数量") + private Integer orderNum; + + @ApiModelProperty(value = "累计服务金额") + private BigDecimal orderAmount; + + @ApiModelProperty(value = "当月订单数量") + private Integer orderMonthNum; + + @ApiModelProperty(value = "动态数") + private Integer postNum; + + @ApiModelProperty(value = "粉丝数") + private Integer fansNum; + +} diff --git a/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/vo/UserVo.java b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/vo/UserVo.java new file mode 100644 index 0000000..3a12187 --- /dev/null +++ b/ruoyi-main/ruoyi-custom/src/main/java/com/ruoyi/vo/UserVo.java @@ -0,0 +1,47 @@ +package com.ruoyi.vo; + +import com.ruoyi.enums.user.UserEnums; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + * @author liwenlong + * @date 2022/1/14 11:07 + */ +@Data +public class UserVo { + + @ApiModelProperty(value = "用户类型 1 用户 对应枚举 UserEnums") + private Integer userType; + + @ApiModelProperty(value = "用户id") + private Long userId; + + public static UserVo customerUserVo(Long customerId) { + UserVo userVo = new UserVo(); + userVo.setUserType(UserEnums.customer.getCode()); + userVo.setUserId(customerId); + return userVo; + } + + public static UserVo storeUserVo(Long storeId) { + UserVo userVo = new UserVo(); + userVo.setUserType(UserEnums.store.getCode()); + userVo.setUserId(storeId); + return userVo; + } + + public UserVo() { + + } + + public UserVo(Integer userType, Long userId) { + this.userId = userId; + this.userType = userType; + } + + public UserVo(UserEnums userEnums,Long userId) { + this.userId = userId; + this.userType = userEnums.getCode(); + } +} diff --git a/ruoyi-main/ruoyi-message/pom.xml b/ruoyi-main/ruoyi-message/pom.xml new file mode 100644 index 0000000..1418621 --- /dev/null +++ b/ruoyi-main/ruoyi-message/pom.xml @@ -0,0 +1,36 @@ + + + 4.0.0 + + com.ruoyi + ruoyi-main + 3.7.0 + + + ruoyi-message + + + 8 + 8 + UTF-8 + + + + + com.ruoyi + ruoyi-custom + 3.7.0 + + + + + commons-codec + commons-codec + 1.16.0 + + + + + + diff --git a/ruoyi-main/ruoyi-message/src/main/java/com/ruoyi/message/controller/ApiGoeasyMessageController.java b/ruoyi-main/ruoyi-message/src/main/java/com/ruoyi/message/controller/ApiGoeasyMessageController.java new file mode 100644 index 0000000..588c04e --- /dev/null +++ b/ruoyi-main/ruoyi-message/src/main/java/com/ruoyi/message/controller/ApiGoeasyMessageController.java @@ -0,0 +1,155 @@ +package com.ruoyi.message.controller; + +import cn.hutool.core.date.DateUtil; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.ruoyi.controller.resp.GoeasyResult; +import com.ruoyi.enums.user.UserEnums; +import com.ruoyi.frequency.customer.entity.Customer; +import com.ruoyi.frequency.customer.mapper.CustomerMapper; +import com.ruoyi.frequency.store.entity.Store; +import com.ruoyi.frequency.store.mapper.StoreMapper; +import com.ruoyi.message.frequency.goeasymessage.entity.GoeasyMessage; +import com.ruoyi.message.frequency.goeasymessage.service.GoeasyMessageService; +import com.ruoyi.vo.RyController; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.web.bind.annotation.CrossOrigin; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import sun.misc.BASE64Encoder; + +import javax.crypto.Mac; +import javax.crypto.spec.SecretKeySpec; +import javax.servlet.http.HttpServletRequest; +import java.util.List; +import java.util.stream.Collectors; + + +/** + * goeasy消息 + * + * @author liwenlong + */ +@CrossOrigin +@RestController +@RequestMapping("/api/goeasy") +@Slf4j +@Api(tags = "goeasy消息") +public class ApiGoeasyMessageController extends RyController { + + @Autowired + private GoeasyMessageService goeasyMessageService; + + + @RequestMapping("/goeasyMessage") + @ApiOperation(value = "数据同步Webhook", notes = "数据同步Webhook") + public GoeasyResult goeasyMessage(HttpServletRequest request) { + log.info("进入goeasy历史消息通知"); + + String content = request.getParameter("content"); + System.out.println(content); + + if (content == null || "".equals(content)) { + return GoeasyResult.success(); + } + + //判断请求签名是否合法 + String goeasy_signature = request.getHeader("x-goeasy-signature"); + log.info("goeasy_signature:" + goeasy_signature); + String signature = goeasyWebhookSignature(secretKey, content); + log.info("signature:" + signature); + if (!signature.equals(goeasy_signature)) { + return GoeasyResult.success(); + } + + JSONArray jsonArray = JSONObject.parseArray(content); + System.out.println(jsonArray); + + List goeasyMessages = jsonArray.stream().filter(s -> { + JSONObject messageJson = JSONObject.parseObject(s.toString()); + return !messageJson.containsKey("channel"); + }).map(s -> { + JSONObject messageJson = JSONObject.parseObject(s.toString()); + GoeasyMessage goeasyMessage = new GoeasyMessage(); + //每条消息唯一标识,可用于去重操作 + goeasyMessage.setMessageId((String) messageJson.get("messageId")); + //消息类型 + goeasyMessage.setType((String) messageJson.get("type")); + //发送方userId + goeasyMessage.setSenderId((String) messageJson.get("senderId")); + //解析发送用户 + String[] sender = goeasyMessage.getSenderId().split("_"); + if (sender.length == 2) { + goeasyMessage.setSenderUserType(UserEnums.valueOf(sender[0]).getCode()); + goeasyMessage.setSenderUserId(Long.valueOf(sender[1])); + } + //接收方userId + goeasyMessage.setReceiverId((String) messageJson.get("receiverId")); + //解析接收用户 + String[] receiver = goeasyMessage.getReceiverId().split("_"); + if (receiver.length == 2) { + goeasyMessage.setReceiverUserType(UserEnums.valueOf(receiver[0]).getCode()); + goeasyMessage.setReceiverUserId(Long.valueOf(receiver[1])); + } + //消息体 + goeasyMessage.setPayload((String) messageJson.get("payload")); + //发送的时间,可用于排序 + goeasyMessage.setGoeasyTime(DateUtil.date((Long) messageJson.get("timestamp"))); + System.out.println(goeasyMessage); + + if (goeasyMessage.getSenderUserType().equals(UserEnums.customer.getCode())) { + Customer customer = customerMapper.selectById(goeasyMessage.getSenderUserId()); + if (customer != null) { + return goeasyMessage; + } + } else if (goeasyMessage.getSenderUserType().equals(UserEnums.store.getCode())) { + Store store = storeMapper.selectById(goeasyMessage.getSenderUserId()); + if (store != null) { + return goeasyMessage; + } + } + return null; + + }).collect(Collectors.toList()); + + goeasyMessageService.goeasyMessage(goeasyMessages); + + + log.info("goeasy历史消息通知结束"); + + return GoeasyResult.success(); + } + + + + @Autowired + private CustomerMapper customerMapper; + @Autowired + private StoreMapper storeMapper; + + + @Value("${push.goeasy.secretKey}") + private String secretKey; + + public String goeasyWebhookSignature(String secretKey, String content) { + try { + SecretKeySpec signinKey = new SecretKeySpec(secretKey.getBytes(), "HmacSHA1"); + Mac mac = Mac.getInstance("HmacSHA1"); + mac.init(signinKey); + byte[] rawHmac = mac.doFinal(content.getBytes("UTF8")); + + return new BASE64Encoder().encode(rawHmac); + } catch (Exception e) { + log.error("HMACSHA1 failed for key:{} and content:{}", secretKey, content, e); + return null; + } + } + + public static void main(String[] args) { + } + +} diff --git a/ruoyi-main/ruoyi-message/src/main/java/com/ruoyi/message/controller/ApiInteractionMessageController.java b/ruoyi-main/ruoyi-message/src/main/java/com/ruoyi/message/controller/ApiInteractionMessageController.java new file mode 100644 index 0000000..545c049 --- /dev/null +++ b/ruoyi-main/ruoyi-message/src/main/java/com/ruoyi/message/controller/ApiInteractionMessageController.java @@ -0,0 +1,46 @@ +package com.ruoyi.message.controller; + +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.ruoyi.annotations.UserLoginToken; +import com.ruoyi.common.page.PageResult; +import com.ruoyi.controller.req.MessageReadOrDeleteReq; +import com.ruoyi.message.controller.resp.InteractionMessagePageResp; +import com.ruoyi.message.frequency.interactionmessagerecord.service.InteractionMessageRecordService; +import com.ruoyi.response.ResponseData; +import com.ruoyi.vo.PageBasic; +import com.ruoyi.vo.RyController; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + + +/** + * 互动消息 + * @author liwenlong + * + */ +@CrossOrigin +@RestController +@RequestMapping("/api/message") +@Api(tags = "互动消息") +public class ApiInteractionMessageController extends RyController { + + @Autowired + private InteractionMessageRecordService interactionMessageRecordService; + + @UserLoginToken + @PostMapping("/interactionMessagePage") + @ApiOperation(value = "互动消息列表", notes = "互动消息列表") + public ResponseData>> interactionMessagePage(@RequestBody PageBasic req) { + return interactionMessageRecordService.interactionMessagePage(req,getUserVo()); + } + + @UserLoginToken + @PostMapping("/interactionMessageReadOrDelete") + @ApiOperation(value = "互动消息列表_已读,删除消息", notes = "互动消息列表_已读,删除消息") + public ResponseData interactionMessageReadOrDelete(@RequestBody MessageReadOrDeleteReq req) { + return interactionMessageRecordService.interactionMessageReadOrDelete(req, getUserVo()); + } + +} diff --git a/ruoyi-main/ruoyi-message/src/main/java/com/ruoyi/message/controller/resp/InteractionMessagePageResp.java b/ruoyi-main/ruoyi-message/src/main/java/com/ruoyi/message/controller/resp/InteractionMessagePageResp.java new file mode 100644 index 0000000..8148fd3 --- /dev/null +++ b/ruoyi-main/ruoyi-message/src/main/java/com/ruoyi/message/controller/resp/InteractionMessagePageResp.java @@ -0,0 +1,60 @@ +package com.ruoyi.message.controller.resp; + +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.vo.UserInfo; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.Date; + +/** + * @author a + * @date 2023/10/17 9:44 + */ +@Data +public class InteractionMessagePageResp { + + @ApiModelProperty("租户号") + private Long id; + + @ApiModelProperty("删除标志;1 正常 2 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("用户id;设计师和表现师") + private Long userId; + + @ApiModelProperty("用户类型") + private Integer userType; + + @ApiModelProperty("消息类型;1点赞消息 2评论消息 3关注消息") + private Integer messageType; + + @ApiModelProperty("标语") + @Excel(name = "标语") + private String title; + + @ApiModelProperty("内容") + private String content; + + @ApiModelProperty("是否已读;1未读 2 已读") + private String isRead; + + @ApiModelProperty("是否清空;1 不清空 2 清空") + private String isShow; + + @ApiModelProperty("跳转主体id") + private Long skipId; + + @ApiModelProperty("对应的主体id") + private Long objectId; + + @ApiModelProperty("创建时间") + private Date createTime; + + @ApiModelProperty("来源类型 1帖子 2作品 3关注 4新闻") + private Integer type; + + @ApiModelProperty("用户信息") + private UserInfo userInfo; + +} diff --git a/ruoyi-main/ruoyi-message/src/main/java/com/ruoyi/message/frequency/goeasymessage/controller/GoeasyMessageController.java b/ruoyi-main/ruoyi-message/src/main/java/com/ruoyi/message/frequency/goeasymessage/controller/GoeasyMessageController.java new file mode 100644 index 0000000..5fa9af8 --- /dev/null +++ b/ruoyi-main/ruoyi-message/src/main/java/com/ruoyi/message/frequency/goeasymessage/controller/GoeasyMessageController.java @@ -0,0 +1,103 @@ +package com.ruoyi.message.frequency.goeasymessage.controller; + +import java.util.List; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.message.frequency.goeasymessage.entity.GoeasyMessage; +import com.ruoyi.message.frequency.goeasymessage.service.GoeasyMessageService; +import com.ruoyi.common.utils.poi.ExcelUtil; +import com.ruoyi.common.core.page.TableDataInfo; + +/** + * goeasy消息Controller + * + * @author liwenlong + * @date 2024-04-17 + */ +@RestController +@RequestMapping("/frequency/goeasymessage") +public class GoeasyMessageController extends BaseController +{ + @Autowired + private GoeasyMessageService goeasyMessageService; + + /** + * 查询goeasy消息列表 + */ + //@PreAuthorize("@ss.hasPermi('frequency:goeasymessage:list')") + @PostMapping("/list") + public TableDataInfo list(@RequestBody GoeasyMessage goeasyMessage) + { + startPage(); + List list = goeasyMessageService.selectGoeasyMessageList(goeasyMessage); + return getDataTable(list); + } + + /** + * 导出goeasy消息列表 + */ + //@PreAuthorize("@ss.hasPermi('frequency:goeasymessage:export')") + @Log(title = "goeasy消息", businessType = BusinessType.EXPORT) + @GetMapping("/export") + public AjaxResult export(GoeasyMessage goeasyMessage) + { + List list = goeasyMessageService.selectGoeasyMessageList(goeasyMessage); + ExcelUtil util = new ExcelUtil(GoeasyMessage.class); + return util.exportExcel(list, "goeasy消息数据"); + } + + /** + * 获取goeasy消息详细信息 + */ + //@PreAuthorize("@ss.hasPermi('frequency:goeasymessage:query')") + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") Long id) + { + return AjaxResult.success(goeasyMessageService.selectGoeasyMessageById(id)); + } + + /** + * 新增goeasy消息 + */ + //@PreAuthorize("@ss.hasPermi('frequency:goeasymessage:add')") + @Log(title = "goeasy消息", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody GoeasyMessage goeasyMessage) + { + return toAjax(goeasyMessageService.insertGoeasyMessage(goeasyMessage)); + } + + /** + * 修改goeasy消息 + */ + //@PreAuthorize("@ss.hasPermi('frequency:goeasymessage:edit')") + @Log(title = "goeasy消息", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody GoeasyMessage goeasyMessage) + { + return toAjax(goeasyMessageService.updateGoeasyMessage(goeasyMessage)); + } + + /** + * 删除goeasy消息 + */ + //@PreAuthorize("@ss.hasPermi('frequency:goeasymessage:remove')") + @Log(title = "goeasy消息", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}/{delFlag}") + public AjaxResult remove(@PathVariable("ids") Long[] ids,@PathVariable("delFlag") Integer delFlag) + { + return toAjax(goeasyMessageService.deleteGoeasyMessageByIds(ids,delFlag)); + } +} diff --git a/ruoyi-main/ruoyi-message/src/main/java/com/ruoyi/message/frequency/goeasymessage/entity/GoeasyMessage.java b/ruoyi-main/ruoyi-message/src/main/java/com/ruoyi/message/frequency/goeasymessage/entity/GoeasyMessage.java new file mode 100644 index 0000000..c51ef89 --- /dev/null +++ b/ruoyi-main/ruoyi-message/src/main/java/com/ruoyi/message/frequency/goeasymessage/entity/GoeasyMessage.java @@ -0,0 +1,89 @@ +package com.ruoyi.message.frequency.goeasymessage.entity; + +import java.util.Date; +import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.Data; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.experimental.Accessors; +import com.ruoyi.common.annotation.Excel; +import io.swagger.annotations.ApiModelProperty; +import com.baomidou.mybatisplus.annotation.TableField; +import com.ruoyi.vo.UserInfo; +import com.ruoyi.common.core.domain.BaseEntity; + +/** + * goeasy消息对象 t_goeasy_message + * + * @author liwenlong + * @date 2024-04-17 + */ +@Data +@Accessors(chain = true) +@TableName("t_goeasy_message") +public class GoeasyMessage extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + + @ApiModelProperty("主键id") + private Long id; + + @ApiModelProperty("删除标志 1正常 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("goeasy返回消息id") + @Excel(name = "goeasy返回消息id") + private String messageId; + + @ApiModelProperty("goeasy消息类型") + @Excel(name = "goeasy消息类型") + private String type; + + @ApiModelProperty("发送用户") + @Excel(name = "发送用户") + private String senderId; + + @ApiModelProperty("发送用户类型 1 用户 ") + @Excel(name = "发送用户类型 1 用户 ") + private Integer senderUserType; + + @ApiModelProperty("发送用户id") + @Excel(name = "发送用户id") + private Long senderUserId; + + + @ApiModelProperty("接收用户") + @Excel(name = "接收用户") + private String receiverId; + + @ApiModelProperty("接收用户类型 1 用户 ") + @Excel(name = "接收用户类型 1 用户 ") + private Integer receiverUserType; + + @ApiModelProperty("接收用户id") + @Excel(name = "接收用户id") + private Long receiverUserId; + + @ApiModelProperty("消息(json字符串)") + @Excel(name = "消息(json字符串)") + private String payload; + + @ApiModelProperty("goeasy消息发送时间") + @Excel(name = "goeasy消息发送时间", width = 30, dateFormat = "yyyy-MM-dd") + private Date goeasyTime; + + @ApiModelProperty("发送用户消息") + @TableField(exist = false) + private UserInfo sendUserInfo; + + @ApiModelProperty("接收用户消息") + @TableField(exist = false) + private UserInfo receiveUserInfo; + + /** + * 最早一條消息的时间 + */ + @TableField(exist = false) + private Date lasttimestamp; + +} diff --git a/ruoyi-main/ruoyi-message/src/main/java/com/ruoyi/message/frequency/goeasymessage/mapper/GoeasyMessageMapper.java b/ruoyi-main/ruoyi-message/src/main/java/com/ruoyi/message/frequency/goeasymessage/mapper/GoeasyMessageMapper.java new file mode 100644 index 0000000..0754771 --- /dev/null +++ b/ruoyi-main/ruoyi-message/src/main/java/com/ruoyi/message/frequency/goeasymessage/mapper/GoeasyMessageMapper.java @@ -0,0 +1,47 @@ +package com.ruoyi.message.frequency.goeasymessage.mapper; + +import java.util.List; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.ruoyi.message.frequency.goeasymessage.entity.GoeasyMessage; + +/** + * goeasy消息Mapper接口 + * + * @author liwenlong + * @date 2024-04-17 + */ +public interface GoeasyMessageMapper extends BaseMapper +{ + /** + * 查询goeasy消息 + * + * @param id goeasy消息主键 + * @return goeasy消息 + */ + public GoeasyMessage selectGoeasyMessageById(Long id); + + /** + * 查询goeasy消息列表 + * + * @param goeasyMessage goeasy消息 + * @return goeasy消息集合 + */ + public List selectGoeasyMessageList(GoeasyMessage goeasyMessage); + + /** + * 新增goeasy消息 + * + * @param goeasyMessage goeasy消息 + * @return 结果 + */ + public int insertGoeasyMessage(GoeasyMessage goeasyMessage); + + /** + * 修改goeasy消息 + * + * @param goeasyMessage goeasy消息 + * @return 结果 + */ + public int updateGoeasyMessage(GoeasyMessage goeasyMessage); + +} diff --git a/ruoyi-main/ruoyi-message/src/main/java/com/ruoyi/message/frequency/goeasymessage/mapper/mapping/GoeasyMessageMapper.xml b/ruoyi-main/ruoyi-message/src/main/java/com/ruoyi/message/frequency/goeasymessage/mapper/mapping/GoeasyMessageMapper.xml new file mode 100644 index 0000000..ca6f78c --- /dev/null +++ b/ruoyi-main/ruoyi-message/src/main/java/com/ruoyi/message/frequency/goeasymessage/mapper/mapping/GoeasyMessageMapper.xml @@ -0,0 +1,139 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + select + t.id , + t.create_by , + t.create_time , + t.update_by , + t.update_time , + t.del_flag , + t.message_id , + t.type , + t.sender_id , + t.receiver_id , + t.payload , + t.goeasy_time , + t.sender_user_id , + t.sender_user_type , + t.receiver_user_id , + t.receiver_user_type + from t_goeasy_message AS t + + + + + + + + + insert into t_goeasy_message + + id, + create_by, + create_time, + update_by, + update_time, + del_flag, + message_id, + type, + sender_id, + receiver_id, + payload, + goeasy_time, + sender_user_id, + sender_user_type, + receiver_user_id, + receiver_user_type, + + + #{id}, + #{createBy}, + #{createTime}, + #{updateBy}, + #{updateTime}, + #{delFlag}, + #{messageId}, + #{type}, + #{senderId}, + #{receiverId}, + #{payload}, + #{goeasyTime}, + #{senderUserId}, + #{senderUserType}, + #{receiverUserId}, + #{receiverUserType}, + + + + + update t_goeasy_message + + create_by = #{createBy}, + create_time = #{createTime}, + update_by = #{updateBy}, + update_time = #{updateTime}, + del_flag = #{delFlag}, + message_id = #{messageId}, + type = #{type}, + sender_id = #{senderId}, + receiver_id = #{receiverId}, + payload = #{payload}, + goeasy_time = #{goeasyTime}, + sender_user_id = #{senderUserId}, + sender_user_type = #{senderUserType}, + receiver_user_id = #{receiverUserId}, + receiver_user_type = #{receiverUserType}, + + where id = #{id} + + diff --git a/ruoyi-main/ruoyi-message/src/main/java/com/ruoyi/message/frequency/goeasymessage/model/param/GoeasyMessageParam.java b/ruoyi-main/ruoyi-message/src/main/java/com/ruoyi/message/frequency/goeasymessage/model/param/GoeasyMessageParam.java new file mode 100644 index 0000000..ddc1cee --- /dev/null +++ b/ruoyi-main/ruoyi-message/src/main/java/com/ruoyi/message/frequency/goeasymessage/model/param/GoeasyMessageParam.java @@ -0,0 +1,62 @@ +package com.ruoyi.message.frequency.goeasymessage.model.param; + +import java.util.Date; +import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.Data; +import lombok.experimental.Accessors; +import com.ruoyi.common.annotation.Excel; +import io.swagger.annotations.ApiModelProperty; +import com.ruoyi.common.core.domain.BaseEntity; + +/** + * goeasy消息对象 t_goeasy_message + * + * @author liwenlong + * @date 2024-04-17 + */ +@Data +@Accessors(chain = true) +public class GoeasyMessageParam extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + @ApiModelProperty("主键id") + private Long id; + + @ApiModelProperty("删除标志 1正常 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("goeasy返回消息id") + @Excel(name = "goeasy返回消息id") + private String messageId; + + @ApiModelProperty("goeasy消息类型") + @Excel(name = "goeasy消息类型") + private String type; + + @ApiModelProperty("发送用户") + @Excel(name = "发送用户") + private String senderId; + + @ApiModelProperty("接收用户") + @Excel(name = "接收用户") + private String receiverId; + + @ApiModelProperty("消息(json字符串)") + @Excel(name = "消息(json字符串)") + private String payload; + + @ApiModelProperty("goeasy消息发送时间") + @Excel(name = "goeasy消息发送时间", width = 30, dateFormat = "yyyy-MM-dd") + private Date goeasyTime; + + + + + + + + + + +} diff --git a/ruoyi-main/ruoyi-message/src/main/java/com/ruoyi/message/frequency/goeasymessage/model/result/GoeasyMessageResult.java b/ruoyi-main/ruoyi-message/src/main/java/com/ruoyi/message/frequency/goeasymessage/model/result/GoeasyMessageResult.java new file mode 100644 index 0000000..f580785 --- /dev/null +++ b/ruoyi-main/ruoyi-message/src/main/java/com/ruoyi/message/frequency/goeasymessage/model/result/GoeasyMessageResult.java @@ -0,0 +1,54 @@ +package com.ruoyi.message.frequency.goeasymessage.model.result; + +import java.util.Date; +import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.Data; +import lombok.experimental.Accessors; +import com.ruoyi.common.annotation.Excel; +import io.swagger.annotations.ApiModelProperty; +import com.ruoyi.common.core.domain.BaseEntity; + +/** + * goeasy消息对象 t_goeasy_message + * + * @author liwenlong + * @date 2024-04-17 + */ +@Data +@Accessors(chain = true) +public class GoeasyMessageResult extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + @ApiModelProperty("主键id") + private Long id; + + @ApiModelProperty("删除标志 1正常 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("goeasy返回消息id") + @Excel(name = "goeasy返回消息id") + private String messageId; + + @ApiModelProperty("goeasy消息类型") + @Excel(name = "goeasy消息类型") + private String type; + + @ApiModelProperty("发送用户") + @Excel(name = "发送用户") + private String senderId; + + @ApiModelProperty("接收用户") + @Excel(name = "接收用户") + private String receiverId; + + @ApiModelProperty("消息(json字符串)") + @Excel(name = "消息(json字符串)") + private String payload; + + @ApiModelProperty("goeasy消息发送时间") + @Excel(name = "goeasy消息发送时间", width = 30, dateFormat = "yyyy-MM-dd") + private Date goeasyTime; + + +} diff --git a/ruoyi-main/ruoyi-message/src/main/java/com/ruoyi/message/frequency/goeasymessage/service/GoeasyMessageService.java b/ruoyi-main/ruoyi-message/src/main/java/com/ruoyi/message/frequency/goeasymessage/service/GoeasyMessageService.java new file mode 100644 index 0000000..98306d9 --- /dev/null +++ b/ruoyi-main/ruoyi-message/src/main/java/com/ruoyi/message/frequency/goeasymessage/service/GoeasyMessageService.java @@ -0,0 +1,58 @@ +package com.ruoyi.message.frequency.goeasymessage.service; + +import java.util.List; + +import com.alibaba.fastjson.JSONObject; +import com.ruoyi.message.frequency.goeasymessage.entity.GoeasyMessage; +import com.baomidou.mybatisplus.extension.service.IService; + +/** + * goeasy消息Service接口 + * + * @author liwenlong + * @date 2024-04-17 + */ +public interface GoeasyMessageService extends IService +{ + /** + * 查询goeasy消息 + * + * @param id goeasy消息主键 + * @return goeasy消息 + */ + public GoeasyMessage selectGoeasyMessageById(Long id); + + /** + * 查询goeasy消息列表 + * + * @param goeasyMessage goeasy消息 + * @return goeasy消息集合 + */ + public List selectGoeasyMessageList(GoeasyMessage goeasyMessage); + + /** + * 新增goeasy消息 + * + * @param goeasyMessage goeasy消息 + * @return 结果 + */ + public int insertGoeasyMessage(GoeasyMessage goeasyMessage); + + /** + * 修改goeasy消息 + * + * @param goeasyMessage goeasy消息 + * @return 结果 + */ + public int updateGoeasyMessage(GoeasyMessage goeasyMessage); + + /** + * 批量删除goeasy消息 + * + * @param ids 需要删除的goeasy消息主键集合 + * @return 结果 + */ + public int deleteGoeasyMessageByIds(Long[] ids,Integer delFlag); + + void goeasyMessage(List goeasyMessages); +} diff --git a/ruoyi-main/ruoyi-message/src/main/java/com/ruoyi/message/frequency/goeasymessage/service/impl/GoeasyMessageServiceImpl.java b/ruoyi-main/ruoyi-message/src/main/java/com/ruoyi/message/frequency/goeasymessage/service/impl/GoeasyMessageServiceImpl.java new file mode 100644 index 0000000..852165e --- /dev/null +++ b/ruoyi-main/ruoyi-message/src/main/java/com/ruoyi/message/frequency/goeasymessage/service/impl/GoeasyMessageServiceImpl.java @@ -0,0 +1,184 @@ +package com.ruoyi.message.frequency.goeasymessage.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.ruoyi.code.PublicCommon; +import com.ruoyi.frequency.customer.service.UserService; +import com.ruoyi.message.frequency.goeasymessage.entity.GoeasyMessage; +import com.ruoyi.message.frequency.goeasymessage.mapper.GoeasyMessageMapper; +import com.ruoyi.message.frequency.goeasymessage.service.GoeasyMessageService; +import com.ruoyi.message.frequency.goeasymessagenew.entity.GoeasyMessageNew; +import com.ruoyi.message.frequency.goeasymessagenew.mapper.GoeasyMessageNewMapper; +import com.ruoyi.message.frequency.goeasymessagenew.service.GoeasyMessageNewService; +import com.ruoyi.vo.UserInfo; +import com.ruoyi.vo.UserVo; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.*; + +/** + * goeasy消息Service业务层处理 + * + * @author liwenlong + * @date 2024-04-17 + */ +@Service +public class GoeasyMessageServiceImpl extends ServiceImpl implements GoeasyMessageService { + @Autowired + private GoeasyMessageMapper goeasyMessageMapper; + + /** + * 查询goeasy消息 + * + * @param id goeasy消息主键 + * @return goeasy消息 + */ + @Override + public GoeasyMessage selectGoeasyMessageById(Long id) { + GoeasyMessage goeasyMessage = goeasyMessageMapper.selectGoeasyMessageById(id); + if (goeasyMessage != null) { + Set userVoSet = new HashSet<>(); + userVoSet.add(new UserVo(goeasyMessage.getSenderUserType(), goeasyMessage.getSenderUserId())); + userVoSet.add(new UserVo(goeasyMessage.getReceiverUserType(), goeasyMessage.getReceiverUserId())); + + //查询用户信息 + Map userMap = userService.selectUserInfoMap(userVoSet, null); + + goeasyMessage.setSendUserInfo(userMap.get(new UserVo(goeasyMessage.getSenderUserType(), goeasyMessage.getSenderUserId()))); + goeasyMessage.setReceiveUserInfo(userMap.get(new UserVo(goeasyMessage.getReceiverUserType(), goeasyMessage.getReceiverUserId()))); + + + } + + return goeasyMessage; + } + + @Autowired + private UserService userService; + + /** + * 查询goeasy消息列表 + * + * @param goeasyMessage goeasy消息 + * @return goeasy消息 + */ + @Override + public List selectGoeasyMessageList(GoeasyMessage goeasyMessage) { + List goeasyMessages = goeasyMessageMapper.selectGoeasyMessageList(goeasyMessage); + //根據goeasy_time 來正序排列 + goeasyMessages.sort(Comparator.comparing(GoeasyMessage::getGoeasyTime)); + if (goeasyMessages.size() > 0) { + Set userVoSet = new HashSet<>(); + goeasyMessages.stream().forEach(s -> { + userVoSet.add(new UserVo(s.getSenderUserType(), s.getSenderUserId())); + userVoSet.add(new UserVo(s.getReceiverUserType(), s.getReceiverUserId())); + }); + + //查询用户信息 + Map userMap = userService.selectUserInfoMap(userVoSet, null); + + goeasyMessages.stream().forEach(s -> { + s.setSendUserInfo(userMap.get(new UserVo(s.getSenderUserType(), s.getSenderUserId()))); + s.setReceiveUserInfo(userMap.get(new UserVo(s.getReceiverUserType(), s.getReceiverUserId()))); + }); + } + + return goeasyMessages; + } + + /** + * 新增goeasy消息 + * + * @param goeasyMessage goeasy消息 + * @return 结果 + */ + @Override + public int insertGoeasyMessage(GoeasyMessage goeasyMessage) { + goeasyMessage.setCreateData(); + return goeasyMessageMapper.insert(goeasyMessage); + } + + /** + * 修改goeasy消息 + * + * @param goeasyMessage goeasy消息 + * @return 结果 + */ + @Override + public int updateGoeasyMessage(GoeasyMessage goeasyMessage) { + goeasyMessage.setUpdateData(); + return goeasyMessageMapper.updateGoeasyMessage(goeasyMessage); + } + + /** + * 批量删除goeasy消息 + * + * @param ids 需要删除的goeasy消息主键 + * @return 结果 + */ + @Override + public int deleteGoeasyMessageByIds(Long[] ids, Integer delFlag) { + this.lambdaUpdate().set(GoeasyMessage::getDelFlag, delFlag).in(GoeasyMessage::getId, ids).update(); + return ids.length; + } + + @Autowired + private GoeasyMessageNewService goeasyMessageNewService; + + @Autowired + private GoeasyMessageNewMapper goeasyMessageNewMapper; + + @Override + public void goeasyMessage(List goeasyMessages) { + + // 使用 Map 存储唯一的 GoeasyMessage,键为 messageId,值为 GoeasyMessage 对象 + Map uniqueMessages = new HashMap<>(); + + // 遍历列表,将每个消息按 messageId 存储到 Map 中 + for (GoeasyMessage message : goeasyMessages) { + if (message == null) { + continue; + } + uniqueMessages.put(message.getMessageId(), message); + } + + Collection onlyList = uniqueMessages.values(); + try { + this.saveBatch(onlyList); + + //更新 goeasy_message_new + List goeasyMessageNewList = new ArrayList<>(); + + onlyList.stream().forEach(x -> { + Long userId = x.getSenderUserId(); + Long otherUserId = x.getReceiverUserId(); + + GoeasyMessageNew goeasyMessageNew = goeasyMessageNewMapper.getMessage(userId, otherUserId); + + if (goeasyMessageNew == null) { + goeasyMessageNew = new GoeasyMessageNew(); + goeasyMessageNew.setGoeasyTime(x.getGoeasyTime()); + goeasyMessageNew.setUserId(userId); + goeasyMessageNew.setOtherUserId(otherUserId); + goeasyMessageNew.setType(x.getType()); + goeasyMessageNew.setPayload(x.getPayload()); + goeasyMessageNew.setDelFlag(PublicCommon.启用); + } else { + goeasyMessageNew.setGoeasyTime(x.getGoeasyTime()); + goeasyMessageNew.setPayload(x.getPayload()); + goeasyMessageNew.setType(x.getType()); + } + + goeasyMessageNewList.add(goeasyMessageNew); + }); + + if (goeasyMessageNewList.size() > 0) { + goeasyMessageNewService.saveOrUpdateBatch(goeasyMessageNewList); + } + + } catch (Exception e) { + log.error("goeasy消息发送失败", e); + } + + } +} diff --git a/ruoyi-main/ruoyi-message/src/main/java/com/ruoyi/message/frequency/goeasymessagenew/controller/GoeasyMessageNewController.java b/ruoyi-main/ruoyi-message/src/main/java/com/ruoyi/message/frequency/goeasymessagenew/controller/GoeasyMessageNewController.java new file mode 100644 index 0000000..9095661 --- /dev/null +++ b/ruoyi-main/ruoyi-message/src/main/java/com/ruoyi/message/frequency/goeasymessagenew/controller/GoeasyMessageNewController.java @@ -0,0 +1,90 @@ +package com.ruoyi.message.frequency.goeasymessagenew.controller; + +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.page.TableDataInfo; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.common.utils.poi.ExcelUtil; +import com.ruoyi.message.frequency.goeasymessagenew.entity.GoeasyMessageNew; +import com.ruoyi.message.frequency.goeasymessagenew.service.GoeasyMessageNewService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +/** + * goeasy最新消息Controller + * + * @author liwenlong + * @date 2024-04-20 + */ +@RestController +@RequestMapping("/frequency/goeasymessagenew") +public class GoeasyMessageNewController extends BaseController { + @Autowired + private GoeasyMessageNewService goeasyMessageNewService; + + /** + * 查询goeasy最新消息列表 + */ +// @PreAuthorize("@ss.hasPermi('frequency:goeasymessagenew:list')") + @PostMapping("/list") + public TableDataInfo list(@RequestBody GoeasyMessageNew goeasyMessageNew) { + startPage(); + List list = goeasyMessageNewService.selectGoeasyMessageNewList(goeasyMessageNew); + return getDataTable(list); + } + + /** + * 导出goeasy最新消息列表 + */ +// @PreAuthorize("@ss.hasPermi('frequency:goeasymessagenew:export')") + @Log(title = "goeasy最新消息", businessType = BusinessType.EXPORT) + @GetMapping("/export") + public AjaxResult export(GoeasyMessageNew goeasyMessageNew) { + List list = goeasyMessageNewService.selectGoeasyMessageNewList(goeasyMessageNew); + ExcelUtil util = new ExcelUtil(GoeasyMessageNew.class); + return util.exportExcel(list, "goeasy最新消息数据"); + } + + /** + * 获取goeasy最新消息详细信息 + */ +// @PreAuthorize("@ss.hasPermi('frequency:goeasymessagenew:query')") + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") Long id) { + return AjaxResult.success(goeasyMessageNewService.selectGoeasyMessageNewById(id)); + } + + /** + * 新增goeasy最新消息 + */ +// @PreAuthorize("@ss.hasPermi('frequency:goeasymessagenew:add')") + @Log(title = "goeasy最新消息", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody GoeasyMessageNew goeasyMessageNew) { + return toAjax(goeasyMessageNewService.insertGoeasyMessageNew(goeasyMessageNew)); + } + + /** + * 修改goeasy最新消息 + */ +// @PreAuthorize("@ss.hasPermi('frequency:goeasymessagenew:edit')") + @Log(title = "goeasy最新消息", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody GoeasyMessageNew goeasyMessageNew) { + return toAjax(goeasyMessageNewService.updateGoeasyMessageNew(goeasyMessageNew)); + } + + /** + * 删除goeasy最新消息 + */ +// @PreAuthorize("@ss.hasPermi('frequency:goeasymessagenew:remove')") + @Log(title = "goeasy最新消息", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}/{delFlag}") + public AjaxResult remove(@PathVariable("ids") Long[] ids, @PathVariable("delFlag") Integer delFlag) { + return toAjax(goeasyMessageNewService.deleteGoeasyMessageNewByIds(ids, delFlag)); + } +} diff --git a/ruoyi-main/ruoyi-message/src/main/java/com/ruoyi/message/frequency/goeasymessagenew/entity/GoeasyMessageNew.java b/ruoyi-main/ruoyi-message/src/main/java/com/ruoyi/message/frequency/goeasymessagenew/entity/GoeasyMessageNew.java new file mode 100644 index 0000000..fea1f08 --- /dev/null +++ b/ruoyi-main/ruoyi-message/src/main/java/com/ruoyi/message/frequency/goeasymessagenew/entity/GoeasyMessageNew.java @@ -0,0 +1,79 @@ +package com.ruoyi.message.frequency.goeasymessagenew.entity; + +import java.util.Date; +import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.Data; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.experimental.Accessors; +import com.ruoyi.common.annotation.Excel; +import io.swagger.annotations.ApiModelProperty; +import com.baomidou.mybatisplus.annotation.TableField; +import com.ruoyi.vo.UserInfo; +import com.ruoyi.common.core.domain.BaseEntity; + +/** + * goeasy最新消息对象 t_goeasy_message_new + * + * @author liwenlong + * @date 2024-04-20 + */ +@Data +@Accessors(chain = true) +@TableName("t_goeasy_message_new") +public class GoeasyMessageNew extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + + @ApiModelProperty("主键id") + private Long id; + + @ApiModelProperty("删除标志 1正常 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("消息(json字符串)") + @Excel(name = "消息(json字符串)") + private String payload; + + @ApiModelProperty("goeasy最新消息发送时间") + @Excel(name = "goeasy最新消息发送时间", width = 30, dateFormat = "yyyy-MM-dd") + private Date goeasyTime; + + @ApiModelProperty("goeasy消息类型") + @Excel(name = "goeasy消息类型") + private String type; + + @ApiModelProperty("用户ID") + @Excel(name = "用户ID") + private Long userId; + + @ApiModelProperty("聊天对象用户ID") + @Excel(name = "聊天对象用户ID") + private Long otherUserId; + + @TableField(exist = false) + private Long senderUserId; + + @TableField(exist = false) + private Integer senderUserType; + + @TableField(exist = false) + private Long receiverUserId; + + @TableField(exist = false) + private Integer receiverUserType; + + + @ApiModelProperty("发送用户消息") + @TableField(exist = false) + private UserInfo sendUserInfo; + + @ApiModelProperty("接收用户消息") + @TableField(exist = false) + private UserInfo receiveUserInfo; + + + @ApiModelProperty("传参") + @TableField(exist = false) + private UserInfo userInfo; +} diff --git a/ruoyi-main/ruoyi-message/src/main/java/com/ruoyi/message/frequency/goeasymessagenew/mapper/GoeasyMessageNewMapper.java b/ruoyi-main/ruoyi-message/src/main/java/com/ruoyi/message/frequency/goeasymessagenew/mapper/GoeasyMessageNewMapper.java new file mode 100644 index 0000000..96eee71 --- /dev/null +++ b/ruoyi-main/ruoyi-message/src/main/java/com/ruoyi/message/frequency/goeasymessagenew/mapper/GoeasyMessageNewMapper.java @@ -0,0 +1,49 @@ +package com.ruoyi.message.frequency.goeasymessagenew.mapper; + +import java.util.List; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.ruoyi.message.frequency.goeasymessagenew.entity.GoeasyMessageNew; +import org.apache.ibatis.annotations.Param; + +/** + * goeasy最新消息Mapper接口 + * + * @author liwenlong + * @date 2024-04-20 + */ +public interface GoeasyMessageNewMapper extends BaseMapper +{ + /** + * 查询goeasy最新消息 + * + * @param id goeasy最新消息主键 + * @return goeasy最新消息 + */ + public GoeasyMessageNew selectGoeasyMessageNewById(Long id); + + /** + * 查询goeasy最新消息列表 + * + * @param goeasyMessageNew goeasy最新消息 + * @return goeasy最新消息集合 + */ + public List selectGoeasyMessageNewList(GoeasyMessageNew goeasyMessageNew); + + /** + * 新增goeasy最新消息 + * + * @param goeasyMessageNew goeasy最新消息 + * @return 结果 + */ + public int insertGoeasyMessageNew(GoeasyMessageNew goeasyMessageNew); + + /** + * 修改goeasy最新消息 + * + * @param goeasyMessageNew goeasy最新消息 + * @return 结果 + */ + public int updateGoeasyMessageNew(GoeasyMessageNew goeasyMessageNew); + + GoeasyMessageNew getMessage(@Param("userId") Long userId, @Param("otherUserId") Long otherUserId); +} diff --git a/ruoyi-main/ruoyi-message/src/main/java/com/ruoyi/message/frequency/goeasymessagenew/mapper/mapping/GoeasyMessageNewMapper.xml b/ruoyi-main/ruoyi-message/src/main/java/com/ruoyi/message/frequency/goeasymessagenew/mapper/mapping/GoeasyMessageNewMapper.xml new file mode 100644 index 0000000..620bc9b --- /dev/null +++ b/ruoyi-main/ruoyi-message/src/main/java/com/ruoyi/message/frequency/goeasymessagenew/mapper/mapping/GoeasyMessageNewMapper.xml @@ -0,0 +1,200 @@ + + + + + + + + + + + + + + + + + + + + + + select + t.id , + t.create_by , + t.create_time , + t.update_by , + t.update_time , + t.del_flag , + t.user_id , + t.other_user_id , + t.payload , + t.goeasy_time , + t.type + from t_goeasy_message_new AS t + + + + + + + + + + insert into t_goeasy_message_new + + id, + create_by, + create_time, + update_by, + update_time, + del_flag, + user_id, + other_user_id, + payload, + goeasy_time, + type, + + + #{id}, + #{createBy}, + #{createTime}, + #{updateBy}, + #{updateTime}, + #{delFlag}, + #{userId}, + #{otherUserId}, + #{payload}, + #{goeasyTime}, + #{type}, + + + + + update t_goeasy_message_new + + create_by = #{createBy}, + create_time = #{createTime}, + update_by = #{updateBy}, + update_time = #{updateTime}, + del_flag = #{delFlag}, + user_id = #{userId}, + other_user_id = #{otherUserId}, + payload = #{payload}, + goeasy_time = #{goeasyTime}, + type = #{type}, + + where id = #{id} + + \ No newline at end of file diff --git a/ruoyi-main/ruoyi-message/src/main/java/com/ruoyi/message/frequency/goeasymessagenew/model/param/GoeasyMessageNewParam.java b/ruoyi-main/ruoyi-message/src/main/java/com/ruoyi/message/frequency/goeasymessagenew/model/param/GoeasyMessageNewParam.java new file mode 100644 index 0000000..6c9df6f --- /dev/null +++ b/ruoyi-main/ruoyi-message/src/main/java/com/ruoyi/message/frequency/goeasymessagenew/model/param/GoeasyMessageNewParam.java @@ -0,0 +1,58 @@ +package com.ruoyi.message.frequency.goeasymessagenew.model.param; + +import java.util.Date; + +import com.baomidou.mybatisplus.annotation.TableField; +import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.Data; +import lombok.experimental.Accessors; +import com.ruoyi.common.annotation.Excel; +import io.swagger.annotations.ApiModelProperty; +import com.ruoyi.common.core.domain.BaseEntity; + +/** + * goeasy最新消息对象 t_goeasy_message_new + * + * @author liwenlong + * @date 2024-04-20 + */ +@Data +@Accessors(chain = true) +public class GoeasyMessageNewParam extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + @ApiModelProperty("主键id") + private Long id; + + @ApiModelProperty("删除标志 1正常 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("聊天对象用户ID") + @Excel(name = "聊天对象用户ID") + private Long otherUserId; + + @TableField(exist = false) + private Long senderUserId; + + @ApiModelProperty("消息(json字符串)") + @Excel(name = "消息(json字符串)") + private String payload; + + @ApiModelProperty("goeasy最新消息发送时间") + @Excel(name = "goeasy最新消息发送时间", width = 30, dateFormat = "yyyy-MM-dd") + private Date goeasyTime; + + @ApiModelProperty("goeasy消息类型") + @Excel(name = "goeasy消息类型") + private String type; + + + + + + + + + +} diff --git a/ruoyi-main/ruoyi-message/src/main/java/com/ruoyi/message/frequency/goeasymessagenew/model/result/GoeasyMessageNewResult.java b/ruoyi-main/ruoyi-message/src/main/java/com/ruoyi/message/frequency/goeasymessagenew/model/result/GoeasyMessageNewResult.java new file mode 100644 index 0000000..78bb7e5 --- /dev/null +++ b/ruoyi-main/ruoyi-message/src/main/java/com/ruoyi/message/frequency/goeasymessagenew/model/result/GoeasyMessageNewResult.java @@ -0,0 +1,51 @@ +package com.ruoyi.message.frequency.goeasymessagenew.model.result; + +import java.util.Date; + +import com.baomidou.mybatisplus.annotation.TableField; +import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.Data; +import lombok.experimental.Accessors; +import com.ruoyi.common.annotation.Excel; +import io.swagger.annotations.ApiModelProperty; +import com.ruoyi.common.core.domain.BaseEntity; + +/** + * goeasy最新消息对象 t_goeasy_message_new + * + * @author liwenlong + * @date 2024-04-20 + */ +@Data +@Accessors(chain = true) +public class GoeasyMessageNewResult extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + @ApiModelProperty("主键id") + private Long id; + + @ApiModelProperty("删除标志 1正常 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("聊天对象用户ID") + @Excel(name = "聊天对象用户ID") + private Long otherUserId; + + @TableField(exist = false) + private Long senderUserId; + + @ApiModelProperty("消息(json字符串)") + @Excel(name = "消息(json字符串)") + private String payload; + + @ApiModelProperty("goeasy最新消息发送时间") + @Excel(name = "goeasy最新消息发送时间", width = 30, dateFormat = "yyyy-MM-dd") + private Date goeasyTime; + + @ApiModelProperty("goeasy消息类型") + @Excel(name = "goeasy消息类型") + private String type; + + +} diff --git a/ruoyi-main/ruoyi-message/src/main/java/com/ruoyi/message/frequency/goeasymessagenew/service/GoeasyMessageNewService.java b/ruoyi-main/ruoyi-message/src/main/java/com/ruoyi/message/frequency/goeasymessagenew/service/GoeasyMessageNewService.java new file mode 100644 index 0000000..a59deb3 --- /dev/null +++ b/ruoyi-main/ruoyi-message/src/main/java/com/ruoyi/message/frequency/goeasymessagenew/service/GoeasyMessageNewService.java @@ -0,0 +1,55 @@ +package com.ruoyi.message.frequency.goeasymessagenew.service; + +import java.util.List; +import com.ruoyi.message.frequency.goeasymessagenew.entity.GoeasyMessageNew; +import com.baomidou.mybatisplus.extension.service.IService; + +/** + * goeasy最新消息Service接口 + * + * @author liwenlong + * @date 2024-04-20 + */ +public interface GoeasyMessageNewService extends IService +{ + /** + * 查询goeasy最新消息 + * + * @param id goeasy最新消息主键 + * @return goeasy最新消息 + */ + public GoeasyMessageNew selectGoeasyMessageNewById(Long id); + + /** + * 查询goeasy最新消息列表 + * + * @param goeasyMessageNew goeasy最新消息 + * @return goeasy最新消息集合 + */ + public List selectGoeasyMessageNewList(GoeasyMessageNew goeasyMessageNew); + + /** + * 新增goeasy最新消息 + * + * @param goeasyMessageNew goeasy最新消息 + * @return 结果 + */ + public int insertGoeasyMessageNew(GoeasyMessageNew goeasyMessageNew); + + /** + * 修改goeasy最新消息 + * + * @param goeasyMessageNew goeasy最新消息 + * @return 结果 + */ + public int updateGoeasyMessageNew(GoeasyMessageNew goeasyMessageNew); + + /** + * 批量删除goeasy最新消息 + * + * @param ids 需要删除的goeasy最新消息主键集合 + * @return 结果 + */ + public int deleteGoeasyMessageNewByIds(Long[] ids,Integer delFlag); + +} diff --git a/ruoyi-main/ruoyi-message/src/main/java/com/ruoyi/message/frequency/goeasymessagenew/service/impl/GoeasyMessageNewServiceImpl.java b/ruoyi-main/ruoyi-message/src/main/java/com/ruoyi/message/frequency/goeasymessagenew/service/impl/GoeasyMessageNewServiceImpl.java new file mode 100644 index 0000000..4467d73 --- /dev/null +++ b/ruoyi-main/ruoyi-message/src/main/java/com/ruoyi/message/frequency/goeasymessagenew/service/impl/GoeasyMessageNewServiceImpl.java @@ -0,0 +1,154 @@ +package com.ruoyi.message.frequency.goeasymessagenew.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.ruoyi.enums.user.UserEnums; +import com.ruoyi.frequency.customer.entity.Customer; +import com.ruoyi.frequency.customer.service.CustomerService; +import com.ruoyi.frequency.customer.service.UserService; +import com.ruoyi.frequency.store.entity.Store; +import com.ruoyi.frequency.store.service.StoreService; +import com.ruoyi.message.frequency.goeasymessagenew.entity.GoeasyMessageNew; +import com.ruoyi.message.frequency.goeasymessagenew.mapper.GoeasyMessageNewMapper; +import com.ruoyi.message.frequency.goeasymessagenew.service.GoeasyMessageNewService; +import com.ruoyi.vo.UserInfo; +import com.ruoyi.vo.UserVo; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.*; + +/** + * goeasy最新消息Service业务层处理 + * + * @author liwenlong + * @date 2024-04-20 + */ +@Service +public class GoeasyMessageNewServiceImpl extends ServiceImpl implements GoeasyMessageNewService { + @Autowired + private GoeasyMessageNewMapper goeasyMessageNewMapper; + + /** + * 查询goeasy最新消息 + * + * @param id goeasy最新消息主键 + * @return goeasy最新消息 + */ + @Override + public GoeasyMessageNew selectGoeasyMessageNewById(Long id) { + return goeasyMessageNewMapper.selectGoeasyMessageNewById(id); + } + + + @Autowired + private UserService userService; + + @Autowired + private CustomerService customerService; + @Autowired + private StoreService storeService; + + /** + * 查询goeasy最新消息列表 + * + * @param goeasyMessageNew goeasy最新消息 + * @return goeasy最新消息 + */ + @Override + public List selectGoeasyMessageNewList(GoeasyMessageNew goeasyMessageNew) { + List goeasyMessageNewList = goeasyMessageNewMapper.selectGoeasyMessageNewList(goeasyMessageNew); + + if (goeasyMessageNewList.size() > 0) { + List userId = new ArrayList<>(); + goeasyMessageNewList.stream().forEach(s -> { + userId.add(s.getUserId()); + userId.add(s.getOtherUserId()); + }); + Set userVoSet = new HashSet<>(); + List customerList = customerService.listByIds(userId); + + Map customerMap = new HashMap<>(); + customerList.stream().forEach(x -> { + customerMap.put(x.getId(), x.getId()); + userVoSet.add(new UserVo(UserEnums.customer.getCode(), x.getId())); + + }); + + List storeList = storeService.listByIds(userId); + + Map storeMap = new HashMap<>(); + storeList.stream().forEach(x -> { + storeMap.put(x.getId(), x.getId()); + userVoSet.add(new UserVo(UserEnums.store.getCode(), x.getId())); + + }); + + + //查询用户信息 + Map userMap = userService.selectUserInfoMap(userVoSet, null); + + goeasyMessageNewList.stream().forEach(s -> { + // 取 userId + if (customerMap.containsKey(s.getUserId())) { + s.setSendUserInfo(userMap.get(new UserVo(UserEnums.customer.getCode(), s.getUserId()))); + s.setSenderUserId(s.getSendUserInfo().getUserId()); + s.setSenderUserType(UserEnums.customer.getCode()); + } else if (storeMap.containsKey(s.getUserId())) { + s.setSendUserInfo(userMap.get(new UserVo(UserEnums.store.getCode(), s.getUserId()))); + s.setSenderUserId(s.getSendUserInfo().getUserId()); + s.setSenderUserType(UserEnums.store.getCode()); + } + + + if (customerMap.containsKey(s.getOtherUserId())) { + s.setReceiveUserInfo(userMap.get(new UserVo(UserEnums.customer.getCode(), s.getOtherUserId()))); + s.setReceiverUserId(s.getReceiveUserInfo().getUserId()); + s.setReceiverUserType(UserEnums.customer.getCode()); + } else if (storeMap.containsKey(s.getOtherUserId())) { + s.setReceiveUserInfo(userMap.get(new UserVo(UserEnums.store.getCode(), s.getOtherUserId()))); + s.setReceiverUserId(s.getReceiveUserInfo().getUserId()); + s.setReceiverUserType(UserEnums.store.getCode()); + } + + }); + } + return goeasyMessageNewList; + } + + /** + * 新增goeasy最新消息 + * + * @param goeasyMessageNew goeasy最新消息 + * @return 结果 + */ + @Override + public int insertGoeasyMessageNew(GoeasyMessageNew goeasyMessageNew) { + goeasyMessageNew.setCreateData(); + return goeasyMessageNewMapper.insert(goeasyMessageNew); + } + + /** + * 修改goeasy最新消息 + * + * @param goeasyMessageNew goeasy最新消息 + * @return 结果 + */ + @Override + public int updateGoeasyMessageNew(GoeasyMessageNew goeasyMessageNew) { + goeasyMessageNew.setUpdateData(); + return goeasyMessageNewMapper.updateGoeasyMessageNew(goeasyMessageNew); + } + + /** + * 批量删除goeasy最新消息 + * + * @param ids 需要删除的goeasy最新消息主键 + * @return 结果 + */ + @Override + public int deleteGoeasyMessageNewByIds(Long[] ids, Integer delFlag) { + this.lambdaUpdate().set(GoeasyMessageNew::getDelFlag, delFlag).in(GoeasyMessageNew::getId, ids).update(); + return ids.length; + } + +} diff --git a/ruoyi-main/ruoyi-message/src/main/java/com/ruoyi/message/frequency/interactionmessagerecord/controller/InteractionMessageRecordController.java b/ruoyi-main/ruoyi-message/src/main/java/com/ruoyi/message/frequency/interactionmessagerecord/controller/InteractionMessageRecordController.java new file mode 100644 index 0000000..cf31663 --- /dev/null +++ b/ruoyi-main/ruoyi-message/src/main/java/com/ruoyi/message/frequency/interactionmessagerecord/controller/InteractionMessageRecordController.java @@ -0,0 +1,97 @@ +package com.ruoyi.message.frequency.interactionmessagerecord.controller; + +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.page.TableDataInfo; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.common.utils.poi.ExcelUtil; +import com.ruoyi.message.frequency.interactionmessagerecord.entity.InteractionMessageRecord; +import com.ruoyi.message.frequency.interactionmessagerecord.service.InteractionMessageRecordService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +/** + * 互动消息记录Controller + * + * @author liwenlong + * @date 2023-10-17 + */ +@RestController +@RequestMapping("/frequency/interactionmessagerecord") +public class InteractionMessageRecordController extends BaseController +{ + @Autowired + private InteractionMessageRecordService interactionMessageRecordService; + + /** + * 查询互动消息记录列表 + */ + @PreAuthorize("@ss.hasPermi('frequency:interactionmessagerecord:list')") + @GetMapping("/list") + public TableDataInfo list(InteractionMessageRecord interactionMessageRecord) + { + startPage(); + List list = interactionMessageRecordService.selectInteractionMessageRecordList(interactionMessageRecord); + return getDataTable(list); + } + + /** + * 导出互动消息记录列表 + */ + @PreAuthorize("@ss.hasPermi('frequency:interactionmessagerecord:export')") + @Log(title = "互动消息记录", businessType = BusinessType.EXPORT) + @GetMapping("/export") + public AjaxResult export(InteractionMessageRecord interactionMessageRecord) + { + List list = interactionMessageRecordService.selectInteractionMessageRecordList(interactionMessageRecord); + ExcelUtil util = new ExcelUtil(InteractionMessageRecord.class); + return util.exportExcel(list, "互动消息记录数据"); + } + + /** + * 获取互动消息记录详细信息 + */ + @PreAuthorize("@ss.hasPermi('frequency:interactionmessagerecord:query')") + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") Long id) + { + return AjaxResult.success(interactionMessageRecordService.selectInteractionMessageRecordById(id)); + } + + /** + * 新增互动消息记录 + */ + @PreAuthorize("@ss.hasPermi('frequency:interactionmessagerecord:add')") + @Log(title = "互动消息记录", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody InteractionMessageRecord interactionMessageRecord) + { + return toAjax(interactionMessageRecordService.insertInteractionMessageRecord(interactionMessageRecord)); + } + + /** + * 修改互动消息记录 + */ + @PreAuthorize("@ss.hasPermi('frequency:interactionmessagerecord:edit')") + @Log(title = "互动消息记录", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody InteractionMessageRecord interactionMessageRecord) + { + return toAjax(interactionMessageRecordService.updateInteractionMessageRecord(interactionMessageRecord)); + } + + /** + * 删除互动消息记录 + */ + @PreAuthorize("@ss.hasPermi('frequency:interactionmessagerecord:remove')") + @Log(title = "互动消息记录", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}") + public AjaxResult remove(@PathVariable Long[] ids) + { + return toAjax(interactionMessageRecordService.deleteInteractionMessageRecordByIds(ids)); + } +} diff --git a/ruoyi-main/ruoyi-message/src/main/java/com/ruoyi/message/frequency/interactionmessagerecord/entity/InteractionMessageRecord.java b/ruoyi-main/ruoyi-message/src/main/java/com/ruoyi/message/frequency/interactionmessagerecord/entity/InteractionMessageRecord.java new file mode 100644 index 0000000..374042e --- /dev/null +++ b/ruoyi-main/ruoyi-message/src/main/java/com/ruoyi/message/frequency/interactionmessagerecord/entity/InteractionMessageRecord.java @@ -0,0 +1,78 @@ +package com.ruoyi.message.frequency.interactionmessagerecord.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; + +/** + * 互动消息记录对象 t_interaction_message_record + * + * @author liwenlong + * @date 2023-10-17 + */ +@Data +@Accessors(chain = true) +@TableName("t_interaction_message_record") +public class InteractionMessageRecord extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + + @ApiModelProperty("租户号") + private Long id; + + @ApiModelProperty("删除标志;1 正常 2 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("用户id;设计师和表现师") + @Excel(name = "用户id;设计师和表现师") + private Long userId; + + @ApiModelProperty("用户类型") + @Excel(name = "用户类型") + private Integer userType; + + @ApiModelProperty("消息类型;1点赞消息 2评论消息 3关注消息") + @Excel(name = "消息类型;1点赞消息 2评论消息 3关注消息") + private Integer messageType; + + @ApiModelProperty("标语") + @Excel(name = "标语") + private String title; + + @ApiModelProperty("内容") + @Excel(name = "内容") + private String content; + + @ApiModelProperty("是否已读;1未读 2 已读") + @Excel(name = "是否已读;1未读 2 已读") + private String isRead; + + @ApiModelProperty("是否清空;1 不清空 2 清空") + @Excel(name = "是否清空;1 不清空 2 清空") + private String isShow; + + @ApiModelProperty("跳转主体id") + @Excel(name = "跳转主体id") + private Long skipId; + + @ApiModelProperty("用户类型 ") + @Excel(name = "用户类型 ") + private Integer interactionUserType; + + @ApiModelProperty("互动消息用户id") + @Excel(name = "互动消息用户id") + private Long interactionUserId; + + @ApiModelProperty("对应的主体id") + @Excel(name = "对应的主体id") + private Long objectId; + + @ApiModelProperty("具体类型看 InteractionMessageEnums 枚举") + private Integer type; + + +} diff --git a/ruoyi-main/ruoyi-message/src/main/java/com/ruoyi/message/frequency/interactionmessagerecord/mapper/InteractionMessageRecordMapper.java b/ruoyi-main/ruoyi-message/src/main/java/com/ruoyi/message/frequency/interactionmessagerecord/mapper/InteractionMessageRecordMapper.java new file mode 100644 index 0000000..a7a6ad9 --- /dev/null +++ b/ruoyi-main/ruoyi-message/src/main/java/com/ruoyi/message/frequency/interactionmessagerecord/mapper/InteractionMessageRecordMapper.java @@ -0,0 +1,69 @@ +package com.ruoyi.message.frequency.interactionmessagerecord.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.ruoyi.message.controller.resp.InteractionMessagePageResp; +import com.ruoyi.message.frequency.interactionmessagerecord.entity.InteractionMessageRecord; +import com.ruoyi.vo.UserVo; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * 互动消息记录Mapper接口 + * + * @author liwenlong + * @date 2023-10-17 + */ +public interface InteractionMessageRecordMapper extends BaseMapper +{ + /** + * 查询互动消息记录 + * + * @param id 互动消息记录主键 + * @return 互动消息记录 + */ + public InteractionMessageRecord selectInteractionMessageRecordById(Long id); + + /** + * 查询互动消息记录列表 + * + * @param interactionMessageRecord 互动消息记录 + * @return 互动消息记录集合 + */ + public List selectInteractionMessageRecordList(InteractionMessageRecord interactionMessageRecord); + + /** + * 新增互动消息记录 + * + * @param interactionMessageRecord 互动消息记录 + * @return 结果 + */ + public int insertInteractionMessageRecord(InteractionMessageRecord interactionMessageRecord); + + /** + * 修改互动消息记录 + * + * @param interactionMessageRecord 互动消息记录 + * @return 结果 + */ + public int updateInteractionMessageRecord(InteractionMessageRecord interactionMessageRecord); + + /** + * 删除互动消息记录 + * + * @param id 互动消息记录主键 + * @return 结果 + */ + public int deleteInteractionMessageRecordById(Long id); + + /** + * 批量删除互动消息记录 + * + * @param ids 需要删除的数据主键集合 + * @return 结果 + */ + public int deleteInteractionMessageRecordByIds(Long[] ids); + + Page interactionMessagePage(@Param("page") Page objectPage, @Param("userVo") UserVo userVo); +} diff --git a/ruoyi-main/ruoyi-message/src/main/java/com/ruoyi/message/frequency/interactionmessagerecord/mapper/mapping/InteractionMessageRecordMapper.xml b/ruoyi-main/ruoyi-message/src/main/java/com/ruoyi/message/frequency/interactionmessagerecord/mapper/mapping/InteractionMessageRecordMapper.xml new file mode 100644 index 0000000..9a5795c --- /dev/null +++ b/ruoyi-main/ruoyi-message/src/main/java/com/ruoyi/message/frequency/interactionmessagerecord/mapper/mapping/InteractionMessageRecordMapper.xml @@ -0,0 +1,181 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + select id, create_by, create_time, update_by, update_time, del_flag, user_id, user_type, message_type, title, content, is_read, is_show, skip_id, interaction_user_type, interaction_user_id, object_id from t_interaction_message_record + + + + + + + + insert into t_interaction_message_record + + id, + create_by, + create_time, + update_by, + update_time, + del_flag, + user_id, + user_type, + message_type, + title, + content, + is_read, + is_show, + skip_id, + interaction_user_type, + interaction_user_id, + object_id, + + + #{id}, + #{createBy}, + #{createTime}, + #{updateBy}, + #{updateTime}, + #{delFlag}, + #{userId}, + #{userType}, + #{messageType}, + #{title}, + #{content}, + #{isRead}, + #{isShow}, + #{skipId}, + #{interactionUserType}, + #{interactionUserId}, + #{objectId}, + + + + + update t_interaction_message_record + + create_by = #{createBy}, + create_time = #{createTime}, + update_by = #{updateBy}, + update_time = #{updateTime}, + del_flag = #{delFlag}, + user_id = #{userId}, + user_type = #{userType}, + message_type = #{messageType}, + title = #{title}, + content = #{content}, + is_read = #{isRead}, + is_show = #{isShow}, + skip_id = #{skipId}, + interaction_user_type = #{interactionUserType}, + interaction_user_id = #{interactionUserId}, + object_id = #{objectId}, + + where id = #{id} + + + + delete from t_interaction_message_record where id = #{id} + + + + delete from t_interaction_message_record where id in + + #{id} + + + + + \ No newline at end of file diff --git a/ruoyi-main/ruoyi-message/src/main/java/com/ruoyi/message/frequency/interactionmessagerecord/model/param/InteractionMessageRecordParam.java b/ruoyi-main/ruoyi-message/src/main/java/com/ruoyi/message/frequency/interactionmessagerecord/model/param/InteractionMessageRecordParam.java new file mode 100644 index 0000000..721f5ae --- /dev/null +++ b/ruoyi-main/ruoyi-message/src/main/java/com/ruoyi/message/frequency/interactionmessagerecord/model/param/InteractionMessageRecordParam.java @@ -0,0 +1,85 @@ +package com.ruoyi.message.frequency.interactionmessagerecord.model.param; + +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; + +/** + * 互动消息记录对象 t_interaction_message_record + * + * @author liwenlong + * @date 2023-10-17 + */ +@Data +@Accessors(chain = true) +public class InteractionMessageRecordParam extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + @ApiModelProperty("租户号") + private Long id; + + @ApiModelProperty("删除标志;1 正常 2 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("用户id;设计师和表现师") + @Excel(name = "用户id;设计师和表现师") + private Long userId; + + @ApiModelProperty("用户类型") + @Excel(name = "用户类型") + private Integer userType; + + @ApiModelProperty("消息类型;1点赞消息 2评论消息 3关注消息") + @Excel(name = "消息类型;1点赞消息 2评论消息 3关注消息") + private Integer messageType; + + @ApiModelProperty("标语") + @Excel(name = "标语") + private String title; + + @ApiModelProperty("内容") + @Excel(name = "内容") + private String content; + + @ApiModelProperty("是否已读;1未读 2 已读") + @Excel(name = "是否已读;1未读 2 已读") + private String isRead; + + @ApiModelProperty("是否清空;1 不清空 2 清空") + @Excel(name = "是否清空;1 不清空 2 清空") + private String isShow; + + @ApiModelProperty("跳转主体id") + @Excel(name = "跳转主体id") + private Long skipId; + + @ApiModelProperty("用户类型 ") + @Excel(name = "用户类型 ") + private Integer interactionUserType; + + @ApiModelProperty("互动消息用户id") + @Excel(name = "互动消息用户id") + private Long interactionUserId; + + @ApiModelProperty("对应的主体id") + @Excel(name = "对应的主体id") + private Long objectId; + + + + + + + + + + + + + + + +} diff --git a/ruoyi-main/ruoyi-message/src/main/java/com/ruoyi/message/frequency/interactionmessagerecord/model/result/InteractionMessageRecordResult.java b/ruoyi-main/ruoyi-message/src/main/java/com/ruoyi/message/frequency/interactionmessagerecord/model/result/InteractionMessageRecordResult.java new file mode 100644 index 0000000..9425d4c --- /dev/null +++ b/ruoyi-main/ruoyi-message/src/main/java/com/ruoyi/message/frequency/interactionmessagerecord/model/result/InteractionMessageRecordResult.java @@ -0,0 +1,72 @@ +package com.ruoyi.message.frequency.interactionmessagerecord.model.result; + +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; + +/** + * 互动消息记录对象 t_interaction_message_record + * + * @author liwenlong + * @date 2023-10-17 + */ +@Data +@Accessors(chain = true) +public class InteractionMessageRecordResult extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + @ApiModelProperty("租户号") + private Long id; + + @ApiModelProperty("删除标志;1 正常 2 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("用户id;设计师和表现师") + @Excel(name = "用户id;设计师和表现师") + private Long userId; + + @ApiModelProperty("用户类型") + @Excel(name = "用户类型") + private Integer userType; + + @ApiModelProperty("消息类型;1点赞消息 2评论消息 3关注消息") + @Excel(name = "消息类型;1点赞消息 2评论消息 3关注消息") + private Integer messageType; + + @ApiModelProperty("标语") + @Excel(name = "标语") + private String title; + + @ApiModelProperty("内容") + @Excel(name = "内容") + private String content; + + @ApiModelProperty("是否已读;1未读 2 已读") + @Excel(name = "是否已读;1未读 2 已读") + private String isRead; + + @ApiModelProperty("是否清空;1 不清空 2 清空") + @Excel(name = "是否清空;1 不清空 2 清空") + private String isShow; + + @ApiModelProperty("跳转主体id") + @Excel(name = "跳转主体id") + private Long skipId; + + @ApiModelProperty("用户类型 ") + @Excel(name = "用户类型 ") + private Integer interactionUserType; + + @ApiModelProperty("互动消息用户id") + @Excel(name = "互动消息用户id") + private Long interactionUserId; + + @ApiModelProperty("对应的主体id") + @Excel(name = "对应的主体id") + private Long objectId; + + +} diff --git a/ruoyi-main/ruoyi-message/src/main/java/com/ruoyi/message/frequency/interactionmessagerecord/service/InteractionMessageRecordService.java b/ruoyi-main/ruoyi-message/src/main/java/com/ruoyi/message/frequency/interactionmessagerecord/service/InteractionMessageRecordService.java new file mode 100644 index 0000000..458e19b --- /dev/null +++ b/ruoyi-main/ruoyi-message/src/main/java/com/ruoyi/message/frequency/interactionmessagerecord/service/InteractionMessageRecordService.java @@ -0,0 +1,96 @@ +package com.ruoyi.message.frequency.interactionmessagerecord.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.ruoyi.enums.message.InteractionMessageEnums; +import com.ruoyi.controller.req.MessageReadOrDeleteReq; +import com.ruoyi.message.frequency.interactionmessagerecord.entity.InteractionMessageRecord; +import com.ruoyi.response.ResponseData; +import com.ruoyi.vo.PageBasic; +import com.ruoyi.vo.UserVo; + +import java.util.List; + +/** + * 互动消息记录Service接口 + * + * @author liwenlong + * @date 2023-10-17 + */ +public interface InteractionMessageRecordService extends IService +{ + /** + * 查询互动消息记录 + * + * @param id 互动消息记录主键 + * @return 互动消息记录 + */ + public InteractionMessageRecord selectInteractionMessageRecordById(Long id); + + /** + * 查询互动消息记录列表 + * + * @param interactionMessageRecord 互动消息记录 + * @return 互动消息记录集合 + */ + public List selectInteractionMessageRecordList(InteractionMessageRecord interactionMessageRecord); + + /** + * 新增互动消息记录 + * + * @param interactionMessageRecord 互动消息记录 + * @return 结果 + */ + public int insertInteractionMessageRecord(InteractionMessageRecord interactionMessageRecord); + + /** + * 修改互动消息记录 + * + * @param interactionMessageRecord 互动消息记录 + * @return 结果 + */ + public int updateInteractionMessageRecord(InteractionMessageRecord interactionMessageRecord); + + /** + * 批量删除互动消息记录 + * + * @param ids 需要删除的互动消息记录主键集合 + * @return 结果 + */ + public int deleteInteractionMessageRecordByIds(Long[] ids); + + /** + * 删除互动消息记录信息 + * + * @param id 互动消息记录主键 + * @return 结果 + */ + public int deleteInteractionMessageRecordById(Long id); + + /** + * 互动消息列表 + * @param req + * @param userVo + * @return + */ + ResponseData interactionMessagePage(PageBasic req, UserVo userVo); + + /** + * 互动消息列表_已读,删除消息 + * @param req + * @param userVo + * @return + */ + ResponseData interactionMessageReadOrDelete(MessageReadOrDeleteReq req, UserVo userVo); + + + /** + * 生成互动消息 + * @param userVo 当前用户 + * @param sendUserVo 目标用户 + * @param messageType 消息类型;1点赞消息 2评论消息 3关注消息 + * @param enums 具体类型看 InteractionMessageEnums 枚举 + * @param objectId + * + */ + void addInteractionMessage(UserVo userVo,UserVo sendUserVo, Integer messageType, Long objectId, Boolean isPush, InteractionMessageEnums enums); +} diff --git a/ruoyi-main/ruoyi-message/src/main/java/com/ruoyi/message/frequency/interactionmessagerecord/service/impl/InteractionMessageRecordServiceImpl.java b/ruoyi-main/ruoyi-message/src/main/java/com/ruoyi/message/frequency/interactionmessagerecord/service/impl/InteractionMessageRecordServiceImpl.java new file mode 100644 index 0000000..790d74d --- /dev/null +++ b/ruoyi-main/ruoyi-message/src/main/java/com/ruoyi/message/frequency/interactionmessagerecord/service/impl/InteractionMessageRecordServiceImpl.java @@ -0,0 +1,246 @@ +package com.ruoyi.message.frequency.interactionmessagerecord.service.impl; + +import cn.hutool.core.collection.CollectionUtil; +import cn.hutool.core.util.ObjectUtil; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.ruoyi.code.PublicCommon; +import com.ruoyi.common.page.PageResult; +import com.ruoyi.common.utils.DateUtils; +import com.ruoyi.controller.req.MessageReadOrDeleteReq; +import com.ruoyi.enums.message.InteractionMessageEnums; +import com.ruoyi.enums.user.UserEnums; +import com.ruoyi.frequency.customer.service.UserService; +import com.ruoyi.frequency.store.entity.Store; +import com.ruoyi.frequency.store.service.StoreService; +import com.ruoyi.message.controller.resp.InteractionMessagePageResp; +import com.ruoyi.message.frequency.interactionmessagerecord.entity.InteractionMessageRecord; +import com.ruoyi.message.frequency.interactionmessagerecord.mapper.InteractionMessageRecordMapper; +import com.ruoyi.message.frequency.interactionmessagerecord.service.InteractionMessageRecordService; +import com.ruoyi.push.service.PushService; +import com.ruoyi.response.ResponseData; +import com.ruoyi.utils.BusinessUtil; +import com.ruoyi.utils.wx.wecom.WecomUtil; +import com.ruoyi.vo.PageBasic; +import com.ruoyi.vo.UserInfo; +import com.ruoyi.vo.UserVo; +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.Map; +import java.util.Set; +import java.util.stream.Collectors; + +/** + * 互动消息记录Service业务层处理 + * + * @author liwenlong + * @date 2023-10-17 + */ +@Service +@Transactional(rollbackFor = Exception.class) +public class InteractionMessageRecordServiceImpl extends ServiceImpl implements InteractionMessageRecordService { + @Autowired + private InteractionMessageRecordMapper interactionMessageRecordMapper; + + /** + * 查询互动消息记录 + * + * @param id 互动消息记录主键 + * @return 互动消息记录 + */ + @Override + public InteractionMessageRecord selectInteractionMessageRecordById(Long id) { + return interactionMessageRecordMapper.selectInteractionMessageRecordById(id); + } + + /** + * 查询互动消息记录列表 + * + * @param interactionMessageRecord 互动消息记录 + * @return 互动消息记录 + */ + @Override + public List selectInteractionMessageRecordList(InteractionMessageRecord interactionMessageRecord) { + return interactionMessageRecordMapper.selectInteractionMessageRecordList(interactionMessageRecord); + } + + /** + * 新增互动消息记录 + * + * @param interactionMessageRecord 互动消息记录 + * @return 结果 + */ + @Override + public int insertInteractionMessageRecord(InteractionMessageRecord interactionMessageRecord) { + interactionMessageRecord.setCreateTime(DateUtils.getNowDate()); + return interactionMessageRecordMapper.insertInteractionMessageRecord(interactionMessageRecord); + } + + /** + * 修改互动消息记录 + * + * @param interactionMessageRecord 互动消息记录 + * @return 结果 + */ + @Override + public int updateInteractionMessageRecord(InteractionMessageRecord interactionMessageRecord) { + interactionMessageRecord.setUpdateTime(DateUtils.getNowDate()); + return interactionMessageRecordMapper.updateInteractionMessageRecord(interactionMessageRecord); + } + + /** + * 批量删除互动消息记录 + * + * @param ids 需要删除的互动消息记录主键 + * @return 结果 + */ + @Override + public int deleteInteractionMessageRecordByIds(Long[] ids) { + this.lambdaUpdate().set(InteractionMessageRecord::getDelFlag, PublicCommon.删除).in(InteractionMessageRecord::getId, ids).update(); + return ids.length; + } + + /** + * 删除互动消息记录信息 + * + * @param id 互动消息记录主键 + * @return 结果 + */ + @Override + public int deleteInteractionMessageRecordById(Long id) { + this.lambdaUpdate().set(InteractionMessageRecord::getDelFlag, PublicCommon.删除).eq(InteractionMessageRecord::getId, id).update(); + return 1; + } + + @Autowired + private UserService userService; + + @Override + public ResponseData interactionMessagePage(PageBasic req, UserVo userVo) { + Page page = this.baseMapper.interactionMessagePage(new Page<>(req.getPageNo(), req.getPageSize()), userVo); + + if (!page.getRecords().isEmpty()) { + Set userVoSet = page.getRecords().stream().map(resp -> new UserVo(resp.getUserType(), resp.getUserId())).collect(Collectors.toSet()); + //查询用户信息 + Map userMap = userService.selectUserInfoMap(userVoSet, userVo); + + page.getRecords().stream().forEach(resp -> { + resp.setUserInfo(userMap.get(new UserVo(resp.getUserType(), resp.getUserId()))); + }); + } + + return ResponseData.success(new PageResult<>(page)); + } + + @Override + public ResponseData interactionMessageReadOrDelete(MessageReadOrDeleteReq req, UserVo userVo) { + //1 标记已读 2 删除消息 + switch (req.getType()) { + case 1: + this.update().set("is_read", PublicCommon.Message.已读) + .eq("user_type", userVo.getUserType()) + .eq("user_id", userVo.getUserId()) + .eq("is_read", PublicCommon.Message.未读) + .in(CollectionUtil.isNotEmpty(req.getIds()), "id", req.getIds()).update(); + break; + case 2: + + this.update().set("is_show", PublicCommon.Message.清空) + .set("is_read", PublicCommon.Message.已读) + .eq("user_type", userVo.getUserType()) + .eq("user_id", userVo.getUserId()) + .eq("is_show", PublicCommon.Message.未清空) + .in(CollectionUtil.isNotEmpty(req.getIds()), "id", req.getIds()).update(); + break; + + default: + throw new IllegalStateException("Unexpected value: " + req.getType()); + } + return ResponseData.success(); + } + + + @Autowired + private PushService pushService; + + @Autowired + private WecomUtil wecomUtil; + + @Autowired + private StoreService storeService; + + @Autowired + private BusinessUtil businessUtil; + + + @Override + public void addInteractionMessage(UserVo userVo, UserVo sendUserVo, Integer messageType, Long objectId, Boolean isPush, InteractionMessageEnums enums) { + + if (!isPush) { + return; + } + if (BusinessUtil.isSelf(userVo, sendUserVo)) { + return; + } + if (sendUserVo == null) { + return; + } + + Boolean canPushMessage = businessUtil.canPushMessage(userVo, sendUserVo); + if (!canPushMessage) { + return; + } + //互动消息 + InteractionMessageRecord messageRecord = new InteractionMessageRecord() + .setMessageType(messageType) + .setInteractionUserId(userVo.getUserId()) + .setInteractionUserType(userVo.getUserType()) + .setSkipId(objectId) + .setObjectId(objectId); + + String title = enums.getTitle(); + String content = enums.getContent(); + + messageRecord.setTitle(title); + messageRecord.setContent(content); + + messageRecord.setType(enums.getCode()); + + messageRecord.setUserType(sendUserVo.getUserType()) + .setUserId(sendUserVo.getUserId()); + + this.save(messageRecord); + + pushService.push(sendUserVo, objectId, messageRecord.getId(), enums); + + //给表现师发送企业微信消息 + if (ObjectUtil.equal(UserEnums.store.getCode(), sendUserVo.getUserType())) { + + Store store = storeService.getById(sendUserVo.getUserId()); + + if (store != null) { + + if (ObjectUtil.isNotEmpty(store.getWecomUserid())) { + wecomUtil.sendTextMessage(content, store.getWecomUserid()); + } else { + //获取表现师在企业微信中的userid + if (ObjectUtil.isNotEmpty(store.getMobile())) { + String userid = wecomUtil.getUserid(store.getMobile()); + if (ObjectUtil.isNotEmpty(userid)) { + storeService.lambdaUpdate().set(Store::getWecomUserid, userid).eq(Store::getId, store.getId()).update(); + wecomUtil.sendTextMessage(content, store.getWecomUserid()); + } + } + + } + + } + + + } + + } +} diff --git a/ruoyi-main/ruoyi-post/pom.xml b/ruoyi-main/ruoyi-post/pom.xml new file mode 100644 index 0000000..3c8b069 --- /dev/null +++ b/ruoyi-main/ruoyi-post/pom.xml @@ -0,0 +1,34 @@ + + + 4.0.0 + + com.ruoyi + ruoyi-main + 3.7.0 + + + ruoyi-post + + + 8 + 8 + UTF-8 + + + + + com.ruoyi + ruoyi-custom + 3.7.0 + + + + com.ruoyi + ruoyi-message + 3.7.0 + + + + \ No newline at end of file diff --git a/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/controller/ApiPostCommentController.java b/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/controller/ApiPostCommentController.java new file mode 100644 index 0000000..24808f8 --- /dev/null +++ b/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/controller/ApiPostCommentController.java @@ -0,0 +1,70 @@ +package com.ruoyi.post.controller; + +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.ruoyi.annotations.UserLoginToken; +import com.ruoyi.common.page.PageResult; +import com.ruoyi.controller.req.DialoguePageReq; +import com.ruoyi.post.controller.req.DeleteCommentReq; +import com.ruoyi.post.controller.req.PostCommentPageReq; +import com.ruoyi.post.controller.req.PostCommentReq; +import com.ruoyi.post.controller.resp.PostCommentPageResp; +import com.ruoyi.post.controller.resp.PostCommentResp; +import com.ruoyi.post.frequency.postcomment.service.PostCommentService; +import com.ruoyi.response.ResponseData; +import com.ruoyi.vo.BodyIdReq; +import com.ruoyi.vo.RyController; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + + +/** + * 帖子评论相关 + * @author liwenlong + * + */ +@CrossOrigin +@RestController +@RequestMapping("/api/postComment") +@Api(tags = "帖子评论相关") +public class ApiPostCommentController extends RyController { + + @Autowired + private PostCommentService postCommentService; + + @PostMapping("/postComment") + @UserLoginToken + @ApiOperation(value = "帖子评论", notes = "帖子评论") + public ResponseData postComment(@RequestBody PostCommentReq req) { + return postCommentService.postComment(req,getUserVo()); + } + + + @PostMapping("/postCommentPage") + @ApiOperation(value = "帖子评论列表", notes = "帖子评论列表") + public ResponseData> postCommentPage(@RequestBody PostCommentPageReq req) { + return postCommentService.postCommentPage(req,getUserVo()); + } + + + @PostMapping("/deleteComment") + @UserLoginToken + @ApiOperation(value = "删除评论", notes = "删除评论") + public ResponseData deleteComment(@RequestBody DeleteCommentReq req) { + return postCommentService.deleteComment(req,getUserVo()); + } + + @PostMapping("/postCommentDetail") + @ApiOperation(value = "帖子评论详情", notes = "帖子评论详情") + public ResponseData postCommentDetail(@RequestBody BodyIdReq req) { + return postCommentService.postCommentDetail(req.getId(),getUserVo()); + } + + @PostMapping("/postCommentDialoguePage") + @ApiOperation(value = "帖子对话评论列表", notes = "帖子对话评论列表") + public ResponseData>> postCommentDialoguePage(@RequestBody DialoguePageReq req) { + return postCommentService.postCommentDialoguePage(req,getUserVo()); + } + +} diff --git a/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/controller/ApiPostLikeController.java b/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/controller/ApiPostLikeController.java new file mode 100644 index 0000000..e74a742 --- /dev/null +++ b/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/controller/ApiPostLikeController.java @@ -0,0 +1,42 @@ +package com.ruoyi.post.controller; + +import com.ruoyi.annotations.UserLoginToken; +import com.ruoyi.post.controller.req.PostLikeReq; +import com.ruoyi.post.frequency.postlike.service.PostLikeService; +import com.ruoyi.response.ResponseData; +import com.ruoyi.vo.RyController; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + + +/** + * 帖子点赞相关 + * @author liwenlong + * + */ +@CrossOrigin +@RestController +@RequestMapping("/api/postLike") +@Api(tags = "帖子点赞相关") +public class ApiPostLikeController extends RyController { + + @Autowired + private PostLikeService postLikeService; + + + /** + * 帖子点赞 + * + * @return + */ + @PostMapping("/postLike") + @UserLoginToken + @ApiOperation(value = "帖子点赞", notes = "帖子点赞") + public ResponseData postLike(@RequestBody PostLikeReq req) { + return postLikeService.postLike(req,getUserVo()); + } + + +} diff --git a/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/controller/ApiPostReportController.java b/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/controller/ApiPostReportController.java new file mode 100644 index 0000000..ce3995e --- /dev/null +++ b/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/controller/ApiPostReportController.java @@ -0,0 +1,34 @@ +package com.ruoyi.post.controller; + +import com.ruoyi.annotations.UserLoginToken; +import com.ruoyi.post.controller.req.PostReportReq; +import com.ruoyi.post.frequency.posreport.service.PostReportService; +import com.ruoyi.response.ResponseData; +import com.ruoyi.vo.RyController; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + + +/** + * 帖子举报相关 + * @author liwenlong + * + */ +@CrossOrigin +@RestController +@RequestMapping("/api/postReport") +@Api(tags = "帖子举报相关") +public class ApiPostReportController extends RyController { + + @Autowired + private PostReportService postReportService; + + @PostMapping("/postReport") + @UserLoginToken + @ApiOperation(value = "帖子举报", notes = "帖子举报") + public ResponseData postReport(@RequestBody PostReportReq req) { + return postReportService.postReport(req,getUserVo()); + } +} diff --git a/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/controller/ApiPostShieldController.java b/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/controller/ApiPostShieldController.java new file mode 100644 index 0000000..8ea7345 --- /dev/null +++ b/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/controller/ApiPostShieldController.java @@ -0,0 +1,36 @@ +package com.ruoyi.post.controller; + +import com.ruoyi.annotations.UserLoginToken; +import com.ruoyi.post.frequency.posshield.service.PostShieldService; +import com.ruoyi.response.ResponseData; +import com.ruoyi.vo.BodyIdReq; +import com.ruoyi.vo.RyController; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + + +/** + * 帖子屏蔽 + * @author liwenlong + * + */ +@CrossOrigin +@RestController +@RequestMapping("/api/postShield") +@Api(tags = "帖子屏蔽") +public class ApiPostShieldController extends RyController { + + @Autowired + private PostShieldService postShieldService; + + @PostMapping("/postShield") + @UserLoginToken + @ApiOperation(value = "帖子屏蔽", notes = "帖子屏蔽") + public ResponseData postShield(@RequestBody BodyIdReq req) { + return postShieldService.postShield(req.getId(),getUserVo()); + } + + +} diff --git a/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/controller/ApiPostTypeController.java b/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/controller/ApiPostTypeController.java new file mode 100644 index 0000000..4869a88 --- /dev/null +++ b/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/controller/ApiPostTypeController.java @@ -0,0 +1,38 @@ +package com.ruoyi.post.controller; + +import com.ruoyi.post.controller.req.PostTypeListReq; +import com.ruoyi.post.frequency.posttype.entity.PostType; +import com.ruoyi.post.frequency.posttype.service.PostTypeService; +import com.ruoyi.response.ResponseData; +import com.ruoyi.vo.RyController; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +/** + * 帖子分类 + * @author liwenlong + * + */ +@CrossOrigin +@RestController +@RequestMapping("/api/postType") +@Api(tags = "帖子分类") +public class ApiPostTypeController extends RyController { + + @Autowired + private PostTypeService postTypeService; + + + @ApiOperation(value = "获取帖子分类列表") + @PostMapping("/postTypeList") + public ResponseData> postTypeList(@RequestBody PostTypeListReq req) { + return postTypeService.postTypeList(req); + } + + + +} diff --git a/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/controller/req/CommentMessageReadOrDeleteReq.java b/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/controller/req/CommentMessageReadOrDeleteReq.java new file mode 100644 index 0000000..032fab5 --- /dev/null +++ b/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/controller/req/CommentMessageReadOrDeleteReq.java @@ -0,0 +1,29 @@ +package com.ruoyi.post.controller.req; + +import lombok.Data; + +import javax.validation.constraints.NotNull; +import java.util.List; + +/** + * @author liwenlong + * @date 2023/4/1 10:05 + */ +@Data +public class CommentMessageReadOrDeleteReq { + + + /** + * 1 标记已读 2 删除消息 + */ + @NotNull(message = "类型不能为空") + private Integer type; + + /** + * 评论消息id 集合 为空删除全部 + */ + @NotNull(message = "评论消息id不能为空") + private List ids; + + +} diff --git a/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/controller/req/DeleteCommentReq.java b/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/controller/req/DeleteCommentReq.java new file mode 100644 index 0000000..7bdd1cf --- /dev/null +++ b/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/controller/req/DeleteCommentReq.java @@ -0,0 +1,25 @@ +package com.ruoyi.post.controller.req; + +import lombok.Data; + +import javax.validation.constraints.NotNull; + +/** + * @author liwenlong + * @date 2023/4/13 18:28 + */ +@Data +public class DeleteCommentReq { + + /** + * id + */ + @NotNull(message = "id不能为空") + private Long id; + +// /** +// * 类型 1 帖子评论 2 +// */ +// @NotNull(message = "类型不能为空") +// private Integer type; +} diff --git a/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/controller/req/LikeMessageReadOrDeleteReq.java b/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/controller/req/LikeMessageReadOrDeleteReq.java new file mode 100644 index 0000000..f56f47b --- /dev/null +++ b/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/controller/req/LikeMessageReadOrDeleteReq.java @@ -0,0 +1,26 @@ +package com.ruoyi.post.controller.req; + +import lombok.Data; + +import javax.validation.constraints.NotNull; +import java.util.List; + +/** + * @author liwenlong + * @date 2023/4/1 10:04 + */ +@Data +public class LikeMessageReadOrDeleteReq { + + /** + * 1 标记已读 2 删除消息 + */ + @NotNull(message = "类型不能为空") + private Integer type; + + /** + * 点赞消息id 集合 为空删除全部 + */ + @NotNull(message = "点赞消息id不能为空") + private List ids; +} diff --git a/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/controller/req/PostCommentPageReq.java b/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/controller/req/PostCommentPageReq.java new file mode 100644 index 0000000..847f5bb --- /dev/null +++ b/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/controller/req/PostCommentPageReq.java @@ -0,0 +1,36 @@ +package com.ruoyi.post.controller.req; + +import com.ruoyi.vo.PageBasic; +import com.ruoyi.vo.UserVo; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import javax.validation.constraints.NotNull; +import java.util.List; + +/** + * @author liwenlong + * @date 2023/4/17 14:18 + */ +@Data +public class PostCommentPageReq extends PageBasic { + + @NotNull(message = "帖子id不能为空") + @ApiModelProperty(value = "帖子id", required = true) + private Long postId; + + @ApiModelProperty(value = "上级评论id", required = false) + private Long parentId; + + @ApiModelProperty("排序 1时间 2热度") + private Integer sortType; + + @ApiModelProperty(value = "1升序 2 降序") + private Integer isAsc; + + @ApiModelProperty(value = "拉黑用户") + private List blockUserList; + + @ApiModelProperty(value = "屏蔽用户") + private List shieldUserList; +} diff --git a/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/controller/req/PostCommentReq.java b/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/controller/req/PostCommentReq.java new file mode 100644 index 0000000..be2e4db --- /dev/null +++ b/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/controller/req/PostCommentReq.java @@ -0,0 +1,29 @@ +package com.ruoyi.post.controller.req; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import javax.validation.constraints.NotNull; + +/** + * @author liwenlong + * @date 2023/4/17 14:17 + */ +@Data +public class PostCommentReq { + + + @NotNull(message = "帖子id不能为空") + @ApiModelProperty(value = "帖子id", required = true) + private Long postId; + + @ApiModelProperty(value = "上级评论id,如果没有上级评论,(不传值默认0,评论帖子)") + private Long parentId = 0L; + + @ApiModelProperty(value = "评论内容", required = true) + @NotNull(message = "评论内容不能为空") + private String content; + + @ApiModelProperty("评论图片") + private String image; +} diff --git a/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/controller/req/PostLikeReq.java b/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/controller/req/PostLikeReq.java new file mode 100644 index 0000000..d042aa5 --- /dev/null +++ b/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/controller/req/PostLikeReq.java @@ -0,0 +1,27 @@ +package com.ruoyi.post.controller.req; + +import lombok.Data; + +import javax.validation.constraints.NotNull; + +/** + * @author liwenlong + * @date 2023/4/17 16:18 + */ +@Data +public class PostLikeReq { + + + /** + * 1 帖子 2 帖子评论 + */ + @NotNull(message = "类型不能为空") + private Integer type; + + /** + * 帖子id/帖子评论id + */ + @NotNull(message = "objectId不能为空") + private Long objectId; + +} diff --git a/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/controller/req/PostPageReq.java b/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/controller/req/PostPageReq.java new file mode 100644 index 0000000..09f31d7 --- /dev/null +++ b/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/controller/req/PostPageReq.java @@ -0,0 +1,46 @@ +package com.ruoyi.post.controller.req; + +import com.ruoyi.vo.PageBasic; +import com.ruoyi.vo.UserVo; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.List; + +/** + * @author liwenlong + * @date 2023/4/17 14:07 + */ +@Data +public class PostPageReq extends PageBasic { + + @ApiModelProperty(value = "类型 1 关注 2 发现") + private Integer type; + + @ApiModelProperty(value = "帖子分类id") + private Long postTypeId; + + @ApiModelProperty(value = "关键字搜索") + private String keyword; + + @ApiModelProperty(value = "用户类型 1 用户 对应枚举 UserEnums") + private Integer userType; + + @ApiModelProperty(value = "帖子类型 1 帖子(用户发布) 2资讯(平台发布)") + private Integer postType; + + @ApiModelProperty(value = "用户id") + private Long userId; + + @ApiModelProperty("排序方式 1 最新 2 点赞最多 3 评论最多") + private Integer orderSort; + + @ApiModelProperty(value = "拉黑用户") + private List blockUserList; + + @ApiModelProperty(value = "屏蔽用户") + private List shieldUserList; + + @ApiModelProperty(value = "屏蔽的帖子") + private List shieldPostIdList; +} diff --git a/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/controller/req/PostReleaseReq.java b/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/controller/req/PostReleaseReq.java new file mode 100644 index 0000000..c08375f --- /dev/null +++ b/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/controller/req/PostReleaseReq.java @@ -0,0 +1,36 @@ +package com.ruoyi.post.controller.req; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + * @author liwenlong + * @date 2023/4/17 14:02 + */ +@Data +public class PostReleaseReq { + + + @ApiModelProperty(value = "帖子id") + private Long id; + + @ApiModelProperty(value = "帖子分类id") + private Long postTypeId; + + @ApiModelProperty(value = "标题") + private String title; + + @ApiModelProperty(value = "内容") + private String content; + + @ApiModelProperty(value = "封面图") + private String coverImage; + + @ApiModelProperty(value = "视频路径") + private String videoUrl; + + @ApiModelProperty(value = "地址") + private String address; + + +} diff --git a/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/controller/req/PostReportReq.java b/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/controller/req/PostReportReq.java new file mode 100644 index 0000000..6164ee0 --- /dev/null +++ b/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/controller/req/PostReportReq.java @@ -0,0 +1,30 @@ +package com.ruoyi.post.controller.req; + +import lombok.Data; + +/** + * @author liwenlong + * @date 2023/4/17 17:08 + */ +@Data +public class PostReportReq { + + /** + * 帖子id + */ + private Long postId; + + /** + * 举报原因 + */ + private String reason; + + /** + * 内容 + */ + private String content; + /** + * 图片 + */ + private String images; +} diff --git a/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/controller/req/PostTypeListReq.java b/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/controller/req/PostTypeListReq.java new file mode 100644 index 0000000..6aa89df --- /dev/null +++ b/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/controller/req/PostTypeListReq.java @@ -0,0 +1,18 @@ +package com.ruoyi.post.controller.req; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + * @author a + * @date 2024/1/29 15:24 + */ +@Data +public class PostTypeListReq { + + @ApiModelProperty("用户类型") + private Integer userType; + + @ApiModelProperty("1帖子 2 资讯") + private Integer type; +} diff --git a/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/controller/resp/CommentMessagePageResp.java b/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/controller/resp/CommentMessagePageResp.java new file mode 100644 index 0000000..38ddfb2 --- /dev/null +++ b/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/controller/resp/CommentMessagePageResp.java @@ -0,0 +1,72 @@ +package com.ruoyi.post.controller.resp; + +import lombok.Data; + +import java.util.Date; + +/** + * @author liwenlong + * @date 2023/4/1 9:54 + */ +@Data +public class CommentMessagePageResp { + + /** + * 主键id + */ + private Long id; + /** + * 消息类型 + */ + private Integer type; + /** + * 标题 + */ + private String title; + /** + * 内容 + */ + private String content; + /** + * 1未读 2 已读 + */ + private Integer isRead; + /** + * 是否清空 1 不清空 2 清空 + */ + private Integer isShow; + /** + * 创建时间 + */ + private Date createTime; + + + /** + * 跳转id + */ + private Long skipId; + + /** + * 用户id + */ + private Long userId; + + /** + * 用户类型 1 用户 2 商家 + */ + private Integer userType; + + + /** + * 头像 + */ + private String avatar; + + + /** + * 用户昵称 + */ + private String nickname; + + +} diff --git a/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/controller/resp/LikeMessagePageResp.java b/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/controller/resp/LikeMessagePageResp.java new file mode 100644 index 0000000..ef64e66 --- /dev/null +++ b/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/controller/resp/LikeMessagePageResp.java @@ -0,0 +1,75 @@ +package com.ruoyi.post.controller.resp; + +import lombok.Data; + +import java.util.Date; + +/** + * @author liwenlong + * @date 2023/3/31 17:51 + */ + +@Data +public class LikeMessagePageResp { + + /** + * 主键id + */ + private Long id; + /** + * 用户类型 : 1用户 2 商家 + */ + private Integer userType; + /** + * 用户id + */ + private Long userId; + + /** + * 消息类型 1 论坛 2 视频 + */ + private Integer type; + + /** + * 类型 + */ + private Integer objectType; + + /** + * 主体id + */ + private Long skipId; + + /** + * 标题 + */ + private String title; + /** + * 内容 + */ + private String content; + /** + * 1未读 2 已读 + */ + private Integer isRead; + /** + * 是否清空 1 不清空 2 清空 + */ + private Integer isShow; + /** + * 创建时间 + */ + private Date createTime; + + + /** + * 头像 + */ + private String avatar; + + + /** + * 用户昵称 + */ + private String nickname; +} diff --git a/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/controller/resp/PostCommentPageResp.java b/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/controller/resp/PostCommentPageResp.java new file mode 100644 index 0000000..ce44d3d --- /dev/null +++ b/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/controller/resp/PostCommentPageResp.java @@ -0,0 +1,70 @@ +package com.ruoyi.post.controller.resp; + +import com.ruoyi.vo.UserInfo; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.Date; +import java.util.List; + +/** + * @author liwenlong + * @date 2023/4/17 14:26 + */ +@Data +public class PostCommentPageResp { + + @ApiModelProperty(value = "租户号") + private Long id; + + @ApiModelProperty(value = "创建时间") + private Date createTime; + + @ApiModelProperty(value = "用户类型") + private Integer userType; + + @ApiModelProperty(value = "用户id") + private Long userId; + + @ApiModelProperty(value = "上级用户类型") + private Integer parentUserType; + + @ApiModelProperty(value = "上级用户id") + private Long parentUserId; + + @ApiModelProperty(value = "上级评论id") + private Long parentId; + + @ApiModelProperty(value = "用户信息") + private UserInfo userInfo; + + @ApiModelProperty(value = "上级用户用户昵称") + private UserInfo parentUserInfo; + + @ApiModelProperty(value = "内容") + private String content; + + @ApiModelProperty(value = "图片") + private String image; + + @ApiModelProperty("顶级评论id") + private Long topId; + + @ApiModelProperty(value = "点赞数") + private Integer likeNum; + + @ApiModelProperty(value = "评论数") + private Integer commentNum; + + @ApiModelProperty(value = "是否点赞 1 没有 2 点赞") + private Integer isLike; + + @ApiModelProperty(value = "是否自己 1 不是 2 是自己") + private Integer isSelf; + + @ApiModelProperty(value = "是否精选评论 1 不是 2 是") + private Integer isSelectedComment; + + @ApiModelProperty(value = "二级评论") + private List childrenList; +} diff --git a/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/controller/resp/PostCommentResp.java b/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/controller/resp/PostCommentResp.java new file mode 100644 index 0000000..88896df --- /dev/null +++ b/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/controller/resp/PostCommentResp.java @@ -0,0 +1,62 @@ +package com.ruoyi.post.controller.resp; + +import com.ruoyi.vo.UserInfo; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.Date; + +/** + * @author liwenlong + * + */ +@Data +public class PostCommentResp { + + + @ApiModelProperty(value = "评论id") + private Long id; + + @ApiModelProperty(value = "上级评论id") + private Long parentId; + + @ApiModelProperty(value = "评论内容") + private String content; + + @ApiModelProperty(value = "点赞数") + private Integer likeNum; + + @ApiModelProperty(value = "评论数") + private Integer commentNum; + + @ApiModelProperty(value = "是否点赞1没有 2点赞") + private Integer isLike; + + + @ApiModelProperty(value = "评论时间") + private Date createTime; + + @ApiModelProperty("顶级评论id") + private Long topId; + + @ApiModelProperty("用户类型") + private Integer userType; + + @ApiModelProperty("评论用户id") + private Long userId; + + + @ApiModelProperty(value = "评论用户信息") + private UserInfo userInfo; + + @ApiModelProperty("用户类型") + private Integer parentUserType; + + @ApiModelProperty("上级评论用户id") + private Long parentUserId; + + @ApiModelProperty(value = "上级评论用户信息") + private UserInfo parentUserInfo; + + +} diff --git a/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/controller/resp/PostDetailResp.java b/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/controller/resp/PostDetailResp.java new file mode 100644 index 0000000..94bdde4 --- /dev/null +++ b/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/controller/resp/PostDetailResp.java @@ -0,0 +1,87 @@ +package com.ruoyi.post.controller.resp; + +import com.ruoyi.vo.UserInfo; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.Date; + +/** + * @author liwenlong + * @date 2023/4/17 17:32 + */ +@Data +public class PostDetailResp { + + @ApiModelProperty(value = "帖子id") + private Long id; + + @ApiModelProperty(value = "时间") + private Date createTime; + + @ApiModelProperty(value = "头像") + private String avatar; + + @ApiModelProperty(value = "昵称") + private String nickname; + + @ApiModelProperty(value = "用户类型 1用户") + private Integer userType; + + @ApiModelProperty(value = "用户id") + private Long userId; + + @ApiModelProperty(value = "标题") + private String title; + + @ApiModelProperty(value = "帖子内容") + private String content; + + @ApiModelProperty("图片(包括封面图)") + private String coverImage; + + @ApiModelProperty("视频路径(一个)") + private String videoUrl; + + @ApiModelProperty(value = "分享数量") + private Integer shareNum; + + @ApiModelProperty(value = "点赞数量") + private Integer likeNum; + + @ApiModelProperty(value = "评论数量") + private Integer commentNum; + + @ApiModelProperty(value = "收藏数量") + private Integer collectNum; + + @ApiModelProperty(value = "浏览量") + private Integer browseNum; + + @ApiModelProperty(value = "审核状态 1 待审核 2 同意 3失败") + private Integer result; + + @ApiModelProperty(value = "失败原因") + private String reason; + + @ApiModelProperty(value = "是否点赞 1没有 2点赞") + private Integer isLike; + + @ApiModelProperty(value = "是否收藏 1没有 2收藏") + private Integer isCollect; + + @ApiModelProperty(value = "是否是自己 1不是 2是") + private Integer isSelf; + + @ApiModelProperty("地址") + private String address; + + @ApiModelProperty("帖子分类名称") + private String postTypeName; + + @ApiModelProperty("用户信息") + private UserInfo userInfo; + + @ApiModelProperty("描述") + private String describes; +} diff --git a/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/controller/resp/PostPageResp.java b/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/controller/resp/PostPageResp.java new file mode 100644 index 0000000..8075fb2 --- /dev/null +++ b/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/controller/resp/PostPageResp.java @@ -0,0 +1,93 @@ +package com.ruoyi.post.controller.resp; + +import com.ruoyi.post.controller.vo.SelectedComment; +import com.ruoyi.vo.UserInfo; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.Date; + +/** + * @author liwenlong + * @date 2023/4/17 17:30 + */ +@Data +public class PostPageResp { + + @ApiModelProperty(value = "帖子id") + private Long id; + + @ApiModelProperty(value = "时间") + private Date createTime; + + @ApiModelProperty(value = "用户类型 1用户") + private Integer userType; + + @ApiModelProperty(value = "用户id") + private Long userId; + + + @ApiModelProperty("封面图") + private String coverImage; + + @ApiModelProperty("视频路径(一个)") + private String videoUrl; + + @ApiModelProperty(value = "标题") + private String title; + + @ApiModelProperty(value = "帖子内容") + private String content; + + @ApiModelProperty(value = "分享数量") + private Integer shareNum; + + @ApiModelProperty(value = "点赞数量") + private Integer likeNum; + + @ApiModelProperty(value = "评论数量") + private Integer commentNum; + + @ApiModelProperty(value = "收藏数量") + private Integer collectNum; + + @ApiModelProperty(value = "浏览量") + private Integer browseNum; + + @ApiModelProperty(value = "审核状态 1 待审核 2 同意 3失败") + private Integer result; + + @ApiModelProperty(value = "失败原因") + private String reason; + + @ApiModelProperty(value = "是否点赞 1没有 2点赞") + private Integer isLike; + + @ApiModelProperty(value = "是否收藏 1没有 2收藏") + private Integer isCollect; + + @ApiModelProperty(value = "是否是自己 1不是 2是") + private Integer isSelf; + + @ApiModelProperty("地址") + private String address; + + @ApiModelProperty("用户信息") + private UserInfo userInfo; + + @ApiModelProperty("精选评论") + private SelectedComment selectedComment; + + @ApiModelProperty("是否推荐 1否 2是") + private Integer isRecommend; + + @ApiModelProperty("推荐排序") + private Integer sort; + + @ApiModelProperty("精彩评论id") + private Long commentId; + + @ApiModelProperty("描述") + private String describes; + +} diff --git a/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/controller/vo/SelectedComment.java b/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/controller/vo/SelectedComment.java new file mode 100644 index 0000000..b32621b --- /dev/null +++ b/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/controller/vo/SelectedComment.java @@ -0,0 +1,55 @@ +package com.ruoyi.post.controller.vo; + +import com.ruoyi.post.frequency.postcomment.entity.PostComment; +import com.ruoyi.vo.UserInfo; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; + +import java.util.Date; + +/** + * 帖子评论对象 t_post_comment + * + * @author liwenlong + * @date 2023-10-09 + */ +@Data +@Accessors(chain = true) +public class SelectedComment +{ + + @ApiModelProperty("租户号") + private Long id; + + @ApiModelProperty("创建时间") + private Date createTime; + + @ApiModelProperty("帖子id") + private Long postId; + + @ApiModelProperty("评论内容") + private String content; + + @ApiModelProperty("图片") + private String image; + + @ApiModelProperty("用户信息") + private UserInfo userInfo; + + @ApiModelProperty(value = "是否精选评论 1 不是 2 是") + private Integer isSelectedComment = 2; + + public SelectedComment(Integer isSelectedComment,PostComment postComment,UserInfo userInfo) { + this.id = postComment.getId(); + this.userInfo = userInfo; + this.postId = postComment.getPostId(); + this.content = postComment.getContent(); + this.image = postComment.getImage(); + this.createTime = postComment.getCreateTime(); + this.isSelectedComment = isSelectedComment; + } + + public SelectedComment() { + } +} diff --git a/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/frequency/posreport/controller/PostReportController.java b/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/frequency/posreport/controller/PostReportController.java new file mode 100644 index 0000000..35b16ea --- /dev/null +++ b/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/frequency/posreport/controller/PostReportController.java @@ -0,0 +1,109 @@ +package com.ruoyi.post.frequency.posreport.controller; + +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.page.TableDataInfo; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.common.utils.poi.ExcelUtil; +import com.ruoyi.post.frequency.posreport.entity.PostReport; +import com.ruoyi.post.frequency.posreport.service.PostReportService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +/** + * 论坛举报Controller + * + * @author liwenlong + * @date 2023-10-26 + */ +@RestController +@RequestMapping("/frequency/posreport") +public class PostReportController extends BaseController +{ + @Autowired + private PostReportService postReportService; + + /** + * 查询论坛举报列表 + */ + @PreAuthorize("@ss.hasPermi('frequency:posreport:list')") + @PostMapping("/list") + public TableDataInfo list(@RequestBody PostReport postReport) + { + startPage(); + List list = postReportService.selectPostReportList(postReport); + return getDataTable(list); + } + + /** + * 导出论坛举报列表 + */ + @PreAuthorize("@ss.hasPermi('frequency:posreport:export')") + @Log(title = "论坛举报", businessType = BusinessType.EXPORT) + @GetMapping("/export") + public AjaxResult export(PostReport postReport) + { + List list = postReportService.selectPostReportList(postReport); + ExcelUtil util = new ExcelUtil(PostReport.class); + return util.exportExcel(list, "论坛举报数据"); + } + + /** + * 获取论坛举报详细信息 + */ + @PreAuthorize("@ss.hasPermi('frequency:posreport:query')") + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") Long id) + { + return AjaxResult.success(postReportService.selectPostReportById(id)); + } + + /** + * 新增论坛举报 + */ + @PreAuthorize("@ss.hasPermi('frequency:posreport:add')") + @Log(title = "论坛举报", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody PostReport postReport) + { + return toAjax(postReportService.insertPostReport(postReport)); + } + + /** + * 修改论坛举报 + */ + @PreAuthorize("@ss.hasPermi('frequency:posreport:edit')") + @Log(title = "论坛举报", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody PostReport postReport) + { + return toAjax(postReportService.updatePostReport(postReport)); + } + + /** + * 删除论坛举报 + */ + @PreAuthorize("@ss.hasPermi('frequency:posreport:remove')") + @Log(title = "论坛举报", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}/{delFlag}") + public AjaxResult remove(@PathVariable Long[] ids,@PathVariable Integer delFlag) + { + return toAjax(postReportService.deletePostReportByIds(ids,delFlag)); + } + + + /** + * 举报处理 + */ + @PreAuthorize("@ss.hasPermi('frequency:posreport:handle')") + @Log(title = "论坛举报", businessType = BusinessType.UPDATE) + @PostMapping("/handle") + public AjaxResult handle(@RequestBody PostReport postReport) + { + return postReportService.handle(postReport); + } +} diff --git a/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/frequency/posreport/entity/PostReport.java b/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/frequency/posreport/entity/PostReport.java new file mode 100644 index 0000000..9b9a765 --- /dev/null +++ b/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/frequency/posreport/entity/PostReport.java @@ -0,0 +1,80 @@ +package com.ruoyi.post.frequency.posreport.entity; + +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableName; +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import com.ruoyi.post.frequency.post.entity.Post; +import com.ruoyi.vo.UserInfo; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; + +import java.util.Date; + +/** + * 论坛举报对象 t_post_report + * + * @author liwenlong + * @date 2023-10-26 + */ +@Data +@Accessors(chain = true) +@TableName("t_post_report") +public class PostReport extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + + @ApiModelProperty("租户号") + private Long id; + + @ApiModelProperty("删除状态 1 正常 2 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("用户类型") + @Excel(name = "用户类型") + private Integer userType; + + @ApiModelProperty("用户id") + @Excel(name = "用户id") + private Long userId; + + @ApiModelProperty("论坛id") + @Excel(name = "论坛id") + private Long postId; + + @ApiModelProperty("举报原因") + @Excel(name = "举报原因") + private String reason; + + @ApiModelProperty("内容") + @Excel(name = "内容") + private String content; + + @ApiModelProperty("图片") + @Excel(name = "图片") + private String images; + + @ApiModelProperty("处理结果 1 未处理 2 已处理 3拒绝处理") + @Excel(name = "处理结果 1 未处理 2 已处理 3拒绝处理") + private Integer result; + + @ApiModelProperty("用户信息") + @TableField(exist = false) + private UserInfo userInfo; + + @ApiModelProperty("帖子信息") + @TableField(exist = false) + private Post post; + + @ApiModelProperty("开始时间") + @TableField(exist = false) + private Date beginTime; + + @ApiModelProperty("结束时间") + @TableField(exist = false) + private Date endTime; + + +} diff --git a/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/frequency/posreport/mapper/PostReportMapper.java b/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/frequency/posreport/mapper/PostReportMapper.java new file mode 100644 index 0000000..69f2ca6 --- /dev/null +++ b/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/frequency/posreport/mapper/PostReportMapper.java @@ -0,0 +1,63 @@ +package com.ruoyi.post.frequency.posreport.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.ruoyi.post.frequency.posreport.entity.PostReport; + +import java.util.List; + +/** + * 论坛举报Mapper接口 + * + * @author liwenlong + * @date 2023-10-26 + */ +public interface PostReportMapper extends BaseMapper +{ + /** + * 查询论坛举报 + * + * @param id 论坛举报主键 + * @return 论坛举报 + */ + public PostReport selectPostReportById(Long id); + + /** + * 查询论坛举报列表 + * + * @param postReport 论坛举报 + * @return 论坛举报集合 + */ + public List selectPostReportList(PostReport postReport); + + /** + * 新增论坛举报 + * + * @param postReport 论坛举报 + * @return 结果 + */ + public int insertPostReport(PostReport postReport); + + /** + * 修改论坛举报 + * + * @param postReport 论坛举报 + * @return 结果 + */ + public int updatePostReport(PostReport postReport); + + /** + * 删除论坛举报 + * + * @param id 论坛举报主键 + * @return 结果 + */ + public int deletePostReportById(Long id); + + /** + * 批量删除论坛举报 + * + * @param ids 需要删除的数据主键集合 + * @return 结果 + */ + public int deletePostReportByIds(Long[] ids); +} diff --git a/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/frequency/posreport/mapper/mapping/PostReportMapper.xml b/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/frequency/posreport/mapper/mapping/PostReportMapper.xml new file mode 100644 index 0000000..5b17839 --- /dev/null +++ b/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/frequency/posreport/mapper/mapping/PostReportMapper.xml @@ -0,0 +1,162 @@ + + + + + + + + + + + + + + + + + + + + + + + SELECT + t.id, + t.create_by, + t.create_time, + t.update_by, + t.update_time, + t.del_flag, + t.user_type, + t.user_id, + t.post_id, + t.reason, + t.content, + t.images, + t.result, + t.remark + FROM + t_post_report AS t + LEFT JOIN t_store s on t.user_id = s.id and t.user_type = 2 + LEFT JOIN t_customer c on t.user_id = c.id and t.user_type = 1 + LEFT JOIN t_sale sa on t.user_id = sa.id and t.user_type = 3 + LEFT JOIN t_post p on t.post_id = p.id + + + + + + + + insert into t_post_report + + id, + create_by, + create_time, + update_by, + update_time, + del_flag, + user_type, + user_id, + post_id, + reason, + content, + images, + result, + remark, + + + #{id}, + #{createBy}, + #{createTime}, + #{updateBy}, + #{updateTime}, + #{delFlag}, + #{userType}, + #{userId}, + #{postId}, + #{reason}, + #{content}, + #{images}, + #{result}, + #{remark}, + + + + + update t_post_report + + create_by = #{createBy}, + create_time = #{createTime}, + update_by = #{updateBy}, + update_time = #{updateTime}, + del_flag = #{delFlag}, + user_type = #{userType}, + user_id = #{userId}, + post_id = #{postId}, + reason = #{reason}, + content = #{content}, + images = #{images}, + result = #{result}, + remark = #{remark}, + + where id = #{id} + + + + delete from t_post_report where id = #{id} + + + + delete from t_post_report where id in + + #{id} + + + \ No newline at end of file diff --git a/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/frequency/posreport/model/param/PostReportParam.java b/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/frequency/posreport/model/param/PostReportParam.java new file mode 100644 index 0000000..f2ae054 --- /dev/null +++ b/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/frequency/posreport/model/param/PostReportParam.java @@ -0,0 +1,65 @@ +package com.ruoyi.post.frequency.posreport.model.param; + +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; + +/** + * 论坛举报对象 t_post_report + * + * @author liwenlong + * @date 2023-10-26 + */ +@Data +@Accessors(chain = true) +public class PostReportParam extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + @ApiModelProperty("租户号") + private Long id; + + @ApiModelProperty("删除状态 1 正常 2 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("用户类型") + @Excel(name = "用户类型") + private Integer userType; + + @ApiModelProperty("用户id") + @Excel(name = "用户id") + private Long userId; + + @ApiModelProperty("论坛id") + @Excel(name = "论坛id") + private Long postId; + + @ApiModelProperty("举报原因") + @Excel(name = "举报原因") + private String reason; + + @ApiModelProperty("内容") + @Excel(name = "内容") + private String content; + + @ApiModelProperty("图片") + @Excel(name = "图片") + private String images; + + @ApiModelProperty("处理结果 1 未处理 2 已处理 3拒绝处理") + @Excel(name = "处理结果 1 未处理 2 已处理 3拒绝处理") + private Integer result; + + + + + + + + + + + +} diff --git a/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/frequency/posreport/model/result/PostReportResult.java b/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/frequency/posreport/model/result/PostReportResult.java new file mode 100644 index 0000000..bff110e --- /dev/null +++ b/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/frequency/posreport/model/result/PostReportResult.java @@ -0,0 +1,56 @@ +package com.ruoyi.post.frequency.posreport.model.result; + +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; + +/** + * 论坛举报对象 t_post_report + * + * @author liwenlong + * @date 2023-10-26 + */ +@Data +@Accessors(chain = true) +public class PostReportResult extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + @ApiModelProperty("租户号") + private Long id; + + @ApiModelProperty("删除状态 1 正常 2 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("用户类型") + @Excel(name = "用户类型") + private Integer userType; + + @ApiModelProperty("用户id") + @Excel(name = "用户id") + private Long userId; + + @ApiModelProperty("论坛id") + @Excel(name = "论坛id") + private Long postId; + + @ApiModelProperty("举报原因") + @Excel(name = "举报原因") + private String reason; + + @ApiModelProperty("内容") + @Excel(name = "内容") + private String content; + + @ApiModelProperty("图片") + @Excel(name = "图片") + private String images; + + @ApiModelProperty("处理结果 1 未处理 2 已处理 3拒绝处理") + @Excel(name = "处理结果 1 未处理 2 已处理 3拒绝处理") + private Integer result; + + +} diff --git a/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/frequency/posreport/service/PostReportService.java b/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/frequency/posreport/service/PostReportService.java new file mode 100644 index 0000000..cfd6b8b --- /dev/null +++ b/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/frequency/posreport/service/PostReportService.java @@ -0,0 +1,83 @@ +package com.ruoyi.post.frequency.posreport.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.post.controller.req.PostReportReq; +import com.ruoyi.post.frequency.posreport.entity.PostReport; +import com.ruoyi.response.ResponseData; +import com.ruoyi.vo.UserVo; + +import java.util.List; + +/** + * 论坛举报Service接口 + * + * @author liwenlong + * @date 2023-10-26 + */ +public interface PostReportService extends IService +{ + /** + * 查询论坛举报 + * + * @param id 论坛举报主键 + * @return 论坛举报 + */ + public PostReport selectPostReportById(Long id); + + /** + * 查询论坛举报列表 + * + * @param postReport 论坛举报 + * @return 论坛举报集合 + */ + public List selectPostReportList(PostReport postReport); + + /** + * 新增论坛举报 + * + * @param postReport 论坛举报 + * @return 结果 + */ + public int insertPostReport(PostReport postReport); + + /** + * 修改论坛举报 + * + * @param postReport 论坛举报 + * @return 结果 + */ + public int updatePostReport(PostReport postReport); + + /** + * 批量删除论坛举报 + * + * @param ids 需要删除的论坛举报主键集合 + * @return 结果 + */ + public int deletePostReportByIds(Long[] ids,Integer delFlag); + + /** + * 删除论坛举报信息 + * + * @param id 论坛举报主键 + * @return 结果 + */ + public int deletePostReportById(Long id); + + /** + * 举报处理 + * @param postReport + * @return + */ + AjaxResult handle(PostReport postReport); + + /** + * 帖子举报 + * @param req + * @param userVo + * @return + */ + ResponseData postReport(PostReportReq req, UserVo userVo); + +} diff --git a/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/frequency/posreport/service/impl/PostReportServiceImpl.java b/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/frequency/posreport/service/impl/PostReportServiceImpl.java new file mode 100644 index 0000000..32e7854 --- /dev/null +++ b/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/frequency/posreport/service/impl/PostReportServiceImpl.java @@ -0,0 +1,185 @@ +package com.ruoyi.post.frequency.posreport.service.impl; + +import cn.hutool.core.collection.CollectionUtil; +import cn.hutool.core.util.ObjectUtil; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.ruoyi.code.PublicCommon; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.utils.DateUtils; +import com.ruoyi.enums.process.ProcessResultEnums; +import com.ruoyi.frequency.customer.service.UserService; +import com.ruoyi.post.controller.req.PostReportReq; +import com.ruoyi.post.frequency.posreport.entity.PostReport; +import com.ruoyi.post.frequency.posreport.mapper.PostReportMapper; +import com.ruoyi.post.frequency.posreport.service.PostReportService; +import com.ruoyi.post.frequency.post.entity.Post; +import com.ruoyi.post.frequency.post.service.PostService; +import com.ruoyi.response.ResponseData; +import com.ruoyi.vo.UserInfo; +import com.ruoyi.vo.UserVo; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.stream.Collectors; + +/** + * 论坛举报Service业务层处理 + * + * @author liwenlong + * @date 2023-10-26 + */ +@Service +@Transactional(rollbackFor = Exception.class) +public class PostReportServiceImpl extends ServiceImpl implements PostReportService +{ + @Autowired + private PostReportMapper postReportMapper; + + @Autowired + private UserService userService; + + @Autowired + private PostService postService; + + /** + * 查询论坛举报 + * + * @param id 论坛举报主键 + * @return 论坛举报 + */ + @Override + public PostReport selectPostReportById(Long id) + { + PostReport s = postReportMapper.selectPostReportById(id); + if (s != null){ + Set userVoSet = new HashSet<>(); + userVoSet.add(new UserVo(s.getUserType(),s.getUserId())); + + //查询用户信息 + Map userMap = userService.selectUserInfoMap(userVoSet,null); + + + //查询帖子信息 + Post post = postService.selectPostById(s.getPostId()); + s.setUserInfo(userMap.get(new UserVo(s.getUserType(),s.getUserId()))); + s.setPost(post); + } + return s; + } + + /** + * 查询论坛举报列表 + * + * @param postReport 论坛举报 + * @return 论坛举报 + */ + @Override + public List selectPostReportList(PostReport postReport) + { + List postReports = postReportMapper.selectPostReportList(postReport); + + if (postReports != null && postReports.size() > 0){ + + Set userVoSet = postReports.stream().map(s -> new UserVo(s.getUserType(),s.getUserId())).collect(Collectors.toSet()); + + //查询用户信息 + Map userMap = userService.selectUserInfoMap(userVoSet,null); + + Set postIds = postReports.stream().map(PostReport::getPostId).collect(Collectors.toSet()); + + //查询帖子信息 + Map postMap = postService.selectPostMap(postIds); + + postReports.stream().forEach(s ->{ + s.setUserInfo(userMap.get(new UserVo(s.getUserType(),s.getUserId()))); + s.setPost(postMap.get(s.getPostId())); + }); + } + + return postReports; + } + + /** + * 新增论坛举报 + * + * @param postReport 论坛举报 + * @return 结果 + */ + @Override + public int insertPostReport(PostReport postReport) + { + postReport.setCreateTime(DateUtils.getNowDate()); + return postReportMapper.insertPostReport(postReport); + } + + /** + * 修改论坛举报 + * + * @param postReport 论坛举报 + * @return 结果 + */ + @Override + public int updatePostReport(PostReport postReport) + { + postReport.setUpdateTime(DateUtils.getNowDate()); + return postReportMapper.updatePostReport(postReport); + } + + /** + * 批量删除论坛举报 + * + * @param ids 需要删除的论坛举报主键 + * @return 结果 + */ + @Override + public int deletePostReportByIds(Long[] ids,Integer delFlag) + { + this.lambdaUpdate().set(PostReport::getDelFlag,delFlag).in(PostReport::getId,ids).update(); + return ids.length; + } + + /** + * 删除论坛举报信息 + * + * @param id 论坛举报主键 + * @return 结果 + */ + @Override + public int deletePostReportById(Long id) + { + this.lambdaUpdate().set(PostReport::getDelFlag,PublicCommon.删除).eq(PostReport::getId,id).update(); + return 1; + } + + @Override + public AjaxResult handle(PostReport postReport) { + + boolean update = this.lambdaUpdate().set(PostReport::getResult, postReport.getResult()) + .eq(PostReport::getResult, ProcessResultEnums.PENDING.getCode()) + .eq(PostReport::getId, postReport.getId()).update(); + //处理(审核通过) + if (update && ObjectUtil.equal(ProcessResultEnums.APPROVED.getCode(), postReport.getResult())) { +// PostReport byId = this.getById(postReport.getId()); +// postService.lambdaUpdate().set(Post::getDelFlag,PublicCommon.禁用).eq(Post::getId,byId.getPostId()).update(); + } + return AjaxResult.success(); + } + + @Override + public ResponseData postReport(PostReportReq req, UserVo userVo) { + PostReport postReport = new PostReport().setPostId(req.getPostId()) + .setUserType(userVo.getUserType()) + .setUserId(userVo.getUserId()) + .setReason(req.getReason()) + .setContent(req.getContent()) + .setImages(req.getImages()); + this.save(postReport); + + return ResponseData.success(); + } +} diff --git a/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/frequency/posshield/controller/PostShieldController.java b/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/frequency/posshield/controller/PostShieldController.java new file mode 100644 index 0000000..45872b6 --- /dev/null +++ b/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/frequency/posshield/controller/PostShieldController.java @@ -0,0 +1,97 @@ +package com.ruoyi.post.frequency.posshield.controller; + +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.page.TableDataInfo; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.common.utils.poi.ExcelUtil; +import com.ruoyi.post.frequency.posshield.entity.PostShield; +import com.ruoyi.post.frequency.posshield.service.PostShieldService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +/** + * 论坛屏蔽Controller + * + * @author liwenlong + * @date 2023-10-26 + */ +@RestController +@RequestMapping("/frequency/posshield") +public class PostShieldController extends BaseController +{ + @Autowired + private PostShieldService postShieldService; + + /** + * 查询论坛屏蔽列表 + */ + @PreAuthorize("@ss.hasPermi('frequency:posshield:list')") + @PostMapping("/list") + public TableDataInfo list(@RequestBody PostShield postShield) + { + startPage(); + List list = postShieldService.selectPostShieldList(postShield); + return getDataTable(list); + } + + /** + * 导出论坛屏蔽列表 + */ + @PreAuthorize("@ss.hasPermi('frequency:posshield:export')") + @Log(title = "论坛屏蔽", businessType = BusinessType.EXPORT) + @GetMapping("/export") + public AjaxResult export(PostShield postShield) + { + List list = postShieldService.selectPostShieldList(postShield); + ExcelUtil util = new ExcelUtil(PostShield.class); + return util.exportExcel(list, "论坛屏蔽数据"); + } + + /** + * 获取论坛屏蔽详细信息 + */ + @PreAuthorize("@ss.hasPermi('frequency:posshield:query')") + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") Long id) + { + return AjaxResult.success(postShieldService.selectPostShieldById(id)); + } + + /** + * 新增论坛屏蔽 + */ + @PreAuthorize("@ss.hasPermi('frequency:posshield:add')") + @Log(title = "论坛屏蔽", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody PostShield postShield) + { + return toAjax(postShieldService.insertPostShield(postShield)); + } + + /** + * 修改论坛屏蔽 + */ + @PreAuthorize("@ss.hasPermi('frequency:posshield:edit')") + @Log(title = "论坛屏蔽", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody PostShield postShield) + { + return toAjax(postShieldService.updatePostShield(postShield)); + } + + /** + * 删除论坛屏蔽 + */ + @PreAuthorize("@ss.hasPermi('frequency:posshield:remove')") + @Log(title = "论坛屏蔽", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}") + public AjaxResult remove(@PathVariable Long[] ids) + { + return toAjax(postShieldService.deletePostShieldByIds(ids)); + } +} diff --git a/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/frequency/posshield/entity/PostShield.java b/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/frequency/posshield/entity/PostShield.java new file mode 100644 index 0000000..3d20ae0 --- /dev/null +++ b/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/frequency/posshield/entity/PostShield.java @@ -0,0 +1,43 @@ +package com.ruoyi.post.frequency.posshield.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; + +/** + * 论坛屏蔽对象 t_post_shield + * + * @author liwenlong + * @date 2023-10-26 + */ +@Data +@Accessors(chain = true) +@TableName("t_post_shield") +public class PostShield extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + + @ApiModelProperty("租户号") + private Long id; + + @ApiModelProperty("删除状态 1 正常 2 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("用户类型") + @Excel(name = "用户类型") + private Integer userType; + + @ApiModelProperty("用户id") + @Excel(name = "用户id") + private Long userId; + + @ApiModelProperty("论坛id") + @Excel(name = "论坛id") + private Long postId; + + +} diff --git a/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/frequency/posshield/mapper/PostShieldMapper.java b/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/frequency/posshield/mapper/PostShieldMapper.java new file mode 100644 index 0000000..39697b0 --- /dev/null +++ b/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/frequency/posshield/mapper/PostShieldMapper.java @@ -0,0 +1,72 @@ +package com.ruoyi.post.frequency.posshield.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.ruoyi.post.frequency.posshield.entity.PostShield; +import com.ruoyi.vo.UserVo; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * 论坛屏蔽Mapper接口 + * + * @author liwenlong + * @date 2023-10-26 + */ +public interface PostShieldMapper extends BaseMapper +{ + /** + * 查询论坛屏蔽 + * + * @param id 论坛屏蔽主键 + * @return 论坛屏蔽 + */ + public PostShield selectPostShieldById(Long id); + + /** + * 查询论坛屏蔽列表 + * + * @param postShield 论坛屏蔽 + * @return 论坛屏蔽集合 + */ + public List selectPostShieldList(PostShield postShield); + + /** + * 新增论坛屏蔽 + * + * @param postShield 论坛屏蔽 + * @return 结果 + */ + public int insertPostShield(PostShield postShield); + + /** + * 修改论坛屏蔽 + * + * @param postShield 论坛屏蔽 + * @return 结果 + */ + public int updatePostShield(PostShield postShield); + + /** + * 删除论坛屏蔽 + * + * @param id 论坛屏蔽主键 + * @return 结果 + */ + public int deletePostShieldById(Long id); + + /** + * 批量删除论坛屏蔽 + * + * @param ids 需要删除的数据主键集合 + * @return 结果 + */ + public int deletePostShieldByIds(Long[] ids); + + /** + * 帖子屏蔽 + * @param postShield + * @param userVo + */ + int postShield(@Param("req") PostShield postShield,@Param("userVo") UserVo userVo); +} diff --git a/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/frequency/posshield/mapper/mapping/PostShieldMapper.xml b/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/frequency/posshield/mapper/mapping/PostShieldMapper.xml new file mode 100644 index 0000000..383592f --- /dev/null +++ b/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/frequency/posshield/mapper/mapping/PostShieldMapper.xml @@ -0,0 +1,103 @@ + + + + + + + + + + + + + + + + + + + select id, del_flag, create_by, create_time, update_by, update_time, user_type, user_id, post_id, remark from t_post_shield + + + + + + + + insert into t_post_shield + + id, + del_flag, + create_by, + create_time, + update_by, + update_time, + user_type, + user_id, + post_id, + remark, + + + #{id}, + #{delFlag}, + #{createBy}, + #{createTime}, + #{updateBy}, + #{updateTime}, + #{userType}, + #{userId}, + #{postId}, + #{remark}, + + + + + update t_post_shield + + del_flag = #{delFlag}, + create_by = #{createBy}, + create_time = #{createTime}, + update_by = #{updateBy}, + update_time = #{updateTime}, + user_type = #{userType}, + user_id = #{userId}, + post_id = #{postId}, + remark = #{remark}, + + where id = #{id} + + + + delete from t_post_shield where id = #{id} + + + + delete from t_post_shield where id in + + #{id} + + + + + insert into t_post_shield + (id, create_by, create_time, update_by, update_time, user_type, user_id, post_id) + values + (#{req.id},#{req.updateBy},#{req.updateTime},#{req.updateBy},#{req.updateTime},#{userVo.userType}, #{userVo.userId}, #{req.postId}) + ON DUPLICATE KEY UPDATE + del_flag = IF( del_flag = 1, 3, 1 ), + update_time = #{req.updateTime}, + update_by = #{req.updateBy}; + + \ No newline at end of file diff --git a/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/frequency/posshield/model/param/PostShieldParam.java b/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/frequency/posshield/model/param/PostShieldParam.java new file mode 100644 index 0000000..e226183 --- /dev/null +++ b/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/frequency/posshield/model/param/PostShieldParam.java @@ -0,0 +1,45 @@ +package com.ruoyi.post.frequency.posshield.model.param; + +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; + +/** + * 论坛屏蔽对象 t_post_shield + * + * @author liwenlong + * @date 2023-10-26 + */ +@Data +@Accessors(chain = true) +public class PostShieldParam extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + @ApiModelProperty("租户号") + private Long id; + + @ApiModelProperty("删除状态 1 正常 2 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("用户类型") + @Excel(name = "用户类型") + private Integer userType; + + @ApiModelProperty("用户id") + @Excel(name = "用户id") + private Long userId; + + @ApiModelProperty("论坛id") + @Excel(name = "论坛id") + private Long postId; + + + + + + + +} diff --git a/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/frequency/posshield/model/result/PostShieldResult.java b/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/frequency/posshield/model/result/PostShieldResult.java new file mode 100644 index 0000000..d4c0550 --- /dev/null +++ b/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/frequency/posshield/model/result/PostShieldResult.java @@ -0,0 +1,40 @@ +package com.ruoyi.post.frequency.posshield.model.result; + +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; + +/** + * 论坛屏蔽对象 t_post_shield + * + * @author liwenlong + * @date 2023-10-26 + */ +@Data +@Accessors(chain = true) +public class PostShieldResult extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + @ApiModelProperty("租户号") + private Long id; + + @ApiModelProperty("删除状态 1 正常 2 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("用户类型") + @Excel(name = "用户类型") + private Integer userType; + + @ApiModelProperty("用户id") + @Excel(name = "用户id") + private Long userId; + + @ApiModelProperty("论坛id") + @Excel(name = "论坛id") + private Long postId; + + +} diff --git a/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/frequency/posshield/service/PostShieldService.java b/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/frequency/posshield/service/PostShieldService.java new file mode 100644 index 0000000..65a3ae2 --- /dev/null +++ b/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/frequency/posshield/service/PostShieldService.java @@ -0,0 +1,82 @@ +package com.ruoyi.post.frequency.posshield.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.ruoyi.post.frequency.posshield.entity.PostShield; +import com.ruoyi.response.ResponseData; +import com.ruoyi.vo.UserVo; + +import java.util.List; + +/** + * 论坛屏蔽Service接口 + * + * @author liwenlong + * @date 2023-10-26 + */ +public interface PostShieldService extends IService +{ + /** + * 查询论坛屏蔽 + * + * @param id 论坛屏蔽主键 + * @return 论坛屏蔽 + */ + public PostShield selectPostShieldById(Long id); + + /** + * 查询论坛屏蔽列表 + * + * @param postShield 论坛屏蔽 + * @return 论坛屏蔽集合 + */ + public List selectPostShieldList(PostShield postShield); + + /** + * 新增论坛屏蔽 + * + * @param postShield 论坛屏蔽 + * @return 结果 + */ + public int insertPostShield(PostShield postShield); + + /** + * 修改论坛屏蔽 + * + * @param postShield 论坛屏蔽 + * @return 结果 + */ + public int updatePostShield(PostShield postShield); + + /** + * 批量删除论坛屏蔽 + * + * @param ids 需要删除的论坛屏蔽主键集合 + * @return 结果 + */ + public int deletePostShieldByIds(Long[] ids); + + /** + * 删除论坛屏蔽信息 + * + * @param id 论坛屏蔽主键 + * @return 结果 + */ + public int deletePostShieldById(Long id); + + + /** + * 帖子屏蔽 + * @param id + * @param userVo + * @return + */ + ResponseData postShield(Long postId, UserVo userVo); + + + /** + * 用户屏蔽的帖子ids + * @param userVo + * @return + */ + List shieldPostList(UserVo userVo); +} diff --git a/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/frequency/posshield/service/impl/PostShieldServiceImpl.java b/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/frequency/posshield/service/impl/PostShieldServiceImpl.java new file mode 100644 index 0000000..80f33fb --- /dev/null +++ b/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/frequency/posshield/service/impl/PostShieldServiceImpl.java @@ -0,0 +1,137 @@ +package com.ruoyi.post.frequency.posshield.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.ruoyi.code.PublicCommon; +import com.ruoyi.common.utils.DateUtils; +import com.ruoyi.post.frequency.posshield.entity.PostShield; +import com.ruoyi.post.frequency.posshield.mapper.PostShieldMapper; +import com.ruoyi.post.frequency.posshield.service.PostShieldService; +import com.ruoyi.response.ResponseData; +import com.ruoyi.utils.SnowIdUtils; +import com.ruoyi.vo.UserVo; +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.stream.Collectors; + +/** + * 论坛屏蔽Service业务层处理 + * + * @author liwenlong + * @date 2023-10-26 + */ +@Service +@Transactional(rollbackFor = Exception.class) +public class PostShieldServiceImpl extends ServiceImpl implements PostShieldService +{ + @Autowired + private PostShieldMapper postShieldMapper; + + /** + * 查询论坛屏蔽 + * + * @param id 论坛屏蔽主键 + * @return 论坛屏蔽 + */ + @Override + public PostShield selectPostShieldById(Long id) + { + return postShieldMapper.selectPostShieldById(id); + } + + /** + * 查询论坛屏蔽列表 + * + * @param postShield 论坛屏蔽 + * @return 论坛屏蔽 + */ + @Override + public List selectPostShieldList(PostShield postShield) + { + return postShieldMapper.selectPostShieldList(postShield); + } + + /** + * 新增论坛屏蔽 + * + * @param postShield 论坛屏蔽 + * @return 结果 + */ + @Override + public int insertPostShield(PostShield postShield) + { + postShield.setCreateTime(DateUtils.getNowDate()); + return postShieldMapper.insertPostShield(postShield); + } + + /** + * 修改论坛屏蔽 + * + * @param postShield 论坛屏蔽 + * @return 结果 + */ + @Override + public int updatePostShield(PostShield postShield) + { + postShield.setUpdateTime(DateUtils.getNowDate()); + return postShieldMapper.updatePostShield(postShield); + } + + /** + * 批量删除论坛屏蔽 + * + * @param ids 需要删除的论坛屏蔽主键 + * @return 结果 + */ + @Override + public int deletePostShieldByIds(Long[] ids) + { + this.lambdaUpdate().set(PostShield::getDelFlag,PublicCommon.删除).in(PostShield::getId,ids).update(); + return ids.length; + } + + /** + * 删除论坛屏蔽信息 + * + * @param id 论坛屏蔽主键 + * @return 结果 + */ + @Override + public int deletePostShieldById(Long id) + { + this.lambdaUpdate().set(PostShield::getDelFlag,PublicCommon.删除).eq(PostShield::getId,id).update(); + return 1; + } + + @Override + public ResponseData postShield(Long postId, UserVo userVo) { + + PostShield postShield = new PostShield() + .setId(SnowIdUtils.uniqueLong()) + .setPostId(postId) + .setUserType(userVo.getUserType()) + .setUserId(userVo.getUserId()); + + postShield.setUpdateData(); + + //帖子屏蔽 + postShieldMapper.postShield(postShield,userVo); + + return ResponseData.success(); + } + + @Override + public List shieldPostList(UserVo userVo) { + + //查询屏蔽帖子记录 + List list = this.list(new QueryWrapper().lambda() + .eq(PostShield::getDelFlag, PublicCommon.启用) + .eq(PostShield::getUserType, userVo.getUserType()) + .eq(PostShield::getUserId, userVo.getUserId())); + + return list.stream().map(PostShield::getPostId).collect(Collectors.toList()); + } +} diff --git a/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/frequency/post/controller/PostController.java b/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/frequency/post/controller/PostController.java new file mode 100644 index 0000000..554ad9a --- /dev/null +++ b/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/frequency/post/controller/PostController.java @@ -0,0 +1,117 @@ +package com.ruoyi.post.frequency.post.controller; + +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.page.TableDataInfo; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.common.utils.poi.ExcelUtil; +import com.ruoyi.post.frequency.post.entity.Post; +import com.ruoyi.post.frequency.post.model.result.PostCount; +import com.ruoyi.post.frequency.post.service.PostService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +/** + * 帖子Controller + * + * @author liwenlong + * @date 2023-10-09 + */ +@RestController +@RequestMapping("/frequency/post") +public class PostController extends BaseController +{ + @Autowired + private PostService postService; + + /** + * 查询帖子列表 + */ +// @PreAuthorize("@ss.hasPermi('frequency:post:list')") + @PostMapping("/list") + public TableDataInfo list(@RequestBody Post post) + { + startPage(); + List list = postService.selectPostList(post); + return getDataTable(list); + } + + /** + * 统计 + */ + @PostMapping("/statistics") + public AjaxResult statistics(@RequestBody Post post) + { + PostCount count = postService.statistics(post); + return AjaxResult.success(count); + } + + /** + * 导出帖子列表 + */ + @PreAuthorize("@ss.hasPermi('frequency:post:export')") + @Log(title = "帖子", businessType = BusinessType.EXPORT) + @GetMapping("/export") + public AjaxResult export(Post post) + { + List list = postService.selectPostList(post); + ExcelUtil util = new ExcelUtil(Post.class); + return util.exportExcel(list, "帖子数据"); + } + + /** + * 获取帖子详细信息 + */ +// @PreAuthorize("@ss.hasPermi('frequency:post:query')") + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") Long id) + { + return AjaxResult.success(postService.selectPostById(id)); + } + + /** + * 新增帖子 + */ + @PreAuthorize("@ss.hasPermi('frequency:post:add')") + @Log(title = "帖子", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody Post post) + { + return toAjax(postService.insertPost(post)); + } + + /** + * 修改帖子 + */ + @PreAuthorize("@ss.hasPermi('frequency:post:edit')") + @Log(title = "帖子", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody Post post) + { + return toAjax(postService.updatePost(post)); + } + + /** + * 删除帖子 + */ +// @PreAuthorize("@ss.hasPermi('frequency:post:remove')") + @Log(title = "帖子", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}") + public AjaxResult remove(@PathVariable Long[] ids) + { + return toAjax(postService.deletePostByIds(ids)); + } + + /** + * 帖子置顶/取消置顶 + */ + @PostMapping("/topping/{id}") + public AjaxResult topping(@PathVariable Long id) + { + return postService.topping(id); + } +} diff --git a/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/frequency/post/entity/Post.java b/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/frequency/post/entity/Post.java new file mode 100644 index 0000000..709287d --- /dev/null +++ b/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/frequency/post/entity/Post.java @@ -0,0 +1,153 @@ +package com.ruoyi.post.frequency.post.entity; + +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableName; +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import com.ruoyi.post.controller.req.PostReleaseReq; +import com.ruoyi.post.controller.vo.SelectedComment; +import com.ruoyi.vo.UserInfo; +import com.ruoyi.vo.UserVo; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; + +import java.util.Date; + +/** + * 帖子对象 t_post + * + * @author liwenlong + * @date 2023-10-09 + */ +@Data +@Accessors(chain = true) +@TableName("t_post") +public class Post extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + + @ApiModelProperty("租户号") + private Long id; + + @ApiModelProperty("删除标识 1 正常 2 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("帖子分类id") + @Excel(name = "帖子分类id") + private Long postTypeId; + + @ApiModelProperty("用户类型") + @Excel(name = "用户类型") + private Integer userType; + + @ApiModelProperty("用户id") + @Excel(name = "用户id") + private Long userId; + + @ApiModelProperty("标题") + @Excel(name = "标题") + private String title; + + @ApiModelProperty("文字描述(富文本)") + @Excel(name = "文字描述(富文本)") + private String content; + + @ApiModelProperty("封面图") + @Excel(name = "封面图") + private String coverImage; + + @ApiModelProperty("视频路径(一个)") + @Excel(name = "视频路径", readConverterExp = "一=个") + private String videoUrl; + + @ApiModelProperty("分享数") + @Excel(name = "分享数") + private Integer shareNum; + + @ApiModelProperty("点赞数") + @Excel(name = "点赞数") + private Integer likeNum; + + @ApiModelProperty("评论数") + @Excel(name = "评论数") + private Integer commentNum; + + @ApiModelProperty("收藏数") + @Excel(name = "收藏数") + private Integer collectNum; + + @ApiModelProperty("浏览数") + @Excel(name = "浏览数") + private Integer browseNum; + + @ApiModelProperty("状态 1 待审核 2 通过 3 拒绝") + @Excel(name = "状态 1 待审核 2 通过 3 拒绝") + private Integer result; + + @ApiModelProperty("拒绝原因") + @Excel(name = "拒绝原因") + private String reason; + + + @Excel(name = "地址") + @ApiModelProperty("地址") + private String address; + + + @ApiModelProperty("精彩评论id") + private Long commentId; + + @ApiModelProperty("帖子类型 1 帖子 2资讯") + private Integer type; + + @ApiModelProperty("描述") + private String describes; + + @ApiModelProperty("热度时间") + private Date trendsTime; + + @ApiModelProperty("帖子分类名称") + @Excel(name = "帖子分类名称") + @TableField(exist = false) + private String postTypeName; + + @ApiModelProperty("用户信息") + @TableField(exist = false) + private UserInfo userInfo; + + @ApiModelProperty("精选评论") + @TableField(exist = false) + private SelectedComment selectedComment; + + @ApiModelProperty("是否推荐 1否 2是") + @TableField(exist = false) + private Integer isRecommend; + + @ApiModelProperty("开始时间") + @TableField(exist = false) + private Date beginTime; + + @ApiModelProperty("结束时间") + @TableField(exist = false) + private Date endTime; + + @ApiModelProperty("企业id") + @TableField(exist = false) + private Long enterpriseId; + + public Post() { + } + + public Post(PostReleaseReq req, UserVo userVo) { + this.userId = userVo.getUserId(); + this.userType = userVo.getUserType(); + this.title = req.getTitle(); + this.content = req.getContent(); + this.coverImage = req.getCoverImage(); + this.videoUrl = req.getVideoUrl(); + this.postTypeId = req.getPostTypeId(); + this.address = req.getAddress(); + } +} diff --git a/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/frequency/post/mapper/PostMapper.java b/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/frequency/post/mapper/PostMapper.java new file mode 100644 index 0000000..1302d4b --- /dev/null +++ b/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/frequency/post/mapper/PostMapper.java @@ -0,0 +1,115 @@ +package com.ruoyi.post.frequency.post.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.ruoyi.post.controller.req.PostPageReq; +import com.ruoyi.post.controller.resp.PostDetailResp; +import com.ruoyi.post.controller.resp.PostPageResp; +import com.ruoyi.post.frequency.post.entity.Post; +import com.ruoyi.post.frequency.post.model.result.PostCount; +import com.ruoyi.vo.UserVo; +import org.apache.ibatis.annotations.Param; +import org.apache.ibatis.annotations.Update; + +import java.util.Date; +import java.util.List; + +/** + * 帖子Mapper接口 + * + * @author liwenlong + * @date 2023-10-09 + */ +public interface PostMapper extends BaseMapper +{ + /** + * 查询帖子 + * + * @param id 帖子主键 + * @return 帖子 + */ + public Post selectPostById(Long id); + + /** + * 查询帖子列表 + * + * @param post 帖子 + * @return 帖子集合 + */ + public List selectPostList(Post post); + + /** + * 新增帖子 + * + * @param post 帖子 + * @return 结果 + */ + public int insertPost(Post post); + + /** + * 修改帖子 + * + * @param post 帖子 + * @return 结果 + */ + public int updatePost(Post post); + + /** + * 删除帖子 + * + * @param id 帖子主键 + * @return 结果 + */ + public int deletePostById(Long id); + + /** + * 批量删除帖子 + * + * @param ids 需要删除的数据主键集合 + * @return 结果 + */ + public int deletePostByIds(Long[] ids); + + + /** + * 修改帖子统计数量 + * @param id 帖子id + * @param type 数量类型 + * @param num 数量 + */ + void updateNumPost(@Param("id") Long id, @Param("type") Integer type, @Param("num") int num); + + + /** + * 帖子列表 + * @param objectPage + * @param req + * @param userVo + * @return + */ + Page postPage(@Param("page")Page objectPage,@Param("req") PostPageReq req,@Param("userVo") UserVo userVo); + + + /** + * 帖子详情 + * @param id + * @param userVo + * @return + */ + PostDetailResp postDetail(@Param("id") Long id, @Param("userVo") UserVo userVo); + + /** + * + * @param id + * @param type type: 类型 1作品 2 帖子 3投票 4新闻 5活动 + * @param updateTime + * @param objectId + * @param userVo + */ + void updateBrowseRecord(@Param("id") Long id, @Param("type") int type, @Param("updateTime") Date updateTime,@Param("objectId") Long objectId, @Param("userVo") UserVo userVo); + + PostCount statistics(@Param("list") List postIdList); + + @Update("update t_post set like_num = like_num + #{num} , update_time=now() where id = #{id} and like_num + #{num} >= 0") + int updatePostLikeNum(@Param("id")Long id, @Param("num")Integer num); +} diff --git a/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/frequency/post/mapper/mapping/PostMapper.xml b/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/frequency/post/mapper/mapping/PostMapper.xml new file mode 100644 index 0000000..8bf8938 --- /dev/null +++ b/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/frequency/post/mapper/mapping/PostMapper.xml @@ -0,0 +1,530 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + SELECT + t.id, + t.del_flag, + t.create_by, + t.create_time, + t.update_by, + t.update_time, + t.post_type_id, + t.user_type, + t.user_id, + t.title, + t.content, + t.cover_image, + t.video_url, + t.share_num, + t.like_num, + t.comment_num, + t.collect_num, + t.browse_num, + t.answer_num, + t.result, + t.reason, + t.address, + t2.`name` postTypeName, + case when r.id is null then 1 else 2 end isRecommend, + r.sort, + t.describes + FROM + t_post AS t + LEFT JOIN t_post_type AS t2 ON t.post_type_id = t2.id + left join t_customer c on c.id = t.user_id and t.user_type = 1 + left join t_store s on s.id = t.user_id and t.user_type = 2 + left join t_recommend r on r.object_id = t.id and r.type = 2 and r.del_flag = 1 + left join t_enterprise e on e.id = t.user_id and t.user_type = 4 + left join t_store s2 on s2.bind_enterprise_id = e.id and t.user_type = 4 + + + + + + + + insert into t_post + + id, + del_flag, + create_by, + create_time, + update_by, + update_time, + post_type_id, + user_type, + user_id, + title, + content, + cover_image, + video_url, + share_num, + like_num, + comment_num, + collect_num, + browse_num, + result, + reason, + + + #{id}, + #{delFlag}, + #{createBy}, + #{createTime}, + #{updateBy}, + #{updateTime}, + #{postTypeId}, + #{userType}, + #{userId}, + #{title}, + #{content}, + #{coverImage}, + #{videoUrl}, + #{shareNum}, + #{likeNum}, + #{commentNum}, + #{collectNum}, + #{browseNum}, + #{result}, + #{reason}, + + + + + update t_post + + del_flag = #{delFlag}, + create_by = #{createBy}, + create_time = #{createTime}, + update_by = #{updateBy}, + update_time = #{updateTime}, + post_type_id = #{postTypeId}, + user_type = #{userType}, + user_id = #{userId}, + title = #{title}, + content = #{content}, + cover_image = #{coverImage}, + video_url = #{videoUrl}, + share_num = share_num + #{shareNum}, + like_num = like_num + #{likeNum}, + comment_num = comment_num + #{commentNum}, + collect_num = collect_num + #{collectNum}, + browse_num = browse_num + #{browseNum}, + result = #{result}, + reason = #{reason}, + + where id = #{id} + + + + delete from t_post where id = #{id} + + + + delete from t_post where id in + + #{id} + + + + + UPDATE t_post + + SET share_num = share_num + #{num} + + + SET like_num = like_num + #{num} + + + SET comment_num = comment_num + #{num} + + + SET collect_num = collect_num + #{num} + + + SET browse_num = browse_num + #{num} + + WHERE + id = #{id} + + AND (share_num + #{num}) >= 0 + + + AND (like_num + #{num}) >= 0 + + + AND (comment_num + #{num}) >= 0 + + + AND (collect_num + #{num}) >= 0 + + + AND (browse_num + #{num}) >= 0 + + + + + + + + + + insert into t_browse_record + (id, create_time, update_time, type, user_type, user_id, object_id) + values + (#{id},#{updateTime},#{updateTime},#{type},#{userVo.userType}, #{userVo.userId}, #{objectId}) + ON DUPLICATE KEY UPDATE + update_time = #{updateTime}; + + + + diff --git a/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/frequency/post/model/param/PostParam.java b/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/frequency/post/model/param/PostParam.java new file mode 100644 index 0000000..077ca40 --- /dev/null +++ b/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/frequency/post/model/param/PostParam.java @@ -0,0 +1,100 @@ +package com.ruoyi.post.frequency.post.model.param; + +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; + +/** + * 帖子对象 t_post + * + * @author liwenlong + * @date 2023-10-09 + */ +@Data +@Accessors(chain = true) +public class PostParam extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + @ApiModelProperty("租户号") + private Long id; + + @ApiModelProperty("删除标识 1 正常 2 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("帖子分类id") + @Excel(name = "帖子分类id") + private Long postTypeId; + + @ApiModelProperty("用户类型") + @Excel(name = "用户类型") + private Integer userType; + + @ApiModelProperty("用户id") + @Excel(name = "用户id") + private Long userId; + + @ApiModelProperty("标题") + @Excel(name = "标题") + private String title; + + @ApiModelProperty("文字描述(富文本)") + @Excel(name = "文字描述(富文本)") + private String content; + + @ApiModelProperty("封面图") + @Excel(name = "封面图") + private String coverImage; + + @ApiModelProperty("视频路径(一个)") + @Excel(name = "视频路径", readConverterExp = "一=个") + private String videoUrl; + + @ApiModelProperty("分享数") + @Excel(name = "分享数") + private Long shareNum; + + @ApiModelProperty("点赞数") + @Excel(name = "点赞数") + private Long likeNum; + + @ApiModelProperty("评论数") + @Excel(name = "评论数") + private Long commentNum; + + @ApiModelProperty("收藏数") + @Excel(name = "收藏数") + private Long collectNum; + + @ApiModelProperty("浏览数") + @Excel(name = "浏览数") + private Long browseNum; + + @ApiModelProperty("状态 1 待审核 2 通过 3 拒绝") + @Excel(name = "状态 1 待审核 2 通过 3 拒绝") + private Integer result; + + @ApiModelProperty("拒绝原因") + @Excel(name = "拒绝原因") + private String reason; + + + + + + + + + + + + + + + + + + +} diff --git a/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/frequency/post/model/result/PostCount.java b/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/frequency/post/model/result/PostCount.java new file mode 100644 index 0000000..caa914d --- /dev/null +++ b/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/frequency/post/model/result/PostCount.java @@ -0,0 +1,37 @@ +package com.ruoyi.post.frequency.post.model.result; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + * @author a + * @date 2024/2/19 10:18 + */ + +@Data +public class PostCount { + + @ApiModelProperty("数量") + private Integer num; + + @ApiModelProperty("人数") + private Integer number; + + @ApiModelProperty("设计师数量") + private Integer customerNum; + + @ApiModelProperty("表现师数量") + private Integer storeNum; + + @ApiModelProperty("浏览量") + private Integer browseNum; + + @ApiModelProperty("点赞量") + private Integer likeNum; + + @ApiModelProperty("评论量") + private Integer commentNum; + + @ApiModelProperty("收藏量") + private Integer collectNum; +} diff --git a/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/frequency/post/model/result/PostResult.java b/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/frequency/post/model/result/PostResult.java new file mode 100644 index 0000000..a9a5c9d --- /dev/null +++ b/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/frequency/post/model/result/PostResult.java @@ -0,0 +1,84 @@ +package com.ruoyi.post.frequency.post.model.result; + +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; + +/** + * 帖子对象 t_post + * + * @author liwenlong + * @date 2023-10-09 + */ +@Data +@Accessors(chain = true) +public class PostResult extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + @ApiModelProperty("租户号") + private Long id; + + @ApiModelProperty("删除标识 1 正常 2 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("帖子分类id") + @Excel(name = "帖子分类id") + private Long postTypeId; + + @ApiModelProperty("用户类型") + @Excel(name = "用户类型") + private Integer userType; + + @ApiModelProperty("用户id") + @Excel(name = "用户id") + private Long userId; + + @ApiModelProperty("标题") + @Excel(name = "标题") + private String title; + + @ApiModelProperty("文字描述(富文本)") + @Excel(name = "文字描述(富文本)") + private String content; + + @ApiModelProperty("封面图") + @Excel(name = "封面图") + private String coverImage; + + @ApiModelProperty("视频路径(一个)") + @Excel(name = "视频路径", readConverterExp = "一=个") + private String videoUrl; + + @ApiModelProperty("分享数") + @Excel(name = "分享数") + private Long shareNum; + + @ApiModelProperty("点赞数") + @Excel(name = "点赞数") + private Long likeNum; + + @ApiModelProperty("评论数") + @Excel(name = "评论数") + private Long commentNum; + + @ApiModelProperty("收藏数") + @Excel(name = "收藏数") + private Long collectNum; + + @ApiModelProperty("浏览数") + @Excel(name = "浏览数") + private Long browseNum; + + @ApiModelProperty("状态 1 待审核 2 通过 3 拒绝") + @Excel(name = "状态 1 待审核 2 通过 3 拒绝") + private Integer result; + + @ApiModelProperty("拒绝原因") + @Excel(name = "拒绝原因") + private String reason; + + +} diff --git a/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/frequency/post/service/PostService.java b/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/frequency/post/service/PostService.java new file mode 100644 index 0000000..af50de0 --- /dev/null +++ b/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/frequency/post/service/PostService.java @@ -0,0 +1,132 @@ +package com.ruoyi.post.frequency.post.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.post.controller.req.PostPageReq; +import com.ruoyi.post.controller.req.PostReleaseReq; +import com.ruoyi.post.frequency.post.entity.Post; +import com.ruoyi.post.frequency.post.model.result.PostCount; +import com.ruoyi.response.ResponseData; +import com.ruoyi.vo.UserVo; + +import java.util.List; +import java.util.Map; +import java.util.Set; + +/** + * 帖子Service接口 + * + * @author liwenlong + * @date 2023-10-09 + */ +public interface PostService extends IService +{ + /** + * 查询帖子 + * + * @param id 帖子主键 + * @return 帖子 + */ + public Post selectPostById(Long id); + + /** + * 查询帖子列表 + * + * @param post 帖子 + * @return 帖子集合 + */ + public List selectPostList(Post post); + + PostCount statistics(Post post); + + /** + * 新增帖子 + * + * @param post 帖子 + * @return 结果 + */ + public int insertPost(Post post); + + /** + * 修改帖子 + * + * @param post 帖子 + * @return 结果 + */ + public int updatePost(Post post); + + int updatePostLikeNum(Post post, Integer num); + + /** + * 批量删除帖子 + * + * @param ids 需要删除的帖子主键集合 + * @return 结果 + */ + public int deletePostByIds(Long[] ids); + + /** + * 删除帖子信息 + * + * @param id 帖子主键 + * @return 结果 + */ + public int deletePostById(Long id); + + /** + * 帖子发布 + * @param req + * @param userVo + * @return + */ + ResponseData postRelease(PostReleaseReq req, UserVo userVo); + + + /** + * 帖子列表 + * @param req + * @param userVo 登入用户 + * @return + */ + ResponseData postPage(PostPageReq req, UserVo userVo); + + + /** + * 帖子详情 + * @param postId 帖子id + * @param userVo 登入用户 + * @return + */ + ResponseData postDetail(Long postId,Integer isAddBrowseNum, UserVo userVo); + + /** + * 查询帖子 + * @param postIds + * @return + */ + Map selectPostMap(Set postIds); + + /** + * 帖子修改 + * @param req + * @param userVo + * @return + */ + ResponseData postEdit(PostReleaseReq req, UserVo userVo); + + /** + * 帖子删除 + * @param id + * @param userVo + * @return + */ + ResponseData postDelete(Long id, UserVo userVo); + + /** + * 帖子置顶/取消置顶 + * @param id + * @return + */ + AjaxResult topping(Long id); + +} diff --git a/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/frequency/post/service/impl/PostServiceImpl.java b/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/frequency/post/service/impl/PostServiceImpl.java new file mode 100644 index 0000000..2e1c58e --- /dev/null +++ b/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/frequency/post/service/impl/PostServiceImpl.java @@ -0,0 +1,365 @@ +package com.ruoyi.post.frequency.post.service.impl; + +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.collection.CollectionUtil; +import cn.hutool.core.util.ObjectUtil; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.ruoyi.code.DictConstant; +import com.ruoyi.code.PublicCommon; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.domain.entity.SysDictData; +import com.ruoyi.common.page.PageResult; +import com.ruoyi.common.utils.DateUtils; +import com.ruoyi.common.utils.SecurityUtils; +import com.ruoyi.enums.process.ProcessResultEnums; +import com.ruoyi.enums.user.UserEnums; +import com.ruoyi.frequency.customer.service.UserService; +import com.ruoyi.frequency.enterprise.entity.Enterprise; +import com.ruoyi.frequency.enterprise.service.EnterpriseService; +import com.ruoyi.frequency.recommend.service.RecommendService; +import com.ruoyi.frequency.store.entity.Store; +import com.ruoyi.frequency.store.service.StoreService; +import com.ruoyi.post.controller.req.PostPageReq; +import com.ruoyi.post.controller.req.PostReleaseReq; +import com.ruoyi.post.controller.resp.PostDetailResp; +import com.ruoyi.post.controller.resp.PostPageResp; +import com.ruoyi.post.controller.vo.SelectedComment; +import com.ruoyi.post.frequency.posshield.service.PostShieldService; +import com.ruoyi.post.frequency.post.entity.Post; +import com.ruoyi.post.frequency.post.mapper.PostMapper; +import com.ruoyi.post.frequency.post.model.result.PostCount; +import com.ruoyi.post.frequency.post.service.PostService; +import com.ruoyi.post.frequency.postcomment.service.PostCommentService; +import com.ruoyi.response.ResponseData; +import com.ruoyi.utils.BusinessUtil; +import com.ruoyi.utils.SnowIdUtils; +import com.ruoyi.vo.UserInfo; +import com.ruoyi.vo.UserVo; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.*; +import java.util.function.Function; +import java.util.stream.Collectors; + +/** + * 帖子Service业务层处理 + * + * @author liwenlong + * @date 2023-10-09 + */ +@Service +@Transactional(rollbackFor = Exception.class) +public class PostServiceImpl extends ServiceImpl implements PostService { + @Autowired + private PostMapper postMapper; + + /** + * 查询帖子 + * + * @param id 帖子主键 + * @return 帖子 + */ + @Override + public Post selectPostById(Long id) { + Post post = postMapper.selectPostById(id); + + if (post != null) { + Set userVoSet = new HashSet<>(); + userVoSet.add(new UserVo(post.getUserType(), post.getUserId())); + //查询用户信息 + Map userMap = userService.selectUserInfoMap(userVoSet, null); + + if (ObjectUtil.isNotEmpty(post.getCommentId())) { + //精彩评论ids + List commentIds = CollectionUtil.toList(post.getCommentId()); + + //查询精选评论 + Map selectedCommentMap = postCommentService.getSelectedCommentMap(commentIds, null); + + post.setSelectedComment(selectedCommentMap.get(post.getId())); + } + + post.setUserInfo(userMap.get(new UserVo(post.getUserType(), post.getUserId()))); + + } + + return post; + } + + @Autowired + private EnterpriseService enterpriseService; + + /** + * 查询帖子列表 + * + * @param post 帖子 + * @return 帖子 + */ + @Override + public List selectPostList(Post post) { + + List posts = postList(post); + + if (!posts.isEmpty()) { + Set userVoSet = posts.stream().map(s -> new UserVo(s.getUserType(), s.getUserId())).collect(Collectors.toSet()); + //查询用户信息 + Map userMap = userService.selectUserInfoMap(userVoSet, null); + + //精彩评论ids + List commentIds = posts.stream().filter(s -> ObjectUtil.isNotEmpty(s.getCommentId())).map(Post::getCommentId).collect(Collectors.toList()); + + //查询精选评论 + Map selectedCommentMap = postCommentService.getSelectedCommentMap(commentIds, null); + + posts.stream().forEach(s -> { + s.setUserInfo(userMap.get(new UserVo(s.getUserType(), s.getUserId()))); + s.setSelectedComment(selectedCommentMap.get(s.getId())); + }); + } + + return posts; + } + + private List postList(Post post) { + if (SecurityUtils.hasRoleKey("enterprise")) { + Enterprise enterprise = enterpriseService.getOne(new QueryWrapper().lambda().eq(Enterprise::getSysUserId, SecurityUtils.getUserId())); + if (enterprise == null) { + return null; + } + post.setEnterpriseId(enterprise.getId()); + } + + List posts = postMapper.selectPostList(post); + return posts; + } + + @Override + public PostCount statistics(Post post) { + + List posts = postList(post); + List postIdList = posts.stream().map(x -> x.getId()).collect(Collectors.toList()); + postIdList.add(-1L); + return postMapper.statistics(postIdList); + } + + /** + * 新增帖子 + * + * @param post 帖子 + * @return 结果 + */ + @Override + public int insertPost(Post post) { + post.setCreateTime(DateUtils.getNowDate()); + return postMapper.insert(post); + } + + /** + * 修改帖子 + * + * @param post 帖子 + * @return 结果 + */ + @Override + public int updatePost(Post post) { + post.setUpdateTime(DateUtils.getNowDate()); + return postMapper.updateById(post); + } + + + /** + * 修改帖子 + * + * @param post 帖子 + * @return 结果 + */ + @Override + public int updatePostLikeNum(Post post, Integer num) { + post.setUpdateTime(DateUtils.getNowDate()); + return postMapper.updatePostLikeNum(post.getId(), num); + } + + /** + * 批量删除帖子 + * + * @param ids 需要删除的帖子主键 + * @return 结果 + */ + @Override + public int deletePostByIds(Long[] ids) { + this.lambdaUpdate().set(Post::getDelFlag, PublicCommon.删除).in(Post::getId, ids).update(); + return ids.length; + } + + /** + * 删除帖子信息 + * + * @param id 帖子主键 + * @return 结果 + */ + @Override + public int deletePostById(Long id) { + this.lambdaUpdate().set(Post::getDelFlag, PublicCommon.删除).eq(Post::getId, id).update(); + return 1; + } + + @Override + public AjaxResult topping(Long id) { + + //自动置顶 1作品 2帖子 + recommendService.topping(2, id); + + return AjaxResult.success(); + } + + + @Autowired + private BusinessUtil businessUtil; + + @Autowired + private UserService userService; + + @Autowired + private StoreService storeService; + + @Autowired + private RecommendService recommendService; + + @Override + public ResponseData postRelease(PostReleaseReq req, UserVo userVo) { + + Post post = new Post(req, userVo); + + //是否需要审核 + SysDictData post_dict = businessUtil.getDict(DictConstant.帖子审核); + + Optional.ofNullable(post_dict) + .filter(s -> s.getDictValue().equals(PublicCommon.Process.不用审核)) + .ifPresent(p -> post.setResult(ProcessResultEnums.APPROVED.getCode())); + + boolean save = this.save(post); + //表现师发布帖子 判断该表现师是否是官方用户 + if (save && ObjectUtil.equal(UserEnums.store.getCode(), userVo.getUserType())) { + Store store = storeService.getById(userVo.getUserId()); + if (store != null && ObjectUtil.isNotEmpty(store.getIsPlatform()) && store.getIsPlatform() == 2) { + //自动置顶 1作品 2帖子 + recommendService.topping(2, post.getId()); + } + } + return ResponseData.success(post.getId()); + } + + @Autowired + private PostCommentService postCommentService; + + @Autowired + private PostShieldService postShieldService; + + @Override + public ResponseData postPage(PostPageReq req, UserVo userVo) { + + //筛去拉黑与被拉黑用户 + List blockUserList = userService.blockUserList(userVo); + req.setBlockUserList(blockUserList); + + //筛去屏蔽用户 + List shieldUserList = userService.shieldUserList(userVo); + req.setShieldUserList(shieldUserList); + + //筛去屏蔽的帖子 + List shieldPostIdList = postShieldService.shieldPostList(userVo); + req.setShieldPostIdList(shieldPostIdList); + + + Page page = this.baseMapper.postPage(new Page<>(req.getPageNo(), req.getPageSize()), req, userVo); + + if (!page.getRecords().isEmpty()) { + Set userVoSet = page.getRecords().stream().map(postPageResp -> new UserVo(postPageResp.getUserType(), postPageResp.getUserId())).collect(Collectors.toSet()); + //查询用户信息 + Map userMap = userService.selectUserInfoMap(userVoSet, userVo); + + //精彩评论ids + List commentIds = page.getRecords().stream().filter(s -> ObjectUtil.isNotEmpty(s.getCommentId())).map(PostPageResp::getCommentId).collect(Collectors.toList()); + + //查询精选评论 + Map selectedCommentMap = postCommentService.getSelectedCommentMap(commentIds, userVo); + + //帖子ids + List postIds = page.getRecords().stream().filter(s -> ObjectUtil.isNotEmpty(s.getId())).map(PostPageResp::getId).collect(Collectors.toList()); + + //查询最新评论 帖子id ->最新评论 + Map selectedNewCommentMap = postCommentService.getSelectedNewCommentMap(postIds, userVo); + + + page.getRecords().stream().forEach(resp -> { + resp.setUserInfo(userMap.get(new UserVo(resp.getUserType(), resp.getUserId()))); + + if (selectedCommentMap.get(resp.getCommentId()) != null) { + resp.setSelectedComment(selectedCommentMap.get(resp.getCommentId())); + } else { + //没有精选评论-->查询最新一条评论 + resp.setSelectedComment(selectedNewCommentMap.get(resp.getId())); + } + }); + } + + return ResponseData.success(new PageResult<>(page)); + } + + + @Override + public ResponseData postDetail(Long id, Integer isAddBrowseNum, UserVo userVo) { + + PostDetailResp detailResp = this.baseMapper.postDetail(id, userVo); + + //增加论坛浏览数 + Optional.ofNullable(detailResp).ifPresent(p -> { + + //是否增加浏览数 1不增加 2 加 + if (ObjectUtil.equal(2, isAddBrowseNum)) { + this.baseMapper.updateNumPost(id, PublicCommon.Post.浏览数, 1); + + this.baseMapper.updateBrowseRecord(SnowIdUtils.uniqueLong(), 2, new Date(), id, userVo); + } + + Set userVoSet = new HashSet<>(); + UserVo user = new UserVo(detailResp.getUserType(), detailResp.getUserId()); + userVoSet.add(user); + //查询用户信息 + Map userMap = userService.selectUserInfoMap(userVoSet, userVo); + detailResp.setUserInfo(userMap.get(user)); + + PostPageResp postPageResp = new PostPageResp(); + BeanUtil.copyProperties(detailResp, postPageResp); + } + ); + return ResponseData.success(detailResp); + } + + @Override + public Map selectPostMap(Set postIds) { + + List posts = this.list(new QueryWrapper().lambda().in(Post::getId, postIds)); + + return posts.stream().collect(Collectors.toMap(Post::getId, Function.identity())); + } + + @Override + public ResponseData postEdit(PostReleaseReq req, UserVo userVo) { + Post post = new Post(); + BeanUtil.copyProperties(req, post); + post.setUpdateData(); + this.updateById(post); + return ResponseData.success(); + } + + @Override + public ResponseData postDelete(Long id, UserVo userVo) { + this.lambdaUpdate().set(Post::getDelFlag, PublicCommon.删除).eq(Post::getId, id).update(); + return ResponseData.success(); + } +} diff --git a/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/frequency/postcomment/controller/PostCommentController.java b/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/frequency/postcomment/controller/PostCommentController.java new file mode 100644 index 0000000..f1d1443 --- /dev/null +++ b/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/frequency/postcomment/controller/PostCommentController.java @@ -0,0 +1,97 @@ +package com.ruoyi.post.frequency.postcomment.controller; + +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.page.TableDataInfo; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.common.utils.poi.ExcelUtil; +import com.ruoyi.post.frequency.postcomment.entity.PostComment; +import com.ruoyi.post.frequency.postcomment.service.PostCommentService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +/** + * 帖子评论Controller + * + * @author liwenlong + * @date 2023-10-09 + */ +@RestController +@RequestMapping("/frequency/poscomment") +public class PostCommentController extends BaseController +{ + @Autowired + private PostCommentService postCommentService; + + /** + * 查询帖子评论列表 + */ +// @PreAuthorize("@ss.hasPermi('frequency:poscomment:list')") + @PostMapping("/list") + public TableDataInfo list(@RequestBody PostComment postComment) + { + startPage(); + List list = postCommentService.selectPostCommentList(postComment); + return getDataTable(list); + } + + /** + * 导出帖子评论列表 + */ + @PreAuthorize("@ss.hasPermi('frequency:poscomment:export')") + @Log(title = "帖子评论", businessType = BusinessType.EXPORT) + @GetMapping("/export") + public AjaxResult export(PostComment postComment) + { + List list = postCommentService.selectPostCommentList(postComment); + ExcelUtil util = new ExcelUtil(PostComment.class); + return util.exportExcel(list, "帖子评论数据"); + } + + /** + * 获取帖子评论详细信息 + */ + @PreAuthorize("@ss.hasPermi('frequency:poscomment:query')") + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") Long id) + { + return AjaxResult.success(postCommentService.selectPostCommentById(id)); + } + + /** + * 新增帖子评论 + */ + @PreAuthorize("@ss.hasPermi('frequency:poscomment:add')") + @Log(title = "帖子评论", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody PostComment postComment) + { + return toAjax(postCommentService.insertPostComment(postComment)); + } + + /** + * 修改帖子评论 + */ + @PreAuthorize("@ss.hasPermi('frequency:poscomment:edit')") + @Log(title = "帖子评论", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody PostComment postComment) + { + return toAjax(postCommentService.updatePostComment(postComment)); + } + + /** + * 删除帖子评论 + */ + @PreAuthorize("@ss.hasPermi('frequency:poscomment:remove')") + @Log(title = "帖子评论", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}/{delFlag}") + public AjaxResult remove(@PathVariable("ids") Long[] ids,@PathVariable("delFlag") Integer delFlag) + { + return toAjax(postCommentService.deleteCommentByIds(ids,delFlag)); + } +} diff --git a/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/frequency/postcomment/entity/PostComment.java b/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/frequency/postcomment/entity/PostComment.java new file mode 100644 index 0000000..b17e1f2 --- /dev/null +++ b/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/frequency/postcomment/entity/PostComment.java @@ -0,0 +1,103 @@ +package com.ruoyi.post.frequency.postcomment.entity; + +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableName; +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import com.ruoyi.post.controller.req.PostCommentReq; +import com.ruoyi.utils.SnowIdUtils; +import com.ruoyi.vo.UserInfo; +import com.ruoyi.vo.UserVo; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; + +/** + * 帖子评论对象 t_post_comment + * + * @author liwenlong + * @date 2023-10-09 + */ +@Data +@Accessors(chain = true) +@TableName("t_post_comment") +public class PostComment extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + + @ApiModelProperty("租户号") + private Long id; + + @ApiModelProperty("删除状态 1 正常 2 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("用户类型") + @Excel(name = "用户类型") + private Integer userType; + + @ApiModelProperty("评论用户id") + @Excel(name = "评论用户id") + private Long userId; + + @ApiModelProperty("帖子id") + @Excel(name = "帖子id") + private Long postId; + + @ApiModelProperty("顶级评论id(对主体的直接评论)") + @Excel(name = "顶级评论id(对主体的直接评论)") + private Long topId; + + @ApiModelProperty("上级评论id 默认0") + @Excel(name = "上级评论id 默认0") + private Long parentId; + + @ApiModelProperty("用户类型") + @Excel(name = "用户类型") + private Integer parentUserType; + + @ApiModelProperty("上级评论用户id") + @Excel(name = "上级评论用户id") + private Long parentUserId; + + @ApiModelProperty("评论内容") + @Excel(name = "评论内容") + private String content; + + @ApiModelProperty("图片") + @Excel(name = "图片") + private String image; + + @ApiModelProperty("点赞数") + @Excel(name = "点赞数") + private Integer likeNum; + + @ApiModelProperty("评论数") + @Excel(name = "评论数") + private Integer commentNum; + + @ApiModelProperty("上级评论id集合,逗号拼接") + @Excel(name = "上级评论id集合,逗号拼接") + private String parentIds; + + @ApiModelProperty(value = "用户信息") + @TableField(exist = false) + private UserInfo userInfo; + + @ApiModelProperty(value = "上级用户用户昵称") + @TableField(exist = false) + private UserInfo parentUserInfo; + + public PostComment() { + } + + public PostComment(PostCommentReq req, UserVo userVo) { + this.id = SnowIdUtils.uniqueLong(); + this.userType = userVo.getUserType(); + this.userId = userVo.getUserId(); + this.postId = req.getPostId(); + this.content = req.getContent(); + this.image = req.getImage(); + this.parentId = req.getParentId(); + } +} diff --git a/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/frequency/postcomment/mapper/PostCommentMapper.java b/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/frequency/postcomment/mapper/PostCommentMapper.java new file mode 100644 index 0000000..f819c51 --- /dev/null +++ b/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/frequency/postcomment/mapper/PostCommentMapper.java @@ -0,0 +1,110 @@ +package com.ruoyi.post.frequency.postcomment.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.ruoyi.controller.req.DialoguePageReq; +import com.ruoyi.controller.resp.CommentNum; +import com.ruoyi.post.controller.req.PostCommentPageReq; +import com.ruoyi.post.controller.resp.PostCommentPageResp; +import com.ruoyi.post.controller.resp.PostCommentResp; +import com.ruoyi.post.frequency.postcomment.entity.PostComment; +import com.ruoyi.vo.UserVo; +import org.apache.ibatis.annotations.Param; +import org.apache.ibatis.annotations.Update; + +import java.util.List; + +/** + * 帖子评论Mapper接口 + * + * @author liwenlong + * @date 2023-10-09 + */ +public interface PostCommentMapper extends BaseMapper +{ + /** + * 查询帖子评论 + * + * @param id 帖子评论主键 + * @return 帖子评论 + */ + public PostComment selectPostCommentById(Long id); + + /** + * 查询帖子评论列表 + * + * @param postComment 帖子评论 + * @return 帖子评论集合 + */ + public List selectPostCommentList(PostComment postComment); + + /** + * 新增帖子评论 + * + * @param postComment 帖子评论 + * @return 结果 + */ + public int insertPostComment(PostComment postComment); + + /** + * 修改帖子评论 + * + * @param postComment 帖子评论 + * @return 结果 + */ + public int updatePostComment(PostComment postComment); + + /** + * 修改帖子评论 + * + * @param postComment 帖子评论 + * @return 结果 + */ + public int updatePostCommentNumBatch(@Param("list") List postComment); + + + /** + * 删除帖子评论 + * + * @param id 帖子评论主键 + * @return 结果 + */ + public int deletePostCommentById(Long id); + + /** + * 批量删除帖子评论 + * + * @param ids 需要删除的数据主键集合 + * @return 结果 + */ + public int deletePostCommentByIds(Long[] ids); + + + /** + *获取评论后数据 + * @param id + * @return + */ + PostCommentResp getPostCommentResp(@Param("id")Long id,@Param("userVo") UserVo userVo); + + + /** + * 帖子评论列表 + * @param objectPage + * @param req + * @param userVo + * @return + */ + Page postCommentPage(@Param("page")Page objectPage, @Param("req") PostCommentPageReq req, @Param("userVo") UserVo userVo); + + List selectCommentNumList(@Param("commentIds") List commentIds,@Param("userVoList") List userVoList); + + List selectedNewCommentList(@Param("postIds") List postIds); + + @Update("update t_post_comment set like_num = like_num + #{num} , update_time=now() where id = #{id}") + int updatePostCommentLikeNum(@Param("id") Long id, @Param("num") Integer num); + + List postCommentList(@Param("req") PostCommentPageReq req,@Param("userVo") UserVo userVo,@Param("list") List parentIds); + + Page postCommentDialoguePage(@Param("page") Page objectPage,@Param("req") DialoguePageReq req,@Param("userVo") UserVo userVo); +} diff --git a/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/frequency/postcomment/mapper/mapping/PostCommentMapper.xml b/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/frequency/postcomment/mapper/mapping/PostCommentMapper.xml new file mode 100644 index 0000000..6102f64 --- /dev/null +++ b/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/frequency/postcomment/mapper/mapping/PostCommentMapper.xml @@ -0,0 +1,713 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + select id, + del_flag, + create_by, + create_time, + update_by, + update_time, + user_type, + user_id, + post_id, + top_id, + parent_id, + parent_user_type, + parent_user_id, + content, + image, + like_num, + comment_num + from t_post_comment + + + + + + + + insert into t_post_comment + + id, + del_flag, + create_by, + create_time, + update_by, + update_time, + user_type, + user_id, + post_id, + top_id, + parent_id, + parent_user_type, + parent_user_id, + content, + image, + like_num, + comment_num, + + + #{id}, + #{delFlag}, + #{createBy}, + #{createTime}, + #{updateBy}, + #{updateTime}, + #{userType}, + #{userId}, + #{postId}, + #{topId}, + #{parentId}, + #{parentUserType}, + #{parentUserId}, + #{content}, + #{image}, + #{likeNum}, + #{commentNum}, + + + + + update t_post_comment + + del_flag = #{delFlag}, + create_by = #{createBy}, + create_time = #{createTime}, + update_by = #{updateBy}, + update_time = #{updateTime}, + user_type = #{userType}, + user_id = #{userId}, + post_id = #{postId}, + top_id = #{topId}, + parent_id = #{parentId}, + parent_user_type = #{parentUserType}, + parent_user_id = #{parentUserId}, + content = #{content}, + image = #{image}, + like_num = like_num + #{likeNum}, + comment_num = comment_num + #{commentNum}, + + where id = #{id} + and like_num + #{likeNum}>=0 + and comment_num + #{commentNum} >= 0 + + + + + + update t_post_comment + + like_num = like_num + #{item.likeNum}, + comment_num = comment_num + #{item.commentNum}, + + where id = #{item.id} + and like_num + #{item.likeNum}>=0 + and comment_num + #{item.commentNum} >= 0 + + + + + delete + from t_post_comment + where id = #{id} + + + + delete from t_post_comment where id in + + #{id} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/frequency/postcomment/model/param/PostCommentParam.java b/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/frequency/postcomment/model/param/PostCommentParam.java new file mode 100644 index 0000000..9f64cb3 --- /dev/null +++ b/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/frequency/postcomment/model/param/PostCommentParam.java @@ -0,0 +1,88 @@ +package com.ruoyi.post.frequency.postcomment.model.param; + +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; + +/** + * 帖子评论对象 t_post_comment + * + * @author liwenlong + * @date 2023-10-09 + */ +@Data +@Accessors(chain = true) +public class PostCommentParam extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + @ApiModelProperty("租户号") + private Long id; + + @ApiModelProperty("删除状态 1 正常 2 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("用户类型") + @Excel(name = "用户类型") + private Integer userType; + + @ApiModelProperty("评论用户id") + @Excel(name = "评论用户id") + private Long userId; + + @ApiModelProperty("帖子id") + @Excel(name = "帖子id") + private Long postId; + + @ApiModelProperty("顶级评论id(对主体的直接评论)") + @Excel(name = "顶级评论id(对主体的直接评论)") + private Long topId; + + @ApiModelProperty("上级评论id 默认0") + @Excel(name = "上级评论id 默认0") + private Long parentId; + + @ApiModelProperty("用户类型") + @Excel(name = "用户类型") + private Integer parentUserType; + + @ApiModelProperty("上级评论用户id") + @Excel(name = "上级评论用户id") + private Long parentUserId; + + @ApiModelProperty("评论内容") + @Excel(name = "评论内容") + private String content; + + @ApiModelProperty("图片") + @Excel(name = "图片") + private String image; + + @ApiModelProperty("点赞数") + @Excel(name = "点赞数") + private Long likeNum; + + @ApiModelProperty("评论数") + @Excel(name = "评论数") + private Long commentNum; + + @ApiModelProperty("上级评论id集合,逗号拼接") + @Excel(name = "上级评论id集合,逗号拼接") + private String parentIds; + + + + + + + + + + + + + + +} diff --git a/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/frequency/postcomment/model/result/PostCommentResult.java b/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/frequency/postcomment/model/result/PostCommentResult.java new file mode 100644 index 0000000..cc7b22d --- /dev/null +++ b/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/frequency/postcomment/model/result/PostCommentResult.java @@ -0,0 +1,75 @@ +package com.ruoyi.post.frequency.postcomment.model.result; + +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; + +/** + * 帖子评论对象 t_post_comment + * + * @author liwenlong + * @date 2023-10-09 + */ +@Data +@Accessors(chain = true) +public class PostCommentResult extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + @ApiModelProperty("租户号") + private Long id; + + @ApiModelProperty("删除状态 1 正常 2 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("用户类型") + @Excel(name = "用户类型") + private Integer userType; + + @ApiModelProperty("评论用户id") + @Excel(name = "评论用户id") + private Long userId; + + @ApiModelProperty("帖子id") + @Excel(name = "帖子id") + private Long postId; + + @ApiModelProperty("顶级评论id(对主体的直接评论)") + @Excel(name = "顶级评论id(对主体的直接评论)") + private Long topId; + + @ApiModelProperty("上级评论id 默认0") + @Excel(name = "上级评论id 默认0") + private Long parentId; + + @ApiModelProperty("用户类型") + @Excel(name = "用户类型") + private Integer parentUserType; + + @ApiModelProperty("上级评论用户id") + @Excel(name = "上级评论用户id") + private Long parentUserId; + + @ApiModelProperty("评论内容") + @Excel(name = "评论内容") + private String content; + + @ApiModelProperty("图片") + @Excel(name = "图片") + private String image; + + @ApiModelProperty("点赞数") + @Excel(name = "点赞数") + private Long likeNum; + + @ApiModelProperty("评论数") + @Excel(name = "评论数") + private Long commentNum; + + @ApiModelProperty("上级评论id集合,逗号拼接") + @Excel(name = "上级评论id集合,逗号拼接") + private String parentIds; + +} diff --git a/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/frequency/postcomment/service/PostCommentService.java b/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/frequency/postcomment/service/PostCommentService.java new file mode 100644 index 0000000..7cc38e7 --- /dev/null +++ b/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/frequency/postcomment/service/PostCommentService.java @@ -0,0 +1,127 @@ +package com.ruoyi.post.frequency.postcomment.service; + +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.IService; +import com.ruoyi.common.page.PageResult; +import com.ruoyi.controller.req.DialoguePageReq; +import com.ruoyi.post.controller.req.DeleteCommentReq; +import com.ruoyi.post.controller.req.PostCommentPageReq; +import com.ruoyi.post.controller.req.PostCommentReq; +import com.ruoyi.post.controller.resp.PostCommentPageResp; +import com.ruoyi.post.controller.resp.PostCommentResp; +import com.ruoyi.post.controller.vo.SelectedComment; +import com.ruoyi.post.frequency.postcomment.entity.PostComment; +import com.ruoyi.response.ResponseData; +import com.ruoyi.vo.UserVo; + +import java.util.List; +import java.util.Map; + +/** + * 帖子评论Service接口 + * + * @author liwenlong + * @date 2023-10-09 + */ +public interface PostCommentService extends IService +{ + /** + * 查询帖子评论 + * + * @param id 帖子评论主键 + * @return 帖子评论 + */ + public PostComment selectPostCommentById(Long id); + + /** + * 查询帖子评论列表 + * + * @param postComment 帖子评论 + * @return 帖子评论集合 + */ + public List selectPostCommentList(PostComment postComment); + + /** + * 新增帖子评论 + * + * @param postComment 帖子评论 + * @return 结果 + */ + public int insertPostComment(PostComment postComment); + + /** + * 修改帖子评论 + * + * @param postComment 帖子评论 + * @return 结果 + */ + public int updatePostComment(PostComment postComment); + + int updatePostCommentBatch(List postCommentList); + + int updatePostCommentLikeNum(PostComment postComment, Integer num); + + /** + * 批量删除帖子评论 + * + * @param ids 需要删除的帖子评论主键集合 + * @return 结果 + */ + public int deletePostCommentByIds(Long[] ids); + + /** + * 删除帖子评论信息 + * + * @param id 帖子评论主键 + * @return 结果 + */ + public int deletePostCommentById(Long id); + + + /** + * 帖子评论 + * @param req + * @param userVo 登入用户 + * @return + */ + ResponseData postComment(PostCommentReq req, UserVo userVo); + + + /** + * 帖子评论列表 + * @param req + * @param userVo 登入用户 + * @return + */ + ResponseData postCommentPage(PostCommentPageReq req, UserVo userVo); + + /** + * 删除评论 + * @param req + * @param userVo 登入用户 + * @return + */ + ResponseData deleteComment(DeleteCommentReq req, UserVo userVo); + + + /** + * 查询精选评论 + * @param commentIds 精彩评论ids + * @param userVo + * @return + */ + Map getSelectedCommentMap(List commentIds, UserVo userVo); + + /** + * 查询最新评论 + * @param userVo + * @return + */ + Map getSelectedNewCommentMap(List postIds, UserVo userVo); + + ResponseData postCommentDetail(Long id, UserVo userVo); + + ResponseData>> postCommentDialoguePage(DialoguePageReq req, UserVo userVo); + + int deleteCommentByIds(Long[] ids, Integer delFlag); +} diff --git a/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/frequency/postcomment/service/impl/PostCommentServiceImpl.java b/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/frequency/postcomment/service/impl/PostCommentServiceImpl.java new file mode 100644 index 0000000..fc890dd --- /dev/null +++ b/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/frequency/postcomment/service/impl/PostCommentServiceImpl.java @@ -0,0 +1,574 @@ +package com.ruoyi.post.frequency.postcomment.service.impl; + +import cn.hutool.core.collection.CollectionUtil; +import cn.hutool.core.util.ObjectUtil; +import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.ruoyi.code.PublicCommon; +import com.ruoyi.common.page.PageResult; +import com.ruoyi.common.utils.DateUtils; +import com.ruoyi.controller.req.DialoguePageReq; +import com.ruoyi.controller.resp.CommentNum; +import com.ruoyi.enums.message.InteractionMessageEnums; +import com.ruoyi.frequency.customer.service.UserService; +import com.ruoyi.message.frequency.interactionmessagerecord.service.InteractionMessageRecordService; +import com.ruoyi.post.controller.req.DeleteCommentReq; +import com.ruoyi.post.controller.req.PostCommentPageReq; +import com.ruoyi.post.controller.req.PostCommentReq; +import com.ruoyi.post.controller.resp.PostCommentPageResp; +import com.ruoyi.post.controller.resp.PostCommentResp; +import com.ruoyi.post.controller.vo.SelectedComment; +import com.ruoyi.post.frequency.post.entity.Post; +import com.ruoyi.post.frequency.post.mapper.PostMapper; +import com.ruoyi.post.frequency.post.service.PostService; +import com.ruoyi.post.frequency.postcomment.entity.PostComment; +import com.ruoyi.post.frequency.postcomment.mapper.PostCommentMapper; +import com.ruoyi.post.frequency.postcomment.service.PostCommentService; +import com.ruoyi.response.ResponseData; +import com.ruoyi.utils.BusinessUtil; +import com.ruoyi.vo.UserInfo; +import com.ruoyi.vo.UserVo; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.*; +import java.util.stream.Collectors; + +/** + * 帖子评论Service业务层处理 + * + * @author liwenlong + * @date 2023-10-09 + */ +@Service +@Transactional(rollbackFor = Exception.class) +public class PostCommentServiceImpl extends ServiceImpl implements PostCommentService { + @Autowired + private PostCommentMapper postCommentMapper; + + /** + * 查询帖子评论 + * + * @param id 帖子评论主键 + * @return 帖子评论 + */ + @Override + public PostComment selectPostCommentById(Long id) { + PostComment postComment = postCommentMapper.selectPostCommentById(id); + + if (postComment != null) { + Set userVoSet = new HashSet<>(); + userVoSet.add(new UserVo(postComment.getUserType(), postComment.getUserId())); + userVoSet.add(new UserVo(postComment.getParentUserType(), postComment.getParentUserId())); + + //查询用户信息 + Map userMap = userService.selectUserInfoMap(userVoSet, null); + + postComment.setUserInfo(userMap.get(new UserVo(postComment.getUserType(), postComment.getUserId()))); + postComment.setParentUserInfo(userMap.get(new UserVo(postComment.getParentUserType(), postComment.getParentUserId()))); + } + + return postComment; + } + + /** + * 查询帖子评论列表 + * + * @param postComment 帖子评论 + * @return 帖子评论 + */ + @Override + public List selectPostCommentList(PostComment postComment) { + List postComments = postCommentMapper.selectPostCommentList(postComment); + + if (!postComments.isEmpty()) { + Set userVoSet = postComments.stream().map(s -> new UserVo(s.getUserType(), s.getUserId())).collect(Collectors.toSet()); + Set parentUserVoSet = postComments.stream().map(s -> new UserVo(s.getParentUserType(), s.getParentUserId())).collect(Collectors.toSet()); + + userVoSet.addAll(parentUserVoSet); + + //查询用户信息 + Map userMap = userService.selectUserInfoMap(userVoSet, null); + + postComments.stream().forEach(s -> { + s.setUserInfo(userMap.get(new UserVo(s.getUserType(), s.getUserId()))); + s.setParentUserInfo(userMap.get(new UserVo(s.getParentUserType(), s.getParentUserId()))); + }); + } + + return postComments; + } + + /** + * 新增帖子评论 + * + * @param postComment 帖子评论 + * @return 结果 + */ + @Override + public int insertPostComment(PostComment postComment) { + postComment.setCreateTime(DateUtils.getNowDate()); + return postCommentMapper.insertPostComment(postComment); + } + + /** + * 修改帖子评论 + * + * @param postComment 帖子评论 + * @return 结果 + */ + @Override + public int updatePostComment(PostComment postComment) { + postComment.setUpdateTime(DateUtils.getNowDate()); + return postCommentMapper.updatePostComment(postComment); + } + + /** + * 修改帖子评论 + * + * @param postCommentList 帖子评论 + * @return 结果 + */ + @Override + public int updatePostCommentBatch(List postCommentList) { + postCommentList.stream().forEach(postComment -> { + postComment.setUpdateTime(DateUtils.getNowDate()); + }); + + return postCommentMapper.updatePostCommentNumBatch(postCommentList); + } + + + /** + * 修改帖子评论 + * + * @param postComment 帖子评论 + * @return 结果 + */ + @Override + public int updatePostCommentLikeNum(PostComment postComment, Integer num) { + return postCommentMapper.updatePostCommentLikeNum(postComment.getId(), num); + } + + /** + * 批量删除帖子评论 + * + * @param ids 需要删除的帖子评论主键 + * @return 结果 + */ + @Override + public int deletePostCommentByIds(Long[] ids) { + this.lambdaUpdate().set(PostComment::getDelFlag, PublicCommon.删除).in(PostComment::getId, ids).update(); + return ids.length; + } + + /** + * 删除帖子评论信息 + * + * @param id 帖子评论主键 + * @return 结果 + */ + @Override + public int deletePostCommentById(Long id) { + this.lambdaUpdate().set(PostComment::getDelFlag, PublicCommon.删除).eq(PostComment::getId, id).update(); + return 1; + } + + @Autowired + private UserService userService; + + @Autowired + private PostService postService; + + @Override + public ResponseData postComment(PostCommentReq req, UserVo userVo) { + + //帖子评论 + PostComment postComment = new PostComment(req, userVo); + + + //帖子-->评论 + if (ObjectUtil.isEmpty(req.getParentId()) || ObjectUtil.equal(0L, req.getParentId())) { + //顶级评论id + postComment.setTopId(postComment.getId()); + + Post post = postService.getById(req.getPostId()); + } else { + //查询上级评论 + PostComment parentPostComment = this.getById(req.getParentId()); + + //评论用户 + postComment.setParentUserId(parentPostComment.getUserId()) + .setParentUserType(parentPostComment.getUserType()); + + postComment.setTopId(parentPostComment.getTopId()); + + //上级id + if (ObjectUtil.isNotEmpty(parentPostComment.getParentIds())) { + postComment.setParentIds(parentPostComment.getParentIds() + "," + parentPostComment.getId()); + } else { + postComment.setParentIds(parentPostComment.getId() + ""); + } + + } + + this.save(postComment); + + //1 帖子 2 帖子评论 + Integer type = ObjectUtil.equal(0L, req.getParentId()) || ObjectUtil.isEmpty(req.getParentId()) ? 1 : 2; + + //修改评论数(只要针对这个贴子下的评论 帖子评论数都要+1) + postMapper.updateNumPost(postComment.getPostId(), PublicCommon.Post.评论数, 1); + //修改热度时间 + postMapper.update(new Post().setTrendsTime(new Date()), new LambdaUpdateWrapper().eq(Post::getId, postComment.getPostId())); + + //帖子评论 所有上级评论数+1 + if (ObjectUtil.equal(2, type)) { + //上级评论ids + List pids = Arrays.stream(postComment.getParentIds().split(",")).collect(Collectors.toList()); + + List postComments = pids.stream().map(id -> new PostComment().setId(Long.valueOf(id)).setCommentNum(1)).collect(Collectors.toList()); + + this.updatePostCommentBatch(postComments); + } + + //返回结果 + PostCommentResp commentResp = baseMapper.getPostCommentResp(postComment.getId(), userVo); + + if (commentResp != null) { + + UserVo parentUserVo = new UserVo(postComment.getParentUserType(), postComment.getParentUserId()); + + Set userVoSet = CollectionUtil.newHashSet(userVo, parentUserVo); + //查询用户信息 + Map userMap = userService.selectUserInfoMap(userVoSet, userVo); + + commentResp.setUserInfo(userMap.get(userVo)); + + commentResp.setParentUserInfo(userMap.get(parentUserVo)); + } + + //给自己的评论不需要推送消息 + pushMessage(req, userVo, true); + return ResponseData.success(commentResp); + } + + @Autowired + private InteractionMessageRecordService interactionMessageRecordService; + + /** + * 推送消息 + * + * @param req + * @param userVo + * @param isPush + */ + private void pushMessage(PostCommentReq req, UserVo userVo, Boolean isPush) { + + InteractionMessageEnums enums = ObjectUtil.equal(0L, req.getParentId()) ? InteractionMessageEnums.COMMENT_POST : InteractionMessageEnums.REPLY_POST_COMMENT; + + //帖子id + Long postId = null; + + //接收消息用户 + UserVo sendUserVo = null; + + if (ObjectUtil.equal(0L, req.getParentId())) { + //评论帖子 + postId = req.getPostId(); + //帖子 + Post post = postService.getById(postId); + sendUserVo = new UserVo(post.getUserType(), post.getUserId()); + } else { + //回复评论 + PostComment postComment = this.getById(req.getParentId()); + postId = postComment.getPostId(); + sendUserVo = new UserVo(postComment.getUserType(), postComment.getUserId()); + } + //互动消息 + interactionMessageRecordService.addInteractionMessage(userVo, sendUserVo, PublicCommon.InteractionMessage.评论, postId, isPush, enums); + + } + + @Override + public ResponseData postCommentPage(PostCommentPageReq req, UserVo userVo) { + + //筛去拉黑与被拉黑用户 + List blockUserList = userService.blockUserList(userVo); + req.setBlockUserList(blockUserList); + + //筛去屏蔽用户 + List shieldUserList = userService.shieldUserList(userVo); + req.setShieldUserList(shieldUserList); + + Page page = this.baseMapper.postCommentPage(new Page<>(req.getPageNo(), req.getPageSize()), req, userVo); + + if (!page.getRecords().isEmpty()) { + Set userVoSet = page.getRecords().stream().map(postPageResp -> new UserVo(postPageResp.getUserType(), postPageResp.getUserId())).collect(Collectors.toSet()); + Set parentUserVoSet = page.getRecords().stream().map(postPageResp -> new UserVo(postPageResp.getParentUserType(), postPageResp.getParentUserId())).collect(Collectors.toSet()); + + userVoSet.addAll(parentUserVoSet); + + List postCommentList = twoCommentList(req, userVo, page); + + postCommentList.stream().forEach(postPageResp -> { + userVoSet.add(new UserVo(postPageResp.getUserType(), postPageResp.getUserId())); + userVoSet.add(new UserVo(postPageResp.getParentUserType(), postPageResp.getParentUserId())); + }); + + + //查询用户信息 + Map userMap = userService.selectUserInfoMap(userVoSet, userVo); + + List userVoList = CollectionUtil.addAllIfNotContains(blockUserList, shieldUserList); + + Map commentNumMap = getCommentNumMap(userVoList, page.getRecords()); + + postCommentList.stream().forEach(resp -> { + resp.setUserInfo(userMap.get(new UserVo(resp.getUserType(), resp.getUserId()))); + resp.setParentUserInfo(userMap.get(new UserVo(resp.getParentUserType(), resp.getParentUserId()))); + }); + //获取二级评论 + Map> map = postCommentList.stream().collect(Collectors.groupingBy(PostCommentPageResp::getParentId)); + ; + + + page.getRecords().stream().forEach(resp -> { + resp.setUserInfo(userMap.get(new UserVo(resp.getUserType(), resp.getUserId()))); + resp.setParentUserInfo(userMap.get(new UserVo(resp.getParentUserType(), resp.getParentUserId()))); + if (commentNumMap.get(resp.getId()) != null) { + resp.setCommentNum(resp.getCommentNum() - commentNumMap.get(resp.getId())); + } + + //二级评论 + resp.setChildrenList(map.get(resp.getId())); + }); + } + + return ResponseData.success(new PageResult<>(page)); + } + + /** + * 获取二级评论ID + * + * @param req + * @param userVo + * @param page + * @return + */ + private List twoCommentList(PostCommentPageReq req, UserVo userVo, Page page) { + + Map> map = new HashMap<>(); + + if (ObjectUtil.isEmpty(req.getParentId())) { + //一级评论ID + List parentIds = page.getRecords().stream().map(PostCommentPageResp::getId).collect(Collectors.toList()); + + if (CollectionUtil.isEmpty(parentIds)) { + return new ArrayList<>(); + } + //查询二级评论 + List postCommentList = this.baseMapper.postCommentList(req, userVo, parentIds); + + return postCommentList; + } + return new ArrayList<>(); + } + + private Map getCommentNumMap(List userVoList, List respList) { + + if (userVoList.size() == 0) { + return new HashMap<>(); + } + List commentIds = respList.stream().map(PostCommentPageResp::getId).collect(Collectors.toList()); + //查询用户对应评论的数量 key一级评论id value 隐藏数量 + List commentNums = postCommentMapper.selectCommentNumList(commentIds, userVoList); + + Map commentNumMap = new HashMap<>(); + commentNums.stream().forEach(s -> { + commentNumMap.put(s.getPostId(), s.getCommentNum()); + }); + return commentNumMap; + } + + @Override + public ResponseData deleteComment(DeleteCommentReq req, UserVo userVo) { + + boolean update = this.lambdaUpdate().set(PostComment::getDelFlag, PublicCommon.删除) + .eq(PostComment::getUserType, userVo.getUserType()) + .eq(PostComment::getUserId, userVo.getUserId()) + .eq(PostComment::getId, req.getId()) + .eq(PostComment::getDelFlag, PublicCommon.启用).update(); + + if (update) { + afterDeleteComment(req.getId()); + } + return ResponseData.success(); + } + + private void afterDeleteComment(Long objectId) { + + PostComment postComment = this.getById(objectId); + + //1 帖子 2 帖子评论 + Integer type = ObjectUtil.equal(0L, postComment.getParentId()) ? 1 : 2; + + Integer num = -(postComment.getCommentNum() + 1); + //帖子评论 上级数量 + if (ObjectUtil.equal(2, type)) { + //当前评论上级ids + List pids = Arrays.stream(postComment.getParentIds() + .split(",")).collect(Collectors.toList()); + num = -1 * pids.size(); + + //上级评论数都要减去当前删除评论数 + 1(本身评论) + List postComments = pids.stream().map(id -> new PostComment().setId(Long.valueOf(id)).setCommentNum(-1 * (postComment.getCommentNum() + 1))).collect(Collectors.toList()); + + this.updatePostCommentBatch(postComments); + + } + //删除当前评论所有下级评论 + this.lambdaUpdate().set(PostComment::getDelFlag, PublicCommon.删除) + .like(PostComment::getParentIds, objectId) + .eq(PostComment::getDelFlag, PublicCommon.启用).update(); + + + //修改评论数 + postMapper.updateNumPost(postComment.getPostId(), PublicCommon.Post.评论数, num); + } + + + @Override + public int deleteCommentByIds(Long[] ids, Integer delFlag) { + + if (PublicCommon.删除.equals(delFlag)) { + for (Long objectId : ids) { + afterDeleteComment(objectId); + } + } + + this.lambdaUpdate().set(PostComment::getDelFlag, delFlag).in(PostComment::getId, ids).update(); + return 1; + } + + @Autowired + private BusinessUtil businessUtil; + + @Override + public Map getSelectedCommentMap(List commentIds, UserVo userVo) { + + Map map = new HashMap<>(); + + if (CollectionUtil.isEmpty(commentIds)) { + return map; + } + + List postComments = this.lambdaQuery().in(PostComment::getId, commentIds).eq(PostComment::getParentId, 0L).eq(PostComment::getDelFlag, PublicCommon.启用).list(); + + Set userVoSet = postComments.stream().map(postComment -> new UserVo(postComment.getUserType(), postComment.getUserId())).collect(Collectors.toSet()); + + //查询用户信息 + Map userMap = userService.selectUserInfoMap(userVoSet, userVo); + + postComments.stream().forEach(postComment -> { + map.put(postComment.getId(), new SelectedComment(2, postComment, userMap.get(new UserVo(postComment.getUserType(), postComment.getUserId())))); + }); + + return map; + } + + @Override + public Map getSelectedNewCommentMap(List postIds, UserVo userVo) { + Map map = new HashMap<>(); + + if (CollectionUtil.isEmpty(postIds)) { + return map; + } + + List postComments = postCommentMapper.selectedNewCommentList(postIds); + + Set userVoSet = postComments.stream().map(postComment -> new UserVo(postComment.getUserType(), postComment.getUserId())).collect(Collectors.toSet()); + + //查询用户信息 + Map userMap = userService.selectUserInfoMap(userVoSet, userVo); + + postComments.stream().forEach(postComment -> { + map.put(postComment.getPostId(), new SelectedComment(1, postComment, userMap.get(new UserVo(postComment.getUserType(), postComment.getUserId())))); + }); + + return map; + } + + + @Autowired + private PostMapper postMapper; + + /** + * 修改评论数 + * + * @param objectId 评论主体id + * @param type 1帖子 2 帖子评论 + * @param num + */ + private void updatePostCommentNum(Long objectId, Integer type, Integer num) { + + switch (type) { + case 1: + postMapper.updateNumPost(objectId, PublicCommon.Post.评论数, num); + break; + case 2: + this.updatePostComment(new PostComment().setId(objectId).setCommentNum(num)); + break; + default: + throw new IllegalStateException("Unexpected value: " + type); + } + } + + + @Override + public ResponseData postCommentDetail(Long id, UserVo userVo) { + //返回结果 + PostCommentResp commentResp = baseMapper.getPostCommentResp(id, userVo); + + if (commentResp != null) { + + UserVo parentUserVo = new UserVo(commentResp.getParentUserType(), commentResp.getParentUserId()); + UserVo user = new UserVo(commentResp.getUserType(), commentResp.getUserId()); + + Set userVoSet = CollectionUtil.newHashSet(user, parentUserVo); + //查询用户信息 + Map userMap = userService.selectUserInfoMap(userVoSet, userVo); + + commentResp.setUserInfo(userMap.get(user)); + + commentResp.setParentUserInfo(userMap.get(parentUserVo)); + } + + return ResponseData.success(commentResp); + } + + @Override + public ResponseData>> postCommentDialoguePage(DialoguePageReq req, UserVo userVo) { + Page page = this.baseMapper.postCommentDialoguePage(new Page<>(req.getPageNo(), req.getPageSize()), req, userVo); + + if (!page.getRecords().isEmpty()) { + Set userVoSet = page.getRecords().stream().map(postPageResp -> new UserVo(postPageResp.getUserType(), postPageResp.getUserId())).collect(Collectors.toSet()); + Set parentUserVoSet = page.getRecords().stream().map(postPageResp -> new UserVo(postPageResp.getParentUserType(), postPageResp.getParentUserId())).collect(Collectors.toSet()); + + userVoSet.addAll(parentUserVoSet); + + //查询用户信息 + Map userMap = userService.selectUserInfoMap(userVoSet, userVo); + + page.getRecords().stream().forEach(resp -> { + resp.setUserInfo(userMap.get(new UserVo(resp.getUserType(), resp.getUserId()))); + resp.setParentUserInfo(userMap.get(new UserVo(resp.getParentUserType(), resp.getParentUserId()))); + }); + } + + return ResponseData.success(new PageResult<>(page)); + } + +} diff --git a/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/frequency/postlike/controller/PostLikeController.java b/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/frequency/postlike/controller/PostLikeController.java new file mode 100644 index 0000000..c67ed37 --- /dev/null +++ b/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/frequency/postlike/controller/PostLikeController.java @@ -0,0 +1,97 @@ +package com.ruoyi.post.frequency.postlike.controller; + +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.page.TableDataInfo; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.common.utils.poi.ExcelUtil; +import com.ruoyi.post.frequency.postlike.entity.PostLike; +import com.ruoyi.post.frequency.postlike.service.PostLikeService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +/** + * 帖子点赞Controller + * + * @author liwenlong + * @date 2023-10-09 + */ +@RestController +@RequestMapping("/frequency/poslike") +public class PostLikeController extends BaseController +{ + @Autowired + private PostLikeService postLikeService; + + /** + * 查询帖子点赞列表 + */ + @PreAuthorize("@ss.hasPermi('frequency:poslike:list')") + @PostMapping("/list") + public TableDataInfo list(@RequestBody PostLike postLike) + { + startPage(); + List list = postLikeService.selectPostLikeList(postLike); + return getDataTable(list); + } + + /** + * 导出帖子点赞列表 + */ + @PreAuthorize("@ss.hasPermi('frequency:poslike:export')") + @Log(title = "帖子点赞", businessType = BusinessType.EXPORT) + @GetMapping("/export") + public AjaxResult export(PostLike postLike) + { + List list = postLikeService.selectPostLikeList(postLike); + ExcelUtil util = new ExcelUtil(PostLike.class); + return util.exportExcel(list, "帖子点赞数据"); + } + + /** + * 获取帖子点赞详细信息 + */ + @PreAuthorize("@ss.hasPermi('frequency:poslike:query')") + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") Long id) + { + return AjaxResult.success(postLikeService.selectPostLikeById(id)); + } + + /** + * 新增帖子点赞 + */ + @PreAuthorize("@ss.hasPermi('frequency:poslike:add')") + @Log(title = "帖子点赞", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody PostLike postLike) + { + return toAjax(postLikeService.insertPostLike(postLike)); + } + + /** + * 修改帖子点赞 + */ + @PreAuthorize("@ss.hasPermi('frequency:poslike:edit')") + @Log(title = "帖子点赞", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody PostLike postLike) + { + return toAjax(postLikeService.updatePostLike(postLike)); + } + + /** + * 删除帖子点赞 + */ + @PreAuthorize("@ss.hasPermi('frequency:poslike:remove')") + @Log(title = "帖子点赞", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}") + public AjaxResult remove(@PathVariable Long[] ids) + { + return toAjax(postLikeService.deletePostLikeByIds(ids)); + } +} diff --git a/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/frequency/postlike/entity/PostLike.java b/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/frequency/postlike/entity/PostLike.java new file mode 100644 index 0000000..940977f --- /dev/null +++ b/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/frequency/postlike/entity/PostLike.java @@ -0,0 +1,56 @@ +package com.ruoyi.post.frequency.postlike.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import com.ruoyi.utils.SnowIdUtils; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; + +/** + * 帖子点赞对象 t_post_like + * + * @author liwenlong + * @date 2023-10-09 + */ +@Data +@Accessors(chain = true) +@TableName("t_post_like") +public class PostLike extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + + @ApiModelProperty("主键id") + private Long id; + + @ApiModelProperty("删除标志 1正常 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("类型 1 帖子2 帖子评论 ") + @Excel(name = "类型 1 帖子2 帖子评论 ") + private Integer type; + + @ApiModelProperty("用户类型 1 用户 ") + @Excel(name = "用户类型 1 用户 ") + private Integer userType; + + @ApiModelProperty("用户id") + @Excel(name = "用户id") + private Long userId; + + @ApiModelProperty("帖子id/帖子评论id") + @Excel(name = "帖子id/帖子评论id") + private Long objectId; + + + public PostLike() { + } + + public PostLike(Integer type, Long objectId) { + this.id = SnowIdUtils.uniqueLong(); + this.type = type; + this.objectId = objectId; + } +} diff --git a/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/frequency/postlike/mapper/PostLikeMapper.java b/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/frequency/postlike/mapper/PostLikeMapper.java new file mode 100644 index 0000000..1ea2632 --- /dev/null +++ b/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/frequency/postlike/mapper/PostLikeMapper.java @@ -0,0 +1,73 @@ +package com.ruoyi.post.frequency.postlike.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.ruoyi.post.frequency.postlike.entity.PostLike; +import com.ruoyi.vo.UserVo; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * 帖子点赞Mapper接口 + * + * @author liwenlong + * @date 2023-10-09 + */ +public interface PostLikeMapper extends BaseMapper +{ + /** + * 查询帖子点赞 + * + * @param id 帖子点赞主键 + * @return 帖子点赞 + */ + public PostLike selectPostLikeById(Long id); + + /** + * 查询帖子点赞列表 + * + * @param postLike 帖子点赞 + * @return 帖子点赞集合 + */ + public List selectPostLikeList(PostLike postLike); + + /** + * 新增帖子点赞 + * + * @param postLike 帖子点赞 + * @return 结果 + */ + public int insertPostLike(PostLike postLike); + + /** + * 修改帖子点赞 + * + * @param postLike 帖子点赞 + * @return 结果 + */ + public int updatePostLike(PostLike postLike); + + /** + * 删除帖子点赞 + * + * @param id 帖子点赞主键 + * @return 结果 + */ + public int deletePostLikeById(Long id); + + /** + * 批量删除帖子点赞 + * + * @param ids 需要删除的数据主键集合 + * @return 结果 + */ + public int deletePostLikeByIds(Long[] ids); + + + /** + * 帖子点赞 + * @param postLike + * @param userVo + */ + void postLike(@Param("req") PostLike postLike,@Param("userVo") UserVo userVo); +} diff --git a/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/frequency/postlike/mapper/mapping/PostLikeMapper.xml b/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/frequency/postlike/mapper/mapping/PostLikeMapper.xml new file mode 100644 index 0000000..8c281c9 --- /dev/null +++ b/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/frequency/postlike/mapper/mapping/PostLikeMapper.xml @@ -0,0 +1,104 @@ + + + + + + + + + + + + + + + + + + + select id, create_by, create_time, update_by, update_time, del_flag, type, user_type, user_id, object_id from t_post_like + + + + + + + + insert into t_post_like + + id, + create_by, + create_time, + update_by, + update_time, + del_flag, + type, + user_type, + user_id, + object_id, + + + #{id}, + #{createBy}, + #{createTime}, + #{updateBy}, + #{updateTime}, + #{delFlag}, + #{type}, + #{userType}, + #{userId}, + #{objectId}, + + + + + update t_post_like + + create_by = #{createBy}, + create_time = #{createTime}, + update_by = #{updateBy}, + update_time = #{updateTime}, + del_flag = #{delFlag}, + type = #{type}, + user_type = #{userType}, + user_id = #{userId}, + object_id = #{objectId}, + + where id = #{id} + + + + delete from t_post_like where id = #{id} + + + + delete from t_post_like where id in + + #{id} + + + + + insert into t_post_like + (id, create_by, create_time, update_by, update_time, type, user_type, user_id, object_id) + values + (#{req.id},#{req.updateBy},#{req.updateTime},#{req.updateBy},#{req.updateTime},#{req.type},#{userVo.userType}, #{userVo.userId}, #{req.objectId}) + ON DUPLICATE KEY UPDATE + del_flag = IF( del_flag = 1, 3, 1 ), + update_time = #{req.updateTime}, + update_by = #{req.updateBy}; + + \ No newline at end of file diff --git a/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/frequency/postlike/model/param/PostLikeParam.java b/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/frequency/postlike/model/param/PostLikeParam.java new file mode 100644 index 0000000..e9af4f1 --- /dev/null +++ b/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/frequency/postlike/model/param/PostLikeParam.java @@ -0,0 +1,50 @@ +package com.ruoyi.post.frequency.postlike.model.param; + +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; + +/** + * 帖子点赞对象 t_post_like + * + * @author liwenlong + * @date 2023-10-09 + */ +@Data +@Accessors(chain = true) +public class PostLikeParam extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + @ApiModelProperty("主键id") + private Long id; + + @ApiModelProperty("删除标志 1正常 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("类型 1 帖子2 帖子评论 ") + @Excel(name = "类型 1 帖子2 帖子评论 ") + private Integer type; + + @ApiModelProperty("用户类型 1 用户 ") + @Excel(name = "用户类型 1 用户 ") + private Integer userType; + + @ApiModelProperty("用户id") + @Excel(name = "用户id") + private Long userId; + + @ApiModelProperty("帖子id/帖子评论id") + @Excel(name = "帖子id/帖子评论id") + private Long objectId; + + + + + + + + +} diff --git a/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/frequency/postlike/model/result/PostLikeResult.java b/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/frequency/postlike/model/result/PostLikeResult.java new file mode 100644 index 0000000..327feb8 --- /dev/null +++ b/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/frequency/postlike/model/result/PostLikeResult.java @@ -0,0 +1,44 @@ +package com.ruoyi.post.frequency.postlike.model.result; + +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; + +/** + * 帖子点赞对象 t_post_like + * + * @author liwenlong + * @date 2023-10-09 + */ +@Data +@Accessors(chain = true) +public class PostLikeResult extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + @ApiModelProperty("主键id") + private Long id; + + @ApiModelProperty("删除标志 1正常 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("类型 1 帖子2 帖子评论 ") + @Excel(name = "类型 1 帖子2 帖子评论 ") + private Integer type; + + @ApiModelProperty("用户类型 1 用户 ") + @Excel(name = "用户类型 1 用户 ") + private Integer userType; + + @ApiModelProperty("用户id") + @Excel(name = "用户id") + private Long userId; + + @ApiModelProperty("帖子id/帖子评论id") + @Excel(name = "帖子id/帖子评论id") + private Long objectId; + + +} diff --git a/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/frequency/postlike/service/PostLikeService.java b/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/frequency/postlike/service/PostLikeService.java new file mode 100644 index 0000000..5498e0d --- /dev/null +++ b/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/frequency/postlike/service/PostLikeService.java @@ -0,0 +1,74 @@ +package com.ruoyi.post.frequency.postlike.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.ruoyi.post.controller.req.PostLikeReq; +import com.ruoyi.post.frequency.postlike.entity.PostLike; +import com.ruoyi.response.ResponseData; +import com.ruoyi.vo.UserVo; + +import java.util.List; + +/** + * 帖子点赞Service接口 + * + * @author liwenlong + * @date 2023-10-09 + */ +public interface PostLikeService extends IService +{ + /** + * 查询帖子点赞 + * + * @param id 帖子点赞主键 + * @return 帖子点赞 + */ + public PostLike selectPostLikeById(Long id); + + /** + * 查询帖子点赞列表 + * + * @param postLike 帖子点赞 + * @return 帖子点赞集合 + */ + public List selectPostLikeList(PostLike postLike); + + /** + * 新增帖子点赞 + * + * @param postLike 帖子点赞 + * @return 结果 + */ + public int insertPostLike(PostLike postLike); + + /** + * 修改帖子点赞 + * + * @param postLike 帖子点赞 + * @return 结果 + */ + public int updatePostLike(PostLike postLike); + + /** + * 批量删除帖子点赞 + * + * @param ids 需要删除的帖子点赞主键集合 + * @return 结果 + */ + public int deletePostLikeByIds(Long[] ids); + + /** + * 删除帖子点赞信息 + * + * @param id 帖子点赞主键 + * @return 结果 + */ + public int deletePostLikeById(Long id); + + /** + * 帖子点赞 + * @param req + * @param userVo + * @return + */ + ResponseData postLike(PostLikeReq req, UserVo userVo); +} diff --git a/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/frequency/postlike/service/impl/PostLikeServiceImpl.java b/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/frequency/postlike/service/impl/PostLikeServiceImpl.java new file mode 100644 index 0000000..9ff7049 --- /dev/null +++ b/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/frequency/postlike/service/impl/PostLikeServiceImpl.java @@ -0,0 +1,224 @@ +package com.ruoyi.post.frequency.postlike.service.impl; + +import cn.hutool.core.util.ObjectUtil; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.ruoyi.code.DictConstant; +import com.ruoyi.code.PublicCommon; +import com.ruoyi.common.utils.DateUtils; +import com.ruoyi.enums.message.InteractionMessageEnums; +import com.ruoyi.message.frequency.interactionmessagerecord.service.InteractionMessageRecordService; +import com.ruoyi.post.controller.req.PostLikeReq; +import com.ruoyi.post.frequency.post.entity.Post; +import com.ruoyi.post.frequency.post.service.PostService; +import com.ruoyi.post.frequency.postcomment.entity.PostComment; +import com.ruoyi.post.frequency.postcomment.service.PostCommentService; +import com.ruoyi.post.frequency.postlike.entity.PostLike; +import com.ruoyi.post.frequency.postlike.mapper.PostLikeMapper; +import com.ruoyi.post.frequency.postlike.service.PostLikeService; +import com.ruoyi.response.ResponseData; +import com.ruoyi.utils.BusinessUtil; +import com.ruoyi.vo.UserVo; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.List; + +/** + * 帖子点赞Service业务层处理 + * + * @author liwenlong + * @date 2023-10-09 + */ +@Service +@Transactional(rollbackFor = Exception.class) +public class PostLikeServiceImpl extends ServiceImpl implements PostLikeService { + @Autowired + private PostLikeMapper postLikeMapper; + + /** + * 查询帖子点赞 + * + * @param id 帖子点赞主键 + * @return 帖子点赞 + */ + @Override + public PostLike selectPostLikeById(Long id) { + return postLikeMapper.selectPostLikeById(id); + } + + /** + * 查询帖子点赞列表 + * + * @param postLike 帖子点赞 + * @return 帖子点赞 + */ + @Override + public List selectPostLikeList(PostLike postLike) { + return postLikeMapper.selectPostLikeList(postLike); + } + + /** + * 新增帖子点赞 + * + * @param postLike 帖子点赞 + * @return 结果 + */ + @Override + public int insertPostLike(PostLike postLike) { + postLike.setCreateTime(DateUtils.getNowDate()); + return postLikeMapper.insertPostLike(postLike); + } + + /** + * 修改帖子点赞 + * + * @param postLike 帖子点赞 + * @return 结果 + */ + @Override + public int updatePostLike(PostLike postLike) { + postLike.setUpdateTime(DateUtils.getNowDate()); + return postLikeMapper.updatePostLike(postLike); + } + + /** + * 批量删除帖子点赞 + * + * @param ids 需要删除的帖子点赞主键 + * @return 结果 + */ + @Override + public int deletePostLikeByIds(Long[] ids) { + this.lambdaUpdate().set(PostLike::getDelFlag, PublicCommon.删除).in(PostLike::getId, ids).update(); + return ids.length; + } + + /** + * 删除帖子点赞信息 + * + * @param id 帖子点赞主键 + * @return 结果 + */ + @Override + public int deletePostLikeById(Long id) { + this.lambdaUpdate().set(PostLike::getDelFlag, PublicCommon.删除).eq(PostLike::getId, id).update(); + return 1; + } + + @Autowired + private PostService postService; + + @Autowired + private PostCommentService postCommentService; + + @Autowired + private BusinessUtil businessUtil; + + @Override + public ResponseData postLike(PostLikeReq req, UserVo userVo) { + + PostLike postLike = new PostLike(req.getType(), req.getObjectId()); + + //更新帖子点赞记录 + postLikeMapper.postLike(postLike, userVo); + + postLike = postLikeMapper.selectOne(new QueryWrapper().lambda() + .eq(PostLike::getObjectId, req.getObjectId()) + .eq(PostLike::getType, req.getType()) + .eq(PostLike::getUserType, userVo.getUserType()) + .eq(PostLike::getUserId, userVo.getUserId())); + + //是否点赞 + Boolean isLike = postLike.getDelFlag().equals(PublicCommon.启用); + + //1 帖子 2帖子评论 + updatePostLikeNum(req.getType(), req.getObjectId(), isLike); + + //精彩评论 1 帖子 2 帖子评论 + if (isLike && req.getType() == 2) { + //点赞量基础量(超过) + Integer likeNum = Integer.valueOf(businessUtil.getDict(DictConstant.点赞好评基础量).getDictValue()); + + PostComment postComment = postCommentService.getById(req.getObjectId()); + + Post post = postService.getById(postComment.getPostId()); + + if (ObjectUtil.isEmpty(post.getCommentId()) && postComment.getParentId() == 0L && postComment.getLikeNum() >= likeNum) { + postService.lambdaUpdate().set(Post::getCommentId, postComment.getId()) + .eq(Post::getId, postComment.getPostId()).update(); + } + } + + //推送消息 + pushMessage(req, userVo, isLike); + return ResponseData.success(); + } + + + /** + * 推送消息 + * + * @param req + * @param userVo + * @param isLike + */ + private void pushMessage(PostLikeReq req, UserVo userVo, Boolean isLike) { + + InteractionMessageEnums enums = ObjectUtil.equal(1, req.getType()) ? InteractionMessageEnums.LIKE_POST : InteractionMessageEnums.LIKE_POST_COMMENT; + + //帖子id + Long postId = null; + + //接收消息用户 + UserVo sendUserVo = null; + + switch (req.getType()) { + case 1: + //帖子点赞 + postId = req.getObjectId(); + Post post = postService.getById(postId); + sendUserVo = new UserVo(post.getUserType(), post.getUserId()); + break; + case 2: + //评论点赞 + PostComment postComment = postCommentService.getById(req.getObjectId()); + postId = postComment.getPostId(); + sendUserVo = new UserVo(postComment.getUserType(), postComment.getUserId()); + break; + } + + //互动消息 + interactionMessageRecordService.addInteractionMessage(userVo, sendUserVo, PublicCommon.InteractionMessage.点赞, postId, isLike, enums); + + } + + @Autowired + private InteractionMessageRecordService interactionMessageRecordService; + + + /** + * 更新帖子点赞数据 + * + * @param type 1 帖子 2帖子评论 + * @param objectId 帖子id/评论id + * @param isLike 是否点赞 + */ + private void updatePostLikeNum(Integer type, Long objectId, Boolean isLike) { + + //点赞 +1 ,取消点赞 -1 + Integer num = isLike ? 1 : -1; + + switch (type) { + case 1: + postService.updatePostLikeNum(new Post().setId(objectId), num); + break; + case 2: + postCommentService.updatePostComment(new PostComment().setId(objectId).setLikeNum(num)); + break; + default: + throw new IllegalStateException("Unexpected value: " + type); + } + } +} diff --git a/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/frequency/posttype/controller/PostTypeController.java b/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/frequency/posttype/controller/PostTypeController.java new file mode 100644 index 0000000..47c6e34 --- /dev/null +++ b/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/frequency/posttype/controller/PostTypeController.java @@ -0,0 +1,97 @@ +package com.ruoyi.post.frequency.posttype.controller; + +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.page.TableDataInfo; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.common.utils.poi.ExcelUtil; +import com.ruoyi.post.frequency.posttype.entity.PostType; +import com.ruoyi.post.frequency.posttype.service.PostTypeService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +/** + * 帖子分类Controller + * + * @author liwenlong + * @date 2023-10-10 + */ +@RestController +@RequestMapping("/frequency/postype") +public class PostTypeController extends BaseController +{ + @Autowired + private PostTypeService postTypeService; + + /** + * 查询帖子分类列表 + */ +// @PreAuthorize("@ss.hasPermi('frequency:postype:list')") + @PostMapping("/list") + public TableDataInfo list(@RequestBody PostType postType) + { + startPage(); + List list = postTypeService.selectPostTypeList(postType); + return getDataTable(list); + } + + /** + * 导出帖子分类列表 + */ + @PreAuthorize("@ss.hasPermi('frequency:postype:export')") + @Log(title = "帖子分类", businessType = BusinessType.EXPORT) + @GetMapping("/export") + public AjaxResult export(PostType postType) + { + List list = postTypeService.selectPostTypeList(postType); + ExcelUtil util = new ExcelUtil(PostType.class); + return util.exportExcel(list, "帖子分类数据"); + } + + /** + * 获取帖子分类详细信息 + */ + @PreAuthorize("@ss.hasPermi('frequency:postype:query')") + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") Long id) + { + return AjaxResult.success(postTypeService.selectPostTypeById(id)); + } + + /** + * 新增帖子分类 + */ + @PreAuthorize("@ss.hasPermi('frequency:postype:add')") + @Log(title = "帖子分类", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody PostType postType) + { + return toAjax(postTypeService.insertPostType(postType)); + } + + /** + * 修改帖子分类 + */ + @PreAuthorize("@ss.hasPermi('frequency:postype:edit')") + @Log(title = "帖子分类", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody PostType postType) + { + return toAjax(postTypeService.updatePostType(postType)); + } + + /** + * 删除帖子分类 + */ + @PreAuthorize("@ss.hasPermi('frequency:postype:remove')") + @Log(title = "帖子分类", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}/{delFlag}") + public AjaxResult remove(@PathVariable Long[] ids,@PathVariable Integer delFlag) + { + return toAjax(postTypeService.deletePostTypeByIds(ids,delFlag)); + } +} diff --git a/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/frequency/posttype/entity/PostType.java b/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/frequency/posttype/entity/PostType.java new file mode 100644 index 0000000..fbd516b --- /dev/null +++ b/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/frequency/posttype/entity/PostType.java @@ -0,0 +1,43 @@ +package com.ruoyi.post.frequency.posttype.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; + +/** + * 帖子分类对象 t_post_type + * + * @author liwenlong + * @date 2023-10-10 + */ +@Data +@Accessors(chain = true) +@TableName("t_post_type") +public class PostType extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + + @ApiModelProperty("租户号") + private Long id; + + @ApiModelProperty("删除标识 1 正常 2 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("分类名称") + @Excel(name = "分类名称") + private String name; + + @ApiModelProperty("排序") + @Excel(name = "排序") + private Long sort; + + @ApiModelProperty("用户类型") + private Integer userType; + + @ApiModelProperty("帖子类型 1 帖子 2资讯") + private Integer type; +} diff --git a/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/frequency/posttype/mapper/PostTypeMapper.java b/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/frequency/posttype/mapper/PostTypeMapper.java new file mode 100644 index 0000000..934439c --- /dev/null +++ b/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/frequency/posttype/mapper/PostTypeMapper.java @@ -0,0 +1,63 @@ +package com.ruoyi.post.frequency.posttype.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.ruoyi.post.frequency.posttype.entity.PostType; + +import java.util.List; + +/** + * 帖子分类Mapper接口 + * + * @author liwenlong + * @date 2023-10-10 + */ +public interface PostTypeMapper extends BaseMapper +{ + /** + * 查询帖子分类 + * + * @param id 帖子分类主键 + * @return 帖子分类 + */ + public PostType selectPostTypeById(Long id); + + /** + * 查询帖子分类列表 + * + * @param postType 帖子分类 + * @return 帖子分类集合 + */ + public List selectPostTypeList(PostType postType); + + /** + * 新增帖子分类 + * + * @param postType 帖子分类 + * @return 结果 + */ + public int insertPostType(PostType postType); + + /** + * 修改帖子分类 + * + * @param postType 帖子分类 + * @return 结果 + */ + public int updatePostType(PostType postType); + + /** + * 删除帖子分类 + * + * @param id 帖子分类主键 + * @return 结果 + */ + public int deletePostTypeById(Long id); + + /** + * 批量删除帖子分类 + * + * @param ids 需要删除的数据主键集合 + * @return 结果 + */ + public int deletePostTypeByIds(Long[] ids); +} diff --git a/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/frequency/posttype/mapper/mapping/PostTypeMapper.xml b/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/frequency/posttype/mapper/mapping/PostTypeMapper.xml new file mode 100644 index 0000000..3ffa42c --- /dev/null +++ b/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/frequency/posttype/mapper/mapping/PostTypeMapper.xml @@ -0,0 +1,88 @@ + + + + + + + + + + + + + + + + + + + select id, del_flag, create_by, create_time, update_by, update_time, name, sort,user_type,type from t_post_type + + + + + + + + insert into t_post_type + + id, + del_flag, + create_by, + create_time, + update_by, + update_time, + name, + sort, + + + #{id}, + #{delFlag}, + #{createBy}, + #{createTime}, + #{updateBy}, + #{updateTime}, + #{name}, + #{sort}, + + + + + update t_post_type + + del_flag = #{delFlag}, + create_by = #{createBy}, + create_time = #{createTime}, + update_by = #{updateBy}, + update_time = #{updateTime}, + name = #{name}, + sort = #{sort}, + + where id = #{id} + + + + delete from t_post_type where id = #{id} + + + + delete from t_post_type where id in + + #{id} + + + diff --git a/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/frequency/posttype/model/param/PostTypeParam.java b/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/frequency/posttype/model/param/PostTypeParam.java new file mode 100644 index 0000000..6193053 --- /dev/null +++ b/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/frequency/posttype/model/param/PostTypeParam.java @@ -0,0 +1,40 @@ +package com.ruoyi.post.frequency.posttype.model.param; + +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; + +/** + * 帖子分类对象 t_post_type + * + * @author liwenlong + * @date 2023-10-10 + */ +@Data +@Accessors(chain = true) +public class PostTypeParam extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + @ApiModelProperty("租户号") + private Long id; + + @ApiModelProperty("删除标识 1 正常 2 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("分类名称") + @Excel(name = "分类名称") + private String name; + + @ApiModelProperty("排序") + @Excel(name = "排序") + private Long sort; + + + + + + +} diff --git a/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/frequency/posttype/model/result/PostTypeResult.java b/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/frequency/posttype/model/result/PostTypeResult.java new file mode 100644 index 0000000..39e4ead --- /dev/null +++ b/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/frequency/posttype/model/result/PostTypeResult.java @@ -0,0 +1,36 @@ +package com.ruoyi.post.frequency.posttype.model.result; + +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; + +/** + * 帖子分类对象 t_post_type + * + * @author liwenlong + * @date 2023-10-10 + */ +@Data +@Accessors(chain = true) +public class PostTypeResult extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + @ApiModelProperty("租户号") + private Long id; + + @ApiModelProperty("删除标识 1 正常 2 删除 3 禁用") + private Integer delFlag; + + @ApiModelProperty("分类名称") + @Excel(name = "分类名称") + private String name; + + @ApiModelProperty("排序") + @Excel(name = "排序") + private Long sort; + + +} diff --git a/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/frequency/posttype/service/PostTypeService.java b/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/frequency/posttype/service/PostTypeService.java new file mode 100644 index 0000000..34defd6 --- /dev/null +++ b/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/frequency/posttype/service/PostTypeService.java @@ -0,0 +1,72 @@ +package com.ruoyi.post.frequency.posttype.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.ruoyi.post.controller.req.PostTypeListReq; +import com.ruoyi.post.frequency.posttype.entity.PostType; +import com.ruoyi.response.ResponseData; + +import java.util.List; + +/** + * 帖子分类Service接口 + * + * @author liwenlong + * @date 2023-10-10 + */ +public interface PostTypeService extends IService +{ + /** + * 查询帖子分类 + * + * @param id 帖子分类主键 + * @return 帖子分类 + */ + public PostType selectPostTypeById(Long id); + + /** + * 查询帖子分类列表 + * + * @param postType 帖子分类 + * @return 帖子分类集合 + */ + public List selectPostTypeList(PostType postType); + + /** + * 新增帖子分类 + * + * @param postType 帖子分类 + * @return 结果 + */ + public int insertPostType(PostType postType); + + /** + * 修改帖子分类 + * + * @param postType 帖子分类 + * @return 结果 + */ + public int updatePostType(PostType postType); + + /** + * 批量删除帖子分类 + * + * @param ids 需要删除的帖子分类主键集合 + * @return 结果 + */ + public int deletePostTypeByIds(Long[] ids,Integer delFlag); + + /** + * 删除帖子分类信息 + * + * @param id 帖子分类主键 + * @return 结果 + */ + public int deletePostTypeById(Long id); + + + /** + * 获取帖子分类列表 + * @return + */ + ResponseData postTypeList(PostTypeListReq req); +} diff --git a/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/frequency/posttype/service/impl/PostTypeServiceImpl.java b/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/frequency/posttype/service/impl/PostTypeServiceImpl.java new file mode 100644 index 0000000..c9366ad --- /dev/null +++ b/ruoyi-main/ruoyi-post/src/main/java/com/ruoyi/post/frequency/posttype/service/impl/PostTypeServiceImpl.java @@ -0,0 +1,126 @@ +package com.ruoyi.post.frequency.posttype.service.impl; + +import cn.hutool.core.util.ObjectUtil; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.ruoyi.code.PublicCommon; +import com.ruoyi.common.exception.ServiceException; +import com.ruoyi.common.utils.DateUtils; +import com.ruoyi.post.controller.req.PostTypeListReq; +import com.ruoyi.post.frequency.post.entity.Post; +import com.ruoyi.post.frequency.post.service.PostService; +import com.ruoyi.post.frequency.posttype.entity.PostType; +import com.ruoyi.post.frequency.posttype.mapper.PostTypeMapper; +import com.ruoyi.post.frequency.posttype.service.PostTypeService; +import com.ruoyi.response.ResponseData; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.Arrays; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +import static net.sf.jsqlparser.util.validation.metadata.NamedObject.user; + +/** + * 帖子分类Service业务层处理 + * + * @author liwenlong + * @date 2023-10-10 + */ +@Service +@Transactional(rollbackFor = Exception.class) +public class PostTypeServiceImpl extends ServiceImpl implements PostTypeService +{ + @Autowired + private PostTypeMapper postTypeMapper; + + /** + * 查询帖子分类 + * + * @param id 帖子分类主键 + * @return 帖子分类 + */ + @Override + public PostType selectPostTypeById(Long id) + { + return postTypeMapper.selectPostTypeById(id); + } + + /** + * 查询帖子分类列表 + * + * @param postType 帖子分类 + * @return 帖子分类 + */ + @Override + public List selectPostTypeList(PostType postType) + { + return postTypeMapper.selectPostTypeList(postType); + } + + /** + * 新增帖子分类 + * + * @param postType 帖子分类 + * @return 结果 + */ + @Override + public int insertPostType(PostType postType) + { + postType.setCreateTime(DateUtils.getNowDate()); + return postTypeMapper.insert(postType); + } + + /** + * 修改帖子分类 + * + * @param postType 帖子分类 + * @return 结果 + */ + @Override + public int updatePostType(PostType postType) + { + postType.setUpdateTime(DateUtils.getNowDate()); + return postTypeMapper.updateById(postType); + } + + /** + * 批量删除帖子分类 + * + * @param ids 需要删除的帖子分类主键 + * @return 结果 + */ + @Override + public int deletePostTypeByIds(Long[] ids,Integer delFlag) + { + this.lambdaUpdate().set(PostType::getDelFlag,delFlag).in(PostType::getId,ids).update(); + return ids.length; + } + + /** + * 删除帖子分类信息 + * + * @param id 帖子分类主键 + * @return 结果 + */ + @Override + public int deletePostTypeById(Long id) + { + this.lambdaUpdate().set(PostType::getDelFlag,PublicCommon.删除).eq(PostType::getId,id).update(); + return 1; + } + + @Override + public ResponseData postTypeList(PostTypeListReq req) { + + List list = this.list(new QueryWrapper().lambda() + .eq(ObjectUtil.isNotEmpty(req.getUserType()),PostType::getUserType,req.getUserType()) + .eq(ObjectUtil.isNotEmpty(req.getType()),PostType::getType,req.getType()) + .eq(PostType::getDelFlag,PublicCommon.启用).orderByAsc(PostType::getSort)); + + return ResponseData.success(list); + } +} diff --git a/sql/quartz.sql b/sql/quartz.sql new file mode 100644 index 0000000..cee613b --- /dev/null +++ b/sql/quartz.sql @@ -0,0 +1,174 @@ +DROP TABLE IF EXISTS QRTZ_FIRED_TRIGGERS; +DROP TABLE IF EXISTS QRTZ_PAUSED_TRIGGER_GRPS; +DROP TABLE IF EXISTS QRTZ_SCHEDULER_STATE; +DROP TABLE IF EXISTS QRTZ_LOCKS; +DROP TABLE IF EXISTS QRTZ_SIMPLE_TRIGGERS; +DROP TABLE IF EXISTS QRTZ_SIMPROP_TRIGGERS; +DROP TABLE IF EXISTS QRTZ_CRON_TRIGGERS; +DROP TABLE IF EXISTS QRTZ_BLOB_TRIGGERS; +DROP TABLE IF EXISTS QRTZ_TRIGGERS; +DROP TABLE IF EXISTS QRTZ_JOB_DETAILS; +DROP TABLE IF EXISTS QRTZ_CALENDARS; + +-- ---------------------------- +-- 1、存储每一个已配置的 jobDetail 的详细信息 +-- ---------------------------- +create table QRTZ_JOB_DETAILS ( + sched_name varchar(120) not null comment '调度名称', + job_name varchar(200) not null comment '任务名称', + job_group varchar(200) not null comment '任务组名', + description varchar(250) null comment '相关介绍', + job_class_name varchar(250) not null comment '执行任务类名称', + is_durable varchar(1) not null comment '是否持久化', + is_nonconcurrent varchar(1) not null comment '是否并发', + is_update_data varchar(1) not null comment '是否更新数据', + requests_recovery varchar(1) not null comment '是否接受恢复执行', + job_data blob null comment '存放持久化job对象', + primary key (sched_name, job_name, job_group) +) engine=innodb comment = '任务详细信息表'; + +-- ---------------------------- +-- 2、 存储已配置的 Trigger 的信息 +-- ---------------------------- +create table QRTZ_TRIGGERS ( + sched_name varchar(120) not null comment '调度名称', + trigger_name varchar(200) not null comment '触发器的名字', + trigger_group varchar(200) not null comment '触发器所属组的名字', + job_name varchar(200) not null comment 'qrtz_job_details表job_name的外键', + job_group varchar(200) not null comment 'qrtz_job_details表job_group的外键', + description varchar(250) null comment '相关介绍', + next_fire_time bigint(13) null comment '上一次触发时间(毫秒)', + prev_fire_time bigint(13) null comment '下一次触发时间(默认为-1表示不触发)', + priority integer null comment '优先级', + trigger_state varchar(16) not null comment '触发器状态', + trigger_type varchar(8) not null comment '触发器的类型', + start_time bigint(13) not null comment '开始时间', + end_time bigint(13) null comment '结束时间', + calendar_name varchar(200) null comment '日程表名称', + misfire_instr smallint(2) null comment '补偿执行的策略', + job_data blob null comment '存放持久化job对象', + primary key (sched_name, trigger_name, trigger_group), + foreign key (sched_name, job_name, job_group) references QRTZ_JOB_DETAILS(sched_name, job_name, job_group) +) engine=innodb comment = '触发器详细信息表'; + +-- ---------------------------- +-- 3、 存储简单的 Trigger,包括重复次数,间隔,以及已触发的次数 +-- ---------------------------- +create table QRTZ_SIMPLE_TRIGGERS ( + sched_name varchar(120) not null comment '调度名称', + trigger_name varchar(200) not null comment 'qrtz_triggers表trigger_name的外键', + trigger_group varchar(200) not null comment 'qrtz_triggers表trigger_group的外键', + repeat_count bigint(7) not null comment '重复的次数统计', + repeat_interval bigint(12) not null comment '重复的间隔时间', + times_triggered bigint(10) not null comment '已经触发的次数', + primary key (sched_name, trigger_name, trigger_group), + foreign key (sched_name, trigger_name, trigger_group) references QRTZ_TRIGGERS(sched_name, trigger_name, trigger_group) +) engine=innodb comment = '简单触发器的信息表'; + +-- ---------------------------- +-- 4、 存储 Cron Trigger,包括 Cron 表达式和时区信息 +-- ---------------------------- +create table QRTZ_CRON_TRIGGERS ( + sched_name varchar(120) not null comment '调度名称', + trigger_name varchar(200) not null comment 'qrtz_triggers表trigger_name的外键', + trigger_group varchar(200) not null comment 'qrtz_triggers表trigger_group的外键', + cron_expression varchar(200) not null comment 'cron表达式', + time_zone_id varchar(80) comment '时区', + primary key (sched_name, trigger_name, trigger_group), + foreign key (sched_name, trigger_name, trigger_group) references QRTZ_TRIGGERS(sched_name, trigger_name, trigger_group) +) engine=innodb comment = 'Cron类型的触发器表'; + +-- ---------------------------- +-- 5、 Trigger 作为 Blob 类型存储(用于 Quartz 用户用 JDBC 创建他们自己定制的 Trigger 类型,JobStore 并不知道如何存储实例的时候) +-- ---------------------------- +create table QRTZ_BLOB_TRIGGERS ( + sched_name varchar(120) not null comment '调度名称', + trigger_name varchar(200) not null comment 'qrtz_triggers表trigger_name的外键', + trigger_group varchar(200) not null comment 'qrtz_triggers表trigger_group的外键', + blob_data blob null comment '存放持久化Trigger对象', + primary key (sched_name, trigger_name, trigger_group), + foreign key (sched_name, trigger_name, trigger_group) references QRTZ_TRIGGERS(sched_name, trigger_name, trigger_group) +) engine=innodb comment = 'Blob类型的触发器表'; + +-- ---------------------------- +-- 6、 以 Blob 类型存储存放日历信息, quartz可配置一个日历来指定一个时间范围 +-- ---------------------------- +create table QRTZ_CALENDARS ( + sched_name varchar(120) not null comment '调度名称', + calendar_name varchar(200) not null comment '日历名称', + calendar blob not null comment '存放持久化calendar对象', + primary key (sched_name, calendar_name) +) engine=innodb comment = '日历信息表'; + +-- ---------------------------- +-- 7、 存储已暂停的 Trigger 组的信息 +-- ---------------------------- +create table QRTZ_PAUSED_TRIGGER_GRPS ( + sched_name varchar(120) not null comment '调度名称', + trigger_group varchar(200) not null comment 'qrtz_triggers表trigger_group的外键', + primary key (sched_name, trigger_group) +) engine=innodb comment = '暂停的触发器表'; + +-- ---------------------------- +-- 8、 存储与已触发的 Trigger 相关的状态信息,以及相联 Job 的执行信息 +-- ---------------------------- +create table QRTZ_FIRED_TRIGGERS ( + sched_name varchar(120) not null comment '调度名称', + entry_id varchar(95) not null comment '调度器实例id', + trigger_name varchar(200) not null comment 'qrtz_triggers表trigger_name的外键', + trigger_group varchar(200) not null comment 'qrtz_triggers表trigger_group的外键', + instance_name varchar(200) not null comment '调度器实例名', + fired_time bigint(13) not null comment '触发的时间', + sched_time bigint(13) not null comment '定时器制定的时间', + priority integer not null comment '优先级', + state varchar(16) not null comment '状态', + job_name varchar(200) null comment '任务名称', + job_group varchar(200) null comment '任务组名', + is_nonconcurrent varchar(1) null comment '是否并发', + requests_recovery varchar(1) null comment '是否接受恢复执行', + primary key (sched_name, entry_id) +) engine=innodb comment = '已触发的触发器表'; + +-- ---------------------------- +-- 9、 存储少量的有关 Scheduler 的状态信息,假如是用于集群中,可以看到其他的 Scheduler 实例 +-- ---------------------------- +create table QRTZ_SCHEDULER_STATE ( + sched_name varchar(120) not null comment '调度名称', + instance_name varchar(200) not null comment '实例名称', + last_checkin_time bigint(13) not null comment '上次检查时间', + checkin_interval bigint(13) not null comment '检查间隔时间', + primary key (sched_name, instance_name) +) engine=innodb comment = '调度器状态表'; + +-- ---------------------------- +-- 10、 存储程序的悲观锁的信息(假如使用了悲观锁) +-- ---------------------------- +create table QRTZ_LOCKS ( + sched_name varchar(120) not null comment '调度名称', + lock_name varchar(40) not null comment '悲观锁名称', + primary key (sched_name, lock_name) +) engine=innodb comment = '存储的悲观锁信息表'; + +-- ---------------------------- +-- 11、 Quartz集群实现同步机制的行锁表 +-- ---------------------------- +create table QRTZ_SIMPROP_TRIGGERS ( + sched_name varchar(120) not null comment '调度名称', + trigger_name varchar(200) not null comment 'qrtz_triggers表trigger_name的外键', + trigger_group varchar(200) not null comment 'qrtz_triggers表trigger_group的外键', + str_prop_1 varchar(512) null comment 'String类型的trigger的第一个参数', + str_prop_2 varchar(512) null comment 'String类型的trigger的第二个参数', + str_prop_3 varchar(512) null comment 'String类型的trigger的第三个参数', + int_prop_1 int null comment 'int类型的trigger的第一个参数', + int_prop_2 int null comment 'int类型的trigger的第二个参数', + long_prop_1 bigint null comment 'long类型的trigger的第一个参数', + long_prop_2 bigint null comment 'long类型的trigger的第二个参数', + dec_prop_1 numeric(13,4) null comment 'decimal类型的trigger的第一个参数', + dec_prop_2 numeric(13,4) null comment 'decimal类型的trigger的第二个参数', + bool_prop_1 varchar(1) null comment 'Boolean类型的trigger的第一个参数', + bool_prop_2 varchar(1) null comment 'Boolean类型的trigger的第二个参数', + primary key (sched_name, trigger_name, trigger_group), + foreign key (sched_name, trigger_name, trigger_group) references QRTZ_TRIGGERS(sched_name, trigger_name, trigger_group) +) engine=innodb comment = '同步机制的行锁表'; + +commit; \ No newline at end of file diff --git a/sql/ruoyi_all.sql b/sql/ruoyi_all.sql new file mode 100644 index 0000000..52e18a7 --- /dev/null +++ b/sql/ruoyi_all.sql @@ -0,0 +1,905 @@ +/* +SQLyog Ultimate v12.09 (64 bit) +MySQL - 5.7.26-log : Database - ruoyi +********************************************************************* +*/ + +/*!40101 SET NAMES utf8 */; + +/*!40101 SET SQL_MODE=''*/; + +/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; +/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; +/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; +/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; +CREATE DATABASE /*!32312 IF NOT EXISTS*/`ruoyi` /*!40100 DEFAULT CHARACTER SET utf8mb4 */; + +USE `ruoyi`; + +/*Table structure for table `demo_car` */ + +DROP TABLE IF EXISTS `demo_car`; + +CREATE TABLE `demo_car` ( + `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键', + `name` varchar(100) DEFAULT NULL COMMENT '名称', + `code` varchar(100) DEFAULT NULL COMMENT '品牌代码', + `remark` varchar(100) DEFAULT NULL COMMENT '备注', + `create_by` varchar(32) DEFAULT NULL, + `create_time` datetime DEFAULT NULL, + `update_by` varchar(32) DEFAULT NULL, + `update_time` datetime DEFAULT NULL, + `del_flag` char(1) DEFAULT NULL, + `tenant_id` varchar(64) NOT NULL DEFAULT '00000000' COMMENT '租户ID', + PRIMARY KEY (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=9 DEFAULT CHARSET=utf8mb4 COMMENT='车辆品牌'; + +/*Data for the table `demo_car` */ + +insert into `demo_car`(`id`,`name`,`code`,`remark`,`create_by`,`create_time`,`update_by`,`update_time`,`del_flag`,`tenant_id`) values (1,'比亚迪','001',NULL,NULL,NULL,NULL,NULL,NULL,'00000000'),(2,'吉利','002',NULL,NULL,NULL,NULL,NULL,NULL,'00000000'); + +/*Table structure for table `demo_car_model` */ + +DROP TABLE IF EXISTS `demo_car_model`; + +CREATE TABLE `demo_car_model` ( + `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键', + `car_id` varchar(32) NOT NULL COMMENT '汽车', + `name` varchar(100) DEFAULT NULL COMMENT '型号名', + `value` varchar(100) DEFAULT NULL COMMENT '型号代码', + `sort` int(5) DEFAULT NULL COMMENT '排序', + `remark` varchar(100) DEFAULT NULL COMMENT '描述', + `create_by` varchar(32) DEFAULT NULL, + `create_time` datetime DEFAULT NULL, + `update_by` varchar(32) DEFAULT NULL, + `update_time` datetime DEFAULT NULL, + `del_flag` char(1) DEFAULT NULL, + `tenant_id` varchar(64) NOT NULL DEFAULT '00000000', + PRIMARY KEY (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=14 DEFAULT CHARSET=utf8mb4 COMMENT='车辆型号'; + +/*Data for the table `demo_car_model` */ + +insert into `demo_car_model`(`id`,`car_id`,`name`,`value`,`sort`,`remark`,`create_by`,`create_time`,`update_by`,`update_time`,`del_flag`,`tenant_id`) values (1,'1','宋dmi','001',1,NULL,NULL,NULL,NULL,NULL,NULL,'00000000'),(2,'2','星越L','001',1,NULL,NULL,NULL,NULL,NULL,NULL,'00000000'),(3,'1','唐DM','002',2,NULL,NULL,NULL,NULL,NULL,NULL,'00000000'); + +/*Table structure for table `demo_expand_table` */ + +DROP TABLE IF EXISTS `demo_expand_table`; + +CREATE TABLE `demo_expand_table` ( + `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键', + `name` varchar(255) NOT NULL COMMENT '商品名称', + `shop` varchar(100) NOT NULL COMMENT '所属店铺', + `category` varchar(100) DEFAULT NULL COMMENT '商品分类', + `address` text COMMENT '店铺地址', + `description` longtext COMMENT '商品描述', + `tag` varchar(200) DEFAULT NULL COMMENT '标签', + `create_time` datetime DEFAULT NULL, + `update_by` varchar(32) DEFAULT NULL, + `update_time` datetime DEFAULT NULL, + `remark` varchar(255) DEFAULT NULL, + `del_flag` char(1) DEFAULT NULL, + `create_by` varchar(32) DEFAULT NULL, + `organization_id` varchar(64) DEFAULT NULL COMMENT '组织ID', + `tenant_id` varchar(64) NOT NULL DEFAULT '00000000' COMMENT '租户ID', + `image` text COMMENT '图片', + PRIMARY KEY (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4; + +/*Data for the table `demo_expand_table` */ + +insert into `demo_expand_table`(`id`,`name`,`shop`,`category`,`address`,`description`,`tag`,`create_time`,`update_by`,`update_time`,`remark`,`del_flag`,`create_by`,`organization_id`,`tenant_id`,`image`) values (1,'红米手机','小米公司','电子产品','{\"lng\":116.415202,\"lat\":39.909298}','红米note9 pro','便宜好用',NULL,NULL,NULL,NULL,NULL,NULL,NULL,'00000000',NULL),(2,'华为手机','华为公司','电子产品','{\"lng\":116.332342,\"lat\":39.907306}','华为mate50','高端牌子',NULL,NULL,NULL,NULL,NULL,NULL,NULL,'00000000',NULL); + +/*Table structure for table `demo_table` */ + +DROP TABLE IF EXISTS `demo_table`; + +CREATE TABLE `demo_table` ( + `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键', + `title` varchar(255) DEFAULT NULL COMMENT '标题', + `author` varchar(100) NOT NULL COMMENT '作者', + `type` varchar(250) DEFAULT NULL COMMENT '类型', + `level` varchar(100) DEFAULT NULL COMMENT '密码', + `content` longtext COMMENT '内容', + `status` varchar(32) DEFAULT NULL COMMENT '状态', + `tag` varchar(200) DEFAULT NULL COMMENT '标签', + `readings` int(11) DEFAULT NULL COMMENT '阅读数', + `publish_date` datetime DEFAULT NULL COMMENT '发布时间', + `create_time` datetime DEFAULT NULL, + `update_by` varchar(32) DEFAULT NULL, + `update_time` datetime DEFAULT NULL, + `remark` varchar(255) DEFAULT NULL, + `del_flag` char(1) DEFAULT NULL, + `create_by` varchar(32) DEFAULT NULL, + `tenant_id` varchar(64) NOT NULL DEFAULT '00000000' COMMENT '租户ID', + PRIMARY KEY (`id`), + UNIQUE KEY `idx_test_table_title` (`title`) +) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4; + +/*Data for the table `demo_table` */ + +insert into `demo_table`(`id`,`title`,`author`,`type`,`level`,`content`,`status`,`tag`,`readings`,`publish_date`,`create_time`,`update_by`,`update_time`,`remark`,`del_flag`,`create_by`,`tenant_id`) values (1,'测试','sunseagear','1','123132','

阿斯顿发送到发斯蒂芬阿斯蒂芬阿萨德发送到发的发送到发的发

','0','111',1111,'2021-10-28 00:00:00',NULL,NULL,NULL,NULL,NULL,NULL,'00000000'); + +/*Table structure for table `demo_tree_and_table` */ + +DROP TABLE IF EXISTS `demo_tree_and_table`; + +CREATE TABLE `demo_tree_and_table` ( + `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键', + `name` varchar(255) DEFAULT NULL COMMENT '部门名称', + `type` varchar(250) DEFAULT NULL COMMENT '类型', + `tag` varchar(200) DEFAULT NULL COMMENT '标签', + `area_id` varchar(64) DEFAULT NULL, + `create_time` datetime DEFAULT NULL, + `update_by` varchar(32) DEFAULT NULL, + `update_time` datetime DEFAULT NULL, + `remark` varchar(255) DEFAULT NULL, + `del_flag` char(1) DEFAULT NULL, + `create_by` varchar(32) DEFAULT NULL, + `tenant_id` varchar(64) NOT NULL DEFAULT '00000000', + PRIMARY KEY (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb4; + +/*Data for the table `demo_tree_and_table` */ + +insert into `demo_tree_and_table`(`id`,`name`,`type`,`tag`,`area_id`,`create_time`,`update_by`,`update_time`,`remark`,`del_flag`,`create_by`,`tenant_id`) values (1,'开发部门',NULL,'java开发','2',NULL,NULL,NULL,NULL,NULL,NULL,'00000000'),(2,'市场部',NULL,'办事处','4',NULL,NULL,NULL,NULL,NULL,NULL,'00000000'); + +/*Table structure for table `demo_tree_table` */ + +DROP TABLE IF EXISTS `demo_tree_table`; + +CREATE TABLE `demo_tree_table` ( + `id` bigint(20) NOT NULL AUTO_INCREMENT, + `name` varchar(100) DEFAULT NULL COMMENT '机构名称', + `geocoding` varchar(32) DEFAULT NULL COMMENT '是否叶子节点', + `postal_code` varchar(32) DEFAULT NULL, + `parent_id` varchar(32) DEFAULT NULL COMMENT '父节点', + `ancestors` varchar(1000) DEFAULT NULL COMMENT '父节点路径', + `create_by` varchar(32) DEFAULT NULL, + `create_time` datetime DEFAULT NULL, + `update_by` varchar(32) DEFAULT NULL, + `update_time` datetime DEFAULT NULL, + `del_flag` char(1) DEFAULT NULL COMMENT '删除标记', + `remark` varchar(255) DEFAULT NULL, + `tenant_id` varchar(64) NOT NULL DEFAULT '00000000' COMMENT '租户ID', + PRIMARY KEY (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=utf8; + +/*Data for the table `demo_tree_table` */ + +insert into `demo_tree_table`(`id`,`name`,`geocoding`,`postal_code`,`parent_id`,`ancestors`,`create_by`,`create_time`,`update_by`,`update_time`,`del_flag`,`remark`,`tenant_id`) values (1,'陕西','001','001','0','0,',NULL,NULL,NULL,NULL,NULL,'Shaanxi','00000000'),(2,'西安','001001','001001','1','0,1,',NULL,NULL,NULL,NULL,NULL,'xi\'an','00000000'),(4,'宝鸡','001003','001003','1','0,1,',NULL,NULL,NULL,NULL,NULL,'baoji','00000000'),(5,'雁塔','001001001','001001001','2','0,1,2,',NULL,NULL,NULL,NULL,NULL,'yanta','00000000'),(6,'兴平','132132','123132','8','0,1,8,',NULL,NULL,NULL,NULL,NULL,'asdfasdf','00000000'),(8,'咸阳','1111','111','1','0,1,',NULL,NULL,NULL,NULL,NULL,'11','00000000'),(9,'安康','111','222','1','0,1,',NULL,NULL,NULL,NULL,NULL,'333','00000000'); + +/*Table structure for table `gen_table` */ + +DROP TABLE IF EXISTS `gen_table`; + +CREATE TABLE `gen_table` ( + `table_id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '编号', + `table_name` varchar(200) DEFAULT '' COMMENT '表名称', + `table_comment` varchar(500) DEFAULT '' COMMENT '表描述', + `sub_table_name` varchar(64) DEFAULT NULL COMMENT '关联子表的表名', + `sub_table_fk_name` varchar(64) DEFAULT NULL COMMENT '子表关联的外键名', + `class_name` varchar(100) DEFAULT '' COMMENT '实体类名称', + `tpl_category` varchar(200) DEFAULT 'crud' COMMENT '使用的模板(crud单表操作 tree树表操作)', + `package_name` varchar(100) DEFAULT NULL COMMENT '生成包路径', + `module_name` varchar(30) DEFAULT NULL COMMENT '生成模块名', + `business_name` varchar(30) DEFAULT NULL COMMENT '生成业务名', + `function_name` varchar(50) DEFAULT NULL COMMENT '生成功能名', + `function_author` varchar(50) DEFAULT NULL COMMENT '生成功能作者', + `gen_type` char(1) DEFAULT '0' COMMENT '生成代码方式(0zip压缩包 1自定义路径)', + `gen_path` varchar(200) DEFAULT '/' COMMENT '生成路径(不填默认项目路径)', + `options` varchar(1000) DEFAULT NULL COMMENT '其它生成选项', + `create_by` varchar(64) DEFAULT '' COMMENT '创建者', + `create_time` datetime DEFAULT NULL COMMENT '创建时间', + `update_by` varchar(64) DEFAULT '' COMMENT '更新者', + `update_time` datetime DEFAULT NULL COMMENT '更新时间', + `remark` varchar(500) DEFAULT NULL COMMENT '备注', + `tenant_id` varchar(8) NOT NULL DEFAULT '00000000', + PRIMARY KEY (`table_id`) +) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=utf8mb4 COMMENT='代码生成业务表'; + +/*Data for the table `gen_table` */ + +insert into `gen_table`(`table_id`,`table_name`,`table_comment`,`sub_table_name`,`sub_table_fk_name`,`class_name`,`tpl_category`,`package_name`,`module_name`,`business_name`,`function_name`,`function_author`,`gen_type`,`gen_path`,`options`,`create_by`,`create_time`,`update_by`,`update_time`,`remark`,`tenant_id`) values (1,'sys_config','参数配置表',NULL,NULL,'SysConfig','crud','com.ruoyi.system','system','config','参数配置','ruoyi','0','/',NULL,'admin','2021-09-21 18:07:52','',NULL,NULL,'00000000'),(2,'sys_tenant','租户管理',NULL,NULL,'SysTenant','crud','com.ruoyi.system','system','tenant','租户管理','ruoyi','0','/',NULL,'admin','2021-10-10 16:10:50','',NULL,NULL,'00000000'),(4,'sys_data_rule','数据权限表',NULL,NULL,'SysDataRule','crud','com.ruoyi.system','system','rule','数据权限','ruoyi','0','/','{}','admin','2021-10-19 17:14:27','','2021-10-19 17:14:50',NULL,'00000000'),(5,'demo_table','综合表格',NULL,NULL,'Table','crud','com.ruoyi.demo','demo','table','综合表格','ruoyi','0','/','{}','admin','2021-10-21 20:43:12','','2021-10-22 13:27:41',NULL,'00000000'),(6,'demo_tree_table','树形表格','','','TreeTable','tree','com.ruoyi.demo','demo','treeTable','树形表格','ruoyi','0','/','{\"treeCode\":\"id\",\"treeName\":\"name\",\"treeParentCode\":\"parent_id\"}','admin','2021-10-22 14:12:07','','2021-10-22 14:17:03',NULL,'00000000'),(7,'demo_expand_table','展开表格',NULL,NULL,'ExpandTable','crud','com.ruoyi.system','demo','expandTable','展开表格','ruoyi','0','/','{}','admin','2021-10-22 22:58:00','','2021-10-22 22:59:56',NULL,'00000000'),(8,'demo_car','车辆品牌',NULL,NULL,'Car','crud','com.ruoyi.system','demo','car','车辆品牌','ruoyi','0','/','{}','admin','2021-10-22 23:33:37','','2021-10-22 23:34:25',NULL,'00000000'),(9,'demo_car_model','车辆型号',NULL,NULL,'CarModel','crud','com.ruoyi.system','demo','car','车辆型号','ruoyi','0','/','{}','admin','2021-10-22 23:33:38','','2021-10-22 23:36:05',NULL,'00000000'),(10,'demo_tree_and_table','左树右表',NULL,NULL,'TreeAndTable','crud','com.ruoyi.system','system','treeandtable','左树右表','ruoyi','0','/','{}','admin','2021-10-23 11:58:21','','2021-10-23 12:01:14',NULL,'00000000'); + +/*Table structure for table `gen_table_column` */ + +DROP TABLE IF EXISTS `gen_table_column`; + +CREATE TABLE `gen_table_column` ( + `column_id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '编号', + `table_id` varchar(64) DEFAULT NULL COMMENT '归属表编号', + `column_name` varchar(200) DEFAULT NULL COMMENT '列名称', + `column_comment` varchar(500) DEFAULT NULL COMMENT '列描述', + `column_type` varchar(100) DEFAULT NULL COMMENT '列类型', + `java_type` varchar(500) DEFAULT NULL COMMENT 'JAVA类型', + `java_field` varchar(200) DEFAULT NULL COMMENT 'JAVA字段名', + `is_pk` char(1) DEFAULT NULL COMMENT '是否主键(1是)', + `is_increment` char(1) DEFAULT NULL COMMENT '是否自增(1是)', + `is_required` char(1) DEFAULT NULL COMMENT '是否必填(1是)', + `is_insert` char(1) DEFAULT NULL COMMENT '是否为插入字段(1是)', + `is_edit` char(1) DEFAULT NULL COMMENT '是否编辑字段(1是)', + `is_list` char(1) DEFAULT NULL COMMENT '是否列表字段(1是)', + `is_query` char(1) DEFAULT NULL COMMENT '是否查询字段(1是)', + `query_type` varchar(200) DEFAULT 'EQ' COMMENT '查询方式(等于、不等于、大于、小于、范围)', + `html_type` varchar(200) DEFAULT NULL COMMENT '显示类型(文本框、文本域、下拉框、复选框、单选框、日期控件)', + `dict_type` varchar(200) DEFAULT '' COMMENT '字典类型', + `sort` int(11) DEFAULT NULL COMMENT '排序', + `create_by` varchar(64) DEFAULT '' COMMENT '创建者', + `create_time` datetime DEFAULT NULL COMMENT '创建时间', + `update_by` varchar(64) DEFAULT '' COMMENT '更新者', + `update_time` datetime DEFAULT NULL COMMENT '更新时间', + `tenant_id` varchar(8) NOT NULL DEFAULT '00000000', + PRIMARY KEY (`column_id`) +) ENGINE=InnoDB AUTO_INCREMENT=142 DEFAULT CHARSET=utf8mb4 COMMENT='代码生成业务表字段'; + +/*Data for the table `gen_table_column` */ + +insert into `gen_table_column`(`column_id`,`table_id`,`column_name`,`column_comment`,`column_type`,`java_type`,`java_field`,`is_pk`,`is_increment`,`is_required`,`is_insert`,`is_edit`,`is_list`,`is_query`,`query_type`,`html_type`,`dict_type`,`sort`,`create_by`,`create_time`,`update_by`,`update_time`,`tenant_id`) values (1,'1','config_id','参数主键','int(5)','Integer','configId','1','1',NULL,'1',NULL,NULL,NULL,'EQ','input','',1,'admin','2021-09-21 18:07:52','',NULL,'00000000'),(2,'1','config_name','参数名称','varchar(100)','String','configName','0','0',NULL,'1','1','1','1','LIKE','input','',2,'admin','2021-09-21 18:07:52','',NULL,'00000000'),(3,'1','config_key','参数键名','varchar(100)','String','configKey','0','0',NULL,'1','1','1','1','EQ','input','',3,'admin','2021-09-21 18:07:52','',NULL,'00000000'),(4,'1','config_value','参数键值','varchar(500)','String','configValue','0','0',NULL,'1','1','1','1','EQ','textarea','',4,'admin','2021-09-21 18:07:52','',NULL,'00000000'),(5,'1','config_type','系统内置(Y是 N否)','char(1)','String','configType','0','0',NULL,'1','1','1','1','EQ','select','',5,'admin','2021-09-21 18:07:52','',NULL,'00000000'),(6,'1','create_by','创建者','varchar(64)','String','createBy','0','0',NULL,'1',NULL,NULL,NULL,'EQ','input','',6,'admin','2021-09-21 18:07:52','',NULL,'00000000'),(7,'1','create_time','创建时间','datetime','Date','createTime','0','0',NULL,'1',NULL,NULL,NULL,'EQ','datetime','',7,'admin','2021-09-21 18:07:52','',NULL,'00000000'),(8,'1','update_by','更新者','varchar(64)','String','updateBy','0','0',NULL,'1','1',NULL,NULL,'EQ','input','',8,'admin','2021-09-21 18:07:52','',NULL,'00000000'),(9,'1','update_time','更新时间','datetime','Date','updateTime','0','0',NULL,'1','1',NULL,NULL,'EQ','datetime','',9,'admin','2021-09-21 18:07:52','',NULL,'00000000'),(10,'1','remark','备注','varchar(500)','String','remark','0','0',NULL,'1','1','1',NULL,'EQ','textarea','',10,'admin','2021-09-21 18:07:52','',NULL,'00000000'),(11,'2','info_id','访问ID','bigint(20)','Long','infoId','1','1',NULL,'1',NULL,NULL,NULL,'EQ','input','',1,'admin','2021-10-10 16:10:50','',NULL,'00000000'),(12,'2','create_by','创建者','varchar(64)','String','createBy','0','0',NULL,'1',NULL,NULL,NULL,'EQ','input','',2,'admin','2021-10-10 16:10:50','',NULL,'00000000'),(13,'2','create_time','创建日期','datetime','Date','createTime','0','0',NULL,'1',NULL,NULL,NULL,'EQ','datetime','',3,'admin','2021-10-10 16:10:50','',NULL,'00000000'),(14,'2','update_by','更新者','varchar(64)','String','updateBy','0','0',NULL,'1','1',NULL,NULL,'EQ','input','',4,'admin','2021-10-10 16:10:50','',NULL,'00000000'),(15,'2','update_time','更新日期','datetime','Date','updateTime','0','0',NULL,'1','1',NULL,NULL,'EQ','datetime','',5,'admin','2021-10-10 16:10:50','',NULL,'00000000'),(16,'2','del_flag','删除标识','char(1)','String','delFlag','0','0',NULL,'1',NULL,NULL,NULL,'EQ','input','',6,'admin','2021-10-10 16:10:50','',NULL,'00000000'),(17,'2','remarks','备注','text','String','remarks','0','0',NULL,'1','1','1','1','EQ','textarea','',7,'admin','2021-10-10 16:10:50','',NULL,'00000000'),(18,'2','tenant_id','租户标识','varchar(64)','String','tenantId','0','0',NULL,'1','1','1','1','EQ','input','',8,'admin','2021-10-10 16:10:51','',NULL,'00000000'),(19,'2','contact','联系人','varchar(64)','String','contact','0','0','1','1','1','1','1','EQ','input','',9,'admin','2021-10-10 16:10:51','',NULL,'00000000'),(20,'2','phone','电话','varchar(64)','String','phone','0','0','1','1','1','1','1','EQ','input','',10,'admin','2021-10-10 16:10:51','',NULL,'00000000'),(21,'2','name','租户名称','varchar(64)','String','name','0','0','1','1','1','1','1','LIKE','input','',11,'admin','2021-10-10 16:10:51','',NULL,'00000000'),(22,'2','user_id',NULL,'varchar(64)','String','userId','0','0',NULL,'1','1','1','1','EQ','input','',12,'admin','2021-10-10 16:10:51','',NULL,'00000000'),(44,'4','id','主键','bigint(20)','Long','id','1','1',NULL,'1',NULL,NULL,NULL,'EQ','input','',1,'admin','2021-10-19 17:14:27','','2021-10-19 17:14:50','00000000'),(45,'4','resource_code','资源编号','varchar(255)','String','resourceCode','0','0','1','1','1','1',NULL,'EQ','input','',2,'admin','2021-10-19 17:14:29','','2021-10-19 17:14:50','00000000'),(46,'4','scope_name','数据权限名称','varchar(255)','String','scopeName','0','0','1','1','1','1','1','LIKE','input','',3,'admin','2021-10-19 17:14:29','','2021-10-19 17:14:50','00000000'),(47,'4','scope_field','数据权限字段','varchar(255)','String','scopeField','0','0','1','1','1','1',NULL,'EQ','input','',4,'admin','2021-10-19 17:14:29','','2021-10-19 17:14:50','00000000'),(48,'4','scope_class','数据权限类名','varchar(500)','String','scopeClass','0','0','1','1','1','1',NULL,'EQ','textarea','',5,'admin','2021-10-19 17:14:29','','2021-10-19 17:14:50','00000000'),(49,'4','scope_column','数据权限字段','varchar(255)','String','scopeColumn','0','0','1','1','1','1',NULL,'EQ','input','',6,'admin','2021-10-19 17:14:29','','2021-10-19 17:14:50','00000000'),(50,'4','scope_type','数据权限类型','int(2)','Integer','scopeType','0','0','1','1','1','1',NULL,'EQ','select','',7,'admin','2021-10-19 17:14:29','','2021-10-19 17:14:50','00000000'),(51,'4','scope_value','数据权限值域','varchar(2000)','String','scopeValue','0','0',NULL,'1','1','1',NULL,'EQ','textarea','',8,'admin','2021-10-19 17:14:29','','2021-10-19 17:14:51','00000000'),(52,'4','remarks','数据权限备注','varchar(255)','String','remarks','0','0',NULL,'1','1','1',NULL,'EQ','input','',9,'admin','2021-10-19 17:14:29','','2021-10-19 17:14:51','00000000'),(53,'4','create_by','创建人','varchar(64)','String','createBy','0','0',NULL,'1',NULL,NULL,NULL,'EQ','input','',10,'admin','2021-10-19 17:14:29','','2021-10-19 17:14:51','00000000'),(54,'4','create_time','创建时间','datetime','Date','createTime','0','0',NULL,'1',NULL,NULL,NULL,'EQ','datetime','',11,'admin','2021-10-19 17:14:30','','2021-10-19 17:14:51','00000000'),(55,'4','update_by','修改人','varchar(64)','String','updateBy','0','0',NULL,'1','1',NULL,NULL,'EQ','input','',12,'admin','2021-10-19 17:14:30','','2021-10-19 17:14:51','00000000'),(56,'4','update_time','修改时间','datetime','Date','updateTime','0','0',NULL,'1','1',NULL,NULL,'EQ','datetime','',13,'admin','2021-10-19 17:14:30','','2021-10-19 17:14:51','00000000'),(57,'4','del_flag','是否已删除','int(2)','Integer','delFlag','0','0',NULL,'1',NULL,NULL,NULL,'EQ','input','',14,'admin','2021-10-19 17:14:30','','2021-10-19 17:14:51','00000000'),(58,'4','table_name','数据库表','varchar(64)','String','tableName','0','0',NULL,'1','1','1',NULL,'LIKE','input','',15,'admin','2021-10-19 17:14:30','','2021-10-19 17:14:51','00000000'),(59,'4','user_column','用户表对应字段','varchar(64)','String','userColumn','0','0',NULL,'1','1','1',NULL,'EQ','input','',16,'admin','2021-10-19 17:14:30','','2021-10-19 17:14:51','00000000'),(60,'4','tenant_id','租户ID','varchar(64)','String','tenantId','0','0','1','1','1','1',NULL,'EQ','input','',17,'admin','2021-10-19 17:14:30','','2021-10-19 17:14:51','00000000'),(61,'4','user_entity_field','user实体类对应字段','varchar(64)','String','userEntityField','0','0',NULL,'1','1','1',NULL,'EQ','input','',18,'admin','2021-10-19 17:14:31','','2021-10-19 17:14:51','00000000'),(62,'5','id','主键','varchar(64)','String','id','1','0',NULL,'1',NULL,NULL,NULL,'EQ','input','',1,'admin','2021-10-21 20:43:12','','2021-10-22 13:27:41','00000000'),(63,'5','title','标题','varchar(255)','String','title','0','0',NULL,'1','1','1','1','EQ','input','',2,'admin','2021-10-21 20:43:12','','2021-10-22 13:27:41','00000000'),(64,'5','author','作者','varchar(100)','String','author','0','0','1','1','1','1',NULL,'EQ','input','',3,'admin','2021-10-21 20:43:12','','2021-10-22 13:27:41','00000000'),(65,'5','type','类型','varchar(250)','String','type','0','0',NULL,'1','1','1',NULL,'EQ','select','sys_notice_type',4,'admin','2021-10-21 20:43:12','','2021-10-22 13:27:41','00000000'),(66,'5','level','密码','varchar(100)','String','level','0','0',NULL,'1','1','1',NULL,'EQ','input','',5,'admin','2021-10-21 20:43:13','','2021-10-22 13:27:42','00000000'),(67,'5','content','内容','longtext','String','content','0','0',NULL,'1','1','1',NULL,'EQ','editor','',6,'admin','2021-10-21 20:43:13','','2021-10-22 13:27:42','00000000'),(68,'5','status','状态','varchar(32)','String','status','0','0',NULL,'1','1','1',NULL,'EQ','radio','sys_common_status',7,'admin','2021-10-21 20:43:13','','2021-10-22 13:27:42','00000000'),(69,'5','tag','标签','varchar(200)','String','tag','0','0',NULL,'1','1','1',NULL,'EQ','input','',8,'admin','2021-10-21 20:43:13','','2021-10-22 13:27:42','00000000'),(70,'5','readings','阅读数','int(11)','Long','readings','0','0',NULL,'1','1','1',NULL,'EQ','input','',9,'admin','2021-10-21 20:43:13','','2021-10-22 13:27:42','00000000'),(71,'5','publish_date','发布时间','datetime','Date','publishDate','0','0',NULL,'1','1','1',NULL,'EQ','datetime','',10,'admin','2021-10-21 20:43:13','','2021-10-22 13:27:42','00000000'),(72,'5','create_time',NULL,'datetime','Date','createTime','0','0',NULL,'1',NULL,NULL,NULL,'EQ','datetime','',11,'admin','2021-10-21 20:43:13','','2021-10-22 13:27:42','00000000'),(73,'5','update_by',NULL,'varchar(32)','String','updateBy','0','0',NULL,'1','1',NULL,NULL,'EQ','input','',12,'admin','2021-10-21 20:43:13','','2021-10-22 13:27:42','00000000'),(74,'5','update_time',NULL,'datetime','Date','updateTime','0','0',NULL,'1','1',NULL,NULL,'EQ','datetime','',13,'admin','2021-10-21 20:43:13','','2021-10-22 13:27:42','00000000'),(75,'5','remarks',NULL,'varchar(255)','String','remarks','0','0',NULL,'1','1',NULL,NULL,'EQ','input','',14,'admin','2021-10-21 20:43:13','','2021-10-22 13:27:42','00000000'),(76,'5','del_flag',NULL,'char(1)','String','delFlag','0','0',NULL,'1',NULL,NULL,NULL,'EQ','input','',15,'admin','2021-10-21 20:43:13','','2021-10-22 13:27:42','00000000'),(77,'5','create_by',NULL,'varchar(32)','String','createBy','0','0',NULL,'1',NULL,NULL,NULL,'EQ','input','',16,'admin','2021-10-21 20:43:13','','2021-10-22 13:27:42','00000000'),(78,'5','tenant_id','租户ID','varchar(64)','String','tenantId','0','0','1','1',NULL,NULL,NULL,'EQ','input','',17,'admin','2021-10-21 20:43:13','','2021-10-22 13:27:42','00000000'),(79,'6','id',NULL,'varchar(64)','String','id','1','0',NULL,'1',NULL,NULL,NULL,'EQ','input','',1,'admin','2021-10-22 14:12:07','','2021-10-22 14:17:03','00000000'),(80,'6','name','机构名称','varchar(100)','String','name','0','0',NULL,'1','1','1','1','LIKE','input','',2,'admin','2021-10-22 14:12:08','','2021-10-22 14:17:03','00000000'),(81,'6','geocoding','是否叶子节点','varchar(32)','String','geocoding','0','0',NULL,'1','1','1','1','EQ','input','',3,'admin','2021-10-22 14:12:09','','2021-10-22 14:17:03','00000000'),(82,'6','postal_code',NULL,'varchar(32)','String','postalCode','0','0',NULL,'1','1','1','1','EQ','input','',4,'admin','2021-10-22 14:12:09','','2021-10-22 14:17:03','00000000'),(83,'6','parent_id','父节点','varchar(32)','String','parentId','0','0',NULL,'1','1','1',NULL,'EQ','input','',5,'admin','2021-10-22 14:12:09','','2021-10-22 14:17:03','00000000'),(84,'6','parent_ids','父节点路径','varchar(1000)','String','parentIds','0','0',NULL,'1','1','1',NULL,'EQ','textarea','',6,'admin','2021-10-22 14:12:09','','2021-10-22 14:17:03','00000000'),(85,'6','create_by',NULL,'varchar(32)','String','createBy','0','0',NULL,'1',NULL,NULL,NULL,'EQ','input','',7,'admin','2021-10-22 14:12:09','','2021-10-22 14:17:04','00000000'),(86,'6','create_time',NULL,'datetime','Date','createTime','0','0',NULL,'1',NULL,NULL,NULL,'EQ','datetime','',8,'admin','2021-10-22 14:12:09','','2021-10-22 14:17:04','00000000'),(87,'6','update_by',NULL,'varchar(32)','String','updateBy','0','0',NULL,'1','1',NULL,NULL,'EQ','input','',9,'admin','2021-10-22 14:12:09','','2021-10-22 14:17:04','00000000'),(88,'6','update_time',NULL,'datetime','Date','updateTime','0','0',NULL,'1','1',NULL,NULL,'EQ','datetime','',10,'admin','2021-10-22 14:12:09','','2021-10-22 14:17:04','00000000'),(89,'6','del_flag','删除标记','char(1)','String','delFlag','0','0',NULL,'1',NULL,NULL,NULL,'EQ','input','',11,'admin','2021-10-22 14:12:09','','2021-10-22 14:17:04','00000000'),(90,'6','remark',NULL,'varchar(255)','String','remark','0','0',NULL,'1','1','1',NULL,'EQ','input','',12,'admin','2021-10-22 14:12:09','','2021-10-22 14:17:04','00000000'),(91,'6','tenant_id','租户ID','varchar(64)','String','tenantId','0','0','1','1','1','1',NULL,'EQ','input','',13,'admin','2021-10-22 14:12:09','','2021-10-22 14:17:04','00000000'),(92,'7','id','主键','bigint(20)','Long','id','1','1',NULL,'1',NULL,NULL,NULL,'EQ','input','',1,'admin','2021-10-22 22:58:00','','2021-10-22 22:59:56','00000000'),(93,'7','name','商品名称','varchar(255)','String','name','0','0','1','1','1','1','1','LIKE','input','',2,'admin','2021-10-22 22:58:00','','2021-10-22 22:59:57','00000000'),(94,'7','shop','所属店铺','varchar(100)','String','shop','0','0','1','1','1','1',NULL,'EQ','input','',3,'admin','2021-10-22 22:58:00','','2021-10-22 22:59:57','00000000'),(95,'7','category','商品分类','varchar(100)','String','category','0','0',NULL,'1','1','1',NULL,'EQ','input','',4,'admin','2021-10-22 22:58:00','','2021-10-22 22:59:57','00000000'),(96,'7','address','店铺地址','text','String','address','0','0',NULL,'1','1','1',NULL,'EQ','textarea','',5,'admin','2021-10-22 22:58:00','','2021-10-22 22:59:57','00000000'),(97,'7','description','商品描述','longtext','String','description','0','0',NULL,'1','1','1',NULL,'EQ','textarea','',6,'admin','2021-10-22 22:58:01','','2021-10-22 22:59:57','00000000'),(98,'7','tag','标签','varchar(200)','String','tag','0','0',NULL,'1','1','1',NULL,'EQ','input','',7,'admin','2021-10-22 22:58:01','','2021-10-22 22:59:57','00000000'),(99,'7','create_time',NULL,'datetime','Date','createTime','0','0',NULL,'1',NULL,NULL,NULL,'EQ','datetime','',8,'admin','2021-10-22 22:58:01','','2021-10-22 22:59:57','00000000'),(100,'7','update_by',NULL,'varchar(32)','String','updateBy','0','0',NULL,'1',NULL,NULL,NULL,'EQ','input','',9,'admin','2021-10-22 22:58:01','','2021-10-22 22:59:57','00000000'),(101,'7','update_time',NULL,'datetime','Date','updateTime','0','0',NULL,'1',NULL,NULL,NULL,'EQ','datetime','',10,'admin','2021-10-22 22:58:01','','2021-10-22 22:59:57','00000000'),(102,'7','remark',NULL,'varchar(255)','String','remark','0','0',NULL,'1',NULL,'1',NULL,'EQ','input','',11,'admin','2021-10-22 22:58:01','','2021-10-22 22:59:57','00000000'),(103,'7','del_flag',NULL,'char(1)','String','delFlag','0','0',NULL,'1',NULL,NULL,NULL,'EQ','input','',12,'admin','2021-10-22 22:58:01','','2021-10-22 22:59:57','00000000'),(104,'7','create_by',NULL,'varchar(32)','String','createBy','0','0',NULL,'1',NULL,NULL,NULL,'EQ','input','',13,'admin','2021-10-22 22:58:01','','2021-10-22 22:59:57','00000000'),(105,'7','organization_id','组织ID','varchar(64)','String','organizationId','0','0',NULL,'1',NULL,'1',NULL,'EQ','input','',14,'admin','2021-10-22 22:58:01','','2021-10-22 22:59:57','00000000'),(106,'7','tenant_id','租户ID','varchar(64)','String','tenantId','0','0',NULL,'1',NULL,'1',NULL,'EQ','input','',15,'admin','2021-10-22 22:58:01','','2021-10-22 22:59:57','00000000'),(107,'7','image','图片','text','String','image','0','0',NULL,'1','1','1','1','EQ','imageUpload','',16,'admin','2021-10-22 22:58:01','','2021-10-22 22:59:57','00000000'),(108,'8','id','主键','bigint(20)','Long','id','1','1',NULL,'1',NULL,NULL,NULL,'EQ','input','',1,'admin','2021-10-22 23:33:37','','2021-10-22 23:34:25','00000000'),(109,'8','name','名称','varchar(100)','String','name','0','0',NULL,'1','1','1','1','LIKE','input','',2,'admin','2021-10-22 23:33:37','','2021-10-22 23:34:25','00000000'),(110,'8','code','品牌代码','varchar(100)','String','code','0','0',NULL,'1','1','1',NULL,'EQ','input','',3,'admin','2021-10-22 23:33:37','','2021-10-22 23:34:25','00000000'),(111,'8','remark','备注','varchar(100)','String','remark','0','0',NULL,'1','1',NULL,NULL,'EQ','input','',4,'admin','2021-10-22 23:33:37','','2021-10-22 23:34:25','00000000'),(112,'8','create_by',NULL,'varchar(32)','String','createBy','0','0',NULL,'1',NULL,NULL,NULL,'EQ','input','',5,'admin','2021-10-22 23:33:37','','2021-10-22 23:34:25','00000000'),(113,'8','create_time',NULL,'datetime','Date','createTime','0','0',NULL,'1',NULL,NULL,NULL,'EQ','datetime','',6,'admin','2021-10-22 23:33:38','','2021-10-22 23:34:25','00000000'),(114,'8','update_by',NULL,'varchar(32)','String','updateBy','0','0',NULL,'1',NULL,NULL,NULL,'EQ','input','',7,'admin','2021-10-22 23:33:38','','2021-10-22 23:34:25','00000000'),(115,'8','update_time',NULL,'datetime','Date','updateTime','0','0',NULL,'1',NULL,NULL,NULL,'EQ','datetime','',8,'admin','2021-10-22 23:33:38','','2021-10-22 23:34:26','00000000'),(116,'8','del_flag',NULL,'char(1)','String','delFlag','0','0',NULL,'1',NULL,NULL,NULL,'EQ','input','',9,'admin','2021-10-22 23:33:38','','2021-10-22 23:34:26','00000000'),(117,'8','tenant_id','租户ID','varchar(64)','String','tenantId','0','0','1','1',NULL,NULL,NULL,'EQ','input','',10,'admin','2021-10-22 23:33:38','','2021-10-22 23:34:26','00000000'),(118,'9','id','主键','bigint(20)','Long','id','1','1',NULL,'1',NULL,NULL,NULL,'EQ','input','',1,'admin','2021-10-22 23:33:38','','2021-10-22 23:36:05','00000000'),(119,'9','car_id','汽车','varchar(32)','String','carId','0','0',NULL,'1',NULL,NULL,NULL,'EQ','input','',2,'admin','2021-10-22 23:33:38','','2021-10-22 23:36:05','00000000'),(120,'9','name','型号名','varchar(100)','String','name','0','0','1','1','1','1','1','LIKE','input','',3,'admin','2021-10-22 23:33:38','','2021-10-22 23:36:05','00000000'),(121,'9','value','型号代码','varchar(100)','String','value','0','0','1','1','1','1',NULL,'EQ','input','',4,'admin','2021-10-22 23:33:38','','2021-10-22 23:36:05','00000000'),(122,'9','sort','排序','int(5)','Integer','sort','0','0','1','1','1','1',NULL,'EQ','input','',5,'admin','2021-10-22 23:33:38','','2021-10-22 23:36:05','00000000'),(123,'9','remark','描述','varchar(100)','String','remark','0','0',NULL,'1','1','1',NULL,'EQ','input','',6,'admin','2021-10-22 23:33:38','','2021-10-22 23:36:05','00000000'),(124,'9','create_by',NULL,'varchar(32)','String','createBy','0','0',NULL,'1',NULL,NULL,NULL,'EQ','input','',7,'admin','2021-10-22 23:33:38','','2021-10-22 23:36:05','00000000'),(125,'9','create_time',NULL,'datetime','Date','createTime','0','0',NULL,'1',NULL,NULL,NULL,'EQ','datetime','',8,'admin','2021-10-22 23:33:38','','2021-10-22 23:36:05','00000000'),(126,'9','update_by',NULL,'varchar(32)','String','updateBy','0','0',NULL,'1',NULL,NULL,NULL,'EQ','input','',9,'admin','2021-10-22 23:33:38','','2021-10-22 23:36:06','00000000'),(127,'9','update_time',NULL,'datetime','Date','updateTime','0','0',NULL,'1',NULL,NULL,NULL,'EQ','datetime','',10,'admin','2021-10-22 23:33:38','','2021-10-22 23:36:06','00000000'),(128,'9','del_flag',NULL,'char(1)','String','delFlag','0','0',NULL,'1',NULL,NULL,NULL,'EQ','input','',11,'admin','2021-10-22 23:33:38','','2021-10-22 23:36:06','00000000'),(129,'9','tenant_id',NULL,'varchar(64)','String','tenantId','0','0',NULL,'1',NULL,NULL,NULL,'EQ','input','',12,'admin','2021-10-22 23:33:39','','2021-10-22 23:36:06','00000000'),(130,'10','id','主键','varchar(64)','String','id','1','0',NULL,'1',NULL,NULL,NULL,'EQ','input','',1,'admin','2021-10-23 11:58:21','','2021-10-23 12:01:14','00000000'),(131,'10','name','部门名称','varchar(255)','String','name','0','0',NULL,'1','1','1','1','LIKE','input','',2,'admin','2021-10-23 11:58:21','','2021-10-23 12:01:14','00000000'),(132,'10','type','类型','varchar(250)','String','type','0','0',NULL,'1','1','1',NULL,'EQ','select','',3,'admin','2021-10-23 11:58:21','','2021-10-23 12:01:14','00000000'),(133,'10','tag','标签','varchar(200)','String','tag','0','0',NULL,'1','1','1',NULL,'EQ','input','',4,'admin','2021-10-23 11:58:21','','2021-10-23 12:01:14','00000000'),(134,'10','area_id','区域','varchar(64)','String','areaId','0','0',NULL,'1','1',NULL,NULL,'EQ','select','',5,'admin','2021-10-23 11:58:21','','2021-10-23 12:01:14','00000000'),(135,'10','create_time',NULL,'datetime','Date','createTime','0','0',NULL,'1',NULL,NULL,NULL,'EQ','datetime','',6,'admin','2021-10-23 11:58:22','','2021-10-23 12:01:14','00000000'),(136,'10','update_by',NULL,'varchar(32)','String','updateBy','0','0',NULL,'1',NULL,NULL,NULL,'EQ','input','',7,'admin','2021-10-23 11:58:22','','2021-10-23 12:01:14','00000000'),(137,'10','update_time',NULL,'datetime','Date','updateTime','0','0',NULL,'1',NULL,NULL,NULL,'EQ','datetime','',8,'admin','2021-10-23 11:58:22','','2021-10-23 12:01:14','00000000'),(138,'10','remark',NULL,'varchar(255)','String','remark','0','0',NULL,'1','1',NULL,NULL,'EQ','input','',9,'admin','2021-10-23 11:58:22','','2021-10-23 12:01:14','00000000'),(139,'10','del_flag',NULL,'char(1)','String','delFlag','0','0',NULL,'1',NULL,NULL,NULL,'EQ','input','',10,'admin','2021-10-23 11:58:22','','2021-10-23 12:01:14','00000000'),(140,'10','create_by',NULL,'varchar(32)','String','createBy','0','0',NULL,'1',NULL,NULL,NULL,'EQ','input','',11,'admin','2021-10-23 11:58:22','','2021-10-23 12:01:14','00000000'),(141,'10','tenant_id',NULL,'varchar(64)','String','tenantId','0','0','1','1',NULL,NULL,NULL,'EQ','input','',12,'admin','2021-10-23 11:58:22','','2021-10-23 12:01:14','00000000'); + +/*Table structure for table `qrtz_blob_triggers` */ + +DROP TABLE IF EXISTS `qrtz_blob_triggers`; + +CREATE TABLE `qrtz_blob_triggers` ( + `sched_name` varchar(120) NOT NULL COMMENT '调度名称', + `trigger_name` varchar(200) NOT NULL COMMENT 'qrtz_triggers表trigger_name的外键', + `trigger_group` varchar(200) NOT NULL COMMENT 'qrtz_triggers表trigger_group的外键', + `blob_data` blob COMMENT '存放持久化Trigger对象', + PRIMARY KEY (`sched_name`,`trigger_name`,`trigger_group`), + CONSTRAINT `qrtz_blob_triggers_ibfk_1` FOREIGN KEY (`sched_name`, `trigger_name`, `trigger_group`) REFERENCES `qrtz_triggers` (`sched_name`, `trigger_name`, `trigger_group`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='Blob类型的触发器表'; + +/*Data for the table `qrtz_blob_triggers` */ + +/*Table structure for table `qrtz_calendars` */ + +DROP TABLE IF EXISTS `qrtz_calendars`; + +CREATE TABLE `qrtz_calendars` ( + `sched_name` varchar(120) NOT NULL COMMENT '调度名称', + `calendar_name` varchar(200) NOT NULL COMMENT '日历名称', + `calendar` blob NOT NULL COMMENT '存放持久化calendar对象', + PRIMARY KEY (`sched_name`,`calendar_name`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='日历信息表'; + +/*Data for the table `qrtz_calendars` */ + +/*Table structure for table `qrtz_cron_triggers` */ + +DROP TABLE IF EXISTS `qrtz_cron_triggers`; + +CREATE TABLE `qrtz_cron_triggers` ( + `sched_name` varchar(120) NOT NULL COMMENT '调度名称', + `trigger_name` varchar(200) NOT NULL COMMENT 'qrtz_triggers表trigger_name的外键', + `trigger_group` varchar(200) NOT NULL COMMENT 'qrtz_triggers表trigger_group的外键', + `cron_expression` varchar(200) NOT NULL COMMENT 'cron表达式', + `time_zone_id` varchar(80) DEFAULT NULL COMMENT '时区', + PRIMARY KEY (`sched_name`,`trigger_name`,`trigger_group`), + CONSTRAINT `qrtz_cron_triggers_ibfk_1` FOREIGN KEY (`sched_name`, `trigger_name`, `trigger_group`) REFERENCES `qrtz_triggers` (`sched_name`, `trigger_name`, `trigger_group`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='Cron类型的触发器表'; + +/*Data for the table `qrtz_cron_triggers` */ + +insert into `qrtz_cron_triggers`(`sched_name`,`trigger_name`,`trigger_group`,`cron_expression`,`time_zone_id`) values ('RuoyiScheduler','TASK_CLASS_NAME1','DEFAULT','0/10 * * * * ?','Asia/Shanghai'),('RuoyiScheduler','TASK_CLASS_NAME2','DEFAULT','0/15 * * * * ?','Asia/Shanghai'),('RuoyiScheduler','TASK_CLASS_NAME3','DEFAULT','0/20 * * * * ?','Asia/Shanghai'); + +/*Table structure for table `qrtz_fired_triggers` */ + +DROP TABLE IF EXISTS `qrtz_fired_triggers`; + +CREATE TABLE `qrtz_fired_triggers` ( + `sched_name` varchar(120) NOT NULL COMMENT '调度名称', + `entry_id` varchar(95) NOT NULL COMMENT '调度器实例id', + `trigger_name` varchar(200) NOT NULL COMMENT 'qrtz_triggers表trigger_name的外键', + `trigger_group` varchar(200) NOT NULL COMMENT 'qrtz_triggers表trigger_group的外键', + `instance_name` varchar(200) NOT NULL COMMENT '调度器实例名', + `fired_time` bigint(13) NOT NULL COMMENT '触发的时间', + `sched_time` bigint(13) NOT NULL COMMENT '定时器制定的时间', + `priority` int(11) NOT NULL COMMENT '优先级', + `state` varchar(16) NOT NULL COMMENT '状态', + `job_name` varchar(200) DEFAULT NULL COMMENT '任务名称', + `job_group` varchar(200) DEFAULT NULL COMMENT '任务组名', + `is_nonconcurrent` varchar(1) DEFAULT NULL COMMENT '是否并发', + `requests_recovery` varchar(1) DEFAULT NULL COMMENT '是否接受恢复执行', + PRIMARY KEY (`sched_name`,`entry_id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='已触发的触发器表'; + +/*Data for the table `qrtz_fired_triggers` */ + +/*Table structure for table `qrtz_job_details` */ + +DROP TABLE IF EXISTS `qrtz_job_details`; + +CREATE TABLE `qrtz_job_details` ( + `sched_name` varchar(120) NOT NULL COMMENT '调度名称', + `job_name` varchar(200) NOT NULL COMMENT '任务名称', + `job_group` varchar(200) NOT NULL COMMENT '任务组名', + `description` varchar(250) DEFAULT NULL COMMENT '相关介绍', + `job_class_name` varchar(250) NOT NULL COMMENT '执行任务类名称', + `is_durable` varchar(1) NOT NULL COMMENT '是否持久化', + `is_nonconcurrent` varchar(1) NOT NULL COMMENT '是否并发', + `is_update_data` varchar(1) NOT NULL COMMENT '是否更新数据', + `requests_recovery` varchar(1) NOT NULL COMMENT '是否接受恢复执行', + `job_data` blob COMMENT '存放持久化job对象', + PRIMARY KEY (`sched_name`,`job_name`,`job_group`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='任务详细信息表'; + +/*Data for the table `qrtz_job_details` */ + +insert into `qrtz_job_details`(`sched_name`,`job_name`,`job_group`,`description`,`job_class_name`,`is_durable`,`is_nonconcurrent`,`is_update_data`,`requests_recovery`,`job_data`) values ('RuoyiScheduler','TASK_CLASS_NAME1','DEFAULT',NULL,'com.ruoyi.quartz.util.QuartzDisallowConcurrentExecution','0','1','0','0','\0sr\0org.quartz.JobDataMap迩\0\0xr\0&org.quartz.utils.StringKeyDirtyFlagMap](\0Z\0allowsTransientDataxr\0org.quartz.utils.DirtyFlagMap.(v\n\0Z\0dirtyL\0mapt\0Ljava/util/Map;xpsr\0java.util.HashMap`\0F\0\nloadFactorI\0 thresholdxp?@\0\0\0\0\0 w\0\0\0\0\0\0t\0TASK_PROPERTIESsr\0com.ruoyi.quartz.domain.SysJob\0\0\0\0\0\0\0\0L\0\nconcurrentt\0Ljava/lang/String;L\0cronExpressionq\0~\0 L\0 invokeTargetq\0~\0 L\0jobGroupq\0~\0 L\0jobIdt\0Ljava/lang/Long;L\0jobNameq\0~\0 L\0\rmisfirePolicyq\0~\0 L\0statusq\0~\0 xr\0\'com.ruoyi.common.core.domain.BaseEntity\0\0\0\0\0\0\0\0L\0createByq\0~\0 L\0\ncreateTimet\0Ljava/util/Date;L\0paramsq\0~\0L\0remarkq\0~\0 L\0 searchValueq\0~\0 L\0updateByq\0~\0 L\0\nupdateTimeq\0~\0 xpt\0adminsr\0java.util.DatehjKYt\0\0xpw\0\0|Fxpt\0\0pppt\01t\00/10 * * * * ?t\0ryTask.ryNoParamst\0DEFAULTsr\0java.lang.Long;̏#\0J\0valuexr\0java.lang.Number \0\0xp\0\0\0\0\0\0\0t\0系统默认(无参)t\03t\01x\0'),('RuoyiScheduler','TASK_CLASS_NAME2','DEFAULT',NULL,'com.ruoyi.quartz.util.QuartzDisallowConcurrentExecution','0','1','0','0','\0sr\0org.quartz.JobDataMap迩\0\0xr\0&org.quartz.utils.StringKeyDirtyFlagMap](\0Z\0allowsTransientDataxr\0org.quartz.utils.DirtyFlagMap.(v\n\0Z\0dirtyL\0mapt\0Ljava/util/Map;xpsr\0java.util.HashMap`\0F\0\nloadFactorI\0 thresholdxp?@\0\0\0\0\0 w\0\0\0\0\0\0t\0TASK_PROPERTIESsr\0com.ruoyi.quartz.domain.SysJob\0\0\0\0\0\0\0\0L\0\nconcurrentt\0Ljava/lang/String;L\0cronExpressionq\0~\0 L\0 invokeTargetq\0~\0 L\0jobGroupq\0~\0 L\0jobIdt\0Ljava/lang/Long;L\0jobNameq\0~\0 L\0\rmisfirePolicyq\0~\0 L\0statusq\0~\0 xr\0\'com.ruoyi.common.core.domain.BaseEntity\0\0\0\0\0\0\0\0L\0createByq\0~\0 L\0\ncreateTimet\0Ljava/util/Date;L\0paramsq\0~\0L\0remarkq\0~\0 L\0 searchValueq\0~\0 L\0updateByq\0~\0 L\0\nupdateTimeq\0~\0 xpt\0adminsr\0java.util.DatehjKYt\0\0xpw\0\0|Jxpt\0\0pppt\01t\00/15 * * * * ?t\0ryTask.ryParams(\'ry\')t\0DEFAULTsr\0java.lang.Long;̏#\0J\0valuexr\0java.lang.Number \0\0xp\0\0\0\0\0\0\0t\0系统默认(有参)t\03t\01x\0'),('RuoyiScheduler','TASK_CLASS_NAME3','DEFAULT',NULL,'com.ruoyi.quartz.util.QuartzDisallowConcurrentExecution','0','1','0','0','\0sr\0org.quartz.JobDataMap迩\0\0xr\0&org.quartz.utils.StringKeyDirtyFlagMap](\0Z\0allowsTransientDataxr\0org.quartz.utils.DirtyFlagMap.(v\n\0Z\0dirtyL\0mapt\0Ljava/util/Map;xpsr\0java.util.HashMap`\0F\0\nloadFactorI\0 thresholdxp?@\0\0\0\0\0 w\0\0\0\0\0\0t\0TASK_PROPERTIESsr\0com.ruoyi.quartz.domain.SysJob\0\0\0\0\0\0\0\0L\0\nconcurrentt\0Ljava/lang/String;L\0cronExpressionq\0~\0 L\0 invokeTargetq\0~\0 L\0jobGroupq\0~\0 L\0jobIdt\0Ljava/lang/Long;L\0jobNameq\0~\0 L\0\rmisfirePolicyq\0~\0 L\0statusq\0~\0 xr\0\'com.ruoyi.common.core.domain.BaseEntity\0\0\0\0\0\0\0\0L\0createByq\0~\0 L\0\ncreateTimet\0Ljava/util/Date;L\0paramsq\0~\0L\0remarkq\0~\0 L\0 searchValueq\0~\0 L\0updateByq\0~\0 L\0\nupdateTimeq\0~\0 xpt\0adminsr\0java.util.DatehjKYt\0\0xpw\0\0|Jxpt\0\0pppt\01t\00/20 * * * * ?t\08ryTask.ryMultipleParams(\'ry\', true, 2000L, 316.50D, 100)t\0DEFAULTsr\0java.lang.Long;̏#\0J\0valuexr\0java.lang.Number \0\0xp\0\0\0\0\0\0\0t\0系统默认(多参)t\03t\01x\0'); + +/*Table structure for table `qrtz_locks` */ + +DROP TABLE IF EXISTS `qrtz_locks`; + +CREATE TABLE `qrtz_locks` ( + `sched_name` varchar(120) NOT NULL COMMENT '调度名称', + `lock_name` varchar(40) NOT NULL COMMENT '悲观锁名称', + PRIMARY KEY (`sched_name`,`lock_name`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='存储的悲观锁信息表'; + +/*Data for the table `qrtz_locks` */ + +insert into `qrtz_locks`(`sched_name`,`lock_name`) values ('RuoyiScheduler','STATE_ACCESS'),('RuoyiScheduler','TRIGGER_ACCESS'); + +/*Table structure for table `qrtz_paused_trigger_grps` */ + +DROP TABLE IF EXISTS `qrtz_paused_trigger_grps`; + +CREATE TABLE `qrtz_paused_trigger_grps` ( + `sched_name` varchar(120) NOT NULL COMMENT '调度名称', + `trigger_group` varchar(200) NOT NULL COMMENT 'qrtz_triggers表trigger_group的外键', + PRIMARY KEY (`sched_name`,`trigger_group`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='暂停的触发器表'; + +/*Data for the table `qrtz_paused_trigger_grps` */ + +/*Table structure for table `qrtz_scheduler_state` */ + +DROP TABLE IF EXISTS `qrtz_scheduler_state`; + +CREATE TABLE `qrtz_scheduler_state` ( + `sched_name` varchar(120) NOT NULL COMMENT '调度名称', + `instance_name` varchar(200) NOT NULL COMMENT '实例名称', + `last_checkin_time` bigint(13) NOT NULL COMMENT '上次检查时间', + `checkin_interval` bigint(13) NOT NULL COMMENT '检查间隔时间', + PRIMARY KEY (`sched_name`,`instance_name`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='调度器状态表'; + +/*Data for the table `qrtz_scheduler_state` */ + +insert into `qrtz_scheduler_state`(`sched_name`,`instance_name`,`last_checkin_time`,`checkin_interval`) values ('RuoyiScheduler','DESKTOP-V4I2IAS1642336404267',1642337346063,15000); + +/*Table structure for table `qrtz_simple_triggers` */ + +DROP TABLE IF EXISTS `qrtz_simple_triggers`; + +CREATE TABLE `qrtz_simple_triggers` ( + `sched_name` varchar(120) NOT NULL COMMENT '调度名称', + `trigger_name` varchar(200) NOT NULL COMMENT 'qrtz_triggers表trigger_name的外键', + `trigger_group` varchar(200) NOT NULL COMMENT 'qrtz_triggers表trigger_group的外键', + `repeat_count` bigint(7) NOT NULL COMMENT '重复的次数统计', + `repeat_interval` bigint(12) NOT NULL COMMENT '重复的间隔时间', + `times_triggered` bigint(10) NOT NULL COMMENT '已经触发的次数', + PRIMARY KEY (`sched_name`,`trigger_name`,`trigger_group`), + CONSTRAINT `qrtz_simple_triggers_ibfk_1` FOREIGN KEY (`sched_name`, `trigger_name`, `trigger_group`) REFERENCES `qrtz_triggers` (`sched_name`, `trigger_name`, `trigger_group`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='简单触发器的信息表'; + +/*Data for the table `qrtz_simple_triggers` */ + +/*Table structure for table `qrtz_simprop_triggers` */ + +DROP TABLE IF EXISTS `qrtz_simprop_triggers`; + +CREATE TABLE `qrtz_simprop_triggers` ( + `sched_name` varchar(120) NOT NULL COMMENT '调度名称', + `trigger_name` varchar(200) NOT NULL COMMENT 'qrtz_triggers表trigger_name的外键', + `trigger_group` varchar(200) NOT NULL COMMENT 'qrtz_triggers表trigger_group的外键', + `str_prop_1` varchar(512) DEFAULT NULL COMMENT 'String类型的trigger的第一个参数', + `str_prop_2` varchar(512) DEFAULT NULL COMMENT 'String类型的trigger的第二个参数', + `str_prop_3` varchar(512) DEFAULT NULL COMMENT 'String类型的trigger的第三个参数', + `int_prop_1` int(11) DEFAULT NULL COMMENT 'int类型的trigger的第一个参数', + `int_prop_2` int(11) DEFAULT NULL COMMENT 'int类型的trigger的第二个参数', + `long_prop_1` bigint(20) DEFAULT NULL COMMENT 'long类型的trigger的第一个参数', + `long_prop_2` bigint(20) DEFAULT NULL COMMENT 'long类型的trigger的第二个参数', + `dec_prop_1` decimal(13,4) DEFAULT NULL COMMENT 'decimal类型的trigger的第一个参数', + `dec_prop_2` decimal(13,4) DEFAULT NULL COMMENT 'decimal类型的trigger的第二个参数', + `bool_prop_1` varchar(1) DEFAULT NULL COMMENT 'Boolean类型的trigger的第一个参数', + `bool_prop_2` varchar(1) DEFAULT NULL COMMENT 'Boolean类型的trigger的第二个参数', + PRIMARY KEY (`sched_name`,`trigger_name`,`trigger_group`), + CONSTRAINT `qrtz_simprop_triggers_ibfk_1` FOREIGN KEY (`sched_name`, `trigger_name`, `trigger_group`) REFERENCES `qrtz_triggers` (`sched_name`, `trigger_name`, `trigger_group`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='同步机制的行锁表'; + +/*Data for the table `qrtz_simprop_triggers` */ + +/*Table structure for table `qrtz_triggers` */ + +DROP TABLE IF EXISTS `qrtz_triggers`; + +CREATE TABLE `qrtz_triggers` ( + `sched_name` varchar(120) NOT NULL COMMENT '调度名称', + `trigger_name` varchar(200) NOT NULL COMMENT '触发器的名字', + `trigger_group` varchar(200) NOT NULL COMMENT '触发器所属组的名字', + `job_name` varchar(200) NOT NULL COMMENT 'qrtz_job_details表job_name的外键', + `job_group` varchar(200) NOT NULL COMMENT 'qrtz_job_details表job_group的外键', + `description` varchar(250) DEFAULT NULL COMMENT '相关介绍', + `next_fire_time` bigint(13) DEFAULT NULL COMMENT '上一次触发时间(毫秒)', + `prev_fire_time` bigint(13) DEFAULT NULL COMMENT '下一次触发时间(默认为-1表示不触发)', + `priority` int(11) DEFAULT NULL COMMENT '优先级', + `trigger_state` varchar(16) NOT NULL COMMENT '触发器状态', + `trigger_type` varchar(8) NOT NULL COMMENT '触发器的类型', + `start_time` bigint(13) NOT NULL COMMENT '开始时间', + `end_time` bigint(13) DEFAULT NULL COMMENT '结束时间', + `calendar_name` varchar(200) DEFAULT NULL COMMENT '日程表名称', + `misfire_instr` smallint(2) DEFAULT NULL COMMENT '补偿执行的策略', + `job_data` blob COMMENT '存放持久化job对象', + PRIMARY KEY (`sched_name`,`trigger_name`,`trigger_group`), + KEY `sched_name` (`sched_name`,`job_name`,`job_group`), + CONSTRAINT `qrtz_triggers_ibfk_1` FOREIGN KEY (`sched_name`, `job_name`, `job_group`) REFERENCES `qrtz_job_details` (`sched_name`, `job_name`, `job_group`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='触发器详细信息表'; + +/*Data for the table `qrtz_triggers` */ + +insert into `qrtz_triggers`(`sched_name`,`trigger_name`,`trigger_group`,`job_name`,`job_group`,`description`,`next_fire_time`,`prev_fire_time`,`priority`,`trigger_state`,`trigger_type`,`start_time`,`end_time`,`calendar_name`,`misfire_instr`,`job_data`) values ('RuoyiScheduler','TASK_CLASS_NAME1','DEFAULT','TASK_CLASS_NAME1','DEFAULT',NULL,1642336410000,-1,5,'PAUSED','CRON',1642336404000,0,NULL,2,''),('RuoyiScheduler','TASK_CLASS_NAME2','DEFAULT','TASK_CLASS_NAME2','DEFAULT',NULL,1642336410000,-1,5,'PAUSED','CRON',1642336405000,0,NULL,2,''),('RuoyiScheduler','TASK_CLASS_NAME3','DEFAULT','TASK_CLASS_NAME3','DEFAULT',NULL,1642336420000,-1,5,'PAUSED','CRON',1642336406000,0,NULL,2,''); + +/*Table structure for table `sys_config` */ + +DROP TABLE IF EXISTS `sys_config`; + +CREATE TABLE `sys_config` ( + `config_id` int(5) NOT NULL AUTO_INCREMENT COMMENT '参数主键', + `config_name` varchar(100) DEFAULT '' COMMENT '参数名称', + `config_key` varchar(100) DEFAULT '' COMMENT '参数键名', + `config_value` varchar(500) DEFAULT '' COMMENT '参数键值', + `config_type` char(1) DEFAULT 'N' COMMENT '系统内置(Y是 N否)', + `create_by` varchar(64) DEFAULT '' COMMENT '创建者', + `create_time` datetime DEFAULT NULL COMMENT '创建时间', + `update_by` varchar(64) DEFAULT '' COMMENT '更新者', + `update_time` datetime DEFAULT NULL COMMENT '更新时间', + `remark` varchar(500) DEFAULT NULL COMMENT '备注', + `tenant_id` varchar(8) NOT NULL DEFAULT '00000000', + PRIMARY KEY (`config_id`) +) ENGINE=InnoDB AUTO_INCREMENT=100 DEFAULT CHARSET=utf8mb4 COMMENT='参数配置表'; + +/*Data for the table `sys_config` */ + +insert into `sys_config`(`config_id`,`config_name`,`config_key`,`config_value`,`config_type`,`create_by`,`create_time`,`update_by`,`update_time`,`remark`,`tenant_id`) values (1,'主框架页-默认皮肤样式名称','sys.index.skinName','skin-blue','Y','admin','2021-09-21 17:02:04','',NULL,'蓝色 skin-blue、绿色 skin-green、紫色 skin-purple、红色 skin-red、黄色 skin-yellow','00000000'),(2,'用户管理-账号初始密码','sys.user.initPassword','123456','Y','admin','2021-09-21 17:02:04','',NULL,'初始化密码 123456','00000000'),(3,'主框架页-侧边栏主题','sys.index.sideTheme','theme-dark','Y','admin','2021-09-21 17:02:05','',NULL,'深色主题theme-dark,浅色主题theme-light','00000000'),(4,'账号自助-验证码开关','sys.account.captchaOnOff','true','Y','admin','2021-09-21 17:02:05','',NULL,'是否开启验证码功能(true开启,false关闭)','00000000'),(5,'账号自助-是否开启用户注册功能','sys.account.registerUser','false','Y','admin','2021-09-21 17:02:05','',NULL,'是否开启注册用户功能(true开启,false关闭)','00000000'); + +/*Table structure for table `sys_data_rule` */ + +DROP TABLE IF EXISTS `sys_data_rule`; + +CREATE TABLE `sys_data_rule` ( + `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键', + `resource_code` varchar(255) NOT NULL COMMENT '资源编号', + `scope_name` varchar(255) NOT NULL COMMENT '数据权限名称', + `scope_field` varchar(255) NOT NULL COMMENT '数据权限字段', + `scope_class` varchar(500) NOT NULL COMMENT '数据权限类名', + `scope_column` varchar(255) NOT NULL COMMENT '数据权限字段', + `scope_type` int(2) NOT NULL COMMENT '数据权限类型', + `scope_value` varchar(2000) DEFAULT NULL COMMENT '数据权限值域', + `remark` varchar(255) DEFAULT NULL COMMENT '数据权限备注', + `create_by` varchar(64) DEFAULT NULL COMMENT '创建人', + `create_time` datetime DEFAULT NULL COMMENT '创建时间', + `update_by` varchar(64) DEFAULT NULL COMMENT '修改人', + `update_time` datetime DEFAULT NULL COMMENT '修改时间', + `del_flag` int(2) DEFAULT NULL COMMENT '是否已删除', + `table_name` varchar(64) DEFAULT NULL COMMENT '数据库表', + `user_column` varchar(64) DEFAULT NULL COMMENT '用户表对应字段', + `tenant_id` varchar(64) NOT NULL DEFAULT '00000000' COMMENT '租户ID', + `user_entity_field` varchar(64) DEFAULT NULL COMMENT 'user实体类对应字段', + PRIMARY KEY (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COMMENT='数据权限表'; + +/*Data for the table `sys_data_rule` */ + +insert into `sys_data_rule`(`id`,`resource_code`,`scope_name`,`scope_field`,`scope_class`,`scope_column`,`scope_type`,`scope_value`,`remark`,`create_by`,`create_time`,`update_by`,`update_time`,`del_flag`,`table_name`,`user_column`,`tenant_id`,`user_entity_field`) values (1,'expandTable','test1','*','com.ruoyi.web.demo.expandtable.mapper.ExpandTableMapper.selectPage','dept_id',4,NULL,NULL,'4028ea815a3d2a8c015a3d2f8d2a0002','2019-12-03 07:30:19','4028ea815a3d2a8c015a3d2f8d2a0002','2020-05-29 22:54:32',0,'sys_dept','organizationId','00000000',NULL),(2,'table','test','id,title,author,type,level,content,`user.realname`,`user.username`,status','com.ruoyi.web.demo.table.mapper.TableMapper.selectPage','author',2,NULL,NULL,'4028ea815a3d2a8c015a3d2f8d2a0002','2019-11-29 15:18:25','4028ea815a3d2a8c015a3d2f8d2a0002','2020-10-31 12:01:59',0,'sys_dept','organization_id','00000000','dept_id'); + +/*Table structure for table `sys_dept` */ + +DROP TABLE IF EXISTS `sys_dept`; + +CREATE TABLE `sys_dept` ( + `dept_id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '部门id', + `parent_id` bigint(20) DEFAULT '0' COMMENT '父部门id', + `ancestors` varchar(50) DEFAULT '' COMMENT '祖级列表', + `dept_name` varchar(30) DEFAULT '' COMMENT '部门名称', + `order_num` int(4) DEFAULT '0' COMMENT '显示顺序', + `leader` varchar(20) DEFAULT NULL COMMENT '负责人', + `phone` varchar(11) DEFAULT NULL COMMENT '联系电话', + `email` varchar(50) DEFAULT NULL COMMENT '邮箱', + `status` char(1) DEFAULT '0' COMMENT '部门状态(0正常 1停用)', + `del_flag` char(1) DEFAULT '0' COMMENT '删除标志(0代表存在 2代表删除)', + `create_by` varchar(64) DEFAULT '' COMMENT '创建者', + `create_time` datetime DEFAULT NULL COMMENT '创建时间', + `update_by` varchar(64) DEFAULT '' COMMENT '更新者', + `update_time` datetime DEFAULT NULL COMMENT '更新时间', + `tenant_id` varchar(8) NOT NULL DEFAULT '00000000', + PRIMARY KEY (`dept_id`) +) ENGINE=InnoDB AUTO_INCREMENT=206 DEFAULT CHARSET=utf8mb4 COMMENT='部门表'; + +/*Data for the table `sys_dept` */ + +insert into `sys_dept`(`dept_id`,`parent_id`,`ancestors`,`dept_name`,`order_num`,`leader`,`phone`,`email`,`status`,`del_flag`,`create_by`,`create_time`,`update_by`,`update_time`,`tenant_id`) values (100,0,'0','若依科技',0,'若依','15888888888','ry@qq.com','0','0','admin','2021-09-21 17:00:30','',NULL,'00000000'),(101,100,'0,100','深圳总公司',1,'若依','15888888888','ry@qq.com','0','0','admin','2021-09-21 17:00:31','',NULL,'00000000'),(102,100,'0,100','长沙分公司',2,'若依','15888888888','ry@qq.com','0','0','admin','2021-09-21 17:00:31','',NULL,'00000000'),(103,101,'0,100,101','研发部门',1,'若依','15888888888','ry@qq.com','0','0','admin','2021-09-21 17:00:31','',NULL,'00000000'),(104,101,'0,100,101','市场部门',2,'若依','15888888888','ry@qq.com','0','0','admin','2021-09-21 17:00:32','',NULL,'00000000'),(105,101,'0,100,101','测试部门',3,'若依','15888888888','ry@qq.com','0','0','admin','2021-09-21 17:00:32','',NULL,'00000000'),(106,101,'0,100,101','财务部门',4,'若依','15888888888','ry@qq.com','0','0','admin','2021-09-21 17:00:33','',NULL,'00000000'),(107,101,'0,100,101','运维部门',5,'若依','15888888888','ry@qq.com','0','0','admin','2021-09-21 17:00:33','',NULL,'00000000'),(108,102,'0,100,102','市场部门',1,'若依','15888888888','ry@qq.com','0','0','admin','2021-09-21 17:00:33','',NULL,'00000000'),(109,102,'0,100,102','财务部门',2,'若依','15888888888','ry@qq.com','0','0','admin','2021-09-21 17:00:34','',NULL,'00000000'),(203,0,'0','Ruoyi-Vue-S',0,NULL,NULL,NULL,'0','0','','2021-10-12 15:56:31','',NULL,'48927269'),(204,203,'0,203','研发部门',0,NULL,NULL,NULL,'0','0','ruoyi','2021-10-19 15:16:37','',NULL,'48927269'),(205,0,'0,','测试',0,NULL,NULL,NULL,'0','0','','2021-11-11 10:37:56','',NULL,'15839669'); + +/*Table structure for table `sys_dict_data` */ + +DROP TABLE IF EXISTS `sys_dict_data`; + +CREATE TABLE `sys_dict_data` ( + `dict_code` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '字典编码', + `dict_sort` int(4) DEFAULT '0' COMMENT '字典排序', + `dict_label` varchar(100) DEFAULT '' COMMENT '字典标签', + `dict_value` varchar(100) DEFAULT '' COMMENT '字典键值', + `dict_type` varchar(100) DEFAULT '' COMMENT '字典类型', + `css_class` varchar(100) DEFAULT NULL COMMENT '样式属性(其他样式扩展)', + `list_class` varchar(100) DEFAULT NULL COMMENT '表格回显样式', + `is_default` char(1) DEFAULT 'N' COMMENT '是否默认(Y是 N否)', + `status` char(1) DEFAULT '0' COMMENT '状态(0正常 1停用)', + `create_by` varchar(64) DEFAULT '' COMMENT '创建者', + `create_time` datetime DEFAULT NULL COMMENT '创建时间', + `update_by` varchar(64) DEFAULT '' COMMENT '更新者', + `update_time` datetime DEFAULT NULL COMMENT '更新时间', + `remark` varchar(500) DEFAULT NULL COMMENT '备注', + `tenant_id` varchar(8) NOT NULL DEFAULT '00000000', + PRIMARY KEY (`dict_code`) +) ENGINE=InnoDB AUTO_INCREMENT=105 DEFAULT CHARSET=utf8mb4 COMMENT='字典数据表'; + +/*Data for the table `sys_dict_data` */ + +insert into `sys_dict_data`(`dict_code`,`dict_sort`,`dict_label`,`dict_value`,`dict_type`,`css_class`,`list_class`,`is_default`,`status`,`create_by`,`create_time`,`update_by`,`update_time`,`remark`,`tenant_id`) values (1,1,'男','0','sys_user_sex','','','Y','0','admin','2021-09-21 17:01:53','',NULL,'性别男','00000000'),(2,2,'女','1','sys_user_sex','','','N','0','admin','2021-09-21 17:01:53','',NULL,'性别女','00000000'),(3,3,'未知','2','sys_user_sex','','','N','0','admin','2021-09-21 17:01:54','',NULL,'性别未知','00000000'),(4,1,'显示','0','sys_show_hide','','primary','Y','0','admin','2021-09-21 17:01:54','',NULL,'显示菜单','00000000'),(5,2,'隐藏','1','sys_show_hide','','danger','N','0','admin','2021-09-21 17:01:54','',NULL,'隐藏菜单','00000000'),(6,1,'正常','0','sys_normal_disable','','primary','Y','0','admin','2021-09-21 17:01:55','',NULL,'正常状态','00000000'),(7,2,'停用','1','sys_normal_disable','','danger','N','0','admin','2021-09-21 17:01:55','',NULL,'停用状态','00000000'),(8,1,'正常','0','sys_job_status','','primary','Y','0','admin','2021-09-21 17:01:55','',NULL,'正常状态','00000000'),(9,2,'暂停','1','sys_job_status','','danger','N','0','admin','2021-09-21 17:01:56','',NULL,'停用状态','00000000'),(10,1,'默认','DEFAULT','sys_job_group','','','Y','0','admin','2021-09-21 17:01:56','',NULL,'默认分组','00000000'),(11,2,'系统','SYSTEM','sys_job_group','','','N','0','admin','2021-09-21 17:01:56','',NULL,'系统分组','00000000'),(12,1,'是','Y','sys_yes_no','','primary','Y','0','admin','2021-09-21 17:01:57','',NULL,'系统默认是','00000000'),(13,2,'否','N','sys_yes_no','','danger','N','0','admin','2021-09-21 17:01:57','',NULL,'系统默认否','00000000'),(14,1,'通知','1','sys_notice_type','','warning','Y','0','admin','2021-09-21 17:01:58','',NULL,'通知','00000000'),(15,2,'公告','2','sys_notice_type','','success','N','0','admin','2021-09-21 17:01:58','',NULL,'公告','00000000'),(16,1,'正常','0','sys_notice_status','','primary','Y','0','admin','2021-09-21 17:01:58','',NULL,'正常状态','00000000'),(17,2,'关闭','1','sys_notice_status','','danger','N','0','admin','2021-09-21 17:01:59','',NULL,'关闭状态','00000000'),(18,1,'新增','1','sys_oper_type','','info','N','0','admin','2021-09-21 17:01:59','',NULL,'新增操作','00000000'),(19,2,'修改','2','sys_oper_type','','info','N','0','admin','2021-09-21 17:01:59','',NULL,'修改操作','00000000'),(20,3,'删除','3','sys_oper_type','','danger','N','0','admin','2021-09-21 17:02:00','',NULL,'删除操作','00000000'),(21,4,'授权','4','sys_oper_type','','primary','N','0','admin','2021-09-21 17:02:00','',NULL,'授权操作','00000000'),(22,5,'导出','5','sys_oper_type','','warning','N','0','admin','2021-09-21 17:02:01','',NULL,'导出操作','00000000'),(23,6,'导入','6','sys_oper_type','','warning','N','0','admin','2021-09-21 17:02:01','',NULL,'导入操作','00000000'),(24,7,'强退','7','sys_oper_type','','danger','N','0','admin','2021-09-21 17:02:01','',NULL,'强退操作','00000000'),(25,8,'生成代码','8','sys_oper_type','','warning','N','0','admin','2021-09-21 17:02:02','',NULL,'生成操作','00000000'),(26,9,'清空数据','9','sys_oper_type','','danger','N','0','admin','2021-09-21 17:02:02','',NULL,'清空操作','00000000'),(27,1,'成功','0','sys_common_status','','primary','N','0','admin','2021-09-21 17:02:02','',NULL,'正常状态','00000000'),(28,2,'失败','1','sys_common_status','','danger','N','0','admin','2021-09-21 17:02:03','',NULL,'停用状态','00000000'),(100,1,'全部','1','data_rule_type',NULL,'default','N','0','admin','2021-10-24 20:08:27','admin','2021-10-24 20:10:36',NULL,'00000000'),(101,2,'本人可见','2','data_rule_type',NULL,'default','N','0','admin','2021-10-24 20:08:47','admin','2021-10-24 20:09:58',NULL,'00000000'),(102,3,'所在机构可见','3','data_rule_type',NULL,'default','N','0','admin','2021-10-24 20:09:34','admin','2021-10-24 20:10:46',NULL,'00000000'),(103,4,'所在机构及子级可见','4','data_rule_type',NULL,'default','N','0','admin','2021-10-24 20:10:15','admin','2021-10-24 20:10:40',NULL,'00000000'),(104,5,'自定义','5','data_rule_type',NULL,'default','N','0','admin','2021-10-24 20:10:27','',NULL,NULL,'00000000'); + +/*Table structure for table `sys_dict_type` */ + +DROP TABLE IF EXISTS `sys_dict_type`; + +CREATE TABLE `sys_dict_type` ( + `dict_id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '字典主键', + `dict_name` varchar(100) DEFAULT '' COMMENT '字典名称', + `dict_type` varchar(100) DEFAULT '' COMMENT '字典类型', + `status` char(1) DEFAULT '0' COMMENT '状态(0正常 1停用)', + `create_by` varchar(64) DEFAULT '' COMMENT '创建者', + `create_time` datetime DEFAULT NULL COMMENT '创建时间', + `update_by` varchar(64) DEFAULT '' COMMENT '更新者', + `update_time` datetime DEFAULT NULL COMMENT '更新时间', + `remark` varchar(500) DEFAULT NULL COMMENT '备注', + `tenant_id` varchar(8) NOT NULL DEFAULT '00000000', + PRIMARY KEY (`dict_id`), + UNIQUE KEY `dict_type` (`dict_type`) +) ENGINE=InnoDB AUTO_INCREMENT=101 DEFAULT CHARSET=utf8mb4 COMMENT='字典类型表'; + +/*Data for the table `sys_dict_type` */ + +insert into `sys_dict_type`(`dict_id`,`dict_name`,`dict_type`,`status`,`create_by`,`create_time`,`update_by`,`update_time`,`remark`,`tenant_id`) values (1,'用户性别','sys_user_sex','0','admin','2021-09-21 17:01:49','',NULL,'用户性别列表','00000000'),(2,'菜单状态','sys_show_hide','0','admin','2021-09-21 17:01:49','',NULL,'菜单状态列表','00000000'),(3,'系统开关','sys_normal_disable','0','admin','2021-09-21 17:01:49','',NULL,'系统开关列表','00000000'),(4,'任务状态','sys_job_status','0','admin','2021-09-21 17:01:50','',NULL,'任务状态列表','00000000'),(5,'任务分组','sys_job_group','0','admin','2021-09-21 17:01:50','',NULL,'任务分组列表','00000000'),(6,'系统是否','sys_yes_no','0','admin','2021-09-21 17:01:50','',NULL,'系统是否列表','00000000'),(7,'通知类型','sys_notice_type','0','admin','2021-09-21 17:01:51','',NULL,'通知类型列表','00000000'),(8,'通知状态','sys_notice_status','0','admin','2021-09-21 17:01:51','',NULL,'通知状态列表','00000000'),(9,'操作类型','sys_oper_type','0','admin','2021-09-21 17:01:51','',NULL,'操作类型列表','00000000'),(10,'系统状态','sys_common_status','0','admin','2021-09-21 17:01:52','',NULL,'登录状态列表','00000000'),(100,'数据权限类型','data_rule_type','0','admin','2021-10-24 20:07:28','',NULL,NULL,'00000000'); + +/*Table structure for table `sys_job` */ + +DROP TABLE IF EXISTS `sys_job`; + +CREATE TABLE `sys_job` ( + `job_id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '任务ID', + `job_name` varchar(64) NOT NULL DEFAULT '' COMMENT '任务名称', + `job_group` varchar(64) NOT NULL DEFAULT 'DEFAULT' COMMENT '任务组名', + `invoke_target` varchar(500) NOT NULL COMMENT '调用目标字符串', + `cron_expression` varchar(255) DEFAULT '' COMMENT 'cron执行表达式', + `misfire_policy` varchar(20) DEFAULT '3' COMMENT '计划执行错误策略(1立即执行 2执行一次 3放弃执行)', + `concurrent` char(1) DEFAULT '1' COMMENT '是否并发执行(0允许 1禁止)', + `status` char(1) DEFAULT '0' COMMENT '状态(0正常 1暂停)', + `create_by` varchar(64) DEFAULT '' COMMENT '创建者', + `create_time` datetime DEFAULT NULL COMMENT '创建时间', + `update_by` varchar(64) DEFAULT '' COMMENT '更新者', + `update_time` datetime DEFAULT NULL COMMENT '更新时间', + `remark` varchar(500) DEFAULT '' COMMENT '备注信息', + `tenant_id` varchar(8) NOT NULL DEFAULT '00000000', + PRIMARY KEY (`job_id`,`job_name`,`job_group`) +) ENGINE=InnoDB AUTO_INCREMENT=100 DEFAULT CHARSET=utf8mb4 COMMENT='定时任务调度表'; + +/*Data for the table `sys_job` */ + +insert into `sys_job`(`job_id`,`job_name`,`job_group`,`invoke_target`,`cron_expression`,`misfire_policy`,`concurrent`,`status`,`create_by`,`create_time`,`update_by`,`update_time`,`remark`,`tenant_id`) values (1,'系统默认(无参)','DEFAULT','ryTask.ryNoParams','0/10 * * * * ?','3','1','1','admin','2021-09-21 17:02:07','',NULL,'','00000000'),(2,'系统默认(有参)','DEFAULT','ryTask.ryParams(\'ry\')','0/15 * * * * ?','3','1','1','admin','2021-09-21 17:02:08','',NULL,'','00000000'),(3,'系统默认(多参)','DEFAULT','ryTask.ryMultipleParams(\'ry\', true, 2000L, 316.50D, 100)','0/20 * * * * ?','3','1','1','admin','2021-09-21 17:02:08','',NULL,'','00000000'); + +/*Table structure for table `sys_job_log` */ + +DROP TABLE IF EXISTS `sys_job_log`; + +CREATE TABLE `sys_job_log` ( + `job_log_id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '任务日志ID', + `job_name` varchar(64) NOT NULL COMMENT '任务名称', + `job_group` varchar(64) NOT NULL COMMENT '任务组名', + `invoke_target` varchar(500) NOT NULL COMMENT '调用目标字符串', + `job_message` varchar(500) DEFAULT NULL COMMENT '日志信息', + `status` char(1) DEFAULT '0' COMMENT '执行状态(0正常 1失败)', + `exception_info` varchar(2000) DEFAULT '' COMMENT '异常信息', + `create_time` datetime DEFAULT NULL COMMENT '创建时间', + `tenant_id` varchar(8) NOT NULL DEFAULT '00000000', + PRIMARY KEY (`job_log_id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='定时任务调度日志表'; + +/*Data for the table `sys_job_log` */ + +/*Table structure for table `sys_logininfor` */ + +DROP TABLE IF EXISTS `sys_logininfor`; + +CREATE TABLE `sys_logininfor` ( + `info_id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '访问ID', + `user_name` varchar(50) DEFAULT '' COMMENT '用户账号', + `ipaddr` varchar(128) DEFAULT '' COMMENT '登录IP地址', + `login_location` varchar(255) DEFAULT '' COMMENT '登录地点', + `browser` varchar(50) DEFAULT '' COMMENT '浏览器类型', + `os` varchar(50) DEFAULT '' COMMENT '操作系统', + `status` char(1) DEFAULT '0' COMMENT '登录状态(0成功 1失败)', + `msg` text COMMENT '提示消息', + `login_time` datetime DEFAULT NULL COMMENT '访问时间', + `tenant_id` varchar(8) NOT NULL DEFAULT '00000000', + PRIMARY KEY (`info_id`) +) ENGINE=InnoDB AUTO_INCREMENT=262 DEFAULT CHARSET=utf8mb4 COMMENT='系统访问记录'; + +/*Data for the table `sys_logininfor` */ + +insert into `sys_logininfor`(`info_id`,`user_name`,`ipaddr`,`login_location`,`browser`,`os`,`status`,`msg`,`login_time`,`tenant_id`) values (100,'admin','127.0.0.1','内网IP','Chrome 9','Windows 10','0','登录成功','2021-09-21 17:04:41','00000000'),(101,'admin','127.0.0.1','内网IP','Chrome 9','Windows 10','1','验证码已失效','2021-09-21 17:09:21','00000000'),(102,'admin','127.0.0.1','内网IP','Chrome 9','Windows 10','0','登录成功','2021-09-21 17:09:27','00000000'),(103,'admin','127.0.0.1','内网IP','Chrome 9','Windows 10','0','登录成功','2021-09-21 18:03:06','00000000'),(104,'admin','127.0.0.1','内网IP','Chrome 9','Windows 10','0','登录成功','2021-10-08 14:38:59','00000000'),(105,'admin','127.0.0.1','内网IP','Chrome 9','Windows 10','0','登录成功','2021-10-08 14:39:09','00000000'),(106,'admin','127.0.0.1','内网IP','Chrome 9','Windows 10','1','验证码已失效','2021-10-08 14:44:54','00000000'),(107,'admin','127.0.0.1','内网IP','Chrome 9','Windows 10','0','登录成功','2021-10-08 14:44:59','00000000'),(108,'admin','127.0.0.1','内网IP','Chrome 9','Windows 10','0','登录成功','2021-10-08 14:50:49','00000000'),(109,'admin','127.0.0.1','内网IP','Chrome 9','Windows 10','0','登录成功','2021-10-09 09:38:46','00000000'),(110,'admin','127.0.0.1','内网IP','Chrome 9','Windows 10','1','验证码已失效','2021-10-09 12:03:11','00000000'),(111,'admin','127.0.0.1','内网IP','Chrome 9','Windows 10','0','登录成功','2021-10-09 12:03:15','00000000'),(112,'admin','127.0.0.1','内网IP','Chrome 8','Windows 10','0','登录成功','2021-10-10 12:58:40','00000000'),(113,'admin','127.0.0.1','内网IP','Chrome 8','Windows 10','1','验证码已失效','2021-10-10 14:45:29','00000000'),(114,'admin','127.0.0.1','内网IP','Chrome 8','Windows 10','1','验证码错误','2021-10-10 14:45:33','00000000'),(115,'admin','127.0.0.1','内网IP','Chrome 8','Windows 10','0','登录成功','2021-10-10 14:45:38','00000000'),(116,'admin','127.0.0.1','内网IP','Chrome 8','Windows 10','1','nested exception is org.apache.ibatis.exceptions.PersistenceException: \r\n### Error querying database. Cause: com.ruoyi.common.exception.ServiceException: 获取用户信息异常\r\n### Cause: com.ruoyi.common.exception.ServiceException: 获取用户信息异常','2021-10-10 15:55:38','00000000'),(117,'admin','127.0.0.1','内网IP','Chrome 8','Windows 10','1','nested exception is org.apache.ibatis.exceptions.PersistenceException: \r\n### Error querying database. Cause: com.ruoyi.common.exception.ServiceException: 获取用户信息异常\r\n### Cause: com.ruoyi.common.exception.ServiceException: 获取用户信息异常','2021-10-10 15:55:42','00000000'),(118,'admin','127.0.0.1','内网IP','Chrome 8','Windows 10','1','验证码错误','2021-10-10 15:55:47','00000000'),(119,'admin','127.0.0.1','内网IP','Chrome 8','Windows 10','1','nested exception is org.apache.ibatis.exceptions.PersistenceException: \r\n### Error querying database. Cause: com.ruoyi.common.exception.ServiceException: 获取用户信息异常\r\n### Cause: com.ruoyi.common.exception.ServiceException: 获取用户信息异常','2021-10-10 15:55:50','00000000'),(120,'admin','127.0.0.1','内网IP','Chrome 8','Windows 10','1','nested exception is org.apache.ibatis.exceptions.PersistenceException: \r\n### Error querying database. Cause: com.ruoyi.common.exception.ServiceException: 获取用户信息异常\r\n### Cause: com.ruoyi.common.exception.ServiceException: 获取用户信息异常','2021-10-10 15:57:14','00000000'),(121,'admin','127.0.0.1','内网IP','Chrome 8','Windows 10','1','nested exception is org.apache.ibatis.exceptions.PersistenceException: \r\n### Error querying database. Cause: com.ruoyi.common.exception.ServiceException: 获取用户信息异常\r\n### Cause: com.ruoyi.common.exception.ServiceException: 获取用户信息异常','2021-10-10 15:58:50','00000000'),(122,'admin','127.0.0.1','内网IP','Chrome 8','Windows 10','1','nested exception is org.apache.ibatis.exceptions.PersistenceException: \r\n### Error querying database. Cause: com.ruoyi.common.exception.ServiceException: 获取用户信息异常\r\n### Cause: com.ruoyi.common.exception.ServiceException: 获取用户信息异常','2021-10-10 15:58:56','00000000'),(123,'admin','127.0.0.1','内网IP','Chrome 8','Windows 10','1','nested exception is org.apache.ibatis.exceptions.PersistenceException: \r\n### Error querying database. Cause: com.ruoyi.common.exception.ServiceException: 获取用户信息异常\r\n### Cause: com.ruoyi.common.exception.ServiceException: 获取用户信息异常','2021-10-10 15:59:38','00000000'),(124,'admin','127.0.0.1','内网IP','Chrome 9','Windows 10','1','nested exception is org.apache.ibatis.exceptions.PersistenceException: \r\n### Error querying database. Cause: com.ruoyi.common.exception.ServiceException: 获取用户信息异常\r\n### Cause: com.ruoyi.common.exception.ServiceException: 获取用户信息异常','2021-10-10 16:01:12','00000000'),(125,'admin','127.0.0.1','内网IP','Chrome 9','Windows 10','0','登录成功','2021-10-10 16:02:32','00000000'),(126,'admin','127.0.0.1','内网IP','Chrome 9','Windows 10','1','验证码错误','2021-10-10 16:02:52','00000000'),(127,'admin','127.0.0.1','内网IP','Chrome 9','Windows 10','0','登录成功','2021-10-10 16:02:57','00000000'),(128,'admin','127.0.0.1','内网IP','Chrome 9','Windows 10','0','登录成功','2021-10-11 21:31:19','00000000'),(129,'admin','127.0.0.1','内网IP','Chrome 8','Windows 10','0','登录成功','2021-10-11 22:30:43','00000000'),(130,'admin','127.0.0.1','内网IP','Chrome 9','Windows 10','0','登录成功','2021-10-11 23:18:16','00000000'),(131,'admin','127.0.0.1','内网IP','Chrome 9','Windows 10','0','登录成功','2021-10-12 14:35:51','00000000'),(132,'admin','127.0.0.1','内网IP','Chrome 9','Windows 10','0','登录成功','2021-10-12 17:29:00','00000000'),(133,'admin','127.0.0.1','内网IP','Chrome 9','Windows 10','0','退出成功','2021-10-12 18:07:11','00000000'),(134,'ruoyi','127.0.0.1','内网IP','Chrome 9','Windows 10','0','登录成功','2021-10-12 18:07:20','00000000'),(135,'ruoyi','127.0.0.1','内网IP','Chrome 9','Windows 10','0','退出成功','2021-10-12 18:07:21','00000000'),(136,'ruoyi','127.0.0.1','内网IP','Chrome 9','Windows 10','1','nested exception is org.apache.ibatis.exceptions.PersistenceException: \r\n### Error querying database. Cause: com.ruoyi.common.exception.ServiceException: 获取用户信息异常\r\n### The error may exist in file [D:\\code\\research\\RuoYi-Vue-S\\ruoyi-system\\target\\classes\\mapper\\system\\SysUserMapper.xml]\r\n### The error may involve com.ruoyi.system.mapper.SysUserMapper.selectUserByUserName\r\n### The error occurred while executing a query\r\n### Cause: com.ruoyi.common.exception.ServiceException: 获取用户信息异常','2021-10-19 14:18:44','00000000'),(137,'ruoyi','127.0.0.1','内网IP','Chrome 9','Windows 10','1','nested exception is org.apache.ibatis.exceptions.PersistenceException: \r\n### Error querying database. Cause: com.ruoyi.common.exception.ServiceException: 获取用户信息异常\r\n### The error may exist in file [D:\\code\\research\\RuoYi-Vue-S\\ruoyi-system\\target\\classes\\mapper\\system\\SysUserMapper.xml]\r\n### The error may involve com.ruoyi.system.mapper.SysUserMapper.selectUserByUserName\r\n### The error occurred while executing a query\r\n### Cause: com.ruoyi.common.exception.ServiceException: 获取用户信息异常','2021-10-19 14:24:45','00000000'),(138,'admin','127.0.0.1','内网IP','Chrome 9','Windows 10','1','nested exception is org.apache.ibatis.exceptions.PersistenceException: \r\n### Error querying database. Cause: com.ruoyi.common.exception.ServiceException: 获取用户信息异常\r\n### The error may exist in file [D:\\code\\research\\RuoYi-Vue-S\\ruoyi-system\\target\\classes\\mapper\\system\\SysUserMapper.xml]\r\n### The error may involve com.ruoyi.system.mapper.SysUserMapper.selectUserByUserName\r\n### The error occurred while executing a query\r\n### Cause: com.ruoyi.common.exception.ServiceException: 获取用户信息异常','2021-10-19 14:25:11','00000000'),(139,'admin','127.0.0.1','内网IP','Chrome 9','Windows 10','1','验证码错误','2021-10-19 14:25:35','00000000'),(140,'admin','127.0.0.1','内网IP','Chrome 9','Windows 10','1','nested exception is org.apache.ibatis.exceptions.PersistenceException: \r\n### Error querying database. Cause: com.ruoyi.common.exception.ServiceException: 获取用户信息异常\r\n### The error may exist in file [D:\\code\\research\\RuoYi-Vue-S\\ruoyi-system\\target\\classes\\mapper\\system\\SysUserMapper.xml]\r\n### The error may involve com.ruoyi.system.mapper.SysUserMapper.selectUserByUserName\r\n### The error occurred while executing a query\r\n### Cause: com.ruoyi.common.exception.ServiceException: 获取用户信息异常','2021-10-19 14:25:40','00000000'),(141,'admin','127.0.0.1','内网IP','Chrome 9','Windows 10','1','验证码已失效','2021-10-19 14:30:27','00000000'),(142,'admin','127.0.0.1','内网IP','Chrome 9','Windows 10','1','nested exception is org.apache.ibatis.exceptions.PersistenceException: \r\n### Error querying database. Cause: com.ruoyi.common.exception.ServiceException: 获取用户信息异常\r\n### The error may exist in file [D:\\code\\research\\RuoYi-Vue-S\\ruoyi-system\\target\\classes\\mapper\\system\\SysUserMapper.xml]\r\n### The error may involve com.ruoyi.system.mapper.SysUserMapper.selectUserByUserName\r\n### The error occurred while executing a query\r\n### Cause: com.ruoyi.common.exception.ServiceException: 获取用户信息异常','2021-10-19 14:30:31','00000000'),(143,'admin','127.0.0.1','内网IP','Chrome 9','Windows 10','1','验证码已失效','2021-10-19 14:41:23','00000000'),(144,'admin','127.0.0.1','内网IP','Chrome 9','Windows 10','0','登录成功','2021-10-19 14:41:28','00000000'),(145,'admin','127.0.0.1','内网IP','Chrome 9','Windows 10','0','退出成功','2021-10-19 14:44:45','00000000'),(146,'admin','127.0.0.1','内网IP','Chrome 9','Windows 10','0','登录成功','2021-10-19 14:44:54','00000000'),(147,'admin','127.0.0.1','内网IP','Chrome 9','Windows 10','0','退出成功','2021-10-19 14:45:01','00000000'),(148,'ruoyi','127.0.0.1','内网IP','Chrome 9','Windows 10','0','登录成功','2021-10-19 14:45:08','00000000'),(149,'ruoyi','127.0.0.1','内网IP','Chrome 9','Windows 10','0','退出成功','2021-10-19 14:45:09','00000000'),(150,'admin','127.0.0.1','内网IP','Chrome 9','Windows 10','0','登录成功','2021-10-19 14:47:47','00000000'),(151,'admin','127.0.0.1','内网IP','Chrome 9','Windows 10','0','退出成功','2021-10-19 14:47:57','00000000'),(152,'ruoyi','127.0.0.1','内网IP','Chrome 9','Windows 10','1','验证码错误','2021-10-19 14:48:08','00000000'),(153,'ruoyi','127.0.0.1','内网IP','Chrome 9','Windows 10','0','登录成功','2021-10-19 14:48:15','00000000'),(154,'ruoyi','127.0.0.1','内网IP','Chrome 9','Windows 10','0','退出成功','2021-10-19 14:48:25','00000000'),(155,'admin','127.0.0.1','内网IP','Chrome 9','Windows 10','0','登录成功','2021-10-19 14:48:33','00000000'),(156,'admin','127.0.0.1','内网IP','Chrome 9','Windows 10','0','退出成功','2021-10-19 14:57:08','00000000'),(157,'ruoyi','127.0.0.1','内网IP','Chrome 9','Windows 10','0','登录成功','2021-10-19 14:57:17','00000000'),(158,'ruoyi','127.0.0.1','内网IP','Chrome 9','Windows 10','0','退出成功','2021-10-19 15:01:49','00000000'),(159,'ruoyi','127.0.0.1','内网IP','Chrome 9','Windows 10','0','登录成功','2021-10-19 15:01:59','00000000'),(160,'ruoyi','127.0.0.1','内网IP','Chrome 9','Windows 10','0','退出成功','2021-10-19 15:08:52','00000000'),(161,'ruoyi','127.0.0.1','内网IP','Chrome 9','Windows 10','0','登录成功','2021-10-19 15:09:01','00000000'),(162,'admin','127.0.0.1','内网IP','Chrome 9','Windows 10','1','nested exception is org.apache.ibatis.exceptions.PersistenceException: \r\n### Error querying database. Cause: com.ruoyi.common.exception.ServiceException: 获取用户信息异常\r\n### The error may exist in file [D:\\code\\research\\RuoYi-Vue-S\\ruoyi-system\\target\\classes\\mapper\\system\\SysUserMapper.xml]\r\n### The error may involve com.ruoyi.system.mapper.SysUserMapper.selectUserByUserName\r\n### The error occurred while executing a query\r\n### Cause: com.ruoyi.common.exception.ServiceException: 获取用户信息异常','2021-10-19 15:59:24','00000000'),(163,'admin','127.0.0.1','内网IP','Chrome 9','Windows 10','1','nested exception is org.apache.ibatis.exceptions.PersistenceException: \r\n### Error querying database. Cause: com.ruoyi.common.exception.ServiceException: 获取用户信息异常\r\n### The error may exist in file [D:\\code\\research\\RuoYi-Vue-S\\ruoyi-system\\target\\classes\\mapper\\system\\SysUserMapper.xml]\r\n### The error may involve com.ruoyi.system.mapper.SysUserMapper.selectUserByUserName\r\n### The error occurred while executing a query\r\n### Cause: com.ruoyi.common.exception.ServiceException: 获取用户信息异常','2021-10-19 16:01:19','00000000'),(164,'admin','127.0.0.1','内网IP','Chrome 9','Windows 10','0','登录成功','2021-10-19 16:11:50','00000000'),(165,'admin','127.0.0.1','内网IP','Chrome 9','Windows 10','1','nested exception is org.apache.ibatis.exceptions.PersistenceException: \r\n### Error querying database. Cause: com.ruoyi.common.exception.ServiceException: 获取用户信息异常\r\n### The error may exist in file [D:\\code\\research\\RuoYi-Vue-S\\ruoyi-system\\target\\classes\\mapper\\system\\SysUserMapper.xml]\r\n### The error may involve com.ruoyi.system.mapper.SysUserMapper.selectUserByUserName\r\n### The error occurred while executing a query\r\n### Cause: com.ruoyi.common.exception.ServiceException: 获取用户信息异常','2021-10-19 16:16:19','00000000'),(166,'admin','127.0.0.1','内网IP','Chrome 9','Windows 10','1','nested exception is org.apache.ibatis.exceptions.PersistenceException: \r\n### Error querying database. Cause: com.ruoyi.common.exception.ServiceException: 获取用户信息异常\r\n### The error may exist in file [D:\\code\\research\\RuoYi-Vue-S\\ruoyi-system\\target\\classes\\mapper\\system\\SysUserMapper.xml]\r\n### The error may involve com.ruoyi.system.mapper.SysUserMapper.selectUserByUserName\r\n### The error occurred while executing a query\r\n### Cause: com.ruoyi.common.exception.ServiceException: 获取用户信息异常','2021-10-19 16:19:52','00000000'),(167,'admin','127.0.0.1','内网IP','Chrome 9','Windows 10','1','验证码已失效','2021-10-19 16:24:23','00000000'),(168,'admin','127.0.0.1','内网IP','Chrome 9','Windows 10','1','nested exception is org.apache.ibatis.exceptions.PersistenceException: \r\n### Error querying database. Cause: com.ruoyi.common.exception.ServiceException: 获取用户信息异常\r\n### The error may exist in file [D:\\code\\research\\RuoYi-Vue-S\\ruoyi-system\\target\\classes\\mapper\\system\\SysUserMapper.xml]\r\n### The error may involve com.ruoyi.system.mapper.SysUserMapper.selectUserByUserName\r\n### The error occurred while executing a query\r\n### Cause: com.ruoyi.common.exception.ServiceException: 获取用户信息异常','2021-10-19 16:24:28','00000000'),(169,'admin','127.0.0.1','内网IP','Chrome 9','Windows 10','1','验证码错误','2021-10-19 16:26:10','00000000'),(170,'admin','127.0.0.1','内网IP','Chrome 9','Windows 10','0','登录成功','2021-10-19 16:27:41','00000000'),(171,'admin','127.0.0.1','内网IP','Chrome 9','Windows 10','1','验证码错误','2021-10-19 16:30:55','00000000'),(172,'admin','127.0.0.1','内网IP','Chrome 9','Windows 10','1','nested exception is org.apache.ibatis.exceptions.PersistenceException: \r\n### Error querying database. Cause: com.ruoyi.common.exception.ServiceException: 获取用户信息异常\r\n### The error may exist in file [D:\\code\\research\\RuoYi-Vue-S\\ruoyi-system\\target\\classes\\mapper\\system\\SysUserMapper.xml]\r\n### The error may involve com.ruoyi.system.mapper.SysUserMapper.selectUserByUserName\r\n### The error occurred while executing a query\r\n### Cause: com.ruoyi.common.exception.ServiceException: 获取用户信息异常','2021-10-19 16:31:00','00000000'),(173,'admin','127.0.0.1','内网IP','Chrome 9','Windows 10','1','nested exception is org.apache.ibatis.exceptions.PersistenceException: \r\n### Error querying database. Cause: com.ruoyi.common.exception.ServiceException: 获取用户信息异常\r\n### The error may exist in file [D:\\code\\research\\RuoYi-Vue-S\\ruoyi-system\\target\\classes\\mapper\\system\\SysUserMapper.xml]\r\n### The error may involve com.ruoyi.system.mapper.SysUserMapper.selectUserByUserName\r\n### The error occurred while executing a query\r\n### Cause: com.ruoyi.common.exception.ServiceException: 获取用户信息异常','2021-10-19 16:32:34','00000000'),(174,'admin','127.0.0.1','内网IP','Chrome 9','Windows 10','1','验证码已失效','2021-10-19 16:33:58','00000000'),(175,'admin','127.0.0.1','内网IP','Chrome 9','Windows 10','1','nested exception is org.apache.ibatis.exceptions.PersistenceException: \r\n### Error querying database. Cause: com.ruoyi.common.exception.ServiceException: 获取用户信息异常\r\n### The error may exist in file [D:\\code\\research\\RuoYi-Vue-S\\ruoyi-system\\target\\classes\\mapper\\system\\SysUserMapper.xml]\r\n### The error may involve com.ruoyi.system.mapper.SysUserMapper.selectUserByUserName\r\n### The error occurred while executing a query\r\n### Cause: com.ruoyi.common.exception.ServiceException: 获取用户信息异常','2021-10-19 16:39:05','00000000'),(176,'admin','127.0.0.1','内网IP','Chrome 9','Windows 10','1','nested exception is org.apache.ibatis.exceptions.PersistenceException: \r\n### Error querying database. Cause: com.ruoyi.common.exception.ServiceException: 获取用户信息异常\r\n### The error may exist in file [D:\\code\\research\\RuoYi-Vue-S\\ruoyi-system\\target\\classes\\mapper\\system\\SysUserMapper.xml]\r\n### The error may involve com.ruoyi.system.mapper.SysUserMapper.selectUserByUserName\r\n### The error occurred while executing a query\r\n### Cause: com.ruoyi.common.exception.ServiceException: 获取用户信息异常','2021-10-19 16:46:20','00000000'),(177,'admin','127.0.0.1','内网IP','Chrome 9','Windows 10','1','验证码已失效','2021-10-19 16:54:19','00000000'),(178,'admin','127.0.0.1','内网IP','Chrome 9','Windows 10','0','登录成功','2021-10-19 16:54:33','00000000'),(179,'admin','127.0.0.1','内网IP','Chrome 9','Windows 10','0','登录成功','2021-10-20 11:23:22','00000000'),(180,'admin','127.0.0.1','内网IP','Chrome 9','Windows 10','0','登录成功','2021-10-21 20:42:56','00000000'),(181,'admin','127.0.0.1','内网IP','Chrome','Windows 10','0','登录成功','2021-10-22 11:31:35','00000000'),(182,'admin','127.0.0.1','内网IP','Chrome 9','Windows 10','0','登录成功','2021-10-22 11:54:54','00000000'),(183,'admin','127.0.0.1','内网IP','Chrome','Windows 10','0','登录成功','2021-10-22 13:21:17','00000000'),(184,'admin','127.0.0.1','内网IP','Chrome 9','Windows 10','0','登录成功','2021-10-22 13:22:41','00000000'),(185,'admin','127.0.0.1','内网IP','Chrome 9','Windows 10','0','登录成功','2021-10-22 14:09:40','00000000'),(186,'admin','127.0.0.1','内网IP','Chrome','Windows 10','0','登录成功','2021-10-22 14:21:07','00000000'),(187,'admin','127.0.0.1','内网IP','Chrome 9','Windows 10','0','登录成功','2021-10-22 16:13:36','00000000'),(188,'admin','127.0.0.1','内网IP','Chrome 9','Windows 10','0','登录成功','2021-10-22 22:35:00','00000000'),(189,'admin','127.0.0.1','内网IP','Chrome 8','Windows 10','0','登录成功','2021-10-22 22:55:32','00000000'),(190,'admin','127.0.0.1','内网IP','Chrome 8','Windows 10','0','登录成功','2021-10-23 10:45:53','00000000'),(191,'admin','127.0.0.1','内网IP','Chrome 8','Windows 10','0','登录成功','2021-10-23 11:31:35','00000000'),(192,'admin','127.0.0.1','内网IP','Chrome 8','Windows 10','0','登录成功','2021-10-23 17:05:57','00000000'),(193,'admin','127.0.0.1','内网IP','Chrome 8','Windows 10','0','登录成功','2021-10-23 22:32:24','00000000'),(194,'admin','127.0.0.1','内网IP','Chrome 8','Windows 10','0','登录成功','2021-10-24 12:04:01','00000000'),(195,'admin','127.0.0.1','内网IP','Chrome 8','Windows 10','0','登录成功','2021-10-24 12:59:55','00000000'),(196,'admin','127.0.0.1','内网IP','Chrome 8','Windows 10','0','登录成功','2021-10-24 19:46:35','00000000'),(197,'admin','127.0.0.1','内网IP','Chrome','Windows 10','0','登录成功','2021-10-25 09:35:56','00000000'),(198,'admin','127.0.0.1','内网IP','Chrome 9','Windows 10','0','登录成功','2021-10-25 10:43:27','00000000'),(199,'admin','127.0.0.1','内网IP','Chrome 9','Windows 10','0','退出成功','2021-10-25 11:36:04','00000000'),(200,'ruoyi','127.0.0.1','内网IP','Chrome 9','Windows 10','0','登录成功','2021-10-25 11:36:13','00000000'),(201,'ruoyi','127.0.0.1','内网IP','Chrome 9','Windows 10','0','退出成功','2021-10-25 11:36:26','00000000'),(202,'admin','127.0.0.1','内网IP','Chrome 9','Windows 10','0','登录成功','2021-10-25 11:36:37','00000000'),(203,'admin','127.0.0.1','内网IP','Chrome 9','Windows 10','0','退出成功','2021-10-25 11:40:17','00000000'),(204,'ry','127.0.0.1','内网IP','Chrome 9','Windows 10','0','登录成功','2021-10-25 11:40:24','00000000'),(205,'ry','127.0.0.1','内网IP','Chrome 9','Windows 10','0','退出成功','2021-10-25 11:50:16','00000000'),(206,'admin','127.0.0.1','内网IP','Chrome 9','Windows 10','1','验证码错误','2021-10-25 11:50:23','00000000'),(207,'admin','127.0.0.1','内网IP','Chrome 9','Windows 10','1','验证码错误','2021-10-25 11:50:27','00000000'),(208,'admin','127.0.0.1','内网IP','Chrome 9','Windows 10','0','登录成功','2021-10-25 11:50:34','00000000'),(209,'admin','127.0.0.1','内网IP','Chrome 9','Windows 10','0','退出成功','2021-10-25 11:51:09','00000000'),(210,'ry','127.0.0.1','内网IP','Chrome 9','Windows 10','0','登录成功','2021-10-25 11:51:15','00000000'),(211,'ry','127.0.0.1','内网IP','Chrome 9','Windows 10','0','退出成功','2021-10-25 11:53:20','00000000'),(212,'ry','127.0.0.1','内网IP','Chrome 9','Windows 10','0','登录成功','2021-10-25 11:53:25','00000000'),(213,'ry','127.0.0.1','内网IP','Chrome 9','Windows 10','0','退出成功','2021-10-25 11:56:38','00000000'),(214,'admin','127.0.0.1','内网IP','Chrome 9','Windows 10','0','登录成功','2021-10-25 11:56:47','00000000'),(215,'admin','127.0.0.1','内网IP','Chrome 9','Windows 10','0','登录成功','2021-10-25 18:28:11','00000000'),(216,'admin','127.0.0.1','内网IP','Chrome 9','Windows 10','0','退出成功','2021-10-25 18:29:35','00000000'),(217,'ry','127.0.0.1','内网IP','Chrome 9','Windows 10','0','登录成功','2021-10-25 18:29:43','00000000'),(218,'ry','127.0.0.1','内网IP','Chrome 9','Windows 10','0','退出成功','2021-10-25 18:33:38','00000000'),(219,'admin','127.0.0.1','内网IP','Chrome 9','Windows 10','0','登录成功','2021-10-25 18:33:42','00000000'),(220,'admin','127.0.0.1','内网IP','Chrome 9','Windows 10','0','退出成功','2021-10-25 18:34:38','00000000'),(221,'ry','127.0.0.1','内网IP','Chrome 9','Windows 10','0','登录成功','2021-10-25 18:34:45','00000000'),(222,'ry','127.0.0.1','内网IP','Chrome 9','Windows 10','0','退出成功','2021-10-25 18:49:15','00000000'),(223,'admin','127.0.0.1','内网IP','Chrome 9','Windows 10','0','登录成功','2021-10-25 18:49:27','00000000'),(224,'admin','127.0.0.1','内网IP','Chrome 9','Windows 10','0','退出成功','2021-10-25 18:51:28','00000000'),(225,'ry','127.0.0.1','内网IP','Chrome 9','Windows 10','0','登录成功','2021-10-25 18:51:34','00000000'),(226,'ry','127.0.0.1','内网IP','Chrome 9','Windows 10','0','退出成功','2021-10-25 18:52:36','00000000'),(227,'admin','127.0.0.1','内网IP','Chrome 9','Windows 10','0','登录成功','2021-10-25 18:52:40','00000000'),(228,'admin','127.0.0.1','内网IP','Chrome 9','Windows 10','0','退出成功','2021-10-25 18:58:41','00000000'),(229,'admin','127.0.0.1','内网IP','Chrome 9','Windows 10','0','登录成功','2021-10-25 18:58:45','00000000'),(230,'admin','127.0.0.1','内网IP','Chrome 8','Windows 10','0','登录成功','2021-10-25 18:59:16','00000000'),(231,'admin','127.0.0.1','内网IP','Chrome 9','Windows 10','0','退出成功','2021-10-25 19:01:26','00000000'),(232,'ry','127.0.0.1','内网IP','Chrome 9','Windows 10','0','登录成功','2021-10-25 19:01:37','00000000'),(233,'admin','127.0.0.1','内网IP','Chrome 9','Windows 10','0','登录成功','2021-10-26 16:32:04','00000000'),(234,'admin','127.0.0.1','内网IP','Chrome 9','Windows 10','0','退出成功','2021-10-26 16:32:18','00000000'),(235,'admin','127.0.0.1','内网IP','Chrome 9','Windows 10','0','登录成功','2021-10-26 16:32:38','00000000'),(236,'admin','127.0.0.1','内网IP','Chrome 9','Windows 10','0','登录成功','2021-10-26 17:06:59','00000000'),(237,'admin','127.0.0.1','内网IP','Chrome 9','Windows 10','0','登录成功','2021-11-11 10:08:31','00000000'),(238,'admin','127.0.0.1','内网IP','Chrome 9','Windows 10','0','退出成功','2021-11-11 10:38:05','00000000'),(239,'test','127.0.0.1','内网IP','Chrome 9','Windows 10','0','登录成功','2021-11-11 10:38:14','00000000'),(240,'test','127.0.0.1','内网IP','Chrome 9','Windows 10','0','退出成功','2021-11-11 10:38:28','00000000'),(241,'admin','127.0.0.1','内网IP','Chrome 9','Windows 10','0','登录成功','2021-11-11 10:38:35','00000000'),(242,'admin','127.0.0.1','内网IP','Chrome','Windows 10','1','验证码错误','2021-11-15 14:24:13','00000000'),(243,'admin','127.0.0.1','内网IP','Chrome','Windows 10','0','登录成功','2021-11-15 14:24:17','00000000'),(244,'admin','127.0.0.1','内网IP','Chrome 9','Windows 10','0','登录成功','2021-11-15 14:37:26','00000000'),(245,'admin','127.0.0.1','内网IP','Chrome 9','Windows 10','0','登录成功','2021-12-23 18:52:25','00000000'),(246,'admin','127.0.0.1','内网IP','Chrome 9','Windows 10','0','登录成功','2021-12-24 14:21:33','00000000'),(247,'admin','127.0.0.1','内网IP','Chrome 9','Windows 10','1','验证码已失效','2022-01-15 16:45:56','00000000'),(248,'admin','127.0.0.1','内网IP','Chrome 9','Windows 10','0','登录成功','2022-01-15 16:46:01','00000000'),(249,'admin','127.0.0.1','内网IP','Chrome 9','Windows 10','0','登录成功','2022-01-15 18:59:47','00000000'),(250,'admin','127.0.0.1','内网IP','Chrome 9','Windows 10','0','登录成功','2022-01-15 19:31:08','00000000'),(251,'admin','127.0.0.1','内网IP','Chrome 9','Windows 10','0','登录成功','2022-01-15 21:39:21','00000000'),(252,'admin','127.0.0.1','内网IP','Chrome 9','Windows 10','0','登录成功','2022-01-15 23:13:43','00000000'),(253,'admin','127.0.0.1','内网IP','Chrome 9','Windows 10','0','登录成功','2022-01-16 13:16:21','00000000'),(254,'admin','127.0.0.1','内网IP','Chrome 9','Windows 10','0','登录成功','2022-01-16 15:31:07','00000000'),(255,'admin','192.168.1.4','内网IP','Chrome 9','Windows 10','1','验证码错误','2022-01-16 17:13:07','00000000'),(256,'admin','192.168.1.4','内网IP','Chrome 9','Windows 10','0','登录成功','2022-01-16 17:13:10','00000000'),(257,'admin','127.0.0.1','内网IP','Chrome 9','Windows 10','0','登录成功','2022-01-16 17:24:35','00000000'),(258,'admin','127.0.0.1','内网IP','Chrome 9','Windows 10','0','登录成功','2022-01-16 18:01:10','00000000'),(259,'admin','127.0.0.1','内网IP','Chrome 9','Windows 10','0','登录成功','2022-01-16 19:18:54','00000000'),(260,'admin','127.0.0.1','内网IP','Chrome 9','Windows 10','0','登录成功','2022-01-16 20:24:58','00000000'),(261,'admin','127.0.0.1','内网IP','Chrome 9','Windows 10','0','登录成功','2022-01-16 20:37:56','00000000'); + +/*Table structure for table `sys_menu` */ + +DROP TABLE IF EXISTS `sys_menu`; + +CREATE TABLE `sys_menu` ( + `menu_id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '菜单ID', + `menu_name` varchar(50) NOT NULL COMMENT '菜单名称', + `parent_id` bigint(20) DEFAULT '0' COMMENT '父菜单ID', + `order_num` int(4) DEFAULT '0' COMMENT '显示顺序', + `path` varchar(200) DEFAULT '' COMMENT '路由地址', + `component` varchar(255) DEFAULT NULL COMMENT '组件路径', + `query` varchar(255) DEFAULT NULL COMMENT '路由参数', + `is_frame` int(1) DEFAULT '1' COMMENT '是否为外链(0是 1否)', + `is_cache` int(1) DEFAULT '0' COMMENT '是否缓存(0缓存 1不缓存)', + `menu_type` char(1) DEFAULT '' COMMENT '菜单类型(M目录 C菜单 F按钮)', + `visible` char(1) DEFAULT '0' COMMENT '菜单状态(0显示 1隐藏)', + `status` char(1) DEFAULT '0' COMMENT '菜单状态(0正常 1停用)', + `perms` varchar(100) DEFAULT NULL COMMENT '权限标识', + `icon` varchar(100) DEFAULT '#' COMMENT '菜单图标', + `create_by` varchar(64) DEFAULT '' COMMENT '创建者', + `create_time` datetime DEFAULT NULL COMMENT '创建时间', + `update_by` varchar(64) DEFAULT '' COMMENT '更新者', + `update_time` datetime DEFAULT NULL COMMENT '更新时间', + `remark` varchar(500) DEFAULT '' COMMENT '备注', + `tenant_id` varchar(8) NOT NULL DEFAULT '00000000', + PRIMARY KEY (`menu_id`) +) ENGINE=InnoDB AUTO_INCREMENT=1482616947476238340 DEFAULT CHARSET=utf8mb4 COMMENT='菜单权限表'; + +/*Data for the table `sys_menu` */ + +insert into `sys_menu`(`menu_id`,`menu_name`,`parent_id`,`order_num`,`path`,`component`,`query`,`is_frame`,`is_cache`,`menu_type`,`visible`,`status`,`perms`,`icon`,`create_by`,`create_time`,`update_by`,`update_time`,`remark`,`tenant_id`) values (1,'系统管理',0,1,'system',NULL,'',1,0,'M','0','0','','system','admin','2021-09-21 17:00:40','',NULL,'系统管理目录','00000000'),(2,'系统监控',0,2,'monitor',NULL,'',1,0,'M','0','0','','monitor','admin','2021-09-21 17:00:41','',NULL,'系统监控目录','00000000'),(3,'系统工具',0,3,'tool',NULL,'',1,0,'M','0','0','','tool','admin','2021-09-21 17:00:41','',NULL,'系统工具目录','00000000'),(4,'若依官网',0,5,'http://ruoyi.vip',NULL,'',0,0,'M','0','0','','guide','admin','2021-09-21 17:00:41','ry','2021-10-25 19:02:36','若依官网地址','00000000'),(100,'用户管理',1,1,'user','system/user/index','',1,0,'C','0','0','system:user:list','user','admin','2021-09-21 17:00:42','',NULL,'用户管理菜单','00000000'),(101,'角色管理',1,2,'role','system/role/index','',1,0,'C','0','0','system:role:list','peoples','admin','2021-09-21 17:00:42','',NULL,'角色管理菜单','00000000'),(102,'菜单管理',1,3,'menu','system/menu/index','',1,0,'C','0','0','system:menu:list','tree-table','admin','2021-09-21 17:00:42','',NULL,'菜单管理菜单','00000000'),(103,'部门管理',1,4,'dept','system/dept/index','',1,0,'C','0','0','system:dept:list','tree','admin','2021-09-21 17:00:43','',NULL,'部门管理菜单','00000000'),(104,'岗位管理',1,5,'post','system/post/index','',1,0,'C','0','0','system:post:list','post','admin','2021-09-21 17:00:43','',NULL,'岗位管理菜单','00000000'),(105,'字典管理',1,6,'dict','system/dict/index','',1,0,'C','0','0','system:dict:list','dict','admin','2021-09-21 17:00:44','',NULL,'字典管理菜单','00000000'),(106,'参数设置',1,7,'config','system/config/index','',1,0,'C','0','0','system:config:list','edit','admin','2021-09-21 17:00:44','',NULL,'参数设置菜单','00000000'),(107,'通知公告',1,8,'notice','system/notice/index','',1,0,'C','0','0','system:notice:list','message','admin','2021-09-21 17:00:44','',NULL,'通知公告菜单','00000000'),(108,'日志管理',1,9,'log','','',1,0,'M','0','0','','log','admin','2021-09-21 17:00:45','',NULL,'日志管理菜单','00000000'),(109,'在线用户',2,1,'online','monitor/online/index','',1,0,'C','0','0','monitor:online:list','online','admin','2021-09-21 17:00:45','',NULL,'在线用户菜单','00000000'),(110,'定时任务',2,2,'job','monitor/job/index','',1,0,'C','0','0','monitor:job:list','job','admin','2021-09-21 17:00:45','',NULL,'定时任务菜单','00000000'),(111,'数据监控',2,3,'druid','monitor/druid/index','',1,0,'C','0','0','monitor:druid:list','druid','admin','2021-09-21 17:00:46','',NULL,'数据监控菜单','00000000'),(112,'服务监控',2,4,'server','monitor/server/index','',1,0,'C','0','0','monitor:server:list','server','admin','2021-09-21 17:00:46','',NULL,'服务监控菜单','00000000'),(113,'缓存监控',2,5,'cache','monitor/cache/index','',1,0,'C','0','0','monitor:cache:list','redis','admin','2021-09-21 17:00:47','',NULL,'缓存监控菜单','00000000'),(114,'表单构建',3,2,'build','tool/build/index','',1,0,'C','0','0','tool:build:list','build','admin','2021-09-21 17:00:47','admin','2022-01-16 20:45:06','表单构建菜单','00000000'),(115,'代码生成',3,3,'gen','tool/gen/index','',1,0,'C','0','0','tool:gen:list','code','admin','2021-09-21 17:00:47','admin','2022-01-16 20:45:22','代码生成菜单','00000000'),(116,'系统接口',3,4,'swagger','tool/swagger/index','',1,0,'C','0','0','tool:swagger:list','swagger','admin','2021-09-21 17:00:48','admin','2022-01-16 20:45:31','系统接口菜单','00000000'),(500,'操作日志',108,1,'operlog','monitor/operlog/index','',1,0,'C','0','0','monitor:operlog:list','form','admin','2021-09-21 17:00:48','',NULL,'操作日志菜单','00000000'),(501,'登录日志',108,2,'logininfor','monitor/logininfor/index','',1,0,'C','0','0','monitor:logininfor:list','logininfor','admin','2021-09-21 17:00:48','',NULL,'登录日志菜单','00000000'),(1001,'用户查询',100,1,'','','',1,0,'F','0','0','system:user:query','#','admin','2021-09-21 17:00:49','',NULL,'','00000000'),(1002,'用户新增',100,2,'','','',1,0,'F','0','0','system:user:add','#','admin','2021-09-21 17:00:49','',NULL,'','00000000'),(1003,'用户修改',100,3,'','','',1,0,'F','0','0','system:user:edit','#','admin','2021-09-21 17:00:50','',NULL,'','00000000'),(1004,'用户删除',100,4,'','','',1,0,'F','0','0','system:user:remove','#','admin','2021-09-21 17:00:50','',NULL,'','00000000'),(1005,'用户导出',100,5,'','','',1,0,'F','0','0','system:user:export','#','admin','2021-09-21 17:00:50','',NULL,'','00000000'),(1006,'用户导入',100,6,'','','',1,0,'F','0','0','system:user:import','#','admin','2021-09-21 17:00:51','',NULL,'','00000000'),(1007,'重置密码',100,7,'','','',1,0,'F','0','0','system:user:resetPwd','#','admin','2021-09-21 17:00:51','',NULL,'','00000000'),(1008,'角色查询',101,1,'','','',1,0,'F','0','0','system:role:query','#','admin','2021-09-21 17:00:51','',NULL,'','00000000'),(1009,'角色新增',101,2,'','','',1,0,'F','0','0','system:role:add','#','admin','2021-09-21 17:00:52','',NULL,'','00000000'),(1010,'角色修改',101,3,'','','',1,0,'F','0','0','system:role:edit','#','admin','2021-09-21 17:00:52','',NULL,'','00000000'),(1011,'角色删除',101,4,'','','',1,0,'F','0','0','system:role:remove','#','admin','2021-09-21 17:00:52','',NULL,'','00000000'),(1012,'角色导出',101,5,'','','',1,0,'F','0','0','system:role:export','#','admin','2021-09-21 17:00:53','',NULL,'','00000000'),(1013,'菜单查询',102,1,'','','',1,0,'F','0','0','system:menu:query','#','admin','2021-09-21 17:00:53','',NULL,'','00000000'),(1014,'菜单新增',102,2,'','','',1,0,'F','0','0','system:menu:add','#','admin','2021-09-21 17:00:53','',NULL,'','00000000'),(1015,'菜单修改',102,3,'','','',1,0,'F','0','0','system:menu:edit','#','admin','2021-09-21 17:00:54','',NULL,'','00000000'),(1016,'菜单删除',102,4,'','','',1,0,'F','0','0','system:menu:remove','#','admin','2021-09-21 17:00:54','',NULL,'','00000000'),(1017,'部门查询',103,1,'','','',1,0,'F','0','0','system:dept:query','#','admin','2021-09-21 17:00:55','',NULL,'','00000000'),(1018,'部门新增',103,2,'','','',1,0,'F','0','0','system:dept:add','#','admin','2021-09-21 17:00:55','',NULL,'','00000000'),(1019,'部门修改',103,3,'','','',1,0,'F','0','0','system:dept:edit','#','admin','2021-09-21 17:00:55','',NULL,'','00000000'),(1020,'部门删除',103,4,'','','',1,0,'F','0','0','system:dept:remove','#','admin','2021-09-21 17:00:56','',NULL,'','00000000'),(1021,'岗位查询',104,1,'','','',1,0,'F','0','0','system:post:query','#','admin','2021-09-21 17:00:56','',NULL,'','00000000'),(1022,'岗位新增',104,2,'','','',1,0,'F','0','0','system:post:add','#','admin','2021-09-21 17:00:56','',NULL,'','00000000'),(1023,'岗位修改',104,3,'','','',1,0,'F','0','0','system:post:edit','#','admin','2021-09-21 17:00:57','',NULL,'','00000000'),(1024,'岗位删除',104,4,'','','',1,0,'F','0','0','system:post:remove','#','admin','2021-09-21 17:00:57','',NULL,'','00000000'),(1025,'岗位导出',104,5,'','','',1,0,'F','0','0','system:post:export','#','admin','2021-09-21 17:00:58','',NULL,'','00000000'),(1026,'字典查询',105,1,'#','','',1,0,'F','0','0','system:dict:query','#','admin','2021-09-21 17:00:58','',NULL,'','00000000'),(1027,'字典新增',105,2,'#','','',1,0,'F','0','0','system:dict:add','#','admin','2021-09-21 17:00:58','',NULL,'','00000000'),(1028,'字典修改',105,3,'#','','',1,0,'F','0','0','system:dict:edit','#','admin','2021-09-21 17:00:59','',NULL,'','00000000'),(1029,'字典删除',105,4,'#','','',1,0,'F','0','0','system:dict:remove','#','admin','2021-09-21 17:00:59','',NULL,'','00000000'),(1030,'字典导出',105,5,'#','','',1,0,'F','0','0','system:dict:export','#','admin','2021-09-21 17:00:59','',NULL,'','00000000'),(1031,'参数查询',106,1,'#','','',1,0,'F','0','0','system:config:query','#','admin','2021-09-21 17:01:00','',NULL,'','00000000'),(1032,'参数新增',106,2,'#','','',1,0,'F','0','0','system:config:add','#','admin','2021-09-21 17:01:00','',NULL,'','00000000'),(1033,'参数修改',106,3,'#','','',1,0,'F','0','0','system:config:edit','#','admin','2021-09-21 17:01:01','',NULL,'','00000000'),(1034,'参数删除',106,4,'#','','',1,0,'F','0','0','system:config:remove','#','admin','2021-09-21 17:01:01','',NULL,'','00000000'),(1035,'参数导出',106,5,'#','','',1,0,'F','0','0','system:config:export','#','admin','2021-09-21 17:01:01','',NULL,'','00000000'),(1036,'公告查询',107,1,'#','','',1,0,'F','0','0','system:notice:query','#','admin','2021-09-21 17:01:02','',NULL,'','00000000'),(1037,'公告新增',107,2,'#','','',1,0,'F','0','0','system:notice:add','#','admin','2021-09-21 17:01:02','',NULL,'','00000000'),(1038,'公告修改',107,3,'#','','',1,0,'F','0','0','system:notice:edit','#','admin','2021-09-21 17:01:02','',NULL,'','00000000'),(1039,'公告删除',107,4,'#','','',1,0,'F','0','0','system:notice:remove','#','admin','2021-09-21 17:01:03','',NULL,'','00000000'),(1040,'操作查询',500,1,'#','','',1,0,'F','0','0','monitor:operlog:query','#','admin','2021-09-21 17:01:03','',NULL,'','00000000'),(1041,'操作删除',500,2,'#','','',1,0,'F','0','0','monitor:operlog:remove','#','admin','2021-09-21 17:01:03','',NULL,'','00000000'),(1042,'日志导出',500,4,'#','','',1,0,'F','0','0','monitor:operlog:export','#','admin','2021-09-21 17:01:04','',NULL,'','00000000'),(1043,'登录查询',501,1,'#','','',1,0,'F','0','0','monitor:logininfor:query','#','admin','2021-09-21 17:01:04','',NULL,'','00000000'),(1044,'登录删除',501,2,'#','','',1,0,'F','0','0','monitor:logininfor:remove','#','admin','2021-09-21 17:01:04','',NULL,'','00000000'),(1045,'日志导出',501,3,'#','','',1,0,'F','0','0','monitor:logininfor:export','#','admin','2021-09-21 17:01:05','',NULL,'','00000000'),(1046,'在线查询',109,1,'#','','',1,0,'F','0','0','monitor:online:query','#','admin','2021-09-21 17:01:05','',NULL,'','00000000'),(1047,'批量强退',109,2,'#','','',1,0,'F','0','0','monitor:online:batchLogout','#','admin','2021-09-21 17:01:06','',NULL,'','00000000'),(1048,'单条强退',109,3,'#','','',1,0,'F','0','0','monitor:online:forceLogout','#','admin','2021-09-21 17:01:06','',NULL,'','00000000'),(1049,'任务查询',110,1,'#','','',1,0,'F','0','0','monitor:job:query','#','admin','2021-09-21 17:01:06','',NULL,'','00000000'),(1050,'任务新增',110,2,'#','','',1,0,'F','0','0','monitor:job:add','#','admin','2021-09-21 17:01:07','',NULL,'','00000000'),(1051,'任务修改',110,3,'#','','',1,0,'F','0','0','monitor:job:edit','#','admin','2021-09-21 17:01:07','',NULL,'','00000000'),(1052,'任务删除',110,4,'#','','',1,0,'F','0','0','monitor:job:remove','#','admin','2021-09-21 17:01:07','',NULL,'','00000000'),(1053,'状态修改',110,5,'#','','',1,0,'F','0','0','monitor:job:changeStatus','#','admin','2021-09-21 17:01:08','',NULL,'','00000000'),(1054,'任务导出',110,7,'#','','',1,0,'F','0','0','monitor:job:export','#','admin','2021-09-21 17:01:08','',NULL,'','00000000'),(1055,'生成查询',115,1,'#','','',1,0,'F','0','0','tool:gen:query','#','admin','2021-09-21 17:01:09','',NULL,'','00000000'),(1056,'生成修改',115,2,'#','','',1,0,'F','0','0','tool:gen:edit','#','admin','2021-09-21 17:01:09','',NULL,'','00000000'),(1057,'生成删除',115,3,'#','','',1,0,'F','0','0','tool:gen:remove','#','admin','2021-09-21 17:01:09','',NULL,'','00000000'),(1058,'导入代码',115,2,'#','','',1,0,'F','0','0','tool:gen:import','#','admin','2021-09-21 17:01:10','',NULL,'','00000000'),(1059,'预览代码',115,4,'#','','',1,0,'F','0','0','tool:gen:preview','#','admin','2021-09-21 17:01:10','',NULL,'','00000000'),(1060,'生成代码',115,5,'#','','',1,0,'F','0','0','tool:gen:code','#','admin','2021-09-21 17:01:10','',NULL,'','00000000'),(2000,'租户管理',1,0,'tenant','system/tenant/index',NULL,1,0,'C','0','0','system:tenant:list','theme','admin','2021-10-10 16:17:46','admin','2021-10-11 22:32:32','','00000000'),(2001,'租户查询',2000,1,'','','',1,0,'F','0','0','system:tenant:query','#','admin','2021-09-21 17:00:51','admin','2021-10-11 22:38:17','','00000000'),(2002,'租户新增',2000,2,'','','',1,0,'F','0','0','system:tenant:add','#','admin','2021-09-21 17:00:52','admin','2021-10-11 22:38:21','','00000000'),(2003,'租户修改',2000,3,'','','',1,0,'F','0','0','system:tenant:edit','#','admin','2021-09-21 17:00:52','admin','2021-10-11 22:38:26','','00000000'),(2004,'租户删除',2000,4,'','','',1,0,'F','0','0','system:tenant:remove','#','admin','2021-09-21 17:00:52','admin','2021-10-11 22:38:32','','00000000'),(2005,'租户导出',2000,5,'','','',1,0,'F','0','0','system:tenant:export','#','admin','2021-09-21 17:00:53','admin','2021-10-11 22:38:37','','00000000'),(2006,'数据权限',1,10,'datarule','system/dataRule/index',NULL,1,0,'C','0','0','system:dataRule:list','validCode','admin','2021-10-20 11:28:20','admin','2021-10-20 11:29:02','','00000000'),(2007,'数据权限查询',2006,1,'','','',1,0,'F','0','0','system:dataRule:query','#','admin','2021-09-21 17:00:51','admin','2021-10-11 22:38:17','','00000000'),(2008,'数据权限新增',2006,2,'','','',1,0,'F','0','0','system:dataRule:add','#','admin','2021-09-21 17:00:52','admin','2021-10-11 22:38:21','','00000000'),(2009,'数据权限修改',2006,3,'','','',1,0,'F','0','0','system:dataRule:edit','#','admin','2021-09-21 17:00:52','admin','2021-10-11 22:38:26','','00000000'),(2010,'数据权限删除',2006,4,'','','',1,0,'F','0','0','system:dataRule:remove','#','admin','2021-09-21 17:00:52','admin','2021-10-11 22:38:32','','00000000'),(2011,'数据权限导出',2006,5,'','','',1,0,'F','0','0','system:dataRule:export','#','admin','2021-09-21 17:00:53','admin','2021-10-11 22:38:37','','00000000'),(2012,'综合表格',2018,1,'table','demo/table/index',NULL,1,0,'C','0','0','demo:table:list','#','admin','2021-10-21 20:55:54','admin','2021-10-21 20:57:40','综合表格菜单','00000000'),(2013,'综合表格查询',2012,1,'#','',NULL,1,0,'F','0','0','demo:table:query','#','admin','2021-10-21 20:55:55','',NULL,'','00000000'),(2014,'综合表格新增',2012,2,'#','',NULL,1,0,'F','0','0','demo:table:add','#','admin','2021-10-21 20:55:55','',NULL,'','00000000'),(2015,'综合表格修改',2012,3,'#','',NULL,1,0,'F','0','0','demo:table:edit','#','admin','2021-10-21 20:55:55','',NULL,'','00000000'),(2016,'综合表格删除',2012,4,'#','',NULL,1,0,'F','0','0','demo:table:remove','#','admin','2021-10-21 20:55:56','',NULL,'','00000000'),(2017,'综合表格导出',2012,5,'#','',NULL,1,0,'F','0','0','demo:table:export','#','admin','2021-10-21 20:55:56','',NULL,'','00000000'),(2018,'代码样例',0,4,'demo',NULL,NULL,1,0,'M','0','0','','code','admin','2021-10-21 20:56:58','ry','2021-10-25 19:02:31','','00000000'),(2019,'树形表格',2018,3,'treeTable','demo/treeTable/index',NULL,1,0,'C','0','0','demo:treeTable:list','#','admin','2021-10-22 14:18:59','ry','2021-10-25 19:02:09','树形表格菜单','00000000'),(2020,'树形表格查询',2019,1,'#','',NULL,1,0,'F','0','0','demo:treeTable:query','#','admin','2021-10-22 14:19:00','',NULL,'','00000000'),(2021,'树形表格新增',2019,2,'#','',NULL,1,0,'F','0','0','demo:treeTable:add','#','admin','2021-10-22 14:19:01','',NULL,'','00000000'),(2022,'树形表格修改',2019,3,'#','',NULL,1,0,'F','0','0','demo:treeTable:edit','#','admin','2021-10-22 14:19:01','',NULL,'','00000000'),(2023,'树形表格删除',2019,4,'#','',NULL,1,0,'F','0','0','demo:treeTable:remove','#','admin','2021-10-22 14:19:02','',NULL,'','00000000'),(2024,'树形表格导出',2019,5,'#','',NULL,1,0,'F','0','0','demo:treeTable:export','#','admin','2021-10-22 14:19:02','',NULL,'','00000000'),(2025,'展开表格',2018,2,'expandTable','demo/expandTable/index',NULL,1,0,'C','0','0','demo:expandTable:list','#','admin','2021-10-22 23:01:27','ry','2021-10-25 19:02:04','展开表格菜单','00000000'),(2026,'展开表格查询',2025,1,'#','',NULL,1,0,'F','0','0','demo:expandTable:query','#','admin','2021-10-22 23:01:28','',NULL,'','00000000'),(2027,'展开表格新增',2025,2,'#','',NULL,1,0,'F','0','0','demo:expandTable:add','#','admin','2021-10-22 23:01:28','',NULL,'','00000000'),(2028,'展开表格修改',2025,3,'#','',NULL,1,0,'F','0','0','demo:expandTable:edit','#','admin','2021-10-22 23:01:29','',NULL,'','00000000'),(2029,'展开表格删除',2025,4,'#','',NULL,1,0,'F','0','0','demo:expandTable:remove','#','admin','2021-10-22 23:01:29','',NULL,'','00000000'),(2030,'展开表格导出',2025,5,'#','',NULL,1,0,'F','0','0','demo:expandTable:export','#','admin','2021-10-22 23:01:29','',NULL,'','00000000'),(2031,'级联表格',2018,4,'car','demo/twoTable/index',NULL,1,0,'C','0','0','demo:twotable:car:list','#','admin','2021-10-22 23:42:03','ry','2021-10-25 19:02:19','车辆品牌菜单','00000000'),(2032,'车辆品牌查询',2031,1,'#','',NULL,1,0,'F','0','0','demo:twotable:car:query','#','admin','2021-10-22 23:42:04','',NULL,'','00000000'),(2033,'车辆品牌新增',2031,2,'#','',NULL,1,0,'F','0','0','demo:twotable:car:add','#','admin','2021-10-22 23:42:04','',NULL,'','00000000'),(2034,'车辆品牌修改',2031,3,'#','',NULL,1,0,'F','0','0','demo:twotable:car:edit','#','admin','2021-10-22 23:42:05','',NULL,'','00000000'),(2035,'车辆品牌删除',2031,4,'#','',NULL,1,0,'F','0','0','demo:twotable:car:remove','#','admin','2021-10-22 23:42:05','',NULL,'','00000000'),(2036,'车辆品牌导出',2031,5,'#','',NULL,1,0,'F','0','0','demo:twotable:car:export','#','admin','2021-10-22 23:42:05','',NULL,'','00000000'),(2037,'左树右表',2018,5,'treeandtable','demo/treeAndTable/index',NULL,1,0,'C','0','0','demo:treeandtable:list','#','admin','2021-10-23 12:01:35','admin','2021-10-23 12:11:48','左树右表菜单','00000000'),(2038,'左树右表查询',2037,1,'#','',NULL,1,0,'F','0','0','demo:treeandtable:query','#','admin','2021-10-23 12:01:36','',NULL,'','00000000'),(2039,'左树右表新增',2037,2,'#','',NULL,1,0,'F','0','0','demo:treeandtable:add','#','admin','2021-10-23 12:01:36','',NULL,'','00000000'),(2040,'左树右表修改',2037,3,'#','',NULL,1,0,'F','0','0','demo:treeandtable:edit','#','admin','2021-10-23 12:01:37','',NULL,'','00000000'),(2041,'左树右表删除',2037,4,'#','',NULL,1,0,'F','0','0','demo:treeandtable:remove','#','admin','2021-10-23 12:01:37','',NULL,'','00000000'),(2042,'左树右表导出',2037,5,'#','',NULL,1,0,'F','0','0','demo:treeandtable:export','#','admin','2021-10-23 12:01:37','',NULL,'','00000000'),(1482616947476238338,'仓颉平台',3,1,'http://sunseagear.com:8081/admin/','http://sunseagear.com:8081/admin/',NULL,0,0,'M','0','0','','component','admin','2022-01-16 20:41:36','admin','2022-01-16 20:47:57','','00000000'),(1482616947476238339,'仓颉介绍',3,0,'cangjie','documentation/index',NULL,1,0,'C','0','0','','log','admin','2022-01-16 20:44:29','admin','2022-01-16 20:48:08','','00000000'); + +/*Table structure for table `sys_notice` */ + +DROP TABLE IF EXISTS `sys_notice`; + +CREATE TABLE `sys_notice` ( + `notice_id` int(4) NOT NULL AUTO_INCREMENT COMMENT '公告ID', + `notice_title` varchar(50) NOT NULL COMMENT '公告标题', + `notice_type` char(1) NOT NULL COMMENT '公告类型(1通知 2公告)', + `notice_content` longblob COMMENT '公告内容', + `status` char(1) DEFAULT '0' COMMENT '公告状态(0正常 1关闭)', + `create_by` varchar(64) DEFAULT '' COMMENT '创建者', + `create_time` datetime DEFAULT NULL COMMENT '创建时间', + `update_by` varchar(64) DEFAULT '' COMMENT '更新者', + `update_time` datetime DEFAULT NULL COMMENT '更新时间', + `remark` varchar(255) DEFAULT NULL COMMENT '备注', + `tenant_id` varchar(8) NOT NULL DEFAULT '00000000', + PRIMARY KEY (`notice_id`) +) ENGINE=InnoDB AUTO_INCREMENT=10 DEFAULT CHARSET=utf8mb4 COMMENT='通知公告表'; + +/*Data for the table `sys_notice` */ + +insert into `sys_notice`(`notice_id`,`notice_title`,`notice_type`,`notice_content`,`status`,`create_by`,`create_time`,`update_by`,`update_time`,`remark`,`tenant_id`) values (1,'温馨提醒:2018-07-01 若依新版本发布啦','2','新版本内容','0','admin','2021-09-21 17:02:10','',NULL,'管理员','00000000'),(2,'维护通知:2018-07-01 若依系统凌晨维护','1','维护内容','0','admin','2021-09-21 17:02:10','',NULL,'管理员','00000000'); + +/*Table structure for table `sys_oper_log` */ + +DROP TABLE IF EXISTS `sys_oper_log`; + +CREATE TABLE `sys_oper_log` ( + `oper_id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '日志主键', + `title` varchar(50) DEFAULT '' COMMENT '模块标题', + `business_type` int(2) DEFAULT '0' COMMENT '业务类型(0其它 1新增 2修改 3删除)', + `method` varchar(100) DEFAULT '' COMMENT '方法名称', + `request_method` varchar(10) DEFAULT '' COMMENT '请求方式', + `operator_type` int(1) DEFAULT '0' COMMENT '操作类别(0其它 1后台用户 2手机端用户)', + `oper_name` varchar(50) DEFAULT '' COMMENT '操作人员', + `dept_name` varchar(50) DEFAULT '' COMMENT '部门名称', + `oper_url` varchar(255) DEFAULT '' COMMENT '请求URL', + `oper_ip` varchar(128) DEFAULT '' COMMENT '主机地址', + `oper_location` varchar(255) DEFAULT '' COMMENT '操作地点', + `oper_param` varchar(2000) DEFAULT '' COMMENT '请求参数', + `json_result` varchar(2000) DEFAULT '' COMMENT '返回参数', + `status` int(1) DEFAULT '0' COMMENT '操作状态(0正常 1异常)', + `error_msg` varchar(2000) DEFAULT '' COMMENT '错误消息', + `oper_time` datetime DEFAULT NULL COMMENT '操作时间', + `tenant_id` varchar(8) NOT NULL DEFAULT '00000000', + PRIMARY KEY (`oper_id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='操作日志记录'; + +/*Data for the table `sys_oper_log` */ + +/*Table structure for table `sys_post` */ + +DROP TABLE IF EXISTS `sys_post`; + +CREATE TABLE `sys_post` ( + `post_id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '岗位ID', + `post_code` varchar(64) NOT NULL COMMENT '岗位编码', + `post_name` varchar(50) NOT NULL COMMENT '岗位名称', + `post_sort` int(4) NOT NULL COMMENT '显示顺序', + `status` char(1) NOT NULL COMMENT '状态(0正常 1停用)', + `create_by` varchar(64) DEFAULT '' COMMENT '创建者', + `create_time` datetime DEFAULT NULL COMMENT '创建时间', + `update_by` varchar(64) DEFAULT '' COMMENT '更新者', + `update_time` datetime DEFAULT NULL COMMENT '更新时间', + `remark` varchar(500) DEFAULT NULL COMMENT '备注', + `tenant_id` varchar(8) NOT NULL DEFAULT '00000000', + PRIMARY KEY (`post_id`) +) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8mb4 COMMENT='岗位信息表'; + +/*Data for the table `sys_post` */ + +insert into `sys_post`(`post_id`,`post_code`,`post_name`,`post_sort`,`status`,`create_by`,`create_time`,`update_by`,`update_time`,`remark`,`tenant_id`) values (1,'ceo','董事长',1,'0','admin','2021-09-21 17:00:36','',NULL,'','00000000'),(2,'se','项目经理',2,'0','admin','2021-09-21 17:00:37','',NULL,'','00000000'),(3,'hr','人力资源',3,'0','admin','2021-09-21 17:00:37','',NULL,'','00000000'),(4,'user','普通员工',4,'0','admin','2021-09-21 17:00:38','',NULL,'','00000000'); + +/*Table structure for table `sys_role` */ + +DROP TABLE IF EXISTS `sys_role`; + +CREATE TABLE `sys_role` ( + `role_id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '角色ID', + `role_name` varchar(30) NOT NULL COMMENT '角色名称', + `role_key` varchar(100) NOT NULL COMMENT '角色权限字符串', + `role_sort` int(4) NOT NULL COMMENT '显示顺序', + `data_scope` char(1) DEFAULT '1' COMMENT '数据范围(1:全部数据权限 2:自定数据权限 3:本部门数据权限 4:本部门及以下数据权限)', + `menu_check_strictly` tinyint(1) DEFAULT '1' COMMENT '菜单树选择项是否关联显示', + `dept_check_strictly` tinyint(1) DEFAULT '1' COMMENT '部门树选择项是否关联显示', + `status` char(1) NOT NULL COMMENT '角色状态(0正常 1停用)', + `del_flag` char(1) DEFAULT '0' COMMENT '删除标志(0代表存在 2代表删除)', + `create_by` varchar(64) DEFAULT '' COMMENT '创建者', + `create_time` datetime DEFAULT NULL COMMENT '创建时间', + `update_by` varchar(64) DEFAULT '' COMMENT '更新者', + `update_time` datetime DEFAULT NULL COMMENT '更新时间', + `remark` varchar(500) DEFAULT NULL COMMENT '备注', + `tenant_id` varchar(8) NOT NULL DEFAULT '00000000', + PRIMARY KEY (`role_id`) +) ENGINE=InnoDB AUTO_INCREMENT=101 DEFAULT CHARSET=utf8mb4 COMMENT='角色信息表'; + +/*Data for the table `sys_role` */ + +insert into `sys_role`(`role_id`,`role_name`,`role_key`,`role_sort`,`data_scope`,`menu_check_strictly`,`dept_check_strictly`,`status`,`del_flag`,`create_by`,`create_time`,`update_by`,`update_time`,`remark`,`tenant_id`) values (1,'超级管理员','admin',1,'1',1,1,'0','0','admin','2021-09-21 17:00:39','',NULL,'超级管理员','00000000'),(2,'租户管理员','tenantAdmin',2,'1',1,1,'0','0','admin','2021-10-08 15:16:18','admin','2021-10-25 18:34:18',NULL,'00000000'),(3,'普通角色','common',3,'2',1,1,'0','0','admin','2021-09-21 17:00:39','admin','2021-10-25 11:39:38','普通角色','00000000'); + +/*Table structure for table `sys_role_data_rule` */ + +DROP TABLE IF EXISTS `sys_role_data_rule`; + +CREATE TABLE `sys_role_data_rule` ( + `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键', + `data_rule_category` int(2) DEFAULT NULL COMMENT '权限类型(1:数据权限、2:接口权限)', + `data_rule_id` varchar(64) DEFAULT NULL COMMENT '权限id', + `role_id` varchar(64) DEFAULT NULL COMMENT '角色id', + PRIMARY KEY (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8mb4 COMMENT='角色数据权限关联表'; + +/*Data for the table `sys_role_data_rule` */ + +insert into `sys_role_data_rule`(`id`,`data_rule_category`,`data_rule_id`,`role_id`) values (5,NULL,'2','2'); + +/*Table structure for table `sys_role_dept` */ + +DROP TABLE IF EXISTS `sys_role_dept`; + +CREATE TABLE `sys_role_dept` ( + `role_id` bigint(20) NOT NULL COMMENT '角色ID', + `dept_id` bigint(20) NOT NULL COMMENT '部门ID', + PRIMARY KEY (`role_id`,`dept_id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='角色和部门关联表'; + +/*Data for the table `sys_role_dept` */ + +insert into `sys_role_dept`(`role_id`,`dept_id`) values (2,100),(2,101),(2,105); + +/*Table structure for table `sys_role_menu` */ + +DROP TABLE IF EXISTS `sys_role_menu`; + +CREATE TABLE `sys_role_menu` ( + `role_id` bigint(20) NOT NULL COMMENT '角色ID', + `menu_id` bigint(20) NOT NULL COMMENT '菜单ID', + PRIMARY KEY (`role_id`,`menu_id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='角色和菜单关联表'; + +/*Data for the table `sys_role_menu` */ + +insert into `sys_role_menu`(`role_id`,`menu_id`) values (2,1),(2,2),(2,3),(2,4),(2,100),(2,101),(2,102),(2,103),(2,104),(2,105),(2,106),(2,107),(2,108),(2,109),(2,110),(2,111),(2,112),(2,113),(2,114),(2,115),(2,116),(2,500),(2,501),(2,1001),(2,1002),(2,1003),(2,1004),(2,1005),(2,1006),(2,1007),(2,1008),(2,1009),(2,1010),(2,1011),(2,1012),(2,1013),(2,1014),(2,1015),(2,1016),(2,1017),(2,1018),(2,1019),(2,1020),(2,1021),(2,1022),(2,1023),(2,1024),(2,1025),(2,1026),(2,1027),(2,1028),(2,1029),(2,1030),(2,1031),(2,1032),(2,1033),(2,1034),(2,1035),(2,1036),(2,1037),(2,1038),(2,1039),(2,1040),(2,1041),(2,1042),(2,1043),(2,1044),(2,1045),(2,1046),(2,1047),(2,1048),(2,1049),(2,1050),(2,1051),(2,1052),(2,1053),(2,1054),(2,1055),(2,1056),(2,1057),(2,1058),(2,1059),(2,1060),(2,2012),(2,2013),(2,2014),(2,2015),(2,2016),(2,2017),(2,2018),(2,2019),(2,2020),(2,2021),(2,2022),(2,2023),(2,2024),(2,2025),(2,2026),(2,2027),(2,2028),(2,2029),(2,2030),(2,2031),(2,2032),(2,2033),(2,2034),(2,2035),(2,2036),(2,2037),(2,2038),(2,2039),(2,2040),(2,2041),(2,2042),(3,2012),(3,2013),(3,2014),(3,2015),(3,2016),(3,2017),(3,2018),(3,2019),(3,2020),(3,2021),(3,2022),(3,2023),(3,2024),(3,2025),(3,2026),(3,2027),(3,2028),(3,2029),(3,2030),(3,2031),(3,2032),(3,2033),(3,2034),(3,2035),(3,2036),(3,2037),(3,2038),(3,2039),(3,2040),(3,2041),(3,2042),(100,1),(100,2),(100,3),(100,100),(100,101),(100,102),(100,103),(100,104),(100,105),(100,106),(100,107),(100,108),(100,109),(100,110),(100,111),(100,112),(100,113),(100,114),(100,115),(100,116),(100,500),(100,501),(100,1001),(100,1002),(100,1003),(100,1004),(100,1005),(100,1006),(100,1007),(100,1008),(100,1009),(100,1010),(100,1011),(100,1012),(100,1013),(100,1014),(100,1015),(100,1016),(100,1017),(100,1018),(100,1019),(100,1020),(100,1021),(100,1022),(100,1023),(100,1024),(100,1025),(100,1026),(100,1027),(100,1028),(100,1029),(100,1030),(100,1031),(100,1032),(100,1033),(100,1034),(100,1035),(100,1036),(100,1037),(100,1038),(100,1039),(100,1040),(100,1041),(100,1042),(100,1043),(100,1044),(100,1045),(100,1046),(100,1047),(100,1048),(100,1049),(100,1050),(100,1051),(100,1052),(100,1053),(100,1054),(100,1055),(100,1056),(100,1057),(100,1058),(100,1059),(100,1060); + +/*Table structure for table `sys_tenant` */ + +DROP TABLE IF EXISTS `sys_tenant`; + +CREATE TABLE `sys_tenant` ( + `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '访问ID', + `create_by` varchar(64) DEFAULT NULL COMMENT '创建者', + `create_time` datetime DEFAULT NULL COMMENT '创建日期', + `update_by` varchar(64) DEFAULT NULL COMMENT '更新者', + `update_time` datetime DEFAULT NULL COMMENT '更新日期', + `del_flag` char(1) DEFAULT NULL COMMENT '删除标识', + `remark` text COMMENT '备注', + `tenant_id` varchar(64) DEFAULT NULL COMMENT '租户标识', + `contact` varchar(64) NOT NULL COMMENT '联系人', + `phone` varchar(64) NOT NULL COMMENT '电话', + `name` varchar(64) NOT NULL COMMENT '租户名称', + `user_id` varchar(64) DEFAULT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb4 COMMENT='租户管理'; + +/*Data for the table `sys_tenant` */ + +insert into `sys_tenant`(`id`,`create_by`,`create_time`,`update_by`,`update_time`,`del_flag`,`remark`,`tenant_id`,`contact`,`phone`,`name`,`user_id`) values (1,NULL,NULL,NULL,NULL,NULL,NULL,'00000000','sunseagear','1311111111','sunseagear','1'),(2,NULL,NULL,NULL,NULL,NULL,NULL,'48927269','若依','15888888888','Ruoyi-Vue-S','103'),(3,NULL,NULL,NULL,NULL,NULL,NULL,'15839669','测试','13111111111','测试','104'); + +/*Table structure for table `sys_user` */ + +DROP TABLE IF EXISTS `sys_user`; + +CREATE TABLE `sys_user` ( + `user_id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '用户ID', + `dept_id` bigint(20) DEFAULT NULL COMMENT '部门ID', + `user_name` varchar(30) NOT NULL COMMENT '用户账号', + `nick_name` varchar(30) NOT NULL COMMENT '用户昵称', + `user_type` varchar(2) DEFAULT '00' COMMENT '用户类型(00系统用户)', + `email` varchar(50) DEFAULT '' COMMENT '用户邮箱', + `phonenumber` varchar(11) DEFAULT '' COMMENT '手机号码', + `sex` char(1) DEFAULT '0' COMMENT '用户性别(0男 1女 2未知)', + `avatar` varchar(100) DEFAULT '' COMMENT '头像地址', + `password` varchar(100) DEFAULT '' COMMENT '密码', + `status` char(1) DEFAULT '0' COMMENT '帐号状态(0正常 1停用)', + `del_flag` char(1) DEFAULT '0' COMMENT '删除标志(0代表存在 2代表删除)', + `login_ip` varchar(128) DEFAULT '' COMMENT '最后登录IP', + `login_date` datetime DEFAULT NULL COMMENT '最后登录时间', + `create_by` varchar(64) DEFAULT '' COMMENT '创建者', + `create_time` datetime DEFAULT NULL COMMENT '创建时间', + `update_by` varchar(64) DEFAULT '' COMMENT '更新者', + `update_time` datetime DEFAULT NULL COMMENT '更新时间', + `remark` varchar(500) DEFAULT NULL COMMENT '备注', + `tenant_id` varchar(8) NOT NULL DEFAULT '00000000', + PRIMARY KEY (`user_id`) +) ENGINE=InnoDB AUTO_INCREMENT=105 DEFAULT CHARSET=utf8mb4 COMMENT='用户信息表'; + +/*Data for the table `sys_user` */ + +insert into `sys_user`(`user_id`,`dept_id`,`user_name`,`nick_name`,`user_type`,`email`,`phonenumber`,`sex`,`avatar`,`password`,`status`,`del_flag`,`login_ip`,`login_date`,`create_by`,`create_time`,`update_by`,`update_time`,`remark`,`tenant_id`) values (1,103,'admin','若依','00','ry@163.com','15888888888','1','','$2a$10$7JB720yubVSZvUI0rEqK/.VqGOZTH.ulu33dHOiBE8ByOhJIrdAu2','0','0','127.0.0.1','2022-01-16 20:37:55','admin','2021-09-21 17:00:35','','2022-01-16 20:37:56','管理员','00000000'),(2,105,'ry','若依','00','ry@qq.com','15666666666','1','','$2a$10$7JB720yubVSZvUI0rEqK/.VqGOZTH.ulu33dHOiBE8ByOhJIrdAu2','0','0','127.0.0.1','2021-10-25 19:01:39','admin','2021-09-21 17:00:35','admin','2021-10-25 19:01:37','测试员','00000000'),(103,203,'ruoyi','Ruoyi-Vue-S','00','','15888888888','0','','$2a$10$7JB720yubVSZvUI0rEqK/.VqGOZTH.ulu33dHOiBE8ByOhJIrdAu2','0','0','127.0.0.1','2021-10-25 11:36:13','','2021-10-12 15:56:31','','2021-10-25 11:36:13','租户管理员','48927269'),(104,NULL,'test','测试','00','','13111111111','0','','$2a$10$T0k7h.P/z9gy/nJuVdsvn.cJup9m7WllbqU4FxeCkOSJtEy72M8mi','0','0','127.0.0.1','2021-11-11 10:38:15','','2021-11-11 10:37:56','','2021-11-11 10:38:14',NULL,'15839669'); + +/*Table structure for table `sys_user_post` */ + +DROP TABLE IF EXISTS `sys_user_post`; + +CREATE TABLE `sys_user_post` ( + `user_id` bigint(20) NOT NULL COMMENT '用户ID', + `post_id` bigint(20) NOT NULL COMMENT '岗位ID', + PRIMARY KEY (`user_id`,`post_id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='用户与岗位关联表'; + +/*Data for the table `sys_user_post` */ + +insert into `sys_user_post`(`user_id`,`post_id`) values (1,1),(2,2); + +/*Table structure for table `sys_user_role` */ + +DROP TABLE IF EXISTS `sys_user_role`; + +CREATE TABLE `sys_user_role` ( + `user_id` bigint(20) NOT NULL COMMENT '用户ID', + `role_id` bigint(20) NOT NULL COMMENT '角色ID', + PRIMARY KEY (`user_id`,`role_id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='用户和角色关联表'; + +/*Data for the table `sys_user_role` */ + +insert into `sys_user_role`(`user_id`,`role_id`) values (1,1),(2,2),(2,100),(103,2),(104,2); + +/*!40101 SET SQL_MODE=@OLD_SQL_MODE */; +/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; +/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; +/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;