简单登录

Raod 3 years ago
parent 18fb98fd37
commit 1a086a5259

@ -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=''

@ -14,17 +14,13 @@
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>com.anjiplus.template.gaea</groupId> <groupId>org.projectlombok</groupId>
<artifactId>template-gaea-common</artifactId> <artifactId>lombok</artifactId>
</dependency>
<dependency>
<groupId>com.anji-plus</groupId>
<artifactId>spring-boot-gaea</artifactId>
<exclusions> <exclusions>
<!-- <exclusion>-->
<!-- <groupId>com.alibaba.cloud</groupId>-->
<!-- <artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>-->
<!-- </exclusion>-->
<!-- <exclusion>-->
<!-- <groupId>com.alibaba.cloud</groupId>-->
<!-- <artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>-->
<!-- </exclusion>-->
<exclusion> <exclusion>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId> <artifactId>spring-boot-starter-data-redis</artifactId>
@ -33,10 +29,32 @@
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.anjiplus.template.gaea</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>template-gaea-generator</artifactId> <artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-context</artifactId>
</dependency> </dependency>
<!--模板引擎-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-freemarker</artifactId>
</dependency>
<!-- <dependency>-->
<!-- <groupId>com.anjiplus.template.gaea</groupId>-->
<!-- <artifactId>template-gaea-generator</artifactId>-->
<!-- <exclusions>-->
<!-- <exclusion>-->
<!-- <groupId>org.springframework.boot</groupId>-->
<!-- <artifactId>spring-boot-starter-data-redis</artifactId>-->
<!-- </exclusion>-->
<!-- </exclusions>-->
<!-- </dependency>-->
<dependency> <dependency>
<groupId>com.baomidou</groupId> <groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId> <artifactId>mybatis-plus-boot-starter</artifactId>
@ -64,15 +82,6 @@
<version>2.10.6</version> <version>2.10.6</version>
</dependency> </dependency>
<!-- <dependency>-->
<!-- <groupId>com.alibaba.cloud</groupId>-->
<!-- <artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>-->
<!-- </dependency>-->
<!-- <dependency>-->
<!-- <groupId>com.alibaba.cloud</groupId>-->
<!-- <artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>-->
<!-- </dependency>-->
<dependency> <dependency>
<groupId>com.anji-plus</groupId> <groupId>com.anji-plus</groupId>
<artifactId>spring-boot-starter-gaea-export</artifactId> <artifactId>spring-boot-starter-gaea-export</artifactId>

