oyq28 1 anno fa
parent
commit
bf3d07e1a6

+ 7 - 3
src/main/resources/templates/service.java.ftl

@@ -1,7 +1,5 @@
 package ${package.Service};
 
-import ${superServiceClassPackage};
-import ${package.Entity}.${entity};
 
 /**
  * <p>
@@ -15,7 +13,13 @@ import ${package.Entity}.${entity};
 <#if kotlin>
 interface ${table.serviceName} : ${superServiceClass}<${entity}>
 <#else>
-public interface ${table.serviceName} extends ${superServiceClass}<${entity}> {
+public interface ${table.serviceName} extends SuperCacheService<${entity}> {
+IPage<${entity}> pageList(IPage page, LbqWrapper<${entity}> wrapper);
 
+ ${entity} save(${entity}SaveDTO data);
+
+ ${entity} update(${entity}UpdateDTO data);
+
+ Boolean delete(${entity} model);
 }
 </#if>

+ 22 - 20
src/main/resources/templates/serviceImpl.java.ftl

@@ -1,11 +1,6 @@
 package ${package.ServiceImpl};
 
 
-import ${package.Mapper}.${table.mapperName};
-import ${package.Entity}.${entity};
-import ${package.Service}.${table.serviceName};
-import ${superServiceImplClassPackage};
-
 import lombok.extern.slf4j.Slf4j;
 <#if superServiceImplClass?? && superServiceImplClass == "SuperCacheServiceImpl">
 import org.springframework.aop.framework.AopContext;
@@ -31,25 +26,32 @@ import org.springframework.stereotype.Service;
 open class ${table.serviceImplName} : ${superServiceImplClass}<${table.mapperName}, ${entity}>(), ${table.serviceName} {
 }
 <#else>
-<#if superServiceImplClass??>
-public class ${table.serviceImplName} extends ${superServiceImplClass}<${table.mapperName}, ${entity}> implements ${table.serviceName} {
-<#else>
-public class ${table.serviceImplName} {
-</#if>
-<#if superServiceImplClass?? && superServiceImplClass == "SuperCacheServiceImpl">
-    /**
-     * 建议将改变量移动到CacheKey工具类中统一管理,并在 caffeine.properties 文件中合理配置有效期
-     */
-    protected static final String ${entity?upper_case} = "${entity?lower_case}";
+public class ${table.serviceImplName} extends SuperCacheServiceImpl<${table.mapperName}, ${entity}> implements ${table.serviceName} {
+    @Override
+    public IPage<${entity}> pageList(IPage page, LbqWrapper<${entity}> wrapper) {
+        return baseMapper.pageList(page, wrapper, new DataScope());
+    }
 
     @Override
-    protected String getRegion() {
-        return ${entity?upper_case};
+    @Transactional(rollbackFor = Exception.class)
+    public ${entity} save(${entity}SaveDTO data) {
+        ${entity} model = BeanPlusUtil.toBean(data, ${entity}.class);
+        save(model);
+        return model;
     }
 
-    protected ${table.serviceName} currentProxy() {
-        return ((${table.serviceName}) AopContext.currentProxy());
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public ${entity} update(${entity}UpdateDTO data) {
+        ${entity} model = BeanPlusUtil.toBean(data, ${entity}.class);
+        updateById(model);
+        return model;
+    }
+
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public Boolean delete(${entity} model) {
+        return removeById(model);
     }
-</#if>
 }
 </#if>