处理
This commit is contained in:
parent
29f78ae021
commit
ceddee9e85
@ -26,7 +26,7 @@ spring.redis.pool.min-idle=0
|
||||
spring.redis.timeout=5000
|
||||
|
||||
# 系统名称
|
||||
system.name = fuint会员营销管理系统
|
||||
system.name = 蓝鲸智慧油站系统
|
||||
|
||||
# 前端h5地址
|
||||
website.url=https://www.fuint.cn/h5/
|
||||
|
@ -126,6 +126,10 @@
|
||||
<artifactId>IJPay-AliPay</artifactId>
|
||||
<version>2.9.6</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-validation</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
@ -0,0 +1,88 @@
|
||||
package com.fuint.business.store.controller;
|
||||
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.api.ApiController;
|
||||
import com.baomidou.mybatisplus.extension.api.R;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.fuint.business.store.entity.ChainStoreInfo;
|
||||
import com.fuint.business.store.service.ChainStoreInfoService;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* (ChainStoreInfo)表控制层
|
||||
*
|
||||
* @author makejava
|
||||
* @since 2023-10-11 13:17:02
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("chainStoreInfo")
|
||||
public class ChainStoreInfoController extends ApiController {
|
||||
/**
|
||||
* 服务对象
|
||||
*/
|
||||
@Resource
|
||||
private ChainStoreInfoService chainStoreInfoService;
|
||||
|
||||
/**
|
||||
* 分页查询所有数据
|
||||
*
|
||||
* @param page 分页对象
|
||||
* @param chainStoreInfo 查询实体
|
||||
* @return 所有数据
|
||||
*/
|
||||
@GetMapping
|
||||
public R selectAll(Page<ChainStoreInfo> page, ChainStoreInfo chainStoreInfo) {
|
||||
return success(this.chainStoreInfoService.page(page, new QueryWrapper<>(chainStoreInfo)));
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过主键查询单条数据
|
||||
*
|
||||
* @param id 主键
|
||||
* @return 单条数据
|
||||
*/
|
||||
@GetMapping("{id}")
|
||||
public R selectOne(@PathVariable Serializable id) {
|
||||
return success(this.chainStoreInfoService.getById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增数据
|
||||
*
|
||||
* @param chainStoreInfo 实体对象
|
||||
* @return 新增结果
|
||||
*/
|
||||
@PostMapping
|
||||
public R insert(@RequestBody ChainStoreInfo chainStoreInfo) {
|
||||
return success(this.chainStoreInfoService.save(chainStoreInfo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改数据
|
||||
*
|
||||
* @param chainStoreInfo 实体对象
|
||||
* @return 修改结果
|
||||
*/
|
||||
@PutMapping
|
||||
public R update(@RequestBody ChainStoreInfo chainStoreInfo) {
|
||||
return success(this.chainStoreInfoService.updateById(chainStoreInfo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除数据
|
||||
*
|
||||
* @param idList 主键结合
|
||||
* @return 删除结果
|
||||
*/
|
||||
@DeleteMapping
|
||||
public R delete(@RequestParam("idList") List<Long> idList) {
|
||||
return success(this.chainStoreInfoService.removeByIds(idList));
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,127 @@
|
||||
package com.fuint.business.store.entity;
|
||||
|
||||
import java.util.Date;
|
||||
import com.baomidou.mybatisplus.extension.activerecord.Model;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* (ChainStoreInfo)表实体类
|
||||
*
|
||||
* @author makejava
|
||||
* @since 2023-10-11 13:17:02
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public class ChainStoreInfo extends Model<ChainStoreInfo> {
|
||||
//主键
|
||||
private Integer id;
|
||||
//连锁店名称
|
||||
private String storeName;
|
||||
//总店地址
|
||||
private String storeAddress;
|
||||
//总店联系方式
|
||||
private String storePhone;
|
||||
//总店经度
|
||||
private String storeLat;
|
||||
//总店纬度
|
||||
private String storeLng;
|
||||
//创建时间
|
||||
private Date createTime;
|
||||
//创建人
|
||||
private String createBy;
|
||||
//更新时间
|
||||
private Date updateTime;
|
||||
//更新人
|
||||
private String updateBy;
|
||||
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getStoreName() {
|
||||
return storeName;
|
||||
}
|
||||
|
||||
public void setStoreName(String storeName) {
|
||||
this.storeName = storeName;
|
||||
}
|
||||
|
||||
public String getStoreAddress() {
|
||||
return storeAddress;
|
||||
}
|
||||
|
||||
public void setStoreAddress(String storeAddress) {
|
||||
this.storeAddress = storeAddress;
|
||||
}
|
||||
|
||||
public String getStorePhone() {
|
||||
return storePhone;
|
||||
}
|
||||
|
||||
public void setStorePhone(String storePhone) {
|
||||
this.storePhone = storePhone;
|
||||
}
|
||||
|
||||
public String getStoreLat() {
|
||||
return storeLat;
|
||||
}
|
||||
|
||||
public void setStoreLat(String storeLat) {
|
||||
this.storeLat = storeLat;
|
||||
}
|
||||
|
||||
public String getStoreLng() {
|
||||
return storeLng;
|
||||
}
|
||||
|
||||
public void setStoreLng(String storeLng) {
|
||||
this.storeLng = storeLng;
|
||||
}
|
||||
|
||||
public Date getCreateTime() {
|
||||
return createTime;
|
||||
}
|
||||
|
||||
public void setCreateTime(Date createTime) {
|
||||
this.createTime = createTime;
|
||||
}
|
||||
|
||||
public String getCreateBy() {
|
||||
return createBy;
|
||||
}
|
||||
|
||||
public void setCreateBy(String createBy) {
|
||||
this.createBy = createBy;
|
||||
}
|
||||
|
||||
public Date getUpdateTime() {
|
||||
return updateTime;
|
||||
}
|
||||
|
||||
public void setUpdateTime(Date updateTime) {
|
||||
this.updateTime = updateTime;
|
||||
}
|
||||
|
||||
public String getUpdateBy() {
|
||||
return updateBy;
|
||||
}
|
||||
|
||||
public void setUpdateBy(String updateBy) {
|
||||
this.updateBy = updateBy;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取主键值
|
||||
*
|
||||
* @return 主键值
|
||||
*/
|
||||
@Override
|
||||
protected Serializable pkVal() {
|
||||
return this.id;
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,15 @@
|
||||
package com.fuint.business.store.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.fuint.business.store.entity.ChainStoreInfo;
|
||||
|
||||
/**
|
||||
* (ChainStoreInfo)表数据库访问层
|
||||
*
|
||||
* @author makejava
|
||||
* @since 2023-10-11 13:17:02
|
||||
*/
|
||||
public interface ChainStoreInfoMapper extends BaseMapper<ChainStoreInfo> {
|
||||
|
||||
}
|
||||
|
@ -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="com.fuint.business.store.mapper.ChainStoreInfoMapper">
|
||||
</mapper>
|
@ -0,0 +1,15 @@
|
||||
package com.fuint.business.store.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.fuint.business.store.entity.ChainStoreInfo;
|
||||
|
||||
/**
|
||||
* (ChainStoreInfo)表服务接口
|
||||
*
|
||||
* @author makejava
|
||||
* @since 2023-10-11 13:17:02
|
||||
*/
|
||||
public interface ChainStoreInfoService extends IService<ChainStoreInfo> {
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,19 @@
|
||||
package com.fuint.business.store.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.fuint.business.store.mapper.ChainStoreInfoMapper;
|
||||
import com.fuint.business.store.entity.ChainStoreInfo;
|
||||
import com.fuint.business.store.service.ChainStoreInfoService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* (ChainStoreInfo)表服务实现类
|
||||
*
|
||||
* @author makejava
|
||||
* @since 2023-10-11 13:17:02
|
||||
*/
|
||||
@Service("chainStoreInfoService")
|
||||
public class ChainStoreInfoServiceImpl extends ServiceImpl<ChainStoreInfoMapper, ChainStoreInfo> implements ChainStoreInfoService {
|
||||
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import java.io.Serializable;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fuint.system.dept.entity.SysDept;
|
||||
|
||||
/**
|
||||
* TreeSelect树结构实体类
|
||||
@ -25,10 +26,17 @@ public class TreeSelect implements Serializable {
|
||||
@JsonInclude(JsonInclude.Include.NON_EMPTY)
|
||||
private List<TreeSelect> childrens;
|
||||
|
||||
public TreeSelect() {
|
||||
// empty
|
||||
public TreeSelect()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public TreeSelect(SysDept dept)
|
||||
{
|
||||
this.id = dept.getDeptId();
|
||||
this.label = dept.getDeptName();
|
||||
this.childrens = dept.getChildren().stream().map(TreeSelect::new).collect(Collectors.toList());
|
||||
}
|
||||
public TreeSelect(TreeNode menu) {
|
||||
this.id = menu.getId();
|
||||
this.label = menu.getName();
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.fuint.common.dto;
|
||||
|
||||
import com.fuint.framework.entity.BaseEntity;
|
||||
import lombok.Data;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
@ -11,7 +12,7 @@ import java.util.Date;
|
||||
* CopyRight https://www.fuint.cn
|
||||
*/
|
||||
@Data
|
||||
public class AccountInfo implements Serializable {
|
||||
public class AccountInfo implements Serializable {
|
||||
|
||||
private Integer id;
|
||||
private String accountKey;
|
||||
@ -30,6 +31,8 @@ public class AccountInfo implements Serializable {
|
||||
private Integer storeId;
|
||||
private String storeName;
|
||||
private Integer staffId;
|
||||
//部门主键
|
||||
private Long deptId;
|
||||
private String token;
|
||||
|
||||
}
|
||||
|
@ -1,5 +1,7 @@
|
||||
package com.fuint.common.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.fuint.common.dto.AccountDto;
|
||||
import com.fuint.common.dto.AccountInfo;
|
||||
@ -25,6 +27,7 @@ public interface AccountService extends IService<TAccount> {
|
||||
* @return
|
||||
*/
|
||||
PaginationResponse<AccountDto> getAccountListByPagination(PaginationRequest paginationRequest) throws BusinessCheckException;
|
||||
IPage<TAccount> listAccount(Page page,TAccount accountInfo);
|
||||
|
||||
/**
|
||||
* 根据用户名获取用户对象
|
||||
|
@ -1,12 +1,14 @@
|
||||
package com.fuint.common.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.fuint.common.dto.AccountDto;
|
||||
import com.fuint.common.dto.AccountInfo;
|
||||
import com.fuint.common.service.AccountService;
|
||||
import com.fuint.common.service.StaffService;
|
||||
import com.fuint.common.util.TokenUtil;
|
||||
import com.fuint.framework.annoation.OperationServiceLog;
|
||||
import com.fuint.framework.exception.BusinessCheckException;
|
||||
import com.fuint.framework.exception.BusinessRuntimeException;
|
||||
@ -14,6 +16,8 @@ import com.fuint.framework.pagination.PaginationRequest;
|
||||
import com.fuint.framework.pagination.PaginationResponse;
|
||||
import com.fuint.repository.mapper.*;
|
||||
import com.fuint.repository.model.*;
|
||||
import com.fuint.system.dept.entity.SysDept;
|
||||
import com.fuint.system.dept.service.ISysDeptService;
|
||||
import com.fuint.utils.Digests;
|
||||
import com.fuint.utils.Encodes;
|
||||
import com.github.pagehelper.Page;
|
||||
@ -58,6 +62,8 @@ public class AccountServiceImpl extends ServiceImpl<TAccountMapper, TAccount> im
|
||||
*/
|
||||
@Autowired
|
||||
private StaffService staffService;
|
||||
@Autowired
|
||||
private ISysDeptService deptService;
|
||||
|
||||
/**
|
||||
* 分页查询账号列表
|
||||
@ -121,6 +127,13 @@ public class AccountServiceImpl extends ServiceImpl<TAccountMapper, TAccount> im
|
||||
return paginationResponse;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPage<TAccount> listAccount(com.baomidou.mybatisplus.extension.plugins.pagination.Page page, TAccount accountInfo) {
|
||||
AccountInfo nowAccountInfo = TokenUtil.getNowAccountInfo();
|
||||
SysDept sysDept = deptService.selectDeptById(nowAccountInfo.getDeptId());
|
||||
return baseMapper.listAccount(page, accountInfo,sysDept.getAncestors());
|
||||
}
|
||||
|
||||
@Override
|
||||
public AccountInfo getAccountByName(String userName) {
|
||||
Map<String, Object> param = new HashMap();
|
||||
@ -136,6 +149,7 @@ public class AccountServiceImpl extends ServiceImpl<TAccountMapper, TAccount> im
|
||||
accountInfo.setStaffId(account.getStaffId());
|
||||
accountInfo.setStoreId(account.getStoreId());
|
||||
accountInfo.setMerchantId(account.getMerchantId());
|
||||
accountInfo.setDeptId(account.getDeptId());
|
||||
if (account.getMerchantId() != null && account.getMerchantId() > 0) {
|
||||
MtMerchant mtMerchant = mtMerchantMapper.selectById(account.getMerchantId());
|
||||
if (mtMerchant != null) {
|
||||
@ -178,8 +192,8 @@ public class AccountServiceImpl extends ServiceImpl<TAccountMapper, TAccount> im
|
||||
account.setStaffId(tAccount.getStaffId());
|
||||
account.setMerchantId(tAccount.getMerchantId());
|
||||
account.setStoreId(tAccount.getStoreId());
|
||||
account.setCreateDate(new Date());
|
||||
account.setModifyDate(new Date());
|
||||
account.setCreateTime(new Date());
|
||||
account.setUpdateTime(new Date());
|
||||
account.setStoreId(tAccount.getStoreId());
|
||||
account.setStaffId(tAccount.getStaffId());
|
||||
account.setPassword(tAccount.getPassword());
|
||||
@ -228,7 +242,7 @@ public class AccountServiceImpl extends ServiceImpl<TAccountMapper, TAccount> im
|
||||
if (oldAccount == null) {
|
||||
throw new BusinessCheckException("账户不存在.");
|
||||
}
|
||||
tAccount.setModifyDate(new Date());
|
||||
tAccount.setUpdateTime(new Date());
|
||||
if (duties != null && duties.size() > 0) {
|
||||
if (tAccount.getAcctId() != null && tAccount.getAcctId() > 0) {
|
||||
tAccountDutyMapper.deleteDutiesByAccountId(tAccount.getAcctId());
|
||||
@ -283,7 +297,7 @@ public class AccountServiceImpl extends ServiceImpl<TAccountMapper, TAccount> im
|
||||
public void deleteAccount(Long userId) {
|
||||
TAccount tAccount = tAccountMapper.selectById(userId);
|
||||
tAccount.setAccountStatus(-1);
|
||||
tAccount.setModifyDate(new Date());
|
||||
tAccount.setUpdateTime(new Date());
|
||||
tAccountMapper.updateById(tAccount);
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,126 @@
|
||||
package com.fuint.system.dept.controller;
|
||||
|
||||
|
||||
import com.fuint.common.constant.UserConstants;
|
||||
import com.fuint.common.dto.AccountInfo;
|
||||
import com.fuint.common.util.StringUtils;
|
||||
import com.fuint.common.util.TokenUtil;
|
||||
import com.fuint.framework.web.BaseController;
|
||||
import com.fuint.framework.web.ResponseObject;
|
||||
import com.fuint.system.dept.entity.SysDept;
|
||||
import com.fuint.system.dept.service.ISysDeptService;
|
||||
import lombok.extern.java.Log;
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 部门信息
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/system/dept")
|
||||
public class SysDeptController extends BaseController
|
||||
{
|
||||
@Autowired
|
||||
private ISysDeptService deptService;
|
||||
|
||||
/**
|
||||
* 获取部门列表
|
||||
*/
|
||||
@GetMapping("/list")
|
||||
public ResponseObject list(SysDept dept)
|
||||
{
|
||||
List<SysDept> depts = deptService.selectDeptList(dept);
|
||||
return getSuccessResult(depts);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询部门列表(排除节点)
|
||||
*/
|
||||
@GetMapping("/list/exclude/{deptId}")
|
||||
public ResponseObject excludeChild(@PathVariable(value = "deptId", required = false) Long deptId)
|
||||
{
|
||||
List<SysDept> depts = deptService.selectDeptList(new SysDept());
|
||||
depts.removeIf(d -> d.getDeptId().intValue() == deptId || ArrayUtils.contains(StringUtils.split(d.getAncestors(), ","), deptId + ""));
|
||||
return getSuccessResult(depts);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据部门编号获取详细信息
|
||||
*/
|
||||
@GetMapping(value = "/{deptId}")
|
||||
public ResponseObject getInfo(@PathVariable Long deptId)
|
||||
{
|
||||
return getSuccessResult(deptService.selectDeptById(deptId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增部门
|
||||
*/
|
||||
@PostMapping("/add")
|
||||
public ResponseObject add(@Validated @RequestBody SysDept dept)
|
||||
{
|
||||
if (!deptService.checkDeptNameUnique(dept))
|
||||
{
|
||||
return getFailureResult("新增部门'" + dept.getDeptName() + "'失败,部门名称已存在");
|
||||
}
|
||||
AccountInfo nowAccountInfo = TokenUtil.getNowAccountInfo();
|
||||
dept.setCreateBy(nowAccountInfo.getId().toString());
|
||||
return getSuccessResult(deptService.insertDept(dept));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改部门
|
||||
*/
|
||||
@PostMapping("/edit")
|
||||
public ResponseObject edit(@Validated @RequestBody SysDept dept)
|
||||
{
|
||||
Long deptId = dept.getDeptId();
|
||||
if (!deptService.checkDeptNameUnique(dept))
|
||||
{
|
||||
return getFailureResult("修改部门'" + dept.getDeptName() + "'失败,部门名称已存在");
|
||||
}
|
||||
else if (dept.getParentId().equals(deptId))
|
||||
{
|
||||
return getFailureResult("修改部门'" + dept.getDeptName() + "'失败,上级部门不能是自己");
|
||||
}
|
||||
else if (StringUtils.equals(UserConstants.DEPT_DISABLE, dept.getStatus()) && deptService.selectNormalChildrenDeptById(deptId) > 0)
|
||||
{
|
||||
return getFailureResult("该部门包含未停用的子部门!");
|
||||
}
|
||||
AccountInfo nowAccountInfo = TokenUtil.getNowAccountInfo();
|
||||
dept.setCreateBy(nowAccountInfo.getId().toString());
|
||||
return getSuccessResult(deptService.updateDept(dept));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除部门
|
||||
*/
|
||||
@DeleteMapping("/{deptId}")
|
||||
public ResponseObject remove(@PathVariable Long deptId)
|
||||
{
|
||||
if (deptService.hasChildByDeptId(deptId))
|
||||
{
|
||||
return getFailureResult("存在下级部门,不允许删除");
|
||||
}
|
||||
if (deptService.checkDeptExistUser(deptId))
|
||||
{
|
||||
return getFailureResult("部门存在用户,不允许删除");
|
||||
}
|
||||
return getSuccessResult(deptService.deleteDeptById(deptId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取部门树列表
|
||||
*/
|
||||
@GetMapping("/deptTree")
|
||||
public ResponseObject deptTree(SysDept dept)
|
||||
{
|
||||
return getSuccessResult(deptService.selectDeptTreeList(dept));
|
||||
}
|
||||
}
|
@ -0,0 +1,64 @@
|
||||
package com.fuint.system.dept.entity;
|
||||
|
||||
import com.fuint.framework.entity.BaseEntity;
|
||||
import lombok.Data;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
|
||||
import javax.validation.constraints.Email;
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import javax.validation.constraints.Size;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 部门表 sys_dept
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
@Data
|
||||
public class SysDept extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 部门ID */
|
||||
private Long deptId;
|
||||
|
||||
/** 父部门ID */
|
||||
private Long parentId;
|
||||
|
||||
/** 祖级列表 */
|
||||
private String ancestors;
|
||||
|
||||
/** 部门名称 */
|
||||
private String deptName;
|
||||
|
||||
/** 显示顺序 */
|
||||
private Integer orderNum;
|
||||
//节点类型:1代理商2连锁店3基本门店
|
||||
private String deptType;
|
||||
|
||||
/** 负责人 */
|
||||
private Integer leaderAccountId;
|
||||
|
||||
/** 联系电话 */
|
||||
private String phone;
|
||||
|
||||
/** 邮箱 */
|
||||
private String email;
|
||||
|
||||
/** 部门状态:0正常,1停用 */
|
||||
private String status;
|
||||
|
||||
/** 删除标志(0代表存在 2代表删除) */
|
||||
private String delFlag;
|
||||
|
||||
/** 父部门名称 */
|
||||
private String parentName;
|
||||
|
||||
/** 子部门 */
|
||||
private List<SysDept> children = new ArrayList<SysDept>();
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,120 @@
|
||||
package com.fuint.system.dept.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.fuint.system.dept.entity.SysDept;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 部门管理 数据层
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
public interface SysDeptMapper extends BaseMapper<SysDept>
|
||||
{
|
||||
/**
|
||||
* 查询部门管理数据
|
||||
*
|
||||
* @param dept 部门信息
|
||||
* @return 部门信息集合
|
||||
*/
|
||||
public List<SysDept> selectDeptList(@Param("dept") SysDept dept,@Param("ownDeptStr") String ownDeptStr);
|
||||
|
||||
/**
|
||||
* 根据角色ID查询部门树信息
|
||||
*
|
||||
* @param roleId 角色ID
|
||||
* @param deptCheckStrictly 部门树选择项是否关联显示
|
||||
* @return 选中部门列表
|
||||
*/
|
||||
public List<Long> selectDeptListByRoleId(@Param("roleId") Long roleId, @Param("deptCheckStrictly") boolean deptCheckStrictly);
|
||||
|
||||
/**
|
||||
* 根据部门ID查询信息
|
||||
*
|
||||
* @param deptId 部门ID
|
||||
* @return 部门信息
|
||||
*/
|
||||
public SysDept selectDeptById(Long deptId);
|
||||
|
||||
/**
|
||||
* 根据ID查询所有子部门
|
||||
*
|
||||
* @param deptId 部门ID
|
||||
* @return 部门列表
|
||||
*/
|
||||
public List<SysDept> selectChildrenDeptById(Long deptId);
|
||||
|
||||
/**
|
||||
* 根据ID查询所有子部门(正常状态)
|
||||
*
|
||||
* @param deptId 部门ID
|
||||
* @return 子部门数
|
||||
*/
|
||||
public int selectNormalChildrenDeptById(Long deptId);
|
||||
|
||||
/**
|
||||
* 是否存在子节点
|
||||
*
|
||||
* @param deptId 部门ID
|
||||
* @return 结果
|
||||
*/
|
||||
public int hasChildByDeptId(Long deptId);
|
||||
|
||||
/**
|
||||
* 查询部门是否存在用户
|
||||
*
|
||||
* @param deptId 部门ID
|
||||
* @return 结果
|
||||
*/
|
||||
public int checkDeptExistUser(Long deptId);
|
||||
|
||||
/**
|
||||
* 校验部门名称是否唯一
|
||||
*
|
||||
* @param deptName 部门名称
|
||||
* @param parentId 父部门ID
|
||||
* @return 结果
|
||||
*/
|
||||
public SysDept checkDeptNameUnique(@Param("deptName") String deptName, @Param("parentId") Long parentId);
|
||||
|
||||
/**
|
||||
* 新增部门信息
|
||||
*
|
||||
* @param dept 部门信息
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertDept(SysDept dept);
|
||||
|
||||
/**
|
||||
* 修改部门信息
|
||||
*
|
||||
* @param dept 部门信息
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateDept(SysDept dept);
|
||||
|
||||
/**
|
||||
* 修改所在部门正常状态
|
||||
*
|
||||
* @param deptIds 部门ID组
|
||||
*/
|
||||
public void updateDeptStatusNormal(Long[] deptIds);
|
||||
|
||||
/**
|
||||
* 修改子元素关系
|
||||
*
|
||||
* @param depts 子元素
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateDeptChildren(@Param("depts") List<SysDept> depts);
|
||||
|
||||
/**
|
||||
* 删除部门管理信息
|
||||
*
|
||||
* @param deptId 部门ID
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteDeptById(Long deptId);
|
||||
}
|
@ -0,0 +1,140 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.fuint.system.dept.mapper.SysDeptMapper">
|
||||
|
||||
|
||||
<select id="selectDeptList" resultType="com.fuint.system.dept.entity.SysDept">
|
||||
select *
|
||||
from sys_dept d
|
||||
where d.del_flag = '0'
|
||||
<if test="dept.deptId != null and dept.deptId != 0">
|
||||
AND dept_id = #{dept.deptId}
|
||||
</if>
|
||||
<if test="dept.parentId != null and dept.parentId != 0">
|
||||
AND parent_id = #{dept.parentId}
|
||||
</if>
|
||||
<if test="dept.deptName != null and dept.deptName != ''">
|
||||
AND dept_name like concat('%', #{dept.deptName}, '%')
|
||||
</if>
|
||||
<if test="dept.status != null and dept.status != ''">
|
||||
AND status = #{dept.status}
|
||||
</if>
|
||||
<!-- 数据范围过滤 -->
|
||||
<if test="ownDeptStr != null and ownDeptStr!=''">
|
||||
AND ancestors like concat (#{ownDeptStr},'%')
|
||||
</if>
|
||||
|
||||
order by d.parent_id, d.order_num
|
||||
</select>
|
||||
|
||||
<select id="selectDeptListByRoleId" resultType="Long">
|
||||
select d.dept_id
|
||||
from sys_dept d
|
||||
left join sys_role_dept rd on d.dept_id = rd.dept_id
|
||||
where rd.role_id = #{roleId}
|
||||
<if test="deptCheckStrictly">
|
||||
and d.dept_id not in (select d.parent_id from sys_dept d inner join sys_role_dept rd on d.dept_id = rd.dept_id and rd.role_id = #{roleId})
|
||||
</if>
|
||||
order by d.parent_id, d.order_num
|
||||
</select>
|
||||
|
||||
<select id="selectDeptById" parameterType="Long" resultType="com.fuint.system.dept.entity.SysDept">
|
||||
select d.*,
|
||||
(select dept_name from sys_dept where dept_id = d.parent_id) parent_name
|
||||
from sys_dept d
|
||||
where d.dept_id = #{deptId}
|
||||
</select>
|
||||
|
||||
<select id="checkDeptExistUser" parameterType="Long" resultType="int">
|
||||
select count(1) from t_account where dept_id = #{deptId}
|
||||
</select>
|
||||
|
||||
<select id="hasChildByDeptId" parameterType="Long" resultType="int">
|
||||
select count(1) from sys_dept
|
||||
where del_flag = '0' and parent_id = #{deptId} limit 1
|
||||
</select>
|
||||
|
||||
<select id="selectChildrenDeptById" resultType="com.fuint.system.dept.entity.SysDept">
|
||||
select * from sys_dept where find_in_set(#{deptId}, ancestors)
|
||||
</select>
|
||||
|
||||
<select id="selectNormalChildrenDeptById" parameterType="Long" resultType="int">
|
||||
select count(*) from sys_dept where status = 0 and del_flag = '0' and find_in_set(#{deptId}, ancestors)
|
||||
</select>
|
||||
|
||||
<select id="checkDeptNameUnique" resultType="com.fuint.system.dept.entity.SysDept">
|
||||
select *
|
||||
from sys_dept
|
||||
where dept_name=#{deptName} and parent_id = #{parentId} and del_flag = '0' limit 1
|
||||
</select>
|
||||
|
||||
<insert id="insertDept">
|
||||
insert into sys_dept(
|
||||
<if test="parentId != null and parentId != 0">parent_id,</if>
|
||||
<if test="deptName != null and deptName != ''">dept_name,</if>
|
||||
<if test="ancestors != null and ancestors != ''">ancestors,</if>
|
||||
<if test="orderNum != null">order_num,</if>
|
||||
<if test="leader != null and leader != ''">leader,</if>
|
||||
<if test="phone != null and phone != ''">phone,</if>
|
||||
<if test="email != null and email != ''">email,</if>
|
||||
<if test="status != null">status,</if>
|
||||
<if test="createBy != null and createBy != ''">create_by,</if>
|
||||
create_time
|
||||
)values(
|
||||
<if test="parentId != null and parentId != 0">#{parentId},</if>
|
||||
<if test="deptName != null and deptName != ''">#{deptName},</if>
|
||||
<if test="ancestors != null and ancestors != ''">#{ancestors},</if>
|
||||
<if test="orderNum != null">#{orderNum},</if>
|
||||
<if test="leader != null and leader != ''">#{leader},</if>
|
||||
<if test="phone != null and phone != ''">#{phone},</if>
|
||||
<if test="email != null and email != ''">#{email},</if>
|
||||
<if test="status != null">#{status},</if>
|
||||
<if test="createBy != null and createBy != ''">#{createBy},</if>
|
||||
sysdate()
|
||||
)
|
||||
</insert>
|
||||
|
||||
<update id="updateDept">
|
||||
update sys_dept
|
||||
<set>
|
||||
<if test="parentId != null and parentId != 0">parent_id = #{parentId},</if>
|
||||
<if test="deptName != null and deptName != ''">dept_name = #{deptName},</if>
|
||||
<if test="ancestors != null and ancestors != ''">ancestors = #{ancestors},</if>
|
||||
<if test="orderNum != null">order_num = #{orderNum},</if>
|
||||
<if test="leader != null">leader = #{leader},</if>
|
||||
<if test="phone != null">phone = #{phone},</if>
|
||||
<if test="email != null">email = #{email},</if>
|
||||
<if test="status != null and status != ''">status = #{status},</if>
|
||||
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
|
||||
update_time = sysdate()
|
||||
</set>
|
||||
where dept_id = #{deptId}
|
||||
</update>
|
||||
|
||||
<update id="updateDeptChildren" parameterType="java.util.List">
|
||||
update sys_dept set ancestors =
|
||||
<foreach collection="depts" item="item" index="index"
|
||||
separator=" " open="case dept_id" close="end">
|
||||
when #{item.deptId} then #{item.ancestors}
|
||||
</foreach>
|
||||
where dept_id in
|
||||
<foreach collection="depts" item="item" index="index"
|
||||
separator="," open="(" close=")">
|
||||
#{item.deptId}
|
||||
</foreach>
|
||||
</update>
|
||||
|
||||
<update id="updateDeptStatusNormal" parameterType="Long">
|
||||
update sys_dept set status = '0' where dept_id in
|
||||
<foreach collection="array" item="deptId" open="(" separator="," close=")">
|
||||
#{deptId}
|
||||
</foreach>
|
||||
</update>
|
||||
|
||||
<delete id="deleteDeptById" parameterType="Long">
|
||||
update sys_dept set del_flag = '2' where dept_id = #{deptId}
|
||||
</delete>
|
||||
|
||||
</mapper>
|
@ -0,0 +1,114 @@
|
||||
package com.fuint.system.dept.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.fuint.common.domain.TreeSelect;
|
||||
import com.fuint.system.dept.entity.SysDept;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 部门管理 服务层
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
public interface ISysDeptService extends IService<SysDept>
|
||||
{
|
||||
/**
|
||||
* 查询部门管理数据
|
||||
*
|
||||
* @param dept 部门信息
|
||||
* @return 部门信息集合
|
||||
*/
|
||||
public List<SysDept> selectDeptList(SysDept dept);
|
||||
|
||||
/**
|
||||
* 查询部门树结构信息
|
||||
*
|
||||
* @param dept 部门信息
|
||||
* @return 部门树信息集合
|
||||
*/
|
||||
public List<TreeSelect> selectDeptTreeList(SysDept dept);
|
||||
|
||||
/**
|
||||
* 构建前端所需要树结构
|
||||
*
|
||||
* @param depts 部门列表
|
||||
* @return 树结构列表
|
||||
*/
|
||||
public List<SysDept> buildDeptTree(List<SysDept> depts);
|
||||
|
||||
/**
|
||||
* 构建前端所需要下拉树结构
|
||||
*
|
||||
* @param depts 部门列表
|
||||
* @return 下拉树结构列表
|
||||
*/
|
||||
public List<TreeSelect> buildDeptTreeSelect(List<SysDept> depts);
|
||||
|
||||
|
||||
/**
|
||||
* 根据部门ID查询信息
|
||||
*
|
||||
* @param deptId 部门ID
|
||||
* @return 部门信息
|
||||
*/
|
||||
public SysDept selectDeptById(Long deptId);
|
||||
|
||||
/**
|
||||
* 根据ID查询所有子部门(正常状态)
|
||||
*
|
||||
* @param deptId 部门ID
|
||||
* @return 子部门数
|
||||
*/
|
||||
public int selectNormalChildrenDeptById(Long deptId);
|
||||
|
||||
/**
|
||||
* 是否存在部门子节点
|
||||
*
|
||||
* @param deptId 部门ID
|
||||
* @return 结果
|
||||
*/
|
||||
public boolean hasChildByDeptId(Long deptId);
|
||||
|
||||
/**
|
||||
* 查询部门是否存在用户
|
||||
*
|
||||
* @param deptId 部门ID
|
||||
* @return 结果 true 存在 false 不存在
|
||||
*/
|
||||
public boolean checkDeptExistUser(Long deptId);
|
||||
|
||||
/**
|
||||
* 校验部门名称是否唯一
|
||||
*
|
||||
* @param dept 部门信息
|
||||
* @return 结果
|
||||
*/
|
||||
public boolean checkDeptNameUnique(SysDept dept);
|
||||
|
||||
|
||||
/**
|
||||
* 新增保存部门信息
|
||||
*
|
||||
* @param dept 部门信息
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertDept(SysDept dept);
|
||||
|
||||
/**
|
||||
* 修改保存部门信息
|
||||
*
|
||||
* @param dept 部门信息
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateDept(SysDept dept);
|
||||
|
||||
/**
|
||||
* 删除部门管理信息
|
||||
*
|
||||
* @param deptId 部门ID
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteDeptById(Long deptId);
|
||||
}
|
@ -0,0 +1,304 @@
|
||||
package com.fuint.system.dept.service.impl;
|
||||
|
||||
import com.aliyun.oss.ServiceException;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.fuint.common.constant.UserConstants;
|
||||
import com.fuint.common.domain.TreeSelect;
|
||||
import com.fuint.common.dto.AccountInfo;
|
||||
import com.fuint.common.util.Convert;
|
||||
import com.fuint.common.util.SpringUtils;
|
||||
import com.fuint.common.util.StringUtils;
|
||||
import com.fuint.common.util.TokenUtil;
|
||||
import com.fuint.system.dept.entity.SysDept;
|
||||
import com.fuint.system.dept.mapper.SysDeptMapper;
|
||||
import com.fuint.system.dept.service.ISysDeptService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 部门管理 服务实现
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
@Service
|
||||
public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper,SysDept> implements ISysDeptService
|
||||
{
|
||||
|
||||
/**
|
||||
* 查询部门管理数据
|
||||
*
|
||||
* @param dept 部门信息
|
||||
* @return 部门信息集合
|
||||
*/
|
||||
@Override
|
||||
public List<SysDept> selectDeptList(SysDept dept)
|
||||
{
|
||||
AccountInfo nowAccountInfo = TokenUtil.getNowAccountInfo();
|
||||
SysDept sysDept = baseMapper.selectDeptById(nowAccountInfo.getDeptId());
|
||||
return baseMapper.selectDeptList(dept,sysDept.getAncestors());
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询部门树结构信息
|
||||
*
|
||||
* @param dept 部门信息
|
||||
* @return 部门树信息集合
|
||||
*/
|
||||
@Override
|
||||
public List<TreeSelect> selectDeptTreeList(SysDept dept)
|
||||
{
|
||||
List<SysDept> depts = this.selectDeptList(dept);
|
||||
return buildDeptTreeSelect(depts);
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建前端所需要树结构
|
||||
*
|
||||
* @param depts 部门列表
|
||||
* @return 树结构列表
|
||||
*/
|
||||
@Override
|
||||
public List<SysDept> buildDeptTree(List<SysDept> depts)
|
||||
{
|
||||
List<SysDept> returnList = new ArrayList<SysDept>();
|
||||
List<Long> tempList = depts.stream().map(SysDept::getDeptId).collect(Collectors.toList());
|
||||
for (SysDept dept : depts)
|
||||
{
|
||||
// 如果是顶级节点, 遍历该父节点的所有子节点
|
||||
if (!tempList.contains(dept.getParentId()))
|
||||
{
|
||||
recursionFn(depts, dept);
|
||||
returnList.add(dept);
|
||||
}
|
||||
}
|
||||
if (returnList.isEmpty())
|
||||
{
|
||||
returnList = depts;
|
||||
}
|
||||
return returnList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建前端所需要下拉树结构
|
||||
*
|
||||
* @param depts 部门列表
|
||||
* @return 下拉树结构列表
|
||||
*/
|
||||
@Override
|
||||
public List<TreeSelect> buildDeptTreeSelect(List<SysDept> depts)
|
||||
{
|
||||
List<SysDept> deptTrees = buildDeptTree(depts);
|
||||
return deptTrees.stream().map(TreeSelect::new).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 根据部门ID查询信息
|
||||
*
|
||||
* @param deptId 部门ID
|
||||
* @return 部门信息
|
||||
*/
|
||||
@Override
|
||||
public SysDept selectDeptById(Long deptId)
|
||||
{
|
||||
return baseMapper.selectDeptById(deptId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据ID查询所有子部门(正常状态)
|
||||
*
|
||||
* @param deptId 部门ID
|
||||
* @return 子部门数
|
||||
*/
|
||||
@Override
|
||||
public int selectNormalChildrenDeptById(Long deptId)
|
||||
{
|
||||
return baseMapper.selectNormalChildrenDeptById(deptId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否存在子节点
|
||||
*
|
||||
* @param deptId 部门ID
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public boolean hasChildByDeptId(Long deptId)
|
||||
{
|
||||
int result = baseMapper.hasChildByDeptId(deptId);
|
||||
return result > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询部门是否存在用户
|
||||
*
|
||||
* @param deptId 部门ID
|
||||
* @return 结果 true 存在 false 不存在
|
||||
*/
|
||||
@Override
|
||||
public boolean checkDeptExistUser(Long deptId)
|
||||
{
|
||||
int result = baseMapper.checkDeptExistUser(deptId);
|
||||
return result > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验部门名称是否唯一
|
||||
*
|
||||
* @param dept 部门信息
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public boolean checkDeptNameUnique(SysDept dept)
|
||||
{
|
||||
Long deptId = StringUtils.isNull(dept.getDeptId()) ? -1L : dept.getDeptId();
|
||||
SysDept info = baseMapper.checkDeptNameUnique(dept.getDeptName(), dept.getParentId());
|
||||
if (StringUtils.isNotNull(info) && info.getDeptId().longValue() != deptId.longValue())
|
||||
{
|
||||
return UserConstants.NOT_UNIQUE;
|
||||
}
|
||||
return UserConstants.UNIQUE;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 新增保存部门信息
|
||||
*
|
||||
* @param dept 部门信息
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int insertDept(SysDept dept)
|
||||
{
|
||||
if (null!=dept.getParentId()){
|
||||
SysDept info = baseMapper.selectDeptById(dept.getParentId());
|
||||
// 如果父节点不为正常状态,则不允许新增子节点
|
||||
if (!UserConstants.DEPT_NORMAL.equals(info.getStatus()))
|
||||
{
|
||||
throw new ServiceException("部门停用,不允许新增");
|
||||
}
|
||||
dept.setAncestors(info.getAncestors() + "," + dept.getParentId());
|
||||
}
|
||||
return baseMapper.insertDept(dept);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改保存部门信息
|
||||
*
|
||||
* @param dept 部门信息
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int updateDept(SysDept dept)
|
||||
{
|
||||
SysDept newParentDept = baseMapper.selectDeptById(dept.getParentId());
|
||||
SysDept oldDept = baseMapper.selectDeptById(dept.getDeptId());
|
||||
if (StringUtils.isNotNull(newParentDept) && StringUtils.isNotNull(oldDept))
|
||||
{
|
||||
String newAncestors = newParentDept.getAncestors() + "," + newParentDept.getDeptId();
|
||||
String oldAncestors = oldDept.getAncestors();
|
||||
dept.setAncestors(newAncestors);
|
||||
updateDeptChildren(dept.getDeptId(), newAncestors, oldAncestors);
|
||||
}
|
||||
int result = baseMapper.updateDept(dept);
|
||||
if (UserConstants.DEPT_NORMAL.equals(dept.getStatus()) && StringUtils.isNotEmpty(dept.getAncestors())
|
||||
&& !StringUtils.equals("0", dept.getAncestors()))
|
||||
{
|
||||
// 如果该部门是启用状态,则启用该部门的所有上级部门
|
||||
updateParentDeptStatusNormal(dept);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改该部门的父级部门状态
|
||||
*
|
||||
* @param dept 当前部门
|
||||
*/
|
||||
private void updateParentDeptStatusNormal(SysDept dept)
|
||||
{
|
||||
String ancestors = dept.getAncestors();
|
||||
Long[] deptIds = Convert.toLongArray(ancestors);
|
||||
baseMapper.updateDeptStatusNormal(deptIds);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改子元素关系
|
||||
*
|
||||
* @param deptId 被修改的部门ID
|
||||
* @param newAncestors 新的父ID集合
|
||||
* @param oldAncestors 旧的父ID集合
|
||||
*/
|
||||
public void updateDeptChildren(Long deptId, String newAncestors, String oldAncestors)
|
||||
{
|
||||
List<SysDept> children = baseMapper.selectChildrenDeptById(deptId);
|
||||
for (SysDept child : children)
|
||||
{
|
||||
child.setAncestors(child.getAncestors().replaceFirst(oldAncestors, newAncestors));
|
||||
}
|
||||
if (children.size() > 0)
|
||||
{
|
||||
baseMapper.updateDeptChildren(children);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除部门管理信息
|
||||
*
|
||||
* @param deptId 部门ID
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteDeptById(Long deptId)
|
||||
{
|
||||
return baseMapper.deleteDeptById(deptId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 递归列表
|
||||
*/
|
||||
private void recursionFn(List<SysDept> list, SysDept t)
|
||||
{
|
||||
// 得到子节点列表
|
||||
List<SysDept> childList = getChildList(list, t);
|
||||
t.setChildren(childList);
|
||||
for (SysDept tChild : childList)
|
||||
{
|
||||
if (hasChild(list, tChild))
|
||||
{
|
||||
recursionFn(list, tChild);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 得到子节点列表
|
||||
*/
|
||||
private List<SysDept> getChildList(List<SysDept> list, SysDept t)
|
||||
{
|
||||
List<SysDept> tlist = new ArrayList<SysDept>();
|
||||
Iterator<SysDept> it = list.iterator();
|
||||
while (it.hasNext())
|
||||
{
|
||||
SysDept n = (SysDept) it.next();
|
||||
if (StringUtils.isNotNull(n.getParentId()) && n.getParentId().longValue() == t.getDeptId().longValue())
|
||||
{
|
||||
tlist.add(n);
|
||||
}
|
||||
}
|
||||
return tlist;
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断是否有子节点
|
||||
*/
|
||||
private boolean hasChild(List<SysDept> list, SysDept t)
|
||||
{
|
||||
return getChildList(list, t).size() > 0;
|
||||
}
|
||||
}
|
@ -37,7 +37,7 @@ public class SysDictDataController extends BaseController
|
||||
|
||||
@GetMapping("/list")
|
||||
public ResponseObject list(SysDictData dictData,
|
||||
@RequestParam(value = "pageNo",defaultValue = "1") Integer pageNo,
|
||||
@RequestParam(value = "pageNum",defaultValue = "1") Integer pageNo,
|
||||
@RequestParam(value = "pageSize",defaultValue = "10") Integer pageSize)
|
||||
{
|
||||
Page page =new Page(pageNo,pageSize);
|
||||
|
@ -30,7 +30,7 @@ public class SysDictTypeController extends BaseController
|
||||
|
||||
@GetMapping("/list")
|
||||
public ResponseObject list(SysDictType dictType,
|
||||
@RequestParam(value = "pageNo",defaultValue = "1") Integer pageNo,
|
||||
@RequestParam(value = "pageNum",defaultValue = "1") Integer pageNo,
|
||||
@RequestParam(value = "pageSize",defaultValue = "10") Integer pageSize)
|
||||
{
|
||||
Page page =new Page(pageNo,pageSize);
|
||||
|
@ -40,10 +40,10 @@ public class DictUtils
|
||||
*/
|
||||
public static List<SysDictData> getDictCache(String key)
|
||||
{
|
||||
JSONArray arrayCache = SpringUtils.getBean(RedisCache.class).getCacheObject(getCacheKey(key));
|
||||
Object arrayCache = SpringUtils.getBean(RedisCache.class).getCacheObject(getCacheKey(key));
|
||||
if (StringUtils.isNotNull(arrayCache))
|
||||
{
|
||||
return arrayCache.toList(SysDictData.class);
|
||||
return JSONArray.parseArray(JSONArray.toJSONString(arrayCache),SysDictData.class);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -1,5 +1,7 @@
|
||||
package com.fuint.module.backendApi.controller;
|
||||
package com.fuint.system.user.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.fuint.common.util.Constants;
|
||||
import com.fuint.common.dto.AccountDto;
|
||||
import com.fuint.common.dto.AccountInfo;
|
||||
@ -69,52 +71,18 @@ public class BackendAccountController extends BaseController {
|
||||
/**
|
||||
* 账户信息列表
|
||||
*
|
||||
* @param request HttpServletRequest对象
|
||||
* @return 账户信息列表
|
||||
*/
|
||||
@ApiOperation(value = "账户信息列表")
|
||||
@RequestMapping(value = "/list", method = RequestMethod.GET)
|
||||
@CrossOrigin
|
||||
public ResponseObject list(HttpServletRequest request) throws BusinessCheckException {
|
||||
String token = request.getHeader("Access-Token");
|
||||
Integer page = request.getParameter("page") == null ? Constants.PAGE_NUMBER : Integer.parseInt(request.getParameter("page"));
|
||||
Integer pageSize = request.getParameter("pageSize") == null ? Constants.PAGE_SIZE : Integer.parseInt(request.getParameter("pageSize"));
|
||||
String accountName = request.getParameter("accountName") == null ? "" : request.getParameter("accountName");
|
||||
String realName = request.getParameter("realName") == null ? "" : request.getParameter("realName");
|
||||
String accountStatus = request.getParameter("accountStatus") == null ? "" : request.getParameter("accountStatus");
|
||||
public ResponseObject list(TAccount accountInfo,
|
||||
@RequestParam(value = "pageNum",defaultValue = "1") Integer pageNo,
|
||||
@RequestParam(value = "pageSize",defaultValue = "10") Integer pageSize) throws BusinessCheckException {
|
||||
|
||||
AccountInfo accountInfo = TokenUtil.getAccountInfoByToken(token);
|
||||
if (accountInfo == null) {
|
||||
return getFailureResult(1001, "请先登录");
|
||||
}
|
||||
|
||||
PaginationRequest paginationRequest = new PaginationRequest();
|
||||
paginationRequest.setCurrentPage(page);
|
||||
paginationRequest.setPageSize(pageSize);
|
||||
|
||||
Map<String, Object> searchParams = new HashMap<>();
|
||||
if (StringUtil.isNotEmpty(accountName)) {
|
||||
searchParams.put("name", accountName);
|
||||
}
|
||||
if (StringUtil.isNotEmpty(realName)) {
|
||||
searchParams.put("realName", realName);
|
||||
}
|
||||
if (StringUtil.isNotEmpty(accountStatus)) {
|
||||
searchParams.put("status", accountStatus);
|
||||
}
|
||||
if (StringUtil.isNotEmpty(accountStatus)) {
|
||||
searchParams.put("status", accountStatus);
|
||||
}
|
||||
if (accountInfo.getMerchantId() != null && accountInfo.getMerchantId() > 0) {
|
||||
searchParams.put("merchantId", accountInfo.getMerchantId());
|
||||
}
|
||||
if (accountInfo.getStoreId() != null && accountInfo.getStoreId() > 0) {
|
||||
searchParams.put("storeId", accountInfo.getStoreId());
|
||||
}
|
||||
|
||||
paginationRequest.setSearchParams(searchParams);
|
||||
PaginationResponse<AccountDto> paginationResponse = tAccountService.getAccountListByPagination(paginationRequest);
|
||||
return getSuccessResult(paginationResponse);
|
||||
Page page =new Page(pageNo,pageSize);
|
||||
IPage<TAccount> res = tAccountService.listAccount(page,accountInfo);
|
||||
return getSuccessResult(res);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -170,9 +138,9 @@ public class BackendAccountController extends BaseController {
|
||||
accountDto.setAccountKey(tAccount.getAccountKey());
|
||||
accountDto.setAccountName(tAccount.getAccountName());
|
||||
accountDto.setAccountStatus(tAccount.getAccountStatus());
|
||||
accountDto.setCreateDate(tAccount.getCreateDate());
|
||||
accountDto.setCreateDate(tAccount.getCreateTime());
|
||||
accountDto.setRealName(tAccount.getRealName());
|
||||
accountDto.setModifyDate(tAccount.getModifyDate());
|
||||
accountDto.setModifyDate(tAccount.getUpdateTime());
|
||||
accountDto.setStaffId(tAccount.getStaffId());
|
||||
accountDto.setMerchantId(tAccount.getMerchantId());
|
||||
if (tAccount.getStoreId() > 0) {
|
@ -90,7 +90,7 @@ public class GlobalExceptionHandler {
|
||||
public ResponseObject handleException(LoginEffectiveException e, HttpServletRequest request) {
|
||||
String requestURI = request.getRequestURI();
|
||||
log.error("登录信息失效", requestURI, e);
|
||||
return new ResponseObject(101, e.getMessage(), null);
|
||||
return new ResponseObject(1001, e.getMessage(), null);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -75,4 +75,13 @@ public class BaseController {
|
||||
public ResponseObject getFailureResult(int errorCode, String message, Object data) {
|
||||
return new ResponseObject(errorCode, message, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取错返回结果(无参数替换)
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public ResponseObject getFailureResult(String message) {
|
||||
return new ResponseObject(201, message, null);
|
||||
}
|
||||
}
|
@ -1,7 +1,10 @@
|
||||
package com.fuint.repository.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.fuint.repository.model.TAccount;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
/**
|
||||
* 后台账号 Mapper 接口
|
||||
@ -10,5 +13,5 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
* CopyRight https://www.fuint.cn
|
||||
*/
|
||||
public interface TAccountMapper extends BaseMapper<TAccount> {
|
||||
|
||||
IPage<TAccount> listAccount(Page page, @Param("accountInfo") TAccount accountInfo,@Param("ancestors") String ancestors);
|
||||
}
|
||||
|
@ -1,10 +1,13 @@
|
||||
package com.fuint.repository.model;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
import com.fuint.repository.model.base.BaseEntity;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Getter;
|
||||
@ -20,7 +23,7 @@ import lombok.Setter;
|
||||
@Setter
|
||||
@TableName("t_account")
|
||||
@ApiModel(value = "TAccount对象", description = "后台管理员表")
|
||||
public class TAccount implements Serializable {
|
||||
public class TAccount extends BaseEntity implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ -43,12 +46,6 @@ public class TAccount implements Serializable {
|
||||
@ApiModelProperty("0 未激活 1已激活")
|
||||
private Integer isActive;
|
||||
|
||||
@ApiModelProperty("创建时间")
|
||||
private Date createDate;
|
||||
|
||||
@ApiModelProperty("修改时间")
|
||||
private Date modifyDate;
|
||||
|
||||
@ApiModelProperty("随机码")
|
||||
private String salt;
|
||||
|
||||
@ -72,10 +69,8 @@ public class TAccount implements Serializable {
|
||||
|
||||
@ApiModelProperty("账户头像地址")
|
||||
private String avatar;
|
||||
|
||||
@ApiModelProperty("创建用户")
|
||||
private String createUser;
|
||||
|
||||
@ApiModelProperty("修改用户")
|
||||
private String updateUser;
|
||||
//机构主键
|
||||
private Long deptId;
|
||||
@TableField(exist = false)
|
||||
private String deptName;
|
||||
}
|
||||
|
@ -1,5 +1,23 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.fuint.repository.mapper.TAccountMapper">
|
||||
<select id="listAccount" resultType="com.fuint.repository.model.TAccount">
|
||||
SELECT
|
||||
ta.*,sd.dept_name
|
||||
FROM
|
||||
`t_account` ta
|
||||
left join sys_dept sd on sd.dept_id = ta.dept_id
|
||||
<if test="accountInfo.realName != null and accountInfo.realName != ''">
|
||||
AND ta.real_name = like concat('%',#{accountInfo.realName},'%')
|
||||
</if>
|
||||
<if test="accountInfo.deptId != null">
|
||||
AND ta.dept_id = #{accountInfo.deptId}
|
||||
</if>
|
||||
<!-- 数据范围过滤 -->
|
||||
<if test="ownDeptStr != null and ownDeptStr!=''">
|
||||
AND sd.ancestors like concat (#{ownDeptStr},'%')
|
||||
</if>
|
||||
order by create_time desc
|
||||
|
||||
</select>
|
||||
</mapper>
|
||||
|
Loading…
Reference in New Issue
Block a user