1 Star 2 Fork 1

我被自己帅瞎了! / codesmith-java代码模板

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
ServiceImpl.cst 3.82 KB
一键复制 编辑 原始数据 按行查看 历史
我被自己帅瞎了! 提交于 2021-02-08 14:25 . 第一次提交
<%@ CodeTemplate Inherits="CodeTemplate" Language="C#" TargetLanguage="Java" Description="NetTiers main template." Debug="True" ResponseEncoding="UTF-8"%>
<%@ Assembly Name="SchemaExplorer"%>
<%@ Import Namespace="SchemaExplorer"%>
<%@ Property Name="Table" Type="TableSchema" DeepLoad="True" Optional="False" Category="01. Getting Started - Required" Description=""%>
<!-- #include file="Common/Common.cst" -->
<%
string TablePascal = GetPascal(Table.Name);
string TableHump = GetHump(Table.Name);
string DaoPascal = GetPascal(Table.Name) +"Dao";
string DaoHump = GetHump(Table.Name) +"Dao";
string DtoPascal = GetPascal(Table.Name) +"Dto";
string DtoHump = GetHump(Table.Name) +"Dto";
var Primary = Table.PrimaryKey.MemberColumns[0];
string [] Methods = GetMethods(Table.Name);
bool isSelect = Methods.Contains("select");
bool IsUpdate = Methods.Contains("update");
bool IsInsert = Methods.Contains("insert");
bool IsDelete = Methods.Contains("delete");
%>
package <%= ServiceImplNamespacesStr %>;
import <%= ServiceNamespacesStr %>.*;
import <%= DaoNamespacesStr %>.*;
import com.bjcsxq.span.springmvc.extend.DataInfo;
import <%= ModelNamespacesStr %>.*;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import <%=isdubbo?"com.alibaba.dubbo.config.annotation.Service":"org.springframework.stereotype.Service" %>;
import java.util.HashMap;
/**
* @author :框架自动生成,修改者自动补全作者
* @date :<%= DateTime.Now.ToLongDateString() %>
* @description : <%= Table.Description %>ServiceImpl
*/
@Service
public class <%= TablePascal %>ServiceImpl implements <%= TablePascal %>Service{
@Autowired
private <%= DaoPascal %> <%= DaoHump %>;
/**
* 获取列表
* @param param
* @return
*/ <%=isSelect?"":"/*" %>
@Override
public DataInfo get<%= TablePascal %>List(int pageIndex, int pageSize) throws Exception{
Page<<%= DtoPascal %>> page = PageHelper.startPage(pageIndex, pageSize);
<%= DaoHump %>.get<%= TablePascal %>List(param);
PageInfo<<%= DtoPascal %>> info = new PageInfo<>(page);
DataInfo data = new DataInfo();
data.setTotal((int) info.getTotal());
data.setResult(page);
return data;
}
<%=isSelect?"":"*/" %>
/**
* 获取信息
* @param <%=Primary.Name%>
* @return
*/ <%=isSelect?"":"/*" %>
@Override
public <%= DtoPascal %> get<%= TablePascal %>(<%=GetDataType(Primary.DataType) + ' ' +Primary.Name%>) throws Exception{
<%= DtoPascal %> <%= DtoHump %> = <%= DaoHump %>.get<%= TablePascal %>(<%=Primary.Name%>);
if (<%= DaoHump %> == null) {
throw new Exception("未查询到信息");
}
return <%= DtoHump %>;
}
<%=isSelect?"":"*/" %>
/**
*修改
* @param <%= DtoHump %>
* @return
*/ <%=IsUpdate?"":"/*" %>
@Override
public boolean update<%= TablePascal %>(<%= DtoPascal %> <%= DtoHump %>) throws Exception{
return <%= DaoHump %>.update<%= TablePascal %>(<%= DtoHump %>) > 0;
}
<%=IsUpdate?"":"*/" %>
/**
* 插入
* @param <%= DtoHump %>
* @return
*/ <%=IsInsert?"":"/*" %>
@Override
public boolean insert<%= TablePascal %>(<%= DtoPascal %> <%= DtoHump %>) throws Exception{
return <%= DaoHump %>.insert<%= TablePascal %>(<%= DtoHump %>) > 0;
}
<%=IsInsert?"":"*/" %>
/**
* 删除
* @param <%=Primary.Name%>
* @return
*/ <%=IsDelete?"":"/*" %>
@Override
public boolean delete<%= TablePascal %>(<%=GetDataType(Primary.DataType) + ' ' +Primary.Name%>) throws Exception{
return <%= DaoHump %>.delete<%= TablePascal %>(<%=Primary.Name%>) > 0;
}
<%=IsDelete?"":"*/" %>
}
其他
1
https://gitee.com/momentzhj/codesmith-java-code-template.git
git@gitee.com:momentzhj/codesmith-java-code-template.git
momentzhj
codesmith-java-code-template
codesmith-java代码模板
master

搜索帮助