简单登录
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=''
|
@ -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,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,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,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;
|
||||
}
|
||||
}
|
@ -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,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,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;
|
||||
}
|
||||
}
|
@ -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,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…
Reference in New Issue