@ -4,6 +4,7 @@ import com.anji.plus.gaea.annotation.enabled.EnabledGaeaConfiguration;
import org.mybatis.spring.annotation.MapperScan; import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication; 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 * @since 2021-02-03
*/ */
@EnabledGaeaConfiguration @EnabledGaeaConfiguration
@SpringBootApplication @SpringBootApplication(scanBasePackages = {
"com.anjiplus.template.gaea",
"com.anji.plus"
})
@MapperScan(basePackages = { @MapperScan(basePackages = {
"com.anjiplus.template.gaea.business.modules.*.dao", "com.anjiplus.template.gaea.business.modules.*.dao",
"com.anjiplus.template.gaea.business.modules.*.**.dao", "com.anjiplus.template.gaea.business.modules.*.**.dao",

@ -13,7 +13,6 @@ import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.concurrent.TimeUnit;
public class ReportCacheHelper implements CacheHelper, ApplicationContextAware { public class ReportCacheHelper implements CacheHelper, ApplicationContextAware {
@ -24,7 +23,7 @@ public class ReportCacheHelper implements CacheHelper, ApplicationContextAware {
public String stringGet(String key) { public String stringGet(String key) {
Cache.ValueWrapper valueWrapper = cache.get(key); Cache.ValueWrapper valueWrapper = cache.get(key);
if (valueWrapper != null) { if (valueWrapper != null) {
return (String)valueWrapper.get(); return (String) valueWrapper.get();
} }
return CacheHelper.super.stringGet(key); return CacheHelper.super.stringGet(key);
} }
@ -38,7 +37,15 @@ public class ReportCacheHelper implements CacheHelper, ApplicationContextAware {
@Override @Override
public boolean exist(String key) { 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); cache.put(key, value);
} }
@Override
public void stringSetExpire(String key, String value, long time, TimeUnit timeUnit) {
CacheHelper.super.stringSetExpire(key, value, time, timeUnit);
}
@Override @Override
public String regKey(String key) { public String regKey(String key) {
@ -59,7 +62,11 @@ public class ReportCacheHelper implements CacheHelper, ApplicationContextAware {
@Override @Override
public void stringSetExpire(String key, String value, long seconds) { 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 @Override
@ -122,7 +129,9 @@ public class ReportCacheHelper implements CacheHelper, ApplicationContextAware {
@Override @Override
public boolean delete(String key) { public boolean delete(String key) {
cache.evict(key); if (exist(key)) {
cache.evict(key);
}
return true; return true;
} }
@ -136,6 +145,6 @@ public class ReportCacheHelper implements CacheHelper, ApplicationContextAware {
@Override @Override
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
/*基于内存的本地缓存*/ /*基于内存的本地缓存*/
cache = (Cache)applicationContext.getBean("ehCacheCache"); cache = (Cache) applicationContext.getBean("ehCacheCache");
} }
} }

@ -6,6 +6,15 @@ package com.anjiplus.template.gaea.business.code;
* @since 2021-02-22 * @since 2021-02-22
*/ */
public interface ResponseCode { 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 SET_CODE_ISEXIST = "4008";
String SOURCE_CODE_ISEXIST = "4009"; String SOURCE_CODE_ISEXIST = "4009";
String CLASS_NOT_FOUND = "4010"; String CLASS_NOT_FOUND = "4010";
} }

@ -30,7 +30,7 @@ public class BusinessAutoConfiguration {
return new ApplicationInitRunner(); return new ApplicationInitRunner();
} }
@Bean("gaeaCacheHelper") @Bean
public CacheHelper gaeaCacheHelper(){ public CacheHelper gaeaCacheHelper(){
return new ReportCacheHelper(); return new ReportCacheHelper();
} }

@ -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();
}
}

@ -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<GaeaExportParam, GaeaExport, GaeaExportDTO> {
@Autowired
private GaeaExportService gaeaExportService;
@Override
public GaeaBaseService<GaeaExportParam, GaeaExport> 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<GaeaExport> exportList=gaeaExportService.getExportListPage(param);
List<GaeaExportDTO> list = exportList.getRecords().stream()
.map(entity -> GaeaBeanUtils.copyAndFormatter(entity, getDTO()))
.collect(Collectors.toList());
Page<GaeaExportDTO> 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);
}
}

@ -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_fileidhttp://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;
/**
* creatingsuccess,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;
}
}

@ -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;
}

@ -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;
}

@ -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<GaeaExport> {
/**
*
* @param page
* @param bo
* @param wrapper
* @return
*/
List<GaeaExport> queryExportInfo(Page<GaeaExport> page, @Param("bo") GaeaExportQueryParam bo, @Param(Constants.WRAPPER) QueryWrapper wrapper);
}

@ -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_fileidhttp://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;
/**
* creatingsuccess,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;
}
}

@ -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<GaeaExportParam, GaeaExport> {
/**
* -
* QueryWrapper QueryWrapper
* @param queryParam
* @return
*/
Page<GaeaExport> getExportListPage(GaeaExportQueryParam queryParam, QueryWrapper ...qe);
/**
* Gaea_export
* @param exportOperation
* @return
*/
Boolean saveExportLog(ExportOperation exportOperation);
}

@ -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<GaeaExport> getMapper() {
return gaeaExportMapper;
}
@Override
@GaeaQuery
public Page<GaeaExport> getExportListPage(GaeaExportQueryParam queryParam, QueryWrapper... qe) {
Page<GaeaExport> page = new Page<>(queryParam.getPageNumber(), queryParam.getPageSize());
QueryWrapper queryWrapper = (null != qe && qe.length > 0) ? qe[0] : null;
List<GaeaExport> 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;
}
}

@ -3,6 +3,7 @@ package com.anjiplus.template.gaea.business.modules.file.controller.dto;
import com.anji.plus.gaea.curd.dto.GaeaBaseDTO; import com.anji.plus.gaea.curd.dto.GaeaBaseDTO;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/** /**
* (GaeaFile) * (GaeaFile)
@ -10,58 +11,21 @@ import io.swagger.annotations.ApiModelProperty;
* @author peiyanni * @author peiyanni
* @since 2021-02-18 14:48:27 * @since 2021-02-18 14:48:27
*/ */
@ApiModel(value = "") @Data
public class GaeaFileDTO extends GaeaBaseDTO { public class GaeaFileDTO extends GaeaBaseDTO {
/** /** 文件标识 */
* uuid
*/
private String fileId; 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; private String filePath;
}
public String getFileInstruction() {
return fileInstruction;
}
public void setFileInstruction(String fileInstruction) {
this.fileInstruction = fileInstruction;
}
public String getFileId() { /** url路径 */
return fileId; private String urlPath;
}
public void setFileId(String fileId) { /** 内容说明 */
this.fileId = fileId; private String fileInstruction;
}
} }

