1、师傅入驻服务技能查询所有父级名称拼做mergeName

2、师傅持久化入驻信息后需要更新师傅入驻类型为服务商
This commit is contained in:
donqi 2022-08-25 13:46:40 +08:00
parent 634c1637ec
commit de181ff5d7
5 changed files with 70 additions and 14 deletions

View File

@ -7,6 +7,7 @@ import com.ghy.common.core.domain.AjaxResult;
import com.ghy.common.core.page.TableDataInfo;
import com.ghy.common.enums.GoodsStatus;
import com.ghy.common.enums.WorkerStatus;
import com.ghy.common.enums.WorkerType;
import com.ghy.common.utils.CacheUtils;
import com.ghy.common.utils.ExceptionUtil;
import com.ghy.goods.domain.Goods;
@ -296,16 +297,15 @@ public class WorkerController extends BaseController {
@ResponseBody
@Transactional(rollbackFor = Exception.class)
public AjaxResult settled(@RequestBody WorkerSettledRequest request) {
try {
// 入驻区域信息持久化
workerAreaService.updateWorkerServArea(request.getWorkerId(), request.getWorkerAreas());
// 入驻服务品类信息持久化
workerGoodsCategoryService.updateWorkerGoodsCategory(request.getWorkerId(), request.getGoodsCategories());
return AjaxResult.success("保存成功");
} catch (Exception e) {
e.printStackTrace();
logger.error(ExceptionUtil.getExceptionMessage(e));
return AjaxResult.error(e.getMessage());
}
// 入驻区域信息持久化
workerAreaService.updateWorkerServArea(request.getWorkerId(), request.getWorkerAreas());
// 入驻服务品类信息持久化
workerGoodsCategoryService.updateWorkerGoodsCategory(request.getWorkerId(), request.getGoodsCategories());
// 更新师傅入驻类型为服务商
Worker worker = new Worker();
worker.setWorkerId(request.getWorkerId());
worker.setType(WorkerType.SP.getCode());
workerService.updateWorker(worker);
return AjaxResult.success("保存成功");
}
}

View File

@ -1,17 +1,25 @@
package com.ghy.web.controller.worker;
import com.ghy.common.constant.Constants;
import com.ghy.common.core.domain.AjaxResult;
import com.ghy.common.core.text.Convert;
import com.ghy.common.utils.StringUtils;
import com.ghy.goods.domain.GoodsCategory;
import com.ghy.goods.service.GoodsCategoryService;
import com.ghy.worker.domain.WorkerGoodsCategory;
import com.ghy.worker.request.WorkerGoodsCategorySaveRequest;
import com.ghy.worker.service.WorkerGoodsCategoryService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
@ -28,6 +36,9 @@ public class WorkerGoodsCategoryController {
@Resource
private WorkerGoodsCategoryService workerGoodsCategoryService;
@Autowired
private GoodsCategoryService goodsCategoryService;
/**
* 查询某个师傅的所有服务类目
*
@ -36,7 +47,19 @@ public class WorkerGoodsCategoryController {
@GetMapping("worker")
@ResponseBody
public AjaxResult getByWorker(Long workerId) {
return AjaxResult.success(workerGoodsCategoryService.getByWorker(workerId));
List<WorkerGoodsCategory> list = workerGoodsCategoryService.getByWorker(workerId);
for (WorkerGoodsCategory item: list) {
List<String> nameList = new ArrayList<String>();
// 查询所有父级服务类目拼接服务名称
GoodsCategory goodsCategory = goodsCategoryService.selectById(item.getGoodsCategoryId());
while (goodsCategory.getParentCategoryId() != null) {
nameList.add(goodsCategory.getGoodsCategoryName());
goodsCategory = goodsCategoryService.selectById(goodsCategory.getParentCategoryId());
}
Collections.reverse(nameList);
item.setMergeName(StringUtils.join(nameList, Constants.JOIN_SYMBOL));
}
return AjaxResult.success(list);
}
@PostMapping("save")

View File

@ -2,7 +2,7 @@ package com.ghy.common.constant;
/**
* 通用常量信息
*
*
* @author clunt
*/
public class Constants
@ -112,4 +112,9 @@ public class Constants
*/
public static final String[] JOB_ERROR_STR = { "java.net.URL", "javax.naming.InitialContext", "org.yaml.snakeyaml",
"org.springframework", "org.apache" };
}
/**
* 默认字符串连接符
* */
public static final String JOIN_SYMBOL = "-";
}

View File

@ -0,0 +1,26 @@
package com.ghy.common.enums;
/**
* @author ydq
* @date : 2022-08-25 10:56
*/
public enum WorkerType {
SP(0, "服务商"),
OBM(1, "品牌商");
private Integer code;
private String desc;
WorkerType(Integer code, String desc) {
this.code = code;
this.desc = desc;
}
public Integer getCode() {
return code;
}
public String getDesc() {
return desc;
}
}

View File

@ -30,5 +30,7 @@ public class WorkerGoodsCategory extends BaseEntity {
private String goodsCategoryName;
private String mergeName;
private List<Long> goodsCategoryIds;
}