first commit

This commit is contained in:
xiang
2026-03-21 17:56:14 +08:00
commit 81dd7ee546
111 changed files with 11528 additions and 0 deletions

View File

@@ -0,0 +1,21 @@
package com.xiang.xs.server;
import org.mybatis.spring.annotation.MapperScan;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.openfeign.EnableFeignClients;
@SpringBootApplication(scanBasePackages = "com.xiang.xs")
@EnableFeignClients
@MapperScan("com.xiang.xs.service.repository.mapper")
public class Application {
private static final Logger log = LoggerFactory.getLogger(Application.class);
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
log.info("common center start success!");
}
}

View File

@@ -0,0 +1,95 @@
package com.xiang.xs.server.controller;
import com.xiang.xs.service.biz.ISysConfigService;
import com.xiang.xs.service.entity.SysConfig;
import com.xiang.xservice.basic.common.resp.Result;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
* 参数配置 信息操作处理
*
* @author ruoyi
*/
@RestController
@RequestMapping("/system/config")
@RequiredArgsConstructor
public class SysConfigController {
private final ISysConfigService configService;
/**
* 获取参数配置列表
*/
@GetMapping("/list")
public Result<List<SysConfig>> list(SysConfig config) {
List<SysConfig> list = configService.selectConfigList(config);
return Result.data(list);
}
/**
* 根据参数编号获取详细信息
*/
@GetMapping(value = "/{configId}")
public Result<SysConfig> getInfo(@PathVariable Long configId) {
return Result.data(configService.selectConfigById(configId));
}
/**
* 根据参数键名查询参数值
*/
@GetMapping(value = "/configKey/{configKey}")
public Result<String> getConfigKey(@PathVariable String configKey) {
return Result.data(configService.selectConfigByKey(configKey));
}
/**
* 新增参数配置
*/
@PostMapping
public Result<Boolean> add(@Validated @RequestBody SysConfig config) {
if (!configService.checkConfigKeyUnique(config)) {
return Result.error("新增参数'" + config.getConfigName() + "'失败,参数键名已存在");
}
return Result.data(configService.insertConfig(config) > 0);
}
/**
* 修改参数配置
*/
@PutMapping
public Result<Boolean> edit(@Validated @RequestBody SysConfig config) {
if (!configService.checkConfigKeyUnique(config)) {
return Result.error("修改参数'" + config.getConfigName() + "'失败,参数键名已存在");
}
return Result.data(configService.updateConfig(config) > 0);
}
/**
* 删除参数配置
*/
@DeleteMapping("/{configIds}")
public Result<Void> remove(@PathVariable Long[] configIds) {
configService.deleteConfigByIds(configIds);
return Result.success();
}
/**
* 刷新参数缓存
*/
@DeleteMapping("/refreshCache")
public Result<Void> refreshCache() {
configService.resetConfigCache();
return Result.success();
}
}

View File

@@ -0,0 +1,110 @@
package com.xiang.xs.server.controller;
import com.xiang.xs.service.biz.ISysDeptService;
import com.xiang.xs.service.contants.UserConstants;
import com.xiang.xs.service.entity.SysDept;
import com.xiang.xservice.basic.common.resp.Result;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
/**
* 部门信息
*
* @author ruoyi
*/
@RestController
@RequestMapping("/system/dept")
public class SysDeptController {
@Autowired
private ISysDeptService deptService;
/**
* 获取部门列表
*/
@GetMapping("/list")
public Result<List<SysDept>> list(SysDept dept) {
List<SysDept> depts = deptService.selectDeptList(dept);
return Result.data(depts);
}
/**
* 查询部门列表(排除节点)
*/
@GetMapping("/list/exclude/{deptId}")
public Result<List<SysDept>> excludeChild(@PathVariable(value = "deptId", required = false) Long deptId) {
List<SysDept> depts = deptService.selectDeptList(new SysDept());
depts.removeIf(d -> d.getDeptId().intValue() == deptId || ArrayUtils.contains(d.getAncestors().split(","), deptId + ""));
return Result.data(depts);
}
/**
* 根据部门编号获取详细信息
*/
@GetMapping(value = "/{deptId}")
public Result<SysDept> getInfo(@PathVariable Long deptId, HttpServletRequest request) {
String token = request.getHeader("Authorization");
deptService.checkDeptDataScope(deptId, token);
return Result.data(deptService.selectDeptById(deptId));
}
/**
* 新增部门
*/
@PostMapping
public Result<Boolean> add(@Validated @RequestBody SysDept dept) {
if (!deptService.checkDeptNameUnique(dept)) {
return Result.error("新增部门'" + dept.getDeptName() + "'失败,部门名称已存在");
}
return Result.data(deptService.insertDept(dept) > 0);
}
/**
* 修改部门
*/
@PutMapping
public Result<Boolean> edit(@Validated @RequestBody SysDept dept, HttpServletRequest request) {
Long deptId = dept.getDeptId();
deptService.checkDeptDataScope(deptId, getToken(request));
if (!deptService.checkDeptNameUnique(dept)) {
return Result.error("修改部门'" + dept.getDeptName() + "'失败,部门名称已存在");
} else if (dept.getParentId().equals(deptId)) {
return Result.error("修改部门'" + dept.getDeptName() + "'失败,上级部门不能是自己");
} else if (StringUtils.equals(UserConstants.DEPT_DISABLE, dept.getStatus()) && deptService.selectNormalChildrenDeptById(deptId) > 0) {
return Result.error("该部门包含未停用的子部门!");
}
return Result.data(deptService.updateDept(dept) > 0);
}
/**
* 删除部门
*/
@DeleteMapping("/{deptId}")
public Result<Boolean> remove(@PathVariable Long deptId, HttpServletRequest request) {
String token = getToken(request);
if (deptService.hasChildByDeptId(deptId)) {
return Result.error("存在下级部门,不允许删除");
}
if (deptService.checkDeptExistUser(deptId)) {
return Result.error("部门存在用户,不允许删除");
}
deptService.checkDeptDataScope(deptId, token);
return Result.data(deptService.deleteDeptById(deptId) > 0);
}
private String getToken(HttpServletRequest request) {
return request.getHeader("Authorization");
}
}

View File

@@ -0,0 +1,86 @@
package com.xiang.xs.server.controller;
import com.xiang.xs.service.biz.ISysDictDataService;
import com.xiang.xs.service.biz.ISysDictTypeService;
import com.xiang.xs.service.entity.SysDictData;
import com.xiang.xservice.basic.common.resp.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.CollectionUtils;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.ArrayList;
import java.util.List;
/**
* 数据字典信息
*
* @author ruoyi
*/
@RestController
@RequestMapping("/system/dict/data")
public class SysDictDataController {
@Autowired
private ISysDictDataService dictDataService;
@Autowired
private ISysDictTypeService dictTypeService;
@GetMapping("/list")
public Result<List<SysDictData>> list(SysDictData dictData) {
List<SysDictData> list = dictDataService.selectDictDataList(dictData);
return Result.data(list);
}
/**
* 查询字典数据详细
*/
@GetMapping(value = "/{dictCode}")
public Result<SysDictData> getInfo(@PathVariable Long dictCode) {
return Result.data(dictDataService.selectDictDataById(dictCode));
}
/**
* 根据字典类型查询字典数据信息
*/
@GetMapping(value = "/type/{dictType}")
public Result<List<SysDictData>> dictType(@PathVariable String dictType) {
List<SysDictData> data = dictTypeService.selectDictDataByType(dictType);
if (CollectionUtils.isEmpty(data)) {
data = new ArrayList<SysDictData>();
}
return Result.data(data);
}
/**
* 新增字典类型
*/
@PostMapping
public Result<Boolean> add(@Validated @RequestBody SysDictData dict) {
return Result.data(dictDataService.insertDictData(dict) > 0);
}
/**
* 修改保存字典类型
*/
@PutMapping
public Result<Boolean> edit(@Validated @RequestBody SysDictData dict) {
return Result.data(dictDataService.updateDictData(dict) > 0);
}
/**
* 删除字典类型
*/
@DeleteMapping("/{dictCodes}")
public Result<Void> remove(@PathVariable Long[] dictCodes) {
dictDataService.deleteDictDataByIds(dictCodes);
return Result.success();
}
}

View File