@ -15,17 +15,11 @@ import java.io.Serializable;
*/ */
public class GaeaFileParam extends PageParam implements Serializable { public class GaeaFileParam extends PageParam implements Serializable {
/** /** 模糊查询 */
* linux/app/dist/export/excel/${fileid}.xlsx @Query(value = QueryEnum.LIKE)
*/
@Query(QueryEnum.LIKE)
private String filePath; private String filePath;
public String getFilePath() { /** 模糊查询 */
return filePath; @Query(value = QueryEnum.EQ)
} private String fileType;
public void setFilePath(String filePath) {
this.filePath = filePath;
}
} }

@ -2,6 +2,8 @@ package com.anjiplus.template.gaea.business.modules.file.entity;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
import com.anji.plus.gaea.curd.entity.GaeaBaseEntity; import com.anji.plus.gaea.curd.entity.GaeaBaseEntity;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable; import java.io.Serializable;
@ -12,54 +14,21 @@ import java.io.Serializable;
* @since 2021-02-18 14:48:20 * @since 2021-02-18 14:48:20
*/ */
@TableName("gaea_file") @TableName("gaea_file")
@Data
public class GaeaFile extends GaeaBaseEntity implements Serializable { public class GaeaFile extends GaeaBaseEntity implements Serializable {
/** @ApiModelProperty(value = "文件标识")
* uuid
*/
private String fileId; 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() { @ApiModelProperty(value = "文件类型")
return urlPath; private String fileType;
}
public void setUrlPath(String urlPath) { @ApiModelProperty(value = "文件路径")
this.urlPath = urlPath; private String filePath;
}
public String getFileInstruction() {
return fileInstruction;
}
public void setFileInstruction(String fileInstruction) {
this.fileInstruction = fileInstruction;
}
public String getFileId() { @ApiModelProperty(value = "url路径")
return fileId; private String urlPath;
}
public void setFileId(String fileId) { @ApiModelProperty(value = "内容说明")
this.fileId = fileId; private String fileInstruction;
}
} }

