mirror of https://github.com/elunez/eladmin
代码生成器优化,新增多数据字典支持,用户修改密码优化
parent
375cdf4dc3
commit
c4fc3da175
|
@ -31,6 +31,7 @@ public @interface Query {
|
||||||
Join join() default Join.LEFT;
|
Join join() default Join.LEFT;
|
||||||
|
|
||||||
enum Type {
|
enum Type {
|
||||||
|
/** jie 2019/6/4 相等 */
|
||||||
EQUAL
|
EQUAL
|
||||||
/** Dong ZhaoYang 2017/8/7 大于等于 */
|
/** Dong ZhaoYang 2017/8/7 大于等于 */
|
||||||
, GREATER_THAN
|
, GREATER_THAN
|
||||||
|
|
|
@ -101,7 +101,9 @@ public class QueryHelp {
|
||||||
private static <T, R> Expression<T> getExpression(String attributeName, Join join, Root<R> root) {
|
private static <T, R> Expression<T> getExpression(String attributeName, Join join, Root<R> root) {
|
||||||
if (ObjectUtil.isNotEmpty(join)) {
|
if (ObjectUtil.isNotEmpty(join)) {
|
||||||
return join.get(attributeName);
|
return join.get(attributeName);
|
||||||
} else return root.get(attributeName);
|
} else {
|
||||||
|
return root.get(attributeName);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
|
|
|
@ -19,4 +19,15 @@ public class TableInfo {
|
||||||
|
|
||||||
/** 创建日期 **/
|
/** 创建日期 **/
|
||||||
private Object createTime;
|
private Object createTime;
|
||||||
|
|
||||||
|
// 数据库引擎
|
||||||
|
private Object engine;
|
||||||
|
|
||||||
|
// 编码集
|
||||||
|
private Object coding;
|
||||||
|
|
||||||
|
// 备注
|
||||||
|
private Object remark;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,6 +23,7 @@ public interface GenConfigService {
|
||||||
/**
|
/**
|
||||||
* update
|
* update
|
||||||
* @param genConfig
|
* @param genConfig
|
||||||
|
* @return
|
||||||
*/
|
*/
|
||||||
@CacheEvict(allEntries = true)
|
@CacheEvict(allEntries = true)
|
||||||
GenConfig update(GenConfig genConfig);
|
GenConfig update(GenConfig genConfig);
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package me.zhengjie.service.impl;
|
package me.zhengjie.service.impl;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import me.zhengjie.domain.GenConfig;
|
import me.zhengjie.domain.GenConfig;
|
||||||
import me.zhengjie.domain.vo.ColumnInfo;
|
import me.zhengjie.domain.vo.ColumnInfo;
|
||||||
import me.zhengjie.domain.vo.TableInfo;
|
import me.zhengjie.domain.vo.TableInfo;
|
||||||
|
@ -7,8 +8,8 @@ import me.zhengjie.exception.BadRequestException;
|
||||||
import me.zhengjie.service.GeneratorService;
|
import me.zhengjie.service.GeneratorService;
|
||||||
import me.zhengjie.utils.GenUtil;
|
import me.zhengjie.utils.GenUtil;
|
||||||
import me.zhengjie.utils.PageUtil;
|
import me.zhengjie.utils.PageUtil;
|
||||||
|
import me.zhengjie.utils.StringUtils;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.util.ObjectUtils;
|
|
||||||
import javax.persistence.EntityManager;
|
import javax.persistence.EntityManager;
|
||||||
import javax.persistence.PersistenceContext;
|
import javax.persistence.PersistenceContext;
|
||||||
import javax.persistence.Query;
|
import javax.persistence.Query;
|
||||||
|
@ -28,20 +29,18 @@ public class GeneratorServiceImpl implements GeneratorService {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object getTables(String name, int[] startEnd) {
|
public Object getTables(String name, int[] startEnd) {
|
||||||
StringBuilder sql = new StringBuilder("select table_name tableName,create_time createTime from information_schema.tables where table_schema = (select database()) ");
|
// 使用预编译防止sql注入
|
||||||
if(!ObjectUtils.isEmpty(name)){
|
String sql = "select table_name ,create_time , engine, table_collation, table_comment from information_schema.tables " +
|
||||||
sql.append("and table_name like '%"+name+"%' ");
|
"where table_schema = (select database()) " +
|
||||||
}
|
"and table_name like ? order by create_time desc";
|
||||||
sql.append("order by table_name");
|
Query query = em.createNativeQuery(sql);
|
||||||
Query query = em.createNativeQuery(sql.toString());
|
|
||||||
query.setFirstResult(startEnd[0]);
|
query.setFirstResult(startEnd[0]);
|
||||||
query.setMaxResults(startEnd[1]-startEnd[0]);
|
query.setMaxResults(startEnd[1]-startEnd[0]);
|
||||||
|
query.setParameter(1, StringUtils.isNotBlank(name) ? ("%" + name + "%") : "%%");
|
||||||
System.out.println(sql.toString());
|
|
||||||
List<Object[]> result = query.getResultList();
|
List<Object[]> result = query.getResultList();
|
||||||
List<TableInfo> tableInfos = new ArrayList<>();
|
List<TableInfo> tableInfos = new ArrayList<>();
|
||||||
for (Object[] obj : result) {
|
for (Object[] obj : result) {
|
||||||
tableInfos.add(new TableInfo(obj[0],obj[1]));
|
tableInfos.add(new TableInfo(obj[0],obj[1],obj[2],obj[3], ObjectUtil.isNotEmpty(obj[4])? obj[4] : "-"));
|
||||||
}
|
}
|
||||||
Query query1 = em.createNativeQuery("SELECT COUNT(*) from information_schema.tables where table_schema = (select database())");
|
Query query1 = em.createNativeQuery("SELECT COUNT(*) from information_schema.tables where table_schema = (select database())");
|
||||||
Object totalElements = query1.getSingleResult();
|
Object totalElements = query1.getSingleResult();
|
||||||
|
@ -50,12 +49,11 @@ public class GeneratorServiceImpl implements GeneratorService {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object getColumns(String name) {
|
public Object getColumns(String name) {
|
||||||
StringBuilder sql = new StringBuilder("select column_name, is_nullable, data_type, column_comment, column_key, extra from information_schema.columns where ");
|
// 使用预编译防止sql注入
|
||||||
if(!ObjectUtils.isEmpty(name)){
|
String sql = "select column_name, is_nullable, data_type, column_comment, column_key, extra from information_schema.columns " +
|
||||||
sql.append("table_name = '"+name+"' ");
|
"where table_name = ? and table_schema = (select database()) order by ordinal_position";
|
||||||
}
|
Query query = em.createNativeQuery(sql);
|
||||||
sql.append("and table_schema = (select database()) order by ordinal_position");
|
query.setParameter(1, StringUtils.isNotBlank(name) ? name : null);
|
||||||
Query query = em.createNativeQuery(sql.toString());
|
|
||||||
List<Object[]> result = query.getResultList();
|
List<Object[]> result = query.getResultList();
|
||||||
List<ColumnInfo> columnInfos = new ArrayList<>();
|
List<ColumnInfo> columnInfos = new ArrayList<>();
|
||||||
for (Object[] obj : result) {
|
for (Object[] obj : result) {
|
||||||
|
|
|
@ -57,8 +57,6 @@ public class GenUtil {
|
||||||
List<String> templateNames = new ArrayList<>();
|
List<String> templateNames = new ArrayList<>();
|
||||||
templateNames.add("api");
|
templateNames.add("api");
|
||||||
templateNames.add("index");
|
templateNames.add("index");
|
||||||
templateNames.add("header");
|
|
||||||
templateNames.add("edit");
|
|
||||||
templateNames.add("eForm");
|
templateNames.add("eForm");
|
||||||
return templateNames;
|
return templateNames;
|
||||||
}
|
}
|
||||||
|
@ -174,8 +172,8 @@ public class GenUtil {
|
||||||
* 定义后端文件路径以及名称
|
* 定义后端文件路径以及名称
|
||||||
*/
|
*/
|
||||||
public static String getAdminFilePath(String templateName, GenConfig genConfig, String className) {
|
public static String getAdminFilePath(String templateName, GenConfig genConfig, String className) {
|
||||||
String ProjectPath = System.getProperty("user.dir") + File.separator + genConfig.getModuleName();
|
String projectPath = System.getProperty("user.dir") + File.separator + genConfig.getModuleName();
|
||||||
String packagePath = ProjectPath + File.separator + "src" +File.separator+ "main" + File.separator + "java" + File.separator;
|
String packagePath = projectPath + File.separator + "src" +File.separator+ "main" + File.separator + "java" + File.separator;
|
||||||
if (!ObjectUtils.isEmpty(genConfig.getPack())) {
|
if (!ObjectUtils.isEmpty(genConfig.getPack())) {
|
||||||
packagePath += genConfig.getPack().replace(".", File.separator) + File.separator;
|
packagePath += genConfig.getPack().replace(".", File.separator) + File.separator;
|
||||||
}
|
}
|
||||||
|
@ -229,16 +227,8 @@ public class GenUtil {
|
||||||
return path + File.separator + "index.vue";
|
return path + File.separator + "index.vue";
|
||||||
}
|
}
|
||||||
|
|
||||||
if ("header".equals(templateName)) {
|
|
||||||
return path + File.separator + "module" + File.separator + "header.vue";
|
|
||||||
}
|
|
||||||
|
|
||||||
if ("edit".equals(templateName)) {
|
|
||||||
return path + File.separator + "module" + File.separator + "edit.vue";
|
|
||||||
}
|
|
||||||
|
|
||||||
if ("eForm".equals(templateName)) {
|
if ("eForm".equals(templateName)) {
|
||||||
return path + File.separator + "module" + File.separator + "form.vue";
|
return path + File.separator + File.separator + "form.vue";
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,6 +22,11 @@ public interface LogRepository extends JpaRepository<Log,Long>, JpaSpecification
|
||||||
@Query(value = "select count(*) FROM (select request_ip FROM log where create_time between ?1 and ?2 GROUP BY request_ip) as s",nativeQuery = true)
|
@Query(value = "select count(*) FROM (select request_ip FROM log where create_time between ?1 and ?2 GROUP BY request_ip) as s",nativeQuery = true)
|
||||||
Long findIp(String date1, String date2);
|
Long findIp(String date1, String date2);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* findExceptionById
|
||||||
|
* @param id
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
@Query(value = "select exception_detail FROM log where id = ?1",nativeQuery = true)
|
@Query(value = "select exception_detail FROM log where id = ?1",nativeQuery = true)
|
||||||
String findExceptionById(Long id);
|
String findExceptionById(Long id);
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,6 +30,8 @@ public interface LogService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 新增日志
|
* 新增日志
|
||||||
|
* @param username
|
||||||
|
* @param ip
|
||||||
* @param joinPoint
|
* @param joinPoint
|
||||||
* @param log
|
* @param log
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -16,4 +16,7 @@ public class LogQueryCriteria {
|
||||||
|
|
||||||
@Query
|
@Query
|
||||||
private String logType;
|
private String logType;
|
||||||
|
|
||||||
|
@Query(type = Query.Type.INNER_LIKE)
|
||||||
|
private String description;
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,7 +42,7 @@ public class LogServiceImpl implements LogService {
|
||||||
@Override
|
@Override
|
||||||
public Object queryAll(LogQueryCriteria criteria, Pageable pageable){
|
public Object queryAll(LogQueryCriteria criteria, Pageable pageable){
|
||||||
Page<Log> page = logRepository.findAll(((root, criteriaQuery, cb) -> QueryHelp.getPredicate(root, criteria, cb)),pageable);
|
Page<Log> page = logRepository.findAll(((root, criteriaQuery, cb) -> QueryHelp.getPredicate(root, criteria, cb)),pageable);
|
||||||
if (criteria.getLogType().equals("ERROR")) {
|
if ("ERROR".equals(criteria.getLogType())) {
|
||||||
return PageUtil.toPage(page.map(logErrorMapper::toDto));
|
return PageUtil.toPage(page.map(logErrorMapper::toDto));
|
||||||
}
|
}
|
||||||
return page;
|
return page;
|
||||||
|
|
|
@ -25,7 +25,7 @@ public class RedisServiceImpl implements RedisService {
|
||||||
@Override
|
@Override
|
||||||
public Page<RedisVo> findByKey(String key, Pageable pageable){
|
public Page<RedisVo> findByKey(String key, Pageable pageable){
|
||||||
List<RedisVo> redisVos = new ArrayList<>();
|
List<RedisVo> redisVos = new ArrayList<>();
|
||||||
if(!key.equals("*")){
|
if(!"*".equals(key)){
|
||||||
key = "*" + key + "*";
|
key = "*" + key + "*";
|
||||||
}
|
}
|
||||||
for (Object s : redisTemplate.keys(key)) {
|
for (Object s : redisTemplate.keys(key)) {
|
||||||
|
|
|
@ -40,6 +40,7 @@ public class QuartzJobServiceImpl implements QuartzJobService {
|
||||||
return PageUtil.toPage(quartzJobRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable));
|
return PageUtil.toPage(quartzJobRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Object queryAllLog(JobQueryCriteria criteria, Pageable pageable){
|
public Object queryAllLog(JobQueryCriteria criteria, Pageable pageable){
|
||||||
return PageUtil.toPage(quartzLogRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable));
|
return PageUtil.toPage(quartzLogRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable));
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,7 @@ import javax.validation.constraints.NotBlank;
|
||||||
import javax.validation.constraints.NotNull;
|
import javax.validation.constraints.NotNull;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.sql.Timestamp;
|
import java.sql.Timestamp;
|
||||||
|
import java.util.Objects;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -61,4 +62,17 @@ public class Menu implements Serializable {
|
||||||
private Timestamp createTime;
|
private Timestamp createTime;
|
||||||
|
|
||||||
public interface Update{}
|
public interface Update{}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if (this == o) return true;
|
||||||
|
if (o == null || getClass() != o.getClass()) return false;
|
||||||
|
Menu menu = (Menu) o;
|
||||||
|
return Objects.equals(id, menu.id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return Objects.hash(id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,6 +15,11 @@ import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Zheng Jie
|
* @author Zheng Jie
|
||||||
* @date 2019-04-10
|
* @date 2019-04-10
|
||||||
|
@ -32,9 +37,23 @@ public class DictDetailController {
|
||||||
@GetMapping(value = "/dictDetail")
|
@GetMapping(value = "/dictDetail")
|
||||||
public ResponseEntity getDictDetails(DictDetailQueryCriteria criteria,
|
public ResponseEntity getDictDetails(DictDetailQueryCriteria criteria,
|
||||||
@PageableDefault(value = 10, sort = {"sort"}, direction = Sort.Direction.ASC) Pageable pageable){
|
@PageableDefault(value = 10, sort = {"sort"}, direction = Sort.Direction.ASC) Pageable pageable){
|
||||||
|
String[] names = criteria.getDictName().split(",");
|
||||||
return new ResponseEntity(dictDetailService.queryAll(criteria,pageable),HttpStatus.OK);
|
return new ResponseEntity(dictDetailService.queryAll(criteria,pageable),HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Log("查询多个字典详情")
|
||||||
|
@GetMapping(value = "/dictDetail/map")
|
||||||
|
public ResponseEntity getDictDetailMaps(DictDetailQueryCriteria criteria,
|
||||||
|
@PageableDefault(value = 10, sort = {"sort"}, direction = Sort.Direction.ASC) Pageable pageable){
|
||||||
|
String[] names = criteria.getDictName().split(",");
|
||||||
|
Map map = new HashMap(names.length);
|
||||||
|
for (String name : names) {
|
||||||
|
criteria.setDictName(name);
|
||||||
|
map.put(name,dictDetailService.queryAll(criteria,pageable).get("content"));
|
||||||
|
}
|
||||||
|
return new ResponseEntity(map,HttpStatus.OK);
|
||||||
|
}
|
||||||
|
|
||||||
@Log("新增字典详情")
|
@Log("新增字典详情")
|
||||||
@PostMapping(value = "/dictDetail")
|
@PostMapping(value = "/dictDetail")
|
||||||
@PreAuthorize("hasAnyRole('ADMIN','DICT_ALL','DICT_CREATE')")
|
@PreAuthorize("hasAnyRole('ADMIN','DICT_ALL','DICT_CREATE')")
|
||||||
|
|
|
@ -121,22 +121,6 @@ public class UserController {
|
||||||
return new ResponseEntity(HttpStatus.OK);
|
return new ResponseEntity(HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 验证密码
|
|
||||||
* @param user
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@PostMapping(value = "/users/validPass")
|
|
||||||
public ResponseEntity validPass(@RequestBody User user){
|
|
||||||
UserDetails userDetails = SecurityUtils.getUserDetails();
|
|
||||||
Map map = new HashMap();
|
|
||||||
map.put("status",200);
|
|
||||||
if(!userDetails.getPassword().equals(EncryptUtils.encryptPassword(user.getPassword()))){
|
|
||||||
map.put("status",400);
|
|
||||||
}
|
|
||||||
return new ResponseEntity(map,HttpStatus.OK);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改密码
|
* 修改密码
|
||||||
* @param user
|
* @param user
|
||||||
|
@ -145,6 +129,9 @@ public class UserController {
|
||||||
@PostMapping(value = "/users/updatePass")
|
@PostMapping(value = "/users/updatePass")
|
||||||
public ResponseEntity updatePass(@RequestBody User user){
|
public ResponseEntity updatePass(@RequestBody User user){
|
||||||
UserDetails userDetails = SecurityUtils.getUserDetails();
|
UserDetails userDetails = SecurityUtils.getUserDetails();
|
||||||
|
if(!userDetails.getPassword().equals(EncryptUtils.encryptPassword(user.getPassword()))){
|
||||||
|
throw new BadRequestException("修改失败,旧密码错误");
|
||||||
|
}
|
||||||
if(userDetails.getPassword().equals(EncryptUtils.encryptPassword(user.getPassword()))){
|
if(userDetails.getPassword().equals(EncryptUtils.encryptPassword(user.getPassword()))){
|
||||||
throw new BadRequestException("新密码不能与旧密码相同");
|
throw new BadRequestException("新密码不能与旧密码相同");
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,8 @@ import org.springframework.cache.annotation.CacheEvict;
|
||||||
import org.springframework.cache.annotation.Cacheable;
|
import org.springframework.cache.annotation.Cacheable;
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Zheng Jie
|
* @author Zheng Jie
|
||||||
* @date 2019-04-10
|
* @date 2019-04-10
|
||||||
|
@ -46,5 +48,5 @@ public interface DictDetailService {
|
||||||
void delete(Long id);
|
void delete(Long id);
|
||||||
|
|
||||||
@Cacheable(keyGenerator = "keyGenerator")
|
@Cacheable(keyGenerator = "keyGenerator")
|
||||||
Object queryAll(DictDetailQueryCriteria criteria, Pageable pageable);
|
Map queryAll(DictDetailQueryCriteria criteria, Pageable pageable);
|
||||||
}
|
}
|
|
@ -26,9 +26,4 @@ public class DictDetailDTO implements Serializable {
|
||||||
* 排序
|
* 排序
|
||||||
*/
|
*/
|
||||||
private String sort;
|
private String sort;
|
||||||
|
|
||||||
/**
|
|
||||||
* 字典id
|
|
||||||
*/
|
|
||||||
private String dictName;
|
|
||||||
}
|
}
|
|
@ -15,6 +15,8 @@ import org.springframework.data.domain.Pageable;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Propagation;
|
import org.springframework.transaction.annotation.Propagation;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -32,7 +34,7 @@ public class DictDetailServiceImpl implements DictDetailService {
|
||||||
private DictDetailMapper dictDetailMapper;
|
private DictDetailMapper dictDetailMapper;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object queryAll(DictDetailQueryCriteria criteria, Pageable pageable) {
|
public Map queryAll(DictDetailQueryCriteria criteria, Pageable pageable) {
|
||||||
Page<DictDetail> page = dictDetailRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable);
|
Page<DictDetail> page = dictDetailRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable);
|
||||||
return PageUtil.toPage(page.map(dictDetailMapper::toDto));
|
return PageUtil.toPage(page.map(dictDetailMapper::toDto));
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,12 +11,13 @@ import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
import io.swagger.annotations.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author ${author}
|
* @author ${author}
|
||||||
* @date ${date}
|
* @date ${date}
|
||||||
*/
|
*/
|
||||||
|
@Api(tags = "${className}管理")
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("api")
|
@RequestMapping("api")
|
||||||
public class ${className}Controller {
|
public class ${className}Controller {
|
||||||
|
@ -25,6 +26,7 @@ public class ${className}Controller {
|
||||||
private ${className}Service ${changeClassName}Service;
|
private ${className}Service ${changeClassName}Service;
|
||||||
|
|
||||||
@Log("查询${className}")
|
@Log("查询${className}")
|
||||||
|
@ApiOperation(value = "查询${className}")
|
||||||
@GetMapping(value = "/${changeClassName}")
|
@GetMapping(value = "/${changeClassName}")
|
||||||
@PreAuthorize("hasAnyRole('ADMIN','${upperCaseClassName}_ALL','${upperCaseClassName}_SELECT')")
|
@PreAuthorize("hasAnyRole('ADMIN','${upperCaseClassName}_ALL','${upperCaseClassName}_SELECT')")
|
||||||
public ResponseEntity get${className}s(${className}QueryCriteria criteria, Pageable pageable){
|
public ResponseEntity get${className}s(${className}QueryCriteria criteria, Pageable pageable){
|
||||||
|
@ -32,6 +34,7 @@ public class ${className}Controller {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Log("新增${className}")
|
@Log("新增${className}")
|
||||||
|
@ApiOperation(value = "新增${className}")
|
||||||
@PostMapping(value = "/${changeClassName}")
|
@PostMapping(value = "/${changeClassName}")
|
||||||
@PreAuthorize("hasAnyRole('ADMIN','${upperCaseClassName}_ALL','${upperCaseClassName}_CREATE')")
|
@PreAuthorize("hasAnyRole('ADMIN','${upperCaseClassName}_ALL','${upperCaseClassName}_CREATE')")
|
||||||
public ResponseEntity create(@Validated @RequestBody ${className} resources){
|
public ResponseEntity create(@Validated @RequestBody ${className} resources){
|
||||||
|
@ -39,6 +42,7 @@ public class ${className}Controller {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Log("修改${className}")
|
@Log("修改${className}")
|
||||||
|
@ApiOperation(value = "修改${className}")
|
||||||
@PutMapping(value = "/${changeClassName}")
|
@PutMapping(value = "/${changeClassName}")
|
||||||
@PreAuthorize("hasAnyRole('ADMIN','${upperCaseClassName}_ALL','${upperCaseClassName}_EDIT')")
|
@PreAuthorize("hasAnyRole('ADMIN','${upperCaseClassName}_ALL','${upperCaseClassName}_EDIT')")
|
||||||
public ResponseEntity update(@Validated @RequestBody ${className} resources){
|
public ResponseEntity update(@Validated @RequestBody ${className} resources){
|
||||||
|
@ -47,6 +51,7 @@ public class ${className}Controller {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Log("删除${className}")
|
@Log("删除${className}")
|
||||||
|
@ApiOperation(value = "删除${className}")
|
||||||
@DeleteMapping(value = "/${changeClassName}/{${pkChangeColName}}")
|
@DeleteMapping(value = "/${changeClassName}/{${pkChangeColName}}")
|
||||||
@PreAuthorize("hasAnyRole('ADMIN','${upperCaseClassName}_ALL','${upperCaseClassName}_DELETE')")
|
@PreAuthorize("hasAnyRole('ADMIN','${upperCaseClassName}_ALL','${upperCaseClassName}_DELETE')")
|
||||||
public ResponseEntity delete(@PathVariable ${pkColumnType} ${pkChangeColName}){
|
public ResponseEntity delete(@PathVariable ${pkColumnType} ${pkChangeColName}){
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
package ${package}.domain;
|
package ${package}.domain;
|
||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
|
import cn.hutool.core.bean.copier.CopyOptions;
|
||||||
import javax.persistence.*;
|
import javax.persistence.*;
|
||||||
<#if hasTimestamp>
|
<#if hasTimestamp>
|
||||||
import java.sql.Timestamp;
|
import java.sql.Timestamp;
|
||||||
|
@ -34,4 +36,8 @@ public class ${className} implements Serializable {
|
||||||
private ${column.columnType} ${column.changeColumnName};
|
private ${column.columnType} ${column.changeColumnName};
|
||||||
</#list>
|
</#list>
|
||||||
</#if>
|
</#if>
|
||||||
|
|
||||||
|
public void copy(${className} source){
|
||||||
|
BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -3,16 +3,16 @@ package ${package}.service;
|
||||||
import ${package}.domain.${className};
|
import ${package}.domain.${className};
|
||||||
import ${package}.service.dto.${className}DTO;
|
import ${package}.service.dto.${className}DTO;
|
||||||
import ${package}.service.dto.${className}QueryCriteria;
|
import ${package}.service.dto.${className}QueryCriteria;
|
||||||
import org.springframework.cache.annotation.CacheConfig;
|
//import org.springframework.cache.annotation.CacheConfig;
|
||||||
import org.springframework.cache.annotation.CacheEvict;
|
//import org.springframework.cache.annotation.CacheEvict;
|
||||||
import org.springframework.cache.annotation.Cacheable;
|
//import org.springframework.cache.annotation.Cacheable;
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author ${author}
|
* @author ${author}
|
||||||
* @date ${date}
|
* @date ${date}
|
||||||
*/
|
*/
|
||||||
@CacheConfig(cacheNames = "${changeClassName}")
|
//@CacheConfig(cacheNames = "${changeClassName}")
|
||||||
public interface ${className}Service {
|
public interface ${className}Service {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -21,7 +21,7 @@ public interface ${className}Service {
|
||||||
* @param pageable
|
* @param pageable
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@Cacheable(keyGenerator = "keyGenerator")
|
//@Cacheable(keyGenerator = "keyGenerator")
|
||||||
Object queryAll(${className}QueryCriteria criteria, Pageable pageable);
|
Object queryAll(${className}QueryCriteria criteria, Pageable pageable);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -29,7 +29,7 @@ public interface ${className}Service {
|
||||||
* @param criteria
|
* @param criteria
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@Cacheable(keyGenerator = "keyGenerator")
|
//@Cacheable(keyGenerator = "keyGenerator")
|
||||||
public Object queryAll(${className}QueryCriteria criteria);
|
public Object queryAll(${className}QueryCriteria criteria);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -37,7 +37,7 @@ public interface ${className}Service {
|
||||||
* @param ${pkChangeColName}
|
* @param ${pkChangeColName}
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@Cacheable(key = "#p0")
|
//@Cacheable(key = "#p0")
|
||||||
${className}DTO findById(${pkColumnType} ${pkChangeColName});
|
${className}DTO findById(${pkColumnType} ${pkChangeColName});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -45,20 +45,20 @@ public interface ${className}Service {
|
||||||
* @param resources
|
* @param resources
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@CacheEvict(allEntries = true)
|
//@CacheEvict(allEntries = true)
|
||||||
${className}DTO create(${className} resources);
|
${className}DTO create(${className} resources);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* update
|
* update
|
||||||
* @param resources
|
* @param resources
|
||||||
*/
|
*/
|
||||||
@CacheEvict(allEntries = true)
|
//@CacheEvict(allEntries = true)
|
||||||
void update(${className} resources);
|
void update(${className} resources);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* delete
|
* delete
|
||||||
* @param ${pkChangeColName}
|
* @param ${pkChangeColName}
|
||||||
*/
|
*/
|
||||||
@CacheEvict(allEntries = true)
|
//@CacheEvict(allEntries = true)
|
||||||
void delete(${pkColumnType} ${pkChangeColName});
|
void delete(${pkColumnType} ${pkChangeColName});
|
||||||
}
|
}
|
|
@ -92,7 +92,6 @@ public class ${className}ServiceImpl implements ${className}Service {
|
||||||
public void update(${className} resources) {
|
public void update(${className} resources) {
|
||||||
Optional<${className}> optional${className} = ${changeClassName}Repository.findById(resources.get${pkCapitalColName}());
|
Optional<${className}> optional${className} = ${changeClassName}Repository.findById(resources.get${pkCapitalColName}());
|
||||||
ValidationUtil.isNull( optional${className},"${className}","id",resources.get${pkCapitalColName}());
|
ValidationUtil.isNull( optional${className},"${className}","id",resources.get${pkCapitalColName}());
|
||||||
|
|
||||||
${className} ${changeClassName} = optional${className}.get();
|
${className} ${changeClassName} = optional${className}.get();
|
||||||
<#if columns??>
|
<#if columns??>
|
||||||
<#list columns as column>
|
<#list columns as column>
|
||||||
|
@ -107,9 +106,8 @@ public class ${className}ServiceImpl implements ${className}Service {
|
||||||
</#if>
|
</#if>
|
||||||
</#list>
|
</#list>
|
||||||
</#if>
|
</#if>
|
||||||
// 此处需自己修改
|
${changeClassName}.copy(resources);
|
||||||
resources.set${pkCapitalColName}(${changeClassName}.get${pkCapitalColName}());
|
${changeClassName}Repository.save(${changeClassName});
|
||||||
${changeClassName}Repository.save(resources);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -25,10 +25,6 @@ export default {
|
||||||
isAdd: {
|
isAdd: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
required: true
|
required: true
|
||||||
},
|
|
||||||
sup_this: {
|
|
||||||
type: Object,
|
|
||||||
default: null
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
|
@ -71,7 +67,7 @@ export default {
|
||||||
duration: 2500
|
duration: 2500
|
||||||
})
|
})
|
||||||
this.loading = false
|
this.loading = false
|
||||||
this.$parent.$parent.init()
|
this.$parent.init()
|
||||||
}).catch(err => {
|
}).catch(err => {
|
||||||
this.loading = false
|
this.loading = false
|
||||||
console.log(err.response.data.message)
|
console.log(err.response.data.message)
|
||||||
|
@ -86,7 +82,7 @@ export default {
|
||||||
duration: 2500
|
duration: 2500
|
||||||
})
|
})
|
||||||
this.loading = false
|
this.loading = false
|
||||||
this.sup_this.init()
|
this.$parent.init()
|
||||||
}).catch(err => {
|
}).catch(err => {
|
||||||
this.loading = false
|
this.loading = false
|
||||||
console.log(err.response.data.message)
|
console.log(err.response.data.message)
|
||||||
|
|
|
@ -1,42 +0,0 @@
|
||||||
<template>
|
|
||||||
<div>
|
|
||||||
<el-button size="mini" type="primary" icon="el-icon-edit" @click="to"/>
|
|
||||||
<eForm ref="form" :sup_this="sup_this" :is-add="false"/>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
<script>
|
|
||||||
import eForm from './form'
|
|
||||||
export default {
|
|
||||||
components: { eForm },
|
|
||||||
props: {
|
|
||||||
data: {
|
|
||||||
type: Object,
|
|
||||||
required: true
|
|
||||||
},
|
|
||||||
sup_this: {
|
|
||||||
type: Object,
|
|
||||||
required: true
|
|
||||||
}
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
to() {
|
|
||||||
const _this = this.$refs.form
|
|
||||||
_this.form = {
|
|
||||||
<#if columns??>
|
|
||||||
<#list columns as column>
|
|
||||||
${column.changeColumnName}: this.data.${column.changeColumnName}<#if column_has_next>,</#if>
|
|
||||||
</#list>
|
|
||||||
</#if>
|
|
||||||
}
|
|
||||||
_this.dialog = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style scoped>
|
|
||||||
div{
|
|
||||||
display: inline-block;
|
|
||||||
margin-right: 3px;
|
|
||||||
}
|
|
||||||
</style>
|
|
|
@ -1,56 +0,0 @@
|
||||||
<template>
|
|
||||||
<div class="head-container">
|
|
||||||
<#if hasQuery>
|
|
||||||
<!-- 搜索 -->
|
|
||||||
<el-input v-model="query.value" clearable placeholder="输入搜索内容" style="width: 200px;" class="filter-item" @keyup.enter.native="toQuery"/>
|
|
||||||
<el-select v-model="query.type" clearable placeholder="类型" class="filter-item" style="width: 130px">
|
|
||||||
<el-option v-for="item in queryTypeOptions" :key="item.key" :label="item.display_name" :value="item.key"/>
|
|
||||||
</el-select>
|
|
||||||
<el-button class="filter-item" size="mini" type="success" icon="el-icon-search" @click="toQuery">搜索</el-button>
|
|
||||||
</#if>
|
|
||||||
<!-- 新增 -->
|
|
||||||
<div style="display: inline-block;margin: 0px 2px;">
|
|
||||||
<el-button
|
|
||||||
v-permission="['ADMIN','${upperCaseClassName}_ALL','${upperCaseClassName}_CREATE']"
|
|
||||||
class="filter-item"
|
|
||||||
size="mini"
|
|
||||||
type="primary"
|
|
||||||
icon="el-icon-plus"
|
|
||||||
@click="$refs.form.dialog = true">新增</el-button>
|
|
||||||
<eForm ref="form" :is-add="true"/>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
import eForm from './form'
|
|
||||||
export default {
|
|
||||||
components: { eForm },
|
|
||||||
props: {
|
|
||||||
query: {
|
|
||||||
type: Object,
|
|
||||||
required: true
|
|
||||||
}
|
|
||||||
},
|
|
||||||
data() {
|
|
||||||
return {
|
|
||||||
<#if hasQuery>
|
|
||||||
queryTypeOptions: [
|
|
||||||
<#if queryColumns??>
|
|
||||||
<#list queryColumns as column>
|
|
||||||
{ key: '${column.changeColumnName}', display_name: '<#if column.columnComment != ''>${column.columnComment}<#else>${column.changeColumnName}</#if>' }<#if column_has_next>,</#if>
|
|
||||||
</#list>
|
|
||||||
</#if>
|
|
||||||
]
|
|
||||||
</#if>
|
|
||||||
}
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
<#if hasQuery>
|
|
||||||
toQuery() {
|
|
||||||
this.$parent.page = 0
|
|
||||||
this.$parent.init()
|
|
||||||
}</#if>
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
|
|
@ -1,7 +1,29 @@
|
||||||
<#--noinspection ALL-->
|
<#--noinspection ALL-->
|
||||||
<template>
|
<template>
|
||||||
<div class="app-container">
|
<div class="app-container">
|
||||||
<eHeader :query="query"/>
|
<!--工具栏-->
|
||||||
|
<div class="head-container">
|
||||||
|
<#if hasQuery>
|
||||||
|
<!-- 搜索 -->
|
||||||
|
<el-input v-model="query.value" clearable placeholder="输入搜索内容" style="width: 200px;" class="filter-item" @keyup.enter.native="toQuery"/>
|
||||||
|
<el-select v-model="query.type" clearable placeholder="类型" class="filter-item" style="width: 130px">
|
||||||
|
<el-option v-for="item in queryTypeOptions" :key="item.key" :label="item.display_name" :value="item.key"/>
|
||||||
|
</el-select>
|
||||||
|
<el-button class="filter-item" size="mini" type="success" icon="el-icon-search" @click="toQuery">搜索</el-button>
|
||||||
|
</#if>
|
||||||
|
<!-- 新增 -->
|
||||||
|
<div style="display: inline-block;margin: 0px 2px;">
|
||||||
|
<el-button
|
||||||
|
v-permission="['ADMIN','${upperCaseClassName}_ALL','${upperCaseClassName}_CREATE']"
|
||||||
|
class="filter-item"
|
||||||
|
size="mini"
|
||||||
|
type="primary"
|
||||||
|
icon="el-icon-plus"
|
||||||
|
@click="add">新增</el-button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<!--表单组件-->
|
||||||
|
<eForm ref="form" :is-add="isAdd"/>
|
||||||
<!--表格渲染-->
|
<!--表格渲染-->
|
||||||
<el-table v-loading="loading" :data="data" size="small" style="width: 100%;">
|
<el-table v-loading="loading" :data="data" size="small" style="width: 100%;">
|
||||||
<#if columns??>
|
<#if columns??>
|
||||||
|
@ -21,7 +43,7 @@
|
||||||
</#if>
|
</#if>
|
||||||
<el-table-column v-if="checkPermission(['ADMIN','${upperCaseClassName}_ALL','${upperCaseClassName}_EDIT','${upperCaseClassName}_DELETE'])" label="操作" width="150px" align="center">
|
<el-table-column v-if="checkPermission(['ADMIN','${upperCaseClassName}_ALL','${upperCaseClassName}_EDIT','${upperCaseClassName}_DELETE'])" label="操作" width="150px" align="center">
|
||||||
<template slot-scope="scope">
|
<template slot-scope="scope">
|
||||||
<edit v-permission="['ADMIN','${upperCaseClassName}_ALL','${upperCaseClassName}_EDIT']" :data="scope.row" :sup_this="sup_this"/>
|
<el-button v-permission="['ADMIN','${upperCaseClassName}_ALL','${upperCaseClassName}_EDIT']" size="mini" type="primary" icon="el-icon-edit" @click="edit(scope.row)"/>
|
||||||
<el-popover
|
<el-popover
|
||||||
v-permission="['ADMIN','${upperCaseClassName}_ALL','${upperCaseClassName}_DELETE']"
|
v-permission="['ADMIN','${upperCaseClassName}_ALL','${upperCaseClassName}_DELETE']"
|
||||||
:ref="scope.row.${pkChangeColName}"
|
:ref="scope.row.${pkChangeColName}"
|
||||||
|
@ -41,6 +63,7 @@
|
||||||
<el-pagination
|
<el-pagination
|
||||||
:total="total"
|
:total="total"
|
||||||
style="margin-top: 8px;"
|
style="margin-top: 8px;"
|
||||||
|
:current-page="page + 1"
|
||||||
layout="total, prev, pager, next, sizes"
|
layout="total, prev, pager, next, sizes"
|
||||||
@size-change="sizeChange"
|
@size-change="sizeChange"
|
||||||
@current-change="pageChange"/>
|
@current-change="pageChange"/>
|
||||||
|
@ -54,14 +77,22 @@ import { del } from '@/api/${changeClassName}'
|
||||||
<#if hasTimestamp>
|
<#if hasTimestamp>
|
||||||
import { parseTime } from '@/utils/index'
|
import { parseTime } from '@/utils/index'
|
||||||
</#if>
|
</#if>
|
||||||
import eHeader from './module/header'
|
import eForm from './form'
|
||||||
import edit from './module/edit'
|
|
||||||
export default {
|
export default {
|
||||||
components: { eHeader, edit },
|
components: { eForm },
|
||||||
mixins: [initData],
|
mixins: [initData],
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
delLoading: false, sup_this: this
|
delLoading: false,
|
||||||
|
<#if hasQuery>
|
||||||
|
queryTypeOptions: [
|
||||||
|
<#if queryColumns??>
|
||||||
|
<#list queryColumns as column>
|
||||||
|
{ key: '${column.changeColumnName}', display_name: '<#if column.columnComment != ''>${column.columnComment}<#else>${column.changeColumnName}</#if>' }<#if column_has_next>,</#if>
|
||||||
|
</#list>
|
||||||
|
</#if>
|
||||||
|
]
|
||||||
|
</#if>
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
|
@ -91,6 +122,7 @@ export default {
|
||||||
del(${pkChangeColName}).then(res => {
|
del(${pkChangeColName}).then(res => {
|
||||||
this.delLoading = false
|
this.delLoading = false
|
||||||
this.$refs[${pkChangeColName}].doClose()
|
this.$refs[${pkChangeColName}].doClose()
|
||||||
|
this.dleChangePage()
|
||||||
this.init()
|
this.init()
|
||||||
this.$notify({
|
this.$notify({
|
||||||
title: '删除成功',
|
title: '删除成功',
|
||||||
|
@ -102,6 +134,22 @@ export default {
|
||||||
this.$refs[${pkChangeColName}].doClose()
|
this.$refs[${pkChangeColName}].doClose()
|
||||||
console.log(err.response.data.message)
|
console.log(err.response.data.message)
|
||||||
})
|
})
|
||||||
|
},
|
||||||
|
add() {
|
||||||
|
this.isAdd = true
|
||||||
|
this.$refs.form.dialog = true
|
||||||
|
},
|
||||||
|
edit(data) {
|
||||||
|
this.isAdd = false
|
||||||
|
const _this = this.$refs.form
|
||||||
|
_this.form = {
|
||||||
|
<#if columns??>
|
||||||
|
<#list columns as column>
|
||||||
|
${column.changeColumnName}: data.${column.changeColumnName}<#if column_has_next>,</#if>
|
||||||
|
</#list>
|
||||||
|
</#if>
|
||||||
|
}
|
||||||
|
_this.dialog = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,8 +34,8 @@ public class AliPayController {
|
||||||
private AlipayService alipayService;
|
private AlipayService alipayService;
|
||||||
|
|
||||||
@GetMapping(value = "/aliPay")
|
@GetMapping(value = "/aliPay")
|
||||||
public ResponseEntity get(){
|
public ResponseEntity<AlipayConfig> get(){
|
||||||
return new ResponseEntity(alipayService.find(),HttpStatus.OK);
|
return new ResponseEntity<>(alipayService.find(),HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Log("配置支付宝")
|
@Log("配置支付宝")
|
||||||
|
@ -49,8 +49,7 @@ public class AliPayController {
|
||||||
@Log("支付宝PC网页支付")
|
@Log("支付宝PC网页支付")
|
||||||
@ApiOperation(value = "PC网页支付")
|
@ApiOperation(value = "PC网页支付")
|
||||||
@PostMapping(value = "/aliPay/toPayAsPC")
|
@PostMapping(value = "/aliPay/toPayAsPC")
|
||||||
public ResponseEntity toPayAsPC(@Validated@RequestBody TradeVo trade) throws Exception{
|
public ResponseEntity<String> toPayAsPC(@Validated@RequestBody TradeVo trade) throws Exception{
|
||||||
log.warn("REST request to toPayAsPC Trade : {}" +trade);
|
|
||||||
AlipayConfig alipay = alipayService.find();
|
AlipayConfig alipay = alipayService.find();
|
||||||
trade.setOutTradeNo(alipayUtils.getOrderCode());
|
trade.setOutTradeNo(alipayUtils.getOrderCode());
|
||||||
String payUrl = alipayService.toPayAsPC(alipay,trade);
|
String payUrl = alipayService.toPayAsPC(alipay,trade);
|
||||||
|
@ -60,8 +59,7 @@ public class AliPayController {
|
||||||
@Log("支付宝手机网页支付")
|
@Log("支付宝手机网页支付")
|
||||||
@ApiOperation(value = "手机网页支付")
|
@ApiOperation(value = "手机网页支付")
|
||||||
@PostMapping(value = "/aliPay/toPayAsWeb")
|
@PostMapping(value = "/aliPay/toPayAsWeb")
|
||||||
public ResponseEntity toPayAsWeb(@Validated @RequestBody TradeVo trade) throws Exception{
|
public ResponseEntity<String> toPayAsWeb(@Validated @RequestBody TradeVo trade) throws Exception{
|
||||||
log.warn("REST request to toPayAsWeb Trade : {}" +trade);
|
|
||||||
AlipayConfig alipay = alipayService.find();
|
AlipayConfig alipay = alipayService.find();
|
||||||
trade.setOutTradeNo(alipayUtils.getOrderCode());
|
trade.setOutTradeNo(alipayUtils.getOrderCode());
|
||||||
String payUrl = alipayService.toPayAsWeb(alipay,trade);
|
String payUrl = alipayService.toPayAsWeb(alipay,trade);
|
||||||
|
@ -71,7 +69,7 @@ public class AliPayController {
|
||||||
@ApiIgnore
|
@ApiIgnore
|
||||||
@GetMapping("/aliPay/return")
|
@GetMapping("/aliPay/return")
|
||||||
@ApiOperation(value = "支付之后跳转的链接")
|
@ApiOperation(value = "支付之后跳转的链接")
|
||||||
public ResponseEntity returnPage(HttpServletRequest request, HttpServletResponse response) throws Exception {
|
public ResponseEntity<String> returnPage(HttpServletRequest request, HttpServletResponse response) throws Exception {
|
||||||
AlipayConfig alipay = alipayService.find();
|
AlipayConfig alipay = alipayService.find();
|
||||||
response.setContentType("text/html;charset=" + alipay.getCharset());
|
response.setContentType("text/html;charset=" + alipay.getCharset());
|
||||||
//内容验签,防止黑客篡改参数
|
//内容验签,防止黑客篡改参数
|
||||||
|
@ -85,12 +83,12 @@ public class AliPayController {
|
||||||
/**
|
/**
|
||||||
* 根据业务需要返回数据,这里统一返回OK
|
* 根据业务需要返回数据,这里统一返回OK
|
||||||
*/
|
*/
|
||||||
return new ResponseEntity("payment successful",HttpStatus.OK);
|
return new ResponseEntity<>("payment successful",HttpStatus.OK);
|
||||||
}else{
|
}else{
|
||||||
/**
|
/**
|
||||||
* 根据业务需要返回数据
|
* 根据业务需要返回数据
|
||||||
*/
|
*/
|
||||||
return new ResponseEntity(HttpStatus.BAD_REQUEST);
|
return new ResponseEntity<>(HttpStatus.BAD_REQUEST);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -45,7 +45,7 @@ public class PictureController {
|
||||||
public ResponseEntity upload(@RequestParam MultipartFile file){
|
public ResponseEntity upload(@RequestParam MultipartFile file){
|
||||||
String userName = SecurityUtils.getUsername();
|
String userName = SecurityUtils.getUsername();
|
||||||
Picture picture = pictureService.upload(file,userName);
|
Picture picture = pictureService.upload(file,userName);
|
||||||
Map map = new HashMap();
|
Map map = new HashMap(3);
|
||||||
map.put("errno",0);
|
map.put("errno",0);
|
||||||
map.put("id",picture.getId());
|
map.put("id",picture.getId());
|
||||||
map.put("data",new String[]{picture.getUrl()});
|
map.put("data",new String[]{picture.getUrl()});
|
||||||
|
|
|
@ -56,7 +56,7 @@ public class QiniuController {
|
||||||
@PostMapping(value = "/qiNiuContent")
|
@PostMapping(value = "/qiNiuContent")
|
||||||
public ResponseEntity upload(@RequestParam MultipartFile file){
|
public ResponseEntity upload(@RequestParam MultipartFile file){
|
||||||
QiniuContent qiniuContent = qiNiuService.upload(file,qiNiuService.find());
|
QiniuContent qiniuContent = qiNiuService.upload(file,qiNiuService.find());
|
||||||
Map map = new HashMap();
|
Map map = new HashMap(3);
|
||||||
map.put("id",qiniuContent.getId());
|
map.put("id",qiniuContent.getId());
|
||||||
map.put("errno",0);
|
map.put("errno",0);
|
||||||
map.put("data",new String[]{qiniuContent.getUrl()});
|
map.put("data",new String[]{qiniuContent.getUrl()});
|
||||||
|
@ -84,7 +84,7 @@ public class QiniuController {
|
||||||
@Log("下载文件")
|
@Log("下载文件")
|
||||||
@GetMapping(value = "/qiNiuContent/download/{id}")
|
@GetMapping(value = "/qiNiuContent/download/{id}")
|
||||||
public ResponseEntity download(@PathVariable Long id){
|
public ResponseEntity download(@PathVariable Long id){
|
||||||
Map map = new HashMap();
|
Map map = new HashMap(1);
|
||||||
map.put("url", qiNiuService.download(qiNiuService.findByContentId(id),qiNiuService.find()));
|
map.put("url", qiNiuService.download(qiNiuService.findByContentId(id),qiNiuService.find()));
|
||||||
return new ResponseEntity(map,HttpStatus.OK);
|
return new ResponseEntity(map,HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,6 +45,7 @@ public interface QiNiuService {
|
||||||
* 上传文件
|
* 上传文件
|
||||||
* @param file
|
* @param file
|
||||||
* @param qiniuConfig
|
* @param qiniuConfig
|
||||||
|
* @return
|
||||||
*/
|
*/
|
||||||
@CacheEvict(allEntries = true)
|
@CacheEvict(allEntries = true)
|
||||||
QiniuContent upload(MultipartFile file, QiniuConfig qiniuConfig);
|
QiniuContent upload(MultipartFile file, QiniuConfig qiniuConfig);
|
||||||
|
@ -84,7 +85,7 @@ public interface QiNiuService {
|
||||||
/**
|
/**
|
||||||
* 删除文件
|
* 删除文件
|
||||||
* @param ids
|
* @param ids
|
||||||
* @return
|
* @param config
|
||||||
*/
|
*/
|
||||||
@CacheEvict(allEntries = true)
|
@CacheEvict(allEntries = true)
|
||||||
void deleteAll(Long[] ids, QiniuConfig config);
|
void deleteAll(Long[] ids, QiniuConfig config);
|
||||||
|
|
|
@ -83,7 +83,8 @@ public class EmailServiceImpl implements EmailService {
|
||||||
.setTitle(emailVo.getSubject())
|
.setTitle(emailVo.getSubject())
|
||||||
.setContent(content)
|
.setContent(content)
|
||||||
.setHtml(true)
|
.setHtml(true)
|
||||||
.setUseGlobalSession(false)//关闭session
|
//关闭session
|
||||||
|
.setUseGlobalSession(false)
|
||||||
.send();
|
.send();
|
||||||
}catch (Exception e){
|
}catch (Exception e){
|
||||||
throw new BadRequestException(e.getMessage());
|
throw new BadRequestException(e.getMessage());
|
||||||
|
|
|
@ -49,7 +49,7 @@ public class PictureServiceImpl implements PictureService {
|
||||||
public Picture upload(MultipartFile multipartFile, String username) {
|
public Picture upload(MultipartFile multipartFile, String username) {
|
||||||
File file = FileUtil.toFile(multipartFile);
|
File file = FileUtil.toFile(multipartFile);
|
||||||
|
|
||||||
HashMap<String, Object> paramMap = new HashMap<>();
|
HashMap<String, Object> paramMap = new HashMap<>(1);
|
||||||
|
|
||||||
paramMap.put("smfile", file);
|
paramMap.put("smfile", file);
|
||||||
String result= HttpUtil.post(ElAdminConstant.Url.SM_MS_URL, paramMap);
|
String result= HttpUtil.post(ElAdminConstant.Url.SM_MS_URL, paramMap);
|
||||||
|
|
Loading…
Reference in New Issue