Browse Source

refactor:区域人员权限管理重构

master
李永德 1 month ago
parent
commit
7c10944494
  1. 6
      lms/nladmin-system/src/main/java/org/nl/wms/basedata/master/classstandard/controller/ClassStandardController.java
  2. 4
      lms/nladmin-system/src/main/java/org/nl/wms/basedata/master/classstandard/service/IClassStandardService.java
  3. 2
      lms/nladmin-system/src/main/java/org/nl/wms/basedata/master/classstandard/service/dao/ClassStandard.java
  4. 4
      lms/nladmin-system/src/main/java/org/nl/wms/basedata/master/classstandard/service/dao/mapper/ClassStandardMapper.java
  5. 2
      lms/nladmin-system/src/main/java/org/nl/wms/basedata/master/classstandard/service/dao/mapper/ClassStandardMapper.xml
  6. 2
      lms/nladmin-system/src/main/java/org/nl/wms/basedata/master/classstandard/service/dto/ClassStandardDto.java
  7. 4
      lms/nladmin-system/src/main/java/org/nl/wms/basedata/master/classstandard/service/dto/ClassStandardQuery.java
  8. 4
      lms/nladmin-system/src/main/java/org/nl/wms/basedata/master/classstandard/service/dto/ClassStandardTrees.java
  9. 10
      lms/nladmin-system/src/main/java/org/nl/wms/basedata/master/classstandard/service/impl/ClassStandardServiceImpl.java
  10. 46
      lms/nladmin-system/src/main/java/org/nl/wms/basedata/st/areapermissions/controller/UserAreaPermissionController.java
  11. 5
      lms/nladmin-system/src/main/java/org/nl/wms/basedata/st/areapermissions/package-info.java
  12. 43
      lms/nladmin-system/src/main/java/org/nl/wms/basedata/st/areapermissions/service/IUserAreaPermissionService.java
  13. 20
      lms/nladmin-system/src/main/java/org/nl/wms/basedata/st/areapermissions/service/dao/UserAreaPermission.java
  14. 20
      lms/nladmin-system/src/main/java/org/nl/wms/basedata/st/areapermissions/service/dao/mapper/UserAreaPermissionMapper.java
  15. 22
      lms/nladmin-system/src/main/java/org/nl/wms/basedata/st/areapermissions/service/dao/mapper/UserAreaPermissionMapper.xml
  16. 69
      lms/nladmin-system/src/main/java/org/nl/wms/basedata/st/areapermissions/service/impl/UserAreaPermissionServiceImpl.java
  17. 134
      lms/nladmin-system/src/main/java/org/nl/wms/basedata/st/areapermissions/service/vo/UsersVo.java
  18. 2
      lms/nladmin-system/src/main/java/org/nl/wms/basedata/st/rest/UserAreaController.java
  19. 21
      lms/nladmin-ui/src/views/wms/basedata/product/userArea/index.vue

6
lms/nladmin-system/src/main/java/org/nl/wms/basedata/master/standard/controller/ClassStandardController.java → lms/nladmin-system/src/main/java/org/nl/wms/basedata/master/classstandard/controller/ClassStandardController.java

@ -1,12 +1,12 @@
package org.nl.wms.basedata.master.standard.controller;
package org.nl.wms.basedata.master.classstandard.controller;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.nl.common.TableDataInfo;
import org.nl.common.domain.query.PageQuery;
import org.nl.modules.logging.annotation.Log;
import org.nl.wms.basedata.master.standard.service.IClassStandardService;
import org.nl.wms.basedata.master.standard.service.dao.ClassStandard;
import org.nl.wms.basedata.master.classstandard.service.IClassStandardService;
import org.nl.wms.basedata.master.classstandard.service.dao.ClassStandard;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;

4
lms/nladmin-system/src/main/java/org/nl/wms/basedata/master/standard/service/IClassStandardService.java → lms/nladmin-system/src/main/java/org/nl/wms/basedata/master/classstandard/service/IClassStandardService.java

@ -1,9 +1,9 @@
package org.nl.wms.basedata.master.standard.service;
package org.nl.wms.basedata.master.classstandard.service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService;
import org.nl.common.domain.query.PageQuery;
import org.nl.wms.basedata.master.standard.service.dao.ClassStandard;
import org.nl.wms.basedata.master.classstandard.service.dao.ClassStandard;
import java.util.ArrayList;
import java.util.List;