@ -24,7 +24,7 @@ public interface GaeaFileService extends GaeaBaseService<GaeaFileParam, GaeaFile
* @param file * @param file
* @return 访 * @return 访
*/ */
String upload(MultipartFile file); GaeaFile upload(MultipartFile file);
/** /**
* fileId * fileId

@ -1,20 +1,18 @@
package com.anjiplus.template.gaea.business.modules.file.service.impl; package com.anjiplus.template.gaea.business.modules.file.service.impl;
import com.alibaba.excel.util.FileUtils;
import com.anji.plus.gaea.constant.BaseOperationEnum; import com.anji.plus.gaea.constant.BaseOperationEnum;
import com.anji.plus.gaea.curd.mapper.GaeaBaseMapper;
import com.anji.plus.gaea.exception.BusinessException; import com.anji.plus.gaea.exception.BusinessException;
import com.anji.plus.gaea.exception.BusinessExceptionBuilder;
import com.anjiplus.template.gaea.business.modules.file.util.StringPatternUtil;
import com.anjiplus.template.gaea.business.code.ResponseCode;
import com.anjiplus.template.gaea.business.modules.file.dao.GaeaFileMapper; import com.anjiplus.template.gaea.business.modules.file.dao.GaeaFileMapper;
import com.anjiplus.template.gaea.business.modules.file.entity.GaeaFile; import com.anjiplus.template.gaea.business.modules.file.entity.GaeaFile;
import com.anjiplus.template.gaea.business.modules.file.service.GaeaFileService; import com.anjiplus.template.gaea.business.modules.file.service.GaeaFileService;
import com.anjiplus.template.gaea.business.modules.export.dao.GaeaExportMapper;
import com.anjiplus.template.gaea.business.modules.export.dao.entity.GaeaExport;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.anjiplus.template.gaea.business.code.ResponseCode;
import com.anji.plus.gaea.curd.mapper.GaeaBaseMapper;
import com.anji.plus.gaea.exception.BusinessExceptionBuilder;
import com.anjiplus.template.gaea.common.util.StringPatternUtil;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
@ -60,8 +58,6 @@ public class GaeaFileServiceImpl implements GaeaFileService {
@Autowired @Autowired
private GaeaFileMapper gaeaFileMapper; private GaeaFileMapper gaeaFileMapper;
@Autowired
private GaeaExportMapper gaeaExportMapper;
@Override @Override
public GaeaBaseMapper<GaeaFile> getMapper() { public GaeaBaseMapper<GaeaFile> getMapper() {
@ -70,15 +66,17 @@ public class GaeaFileServiceImpl implements GaeaFileService {
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public String upload(MultipartFile file) { public GaeaFile upload(MultipartFile file) {
try { try {
String fileName = file.getOriginalFilename(); String fileName = file.getOriginalFilename();
if (StringUtils.isBlank(fileName)) { if (StringUtils.isBlank(fileName)) {
throw BusinessExceptionBuilder.build(ResponseCode.FILE_EMPTY_FILENAME); throw BusinessExceptionBuilder.build(ResponseCode.FILE_EMPTY_FILENAME);
} }
String suffixName = fileName.substring(fileName.lastIndexOf(".")); String suffixName = fileName.substring(fileName.lastIndexOf("."));
String fileInstruction = fileName.substring(0, fileName.lastIndexOf("."));
//白名单校验(不区分大小写) //白名单校验(不区分大小写)
List<String> list = new ArrayList<String>(Arrays.asList(whiteList.split("\\|"))); List<String> list = new ArrayList<>(Arrays.asList(whiteList.split("\\|")));
list.addAll(list.stream().map(String::toUpperCase).collect(Collectors.toList())); list.addAll(list.stream().map(String::toUpperCase).collect(Collectors.toList()));
if (!list.contains(suffixName)) { if (!list.contains(suffixName)) {
throw BusinessExceptionBuilder.build(ResponseCode.FILE_SUFFIX_UNSUPPORTED); throw BusinessExceptionBuilder.build(ResponseCode.FILE_SUFFIX_UNSUPPORTED);
@ -88,19 +86,25 @@ public class GaeaFileServiceImpl implements GaeaFileService {
String newFileName = fileId + suffixName; String newFileName = fileId + suffixName;
// 本地文件保存路径 // 本地文件保存路径
String filePath = dictPath + newFileName; String filePath = dictPath + newFileName;
String urlPath = fileDownloadPath + File.separator + fileId; String urlPath = fileDownloadPath + java.io.File.separator + fileId;
GaeaFile gaeaFile = new GaeaFile(); GaeaFile gaeaFile = new GaeaFile();
gaeaFile.setFilePath(filePath); gaeaFile.setFilePath(filePath);
gaeaFile.setFileId(fileId); gaeaFile.setFileId(fileId);
gaeaFile.setUrlPath(urlPath); gaeaFile.setUrlPath(urlPath);
gaeaFile.setFileType(suffixName.replace(".", ""));
gaeaFile.setFileInstruction(fileInstruction);
gaeaFileMapper.insert(gaeaFile); gaeaFileMapper.insert(gaeaFile);
//写文件 将文件保存/app/dictPath/upload/下 //写文件 将文件保存/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); file.transferTo(dest);
// 将完整的http访问路径返回 // 将完整的http访问路径返回
return urlPath; return gaeaFile;
} catch (Exception e) { } catch (Exception e) {
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
log.error("file upload error: {}", e); log.error("file upload error: {}", e);
@ -127,16 +131,7 @@ public class GaeaFileServiceImpl implements GaeaFileService {
} }
String filename = filePath.substring(filePath.lastIndexOf(File.separator)); String filename = filePath.substring(filePath.lastIndexOf(File.separator));
String fileSuffix = filename.substring(filename.lastIndexOf(".")); String fileSuffix = filename.substring(filename.lastIndexOf("."));
//特殊处理如果是excel文件则从t_export表中查询文件名
List list = Arrays.asList(excelSuffix.split("\\|"));
if (list.contains(fileSuffix)) {
LambdaQueryWrapper<GaeaExport> 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); File file = new File(filePath);
ResponseEntity.BodyBuilder builder = ResponseEntity.ok(); ResponseEntity.BodyBuilder builder = ResponseEntity.ok();

@ -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 {
/**
*
* <p>Discription:[sourceStrpatternboolean]</p>
* @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;
}
/**
* <p>Discription:[sourceStrpattern]</p>
* @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;
}
}

@ -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<GaeaUiI18nParam, GaeaUiI18n, GaeaUiI18nDto> {
@Autowired
private GaeaUiI18nService gaeaUiI18nService;
@Override
public GaeaBaseService<GaeaUiI18nParam, GaeaUiI18n> 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<String> 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);
}
}

@ -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;
}

@ -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;
}

@ -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<GaeaUiI18n> {
/**
*
* @param tableName
* @return
*/
List<ColumnDesc> queryColumns(@Param(value = "tableName") String tableName);
/**
*
* @param s
* @return
*/
List<String> queryTables(@Param(value = "tableName") String s);
}