@@ -0,0 +1,104 @@
package com.xiang.xs.server.controller;
import com.xiang.xs.service.biz.ISysDictTypeService;
import com.xiang.xs.service.entity.SysDictType;
import com.xiang.xservice.basic.common.resp.Result;
import lombok.extern.java.Log;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
/**
* 数据字典信息
*
* @author ruoyi
*/
@RestController
@RequestMapping("/system/dict/type")
public class SysDictTypeController
{
@Autowired
private ISysDictTypeService dictTypeService;
@GetMapping("/list")
public Result<List<SysDictType>> list(SysDictType dictType)
{
List<SysDictType> list = dictTypeService.selectDictTypeList(dictType);
return Result.data(list);
}
/**
* 查询字典类型详细
*/
@GetMapping(value = "/{dictId}")
public Result<SysDictType> getInfo(@PathVariable Long dictId)
{
return Result.data(dictTypeService.selectDictTypeById(dictId));
}
/**
* 新增字典类型
*/
@PostMapping
public Result<Boolean> add(@Validated @RequestBody SysDictType dict)
{
if (!dictTypeService.checkDictTypeUnique(dict))
{
return Result.error("新增字典'" + dict.getDictName() + "'失败,字典类型已存在");
}
return Result.data(dictTypeService.insertDictType(dict) > 0);
}
/**
* 修改字典类型
*/
@PutMapping
public Result<Boolean> edit(@Validated @RequestBody SysDictType dict)
{
if (!dictTypeService.checkDictTypeUnique(dict))
{
return Result.error("修改字典'" + dict.getDictName() + "'失败,字典类型已存在");
}
return Result.data(dictTypeService.updateDictType(dict) > 0);
}
/**
* 删除字典类型
*/
@DeleteMapping("/{dictIds}")
public Result<Void> remove(@PathVariable Long[] dictIds)
{
dictTypeService.deleteDictTypeByIds(dictIds);
return Result.success();
}
/**
* 刷新字典缓存
*/
@DeleteMapping("/refreshCache")
public Result<Void> refreshCache()
{
dictTypeService.resetDictCache();
return Result.success();
}
/**
* 获取字典选择框列表
*/
@GetMapping("/optionselect")
public Result<List<SysDictType>> optionselect()
{
List<SysDictType> dictTypes = dictTypeService.selectDictTypeAll();
return Result.data(dictTypes);
}
}

View File

@@ -0,0 +1,116 @@
package com.xiang.xs.server.controller;
import com.xiang.xs.api.client.TokenApi;
import com.xiang.xs.service.biz.ISysMenuService;
import com.xiang.xs.service.contants.UserConstants;
import com.xiang.xs.service.entity.SysMenu;
import com.xiang.xs.service.entity.TreeSelect;
import com.xiang.xs.service.entity.vo.RoleTreeVo;
import com.xiang.xservice.basic.common.resp.Result;
import com.xiang.xservice.basic.utils.MyStringUtils;
import lombok.extern.java.Log;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
/**
* 菜单信息
*
* @author ruoyi
*/
@RestController
@RequestMapping("/system/menu")
public class SysMenuController {
@Autowired
private ISysMenuService menuService;
@Autowired
private TokenApi tokenApi;
/**
* 获取菜单列表
*/
@GetMapping("/list")
public Result<List<SysMenu>> list(SysMenu menu, HttpServletRequest request) {
Long userId = tokenApi.getUserId(request.getHeader("Authorization"));
List<SysMenu> menus = menuService.selectMenuList(menu, userId);
return Result.data(menus);
}
/**
* 根据菜单编号获取详细信息
*/
@GetMapping(value = "/{menuId}")
public Result<SysMenu> getInfo(@PathVariable Long menuId) {
return Result.data(menuService.selectMenuById(menuId));
}
/**
* 获取菜单下拉树列表
*/
@GetMapping("/treeselect")
public Result<List<TreeSelect>> treeselect(SysMenu menu, HttpServletRequest request) {
List<SysMenu> menus = menuService.selectMenuList(menu, tokenApi.getUserId(request.getHeader("Authorization")));
return Result.data(menuService.buildMenuTreeSelect(menus));
}
/**
* 加载对应角色菜单列表树
*/
@GetMapping(value = "/roleMenuTreeselect/{roleId}")
public Result<RoleTreeVo> roleMenuTreeselect(@PathVariable("roleId") Long roleId, HttpServletRequest request) {
List<SysMenu> menus = menuService.selectMenuList(tokenApi.getUserId(request.getHeader("Authorization")));
return Result.data(new RoleTreeVo(menuService.selectMenuListByRoleId(roleId), menuService.buildMenuTreeSelect(menus)));
}
/**
* 新增菜单
*/
@PostMapping
public Result<Boolean> add(@Validated @RequestBody SysMenu menu) {
if (!menuService.checkMenuNameUnique(menu)) {
return Result.error("新增菜单'" + menu.getMenuName() + "'失败,菜单名称已存在");
} else if (UserConstants.YES_FRAME.equals(menu.getIsFrame()) && !MyStringUtils.isHttp(menu.getPath())) {
return Result.error("新增菜单'" + menu.getMenuName() + "'失败地址必须以http(s)://开头");
}
return Result.data(menuService.insertMenu(menu) > 0);
}
/**
* 修改菜单
*/
@PutMapping
public Result<Boolean> edit(@Validated @RequestBody SysMenu menu) {
if (!menuService.checkMenuNameUnique(menu)) {
return Result.error("修改菜单'" + menu.getMenuName() + "'失败,菜单名称已存在");
} else if (UserConstants.YES_FRAME.equals(menu.getIsFrame()) && !MyStringUtils.isHttp(menu.getPath())) {
return Result.error("修改菜单'" + menu.getMenuName() + "'失败地址必须以http(s)://开头");
} else if (menu.getMenuId().equals(menu.getParentId())) {
return Result.error("修改菜单'" + menu.getMenuName() + "'失败,上级菜单不能选择自己");
}
return Result.data(menuService.updateMenu(menu) > 0);
}
/**
* 删除菜单
*/
@DeleteMapping("/{menuId}")
public Result<Boolean> remove(@PathVariable("menuId") Long menuId) {
if (menuService.hasChildByMenuId(menuId)) {
return Result.error("存在子菜单,不允许删除");
}
if (menuService.checkMenuExistRole(menuId)) {
return Result.error("菜单已分配,不允许删除");
}
return Result.data(menuService.deleteMenuById(menuId) > 0);
}
}

