正在显示
6 个修改的文件
包含
141 行增加
和
1 行删除
CHANGELOG
0 → 100644
1 | +package com.tianbo.warehouse.controller; | ||
2 | + | ||
3 | +import com.github.pagehelper.PageInfo; | ||
4 | +import com.tianbo.warehouse.controller.response.ResultJson; | ||
5 | +import com.tianbo.warehouse.model.DataPermission; | ||
6 | +import com.tianbo.warehouse.service.DataPermissionService; | ||
7 | +import org.springframework.beans.factory.annotation.Autowired; | ||
8 | +import org.springframework.web.bind.annotation.*; | ||
9 | + | ||
10 | +@RestController | ||
11 | +@RequestMapping("/dataPermission") | ||
12 | +public class DataPermissionController { | ||
13 | + | ||
14 | + @Autowired | ||
15 | + private DataPermissionService dataPermissionService; | ||
16 | + | ||
17 | + @GetMapping("/{data_perm_id}") | ||
18 | + public ResultJson<DataPermission> getDataPermission(@PathVariable("data_perm_id") Integer dataPermId) { | ||
19 | + DataPermission dataPermission = dataPermissionService.selectByPrimaryKey(dataPermId); | ||
20 | + return new ResultJson("200","查询数据权限成功",dataPermission); | ||
21 | + } | ||
22 | + | ||
23 | + @PostMapping("/create") | ||
24 | + public ResultJson<Integer> createDataPermission(@RequestBody DataPermission dataPermission) { | ||
25 | + int i= dataPermissionService.insertSelective(dataPermission); | ||
26 | + return i==1 ? new ResultJson("200","新增数据权限成功") :new ResultJson("500","新增数据权限失败"); | ||
27 | + } | ||
28 | + | ||
29 | + @PostMapping("/update") | ||
30 | + public ResultJson<Integer> updateDataPermission(@RequestBody DataPermission dataPermission) { | ||
31 | + int i = dataPermissionService.updateByPrimaryKeySelective(dataPermission); | ||
32 | + return i==1 ? new ResultJson("200","更新数据权限成功") :new ResultJson("500","更新数据权限失败"); | ||
33 | + } | ||
34 | + | ||
35 | + @PostMapping("/del/{data_perm_id}") | ||
36 | + public ResultJson<Integer> deleteDataPermission(@PathVariable("data_perm_id") Integer dataPermId) { | ||
37 | + int i = dataPermissionService.deleteByPrimaryKey(dataPermId); | ||
38 | + return i==1 ? new ResultJson("200","删除数据权限成功") :new ResultJson("500","删除数据权限失败"); | ||
39 | + } | ||
40 | + | ||
41 | + @GetMapping("/list") | ||
42 | + public ResultJson<PageInfo> getAllDataPermissions(@RequestParam(defaultValue = "1") int pageNum, | ||
43 | + @RequestParam(defaultValue = "10") int pageSize) { | ||
44 | + PageInfo<DataPermission> dataPermissionPageInfo = dataPermissionService.selectAll(pageNum, pageSize); | ||
45 | + return new ResultJson<PageInfo>("200","获取数据权限成功",dataPermissionPageInfo); | ||
46 | + } | ||
47 | +} |
@@ -2,6 +2,8 @@ package com.tianbo.warehouse.dao; | @@ -2,6 +2,8 @@ package com.tianbo.warehouse.dao; | ||
2 | 2 | ||
3 | import com.tianbo.warehouse.model.DataPermission; | 3 | import com.tianbo.warehouse.model.DataPermission; |
4 | 4 | ||
5 | +import java.util.List; | ||
6 | + | ||
5 | public interface DataPermissionDao { | 7 | public interface DataPermissionDao { |
6 | int deleteByPrimaryKey(Integer data_perm_id); | 8 | int deleteByPrimaryKey(Integer data_perm_id); |
7 | 9 | ||
@@ -11,6 +13,8 @@ public interface DataPermissionDao { | @@ -11,6 +13,8 @@ public interface DataPermissionDao { | ||
11 | 13 | ||
12 | DataPermission selectByPrimaryKey(Integer data_perm_id); | 14 | DataPermission selectByPrimaryKey(Integer data_perm_id); |
13 | 15 | ||
16 | + List<DataPermission> selectAll(); | ||
17 | + | ||
14 | int updateByPrimaryKeySelective(DataPermission record); | 18 | int updateByPrimaryKeySelective(DataPermission record); |
15 | 19 | ||
16 | int updateByPrimaryKey(DataPermission record); | 20 | int updateByPrimaryKey(DataPermission record); |
1 | package com.tianbo.warehouse.service; | 1 | package com.tianbo.warehouse.service; |
2 | +import com.github.pagehelper.PageInfo; | ||
3 | +import com.tianbo.warehouse.model.DataPermission; | ||
2 | 4 | ||
3 | public interface DataPermissionService { | 5 | public interface DataPermissionService { |
4 | 6 | ||
5 | - Boolean getPermission(String token,String url,String name); | 7 | + int deleteByPrimaryKey(Integer data_perm_id); |
8 | + | ||
9 | + int insert(DataPermission record); | ||
10 | + | ||
11 | + int insertSelective(DataPermission record); | ||
12 | + | ||
13 | + DataPermission selectByPrimaryKey(Integer data_perm_id); | ||
14 | + | ||
15 | + PageInfo<DataPermission> selectAll(int pageNum,int pageSize); | ||
16 | + | ||
17 | + int updateByPrimaryKeySelective(DataPermission record); | ||
18 | + | ||
19 | + int updateByPrimaryKey(DataPermission record); | ||
6 | } | 20 | } |
1 | +package com.tianbo.warehouse.service.imp; | ||
2 | + | ||
3 | +import com.github.pagehelper.Page; | ||
4 | +import com.github.pagehelper.PageHelper; | ||
5 | +import com.github.pagehelper.PageInfo; | ||
6 | +import com.tianbo.warehouse.dao.DataPermissionDao; | ||
7 | +import com.tianbo.warehouse.model.DataPermission; | ||
8 | +import com.tianbo.warehouse.model.ROLE; | ||
9 | +import com.tianbo.warehouse.model.USERS; | ||
10 | +import com.tianbo.warehouse.service.DataPermissionService; | ||
11 | +import org.springframework.stereotype.Service; | ||
12 | + | ||
13 | +import javax.annotation.Resource; | ||
14 | +import java.util.List; | ||
15 | + | ||
16 | +@Service | ||
17 | +public class DataPermissionServiceImpl implements DataPermissionService { | ||
18 | + | ||
19 | + | ||
20 | + @Resource | ||
21 | + DataPermissionDao dataPermissionDao; | ||
22 | + @Override | ||
23 | + public int deleteByPrimaryKey(Integer data_perm_id) { | ||
24 | + return dataPermissionDao.deleteByPrimaryKey(data_perm_id); | ||
25 | + } | ||
26 | + | ||
27 | + @Override | ||
28 | + public int insert(DataPermission record) { | ||
29 | + return dataPermissionDao.insert(record); | ||
30 | + } | ||
31 | + | ||
32 | + @Override | ||
33 | + public int insertSelective(DataPermission record) { | ||
34 | + return dataPermissionDao.insertSelective(record); | ||
35 | + } | ||
36 | + | ||
37 | + @Override | ||
38 | + public DataPermission selectByPrimaryKey(Integer data_perm_id) { | ||
39 | + return dataPermissionDao.selectByPrimaryKey(data_perm_id); | ||
40 | + } | ||
41 | + | ||
42 | + @Override | ||
43 | + public PageInfo<DataPermission> selectAll(int pageNum,int pageSize) { | ||
44 | + Page<DataPermission> page = PageHelper.startPage(pageNum,pageSize); | ||
45 | + List<DataPermission> list = dataPermissionDao.selectAll(); | ||
46 | + PageInfo<DataPermission> result = new PageInfo<DataPermission>(list); | ||
47 | + return result; | ||
48 | + } | ||
49 | + | ||
50 | + @Override | ||
51 | + public int updateByPrimaryKeySelective(DataPermission record) { | ||
52 | + return dataPermissionDao.updateByPrimaryKeySelective(record); | ||
53 | + } | ||
54 | + | ||
55 | + @Override | ||
56 | + public int updateByPrimaryKey(DataPermission record) { | ||
57 | + return 0; | ||
58 | + } | ||
59 | +} |
@@ -32,6 +32,11 @@ | @@ -32,6 +32,11 @@ | ||
32 | from data_permission | 32 | from data_permission |
33 | where data_perm_id = #{data_perm_id,jdbcType=INTEGER} | 33 | where data_perm_id = #{data_perm_id,jdbcType=INTEGER} |
34 | </select> | 34 | </select> |
35 | + <select id="selectAll" parameterType="java.lang.Integer" resultMap="BaseResultMap"> | ||
36 | + select | ||
37 | + <include refid="Base_Column_List" /> | ||
38 | + from data_permission | ||
39 | + </select> | ||
35 | <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer"> | 40 | <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer"> |
36 | delete from data_permission | 41 | delete from data_permission |
37 | where data_perm_id = #{data_perm_id,jdbcType=INTEGER} | 42 | where data_perm_id = #{data_perm_id,jdbcType=INTEGER} |
-
请 注册 或 登录 后发表评论