@ -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;
}

@ -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<GaeaUiI18nParam, GaeaUiI18n> {
/***
*
*
* @param id
* @return
*/
GaeaUiI18n getDetail(Long id);
/**
* i18n,
*
*
* @param table
*/
void scan(String table);
/**
*
* @return
*/
List<String> getUi18nTables();
/**
*
* @param initQry
* @return map
*/
Map getI18nFields(GaeaUiI18n initQry);
}

@ -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 {
}

@ -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<GaeaUiI18n> 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<GaeaUiI18n> 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<Column> columnDescList = generatorService.getColumns(table);
//List<ColumnDesc> columnDescList = gaeaUiI18nMapper.queryColumns(table);
if(!CollectionUtils.isEmpty(columnDescList)){
List<GaeaUiI18n> 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<String> 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<GaeaUiI18n> 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<GaeaUiI18n> 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;
}
}

@ -49,7 +49,7 @@ public class ReportExcelServiceImpl implements ReportExcelService {
@Autowired @Autowired
private ReportMapper reportMapper; private ReportMapper reportMapper;
@Value("${file.dist-path}") @Value("${file.dist-path:''}")
private String dictPath; private String dictPath;
@Autowired @Autowired

@ -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();
}
}

@ -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<GaeaUser> {
}

@ -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;
}

@ -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;
}

@ -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);
}

@ -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<GaeaUser> 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<String, String> 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 "";
}
}

@ -1,16 +1,16 @@
spring: spring:
application: application:
name: gaea-business name: gaea-business
cloud: # cloud:
nacos: # nacos:
server-addr: 10.108.26.121:8848,10.108.26.145:8848 # server-addr: 10.108.26.121:8848,10.108.26.145:8848
username: gaea # username: gaea
password: p@ss1234 # password: p@ss1234
# config: # config:
# namespace: 5c6b6687-ad43-450f-88b6-e704ff78d83f # namespace: 5c6b6687-ad43-450f-88b6-e704ff78d83f
# file-extension: yaml # file-extension: yaml
discovery: # discovery:
namespace: 5c6b6687-ad43-450f-88b6-e704ff78d83f # namespace: 5c6b6687-ad43-450f-88b6-e704ff78d83f
jackson: jackson:
date-format: yyyy-MM-dd HH:mm:ss date-format: yyyy-MM-dd HH:mm:ss
messages: messages:
@ -39,6 +39,11 @@ generator:
templatePath: template templatePath: template
server: server:
port: 9092 port: 9092
servlet:
encoding:
charset: UTF-8
force: true
enabled: true
# servlet: # servlet:
# context-path: /business # context-path: /business
mybatis-plus: mybatis-plus:

@ -6,4 +6,4 @@ logging:
config: classpath:logback.xml config: classpath:logback.xml
generator: generator:
tableExclude: tableExclude:
mysql: "AND table_name not like 'gaea_%' AND table_name not like 'ACT_%'" mysql: "AND table_name not like 'gaea_%' AND table_name not like 'ACT_%'"

@ -6,6 +6,9 @@
2003=File upload failed 2003=File upload failed
2004=File does not exist 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 3001=Template code does not allow duplication
3002=The receiver is not allowed to be empty 3002=The receiver is not allowed to be empty
Insert.failure=Insert failure Insert.failure=Insert failure

