Commit 141e63751a1023e7f7a81527fefac6dc7a041623

Authored by changpengfei
1 parent 3a1292d815
Exists in master and in 1 other branch dev

添加用户、角色、权限接口;

添加实体对象验证

Showing 11 changed files with 449 additions and 0 deletions

talkonlineweb/src/main/java/com/lyms/talkonlineweb/domain/LymsPermission.java View file @ 141e637
  1 +package com.lyms.talkonlineweb.domain;
  2 +
  3 +import com.baomidou.mybatisplus.annotation.IdType;
  4 +import com.baomidou.mybatisplus.annotation.TableField;
  5 +import com.baomidou.mybatisplus.annotation.TableId;
  6 +import com.baomidou.mybatisplus.annotation.TableName;
  7 +import java.io.Serializable;
  8 +import java.util.Date;
  9 +import lombok.Data;
  10 +
  11 +/**
  12 + * 权限表
  13 + * @TableName lyms_permission
  14 + */
  15 +@TableName(value ="lyms_permission")
  16 +@Data
  17 +public class LymsPermission implements Serializable {
  18 + /**
  19 + *
  20 + */
  21 + @TableId(value = "id", type = IdType.AUTO)
  22 + private Integer id;
  23 +
  24 + /**
  25 + * 权限名称
  26 + */
  27 + @TableField(value = "pmname")
  28 + private String pmname;
  29 +
  30 + /**
  31 + * 权限
  32 + */
  33 + @TableField(value = "purl")
  34 + private String purl;
  35 +
  36 + /**
  37 + * 上级菜单ID;根菜单默认0
  38 + */
  39 + @TableField(value = "pid")
  40 + private Integer pid;
  41 +
  42 + /**
  43 + * 创建人
  44 + */
  45 + @TableField(value = "createdby")
  46 + private Integer createdby;
  47 +
  48 + /**
  49 + * 创建时间
  50 + */
  51 + @TableField(value = "createdtime")
  52 + private Date createdtime;
  53 +
  54 + /**
  55 + * 更新人
  56 + */
  57 + @TableField(value = "updatedby")
  58 + private Integer updatedby;
  59 +
  60 + /**
  61 + * 更新时间
  62 + */
  63 + @TableField(value = "updated_time")
  64 + private Date updatedTime;
  65 +
  66 + @TableField(exist = false)
  67 + private static final long serialVersionUID = 1L;
  68 +
  69 + @Override
  70 + public boolean equals(Object that) {
  71 + if (this == that) {
  72 + return true;
  73 + }
  74 + if (that == null) {
  75 + return false;
  76 + }
  77 + if (getClass() != that.getClass()) {
  78 + return false;
  79 + }
  80 + LymsPermission other = (LymsPermission) that;
  81 + return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
  82 + && (this.getPmname() == null ? other.getPmname() == null : this.getPmname().equals(other.getPmname()))
  83 + && (this.getPurl() == null ? other.getPurl() == null : this.getPurl().equals(other.getPurl()))
  84 + && (this.getCreatedby() == null ? other.getCreatedby() == null : this.getCreatedby().equals(other.getCreatedby()))
  85 + && (this.getCreatedtime() == null ? other.getCreatedtime() == null : this.getCreatedtime().equals(other.getCreatedtime()))
  86 + && (this.getUpdatedby() == null ? other.getUpdatedby() == null : this.getUpdatedby().equals(other.getUpdatedby()))
  87 + && (this.getUpdatedTime() == null ? other.getUpdatedTime() == null : this.getUpdatedTime().equals(other.getUpdatedTime()));
  88 + }
  89 +
  90 + @Override
  91 + public int hashCode() {
  92 + final int prime = 31;
  93 + int result = 1;
  94 + result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
  95 + result = prime * result + ((getPmname() == null) ? 0 : getPmname().hashCode());
  96 + result = prime * result + ((getPurl() == null) ? 0 : getPurl().hashCode());
  97 + result = prime * result + ((getCreatedby() == null) ? 0 : getCreatedby().hashCode());
  98 + result = prime * result + ((getCreatedtime() == null) ? 0 : getCreatedtime().hashCode());
  99 + result = prime * result + ((getUpdatedby() == null) ? 0 : getUpdatedby().hashCode());
  100 + result = prime * result + ((getUpdatedTime() == null) ? 0 : getUpdatedTime().hashCode());
  101 + return result;
  102 + }
  103 +
  104 + @Override
  105 + public String toString() {
  106 + StringBuilder sb = new StringBuilder();
  107 + sb.append(getClass().getSimpleName());
  108 + sb.append(" [");
  109 + sb.append("Hash = ").append(hashCode());
  110 + sb.append(", id=").append(id);
  111 + sb.append(", pmname=").append(pmname);
  112 + sb.append(", purl=").append(purl);
  113 + sb.append(", pid=").append(pid);
  114 + sb.append(", createdby=").append(createdby);
  115 + sb.append(", createdtime=").append(createdtime);
  116 + sb.append(", updatedby=").append(updatedby);
  117 + sb.append(", updatedTime=").append(updatedTime);
  118 + sb.append(", serialVersionUID=").append(serialVersionUID);
  119 + sb.append("]");
  120 + return sb.toString();
  121 + }
  122 +}
talkonlineweb/src/main/java/com/lyms/talkonlineweb/domain/LymsRole.java View file @ 141e637
  1 +package com.lyms.talkonlineweb.domain;
  2 +
  3 +import com.baomidou.mybatisplus.annotation.IdType;
  4 +import com.baomidou.mybatisplus.annotation.TableField;
  5 +import com.baomidou.mybatisplus.annotation.TableId;
  6 +import com.baomidou.mybatisplus.annotation.TableName;
  7 +import java.io.Serializable;
  8 +import java.util.Date;
  9 +import lombok.Data;
  10 +
  11 +/**
  12 + * 角色
  13 + * @TableName lyms_role
  14 + */
  15 +@TableName(value ="lyms_role")
  16 +@Data
  17 +public class LymsRole implements Serializable {
  18 + /**
  19 + *
  20 + */
  21 + @TableId(value = "rid", type = IdType.AUTO)
  22 + private Integer rid;
  23 +
  24 + /**
  25 + * 角色名称
  26 + */
  27 + @TableField(value = "rname")
  28 + private String rname;
  29 +
  30 + /**
  31 + * 创建人
  32 + */
  33 + @TableField(value = "createdby")
  34 + private Integer createdby;
  35 +
  36 + /**
  37 + * 创建时间
  38 + */
  39 + @TableField(value = "createdtime")
  40 + private Date createdtime;
  41 +
  42 + /**
  43 + * 更新人
  44 + */
  45 + @TableField(value = "updatedby")
  46 + private Integer updatedby;
  47 +
  48 + /**
  49 + * 更新时间
  50 + */
  51 + @TableField(value = "updated_time")
  52 + private Date updatedTime;
  53 +
  54 + @TableField(exist = false)
  55 + private static final long serialVersionUID = 1L;
  56 +
  57 + @Override
  58 + public boolean equals(Object that) {
  59 + if (this == that) {
  60 + return true;
  61 + }
  62 + if (that == null) {
  63 + return false;
  64 + }
  65 + if (getClass() != that.getClass()) {
  66 + return false;
  67 + }
  68 + LymsRole other = (LymsRole) that;
  69 + return (this.getRid() == null ? other.getRid() == null : this.getRid().equals(other.getRid()))
  70 + && (this.getRname() == null ? other.getRname() == null : this.getRname().equals(other.getRname()))
  71 + && (this.getCreatedby() == null ? other.getCreatedby() == null : this.getCreatedby().equals(other.getCreatedby()))
  72 + && (this.getCreatedtime() == null ? other.getCreatedtime() == null : this.getCreatedtime().equals(other.getCreatedtime()))
  73 + && (this.getUpdatedby() == null ? other.getUpdatedby() == null : this.getUpdatedby().equals(other.getUpdatedby()))
  74 + && (this.getUpdatedTime() == null ? other.getUpdatedTime() == null : this.getUpdatedTime().equals(other.getUpdatedTime()));
  75 + }
  76 +
  77 + @Override
  78 + public int hashCode() {
  79 + final int prime = 31;
  80 + int result = 1;
  81 + result = prime * result + ((getRid() == null) ? 0 : getRid().hashCode());
  82 + result = prime * result + ((getRname() == null) ? 0 : getRname().hashCode());
  83 + result = prime * result + ((getCreatedby() == null) ? 0 : getCreatedby().hashCode());
  84 + result = prime * result + ((getCreatedtime() == null) ? 0 : getCreatedtime().hashCode());
  85 + result = prime * result + ((getUpdatedby() == null) ? 0 : getUpdatedby().hashCode());
  86 + result = prime * result + ((getUpdatedTime() == null) ? 0 : getUpdatedTime().hashCode());
  87 + return result;
  88 + }
  89 +
  90 + @Override
  91 + public String toString() {
  92 + StringBuilder sb = new StringBuilder();
  93 + sb.append(getClass().getSimpleName());
  94 + sb.append(" [");
  95 + sb.append("Hash = ").append(hashCode());
  96 + sb.append(", rid=").append(rid);
  97 + sb.append(", rname=").append(rname);
  98 + sb.append(", createdby=").append(createdby);
  99 + sb.append(", createdtime=").append(createdtime);
  100 + sb.append(", updatedby=").append(updatedby);
  101 + sb.append(", updatedTime=").append(updatedTime);
  102 + sb.append(", serialVersionUID=").append(serialVersionUID);
  103 + sb.append("]");
  104 + return sb.toString();
  105 + }
  106 +}
