修复一下bug

This commit is contained in:
wangjinlei
2024-04-22 14:33:39 +08:00
parent 3ae068513c
commit d6123a8132
8 changed files with 96 additions and 13 deletions

View File

@@ -129,4 +129,10 @@ public class CourseController {
return R.ok();
}
@RequestMapping("/testCourse")
public R testCourse(){
courseService.testCourse();
return R.ok();
}
}

View File

@@ -18,4 +18,6 @@ public interface CourseService extends IService<CourseEntity> {
List<CourseEntity> getCourseListForSociology(int sociologyId);
Page getCourseListCanSociology(ParamTo param);
void testCourse();
}

View File

@@ -33,6 +33,10 @@ public class CourseServiceImpl extends ServiceImpl<CourseDao, CourseEntity> impl
private CourseToSociologyDao courseToSociologyDao;
@Autowired
private CourseCatalogueDao courseCatalogueDao;
@Autowired
private ShopProductDao shopProductDao;
@Autowired
private ShopProductCourseDao shopProductCourseDao;
@Override
public Page getCourseList(Map<String,Object> map) {
@@ -117,6 +121,43 @@ public class CourseServiceImpl extends ServiceImpl<CourseDao, CourseEntity> impl
return page;
}
@Override
public void testCourse() {
List<CourseCatalogueEntity> courseCatalogueEntities = courseCatalogueDao.selectList(new LambdaQueryWrapper<CourseCatalogueEntity>());
for (CourseCatalogueEntity c: courseCatalogueEntities){
if(shopProductCourseDao.selectCount(new LambdaQueryWrapper<ShopProductCourseEntity>().eq(ShopProductCourseEntity::getCatalogueId,c.getId()))>0){
continue;
}
ShopProduct shopProduct = new ShopProduct();
shopProduct.setProductName(c.getTitle()+"."+c.getTitle()+"(半年)");
shopProduct.setPrice(c.getHalfFee());
shopProduct.setGoodsType("05");
shopProductDao.insert(shopProduct);
//添加半年期的商品课程对应关系
ShopProductCourseEntity shopProductCourseEntity = new ShopProductCourseEntity();
shopProductCourseEntity.setProductId(shopProduct.getProductId());
shopProductCourseEntity.setCourseId(c.getCourseId());
shopProductCourseEntity.setCatalogueId(c.getId());
shopProductCourseEntity.setDays(180);
shopProductCourseDao.insert(shopProductCourseEntity);
//添加一年期商品
ShopProduct shopProduct1 = new ShopProduct();
shopProduct1.setProductName(c.getTitle()+"."+c.getTitle()+"(一年)");
shopProduct1.setPrice(c.getFee());
shopProduct1.setGoodsType("05");
shopProductDao.insert(shopProduct1);
//添加一年期的商品课程对应关系
ShopProductCourseEntity shopProductCourseEntity1 = new ShopProductCourseEntity();
shopProductCourseEntity1.setProductId(shopProduct1.getProductId());
shopProductCourseEntity1.setCourseId(c.getCourseId());
shopProductCourseEntity1.setCatalogueId(c.getId());
shopProductCourseEntity1.setDays(365);
shopProductCourseDao.insert(shopProductCourseEntity1);
}
}
private List<Integer> categoryIds(Integer id){
ArrayList<Integer> integers = new ArrayList<>();
CourseCategoryEntity courseCategoryEntity = courseCategoryDao.selectById(id);