【功能】添加扫描枪核销功能、根据当前登录人查询自提点功能和绑定自提员工功能

This commit is contained in:
痴货 2024-09-20 20:23:45 +08:00
parent 2c4d8298cf
commit 476dafbb99
16 changed files with 356 additions and 13 deletions

View File

@ -80,6 +80,7 @@ public interface ErrorCodeConstants {
// ========== 物流 PICK_UP 模块 1-011-006-000 ==========
ErrorCode PICK_UP_STORE_NOT_EXISTS = new ErrorCode(1_011_006_000, "自提门店不存在");
ErrorCode PICK_UP_STORE_STAFF_NOT_EXISTS = new ErrorCode(1_011_006_000, "自提门店店员不存在");
// ========== 分销用户 模块 1-011-007-000 ==========
ErrorCode BROKERAGE_USER_NOT_EXISTS = new ErrorCode(1_011_007_000, "分销用户不存在");

View File

@ -3,10 +3,14 @@ package cn.iocoder.yudao.module.trade.controller.admin.delivery;
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.security.core.LoginUser;
import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.pickup.*;
import cn.iocoder.yudao.module.trade.convert.delivery.DeliveryPickUpStoreConvert;
import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryPickUpStoreDO;
import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryPickUpStoreStaffDO;
import cn.iocoder.yudao.module.trade.service.delivery.DeliveryPickUpStoreService;
import cn.iocoder.yudao.module.trade.service.delivery.DeliveryPickUpStoreStaffService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
@ -16,10 +20,15 @@ import org.springframework.web.bind.annotation.*;
import jakarta.annotation.Resource;
import jakarta.validation.Valid;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUser;
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
import static java.util.stream.Collectors.toList;
@Tag(name = "管理后台 - 自提门店")
@RestController
@ -30,6 +39,9 @@ public class DeliveryPickUpStoreController {
@Resource
private DeliveryPickUpStoreService deliveryPickUpStoreService;
@Resource
private DeliveryPickUpStoreStaffService deliveryPickUpStoreStaffService;
@PostMapping("/create")
@Operation(summary = "创建自提门店")
@PreAuthorize("@ss.hasPermission('trade:delivery:pick-up-store:create')")
@ -66,9 +78,16 @@ public class DeliveryPickUpStoreController {
@GetMapping("/list-all-simple")
@Operation(summary = "获得自提门店精简信息列表")
public CommonResult<List<DeliveryPickUpStoreSimpleRespVO>> getSimpleDeliveryPickUpStoreList() {
List<DeliveryPickUpStoreDO> list = deliveryPickUpStoreService.getDeliveryPickUpStoreListByStatus(
CommonStatusEnum.ENABLE.getStatus());
return success(DeliveryPickUpStoreConvert.INSTANCE.convertList1(list));
List<DeliveryPickUpStoreStaffDO> storeStaffDOS = deliveryPickUpStoreStaffService.selectStaffByUserId(getLoginUserId());
List<Long> storeIds = storeStaffDOS.stream().map(DeliveryPickUpStoreStaffDO::getStoreId).toList();
if(!storeIds.isEmpty()){
List<DeliveryPickUpStoreDO> list = deliveryPickUpStoreService.getDeliveryPickUpStoreListByStatus(
CommonStatusEnum.ENABLE.getStatus(), storeIds);
return success(DeliveryPickUpStoreConvert.INSTANCE.convertList1(list));
}else{
return success(new ArrayList<>());
}
}
@GetMapping("/list")
@ -88,4 +107,22 @@ public class DeliveryPickUpStoreController {
return success(DeliveryPickUpStoreConvert.INSTANCE.convertPage(pageResult));
}
@PostMapping("/bind")
@Operation(summary = "绑定自提店员")
@PreAuthorize("@ss.hasPermission('trade:delivery:pick-up-store:create')")
public CommonResult<Boolean> bindDeliveryPickUpBindStoreStaffId(@Valid @RequestBody DeliveryPickUpBindStoreStaffIdReqVO bindStoreStaffIdVO) {
deliveryPickUpStoreService.bindDeliveryPickUpBindStoreStaffId(bindStoreStaffIdVO);
return success(true);
}
@GetMapping("/get-store-staff")
@Operation(summary = "查询门店绑定情况")
@Parameter(name = "id", description = "编号", required = true, example = "1024")
@PreAuthorize("@ss.hasPermission('trade:delivery:pick-up-store:query')")
public CommonResult<DeliveryPickUpBindStoreStaffIdReqsVO> getDeliveryPickUpStoreStaff(@RequestParam("id") Long id) {
DeliveryPickUpStoreDO deliveryPickUpStore = deliveryPickUpStoreService.getDeliveryPickUpStore(id);
return success(deliveryPickUpStoreStaffService.getDeliveryPickUpStoreStaff(deliveryPickUpStore.getId(),deliveryPickUpStore.getName()));
}
}

View File

@ -0,0 +1,46 @@
package cn.iocoder.yudao.module.trade.controller.admin.delivery;
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.pickup.*;
import cn.iocoder.yudao.module.trade.convert.delivery.DeliveryPickUpStoreConvert;
import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryPickUpStoreDO;
import cn.iocoder.yudao.module.trade.service.delivery.DeliveryPickUpStoreService;
import cn.iocoder.yudao.module.trade.service.delivery.DeliveryPickUpStoreStaffService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import jakarta.validation.Valid;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.util.Collection;
import java.util.List;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
@Tag(name = "管理后台 - 自提门店店员")
@RestController
@RequestMapping("/trade/delivery/pick-up-store-staff")
@Validated
public class DeliveryPickUpStoreStaffController {
@Resource
private DeliveryPickUpStoreStaffService deliveryPickUpStoreStaffService;
@DeleteMapping("/delete")
@Operation(summary = "删除自提门店店员")
@Parameter(name = "userId", description = "用户编号", required = true)
@Parameter(name = "storeId", description = "自提门店编号", required = true)
@PreAuthorize("@ss.hasPermission('trade:delivery:pick-up-store:delete')")
public CommonResult<Boolean> deleteDeliveryPickUpStoreStaff(@RequestParam("userId") Long id,@RequestParam("storeId") Long storeId) {
deliveryPickUpStoreStaffService.deleteDeliveryPickUpStoreStaff(id, storeId);
return success(true);
}
}

View File

@ -0,0 +1,24 @@
package cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.pickup;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotNull;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import java.util.List;
@Schema(description = "管理后台 - 自提门店创建 Request VO")
@Data
@ToString(callSuper = true)
public class DeliveryPickUpBindStoreStaffIdReqVO {
@Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "23128")
@NotNull(message = "编号不能为空")
private Long id;
@Schema(description = "绑定用户编号组数", requiredMode = Schema.RequiredMode.REQUIRED, example = "23128")
@NotNull(message = "绑定用户编号组数不能未空")
private List<Long> storeStaffIds;
}

View File

@ -0,0 +1,27 @@
package cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.pickup;
import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotNull;
import lombok.Builder;
import lombok.Data;
import lombok.ToString;
import java.util.List;
@Schema(description = "管理后台 - 自提门店创建 Request VO")
@Data
@ToString(callSuper = true)
@Builder
public class DeliveryPickUpBindStoreStaffIdReqsVO {
@Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "23128")
private Long id;
@Schema(description = "门店名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "23128")
private String name;
@Schema(description = "绑定用户信息组数", requiredMode = Schema.RequiredMode.REQUIRED, example = "23128")
private List<AdminUserRespDTO> storeStaffs;
}

View File

@ -40,7 +40,7 @@ public class AppDeliverPickUpStoreController {
@RequestParam(value = "latitude", required = false) Double latitude,
@RequestParam(value = "longitude", required = false) Double longitude) {
List<DeliveryPickUpStoreDO> list = deliveryPickUpStoreService.getDeliveryPickUpStoreListByStatus(
CommonStatusEnum.ENABLE.getStatus());
CommonStatusEnum.ENABLE.getStatus(), null);
return success(DeliveryPickUpStoreConvert.INSTANCE.convertList(list, latitude, longitude));
}