talkonlineweb/src/main/java/com/lyms/talkonlineweb/mapper/LymsPermissionMapper.java View file @ 141e637
  1 +package com.lyms.talkonlineweb.mapper;
  2 +
  3 +import com.lyms.talkonlineweb.domain.LymsPermission;
  4 +import com.baomidou.mybatisplus.core.mapper.BaseMapper;
  5 +import org.apache.ibatis.annotations.Param;
  6 +import org.apache.ibatis.annotations.Select;
  7 +
  8 +import java.util.List;
  9 +
  10 +/**
  11 + * @Entity com.lyms.talkonlineweb.domain.LymsPermission
  12 + */
  13 +public interface LymsPermissionMapper extends BaseMapper<LymsPermission> {
  14 +
  15 + @Select("SELECT * FROM lyms_permission p,lyms_rolepermiss rp WHERE rp.`pid`=p.`id` AND rp.`rid`=#{rid} AND p.`pid`=#{pid}")
  16 + List<LymsPermission> sltPermissByRole(@Param("rid") int rid, @Param("pid") int pid);
  17 +}
talkonlineweb/src/main/java/com/lyms/talkonlineweb/mapper/LymsRoleMapper.java View file @ 141e637
  1 +package com.lyms.talkonlineweb.mapper;
  2 +
  3 +import com.lyms.talkonlineweb.domain.LymsRole;
  4 +import com.baomidou.mybatisplus.core.mapper.BaseMapper;
  5 +import org.apache.ibatis.annotations.Delete;
  6 +import org.apache.ibatis.annotations.Insert;
  7 +import org.apache.ibatis.annotations.Param;
  8 +import org.apache.ibatis.annotations.Select;
  9 +
  10 +import java.util.List;
  11 +
  12 +/**
  13 + * @Entity com.lyms.talkonlineweb.domain.LymsRole
  14 + */
  15 +public interface LymsRoleMapper extends BaseMapper<LymsRole> {
  16 +
  17 + @Select(" SELECT * FROM lyms_role r,lyms_userrole ur WHERE ur.`rid`=r.`rid` AND ur.`uid`= #{uid} ")
  18 + List<LymsRole> sltRoleByUser(@Param("uid") int uid);
  19 +
  20 + @Delete("delete FROM lyms_rolepermiss WHERE `rid` =#{rid} ")
  21 + int delPersByRole(@Param("rid") int rid);
  22 +
  23 + @Insert("insert lyms_rolepermiss(rid,pid) values(#{rid},#{pid})")
  24 + int addRoleByPerms(@Param("rid") int rid, @Param("pid") int pid);
  25 +}