2
lms/nladmin-system/src/main/java/org/nl/wms/basedata/master/standard/service/dao/ClassStandard.java → lms/nladmin-system/src/main/java/org/nl/wms/basedata/master/classstandard/service/dao/ClassStandard.java

@ -1,4 +1,4 @@
package org.nl.wms.basedata.master.standard.service.dao;
package org.nl.wms.basedata.master.classstandard.service.dao;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;

4
lms/nladmin-system/src/main/java/org/nl/wms/basedata/master/standard/service/dao/mapper/ClassStandardMapper.java → lms/nladmin-system/src/main/java/org/nl/wms/basedata/master/classstandard/service/dao/mapper/ClassStandardMapper.java

@ -1,7 +1,7 @@
package org.nl.wms.basedata.master.standard.service.dao.mapper;
package org.nl.wms.basedata.master.classstandard.service.dao.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.nl.wms.basedata.master.standard.service.dao.ClassStandard;
import org.nl.wms.basedata.master.classstandard.service.dao.ClassStandard;
import java.util.ArrayList;

2
lms/nladmin-system/src/main/java/org/nl/wms/basedata/master/standard/service/dao/mapper/ClassStandardMapper.xml → lms/nladmin-system/src/main/java/org/nl/wms/basedata/master/classstandard/service/dao/mapper/ClassStandardMapper.xml

@ -1,6 +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="org.nl.wms.basedata.master.standard.service.dao.mapper.ClassStandardMapper">
<mapper namespace="org.nl.wms.basedata.master.classstandard.service.dao.mapper.ClassStandardMapper">
<select id="getAllChildrenIds" resultType="java.lang.String">
SELECT DISTINCT

2
lms/nladmin-system/src/main/java/org/nl/wms/basedata/master/standard/service/dto/ClassStandardDto.java → lms/nladmin-system/src/main/java/org/nl/wms/basedata/master/classstandard/service/dto/ClassStandardDto.java

@ -1,4 +1,4 @@
package org.nl.wms.basedata.master.standard.service.dto;
package org.nl.wms.basedata.master.classstandard.service.dto;
import lombok.Data;
import java.io.Serializable;

4
lms/nladmin-system/src/main/java/org/nl/wms/basedata/master/standard/service/dto/ClassStandardQuery.java → lms/nladmin-system/src/main/java/org/nl/wms/basedata/master/classstandard/service/dto/ClassStandardQuery.java

