From 1a086a52599d0f1792a43e1214d0385f8af528e5 Mon Sep 17 00:00:00 2001 From: Raod <1130305001@qq.com> Date: Thu, 24 Jun 2021 13:58:52 +0800 Subject: [PATCH] =?UTF-8?q?=E7=AE=80=E5=8D=95=E7=99=BB=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- derby.log | 13 ++ report-core/pom.xml | 51 +++--- .../gaea/business/ReportApplication.java | 6 +- .../business/cache/ReportCacheHelper.java | 29 ++-- .../gaea/business/code/ResponseCode.java | 10 ++ .../config/BusinessAutoConfiguration.java | 2 +- .../gaea/business/filter/TokenFilter.java | 75 ++++++++ .../controller/GaeaExportController.java | 74 -------- .../export/controller/dto/GaeaExportDTO.java | 144 ---------------- .../controller/param/GaeaExportParam.java | 26 --- .../param/GaeaExportQueryParam.java | 23 --- .../modules/export/dao/GaeaExportMapper.java | 30 ---- .../modules/export/dao/entity/GaeaExport.java | 126 -------------- .../export/service/GaeaExportService.java | 32 ---- .../service/impl/GaeaExportServiceImpl.java | 73 -------- .../file/controller/dto/GaeaFileDTO.java | 58 ++----- .../file/controller/param/GaeaFileParam.java | 16 +- .../modules/file/entity/GaeaFile.java | 55 ++---- .../modules/file/service/GaeaFileService.java | 2 +- .../service/impl/GaeaFileServiceImpl.java | 43 ++--- .../modules/file/util/StringPatternUtil.java | 98 +++++++++++ .../controller/GaeaUiI18nController.java | 100 ----------- .../controller/dto/GaeaUiI18nDto.java | 50 ------ .../controller/param/GaeaUiI18nParam.java | 54 ------ .../gaeaUiI18n/dao/GaeaUiI18nMapper.java | 33 ---- .../gaeaUiI18n/dao/entity/GaeaUiI18n.java | 46 ----- .../gaeaUiI18n/service/GaeaUiI18nService.java | 46 ----- .../gaeaUiI18n/service/impl/ColumnDesc.java | 11 -- .../service/impl/GaeaUiI18nServiceImpl.java | 162 ------------------ .../service/impl/ReportExcelServiceImpl.java | 2 +- .../user/controller/LoginController.java | 34 ++++ .../modules/user/dao/GaeaUserMapper.java | 12 ++ .../modules/user/dao/entity/GaeaUser.java | 23 +++ .../modules/user/dto/GaeaUserDTO.java | 23 +++ .../modules/user/service/UserService.java | 10 ++ .../user/service/impl/UserServiceImpl.java | 86 ++++++++++ .../src/main/resources/bootstrap-dev.yml | 19 +- report-core/src/main/resources/bootstrap.yml | 2 +- .../resources/i18n/messages_en_US.properties | 3 + .../resources/i18n/messages_zh_CN.properties | 4 + .../resources/mapper/GaeaExportMapper.xml | 48 ------ .../resources/mapper/GaeaUiI18nMapper.xml | 50 ------ 42 files changed, 508 insertions(+), 1296 deletions(-) create mode 100644 report-core/src/main/java/com/anjiplus/template/gaea/business/filter/TokenFilter.java delete mode 100644 report-core/src/main/java/com/anjiplus/template/gaea/business/modules/export/controller/GaeaExportController.java delete mode 100644 report-core/src/main/java/com/anjiplus/template/gaea/business/modules/export/controller/dto/GaeaExportDTO.java delete mode 100644 report-core/src/main/java/com/anjiplus/template/gaea/business/modules/export/controller/param/GaeaExportParam.java delete mode 100644 report-core/src/main/java/com/anjiplus/template/gaea/business/modules/export/controller/param/GaeaExportQueryParam.java delete mode 100644 report-core/src/main/java/com/anjiplus/template/gaea/business/modules/export/dao/GaeaExportMapper.java delete mode 100644 report-core/src/main/java/com/anjiplus/template/gaea/business/modules/export/dao/entity/GaeaExport.java delete mode 100644 report-core/src/main/java/com/anjiplus/template/gaea/business/modules/export/service/GaeaExportService.java delete mode 100644 report-core/src/main/java/com/anjiplus/template/gaea/business/modules/export/service/impl/GaeaExportServiceImpl.java create mode 100644 report-core/src/main/java/com/anjiplus/template/gaea/business/modules/file/util/StringPatternUtil.java delete mode 100644 report-core/src/main/java/com/anjiplus/template/gaea/business/modules/gaeaUiI18n/controller/GaeaUiI18nController.java delete mode 100644 report-core/src/main/java/com/anjiplus/template/gaea/business/modules/gaeaUiI18n/controller/dto/GaeaUiI18nDto.java delete mode 100644 report-core/src/main/java/com/anjiplus/template/gaea/business/modules/gaeaUiI18n/controller/param/GaeaUiI18nParam.java delete mode 100644 report-core/src/main/java/com/anjiplus/template/gaea/business/modules/gaeaUiI18n/dao/GaeaUiI18nMapper.java delete mode 100644 report-core/src/main/java/com/anjiplus/template/gaea/business/modules/gaeaUiI18n/dao/entity/GaeaUiI18n.java delete mode 100644 report-core/src/main/java/com/anjiplus/template/gaea/business/modules/gaeaUiI18n/service/GaeaUiI18nService.java delete mode 100644 report-core/src/main/java/com/anjiplus/template/gaea/business/modules/gaeaUiI18n/service/impl/ColumnDesc.java delete mode 100644 report-core/src/main/java/com/anjiplus/template/gaea/business/modules/gaeaUiI18n/service/impl/GaeaUiI18nServiceImpl.java create mode 100644 report-core/src/main/java/com/anjiplus/template/gaea/business/modules/user/controller/LoginController.java create mode 100644 report-core/src/main/java/com/anjiplus/template/gaea/business/modules/user/dao/GaeaUserMapper.java create mode 100644 report-core/src/main/java/com/anjiplus/template/gaea/business/modules/user/dao/entity/GaeaUser.java create mode 100644 report-core/src/main/java/com/anjiplus/template/gaea/business/modules/user/dto/GaeaUserDTO.java create mode 100644 report-core/src/main/java/com/anjiplus/template/gaea/business/modules/user/service/UserService.java create mode 100644 report-core/src/main/java/com/anjiplus/template/gaea/business/modules/user/service/impl/UserServiceImpl.java delete mode 100644 report-core/src/main/resources/mapper/GaeaExportMapper.xml delete mode 100644 report-core/src/main/resources/mapper/GaeaUiI18nMapper.xml diff --git a/derby.log b/derby.log index e69de29b..408edefa 100644 --- a/derby.log +++ b/derby.log @@ -0,0 +1,13 @@ +---------------------------------------------------------------- +Thu Jun 24 13:44:40 CST 2021: +Booting Derby version The Apache Software Foundation - Apache Derby - 10.14.2.0 - (1828579): instance a816c00e-017a-3c8c-7997-00000fdd7788 +on database directory memory:D:\anji-code\gitee\aj-report\55b30257-1477-453c-b5b1-a9bbd7a931a7 with class loader sun.misc.Launcher$AppClassLoader@18b4aac2 +Loaded from file:/C:/Users/raodeming/.m2/repository/org/apache/derby/derby/10.14.2.0/derby-10.14.2.0.jar +java.vendor=Oracle Corporation +java.runtime.version=1.8.0_191-b12 +user.dir=D:\anji-code\gitee\aj-report +os.name=Windows 10 +os.arch=amd64 +os.version=10.0 +derby.system.home=null +Database Class Loader started - derby.database.classpath='' diff --git a/report-core/pom.xml b/report-core/pom.xml index 9afe842f..7bc70333 100644 --- a/report-core/pom.xml +++ b/report-core/pom.xml @@ -14,17 +14,13 @@ - com.anjiplus.template.gaea - template-gaea-common + org.projectlombok + lombok + + + com.anji-plus + spring-boot-gaea - - - - - - - - org.springframework.boot spring-boot-starter-data-redis @@ -33,10 +29,32 @@ - com.anjiplus.template.gaea - template-gaea-generator + org.springframework.boot + spring-boot-starter-web + + + + org.springframework.cloud + spring-cloud-context + + + org.springframework.boot + spring-boot-starter-freemarker + + + + + + + + + + + + + com.baomidou mybatis-plus-boot-starter @@ -64,15 +82,6 @@ 2.10.6 - - - - - - - - - com.anji-plus spring-boot-starter-gaea-export diff --git a/report-core/src/main/java/com/anjiplus/template/gaea/business/ReportApplication.java b/report-core/src/main/java/com/anjiplus/template/gaea/business/ReportApplication.java index 45d32084..b4f7ea38 100644 --- a/report-core/src/main/java/com/anjiplus/template/gaea/business/ReportApplication.java +++ b/report-core/src/main/java/com/anjiplus/template/gaea/business/ReportApplication.java @@ -4,6 +4,7 @@ import com.anji.plus.gaea.annotation.enabled.EnabledGaeaConfiguration; import org.mybatis.spring.annotation.MapperScan; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.ComponentScans; /** * 业务模板 @@ -11,7 +12,10 @@ import org.springframework.boot.autoconfigure.SpringBootApplication; * @since 2021-02-03 */ @EnabledGaeaConfiguration -@SpringBootApplication +@SpringBootApplication(scanBasePackages = { + "com.anjiplus.template.gaea", + "com.anji.plus" +}) @MapperScan(basePackages = { "com.anjiplus.template.gaea.business.modules.*.dao", "com.anjiplus.template.gaea.business.modules.*.**.dao", diff --git a/report-core/src/main/java/com/anjiplus/template/gaea/business/cache/ReportCacheHelper.java b/report-core/src/main/java/com/anjiplus/template/gaea/business/cache/ReportCacheHelper.java index 5010945c..7cb03a5b 100644 --- a/report-core/src/main/java/com/anjiplus/template/gaea/business/cache/ReportCacheHelper.java +++ b/report-core/src/main/java/com/anjiplus/template/gaea/business/cache/ReportCacheHelper.java @@ -13,7 +13,6 @@ import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Set; -import java.util.concurrent.TimeUnit; public class ReportCacheHelper implements CacheHelper, ApplicationContextAware { @@ -24,7 +23,7 @@ public class ReportCacheHelper implements CacheHelper, ApplicationContextAware { public String stringGet(String key) { Cache.ValueWrapper valueWrapper = cache.get(key); if (valueWrapper != null) { - return (String)valueWrapper.get(); + return (String) valueWrapper.get(); } return CacheHelper.super.stringGet(key); } @@ -38,7 +37,15 @@ public class ReportCacheHelper implements CacheHelper, ApplicationContextAware { @Override public boolean exist(String key) { - return cache.get(key)!=null; + String cacheHoldTime = stringGet(key + "_HoldTime"); + if (cacheHoldTime != null && Long.parseLong(cacheHoldTime) > 0) { + if (Long.parseLong(cacheHoldTime) < System.currentTimeMillis()) { + delete(key + "_HoldTime"); + delete(key); + return false; + } + } + return cache.get(key) != null; } @@ -47,10 +54,6 @@ public class ReportCacheHelper implements CacheHelper, ApplicationContextAware { cache.put(key, value); } - @Override - public void stringSetExpire(String key, String value, long time, TimeUnit timeUnit) { - CacheHelper.super.stringSetExpire(key, value, time, timeUnit); - } @Override public String regKey(String key) { @@ -59,7 +62,11 @@ public class ReportCacheHelper implements CacheHelper, ApplicationContextAware { @Override public void stringSetExpire(String key, String value, long seconds) { - CacheHelper.super.stringSetExpire(key, value, seconds); + stringSet(key, value); + if (seconds > 0) { + //缓存失效时间 + stringSet(key + "_HoldTime", String.valueOf(System.currentTimeMillis() + seconds * 1000)); + } } @Override @@ -122,7 +129,9 @@ public class ReportCacheHelper implements CacheHelper, ApplicationContextAware { @Override public boolean delete(String key) { - cache.evict(key); + if (exist(key)) { + cache.evict(key); + } return true; } @@ -136,6 +145,6 @@ public class ReportCacheHelper implements CacheHelper, ApplicationContextAware { @Override public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { /*基于内存的本地缓存*/ - cache = (Cache)applicationContext.getBean("ehCacheCache"); + cache = (Cache) applicationContext.getBean("ehCacheCache"); } } diff --git a/report-core/src/main/java/com/anjiplus/template/gaea/business/code/ResponseCode.java b/report-core/src/main/java/com/anjiplus/template/gaea/business/code/ResponseCode.java index 06f80598..742ba67e 100644 --- a/report-core/src/main/java/com/anjiplus/template/gaea/business/code/ResponseCode.java +++ b/report-core/src/main/java/com/anjiplus/template/gaea/business/code/ResponseCode.java @@ -6,6 +6,15 @@ package com.anjiplus.template.gaea.business.code; * @since 2021-02-22 */ public interface ResponseCode { + /** + * 用户名或者密码不正确 + */ + String LOGIN_ERROR = "login.error"; + + /** + * 用户token过期 + */ + String USER_TOKEN_EXPIRED = "User.token.expired"; /** * 字典项重复 @@ -98,4 +107,5 @@ public interface ResponseCode { String SET_CODE_ISEXIST = "4008"; String SOURCE_CODE_ISEXIST = "4009"; String CLASS_NOT_FOUND = "4010"; + } diff --git a/report-core/src/main/java/com/anjiplus/template/gaea/business/config/BusinessAutoConfiguration.java b/report-core/src/main/java/com/anjiplus/template/gaea/business/config/BusinessAutoConfiguration.java index ce4ade6f..a5fbff03 100644 --- a/report-core/src/main/java/com/anjiplus/template/gaea/business/config/BusinessAutoConfiguration.java +++ b/report-core/src/main/java/com/anjiplus/template/gaea/business/config/BusinessAutoConfiguration.java @@ -30,7 +30,7 @@ public class BusinessAutoConfiguration { return new ApplicationInitRunner(); } - @Bean("gaeaCacheHelper") + @Bean public CacheHelper gaeaCacheHelper(){ return new ReportCacheHelper(); } diff --git a/report-core/src/main/java/com/anjiplus/template/gaea/business/filter/TokenFilter.java b/report-core/src/main/java/com/anjiplus/template/gaea/business/filter/TokenFilter.java new file mode 100644 index 00000000..1fe886b9 --- /dev/null +++ b/report-core/src/main/java/com/anjiplus/template/gaea/business/filter/TokenFilter.java @@ -0,0 +1,75 @@ +package com.anjiplus.template.gaea.business.filter; + + +import com.alibaba.fastjson.JSONObject; +import com.anji.plus.gaea.bean.ResponseBean; +import com.anji.plus.gaea.cache.CacheHelper; +import com.anji.plus.gaea.utils.JwtBean; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import javax.servlet.*; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; + +/** + * 简单的鉴权 + * Created by raodeming on 2021/6/24. + */ +@Component +public class TokenFilter implements Filter { + @Autowired + private CacheHelper cacheHelper; + @Autowired + private JwtBean jwtBean; + + @Override + public void init(FilterConfig filterConfig) throws ServletException { + Filter.super.init(filterConfig); + } + + @Override + public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException { + HttpServletRequest request = (HttpServletRequest) servletRequest; + HttpServletResponse response = (HttpServletResponse) servletResponse; + String uri = request.getRequestURI(); + + if (!uri.startsWith("/login")) { + + //获取token + String authorization = request.getHeader("Authorization"); + if (StringUtils.isBlank(authorization)) { + error(response); + return; + } + + String username = jwtBean.getUsername(authorization); +// String uuid = jwtBean.getUUID(authorization); + + if (!cacheHelper.exist(username)) { + error(response); + return; + } + + //延长有效期 + cacheHelper.stringSetExpire(username, authorization, 3600); + } + + //执行 + filterChain.doFilter(request, response); + + } + + @Override + public void destroy() { + Filter.super.destroy(); + } + + private void error(HttpServletResponse response) throws IOException { + ResponseBean responseBean = ResponseBean.builder().code("500").message("The Token has expired").build(); + response.getWriter().print(JSONObject.toJSONString(responseBean)); + response.getOutputStream().flush(); + } +} diff --git a/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/export/controller/GaeaExportController.java b/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/export/controller/GaeaExportController.java deleted file mode 100644 index d5206167..00000000 --- a/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/export/controller/GaeaExportController.java +++ /dev/null @@ -1,74 +0,0 @@ -package com.anjiplus.template.gaea.business.modules.export.controller; - -import com.anji.plus.gaea.annotation.log.GaeaAuditLog; -import com.anji.plus.gaea.bean.ResponseBean; -import com.anji.plus.gaea.curd.controller.GaeaBaseController; -import com.anji.plus.gaea.curd.service.GaeaBaseService; -import com.anji.plus.gaea.utils.GaeaBeanUtils; -import com.anjiplus.template.gaea.business.modules.export.controller.dto.GaeaExportDTO; -import com.anjiplus.template.gaea.business.modules.export.controller.param.GaeaExportParam; -import com.anjiplus.template.gaea.business.modules.export.controller.param.GaeaExportQueryParam; -import com.anjiplus.template.gaea.business.modules.export.dao.entity.GaeaExport; -import com.anjiplus.template.gaea.business.modules.export.service.GaeaExportService; -import com.anji.plus.gaea.export.vo.ExportOperation; -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import io.swagger.annotations.Api; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import java.util.List; -import java.util.stream.Collectors; - -/** - * 导出中心(GaeaExport)实体类 - * - * @author makejava - * @since 2021-02-07 17:12:31 - */ -@RestController -@RequestMapping("/export") -@Api(value = "/export", tags = "导出中心") -public class GaeaExportController extends GaeaBaseController { - @Autowired - private GaeaExportService gaeaExportService; - - @Override - public GaeaBaseService getService() { - return gaeaExportService; - } - - @Override - public GaeaExport getEntity() { - return new GaeaExport(); - } - - @Override - public GaeaExportDTO getDTO() { - return new GaeaExportDTO(); - } - - @PostMapping("/queryAdvanceExport") - @GaeaAuditLog(pageTitle = "高级查询") - public ResponseBean queryExportInfo(@RequestBody GaeaExportQueryParam param) { - Page exportList=gaeaExportService.getExportListPage(param); - List list = exportList.getRecords().stream() - .map(entity -> GaeaBeanUtils.copyAndFormatter(entity, getDTO())) - .collect(Collectors.toList()); - Page pageDto = new Page<>(); - pageDto.setCurrent(exportList.getCurrent()); - pageDto.setRecords(list); - pageDto.setPages(exportList.getPages()); - pageDto.setTotal(exportList.getTotal()); - pageDto.setSize(exportList.getSize()); - return responseSuccessWithData(pageDto); - } - - @PostMapping("/saveExportLog") - public Boolean export(@RequestBody ExportOperation exportOperation) { - return gaeaExportService.saveExportLog(exportOperation); - } - -} diff --git a/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/export/controller/dto/GaeaExportDTO.java b/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/export/controller/dto/GaeaExportDTO.java deleted file mode 100644 index b608ee91..00000000 --- a/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/export/controller/dto/GaeaExportDTO.java +++ /dev/null @@ -1,144 +0,0 @@ -package com.anjiplus.template.gaea.business.modules.export.controller.dto; - -import com.anji.plus.gaea.curd.dto.GaeaBaseDTO; -import com.fasterxml.jackson.annotation.JsonFormat; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; - -import java.time.LocalDateTime; -import java.util.Date; - -/** - * 导出中心(GaeaExport)实体类 - * - * @author makejava - * @since 2021-02-07 17:12:25 - */ -@ApiModel(value = "导出中心") -public class GaeaExportDTO extends GaeaBaseDTO { - /** - * 文件在t_file中的id,前端传它来读流接口显示,http://auth/file/download/fileId - */ - @ApiModelProperty(value = "文件在t_file中的id,前端传它来读流接口显示,http://auth/file/download/fileId") - private String fileId; - /** - * 文件标题,比如:对账单报表6月份报表 - */ - @ApiModelProperty(value = "文件标题,比如:对账单报表6月份报表") - private String fileTitle; - /** - * 导出前,查询的数据开始时间 - */ - @ApiModelProperty(value = "导出前,查询的数据开始时间") - @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8") - private LocalDateTime resultStartTime; - /** - * 导出前,查询的数据结束时间 - */ - @ApiModelProperty(value = "导出前,查询的数据结束时间") - @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8") - private LocalDateTime resultEndTime; - /** - * 导出查询结果,数据总条数 - */ - @ApiModelProperty(value = "导出查询结果,数据总条数") - private Long resultSize; - /** - * 文件导出触发时间 - */ - @ApiModelProperty(value = "文件导出触发时间") - @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8") - private LocalDateTime fileCreateTime; - /** - * 文件生成完成时间 - */ - @ApiModelProperty(value = "文件生成完成时间") - @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8") - private LocalDateTime fileFinishTime; - /** - * 文件状态,creating生成中,success生成成功,failed生成失败 - */ - @ApiModelProperty(value = "文件状态,creating生成中,success生成成功,failed生成失败") - private String fileStatus; - /** - * 备注 - */ - @ApiModelProperty(value = "备注") - private String remark; - - public String getFileId() { - return fileId; - } - - public void setFileId(String fileId) { - this.fileId = fileId; - } - - public String getFileTitle() { - return fileTitle; - } - - public void setFileTitle(String fileTitle) { - this.fileTitle = fileTitle; - } - - - - public Long getResultSize() { - return resultSize; - } - - public void setResultSize(Long resultSize) { - this.resultSize = resultSize; - } - - public LocalDateTime getResultStartTime() { - return resultStartTime; - } - - public void setResultStartTime(LocalDateTime resultStartTime) { - this.resultStartTime = resultStartTime; - } - - public LocalDateTime getResultEndTime() { - return resultEndTime; - } - - public void setResultEndTime(LocalDateTime resultEndTime) { - this.resultEndTime = resultEndTime; - } - - public LocalDateTime getFileCreateTime() { - return fileCreateTime; - } - - public void setFileCreateTime(LocalDateTime fileCreateTime) { - this.fileCreateTime = fileCreateTime; - } - - public LocalDateTime getFileFinishTime() { - return fileFinishTime; - } - - public void setFileFinishTime(LocalDateTime fileFinishTime) { - this.fileFinishTime = fileFinishTime; - } - - public String getFileStatus() { - return fileStatus; - } - - public void setFileStatus(String fileStatus) { - this.fileStatus = fileStatus; - } - - public String getRemark() { - return remark; - } - - public void setRemark(String remark) { - this.remark = remark; - } - - -} diff --git a/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/export/controller/param/GaeaExportParam.java b/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/export/controller/param/GaeaExportParam.java deleted file mode 100644 index bafb04ec..00000000 --- a/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/export/controller/param/GaeaExportParam.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.anjiplus.template.gaea.business.modules.export.controller.param; - - -import com.anji.plus.gaea.annotation.Query; -import com.anji.plus.gaea.constant.QueryEnum; -import com.anji.plus.gaea.curd.params.PageParam; -import lombok.Getter; -import lombok.Setter; - -import java.io.Serializable; - -/** - * 导出中心(GaeaExport)param - * - * @author makejava - * @since 2021-02-07 17:12:26 - */ -@Getter -@Setter -public class GaeaExportParam extends PageParam implements Serializable { - /** - * 文件标题 - */ - @Query(QueryEnum.LIKE) - private String fileTitle; -} diff --git a/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/export/controller/param/GaeaExportQueryParam.java b/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/export/controller/param/GaeaExportQueryParam.java deleted file mode 100644 index dd5eb2ee..00000000 --- a/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/export/controller/param/GaeaExportQueryParam.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.anjiplus.template.gaea.business.modules.export.controller.param; - -import com.anjiplus.template.gaea.common.dto.BaseQueryBO; -import lombok.Getter; -import lombok.Setter; - -import java.io.Serializable; - -/** - * 功能描述: - * - * @Author: peiyanni - * @Date: 2021/2/20 12:49 - */ -@Setter -@Getter -public class GaeaExportQueryParam extends BaseQueryBO implements Serializable{ - - /** - * 文件标题 - */ - private String fileTitle; -} diff --git a/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/export/dao/GaeaExportMapper.java b/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/export/dao/GaeaExportMapper.java deleted file mode 100644 index df67e390..00000000 --- a/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/export/dao/GaeaExportMapper.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.anjiplus.template.gaea.business.modules.export.dao; - -import com.anjiplus.template.gaea.business.modules.export.controller.param.GaeaExportQueryParam; -import com.anjiplus.template.gaea.business.modules.export.dao.entity.GaeaExport; -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import com.baomidou.mybatisplus.core.toolkit.Constants; -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import com.anji.plus.gaea.curd.mapper.GaeaBaseMapper; -import org.apache.ibatis.annotations.Mapper; -import org.apache.ibatis.annotations.Param; - -import java.util.List; - -/** - * 导出中心(GaeaExport)Mapper - * - * @author makejava - * @since 2021-02-07 17:12:16 - */ -@Mapper -public interface GaeaExportMapper extends GaeaBaseMapper { - /** - * 导出信息的高级查询 - * @param page - * @param bo - * @param wrapper - * @return - */ - List queryExportInfo(Page page, @Param("bo") GaeaExportQueryParam bo, @Param(Constants.WRAPPER) QueryWrapper wrapper); -} diff --git a/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/export/dao/entity/GaeaExport.java b/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/export/dao/entity/GaeaExport.java deleted file mode 100644 index 632153fd..00000000 --- a/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/export/dao/entity/GaeaExport.java +++ /dev/null @@ -1,126 +0,0 @@ -package com.anjiplus.template.gaea.business.modules.export.dao.entity; - -import com.anji.plus.gaea.annotation.Formatter; -import com.baomidou.mybatisplus.annotation.TableName; -import com.anji.plus.gaea.curd.entity.GaeaBaseEntity; - -import java.io.Serializable; -import java.time.LocalDateTime; - -/** - * 导出中心(GaeaExport)实体类 - * - * @author peiyanni - * @since 2021-02-07 17:12:14 - */ -@TableName("gaea_export") -public class GaeaExport extends GaeaBaseEntity implements Serializable { - /** - * 文件在t_file中的id,前端传它来读流接口显示,http://auth/file/download/fileId - */ - private String fileId; - /** - * 文件标题,比如:对账单报表6月份报表 - */ - private String fileTitle; - /** - * 导出前,查询的数据开始时间 - */ - private LocalDateTime resultStartTime; - /** - * 导出前,查询的数据结束时间 - */ - private LocalDateTime resultEndTime; - /** - * 导出查询结果,数据总条数 - */ - private Long resultSize; - /** 文件导出触发时间 */ - private LocalDateTime fileCreateTime; - - /** 文件生成完成时间 */ - private LocalDateTime fileFinishTime; - /** - * 文件状态,creating生成中,success生成成功,failed生成失败 - */ - @Formatter(dictCode="FILE_STATUS",targetField = "fileStatus") - private String fileStatus; - /** - * 备注 - */ - private String remark; - - public String getFileId() { - return fileId; - } - - public void setFileId(String fileId) { - this.fileId = fileId; - } - - public String getFileTitle() { - return fileTitle; - } - - public void setFileTitle(String fileTitle) { - this.fileTitle = fileTitle; - } - - public LocalDateTime getResultStartTime() { - return resultStartTime; - } - - public LocalDateTime getResultEndTime() { - return resultEndTime; - } - - public LocalDateTime getFileFinishTime() { - return fileFinishTime; - } - - public void setFileFinishTime(LocalDateTime fileFinishTime) { - this.fileFinishTime = fileFinishTime; - } - - public Long getResultSize() { - return resultSize; - } - - public void setResultSize(Long resultSize) { - this.resultSize = resultSize; - } - - public void setResultStartTime(LocalDateTime resultStartTime) { - this.resultStartTime = resultStartTime; - } - - public void setResultEndTime(LocalDateTime resultEndTime) { - this.resultEndTime = resultEndTime; - } - - public LocalDateTime getFileCreateTime() { - return fileCreateTime; - } - - public void setFileCreateTime(LocalDateTime fileCreateTime) { - this.fileCreateTime = fileCreateTime; - } - - public String getFileStatus() { - return fileStatus; - } - - public void setFileStatus(String fileStatus) { - this.fileStatus = fileStatus; - } - - public String getRemark() { - return remark; - } - - public void setRemark(String remark) { - this.remark = remark; - } - - -} diff --git a/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/export/service/GaeaExportService.java b/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/export/service/GaeaExportService.java deleted file mode 100644 index 7d02207e..00000000 --- a/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/export/service/GaeaExportService.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.anjiplus.template.gaea.business.modules.export.service; - -import com.anjiplus.template.gaea.business.modules.export.dao.entity.GaeaExport; -import com.anji.plus.gaea.export.vo.ExportOperation; -import com.anjiplus.template.gaea.business.modules.export.controller.param.GaeaExportParam; -import com.anjiplus.template.gaea.business.modules.export.controller.param.GaeaExportQueryParam; -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import com.anji.plus.gaea.curd.service.GaeaBaseService; - -/** - * 导出中心(GaeaExport)Service - * - * @author peiyanni - * @since 2021-02-07 17:12:22 - */ -public interface GaeaExportService extends GaeaBaseService { - /** - * 导出中心-高级查询 - * 需要 QueryWrapper 类型的动态参数,用来进行获取组装好的QueryWrapper对象 - * @param queryParam - * @return - */ - Page getExportListPage(GaeaExportQueryParam queryParam, QueryWrapper ...qe); - - /** - * 导出操作,保存导出日志信息到表Gaea_export - * @param exportOperation - * @return - */ - Boolean saveExportLog(ExportOperation exportOperation); -} diff --git a/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/export/service/impl/GaeaExportServiceImpl.java b/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/export/service/impl/GaeaExportServiceImpl.java deleted file mode 100644 index e3fb8e92..00000000 --- a/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/export/service/impl/GaeaExportServiceImpl.java +++ /dev/null @@ -1,73 +0,0 @@ -package com.anjiplus.template.gaea.business.modules.export.service.impl; - -import com.anjiplus.template.gaea.business.modules.export.dao.GaeaExportMapper; -import com.anjiplus.template.gaea.business.modules.export.dao.entity.GaeaExport; -import com.anjiplus.template.gaea.business.modules.export.service.GaeaExportService; -import com.anjiplus.template.gaea.business.modules.file.dao.GaeaFileMapper; -import com.anjiplus.template.gaea.business.modules.file.entity.GaeaFile; -import com.anji.plus.gaea.export.vo.ExportOperation; -import com.anjiplus.template.gaea.business.modules.export.controller.param.GaeaExportQueryParam; -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import com.anjiplus.template.gaea.common.aop.GaeaQuery; -import com.anji.plus.gaea.curd.mapper.GaeaBaseMapper; -import org.springframework.beans.BeanUtils; -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; - -/** - * 导出中心(GaeaExport)ServiceImpl - * - * @author makejava - * @since 2021-02-07 17:12:24 - */ -@Service -public class GaeaExportServiceImpl implements GaeaExportService { - @Autowired - private GaeaExportMapper gaeaExportMapper; - @Autowired - private GaeaFileMapper gaeaFileMapper; - - @Override - public GaeaBaseMapper getMapper() { - return gaeaExportMapper; - } - - - @Override - @GaeaQuery - public Page getExportListPage(GaeaExportQueryParam queryParam, QueryWrapper... qe) { - Page page = new Page<>(queryParam.getPageNumber(), queryParam.getPageSize()); - QueryWrapper queryWrapper = (null != qe && qe.length > 0) ? qe[0] : null; - List gaeaExports = gaeaExportMapper.queryExportInfo(page, queryParam, queryWrapper); - page.setRecords(gaeaExports); - return page; - } - - @Override - @Transactional - public Boolean saveExportLog(ExportOperation exportOperation) { - //需要保存两张表数据 gaea_file ,gaea_export数据 - Date nowDate = new Date(); - GaeaFile gaeaFile = new GaeaFile(); - gaeaFile.setFileId(exportOperation.getFileId()); - gaeaFile.setFilePath(exportOperation.getFilePath()); - gaeaFile.setCreateBy(exportOperation.getCreaterUsername()); - gaeaFile.setCreateTime(nowDate); - gaeaFile.setUpdateBy(exportOperation.getCreaterUsername()); - gaeaFile.setUpdateTime(nowDate); - gaeaFileMapper.insert(gaeaFile); - GaeaExport export = new GaeaExport(); - BeanUtils.copyProperties(exportOperation, export); - export.setCreateBy(exportOperation.getCreaterUsername()); - export.setCreateTime(nowDate); - export.setUpdateBy(exportOperation.getCreaterUsername()); - export.setUpdateTime(nowDate); - gaeaExportMapper.insert(export); - return true; - } -} diff --git a/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/file/controller/dto/GaeaFileDTO.java b/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/file/controller/dto/GaeaFileDTO.java index 649c7f64..86a735cb 100644 --- a/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/file/controller/dto/GaeaFileDTO.java +++ b/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/file/controller/dto/GaeaFileDTO.java @@ -3,6 +3,7 @@ package com.anjiplus.template.gaea.business.modules.file.controller.dto; import com.anji.plus.gaea.curd.dto.GaeaBaseDTO; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; +import lombok.Data; /** * (GaeaFile)实体类 @@ -10,58 +11,21 @@ import io.swagger.annotations.ApiModelProperty; * @author peiyanni * @since 2021-02-18 14:48:27 */ -@ApiModel(value = "") +@Data public class GaeaFileDTO extends GaeaBaseDTO { - /** - * 文件uuid - */ + /** 文件标识 */ private String fileId; - /** - * 文件在linux中的完整目录,比如/app/dist/export/excel/${fileid}.xlsx - */ - @ApiModelProperty(value = "文件在linux中的完整目录,比如/app/dist/export/excel/${fileid}.xlsx") - private String filePath; - /** - * 通过接口的下载完整http路径 - */ - @ApiModelProperty(value = "通过接口的下载完整http路径") - private String urlPath; - /** - * 文件内容说明,比如 对账单(202001~202012) - */ - @ApiModelProperty(value = "文件内容说明,比如 对账单(202001~202012)") - private String fileInstruction; - - public String getFilePath() { - return filePath; - } - - public void setFilePath(String filePath) { - this.filePath = filePath; - } - public String getUrlPath() { - return urlPath; - } + /** 文件类型 */ + private String fileType; - public void setUrlPath(String urlPath) { - this.urlPath = urlPath; - } - - public String getFileInstruction() { - return fileInstruction; - } - - public void setFileInstruction(String fileInstruction) { - this.fileInstruction = fileInstruction; - } + /** 文件路径 */ + private String filePath; - public String getFileId() { - return fileId; - } + /** url路径 */ + private String urlPath; - public void setFileId(String fileId) { - this.fileId = fileId; - } + /** 内容说明 */ + private String fileInstruction; } diff --git a/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/file/controller/param/GaeaFileParam.java b/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/file/controller/param/GaeaFileParam.java index 0aa4040b..7d6bd835 100644 --- a/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/file/controller/param/GaeaFileParam.java +++ b/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/file/controller/param/GaeaFileParam.java @@ -15,17 +15,11 @@ import java.io.Serializable; */ public class GaeaFileParam extends PageParam implements Serializable { - /** - * 文件在linux中的完整目录,比如/app/dist/export/excel/${fileid}.xlsx - */ - @Query(QueryEnum.LIKE) + /** 模糊查询 */ + @Query(value = QueryEnum.LIKE) private String filePath; - public String getFilePath() { - return filePath; - } - - public void setFilePath(String filePath) { - this.filePath = filePath; - } + /** 模糊查询 */ + @Query(value = QueryEnum.EQ) + private String fileType; } diff --git a/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/file/entity/GaeaFile.java b/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/file/entity/GaeaFile.java index 38852564..13747600 100644 --- a/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/file/entity/GaeaFile.java +++ b/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/file/entity/GaeaFile.java @@ -2,6 +2,8 @@ package com.anjiplus.template.gaea.business.modules.file.entity; import com.baomidou.mybatisplus.annotation.TableName; import com.anji.plus.gaea.curd.entity.GaeaBaseEntity; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; import java.io.Serializable; @@ -12,54 +14,21 @@ import java.io.Serializable; * @since 2021-02-18 14:48:20 */ @TableName("gaea_file") +@Data public class GaeaFile extends GaeaBaseEntity implements Serializable { - /** - * 文件uuid - */ + @ApiModelProperty(value = "文件标识") private String fileId; - /** - * 文件在linux中的完整目录,比如/app/dist/export/excel/${fileid}.xlsx - */ - private String filePath; - /** - * 通过接口的下载完整http路径 - */ - private String urlPath; - /** - * 文件内容说明,比如 对账单(202001~202012) - */ - private String fileInstruction; - - public String getFilePath() { - return filePath; - } - - public void setFilePath(String filePath) { - this.filePath = filePath; - } - public String getUrlPath() { - return urlPath; - } + @ApiModelProperty(value = "文件类型") + private String fileType; - public void setUrlPath(String urlPath) { - this.urlPath = urlPath; - } - - public String getFileInstruction() { - return fileInstruction; - } - - public void setFileInstruction(String fileInstruction) { - this.fileInstruction = fileInstruction; - } + @ApiModelProperty(value = "文件路径") + private String filePath; - public String getFileId() { - return fileId; - } + @ApiModelProperty(value = "url路径") + private String urlPath; - public void setFileId(String fileId) { - this.fileId = fileId; - } + @ApiModelProperty(value = "内容说明") + private String fileInstruction; } diff --git a/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/file/service/GaeaFileService.java b/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/file/service/GaeaFileService.java index 6c7f0331..d7321404 100644 --- a/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/file/service/GaeaFileService.java +++ b/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/file/service/GaeaFileService.java @@ -24,7 +24,7 @@ public interface GaeaFileService extends GaeaBaseService getMapper() { @@ -70,15 +66,17 @@ public class GaeaFileServiceImpl implements GaeaFileService { @Override @Transactional(rollbackFor = Exception.class) - public String upload(MultipartFile file) { + public GaeaFile upload(MultipartFile file) { try { String fileName = file.getOriginalFilename(); if (StringUtils.isBlank(fileName)) { throw BusinessExceptionBuilder.build(ResponseCode.FILE_EMPTY_FILENAME); } + String suffixName = fileName.substring(fileName.lastIndexOf(".")); + String fileInstruction = fileName.substring(0, fileName.lastIndexOf(".")); //白名单校验(不区分大小写) - List list = new ArrayList(Arrays.asList(whiteList.split("\\|"))); + List list = new ArrayList<>(Arrays.asList(whiteList.split("\\|"))); list.addAll(list.stream().map(String::toUpperCase).collect(Collectors.toList())); if (!list.contains(suffixName)) { throw BusinessExceptionBuilder.build(ResponseCode.FILE_SUFFIX_UNSUPPORTED); @@ -88,19 +86,25 @@ public class GaeaFileServiceImpl implements GaeaFileService { String newFileName = fileId + suffixName; // 本地文件保存路径 String filePath = dictPath + newFileName; - String urlPath = fileDownloadPath + File.separator + fileId; + String urlPath = fileDownloadPath + java.io.File.separator + fileId; GaeaFile gaeaFile = new GaeaFile(); gaeaFile.setFilePath(filePath); gaeaFile.setFileId(fileId); gaeaFile.setUrlPath(urlPath); + gaeaFile.setFileType(suffixName.replace(".", "")); + gaeaFile.setFileInstruction(fileInstruction); gaeaFileMapper.insert(gaeaFile); //写文件 将文件保存/app/dictPath/upload/下 - File dest = new File(dictPath + newFileName); + java.io.File dest = new java.io.File(dictPath + newFileName); + java.io.File parentFile = dest.getParentFile(); + if (!parentFile.exists()) { + parentFile.mkdirs(); + } file.transferTo(dest); // 将完整的http访问路径返回 - return urlPath; + return gaeaFile; } catch (Exception e) { TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); log.error("file upload error: {}", e); @@ -127,16 +131,7 @@ public class GaeaFileServiceImpl implements GaeaFileService { } String filename = filePath.substring(filePath.lastIndexOf(File.separator)); String fileSuffix = filename.substring(filename.lastIndexOf(".")); - //特殊处理:如果是excel文件,则从t_export表中查询文件名 - List list = Arrays.asList(excelSuffix.split("\\|")); - if (list.contains(fileSuffix)) { - LambdaQueryWrapper exportWrapper = Wrappers.lambdaQuery(); - exportWrapper.eq(GaeaExport::getFileId, fileId); - GaeaExport exportPO = gaeaExportMapper.selectOne(exportWrapper); - if (null != exportPO) { - filename = exportPO.getFileTitle() + fileSuffix; - } - } + //根据文件后缀来判断,是显示图片\视频\音频,还是下载文件 File file = new File(filePath); ResponseEntity.BodyBuilder builder = ResponseEntity.ok(); diff --git a/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/file/util/StringPatternUtil.java b/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/file/util/StringPatternUtil.java new file mode 100644 index 00000000..e8d45e20 --- /dev/null +++ b/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/file/util/StringPatternUtil.java @@ -0,0 +1,98 @@ +package com.anjiplus.template.gaea.business.modules.file.util; + +import org.apache.commons.lang3.StringUtils; + +import java.util.regex.Matcher; +import java.util.regex.Pattern; + + +public class StringPatternUtil { + + + /** + * + *

Discription:[查找源sourceStr中是否包含pattern,返回boolean]

+ * @author + * @update:[日期YYYY-MM-DD] [更改人姓名] + * @param sourceStr + * @param pattern + * @return + */ + public static boolean StringMatch(String sourceStr,String pattern){ + boolean result=false; + try{ + if(StringUtils.isBlank(sourceStr)|| StringUtils.isBlank(pattern)){ + return result; + } + Pattern p = Pattern.compile(pattern); + Matcher m = p.matcher(sourceStr); + while (m.find()) { + //String aa=m.group(0); + result=true; + break ; + } + + }catch(Exception e){ + result=false; + } + return result; + } + + public static boolean StringMatchIgnoreCase(String sourceStr,String pattern){ + boolean result=false; + try{ + if(StringUtils.isBlank(sourceStr)|| StringUtils.isBlank(pattern)){ + return result; + } + sourceStr=sourceStr.toLowerCase(); + pattern=pattern.toLowerCase(); + result=StringMatch(sourceStr,pattern); + }catch(Exception e){ + result=false; + } + return result; + } + + + + /** + *

Discription:[查找源sourceStr中是否包含pattern,返回找到的字符串,未找到就返回空字符串]

+ * @author + * @update:[日期YYYY-MM-DD] [更改人姓名] + * @param sourceStr + * @param pattern + * @return + */ + public static String StringFind(String sourceStr,String pattern){ + String result=""; + try{ + if(StringUtils.isBlank(sourceStr)|| StringUtils.isBlank(pattern)){ + return result; + } + Pattern p = Pattern.compile(pattern); + Matcher m = p.matcher(sourceStr); + while (m.find()) { + result = m.group(0); + break; + } + }catch(Exception e){ + result=""; + } + return result; + } + + public static String replace(String sourceStr, String pattern, String replaceStr){ + String result=""; + try{ + if(StringUtils.isBlank(sourceStr)|| StringUtils.isBlank(pattern)){ + return result; + } + Pattern p = Pattern.compile(pattern); + Matcher m = p.matcher(sourceStr); + result = m.replaceAll(replaceStr); + }catch(Exception e){ + result=""; + } + return result; + } +} diff --git a/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/gaeaUiI18n/controller/GaeaUiI18nController.java b/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/gaeaUiI18n/controller/GaeaUiI18nController.java deleted file mode 100644 index 98a8ae72..00000000 --- a/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/gaeaUiI18n/controller/GaeaUiI18nController.java +++ /dev/null @@ -1,100 +0,0 @@ - -package com.anjiplus.template.gaea.business.modules.gaeaUiI18n.controller; - -import com.anji.plus.gaea.annotation.AccessKey; -import com.anji.plus.gaea.bean.ResponseBean; -import com.anji.plus.gaea.curd.service.GaeaBaseService; -import com.anji.plus.gaea.utils.GaeaBeanUtils; -import com.anji.plus.gaea.utils.GaeaUtils; -import com.anjiplus.template.gaea.business.base.BaseController; -import com.anjiplus.template.gaea.business.modules.gaeaUiI18n.controller.dto.GaeaUiI18nDto; -import com.anjiplus.template.gaea.business.modules.gaeaUiI18n.controller.param.GaeaUiI18nParam; -import com.anjiplus.template.gaea.business.modules.gaeaUiI18n.dao.entity.GaeaUiI18n; -import com.anjiplus.template.gaea.business.modules.gaeaUiI18n.service.GaeaUiI18nService; - -import io.swagger.annotations.Api; -import org.apache.commons.lang3.StringUtils; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.*; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -/** -* @desc ui文字国际化处理 controller -* @website https://gitee.com/anji-plus/gaea -* @author 王斌 -* @date 2021-03-25 15:30:59.286 -**/ -@RestController -@Api(tags = "ui文字国际化处理管理") -@RequestMapping("/gaeaUiI18n") -public class GaeaUiI18nController extends BaseController { - - @Autowired - private GaeaUiI18nService gaeaUiI18nService; - - @Override - public GaeaBaseService getService() { - return gaeaUiI18nService; - } - - @Override - public GaeaUiI18n getEntity() { - return new GaeaUiI18n(); - } - - @Override - public GaeaUiI18nDto getDTO() { - return new GaeaUiI18nDto(); - } - - - @GetMapping({"/{id}"}) - @AccessKey - @Override - public ResponseBean detail(@PathVariable("id") Long id) { - this.logger.info("{}根据ID查询服务开始,id为:{}", this.getClass().getSimpleName(), id); - GaeaUiI18n result = gaeaUiI18nService.getDetail(id); - GaeaUiI18nDto dto = this.getDTO(); - GaeaBeanUtils.copyAndFormatter(result, dto); - ResponseBean responseBean = this.responseSuccessWithData(this.resultDtoHandle(dto)); - this.logger.info("{}根据ID查询结束,结果:{}", this.getClass().getSimpleName(), GaeaUtils.toJSONString(responseBean)); - return responseBean; - } - - @PostMapping(value = "/scan") - public ResponseBean scan(@RequestParam String table){ - gaeaUiI18nService.scan(table); - return responseSuccess(); - } - - @GetMapping(value = "/getTables") - public ResponseBean getTables(){ - List t = gaeaUiI18nService.getUi18nTables(); - return responseSuccessWithData(t); - } - - @PostMapping(value = "/listI18nFields") - public ResponseBean getI18nFields(@RequestBody GaeaUiI18nDto q){ - GaeaUiI18n qry = new GaeaUiI18n(); - GaeaBeanUtils.copyAndFormatter(q,qry); - // 客户端测试时,以前端参数为准 - if(StringUtils.isEmpty(qry.getLocale())) { - qry.setLocale(getI18nLang()); - } - Map ret = new HashMap(); - for(String table : q.getRefer().split(",")) { - qry.setRefer(table); - Map t = gaeaUiI18nService.getI18nFields(qry); - ret.putIfAbsent(qry.getModule(),new HashMap<>()); - // 合并module子节点 - ((Map)ret.get(qry.getModule())).putAll((Map)t.get(qry.getModule())); - } - - ret.put("locale",q.getLocale()); - return responseSuccessWithData(ret); - } - -} diff --git a/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/gaeaUiI18n/controller/dto/GaeaUiI18nDto.java b/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/gaeaUiI18n/controller/dto/GaeaUiI18nDto.java deleted file mode 100644 index 2d5e5dca..00000000 --- a/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/gaeaUiI18n/controller/dto/GaeaUiI18nDto.java +++ /dev/null @@ -1,50 +0,0 @@ - -package com.anjiplus.template.gaea.business.modules.gaeaUiI18n.controller.dto; - -import java.io.Serializable; - -import com.anji.plus.gaea.curd.dto.GaeaBaseDTO; -import com.anji.plus.gaea.annotation.Formatter; -import lombok.Data; -import java.sql.Timestamp; - - -/** -* -* @description ui文字国际化处理 dto -* @author 王斌 -* @date 2021-03-25 15:30:59.286 -**/ -@Data -public class GaeaUiI18nDto extends GaeaBaseDTO implements Serializable { - /** 语言标识 */ - @Formatter(dictCode = "LOCALE",targetField = "localeCn") - private String locale; - private String localeCn; - - /** 行业标识 */ - @Formatter(dictCode = "SYS_CATA_TYPE",targetField = "cataTypeCn") - private String cataType; - private String cataTypeCn; - - /** 所属系统 */ - private String system; - - /** 所属菜单编号 */ - private String module; - - /** 字段编码 */ - private String code; - - /** 字段名称 */ - private String name; - - /** 业务描述 */ - private String remark; - private String refer; - /** 启用状态 */ - @Formatter(dictCode = "ENABLE_FLAG",targetField = "enabledCn") - private Integer enabled; - private String enabledCn; - -} \ No newline at end of file diff --git a/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/gaeaUiI18n/controller/param/GaeaUiI18nParam.java b/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/gaeaUiI18n/controller/param/GaeaUiI18nParam.java deleted file mode 100644 index f36d5b7b..00000000 --- a/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/gaeaUiI18n/controller/param/GaeaUiI18nParam.java +++ /dev/null @@ -1,54 +0,0 @@ -/**/ -package com.anjiplus.template.gaea.business.modules.gaeaUiI18n.controller.param; - -import lombok.Data; -import java.io.Serializable; -import com.anji.plus.gaea.annotation.Query; -import com.anji.plus.gaea.constant.QueryEnum; -import com.anji.plus.gaea.curd.params.PageParam; - -import java.util.List; - - -/** -* @desc GaeaUiI18n ui文字国际化处理查询输入类 -* @author 王斌 -* @date 2021-03-25 15:30:59.286 -**/ -@Data -public class GaeaUiI18nParam extends PageParam implements Serializable{ - - /** 精确查询 */ - @Query - private String locale; - - /** 精确查询 */ - @Query - private String cataType; - - /** 精确查询 */ - @Query - private String system; - - /** 模糊查询 */ - @Query(value = QueryEnum.LIKE) - private String code; - - /** 模糊查询 */ - @Query(value = QueryEnum.LIKE) - private String name; - - /** 模糊查询 */ - @Query(value = QueryEnum.LIKE) - private String remark; - - @Query(value = QueryEnum.EQ) - private String refer; - - @Query(value = QueryEnum.EQ) - private String module; - - /** 精确查询 */ - @Query - private Integer enabled; -} \ No newline at end of file diff --git a/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/gaeaUiI18n/dao/GaeaUiI18nMapper.java b/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/gaeaUiI18n/dao/GaeaUiI18nMapper.java deleted file mode 100644 index 7abfe917..00000000 --- a/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/gaeaUiI18n/dao/GaeaUiI18nMapper.java +++ /dev/null @@ -1,33 +0,0 @@ -package com.anjiplus.template.gaea.business.modules.gaeaUiI18n.dao; - -import org.apache.ibatis.annotations.Mapper; -import org.apache.ibatis.annotations.Param; - -import java.util.List; - -import com.anji.plus.gaea.curd.mapper.GaeaBaseMapper; -import com.anjiplus.template.gaea.business.modules.gaeaUiI18n.dao.entity.GaeaUiI18n; -import com.anjiplus.template.gaea.business.modules.gaeaUiI18n.service.impl.ColumnDesc; - -/** -* GaeaUiI18n Mapper -* @author 王斌 -* @date 2021-03-25 15:30:59.286 -**/ -@Mapper -public interface GaeaUiI18nMapper extends GaeaBaseMapper { - - /** - * 查询表的定义,字段中文描述等信息 - * @param tableName - * @return - */ - List queryColumns(@Param(value = "tableName") String tableName); - - /** - * 查询项目所有的表名 - * @param s - * @return - */ - List queryTables(@Param(value = "tableName") String s); -} \ No newline at end of file diff --git a/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/gaeaUiI18n/dao/entity/GaeaUiI18n.java b/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/gaeaUiI18n/dao/entity/GaeaUiI18n.java deleted file mode 100644 index 6381e5b2..00000000 --- a/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/gaeaUiI18n/dao/entity/GaeaUiI18n.java +++ /dev/null @@ -1,46 +0,0 @@ - -package com.anjiplus.template.gaea.business.modules.gaeaUiI18n.dao.entity; - -import lombok.Data; -import io.swagger.annotations.ApiModelProperty; - -import com.anji.plus.gaea.curd.entity.GaeaBaseEntity; -import com.baomidou.mybatisplus.annotation.TableName; - -/** -* @description ui文字国际化处理 entity -* @author 王斌 -* @date 2021-03-25 15:30:59.286 -**/ -@TableName(value="gaea_ui_i18n") -@Data -public class GaeaUiI18n extends GaeaBaseEntity { - @ApiModelProperty(value = "语言标识") - private String locale; - - @ApiModelProperty(value = "行业标识") - private String cataType; - - @ApiModelProperty(value = "所属系统") - private String system; - - @ApiModelProperty(value = "所属模块") - private String module; - - @ApiModelProperty(value = "字段编码") - private String code; - - @ApiModelProperty(value = "字段名称") - private String name; - - @ApiModelProperty(value = "业务描述") - private String remark; - - @ApiModelProperty(value = "关联表名") - private String refer; - - @ApiModelProperty(value = "启用状态") - private Integer enabled; - - -} \ No newline at end of file diff --git a/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/gaeaUiI18n/service/GaeaUiI18nService.java b/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/gaeaUiI18n/service/GaeaUiI18nService.java deleted file mode 100644 index b9ca6b5a..00000000 --- a/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/gaeaUiI18n/service/GaeaUiI18nService.java +++ /dev/null @@ -1,46 +0,0 @@ - -package com.anjiplus.template.gaea.business.modules.gaeaUiI18n.service; - -import com.anjiplus.template.gaea.business.base.BaseService; -import com.anjiplus.template.gaea.business.modules.gaeaUiI18n.dao.entity.GaeaUiI18n; -import com.anjiplus.template.gaea.business.modules.gaeaUiI18n.controller.param.GaeaUiI18nParam; - -import java.util.List; -import java.util.Map; - -/** -* @desc GaeaUiI18n ui文字国际化处理服务接口 -* @author 王斌 -* @date 2021-03-25 15:30:59.286 -**/ -public interface GaeaUiI18nService extends BaseService { - - /*** - * 查询详情 - * - * @param id - * @return - */ - GaeaUiI18n getDetail(Long id); - - /** - * 新加功能菜单时,i18n同步、初始化,以单表为单位处理 - * 优先从 自动生成处理表查询,没有则从源表查询,减少重复维护 - * - * @param table 表名称 - */ - void scan(String table); - - /** - * 查询项目所有的表 - * @return - */ - List getUi18nTables(); - - /** - * 菜单初始化时,查询该菜单需要的国际化列表 - * @param initQry - * @return map - */ - Map getI18nFields(GaeaUiI18n initQry); -} \ No newline at end of file diff --git a/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/gaeaUiI18n/service/impl/ColumnDesc.java b/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/gaeaUiI18n/service/impl/ColumnDesc.java deleted file mode 100644 index 77d44336..00000000 --- a/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/gaeaUiI18n/service/impl/ColumnDesc.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.anjiplus.template.gaea.business.modules.gaeaUiI18n.service.impl; - -import com.anjiplus.template.gaea.generator.domain.Column; - -/** - * @author WongBin - * @date 2021/3/26 - */ -public class ColumnDesc extends Column { - -} diff --git a/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/gaeaUiI18n/service/impl/GaeaUiI18nServiceImpl.java b/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/gaeaUiI18n/service/impl/GaeaUiI18nServiceImpl.java deleted file mode 100644 index ac49537e..00000000 --- a/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/gaeaUiI18n/service/impl/GaeaUiI18nServiceImpl.java +++ /dev/null @@ -1,162 +0,0 @@ - -package com.anjiplus.template.gaea.business.modules.gaeaUiI18n.service.impl; - -import cn.hutool.core.util.StrUtil; - -import com.anji.plus.gaea.constant.BaseOperationEnum; -import com.anji.plus.gaea.constant.Enabled; -import com.anji.plus.gaea.curd.mapper.GaeaBaseMapper; - -import com.anji.plus.gaea.exception.BusinessException; -import com.anjiplus.template.gaea.generator.domain.Column; -import com.anjiplus.template.gaea.generator.service.GeneratorService; -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import com.baomidou.mybatisplus.core.toolkit.Wrappers; -import lombok.extern.slf4j.Slf4j; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.i18n.LocaleContextHolder; -import org.springframework.stereotype.Service; -import org.springframework.util.CollectionUtils; - -import com.anjiplus.template.gaea.business.modules.gaeaUiI18n.dao.entity.GaeaUiI18n; -import com.anjiplus.template.gaea.business.modules.gaeaUiI18n.service.GaeaUiI18nService; -import com.anjiplus.template.gaea.business.modules.gaeaUiI18n.dao.GaeaUiI18nMapper; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Optional; -import java.util.stream.Collectors; - -/** -* @desc GaeaUiI18n ui文字国际化处理服务实现 -* @author 王斌 -* @date 2021-03-25 15:30:59.286 -**/ -@Service -@Slf4j -public class GaeaUiI18nServiceImpl implements GaeaUiI18nService { - - @Autowired - private GaeaUiI18nMapper gaeaUiI18nMapper; - - @Override - public GaeaBaseMapper getMapper() { - return gaeaUiI18nMapper; - } - - @Override - public GaeaUiI18n getDetail(Long id) { - GaeaUiI18n gaeaUiI18n = this.selectOne(id); - return gaeaUiI18n; - } - - @Autowired(required = false) - GeneratorService generatorService; - - @Value("${spring.application.name}") - private String applicationName; - - @Override - public void processBeforeOperation(GaeaUiI18n entity, - BaseOperationEnum type) throws BusinessException { - if(BaseOperationEnum.INSERT.equals(type)){ - entity.setSystem(applicationName); - //entity.setCataType(""); - } - } - - @Override - public void scan(String table) { - assert table!=null; - LambdaQueryWrapper wrapper = Wrappers.lambdaQuery(); - wrapper.eq(GaeaUiI18n::getRefer,table); - if(gaeaUiI18nMapper.selectCount(wrapper) > 0){ - log.warn("{} exist,ignore",table); - throw new BusinessException("6001",new String[]{"该表的字段已维护国际化配置"}); - } - List columnDescList = generatorService.getColumns(table); - //List columnDescList = gaeaUiI18nMapper.queryColumns(table); - if(!CollectionUtils.isEmpty(columnDescList)){ - List list = columnDescList.stream().map(item->{ - if(item.getRemark()!=null && item.getRemark().length()>20){ - item.setRemark(item.getRemark().substring(0,20)); - } - GaeaUiI18n it = new GaeaUiI18n(); - it.setCode(StrUtil.toCamelCase(item.getColumnName())); - it.setName(item.getRemark()); - it.setLocale(getI18nLang()); - it.setSystem(applicationName); - it.setRemark(item.getRemark()); - it.setEnabled(Enabled.YES.getValue()); - it.setRefer(item.getTableName()); - return it; - }).collect(Collectors.toList()); - - int ret = gaeaUiI18nMapper.insertBatch(list); - log.info("insert-batch-for:{},size:{}",table,ret); - } - } - - private String getI18nLang(){ - return LocaleContextHolder.getLocale().getLanguage(); - } - - @Override - public List getUi18nTables() { - return gaeaUiI18nMapper.queryTables(""); - } - - @Override - public Map getI18nFields(GaeaUiI18n q) { - String table = q.getRefer(); - String tableAlias = ""; - // 提取表名称和别名 - if(q.getRefer().contains(":")) { - table = q.getRefer().split(":")[0]; - tableAlias = Optional.ofNullable(q.getRefer().substring(table.length() + 1)).orElse(""); - q.setRefer(table); - } - - LambdaQueryWrapper qry = Wrappers.lambdaQuery(); - qry.eq(GaeaUiI18n::getLocale,q.getLocale()) - .and(t->t.eq(GaeaUiI18n::getEnabled,Enabled.YES.getValue())) - // 所属行业 - .and(t->t.eq(GaeaUiI18n::getCataType,q.getCataType()).or().isNull(GaeaUiI18n::getCataType)) - // 同一个表 或同一个菜单 - .and(t->t.eq(GaeaUiI18n::getRefer,q.getRefer()).or().eq(GaeaUiI18n::getModule,q.getModule())) - ; - List list = gaeaUiI18nMapper.selectList(qry); - - HashMap kv = new HashMap(); - // 表级别 字段默认设置 - list.stream().filter(i->i.getRefer()!=null && i.getCataType()==null).forEach(i->{ - kv.put(i.getCode(),i.getName()); - }); - // 表级别 字段行业属性,覆盖默认设置 - list.stream().filter(i->i.getRefer()!=null && i.getCataType()!=null).forEach(i->{ - kv.put(i.getCode(),i.getName()); - }); - - Map result = new HashMap(); - // 挂载在module根节点 - if(tableAlias.length()<1) { - result.put(q.getModule(), kv); - }else { - // 作为module的子节点 - result.putIfAbsent(q.getModule(),new HashMap<>()); - ((Map)result.get(q.getModule())).put(tableAlias,kv); - } - - // 设置模块级别的字段配置 - HashMap m = new HashMap(); - list.stream().filter(i->i.getRefer()==null && i.getModule().equals(q.getModule())).forEach(item->{ - m.put(item.getCode(),item.getName()); - }); - if(!m.isEmpty()) { - ((Map)result.get(q.getModule())).putAll(m); - } - return result; - } -} \ No newline at end of file diff --git a/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/reportexcel/service/impl/ReportExcelServiceImpl.java b/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/reportexcel/service/impl/ReportExcelServiceImpl.java index 4963f54c..3295e64c 100644 --- a/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/reportexcel/service/impl/ReportExcelServiceImpl.java +++ b/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/reportexcel/service/impl/ReportExcelServiceImpl.java @@ -49,7 +49,7 @@ public class ReportExcelServiceImpl implements ReportExcelService { @Autowired private ReportMapper reportMapper; - @Value("${file.dist-path}") + @Value("${file.dist-path:''}") private String dictPath; @Autowired diff --git a/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/user/controller/LoginController.java b/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/user/controller/LoginController.java new file mode 100644 index 00000000..405b9f0b --- /dev/null +++ b/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/user/controller/LoginController.java @@ -0,0 +1,34 @@ +package com.anjiplus.template.gaea.business.modules.user.controller; + +import com.anji.plus.gaea.bean.ResponseBean; +import com.anjiplus.template.gaea.business.modules.user.dto.GaeaUserDTO; +import com.anjiplus.template.gaea.business.modules.user.service.UserService; +import io.swagger.annotations.Api; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RestController; + +/** + * 简单登录 + * Created by raodeming on 2021/6/23. + */ +@RestController +@Api(tags = "用户管理") +public class LoginController { + + @Autowired + private UserService userService; + + + /** + * 简单实现登录 + * @param dto + * @return + */ + @PostMapping({"/login"}) + public ResponseBean login(@RequestBody @Validated GaeaUserDTO dto) { + return ResponseBean.builder().data(userService.login(dto)).build(); + } +} diff --git a/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/user/dao/GaeaUserMapper.java b/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/user/dao/GaeaUserMapper.java new file mode 100644 index 00000000..e6c3f93d --- /dev/null +++ b/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/user/dao/GaeaUserMapper.java @@ -0,0 +1,12 @@ +package com.anjiplus.template.gaea.business.modules.user.dao; + +import com.anji.plus.gaea.curd.mapper.GaeaBaseMapper; +import com.anjiplus.template.gaea.business.modules.user.dao.entity.GaeaUser; +import org.apache.ibatis.annotations.Mapper; + +/** + * Created by raodeming on 2021/6/23. + */ +@Mapper +public interface GaeaUserMapper extends GaeaBaseMapper { +} diff --git a/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/user/dao/entity/GaeaUser.java b/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/user/dao/entity/GaeaUser.java new file mode 100644 index 00000000..4dcde5e8 --- /dev/null +++ b/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/user/dao/entity/GaeaUser.java @@ -0,0 +1,23 @@ +package com.anjiplus.template.gaea.business.modules.user.dao.entity; + +import com.anji.plus.gaea.annotation.Unique; +import com.anji.plus.gaea.curd.entity.GaeaBaseEntity; +import lombok.Data; + +import java.io.Serializable; + +/** + * Created by raodeming on 2021/6/23. + */ +@Data +public class GaeaUser extends GaeaBaseEntity implements Serializable { + /** + * 用户名 + */ + private String username; + + /** + * 密码 + */ + private String password; +} diff --git a/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/user/dto/GaeaUserDTO.java b/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/user/dto/GaeaUserDTO.java new file mode 100644 index 00000000..f4fc287b --- /dev/null +++ b/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/user/dto/GaeaUserDTO.java @@ -0,0 +1,23 @@ +package com.anjiplus.template.gaea.business.modules.user.dto; + +import com.anji.plus.gaea.annotation.Unique; +import com.anji.plus.gaea.curd.dto.GaeaBaseDTO; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import javax.validation.constraints.NotBlank; + + +@ApiModel(value = "用户表") +@Data +public class GaeaUserDTO extends GaeaBaseDTO { + + @ApiModelProperty(value = "用户登录名") + @NotBlank + private String username; + + @ApiModelProperty(value = "用户密码") + @NotBlank + private String password; +} diff --git a/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/user/service/UserService.java b/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/user/service/UserService.java new file mode 100644 index 00000000..9dab0138 --- /dev/null +++ b/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/user/service/UserService.java @@ -0,0 +1,10 @@ +package com.anjiplus.template.gaea.business.modules.user.service; + +import com.anjiplus.template.gaea.business.modules.user.dto.GaeaUserDTO; + +/** + * Created by raodeming on 2021/6/23. + */ +public interface UserService { + Object login(GaeaUserDTO dto); +} diff --git a/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/user/service/impl/UserServiceImpl.java b/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/user/service/impl/UserServiceImpl.java new file mode 100644 index 00000000..7a44d0c0 --- /dev/null +++ b/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/user/service/impl/UserServiceImpl.java @@ -0,0 +1,86 @@ +package com.anjiplus.template.gaea.business.modules.user.service.impl; + +import com.anji.plus.gaea.cache.CacheHelper; +import com.anji.plus.gaea.exception.BusinessExceptionBuilder; +import com.anji.plus.gaea.utils.GaeaUtils; +import com.anji.plus.gaea.utils.JwtBean; +import com.anjiplus.template.gaea.business.code.ResponseCode; +import com.anjiplus.template.gaea.business.modules.user.dao.GaeaUserMapper; +import com.anjiplus.template.gaea.business.modules.user.dao.entity.GaeaUser; +import com.anjiplus.template.gaea.business.modules.user.dto.GaeaUserDTO; +import com.anjiplus.template.gaea.business.modules.user.service.UserService; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.google.common.collect.Maps; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.security.MessageDigest; +import java.util.HashMap; +import java.util.Map; + +/** + * Created by raodeming on 2021/6/23. + */ +@Service +public class UserServiceImpl implements UserService { + + @Autowired + private JwtBean jwtBean; + + @Autowired + private GaeaUserMapper gaeaUserMapper; + + @Autowired + private CacheHelper cacheHelper; + + @Override + public Object login(GaeaUserDTO dto) { + + String username = dto.getUsername(); + String password = dto.getPassword(); + //1.判断用户是否存在 + LambdaQueryWrapper wrapper = Wrappers.lambdaQuery(); + wrapper.eq(GaeaUser::getUsername, username); + GaeaUser gaeaUser = gaeaUserMapper.selectOne(wrapper); + if (null == gaeaUser || !gaeaUser.getPassword().equals(encrypt(password))) { + throw BusinessExceptionBuilder.build(ResponseCode.LOGIN_ERROR); + } + + + Map map = Maps.newHashMap(); + + //将登录信息缓存,默认一小时 + if (cacheHelper.exist(username)) { + map.put("token", cacheHelper.stringGet(username)); + } else { + String uuid = GaeaUtils.UUID(); + String token = jwtBean.createToken(username, uuid); + cacheHelper.stringSetExpire(username, token, 3600); + map.put("token", token); + } + + return map; + } + + /** + * 获取指定字符串的md5值 + * @param dataStr 明文 + * @return String + */ + public static String encrypt(String dataStr) { + try { + MessageDigest m = MessageDigest.getInstance("MD5"); + m.update(dataStr.getBytes("UTF8")); + byte[] s = m.digest(); + StringBuilder result = new StringBuilder(); + for (int i = 0; i < s.length; i++) { + result.append(Integer.toHexString((0x000000FF & s[i]) | 0xFFFFFF00).substring(6)); + } + return result.toString(); + } catch (Exception e) { + e.printStackTrace(); + } + return ""; + } +} diff --git a/report-core/src/main/resources/bootstrap-dev.yml b/report-core/src/main/resources/bootstrap-dev.yml index e606b533..66f057f1 100644 --- a/report-core/src/main/resources/bootstrap-dev.yml +++ b/report-core/src/main/resources/bootstrap-dev.yml @@ -1,16 +1,16 @@ spring: application: name: gaea-business - cloud: - nacos: - server-addr: 10.108.26.121:8848,10.108.26.145:8848 - username: gaea - password: p@ss1234 +# cloud: +# nacos: +# server-addr: 10.108.26.121:8848,10.108.26.145:8848 +# username: gaea +# password: p@ss1234 # config: # namespace: 5c6b6687-ad43-450f-88b6-e704ff78d83f # file-extension: yaml - discovery: - namespace: 5c6b6687-ad43-450f-88b6-e704ff78d83f +# discovery: +# namespace: 5c6b6687-ad43-450f-88b6-e704ff78d83f jackson: date-format: yyyy-MM-dd HH:mm:ss messages: @@ -39,6 +39,11 @@ generator: templatePath: template server: port: 9092 + servlet: + encoding: + charset: UTF-8 + force: true + enabled: true # servlet: # context-path: /business mybatis-plus: diff --git a/report-core/src/main/resources/bootstrap.yml b/report-core/src/main/resources/bootstrap.yml index 0c268749..095bc014 100644 --- a/report-core/src/main/resources/bootstrap.yml +++ b/report-core/src/main/resources/bootstrap.yml @@ -6,4 +6,4 @@ logging: config: classpath:logback.xml generator: tableExclude: - mysql: "AND table_name not like 'gaea_%' AND table_name not like 'ACT_%'" \ No newline at end of file + mysql: "AND table_name not like 'gaea_%' AND table_name not like 'ACT_%'" diff --git a/report-core/src/main/resources/i18n/messages_en_US.properties b/report-core/src/main/resources/i18n/messages_en_US.properties index 35bad51b..702285db 100644 --- a/report-core/src/main/resources/i18n/messages_en_US.properties +++ b/report-core/src/main/resources/i18n/messages_en_US.properties @@ -6,6 +6,9 @@ 2003=File upload failed 2004=File does not exist +login.error=username or password error +User.token.expired=User token has expired + 3001=Template code does not allow duplication 3002=The receiver is not allowed to be empty Insert.failure=Insert failure diff --git a/report-core/src/main/resources/i18n/messages_zh_CN.properties b/report-core/src/main/resources/i18n/messages_zh_CN.properties index 2399eff3..f05c8e55 100644 --- a/report-core/src/main/resources/i18n/messages_zh_CN.properties +++ b/report-core/src/main/resources/i18n/messages_zh_CN.properties @@ -6,6 +6,10 @@ 2003=\u6587\u4EF6\u4E0A\u4F20\u5931\u8D25 2004=\u6587\u4EF6\u4E0D\u5B58\u5728 +login.error=\u7528\u6237\u540D\u6216\u8005\u5BC6\u7801\u4E0D\u6B63\u786E +User.token.expired=\u7528\u6237\u672A\u767B\u5F55\u6216\u767B\u5F55\u4FE1\u606F\u8FC7\u671F + + 3001=\u6A21\u677F\u4EE3\u7801\u4E0D\u5141\u8BB8\u91CD\u590D 3002=\u63A5\u6536\u4EBA\u4E0D\u5141\u8BB8\u4E3A\u7A7A Dict.item.code.exist=\u6570\u636E\u5B57\u5178\u9879\u503C\u5DF2\u5B58\u5728 diff --git a/report-core/src/main/resources/mapper/GaeaExportMapper.xml b/report-core/src/main/resources/mapper/GaeaExportMapper.xml deleted file mode 100644 index f9253ece..00000000 --- a/report-core/src/main/resources/mapper/GaeaExportMapper.xml +++ /dev/null @@ -1,48 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - id, file_id, file_title, result_start_time, result_end_time, result_size, file_create_time, file_finish_time, - file_status, create_by, update_by, create_time, update_time, version, remark - - - - - diff --git a/report-core/src/main/resources/mapper/GaeaUiI18nMapper.xml b/report-core/src/main/resources/mapper/GaeaUiI18nMapper.xml deleted file mode 100644 index db8442aa..00000000 --- a/report-core/src/main/resources/mapper/GaeaUiI18nMapper.xml +++ /dev/null @@ -1,50 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - id,locale,cata_type,system,code,name,remark,enabled,create_by,create_time,update_by,update_time,version - - - - - - - \ No newline at end of file