代码生成器优化,新增多数据字典支持,用户修改密码优化

pull/99/head
zhengjie 2019-06-29 22:23:46 +08:00
parent 375cdf4dc3
commit c4fc3da175
32 changed files with 183 additions and 195 deletions

View File

@ -31,6 +31,7 @@ public @interface Query {
Join join() default Join.LEFT;
enum Type {
/** jie 2019/6/4 相等 */
EQUAL
/** Dong ZhaoYang 2017/8/7 大于等于 */
, GREATER_THAN

View File

@ -101,7 +101,9 @@ public class QueryHelp {
private static <T, R> Expression<T> getExpression(String attributeName, Join join, Root<R> root) {
if (ObjectUtil.isNotEmpty(join)) {
return join.get(attributeName);
} else return root.get(attributeName);
} else {
return root.get(attributeName);
}
}
@SuppressWarnings("unchecked")

View File

@ -19,4 +19,15 @@ public class TableInfo {
/** 创建日期 **/
private Object createTime;
// 数据库引擎
private Object engine;
// 编码集
private Object coding;
// 备注
private Object remark;
}

View File

@ -23,6 +23,7 @@ public interface GenConfigService {
/**
* update
* @param genConfig
* @return
*/
@CacheEvict(allEntries = true)
GenConfig update(GenConfig genConfig);

View File

@ -1,5 +1,6 @@
package me.zhengjie.service.impl;
import cn.hutool.core.util.ObjectUtil;
import me.zhengjie.domain.GenConfig;
import me.zhengjie.domain.vo.ColumnInfo;
import me.zhengjie.domain.vo.TableInfo;
@ -7,8 +8,8 @@ import me.zhengjie.exception.BadRequestException;
import me.zhengjie.service.GeneratorService;
import me.zhengjie.utils.GenUtil;
import me.zhengjie.utils.PageUtil;
import me.zhengjie.utils.StringUtils;
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;
@ -28,20 +29,18 @@ public class GeneratorServiceImpl implements GeneratorService {
@Override
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()) ");
if(!ObjectUtils.isEmpty(name)){
sql.append("and table_name like '%"+name+"%' ");
}
sql.append("order by table_name");
Query query = em.createNativeQuery(sql.toString());
// 使用预编译防止sql注入
String sql = "select table_name ,create_time , engine, table_collation, table_comment from information_schema.tables " +
"where table_schema = (select database()) " +
"and table_name like ? order by create_time desc";
Query query = em.createNativeQuery(sql);
query.setFirstResult(startEnd[0]);
query.setMaxResults(startEnd[1]-startEnd[0]);
System.out.println(sql.toString());
query.setParameter(1, StringUtils.isNotBlank(name) ? ("%" + name + "%") : "%%");
List<Object[]> result = query.getResultList();
List<TableInfo> tableInfos = new ArrayList<>();
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())");
Object totalElements = query1.getSingleResult();
@ -50,12 +49,11 @@ public class GeneratorServiceImpl implements GeneratorService {
@Override
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 ");
if(!ObjectUtils.isEmpty(name)){
sql.append("table_name = '"+name+"' ");
}
sql.append("and table_schema = (select database()) order by ordinal_position");
Query query = em.createNativeQuery(sql.toString());
// 使用预编译防止sql注入
String sql = "select column_name, is_nullable, data_type, column_comment, column_key, extra from information_schema.columns " +
"where table_name = ? and table_schema = (select database()) order by ordinal_position";
Query query = em.createNativeQuery(sql);
query.setParameter(1, StringUtils.isNotBlank(name) ? name : null);
List<Object[]> result = query.getResultList();
List<ColumnInfo> columnInfos = new ArrayList<>();
for (Object[] obj : result) {

View File

@ -57,8 +57,6 @@ public class GenUtil {
List<String> templateNames = new ArrayList<>();
templateNames.add("api");
templateNames.add("index");
templateNames.add("header");
templateNames.add("edit");
templateNames.add("eForm");
return templateNames;
}
@ -174,8 +172,8 @@ public class GenUtil {
*
*/
public static String getAdminFilePath(String templateName, GenConfig genConfig, String className) {
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 projectPath = System.getProperty("user.dir") + File.separator + genConfig.getModuleName();
String packagePath = projectPath + File.separator + "src" +File.separator+ "main" + File.separator + "java" + File.separator;
if (!ObjectUtils.isEmpty(genConfig.getPack())) {
packagePath += genConfig.getPack().replace(".", File.separator) + File.separator;
}
@ -229,16 +227,8 @@ public class GenUtil {
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)) {
return path + File.separator + "module" + File.separator + "form.vue";
return path + File.separator + File.separator + "form.vue";
}
return null;
}

View File

@ -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)
Long findIp(String date1, String date2);
/**
* findExceptionById
* @param id
* @return
*/
@Query(value = "select exception_detail FROM log where id = ?1",nativeQuery = true)
String findExceptionById(Long id);
}

View File

@ -30,6 +30,8 @@ public interface LogService {
/**
*
* @param username
* @param ip
* @param joinPoint
* @param log
*/

View File

@ -16,4 +16,7 @@ public class LogQueryCriteria {
@Query
private String logType;
@Query(type = Query.Type.INNER_LIKE)
private String description;
}

View File

@ -42,7 +42,7 @@ public class LogServiceImpl implements LogService {
@Override
public Object queryAll(LogQueryCriteria criteria, Pageable 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 page;

View File

@ -25,7 +25,7 @@ public class RedisServiceImpl implements RedisService {
@Override
public Page<RedisVo> findByKey(String key, Pageable pageable){
List<RedisVo> redisVos = new ArrayList<>();
if(!key.equals("*")){
if(!"*".equals(key)){
key = "*" + key + "*";
}
for (Object s : redisTemplate.keys(key)) {

View File

@ -40,6 +40,7 @@ public class QuartzJobServiceImpl implements QuartzJobService {
return PageUtil.toPage(quartzJobRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable));
}
@Override
public Object queryAllLog(JobQueryCriteria criteria, Pageable pageable){
return PageUtil.toPage(quartzLogRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable));
}

View File

@ -9,6 +9,7 @@ import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.sql.Timestamp;
import java.util.Objects;
import java.util.Set;
/**
@ -61,4 +62,17 @@ public class Menu implements Serializable {
private Timestamp createTime;
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);
}
}

View File

@ -15,6 +15,11 @@ import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
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
* @date 2019-04-10
@ -32,9 +37,23 @@ public class DictDetailController {
@GetMapping(value = "/dictDetail")
public ResponseEntity getDictDetails(DictDetailQueryCriteria criteria,
@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);
}
@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("新增字典详情")
@PostMapping(value = "/dictDetail")
@PreAuthorize("hasAnyRole('ADMIN','DICT_ALL','DICT_CREATE')")

View File

@ -121,22 +121,6 @@ public class UserController {
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
@ -145,6 +129,9 @@ public class UserController {
@PostMapping(value = "/users/updatePass")
public ResponseEntity updatePass(@RequestBody User user){
UserDetails userDetails = SecurityUtils.getUserDetails();
if(!userDetails.getPassword().equals(EncryptUtils.encryptPassword(user.getPassword()))){
throw new BadRequestException("修改失败,旧密码错误");
}
if(userDetails.getPassword().equals(EncryptUtils.encryptPassword(user.getPassword()))){
throw new BadRequestException("新密码不能与旧密码相同");
}

View File

@ -8,6 +8,8 @@ import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.data.domain.Pageable;
import java.util.Map;
/**
* @author Zheng Jie
* @date 2019-04-10
@ -46,5 +48,5 @@ public interface DictDetailService {
void delete(Long id);
@Cacheable(keyGenerator = "keyGenerator")
Object queryAll(DictDetailQueryCriteria criteria, Pageable pageable);
Map queryAll(DictDetailQueryCriteria criteria, Pageable pageable);
}

View File

@ -26,9 +26,4 @@ public class DictDetailDTO implements Serializable {
*
*/
private String sort;
/**
* id
*/
private String dictName;
}

View File

@ -15,6 +15,8 @@ import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import java.util.Map;
import java.util.Optional;
/**
@ -32,7 +34,7 @@ public class DictDetailServiceImpl implements DictDetailService {
private DictDetailMapper dictDetailMapper;
@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);
return PageUtil.toPage(page.map(dictDetailMapper::toDto));
}

View File

@ -11,12 +11,13 @@ import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.*;
/**
* @author ${author}
* @date ${date}
*/
@Api(tags = "${className}管理")
@RestController
@RequestMapping("api")
public class ${className}Controller {
@ -25,6 +26,7 @@ public class ${className}Controller {
private ${className}Service ${changeClassName}Service;
@Log("查询${className}")
@ApiOperation(value = "查询${className}")
@GetMapping(value = "/${changeClassName}")
@PreAuthorize("hasAnyRole('ADMIN','${upperCaseClassName}_ALL','${upperCaseClassName}_SELECT')")
public ResponseEntity get${className}s(${className}QueryCriteria criteria, Pageable pageable){
@ -32,6 +34,7 @@ public class ${className}Controller {
}
@Log("新增${className}")
@ApiOperation(value = "新增${className}")
@PostMapping(value = "/${changeClassName}")
@PreAuthorize("hasAnyRole('ADMIN','${upperCaseClassName}_ALL','${upperCaseClassName}_CREATE')")
public ResponseEntity create(@Validated @RequestBody ${className} resources){
@ -39,6 +42,7 @@ public class ${className}Controller {
}
@Log("修改${className}")
@ApiOperation(value = "修改${className}")
@PutMapping(value = "/${changeClassName}")
@PreAuthorize("hasAnyRole('ADMIN','${upperCaseClassName}_ALL','${upperCaseClassName}_EDIT')")
public ResponseEntity update(@Validated @RequestBody ${className} resources){
@ -47,6 +51,7 @@ public class ${className}Controller {
}
@Log("删除${className}")
@ApiOperation(value = "删除${className}")
@DeleteMapping(value = "/${changeClassName}/{${pkChangeColName}}")
@PreAuthorize("hasAnyRole('ADMIN','${upperCaseClassName}_ALL','${upperCaseClassName}_DELETE')")
public ResponseEntity delete(@PathVariable ${pkColumnType} ${pkChangeColName}){

View File

@ -1,6 +1,8 @@
package ${package}.domain;
import lombok.Data;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import javax.persistence.*;
<#if hasTimestamp>
import java.sql.Timestamp;
@ -34,4 +36,8 @@ public class ${className} implements Serializable {
private ${column.columnType} ${column.changeColumnName};
</#list>
</#if>
public void copy(${className} source){
BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
}
}

View File

@ -3,16 +3,16 @@ package ${package}.service;
import ${package}.domain.${className};
import ${package}.service.dto.${className}DTO;
import ${package}.service.dto.${className}QueryCriteria;
import org.springframework.cache.annotation.CacheConfig;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
//import org.springframework.cache.annotation.CacheConfig;
//import org.springframework.cache.annotation.CacheEvict;
//import org.springframework.cache.annotation.Cacheable;
import org.springframework.data.domain.Pageable;
/**
* @author ${author}
* @date ${date}
*/
@CacheConfig(cacheNames = "${changeClassName}")
//@CacheConfig(cacheNames = "${changeClassName}")
public interface ${className}Service {
/**
@ -21,7 +21,7 @@ public interface ${className}Service {
* @param pageable
* @return
*/
@Cacheable(keyGenerator = "keyGenerator")
//@Cacheable(keyGenerator = "keyGenerator")
Object queryAll(${className}QueryCriteria criteria, Pageable pageable);
/**
@ -29,7 +29,7 @@ public interface ${className}Service {
* @param criteria
* @return
*/
@Cacheable(keyGenerator = "keyGenerator")
//@Cacheable(keyGenerator = "keyGenerator")
public Object queryAll(${className}QueryCriteria criteria);
/**
@ -37,7 +37,7 @@ public interface ${className}Service {
* @param ${pkChangeColName}
* @return
*/
@Cacheable(key = "#p0")
//@Cacheable(key = "#p0")
${className}DTO findById(${pkColumnType} ${pkChangeColName});
/**
@ -45,20 +45,20 @@ public interface ${className}Service {
* @param resources
* @return
*/
@CacheEvict(allEntries = true)
//@CacheEvict(allEntries = true)
${className}DTO create(${className} resources);
/**
* update
* @param resources
*/
@CacheEvict(allEntries = true)
//@CacheEvict(allEntries = true)
void update(${className} resources);
/**
* delete
* @param ${pkChangeColName}
*/
@CacheEvict(allEntries = true)
//@CacheEvict(allEntries = true)
void delete(${pkColumnType} ${pkChangeColName});
}

View File

@ -92,7 +92,6 @@ public class ${className}ServiceImpl implements ${className}Service {
public void update(${className} resources) {
Optional<${className}> optional${className} = ${changeClassName}Repository.findById(resources.get${pkCapitalColName}());
ValidationUtil.isNull( optional${className},"${className}","id",resources.get${pkCapitalColName}());
${className} ${changeClassName} = optional${className}.get();
<#if columns??>
<#list columns as column>
@ -107,9 +106,8 @@ public class ${className}ServiceImpl implements ${className}Service {
</#if>
</#list>
</#if>
// 此处需自己修改
resources.set${pkCapitalColName}(${changeClassName}.get${pkCapitalColName}());
${changeClassName}Repository.save(resources);
${changeClassName}.copy(resources);
${changeClassName}Repository.save(${changeClassName});
}
@Override

View File

@ -25,10 +25,6 @@ export default {
isAdd: {
type: Boolean,
required: true
},
sup_this: {
type: Object,
default: null
}
},
data() {
@ -71,7 +67,7 @@ export default {
duration: 2500
})
this.loading = false
this.$parent.$parent.init()
this.$parent.init()
}).catch(err => {
this.loading = false
console.log(err.response.data.message)
@ -86,7 +82,7 @@ export default {
duration: 2500
})
this.loading = false
this.sup_this.init()
this.$parent.init()
}).catch(err => {
this.loading = false
console.log(err.response.data.message)

View File

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

View File

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

View File

@ -1,7 +1,29 @@
<#--noinspection ALL-->
<template>
<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%;">
<#if columns??>
@ -21,7 +43,7 @@
</#if>
<el-table-column v-if="checkPermission(['ADMIN','${upperCaseClassName}_ALL','${upperCaseClassName}_EDIT','${upperCaseClassName}_DELETE'])" label="操作" width="150px" align="center">
<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
v-permission="['ADMIN','${upperCaseClassName}_ALL','${upperCaseClassName}_DELETE']"
:ref="scope.row.${pkChangeColName}"
@ -41,6 +63,7 @@
<el-pagination
:total="total"
style="margin-top: 8px;"
:current-page="page + 1"
layout="total, prev, pager, next, sizes"
@size-change="sizeChange"
@current-change="pageChange"/>
@ -54,14 +77,22 @@ import { del } from '@/api/${changeClassName}'
<#if hasTimestamp>
import { parseTime } from '@/utils/index'
</#if>
import eHeader from './module/header'
import edit from './module/edit'
import eForm from './form'
export default {
components: { eHeader, edit },
components: { eForm },
mixins: [initData],
data() {
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() {
@ -91,6 +122,7 @@ export default {
del(${pkChangeColName}).then(res => {
this.delLoading = false
this.$refs[${pkChangeColName}].doClose()
this.dleChangePage()
this.init()
this.$notify({
title: '删除成功',
@ -102,6 +134,22 @@ export default {
this.$refs[${pkChangeColName}].doClose()
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
}
}
}

View File

@ -34,8 +34,8 @@ public class AliPayController {
private AlipayService alipayService;
@GetMapping(value = "/aliPay")
public ResponseEntity get(){
return new ResponseEntity(alipayService.find(),HttpStatus.OK);
public ResponseEntity<AlipayConfig> get(){
return new ResponseEntity<>(alipayService.find(),HttpStatus.OK);
}
@Log("配置支付宝")
@ -49,8 +49,7 @@ public class AliPayController {
@Log("支付宝PC网页支付")
@ApiOperation(value = "PC网页支付")
@PostMapping(value = "/aliPay/toPayAsPC")
public ResponseEntity toPayAsPC(@Validated@RequestBody TradeVo trade) throws Exception{
log.warn("REST request to toPayAsPC Trade : {}" +trade);
public ResponseEntity<String> toPayAsPC(@Validated@RequestBody TradeVo trade) throws Exception{
AlipayConfig alipay = alipayService.find();
trade.setOutTradeNo(alipayUtils.getOrderCode());
String payUrl = alipayService.toPayAsPC(alipay,trade);
@ -60,8 +59,7 @@ public class AliPayController {
@Log("支付宝手机网页支付")
@ApiOperation(value = "手机网页支付")
@PostMapping(value = "/aliPay/toPayAsWeb")
public ResponseEntity toPayAsWeb(@Validated @RequestBody TradeVo trade) throws Exception{
log.warn("REST request to toPayAsWeb Trade : {}" +trade);
public ResponseEntity<String> toPayAsWeb(@Validated @RequestBody TradeVo trade) throws Exception{
AlipayConfig alipay = alipayService.find();
trade.setOutTradeNo(alipayUtils.getOrderCode());
String payUrl = alipayService.toPayAsWeb(alipay,trade);
@ -71,7 +69,7 @@ public class AliPayController {
@ApiIgnore
@GetMapping("/aliPay/return")
@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();
response.setContentType("text/html;charset=" + alipay.getCharset());
//内容验签,防止黑客篡改参数
@ -85,12 +83,12 @@ public class AliPayController {
/**
* OK
*/
return new ResponseEntity("payment successful",HttpStatus.OK);
return new ResponseEntity<>("payment successful",HttpStatus.OK);
}else{
/**
*
*/
return new ResponseEntity(HttpStatus.BAD_REQUEST);
return new ResponseEntity<>(HttpStatus.BAD_REQUEST);
}
}

View File

@ -45,7 +45,7 @@ public class PictureController {
public ResponseEntity upload(@RequestParam MultipartFile file){
String userName = SecurityUtils.getUsername();
Picture picture = pictureService.upload(file,userName);
Map map = new HashMap();
Map map = new HashMap(3);
map.put("errno",0);
map.put("id",picture.getId());
map.put("data",new String[]{picture.getUrl()});

View File

@ -56,7 +56,7 @@ public class QiniuController {
@PostMapping(value = "/qiNiuContent")
public ResponseEntity upload(@RequestParam MultipartFile file){
QiniuContent qiniuContent = qiNiuService.upload(file,qiNiuService.find());
Map map = new HashMap();
Map map = new HashMap(3);
map.put("id",qiniuContent.getId());
map.put("errno",0);
map.put("data",new String[]{qiniuContent.getUrl()});
@ -84,7 +84,7 @@ public class QiniuController {
@Log("下载文件")
@GetMapping(value = "/qiNiuContent/download/{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()));
return new ResponseEntity(map,HttpStatus.OK);
}

View File

@ -45,6 +45,7 @@ public interface QiNiuService {
*
* @param file
* @param qiniuConfig
* @return
*/
@CacheEvict(allEntries = true)
QiniuContent upload(MultipartFile file, QiniuConfig qiniuConfig);
@ -84,7 +85,7 @@ public interface QiNiuService {
/**
*
* @param ids
* @return
* @param config
*/
@CacheEvict(allEntries = true)
void deleteAll(Long[] ids, QiniuConfig config);

View File

@ -83,7 +83,8 @@ public class EmailServiceImpl implements EmailService {
.setTitle(emailVo.getSubject())
.setContent(content)
.setHtml(true)
.setUseGlobalSession(false)//关闭session
//关闭session
.setUseGlobalSession(false)
.send();
}catch (Exception e){
throw new BadRequestException(e.getMessage());

View File

@ -49,7 +49,7 @@ public class PictureServiceImpl implements PictureService {
public Picture upload(MultipartFile multipartFile, String username) {
File file = FileUtil.toFile(multipartFile);
HashMap<String, Object> paramMap = new HashMap<>();
HashMap<String, Object> paramMap = new HashMap<>(1);
paramMap.put("smfile", file);
String result= HttpUtil.post(ElAdminConstant.Url.SM_MS_URL, paramMap);