chenjiahe
2024-09-23 826b66207dafbce24f441cb83fed1b241a6fba27
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
package ${packageName};
 
import java.util.List;
import javax.annotation.Resource;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
 
import com.hx.common.BaseController;
import com.hx.mybatisTool.SqlSentence;
import ${DAOPackageName}.${entityName}Mapper;
import ${entityPackageName}.${entityName};
import ${servicePackageName}.${entityName}Service;
import com.hx.resultTool.Result;
import com.hx.util.SimpleTool;
import net.sf.json.JSONObject;
import com.hx.phitab.common.AuthConstants;
 
@RestController
@RequestMapping("${entityNameSmall}")
public class ${entityName}Controller extends BaseController {
 
    @Resource
    private ${entityName}Service service;
    
    /**列表*/
    @Authority(tag = AuthConstants.${entityName}.SEE)
    @RequestMapping("/list")
    public Result listData(Integer pageNum,Integer pageSize) {
        //pageNum当前第几页
        //rowCount 拿几条
 
        //分页插件
         PageHelper.startPage(pageNum==null?1:pageNum,pageSize==null?20:pageSize);
        SqlSentence sqlSentence = new SqlSentence();
        List<${entityName}> ${entityNameSmall}s = service.selectList(sqlSentence);
        PageInfo pageInfo = new PageInfo<${entityName}>(${entityNameSmall}s);
        Map<String,Object> data = new HashMap<>();
        data.put("pageNum",pageInfo.getPageNum());
        data.put("pageSize",pageInfo.getPageSize());
        data.put("total",pageInfo.getTotal());
        data.put("isLastPage",pageInfo.isIsLastPage());
        data.put("list",pageInfo.getList());
        return Result.success(data);
    }
    
    /**新增*/
    @Authority(tag = AuthConstants.${entityName}.ADD)
    @RequestMapping("/add")
    public Result addData(${entityName} ${entityNameSmall}) {
        service.insert(${entityNameSmall});
        return Result.success();
    }
    
    /**获取数据*/
    @Authority(tag = AuthConstants.${entityName}.SEE)
    @RequestMapping("/see")
    public Result editeData(String id) {
        ${entityName} ${entityNameSmall} = service.selectOneByKeyBlob(id);
        return Result.success(${entityNameSmall});
    }
    
    /**修改数据*/
    @Authority(tag = AuthConstants.${entityName}.EDIT)
    @RequestMapping("/update")
    public Result updateData(${entityName} ${entityNameSmall}) {
        service.updateAll(${entityNameSmall});
        return Result.success();
    }
    
    /**删除数据(单个)*/
    @Authority(tag = AuthConstants.${entityName}.DELETE)
    @RequestMapping("/delete/one")
    public Result deleteData(String id) {
        service.deleteOne(id);
        return Result.success();
    }
}