|
@@ -2,48 +2,47 @@ package com.gubersail.app.corp.controller;
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
-import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
|
|
|
-import com.gubersail.app.api.corps.entity.*;
|
|
|
+import com.gubersail.app.api.corps.entity.AppCorpsLabel;
|
|
|
+import com.gubersail.app.api.corps.entity.AppPjCorpsDesc;
|
|
|
+import com.gubersail.app.api.corps.entity.AppPjCorpsFiles;
|
|
|
+import com.gubersail.app.api.corps.entity.AppPjCorpsType;
|
|
|
import com.gubersail.app.api.corps.vo.AppCorpsDescVO;
|
|
|
-import com.gubersail.app.corp.service.*;
|
|
|
+import com.gubersail.app.corp.service.IAppCorpsDescService;
|
|
|
+import com.gubersail.app.corp.service.IAppCorpsFilesService;
|
|
|
+import com.gubersail.app.corp.service.IAppCorpsLabelService;
|
|
|
+import com.gubersail.app.corp.service.IAppCorpsTypeService;
|
|
|
+import com.gubersail.app.wrapper.AppCorpsWrapper;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
-import io.swagger.annotations.ApiParam;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
import org.springblade.common.annotation.RepeatSubmit;
|
|
|
-import org.springblade.common.enums.CommonEnum;
|
|
|
import org.springblade.core.boot.ctrl.BladeController;
|
|
|
import org.springblade.core.mp.support.Condition;
|
|
|
import org.springblade.core.mp.support.Query;
|
|
|
import org.springblade.core.secure.utils.AuthUtil;
|
|
|
import org.springblade.core.secure.utils.SecureUtil;
|
|
|
import org.springblade.core.tool.api.R;
|
|
|
-import org.springblade.core.tool.utils.Func;
|
|
|
-import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import javax.validation.Valid;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.Arrays;
|
|
|
import java.util.List;
|
|
|
-import java.util.Objects;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
@RestController
|
|
|
@AllArgsConstructor
|
|
|
@RequestMapping("/corpsDesc")
|
|
|
-@Api(value = "客户", tags = "客户接口")
|
|
|
+@Api(value = "app门店", tags = "app门店接口")
|
|
|
public class AppCorpsDescController extends BladeController {
|
|
|
|
|
|
private final IAppCorpsDescService corpsDescService;
|
|
|
- private final IAppCorpsTypeDescService corpsTypeDescService;
|
|
|
private final IAppCorpsTypeService corpsTypeService;
|
|
|
- private final IAppCorpsAttnService corpsAttnService;
|
|
|
- private final IAppCorpsAddrService corpsAddrService;
|
|
|
+ private final IAppCorpsLabelService corpsLabelService;
|
|
|
+ private final IAppCorpsFilesService corpsFilesService;
|
|
|
|
|
|
/**
|
|
|
* 详情
|
|
@@ -57,57 +56,50 @@ public class AppCorpsDescController extends BladeController {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 分页
|
|
|
+ * 列表-分页
|
|
|
*/
|
|
|
@GetMapping("/list")
|
|
|
- @ApiOperationSupport(order = 2)
|
|
|
- @ApiOperation(value = "分页", notes = "传入corpsDesc")
|
|
|
public R<IPage<AppCorpsDescVO>> list(AppCorpsDescVO corpsDesc, Query query) {
|
|
|
- // 默认查有效的
|
|
|
- corpsDesc.setIsDeleted(0);
|
|
|
- corpsDesc.setTenantId(SecureUtil.getTenantId());
|
|
|
- IPage<AppCorpsDescVO> pages = corpsDescService.selectCorpsDescPage(Condition.getPage(query), corpsDesc);
|
|
|
-
|
|
|
- if (CollectionUtils.isNotEmpty(pages.getRecords())) {
|
|
|
- List<Long> corpsIds = new ArrayList<>();
|
|
|
- for (AppCorpsDescVO item : pages.getRecords()) {
|
|
|
- corpsIds.add(item.getId());
|
|
|
- }
|
|
|
- List<AppPjCorpsTypeDesc> pjCorpsTypeDescList = corpsTypeDescService.list(new LambdaQueryWrapper<AppPjCorpsTypeDesc>()
|
|
|
- .in(AppPjCorpsTypeDesc::getCorpId, corpsIds));
|
|
|
- List<AppPjCorpsType> pjCorpsTypeList = new ArrayList<>();
|
|
|
- if (!pjCorpsTypeDescList.isEmpty()) {
|
|
|
- List<Long> typeIdList = pjCorpsTypeDescList.stream().map(AppPjCorpsTypeDesc::getCorpTypeId).collect(Collectors.toList());
|
|
|
- if (!typeIdList.isEmpty()) {
|
|
|
- pjCorpsTypeList = corpsTypeService.list(new LambdaQueryWrapper<AppPjCorpsType>()
|
|
|
- .in(AppPjCorpsType::getId, typeIdList)
|
|
|
- .eq(AppPjCorpsType::getIsDeleted, 0));
|
|
|
+ LambdaQueryWrapper<AppPjCorpsDesc> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ lambdaQueryWrapper.eq(AppPjCorpsDesc::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .eq(AppPjCorpsDesc::getIsDeleted, 0)
|
|
|
+ .and(ObjectUtils.isNotNull(corpsDesc.getRetrieve()),i -> i.like(AppPjCorpsDesc::getCname, corpsDesc.getRetrieve()).or()
|
|
|
+ .like(AppPjCorpsDesc::getTel, corpsDesc.getRetrieve()))
|
|
|
+ .orderByAsc(AppPjCorpsDesc::getCname);
|
|
|
+ if (AuthUtil.getUserRole().contains("dealer")) {
|
|
|
+ lambdaQueryWrapper.and(i -> i.like(AppPjCorpsDesc::getSrcDistributorId, AuthUtil.getUserId()).or()
|
|
|
+ .isNull(AppPjCorpsDesc::getSrcDistributorId));
|
|
|
+ }
|
|
|
+ IPage<AppPjCorpsDesc> pages = corpsDescService.page(Condition.getPage(query), lambdaQueryWrapper);
|
|
|
+ IPage<AppCorpsDescVO> voPage = new Page<>();
|
|
|
+ if (!pages.getRecords().isEmpty()) {
|
|
|
+ //查询数据返回实体转换
|
|
|
+ voPage = AppCorpsWrapper.build().pageVO(pages);
|
|
|
+ List<Long> idList = pages.getRecords().stream().map(AppPjCorpsDesc::getId).collect(Collectors.toList());
|
|
|
+ List<AppPjCorpsFiles> filesList = corpsFilesService.list(new LambdaQueryWrapper<AppPjCorpsFiles>()
|
|
|
+ .eq(AppPjCorpsFiles::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .eq(AppPjCorpsFiles::getIsDeleted, 0)
|
|
|
+ .in(AppPjCorpsFiles::getPid, idList)
|
|
|
+ .eq(AppPjCorpsFiles::getMainImage, "1"));
|
|
|
+ for (AppCorpsDescVO item : voPage.getRecords()) {
|
|
|
+ if (filesList.isEmpty()) {
|
|
|
+ continue;
|
|
|
}
|
|
|
- }
|
|
|
- for (AppCorpsDescVO item : pages.getRecords()) {
|
|
|
- if (!pjCorpsTypeList.isEmpty()) {
|
|
|
- List<Long> typeIds = pjCorpsTypeDescList.stream()
|
|
|
- .filter(e -> e.getCorpId().equals(item.getId())).map(AppPjCorpsTypeDesc::getCorpTypeId)
|
|
|
- .collect(Collectors.toList());
|
|
|
- List<AppPjCorpsType> pjCorpsTypes = pjCorpsTypeList.stream()
|
|
|
- .filter(e -> e.getCorpType().equals(item.getCorpType()) && typeIds.contains(e.getId()))
|
|
|
- .collect(Collectors.toList());
|
|
|
- if (!pjCorpsTypes.isEmpty()) {
|
|
|
- String typeName = pjCorpsTypes.stream().map(AppPjCorpsType::getCname).collect(Collectors.joining(","));
|
|
|
- item.setCorpsTypeName(typeName);
|
|
|
- }
|
|
|
+ AppPjCorpsFiles files = filesList.stream().filter(e -> e.getPid().equals(item.getId())).findFirst().orElse(null);
|
|
|
+ if (files != null) {
|
|
|
+ item.setUrl(files.getUrl());
|
|
|
+ } else {
|
|
|
+ item.setUrl("");
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- return R.data(pages);
|
|
|
+ return R.data(voPage);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 新增或修改
|
|
|
*/
|
|
|
@PostMapping("/submit")
|
|
|
- @ApiOperationSupport(order = 6)
|
|
|
- @ApiOperation(value = "新增或修改", notes = "传入corpsDesc")
|
|
|
@RepeatSubmit
|
|
|
public R submit(@Valid @RequestBody AppCorpsDescVO corpsDescVO) {
|
|
|
if (StringUtils.isNotBlank(corpsDescVO.getTenantId())) {
|
|
@@ -118,43 +110,11 @@ public class AppCorpsDescController extends BladeController {
|
|
|
|
|
|
|
|
|
/**
|
|
|
- * 删除
|
|
|
- */
|
|
|
- @PostMapping("/remove")
|
|
|
- @ApiOperationSupport(order = 7)
|
|
|
- @ApiOperation(value = "删除", notes = "传入ids")
|
|
|
- @Transactional(rollbackFor = Exception.class)
|
|
|
- @RepeatSubmit
|
|
|
- public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) {
|
|
|
- if (!AuthUtil.getUserRole().contains("admin") && !AuthUtil.getUserRole().contains("基础资料")) {
|
|
|
- throw new RuntimeException("暂无权限,删除失败");
|
|
|
- }
|
|
|
- List<Long> list = Func.toLongList(ids);
|
|
|
- if (!list.isEmpty()) {
|
|
|
- List<AppPjCorpsAttn> corpsAttnList = corpsAttnService.list(new LambdaQueryWrapper<AppPjCorpsAttn>()
|
|
|
- .in(AppPjCorpsAttn::getPid, list));
|
|
|
- if (!corpsAttnList.isEmpty()) {
|
|
|
- List<Long> attnIds = corpsAttnList.stream().map(AppPjCorpsAttn::getId).collect(Collectors.toList());
|
|
|
- corpsAttnService.removeByIds(attnIds);
|
|
|
- }
|
|
|
- List<AppPjCorpsAddr> corpsAddrList = corpsAddrService.list(new LambdaQueryWrapper<AppPjCorpsAddr>()
|
|
|
- .in(AppPjCorpsAddr::getPid, list));
|
|
|
- if (!corpsAddrList.isEmpty()) {
|
|
|
- List<Long> addrIds = corpsAddrList.stream().map(AppPjCorpsAddr::getId).collect(Collectors.toList());
|
|
|
- corpsAddrService.removeByIds(addrIds);
|
|
|
- }
|
|
|
- }
|
|
|
- return R.status(corpsDescService.removeByIds(list));
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 启用禁用
|
|
|
+ * 审核
|
|
|
*/
|
|
|
- @GetMapping("/updateEnableOrNot")
|
|
|
- @ApiOperationSupport(order = 13)
|
|
|
- @ApiOperation(value = "启用禁用", notes = "传入corpsDesc")
|
|
|
+ @PostMapping("/review")
|
|
|
@RepeatSubmit
|
|
|
- public R updateEnableOrNot(AppPjCorpsDesc corpsDesc) {
|
|
|
+ public R review(@Valid @RequestBody AppPjCorpsDesc corpsDesc) {
|
|
|
if (corpsDesc.getId() == null) {
|
|
|
return R.fail(500, "请选择数据");
|
|
|
}
|
|
@@ -163,27 +123,47 @@ public class AppCorpsDescController extends BladeController {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 下拉
|
|
|
+ * 门店分类下拉
|
|
|
+ */
|
|
|
+ @GetMapping("/selectType")
|
|
|
+ public R<List<AppPjCorpsType>> selectType(AppPjCorpsType corpsType) {
|
|
|
+ LambdaQueryWrapper<AppPjCorpsType> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ lambdaQueryWrapper.eq(AppPjCorpsType::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .eq(AppPjCorpsType::getIsDeleted, 0)
|
|
|
+ .eq(AppPjCorpsType::getSalesCompanyId, AuthUtil.getDeptId())
|
|
|
+ .like(ObjectUtils.isNotNull(corpsType.getCname()), AppPjCorpsType::getCname, corpsType.getCname());
|
|
|
+ List<AppPjCorpsType> list = corpsTypeService.list(lambdaQueryWrapper);
|
|
|
+ return R.data(list);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 门店标签下拉
|
|
|
+ */
|
|
|
+ @GetMapping("/selectLabel")
|
|
|
+ public R<List<AppCorpsLabel>> selectType(AppCorpsLabel label) {
|
|
|
+ LambdaQueryWrapper<AppCorpsLabel> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ lambdaQueryWrapper.eq(AppCorpsLabel::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .eq(AppCorpsLabel::getIsDeleted, 0)
|
|
|
+ .like(ObjectUtils.isNotNull(label.getLabel()), AppCorpsLabel::getLabel, label.getLabel());
|
|
|
+ List<AppCorpsLabel> list = corpsLabelService.list(lambdaQueryWrapper);
|
|
|
+ return R.data(list);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 门店下拉
|
|
|
*/
|
|
|
@GetMapping("/listAll")
|
|
|
- @ApiOperationSupport(order = 14)
|
|
|
- @ApiOperation(value = "下拉", notes = "传入corpsDesc")
|
|
|
public R<List<AppPjCorpsDesc>> listAll(AppPjCorpsDesc corpsDesc) {
|
|
|
LambdaQueryWrapper<AppPjCorpsDesc> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
lambdaQueryWrapper.eq(AppPjCorpsDesc::getTenantId, AuthUtil.getTenantId())
|
|
|
.eq(AppPjCorpsDesc::getIsDeleted, 0)
|
|
|
.eq(AppPjCorpsDesc::getSalesCompanyId, AuthUtil.getDeptId())//公司
|
|
|
- .apply("find_in_set(corp_type,'" + corpsDesc.getCorpType() + "')")
|
|
|
.eq(ObjectUtils.isNotNull(corpsDesc.getEnableOrNot()), AppPjCorpsDesc::getEnableOrNot, corpsDesc.getEnableOrNot())
|
|
|
.like(ObjectUtils.isNotNull(corpsDesc.getCname()), AppPjCorpsDesc::getCname, corpsDesc.getCname());
|
|
|
- if (!AuthUtil.getUserRole().contains("admin") && !AuthUtil.getUserRole().contains("老板")
|
|
|
- && !AuthUtil.getUserRole().contains("销售总览")) {
|
|
|
- if (AuthUtil.getUserRole().contains("业务员")) {
|
|
|
- lambdaQueryWrapper.eq(AppPjCorpsDesc::getSalesmanId, AuthUtil.getUserId());
|
|
|
- }
|
|
|
+ if (AuthUtil.getUserRole().contains("dealer")) {
|
|
|
+ lambdaQueryWrapper.eq(AppPjCorpsDesc::getSrcDistributorId, AuthUtil.getUserId());
|
|
|
}
|
|
|
List<AppPjCorpsDesc> list = corpsDescService.list(lambdaQueryWrapper);
|
|
|
-
|
|
|
return R.data(list);
|
|
|
}
|
|
|
|