View File

@ -5,7 +5,9 @@ import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
import com.baomidou.mybatisplus.annotation.KeySequence;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
// TODO @芋艿后续再详细 review 一轮
// TODO @芋艿可能改成 DeliveryPickUpStoreUserDO

View File

@ -22,8 +22,10 @@ public interface DeliveryPickUpStoreMapper extends BaseMapperX<DeliveryPickUpSto
.orderByDesc(DeliveryPickUpStoreDO::getId));
}
default List<DeliveryPickUpStoreDO> selectListByStatus(Integer status) {
return selectList(DeliveryPickUpStoreDO::getStatus, status);
default List<DeliveryPickUpStoreDO> selectListByStatus(Integer status, List<Long> storeIds) {
return selectList(new LambdaQueryWrapperX<DeliveryPickUpStoreDO>()
.eq(DeliveryPickUpStoreDO::getStatus, status)
.inIfPresent(DeliveryPickUpStoreDO::getId, storeIds));
}
}

View File

@ -1,12 +1,33 @@
package cn.iocoder.yudao.module.trade.dal.mysql.delivery;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryPickUpStoreStaffDO;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.apache.ibatis.annotations.Mapper;
import java.util.Collections;
import java.util.List;
@Mapper
public interface DeliveryPickUpStoreStaffMapper extends BaseMapperX<DeliveryPickUpStoreStaffDO> {
default Long selectStaffIdByUserIdAndStoreId(List<Long> userId, Long storeId){
return selectOne(new LambdaQueryWrapperX<DeliveryPickUpStoreStaffDO>()
.inIfPresent(DeliveryPickUpStoreStaffDO::getAdminUserId, userId)
.eqIfPresent(DeliveryPickUpStoreStaffDO::getStoreId, storeId))
.getId();
}
default List<DeliveryPickUpStoreStaffDO> getUserIdsByStoreId(Long id){
return selectList(new LambdaQueryWrapperX<DeliveryPickUpStoreStaffDO>()
.eq(DeliveryPickUpStoreStaffDO::getStoreId,id));
}
default void deleteStaffByUserIdsAndStoreId(List<Long> userIds, Long storeId){
Long StaffId = selectStaffIdByUserIdAndStoreId(userIds, storeId);
deleteById(StaffId);
}
}

