Merge branch 'main' of http://121.37.111.42:3000/ThbTech/gis-bi into main
This commit is contained in:
commit
d9ab16d6ac
@ -67,6 +67,12 @@
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
</dependency>
|
||||
<!-- 胡图工具类 -->
|
||||
<dependency>
|
||||
<groupId>cn.hutool</groupId>
|
||||
<artifactId>hutool-all</artifactId>
|
||||
<version>5.8.8</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
|
@ -0,0 +1,154 @@
|
||||
package io.gisbi.application.system.controller;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||
import io.gisbi.application.system.domain.Menu;
|
||||
import io.gisbi.application.system.service.IMenuService;
|
||||
import io.gisbi.config.ResponseResult;
|
||||
import io.gisbi.utils.AuthUtils;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 菜单及按钮 前端控制器
|
||||
* </p>
|
||||
*
|
||||
* @author lilin
|
||||
* @since 2025-05-08
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/menuInterface")
|
||||
public class MenuController {
|
||||
|
||||
@Resource
|
||||
private IMenuService menuService;
|
||||
|
||||
|
||||
/***********************************
|
||||
* 用途说明:获取菜单结构树(含按钮)
|
||||
* 参数说明
|
||||
* appId 应用ID 关联应用系统
|
||||
* name 名称
|
||||
* isdisplay 是否显示
|
||||
* 返回值说明: 菜单结构树集合
|
||||
***********************************/
|
||||
@PostMapping("/getMenuButtonTree")
|
||||
@ResponseBody
|
||||
public List<Map<String, Object>> getMenuButtonTree(String appId,String name,String isdisplay) {
|
||||
return menuService.getMenuButtonTree(appId, name, isdisplay);
|
||||
}
|
||||
|
||||
/***********************************
|
||||
* 用途说明:获取菜单结构树(不含按钮)
|
||||
* 参数说明
|
||||
* appId 应用ID 关联应用系统
|
||||
* name 名称
|
||||
* isdisplay 是否显示
|
||||
* 返回值说明: 菜单结构树集合
|
||||
***********************************/
|
||||
@PostMapping("/getMenuTreegetMenuTree")
|
||||
@ResponseBody
|
||||
public List<Map<String, Object>> getMenuTree(String appId,
|
||||
String name,
|
||||
String isdisplay) {
|
||||
return menuService.getMenuTree(appId, name, isdisplay);
|
||||
}
|
||||
|
||||
/***********************************
|
||||
* 用途说明:根据id查询菜单或按钮详情
|
||||
* 参数说明
|
||||
* id 菜单或按钮表id
|
||||
* 返回值说明: 菜单或按钮表对象
|
||||
***********************************/
|
||||
@PostMapping("/getMenuById")
|
||||
@ResponseBody
|
||||
public ResponseResult getMenuById(String id) {
|
||||
Menu menu = menuService.getById(id);
|
||||
return ResponseResult.successData(menu);
|
||||
}
|
||||
|
||||
/***********************************
|
||||
* 用途说明:新增菜单及按钮
|
||||
* 参数说明
|
||||
* sysMenu 菜单或按钮表对象
|
||||
* 返回值说明: 是否添加成功提示
|
||||
***********************************/
|
||||
@PostMapping("/addMenu")
|
||||
@ResponseBody
|
||||
public ResponseResult addMenu(@RequestBody Menu menu) {
|
||||
boolean isOk = menuService.addMenu(menu);
|
||||
if (isOk) {
|
||||
return ResponseResult.success();
|
||||
} else {
|
||||
return ResponseResult.error();
|
||||
}
|
||||
}
|
||||
|
||||
/***********************************
|
||||
* 用途说明:修改菜单及按钮根据ID
|
||||
* 参数说明
|
||||
* sysMenu 菜单或按钮表对象
|
||||
* 返回值说明: 是否修改成功提示
|
||||
***********************************/
|
||||
@PostMapping("/updateMenuById")
|
||||
@ResponseBody
|
||||
public ResponseResult updateById(@RequestBody Menu menu) {
|
||||
//填写 当前用户名称
|
||||
menu.setLastmodifier(AuthUtils.getUser().getUserId().toString());
|
||||
//填写 当前日期
|
||||
menu.setLastmodifydate(LocalDateTime.now());
|
||||
boolean isOk = menuService.updateById(menu);
|
||||
if (isOk) {
|
||||
return ResponseResult.success();
|
||||
} else {
|
||||
return ResponseResult.error();
|
||||
}
|
||||
}
|
||||
|
||||
/***********************************
|
||||
* 用途说明:根据id删除菜单或按钮
|
||||
* 参数说明
|
||||
* id 删除列的id
|
||||
* 返回值说明: 是否删除成功
|
||||
***********************************/
|
||||
@PostMapping("/deleteMenuById")
|
||||
@ResponseBody
|
||||
public ResponseResult deleteById(@RequestParam String id) {
|
||||
boolean ok = menuService.deleteById(id);
|
||||
if (ok) {
|
||||
return ResponseResult.success();
|
||||
} else {
|
||||
return ResponseResult.error();
|
||||
}
|
||||
}
|
||||
|
||||
/***********************************
|
||||
* 用途说明:更新菜单及按钮是否有效
|
||||
* 参数说明
|
||||
* id 菜单及按钮表id
|
||||
* isdisplay 是否有效字段
|
||||
* 返回值说明: 是否更新成功
|
||||
***********************************/
|
||||
@PostMapping("/setIsDisplay")
|
||||
@ResponseBody
|
||||
public ResponseResult setIsDisplay(String id, String isdisplay) {
|
||||
UpdateWrapper<Menu> updateWrapper = new UpdateWrapper<>();
|
||||
//根据id 修改是否显示 ,最近修改人,最近修改时间
|
||||
updateWrapper.eq("id", id)
|
||||
.set("isdisplay", isdisplay)
|
||||
.set( "lastmodifier", AuthUtils.getUser().getUserId().toString())
|
||||
.set("lastmodifydate",new Timestamp(System.currentTimeMillis()));
|
||||
boolean ok = menuService.update(updateWrapper);
|
||||
if (ok) {
|
||||
return ResponseResult.success();
|
||||
} else {
|
||||
return ResponseResult.error();
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,165 @@
|
||||
package io.gisbi.application.system.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||
import com.github.xiaoymin.knife4j.core.util.StrUtil;
|
||||
import io.gisbi.application.system.domain.Organization;
|
||||
import io.gisbi.application.system.service.IOrganizationService;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import io.gisbi.config.ResponseResult;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 组织机构 前端控制器
|
||||
* </p>
|
||||
*
|
||||
* @author lilin
|
||||
* @since 2025-05-08
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/organization")
|
||||
public class OrganizationController {
|
||||
|
||||
@Resource
|
||||
private IOrganizationService organizationService;
|
||||
|
||||
|
||||
/***********************************
|
||||
* 用途说明:获取企业列表
|
||||
* 参数说明
|
||||
* id 企业id
|
||||
* orgName 部门名称
|
||||
* 返回值说明: 企业列表集合
|
||||
***********************************/
|
||||
@PostMapping("/getOrganization")
|
||||
@ResponseBody
|
||||
public List<Map<String, Object>> getOrganization(String appId, String parentid, String orgName) {
|
||||
return organizationService.getOrganization(appId, parentid, orgName);
|
||||
}
|
||||
|
||||
/***********************************
|
||||
* 用途说明:根据企业ID查询部门信息
|
||||
* 参数说明
|
||||
* id 企业id
|
||||
* orgName 部门名称
|
||||
* 返回值说明: 系统部门框架对象
|
||||
***********************************/
|
||||
@PostMapping("/getOrganizationById")
|
||||
@ResponseBody
|
||||
public ResponseResult getOrganizationById(String id, String orgName) {
|
||||
if (StrUtil.isBlank(id)) {
|
||||
return ResponseResult.error("查询失败!");
|
||||
}
|
||||
List<Organization> Organizations = organizationService.getOrganizationById(id, orgName);
|
||||
return ResponseResult.successData(Organizations);
|
||||
}
|
||||
|
||||
|
||||
/***********************************
|
||||
* 用途说明:新增系统组织框架
|
||||
* 参数说明
|
||||
* organization 系统组织框架对象
|
||||
* 返回值说明: 是否新增成功
|
||||
***********************************/
|
||||
@PostMapping("/addOrganization")
|
||||
@ResponseBody
|
||||
public ResponseResult addOrganization(@RequestBody Organization organization) {
|
||||
if (organization == null) {
|
||||
return ResponseResult.error("组织信息不能为空");
|
||||
}
|
||||
//新增 系统组织R
|
||||
boolean isOk = organizationService.addOrganization(organization);
|
||||
if (isOk) {
|
||||
return ResponseResult.success();
|
||||
} else {
|
||||
return ResponseResult.error("新增失败,未知原因");
|
||||
}
|
||||
}
|
||||
|
||||
/***********************************
|
||||
* 用途说明:修改系统组织框架
|
||||
* 参数说明
|
||||
* organization 系统组织框架对象
|
||||
* 返回值说明: 是否修改成功
|
||||
***********************************/
|
||||
@PostMapping("/updateOrganizationById")
|
||||
@ResponseBody
|
||||
public ResponseResult updateOrganizationById(@RequestBody Organization organization) {
|
||||
if (organization == null) {
|
||||
return ResponseResult.error("组织信息不能为空");
|
||||
}
|
||||
//填写 最近修改者
|
||||
organization.setLastmodifier("admin");
|
||||
//填写 最近修改时间
|
||||
organization.setLastmodifydate(LocalDateTime.now());
|
||||
//根据id 修改系统组织
|
||||
boolean isOk = organizationService.updateById(organization);
|
||||
if (isOk) {
|
||||
return ResponseResult.success();
|
||||
} else {
|
||||
return ResponseResult.error();
|
||||
}
|
||||
}
|
||||
|
||||
/***********************************
|
||||
* 用途说明:设置组织是否有效
|
||||
* 参数说明
|
||||
* sysOrganization 系统组织框架对象
|
||||
* 返回值说明: 是否修改成功
|
||||
***********************************/
|
||||
@PostMapping("/setIsValid")
|
||||
@ResponseBody
|
||||
public ResponseResult setIsValid(@RequestParam String id, @RequestParam String isvaild) {
|
||||
// 参数校验
|
||||
if (id == null || id.isEmpty() || isvaild == null || isvaild.isEmpty()) {
|
||||
return ResponseResult.error("参数不能为空");
|
||||
}
|
||||
// 校验 isvalid 的合法性(示例)
|
||||
if (!"0".equals(isvaild) && !"1".equals(isvaild)) {
|
||||
return ResponseResult.error("isvaild 参数不合法");
|
||||
}
|
||||
UpdateWrapper<Organization> updateWrapper = new UpdateWrapper<>();
|
||||
updateWrapper.eq("id", id)
|
||||
.set("isvaild", isvaild)
|
||||
.set("lastmodifier", "admin")
|
||||
.set("lastmodifydate", LocalDateTime.now());
|
||||
boolean isOk = organizationService.update(updateWrapper);
|
||||
if (isOk) {
|
||||
return ResponseResult.success();
|
||||
} else {
|
||||
return ResponseResult.error();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/***********************************
|
||||
* 用途说明:根据id删除系统组织框架
|
||||
* 参数说明
|
||||
* id 系统组织框架id
|
||||
* 返回值说明: 是否删除成功
|
||||
***********************************/
|
||||
@DeleteMapping("/deleteById")
|
||||
@ResponseBody
|
||||
public ResponseResult deleteById(@RequestParam String id) {
|
||||
String[] orgIds = id.split(",");
|
||||
for (String orgId : orgIds) {
|
||||
LambdaQueryWrapper<Organization> queryWrapper = new LambdaQueryWrapper<>();
|
||||
List<Organization> list = organizationService.list(queryWrapper.eq(Organization::getParentid, orgId));
|
||||
List<String> ids = list.stream().map(Organization::getId).collect(Collectors.toList());
|
||||
boolean isOk = organizationService.removeById(orgId);
|
||||
if (!isOk) {
|
||||
continue;
|
||||
}
|
||||
for (String oid : ids) {
|
||||
organizationService.removeById(oid);
|
||||
}
|
||||
}
|
||||
return ResponseResult.success();
|
||||
}
|
||||
}
|
@ -0,0 +1,177 @@
|
||||
package io.gisbi.application.system.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||
import io.gisbi.application.system.domain.Role;
|
||||
import io.gisbi.application.system.service.IRoleService;
|
||||
import io.gisbi.application.system.service.IUserService;
|
||||
import io.gisbi.config.ResponseResult;
|
||||
import io.gisbi.utils.AuthUtils;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 角色 前端控制器
|
||||
* </p>
|
||||
*
|
||||
* @author lilin
|
||||
* @since 2025-05-08
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/role")
|
||||
public class RoleController {
|
||||
|
||||
@Resource
|
||||
private IRoleService roleService;
|
||||
|
||||
@Resource
|
||||
private IUserService userService;
|
||||
|
||||
|
||||
/***********************************
|
||||
* 用途说明:查询所有角色
|
||||
* 参数说明
|
||||
* rolename 角色名称
|
||||
* 返回值说明: 查询都有角色
|
||||
***********************************/
|
||||
@PostMapping("/listRole")
|
||||
@ResponseBody
|
||||
public List<Role> listRole(String appId, String rolename) {
|
||||
return roleService.listRole(appId,rolename);
|
||||
}
|
||||
|
||||
/***********************************
|
||||
* 用途说明:根据Id获取当个角色
|
||||
* 参数说明
|
||||
* id 角色表id
|
||||
* 返回值说明: 根据id查询到角色详情
|
||||
***********************************/
|
||||
@PostMapping("/getRoleById")
|
||||
@ResponseBody
|
||||
public ResponseResult getOneById(String id) {
|
||||
Role role = roleService.getById(id);
|
||||
return ResponseResult.successData(role);
|
||||
}
|
||||
|
||||
/***********************************
|
||||
* 用途说明:新增角色
|
||||
* 参数说明
|
||||
* sysRole 新增角色信息
|
||||
* 返回值说明: 是否新增成功
|
||||
***********************************/
|
||||
@PostMapping("/addRole")
|
||||
@ResponseBody
|
||||
public ResponseResult addRole(@RequestBody Role role) {
|
||||
boolean isOk = roleService.addRole(role);
|
||||
if (isOk) {
|
||||
return ResponseResult.success();
|
||||
} else {
|
||||
return ResponseResult.error();
|
||||
}
|
||||
}
|
||||
|
||||
/***********************************
|
||||
* 用途说明:更新角色信息
|
||||
* 参数说明
|
||||
* role 角色对象
|
||||
* 返回值说明: 是否修改成功
|
||||
***********************************/
|
||||
@PostMapping("/updateRoleById")
|
||||
@ResponseBody
|
||||
public ResponseResult updateRoleById(@RequestBody Role role) {
|
||||
//更新最近修改人
|
||||
role.setLastmodifier(AuthUtils.getUser().getUserId().toString());
|
||||
//更新最近修改时间
|
||||
role.setLastmodifydate(LocalDateTime.now());
|
||||
//根据id更新角色信息
|
||||
boolean ok = roleService.updateById(role);
|
||||
if (ok) {
|
||||
return ResponseResult.success();
|
||||
} else {
|
||||
return ResponseResult.error();
|
||||
}
|
||||
}
|
||||
|
||||
/***********************************
|
||||
* 用途说明:根据id删除角色
|
||||
* 参数说明
|
||||
* id 角色id
|
||||
* 返回值说明: 是否删除成功
|
||||
***********************************/
|
||||
@PostMapping("/deleteRoleById")
|
||||
@ResponseBody
|
||||
public ResponseResult deleteRoleById(@RequestParam String id) {
|
||||
roleService.deleteById(id);
|
||||
return ResponseResult.success();
|
||||
}
|
||||
|
||||
/***********************************
|
||||
* 用途说明:设置角色是否有效
|
||||
* 参数说明
|
||||
* id 角色id
|
||||
*isvaild 是否有效(1 是 0 否 )
|
||||
* 返回值说明: 是否新增成功
|
||||
***********************************/
|
||||
@PostMapping("/setIsvaild")
|
||||
@ResponseBody
|
||||
public ResponseResult setIsvaild(String id, String isvaild) {
|
||||
UpdateWrapper<Role> updateWrapper = new UpdateWrapper<>();
|
||||
//根据id 更新业务范围,最近修改人,最近修改时间
|
||||
updateWrapper.eq("id", id)
|
||||
.set("isvaild", isvaild)
|
||||
.set("lastmodifier", AuthUtils.getUser().getUserId().toString())
|
||||
.set("lastmodifydate",LocalDateTime.now());
|
||||
boolean ok = roleService.update(updateWrapper);
|
||||
if (ok) {
|
||||
return ResponseResult.success();
|
||||
} else {
|
||||
return ResponseResult.error();
|
||||
}
|
||||
}
|
||||
|
||||
/***********************************
|
||||
* 用途说明:角色添加用户
|
||||
* 参数说明
|
||||
* roleid 角色id
|
||||
* userids 用户id组
|
||||
* 返回值说明: 是否新增成功
|
||||
***********************************/
|
||||
@PostMapping("/setRoleUsers")
|
||||
@ResponseBody
|
||||
public ResponseResult setRoleUsers(String roleid, String userids) {
|
||||
boolean isOk = true;
|
||||
String[] temp = userids.split(",");
|
||||
for (String userid : temp) {
|
||||
isOk = isOk && userService.addUserRoles(roleid, userid);
|
||||
}
|
||||
if (isOk) {
|
||||
return ResponseResult.success();
|
||||
} else {
|
||||
return ResponseResult.error();
|
||||
}
|
||||
}
|
||||
|
||||
/***********************************
|
||||
* 用途说明:删除角色用户
|
||||
* 参数说明
|
||||
* roleid 角色id
|
||||
* 返回值说明: 是否新增成功
|
||||
***********************************/
|
||||
@PostMapping("/deleteRoleUser")
|
||||
@ResponseBody
|
||||
public ResponseResult deleteRoleUsers(@RequestParam String roleid,
|
||||
@RequestParam String userids) {
|
||||
//根据角色id、用户id删除
|
||||
boolean ok = roleService.deleteRoleUsers(roleid, userids);
|
||||
if (ok) {
|
||||
return ResponseResult.success();
|
||||
} else {
|
||||
return ResponseResult.error();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,160 @@
|
||||
package io.gisbi.application.system.controller;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import io.gisbi.application.system.domain.User;
|
||||
import io.gisbi.application.system.service.IUserService;
|
||||
import io.gisbi.config.ResponseResult;
|
||||
import io.micrometer.common.util.StringUtils;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 用户 前端控制器
|
||||
* </p>
|
||||
*
|
||||
* @author lilin
|
||||
* @since 2025-05-08
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/user")
|
||||
public class UserController {
|
||||
|
||||
@Resource
|
||||
private IUserService userService;
|
||||
|
||||
/***********************************
|
||||
* 用途说明:新增系统用户
|
||||
* 参数说明
|
||||
* user 用户对象
|
||||
* roleids 角色ID
|
||||
* 返回值说明: 是否新增成功
|
||||
***********************************/
|
||||
@PostMapping("/addUser")
|
||||
@ResponseBody
|
||||
public ResponseResult addUser(@RequestBody User user, String roleids) {
|
||||
Map reslut = userService.addUser(user, roleids);
|
||||
return ResponseResult.successData(reslut);
|
||||
}
|
||||
|
||||
/***********************************
|
||||
* 用途说明:修改用户信息
|
||||
* 参数说明
|
||||
* user 用户对象
|
||||
* roleids 角色ID
|
||||
* 返回值说明: 是否新增成功
|
||||
***********************************/
|
||||
@PostMapping("/updateUser")
|
||||
@ResponseBody
|
||||
public ResponseResult updateUser(@RequestBody User user, String roleids) {
|
||||
if (StringUtils.isEmpty(user.getId())) {
|
||||
return ResponseResult.error("没有用户ID");
|
||||
}
|
||||
Map reslut = userService.updateById(user, roleids);
|
||||
return ResponseResult.successData(reslut);
|
||||
}
|
||||
|
||||
/***********************************
|
||||
* 用途说明:查询用户信息
|
||||
* 参数说明
|
||||
* orgid 所属组织ID
|
||||
* nickname 用户昵称
|
||||
* page 分页条件
|
||||
* 返回值说明: 用户信息集合
|
||||
***********************************/
|
||||
@GetMapping("/queryUsers")
|
||||
@ResponseBody
|
||||
public ResponseResult queryUsers(String orgid,String appId, String nickname, Page<User> page) {
|
||||
Page<Map<String, Object>> mapPage = userService.queryUsers(orgid, appId, nickname, page);
|
||||
return ResponseResult.successData(mapPage);
|
||||
}
|
||||
|
||||
/***********************************
|
||||
* 用途说明:根据ID删除用户
|
||||
* 参数说明
|
||||
*id 用户id
|
||||
* 返回值说明: 判断是否删除成功
|
||||
************************************/
|
||||
@PostMapping("/deleteUserById")
|
||||
@ResponseBody
|
||||
public ResponseResult deleteUserById(String id) {
|
||||
if (id == null || id.trim().isEmpty()) {
|
||||
return ResponseResult.error("用户ID不能为空");
|
||||
}
|
||||
boolean result = userService.deleteUserById(id);
|
||||
if (!result) {
|
||||
return ResponseResult.error("删除用户失败,可能用户不存在");
|
||||
}
|
||||
return ResponseResult.success();
|
||||
}
|
||||
|
||||
/***********************************
|
||||
* 用途说明:根据ID批量删除用户
|
||||
* 参数说明
|
||||
*ids 用户id集合
|
||||
* 返回值说明: 判断是否删除成功
|
||||
************************************/
|
||||
@PostMapping("/deleteUserByIds")
|
||||
@ResponseBody
|
||||
public ResponseResult deleteUserByIds(String ids) {
|
||||
if (StringUtils.isBlank(ids)) {
|
||||
return ResponseResult.error("参数为空");
|
||||
}
|
||||
boolean ok = userService.deleteUserByIds(ids);
|
||||
if (ok) {
|
||||
return ResponseResult.success();
|
||||
} else {
|
||||
return ResponseResult.error();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/***********************************
|
||||
* 用途说明:设置账号状态(管理员)
|
||||
* 参数说明
|
||||
*id 用户id
|
||||
* status 设置状态
|
||||
* 返回值说明: 判断是否设置成功
|
||||
************************************/
|
||||
@PostMapping("/setStatus")
|
||||
@ResponseBody
|
||||
public ResponseResult setStatus(@RequestParam String id,@RequestParam String status) {
|
||||
if (StringUtils.isEmpty(id)) {
|
||||
return ResponseResult.error("用户ID为空");
|
||||
}
|
||||
if (StringUtils.isEmpty(status)) {
|
||||
return ResponseResult.error("设置状态为空");
|
||||
}
|
||||
boolean ok = userService.setStatus(id, status);
|
||||
if (ok) {
|
||||
return ResponseResult.success();
|
||||
} else {
|
||||
return ResponseResult.error();
|
||||
}
|
||||
}
|
||||
|
||||
/***********************************
|
||||
* 用途说明:重置用户密码(管理员)
|
||||
* 参数说明
|
||||
*id 重置密码的 用户id
|
||||
* 返回值说明: 判断是否重置成功
|
||||
************************************/
|
||||
@PostMapping("/resetPassword")
|
||||
@ResponseBody
|
||||
public ResponseResult resetPassword(String id) throws Exception {
|
||||
if (StrUtil.isBlank(id)) {
|
||||
ResponseResult.error("参数为空");
|
||||
}
|
||||
boolean ok = userService.resetPassword(id);
|
||||
if (ok) {
|
||||
return ResponseResult.success();
|
||||
} else {
|
||||
return ResponseResult.error();
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,85 @@
|
||||
package io.gisbi.application.system.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@TableName("app_menu")
|
||||
public class Menu {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* ID
|
||||
*/
|
||||
private String id;
|
||||
/**
|
||||
* 应用ID 关联应用系统
|
||||
*/
|
||||
private String appId;
|
||||
/**
|
||||
* 菜单类型 01-目录 02-菜单
|
||||
*/
|
||||
private String type;
|
||||
/**
|
||||
* 菜单编号
|
||||
*/
|
||||
private String code;
|
||||
/**
|
||||
* 同级序号
|
||||
*/
|
||||
private Integer orderno;
|
||||
/**
|
||||
* 菜单名称
|
||||
*/
|
||||
private String name;
|
||||
/**
|
||||
* 菜单图标 base64存储
|
||||
*/
|
||||
private String icon;
|
||||
/**
|
||||
* 是否外链 0-非外部 1-是外链
|
||||
*/
|
||||
private String islink;
|
||||
/**
|
||||
* 菜单URL 内部资源页面URL访问地址
|
||||
*/
|
||||
private String url;
|
||||
/**
|
||||
* 模块ID 菜单关联的模块ID
|
||||
*/
|
||||
private String moduleId;
|
||||
/**
|
||||
* 父级菜单ID 顶级为0
|
||||
*/
|
||||
private String parentid;
|
||||
/**
|
||||
* 是否显示 0-不显示 1-显示
|
||||
*/
|
||||
private String isdisplay;
|
||||
/**
|
||||
* 最近修改者
|
||||
*/
|
||||
private String lastmodifier;
|
||||
/**
|
||||
* 最近修改日期
|
||||
*/
|
||||
private LocalDateTime lastmodifydate;
|
||||
/**
|
||||
* 备用1
|
||||
*/
|
||||
private String custom1;
|
||||
|
||||
/**
|
||||
* 备用2
|
||||
*/
|
||||
private String custom2;
|
||||
|
||||
/**
|
||||
* 备用3
|
||||
*/
|
||||
private String custom3;
|
||||
}
|
@ -0,0 +1,96 @@
|
||||
package io.gisbi.application.system.domain;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 组织机构
|
||||
* </p>
|
||||
*
|
||||
* @author lilin
|
||||
* @since 2025-05-08
|
||||
*/
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@TableName("app_organization")
|
||||
public class Organization {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* ID
|
||||
*/
|
||||
private String id;
|
||||
/**
|
||||
* 应用ID 关联应用系统
|
||||
*/
|
||||
private String appId;
|
||||
/**
|
||||
* 组织类型:01-公司 02-部门
|
||||
*/
|
||||
private String orgtype;
|
||||
/**
|
||||
* 组织编号
|
||||
*/
|
||||
private String orgcode;
|
||||
/**
|
||||
* 组织名称
|
||||
*/
|
||||
private String orgname;
|
||||
/**
|
||||
* 上级ID
|
||||
*/
|
||||
private String parentid;
|
||||
/**
|
||||
* 组织负责人
|
||||
*/
|
||||
private String manager;
|
||||
/**
|
||||
* 组织详情
|
||||
*/
|
||||
private String description;
|
||||
/**
|
||||
* 联系地址
|
||||
*/
|
||||
private String address;
|
||||
/**
|
||||
* 联系电话
|
||||
*/
|
||||
private String contactPhone;
|
||||
/**
|
||||
* 联系人
|
||||
*/
|
||||
private String contactPerson;
|
||||
/**
|
||||
* 是否有效 1-是 0-否
|
||||
*/
|
||||
private String isvaild;
|
||||
/**
|
||||
* 最近修改者
|
||||
*/
|
||||
private String lastmodifier;
|
||||
/**
|
||||
* 最近修改日期
|
||||
*/
|
||||
private LocalDateTime lastmodifydate;
|
||||
/**
|
||||
* 备用1
|
||||
*/
|
||||
private String custom1;
|
||||
|
||||
/**
|
||||
* 备用2
|
||||
*/
|
||||
private String custom2;
|
||||
|
||||
/**
|
||||
* 备用3
|
||||
*/
|
||||
private String custom3;
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,74 @@
|
||||
package io.gisbi.application.system.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 角色
|
||||
* </p>
|
||||
*
|
||||
* @author lilin
|
||||
* @since 2025-05-08
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@TableName("app_role")
|
||||
public class Role {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* ID
|
||||
*/
|
||||
private String id;
|
||||
/**
|
||||
* 应用ID 关联应用系统
|
||||
*/
|
||||
private String appId;
|
||||
/**
|
||||
* 角色编号 系统生成,三位编号
|
||||
*/
|
||||
private String rolecode;
|
||||
/**
|
||||
* 角色名称
|
||||
*/
|
||||
private String rolename;
|
||||
/**
|
||||
* 角色类别 1-应用管理员 2-应用普通用户
|
||||
*/
|
||||
private String type;
|
||||
/**
|
||||
* 角色描述
|
||||
*/
|
||||
private String description;
|
||||
/**
|
||||
* 是否有效 1-是 0-否
|
||||
*/
|
||||
private String isvaild;
|
||||
/**
|
||||
* 最近修改者
|
||||
*/
|
||||
private String lastmodifier;
|
||||
/**
|
||||
* 最近修改日期
|
||||
*/
|
||||
private LocalDateTime lastmodifydate;
|
||||
/**
|
||||
* 备用1
|
||||
*/
|
||||
private String custom1;
|
||||
|
||||
/**
|
||||
* 备用2
|
||||
*/
|
||||
private String custom2;
|
||||
|
||||
/**
|
||||
* 备用3
|
||||
*/
|
||||
private String custom3;
|
||||
|
||||
}
|
@ -0,0 +1,110 @@
|
||||
package io.gisbi.application.system.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 用户
|
||||
* </p>
|
||||
*
|
||||
* @author lilin
|
||||
* @since 2025-05-08
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@TableName("app_user")
|
||||
public class User {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* ID
|
||||
*/
|
||||
private String id;
|
||||
/**
|
||||
* 应用ID 关联应用系统
|
||||
*/
|
||||
private String appId;
|
||||
/**
|
||||
* 所属组织
|
||||
*/
|
||||
private String orgid;
|
||||
/**
|
||||
* 用户类型 0-管理员 1-普通用户
|
||||
*/
|
||||
private String usertype;
|
||||
/**
|
||||
* 用户名称 用户名称(账号)
|
||||
*/
|
||||
private String username;
|
||||
/**
|
||||
* 用户昵称(中文)
|
||||
*/
|
||||
private String nickname;
|
||||
/**
|
||||
* 登录密码
|
||||
*/
|
||||
private String password;
|
||||
/**
|
||||
* 邮箱
|
||||
*/
|
||||
private String email;
|
||||
/**
|
||||
* 手机号
|
||||
*/
|
||||
private String phone;
|
||||
/**
|
||||
* 头像(预留)
|
||||
*/
|
||||
private String avatar;
|
||||
/**
|
||||
* 账号状态(1-正常 0-停用)
|
||||
*/
|
||||
private String status;
|
||||
/**
|
||||
* 密码有限期 密码有限期(天)
|
||||
*/
|
||||
private Integer pwdvalidperiod;
|
||||
/**
|
||||
* 登录失败次数 允许的登录失败次数
|
||||
*/
|
||||
private Integer failednum;
|
||||
/**
|
||||
* 用户指定登录IP 如果设置了IP,则只允许IP用户登录
|
||||
*/
|
||||
private String loginip;
|
||||
/**
|
||||
* 登录失败锁定时间
|
||||
*/
|
||||
private LocalDateTime failedlocktime;
|
||||
/**
|
||||
* 密码修改时间
|
||||
*/
|
||||
private LocalDateTime pwdresettime;
|
||||
/**
|
||||
* 最近修改者
|
||||
*/
|
||||
private String lastmodifier;
|
||||
/**
|
||||
* 最近修改日期
|
||||
*/
|
||||
private LocalDateTime lastmodifydate;
|
||||
/**
|
||||
* 备用1
|
||||
*/
|
||||
private String custom1;
|
||||
|
||||
/**
|
||||
* 备用2
|
||||
*/
|
||||
private String custom2;
|
||||
|
||||
/**
|
||||
* 备用3
|
||||
*/
|
||||
private String custom3;
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
package io.gisbi.application.system.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import io.gisbi.application.system.domain.Menu;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
public interface MenuMapper extends BaseMapper<Menu> {
|
||||
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
package io.gisbi.application.system.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import io.gisbi.application.system.domain.Organization;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
public interface OrganizationMapper extends BaseMapper<Organization> {
|
||||
}
|
@ -0,0 +1,49 @@
|
||||
package io.gisbi.application.system.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import io.gisbi.application.system.domain.Role;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface RoleMapper extends BaseMapper<Role> {
|
||||
/**********************************
|
||||
* 用途说明: 根据用户id获取角色信息
|
||||
* 参数说明 id 角色id
|
||||
* 返回值说明: void
|
||||
***********************************/
|
||||
List<Role> getRoleByUserId(String id);
|
||||
|
||||
/**********************************
|
||||
* 用途说明: 根据用户id获取角色id
|
||||
* 参数说明 userid 用户id
|
||||
* 返回值说明: void
|
||||
***********************************/
|
||||
List<String> getRoleUsers(String userid, String appId);
|
||||
|
||||
/***********************************
|
||||
* 用途说明:根据角色id删除角色菜单关联
|
||||
* 参数说明
|
||||
*id 角色id
|
||||
* 返回值说明: 是否删除成功
|
||||
***********************************/
|
||||
void deleteRoleMenus(String roleId);
|
||||
|
||||
/***********************************
|
||||
* 用途说明:根据角色id删除角色用户关联
|
||||
* 参数说明
|
||||
*id 角色id
|
||||
* 返回值说明: 是否删除成功
|
||||
***********************************/
|
||||
void deleteRoleUser(String roleId);
|
||||
|
||||
/***********************************
|
||||
* 用途说明:根据 角色id和用户id 删除 (admin除外)
|
||||
* 参数说明
|
||||
*roleid 角色id
|
||||
* urserid 用户id
|
||||
* 返回值说明: 是否删除成功
|
||||
***********************************/
|
||||
boolean deleteRoleUsers(String roleid, String urserid);
|
||||
}
|
@ -0,0 +1,78 @@
|
||||
package io.gisbi.application.system.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import io.gisbi.application.system.domain.User;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Mapper
|
||||
public interface UserMapper extends BaseMapper<User> {
|
||||
|
||||
|
||||
/***********************************
|
||||
* 用途说明:新增系统角色用户对照表 对用户分配角色
|
||||
* 参数说明
|
||||
* roleid 角色id
|
||||
* userid 用户id
|
||||
* 返回值说明:
|
||||
************************************/
|
||||
boolean addUserRoles(@Param("id") String id, @Param("appid") String appid, @Param("roleid") String roleid,@Param("userid") String userid);
|
||||
|
||||
/***********************************
|
||||
* 用途说明:根据用户表id查询角色表所有角色id
|
||||
* 参数说明
|
||||
* userid 用户id
|
||||
* 返回值说明:
|
||||
************************************/
|
||||
List<String> getRoleid(@Param("userid") String id);
|
||||
|
||||
/***********************************
|
||||
* 用途说明:根据用户id删除所分配的不包含角色
|
||||
* 参数说明
|
||||
* userid 用户id
|
||||
* roleids 多个角色id
|
||||
* 返回值说明:
|
||||
************************************/
|
||||
void delInRoleUsersByUserid(@Param("userid") String userid,@Param("roleids")String[] roleids);
|
||||
|
||||
/***********************************
|
||||
* 用途说明:根据用户id删除所分配的角色
|
||||
* 参数说明
|
||||
* userid 用户id
|
||||
* 返回值说明:
|
||||
************************************/
|
||||
boolean delRoleUsersByUserid( @Param("userid") String id);
|
||||
|
||||
/***********************************
|
||||
* 用途说明:根据条件分页查询用户信息
|
||||
* 参数说明
|
||||
* orgid 所属组织ID
|
||||
* nickname 用户昵称
|
||||
* page 分页条件
|
||||
* 返回值说明:
|
||||
************************************/
|
||||
Page<Map<String, Object>> queryUsers(String orgid,String appId, String nickname, Page<User> page);
|
||||
|
||||
|
||||
/***********************************
|
||||
* 用途说明:根据ID删除用户与角色的关联信息
|
||||
* 参数说明
|
||||
* idList 用户id集合
|
||||
* 返回值说明:
|
||||
************************************/
|
||||
void delRoleUsersByUserIds(List<String> idList);
|
||||
|
||||
/***********************************
|
||||
* 用途说明:根据用户id 和角色id 查询 系统角色用户对照表
|
||||
* 参数说明
|
||||
* userid 用户id
|
||||
* roleid 角色id
|
||||
* 返回值说明:
|
||||
************************************/
|
||||
|
||||
List<Map> getRoleUsersByid(@Param("roleid") String roleid,@Param("userid") String userid);
|
||||
}
|
@ -0,0 +1,6 @@
|
||||
<?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="io.gisbi.application.system.mapper.MenuMapper">
|
||||
|
||||
|
||||
</mapper>
|
@ -0,0 +1,5 @@
|
||||
<?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="io.gisbi.application.system.mapper.OrganizationMapper">
|
||||
|
||||
</mapper>
|
@ -0,0 +1,52 @@
|
||||
package io.gisbi.application.system.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import io.gisbi.application.system.domain.Menu;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
/**
|
||||
* <p>
|
||||
* 菜单及按钮 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author lilin
|
||||
* @since 2025-05-08
|
||||
*/
|
||||
public interface IMenuService extends IService<Menu> {
|
||||
/***********************************
|
||||
* 用途说明:获取菜单结构树(含按钮)
|
||||
* 参数说明
|
||||
* appId 应用ID 关联应用系统
|
||||
* name 名称
|
||||
* isdisplay 是否显示
|
||||
* 返回值说明: 菜单结构树集合
|
||||
***********************************/
|
||||
List<Map<String, Object>> getMenuButtonTree(String appId, String name, String isdisplay);
|
||||
|
||||
/***********************************
|
||||
* 用途说明:获取菜单结构树(不含按钮)
|
||||
* 参数说明
|
||||
* appId 应用ID 关联应用系统
|
||||
* name 名称
|
||||
* isdisplay 是否显示
|
||||
* 返回值说明: 菜单结构树集合
|
||||
***********************************/
|
||||
List<Map<String, Object>> getMenuTree(String appId, String name, String isdisplay);
|
||||
|
||||
/***********************************
|
||||
* 用途说明:新增菜单及按钮
|
||||
* 参数说明
|
||||
* sysMenu 菜单或按钮表对象
|
||||
* 返回值说明: 是否添加成功提示
|
||||
***********************************/
|
||||
boolean addMenu(Menu menu);
|
||||
|
||||
/***********************************
|
||||
* 用途说明:根据id删除菜单或按钮
|
||||
* 参数说明
|
||||
* id 删除列的id
|
||||
* 返回值说明: 是否删除成功
|
||||
***********************************/
|
||||
boolean deleteById(String id);
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
package io.gisbi.application.system.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import io.gisbi.application.system.domain.Organization;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 组织机构 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author lilin
|
||||
* @since 2025-05-08
|
||||
*/
|
||||
public interface IOrganizationService extends IService<Organization> {
|
||||
/***********************************
|
||||
* 用途说明:获取企业列表
|
||||
* 参数说明
|
||||
* 返回值说明: 企业列表集合
|
||||
***********************************/
|
||||
List<Map<String, Object>> getOrganization(String appId, String parentid, String orgname);
|
||||
|
||||
/***********************************
|
||||
* 用途说明:根据企业ID查询部门信息
|
||||
* 参数说明
|
||||
* id 企业id
|
||||
* orgName 部门名称
|
||||
* 返回值说明: 系统部门框架对象
|
||||
***********************************/
|
||||
List<Organization> getOrganizationById(String id, String orgName);
|
||||
|
||||
/***********************************
|
||||
* 用途说明:新增系统组织框架
|
||||
* 参数说明
|
||||
* Organization 系统组织框架对象
|
||||
* 返回值说明: 是否新增成功
|
||||
***********************************/
|
||||
boolean addOrganization(Organization organization);
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,50 @@
|
||||
package io.gisbi.application.system.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import io.gisbi.application.system.domain.Role;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 角色 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author lilin
|
||||
* @since 2025-05-08
|
||||
*/
|
||||
public interface IRoleService extends IService<Role> {
|
||||
|
||||
/**********************************
|
||||
* 用途说明: 根据用户id获取角色id
|
||||
* 参数说明 userid 用户id
|
||||
* 返回值说明: void
|
||||
***********************************/
|
||||
List<String> getRoleUsers(String userid,String appId);
|
||||
|
||||
/***********************************
|
||||
* 用途说明:新增角色
|
||||
* 参数说明
|
||||
* sysRole 新增角色信息
|
||||
* 返回值说明: 是否新增成功
|
||||
***********************************/
|
||||
boolean addRole(Role role);
|
||||
|
||||
/***********************************
|
||||
* 用途说明:查询所有角色
|
||||
* 参数说明
|
||||
* rolename 角色名称
|
||||
* 返回值说明: 查询都有角色
|
||||
***********************************/
|
||||
List<Role> listRole(String appId, String rolename);
|
||||
|
||||
void deleteById(String id);
|
||||
|
||||
/***********************************
|
||||
* 用途说明:删除角色用户
|
||||
* 参数说明
|
||||
* roleid 角色id
|
||||
* 返回值说明: 是否新增成功
|
||||
***********************************/
|
||||
boolean deleteRoleUsers(String roleid, String userids);
|
||||
}
|
@ -0,0 +1,90 @@
|
||||
package io.gisbi.application.system.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import io.gisbi.application.system.domain.User;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 用户 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author lilin
|
||||
* @since 2025-05-08
|
||||
*/
|
||||
public interface IUserService extends IService<User> {
|
||||
|
||||
|
||||
|
||||
/***********************************
|
||||
* 用途说明:新增系统用户
|
||||
* 参数说明
|
||||
* user 用户对象
|
||||
* roleids 角色ID
|
||||
* 返回值说明: 是否新增成功
|
||||
***********************************/
|
||||
Map addUser(User user, String roleids);
|
||||
|
||||
/***********************************
|
||||
* 用途说明:修改用户信息
|
||||
* 参数说明
|
||||
* user 用户对象
|
||||
* roleids 角色ID
|
||||
* 返回值说明: 是否新增成功
|
||||
***********************************/
|
||||
Map updateById(User user, String roleids);
|
||||
|
||||
/***********************************
|
||||
* 用途说明:查询用户信息
|
||||
* 参数说明
|
||||
* orgid 所属组织ID
|
||||
* nickname 用户昵称
|
||||
* page 分页条件
|
||||
* 返回值说明: 用户信息集合
|
||||
***********************************/
|
||||
Page<Map<String, Object>> queryUsers(String orgid, String nickname,String appId, Page<User> page);
|
||||
|
||||
/***********************************
|
||||
* 用途说明:根据id删除用户
|
||||
* 参数说明
|
||||
*id 用户id
|
||||
* 返回值说明: 判断是否删除成功
|
||||
************************************/
|
||||
Boolean deleteUserById(String id);
|
||||
|
||||
/***********************************
|
||||
* 用途说明:根据ID批量删除用户
|
||||
* 参数说明
|
||||
*ids 用户id集合
|
||||
* 返回值说明: 判断是否删除成功
|
||||
************************************/
|
||||
boolean deleteUserByIds(String ids);
|
||||
|
||||
/***********************************
|
||||
* 用途说明:重置用户密码(管理员)
|
||||
* 参数说明
|
||||
*id 重置密码的 用户id
|
||||
* 返回值说明: 判断是否重置成功
|
||||
************************************/
|
||||
boolean resetPassword(String id);
|
||||
|
||||
/***********************************
|
||||
* 用途说明:设置账号状态(管理员)
|
||||
* 参数说明
|
||||
*id 用户id
|
||||
* status 设置状态
|
||||
* 返回值说明: 判断是否设置成功
|
||||
************************************/
|
||||
boolean setStatus(String id, String status);
|
||||
|
||||
/***********************************
|
||||
* 用途说明:角色添加用户
|
||||
* 参数说明
|
||||
* roleid 角色id
|
||||
* userids 用户id组
|
||||
* 返回值说明: 是否新增成功
|
||||
***********************************/
|
||||
boolean addUserRoles(String roleid, String userid);
|
||||
}
|
@ -0,0 +1,242 @@
|
||||
package io.gisbi.application.system.service.impl;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import io.gisbi.application.system.domain.Menu;
|
||||
import io.gisbi.application.system.mapper.MenuMapper;
|
||||
import io.gisbi.application.system.service.IMenuService;
|
||||
import io.gisbi.utils.AuthUtils;
|
||||
import io.micrometer.common.util.StringUtils;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.io.File;
|
||||
import java.sql.Timestamp;
|
||||
import java.text.DecimalFormat;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 菜单及按钮 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author lilin
|
||||
* @since 2025-05-08
|
||||
*/
|
||||
@Service
|
||||
public class MenuServiceImpl extends ServiceImpl<MenuMapper, Menu> implements IMenuService {
|
||||
|
||||
@Resource
|
||||
private MenuMapper menuMapper;
|
||||
|
||||
//菜单图片路径
|
||||
@Value("${file-space.system}")
|
||||
private String sysetmPath;
|
||||
|
||||
@Override
|
||||
public List<Map<String, Object>> getMenuButtonTree(String appId, String name, String isdisplay) {
|
||||
List<Map<String, Object>> listMap = null;
|
||||
//不带名称查询,返回树结构
|
||||
if (StringUtils.isEmpty(name)) {
|
||||
QueryWrapper<Menu> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("parentid", "0").eq("app_id", appId).orderByAsc("orderno");
|
||||
listMap = this.listMaps(queryWrapper);
|
||||
|
||||
for (int i = 0; i < listMap.size(); i++) {
|
||||
//查询下一子集
|
||||
List<Map<String, Object>> childList = child(listMap.get(i).get(
|
||||
"id").toString(), appId, name, null, null);
|
||||
listMap.get(i).put("children", childList); //添加新列 子集
|
||||
}
|
||||
} else { //根据菜单名称查询,直接返回类别
|
||||
QueryWrapper<Menu> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.like("name", name).eq("app_id", appId).orderByAsc("name");
|
||||
listMap = this.listMaps(queryWrapper);
|
||||
}
|
||||
return listMap;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Map<String, Object>> getMenuTree(String appId, String name, String isdisplay) {
|
||||
|
||||
QueryWrapper<Menu> queryWrapper = new QueryWrapper<>();
|
||||
if (StringUtils.isNotEmpty(isdisplay)) {
|
||||
queryWrapper.eq("isdisplay", isdisplay);
|
||||
} else {
|
||||
queryWrapper.eq("isdisplay", 1);
|
||||
}
|
||||
|
||||
//根据系统 ,类型不为2 显示,序号 正序排序
|
||||
queryWrapper.eq("parentid", "0").eq("systemcode", appId).ne(
|
||||
"type", "02").orderByAsc("orderno");
|
||||
List<Map<String, Object>> listMap = this.listMaps(queryWrapper);
|
||||
for (int i = 0; i < listMap.size(); i++) {
|
||||
List<Map<String, Object>> childList = child(listMap.get(i).get(
|
||||
"id").toString(), appId, name, isdisplay, "02");//查询下一子集
|
||||
listMap.get(i).put("children", childList); //添加新列 子集
|
||||
}
|
||||
return listMap;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addMenu(Menu menu) {
|
||||
String parentId = menu.getParentid();
|
||||
QueryWrapper<Menu> queryWrapper = new QueryWrapper<>();
|
||||
//根据上级id 查询到总数 并累加
|
||||
int orderno = (int) (this.count(queryWrapper.eq("parentid", parentId)) + 1);
|
||||
// 生成排序号
|
||||
// 生成编号
|
||||
QueryWrapper<Menu> queryMaxCode = new QueryWrapper<>();
|
||||
queryMaxCode.eq("parentid", parentId);
|
||||
// 查询最大的编号
|
||||
List<Object> maxList = this.listObjs(queryMaxCode.select("max(code) " +
|
||||
"code").eq("app_id", menu.getAppId()));
|
||||
Menu parentMenu = menuMapper.selectById(parentId);
|
||||
// 最大编号转换成int类型
|
||||
String maxCode = maxList.isEmpty() ? "0" : (maxList.get(0) != null ? maxList.get(0).toString() : "0");
|
||||
int max = ObjectUtil.isEmpty(maxList) ? 0 : Integer.parseInt(maxCode);
|
||||
DecimalFormat df;
|
||||
if ("0".equals(menu.getParentid())) {
|
||||
df = new DecimalFormat("00");
|
||||
} else if (parentMenu.getCode().length() == 2) {
|
||||
df = new DecimalFormat("0000");
|
||||
} else {
|
||||
df = new DecimalFormat("000000");
|
||||
}
|
||||
//DecimalFormat df = new DecimalFormat("00");
|
||||
//int parentCode = Integer.parseInt(parentMenu.getCode());
|
||||
String parentCode = "";
|
||||
if (parentMenu != null) {
|
||||
parentCode = parentMenu.getCode();
|
||||
}
|
||||
// 生成的新编号 年月日+4位编号
|
||||
String code;
|
||||
if (max > 0) {
|
||||
code = df.format(max + 1);
|
||||
} else {
|
||||
max = max + 1;
|
||||
if (StringUtils.isBlank(parentCode)) {
|
||||
parentCode = "0" + max;
|
||||
} else {
|
||||
int i = Integer.parseInt(parentCode);
|
||||
parentCode = i + "0" + max;
|
||||
}
|
||||
|
||||
int format = Integer.parseInt(parentCode);
|
||||
code = df.format(format);
|
||||
}
|
||||
|
||||
// 判断是否显示字段 是否填写 为空
|
||||
if (StringUtils.isEmpty(menu.getIsdisplay())) {
|
||||
// 默认设置成 1 显示
|
||||
menu.setIsdisplay("1");
|
||||
}
|
||||
// 判断是否填写父级id 为空 默认设置成 0
|
||||
if (StringUtils.isEmpty(menu.getParentid())) {
|
||||
menu.setParentid("0");
|
||||
}
|
||||
// 添加编号
|
||||
menu.setCode(code);
|
||||
// 添加排序号
|
||||
menu.setOrderno(orderno);
|
||||
//填写 当前用户名称
|
||||
menu.setLastmodifier(AuthUtils.getUser().getUserId().toString());
|
||||
//填写 当前日期
|
||||
menu.setLastmodifydate(LocalDateTime.now());
|
||||
return this.save(menu);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean deleteById(String id) {
|
||||
//根据id查询
|
||||
Menu menu = this.getById(id);
|
||||
//图片路径
|
||||
String iconname = sysetmPath + "menu" + File.separator + menu.getIcon();
|
||||
//删除图标
|
||||
new File(iconname).delete();
|
||||
//根据id删除
|
||||
boolean isOk = this.removeById(id);
|
||||
//删除成功同步更新表数据
|
||||
if (isOk) {
|
||||
//1 创建list集合,用于封装所有删除目录或菜单id值
|
||||
List<String> idList = new ArrayList<>();
|
||||
this.selectPermissionChildById(id, idList);
|
||||
if (idList.size() > 0) {
|
||||
menuMapper.deleteBatchIds(idList);
|
||||
}
|
||||
QueryWrapper<Menu> queryWrapper = new QueryWrapper<>();
|
||||
//根据上级id 查询 根据 orderno 正序排序
|
||||
queryWrapper.eq("parentid", menu.getParentid()).orderByAsc(
|
||||
"orderno");
|
||||
List<Menu> list = this.list(queryWrapper);
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
Menu menuData = list.get(i);
|
||||
//更新序列号
|
||||
menuData.setOrderno(i + 1);
|
||||
}
|
||||
//更新表数据
|
||||
this.updateBatchById(list);
|
||||
}
|
||||
return isOk;
|
||||
}
|
||||
|
||||
//2 根据当前菜单id,查询菜单里面子菜单id,封装到list集合
|
||||
private void selectPermissionChildById(String id, List<String> idList) {
|
||||
//查询菜单里面子菜单id
|
||||
QueryWrapper<Menu> wrapper = new QueryWrapper<>();
|
||||
wrapper.eq("parentid", id);
|
||||
wrapper.select("id");
|
||||
List<Menu> childIdList = baseMapper.selectList(wrapper);
|
||||
//把childIdList里面菜单id值获取出来,封装idList里面,做递归查询
|
||||
childIdList.stream().forEach(item -> {
|
||||
//封装idList里面
|
||||
idList.add(item.getId());
|
||||
//递归查询
|
||||
this.selectPermissionChildById(item.getId(), idList);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/***********************************
|
||||
* 用途说明:查询菜单及按钮树状图
|
||||
* 参数说明
|
||||
* parentid 上级id
|
||||
*systemcode 系统
|
||||
* isdisplay 是否显示
|
||||
* type 按钮
|
||||
* 返回值说明: 菜单结构树集合
|
||||
***********************************/
|
||||
private List<Map<String, Object>> child(String parentid,
|
||||
String appId, String name,
|
||||
String isdisplay, String type) {
|
||||
List<Map<String, Object>> listMap = new ArrayList<>();
|
||||
QueryWrapper<Menu> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("parentid", parentid).eq("app_id", appId);
|
||||
//根据上级id 系统 查询
|
||||
if (StringUtils.isNotEmpty(type)) {
|
||||
queryWrapper.ne("type", type);
|
||||
}
|
||||
//根据菜单名称查询
|
||||
if (StringUtils.isNotEmpty(name)) {
|
||||
queryWrapper.like("name", name);
|
||||
}
|
||||
listMap = this.listMaps(queryWrapper.orderByAsc("orderno"));
|
||||
if (listMap.size() > 0) { //判断是否存在子集
|
||||
for (int i = 0; i < listMap.size(); i++) { //遍历表数据
|
||||
List<Map<String, Object>> childList =
|
||||
child(listMap.get(i).get("id").toString(), appId
|
||||
, name, isdisplay, type); //循环获取下一子集
|
||||
listMap.get(i).put("children", childList); //添加新列 子集
|
||||
}
|
||||
}
|
||||
return listMap;
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,178 @@
|
||||
package io.gisbi.application.system.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.github.xiaoymin.knife4j.core.util.StrUtil;
|
||||
import io.gisbi.application.system.domain.Organization;
|
||||
import io.gisbi.application.system.domain.User;
|
||||
import io.gisbi.application.system.mapper.OrganizationMapper;
|
||||
import io.gisbi.application.system.service.IOrganizationService;
|
||||
import io.gisbi.application.system.service.IUserService;
|
||||
import io.gisbi.utils.AuthUtils;
|
||||
import io.micrometer.common.util.StringUtils;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 组织机构 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author lilin
|
||||
* @since 2025-05-08
|
||||
*/
|
||||
@Service
|
||||
public class OrganizationServiceImpl extends ServiceImpl<OrganizationMapper, Organization> implements IOrganizationService {
|
||||
|
||||
@Resource
|
||||
private IUserService userService;
|
||||
|
||||
@Resource
|
||||
private OrganizationMapper organizationMapper;
|
||||
|
||||
public static final String DEFAULT_IS_VALID = "1";
|
||||
|
||||
/***********************************
|
||||
* 用途说明:获取企业列表
|
||||
* 参数说明
|
||||
* 返回值说明: 企业列表集合
|
||||
***********************************/
|
||||
@Override
|
||||
public List<Map<String, Object>> getOrganization(String appId, String parentid, String orgname) {
|
||||
LambdaQueryWrapper<Organization> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(StringUtils.isNotBlank(parentid), Organization::getParentid, parentid);
|
||||
queryWrapper.eq(StringUtils.isNotBlank(appId), Organization::getAppId, appId);
|
||||
List<Map<String, Object>> listMap = this.listMaps(queryWrapper.orderByAsc(Organization::getOrgcode));
|
||||
|
||||
if (listMap == null) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
List<Map<String, Object>> result = new ArrayList<>();
|
||||
|
||||
for (Map<String, Object> item : listMap) {
|
||||
Object idObj = item.get("id");
|
||||
// 避免空指针
|
||||
if (idObj == null) {
|
||||
continue;
|
||||
}
|
||||
List<Map<String, Object>> childList = child(idObj.toString(), appId, orgname);
|
||||
item.put("childList", childList); // 添加新列 子集
|
||||
if (childList != null && !childList.isEmpty()) {
|
||||
result.add(item); // 仅保留有子节点的数据
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/***********************************
|
||||
* 用途说明:获取部门结构树
|
||||
* 参数说明
|
||||
* parentid 上级id
|
||||
* orgname (根据参数查询部门名称)
|
||||
* 返回值说明: 部门结构树
|
||||
***********************************/
|
||||
private List<Map<String, Object>> child(String parentid, String appId, String orgname) {
|
||||
List<Map<String, Object>> listMap;
|
||||
|
||||
LambdaQueryWrapper<Organization> queryWrapper = new LambdaQueryWrapper<>();
|
||||
//根据上级id 查询
|
||||
queryWrapper.eq(StringUtils.isNotBlank(parentid), Organization::getParentid, parentid);
|
||||
queryWrapper.eq(StringUtils.isNotBlank(appId), Organization::getAppId, appId);
|
||||
//根据部门名称查询
|
||||
queryWrapper.like(StringUtils.isNotBlank(orgname), Organization::getOrgname, orgname);
|
||||
|
||||
listMap = this.listMaps(queryWrapper.orderByAsc(Organization::getOrgcode));
|
||||
//判断是否存在子集
|
||||
if (listMap != null && !listMap.isEmpty()) {
|
||||
//遍历表数据
|
||||
for (int i = 0; i < listMap.size(); i++) {
|
||||
//循环获取下一子集
|
||||
List<Map<String, Object>> childList = child(listMap.get(i).get("id").toString(), appId, orgname);
|
||||
//添加新列 子集
|
||||
listMap.get(i).put("childList", childList);
|
||||
}
|
||||
}
|
||||
return listMap;
|
||||
}
|
||||
|
||||
/***********************************
|
||||
* 用途说明:根据企业ID查询部门信息
|
||||
* 参数说明
|
||||
* id 企业id
|
||||
* orgName 部门名称
|
||||
* 返回值说明: 系统部门框架对象
|
||||
***********************************/
|
||||
@Override
|
||||
public List<Organization> getOrganizationById(String id, String orgName) {
|
||||
LambdaQueryWrapper<Organization> queryWrapper = new LambdaQueryWrapper<>();
|
||||
if (StrUtil.isNotBlank(orgName)) {
|
||||
queryWrapper.like(Organization::getOrgname, orgName);
|
||||
}
|
||||
queryWrapper.eq(Organization::getParentid, id).orderByDesc(Organization::getOrgcode);
|
||||
return this.list(queryWrapper);
|
||||
}
|
||||
|
||||
/***********************************
|
||||
* 用途说明:新增系统组织框架
|
||||
* 参数说明
|
||||
* Organization 系统组织框架对象
|
||||
* 返回值说明: 是否新增成功
|
||||
***********************************/
|
||||
@Override
|
||||
public boolean addOrganization(Organization organization) {
|
||||
|
||||
// 构建查询条件
|
||||
LambdaQueryWrapper<Organization> queryWrapper = new LambdaQueryWrapper<>();
|
||||
Organization parent = null;
|
||||
int codeMax = 0;
|
||||
//查询最大的编号 判断是否存在父级id 有值 根据父级id查询 否则 根据父级id为0 查询
|
||||
queryWrapper.select(Organization::getOrgcode);
|
||||
if (StrUtil.isNotBlank(organization.getParentid())) {
|
||||
parent = this.getById(organization.getParentid());
|
||||
queryWrapper.eq(Organization::getParentid, organization.getParentid());
|
||||
} else {
|
||||
organization.setParentid("0");
|
||||
queryWrapper.eq(Organization::getParentid, "0");
|
||||
}
|
||||
List<Object> maxResult = this.listObjs(queryWrapper);
|
||||
if (!maxResult.isEmpty()) {
|
||||
String maxCodeStr = maxResult.get(0).toString();
|
||||
try {
|
||||
codeMax = Integer.parseInt(maxCodeStr.substring(maxCodeStr.length() - 2));
|
||||
} catch (NumberFormatException e) {
|
||||
// 记录日志并默认从 0 开始
|
||||
codeMax = 0;
|
||||
}
|
||||
}
|
||||
|
||||
DecimalFormat df = new DecimalFormat("00");
|
||||
String code = df.format(codeMax + 1);
|
||||
|
||||
if (parent != null) {
|
||||
code = parent.getOrgcode() + df.format(codeMax + 1);
|
||||
}
|
||||
|
||||
if (StrUtil.isBlank(organization.getIsvaild())) {
|
||||
organization.setIsvaild(DEFAULT_IS_VALID);
|
||||
}
|
||||
//填写 编号
|
||||
organization.setOrgcode(code);
|
||||
//填写 当前用户名称
|
||||
organization.setLastmodifier(AuthUtils.getUser().getUserId().toString());
|
||||
//填写 当前日期
|
||||
organization.setLastmodifydate(LocalDateTime.now());
|
||||
return this.save(organization);
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,141 @@
|
||||
package io.gisbi.application.system.service.impl;
|
||||
|
||||
import cn.hutool.core.text.CharSequenceUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import io.gisbi.application.system.domain.Role;
|
||||
import io.gisbi.application.system.mapper.RoleMapper;
|
||||
import io.gisbi.application.system.service.IRoleService;
|
||||
import io.gisbi.utils.AuthUtils;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
import java.text.DecimalFormat;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 应用系统 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author lilin
|
||||
* @since 2025-05-08
|
||||
*/
|
||||
@Service
|
||||
public class RoleServiceImpl extends ServiceImpl<RoleMapper, Role> implements IRoleService {
|
||||
|
||||
@Resource
|
||||
private RoleMapper roleMapper;
|
||||
|
||||
|
||||
/**********************************
|
||||
* 用途说明: 根据用户id获取角色id
|
||||
* 参数说明 userid 用户id
|
||||
* 返回值说明: void
|
||||
***********************************/
|
||||
@Override
|
||||
public List<String> getRoleUsers(String userid, String appId) {
|
||||
List<String> roleIds = roleMapper.getRoleUsers(userid, appId);
|
||||
return roleIds;
|
||||
}
|
||||
|
||||
/***********************************
|
||||
* 用途说明:新增角色
|
||||
* 参数说明
|
||||
* sysRole 新增角色信息
|
||||
* 返回值说明: 是否新增成功
|
||||
***********************************/
|
||||
@Override
|
||||
public boolean addRole(Role role) {
|
||||
//生成用户编号
|
||||
int codeMax = 0;
|
||||
DecimalFormat df = new DecimalFormat("000");//四位数字编号
|
||||
QueryWrapper<Role> queryWrapper = new QueryWrapper<>();
|
||||
// 查询最大的编号
|
||||
List<Object> max = this.listObjs(queryWrapper.select("MAX(rolecode) " + "rolecode"));
|
||||
//判断查询是否存在
|
||||
if (max.size() > 0) {
|
||||
codeMax = Integer.parseInt(max.get(0).toString());
|
||||
}
|
||||
// 存在转换成int类型并给codeMax替换值 // 最大编号累加
|
||||
String code = df.format(codeMax + 1);
|
||||
//添加角色编号
|
||||
role.setRolecode(code);
|
||||
//判断是否填写有效性 默认为 1 是
|
||||
if (StringUtils.isEmpty(role.getIsvaild())) {
|
||||
role.setIsvaild("1");
|
||||
}
|
||||
//添加最近修改者
|
||||
role.setLastmodifier(AuthUtils.getUser().getUserId().toString());
|
||||
//添加最近修改时间
|
||||
role.setLastmodifydate(LocalDateTime.now());
|
||||
return this.save(role);
|
||||
}
|
||||
|
||||
/***********************************
|
||||
* 用途说明:查询所有角色
|
||||
* 参数说明
|
||||
* rolename 角色名称
|
||||
* 返回值说明: 查询都有角色
|
||||
***********************************/
|
||||
@Override
|
||||
public List<Role> listRole(String appId, String rolename) {
|
||||
LambdaQueryWrapper<Role> queryWrapper = new LambdaQueryWrapper<>();
|
||||
//根据应用ID查询
|
||||
if (StringUtils.isNotEmpty(appId)) {
|
||||
queryWrapper.eq(Role::getAppId, appId);
|
||||
}
|
||||
//根据角色名称模糊查询
|
||||
if (StringUtils.isNotEmpty(rolename)) {
|
||||
queryWrapper.like(Role::getRolename, rolename);
|
||||
}
|
||||
//根据角色类别 正序排序
|
||||
queryWrapper.orderByAsc(Role::getType);
|
||||
List<Role> roles = roleMapper.selectList(queryWrapper);
|
||||
return roles;
|
||||
}
|
||||
|
||||
/***********************************
|
||||
* 用途说明:根据id删除角色
|
||||
* 参数说明
|
||||
*id 角色id
|
||||
* 返回值说明: 是否删除成功
|
||||
***********************************/
|
||||
@Override
|
||||
public void deleteById(String id) {
|
||||
String[] ids = id.split(",");
|
||||
for (String roleId : ids) {
|
||||
//根据id删除 角色
|
||||
boolean isOk = this.removeById(roleId);
|
||||
if (!isOk) {
|
||||
continue;
|
||||
}
|
||||
//删除角色菜单关联
|
||||
roleMapper.deleteRoleMenus(roleId);
|
||||
//删除角色用户关联
|
||||
roleMapper.deleteRoleUser(roleId);
|
||||
}
|
||||
}
|
||||
|
||||
/***********************************
|
||||
* 用途说明:删除角色用户
|
||||
* 参数说明
|
||||
* id 系统角色用户对照表id
|
||||
* 返回值说明: 是否新增成功
|
||||
***********************************/
|
||||
@Override
|
||||
public boolean deleteRoleUsers(String roleid, String userids) {
|
||||
boolean ok = true;
|
||||
//得到单个用户id
|
||||
String[] temp = userids.split(",");
|
||||
for (String userid : temp) {
|
||||
//根据角色id、用户id删除 (登录账号admin除外)
|
||||
ok = ok && roleMapper.deleteRoleUsers(roleid, userid);
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
}
|
@ -0,0 +1,370 @@
|
||||
package io.gisbi.application.system.service.impl;
|
||||
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import io.gisbi.application.system.domain.Role;
|
||||
import io.gisbi.application.system.domain.User;
|
||||
import io.gisbi.application.system.mapper.OrganizationMapper;
|
||||
import io.gisbi.application.system.mapper.RoleMapper;
|
||||
import io.gisbi.application.system.mapper.UserMapper;
|
||||
import io.gisbi.application.system.service.IUserService;
|
||||
import io.gisbi.utils.AuthUtils;
|
||||
import io.micrometer.common.util.StringUtils;
|
||||
import io.netty.channel.ChannelInboundHandlerAdapter;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.io.File;
|
||||
import java.sql.Timestamp;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 用户 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author lilin
|
||||
* @since 2025-05-08
|
||||
*/
|
||||
@Service
|
||||
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IUserService {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(ChannelInboundHandlerAdapter.class);
|
||||
|
||||
@Resource
|
||||
private UserMapper userMapper;
|
||||
|
||||
@Resource
|
||||
private RoleMapper roleMapper;
|
||||
|
||||
|
||||
public static final String DEFAULT_IS_VALID = "1";
|
||||
//定义密码常量
|
||||
public static final String PASSWORD_VALID = "123456";
|
||||
|
||||
|
||||
/***********************************
|
||||
* 用途说明:新增系统用户
|
||||
* 参数说明
|
||||
* user 用户对象
|
||||
* roleids 角色ID
|
||||
* 返回值说明: 是否新增成功
|
||||
***********************************/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class) // 添加事务控制
|
||||
public Map addUser(User user, String roleids) {
|
||||
//返回信息
|
||||
Map<String, String> result = new HashMap<>();
|
||||
//普通用户
|
||||
user.setUsertype(DEFAULT_IS_VALID);
|
||||
// BCryptPasswordEncoder passwordEncoder = new BCryptPasswordEncoder();
|
||||
// //设置缺省密码
|
||||
// String cryptPassword = passwordEncoder.encode("123456");
|
||||
user.setPassword(PASSWORD_VALID);
|
||||
//最近修改日期
|
||||
user.setLastmodifydate(LocalDateTime.now());
|
||||
//最近修改者
|
||||
user.setLastmodifier(AuthUtils.getUser().getUserId().toString());
|
||||
//账号有效 状态 1-有效 0-停用
|
||||
user.setStatus(DEFAULT_IS_VALID);
|
||||
//判断注册的登录账号是否存在
|
||||
if (isExistAccount(user.getUsername())) {
|
||||
//新增用户
|
||||
boolean ok = this.save(user);
|
||||
//新增用户分配权限
|
||||
if (StringUtils.isNotEmpty(roleids)) {
|
||||
String[] roles = roleids.split(",");
|
||||
for (String roleid : roles) {
|
||||
//系统生成id
|
||||
String id = IdUtil.fastSimpleUUID();
|
||||
//新增app_role_users表数据
|
||||
ok = ok && userMapper.addUserRoles(id, user.getAppId(), roleid, user.getId());
|
||||
}
|
||||
}
|
||||
//判断新增是否成功 消息提示
|
||||
if (ok) {
|
||||
result.put("status", "sucess");
|
||||
result.put("msg", "新增用户成功!");
|
||||
|
||||
} else {
|
||||
result.put("status", "error");
|
||||
result.put("msg", "新增用户失败!");
|
||||
}
|
||||
} else {
|
||||
result.put("status", "error");
|
||||
result.put("msg", "用户账号已存在,不能重复添加!");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/***********************************
|
||||
* 用途说明:修改用户信息
|
||||
* 参数说明
|
||||
* user 用户对象
|
||||
* roleids 角色ID
|
||||
* 返回值说明: 是否新增成功
|
||||
***********************************/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Map updateById(User user, String roleids) {
|
||||
Map<String, String> result = new HashMap<>();
|
||||
try {
|
||||
// 设置最近修改人和时间
|
||||
user.setLastmodifier(AuthUtils.getUser().getUserId().toString());
|
||||
user.setLastmodifydate(LocalDateTime.now());
|
||||
//修改用户信息
|
||||
boolean ok = this.updateById(user);
|
||||
if (ok) {
|
||||
if (StringUtils.isNotEmpty(roleids)) {
|
||||
String[] roles = roleids.split(",");
|
||||
Set<String> roleSet = new HashSet<>(Arrays.asList(roles));
|
||||
List<String> existingRoles = userMapper.getRoleid(user.getId());
|
||||
|
||||
// 添加新角色
|
||||
for (String role : roles) {
|
||||
if (!existingRoles.contains(role)) {
|
||||
//系统生成id
|
||||
String id = IdUtil.fastSimpleUUID();
|
||||
ok = ok && userMapper.addUserRoles(id, user.getAppId(), role, user.getId());
|
||||
}
|
||||
}
|
||||
|
||||
// 删除不在 roleids 中的角色
|
||||
userMapper.delInRoleUsersByUserid(user.getId(), roles);
|
||||
} else {
|
||||
// 删除所有关联角色
|
||||
ok = ok && userMapper.delRoleUsersByUserid(user.getId());
|
||||
}
|
||||
|
||||
result.put("status", "success");
|
||||
result.put("msg", "用户信息修改成功!");
|
||||
} else {
|
||||
result.put("status", "error");
|
||||
result.put("msg", "用户信息修改失败!");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// 记录日志
|
||||
LOGGER.error("用户信息修改过程中发生异常", e);
|
||||
result.put("status", "error");
|
||||
result.put("msg", "用户信息修改失败,请稍后再试!");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/***********************************
|
||||
* 用途说明:查询用户信息
|
||||
* 参数说明
|
||||
* orgid 所属组织ID
|
||||
* nickname 用户昵称
|
||||
* page 分页条件
|
||||
* 返回值说明: 用户信息集合
|
||||
***********************************/
|
||||
@Override
|
||||
public Page<Map<String, Object>> queryUsers(String orgid, String nickname, String appId, Page<User> page) {
|
||||
|
||||
//当前用户类型 用户类型 0-管理员 1-普通用户
|
||||
int usertype = 0;//currentUser.getUsertype();
|
||||
if (usertype == 0 || usertype == 1) {
|
||||
//根据条件分页查询用户信息 查询到的用户信息挨个查询角色信息
|
||||
Page<Map<String, Object>> mapPage = userMapper.queryUsers(orgid, appId, nickname, page);
|
||||
|
||||
List<Map<String, Object>> records = mapPage != null ? mapPage.getRecords() : new ArrayList<>();
|
||||
if (records.isEmpty()) {
|
||||
return mapPage;
|
||||
}
|
||||
|
||||
List<Map<String, Object>> list = new ArrayList<>(records.size());
|
||||
|
||||
for (Map<String, Object> record : records) {
|
||||
|
||||
Object idObj = record.get("id");
|
||||
if (idObj == null) {
|
||||
continue; // 跳过无效记录
|
||||
}
|
||||
// 更安全地处理id
|
||||
String id = idObj.toString();
|
||||
List<Role> roles = roleMapper.getRoleByUserId(id);
|
||||
if (roles == null) {
|
||||
// 防止null值
|
||||
roles = Collections.emptyList();
|
||||
}
|
||||
record.put("roles", roles);
|
||||
list.add(record);
|
||||
}
|
||||
mapPage.setRecords(list);
|
||||
return mapPage;
|
||||
} else {
|
||||
// 明确返回null比返回未初始化的mapPage更好
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/***********************************
|
||||
* 用途说明:根据id删除用户
|
||||
* 参数说明
|
||||
*id 用户id
|
||||
* 返回值说明: 判断是否删除成功
|
||||
************************************/
|
||||
@Override
|
||||
public Boolean deleteUserById(String id) {
|
||||
//根据id查询
|
||||
User user = this.getById(id);
|
||||
//账号头像存储地址
|
||||
//String imgName = systempath + File.separator + "user" + File.separator + user.getAvatar();
|
||||
String imgName = File.separator + "user" + File.separator + user.getAvatar();
|
||||
//如果是管理员不能删除
|
||||
if ("admin".equals(user.getUsername())) {
|
||||
return false;
|
||||
} else {
|
||||
boolean isOk = this.removeById(id);
|
||||
//判断是否删除成功
|
||||
if (isOk) {
|
||||
//根据用户id 删除该用户角色关联
|
||||
userMapper.delRoleUsersByUserid(id);
|
||||
//判断是否存在 账号头像 存在删除
|
||||
if (StringUtils.isNotEmpty(user.getAvatar())) {
|
||||
// FileUtil.del(imgName);
|
||||
}
|
||||
return false;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/***********************************
|
||||
* 用途说明:根据ID批量删除用户
|
||||
* 参数说明
|
||||
*ids 用户id集合
|
||||
* 返回值说明: 判断是否删除成功
|
||||
************************************/
|
||||
@Override
|
||||
public boolean deleteUserByIds(String ids) {
|
||||
|
||||
List<String> idList = Arrays.asList(ids.split(","));
|
||||
|
||||
LambdaQueryWrapper<User> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.in(User::getId, idList);
|
||||
List<User> sysUsers = userMapper.selectList(queryWrapper);
|
||||
|
||||
List<String> names = sysUsers.stream().map(User::getUsername).collect(Collectors.toList());
|
||||
if (names.contains("admin")) {
|
||||
return false;
|
||||
} else {
|
||||
int result = userMapper.deleteBatchIds(idList);
|
||||
if (result <= 0) {
|
||||
return false;
|
||||
}
|
||||
// 根据ID删除用户与角色的关联信息
|
||||
userMapper.delRoleUsersByUserIds(idList);
|
||||
List<String> avatars =
|
||||
sysUsers.stream().map(User::getAvatar).collect(Collectors.toList());
|
||||
if (avatars.size() > 0) {
|
||||
for (String avatar : avatars) {
|
||||
//账号头像存储地址
|
||||
// String imgName =systempath + File.separator + "user" + File.separator + avatar;
|
||||
// FileUtil.del(imgName);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/***********************************
|
||||
* 用途说明:重置用户密码(管理员)
|
||||
* 参数说明
|
||||
*id 重置密码的 用户id
|
||||
* 返回值说明: 判断是否重置成功
|
||||
************************************/
|
||||
@Override
|
||||
public boolean resetPassword(String id) {
|
||||
boolean isOk = false;
|
||||
UpdateWrapper<User> updateWrapper = new UpdateWrapper<>();
|
||||
//根据id 修改密码,密码修改时间,最近修改者,最近修改日期 将密码修改为 123456
|
||||
String cryptPassword = PASSWORD_VALID;
|
||||
updateWrapper.eq("id", id).set("password", cryptPassword)
|
||||
.set("pwdresettime", LocalDateTime.now())
|
||||
.set("lastmodifydate", LocalDateTime.now())
|
||||
.set("lastmodifier", AuthUtils.getUser().getUserId().toString());
|
||||
//是否修改成功
|
||||
isOk = this.update(updateWrapper);
|
||||
return isOk;
|
||||
}
|
||||
|
||||
/***********************************
|
||||
* 用途说明:设置账号状态(管理员)
|
||||
* 参数说明
|
||||
*id 用户id
|
||||
* status 设置状态
|
||||
* 返回值说明: 判断是否设置成功
|
||||
************************************/
|
||||
@Override
|
||||
public boolean setStatus(String id, String status) {
|
||||
boolean isOk = false;
|
||||
// //根据当前用户id 查询角色表的级别 currentUser.getUser() 获取当前用户id
|
||||
// String level = userMapper.getMaxLevel(id);
|
||||
// //判断当前用户级别 管理员及以上权限
|
||||
// if (Integer.parseInt(level) <= 2) {
|
||||
UpdateWrapper<User> updateWrapper = new UpdateWrapper<>();
|
||||
//根据id修改用户状态,最近修改人,最近修改时间
|
||||
updateWrapper.eq("id", id)
|
||||
.set("status", status)
|
||||
.set("lastmodifydate", LocalDateTime.now())
|
||||
.set("lastmodifier", AuthUtils.getUser().getUserId().toString());
|
||||
//是否修改成功
|
||||
isOk = this.update(updateWrapper);
|
||||
//}
|
||||
return isOk;
|
||||
}
|
||||
|
||||
/***********************************
|
||||
* 用途说明:角色添加用户
|
||||
* 参数说明
|
||||
* roleid 角色id
|
||||
* userids 用户id组
|
||||
* 返回值说明: 是否新增成功
|
||||
***********************************/
|
||||
@Override
|
||||
public boolean addUserRoles(String roleid, String userid) {
|
||||
boolean isOk = true;
|
||||
if (StringUtils.isEmpty(roleid) || StringUtils.isEmpty(userid)) {
|
||||
return false;
|
||||
}
|
||||
User user = userMapper.selectById(userid);
|
||||
//根据角色id与用户id查询
|
||||
List<Map> list = userMapper.getRoleUsersByid(roleid, userid);
|
||||
//判断是否用户已分配此权限
|
||||
if (list.size() == 0) {
|
||||
//系统生成id
|
||||
String id = IdUtil.fastSimpleUUID();
|
||||
//新增app_role_users表数据
|
||||
isOk = userMapper.addUserRoles(id, user.getAppId(), roleid, userid);
|
||||
}
|
||||
return isOk;
|
||||
}
|
||||
|
||||
|
||||
/***********************************
|
||||
* 用途说明:比较登录名称是否有重复
|
||||
* 参数说明
|
||||
* account 登录名称
|
||||
* 返回值说明: 重复返回 false 否则返回 true
|
||||
************************************/
|
||||
private boolean isExistAccount(String username) {
|
||||
QueryWrapper<User> queryWrapper = new QueryWrapper<>();
|
||||
if (this.list(queryWrapper.eq("username", username)).size() > 0) {
|
||||
//判断 查询登录账号 结果集是否为null 重复返回 false 否则返回 tree
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
@ -71,3 +71,5 @@ knife4j:
|
||||
setting:
|
||||
language: zh_cn
|
||||
enable-swagger-models: false
|
||||
file-space: #项目文档空间
|
||||
system: D:\file\system\ #单独上传的文件
|
||||
|
39
core/core-backend/src/main/resources/mybatis/RoleMapper.xml
Normal file
39
core/core-backend/src/main/resources/mybatis/RoleMapper.xml
Normal file
@ -0,0 +1,39 @@
|
||||
<?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="io.gisbi.application.system.mapper.RoleMapper">
|
||||
|
||||
<!--根据用户id获取角色信息-->
|
||||
|
||||
<select id="getRoleByUserId">
|
||||
SELECT r.id,
|
||||
r.rolename,
|
||||
r.rolecode
|
||||
FROM app_role_users ru
|
||||
INNER JOIN app_role r ON ru.roleid = r.id
|
||||
WHERE ru.userid = #{id}
|
||||
</select>
|
||||
|
||||
|
||||
<!--根据用户id获取角色id-->
|
||||
<select id="getRoleUsers" resultType="java.lang.String">
|
||||
SELECT roleid
|
||||
FROM app_role_users
|
||||
WHERE userid = #{userid}
|
||||
AND app_id = #{appId}
|
||||
</select>
|
||||
|
||||
<!--根据角色ID删除菜单与角色关联信息-->
|
||||
<delete id="deleteRoleMenus">
|
||||
DELETE FROM app_role_menu WHERE roleid= #{id}
|
||||
</delete>
|
||||
|
||||
<!--根据角色ID删除用户与角色关联信息-->
|
||||
<delete id="deleteRoleUser">
|
||||
DELETE FROM app_role_users WHERE roleid= #{id}
|
||||
</delete>
|
||||
|
||||
<!--根据 角色id和用户id 删除系统角色用户对照 -->
|
||||
<delete id="deleteRoleUsers">
|
||||
delete from app_role_users where userid !=(select u.id from app_user u where u.account="admin") and roleid=#{roleid} and userid=#{urserid}
|
||||
</delete>
|
||||
</mapper>
|
84
core/core-backend/src/main/resources/mybatis/UserMapper.xml
Normal file
84
core/core-backend/src/main/resources/mybatis/UserMapper.xml
Normal file
@ -0,0 +1,84 @@
|
||||
<?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="io.gisbi.application.system.mapper.UserMapper">
|
||||
|
||||
|
||||
<!--用户分配角色 系统角色用户对照新增数据-->
|
||||
<insert id="addUserRoles">
|
||||
INSERT INTO app_role_users(id, app_id, roleid, userid)
|
||||
VALUES (#{id}, #{appid}, #{roleid}, #{userid});
|
||||
</insert>
|
||||
|
||||
<!--根据用户表id查询角色表所有角色id-->
|
||||
<select id="getRoleid" resultType="String">
|
||||
SELECT roleid
|
||||
FROM app_role_users
|
||||
WHERE userid = #{userid}
|
||||
</select>
|
||||
|
||||
<!--根据用户id删除所分配的不包含角色-->
|
||||
<delete id="delInRoleUsersByUserid">
|
||||
delete from app_role_users
|
||||
where
|
||||
userid=#{userid}
|
||||
and roleid not in
|
||||
<foreach collection="roleids" item="roleids" open="(" separator=","
|
||||
close=")">
|
||||
#{roleids}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
<!--根据用户id删除所分配的角色-->
|
||||
<delete id="delRoleUsersByUserid">
|
||||
delete from sys_role_users where userid=#{userid}
|
||||
</delete>
|
||||
|
||||
<!--根据条件分页查询用户信息-->
|
||||
<select id="queryUsers" resultType="java.util.Map">
|
||||
SELECT DISTINCT
|
||||
u.id,
|
||||
u.usertype,
|
||||
u.username,
|
||||
u.nickname,
|
||||
u.email,
|
||||
u.phone,
|
||||
u.avatar,
|
||||
u.orgid,
|
||||
u.status,
|
||||
u.lastmodifier,
|
||||
u.lastmodifydate
|
||||
FROM
|
||||
app_user u
|
||||
WHERE
|
||||
1 = 1
|
||||
AND u.usertype != 0
|
||||
<if test="orgid != null">
|
||||
AND u.orgid = #{orgid}
|
||||
</if>
|
||||
<if test="appId != null">
|
||||
AND u.app_id = #{appId}
|
||||
</if>
|
||||
<if test="nickname != null">
|
||||
AND u.nickname LIKE CONCAT('%',#{nickname},'%')
|
||||
</if>
|
||||
ORDER BY
|
||||
u.lastmodifydate DESC
|
||||
</select>
|
||||
|
||||
<!--根据ID删除用户与角色的关联信息-->
|
||||
<delete id="delRoleUsersByUserIds">
|
||||
DELETE FROM app_role_users WHERE userid IN
|
||||
<foreach collection="idList" item="id" open="(" separator=","
|
||||
close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
<!--根据用户id 和角色id 查询 系统角色用户对照表-->
|
||||
<select id="getRoleUsersByid" resultType="java.util.Map">
|
||||
select id, app_id, roleid, userid
|
||||
from app_role_users
|
||||
where roleid = #{roleid}
|
||||
and userid = #{userid}
|
||||
</select>
|
||||
</mapper>
|
Loading…
Reference in New Issue
Block a user