修改代码生成器模板.
This commit is contained in:
@@ -29,7 +29,7 @@ GET {{baseUrl}}/${package.ModuleName}/${typeHyphen}/get?id=1
|
||||
Authorization: {{token}}
|
||||
|
||||
|
||||
${httpComment} ${apiComment.listById}
|
||||
${httpComment} ${apiComment.listByIdList}
|
||||
GET {{baseUrl}}/${package.ModuleName}/${typeHyphen}/list?idList=1,2,3
|
||||
Authorization: {{token}}
|
||||
|
||||
@@ -63,7 +63,7 @@ DELETE {{baseUrl}}/${package.ModuleName}/${typeHyphen}/delete?id=1
|
||||
Authorization: {{token}}
|
||||
|
||||
|
||||
${httpComment} ${apiComment.batchDeleteById}
|
||||
${httpComment} ${apiComment.batchDeleteByIdList}
|
||||
DELETE {{baseUrl}}/${package.ModuleName}/${typeHyphen}/delete-batch?idList=1,2,3
|
||||
Authorization: {{token}}
|
||||
|
||||
@@ -5,7 +5,7 @@ import com.orion.ops.framework.common.annotation.IgnoreLog;
|
||||
import com.orion.ops.framework.common.annotation.RestWrapper;
|
||||
import com.orion.ops.framework.common.constant.IgnoreLogMode;
|
||||
import ${package.Service}.*;
|
||||
#foreach($pkg in ${customFilePackages})
|
||||
#foreach($pkg in ${customModuleFilePackages})
|
||||
import ${pkg}.*;
|
||||
#end
|
||||
#if(${superControllerClassPackage})
|
||||
@@ -70,7 +70,7 @@ public class ${table.controllerName} {
|
||||
|
||||
@IgnoreLog(IgnoreLogMode.RET)
|
||||
@GetMapping("/list")
|
||||
@Operation(summary = "${apiComment.listById}")
|
||||
@Operation(summary = "${apiComment.listByIdList}")
|
||||
@Parameter(name = "idList", description = "idList", required = true)
|
||||
@PreAuthorize("@ss.hasPermission('${package.ModuleName}:${typeHyphen}:query')")
|
||||
public List<${type}VO> get${type}List(@RequestParam("idList") List<Long> idList) {
|
||||
@@ -102,7 +102,7 @@ public class ${table.controllerName} {
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete-batch")
|
||||
@Operation(summary = "${apiComment.batchDeleteById}")
|
||||
@Operation(summary = "${apiComment.batchDeleteByIdList}")
|
||||
@Parameter(name = "idList", description = "idList", required = true)
|
||||
@PreAuthorize("@ss.hasPermission('${package.ModuleName}:${typeHyphen}:delete')")
|
||||
public Integer batchDelete${type}(@RequestParam("idList") List<Long> idList) {
|
||||
@@ -3,7 +3,7 @@ package ${currentPackage};
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
import ${package.Entity}.*;
|
||||
#foreach($pkg in ${customFilePackages})
|
||||
#foreach($pkg in ${customModuleFilePackages})
|
||||
import ${pkg}.*;
|
||||
#end
|
||||
import java.util.List;
|
||||
@@ -28,7 +28,7 @@ public interface ${table.mapperName} extends ${superMapperClass}<${entity}> {
|
||||
default LambdaQueryWrapper<${entity}> queryCondition(${entity} entity) {
|
||||
return this.wrapper()
|
||||
#foreach($field in ${table.fields})
|
||||
.eq(${type}DO::get${field.capitalName}, entity.get${field.capitalName}())#if(!$foreach.hasNext);#end
|
||||
.eq(${type}DO::get${field.capitalName}, entity.get${field.capitalName}())#if(!$foreach.hasNext);#end
|
||||
#end
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
#if(${baseColumnList})
|
||||
<!-- 通用查询结果列 -->
|
||||
<sql id="Base_Column_List">
|
||||
#foreach($field in ${table.commonFields})#if(${foreach.count} == 1) #end${field.columnName}, #end${table.fieldNames}
|
||||
${table.fieldNames}, #foreach($field in ${table.commonFields})${field.columnName}#if($foreach.hasNext), #end#end
|
||||
</sql>
|
||||
|
||||
#end
|
||||
@@ -6,7 +6,7 @@ import com.orion.lang.define.wrapper.DataGrid;
|
||||
import com.orion.lang.utils.collect.Lists;
|
||||
import com.orion.ops.framework.common.constant.ErrorMessage;
|
||||
import com.orion.ops.framework.common.utils.Valid;
|
||||
#foreach($pkg in ${customFilePackages})
|
||||
#foreach($pkg in ${customModuleFilePackages})
|
||||
import ${pkg}.*;
|
||||
#end
|
||||
import ${package.Entity}.${entity};
|
||||
@@ -57,7 +57,7 @@ public class ${table.serviceImplName} implements ${table.serviceName} {
|
||||
this.check${type}Present(updateRecord);
|
||||
// 更新
|
||||
int effect = ${typeLower}DAO.updateById(updateRecord);
|
||||
log.info("${type}Service-update${type} effect: {}, updateRecord: {}", effect, JSON.toJSONString(updateRecord));
|
||||
log.info("${type}Service-update${type}ById effect: {}, updateRecord: {}", effect, JSON.toJSONString(updateRecord));
|
||||
return effect;
|
||||
}
|
||||
|
||||
@@ -109,14 +109,14 @@ public class ${table.serviceImplName} implements ${table.serviceName} {
|
||||
@Override
|
||||
public Integer delete${type}ById(Long id) {
|
||||
int effect = ${typeLower}DAO.deleteById(id);
|
||||
log.info("${type}Service-delete${type} id: {}, effect: {}", id, effect);
|
||||
log.info("${type}Service-delete${type}ById id: {}, effect: {}", id, effect);
|
||||
return effect;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer batchDelete${type}ByIdList(List<Long> idList) {
|
||||
int effect = ${typeLower}DAO.deleteBatchIds(idList);
|
||||
log.info("${type}Service-batchDelete${type} idList: {}, effect: {}", idList, effect);
|
||||
log.info("${type}Service-batchDelete${type}ByIdList idList: {}, effect: {}", idList, effect);
|
||||
return effect;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package ${package.Service};
|
||||
|
||||
import com.orion.lang.define.wrapper.DataGrid;
|
||||
#foreach($pkg in ${customFilePackages})
|
||||
#foreach($pkg in ${customModuleFilePackages})
|
||||
import ${pkg}.*;
|
||||
#end
|
||||
|
||||
@@ -41,7 +41,7 @@ public interface ${table.serviceName} {
|
||||
${type}VO get${type}ById(Long id);
|
||||
|
||||
/**
|
||||
* ${apiComment.listById}
|
||||
* ${apiComment.listByIdList}
|
||||
*
|
||||
* @param idList idList
|
||||
* @return rows
|
||||
@@ -73,7 +73,7 @@ public interface ${table.serviceName} {
|
||||
Integer delete${type}ById(Long id);
|
||||
|
||||
/**
|
||||
* ${apiComment.batchDeleteById}
|
||||
* ${apiComment.batchDeleteByIdList}
|
||||
*
|
||||
* @param idList idList
|
||||
* @return effect
|
||||
@@ -5,10 +5,12 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.orion.lang.utils.collect.Collections;
|
||||
import com.orion.ops.framework.common.constant.ErrorMessage;
|
||||
import com.orion.ops.framework.common.utils.Valid;
|
||||
#foreach($pkg in ${customFilePackages})
|
||||
#foreach($pkg in ${customModuleFilePackages})
|
||||
import ${pkg}.*;
|
||||
#end
|
||||
#foreach($pkg in ${customProviderFilePackages})
|
||||
import ${pkg}.*;
|
||||
#end
|
||||
import ${customApiInterfaceFilePackage}.${type}Api;
|
||||
import ${package.Entity}.${entity};
|
||||
import ${package.Mapper}.${table.mapperName};
|
||||
import ${package.Service}.${table.serviceName};
|
||||
@@ -16,6 +18,8 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -30,7 +34,7 @@ import java.util.List;
|
||||
public class ${type}ApiImpl implements ${type}Api {
|
||||
|
||||
@Resource
|
||||
private ${type}Service ${type}Service;
|
||||
private ${type}Service ${typeLower}Service;
|
||||
|
||||
@Resource
|
||||
private ${type}DAO ${typeLower}DAO;
|
||||
@@ -40,19 +44,19 @@ public class ${type}ApiImpl implements ${type}Api {
|
||||
log.info("${type}Api.create${type} request: {}", JSON.toJSONString(dto));
|
||||
Valid.valid(dto);
|
||||
// 转换
|
||||
${type}CreateRequest request = ${type}ApiConvert.MAPPER.to(dto);
|
||||
${type}CreateRequest request = ${type}ProviderConvert.MAPPER.to(dto);
|
||||
// 创建
|
||||
return ${type}Service.create${type}(request);
|
||||
return ${typeLower}Service.create${type}(request);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer update${type}ById(${type}UpdateDTO dto) {
|
||||
log.info("${type}Api.update${type} request: {}", JSON.toJSONString(dto));
|
||||
log.info("${type}Api.update${type}ById request: {}", JSON.toJSONString(dto));
|
||||
Valid.valid(dto);
|
||||
// 转换
|
||||
${type}UpdateRequest request = ${type}ApiConvert.MAPPER.to(dto);
|
||||
${type}UpdateRequest request = ${type}ProviderConvert.MAPPER.to(dto);
|
||||
// 修改
|
||||
return ${type}Service.update${type}(request);
|
||||
return ${typeLower}Service.update${type}ById(request);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -60,24 +64,24 @@ public class ${type}ApiImpl implements ${type}Api {
|
||||
log.info("${type}Api.get${type}ById id: {}", id);
|
||||
Valid.notNull(id, ErrorMessage.ID_MISSING);
|
||||
// 修改
|
||||
${type}DO record = ${type}DAO.selectById(id);
|
||||
${type}DO record = ${typeLower}DAO.selectById(id);
|
||||
if (record == null) {
|
||||
return null;
|
||||
}
|
||||
// 转换
|
||||
return ${type}ApiConvert.MAPPER.to(record);
|
||||
return ${type}ProviderConvert.MAPPER.to(record);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<${type}DTO> get${type}ListById(Collection<Long> idList) {
|
||||
log.info("${type}Api.get${type}ListById idList: {}", idList);
|
||||
public List<${type}DTO> get${type}ByIdList(Collection<Long> idList) {
|
||||
log.info("${type}Api.get${type}ByIdList idList: {}", idList);
|
||||
if (Collections.isEmpty(idList)) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
// 查询
|
||||
List<${type}DO> rows = ${type}DAO.selectBatchIds(idList);
|
||||
List<${type}DO> rows = ${typeLower}DAO.selectBatchIds(idList);
|
||||
// 转换
|
||||
return ${type}ApiConvert.MAPPER.toDTO(rows);
|
||||
return ${type}ProviderConvert.MAPPER.toList(rows);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -85,12 +89,12 @@ public class ${type}ApiImpl implements ${type}Api {
|
||||
log.info("${type}Api.get${type}List dto: {}", JSON.toJSONString(dto));
|
||||
Valid.valid(dto);
|
||||
// 转换条件
|
||||
${type}DO domain = ${type}ApiConvert.MAPPER.to(dto);
|
||||
${type}DO domain = ${type}ProviderConvert.MAPPER.to(dto);
|
||||
// 查询
|
||||
LambdaQueryWrapper<${type}DO> wrapper = ${type}DAO.queryCondition(domain);
|
||||
List<${type}DO> rows = ${type}DAO.selectList(wrapper);
|
||||
LambdaQueryWrapper<${type}DO> wrapper = ${typeLower}DAO.queryCondition(domain);
|
||||
List<${type}DO> rows = ${typeLower}DAO.selectList(wrapper);
|
||||
// 转换结果
|
||||
return ${type}ApiConvert.MAPPER.toDTO(rows);
|
||||
return ${type}ProviderConvert.MAPPER.toList(rows);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -98,15 +102,15 @@ public class ${type}ApiImpl implements ${type}Api {
|
||||
log.info("${type}Api.delete${type}ById id: {}", id);
|
||||
Valid.notNull(id, ErrorMessage.ID_MISSING);
|
||||
// 删除
|
||||
return ${type}DAO.deleteById(id);
|
||||
return ${typeLower}DAO.deleteById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer batchDelete${type}ById(Collection<Long> idList) {
|
||||
log.info("${type}Api.batchDelete${type}ById idList: {}", idList);
|
||||
public Integer batchDelete${type}ByIdList(Collection<Long> idList) {
|
||||
log.info("${type}Api.batchDelete${type}ByIdList idList: {}", idList);
|
||||
Valid.notEmpty(idList, ErrorMessage.ID_MISSING);
|
||||
// 删除
|
||||
return ${type}DAO.deleteBatchIds(idList);
|
||||
return ${typeLower}DAO.deleteBatchIds(idList);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
package ${currentPackage};
|
||||
|
||||
#foreach($pkg in ${customApiEntityFilePackages})
|
||||
#foreach($pkg in ${customProviderEntityFilePackages})
|
||||
import ${pkg}.*;
|
||||
#end
|
||||
|
||||
@@ -41,7 +41,7 @@ public interface ${type}Api {
|
||||
${type}DTO get${type}ById(Long id);
|
||||
|
||||
/**
|
||||
* ${apiComment.listById}
|
||||
* ${apiComment.listByIdList}
|
||||
*
|
||||
* @param idList idList
|
||||
* @return rows
|
||||
@@ -65,7 +65,7 @@ public interface ${type}Api {
|
||||
Integer delete${type}ById(Long id);
|
||||
|
||||
/**
|
||||
* ${apiComment.batchDeleteById}
|
||||
* ${apiComment.batchDeleteByIdList}
|
||||
*
|
||||
* @param idList idList
|
||||
* @return effect
|
||||
@@ -3,10 +3,10 @@ package ${currentPackage};
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
import ${package.Entity}.*;
|
||||
#foreach($pkg in ${customFilePackages})
|
||||
#foreach($pkg in ${customModuleFilePackages})
|
||||
import ${pkg}.*;
|
||||
#end
|
||||
#foreach($pkg in ${customApiEntityFilePackages})
|
||||
#foreach($pkg in ${customProviderEntityFilePackages})
|
||||
import ${pkg}.*;
|
||||
#end
|
||||
import java.util.List;
|
||||
@@ -19,9 +19,9 @@ import java.util.List;
|
||||
* @since ${date}
|
||||
*/
|
||||
@Mapper
|
||||
public interface ${type}ApiConvert {
|
||||
public interface ${type}ProviderConvert {
|
||||
|
||||
${type}ApiConvert MAPPER = Mappers.getMapper(${type}ApiConvert.class);
|
||||
${type}ProviderConvert MAPPER = Mappers.getMapper(${type}ProviderConvert.class);
|
||||
|
||||
${type}DO to(${type}DTO dto);
|
||||
|
||||
@@ -33,7 +33,8 @@ public interface ${type}ApiConvert {
|
||||
|
||||
${type}UpdateRequest to(${type}UpdateDTO domain);
|
||||
|
||||
List<${type}DTO> toDTO(List<${type}DO> list);
|
||||
List<${type}DTO> toList(List<${type}DO> list);
|
||||
|
||||
List<${type}DO> toList1(List<${type}DTO> list);
|
||||
|
||||
List<${type}DO> toDomain(List<${type}DTO> list);
|
||||
}
|
||||
@@ -88,7 +88,7 @@ export function get${vue.featureFirstUpper}(id: number) {
|
||||
}
|
||||
|
||||
/**
|
||||
* $apiComment.listById
|
||||
* $apiComment.listByIdList
|
||||
*/
|
||||
export function get${vue.featureFirstUpper}List(idList: Array<number>) {
|
||||
return axios.get<${vue.featureFirstUpper}QueryResponse[]>('/${package.ModuleName}/${typeHyphen}/list', {
|
||||
@@ -121,7 +121,7 @@ export function delete${vue.featureFirstUpper}(id: number) {
|
||||
}
|
||||
|
||||
/**
|
||||
* $apiComment.batchDeleteById
|
||||
* $apiComment.batchDeleteByIdList
|
||||
*/
|
||||
export function batchDelete${vue.featureFirstUpper}(idList: Array<number>) {
|
||||
return axios.delete('/${package.ModuleName}/${typeHyphen}/delete-batch', {
|
||||
|
||||
Reference in New Issue
Block a user