View File

@ -1,6 +1,7 @@
package cn.iocoder.yudao.module.trade.service.delivery;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.pickup.DeliveryPickUpBindStoreStaffIdReqVO;
import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.pickup.DeliveryPickUpStoreCreateReqVO;
import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.pickup.DeliveryPickUpStorePageReqVO;
import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.pickup.DeliveryPickUpStoreUpdateReqVO;
@ -67,7 +68,16 @@ public interface DeliveryPickUpStoreService {
* 获得指定状态的自提门店列表
*
* @param status 状态
* @param storeIds 指定门店id
* @return 自提门店列表
*/
List<DeliveryPickUpStoreDO> getDeliveryPickUpStoreListByStatus(Integer status);
List<DeliveryPickUpStoreDO> getDeliveryPickUpStoreListByStatus(Integer status, List<Long> storeIds);
/**
* 绑定自提店员
*
* @param bindStoreStaffIdVO 绑定数据
* @return
*/
void bindDeliveryPickUpBindStoreStaffId(DeliveryPickUpBindStoreStaffIdReqVO bindStoreStaffIdVO);
}

View File

@ -1,18 +1,26 @@
package cn.iocoder.yudao.module.trade.service.delivery;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.pickup.DeliveryPickUpBindStoreStaffIdReqVO;
import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.pickup.DeliveryPickUpStoreCreateReqVO;
import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.pickup.DeliveryPickUpStorePageReqVO;
import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.pickup.DeliveryPickUpStoreUpdateReqVO;
import cn.iocoder.yudao.module.trade.convert.delivery.DeliveryPickUpStoreConvert;
import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryPickUpStoreDO;
import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryPickUpStoreStaffDO;
import cn.iocoder.yudao.module.trade.dal.mysql.delivery.DeliveryPickUpStoreMapper;
import cn.iocoder.yudao.module.trade.dal.mysql.delivery.DeliveryPickUpStoreStaffMapper;
import com.mchange.lang.LongUtils;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
import jakarta.annotation.Resource;
import java.util.Collection;
import java.util.List;
import java.util.stream.Collectors;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.yudao.module.trade.enums.ErrorCodeConstants.PICK_UP_STORE_NOT_EXISTS;
@ -28,6 +36,8 @@ public class DeliveryPickUpStoreServiceImpl implements DeliveryPickUpStoreServic
@Resource
private DeliveryPickUpStoreMapper deliveryPickUpStoreMapper;
@Resource
private DeliveryPickUpStoreStaffMapper deliveryPickUpStoreStaffMapper;
@Override
public Long createDeliveryPickUpStore(DeliveryPickUpStoreCreateReqVO createReqVO) {
@ -77,8 +87,32 @@ public class DeliveryPickUpStoreServiceImpl implements DeliveryPickUpStoreServic
}
@Override
public List<DeliveryPickUpStoreDO> getDeliveryPickUpStoreListByStatus(Integer status) {
return deliveryPickUpStoreMapper.selectListByStatus(status);
public List<DeliveryPickUpStoreDO> getDeliveryPickUpStoreListByStatus(Integer status, List<Long> storeIds) {
return deliveryPickUpStoreMapper.selectListByStatus(status, storeIds);
}
@Override
public void bindDeliveryPickUpBindStoreStaffId(DeliveryPickUpBindStoreStaffIdReqVO bindStoreStaffIdVO) {
//查询旧列表
List<DeliveryPickUpStoreStaffDO> storeStaffDOS = deliveryPickUpStoreStaffMapper.getUserIdsByStoreId(bindStoreStaffIdVO.getId());
List<Long> oldStoreStaffIds = storeStaffDOS.stream().map(DeliveryPickUpStoreStaffDO::getAdminUserId).toList();
List<Long> newStoreStaffIds = bindStoreStaffIdVO.getStoreStaffIds();
List<List<Long>> diffList = CollectionUtils.diffList(oldStoreStaffIds, newStoreStaffIds, // id 不同就认为是不同的记录
ObjectUtil::equal);
// 添加
if (CollUtil.isNotEmpty(diffList.get(0))) {
diffList.get(0).forEach(id -> {
DeliveryPickUpStoreStaffDO storeStaffDO = new DeliveryPickUpStoreStaffDO();
storeStaffDO.setStoreId(bindStoreStaffIdVO.getId());
storeStaffDO.setAdminUserId(id);
deliveryPickUpStoreStaffMapper.insert(storeStaffDO);
});
}
//删除
if (CollUtil.isNotEmpty(diffList.get(2))) {
deliveryPickUpStoreStaffMapper.deleteStaffByUserIdsAndStoreId(diffList.get(2), bindStoreStaffIdVO.getId());
}
}
}

