"source/java/src/git@ustchcs.com:wq123/test.git" did not exist on "09d220a27b164917971191000661659d38d4f876"
Commit ba16a830 authored by Zheng Jie's avatar Zheng Jie
Browse files

Merge branch 'master' into deploy

# Conflicts:
#	README.md
#	eladmin-system/src/main/java/me/zhengjie/modules/security/rest/OnlineController.java
parents 6c9901a8 cf3655ad
...@@ -176,7 +176,7 @@ recommend that a file or class name and description of purpose be included on ...@@ -176,7 +176,7 @@ recommend that a file or class name and description of purpose be included on
the same "printed page" as the copyright notice for easier identification within the same "printed page" as the copyright notice for easier identification within
third-party archives. third-party archives.
Copyright 2019-2020 Zheng Jie Copyright 2019-2023 Zheng Jie
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
......
...@@ -74,7 +74,9 @@ public @interface Query { ...@@ -74,7 +74,9 @@ public @interface Query {
// 不为空 // 不为空
,NOT_NULL ,NOT_NULL
// 为空 // 为空
,IS_NULL ,IS_NULL,
// Aborn Jiang 2022/06/01, 对应SQL: SELECT * FROM table WHERE FIND_IN_SET('querytag', table.tags);
FIND_IN_SET
} }
/** /**
......
package me.zhengjie.utils;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import java.util.List;
@Getter
@RequiredArgsConstructor(access = AccessLevel.PACKAGE)
public class PageResult<T> {
private final List<T> content;
private final long totalElements;
}
...@@ -28,11 +28,11 @@ public class PageUtil extends cn.hutool.core.util.PageUtil { ...@@ -28,11 +28,11 @@ public class PageUtil extends cn.hutool.core.util.PageUtil {
/** /**
* List 分页 * List 分页
*/ */
public static List toPage(int page, int size , List list) { public static <T> List<T> paging(int page, int size , List<T> list) {
int fromIndex = page * size; int fromIndex = page * size;
int toIndex = page * size + size; int toIndex = page * size + size;
if(fromIndex > list.size()){ if(fromIndex > list.size()){
return new ArrayList(); return Collections.emptyList();
} else if(toIndex >= list.size()) { } else if(toIndex >= list.size()) {
return list.subList(fromIndex,list.size()); return list.subList(fromIndex,list.size());
} else { } else {
...@@ -43,21 +43,21 @@ public class PageUtil extends cn.hutool.core.util.PageUtil { ...@@ -43,21 +43,21 @@ public class PageUtil extends cn.hutool.core.util.PageUtil {
/** /**
* Page 数据处理,预防redis反序列化报错 * Page 数据处理,预防redis反序列化报错
*/ */
public static Map<String,Object> toPage(Page page) { public static <T> PageResult<T> toPage(Page<T> page) {
Map<String,Object> map = new LinkedHashMap<>(2); return new PageResult<>(page.getContent(), page.getTotalElements());
map.put("content",page.getContent());
map.put("totalElements",page.getTotalElements());
return map;
} }
/** /**
* 自定义分页 * 自定义分页
*/ */
public static Map<String,Object> toPage(Object object, Object totalElements) { public static <T> PageResult<T> toPage(List<T> list, long totalElements) {
Map<String,Object> map = new LinkedHashMap<>(2); return new PageResult<>(list, totalElements);
map.put("content",object);
map.put("totalElements",totalElements);
return map;
} }
/**
* 返回空数据
*/
public static <T> PageResult<T> noData () {
return new PageResult<>(null, 0);
}
} }
...@@ -166,6 +166,10 @@ public class QueryHelp { ...@@ -166,6 +166,10 @@ public class QueryHelp {
(Comparable) between.get(0), (Comparable) between.get(1))); (Comparable) between.get(0), (Comparable) between.get(1)));
} }
break; break;
case FIND_IN_SET:
list.add(cb.greaterThan(cb.function("FIND_IN_SET", Integer.class,
cb.literal(val.toString()), root.get(attributeName)), 0));
break;
default: break; default: break;
} }
} }
......
...@@ -19,13 +19,11 @@ import com.google.common.collect.Lists; ...@@ -19,13 +19,11 @@ import com.google.common.collect.Lists;
import com.google.common.collect.Sets; import com.google.common.collect.Sets;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.redis.connection.RedisConnection; import org.springframework.data.redis.connection.RedisConnection;
import org.springframework.data.redis.connection.RedisConnectionFactory; import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.core.*; import org.springframework.data.redis.core.*;
import org.springframework.data.redis.serializer.StringRedisSerializer; import org.springframework.data.redis.serializer.StringRedisSerializer;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.util.*; import java.util.*;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
...@@ -36,9 +34,8 @@ import java.util.concurrent.TimeUnit; ...@@ -36,9 +34,8 @@ import java.util.concurrent.TimeUnit;
@SuppressWarnings({"unchecked", "all"}) @SuppressWarnings({"unchecked", "all"})
public class RedisUtils { public class RedisUtils {
private static final Logger log = LoggerFactory.getLogger(RedisUtils.class); private static final Logger log = LoggerFactory.getLogger(RedisUtils.class);
private RedisTemplate<Object, Object> redisTemplate; private RedisTemplate<Object, Object> redisTemplate;
@Value("${jwt.online-key}")
private String onlineKey;
public RedisUtils(RedisTemplate<Object, Object> redisTemplate) { public RedisUtils(RedisTemplate<Object, Object> redisTemplate) {
this.redisTemplate = redisTemplate; this.redisTemplate = redisTemplate;
...@@ -51,7 +48,7 @@ public class RedisUtils { ...@@ -51,7 +48,7 @@ public class RedisUtils {
* 指定缓存失效时间 * 指定缓存失效时间
* *
* @param key 键 * @param key 键
* @param time 时间(秒) * @param time 时间(秒) 注意:这里将会替换原有的时间
*/ */
public boolean expire(String key, long time) { public boolean expire(String key, long time) {
try { try {
...@@ -69,7 +66,7 @@ public class RedisUtils { ...@@ -69,7 +66,7 @@ public class RedisUtils {
* 指定缓存失效时间 * 指定缓存失效时间
* *
* @param key 键 * @param key 键
* @param time 时间(秒) * @param time 时间(秒) 注意:这里将会替换原有的时间
* @param timeUnit 单位 * @param timeUnit 单位
*/ */
public boolean expire(String key, long time, TimeUnit timeUnit) { public boolean expire(String key, long time, TimeUnit timeUnit) {
...@@ -197,6 +194,21 @@ public class RedisUtils { ...@@ -197,6 +194,21 @@ public class RedisUtils {
} }
} }
/**
* 批量模糊删除key
* @param pattern
*/
public void scanDel(String pattern){
ScanOptions options = ScanOptions.scanOptions().match(pattern).build();
try (Cursor<byte[]> cursor = redisTemplate.executeWithStickyConnection(
(RedisCallback<Cursor<byte[]>>) connection -> (Cursor<byte[]>) new ConvertingCursor<>(
connection.scan(options), redisTemplate.getKeySerializer()::deserialize))) {
while (cursor.hasNext()) {
redisTemplate.delete(cursor.next());
}
}
}
// ============================String============================= // ============================String=============================
/** /**
...@@ -244,7 +256,7 @@ public class RedisUtils { ...@@ -244,7 +256,7 @@ public class RedisUtils {
* *
* @param key 键 * @param key 键
* @param value 值 * @param value 值
* @param time 时间(秒) time要大于0 如果time小于等于0 将设置无限期 * @param time 时间(秒) time要大于0 如果time小于等于0 将设置无限期,注意:这里将会替换原有的时间
* @return true成功 false 失败 * @return true成功 false 失败
*/ */
public boolean set(String key, Object value, long time) { public boolean set(String key, Object value, long time) {
...@@ -266,7 +278,7 @@ public class RedisUtils { ...@@ -266,7 +278,7 @@ public class RedisUtils {
* *
* @param key 键 * @param key 键
* @param value 值 * @param value 值
* @param time 时间 * @param time 时间,注意:这里将会替换原有的时间
* @param timeUnit 类型 * @param timeUnit 类型
* @return true成功 false 失败 * @return true成功 false 失败
*/ */
...@@ -326,11 +338,11 @@ public class RedisUtils { ...@@ -326,11 +338,11 @@ public class RedisUtils {
} }
/** /**
* HashSet 并设置时间 * HashSet
* *
* @param key 键 * @param key 键
* @param map 对应多个键值 * @param map 对应多个键值
* @param time 时间(秒) * @param time 时间(秒) 注意:如果已存在的hash表有时间,这里将会替换原有的时间
* @return true成功 false失败 * @return true成功 false失败
*/ */
public boolean hmset(String key, Map<String, Object> map, long time) { public boolean hmset(String key, Map<String, Object> map, long time) {
...@@ -484,7 +496,7 @@ public class RedisUtils { ...@@ -484,7 +496,7 @@ public class RedisUtils {
* 将set数据放入缓存 * 将set数据放入缓存
* *
* @param key 键 * @param key 键
* @param time 时间(秒) * @param time 时间(秒) 注意:这里将会替换原有的时间
* @param values 值 可以是多个 * @param values 值 可以是多个
* @return 成功个数 * @return 成功个数
*/ */
...@@ -605,7 +617,7 @@ public class RedisUtils { ...@@ -605,7 +617,7 @@ public class RedisUtils {
* *
* @param key 键 * @param key 键
* @param value 值 * @param value 值
* @param time 时间(秒) * @param time 时间(秒) 注意:这里将会替换原有的时间
* @return * @return
*/ */
public boolean lSet(String key, Object value, long time) { public boolean lSet(String key, Object value, long time) {
...@@ -643,7 +655,7 @@ public class RedisUtils { ...@@ -643,7 +655,7 @@ public class RedisUtils {
* *
* @param key 键 * @param key 键
* @param value 值 * @param value 值
* @param time 时间(秒) * @param time 时间(秒) 注意:这里将会替换原有的时间
* @return * @return
*/ */
public boolean lSet(String key, List<Object> value, long time) { public boolean lSet(String key, List<Object> value, long time) {
......
...@@ -39,7 +39,7 @@ public class GenConfigController { ...@@ -39,7 +39,7 @@ public class GenConfigController {
@ApiOperation("查询") @ApiOperation("查询")
@GetMapping(value = "/{tableName}") @GetMapping(value = "/{tableName}")
public ResponseEntity<Object> queryGenConfig(@PathVariable String tableName){ public ResponseEntity<GenConfig> queryGenConfig(@PathVariable String tableName){
return new ResponseEntity<>(genConfigService.find(tableName), HttpStatus.OK); return new ResponseEntity<>(genConfigService.find(tableName), HttpStatus.OK);
} }
......
...@@ -19,9 +19,11 @@ import io.swagger.annotations.Api; ...@@ -19,9 +19,11 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import me.zhengjie.domain.ColumnInfo; import me.zhengjie.domain.ColumnInfo;
import me.zhengjie.domain.vo.TableInfo;
import me.zhengjie.exception.BadRequestException; import me.zhengjie.exception.BadRequestException;
import me.zhengjie.service.GenConfigService; import me.zhengjie.service.GenConfigService;
import me.zhengjie.service.GeneratorService; import me.zhengjie.service.GeneratorService;
import me.zhengjie.utils.PageResult;
import me.zhengjie.utils.PageUtil; import me.zhengjie.utils.PageUtil;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
...@@ -55,16 +57,16 @@ public class GeneratorController { ...@@ -55,16 +57,16 @@ public class GeneratorController {
@ApiOperation("查询数据库数据") @ApiOperation("查询数据库数据")
@GetMapping(value = "/tables") @GetMapping(value = "/tables")
public ResponseEntity<Object> queryTables(@RequestParam(defaultValue = "") String name, public ResponseEntity<PageResult<TableInfo>> queryTables(@RequestParam(defaultValue = "") String name,
@RequestParam(defaultValue = "0")Integer page, @RequestParam(defaultValue = "0")Integer page,
@RequestParam(defaultValue = "10")Integer size){ @RequestParam(defaultValue = "10")Integer size){
int[] startEnd = PageUtil.transToStartEnd(page, size); int[] startEnd = PageUtil.transToStartEnd(page, size);
return new ResponseEntity<>(generatorService.getTables(name,startEnd), HttpStatus.OK); return new ResponseEntity<>(generatorService.getTables(name,startEnd), HttpStatus.OK);
} }
@ApiOperation("查询字段数据") @ApiOperation("查询字段数据")
@GetMapping(value = "/columns") @GetMapping(value = "/columns")
public ResponseEntity<Object> queryColumns(@RequestParam String tableName){ public ResponseEntity<PageResult<ColumnInfo>> queryColumns(@RequestParam String tableName){
List<ColumnInfo> columnInfos = generatorService.getColumns(tableName); List<ColumnInfo> columnInfos = generatorService.getColumns(tableName);
return new ResponseEntity<>(PageUtil.toPage(columnInfos,columnInfos.size()), HttpStatus.OK); return new ResponseEntity<>(PageUtil.toPage(columnInfos,columnInfos.size()), HttpStatus.OK);
} }
......
...@@ -17,6 +17,8 @@ package me.zhengjie.service; ...@@ -17,6 +17,8 @@ package me.zhengjie.service;
import me.zhengjie.domain.GenConfig; import me.zhengjie.domain.GenConfig;
import me.zhengjie.domain.ColumnInfo; import me.zhengjie.domain.ColumnInfo;
import me.zhengjie.domain.vo.TableInfo;
import me.zhengjie.utils.PageResult;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.scheduling.annotation.Async; import org.springframework.scheduling.annotation.Async;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
...@@ -35,7 +37,7 @@ public interface GeneratorService { ...@@ -35,7 +37,7 @@ public interface GeneratorService {
* @param startEnd 分页参数 * @param startEnd 分页参数
* @return / * @return /
*/ */
Object getTables(String name, int[] startEnd); PageResult<TableInfo> getTables(String name, int[] startEnd);
/** /**
* 得到数据表的元数据 * 得到数据表的元数据
......
...@@ -25,10 +25,7 @@ import me.zhengjie.domain.vo.TableInfo; ...@@ -25,10 +25,7 @@ import me.zhengjie.domain.vo.TableInfo;
import me.zhengjie.exception.BadRequestException; import me.zhengjie.exception.BadRequestException;
import me.zhengjie.repository.ColumnInfoRepository; import me.zhengjie.repository.ColumnInfoRepository;
import me.zhengjie.service.GeneratorService; import me.zhengjie.service.GeneratorService;
import me.zhengjie.utils.FileUtil; import me.zhengjie.utils.*;
import me.zhengjie.utils.GenUtil;
import me.zhengjie.utils.PageUtil;
import me.zhengjie.utils.StringUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
...@@ -41,6 +38,7 @@ import javax.servlet.http.HttpServletRequest; ...@@ -41,6 +38,7 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.math.BigInteger;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
...@@ -71,7 +69,7 @@ public class GeneratorServiceImpl implements GeneratorService { ...@@ -71,7 +69,7 @@ public class GeneratorServiceImpl implements GeneratorService {
} }
@Override @Override
public Object getTables(String name, int[] startEnd) { public PageResult<TableInfo> getTables(String name, int[] startEnd) {
// 使用预编译防止sql注入 // 使用预编译防止sql注入
String sql = "select table_name ,create_time , engine, table_collation, table_comment from information_schema.tables " + String sql = "select table_name ,create_time , engine, table_collation, table_comment from information_schema.tables " +
"where table_schema = (select database()) " + "where table_schema = (select database()) " +
...@@ -90,8 +88,8 @@ public class GeneratorServiceImpl implements GeneratorService { ...@@ -90,8 +88,8 @@ public class GeneratorServiceImpl implements GeneratorService {
"where table_schema = (select database()) and table_name like :table"; "where table_schema = (select database()) and table_name like :table";
Query queryCount = em.createNativeQuery(countSql); Query queryCount = em.createNativeQuery(countSql);
queryCount.setParameter("table", StringUtils.isNotBlank(name) ? ("%" + name + "%") : "%%"); queryCount.setParameter("table", StringUtils.isNotBlank(name) ? ("%" + name + "%") : "%%");
Object totalElements = queryCount.getSingleResult(); BigInteger totalElements = (BigInteger) queryCount.getSingleResult();
return PageUtil.toPage(tableInfos, totalElements); return PageUtil.toPage(tableInfos, totalElements.longValue());
} }
@Override @Override
......
...@@ -87,7 +87,7 @@ public class GenUtil { ...@@ -87,7 +87,7 @@ public class GenUtil {
TemplateEngine engine = TemplateUtil.createEngine(new TemplateConfig("template", TemplateConfig.ResourceMode.CLASSPATH)); TemplateEngine engine = TemplateUtil.createEngine(new TemplateConfig("template", TemplateConfig.ResourceMode.CLASSPATH));
for (String templateName : templates) { for (String templateName : templates) {
Map<String, Object> map = new HashMap<>(1); Map<String, Object> map = new HashMap<>(1);
Template template = engine.getTemplate("generator/admin/" + templateName + ".ftl"); Template template = engine.getTemplate("admin/" + templateName + ".ftl");
map.put("content", template.render(genMap)); map.put("content", template.render(genMap));
map.put("name", templateName); map.put("name", templateName);
genList.add(map); genList.add(map);
...@@ -96,7 +96,7 @@ public class GenUtil { ...@@ -96,7 +96,7 @@ public class GenUtil {
templates = getFrontTemplateNames(); templates = getFrontTemplateNames();
for (String templateName : templates) { for (String templateName : templates) {
Map<String, Object> map = new HashMap<>(1); Map<String, Object> map = new HashMap<>(1);
Template template = engine.getTemplate("generator/front/" + templateName + ".ftl"); Template template = engine.getTemplate("front/" + templateName + ".ftl");
map.put(templateName, template.render(genMap)); map.put(templateName, template.render(genMap));
map.put("content", template.render(genMap)); map.put("content", template.render(genMap));
map.put("name", templateName); map.put("name", templateName);
...@@ -114,7 +114,7 @@ public class GenUtil { ...@@ -114,7 +114,7 @@ public class GenUtil {
// 生成后端代码 // 生成后端代码
List<String> templates = getAdminTemplateNames(); List<String> templates = getAdminTemplateNames();
for (String templateName : templates) { for (String templateName : templates) {
Template template = engine.getTemplate("generator/admin/" + templateName + ".ftl"); Template template = engine.getTemplate("admin/" + templateName + ".ftl");
String filePath = getAdminFilePath(templateName, genConfig, genMap.get("className").toString(), tempPath + "eladmin" + File.separator); String filePath = getAdminFilePath(templateName, genConfig, genMap.get("className").toString(), tempPath + "eladmin" + File.separator);
assert filePath != null; assert filePath != null;
File file = new File(filePath); File file = new File(filePath);
...@@ -128,7 +128,7 @@ public class GenUtil { ...@@ -128,7 +128,7 @@ public class GenUtil {
// 生成前端代码 // 生成前端代码
templates = getFrontTemplateNames(); templates = getFrontTemplateNames();
for (String templateName : templates) { for (String templateName : templates) {
Template template = engine.getTemplate("generator/front/" + templateName + ".ftl"); Template template = engine.getTemplate("front/" + templateName + ".ftl");
String path = tempPath + "eladmin-web" + File.separator; String path = tempPath + "eladmin-web" + File.separator;
String apiPath = path + "src" + File.separator + "api" + File.separator; String apiPath = path + "src" + File.separator + "api" + File.separator;
String srcPath = path + "src" + File.separator + "views" + File.separator + genMap.get("changeClassName").toString() + File.separator; String srcPath = path + "src" + File.separator + "views" + File.separator + genMap.get("changeClassName").toString() + File.separator;
...@@ -151,7 +151,7 @@ public class GenUtil { ...@@ -151,7 +151,7 @@ public class GenUtil {
// 生成后端代码 // 生成后端代码
List<String> templates = getAdminTemplateNames(); List<String> templates = getAdminTemplateNames();
for (String templateName : templates) { for (String templateName : templates) {
Template template = engine.getTemplate("generator/admin/" + templateName + ".ftl"); Template template = engine.getTemplate("admin/" + templateName + ".ftl");
String rootPath = System.getProperty("user.dir"); String rootPath = System.getProperty("user.dir");
String filePath = getAdminFilePath(templateName, genConfig, genMap.get("className").toString(), rootPath); String filePath = getAdminFilePath(templateName, genConfig, genMap.get("className").toString(), rootPath);
...@@ -169,7 +169,7 @@ public class GenUtil { ...@@ -169,7 +169,7 @@ public class GenUtil {
// 生成前端代码 // 生成前端代码
templates = getFrontTemplateNames(); templates = getFrontTemplateNames();
for (String templateName : templates) { for (String templateName : templates) {
Template template = engine.getTemplate("generator/front/" + templateName + ".ftl"); Template template = engine.getTemplate("front/" + templateName + ".ftl");
String filePath = getFrontFilePath(templateName, genConfig.getApiPath(), genConfig.getPath(), genMap.get("changeClassName").toString()); String filePath = getFrontFilePath(templateName, genConfig.getApiPath(), genConfig.getPath(), genMap.get("changeClassName").toString());
assert filePath != null; assert filePath != null;
......
#数据库类型转Java类型 # Database type to Java type
tinyint=Integer tinyint=Integer
smallint=Integer smallint=Integer
mediumint=Integer mediumint=Integer
......
...@@ -29,6 +29,8 @@ import org.springframework.web.bind.annotation.*; ...@@ -29,6 +29,8 @@ import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.*; import io.swagger.annotations.*;
import java.io.IOException; import java.io.IOException;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import me.zhengjie.utils.PageResult;
import ${package}.service.dto.${className}Dto;
/** /**
* @website https://eladmin.vip * @website https://eladmin.vip
...@@ -55,7 +57,7 @@ public class ${className}Controller { ...@@ -55,7 +57,7 @@ public class ${className}Controller {
@Log("查询${apiAlias}") @Log("查询${apiAlias}")
@ApiOperation("查询${apiAlias}") @ApiOperation("查询${apiAlias}")
@PreAuthorize("@el.check('${changeClassName}:list')") @PreAuthorize("@el.check('${changeClassName}:list')")
public ResponseEntity<Object> query${className}(${className}QueryCriteria criteria, Pageable pageable){ public ResponseEntity<PageResult<${className}Dto>> query${className}(${className}QueryCriteria criteria, Pageable pageable){
return new ResponseEntity<>(${changeClassName}Service.queryAll(criteria,pageable),HttpStatus.OK); return new ResponseEntity<>(${changeClassName}Service.queryAll(criteria,pageable),HttpStatus.OK);
} }
...@@ -64,7 +66,8 @@ public class ${className}Controller { ...@@ -64,7 +66,8 @@ public class ${className}Controller {
@ApiOperation("新增${apiAlias}") @ApiOperation("新增${apiAlias}")
@PreAuthorize("@el.check('${changeClassName}:add')") @PreAuthorize("@el.check('${changeClassName}:add')")
public ResponseEntity<Object> create${className}(@Validated @RequestBody ${className} resources){ public ResponseEntity<Object> create${className}(@Validated @RequestBody ${className} resources){
return new ResponseEntity<>(${changeClassName}Service.create(resources),HttpStatus.CREATED); ${changeClassName}Service.create(resources);
return new ResponseEntity<>(HttpStatus.CREATED);
} }
@PutMapping @PutMapping
......
...@@ -23,6 +23,7 @@ import java.util.Map; ...@@ -23,6 +23,7 @@ import java.util.Map;
import java.util.List; import java.util.List;
import java.io.IOException; import java.io.IOException;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import me.zhengjie.utils.PageResult;
/** /**
* @website https://eladmin.vip * @website https://eladmin.vip
...@@ -38,7 +39,7 @@ public interface ${className}Service { ...@@ -38,7 +39,7 @@ public interface ${className}Service {
* @param pageable 分页参数 * @param pageable 分页参数
* @return Map<String,Object> * @return Map<String,Object>
*/ */
Map<String,Object> queryAll(${className}QueryCriteria criteria, Pageable pageable); PageResult<${className}Dto> queryAll(${className}QueryCriteria criteria, Pageable pageable);
/** /**
* 查询所有数据不分页 * 查询所有数据不分页
...@@ -57,9 +58,8 @@ public interface ${className}Service { ...@@ -57,9 +58,8 @@ public interface ${className}Service {
/** /**
* 创建 * 创建
* @param resources / * @param resources /
* @return ${className}Dto
*/ */
${className}Dto create(${className} resources); void create(${className} resources);
/** /**
* 编辑 * 编辑
......
...@@ -52,6 +52,7 @@ import java.io.IOException; ...@@ -52,6 +52,7 @@ import java.io.IOException;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import me.zhengjie.utils.PageResult;
/** /**
* @website https://eladmin.vip * @website https://eladmin.vip
...@@ -67,7 +68,7 @@ public class ${className}ServiceImpl implements ${className}Service { ...@@ -67,7 +68,7 @@ public class ${className}ServiceImpl implements ${className}Service {
private final ${className}Mapper ${changeClassName}Mapper; private final ${className}Mapper ${changeClassName}Mapper;
@Override @Override
public Map<String,Object> queryAll(${className}QueryCriteria criteria, Pageable pageable){ public PageResult<${className}Dto> queryAll(${className}QueryCriteria criteria, Pageable pageable){
Page<${className}> page = ${changeClassName}Repository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable); Page<${className}> page = ${changeClassName}Repository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable);
return PageUtil.toPage(page.map(${changeClassName}Mapper::toDto)); return PageUtil.toPage(page.map(${changeClassName}Mapper::toDto));
} }
...@@ -87,7 +88,7 @@ public class ${className}ServiceImpl implements ${className}Service { ...@@ -87,7 +88,7 @@ public class ${className}ServiceImpl implements ${className}Service {
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public ${className}Dto create(${className} resources) { public void create(${className} resources) {
<#if !auto && pkColumnType = 'Long'> <#if !auto && pkColumnType = 'Long'>
Snowflake snowflake = IdUtil.createSnowflake(1, 1); Snowflake snowflake = IdUtil.createSnowflake(1, 1);
resources.set${pkCapitalColName}(snowflake.nextId()); resources.set${pkCapitalColName}(snowflake.nextId());
...@@ -104,7 +105,7 @@ public class ${className}ServiceImpl implements ${className}Service { ...@@ -104,7 +105,7 @@ public class ${className}ServiceImpl implements ${className}Service {
</#if> </#if>
</#list> </#list>
</#if> </#if>
return ${changeClassName}Mapper.toDto(${changeClassName}Repository.save(resources)); ${changeClassName}Repository.save(resources);
} }
@Override @Override
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment