提交 86b2033c 作者: zhenjie

课程相关接口修改

上级 a29ed3bc
package com.mmc.csf.release.flyer.dto;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
import java.util.List;
/**
* @author: zj
* @Date: 2023/6/10 20:34
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class AllCategoryDTO implements Serializable {
private static final long serialVersionUID = 1171841063641249397L;
private Integer directoryId;
private String name;
private List<CategoriesInfoListDTO> categoriesInfoListDTO;
}
/** Copyright 2023 bejson.com */
package com.mmc.csf.release.flyer.dto;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
/**
* Auto-generated: 2023-06-08 16:2:43
*
* @author bejson.com (i@bejson.com)
* @website http://www.bejson.com/java2pojo/
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class CategoriesInfoListDTO implements Serializable {
private static final long serialVersionUID = -8381856228953745772L;
private Integer id;
private Integer directoryId;
private String name;
private String icon;
}
......@@ -23,12 +23,14 @@ public class CurriculumQo implements Serializable {
private static final long serialVersionUID = 3124398495152234751L;
@ApiModelProperty(value = "课程名称")
private String curriculumName;
@ApiModelProperty(value = "地域id")
private Integer regionId;
@ApiModelProperty(value = "省份编码")
private Integer provinceCode;
@ApiModelProperty(value = "执照id")
private Integer licenseId;
@ApiModelProperty(value = "技能id")
private Integer flightSkillsId;
@ApiModelProperty(value = "课程类型id")
private Integer categoriesId;
@ApiModelProperty(value = "页码", required = true)
@NotNull(message = "页码不能为空", groups = { Page.class })
@Min(value = 1, groups = Page.class)
......
......@@ -41,15 +41,18 @@ public class CurriculumInfoVO implements Serializable {
@ApiModelProperty(value = "课程是否免费 0:免费 1:付费")
private Integer free;
@ApiModelProperty(value = "课程技能类型,二级id")
@NotNull(message = "课程技能id不能为空" ,groups = {Insert.class})
private Integer flightSkills;
@ApiModelProperty(value = "课程类型,二级id")
@NotNull(message = "课程类型id不能为空" ,groups = {Insert.class})
private Integer categoriesId;
@ApiModelProperty(value = "目录名称", example = "技能")
private String directoryName;
@ApiModelProperty(value = "课程技能类型名称1", example = "技能")
private String flightSkillsName1;
@ApiModelProperty(value = "课程类型名称", example = "通用巡检")
private String categoriesName;
@ApiModelProperty(value = "课程技能类型名称2", example = "通用巡检")
private String flightSkillsName2;
@ApiModelProperty(value = "课程技能类型,二级id")
private Integer flightSkills;
@ApiModelProperty(value = "课程介绍(简介), 长度255")
@Length(max = 255)
......
package com.mmc.csf.release.controller;
import com.mmc.csf.common.util.web.ResultBody;
import com.mmc.csf.release.feign.PmsAppApi;
import com.mmc.csf.release.flyer.qo.CurriculumQo;
import com.mmc.csf.release.flyer.vo.CurriculumInfoVO;
import com.mmc.csf.release.model.group.Insert;
......@@ -10,6 +11,7 @@ import com.mmc.csf.release.flyer.vo.DronePilotLicenseVO;
import com.mmc.csf.release.flyer.vo.FlightSkillsVO;
import com.mmc.csf.release.flyer.vo.RegistrationVO;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
......@@ -59,7 +61,7 @@ public class FlyerTrainingController extends BaseController{
return flyerTrainingService.licenseOrSkillQueryCurriculum(type);
}
@ApiOperation(value = "V1.0.1课程技能列表")
@ApiOperation(value = "飞手技能列表")
@ApiResponses({@ApiResponse(code = 200, message = "OK", response = FlightSkillsVO.class)})
@GetMapping("treeCurriculumSkill")
public ResultBody treeCurriculumSkill() {
......@@ -100,4 +102,14 @@ public class FlyerTrainingController extends BaseController{
public ResultBody removeCurriculum(@RequestParam Integer id) {
return ResultBody.success(flyerTrainingService.removeCurriculum(id));
}
@Autowired
private PmsAppApi pmsAppApi;
@ApiOperation(value = "V1.0.1test")
@ApiResponses({@ApiResponse(code = 200, message = "OK", response = ResultBody.class)})
@GetMapping("test")
public ResultBody test() {
return ResultBody.success(pmsAppApi.feignQqueryCategoryInfoByType(3));
}
}
......@@ -69,6 +69,11 @@ public class CurriculumInfoDO implements Serializable {
private String detailContent;
/**
* 课程类型id
*/
private Integer categoriesId;
public CurriculumInfoDO(CurriculumInfoVO curriculumInfoVO) {
this.id = curriculumInfoVO.getId();
this.curriculumName = curriculumInfoVO.getCurriculumName();
......@@ -77,12 +82,14 @@ public class CurriculumInfoDO implements Serializable {
this.surfaceUrl = curriculumInfoVO.getSurfaceUrl();
this.detailContent = curriculumInfoVO.getDetailContent();
this.videoUrl = curriculumInfoVO.getVideoUrl();
this.categoriesId = curriculumInfoVO.getCategoriesId();
}
public CurriculumInfoVO buildCurriculumInfoVO(){
return CurriculumInfoVO.builder().id(id).curriculumDesc(curriculumDesc).price(curriculumPrice)
.free(free).supplierName("浙江科比特创新科技有限公司").curriculumName(curriculumName)
.videoUrl(videoUrl).surfaceUrl(this.surfaceUrl).flightSkills(this.flightSkills).detailContent(this.detailContent).build();
.videoUrl(videoUrl).surfaceUrl(this.surfaceUrl).flightSkills(this.flightSkills).detailContent(this.detailContent)
.categoriesId(this.categoriesId).build();
}
}
......
package com.mmc.csf.release.feign;
import com.mmc.csf.release.feign.hystrix.PmsAppApHystrix;
import com.mmc.csf.release.flyer.dto.AllCategoryDTO;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import java.util.List;
/**
* @author: zj
* @Date: 2023/6/10 20:23
*/
@FeignClient(url = "${iuav.pmsapp.url}", name = "pms-svc", fallback = PmsAppApHystrix.class)
public interface PmsAppApi {
@RequestMapping(value = "/pms/classify/feignQqueryCategoryInfoByType", method = RequestMethod.GET)
public List<AllCategoryDTO> feignQqueryCategoryInfoByType(@RequestParam Integer type);
}
package com.mmc.csf.release.feign.config;
import com.mmc.csf.release.feign.hystrix.PmsAppApHystrix;
import com.mmc.csf.release.feign.hystrix.UserAppApiHystrix;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
......@@ -18,4 +19,9 @@ public class FeignConfiguration {
public UserAppApiHystrix userAppApi(){
return new UserAppApiHystrix();
}
@Bean(name = "PmsAppApHystrix")
public PmsAppApHystrix pmsAppApi(){
return new PmsAppApHystrix();
}
}
package com.mmc.csf.release.feign.hystrix;
import com.mmc.csf.release.feign.PmsAppApi;
import com.mmc.csf.release.flyer.dto.AllCategoryDTO;
import lombok.extern.slf4j.Slf4j;
import java.util.List;
/**
* @author: zj
* @Date: 2023/6/10 20:24
*/
@Slf4j
public class PmsAppApHystrix implements PmsAppApi {
@Override
public List<AllCategoryDTO> feignQqueryCategoryInfoByType(Integer type) {
log.info("熔断--feignQqueryCategoryInfoByType:" + type);
return null;
}
}
......@@ -6,6 +6,9 @@ import com.mmc.csf.release.dao.FlyerTrainingDao;
import com.mmc.csf.release.entity.CurriculumInfoDO;
import com.mmc.csf.release.entity.FlightSkillsDO;
import com.mmc.csf.release.entity.PilotRegistrationDO;
import com.mmc.csf.release.feign.PmsAppApi;
import com.mmc.csf.release.flyer.dto.AllCategoryDTO;
import com.mmc.csf.release.flyer.dto.CategoriesInfoListDTO;
import com.mmc.csf.release.flyer.qo.CurriculumQo;
import com.mmc.csf.release.flyer.vo.CurriculumInfoVO;
import com.mmc.csf.release.flyer.vo.DronePilotLicenseVO;
......@@ -14,6 +17,7 @@ import com.mmc.csf.release.flyer.vo.RegistrationVO;
import com.mmc.csf.release.service.FlyerTrainingService;
import io.swagger.models.auth.In;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
......@@ -34,6 +38,9 @@ public class FlyerTrainingServiceImpl implements FlyerTrainingService {
@Resource
private FlyerTrainingDao flyerTrainingDao;
@Autowired
private PmsAppApi pmsAppApi;
@Override
public ResultBody pilotRegistration(RegistrationVO registrationVO,Integer userAccountId) {
PilotRegistrationDO pilotRegistrationDO = new PilotRegistrationDO(registrationVO);
......@@ -81,7 +88,7 @@ public class FlyerTrainingServiceImpl implements FlyerTrainingService {
@Override
public PageResult queryCurriculumInfoList(CurriculumQo curriculumQo) {
Integer SZ = 440300;
if (curriculumQo.getRegionId() != null && !curriculumQo.getRegionId().equals(SZ)) {
if (curriculumQo.getProvinceCode() != null && !curriculumQo.getProvinceCode().equals(SZ)) {
return PageResult.buildPage(curriculumQo.getPageNo(), curriculumQo.getPageSize(), 0);
}
int count = flyerTrainingDao.countCurriculumInfoList(curriculumQo);
......@@ -91,16 +98,22 @@ public class FlyerTrainingServiceImpl implements FlyerTrainingService {
Integer pageNo = curriculumQo.getPageNo();
curriculumQo.buildCurrentPage();
List<CurriculumInfoDO> curriculumList = flyerTrainingDao.listPageCurriculumInfo(curriculumQo);
Map<Integer, FlightSkillsDO> flightSkillsMap = flyerTrainingDao.listIndustryFlightSkills().stream().collect(Collectors.toMap(FlightSkillsDO::getId, d -> d));
List<AllCategoryDTO> allCategoryDTOS = pmsAppApi.feignQqueryCategoryInfoByType(3);
List<CurriculumInfoVO> list = curriculumList.stream().map(CurriculumInfoDO::buildCurriculumInfoVO).collect(Collectors.toList());
list.stream().map(d -> {
if (flightSkillsMap.get(d.getFlightSkills()) != null){
FlightSkillsDO flightSkillsDO = flightSkillsMap.get(d.getFlightSkills());
d.setFlightSkillsName1(flightSkillsMap.get(flightSkillsDO.getPid()).getSkillsName());
d.setFlightSkillsName2(flightSkillsDO.getSkillsName());
}
return d;
}).collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(allCategoryDTOS)){
list.stream().forEach(curriculumInfoVO -> {
allCategoryDTOS.stream().forEach(directory -> {
if (CollectionUtils.isNotEmpty(directory.getCategoriesInfoListDTO())){
directory.getCategoriesInfoListDTO().stream().forEach(category -> {
if (curriculumInfoVO.getCategoriesId().equals(category.getId())){
curriculumInfoVO.setDirectoryName(directory.getName());
curriculumInfoVO.setCategoriesName(category.getName());
}
});
}
});
});
}
return PageResult.buildPage(pageNo, curriculumQo.getPageSize(), count, list);
}
......@@ -124,12 +137,18 @@ public class FlyerTrainingServiceImpl implements FlyerTrainingService {
if (curriculumInfoDO == null) {
return ResultBody.error("课程不存在或已下架!");
}else {
Map<Integer, FlightSkillsDO> flightSkillsMap = flyerTrainingDao.listIndustryFlightSkills().stream().collect(Collectors.toMap(FlightSkillsDO::getId, d -> d));
CurriculumInfoVO curriculumInfoVO = curriculumInfoDO.buildCurriculumInfoVO();
if (flightSkillsMap.get(curriculumInfoVO.getFlightSkills()) != null) {
FlightSkillsDO flightSkillsDO = flightSkillsMap.get(curriculumInfoVO.getFlightSkills());
curriculumInfoVO.setFlightSkillsName1(flightSkillsMap.get(flightSkillsDO.getPid()).getSkillsName());
curriculumInfoVO.setFlightSkillsName2(flightSkillsDO.getSkillsName());
List<AllCategoryDTO> allCategoryDTOS = pmsAppApi.feignQqueryCategoryInfoByType(3);
for (AllCategoryDTO directory : allCategoryDTOS) {
if (CollectionUtils.isNotEmpty(directory.getCategoriesInfoListDTO())){
for (CategoriesInfoListDTO category : directory.getCategoriesInfoListDTO()) {
if (curriculumInfoVO.getCategoriesId().equals(category.getId())){
curriculumInfoVO.setDirectoryName(directory.getName());
curriculumInfoVO.setCategoriesName(category.getName());
break;
}
}
}
}
return ResultBody.success(curriculumInfoVO);
}
......
......@@ -144,6 +144,8 @@ ribbon:
iuav:
userapp:
url: http://cms-svc:35150
pmsapp:
url: http://pms-svc:8099
#mmc:
# appid: 80001
......
......@@ -118,6 +118,8 @@ mybatis:
iuav:
userapp:
url: http://cms-svc:35150
pmsapp:
url: http://127.0.0.1:8099
##feign
#feign:
......
......@@ -144,6 +144,8 @@ ribbon:
iuav:
userapp:
url: http://cms-svc:35150
pmsapp:
url: http://pms-svc:8099
#mmc:
# appid: 80001
......
......@@ -25,8 +25,8 @@
</insert>
<insert id="addCurriculum" keyProperty="id" useGeneratedKeys="true" parameterType="com.mmc.csf.release.entity.CurriculumInfoDO">
INSERT INTO `curriculum_info`(`curriculum_name`, `supplier_id`, `curriculum_desc`, `drone_pilot_license_id`, `flight_skills`, `surface_url`, `video_url`, `detail_content`)
VALUES (#{curriculumName},#{supplierId},#{curriculumDesc},#{dronePilotLicenseId},#{flightSkills},#{surfaceUrl},#{videoUrl},#{detailContent});
INSERT INTO `curriculum_info`(`curriculum_name`, `supplier_id`, `curriculum_desc`, `drone_pilot_license_id`, `flight_skills`, `categories_id`, `surface_url`, `video_url`, `detail_content`)
VALUES (#{curriculumName},#{supplierId},#{curriculumDesc},#{dronePilotLicenseId},#{flightSkills},#{categoriesId},#{surfaceUrl},#{videoUrl},#{detailContent});
</insert>
<update id="updateCurriculum" parameterType="com.mmc.csf.release.entity.CurriculumInfoDO">
......@@ -44,6 +44,9 @@
<if test="flightSkills != null">
flight_skills = #{flightSkills},
</if>
<if test="categoriesId != null">
categories_id = #{categoriesId},
</if>
<if test="surfaceUrl != null">
surface_url = #{surfaceUrl},
</if>
......@@ -107,6 +110,7 @@
ci.flight_skills,
ci.detail_content,
ci.video_url,
ci.categories_id,
ci.surface_url
from curriculum_info ci
<where>
......@@ -120,6 +124,9 @@
<if test="flightSkillsId != null">
and flight_skills = #{flightSkillsId}
</if>
<if test="categoriesId != null">
and categories_id = #{categoriesId}
</if>
</where>
order by ci.create_time desc
LIMIT #{pageNo},#{pageSize}
......@@ -163,6 +170,7 @@
ci.flight_skills,
ci.detail_content,
ci.video_url,
ci.categories_id,
ci.surface_url
from curriculum_info ci
where ci.id = #{id}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论