Commit 4aa3ec52 by HlQ

[add] 项目列表添加项目经理字段

1 parent 7c7fa772
...@@ -10,12 +10,16 @@ import lombok.extern.slf4j.Slf4j; ...@@ -10,12 +10,16 @@ import lombok.extern.slf4j.Slf4j;
import org.dromara.hutool.core.array.ArrayUtil; import org.dromara.hutool.core.array.ArrayUtil;
import org.dromara.hutool.core.lang.Assert; import org.dromara.hutool.core.lang.Assert;
import org.dromara.hutool.core.lang.Opt; import org.dromara.hutool.core.lang.Opt;
import org.dromara.hutool.core.map.MapUtil;
import org.dromara.hutool.core.text.StrUtil; import org.dromara.hutool.core.text.StrUtil;
import org.dromara.hutool.core.util.ObjUtil; import org.dromara.hutool.core.util.ObjUtil;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import vion.dto.StatusDTO; import vion.dto.StatusDTO;
import vion.dto.StoreDTO; import vion.dto.StoreDTO;
import vion.model.*; import vion.model.RStoreConfederate;
import vion.model.RStoreUser;
import vion.model.Store;
import vion.model.StoreLog;
import vion.service.IRStoreConfederateService; import vion.service.IRStoreConfederateService;
import vion.service.IRStoreUserService; import vion.service.IRStoreUserService;
import vion.service.IStoreLogService; import vion.service.IStoreLogService;
...@@ -26,6 +30,7 @@ import vion.vo.UserVO; ...@@ -26,6 +30,7 @@ import vion.vo.UserVO;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.stream.Collectors;
@RestController @RestController
@RequestMapping("/api") @RequestMapping("/api")
...@@ -59,9 +64,16 @@ public class StoreController { ...@@ -59,9 +64,16 @@ public class StoreController {
.eq(ObjUtil.isNotNull(accountId), Store::getAccountId, accountId) .eq(ObjUtil.isNotNull(accountId), Store::getAccountId, accountId)
.eq(ObjUtil.isNotNull(id), Store::getId, id) .eq(ObjUtil.isNotNull(id), Store::getId, id)
.like(StrUtil.isNotBlank(name), Store::getName, name) .like(StrUtil.isNotBlank(name), Store::getName, name)
.last(limit != null, "limit " + limit) .last(ObjUtil.isNotNull(limit), "limit " + limit)
.list(); .list();
return converter.convert(storeList, StoreVO.class); var storeIdList = storeList.stream().map(Store::getId).toList();
var storeId2UserIdMap = Opt.ofEmptyAble(storeIdList)
.map(l -> storeUserService.lambdaQuery().in(RStoreUser::getStoreId, l).eq(RStoreUser::getIsMain, 1).list())
.map(suList -> suList.stream().collect(Collectors.toMap(RStoreUser::getStoreId, RStoreUser::getUserId)))
.orElse(MapUtil.empty());
var voList = converter.convert(storeList, StoreVO.class);
voList.forEach(v -> v.setMainUser(storeId2UserIdMap.getOrDefault(v.getId(), null)));
return voList;
} }
@PostMapping("/stores") @PostMapping("/stores")
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!