View File

@@ -0,0 +1,71 @@
package com.xiang.xs.server.controller;
import com.xiang.xs.service.biz.ISysNoticeService;
import com.xiang.xs.service.entity.SysNotice;
import com.xiang.xservice.basic.common.resp.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
* 公告 信息操作处理
*
* @author ruoyi
*/
@RestController
@RequestMapping("/system/notice")
public class SysNoticeController {
@Autowired
private ISysNoticeService noticeService;
/**
* 获取通知公告列表
*/
@GetMapping("/list")
public Result<List<SysNotice>> list(SysNotice notice) {
List<SysNotice> list = noticeService.selectNoticeList(notice);
return Result.data(list);
}
/**
* 根据通知公告编号获取详细信息
*/
@GetMapping(value = "/{noticeId}")
public Result<SysNotice> getInfo(@PathVariable Long noticeId) {
return Result.data(noticeService.selectNoticeById(noticeId));
}
/**
* 新增通知公告
*/
@PostMapping
public Result<Boolean> add(@Validated @RequestBody SysNotice notice) {
return Result.data(noticeService.insertNotice(notice) > 0);
}
/**
* 修改通知公告
*/
@PutMapping
public Result<Boolean> edit(@Validated @RequestBody SysNotice notice) {
return Result.data(noticeService.updateNotice(notice) > 0);
}
/**
* 删除通知公告
*/
@DeleteMapping("/{noticeIds}")
public Result<Boolean> remove(@PathVariable Long[] noticeIds) {
return Result.data(noticeService.deleteNoticeByIds(noticeIds) > 0);
}
}

View File

@@ -0,0 +1,90 @@
package com.xiang.xs.server.controller;
import com.xiang.xs.service.biz.ISysPostService;
import com.xiang.xs.service.entity.SysPost;
import com.xiang.xservice.basic.common.resp.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
* 岗位信息操作处理
*
* @author ruoyi
*/
@RestController
@RequestMapping("/system/post")
public class SysPostController {
@Autowired
private ISysPostService postService;
/**
* 获取岗位列表
*/
@GetMapping("/list")
public Result<List<SysPost>> list(SysPost post) {
List<SysPost> list = postService.selectPostList(post);
return Result.data(list);
}
/**
* 根据岗位编号获取详细信息
*/
@GetMapping(value = "/{postId}")
public Result<SysPost> getInfo(@PathVariable Long postId) {
return Result.data(postService.selectPostById(postId));
}
/**
* 新增岗位
*/
@PostMapping
public Result<Boolean> add(@Validated @RequestBody SysPost post) {
if (!postService.checkPostNameUnique(post)) {
return Result.error("新增岗位'" + post.getPostName() + "'失败,岗位名称已存在");
} else if (!postService.checkPostCodeUnique(post)) {
return Result.error("新增岗位'" + post.getPostName() + "'失败,岗位编码已存在");
}
return Result.data(postService.insertPost(post) > 0);
}
/**
* 修改岗位
*/
@PutMapping
public Result<Boolean> edit(@Validated @RequestBody SysPost post) {
if (!postService.checkPostNameUnique(post)) {
return Result.error("修改岗位'" + post.getPostName() + "'失败,岗位名称已存在");
} else if (!postService.checkPostCodeUnique(post)) {
return Result.error("修改岗位'" + post.getPostName() + "'失败,岗位编码已存在");
}
return Result.data(postService.updatePost(post) > 0);
}
/**
* 删除岗位
*/
@DeleteMapping("/{postIds}")
public Result<Boolean> remove(@PathVariable Long[] postIds) {
return Result.data(postService.deletePostByIds(postIds) > 0);
}
/**
* 获取岗位选择框列表
*/
@GetMapping("/optionselect")
public Result<List<SysPost>> optionselect() {
List<SysPost> posts = postService.selectPostAll();
return Result.data(posts);
}
}

