liurunyu
2024-04-26 f717a59e727726535235642937f62e8851cc4a67
Merge branch 'master' of http://8.140.179.55:20000/r/pms-SV
8个文件已修改
3个文件已添加
264 ■■■■■ 已修改文件
pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/aop/LogAspect.java 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/aop/LogService.java 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/daoBa/BaPrivilegeMapper.java 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/pojoBa/BaLog.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/pojoBa/BaPrivilege.java 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pms-parent/pms-global/src/main/resources/mapper/BaLogMapper.xml 19 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pms-parent/pms-global/src/main/resources/mapper/BaPrivilegeMapper.xml 65 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pms-parent/pms-web-base/src/main/java/com/dy/pmsBase/privilege/PriSv.java 46 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pms-parent/pms-web-base/src/main/java/com/dy/pmsBase/privilege/PrivilegeCtrl.java 66 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pms-parent/pms-web-base/src/main/java/com/dy/pmsBase/privilege/QueryVo.java 17 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pms-parent/pms-web-base/src/main/java/com/dy/pmsBase/user/UserCtrl.java 26 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/aop/LogAspect.java
@@ -50,7 +50,6 @@
            // 获取用户信息
            BaUser user = (BaUser)getCurUser(result);
            if(user!=null && user.id !=null && !StringUtils.isNullOrEmpty(user.name)){
                Long operator = user.id;
                // 获取方法的中文描述
                MethodSignature sign = (MethodSignature) joinPoint.getSignature();
                Log logDesc = sign.getMethod().getAnnotation(Log.class);
@@ -58,7 +57,7 @@
                // 获取IP地址
                String ip = getRemoteHost();
                // 记录日志
                logSv.save(operator, operationName,ip,result.getCode(),result.getMsg());
                logSv.save(user.id,user.name, operationName,ip,result.getCode(),result.getMsg());
            }
        }catch (Exception e){
            log.error("记录日志异常:"+e.getMessage());
pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/aop/LogService.java
@@ -13,9 +13,10 @@
    @Autowired
    private BaLogMapper dao;
    public void save(long operator, String operation,String ip,String code,String msg) {
    public void save(long operator,String operatorName, String operation,String ip,String code,String msg) {
        BaLog log = new BaLog();
        log.userId=operator;
        log.userName=operatorName;
        log.content = operation;
        log.dt = new Date();
        log.ip = ip;
pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/daoBa/BaPrivilegeMapper.java
@@ -1,10 +1,13 @@
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 {
@@ -16,6 +19,11 @@
     * @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) ;
    /**
pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/pojoBa/BaLog.java
@@ -25,6 +25,10 @@
    * 用户ID
    */
    public Long userId;
    /**
     * 用户姓名
     */
    public String userName;
    /**
    * 日志内容
pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/pojoBa/BaPrivilege.java
@@ -58,4 +58,11 @@
    @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;
}
pms-parent/pms-global/src/main/resources/mapper/BaLogMapper.xml
@@ -6,6 +6,7 @@
    <!--@Table ba_log-->
    <id column="id" jdbcType="BIGINT" property="id" />
    <result column="user_id" jdbcType="BIGINT" property="userId" />
    <result column="user_name" jdbcType="VARCHAR" property="userName" />
    <result column="content" jdbcType="VARCHAR" property="content" />
    <result column="ip" jdbcType="VARCHAR" property="ip" />
    <result column="code" jdbcType="VARCHAR" property="code" />
@@ -14,7 +15,7 @@
  </resultMap>
  <sql id="Base_Column_List">
    <!--@mbg.generated-->
    id, user_id, content, dt,ip,code,msg
    id, user_id,user_name, content, dt,ip,code,msg
  </sql>
  <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
    <!--@mbg.generated-->
@@ -25,9 +26,9 @@
  </select>
  <insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.dy.pmsGlobal.pojoBa.BaLog" useGeneratedKeys="true">
    <!--@mbg.generated-->
    insert into ba_log (user_id, content, ip,code,msg
    insert into ba_log (user_id,user_name, content, ip,code,msg
      )
    values (#{userId,jdbcType=BIGINT}, #{content,jdbcType=VARCHAR}, #{ip,jdbcType=VARCHAR},
    values (#{userId,jdbcType=BIGINT},#{userName,jdbcType=VARCHAR}, #{content,jdbcType=VARCHAR}, #{ip,jdbcType=VARCHAR},
    #{code,jdbcType=VARCHAR},#{msg,jdbcType=VARCHAR}
      )
  </insert>
@@ -37,6 +38,9 @@
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="userId != null">
        user_id,
      </if>
      <if test="userName != null">
        user_name,
      </if>
      <if test="content != null">
        content,
@@ -54,6 +58,9 @@
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="userId != null">
        #{userId,jdbcType=BIGINT},
      </if>
      <if test="userName != null">
        #{userName,jdbcType=VARCHAR},
      </if>
      <if test="content != null">
        #{content,jdbcType=VARCHAR},
@@ -80,6 +87,9 @@
      <if test="userId != null and userId != ''">
        user_id = #{userId,jdbcType=BIGINT} and
      </if>
      <if test="userName != null and userName != ''">
        user_name = #{userName,jdbcType=VARCHAR} and
      </if>
      <if test="content != null  and content != '' ">
        content like concat('%', #{content}, '%') and
      </if>
@@ -105,6 +115,9 @@
      <if test="userId != null and userId != ''">
        user_id = #{userId,jdbcType=BIGINT} and
      </if>
      <if test="userName != null and userName != ''">
        user_name = #{userName,jdbcType=VARCHAR} and
      </if>
      <if test="content != null  and content != '' ">
        content like concat('%', #{content}, '%') and
      </if>
pms-parent/pms-global/src/main/resources/mapper/BaPrivilegeMapper.xml
@@ -8,10 +8,11 @@
    <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-->
@@ -67,8 +68,8 @@
  <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-->
@@ -86,6 +87,9 @@
      <if test="type != null">
        `type`,
      </if>
      <if test="typeName != null">
        type_name,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="id != null">
@@ -99,6 +103,9 @@
      </if>
      <if test="type != null">
        #{type},
      </if>
      <if test="typeName != null">
        #{typeName},
      </if>
    </trim>
  </insert>
@@ -115,6 +122,9 @@
      <if test="type != null">
        `type` = #{type},
      </if>
      <if test="typeName != null">
        type_name = #{typeName},
      </if>
    </set>
    where id = #{id}
  </update>
@@ -123,7 +133,8 @@
    update ba_privilege
    set num = #{num},
      `name` = #{name},
      `type` = #{type}
      `type` = #{type},
       type_name = #{typeName}
    where id = #{id}
  </update>
@@ -141,4 +152,50 @@
      #{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>
pms-parent/pms-web-base/src/main/java/com/dy/pmsBase/privilege/PriSv.java
New file
@@ -0,0 +1,46 @@
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;
    }
}
pms-parent/pms-web-base/src/main/java/com/dy/pmsBase/privilege/PrivilegeCtrl.java
New file
@@ -0,0 +1,66 @@
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());
        }
    }
}
pms-parent/pms-web-base/src/main/java/com/dy/pmsBase/privilege/QueryVo.java
New file
@@ -0,0 +1,17 @@
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;
}
pms-parent/pms-web-base/src/main/java/com/dy/pmsBase/user/UserCtrl.java
@@ -166,6 +166,32 @@
    }
    /**
     * 删除用户信息
     * @param id
     * @return
     */
    @GetMapping(path = "delete")
    @SsoPowerAop(power = "10100011") //登录与权限同时验证
    @Log("删除用户")
    public BaseResponse<Boolean> delete(Long id) {
        int count;
        try {
            BaUser po = new BaUser();
            po.id = id;
            po.deleted = true;
            count = this.sv.update(po);
        } catch (Exception e) {
            log.error("删除用户异常", e);
            return BaseResponseUtils.buildException(e.getMessage());
        }
        if (count <= 0) {
            return BaseResponseUtils.buildFail("数据库存储失败");
        } else {
            return BaseResponseUtils.buildSuccess(true);
        }
    }
    /**
     * 修改密码
     * @param id 用户ID
     * @return 是否成功