Browse Source

角色管理

tags/v1.0.0^2
chengwang 1 year ago
parent
commit
a6a6b7e45c
6 changed files with 127 additions and 0 deletions
  1. +17
    -0
      tuoheng-service/tuoheng-miniprogram/src/main/java/com/tuoheng/miniprogram/controller/RoleController.java
  2. +21
    -0
      tuoheng-service/tuoheng-miniprogram/src/main/java/com/tuoheng/miniprogram/dao/RoleMapper.java
  3. +49
    -0
      tuoheng-service/tuoheng-miniprogram/src/main/java/com/tuoheng/miniprogram/entity/Role.java
  4. +11
    -0
      tuoheng-service/tuoheng-miniprogram/src/main/java/com/tuoheng/miniprogram/service/IRoleService.java
  5. +17
    -0
      tuoheng-service/tuoheng-miniprogram/src/main/java/com/tuoheng/miniprogram/service/impl/RoleServiceImpl.java
  6. +12
    -0
      tuoheng-service/tuoheng-miniprogram/src/main/resources/mapper/RoleMapper.xml

+ 17
- 0
tuoheng-service/tuoheng-miniprogram/src/main/java/com/tuoheng/miniprogram/controller/RoleController.java View File

@@ -0,0 +1,17 @@
package com.tuoheng.miniprogram.controller;

import com.tuoheng.common.core.common.BaseController;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
* @Author ChengWang
* @Date 2022/12/16
*/
@RestController
@RequestMapping("/role")
public class RoleController extends BaseController {



}

+ 21
- 0
tuoheng-service/tuoheng-miniprogram/src/main/java/com/tuoheng/miniprogram/dao/RoleMapper.java View File

@@ -0,0 +1,21 @@
package com.tuoheng.miniprogram.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.tuoheng.miniprogram.entity.Role;

import java.util.List;

/**
* @Author ChengWang
* @Date 2022/12/16
*/
public interface RoleMapper extends BaseMapper<Role> {

/**
* 根据用户ID获取角色信息
*
* @param userId 用户ID
* @return
*/
List<Role> getRolesByUserId(Integer userId);
}

+ 49
- 0
tuoheng-service/tuoheng-miniprogram/src/main/java/com/tuoheng/miniprogram/entity/Role.java View File

@@ -0,0 +1,49 @@
package com.tuoheng.miniprogram.entity;

import com.baomidou.mybatisplus.annotation.TableName;
import com.tuoheng.common.core.common.BaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

/**
* <p>
* 系统角色表
* </p>
*
* @author 拓恒
* @since 2020-10-31
*/
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@TableName("op_roles")
public class Role extends BaseEntity {

private static final long serialVersionUID = 1L;

/**
* 租户id
*/
private Integer tenantId;

/**
* 角色名称
*/
private String roleName;

/**
* 角色标签
*/
private String code;

/**
* 状态:1正常 2禁用
*/
private Integer status;

/**
* 备注
*/
private String remark;
}

+ 11
- 0
tuoheng-service/tuoheng-miniprogram/src/main/java/com/tuoheng/miniprogram/service/IRoleService.java View File

@@ -0,0 +1,11 @@
package com.tuoheng.miniprogram.service;

import com.tuoheng.common.core.common.IBaseService;
import com.tuoheng.miniprogram.entity.Role;

/**
* @Author ChengWang
* @Date 2022/12/16
*/
public interface IRoleService extends IBaseService<Role> {
}

+ 17
- 0
tuoheng-service/tuoheng-miniprogram/src/main/java/com/tuoheng/miniprogram/service/impl/RoleServiceImpl.java View File

@@ -0,0 +1,17 @@
package com.tuoheng.miniprogram.service.impl;

import com.tuoheng.common.core.common.BaseServiceImpl;
import com.tuoheng.miniprogram.dao.RoleMapper;
import com.tuoheng.miniprogram.entity.Role;
import com.tuoheng.miniprogram.service.IRoleService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

/**
* @Author ChengWang
* @Date 2022/12/16
*/
@Service
@Slf4j
public class RoleServiceImpl extends BaseServiceImpl<RoleMapper, Role> implements IRoleService {
}

+ 12
- 0
tuoheng-service/tuoheng-miniprogram/src/main/resources/mapper/RoleMapper.xml View File

@@ -0,0 +1,12 @@
<?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.tuoheng.miniprogram.dao.RoleMapper">

<!-- 获取用户角色 -->
<select id="getRolesByUserId" resultType="com.tuoheng.miniprogram.entity.Role">
SELECT r.* FROM op_roles AS r
INNER JOIN sys_user_role AS ur ON r.id=ur.role_id
WHERE ur.user_id=#{userId} AND r.mark=1;
</select>

</mapper>

Loading…
Cancel
Save