@ -1,7 +1,7 @@
package org.nl.wms.basedata.master.standard.service.dto;
package org.nl.wms.basedata.master.classstandard.service.dto;
import org.nl.common.domain.query.BaseQuery;
import org.nl.wms.basedata.master.standard.service.dao.ClassStandard;
import org.nl.wms.basedata.master.classstandard.service.dao.ClassStandard;
/**
* @author lyd

4
lms/nladmin-system/src/main/java/org/nl/wms/basedata/master/standard/service/dto/ClassStandardTrees.java → lms/nladmin-system/src/main/java/org/nl/wms/basedata/master/classstandard/service/dto/ClassStandardTrees.java

@ -1,11 +1,11 @@
package org.nl.wms.basedata.master.standard.service.dto;
package org.nl.wms.basedata.master.classstandard.service.dto;
import com.baomidou.mybatisplus.annotation.TableField;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.nl.wms.basedata.master.standard.service.dao.ClassStandard;
import org.nl.wms.basedata.master.classstandard.service.dao.ClassStandard;
import java.io.Serializable;
import java.util.List;

10
lms/nladmin-system/src/main/java/org/nl/wms/basedata/master/standard/service/impl/ClassStandardServiceImpl.java → lms/nladmin-system/src/main/java/org/nl/wms/basedata/master/classstandard/service/impl/ClassStandardServiceImpl.java

@ -1,4 +1,4 @@
package org.nl.wms.basedata.master.standard.service.impl;
package org.nl.wms.basedata.master.classstandard.service.impl;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.IdUtil;
@ -12,10 +12,10 @@ import org.nl.common.domain.query.PageQuery;
import org.nl.common.utils.SecurityUtils;
import org.nl.config.language.LangProcess;
import org.nl.modules.common.exception.BadRequestException;
import org.nl.wms.basedata.master.standard.service.IClassStandardService;
import org.nl.wms.basedata.master.standard.service.dao.ClassStandard;
import org.nl.wms.basedata.master.standard.service.dao.mapper.ClassStandardMapper;
import org.nl.wms.basedata.master.standard.service.dto.ClassStandardTrees;
import org.nl.wms.basedata.master.classstandard.service.IClassStandardService;
import org.nl.wms.basedata.master.classstandard.service.dao.ClassStandard;
import org.nl.wms.basedata.master.classstandard.service.dao.mapper.ClassStandardMapper;
import org.nl.wms.basedata.master.classstandard.service.dto.ClassStandardTrees;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

46
lms/nladmin-system/src/main/java/org/nl/wms/basedata/st/areapermissions/controller/UserAreaPermissionController.java

@ -0,0 +1,46 @@
package org.nl.wms.basedata.st.areapermissions.controller;
import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j;
import org.nl.common.TableDataInfo;
import org.nl.common.domain.query.PageQuery;
import org.nl.modules.logging.annotation.Log;
import org.nl.wms.basedata.st.areapermissions.service.IUserAreaPermissionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import java.util.Map;
/**
* 区域权限管理
* @Author: lyd
* @Date: 2024/10/18
*/
@RestController
@RequestMapping("/api/userArea")
@Slf4j
public class UserAreaPermissionController {
@Autowired
private IUserAreaPermissionService userAreaPermissionService;
@GetMapping
@Log(value = "查询用户信息", isAddLogTable = false)
public ResponseEntity<Object> query(@RequestParam Map whereJson, PageQuery page) {
return new ResponseEntity<>(TableDataInfo.build(userAreaPermissionService.pageQuery(whereJson, page)), HttpStatus.OK);
}
@PostMapping("/queryUserArea")
@Log(value = "查询用户对应区域", isAddLogTable = false)
public ResponseEntity<Object> queryUserArea(@RequestBody JSONObject whereJson) {
return new ResponseEntity<>(userAreaPermissionService.queryUserArea(whereJson), HttpStatus.OK);
}
@PostMapping("/save")
@Log("保存用户仓库信息")
public ResponseEntity<Object> save(@RequestBody JSONObject whereJson) {
userAreaPermissionService.save(whereJson);
return new ResponseEntity<>(HttpStatus.OK);
}
}

5
lms/nladmin-system/src/main/java/org/nl/wms/basedata/st/areapermissions/package-info.java

@ -0,0 +1,5 @@
/**
* 区域权限管理相关内容
* 基础的三层逻辑
*/
package org.nl.wms.basedata.st.areapermissions;

43
lms/nladmin-system/src/main/java/org/nl/wms/basedata/st/areapermissions/service/IUserAreaPermissionService.java

@ -0,0 +1,43 @@
package org.nl.wms.basedata.st.areapermissions.service;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService;
import org.nl.common.domain.query.PageQuery;
import org.nl.system.service.user.dao.SysUser;
import org.nl.wms.basedata.st.areapermissions.service.dao.UserAreaPermission;
import org.nl.wms.basedata.st.areapermissions.service.vo.UsersVo;
import org.springframework.data.domain.Pageable;
import java.util.List;
import java.util.Map;
/**
* @Author: lyd
* @Date: 2024/10/18
*/
public interface IUserAreaPermissionService extends IService<UserAreaPermission> {
/**
* 分页获取用户信息
*
* @param whereJson 条件
* @param page 分页参数
* @return Map<String, Object>
*/
IPage<UsersVo> pageQuery(Map whereJson, PageQuery page);
/**
* 查询用户对应仓库
*
* @param whereJson /
*/
List<UserAreaPermission> queryUserArea(JSONObject whereJson);
/**
* 保存
*
* @param whereJson /
*/
void save(JSONObject whereJson);
}

20
lms/nladmin-system/src/main/java/org/nl/wms/basedata/st/areapermissions/service/dao/UserAreaPermission.java

@ -0,0 +1,20 @@
package org.nl.wms.basedata.st.areapermissions.service.dao;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* 区域与人员关联表
* @Author: lyd
* @Date: 2024/10/18
*/
@Data
@EqualsAndHashCode(callSuper = false)
@TableName("st_ivt_userarea")
public class UserAreaPermission {
/** 区域 */
private String product_area;
/** 用户id */
private String user_id;
}

