forked from DeepBin/codegen
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcontrollerNg.ftl
More file actions
124 lines (113 loc) · 4.1 KB
/
controllerNg.ftl
File metadata and controls
124 lines (113 loc) · 4.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
<#import "function.ftl" as func>
<#assign package=model.variables.package>
<#assign class=model.variables.class>
<#assign system=vars.system>
<#assign comment=model.tabComment>
<#assign subtables=model.subTableList>
<#assign classVar=model.variables.classVar>
<#assign pk=func.getPk(model) >
<#assign pkVar=func.convertUnderLine(pk) >
<#assign pkType=func.getPkType(model)>
package com.sky.${system}.${package}.controller;
import javax.annotation.Resource;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;
import com.hotent.base.api.query.QueryFilter;
import com.hotent.base.core.web.RequestUtil;
import com.hotent.base.db.mybatis.domain.PageJson;
import com.hotent.base.db.mybatis.domain.PageList;
import com.sky.common.controller.BaseController;
import com.sky.${system}.${package}.persistence.manager.${class}Manager;
import com.sky.${system}.${package}.persistence.model.${class};
/**
*
* <pre>
* 描述:[${comment}]控制器类
* 构建组:x5-bpmx-platform
<#if vars.developer?exists>
* 作者:${vars.developer}
* 邮箱:${vars.email}
</#if>
* 日期:${date?string("yyyy-MM-dd HH:mm:ss")}
* 版权:${vars.company}
* </pre>
*/
@Controller
@RequestMapping("/${system}/${package}")
public class ${class}Controller extends BaseController {
@Resource
${class}Manager ${classVar}Manager;
/**
* 执行查询 ,系统自动封装查询条件
* @return ModelAndView
* @throws Exception
* @author wjg
* @Create Date 2017 下午4:33:31
*/
@RequestMapping("${classVar}List")
public ModelAndView ${classVar}List() throws Exception {
ModelAndView modelAndView = new ModelAndView("${system}/${package}/${classVar}List");//跳转的页面
QueryFilter queryFilter = getQueryFilter(getRequest());//封装查询条件
PageList<${class}> ${classVar}List = (PageList<${class}>) ${classVar}Manager.query(queryFilter);//执行查询
PageJson pageJson = new PageJson(${classVar}List);
modelAndView.addObject("pageJson", pageJson);
return modelAndView;
}
/**
* 通过ajax方式查询[${comment}]信息
* @return ${class}
* @throws Exception
* @author wjg
* @Create Date 2017 下午4:33:57
*/
@RequestMapping("get${class}Json")
public @ResponseBody ${class} get${class}Json() throws Exception {
String id = RequestUtil.getString(this.getRequest(), "id");//主键
${class} ${classVar} = ${classVar}Manager.get${class}(id);
return ${classVar};
}
/**
* 新增[${comment}]信息,跳转新增[${comment}]页面
* @return ModelAndView
* @throws Exception
* @author wjg
* @Create Date 2017 下午4:53:16
*/
@RequestMapping("add${class}")
public ModelAndView add${class}() throws Exception {
ModelAndView modelAndView = new ModelAndView("${system}/${package}/${classVar}Edit");
modelAndView.addObject("id", idGenerator.getSuid());
return modelAndView;
}
/**
* 执行新增或者更新[${comment}]信息
* @param ${classVar}
* @return ModelAndView
* @throws Exception
* @author wjg
* @Create Date 2017 下午4:54:14
*/
@RequestMapping("save${class}")
public ModelAndView saveOrUpdate(${class} ${classVar}) throws Exception {
${classVar} = ${classVar}Manager.saveOrUpdate(${classVar});
ModelAndView modelAndView = new ModelAndView("redirect:/${system}/${package}/${classVar}Result?id=" + ${classVar}.getId() );
return modelAndView;
}
/**
* 执行删除[${comment}]对象
* @return ModelAndView
* @throws Exception
* @author wjg
* @Create Date 2017 下午5:03:29
*/
@RequestMapping("do${class}Remove")
public ModelAndView do${class}Remove() throws Exception {
ModelAndView modelAndView = new ModelAndView("${system}/${package}/${classVar}Result");
String[] aryIds = RequestUtil.getStringAryByStr(this.getRequest(), "id");
${class} ${classVar} = ${classVar}Manager.doRemove(aryIds);
modelAndView.addObject("obj", ${classVar});
return modelAndView;
}
}