1、完善代码:mysql的varchar的长度就是中文汉字的数量
2、增加了系统设置管理
New file |
| | |
| | | package com.dy.pmsGlobal.daoBa; |
| | | |
| | | import com.dy.pmsGlobal.pojoBa.BaSysSet; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | |
| | | import java.util.List; |
| | | |
| | | @Mapper |
| | | public interface BaSysSetMapper { |
| | | /** |
| | | * 查询某个用户所隶属于的角色 |
| | | * @return List<BaSysSet> |
| | | */ |
| | | List<BaSysSet> selectSingle() ; |
| | | |
| | | int insert(BaSysSet record); |
| | | |
| | | int insertSelective(BaSysSet record); |
| | | } |
New file |
| | |
| | | package com.dy.pmsGlobal.global; |
| | | |
| | | |
| | | import com.dy.common.aop.SsoPowerAop; |
| | | import com.dy.common.webUtil.BaseResponse; |
| | | import com.dy.common.webUtil.BaseResponseUtils; |
| | | import com.dy.pmsGlobal.pojoBa.BaUser; |
| | | 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.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | /** |
| | | * 系统设置 |
| | | */ |
| | | @Slf4j |
| | | @RestController |
| | | @RequestMapping(path = "sysSet") |
| | | @SuppressWarnings("unchecked")//java版本越高,对泛型约束越严,所以配置SuppressWarnings("unchecked") |
| | | public class SysSetCtrl { |
| | | |
| | | @Autowired |
| | | private SysSetSv sv; |
| | | |
| | | /** |
| | | * 得到唯一系统设置 |
| | | * @return 唯一系统设置 |
| | | */ |
| | | //@GetMapping(path = "one", consumes = MediaType.TEXT_PLAIN_VALUE)//指前端向后传的参数类型 |
| | | @GetMapping(path = "one") |
| | | //@SsoAop() //只有登录验证,没有权限验证 |
| | | @SsoPowerAop(power = "-1") //登录与权限同时验证 |
| | | public BaseResponse<BaUser> single() { |
| | | try { |
| | | return BaseResponseUtils.buildSuccess(this.sv.selectSingle()); |
| | | } catch (Exception e) { |
| | | log.error("查询一个用户数据异常", e); |
| | | return BaseResponseUtils.buildException(e.getMessage()); |
| | | } |
| | | } |
| | | } |
New file |
| | |
| | | package com.dy.pmsGlobal.global; |
| | | |
| | | |
| | | import com.dy.pmsGlobal.daoBa.BaSysSetMapper; |
| | | import com.dy.pmsGlobal.pojoBa.BaSysSet; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.List; |
| | | |
| | | @Slf4j |
| | | @Service |
| | | public class SysSetSv { |
| | | @Autowired |
| | | private BaSysSetMapper dao ; |
| | | |
| | | public BaSysSet selectSingle(){ |
| | | List<BaSysSet> list = this.dao.selectSingle() ; |
| | | if(list != null && list.size() > 0){ |
| | | return list.get(0) ; |
| | | }else{ |
| | | return null ; |
| | | } |
| | | } |
| | | |
| | | } |
| | |
| | | * 权限名称 |
| | | */ |
| | | @NotEmpty(message = "权限名称不能为空") //不能为空也不能为null |
| | | @Length(message = "权限名称不大于{max}字,不小于{min}字", min = 2, max = 25) |
| | | @Length(message = "权限名称不大于{max}字,不小于{min}字", min = 2, max = 50) |
| | | public String name; |
| | | |
| | | /** |
| | |
| | | * 角色名称 |
| | | */ |
| | | @NotEmpty(message = "姓名不能为空") //不能为空也不能为null |
| | | @Length(message = "姓名不大于{max}字,不小于{min}字", min = 2, max = 25) |
| | | @Length(message = "姓名不大于{max}字,不小于{min}字", min = 2, max = 50) |
| | | public String name; |
| | | |
| | | /** |
New file |
| | |
| | | package com.dy.pmsGlobal.pojoBa; |
| | | |
| | | |
| | | import com.alibaba.fastjson2.annotation.JSONField; |
| | | import com.alibaba.fastjson2.writer.ObjectWriterImplToString; |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import com.dy.common.po.BaseEntity; |
| | | import jakarta.validation.constraints.NotEmpty; |
| | | import lombok.*; |
| | | import org.hibernate.validator.constraints.Length; |
| | | |
| | | /** |
| | | * 用户 |
| | | */ |
| | | //2024-04-12下面TableName不用配置表名称(value="BaUser"或“ba_user”) |
| | | //只要通过驼峰命名法则类名与表名对应起来就可以了,如果不能对应起来,需要指定表名称 |
| | | //例如@TableName(value="TestUser" autoResultMap = true) |
| | | @TableName(value="ba_sys_set", autoResultMap = true) |
| | | @Data |
| | | @Builder |
| | | @ToString |
| | | @NoArgsConstructor |
| | | @AllArgsConstructor |
| | | public class BaSysSet implements BaseEntity { |
| | | |
| | | public static final long serialVersionUID = 202404151528001L; |
| | | /** |
| | | * 主键 |
| | | */ |
| | | /* 如果不明确 type类型,MP将自动为其赋值(雪花ID) |
| | | IdType: |
| | | AUTO(0), //自增 |
| | | NONE(1), //未设置主键 |
| | | INPUT(2), //手动输入 |
| | | ASSIGN_ID(3), //默认全局唯一ID |
| | | ASSIGN_UUID(4), //全局唯一的 uuid |
| | | */ |
| | | @JSONField(serializeUsing= ObjectWriterImplToString.class) |
| | | @TableId(value = "id", type = IdType.INPUT) |
| | | public Long id; |
| | | |
| | | /** |
| | | * 系统名称 |
| | | */ |
| | | @NotEmpty(message = "系统名称不能为空") //不能为空也不能为null |
| | | @Length(message = "系统名称不大于{max}字,不小于{min}字", min = 2, max = 30) |
| | | public String sysName; |
| | | |
| | | |
| | | } |
| | |
| | | * 姓名 |
| | | */ |
| | | @NotEmpty(message = "姓名不能为空") //不能为空也不能为null |
| | | @Length(message = "姓名不大于{max}字,不小于{min}字", min = 2, max = 25) |
| | | @Length(message = "姓名不大于{max}字,不小于{min}字", min = 2, max = 50) |
| | | public String name; |
| | | |
| | | /** |
New file |
| | |
| | | <?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.dy.pmsGlobal.daoBa.BaSysSetMapper"> |
| | | <resultMap id="BaseResultMap" type="com.dy.pmsGlobal.pojoBa.BaSysSet"> |
| | | <!--@mbg.generated--> |
| | | <!--@Table ba_sys_set--> |
| | | <result column="id" property="id" /> |
| | | <result column="sys_name" property="sysName" /> |
| | | </resultMap> |
| | | <sql id="Base_Column_List"> |
| | | <!--@mbg.generated--> |
| | | id, sys_name |
| | | </sql> |
| | | |
| | | <select id="selectSingle" resultMap="BaseResultMap"> |
| | | select <include refid="Base_Column_List" /> |
| | | from ba_sys_set |
| | | </select> |
| | | |
| | | |
| | | <insert id="insert" parameterType="com.dy.pmsGlobal.pojoBa.BaSysSet"> |
| | | <!--@mbg.generated--> |
| | | insert into ba_sys_set (id, sys_name) |
| | | values (#{id}, #{sysName}) |
| | | </insert> |
| | | <insert id="insertSelective" parameterType="com.dy.pmsGlobal.pojoBa.BaSysSet"> |
| | | <!--@mbg.generated--> |
| | | insert into ba_sys_set |
| | | <trim prefix="(" suffix=")" suffixOverrides=","> |
| | | <if test="id != null"> |
| | | id, |
| | | </if> |
| | | <if test="sysName != null"> |
| | | sys_name, |
| | | </if> |
| | | </trim> |
| | | <trim prefix="values (" suffix=")" suffixOverrides=","> |
| | | <if test="id != null"> |
| | | #{id}, |
| | | </if> |
| | | <if test="sysName != null"> |
| | | #{sysName}, |
| | | </if> |
| | | </trim> |
| | | </insert> |
| | | </mapper> |
| | |
| | | import java.util.Objects; |
| | | |
| | | /** |
| | | * 测试 |
| | | * 用户管理 |
| | | */ |
| | | @Slf4j |
| | | @RestController |