From 54c76e64b140603d8267968af6789a0e9a1fc1bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9B=B9=E9=B9=8F=E9=A3=9E?= Date: Tue, 10 Mar 2026 17:40:13 +0800 Subject: [PATCH] =?UTF-8?q?feat(repository):=20=E6=B7=BB=E5=8A=A0=E5=AE=A2?= =?UTF-8?q?=E6=88=B7=E6=9F=A5=E8=AF=A2=E5=8A=9F=E8=83=BD=E5=B9=B6=E5=AE=9E?= =?UTF-8?q?=E7=8E=B0=E8=B4=AD=E7=89=A9=E6=8E=A7=E5=88=B6=E5=99=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在AppUserService中新增getCustomers方法用于获取用户关联的客户列表 - 添加ShoppingController控制器提供报价对象查询接口 - 实现代理商和普通用户的差异化报价对象获取逻辑 - 新增SimpleUserVO数据传输对象并启用链式访问器 - 优化代码结构和依赖导入整理 --- .../common/pojo/vo/SimpleUserVO.java | 2 + .../controller/app/ShoppingController.java | 50 +++++++++++++++++++ .../repository/service/IAppUserService.java | 9 ++-- .../service/impl/AppUserServiceImpl.java | 11 ++++ 4 files changed, 68 insertions(+), 4 deletions(-) create mode 100644 nflg-mobilebroken-quotation/src/main/java/com/nflg/mobilebroken/quotation/controller/app/ShoppingController.java diff --git a/nflg-mobilebroken-common/src/main/java/com/nflg/mobilebroken/common/pojo/vo/SimpleUserVO.java b/nflg-mobilebroken-common/src/main/java/com/nflg/mobilebroken/common/pojo/vo/SimpleUserVO.java index c7ae8eb1..c2243a0f 100644 --- a/nflg-mobilebroken-common/src/main/java/com/nflg/mobilebroken/common/pojo/vo/SimpleUserVO.java +++ b/nflg-mobilebroken-common/src/main/java/com/nflg/mobilebroken/common/pojo/vo/SimpleUserVO.java @@ -1,8 +1,10 @@ package com.nflg.mobilebroken.common.pojo.vo; import lombok.Data; +import lombok.experimental.Accessors; @Data +@Accessors(chain = true) public class SimpleUserVO { /** diff --git a/nflg-mobilebroken-quotation/src/main/java/com/nflg/mobilebroken/quotation/controller/app/ShoppingController.java b/nflg-mobilebroken-quotation/src/main/java/com/nflg/mobilebroken/quotation/controller/app/ShoppingController.java new file mode 100644 index 00000000..c400ee51 --- /dev/null +++ b/nflg-mobilebroken-quotation/src/main/java/com/nflg/mobilebroken/quotation/controller/app/ShoppingController.java @@ -0,0 +1,50 @@ +package com.nflg.mobilebroken.quotation.controller.app; + +import com.nflg.mobilebroken.common.pojo.ApiResult; +import com.nflg.mobilebroken.common.pojo.vo.SimpleUserVO; +import com.nflg.mobilebroken.common.util.AppUserUtil; +import com.nflg.mobilebroken.quotation.controller.ControllerBase; +import com.nflg.mobilebroken.repository.entity.TBaseCustomer; +import com.nflg.mobilebroken.repository.service.IAppUserService; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import javax.annotation.Resource; +import java.util.List; +import java.util.stream.Collectors; + +/** + * 购物 + */ +@RestController +@RequestMapping("/shopping") +public class ShoppingController extends ControllerBase { + + @Resource + private IAppUserService appUserService; + + /** + * 获取报价对象 + */ + @GetMapping("/getTargets") + public ApiResult> getTargets() { + if (AppUserUtil.isAgent()) { + return ApiResult.success(appUserService.getCustomers(AppUserUtil.getUserId()) + .stream() + .filter(TBaseCustomer::getQuotationUse) + .map(cus -> new SimpleUserVO() + .setUserId(cus.getId()) + .setUserName(cus.getAgencyCompanyName()) + ) + .collect(Collectors.toList()) + ); + } else { + return ApiResult.success(List.of(new SimpleUserVO() + .setUserId(AppUserUtil.getUserId()) + .setUserName(AppUserUtil.getUserName()) + ) + ); + } + } +} diff --git a/nflg-mobilebroken-repository/src/main/java/com/nflg/mobilebroken/repository/service/IAppUserService.java b/nflg-mobilebroken-repository/src/main/java/com/nflg/mobilebroken/repository/service/IAppUserService.java index e42f58c0..b3ce1c96 100644 --- a/nflg-mobilebroken-repository/src/main/java/com/nflg/mobilebroken/repository/service/IAppUserService.java +++ b/nflg-mobilebroken-repository/src/main/java/com/nflg/mobilebroken/repository/service/IAppUserService.java @@ -2,14 +2,13 @@ package com.nflg.mobilebroken.repository.service; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.service.IService; +import com.nflg.mobilebroken.common.pojo.ApiResult; import com.nflg.mobilebroken.common.pojo.PageData; import com.nflg.mobilebroken.common.pojo.request.*; -import com.nflg.mobilebroken.common.pojo.vo.AppUserForAdminVO; -import com.nflg.mobilebroken.common.pojo.vo.AppUserVO; -import com.nflg.mobilebroken.common.pojo.vo.AreaSimpleVO; -import com.nflg.mobilebroken.common.pojo.vo.CompanyVO; +import com.nflg.mobilebroken.common.pojo.vo.*; import com.nflg.mobilebroken.repository.entity.AppUser; import com.nflg.mobilebroken.repository.entity.DictionaryItem; +import com.nflg.mobilebroken.repository.entity.TBaseCustomer; import java.util.List; @@ -76,4 +75,6 @@ public interface IAppUserService extends IService { void updateEndUser(EndUserUpdateRequest request); DictionaryItem getCategory(AppUser cuser); + + List getCustomers(Integer userId); } diff --git a/nflg-mobilebroken-repository/src/main/java/com/nflg/mobilebroken/repository/service/impl/AppUserServiceImpl.java b/nflg-mobilebroken-repository/src/main/java/com/nflg/mobilebroken/repository/service/impl/AppUserServiceImpl.java index 3aca58ce..d472fa5c 100644 --- a/nflg-mobilebroken-repository/src/main/java/com/nflg/mobilebroken/repository/service/impl/AppUserServiceImpl.java +++ b/nflg-mobilebroken-repository/src/main/java/com/nflg/mobilebroken/repository/service/impl/AppUserServiceImpl.java @@ -415,6 +415,17 @@ public class AppUserServiceImpl extends ServiceImpl impl .orElse(null); } + @Override + public List getCustomers(Integer userId) { + AppUser appUser = getById(userId); + return customerService.lambdaQuery() + .in(TBaseCustomer::getId, Arrays.stream(appUser.getCompanyId().split(",")) + .map(Integer::parseInt) + .collect(Collectors.toList()) + ) + .list(); + } + private void bindChildren1(AreaSimpleVO vo) { List datas = appAreaService.lambdaQuery().eq(AppArea::getParentId, vo.getId()).eq(AppArea::getEnable, true).list(); List vos = datas.stream().map(d -> new AreaSimpleVO().setId(d.getId()).setName(d.getName())).collect(Collectors.toList());