bug
This commit is contained in:
@@ -8,6 +8,7 @@ import lombok.Data;
|
|||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
@TableName("course_catalogue")
|
@TableName("course_catalogue")
|
||||||
@@ -48,4 +49,10 @@ public class CourseCatalogueEntity{
|
|||||||
*/
|
*/
|
||||||
@TableField(exist = false)
|
@TableField(exist = false)
|
||||||
private int completion;
|
private int completion;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 存在的商品列表
|
||||||
|
*/
|
||||||
|
@TableField(exist = false)
|
||||||
|
private List<ShopProduct> productList;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -69,6 +69,12 @@ public class CourseController {
|
|||||||
return R.ok().put("catalogues",courseCatalogues);
|
return R.ok().put("catalogues",courseCatalogues);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@RequestMapping("/createProductForCatalogue")
|
||||||
|
public R createProductForCatalogue(@RequestBody Map<String,Integer> map){
|
||||||
|
int id = map.get("id");
|
||||||
|
return courseCatalogueService.createProductForCatalogue(id);
|
||||||
|
}
|
||||||
|
|
||||||
@RequestMapping("/addCourseCatalogue")
|
@RequestMapping("/addCourseCatalogue")
|
||||||
public R addCourseCatalogue(@RequestBody CourseCatalogueEntity courseCatalogue){
|
public R addCourseCatalogue(@RequestBody CourseCatalogueEntity courseCatalogue){
|
||||||
courseCatalogueService.addCourseCatalogue(courseCatalogue);
|
courseCatalogueService.addCourseCatalogue(courseCatalogue);
|
||||||
|
|||||||
@@ -13,4 +13,6 @@ public interface CourseCatalogueService extends IService<CourseCatalogueEntity>
|
|||||||
R delCourseCatalogue(int id);
|
R delCourseCatalogue(int id);
|
||||||
|
|
||||||
void addCourseCatalogue(CourseCatalogueEntity courseCatalogue);
|
void addCourseCatalogue(CourseCatalogueEntity courseCatalogue);
|
||||||
|
|
||||||
|
R createProductForCatalogue(int id);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import lombok.extern.slf4j.Slf4j;
|
|||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -70,6 +71,19 @@ public class CourseCatalogueServiceImpl extends ServiceImpl<CourseCatalogueDao,
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public R createProductForCatalogue(int id) {
|
||||||
|
//check
|
||||||
|
CourseCatalogueEntity byId = this.getById(id);
|
||||||
|
if(byId.getType()!=1){
|
||||||
|
return R.error("普通类型的课程才可以生成商品");
|
||||||
|
}
|
||||||
|
if(byId.getFee().compareTo(BigDecimal.ZERO)==0||byId.getHalfFee().compareTo(BigDecimal.ZERO)==0){
|
||||||
|
return R.error("价格异常");
|
||||||
|
}
|
||||||
|
createProduct(byId);
|
||||||
|
return R.ok();
|
||||||
|
}
|
||||||
|
|
||||||
private void createProduct(CourseCatalogueEntity courseCatalogue){
|
private void createProduct(CourseCatalogueEntity courseCatalogue){
|
||||||
CourseEntity courseEntity = courseDao.selectById(courseCatalogue.getCourseId());
|
CourseEntity courseEntity = courseDao.selectById(courseCatalogue.getCourseId());
|
||||||
|
|||||||
@@ -74,6 +74,14 @@ public class CourseServiceImpl extends ServiceImpl<CourseDao, CourseEntity> impl
|
|||||||
courseEntityPage = this.getBaseMapper().selectPage(new Page<>(page, limit), wrapper);
|
courseEntityPage = this.getBaseMapper().selectPage(new Page<>(page, limit), wrapper);
|
||||||
for (CourseEntity c:courseEntityPage.getRecords()){
|
for (CourseEntity c:courseEntityPage.getRecords()){
|
||||||
List<CourseCatalogueEntity> courseCatalogueEntities = courseCatalogueDao.selectList(new LambdaQueryWrapper<CourseCatalogueEntity>().eq(CourseCatalogueEntity::getCourseId, c.getId()).orderByAsc(CourseCatalogueEntity::getSort));
|
List<CourseCatalogueEntity> courseCatalogueEntities = courseCatalogueDao.selectList(new LambdaQueryWrapper<CourseCatalogueEntity>().eq(CourseCatalogueEntity::getCourseId, c.getId()).orderByAsc(CourseCatalogueEntity::getSort));
|
||||||
|
for (CourseCatalogueEntity co : courseCatalogueEntities){
|
||||||
|
MPJLambdaWrapper<ShopProductCourseEntity> shopProductCourseEntityMPJLambdaWrapper = new MPJLambdaWrapper<>();
|
||||||
|
shopProductCourseEntityMPJLambdaWrapper.selectAll(ShopProduct.class);
|
||||||
|
shopProductCourseEntityMPJLambdaWrapper.leftJoin(ShopProduct.class,ShopProduct::getProductId,ShopProductCourseEntity::getProductId);
|
||||||
|
shopProductCourseEntityMPJLambdaWrapper.eq(ShopProductCourseEntity::getCatalogueId,co.getId());
|
||||||
|
List<ShopProduct> shopProducts = shopProductCourseDao.selectJoinList(ShopProduct.class, shopProductCourseEntityMPJLambdaWrapper);
|
||||||
|
co.setProductList(shopProducts);
|
||||||
|
}
|
||||||
c.setCourseCatalogueEntityList(courseCatalogueEntities);
|
c.setCourseCatalogueEntityList(courseCatalogueEntities);
|
||||||
}
|
}
|
||||||
return courseEntityPage;
|
return courseEntityPage;
|
||||||
|
|||||||
Reference in New Issue
Block a user