@ -6,6 +6,10 @@
2003=\u6587\u4EF6\u4E0A\u4F20\u5931\u8D25 2003=\u6587\u4EF6\u4E0A\u4F20\u5931\u8D25
2004=\u6587\u4EF6\u4E0D\u5B58\u5728 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 3001=\u6A21\u677F\u4EE3\u7801\u4E0D\u5141\u8BB8\u91CD\u590D
3002=\u63A5\u6536\u4EBA\u4E0D\u5141\u8BB8\u4E3A\u7A7A 3002=\u63A5\u6536\u4EBA\u4E0D\u5141\u8BB8\u4E3A\u7A7A
Dict.item.code.exist=\u6570\u636E\u5B57\u5178\u9879\u503C\u5DF2\u5B58\u5728 Dict.item.code.exist=\u6570\u636E\u5B57\u5178\u9879\u503C\u5DF2\u5B58\u5728

@ -1,48 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.anjiplus.template.gaea.business.modules.export.dao.GaeaExportMapper">
<resultMap type="com.anjiplus.template.gaea.business.modules.export.dao.entity.GaeaExport" id="GaeaExportMap">
<result property="id" column="id" jdbcType="INTEGER"/>
<result property="fileId" column="file_id" jdbcType="VARCHAR"/>
<result property="fileTitle" column="file_title" jdbcType="VARCHAR"/>
<result property="resultStartTime" column="result_start_time" jdbcType="TIMESTAMP"/>
<result property="resultEndTime" column="result_end_time" jdbcType="TIMESTAMP"/>
<result property="resultSize" column="result_size" jdbcType="INTEGER"/>
<result property="fileCreateTime" column="file_create_time" jdbcType="TIMESTAMP"/>
<result property="fileFinishTime" column="file_finish_time" jdbcType="TIMESTAMP"/>
<result property="fileStatus" column="file_status" jdbcType="VARCHAR"/>
<result property="createBy" column="create_by" jdbcType="VARCHAR"/>
<result property="updateBy" column="update_by" jdbcType="VARCHAR"/>
<result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
<result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
<result property="version" column="version" jdbcType="INTEGER"/>
<result property="remark" column="remark" jdbcType="VARCHAR"/>
</resultMap>
<sql id="Base_Column_List">
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
</sql>
<select id="queryExportInfo" resultMap="GaeaExportMap">
SELECT
<include refid="Base_Column_List"></include>
FROM gaea_export ge
WHERE 1=1
<if test="bo.fileTitle!=null and bo.fileTitle!=''">
and ge.file_title=#{bo.fileTitle}
</if>
<if test="ew == null or ew.sqlSegment == null or ew.sqlSegment == '' ">
ORDER BY
ge.create_time DESC
</if>
<if test="ew != null and ew.sqlSegment != null and ew.sqlSegment != '' ">
<if test="ew.paramNameValuePairs != null and ew.paramNameValuePairs.size > 0">
and
</if>
${ew.sqlSegment}
</if>
</select>
</mapper>

@ -1,50 +0,0 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.anjiplus.template.gaea.business.modules.gaeaUiI18n.dao.GaeaUiI18nMapper">
<resultMap type="com.anjiplus.template.gaea.business.modules.gaeaUiI18n.dao.entity.GaeaUiI18n" id="GaeaUiI18nMap">
<!--jdbcType="{column.columnType}"-->
<result property="id" column="id" />
<result property="locale" column="locale" />
<result property="cataType" column="cata_type" />
<result property="system" column="system" />
<result property="code" column="code" />
<result property="name" column="name" />
<result property="remark" column="remark" />
<result property="enabled" column="enabled" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
<result property="version" column="version" />
</resultMap>
<sql id="Base_Column_List">
id,locale,cata_type,system,code,name,remark,enabled,create_by,create_time,update_by,update_time,version
</sql>
<!--自定义sql -->
<select id="queryColumns" resultType="com.anjiplus.template.gaea.business.modules.gaeaUiI18n.service.impl.ColumnDesc" parameterType="java.lang.String">
select table_name as tableName,column_name as columnName,
column_type as columnType,data_type as dataType,character_maximum_length as maxLength,
column_comment as remark,column_default as defaultValue
from information_schema.columns
where table_schema=(select database())
and table_name not like 'ACT%'
<if test="tableName!=null">
and table_name like CONCAT('%', #{tableName})
</if>
</select>
<select id="queryTables" resultType="java.lang.String" parameterType="java.lang.String">
select concat(table_comment,':',table_name) as tableName
from information_schema.tables
where table_schema=(select database())
and table_name not like 'ACT%'
<if test="tableName!=null">
and table_name like CONCAT('%', #{tableName})
</if>
order by update_time desc
limit 100
</select>
<!--,table_comment as comment-->
</mapper>
Loading…
Cancel
Save