talkonlineweb/src/main/java/com/lyms/talkonlineweb/service/LymsPermissionService.java View file @ 141e637
  1 +package com.lyms.talkonlineweb.service;
  2 +
  3 +import com.lyms.talkonlineweb.domain.LymsPermission;
  4 +import com.baomidou.mybatisplus.extension.service.IService;
  5 +
  6 +/**
  7 + *
  8 + */
  9 +public interface LymsPermissionService extends IService<LymsPermission> {
  10 +
  11 +}
talkonlineweb/src/main/java/com/lyms/talkonlineweb/service/LymsRoleService.java View file @ 141e637
  1 +package com.lyms.talkonlineweb.service;
  2 +
  3 +import com.lyms.talkonlineweb.domain.LymsRole;
  4 +import com.baomidou.mybatisplus.extension.service.IService;
  5 +
  6 +import java.util.List;
  7 +
  8 +/**
  9 + *
  10 + */
  11 +public interface LymsRoleService extends IService<LymsRole> {
  12 +
  13 + /**
  14 + * 根据用户获取角色
  15 + * @param uid
  16 + * @return
  17 + */
  18 + List<LymsRole> getRolesByUid(int uid);
  19 +
  20 + /**
  21 + * 角色权限关系表
  22 + * @param rid
  23 + * @param pid
  24 + * @return
  25 + */
  26 + int addRoleByPerms(int rid, int pid);
  27 +
  28 + /**
  29 + * 删除角色权限关系
  30 + * @param rid
  31 + * @return
  32 + */
  33 + int delPersByRole(int rid);
  34 +}
talkonlineweb/src/main/java/com/lyms/talkonlineweb/service/impl/LymsPermissionServiceImpl.java View file @ 141e637
  1 +package com.lyms.talkonlineweb.service.impl;
  2 +
  3 +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
  4 +import com.lyms.talkonlineweb.domain.LymsPermission;
  5 +import com.lyms.talkonlineweb.service.LymsPermissionService;
  6 +import com.lyms.talkonlineweb.mapper.LymsPermissionMapper;
  7 +import org.springframework.stereotype.Service;
  8 +
  9 +/**
  10 + *
  11 + */
  12 +@Service
  13 +public class LymsPermissionServiceImpl extends ServiceImpl<LymsPermissionMapper, LymsPermission>
  14 + implements LymsPermissionService{
  15 +
  16 +}
talkonlineweb/src/main/java/com/lyms/talkonlineweb/service/impl/LymsRoleServiceImpl.java View file @ 141e637
  1 +package com.lyms.talkonlineweb.service.impl;
  2 +
  3 +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
  4 +import com.lyms.talkonlineweb.domain.LymsRole;
  5 +import com.lyms.talkonlineweb.service.LymsRoleService;
  6 +import com.lyms.talkonlineweb.mapper.LymsRoleMapper;
  7 +import org.springframework.beans.factory.annotation.Autowired;
  8 +import org.springframework.stereotype.Service;
  9 +
  10 +import java.util.List;
  11 +
  12 +/**
  13 + *
  14 + */
  15 +@Service
  16 +public class LymsRoleServiceImpl extends ServiceImpl<LymsRoleMapper, LymsRole>
  17 + implements LymsRoleService{
  18 +
  19 + @Autowired
  20 + private LymsRoleMapper lymsRoleMapper;
  21 +
  22 + @Override
  23 + public List<LymsRole> getRolesByUid(int uid) {
  24 + return lymsRoleMapper.sltRoleByUser(uid);
  25 + }
  26 +
  27 + @Override
  28 + public int addRoleByPerms(int rid, int pid) {
  29 + return lymsRoleMapper.addRoleByPerms(rid,pid);
  30 + }
  31 +
  32 + @Override
  33 + public int delPersByRole(int rid) {
  34 + return lymsRoleMapper.delPersByRole(rid);
  35 + }
  36 +}
