Forráskód Böngészése

新增权限数据

Administrator 4 éve
szülő
commit
ac7813babf

+ 1 - 1
boman-modules/boman-gen/src/main/java/com/boman/gen/controller/GenController.java

@@ -166,7 +166,7 @@ public class GenController extends BaseController {
     /**
      * 生成代码(下载方式)
      */
-    @PreAuthorize(hasPermi = "tool:gen:code")
+    //@PreAuthorize(hasPermi = "tool:gen:code")
     @Log(title = "代码生成" , businessType = BusinessType.GENCODE)
     @GetMapping("/download/{tableName}")
     public void download(HttpServletResponse response, @PathVariable("tableName") String tableName) throws IOException {

+ 107 - 0
boman-modules/boman-system/src/main/java/com/boman/system/controller/SysRoleDataController.java

@@ -0,0 +1,107 @@
+package com.boman.system.controller;
+
+import java.util.List;
+import java.io.IOException;
+import javax.servlet.http.HttpServletResponse;
+
+import com.boman.common.core.utils.poi.ExcelUtil;
+import com.boman.common.core.web.controller.BaseController;
+import com.boman.common.core.web.domain.AjaxResult;
+import com.boman.common.core.web.page.TableDataInfo;
+import com.boman.common.log.annotation.Log;
+import com.boman.common.log.enums.BusinessType;
+import com.boman.common.security.annotation.PreAuthorize;
+import com.boman.system.service.ISysRoleDataService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.PutMapping;
+import org.springframework.web.bind.annotation.DeleteMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+import com.boman.system.domain.SysRoleData;
+
+
+/**
+ * 角色权限数据Controller
+ * 
+ * @author ruoyi
+ * @date 2021-04-26
+ */
+@RestController
+@RequestMapping("/roleData")
+public class SysRoleDataController extends BaseController
+{
+    @Autowired
+    private ISysRoleDataService sysRoleDataService;
+
+    /**
+     * 查询角色权限数据列表
+     */
+    //@PreAuthorize(hasPermi = "system:data:list")
+    @GetMapping("/list")
+    public TableDataInfo list(SysRoleData roleData)
+    {
+        startPage();
+        List<SysRoleData> list = sysRoleDataService.selectSysRoleDataList(roleData);
+        return getDataTable(list);
+    }
+
+    /**
+     * 导出角色权限数据列表
+     */
+    @PreAuthorize(hasPermi = "system:data:export")
+    @Log(title = "角色权限数据", businessType = BusinessType.EXPORT)
+    @PostMapping("/export")
+    public void export(HttpServletResponse response, SysRoleData sysRoleData) throws IOException
+    {
+        List<SysRoleData> list = sysRoleDataService.selectSysRoleDataList(sysRoleData);
+        ExcelUtil<SysRoleData> util = new ExcelUtil<SysRoleData>(SysRoleData.class);
+        util.exportExcel(response, list, "data");
+    }
+
+    /**
+     * 获取角色权限数据详细信息
+     */
+    @PreAuthorize(hasPermi = "system:data:query")
+    @GetMapping(value = "/{id}")
+    public AjaxResult getInfo(@PathVariable("id") Long id)
+    {
+        return AjaxResult.success(sysRoleDataService.selectSysRoleDataById(id));
+    }
+
+    /**
+     * 新增角色权限数据
+     */
+    @PreAuthorize(hasPermi = "system:data:add")
+    @Log(title = "角色权限数据", businessType = BusinessType.INSERT)
+    @PostMapping
+    public AjaxResult add(@RequestBody SysRoleData sysRoleData)
+    {
+        return toAjax(sysRoleDataService.insertSysRoleData(sysRoleData));
+    }
+
+    /**
+     * 修改角色权限数据
+     */
+    @PreAuthorize(hasPermi = "system:data:edit")
+    @Log(title = "角色权限数据", businessType = BusinessType.UPDATE)
+    @PutMapping
+    public AjaxResult edit(@RequestBody SysRoleData sysRoleData)
+    {
+        return toAjax(sysRoleDataService.updateSysRoleData(sysRoleData));
+    }
+
+    /**
+     * 删除角色权限数据
+     */
+    @PreAuthorize(hasPermi = "system:data:remove")
+    @Log(title = "角色权限数据", businessType = BusinessType.DELETE)
+	@DeleteMapping("/{ids}")
+    public AjaxResult remove(@PathVariable Long[] ids)
+    {
+        return toAjax(sysRoleDataService.deleteSysRoleDataByIds(ids));
+    }
+}

+ 175 - 0
boman-modules/boman-system/src/main/java/com/boman/system/domain/SysRoleData.java

@@ -0,0 +1,175 @@
+package com.boman.system.domain;
+
+import com.boman.common.core.web.domain.BaseEntity;
+import java.util.Date;
+
+/**
+ * 角色权限数据对象 sys_role_data
+ * 
+ * @author ruoyi
+ * @date 2021-04-26
+ */
+public class SysRoleData extends BaseEntity
+{
+    private static final long serialVersionUID = 1L;
+
+    /** 角色权限id */
+    private Long id;
+
+    /** 角色id */
+    private Long roleId;
+
+    private String roleName;
+
+    /** 显示顺序 */
+    private Integer roleSort;
+
+    /** 权限表单 */
+    private String tableName;
+
+    /** 数据过滤(字典表)(1:全部数据权限 2:自定数据权限 3:本部门数据权限 4:本部门及以下数据权限) */
+    private String dataScope;
+
+    /** 是否可用(Y是) */
+    private String isUse;
+
+    /** 是否删除(Y是) */
+    private String isDel;
+
+    /** 创建者 */
+    private String createBy;
+
+    /** 创建时间 */
+    private Date createTime;
+
+    /** 更新者 */
+    private String updateBy;
+
+    /** 更新时间 */
+    private Date updateTime;
+
+    /** 备注 */
+    private String remark;
+
+    public String getRoleName() {
+        return roleName;
+    }
+
+    public void setRoleName(String roleName) {
+        this.roleName = roleName;
+    }
+
+    public void setId(Long id)
+    {
+        this.id = id;
+    }
+
+    public Long getId() 
+    {
+        return id;
+    }
+    public void setRoleId(Long roleId) 
+    {
+        this.roleId = roleId;
+    }
+
+    public Long getRoleId() 
+    {
+        return roleId;
+    }
+    public void setRoleSort(Integer roleSort) 
+    {
+        this.roleSort = roleSort;
+    }
+
+    public Integer getRoleSort() 
+    {
+        return roleSort;
+    }
+    public void setTableName(String tableName) 
+    {
+        this.tableName = tableName;
+    }
+
+    public String getTableName() 
+    {
+        return tableName;
+    }
+    public void setDataScope(String dataScope) 
+    {
+        this.dataScope = dataScope;
+    }
+
+    public String getDataScope() 
+    {
+        return dataScope;
+    }
+    public void setIsUse(String isUse) 
+    {
+        this.isUse = isUse;
+    }
+
+    public String getIsUse() 
+    {
+        return isUse;
+    }
+    public void setIsDel(String isDel) 
+    {
+        this.isDel = isDel;
+    }
+
+    public String getIsDel() 
+    {
+        return isDel;
+    }
+
+    @Override
+    public String getCreateBy() {
+        return createBy;
+    }
+
+    @Override
+    public void setCreateBy(String createBy) {
+        this.createBy = createBy;
+    }
+
+    @Override
+    public Date getCreateTime() {
+        return createTime;
+    }
+
+    @Override
+    public void setCreateTime(Date createTime) {
+        this.createTime = createTime;
+    }
+
+    @Override
+    public String getUpdateBy() {
+        return updateBy;
+    }
+
+    @Override
+    public void setUpdateBy(String updateBy) {
+        this.updateBy = updateBy;
+    }
+
+    @Override
+    public Date getUpdateTime() {
+        return updateTime;
+    }
+
+    @Override
+    public void setUpdateTime(Date updateTime) {
+        this.updateTime = updateTime;
+    }
+
+    @Override
+    public String getRemark() {
+        return remark;
+    }
+
+    @Override
+    public void setRemark(String remark) {
+        this.remark = remark;
+    }
+}

+ 61 - 0
boman-modules/boman-system/src/main/java/com/boman/system/mapper/SysRoleDataMapper.java

@@ -0,0 +1,61 @@
+package com.boman.system.mapper;
+
+import java.util.List;
+import com.boman.system.domain.SysRoleData;
+
+/**
+ * 角色权限数据Mapper接口
+ * 
+ * @author ruoyi
+ * @date 2021-04-26
+ */
+public interface SysRoleDataMapper 
+{
+    /**
+     * 查询角色权限数据
+     * 
+     * @param id 角色权限数据ID
+     * @return 角色权限数据
+     */
+    public SysRoleData selectSysRoleDataById(Long id);
+
+    /**
+     * 查询角色权限数据列表
+     * 
+     * @param sysRoleData 角色权限数据
+     * @return 角色权限数据集合
+     */
+    public List<SysRoleData> selectSysRoleDataList(SysRoleData sysRoleData);
+
+    /**
+     * 新增角色权限数据
+     * 
+     * @param sysRoleData 角色权限数据
+     * @return 结果
+     */
+    public int insertSysRoleData(SysRoleData sysRoleData);
+
+    /**
+     * 修改角色权限数据
+     * 
+     * @param sysRoleData 角色权限数据
+     * @return 结果
+     */
+    public int updateSysRoleData(SysRoleData sysRoleData);
+
+    /**
+     * 删除角色权限数据
+     * 
+     * @param id 角色权限数据ID
+     * @return 结果
+     */
+    public int deleteSysRoleDataById(Long id);
+
+    /**
+     * 批量删除角色权限数据
+     * 
+     * @param ids 需要删除的数据ID
+     * @return 结果
+     */
+    public int deleteSysRoleDataByIds(Long[] ids);
+}

+ 61 - 0
boman-modules/boman-system/src/main/java/com/boman/system/service/ISysRoleDataService.java

@@ -0,0 +1,61 @@
+package com.boman.system.service;
+
+import java.util.List;
+import com.boman.system.domain.SysRoleData;
+
+/**
+ * 角色权限数据Service接口
+ * 
+ * @author ruoyi
+ * @date 2021-04-26
+ */
+public interface ISysRoleDataService 
+{
+    /**
+     * 查询角色权限数据
+     * 
+     * @param id 角色权限数据ID
+     * @return 角色权限数据
+     */
+    public SysRoleData selectSysRoleDataById(Long id);
+
+    /**
+     * 查询角色权限数据列表
+     * 
+     * @param sysRoleData 角色权限数据
+     * @return 角色权限数据集合
+     */
+    public List<SysRoleData> selectSysRoleDataList(SysRoleData sysRoleData);
+
+    /**
+     * 新增角色权限数据
+     * 
+     * @param sysRoleData 角色权限数据
+     * @return 结果
+     */
+    public int insertSysRoleData(SysRoleData sysRoleData);
+
+    /**
+     * 修改角色权限数据
+     * 
+     * @param sysRoleData 角色权限数据
+     * @return 结果
+     */
+    public int updateSysRoleData(SysRoleData sysRoleData);
+
+    /**
+     * 批量删除角色权限数据
+     * 
+     * @param ids 需要删除的角色权限数据ID
+     * @return 结果
+     */
+    public int deleteSysRoleDataByIds(Long[] ids);
+
+    /**
+     * 删除角色权限数据信息
+     * 
+     * @param id 角色权限数据ID
+     * @return 结果
+     */
+    public int deleteSysRoleDataById(Long id);
+}

+ 97 - 0
boman-modules/boman-system/src/main/java/com/boman/system/service/impl/SysRoleDataServiceImpl.java

@@ -0,0 +1,97 @@
+package com.boman.system.service.impl;
+
+import java.util.List;
+
+import com.boman.common.core.utils.DateUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import com.boman.system.mapper.SysRoleDataMapper;
+import com.boman.system.domain.SysRoleData;
+import com.boman.system.service.ISysRoleDataService;
+
+/**
+ * 角色权限数据Service业务层处理
+ * 
+ * @author ruoyi
+ * @date 2021-04-26
+ */
+@Service
+public class SysRoleDataServiceImpl implements ISysRoleDataService 
+{
+    @Autowired
+    private SysRoleDataMapper sysRoleDataMapper;
+
+    /**
+     * 查询角色权限数据
+     * 
+     * @param id 角色权限数据ID
+     * @return 角色权限数据
+     */
+    @Override
+    public SysRoleData selectSysRoleDataById(Long id)
+    {
+        return sysRoleDataMapper.selectSysRoleDataById(id);
+    }
+
+    /**
+     * 查询角色权限数据列表
+     * 
+     * @param sysRoleData 角色权限数据
+     * @return 角色权限数据
+     */
+    @Override
+    public List<SysRoleData> selectSysRoleDataList(SysRoleData sysRoleData)
+    {
+        return sysRoleDataMapper.selectSysRoleDataList(sysRoleData);
+    }
+
+    /**
+     * 新增角色权限数据
+     * 
+     * @param sysRoleData 角色权限数据
+     * @return 结果
+     */
+    @Override
+    public int insertSysRoleData(SysRoleData sysRoleData)
+    {
+        sysRoleData.setCreateTime(DateUtils.getNowDate());
+        return sysRoleDataMapper.insertSysRoleData(sysRoleData);
+    }
+
+    /**
+     * 修改角色权限数据
+     * 
+     * @param sysRoleData 角色权限数据
+     * @return 结果
+     */
+    @Override
+    public int updateSysRoleData(SysRoleData sysRoleData)
+    {
+        sysRoleData.setUpdateTime(DateUtils.getNowDate());
+        return sysRoleDataMapper.updateSysRoleData(sysRoleData);
+    }
+
+    /**
+     * 批量删除角色权限数据
+     * 
+     * @param ids 需要删除的角色权限数据ID
+     * @return 结果
+     */
+    @Override
+    public int deleteSysRoleDataByIds(Long[] ids)
+    {
+        return sysRoleDataMapper.deleteSysRoleDataByIds(ids);
+    }
+
+    /**
+     * 删除角色权限数据信息
+     * 
+     * @param id 角色权限数据ID
+     * @return 结果
+     */
+    @Override
+    public int deleteSysRoleDataById(Long id)
+    {
+        return sysRoleDataMapper.deleteSysRoleDataById(id);
+    }
+}

+ 117 - 0
boman-modules/boman-system/src/main/resources/mapper/system/SysRoleDataMapper.xml

@@ -0,0 +1,117 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper
+        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.boman.system.mapper.SysRoleDataMapper">
+
+    <resultMap type="SysRoleData" id="SysRoleDataResult">
+        <result property="id" column="id"/>
+        <result property="roleId" column="role_id"/>
+        <result property="roleName" column="role_name"/>
+        <result property="roleSort" column="role_sort"/>
+        <result property="tableName" column="table_name"/>
+        <result property="dataScope" column="data_scope"/>
+        <result property="isUse" column="is_use"/>
+        <result property="isDel" column="is_del"/>
+        <result property="createBy" column="create_by"/>
+        <result property="createTime" column="create_time"/>
+        <result property="updateBy" column="update_by"/>
+        <result property="updateTime" column="update_time"/>
+        <result property="remark" column="remark"/>
+    </resultMap>
+
+    <sql id="selectSysRoleDataVo">
+        select id, role_id, role_sort, table_name, data_scope, is_use, is_del, create_by, create_time, update_by, update_time, remark from sys_role_data
+    </sql>
+
+    <select id="selectSysRoleDataList" parameterType="SysRoleData" resultMap="SysRoleDataResult">
+        select d.id, d.role_id, d.role_sort, d.table_name, d.data_scope, d.is_use, d.is_del, d.remark, r.role_name
+        from sys_role_data d
+        left join sys_role r on d.role_id = r.id
+        <where>
+            d.is_del = 'N'
+            <if test="id != null and id != ''">
+                AND d.id = #{id}
+            </if>
+            <if test="roleId != null and roleId != ''">
+                AND d.role_id = #{roleId}
+            </if>
+            <if test="tableName != null and tableName != ''">
+                AND d.table_name like concat('%', #{tableName}, '%')
+            </if>
+            <if test="dataScope != null and dataScope != ''">
+                AND d.data_scope = #{dataScope}
+            </if>
+            <if test="isUse != null and isUse != ''">
+                AND d.is_use = #{isUse}
+            </if>
+        </where>
+        order by d.role_sort
+    </select>
+
+    <select id="selectSysRoleDataById" parameterType="Long" resultMap="SysRoleDataResult">
+        <include refid="selectSysRoleDataVo"/>
+        where is_del = 'N' and id = #{id} order by role_sort asc
+    </select>
+
+    <insert id="insertSysRoleData" parameterType="SysRoleData">
+        insert into sys_role_data
+        <trim prefix="(" suffix=")" suffixOverrides=",">
+            <if test="id != null">id,</if>
+            <if test="roleId != null">role_id,</if>
+            <if test="roleSort != null">role_sort,</if>
+            <if test="tableName != null">table_name,</if>
+            <if test="dataScope != null">data_scope,</if>
+            <if test="isUse != null">is_use,</if>
+            <if test="isDel != null">is_del,</if>
+            <if test="createBy != null">create_by,</if>
+            <if test="createTime != null">create_time,</if>
+            <if test="updateBy != null">update_by,</if>
+            <if test="updateTime != null">update_time,</if>
+            <if test="remark != null">remark,</if>
+        </trim>
+        <trim prefix="values (" suffix=")" suffixOverrides=",">
+            <if test="id != null">#{id},</if>
+            <if test="roleId != null">#{roleId},</if>
+            <if test="roleSort != null">#{roleSort},</if>
+            <if test="tableName != null">#{tableName},</if>
+            <if test="dataScope != null">#{dataScope},</if>
+            <if test="isUse != null">#{isUse},</if>
+            <if test="isDel != null">#{isDel},</if>
+            <if test="createBy != null">#{createBy},</if>
+            <if test="createTime != null">#{createTime},</if>
+            <if test="updateBy != null">#{updateBy},</if>
+            <if test="updateTime != null">#{updateTime},</if>
+            <if test="remark != null">#{remark},</if>
+        </trim>
+    </insert>
+
+    <update id="updateSysRoleData" parameterType="SysRoleData">
+        update sys_role_data
+        <trim prefix="SET" suffixOverrides=",">
+            <if test="roleId != null">role_id = #{roleId},</if>
+            <if test="roleSort != null">role_sort = #{roleSort},</if>
+            <if test="tableName != null">table_name = #{tableName},</if>
+            <if test="dataScope != null">data_scope = #{dataScope},</if>
+            <if test="isUse != null">is_use = #{isUse},</if>
+            <if test="isDel != null">is_del = #{isDel},</if>
+            <if test="createBy != null">create_by = #{createBy},</if>
+            <if test="createTime != null">create_time = #{createTime},</if>
+            <if test="updateBy != null">update_by = #{updateBy},</if>
+            <if test="updateTime != null">update_time = #{updateTime},</if>
+            <if test="remark != null">remark = #{remark},</if>
+        </trim>
+        where id = #{id}
+    </update>
+
+    <delete id="deleteSysRoleDataById" parameterType="Long">
+        delete from sys_role_data where id = #{id}
+    </delete>
+
+    <delete id="deleteSysRoleDataByIds" parameterType="String">
+        delete from sys_role_data where id in
+        <foreach item="id" collection="array" open="(" separator="," close=")">
+            #{id}
+        </foreach>
+    </delete>
+</mapper>