5442f652
YunaiV
整理 vm 模板
|
1
2
3
4
5
6
7
8
9
|
package ${basePackage}.${table.moduleName}.service.${table.businessName}.impl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import java.util.*;
import ${basePackage}.${table.moduleName}.controller.${table.businessName}.vo.*;
|
305090b7
YunaiV
1. 完成代码生成的表和字段定义的编辑
|
10
|
import ${basePackage}.${table.moduleName}.dal.dataobject.${table.businessName}.${table.className}DO;
|
5442f652
YunaiV
整理 vm 模板
|
11
12
|
import ${PageResultClassName};
|
59be930f
YunaiV
添加 serviceImpl.vm...
|
13
|
import ${basePackage}.${table.moduleName}.convert.${table.businessName}.${table.className}Convert;
|
305090b7
YunaiV
1. 完成代码生成的表和字段定义的编辑
|
14
|
import ${basePackage}.${table.moduleName}.dal.mysql.${table.businessName}.${table.className}Mapper;
|
59be930f
YunaiV
添加 serviceImpl.vm...
|
15
16
17
18
|
import ${basePackage}.${table.moduleName}.service.${table.businessName}.${table.className}Service;
import ${ServiceExceptionUtilClassName};
|
ea631ee4
YunaiV
1. 调整代码生成器模板的目录
|
19
|
import static ${basePackage}.${table.moduleName}.enums.${simpleModuleName_upperFirst}ErrorCodeConstants.*;
|
5442f652
YunaiV
整理 vm 模板
|
20
21
22
23
24
25
|
/**
* ${table.classComment} Service 实现类
*
* @author ${table.author}
*/
|
59be930f
YunaiV
添加 serviceImpl.vm...
|
26
|
@Service
|
5442f652
YunaiV
整理 vm 模板
|
27
|
@Validated
|
59be930f
YunaiV
添加 serviceImpl.vm...
|
28
|
public class ${table.className}ServiceImpl implements ${table.className}Service {
|
5442f652
YunaiV
整理 vm 模板
|
29
30
31
32
33
|
@Resource
private ${table.className}Mapper ${classNameVar}Mapper;
@Override
|
59be930f
YunaiV
添加 serviceImpl.vm...
|
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
public ${primaryColumn.javaType} create${simpleClassName}(${table.className}CreateReqVO createReqVO) {
// 插入
${table.className}DO ${classNameVar} = ${table.className}Convert.INSTANCE.convert(createReqVO);
${classNameVar}Mapper.insert(${classNameVar});
// 返回
return ${classNameVar}.getId();
}
@Override
public void update${simpleClassName}(${table.className}UpdateReqVO updateReqVO) {
// 校验存在
this.validate${simpleClassName}Exists(updateReqVO.getId());
// 更新
${table.className}DO updateObj = ${table.className}Convert.INSTANCE.convert(updateReqVO);
${classNameVar}Mapper.updateById(updateObj);
}
@Override
public void delete${simpleClassName}(${primaryColumn.javaType} id) {
// 校验存在
this.validate${simpleClassName}Exists(id);
// 更新
${classNameVar}Mapper.deleteById(id);
}
private void validate${simpleClassName}Exists(${primaryColumn.javaType} id) {
if (${classNameVar}Mapper.selectById(id) == null) {
throw ServiceExceptionUtil.exception(${simpleClassName_underlineCase.toUpperCase()}_NOT_EXISTS);
}
}
@Override
public ${table.className}DO get${simpleClassName}(${primaryColumn.javaType} id) {
return ${classNameVar}Mapper.selectById(id);
}
@Override
public List<${table.className}DO> get${simpleClassName}List(Collection<${primaryColumn.javaType}> ids) {
return ${classNameVar}Mapper.selectBatchIds(ids);
}
|
8cfb8265
YunaiV
代码预览的功能,完成
|
75
|
@Override
|
59be930f
YunaiV
添加 serviceImpl.vm...
|
76
77
|
public PageResult<${table.className}DO> get${simpleClassName}Page(${table.className}PageReqVO pageReqVO) {
return ${classNameVar}Mapper.selectPage(pageReqVO);
|
5442f652
YunaiV
整理 vm 模板
|
78
79
80
|
}
}
|