View File

@@ -0,0 +1,183 @@
package com.xiang.xs.server.controller;
import com.alibaba.fastjson.JSONObject;
import com.xiang.xs.service.biz.ISysDeptService;
import com.xiang.xs.service.biz.ISysRoleService;
import com.xiang.xs.service.biz.ISysUserService;
import com.xiang.xs.service.entity.SysDept;
import com.xiang.xs.service.entity.SysRole;
import com.xiang.xs.service.entity.SysUser;
import com.xiang.xs.service.entity.SysUserRole;
import com.xiang.xservice.basic.common.resp.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
/**
* 角色信息
*
* @author ruoyi
*/
@RestController
@RequestMapping("/system/role")
public class SysRoleController {
@Autowired
private ISysRoleService roleService;
@Autowired
private ISysUserService userService;
@Autowired
private ISysDeptService deptService;
@GetMapping("/list")
public Result<List<SysRole>> list(SysRole role) {
List<SysRole> list = roleService.selectRoleList(role);
return Result.data(list);
}
/**
* 根据角色编号获取详细信息
*/
@GetMapping(value = "/{roleId}")
public Result<SysRole> getInfo(@PathVariable Long roleId, HttpServletRequest request) {
String token = request.getHeader("Authorization");
roleService.checkRoleDataScope(token, roleId);
return Result.data(roleService.selectRoleById(roleId));
}
/**
* 新增角色
*/
@PostMapping
public Result<Boolean> add(@Validated @RequestBody SysRole role) {
if (!roleService.checkRoleNameUnique(role)) {
return Result.error("新增角色'" + role.getRoleName() + "'失败,角色名称已存在");
} else if (!roleService.checkRoleKeyUnique(role)) {
return Result.error("新增角色'" + role.getRoleName() + "'失败,角色权限已存在");
}
return Result.data(roleService.insertRole(role) > 0);
}
/**
* 修改保存角色
*/
@PutMapping
public Result<Boolean> edit(@Validated @RequestBody SysRole role, HttpServletRequest request) {
String token = request.getHeader("Authorization");
roleService.checkRoleAllowed(role);
roleService.checkRoleDataScope(token, role.getRoleId());
if (!roleService.checkRoleNameUnique(role)) {
return Result.error("修改角色'" + role.getRoleName() + "'失败,角色名称已存在");
} else if (!roleService.checkRoleKeyUnique(role)) {
return Result.error("修改角色'" + role.getRoleName() + "'失败,角色权限已存在");
}
return Result.data(roleService.updateRole(role) > 0);
}
/**
* 修改保存数据权限
*/
@PutMapping("/dataScope")
public Result<Boolean> dataScope(@RequestBody SysRole role, HttpServletRequest request) {
String token = request.getHeader("Authorization");
roleService.checkRoleAllowed(role);
roleService.checkRoleDataScope(token, role.getRoleId());
return Result.data(roleService.authDataScope(role) > 0);
}
/**
* 状态修改
*/
@PutMapping("/changeStatus")
public Result<Boolean> changeStatus(@RequestBody SysRole role, HttpServletRequest request) {
String token = request.getHeader("Authorization");
roleService.checkRoleAllowed(role);
roleService.checkRoleDataScope(token, role.getRoleId());
return Result.data(roleService.updateRoleStatus(role) > 0);
}
/**
* 删除角色
*/
@DeleteMapping("/{roleIds}")
public Result<Boolean> remove(@PathVariable Long[] roleIds, HttpServletRequest request) {
String token = request.getHeader("Authorization");
return Result.data(roleService.deleteRoleByIds(token, roleIds) > 0);
}
/**
* 获取角色选择框列表
*/
@GetMapping("/optionselect")
public Result<List<SysRole>> optionselect() {
return Result.data(roleService.selectRoleAll());
}
/**
* 查询已分配用户角色列表
*/
@GetMapping("/authUser/allocatedList")
public Result<List<SysUser>> allocatedList(SysUser user) {
List<SysUser> list = userService.selectAllocatedList(user);
return Result.data(list);
}
/**
* 查询未分配用户角色列表
*/
@GetMapping("/authUser/unallocatedList")
public Result<List<SysUser>> unallocatedList(SysUser user) {
List<SysUser> list = userService.selectUnallocatedList(user);
return Result.data(list);
}
/**
* 取消授权用户
*/
@PutMapping("/authUser/cancel")
public Result<Boolean> cancelAuthUser(@RequestBody SysUserRole userRole) {
return Result.data(roleService.deleteAuthUser(userRole) > 0);
}
/**
* 批量取消授权用户
*/
@PutMapping("/authUser/cancelAll")
public Result<Boolean> cancelAuthUserAll(Long roleId, Long[] userIds) {
return Result.data(roleService.deleteAuthUsers(roleId, userIds) > 0);
}
/**
* 批量选择用户授权
*/
@PutMapping("/authUser/selectAll")
public Result<Boolean> selectAuthUserAll(Long roleId, Long[] userIds, HttpServletRequest request) {
String token = request.getHeader("Authorization");
roleService.checkRoleDataScope(token, roleId);
return Result.data(roleService.insertAuthUsers(roleId, userIds) > 0);
}
/**
* 获取对应角色部门树列表
*/
@GetMapping(value = "/deptTree/{roleId}")
public Result<JSONObject> deptTree(@PathVariable("roleId") Long roleId) {
JSONObject ajax = new JSONObject();
ajax.put("checkedKeys", deptService.selectDeptListByRoleId(roleId));
ajax.put("depts", deptService.selectDeptTreeList(new SysDept()));
return Result.data(ajax);
}
}