talkonlineweb/src/main/resources/mapper/LymsPermissionMapper.xml View file @ 141e637
  1 +<?xml version="1.0" encoding="UTF-8"?>
  2 +<!DOCTYPE mapper
  3 + PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  4 + "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  5 +<mapper namespace="com.lyms.talkonlineweb.mapper.LymsPermissionMapper">
  6 +
  7 + <resultMap id="BaseResultMap" type="com.lyms.talkonlineweb.domain.LymsPermission">
  8 + <id property="id" column="id" jdbcType="INTEGER"/>
  9 + <result property="pmname" column="pmname" jdbcType="VARCHAR"/>
  10 + <result property="purl" column="purl" jdbcType="VARCHAR"/>
  11 + <result property="createdby" column="createdby" jdbcType="INTEGER"/>
  12 + <result property="createdtime" column="createdtime" jdbcType="TIMESTAMP"/>
  13 + <result property="updatedby" column="updatedby" jdbcType="INTEGER"/>
  14 + <result property="updatedTime" column="updated_time" jdbcType="TIMESTAMP"/>
  15 + </resultMap>
  16 +
  17 + <sql id="Base_Column_List">
  18 + id,pmname,purl,
  19 + createdby,createdtime,updatedby,
  20 + updated_time
  21 + </sql>
  22 +</mapper>
talkonlineweb/src/main/resources/mapper/LymsRoleMapper.xml View file @ 141e637
  1 +<?xml version="1.0" encoding="UTF-8"?>
  2 +<!DOCTYPE mapper
  3 + PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  4 + "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  5 +<mapper namespace="com.lyms.talkonlineweb.mapper.LymsRoleMapper">
  6 +
  7 + <resultMap id="BaseResultMap" type="com.lyms.talkonlineweb.domain.LymsRole">
  8 + <id property="rid" column="rid" jdbcType="INTEGER"/>
  9 + <result property="rname" column="rname" jdbcType="VARCHAR"/>
  10 + <result property="createdby" column="createdby" jdbcType="INTEGER"/>
  11 + <result property="createdtime" column="createdtime" jdbcType="TIMESTAMP"/>
  12 + <result property="updatedby" column="updatedby" jdbcType="INTEGER"/>
  13 + <result property="updatedTime" column="updated_time" jdbcType="TIMESTAMP"/>
  14 + </resultMap>
  15 +
  16 + <sql id="Base_Column_List">
  17 + rid,rname,createdby,
  18 + createdtime,updatedby,updated_time
  19 + </sql>
  20 +</mapper>
talkonlineweb/src/main/resources/mapper/LymsUserMapper.xml View file @ 141e637
  1 +<?xml version="1.0" encoding="UTF-8"?>
  2 +<!DOCTYPE mapper
  3 + PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  4 + "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  5 +<mapper namespace="com.lyms.talkonlineweb.mapper.LymsUserMapper">
  6 +
  7 + <resultMap id="BaseResultMap" type="com.lyms.talkonlineweb.domain.LymsUser">
  8 + <id property="uid" column="uid" jdbcType="INTEGER"/>
  9 + <result property="uname" column="uname" jdbcType="VARCHAR"/>
  10 + <result property="login" column="login" jdbcType="VARCHAR"/>
  11 + <result property="passwd" column="passwd" jdbcType="VARCHAR"/>
  12 + <result property="hxid" column="hxid" jdbcType="INTEGER"/>
  13 + <result property="createdby" column="createdby" jdbcType="INTEGER"/>
  14 + <result property="createdtime" column="createdtime" jdbcType="TIMESTAMP"/>
  15 + <result property="updatedby" column="updatedby" jdbcType="INTEGER"/>
  16 + <result property="updatedTime" column="updated_time" jdbcType="TIMESTAMP"/>
  17 + </resultMap>
  18 +
  19 + <sql id="Base_Column_List">
  20 + uid,uname,login,
  21 + passwd,hxid,createdby,
  22 + createdtime,updatedby,updated_time
  23 + </sql>
  24 +</mapper>