提交 e2867246 作者: xiaowang

分类删除校验

上级 499dc1d2
...@@ -334,7 +334,7 @@ public enum ResultEnum implements BaseErrorInfoInterface { ...@@ -334,7 +334,7 @@ public enum ResultEnum implements BaseErrorInfoInterface {
WARE_NAME_HAS_BEEN_EXIST("30900", "商品名称已存在"), WARE_NAME_HAS_BEEN_EXIST("30900", "商品名称已存在"),
WARE_TYPE_NAME_HAS_BEEN_EXIST("30901", "分类名称已存在"), WARE_TYPE_NAME_HAS_BEEN_EXIST("30901", "分类名称已存在"),
WARE_TYPE_ICON_NOT_NULL("30902", "一级分类图标不能为空"), WARE_TYPE_ICON_NOT_NULL("30902", "一级分类图标不能为空"),
GROUP_DONT_DELETE("30903", "该分类下尚有商品存在"), GROUP_DONT_DELETE("30903", "该分类下尚有商品或服务或课程存在"),
GOODS_STATUS_ERROR("30904", "状态有误"), GOODS_STATUS_ERROR("30904", "状态有误"),
GOODS_ON_SHELF_SUCCESS("30905", "商品上架成功"), GOODS_ON_SHELF_SUCCESS("30905", "商品上架成功"),
GOODS_DOWN_SHELF_SUCCESS("30906", "商品下架成功"), GOODS_DOWN_SHELF_SUCCESS("30906", "商品下架成功"),
......
...@@ -63,7 +63,8 @@ public class BackstageTaskServiceController extends BaseController { ...@@ -63,7 +63,8 @@ public class BackstageTaskServiceController extends BaseController {
@ApiOperation(value = "查询作业服务") @ApiOperation(value = "查询作业服务")
@ApiResponses({@ApiResponse(code = 200, message = "OK", response = ServiceDTO.class)}) @ApiResponses({@ApiResponse(code = 200, message = "OK", response = ServiceDTO.class)})
@GetMapping("queryWorkService") @GetMapping("queryWorkService")
public ResultBody<ServiceDTO> queryWorkService(@ApiParam("作业服务id") @RequestParam(value = "id") Integer id) { public ResultBody<ServiceDTO> queryWorkService(
@ApiParam("作业服务id") @RequestParam(value = "id") Integer id) {
return backstageTaskService.queryById(id); return backstageTaskService.queryById(id);
} }
...@@ -71,8 +72,10 @@ public class BackstageTaskServiceController extends BaseController { ...@@ -71,8 +72,10 @@ public class BackstageTaskServiceController extends BaseController {
@ApiResponses({@ApiResponse(code = 200, message = "OK", response = ServiceDTO.class)}) @ApiResponses({@ApiResponse(code = 200, message = "OK", response = ServiceDTO.class)})
@PostMapping("queryServiceManagerList") @PostMapping("queryServiceManagerList")
public ResultBody<ServiceDTO> queryServiceManagerList( public ResultBody<ServiceDTO> queryServiceManagerList(
@Validated(Page.class) @RequestBody ServiceQO param, HttpServletRequest request) { @Validated(Page.class) @RequestBody ServiceQO param, HttpServletRequest request) {
return ResultBody.success(backstageTaskService.queryServiceManagerList(param, this.getUserLoginInfoFromRedis(request).getUserAccountId())); return ResultBody.success(
backstageTaskService.queryServiceManagerList(
param, this.getUserLoginInfoFromRedis(request).getUserAccountId()));
} }
@ApiOperation(value = "远程查询作业服务") @ApiOperation(value = "远程查询作业服务")
...@@ -85,9 +88,9 @@ public class BackstageTaskServiceController extends BaseController { ...@@ -85,9 +88,9 @@ public class BackstageTaskServiceController extends BaseController {
@ApiOperation(value = "批量查询分类下的作业服务数量") @ApiOperation(value = "批量查询分类下的作业服务数量")
@ApiResponses({@ApiResponse(code = 200, message = "OK", response = Integer.class)}) @ApiResponses({@ApiResponse(code = 200, message = "OK", response = Integer.class)})
@PostMapping("getWorkServiceConutByCategoriesId") @PostMapping("getWorkServiceCountByCategoriesId")
@ApiIgnore public Integer getWorkServiceCountByCategoriesId(
public Integer getWorkServiceConutByCategoriesId(@ApiParam("分类id") @RequestBody List<Integer> categoriesId) { @ApiParam("分类id") @RequestBody List<Integer> categoriesId) {
return backstageTaskService.getWorkServiceConutByCategoriesId(categoriesId); return backstageTaskService.getWorkServiceCountByCategoriesId(categoriesId);
} }
} }
package com.mmc.pms.dao; package com.mmc.pms.dao;
import com.mmc.pms.common.ResultBody;
import com.mmc.pms.entity.ServiceDO; import com.mmc.pms.entity.ServiceDO;
import com.mmc.pms.model.qo.ServiceQO; import com.mmc.pms.model.qo.ServiceQO;
import com.mmc.pms.model.work.dto.ServiceDTO; import com.mmc.pms.model.work.dto.ServiceDTO;
...@@ -29,13 +28,19 @@ public interface BackstageTaskServiceDao { ...@@ -29,13 +28,19 @@ public interface BackstageTaskServiceDao {
Integer count(ServiceQO param); Integer count(ServiceQO param);
int conditionCount(@Param("param") ServiceQO param, @Param("categoriesIds") List<Integer> categoriesIds, @Param("userIds") List<Integer> userIds); int conditionCount(
@Param("param") ServiceQO param,
@Param("categoriesIds") List<Integer> categoriesIds,
@Param("userIds") List<Integer> userIds);
List<ServiceDO> queryPageByLimit(@Param("param") ServiceQO param,@Param("categoriesIds") List<Integer> categoriesIds, @Param("userIds") List<Integer> userIds); List<ServiceDO> queryPageByLimit(
@Param("param") ServiceQO param,
@Param("categoriesIds") List<Integer> categoriesIds,
@Param("userIds") List<Integer> userIds);
List<ServiceDTO> QueryWorkServiceListById(@Param("ids") List<Integer> ids); List<ServiceDTO> QueryWorkServiceListById(@Param("ids") List<Integer> ids);
Integer batchUpAndDownWorkService(@Param("param") UpAndDownServiceVO param); Integer batchUpAndDownWorkService(@Param("param") UpAndDownServiceVO param);
Integer getWorkServiceConutByCategoriesId(@Param("categoriesIds") List<Integer> categoriesIds); Integer getWorkServiceCountByCategoriesId(@Param("categoriesIds") List<Integer> categoriesIds);
} }
package com.mmc.pms.feign;
import com.mmc.pms.feign.hystrix.ImsApiHystrix;
import com.mmc.pms.model.categories.vo.CurriculumInfoVO;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import java.util.List;
/**
* @Author LW
*
* @date 2023/6/15 10:46 概要:
*/
@FeignClient(url = "${iuav.ims.url}", name = "ims", fallback = ImsApiHystrix.class)
public interface ImsAppApi {
@GetMapping("/release/curriculum/feignCurriculumInfoList")
List<CurriculumInfoVO> feignCurriculumInfoList(@RequestParam Integer categoriesId);
}
package com.mmc.pms.feign.config; package com.mmc.pms.feign.config;
import com.mmc.pms.feign.hystrix.ImsApiHystrix;
import com.mmc.pms.feign.hystrix.UserAppApiHystrix; import com.mmc.pms.feign.hystrix.UserAppApiHystrix;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
/** /**
* @author: zj * @author: zj @Date: 2023/5/18 18:21
* @Date: 2023/5/18 18:21
*/ */
@ComponentScan(basePackages = "com.mmc.pms.feign") @ComponentScan(basePackages = "com.mmc.pms.feign")
@Configuration @Configuration
public class FeignConfiguration { public class FeignConfiguration {
@Bean(name = "userAppApiHystrix") @Bean(name = "userAppApiHystrix")
public UserAppApiHystrix userAppApi() { public UserAppApiHystrix userAppApi() {
return new UserAppApiHystrix(); return new UserAppApiHystrix();
} }
@Bean(name = "imsApiHystrix")
public ImsApiHystrix imsAppApi() {
return new ImsApiHystrix();
}
} }
package com.mmc.pms.feign.hystrix;
import com.mmc.pms.feign.ImsAppApi;
import com.mmc.pms.model.categories.vo.CurriculumInfoVO;
import lombok.extern.slf4j.Slf4j;
import java.util.List;
/**
* @Author LW
*
* @date 2023/6/15 10:47 概要:
*/
@Slf4j
public class ImsApiHystrix implements ImsAppApi {
@Override
public List<CurriculumInfoVO> feignCurriculumInfoList(Integer categoriesId) {
log.error("熔断:feignCurriculumInfoList:{}", categoriesId);
return null;
}
}
package com.mmc.pms.model.categories.vo;
import com.mmc.pms.model.group.Insert;
import com.mmc.pms.model.group.Update;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.hibernate.validator.constraints.Length;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.math.BigDecimal;
/**
* @Author LW
*
* @date 2023/5/17 14:28 概要:课程信息
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class CurriculumInfoVO implements Serializable {
private static final long serialVersionUID = -7343885960160805850L;
@ApiModelProperty(value = "课程id")
@NotNull(
message = "课程id不能为空",
groups = {Update.class})
private Integer id;
@ApiModelProperty(value = "价格")
private BigDecimal price;
@ApiModelProperty(value = "供应商名称")
private String supplierName;
@ApiModelProperty(value = "课程名称,长度30")
@Length(max = 30)
private String curriculumName;
@ApiModelProperty(value = "课程是否免费 0:免费 1:付费")
private Integer free;
@ApiModelProperty(value = "课程类型,二级id")
@NotNull(
message = "课程类型id不能为空",
groups = {Insert.class})
private Integer categoriesId;
@ApiModelProperty(value = "目录名称", example = "技能")
private String directoryName;
@ApiModelProperty(value = "课程类型名称", example = "通用巡检")
private String categoriesName;
@ApiModelProperty(value = "课程技能类型,二级id")
private Integer flightSkills;
@ApiModelProperty(value = "课程介绍(简介), 长度255")
@Length(max = 255)
private String curriculumDesc;
@ApiModelProperty(value = "课程封面")
private String surfaceUrl;
@ApiModelProperty(value = "课程视频")
private String videoUrl;
@ApiModelProperty(value = "课程详情")
private String detailContent;
}
package com.mmc.pms.model.group;
/**
* @Author LW
*
* @date 2023/6/15 10:56 概要:
*/
public interface Insert {}
...@@ -32,5 +32,5 @@ public interface BackstageTaskService { ...@@ -32,5 +32,5 @@ public interface BackstageTaskService {
ResultBody batchUpAndDownWorkService(UpAndDownServiceVO param); ResultBody batchUpAndDownWorkService(UpAndDownServiceVO param);
Integer getWorkServiceConutByCategoriesId(List<Integer> ids); Integer getWorkServiceCountByCategoriesId(List<Integer> ids);
} }
...@@ -67,7 +67,7 @@ public class BackstageTaskServiceImpl implements BackstageTaskService { ...@@ -67,7 +67,7 @@ public class BackstageTaskServiceImpl implements BackstageTaskService {
@Override @Override
public ResultBody deleteByIds(List<Integer> ids) { public ResultBody deleteByIds(List<Integer> ids) {
if(!CollectionUtils.isEmpty(ids)){ if (!CollectionUtils.isEmpty(ids)) {
backstageTaskServiceDao.deleteByIds(ids); backstageTaskServiceDao.deleteByIds(ids);
} }
return ResultBody.success(); return ResultBody.success();
...@@ -139,7 +139,6 @@ public class BackstageTaskServiceImpl implements BackstageTaskService { ...@@ -139,7 +139,6 @@ public class BackstageTaskServiceImpl implements BackstageTaskService {
return pageList; return pageList;
} }
@Override @Override
public PageResult queryWorkServiceList(ServiceQO param, HttpServletRequest request) { public PageResult queryWorkServiceList(ServiceQO param, HttpServletRequest request) {
log.info( log.info(
...@@ -149,23 +148,24 @@ public class BackstageTaskServiceImpl implements BackstageTaskService { ...@@ -149,23 +148,24 @@ public class BackstageTaskServiceImpl implements BackstageTaskService {
param.buildCurrentPage(); param.buildCurrentPage();
List<Integer> userIds = null; List<Integer> userIds = null;
Integer provinceCode = param.getProvinceId(); Integer provinceCode = param.getProvinceId();
if(provinceCode!=null){ if (provinceCode != null) {
userIds = userAppApi.feignListUserAccountIds(provinceCode, null, null, null); userIds = userAppApi.feignListUserAccountIds(provinceCode, null, null, null);
if(userIds==null || userIds.size()==0){ if (userIds == null || userIds.size() == 0) {
userIds = Arrays.asList(-1); userIds = Arrays.asList(-1);
} }
} }
List<Integer> categoriesIds = param.getCategoryId(); List<Integer> categoriesIds = param.getCategoryId();
int count = backstageTaskServiceDao.conditionCount(param,categoriesIds,userIds); int count = backstageTaskServiceDao.conditionCount(param, categoriesIds, userIds);
if (count == 0) { if (count == 0) {
return PageResult.buildPage(param.getPageNo(), param.getPageSize(), count); return PageResult.buildPage(param.getPageNo(), param.getPageSize(), count);
} }
List<ServiceDO> pageList = backstageTaskServiceDao.queryPageByLimit(param,categoriesIds,userIds); List<ServiceDO> pageList =
backstageTaskServiceDao.queryPageByLimit(param, categoriesIds, userIds);
List<WorkServiceDTO> workServiceDTOList = getWorkServiceDTOS(pageList); List<WorkServiceDTO> workServiceDTOList = getWorkServiceDTOS(pageList);
log.info( log.info(
"结束queryWorkServiceList==>{}", "结束queryWorkServiceList==>{}",
JSONObject.toJSONString(DateFormatUtils.format(new Date(), DateConstant.YYYYMMDDHHMMSS))); JSONObject.toJSONString(DateFormatUtils.format(new Date(), DateConstant.YYYYMMDDHHMMSS)));
return PageResult.buildPage(pageNo, param.getPageSize(), count, workServiceDTOList); return PageResult.buildPage(pageNo, param.getPageSize(), count, workServiceDTOList);
} }
...@@ -176,41 +176,47 @@ public class BackstageTaskServiceImpl implements BackstageTaskService { ...@@ -176,41 +176,47 @@ public class BackstageTaskServiceImpl implements BackstageTaskService {
@Override @Override
public ResultBody batchUpAndDownWorkService(UpAndDownServiceVO param) { public ResultBody batchUpAndDownWorkService(UpAndDownServiceVO param) {
if(!CollectionUtils.isEmpty(param.getIds())){ if (!CollectionUtils.isEmpty(param.getIds())) {
backstageTaskServiceDao.batchUpAndDownWorkService(param); backstageTaskServiceDao.batchUpAndDownWorkService(param);
} }
return ResultBody.success(); return ResultBody.success();
} }
@Override @Override
public Integer getWorkServiceConutByCategoriesId(List<Integer> ids) { public Integer getWorkServiceCountByCategoriesId(List<Integer> ids) {
if(CollectionUtils.isEmpty(ids)){ if (CollectionUtils.isEmpty(ids)) {
return 0; return 0;
}
return backstageTaskServiceDao.getWorkServiceConutByCategoriesId(ids);
} }
return backstageTaskServiceDao.getWorkServiceCountByCategoriesId(ids);
}
private List<WorkServiceDTO> getWorkServiceDTOS(List<ServiceDO> pageList) { private List<WorkServiceDTO> getWorkServiceDTOS(List<ServiceDO> pageList) {
// 用户暂时无关联公司数据,先用假数据展示 // 用户暂时无关联公司数据,先用假数据展示
String companyName = "浙江科比特创新科技有限公司"; String companyName = "浙江科比特创新科技有限公司";
List<WorkServiceDTO> workServiceDTOList = new ArrayList<>(); List<WorkServiceDTO> workServiceDTOList = new ArrayList<>();
for (ServiceDO item : pageList) { for (ServiceDO item : pageList) {
WorkServiceDTO workServiceDTO = WorkServiceDTO.builder().id(item.getId()).serviceName(item.getServiceName()).companyName(companyName) WorkServiceDTO workServiceDTO =
.coverPlan(item.getCoverPlan()).serviceIntroduction(item.getServiceIntroduction()).video(item.getVideo()).shareCard(item.getShareCard()).build(); WorkServiceDTO.builder()
.id(item.getId())
.serviceName(item.getServiceName())
.companyName(companyName)
.coverPlan(item.getCoverPlan())
.serviceIntroduction(item.getServiceIntroduction())
.video(item.getVideo())
.shareCard(item.getShareCard())
.build();
workServiceDTOList.add(workServiceDTO); workServiceDTOList.add(workServiceDTO);
} }
return workServiceDTOList; return workServiceDTOList;
} }
/** /** 根据id随机获取50条以上的评论 */
* 根据id随机获取50条以上的评论
*/
private List<InspComtDO> RandomGetInspComt(Integer id) { private List<InspComtDO> RandomGetInspComt(Integer id) {
String listStr = (String) redisTemplate.opsForValue().get(id); String listStr = (String) redisTemplate.opsForValue().get(id);
List<InspComtDO> inspComtRandomList = null; List<InspComtDO> inspComtRandomList = null;
if(StringUtils.isNotBlank(listStr)){ if (StringUtils.isNotBlank(listStr)) {
inspComtRandomList = JSONArray.parseArray(listStr, InspComtDO.class); inspComtRandomList = JSONArray.parseArray(listStr, InspComtDO.class);
}else { } else {
inspComtRandomList = inspComtService.randomGetInspComtList(RandomUtils.nextInt(50, 9999)); inspComtRandomList = inspComtService.randomGetInspComtList(RandomUtils.nextInt(50, 9999));
String toJSONString = JSONObject.toJSONString(inspComtRandomList); String toJSONString = JSONObject.toJSONString(inspComtRandomList);
redisTemplate.opsForValue().set(id, toJSONString, 2L, TimeUnit.DAYS); redisTemplate.opsForValue().set(id, toJSONString, 2L, TimeUnit.DAYS);
......
...@@ -9,15 +9,18 @@ import com.mmc.pms.dao.GoodsInfoDao; ...@@ -9,15 +9,18 @@ import com.mmc.pms.dao.GoodsInfoDao;
import com.mmc.pms.entity.Categories; import com.mmc.pms.entity.Categories;
import com.mmc.pms.entity.DirectoryDO; import com.mmc.pms.entity.DirectoryDO;
import com.mmc.pms.entity.GoodsInfo; import com.mmc.pms.entity.GoodsInfo;
import com.mmc.pms.feign.ImsAppApi;
import com.mmc.pms.model.categories.dto.AllCategoryDTO; import com.mmc.pms.model.categories.dto.AllCategoryDTO;
import com.mmc.pms.model.categories.dto.CategoriesDTO; import com.mmc.pms.model.categories.dto.CategoriesDTO;
import com.mmc.pms.model.categories.dto.CategoriesInfoListDTO; import com.mmc.pms.model.categories.dto.CategoriesInfoListDTO;
import com.mmc.pms.model.categories.dto.ClassifyInfoDTO; import com.mmc.pms.model.categories.dto.ClassifyInfoDTO;
import com.mmc.pms.model.categories.vo.ClassifyInfoVO; import com.mmc.pms.model.categories.vo.ClassifyInfoVO;
import com.mmc.pms.model.categories.vo.CurriculumInfoVO;
import com.mmc.pms.model.categories.vo.DirectoryInfoVO; import com.mmc.pms.model.categories.vo.DirectoryInfoVO;
import com.mmc.pms.model.categories.vo.RelevantBusinessVO; import com.mmc.pms.model.categories.vo.RelevantBusinessVO;
import com.mmc.pms.model.sale.vo.QueryClassifyVO; import com.mmc.pms.model.sale.vo.QueryClassifyVO;
import com.mmc.pms.page.PageResult; import com.mmc.pms.page.PageResult;
import com.mmc.pms.service.BackstageTaskService;
import com.mmc.pms.service.CategoriesService; import com.mmc.pms.service.CategoriesService;
import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -39,6 +42,8 @@ public class CategoriesServiceImpl implements CategoriesService { ...@@ -39,6 +42,8 @@ public class CategoriesServiceImpl implements CategoriesService {
@Autowired private CategoriesDao categoriesDao; @Autowired private CategoriesDao categoriesDao;
@Resource private GoodsInfoDao goodsInfoDao; @Resource private GoodsInfoDao goodsInfoDao;
@Autowired private DirectoryDao directoryDao; @Autowired private DirectoryDao directoryDao;
@Autowired private BackstageTaskService backstageTaskService;
@Autowired private ImsAppApi appApi;
@Override @Override
public ResultBody addOrEditDirectory(DirectoryInfoVO param) { public ResultBody addOrEditDirectory(DirectoryInfoVO param) {
...@@ -259,6 +264,15 @@ public class CategoriesServiceImpl implements CategoriesService { ...@@ -259,6 +264,15 @@ public class CategoriesServiceImpl implements CategoriesService {
if (count > 0) { if (count > 0) {
return ResultBody.error(ResultEnum.GROUP_DONT_DELETE); return ResultBody.error(ResultEnum.GROUP_DONT_DELETE);
} }
Integer taskCount =
backstageTaskService.getWorkServiceCountByCategoriesId(Collections.singletonList(id));
if (taskCount > 0) {
return ResultBody.error(ResultEnum.GROUP_DONT_DELETE);
}
List<CurriculumInfoVO> curriculumInfo = appApi.feignCurriculumInfoList(id);
if (CollectionUtils.isNotEmpty(curriculumInfo)) {
return ResultBody.error(ResultEnum.GROUP_DONT_DELETE);
}
// 获取分类信息 // 获取分类信息
Categories categories = categoriesDao.getGoodsGroupById(id); Categories categories = categoriesDao.getGoodsGroupById(id);
if (categories != null && categories.getParentId().equals(0)) { if (categories != null && categories.getParentId().equals(0)) {
......
...@@ -40,5 +40,8 @@ mount: ...@@ -40,5 +40,8 @@ mount:
iuav: iuav:
userapp: userapp:
url: https://test.iuav.shop url: https://test.iuav.shop
ims:
url: https://test.iuav.shop
...@@ -61,5 +61,7 @@ mount: ...@@ -61,5 +61,7 @@ mount:
iuav: iuav:
userapp: userapp:
url: http://127.0.0.1:35150 url: http://127.0.0.1:35150
ims:
url: http://127.0.0.1:10001
...@@ -40,3 +40,6 @@ mount: ...@@ -40,3 +40,6 @@ mount:
iuav: iuav:
userapp: userapp:
url: https://www.iuav.shop url: https://www.iuav.shop
ims:
url: https://www.iuav.shop
...@@ -267,7 +267,7 @@ ...@@ -267,7 +267,7 @@
</foreach> </foreach>
</select> </select>
<select id="getWorkServiceConutByCategoriesId" resultType="java.lang.Integer"> <select id="getWorkServiceCountByCategoriesId" resultType="java.lang.Integer">
select count(*) from service select count(*) from service
<where> <where>
is_deleted = 0 is_deleted = 0
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论