View File

@@ -0,0 +1,31 @@
spring:
cloud:
nacos:
discovery:
group: DEFAULT_GROUP
namespace: 00131110-3ecb-4a35-8bbb-624edde1d937
server-addr: general.xiangtech.xyz:8848
username: nacos
password: nacos
datasource:
dynamic:
primary: master
datasource:
master:
url: jdbc:mysql://120.27.153.87:3306/xservice-user?useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai&allowMultiQueries=true
username: root
password: sdkljfikdfn@123
driver-class-name: com.mysql.cj.jdbc.Driver
sshConnect: false
redis:
host: r-bp1wt59a6nfyt4e3ltpd.redis.rds.aliyuncs.com
port: 6379
password: Xiang0000 # 如果无密码可以省略
database: 10
timeout: 5000
lettuce:
pool:
max-active: 8
max-idle: 8
min-idle: 0
max-wait: 1000

View File

@@ -0,0 +1,19 @@
server:
port: 38012
spring:
profiles:
active: local
application:
name: xservice-common-center
mvc:
pathmatch:
matching-strategy: ant_path_matcher
main:
allow-bean-definition-overriding: true
headless: true
mybatis:
mapper-locations:
- classpath*:mapper/*/*.xml
configuration:
map-underscore-to-camel-case: true

View File

@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE configuration
PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-config.dtd">
<configuration>
<!-- 全局参数 -->
<settings>
<!-- 使全局的映射器启用或禁用缓存 -->
<setting name="cacheEnabled" value="true" />
<!-- 允许JDBC 支持自动生成主键 -->
<setting name="useGeneratedKeys" value="true" />
<!-- 配置默认的执行器.SIMPLE就是普通执行器;REUSE执行器会重用预处理语句(prepared statements);BATCH执行器将重用语句并执行批量更新 -->
<setting name="defaultExecutorType" value="SIMPLE" />
<!-- 指定 MyBatis 所用日志的具体实现 -->
<setting name="logImpl" value="SLF4J" />
<!-- 使用驼峰命名法转换字段 -->
<!-- <setting name="mapUnderscoreToCamelCase" value="true"/> -->
</settings>
</configuration>