mirror of
https://gitee.com/hhyykk/ipms-sjy.git
synced 2025-07-23 07:25:07 +08:00
添加 serviceImpl.vm 的模板
This commit is contained in:
@ -75,4 +75,7 @@ public interface SysErrorCodeConstants {
|
||||
// ========== 文件 1002009000 ==========
|
||||
ErrorCode FILE_PATH_EXISTS = new ErrorCode(1002009001, "文件路径已经存在");
|
||||
|
||||
// ========== 字典类型(测试) 1002010000 ==========
|
||||
ErrorCode TEST_DEMO_NOT_EXISTS = new ErrorCode(1002010000, "字典类型不存在}");
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,80 @@
|
||||
package cn.iocoder.dashboard.modules.system.service.test.impl;
|
||||
|
||||
import cn.iocoder.dashboard.common.exception.util.ServiceExceptionUtil;
|
||||
import cn.iocoder.dashboard.common.pojo.PageResult;
|
||||
import cn.iocoder.dashboard.modules.system.controller.test.vo.SysTestDemoCreateReqVO;
|
||||
import cn.iocoder.dashboard.modules.system.controller.test.vo.SysTestDemoPageReqVO;
|
||||
import cn.iocoder.dashboard.modules.system.controller.test.vo.SysTestDemoUpdateReqVO;
|
||||
import cn.iocoder.dashboard.modules.system.convert.test.SysTestDemoConvert;
|
||||
import cn.iocoder.dashboard.modules.system.dal.mysql.dao.test.SysTestDemoMapper;
|
||||
import cn.iocoder.dashboard.modules.system.dal.mysql.dataobject.test.SysTestDemoDO;
|
||||
import cn.iocoder.dashboard.modules.system.service.test.SysTestDemoService;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import static cn.iocoder.dashboard.modules.system.enums.SysErrorCodeConstants.TEST_DEMO_NOT_EXISTS;
|
||||
|
||||
/**
|
||||
* 字典类型 Service 实现类
|
||||
*
|
||||
* @author 芋艿
|
||||
*/
|
||||
@Service
|
||||
@Validated
|
||||
public class SysTestDemoServiceImpl implements SysTestDemoService {
|
||||
|
||||
@Resource
|
||||
private SysTestDemoMapper testDemoMapper;
|
||||
|
||||
@Override
|
||||
public Long createTestDemo(SysTestDemoCreateReqVO createReqVO) {
|
||||
// 插入
|
||||
SysTestDemoDO testDemo = SysTestDemoConvert.INSTANCE.convert(createReqVO);
|
||||
testDemoMapper.insert(testDemo);
|
||||
// 返回
|
||||
return testDemo.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateTestDemo(SysTestDemoUpdateReqVO updateReqVO) {
|
||||
// 校验存在
|
||||
this.validateTestDemoExists(updateReqVO.getId());
|
||||
// 更新
|
||||
SysTestDemoDO updateObj = SysTestDemoConvert.INSTANCE.convert(updateReqVO);
|
||||
testDemoMapper.updateById(updateObj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteTestDemo(Long id) {
|
||||
// 校验存在
|
||||
this.validateTestDemoExists(id);
|
||||
// 更新
|
||||
testDemoMapper.deleteById(id);
|
||||
}
|
||||
|
||||
private void validateTestDemoExists(Long id) {
|
||||
if (testDemoMapper.selectById(id) == null) {
|
||||
throw ServiceExceptionUtil.exception(TEST_DEMO_NOT_EXISTS);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public SysTestDemoDO getTestDemo(Long id) {
|
||||
return testDemoMapper.selectById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SysTestDemoDO> getTestDemoList(Collection<Long> ids) {
|
||||
return testDemoMapper.selectBatchIds(ids);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<SysTestDemoDO> getTestDemoPage(SysTestDemoPageReqVO pageReqVO) {
|
||||
return testDemoMapper.selectPage(pageReqVO);
|
||||
}
|
||||
|
||||
}
|
@ -3,6 +3,7 @@ package cn.iocoder.dashboard.modules.tool.service.codegen.impl;
|
||||
import cn.hutool.extra.template.TemplateConfig;
|
||||
import cn.hutool.extra.template.TemplateEngine;
|
||||
import cn.hutool.extra.template.TemplateUtil;
|
||||
import cn.iocoder.dashboard.common.exception.util.ServiceExceptionUtil;
|
||||
import cn.iocoder.dashboard.common.pojo.PageParam;
|
||||
import cn.iocoder.dashboard.common.pojo.PageResult;
|
||||
import cn.iocoder.dashboard.framework.mybatis.core.dataobject.BaseDO;
|
||||
@ -59,11 +60,12 @@ public class ToolCodegenEngine {
|
||||
// 全局 Java Bean
|
||||
globalBindingMap.put("PageResultClassName", PageResult.class.getName());
|
||||
globalBindingMap.put("DateUtilsClassName", DateUtils.class.getName());
|
||||
globalBindingMap.put("ServiceExceptionUtilClassName", ServiceExceptionUtil.class.getName());
|
||||
// VO 类,独有字段
|
||||
globalBindingMap.put("PageParamClassName", PageParam.class.getName());
|
||||
// DO 类,独有字段
|
||||
globalBindingMap.put("baseDOFields", ToolCodegenBuilder.BASE_DO_FIELDS);
|
||||
globalBindingMap.put("baseDOClassName", BaseDO.class.getName());
|
||||
globalBindingMap.put("BaseDOClassName", BaseDO.class.getName());
|
||||
globalBindingMap.put("QueryWrapperClassName", QueryWrapperX.class.getName());
|
||||
globalBindingMap.put("BaseMapperClassName", BaseMapperX.class.getName());
|
||||
}
|
||||
@ -92,8 +94,8 @@ public class ToolCodegenEngine {
|
||||
// String result = templateEngine.getTemplate("codegen/controller/vo/respVO.vm").render(bindingMap);
|
||||
// String result = templateEngine.getTemplate("codegen/convert/convert.vm").render(bindingMap);
|
||||
// String result = templateEngine.getTemplate("codegen/enums/errorcode.vm").render(bindingMap);
|
||||
String result = templateEngine.getTemplate("codegen/service/service.vm").render(bindingMap);
|
||||
// String result = templateEngine.getTemplate("codegen/service/serviceImpl.vm").render(bindingMap);
|
||||
// String result = templateEngine.getTemplate("codegen/service/service.vm").render(bindingMap);
|
||||
String result = templateEngine.getTemplate("codegen/service/serviceImpl.vm").render(bindingMap);
|
||||
System.out.println(result);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user