20
lms/nladmin-system/src/main/java/org/nl/wms/basedata/st/areapermissions/service/dao/mapper/UserAreaPermissionMapper.java

@ -0,0 +1,20 @@
package org.nl.wms.basedata.st.areapermissions.service.dao.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.nl.wms.basedata.st.areapermissions.service.dao.UserAreaPermission;
import org.nl.wms.basedata.st.areapermissions.service.vo.UsersVo;
/**
* @Author: lyd
* @Date: 2024/10/18
*/
public interface UserAreaPermissionMapper extends BaseMapper<UserAreaPermission> {
/**
* 分页查询获取用户信息
* @param pages 分页
* @param blurry 模糊查询
* @return
*/
IPage<UsersVo> selectPageLeftJoin(IPage<UsersVo> pages, String blurry);
}

22
lms/nladmin-system/src/main/java/org/nl/wms/basedata/st/areapermissions/service/dao/mapper/UserAreaPermissionMapper.xml

@ -0,0 +1,22 @@
<?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="org.nl.wms.basedata.st.areapermissions.service.dao.mapper.UserAreaPermissionMapper">
<select id="selectPageLeftJoin" resultType="org.nl.wms.basedata.st.areapermissions.service.vo.UsersVo">
SELECT
sys_user.*,
dept.name
FROM
sys_user sys_user
LEFT JOIN sys_user_dept sdept ON sdept.user_id = sys_user.user_id
LEFT JOIN sys_dept dept ON dept.dept_id = sdept.dept_id
WHERE
sys_user.is_used = '1'
<if test="blurry != null">
sys_user.username LIKE concat('%',#{blurry},'%')
OR
sys_user.person_name LIKE concat('%',#{blurry},'%')
</if>
ORDER BY username DESC
</select>
</mapper>

69
lms/nladmin-system/src/main/java/org/nl/wms/basedata/st/areapermissions/service/impl/UserAreaPermissionServiceImpl.java

@ -0,0 +1,69 @@
package org.nl.wms.basedata.st.areapermissions.service.impl;
import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.nl.common.domain.query.PageQuery;
import org.nl.modules.common.exception.BadRequestException;
import org.nl.wms.basedata.st.areapermissions.service.IUserAreaPermissionService;
import org.nl.wms.basedata.st.areapermissions.service.dao.UserAreaPermission;
import org.nl.wms.basedata.st.areapermissions.service.dao.mapper.UserAreaPermissionMapper;
import org.nl.wms.basedata.st.areapermissions.service.vo.UsersVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
/**
* @Author: lyd
* @Date: 2024/10/18
*/
@Service
public class UserAreaPermissionServiceImpl extends ServiceImpl<UserAreaPermissionMapper, UserAreaPermission> implements IUserAreaPermissionService {
@Autowired
private UserAreaPermissionMapper userAreaPermissionMapper;
@Override
public IPage<UsersVo> pageQuery(Map whereJson, PageQuery page) {
String blurry = ObjectUtil.isNotEmpty(whereJson.get("blurry")) ? (String) whereJson.get("blurry") : null;
IPage<UsersVo> pages = new Page<>(page.getPage() + 1, page.getSize());
pages = userAreaPermissionMapper.selectPageLeftJoin(pages, blurry);
return pages;
}
@Override
public List<UserAreaPermission> queryUserArea(JSONObject whereJson) {
String userId = whereJson.getString("user_id");
return this.list(new LambdaQueryWrapper<UserAreaPermission>().eq(UserAreaPermission::getUser_id, userId));
}
@Override
public void save(JSONObject whereJson) {
JSONObject userInfo = whereJson.getJSONObject("jo");
JSONArray areas = whereJson.getJSONArray("rows");
if (ObjectUtil.isEmpty(userInfo)) {
throw new BadRequestException("用户数据不能为空!");
}
String userId = userInfo.getString("user_id");
// 先删除
userAreaPermissionMapper.delete(new LambdaQueryWrapper<UserAreaPermission>()
.eq(UserAreaPermission::getUser_id, userId));
// 后增加
List<UserAreaPermission> list = new LinkedList<>();
for (int i = 0; i < areas.size(); i++) {
JSONObject jsonObject = areas.getJSONObject(i);
UserAreaPermission userAreaPermission = new UserAreaPermission();
userAreaPermission.setProduct_area(jsonObject.getString("product_area"));
userAreaPermission.setUser_id(userId);
list.add(userAreaPermission);
}
this.saveBatch(list);
}
}

134
lms/nladmin-system/src/main/java/org/nl/wms/basedata/st/areapermissions/service/vo/UsersVo.java

@ -0,0 +1,134 @@
package org.nl.wms.basedata.st.areapermissions.service.vo;
import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
/**
* <p>
* 用户表
* </p>
* @author lyd
*/
@Data
public class UsersVo implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 用户标识
*/
private String user_id;
/**
* 登录账号
*/
private String username;
/**
* 姓名
*/
private String person_name;
/**
* 性别
*/
private String gender;
/**
* 电话
*/
private String phone;
/**
* 电子邮箱
*/
private String email;
/**
* 头像地址
*/
private String avatar_name;
/**
* 头像真实路径
*/
private String avatar_path;
/**
* 密码
*/
private String password;
/**
* 是否为admin账号
*/
private Boolean is_admin;
/**
* 是否启用
*/
private Boolean is_used;
/**
* 密码重置者
*/
private Long pwd_reset_user_id;
/**
* 密码重置时间
*/
private Date pwd_reset_time;
/**
* 创建人标识
*/
private String create_id;
/**
* 创建人
*/
private String create_name;
/**
* 创建时间
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JSONField(format = "yyyy-MM-dd HH:mm:ss")
private Date create_time;
/**
* 修改人标识
*/
private String update_id;
/**
* 修改人
*/
private String update_name;
/**
* 修改时间
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date update_time;
/**
* 外部人员标识
*/
private String extperson_id;
/**
* 外部用户标识
*/
private String extuser_id;
/**
* 部门名称
*/
private String name;
}

2
lms/nladmin-system/src/main/java/org/nl/wms/basedata/st/rest/UserAreaController.java

@ -15,7 +15,7 @@ import java.util.Map;
@RestController
@RequiredArgsConstructor
@RequestMapping("/api/userArea")
@RequestMapping("/api/userArea2")
@Slf4j
public class UserAreaController {
private final UserAreaService userAreaService;

21
lms/nladmin-ui/src/views/wms/basedata/product/userArea/index.vue

@ -13,9 +13,9 @@
class="filter-item"
@keyup.enter.native="crud.toQuery"
/>
<rrOperation/>
<rrOperation />
</div>
<crudOperation :permission="permission"/>
<crudOperation :permission="permission" />
</div>
<!-- 表单渲染 -->
<el-row :gutter="15">
@ -34,9 +34,9 @@
@selection-change="crud.selectionChangeHandler"
@current-change="handleCurrentChange"
>
<el-table-column show-overflow-tooltip prop="username" label="用户名"/>
<el-table-column show-overflow-tooltip prop="person_name" label="姓名"/>
<el-table-column prop="name" label="部门"/>
<el-table-column show-overflow-tooltip prop="username" label="用户名" />
<el-table-column show-overflow-tooltip prop="person_name" label="姓名" />
<el-table-column prop="name" label="部门" />
<!--<el-table-column show-overflow-tooltip prop="dept" label="部门">
<template slot-scope="scope">
<div>{{ scope.row.dept.name }}</div>
@ -44,7 +44,7 @@
</el-table-column>-->
</el-table>
<!--分页组件-->
<pagination/>
<pagination />
</el-card>
</el-col>
<!-- 菜单授权 -->
@ -71,11 +71,12 @@
:data="tableData"
tooltip-effect="dark"
style="width: 100%"
@selection-change="handleSelectionChange">
@selection-change="handleSelectionChange"
>
<el-table-column
type="selection"
width="55">
</el-table-column>
width="55"
/>
<el-table-column prop="product_area" label="区域" />
</el-table>
</el-card>
@ -104,7 +105,7 @@ export default {
cruds() {
return CRUD({
title: '角色',
url: 'api/userStor',
url: 'api/userArea',
crudMethod: { ...crudUserArea },
optShow: { add: false, reset: false, edit: false, del: false }
})

Loading…
Cancel
Save