fwq
2024-10-08 489682e2d163e104e621ce77a62925f6ce4e8a11
提交 | 用户 | age
826b66 1 package ${packageName};
C 2
3 import java.util.List;
4 import javax.annotation.Resource;
5 import org.springframework.web.bind.annotation.RequestMapping;
6 import org.springframework.web.bind.annotation.RestController;
7 import com.github.pagehelper.PageHelper;
8 import com.github.pagehelper.PageInfo;
9
10 import com.hx.common.BaseController;
11 import com.hx.mybatisTool.SqlSentence;
12 import ${DAOPackageName}.${entityName}Mapper;
13 import ${entityPackageName}.${entityName};
14 import ${servicePackageName}.${entityName}Service;
15 import com.hx.resultTool.Result;
16 import com.hx.util.SimpleTool;
17 import net.sf.json.JSONObject;
18 import com.hx.phitab.common.AuthConstants;
19
20 @RestController
21 @RequestMapping("${entityNameSmall}")
22 public class ${entityName}Controller extends BaseController {
23
24     @Resource
25     private ${entityName}Service service;
26     
27     /**列表*/
28     @Authority(tag = AuthConstants.${entityName}.SEE)
29     @RequestMapping("/list")
30     public Result listData(Integer pageNum,Integer pageSize) {
31         //pageNum当前第几页
32         //rowCount 拿几条
33
34         //分页插件
35          PageHelper.startPage(pageNum==null?1:pageNum,pageSize==null?20:pageSize);
36         SqlSentence sqlSentence = new SqlSentence();
37         List<${entityName}> ${entityNameSmall}s = service.selectList(sqlSentence);
38         PageInfo pageInfo = new PageInfo<${entityName}>(${entityNameSmall}s);
39         Map<String,Object> data = new HashMap<>();
40         data.put("pageNum",pageInfo.getPageNum());
41         data.put("pageSize",pageInfo.getPageSize());
42         data.put("total",pageInfo.getTotal());
43         data.put("isLastPage",pageInfo.isIsLastPage());
44         data.put("list",pageInfo.getList());
45         return Result.success(data);
46     }
47     
48     /**新增*/
49     @Authority(tag = AuthConstants.${entityName}.ADD)
50     @RequestMapping("/add")
51     public Result addData(${entityName} ${entityNameSmall}) {
52         service.insert(${entityNameSmall});
53         return Result.success();
54     }
55     
56     /**获取数据*/
57     @Authority(tag = AuthConstants.${entityName}.SEE)
58     @RequestMapping("/see")
59     public Result editeData(String id) {
60         ${entityName} ${entityNameSmall} = service.selectOneByKeyBlob(id);
61         return Result.success(${entityNameSmall});
62     }
63     
64     /**修改数据*/
65     @Authority(tag = AuthConstants.${entityName}.EDIT)
66     @RequestMapping("/update")
67     public Result updateData(${entityName} ${entityNameSmall}) {
68         service.updateAll(${entityNameSmall});
69         return Result.success();
70     }
71     
72     /**删除数据(单个)*/
73     @Authority(tag = AuthConstants.${entityName}.DELETE)
74     @RequestMapping("/delete/one")
75     public Result deleteData(String id) {
76         service.deleteOne(id);
77         return Result.success();
78     }
79 }