| | |
| | | package com.dy.pmsGlobal.daoBa; |
| | | |
| | | import com.dy.pmsGlobal.pojoBa.BaLog; |
| | | import com.dy.pmsGlobal.pojoBa.BaPrivilege; |
| | | import org.apache.ibatis.annotations.MapKey; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | @Mapper |
| | | public interface BaPrivilegeMapper { |
| | |
| | | * @return List<BaPrivilege> |
| | | */ |
| | | List<BaPrivilege> selectAll() ; |
| | | |
| | | List<BaPrivilege> selectSome(Map<String, Object> params); |
| | | |
| | | Long selectSomeCount(Map<String, Object> params); |
| | | |
| | | List<BaPrivilege> selectByIds(List<String> ids) ; |
| | | |
| | | /** |
| | |
| | | @Length(message = "权限类型不大于{max}字,不小于{min}字", min = 4, max = 4) |
| | | public Integer type; |
| | | |
| | | /** |
| | | * 类别名称 |
| | | */ |
| | | @NotEmpty(message = "类别名称不能为空") //不能为空也不能为null |
| | | @Length(message = "权限类型不大于{max}字,不小于{min}字", min = 3, max = 6) |
| | | public String typeName; |
| | | |
| | | } |
| | |
| | | <result column="num" property="num" /> |
| | | <result column="name" property="name" /> |
| | | <result column="type" property="type" /> |
| | | <result column="type_name" property="typeName" /> |
| | | </resultMap> |
| | | <sql id="Base_Column_List"> |
| | | <!--@mbg.generated--> |
| | | id, num, `name`, `type` |
| | | id, num, `name`, `type`,type_name |
| | | </sql> |
| | | <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap"> |
| | | <!--@mbg.generated--> |
| | |
| | | |
| | | <insert id="insert" parameterType="com.dy.pmsGlobal.pojoBa.BaPrivilege"> |
| | | <!--@mbg.generated--> |
| | | insert into ba_privilege (id, num, `name`, `type`) |
| | | values (#{id}, #{num}, #{name}, #{type}) |
| | | insert into ba_privilege (id, num, `name`, `type`,type_name) |
| | | values (#{id}, #{num}, #{name}, #{type}, #{typeName}) |
| | | </insert> |
| | | <insert id="insertSelective" parameterType="com.dy.pmsGlobal.pojoBa.BaPrivilege"> |
| | | <!--@mbg.generated--> |
| | |
| | | <if test="type != null"> |
| | | `type`, |
| | | </if> |
| | | <if test="typeName != null"> |
| | | type_name, |
| | | </if> |
| | | </trim> |
| | | <trim prefix="values (" suffix=")" suffixOverrides=","> |
| | | <if test="id != null"> |
| | |
| | | </if> |
| | | <if test="type != null"> |
| | | #{type}, |
| | | </if> |
| | | <if test="typeName != null"> |
| | | #{typeName}, |
| | | </if> |
| | | </trim> |
| | | </insert> |
| | |
| | | <if test="type != null"> |
| | | `type` = #{type}, |
| | | </if> |
| | | <if test="typeName != null"> |
| | | type_name = #{typeName}, |
| | | </if> |
| | | </set> |
| | | where id = #{id} |
| | | </update> |
| | |
| | | update ba_privilege |
| | | set num = #{num}, |
| | | `name` = #{name}, |
| | | `type` = #{type} |
| | | `type` = #{type}, |
| | | type_name = #{typeName} |
| | | where id = #{id} |
| | | </update> |
| | | |
| | |
| | | #{id} |
| | | </foreach> |
| | | </select> |
| | | |
| | | <select id="selectSome" resultType="com.dy.pmsGlobal.pojoBa.BaPrivilege"> |
| | | select |
| | | <include refid="Base_Column_List" /> |
| | | from ba_privilege |
| | | <trim prefix="where " suffixOverrides="and"> |
| | | <if test="num != null and num != ''"> |
| | | num = #{num,jdbcType=INTEGER} and |
| | | </if> |
| | | <if test="name != null and name != ''"> |
| | | name like concat('%', #{name}, '%') and |
| | | </if> |
| | | <if test="typeName != null and typeName != '' "> |
| | | type_name like concat('%', #{typeName}, '%') and |
| | | </if> |
| | | <if test="type != null and type != ''"> |
| | | type = #{type,jdbcType=INTEGER} and |
| | | </if> |
| | | </trim> |
| | | order by id desc |
| | | <trim prefix="limit " > |
| | | <if test="start != null and count != null"> |
| | | #{start}, #{count} |
| | | </if> |
| | | </trim> |
| | | </select> |
| | | |
| | | <select id="selectSomeCount" resultType="java.lang.Long"> |
| | | select |
| | | count(1) |
| | | from ba_privilege |
| | | <trim prefix="where " suffixOverrides="and"> |
| | | <if test="num != null and num != ''"> |
| | | num = #{num,jdbcType=INTEGER} and |
| | | </if> |
| | | <if test="name != null and name != ''"> |
| | | name like concat('%', #{name}, '%') and |
| | | </if> |
| | | <if test="typeName != null and typeName != '' "> |
| | | type_name like concat('%', #{typeName}, '%') and |
| | | </if> |
| | | <if test="type != null and type != ''"> |
| | | type = #{type,jdbcType=INTEGER} and |
| | | </if> |
| | | </trim> |
| | | </select> |
| | | </mapper> |
New file |
| | |
| | | package com.dy.pmsBase.privilege; |
| | | |
| | | import com.dy.common.webUtil.QueryResultVo; |
| | | import com.dy.pmsGlobal.daoBa.BaPrivilegeMapper; |
| | | import com.dy.pmsGlobal.pojoBa.BaPrivilege; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.dubbo.common.utils.PojoUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.stream.Collectors; |
| | | |
| | | @Slf4j |
| | | @Service |
| | | public class PriSv { |
| | | |
| | | private BaPrivilegeMapper dao; |
| | | @Autowired |
| | | public void setDao(BaPrivilegeMapper dao) { |
| | | this.dao = dao; |
| | | } |
| | | |
| | | /** |
| | | * 获取角色列表 |
| | | */ |
| | | public QueryResultVo<List<BaPrivilege>> selectSome(QueryVo queryVo) { |
| | | Map<String, Object> params = (Map<String, Object>) PojoUtils.generalize(queryVo); |
| | | //查询符合条件的记录总数 |
| | | Long itemTotal = dao.selectSomeCount(params); |
| | | QueryResultVo<List<BaPrivilege>> rsVo = new QueryResultVo<>(queryVo.pageSize, queryVo.pageCurr) ; |
| | | //计算分页等信息 |
| | | rsVo.calculateAndSet(itemTotal, params); |
| | | //查询符合条件的记录 |
| | | rsVo.obj = dao.selectSome(params) ; |
| | | return rsVo ; |
| | | } |
| | | |
| | | public Map<String, List<BaPrivilege>> selectByType(){ |
| | | List<BaPrivilege> priList = dao.selectAll(); |
| | | Map<String, List<BaPrivilege>> map = priList.stream() |
| | | .collect(Collectors.groupingBy(BaPrivilege::getTypeName)); |
| | | return map; |
| | | } |
| | | } |
New file |
| | |
| | | package com.dy.pmsBase.privilege; |
| | | |
| | | import com.dy.common.aop.SsoPowerAop; |
| | | import com.dy.common.webUtil.BaseResponse; |
| | | import com.dy.common.webUtil.BaseResponseUtils; |
| | | import com.dy.common.webUtil.QueryResultVo; |
| | | import com.dy.pmsGlobal.aop.Log; |
| | | import com.dy.pmsGlobal.daoBa.BaPrivilegeMapper; |
| | | import com.dy.pmsGlobal.pojoBa.BaPrivilege; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * 权限管理 |
| | | */ |
| | | @Slf4j |
| | | @RestController |
| | | @RequestMapping(path="pri") |
| | | @SuppressWarnings("unchecked") |
| | | public class PrivilegeCtrl { |
| | | private PriSv sv; |
| | | @Autowired |
| | | public PrivilegeCtrl(PriSv sv){ |
| | | this.sv = sv; |
| | | } |
| | | |
| | | /** |
| | | * 分类型查询权限 |
| | | * @return |
| | | */ |
| | | @GetMapping(path="getByType") |
| | | @SsoPowerAop(power = "10100010") |
| | | public BaseResponse<Map<String, List<BaPrivilege>>> getByType(){ |
| | | try { |
| | | return BaseResponseUtils.buildSuccess(sv.selectByType()); |
| | | }catch (Exception e){ |
| | | log.error("分类型获取权限",e); |
| | | return BaseResponseUtils.buildException(e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 分页查询权限 |
| | | * @param vo |
| | | * @return |
| | | */ |
| | | @RequestMapping(path="some") |
| | | @SsoPowerAop(power = "10100010") |
| | | @Log("查询权限信息") |
| | | public BaseResponse<QueryResultVo<List<BaPrivilege>>> some(@RequestBody QueryVo vo){ |
| | | try { |
| | | return BaseResponseUtils.buildSuccess(sv.selectSome(vo)); |
| | | }catch (Exception e){ |
| | | log.error("分页获取权限",e); |
| | | return BaseResponseUtils.buildException(e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package com.dy.pmsBase.privilege; |
| | | |
| | | import com.dy.common.webUtil.QueryConditionVo; |
| | | import lombok.*; |
| | | |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = false) |
| | | @ToString(callSuper = true) |
| | | @NoArgsConstructor |
| | | @AllArgsConstructor |
| | | @Builder |
| | | public class QueryVo extends QueryConditionVo { |
| | | public String name; |
| | | public Integer num; |
| | | public Integer type; |
| | | public String typeName; |
| | | } |