rev: 代码生成器转为mybatis-plus的生成
This commit is contained in:
@@ -1,64 +1,60 @@
|
||||
package ${package}.controller;
|
||||
|
||||
package ${package}.rest;
|
||||
|
||||
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.common.TableDataInfo;
|
||||
import org.nl.common.domain.query.PageQuery;
|
||||
import org.nl.modules.logging.annotation.Log;
|
||||
import ${package}.service.I${className}Service;
|
||||
import ${package}.service.dao.${className};
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Map;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.util.Set;
|
||||
/**
|
||||
* @author ${author}
|
||||
* @date ${date}
|
||||
**/
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
|
||||
@RequestMapping("/api/${changeClassName}")
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/api/${changeClassName}")
|
||||
public class ${className}Controller {
|
||||
|
||||
private final ${className}Service ${changeClassName}Service;
|
||||
@Autowired
|
||||
private I${className}Service ${changeClassName}Service;
|
||||
|
||||
@GetMapping
|
||||
@Log("查询${apiAlias}")
|
||||
|
||||
//@SaCheckPermission("@el.check('${changeClassName}:list')")
|
||||
public ResponseEntity<Object> query(@RequestParam Map whereJson, Pageable page){
|
||||
return new ResponseEntity<>(${changeClassName}Service.queryAll(whereJson,page),HttpStatus.OK);
|
||||
public ResponseEntity<Object> query(@RequestParam Map whereJson, PageQuery page){
|
||||
return new ResponseEntity<>(TableDataInfo.build(${changeClassName}Service.queryAll(whereJson,page)),HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
@Log("新增${apiAlias}")
|
||||
|
||||
//@SaCheckPermission("@el.check('${changeClassName}:add')")
|
||||
public ResponseEntity<Object> create(@Validated @RequestBody ${className}Dto dto){
|
||||
${changeClassName}Service.create(dto);
|
||||
public ResponseEntity
|
||||
<Object> create(@Validated @RequestBody ${className} entity){
|
||||
${changeClassName}Service.create(entity);
|
||||
return new ResponseEntity<>(HttpStatus.CREATED);
|
||||
}
|
||||
|
||||
@PutMapping
|
||||
@Log("修改${apiAlias}")
|
||||
|
||||
//@SaCheckPermission("@el.check('${changeClassName}:edit')")
|
||||
public ResponseEntity<Object> update(@Validated @RequestBody ${className}Dto dto){
|
||||
${changeClassName}Service.update(dto);
|
||||
public ResponseEntity<Object> update(@Validated @RequestBody ${className} entity){
|
||||
${changeClassName}Service.update(entity);
|
||||
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
|
||||
@Log("删除${apiAlias}")
|
||||
|
||||
//@SaCheckPermission("@el.check('${changeClassName}:del')")
|
||||
@DeleteMapping
|
||||
public ResponseEntity<Object> delete(@RequestBody ${pkColumnType}[] ids) {
|
||||
${changeClassName}Service.deleteAll(ids);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
public ResponseEntity<Object> delete(@RequestBody Set<String> ids) {
|
||||
${changeClassName}Service.deleteAll(ids);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,17 +1,16 @@
|
||||
package ${package}.service.dto;
|
||||
|
||||
import lombok.Data;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||
<#if hasTimestamp>
|
||||
import java.sql.Timestamp;
|
||||
import java.sql.Timestamp;
|
||||
</#if>
|
||||
<#if hasBigDecimal>
|
||||
import java.math.BigDecimal;
|
||||
import java.math.BigDecimal;
|
||||
</#if>
|
||||
import lombok.Data;
|
||||
import lombok.Builder;
|
||||
import java.io.Serializable;
|
||||
<#if !auto && pkColumnType = 'Long'>
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||
</#if>
|
||||
|
||||
/**
|
||||
* @description /
|
||||
@@ -19,20 +18,21 @@ import java.io.Serializable;
|
||||
* @date ${date}
|
||||
**/
|
||||
@Data
|
||||
@Builder
|
||||
public class ${className}Dto implements Serializable {
|
||||
<#if columns??>
|
||||
<#list columns as column>
|
||||
|
||||
<#if column.remark != ''>
|
||||
/** ${column.remark} */
|
||||
</#if>
|
||||
<#if column.columnKey = 'PRI'>
|
||||
<#if !auto && pkColumnType = 'Long'>
|
||||
/** 防止精度丢失 */
|
||||
@JsonSerialize(using= ToStringSerializer.class)
|
||||
</#if>
|
||||
</#if>
|
||||
private ${column.columnType} ${column.changeColumnName};
|
||||
<#if column.remark != ''>
|
||||
/** ${column.remark} */
|
||||
</#if>
|
||||
<#if column.columnKey = 'PRI'>
|
||||
<#if !auto && pkColumnType = 'Long'>
|
||||
/** 防止精度丢失 */
|
||||
@JsonSerialize(using= ToStringSerializer.class)
|
||||
</#if>
|
||||
</#if>
|
||||
private ${column.columnType} ${column.changeColumnName};
|
||||
</#list>
|
||||
</#if>
|
||||
}
|
||||
|
||||
@@ -1,69 +1,47 @@
|
||||
package ${package}.domain;
|
||||
package ${package}.service.dao;
|
||||
|
||||
<#if hasPk>
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
</#if>
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import cn.hutool.core.bean.copier.CopyOptions;
|
||||
import javax.persistence.*;
|
||||
<#if isNotNullColumns??>
|
||||
import javax.validation.constraints.*;
|
||||
</#if>
|
||||
<#if hasDateAnnotation>
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Table;
|
||||
import org.hibernate.annotations.*;
|
||||
</#if>
|
||||
<#if hasTimestamp>
|
||||
import java.sql.Timestamp;
|
||||
import java.sql.Timestamp;
|
||||
</#if>
|
||||
<#if hasBigDecimal>
|
||||
import java.math.BigDecimal;
|
||||
import java.math.BigDecimal;
|
||||
</#if>
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @description /
|
||||
* @description 添加'@Builder'注解最好不好添加'@NoArgsConstructor'
|
||||
* @author ${author}
|
||||
* @date ${date}
|
||||
**/
|
||||
@Entity
|
||||
@Data
|
||||
@Table(name="${tableName}")
|
||||
@Builder
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@TableName("${tableName}")
|
||||
public class ${className} implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
<#if columns??>
|
||||
<#list columns as column>
|
||||
|
||||
<#if column.columnKey = 'PRI'>
|
||||
@Id
|
||||
<#if auto>
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
</#if>
|
||||
</#if>
|
||||
@Column(name = "${column.columnName}"<#if column.columnKey = 'UNI'>,unique = true</#if><#if column.istNotNull && column.columnKey != 'PRI'>,nullable = false</#if>)
|
||||
<#if column.istNotNull && column.columnKey != 'PRI'>
|
||||
<#if column.columnType = 'String'>
|
||||
@NotBlank
|
||||
<#else>
|
||||
@NotNull
|
||||
</#if>
|
||||
</#if>
|
||||
<#if (column.dateAnnotation)?? && column.dateAnnotation != ''>
|
||||
<#if column.dateAnnotation = 'CreationTimestamp'>
|
||||
@CreationTimestamp
|
||||
<#else>
|
||||
@UpdateTimestamp
|
||||
</#if>
|
||||
</#if>
|
||||
<#if column.remark != ''>
|
||||
|
||||
<#else>
|
||||
|
||||
</#if>
|
||||
private ${column.columnType} ${column.changeColumnName};
|
||||
</#list>
|
||||
<#list columns as column>
|
||||
<#if column.columnKey = 'PRI'>
|
||||
@TableId(value = "${column.columnName}", type = <#if auto>IdType.AUTO<#else>IdType.NONE</#if>)
|
||||
</#if>
|
||||
<#if column.remark != ''>
|
||||
/** ${column.remark} */
|
||||
<#else>
|
||||
/** ${column.changeColumnName} */
|
||||
</#if>
|
||||
private ${column.columnType} ${column.changeColumnName};
|
||||
|
||||
public void copy(${className} source){
|
||||
BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
|
||||
}
|
||||
</#list>
|
||||
</#if>
|
||||
}
|
||||
|
||||
@@ -1,17 +1,12 @@
|
||||
package ${package}.service.mapstruct;
|
||||
package ${package}.service.dao.mapper;
|
||||
|
||||
import BaseMapper;
|
||||
import ${package}.domain.${className};
|
||||
import ${package}.service.dto.${className}Dto;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.ReportingPolicy;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import ${package}.service.dao.${className};
|
||||
|
||||
/**
|
||||
* @website https://el-admin.vip
|
||||
* @author ${author}
|
||||
* @date ${date}
|
||||
**/
|
||||
@Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE)
|
||||
public interface ${className}Mapper extends BaseMapper<${className}Dto, ${className}> {
|
||||
public interface ${className}Mapper extends BaseMapper<${className}> {
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="${package}.service.dao.mapper.${className}Mapper">
|
||||
|
||||
</mapper>
|
||||
@@ -1,66 +1,12 @@
|
||||
|
||||
package ${package}.service.dto;
|
||||
|
||||
import lombok.Data;
|
||||
<#if queryHasTimestamp>
|
||||
import java.sql.Timestamp;
|
||||
</#if>
|
||||
<#if queryHasBigDecimal>
|
||||
import java.math.BigDecimal;
|
||||
</#if>
|
||||
<#if betweens??>
|
||||
import java.util.List;
|
||||
</#if>
|
||||
<#if queryColumns??>
|
||||
import Query;
|
||||
</#if>
|
||||
import org.nl.common.domain.query.BaseQuery;
|
||||
import ${package}.service.dao.${className};
|
||||
|
||||
/**
|
||||
* @author ${author}
|
||||
* @date ${date}
|
||||
**/
|
||||
@Data
|
||||
public class ${className}QueryCriteria{
|
||||
<#if queryColumns??>
|
||||
<#list queryColumns as column>
|
||||
public class ${className}Query extends BaseQuery<${className}> {
|
||||
|
||||
<#if column.queryType = '='>
|
||||
/** 精确 */
|
||||
@Query
|
||||
private ${column.columnType} ${column.changeColumnName};
|
||||
</#if>
|
||||
<#if column.queryType = 'Like'>
|
||||
/** 模糊 */
|
||||
@Query(type = Query.Type.INNER_LIKE)
|
||||
private ${column.columnType} ${column.changeColumnName};
|
||||
</#if>
|
||||
<#if column.queryType = '!='>
|
||||
/** 不等于 */
|
||||
@Query(type = Query.Type.NOT_EQUAL)
|
||||
private ${column.columnType} ${column.changeColumnName};
|
||||
</#if>
|
||||
<#if column.queryType = 'NotNull'>
|
||||
/** 不为空 */
|
||||
@Query(type = Query.Type.NOT_NULL)
|
||||
private ${column.columnType} ${column.changeColumnName};
|
||||
</#if>
|
||||
<#if column.queryType = '>='>
|
||||
/** 大于等于 */
|
||||
@Query(type = Query.Type.GREATER_THAN)
|
||||
private ${column.columnType} ${column.changeColumnName};
|
||||
</#if>
|
||||
<#if column.queryType = '<='>
|
||||
/** 小于等于 */
|
||||
@Query(type = Query.Type.LESS_THAN)
|
||||
private ${column.columnType} ${column.changeColumnName};
|
||||
</#if>
|
||||
</#list>
|
||||
</#if>
|
||||
<#if betweens??>
|
||||
<#list betweens as column>
|
||||
/** BETWEEN */
|
||||
@Query(type = Query.Type.BETWEEN)
|
||||
private List<${column.columnType}> ${column.changeColumnName};
|
||||
</#list>
|
||||
</#if>
|
||||
}
|
||||
|
||||
@@ -1,64 +1,43 @@
|
||||
|
||||
package ${package}.service;
|
||||
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import org.nl.common.domain.query.PageQuery;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import ${package}.service.dao.${className};
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.List;
|
||||
import java.io.IOException;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @description 服务接口
|
||||
* @author ${author}
|
||||
* @date ${date}
|
||||
**/
|
||||
public interface ${className}Service {
|
||||
public interface I${className}Service extends IService<${className}> {
|
||||
|
||||
/**
|
||||
* 查询数据分页
|
||||
* @param whereJson 条件
|
||||
* @param page 分页参数
|
||||
* @return Map<String,Object>
|
||||
*/
|
||||
Map<String,Object> queryAll(Map whereJson, Pageable page);
|
||||
|
||||
/**
|
||||
* 查询所有数据不分页
|
||||
* @param whereJson 条件参数
|
||||
* @return List<${className}Dto>
|
||||
/**
|
||||
* 查询数据分页
|
||||
* @param whereJson 条件
|
||||
* @param pageable 分页参数
|
||||
* @return IPage<${className}>
|
||||
*/
|
||||
List<${className}Dto> queryAll(Map whereJson);
|
||||
IPage<${className}> queryAll(Map whereJson, PageQuery pageable);
|
||||
|
||||
/**
|
||||
* 根据ID查询
|
||||
* @param ${pkChangeColName} ID
|
||||
* @return ${className}
|
||||
*/
|
||||
${className}Dto findById(${pkColumnType} ${pkChangeColName});
|
||||
/**
|
||||
* 创建
|
||||
* @param entity /
|
||||
*/
|
||||
void create(${className} entity);
|
||||
|
||||
/**
|
||||
* 根据编码查询
|
||||
* @param code code
|
||||
* @return ${className}
|
||||
*/
|
||||
${className}Dto findByCode(String code);
|
||||
/**
|
||||
* 编辑
|
||||
* @param entity /
|
||||
*/
|
||||
void update(${className} entity);
|
||||
|
||||
|
||||
/**
|
||||
* 创建
|
||||
* @param dto /
|
||||
*/
|
||||
void create(${className}Dto dto);
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
* @param dto /
|
||||
*/
|
||||
void update(${className}Dto dto);
|
||||
|
||||
/**
|
||||
* 多选删除
|
||||
* @param ids /
|
||||
*/
|
||||
void deleteAll(${pkColumnType}[] ids);
|
||||
}
|
||||
/**
|
||||
* 多选删除
|
||||
* @param ids /
|
||||
*/
|
||||
void deleteAll(Set<String> ids);
|
||||
}
|
||||
|
||||
@@ -1,128 +1,80 @@
|
||||
|
||||
package ${package}.service.impl;
|
||||
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import org.nl.common.utils.SecurityUtils;
|
||||
import org.nl.modules.wql.core.bean.ResultBean;
|
||||
import org.nl.modules.wql.core.bean.WQLObject;
|
||||
import org.nl.modules.wql.util.WqlUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import org.nl.modules.common.exception.BadRequestException;
|
||||
import org.nl.common.domain.query.PageQuery;
|
||||
import org.nl.common.utils.SecurityUtils;
|
||||
import ${package}.service.I${className}Service;
|
||||
import ${package}.service.dao.mapper.${className}Mapper;
|
||||
import ${package}.service.dao.${className};
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @description 服务实现
|
||||
* @author ${author}
|
||||
* @date ${date}
|
||||
**/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
@Slf4j
|
||||
public class ${className}ServiceImpl implements ${className}Service {
|
||||
@Service
|
||||
public class ${className}ServiceImpl extends ServiceImpl<${className}Mapper, ${className}> implements I${className}Service {
|
||||
|
||||
@Autowired
|
||||
private ${className}Mapper ${changeClassName}Mapper;
|
||||
|
||||
@Override
|
||||
public IPage<${className}> queryAll(Map whereJson, PageQuery page){
|
||||
LambdaQueryWrapper<${className}> lam = new LambdaQueryWrapper<>();
|
||||
IPage<${className}> pages = new Page<>(page.getPage() + 1, page.getSize());
|
||||
${changeClassName}Mapper.selectPage(pages, lam);
|
||||
return pages;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void create(${className} entity) {
|
||||
String currentUserId = SecurityUtils.getCurrentUserId();
|
||||
String nickName = SecurityUtils.getCurrentNickName();
|
||||
String now = DateUtil.now();
|
||||
|
||||
entity.set${pkChangeColName ? cap_first }(IdUtil.getSnowflake(1, 1).nextIdStr());
|
||||
entity.setCreate_id(currentUserId);
|
||||
entity.setCreate_name(nickName);
|
||||
entity.setCreate_time(now);
|
||||
entity.setUpdate_id(currentUserId);
|
||||
entity.setUpdate_name(nickName);
|
||||
entity.setUpdate_time(now);
|
||||
${changeClassName}Mapper.insert(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(${className} entity) {
|
||||
${className} dto = ${changeClassName}Mapper.selectById(entity.get${pkChangeColName ? cap_first }());
|
||||
if (dto == null) throw new BadRequestException("被删除或无权限,操作失败!");
|
||||
|
||||
String currentUserId = SecurityUtils.getCurrentUserId();
|
||||
String nickName = SecurityUtils.getCurrentNickName();
|
||||
String now = DateUtil.now();
|
||||
entity.setUpdate_id(currentUserId);
|
||||
entity.setUpdate_name(nickName);
|
||||
entity.setUpdate_time(now);
|
||||
|
||||
${changeClassName}Mapper.updateById(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteAll(Set<String> ids) {
|
||||
// 真删除
|
||||
${changeClassName}Mapper.deleteBatchIds(ids);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String,Object> queryAll(Map whereJson, Pageable page){
|
||||
WQLObject wo = WQLObject.getWQLObject("${tableName}");
|
||||
ResultBean rb = wo.pagequery(WqlUtil.getHttpContext(page), "1=1", "update_time desc");
|
||||
final JSONObject json = rb.pageResult();
|
||||
return json;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<${className}Dto> queryAll(Map whereJson){
|
||||
WQLObject wo = WQLObject.getWQLObject("${tableName}");
|
||||
JSONArray arr = wo.query().getResultJSONArray(0);
|
||||
if (ObjectUtil.isNotEmpty(arr)) return arr.toJavaList(${className}Dto.class);
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ${className}Dto findById(${pkColumnType} ${pkChangeColName}) {
|
||||
WQLObject wo = WQLObject.getWQLObject("${tableName}");
|
||||
JSONObject json = wo.query("${pkChangeColName} = '" + ${pkChangeColName} + "'").uniqueResult(0);
|
||||
if (ObjectUtil.isNotEmpty(json)){
|
||||
return json.toJavaObject( ${className}Dto.class);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ${className}Dto findByCode(String code) {
|
||||
WQLObject wo = WQLObject.getWQLObject("${tableName}");
|
||||
JSONObject json = wo.query("code ='" + code + "'").uniqueResult(0);
|
||||
if (ObjectUtil.isNotEmpty(json)){
|
||||
return json.toJavaObject( ${className}Dto.class);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void create(${className}Dto dto) {
|
||||
String currentUserId = SecurityUtils.getCurrentUserId();
|
||||
String nickName = SecurityUtils.getCurrentNickName();
|
||||
String now = DateUtil.now();
|
||||
|
||||
dto.set${pkChangeColName ? cap_first }(IdUtil.getSnowflake(1, 1).nextId());
|
||||
dto.setCreate_id(currentUserId);
|
||||
dto.setCreate_name(nickName);
|
||||
dto.setUpdate_optid(currentUserId);
|
||||
dto.setUpdate_optname(nickName);
|
||||
dto.setUpdate_time(now);
|
||||
dto.setCreate_time(now);
|
||||
|
||||
WQLObject wo = WQLObject.getWQLObject("${tableName}");
|
||||
JSONObject json = JSONObject.parseObject(JSON.toJSONString(dto));
|
||||
wo.insert(json);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void update(${className}Dto dto) {
|
||||
${className}Dto entity = this.findById(dto.get${pkChangeColName ? cap_first }());
|
||||
if (entity == null) throw new BadRequestException("被删除或无权限,操作失败!");
|
||||
|
||||
String currentUserId = SecurityUtils.getCurrentUserId();
|
||||
String nickName = SecurityUtils.getCurrentNickName();
|
||||
|
||||
String now = DateUtil.now();
|
||||
dto.setUpdate_time(now);
|
||||
dto.setUpdate_optid(currentUserId);
|
||||
dto.setUpdate_optname(nickName);
|
||||
|
||||
WQLObject wo = WQLObject.getWQLObject("${tableName}");
|
||||
JSONObject json = JSONObject.parseObject(JSON.toJSONString(dto));
|
||||
wo.update(json);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void deleteAll(${pkColumnType}[] ids) {
|
||||
String currentUserId = SecurityUtils.getCurrentUserId();
|
||||
String nickName = SecurityUtils.getCurrentNickName();
|
||||
String now = DateUtil.now();
|
||||
|
||||
WQLObject wo = WQLObject.getWQLObject("${tableName}");
|
||||
for (${pkColumnType} ${pkChangeColName}: ids) {
|
||||
JSONObject param = new JSONObject();
|
||||
param.put("${pkChangeColName}", String.valueOf(${pkChangeColName}));
|
||||
param.put("is_delete", "1");
|
||||
param.put("update_optid", currentUserId);
|
||||
param.put("update_optname", nickName);
|
||||
param.put("update_time", now);
|
||||
wo.update(param);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -113,13 +113,20 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import CRUD, {crud, form, header, presenter} from '@crud/crud'
|
||||
import rrOperation from '@crud/RR.operation'
|
||||
import crudOperation from '@crud/CRUD.operation'
|
||||
import udOperation from '@crud/UD.operation'
|
||||
import pagination from '@crud/Pagination'
|
||||
import crud${className} from './${changeClassName}'
|
||||
import CRUD, {crud, form, header, presenter} from '@crud/crud'
|
||||
import rrOperation from '@crud/RR.operation'
|
||||
import crudOperation from '@crud/CRUD.operation'
|
||||
import udOperation from '@crud/UD.operation'
|
||||
import pagination from '@crud/Pagination'
|
||||
|
||||
const defaultForm = { <#if columns??><#list columns as column>${column.changeColumnName}: null<#if column_has_next>, </#if></#list></#if> }
|
||||
const defaultForm = {
|
||||
<#if columns??>
|
||||
<#list columns as column>
|
||||
${column.changeColumnName}: null<#if column_has_next>,</#if>
|
||||
</#list>
|
||||
</#if>
|
||||
}
|
||||
export default {
|
||||
name: '${className}',
|
||||
components: { pagination, crudOperation, rrOperation, udOperation },
|
||||
@@ -128,7 +135,13 @@ export default {
|
||||
dicts: [<#if hasDict??><#list dicts as dict>'${dict}'<#if dict_has_next>, </#if></#list></#if>],
|
||||
</#if>
|
||||
cruds() {
|
||||
return CRUD({ title: '${apiAlias}', url: 'api/${changeClassName}', idField: '${pkChangeColName}', sort: '${pkChangeColName},desc', crudMethod: { ...crud${className} }})
|
||||
return CRUD({
|
||||
title: '${apiAlias}',
|
||||
url: 'api/${changeClassName}',
|
||||
idField: '${pkChangeColName}',
|
||||
sort: '${pkChangeColName},desc',
|
||||
crudMethod: { ...crud${className} }
|
||||
})
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user