正在显示
6 个修改的文件
包含
156 行增加
和
16 行删除
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,7 +13,9 @@ public interface DataPermissionDao { | @@ -11,7 +13,9 @@ 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); |
| 17 | -} | ||
| 21 | +} |
| 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 | +} |
| @@ -22,32 +22,37 @@ | @@ -22,32 +22,37 @@ | ||
| 22 | <result column="perm_type" jdbcType="VARCHAR" property="perm_type" /> | 22 | <result column="perm_type" jdbcType="VARCHAR" property="perm_type" /> |
| 23 | </resultMap> | 23 | </resultMap> |
| 24 | <sql id="Base_Column_List"> | 24 | <sql id="Base_Column_List"> |
| 25 | - data_perm_id, perm_name, perm_des, perm_sort, perm_status, create_time, update_time, | ||
| 26 | - create_user, row_condition, row_condition_property, cols_list, permission_id, `path`, | 25 | + data_perm_id, perm_name, perm_des, perm_sort, perm_status, create_time, update_time, |
| 26 | + create_user, row_condition, row_condition_property, cols_list, permission_id, `path`, | ||
| 27 | interface_name, service_name, service_name_des, perm_keyword, perm_type | 27 | interface_name, service_name, service_name_des, perm_keyword, perm_type |
| 28 | </sql> | 28 | </sql> |
| 29 | <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap"> | 29 | <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap"> |
| 30 | - select | 30 | + select |
| 31 | <include refid="Base_Column_List" /> | 31 | <include refid="Base_Column_List" /> |
| 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} |
| 38 | </delete> | 43 | </delete> |
| 39 | <insert id="insert" keyColumn="data_perm_id" keyProperty="data_perm_id" parameterType="com.tianbo.warehouse.model.DataPermission" useGeneratedKeys="true"> | 44 | <insert id="insert" keyColumn="data_perm_id" keyProperty="data_perm_id" parameterType="com.tianbo.warehouse.model.DataPermission" useGeneratedKeys="true"> |
| 40 | - insert into data_permission (perm_name, perm_des, perm_sort, | ||
| 41 | - perm_status, create_time, update_time, | ||
| 42 | - create_user, row_condition, row_condition_property, | ||
| 43 | - cols_list, permission_id, `path`, | ||
| 44 | - interface_name, service_name, service_name_des, | 45 | + insert into data_permission (perm_name, perm_des, perm_sort, |
| 46 | + perm_status, create_time, update_time, | ||
| 47 | + create_user, row_condition, row_condition_property, | ||
| 48 | + cols_list, permission_id, `path`, | ||
| 49 | + interface_name, service_name, service_name_des, | ||
| 45 | perm_keyword, perm_type) | 50 | perm_keyword, perm_type) |
| 46 | - values (#{perm_name,jdbcType=VARCHAR}, #{perm_des,jdbcType=VARCHAR}, #{perm_sort,jdbcType=TINYINT}, | ||
| 47 | - #{perm_status,jdbcType=BOOLEAN}, #{create_time,jdbcType=TIMESTAMP}, #{update_time,jdbcType=TIMESTAMP}, | ||
| 48 | - #{create_user,jdbcType=VARCHAR}, #{row_condition,jdbcType=VARCHAR}, #{row_condition_property,jdbcType=VARCHAR}, | ||
| 49 | - #{cols_list,jdbcType=VARCHAR}, #{permission_id,jdbcType=INTEGER}, #{path,jdbcType=VARCHAR}, | ||
| 50 | - #{interface_name,jdbcType=VARCHAR}, #{service_name,jdbcType=VARCHAR}, #{service_name_des,jdbcType=VARCHAR}, | 51 | + values (#{perm_name,jdbcType=VARCHAR}, #{perm_des,jdbcType=VARCHAR}, #{perm_sort,jdbcType=TINYINT}, |
| 52 | + #{perm_status,jdbcType=BOOLEAN}, #{create_time,jdbcType=TIMESTAMP}, #{update_time,jdbcType=TIMESTAMP}, | ||
| 53 | + #{create_user,jdbcType=VARCHAR}, #{row_condition,jdbcType=VARCHAR}, #{row_condition_property,jdbcType=VARCHAR}, | ||
| 54 | + #{cols_list,jdbcType=VARCHAR}, #{permission_id,jdbcType=INTEGER}, #{path,jdbcType=VARCHAR}, | ||
| 55 | + #{interface_name,jdbcType=VARCHAR}, #{service_name,jdbcType=VARCHAR}, #{service_name_des,jdbcType=VARCHAR}, | ||
| 51 | #{perm_keyword,jdbcType=VARCHAR}, #{perm_type,jdbcType=VARCHAR}) | 56 | #{perm_keyword,jdbcType=VARCHAR}, #{perm_type,jdbcType=VARCHAR}) |
| 52 | </insert> | 57 | </insert> |
| 53 | <insert id="insertSelective" keyColumn="data_perm_id" keyProperty="data_perm_id" parameterType="com.tianbo.warehouse.model.DataPermission" useGeneratedKeys="true"> | 58 | <insert id="insertSelective" keyColumn="data_perm_id" keyProperty="data_perm_id" parameterType="com.tianbo.warehouse.model.DataPermission" useGeneratedKeys="true"> |
| @@ -237,4 +242,4 @@ | @@ -237,4 +242,4 @@ | ||
| 237 | perm_type = #{perm_type,jdbcType=VARCHAR} | 242 | perm_type = #{perm_type,jdbcType=VARCHAR} |
| 238 | where data_perm_id = #{data_perm_id,jdbcType=INTEGER} | 243 | where data_perm_id = #{data_perm_id,jdbcType=INTEGER} |
| 239 | </update> | 244 | </update> |
| 240 | -</mapper> | ||
| 245 | +</mapper> |
-
请 注册 或 登录 后发表评论