View File

@ -0,0 +1,42 @@
package cn.iocoder.yudao.module.trade.service.delivery;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.pickup.*;
import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryPickUpStoreDO;
import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryPickUpStoreStaffDO;
import cn.iocoder.yudao.module.trade.dal.mysql.delivery.DeliveryPickUpStoreStaffMapper;
import jakarta.annotation.Resource;
import jakarta.validation.Valid;
import java.util.Collection;
import java.util.List;
/**
* 自提门店店员 Service 接口
*
* @author jason
*/
public interface DeliveryPickUpStoreStaffService {
/**
* 查询门店绑定用户信息数组
*
* @param id 门店编号
* @return 用户信息数组
*/
DeliveryPickUpBindStoreStaffIdReqsVO getDeliveryPickUpStoreStaff(Long id, String name);
/**
* 删除自提门店店员
*
* @param id 门店店员编号
*/
void deleteDeliveryPickUpStoreStaff(Long id, Long storeId);
/**
* 根据用户id查询自提门店店员信息
* @param userId
* @return
*/
List<DeliveryPickUpStoreStaffDO> selectStaffByUserId(Long userId);
}

View File

@ -0,0 +1,79 @@
package cn.iocoder.yudao.module.trade.service.delivery;
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.pickup.*;
import cn.iocoder.yudao.module.trade.convert.delivery.DeliveryPickUpStoreConvert;
import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryPickUpStoreDO;
import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryPickUpStoreStaffDO;
import cn.iocoder.yudao.module.trade.dal.mysql.delivery.DeliveryPickUpStoreMapper;
import cn.iocoder.yudao.module.trade.dal.mysql.delivery.DeliveryPickUpStoreStaffMapper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.yudao.module.trade.enums.ErrorCodeConstants.PICK_UP_STORE_NOT_EXISTS;
import static cn.iocoder.yudao.module.trade.enums.ErrorCodeConstants.PICK_UP_STORE_STAFF_NOT_EXISTS;
import static java.util.stream.Collectors.toList;
/**
* 自提门店店员 Service 实现类
*
* @author jason
*/
@Service
@Validated
public class DeliveryPickUpStoreStaffServiceImpl implements DeliveryPickUpStoreStaffService {
@Resource
private DeliveryPickUpStoreStaffMapper deliveryPickUpStoreStaffMapper;
@Resource
private AdminUserApi adminUserApi;
@Override
public DeliveryPickUpBindStoreStaffIdReqsVO getDeliveryPickUpStoreStaff(Long id, String name) {
//1 查询绑定对应关系
List<DeliveryPickUpStoreStaffDO> storeStaffDOS = deliveryPickUpStoreStaffMapper.selectList(new LambdaQueryWrapperX<DeliveryPickUpStoreStaffDO>()
.eq(DeliveryPickUpStoreStaffDO::getStoreId, id)
.eq(DeliveryPickUpStoreStaffDO::getStatus, CommonStatusEnum.ENABLE.getStatus()));
List<Long> adminUserIds = storeStaffDOS.stream().map(DeliveryPickUpStoreStaffDO::getAdminUserId).collect(toList());
//2 查询绑定用户信息
List<AdminUserRespDTO> storeStaffs = adminUserApi.getUserList(adminUserIds);
return DeliveryPickUpBindStoreStaffIdReqsVO.builder().storeStaffs(storeStaffs).name(name).id(id).build();
}
@Override
public void deleteDeliveryPickUpStoreStaff(Long userId, Long storeId) {
//通过用户编号和自提门店id查询
Long StaffId = deliveryPickUpStoreStaffMapper.selectStaffIdByUserIdAndStoreId(Collections.singletonList(userId), storeId);
// 校验存在
validateDeliveryPickUpStoreStaffExists(StaffId);
// 删除
deliveryPickUpStoreStaffMapper.deleteById(StaffId);
}
@Override
public List<DeliveryPickUpStoreStaffDO> selectStaffByUserId(Long userId) {
return deliveryPickUpStoreStaffMapper.selectList(new LambdaQueryWrapper<DeliveryPickUpStoreStaffDO>().eq(DeliveryPickUpStoreStaffDO::getAdminUserId,userId));
}
private void validateDeliveryPickUpStoreStaffExists(Long id) {
if (deliveryPickUpStoreStaffMapper.selectById(id) == null) {
throw exception(PICK_UP_STORE_STAFF_NOT_EXISTS);
}
}
}

View File

@ -35,4 +35,7 @@ public class UserPageReqVO extends PageParam {
@Schema(description = "部门编号,同时筛选子部门", example = "1024")
private Long deptId;
@Schema(description = "角色id", example = "1024")
private Long roleId;
}

View File

@ -25,14 +25,18 @@ public interface AdminUserMapper extends BaseMapperX<AdminUserDO> {
return selectOne(AdminUserDO::getMobile, mobile);
}
default PageResult<AdminUserDO> selectPage(UserPageReqVO reqVO, Collection<Long> deptIds) {
return selectPage(reqVO, new LambdaQueryWrapperX<AdminUserDO>()
default PageResult<AdminUserDO> selectPage(UserPageReqVO reqVO, Collection<Long> deptIds,List<Long> userIds) {
LambdaQueryWrapperX<AdminUserDO> adminUserDOLambdaQueryWrapperX = new LambdaQueryWrapperX<AdminUserDO>()
.likeIfPresent(AdminUserDO::getUsername, reqVO.getUsername())
.likeIfPresent(AdminUserDO::getMobile, reqVO.getMobile())
.eqIfPresent(AdminUserDO::getStatus, reqVO.getStatus())
.betweenIfPresent(AdminUserDO::getCreateTime, reqVO.getCreateTime())
.inIfPresent(AdminUserDO::getDeptId, deptIds)
.orderByDesc(AdminUserDO::getId));
.orderByDesc(AdminUserDO::getId);
if(userIds != null){
adminUserDOLambdaQueryWrapperX.in(AdminUserDO::getId, userIds);
}
return selectPage(reqVO, adminUserDOLambdaQueryWrapperX);
}
default List<AdminUserDO> selectListByNickname(String nickname) {

View File

@ -22,8 +22,10 @@ import cn.iocoder.yudao.module.system.controller.admin.user.vo.user.UserPageReqV
import cn.iocoder.yudao.module.system.controller.admin.user.vo.user.UserSaveReqVO;
import cn.iocoder.yudao.module.system.dal.dataobject.dept.DeptDO;
import cn.iocoder.yudao.module.system.dal.dataobject.dept.UserPostDO;
import cn.iocoder.yudao.module.system.dal.dataobject.permission.UserRoleDO;
import cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO;
import cn.iocoder.yudao.module.system.dal.mysql.dept.UserPostMapper;
import cn.iocoder.yudao.module.system.dal.mysql.permission.UserRoleMapper;
import cn.iocoder.yudao.module.system.dal.mysql.user.AdminUserMapper;
import cn.iocoder.yudao.module.system.service.dept.DeptService;
import cn.iocoder.yudao.module.system.service.dept.PostService;
@ -44,6 +46,7 @@ import org.springframework.transaction.annotation.Transactional;
import java.io.InputStream;
import java.time.LocalDateTime;
import java.util.*;
import java.util.stream.Collectors;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList;
@ -79,6 +82,8 @@ public class AdminUserServiceImpl implements AdminUserService {
@Resource
private UserPostMapper userPostMapper;
@Resource
private UserRoleMapper userRoleMapper;
@Resource
private FileApi fileApi;
@ -272,7 +277,13 @@ public class AdminUserServiceImpl implements AdminUserService {
@Override
public PageResult<AdminUserDO> getUserPage(UserPageReqVO reqVO) {
return userMapper.selectPage(reqVO, getDeptCondition(reqVO.getDeptId()));
List<Long> userIds = null;
if (reqVO.getRoleId() != null){
//查询角色信息
List<UserRoleDO> userRoleDOS = userRoleMapper.selectListByRoleIds(List.of(reqVO.getRoleId()));
userIds = userRoleDOS.stream().map(UserRoleDO::getUserId).toList();
}
return userMapper.selectPage(reqVO, getDeptCondition(reqVO.getDeptId()), userIds);
}
@Override