【代码优化】商城:门店自提的员工绑定
This commit is contained in:
parent
d5652b950e
commit
6bfe628503
|
@ -0,0 +1,4 @@
|
|||
/**
|
||||
* 占位符,可忽略
|
||||
*/
|
||||
package cn.iocoder.yudao.module.trade.controller.admin.base.system;
|
|
@ -0,0 +1,19 @@
|
|||
package cn.iocoder.yudao.module.trade.controller.admin.base.system.user;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
@Schema(description = "用户精简信息 VO")
|
||||
@Data
|
||||
public class UserSimpleBaseVO {
|
||||
|
||||
@Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "用户昵称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋艿")
|
||||
private String nickname;
|
||||
|
||||
@Schema(description = "用户头像", example = "https://www.iocoder.cn/1.png")
|
||||
private String avatar;
|
||||
|
||||
}
|
|
@ -1,8 +1,13 @@
|
|||
package cn.iocoder.yudao.module.trade.controller.admin.delivery;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
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.common.util.object.BeanUtils;
|
||||
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.base.system.user.UserSimpleBaseVO;
|
||||
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;
|
||||
|
@ -10,19 +15,16 @@ import cn.iocoder.yudao.module.trade.service.delivery.DeliveryPickUpStoreService
|
|||
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 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.getLoginUserId;
|
||||
|
||||
@Tag(name = "管理后台 - 自提门店")
|
||||
@RestController
|
||||
|
@ -33,6 +35,9 @@ public class DeliveryPickUpStoreController {
|
|||
@Resource
|
||||
private DeliveryPickUpStoreService deliveryPickUpStoreService;
|
||||
|
||||
@Resource
|
||||
private AdminUserApi adminUserApi;
|
||||
|
||||
@PostMapping("/create")
|
||||
@Operation(summary = "创建自提门店")
|
||||
@PreAuthorize("@ss.hasPermission('trade:delivery:pick-up-store:create')")
|
||||
|
@ -63,22 +68,21 @@ public class DeliveryPickUpStoreController {
|
|||
@PreAuthorize("@ss.hasPermission('trade:delivery:pick-up-store:query')")
|
||||
public CommonResult<DeliveryPickUpStoreRespVO> getDeliveryPickUpStore(@RequestParam("id") Long id) {
|
||||
DeliveryPickUpStoreDO deliveryPickUpStore = deliveryPickUpStoreService.getDeliveryPickUpStore(id);
|
||||
return success(DeliveryPickUpStoreConvert.INSTANCE.convert(deliveryPickUpStore));
|
||||
if (deliveryPickUpStore == null) {
|
||||
return success(null);
|
||||
}
|
||||
List<AdminUserRespDTO> verifyUsers = CollUtil.isNotEmpty(deliveryPickUpStore.getVerifyUserIds()) ?
|
||||
adminUserApi.getUserList(deliveryPickUpStore.getVerifyUserIds()) : null;
|
||||
return success(BeanUtils.toBean(deliveryPickUpStore, DeliveryPickUpStoreRespVO.class)
|
||||
.setVerifyUsers(BeanUtils.toBean(verifyUsers, UserSimpleBaseVO.class)));
|
||||
}
|
||||
|
||||
@GetMapping("/list-all-simple")
|
||||
@GetMapping("/simple-list")
|
||||
@Operation(summary = "获得自提门店精简信息列表")
|
||||
public CommonResult<List<DeliveryPickUpStoreSimpleRespVO>> getSimpleDeliveryPickUpStoreList() {
|
||||
List<DeliveryPickUpStoreDO> storeStaffDOS = deliveryPickUpStoreService.selectStaffByUserId(getLoginUserId());
|
||||
List<Long> storeIds = storeStaffDOS.stream().map(DeliveryPickUpStoreDO::getId).toList();
|
||||
if(!storeIds.isEmpty()){
|
||||
List<DeliveryPickUpStoreDO> list = deliveryPickUpStoreService.getDeliveryPickUpStoreListByStatus(
|
||||
CommonStatusEnum.ENABLE.getStatus(), storeIds);
|
||||
CommonStatusEnum.ENABLE.getStatus());
|
||||
return success(DeliveryPickUpStoreConvert.INSTANCE.convertList1(list));
|
||||
}else{
|
||||
return success(new ArrayList<>());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@GetMapping("/list")
|
||||
|
@ -101,18 +105,9 @@ public class DeliveryPickUpStoreController {
|
|||
@PostMapping("/bind")
|
||||
@Operation(summary = "绑定自提店员")
|
||||
@PreAuthorize("@ss.hasPermission('trade:delivery:pick-up-store:create')")
|
||||
public CommonResult<Boolean> bindDeliveryPickUpBindStoreStaffId(@Valid @RequestBody DeliveryPickUpBindStoreStaffIdReqVO bindStoreStaffIdVO) {
|
||||
deliveryPickUpStoreService.bindDeliveryPickUpBindStoreStaffId(bindStoreStaffIdVO);
|
||||
public CommonResult<Boolean> bindDeliveryPickUpStore(@Valid @RequestBody DeliveryPickUpBindReqVO bindReqVO) {
|
||||
deliveryPickUpStoreService.bindDeliveryPickUpStore(bindReqVO);
|
||||
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) {
|
||||
return success(deliveryPickUpStoreService.getDeliveryPickUpStoreStaff(id));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -1,24 +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.NotEmpty;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Schema(description = "管理后台 - 自提门店创建 Request VO")
|
||||
@Schema(description = "管理后台 - 自提门店绑定核销人 Request VO")
|
||||
@Data
|
||||
@ToString(callSuper = true)
|
||||
public class DeliveryPickUpBindStoreStaffIdReqVO {
|
||||
public class DeliveryPickUpBindReqVO {
|
||||
|
||||
@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;
|
||||
@NotEmpty(message = "绑定用户编号组数不能未空")
|
||||
private List<Long> verifyUserIds;
|
||||
|
||||
}
|
|
@ -1,27 +0,0 @@
|
|||
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;
|
||||
|
||||
}
|
|
@ -1,11 +1,13 @@
|
|||
package cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.pickup;
|
||||
|
||||
import cn.iocoder.yudao.module.trade.controller.admin.base.system.user.UserSimpleBaseVO;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
@Schema(description = "管理后台 - 自提门店 Response VO")
|
||||
@Data
|
||||
|
@ -19,4 +21,7 @@ public class DeliveryPickUpStoreRespVO extends DeliveryPickUpStoreBaseVO {
|
|||
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private LocalDateTime createTime;
|
||||
|
||||
@Schema(description = "核销用户数组", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private List<UserSimpleBaseVO> verifyUsers;
|
||||
|
||||
}
|
||||
|
|
|
@ -5,6 +5,8 @@ import lombok.AllArgsConstructor;
|
|||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Schema(description = "管理后台 - 自提门店精简信息 Response VO")
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
|
@ -29,4 +31,7 @@ public class DeliveryPickUpStoreSimpleRespVO {
|
|||
@Schema(description = "门店详细地址", requiredMode = Schema.RequiredMode.REQUIRED, example = "复旦大学路 188 号")
|
||||
private String detailAddress;
|
||||
|
||||
@Schema(description = "绑定用户编号组数", requiredMode = Schema.RequiredMode.REQUIRED, example = "23128")
|
||||
private List<Long> verifyUserIds;
|
||||
|
||||
}
|
||||
|
|
|
@ -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(), null);
|
||||
CommonStatusEnum.ENABLE.getStatus());
|
||||
return success(DeliveryPickUpStoreConvert.INSTANCE.convertList(list, latitude, longitude));
|
||||
}
|
||||
|
||||
|
|
|
@ -26,8 +26,6 @@ public interface DeliveryPickUpStoreConvert {
|
|||
|
||||
DeliveryPickUpStoreDO convert(DeliveryPickUpStoreUpdateReqVO bean);
|
||||
|
||||
DeliveryPickUpStoreRespVO convert(DeliveryPickUpStoreDO bean);
|
||||
|
||||
List<DeliveryPickUpStoreRespVO> convertList(List<DeliveryPickUpStoreDO> list);
|
||||
|
||||
PageResult<DeliveryPickUpStoreRespVO> convertPage(PageResult<DeliveryPickUpStoreDO> page);
|
||||
|
@ -43,14 +41,13 @@ public interface DeliveryPickUpStoreConvert {
|
|||
|
||||
default List<AppDeliveryPickUpStoreRespVO> convertList(List<DeliveryPickUpStoreDO> list,
|
||||
Double latitude, Double longitude) {
|
||||
List<AppDeliveryPickUpStoreRespVO> voList = CollectionUtils.convertList(list, store -> {
|
||||
return CollectionUtils.convertList(list, store -> {
|
||||
AppDeliveryPickUpStoreRespVO storeVO = convert03(store);
|
||||
if (latitude != null && longitude != null) {
|
||||
storeVO.setDistance(NumberUtils.getDistance(latitude, longitude, storeVO.getLatitude(), storeVO.getLongitude()));
|
||||
}
|
||||
return storeVO;
|
||||
});
|
||||
return voList;
|
||||
}
|
||||
@Mapping(source = "areaId", target = "areaName", qualifiedByName = "convertAreaIdToAreaName")
|
||||
AppDeliveryPickUpStoreRespVO convert03(DeliveryPickUpStoreDO bean);
|
||||
|
|
|
@ -3,11 +3,11 @@ package cn.iocoder.yudao.module.trade.dal.dataobject.delivery;
|
|||
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.type.LongListTypeHandler;
|
||||
import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
|
||||
import com.baomidou.mybatisplus.annotation.KeySequence;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalTime;
|
||||
|
@ -77,11 +77,16 @@ public class DeliveryPickUpStoreDO extends BaseDO {
|
|||
* 经度
|
||||
*/
|
||||
private Double longitude;
|
||||
|
||||
/**
|
||||
* 店员id列表
|
||||
* 核销员工用户编号数组
|
||||
*
|
||||
* 订单自提核销时,只有对应门店的店员才能核销
|
||||
*
|
||||
* 关联 {@link AdminUserRespDTO#getId()} 管理员编号
|
||||
*/
|
||||
@TableField(typeHandler = LongListTypeHandler.class)
|
||||
private List<Long> staffIds;
|
||||
private List<Long> verifyUserIds;
|
||||
|
||||
/**
|
||||
* 门店状态
|
||||
|
|
|
@ -22,16 +22,10 @@ public interface DeliveryPickUpStoreMapper extends BaseMapperX<DeliveryPickUpSto
|
|||
.orderByDesc(DeliveryPickUpStoreDO::getId));
|
||||
}
|
||||
|
||||
default List<DeliveryPickUpStoreDO> selectListByStatus(Integer status, List<Long> storeIds) {
|
||||
return selectList(new LambdaQueryWrapperX<DeliveryPickUpStoreDO>()
|
||||
.eq(DeliveryPickUpStoreDO::getStatus, status)
|
||||
.inIfPresent(DeliveryPickUpStoreDO::getId, storeIds));
|
||||
default List<DeliveryPickUpStoreDO> selectListByStatus(Integer status) {
|
||||
return selectList(DeliveryPickUpStoreDO::getStatus, status);
|
||||
}
|
||||
|
||||
default List<DeliveryPickUpStoreDO> selectStaffByUserId(Long userId){
|
||||
return selectList(new LambdaQueryWrapperX<DeliveryPickUpStoreDO>()
|
||||
.and(userId != null, w -> w.apply("FIND_IN_SET({0}, staff_ids)", userId)));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -53,6 +53,14 @@ public interface DeliveryPickUpStoreService {
|
|||
*/
|
||||
List<DeliveryPickUpStoreDO> getDeliveryPickUpStoreList(Collection<Long> ids);
|
||||
|
||||
/**
|
||||
* 获得指定状态的自提门店列表
|
||||
*
|
||||
* @param status 状态
|
||||
* @return 自提门店列表
|
||||
*/
|
||||
List<DeliveryPickUpStoreDO> getDeliveryPickUpStoreListByStatus(Integer status);
|
||||
|
||||
/**
|
||||
* 获得自提门店分页
|
||||
*
|
||||
|
@ -61,34 +69,11 @@ public interface DeliveryPickUpStoreService {
|
|||
*/
|
||||
PageResult<DeliveryPickUpStoreDO> getDeliveryPickUpStorePage(DeliveryPickUpStorePageReqVO pageReqVO);
|
||||
|
||||
/**
|
||||
* 获得指定状态的自提门店列表
|
||||
*
|
||||
* @param status 状态
|
||||
* @param storeIds 指定门店id
|
||||
* @return 自提门店列表
|
||||
*/
|
||||
List<DeliveryPickUpStoreDO> getDeliveryPickUpStoreListByStatus(Integer status, List<Long> storeIds);
|
||||
|
||||
/**
|
||||
* 绑定自提店员
|
||||
*
|
||||
* @param bindStoreStaffIdVO 绑定数据
|
||||
* @return
|
||||
* @param bindReqVO 绑定数据
|
||||
*/
|
||||
void bindDeliveryPickUpBindStoreStaffId(DeliveryPickUpBindStoreStaffIdReqVO bindStoreStaffIdVO);
|
||||
void bindDeliveryPickUpStore(DeliveryPickUpBindReqVO bindReqVO);
|
||||
|
||||
/**
|
||||
* 根据门店id获取自提店员
|
||||
* @param id 门店id
|
||||
* @return 自提店员
|
||||
*/
|
||||
DeliveryPickUpBindStoreStaffIdReqsVO getDeliveryPickUpStoreStaff(Long id);
|
||||
|
||||
/**
|
||||
* 根据用户id查询自提门店店员信息
|
||||
* @param userId 用户id
|
||||
* @return 自提门店店员信息
|
||||
*/
|
||||
List<DeliveryPickUpStoreDO> selectStaffByUserId(Long userId);
|
||||
}
|
||||
|
|
|
@ -1,16 +1,19 @@
|
|||
package cn.iocoder.yudao.module.trade.service.delivery;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
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.controller.admin.delivery.vo.pickup.DeliveryPickUpBindReqVO;
|
||||
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.mysql.delivery.DeliveryPickUpStoreMapper;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import jakarta.annotation.Resource;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
|
@ -59,7 +62,8 @@ public class DeliveryPickUpStoreServiceImpl implements DeliveryPickUpStoreServic
|
|||
}
|
||||
|
||||
private void validateDeliveryPickUpStoreExists(Long id) {
|
||||
if (deliveryPickUpStoreMapper.selectById(id) == null) {
|
||||
DeliveryPickUpStoreDO deliveryPickUpStore = deliveryPickUpStoreMapper.selectById(id);
|
||||
if (deliveryPickUpStore == null) {
|
||||
throw exception(PICK_UP_STORE_NOT_EXISTS);
|
||||
}
|
||||
}
|
||||
|
@ -74,35 +78,26 @@ public class DeliveryPickUpStoreServiceImpl implements DeliveryPickUpStoreServic
|
|||
return deliveryPickUpStoreMapper.selectBatchIds(ids);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DeliveryPickUpStoreDO> getDeliveryPickUpStoreListByStatus(Integer status) {
|
||||
return deliveryPickUpStoreMapper.selectListByStatus(status);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<DeliveryPickUpStoreDO> getDeliveryPickUpStorePage(DeliveryPickUpStorePageReqVO pageReqVO) {
|
||||
return deliveryPickUpStoreMapper.selectPage(pageReqVO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DeliveryPickUpStoreDO> getDeliveryPickUpStoreListByStatus(Integer status, List<Long> storeIds) {
|
||||
return deliveryPickUpStoreMapper.selectListByStatus(status, storeIds);
|
||||
}
|
||||
public void bindDeliveryPickUpStore(DeliveryPickUpBindReqVO bindReqVO) {
|
||||
// 1.1 校验门店存在
|
||||
validateDeliveryPickUpStoreExists(bindReqVO.getId());
|
||||
// 1.2 校验用户存在
|
||||
adminUserApi.validateUserList(bindReqVO.getVerifyUserIds());
|
||||
|
||||
@Override
|
||||
public void bindDeliveryPickUpBindStoreStaffId(DeliveryPickUpBindStoreStaffIdReqVO bindStoreStaffIdVO) {
|
||||
DeliveryPickUpStoreDO deliveryPickUpStoreDO = deliveryPickUpStoreMapper.selectById(bindStoreStaffIdVO.getId());
|
||||
deliveryPickUpStoreDO.setStaffIds(bindStoreStaffIdVO.getStoreStaffIds());
|
||||
deliveryPickUpStoreMapper.updateById(deliveryPickUpStoreDO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DeliveryPickUpBindStoreStaffIdReqsVO getDeliveryPickUpStoreStaff(Long id) {
|
||||
DeliveryPickUpStoreDO store = deliveryPickUpStoreMapper.selectById(id);
|
||||
List<Long> adminUserIds = store.getStaffIds();
|
||||
//2 查询绑定用户信息
|
||||
List<AdminUserRespDTO> storeStaffs = adminUserApi.getUserList(adminUserIds);
|
||||
return DeliveryPickUpBindStoreStaffIdReqsVO.builder().storeStaffs(storeStaffs).name(store.getName()).id(id).build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DeliveryPickUpStoreDO> selectStaffByUserId(Long userId) {
|
||||
return deliveryPickUpStoreMapper.selectStaffByUserId(userId);
|
||||
// 2. 更新
|
||||
DeliveryPickUpStoreDO updateObj = BeanUtils.toBean(bindReqVO, DeliveryPickUpStoreDO.class);
|
||||
deliveryPickUpStoreMapper.updateById(updateObj);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -35,7 +35,7 @@ public class UserPageReqVO extends PageParam {
|
|||
@Schema(description = "部门编号,同时筛选子部门", example = "1024")
|
||||
private Long deptId;
|
||||
|
||||
@Schema(description = "角色id", example = "1024")
|
||||
@Schema(description = "角色编号", example = "1024")
|
||||
private Long roleId;
|
||||
|
||||
}
|
||||
|
|
|
@ -7,7 +7,6 @@ import cn.iocoder.yudao.module.system.controller.admin.user.vo.user.UserPageReqV
|
|||
import cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
|
@ -26,21 +25,15 @@ public interface AdminUserMapper extends BaseMapperX<AdminUserDO> {
|
|||
return selectOne(AdminUserDO::getMobile, mobile);
|
||||
}
|
||||
|
||||
default PageResult<AdminUserDO> selectPage(UserPageReqVO reqVO, Collection<Long> deptIds,List<Long> userIds) {
|
||||
LambdaQueryWrapperX<AdminUserDO> adminUserDOLambdaQueryWrapperX = new LambdaQueryWrapperX<AdminUserDO>()
|
||||
default PageResult<AdminUserDO> selectPage(UserPageReqVO reqVO, Collection<Long> deptIds, Collection<Long> userIds) {
|
||||
return selectPage(reqVO, 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);
|
||||
if(userIds != null){
|
||||
if(userIds.isEmpty()){
|
||||
return new PageResult<AdminUserDO>().setList(new ArrayList<>()).setTotal(0L);
|
||||
}
|
||||
adminUserDOLambdaQueryWrapperX.in(AdminUserDO::getId, userIds);
|
||||
}
|
||||
return selectPage(reqVO, adminUserDOLambdaQueryWrapperX);
|
||||
.inIfPresent(AdminUserDO::getId, userIds)
|
||||
.orderByDesc(AdminUserDO::getId));
|
||||
}
|
||||
|
||||
default List<AdminUserDO> selectListByNickname(String nickname) {
|
||||
|
|
|
@ -22,10 +22,8 @@ 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;
|
||||
|
@ -46,11 +44,9 @@ 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;
|
||||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet;
|
||||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*;
|
||||
import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.*;
|
||||
import static cn.iocoder.yudao.module.system.enums.LogRecordConstants.*;
|
||||
|
||||
|
@ -82,8 +78,6 @@ public class AdminUserServiceImpl implements AdminUserService {
|
|||
|
||||
@Resource
|
||||
private UserPostMapper userPostMapper;
|
||||
@Resource
|
||||
private UserRoleMapper userRoleMapper;
|
||||
|
||||
@Resource
|
||||
private FileApi fileApi;
|
||||
|
@ -277,12 +271,11 @@ public class AdminUserServiceImpl implements AdminUserService {
|
|||
|
||||
@Override
|
||||
public PageResult<AdminUserDO> getUserPage(UserPageReqVO reqVO) {
|
||||
List<Long> userIds = null;
|
||||
if (reqVO.getRoleId() != null){
|
||||
//查询角色信息
|
||||
List<UserRoleDO> userRoleDOS = userRoleMapper.selectListByRoleIds(List.of(reqVO.getRoleId()));
|
||||
userIds = userRoleDOS.stream().map(UserRoleDO::getUserId).toList();
|
||||
}
|
||||
// 如果有角色编号,查询角色对应的用户编号
|
||||
Set<Long> userIds = reqVO.getRoleId() != null ?
|
||||
permissionService.getUserRoleIdListByRoleId(singleton(reqVO.getRoleId())) : null;
|
||||
|
||||
// 分页查询
|
||||
return userMapper.selectPage(reqVO, getDeptCondition(reqVO.getDeptId()), userIds);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue