1 Star 2 Fork 1

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

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
Controller.cst 5.37 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 DtoPascal = GetPascal(Table.Name) +"Dto";
string DtoHump = GetHump(Table.Name) +"Dto";
string ServicePascal = GetPascal(Table.Name) +"Service";
string ServiceHump = GetHump(Table.Name) +"Service";
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 <%= WebNamespacesStr %>;
import <%= ModelNamespacesStr %>.*;
import <%= ServiceNamespacesStr %>.*;
import <%=isdubbo? "com.alibaba.dubbo.config.annotation.Reference": "javax.annotation.Resource"%>;
import com.bjcsxq.span.springmvc.extend.BaseController;
import com.bjcsxq.span.springmvc.extend.DataInfo;
import com.bjcsxq.span.springmvc.extend.ResultData;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.HashMap;
/**
* @author :框架自动生成,修改者自动补全作者
* @date :<%= DateTime.Now.ToLongDateString() %>
* @description : <%= Table.Description %>Controller
*/
@Api(value = "<%= TablePascal %>Controller", tags = {"<%= Table.Description %>接口"})
@Controller
@RequestMapping("/driver/<%= TableHump.ToLower() %>")
public class <%= TablePascal %>Controller extends BaseController {
<%=isdubbo? "@Reference": "@Resource"%>
private <%= ServicePascal %> <%= ServiceHump %>;
<%=isSelect?"":"/*" %>
@ApiOperation(value = "获取<%= Table.Description %>列表接口", httpMethod = "GET")
@ResponseBody
@RequestMapping("/get<%= TablePascal.ToLower() %>list")
public ResultData get<%= TablePascal %>List(
@RequestParam(required = false, defaultValue = "10") Integer pageSize,
@RequestParam(required = false, defaultValue = "1") Integer pageIndex
) throws Exception {
DataInfo data = <%= ServiceHump %>.get<%= TablePascal %>List(pageIndex, pageSize);
return success(data);
}
@ApiOperation(value = "获取<%= Table.Description %>接口", httpMethod = "GET")
@ApiImplicitParams({
@ApiImplicitParam(name = "<%=Primary.Name%>", value = "<%=Primary.ExtendedProperties["CS_Description"].Value%>", required = true, dataType = "<%=GetDataType(Primary.DataType)%>")
})
@RequestMapping("/get<%= TablePascal.ToLower() %>")
@ResponseBody
public ResultData get<%= TablePascal %>Info(
@RequestParam(required = false, defaultValue = "") <%=GetDataType(Primary.DataType) + ' ' +Primary.Name%>
) throws Exception {
<%=DtoPascal%> <%=DtoHump%> = <%= ServiceHump %>.get<%= TablePascal %>(<%=Primary.Name%>);
return success(<%=DtoHump%>);
}
<%=isSelect?"":"*/" %>
<%=IsInsert?"":"/*" %>
@ApiOperation(value = "添加<%= Table.Description %>接口", httpMethod = "POST")
@RequestMapping("/insert<%= TablePascal.ToLower() %>")
@ResponseBody
public ResultData insert<%= TablePascal %>(
<%=DtoPascal%> <%=DtoHump%>
) throws Exception {
boolean result = <%= ServiceHump %>.insert<%= TablePascal %>(<%=DtoHump%>);
return result ? success("", "添加成功") : fail("", "添加失败");
}
<%=IsInsert?"":"*/" %>
<%=IsUpdate?"":"/*" %>
@ApiOperation(value = "修改<%= Table.Description %>接口", httpMethod = "POST")
@RequestMapping("/update<%= TablePascal.ToLower() %>")
@ResponseBody
public ResultData update<%= TablePascal %>(
<%=DtoPascal%> <%=DtoHump%>
) throws Exception {
boolean result = <%= ServiceHump %>.update<%= TablePascal %>(<%=DtoHump%>);
return result ? success("", "修改成功") : fail("", "修改失败");
}
<%=IsUpdate?"":"*/" %>
<%=IsDelete?"":"/*" %>
@ApiOperation(value = "删除<%= Table.Description %>接口", httpMethod = "GET")
@ApiImplicitParams({
@ApiImplicitParam(name = "<%=Primary.Name%>", value = "<%=Primary.ExtendedProperties["CS_Description"].Value%>", required = true, dataType = "<%=GetDataType(Primary.DataType)%>")
})
@RequestMapping("/delete<%= TablePascal.ToLower() %>")
@ResponseBody
public ResultData delete<%= TablePascal %>(
@RequestParam(required = false, defaultValue = "") <%=GetDataType(Primary.DataType) + ' ' +Primary.Name%>
) throws Exception {
boolean result = <%= ServiceHump %>.delete<%= TablePascal %>(<%=Primary.Name%>);
return result ? success("", "删除成功") : fail("", "删除失败");
}
<%=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

搜索帮助