feat(repository): 添加客户查询功能并实现购物控制器
- 在AppUserService中新增getCustomers方法用于获取用户关联的客户列表 - 添加ShoppingController控制器提供报价对象查询接口 - 实现代理商和普通用户的差异化报价对象获取逻辑 - 新增SimpleUserVO数据传输对象并启用链式访问器 - 优化代码结构和依赖导入整理
This commit is contained in:
parent
49dcfe3a15
commit
54c76e64b1
|
|
@ -1,8 +1,10 @@
|
||||||
package com.nflg.mobilebroken.common.pojo.vo;
|
package com.nflg.mobilebroken.common.pojo.vo;
|
||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
|
@Accessors(chain = true)
|
||||||
public class SimpleUserVO {
|
public class SimpleUserVO {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -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<List<SimpleUserVO>> 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())
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -2,14 +2,13 @@ package com.nflg.mobilebroken.repository.service;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
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.PageData;
|
||||||
import com.nflg.mobilebroken.common.pojo.request.*;
|
import com.nflg.mobilebroken.common.pojo.request.*;
|
||||||
import com.nflg.mobilebroken.common.pojo.vo.AppUserForAdminVO;
|
import com.nflg.mobilebroken.common.pojo.vo.*;
|
||||||
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.repository.entity.AppUser;
|
import com.nflg.mobilebroken.repository.entity.AppUser;
|
||||||
import com.nflg.mobilebroken.repository.entity.DictionaryItem;
|
import com.nflg.mobilebroken.repository.entity.DictionaryItem;
|
||||||
|
import com.nflg.mobilebroken.repository.entity.TBaseCustomer;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
|
@ -76,4 +75,6 @@ public interface IAppUserService extends IService<AppUser> {
|
||||||
void updateEndUser(EndUserUpdateRequest request);
|
void updateEndUser(EndUserUpdateRequest request);
|
||||||
|
|
||||||
DictionaryItem getCategory(AppUser cuser);
|
DictionaryItem getCategory(AppUser cuser);
|
||||||
|
|
||||||
|
List<TBaseCustomer> getCustomers(Integer userId);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -415,6 +415,17 @@ public class AppUserServiceImpl extends ServiceImpl<AppUserMapper, AppUser> impl
|
||||||
.orElse(null);
|
.orElse(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<TBaseCustomer> 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) {
|
private void bindChildren1(AreaSimpleVO vo) {
|
||||||
List<AppArea> datas = appAreaService.lambdaQuery().eq(AppArea::getParentId, vo.getId()).eq(AppArea::getEnable, true).list();
|
List<AppArea> datas = appAreaService.lambdaQuery().eq(AppArea::getParentId, vo.getId()).eq(AppArea::getEnable, true).list();
|
||||||
List<AreaSimpleVO> vos = datas.stream().map(d -> new AreaSimpleVO().setId(d.getId()).setName(d.getName())).collect(Collectors.toList());
|
List<AreaSimpleVO> vos = datas.stream().map(d -> new AreaSimpleVO().setId(d.getId()).setName(d.getName())).collect(Collectors.toList());
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue