Compare commits
No commits in common. "08d0d6bd09339d3912559c7f21c76cd90bc71d89" and "7b759baeed46e467c5d9007c0a6f6abe618f7180" have entirely different histories.
08d0d6bd09
...
7b759baeed
|
@ -1,18 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
|
||||||
<component name="DataSourceManagerImpl" format="xml" multifile-model="true">
|
|
||||||
<data-source source="LOCAL" name="guigu-oa@106.15.251.123" uuid="9d89e3b4-ae68-4e89-b7e1-1866250cab0a">
|
|
||||||
<driver-ref>mysql.8</driver-ref>
|
|
||||||
<synchronize>true</synchronize>
|
|
||||||
<imported>true</imported>
|
|
||||||
<jdbc-driver>com.mysql.cj.jdbc.Driver</jdbc-driver>
|
|
||||||
<jdbc-url>jdbc:mysql://106.15.251.123:3305/guigu-oa?serverTimezone=GMT</jdbc-url>
|
|
||||||
<jdbc-additional-properties>
|
|
||||||
<property name="com.intellij.clouds.kubernetes.db.host.port" />
|
|
||||||
<property name="com.intellij.clouds.kubernetes.db.enabled" value="false" />
|
|
||||||
<property name="com.intellij.clouds.kubernetes.db.container.port" />
|
|
||||||
</jdbc-additional-properties>
|
|
||||||
<working-dir>$ProjectFileDir$</working-dir>
|
|
||||||
</data-source>
|
|
||||||
</component>
|
|
||||||
</project>
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="PublishConfigData" autoUpload="Always" remoteFilesAllowedToDisappearOnAutoupload="false" autoUploadExternalChanges="true">
|
||||||
|
<option name="myAutoUpload" value="ALWAYS" />
|
||||||
|
</component>
|
||||||
|
</project>
|
|
@ -18,7 +18,8 @@ public class CodeGet {
|
||||||
// 全局配置
|
// 全局配置
|
||||||
GlobalConfig gc = new GlobalConfig();
|
GlobalConfig gc = new GlobalConfig();
|
||||||
// TODO 需要修改路径名称
|
// TODO 需要修改路径名称
|
||||||
gc.setOutputDir("G:\\java项目\\guigu-oa\\guigu-oa\\service-oa" + "/src/main/java");
|
gc.setOutputDir("G:\\java项目\\guigu-oa\\guigu-oa-parent\\service-oa" + "/src/main/java");
|
||||||
|
|
||||||
gc.setServiceName("%sService"); // 去掉Service接口的首字母I
|
gc.setServiceName("%sService"); // 去掉Service接口的首字母I
|
||||||
gc.setAuthor("bunny");
|
gc.setAuthor("bunny");
|
||||||
gc.setOpen(false);
|
gc.setOpen(false);
|
||||||
|
@ -55,7 +56,7 @@ public class CodeGet {
|
||||||
private static StrategyConfig getStrategyConfig() {
|
private static StrategyConfig getStrategyConfig() {
|
||||||
StrategyConfig strategy = new StrategyConfig();
|
StrategyConfig strategy = new StrategyConfig();
|
||||||
// TODO 要生成的表
|
// TODO 要生成的表
|
||||||
strategy.setInclude("sys_user", "sys_role","sys_user_role");
|
strategy.setInclude("sys_user", "sys_role");
|
||||||
strategy.setNaming(NamingStrategy.underline_to_camel);// 数据库表映射到实体的命名策略
|
strategy.setNaming(NamingStrategy.underline_to_camel);// 数据库表映射到实体的命名策略
|
||||||
strategy.setColumnNaming(NamingStrategy.underline_to_camel);// 数据库表字段映射到实体的命名策略
|
strategy.setColumnNaming(NamingStrategy.underline_to_camel);// 数据库表字段映射到实体的命名策略
|
||||||
strategy.setEntityLombokModel(true); // lombok 模型 @Accessors(chain = true) setter链式操作
|
strategy.setEntityLombokModel(true); // lombok 模型 @Accessors(chain = true) setter链式操作
|
||||||
|
|
Binary file not shown.
|
@ -1,17 +0,0 @@
|
||||||
package com.atguigu.model.system;
|
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Builder;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
@Builder
|
|
||||||
@AllArgsConstructor
|
|
||||||
@NoArgsConstructor
|
|
||||||
public class RoleByUser {
|
|
||||||
private List<SysRole> assginRoleList;
|
|
||||||
private List<SysRole> allRolesList;
|
|
||||||
}
|
|
|
@ -2,9 +2,7 @@ package com.atguigu.auth.controller;
|
||||||
|
|
||||||
import com.atguigu.auth.service.SysRoleService;
|
import com.atguigu.auth.service.SysRoleService;
|
||||||
import com.atguigu.common.result.Result;
|
import com.atguigu.common.result.Result;
|
||||||
import com.atguigu.model.system.RoleByUser;
|
|
||||||
import com.atguigu.model.system.SysRole;
|
import com.atguigu.model.system.SysRole;
|
||||||
import com.atguigu.vo.system.AssginRoleVo;
|
|
||||||
import com.atguigu.vo.system.SysRoleQueryVo;
|
import com.atguigu.vo.system.SysRoleQueryVo;
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
@ -14,7 +12,6 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
@Tag(name = "角色管理接口")
|
@Tag(name = "角色管理接口")
|
||||||
@RestController
|
@RestController
|
||||||
|
@ -65,18 +62,4 @@ public class SysRoleController {
|
||||||
sysRoleService.removeByIds(idList);
|
sysRoleService.removeByIds(idList);
|
||||||
return Result.success();
|
return Result.success();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation(value = "根据用户获取角色数据")
|
|
||||||
@GetMapping("/toAssign/{userId}")
|
|
||||||
public Result<RoleByUser> toAssign(@PathVariable Long userId) {
|
|
||||||
RoleByUser roleMap = sysRoleService.findRoleByAdminId(userId);
|
|
||||||
return Result.success(roleMap);
|
|
||||||
}
|
|
||||||
|
|
||||||
@ApiOperation(value = "根据用户分配角色")
|
|
||||||
@PostMapping("/doAssign")
|
|
||||||
public Result<AssginRoleVo> doAssign(@RequestBody AssginRoleVo assginRoleVo) {
|
|
||||||
sysRoleService.doAssign(assginRoleVo);
|
|
||||||
return Result.success();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -71,12 +71,5 @@ public class SysUserController {
|
||||||
sysUserService.removeByIds(idList);
|
sysUserService.removeByIds(idList);
|
||||||
return Result.success();
|
return Result.success();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Operation(summary = "更新状态", description = "更新状态")
|
|
||||||
@GetMapping("updateStatus/{id}/{status}")
|
|
||||||
public Result<SysUser> updateStatus(@PathVariable Long id, @PathVariable Long status) {
|
|
||||||
sysUserService.updateStatus(id, status);
|
|
||||||
return Result.success();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,17 +2,6 @@ package com.atguigu.auth.mapper;
|
||||||
|
|
||||||
import com.atguigu.model.system.SysRole;
|
import com.atguigu.model.system.SysRole;
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@Mapper
|
|
||||||
public interface SysRoleMapper extends BaseMapper<SysRole> {
|
public interface SysRoleMapper extends BaseMapper<SysRole> {
|
||||||
/**
|
|
||||||
* 根据用户id查询所有的角色
|
|
||||||
*
|
|
||||||
* @param userId 用户id
|
|
||||||
* @return 角色列表
|
|
||||||
*/
|
|
||||||
List<SysRole> selectByUserId(Long userId);
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,18 +0,0 @@
|
||||||
package com.atguigu.auth.mapper;
|
|
||||||
|
|
||||||
import com.atguigu.model.system.SysUserRole;
|
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
* 用户角色 Mapper 接口
|
|
||||||
* </p>
|
|
||||||
*
|
|
||||||
* @author bunny
|
|
||||||
* @since 2024-04-23
|
|
||||||
*/
|
|
||||||
@Mapper
|
|
||||||
public interface SysUserRoleMapper extends BaseMapper<SysUserRole> {
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,8 +1,6 @@
|
||||||
package com.atguigu.auth.service;
|
package com.atguigu.auth.service;
|
||||||
|
|
||||||
import com.atguigu.model.system.RoleByUser;
|
|
||||||
import com.atguigu.model.system.SysRole;
|
import com.atguigu.model.system.SysRole;
|
||||||
import com.atguigu.vo.system.AssginRoleVo;
|
|
||||||
import com.atguigu.vo.system.SysRoleQueryVo;
|
import com.atguigu.vo.system.SysRoleQueryVo;
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
@ -17,19 +15,5 @@ public interface SysRoleService extends IService<SysRole> {
|
||||||
* @return 分页结果
|
* @return 分页结果
|
||||||
*/
|
*/
|
||||||
IPage<SysRole> pageResult(Long page, Long limit, SysRoleQueryVo vo);
|
IPage<SysRole> pageResult(Long page, Long limit, SysRoleQueryVo vo);
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据用户获取角色数据
|
|
||||||
*
|
|
||||||
* @param userId 用户id
|
|
||||||
* @return 用户角色集合
|
|
||||||
*/
|
|
||||||
RoleByUser findRoleByAdminId(Long userId);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据用户分配角色
|
|
||||||
* @param vo 分配条件
|
|
||||||
*/
|
|
||||||
void doAssign(AssginRoleVo vo);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,16 +0,0 @@
|
||||||
package com.atguigu.auth.service;
|
|
||||||
|
|
||||||
import com.atguigu.model.system.SysUserRole;
|
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
* 用户角色 服务类
|
|
||||||
* </p>
|
|
||||||
*
|
|
||||||
* @author bunny
|
|
||||||
* @since 2024-04-23
|
|
||||||
*/
|
|
||||||
public interface SysUserRoleService extends IService<SysUserRole> {
|
|
||||||
|
|
||||||
}
|
|
|
@ -24,12 +24,4 @@ public interface SysUserService extends IService<SysUser> {
|
||||||
* @return 分页结果
|
* @return 分页结果
|
||||||
*/
|
*/
|
||||||
IPage<SysUser> getUserByPage(Long page, Long limit, SysUserQueryVo vo);
|
IPage<SysUser> getUserByPage(Long page, Long limit, SysUserQueryVo vo);
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新状态
|
|
||||||
*
|
|
||||||
* @param id 用户id
|
|
||||||
* @param status 修改的状态
|
|
||||||
*/
|
|
||||||
void updateStatus(Long id, Long status);
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,34 +1,18 @@
|
||||||
package com.atguigu.auth.service.impl;
|
package com.atguigu.auth.service.impl;
|
||||||
|
|
||||||
|
|
||||||
import com.atguigu.auth.mapper.SysRoleMapper;
|
import com.atguigu.auth.mapper.SysRoleMapper;
|
||||||
import com.atguigu.auth.mapper.SysUserRoleMapper;
|
|
||||||
import com.atguigu.auth.service.SysRoleService;
|
import com.atguigu.auth.service.SysRoleService;
|
||||||
import com.atguigu.auth.service.SysUserRoleService;
|
|
||||||
import com.atguigu.model.system.RoleByUser;
|
|
||||||
import com.atguigu.model.system.SysRole;
|
import com.atguigu.model.system.SysRole;
|
||||||
import com.atguigu.model.system.SysUserRole;
|
|
||||||
import com.atguigu.vo.system.AssginRoleVo;
|
|
||||||
import com.atguigu.vo.system.SysRoleQueryVo;
|
import com.atguigu.vo.system.SysRoleQueryVo;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
|
||||||
import org.springframework.util.StringUtils;
|
import org.springframework.util.StringUtils;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> implements SysRoleService {
|
public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> implements SysRoleService {
|
||||||
@Autowired
|
|
||||||
private SysUserRoleMapper sysUserRoleMapper;
|
|
||||||
@Autowired
|
|
||||||
private SysUserRoleService sysUserRoleService;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 角色条件分页查询
|
* 角色条件分页查询
|
||||||
*
|
*
|
||||||
|
@ -47,48 +31,4 @@ public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> impl
|
||||||
|
|
||||||
return page(pageParam, wrapper);
|
return page(pageParam, wrapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据用户获取角色数据
|
|
||||||
*
|
|
||||||
* @param userId 用户id
|
|
||||||
* @return 用户角色集合
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public RoleByUser findRoleByAdminId(Long userId) {
|
|
||||||
// 查询所有角色
|
|
||||||
List<SysRole> allRolesList = list();
|
|
||||||
|
|
||||||
// 根据用户id查询所有的角色
|
|
||||||
List<SysRole> assginRoleList = baseMapper.selectByUserId(userId);
|
|
||||||
return RoleByUser.builder().allRolesList(allRolesList).assginRoleList(assginRoleList).build();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据用户分配角色
|
|
||||||
*
|
|
||||||
* @param vo 分配条件
|
|
||||||
*/
|
|
||||||
@Transactional
|
|
||||||
@Override
|
|
||||||
public void doAssign(AssginRoleVo vo) {
|
|
||||||
// 删除原有数据
|
|
||||||
LambdaQueryWrapper<SysUserRole> wrapper = new LambdaQueryWrapper<>();
|
|
||||||
wrapper.eq(SysUserRole::getUserId, vo.getUserId());
|
|
||||||
sysUserRoleService.remove(wrapper);
|
|
||||||
|
|
||||||
// 为用户分配角色
|
|
||||||
ArrayList<SysUserRole> userRoleArrayList = new ArrayList<>();
|
|
||||||
vo.getRoleIdList().forEach(roleId -> {
|
|
||||||
if (!StringUtils.isEmpty(roleId)) {
|
|
||||||
SysUserRole sysUserRole = new SysUserRole();
|
|
||||||
sysUserRole.setUserId(vo.getUserId());
|
|
||||||
sysUserRole.setRoleId(roleId);
|
|
||||||
userRoleArrayList.add(sysUserRole);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// 批量插入用户角色信息
|
|
||||||
sysUserRoleService.saveBatch(userRoleArrayList);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,20 +0,0 @@
|
||||||
package com.atguigu.auth.service.impl;
|
|
||||||
|
|
||||||
import com.atguigu.auth.mapper.SysUserRoleMapper;
|
|
||||||
import com.atguigu.auth.service.SysUserRoleService;
|
|
||||||
import com.atguigu.model.system.SysUserRole;
|
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
* 用户角色 服务实现类
|
|
||||||
* </p>
|
|
||||||
*
|
|
||||||
* @author bunny
|
|
||||||
* @since 2024-04-23
|
|
||||||
*/
|
|
||||||
@Service
|
|
||||||
public class SysUserRoleServiceImpl extends ServiceImpl<SysUserRoleMapper, SysUserRole> implements SysUserRoleService {
|
|
||||||
|
|
||||||
}
|
|
|
@ -50,20 +50,4 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
||||||
|
|
||||||
return page(pageParam, wrapper);
|
return page(pageParam, wrapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新状态
|
|
||||||
*
|
|
||||||
* @param id 用户id
|
|
||||||
* @param status 修改的状态
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void updateStatus(Long id, Long status) {
|
|
||||||
SysUser sysUser = getById(id);
|
|
||||||
if (status == 1) sysUser.setStatus(1);
|
|
||||||
else sysUser.setStatus(0);
|
|
||||||
|
|
||||||
// 更新用户状态
|
|
||||||
updateById(sysUser);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,21 +1,20 @@
|
||||||
package com.atguigu.auth.controller;
|
package mapper;
|
||||||
|
|
||||||
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
* 用户角色 前端控制器
|
* 角色 前端控制器
|
||||||
* </p>
|
* </p>
|
||||||
*
|
*
|
||||||
* @author bunny
|
* @author bunny
|
||||||
* @since 2024-04-23
|
* @since 2024-04-22
|
||||||
*/
|
*/
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/auth/sys-user-role")
|
@RequestMapping("/order/sys-role")
|
||||||
public class SysUserRoleController {
|
public class SysRoleController {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +0,0 @@
|
||||||
<?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.atguigu.auth.mapper.SysRoleMapper">
|
|
||||||
<!-- 根据用户id查询所有的角色 -->
|
|
||||||
<select id="selectByUserId" resultType="com.atguigu.model.system.SysRole">
|
|
||||||
SELECT *
|
|
||||||
FROM sys_role
|
|
||||||
WHERE id IN (SELECT role_id FROM sys_user_role WHERE user_id = #{user_id})
|
|
||||||
</select>
|
|
||||||
</mapper>
|
|
|
@ -0,0 +1,20 @@
|
||||||
|
package mapper;
|
||||||
|
|
||||||
|
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 用户表 前端控制器
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author bunny
|
||||||
|
* @since 2024-04-22
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/order/sys-user")
|
||||||
|
public class SysUserController {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -1,5 +0,0 @@
|
||||||
<?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.atguigu.auth.mapper.SysUserMapper">
|
|
||||||
|
|
||||||
</mapper>
|
|
|
@ -1,5 +0,0 @@
|
||||||
<?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.atguigu.auth.mapper.SysUserRoleMapper">
|
|
||||||
|
|
||||||
</mapper>
|
|
Loading…
Reference in New Issue