心灵空间
This commit is contained in:
@@ -131,6 +131,34 @@ public class ShopProductController {
|
|||||||
return R.ok();
|
return R.ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@RequestMapping("/bindProductAndPsycheLabel")
|
||||||
|
public R bindProductAndPsycheLabel(@RequestBody Map<String,String> map){
|
||||||
|
String[] productIds = map.get("productId").split(",");
|
||||||
|
Integer labelId = Integer.valueOf(map.get("labelId"));
|
||||||
|
shopProductService.bindProductAndPsycheLabel(productIds,labelId);
|
||||||
|
return R.ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequestMapping("/unbindProductAndPsycheLabel")
|
||||||
|
public R unbindProductAndPsycheLabel(@RequestBody Map<String,Integer> map){
|
||||||
|
shopProductService.unbindProductAndPsycheLabel(map.get("productId"),map.get("labelId"));
|
||||||
|
return R.ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequestMapping("/bindProductAndPsycheMarket")
|
||||||
|
public R bindProductAndPsycheMarket(@RequestBody Map<String,String> map){
|
||||||
|
String[] productIds = map.get("productId").split(",");
|
||||||
|
Integer marketId = Integer.valueOf(map.get("marketId"));
|
||||||
|
shopProductService.bindProductAndPsycheMarket(productIds,marketId);
|
||||||
|
return R.ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequestMapping("/unbindProductAndPsycheMarket")
|
||||||
|
public R unbindProductAndPsycheMarket(@RequestBody Map<String,Integer> map){
|
||||||
|
shopProductService.unbindProductAndPsycheMarket(map.get("productId"),map.get("marketId"));
|
||||||
|
return R.ok();
|
||||||
|
}
|
||||||
|
|
||||||
@RequestMapping("/bindProductAndMedicineLabel")
|
@RequestMapping("/bindProductAndMedicineLabel")
|
||||||
public R bindProductAndMedicineLabel(@RequestBody Map<String,String> map){
|
public R bindProductAndMedicineLabel(@RequestBody Map<String,String> map){
|
||||||
String[] productIds = map.get("productId").split(",");
|
String[] productIds = map.get("productId").split(",");
|
||||||
|
|||||||
@@ -33,6 +33,14 @@ public interface ShopProductService extends IService<ShopProduct> {
|
|||||||
|
|
||||||
void unbindProductAndSociologyMarket(int product,int marketId);
|
void unbindProductAndSociologyMarket(int product,int marketId);
|
||||||
|
|
||||||
|
void bindProductAndPsycheLabel(String[] productIds,Integer labelId);
|
||||||
|
|
||||||
|
void unbindProductAndPsycheLabel(int productId,int labelId);
|
||||||
|
|
||||||
|
void bindProductAndPsycheMarket(String[] productId,int marketId);
|
||||||
|
|
||||||
|
void unbindProductAndPsycheMarket(int product,int marketId);
|
||||||
|
|
||||||
void bindProductAndMedicineLabel(String[] productId,int labelId);
|
void bindProductAndMedicineLabel(String[] productId,int labelId);
|
||||||
|
|
||||||
void unbindProductAndMedicineLabel(int productId,int labelId);
|
void unbindProductAndMedicineLabel(int productId,int labelId);
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ public class CourseMedicineServiceImpl extends ServiceImpl<CourseMedicineDao, Co
|
|||||||
//查看绑定关系是否存在
|
//查看绑定关系是否存在
|
||||||
Integer integer = toMedicalDao.selectCount(new LambdaQueryWrapper<CourseToMedicine>().eq(CourseToMedicine::getMedicalId, id));
|
Integer integer = toMedicalDao.selectCount(new LambdaQueryWrapper<CourseToMedicine>().eq(CourseToMedicine::getMedicalId, id));
|
||||||
if(integer>0){
|
if(integer>0){
|
||||||
return R.error(502,"删除失败,请先解绑课程与国学标签的绑定关系");
|
return R.error(502,"删除失败,请先解绑课程与医学标签的绑定关系");
|
||||||
}
|
}
|
||||||
this.removeById(id);
|
this.removeById(id);
|
||||||
return R.ok();
|
return R.ok();
|
||||||
|
|||||||
@@ -52,6 +52,14 @@ public class ShopProductServiceImpl extends ServiceImpl<ShopProductDao, ShopProd
|
|||||||
@Autowired
|
@Autowired
|
||||||
private ShopProductSociologyMarketDao shopProductSociologyMarketDao;
|
private ShopProductSociologyMarketDao shopProductSociologyMarketDao;
|
||||||
@Autowired
|
@Autowired
|
||||||
|
private ShopProductToPsycheLabelDao shopProductToPsycheLabelDao;
|
||||||
|
@Autowired
|
||||||
|
private ShopProductPsycheLabelDao shopProductPsycheLabelDao;
|
||||||
|
@Autowired
|
||||||
|
private ShopProductToPsycheMarketDao shopProductToPsycheMarketDao;
|
||||||
|
@Autowired
|
||||||
|
private ShopProductPsycheMarketDao shopProductPsycheMarketDao;
|
||||||
|
@Autowired
|
||||||
private ShopProductBookDao shopProductBookDao;
|
private ShopProductBookDao shopProductBookDao;
|
||||||
@Autowired
|
@Autowired
|
||||||
private BookDao bookDao;
|
private BookDao bookDao;
|
||||||
@@ -149,6 +157,44 @@ public class ShopProductServiceImpl extends ServiceImpl<ShopProductDao, ShopProd
|
|||||||
shopProductToSociologyMarketDao.delete(new LambdaQueryWrapper<ShopProductToSociologyMarket>().eq(ShopProductToSociologyMarket::getProductId,product).eq(ShopProductToSociologyMarket::getSociologyMarketId,marketId));
|
shopProductToSociologyMarketDao.delete(new LambdaQueryWrapper<ShopProductToSociologyMarket>().eq(ShopProductToSociologyMarket::getProductId,product).eq(ShopProductToSociologyMarket::getSociologyMarketId,marketId));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void bindProductAndPsycheLabel(String[] productIds, Integer labelId) {
|
||||||
|
for (String p : productIds){
|
||||||
|
Integer integer = shopProductToPsycheLabelDao.selectCount(new LambdaQueryWrapper<ShopProductToPsycheLabel>().eq(ShopProductToPsycheLabel::getProductId, Integer.valueOf(p)).eq(ShopProductToPsycheLabel::getPsycheLabelId, labelId));
|
||||||
|
if(integer>0){
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
ShopProductToPsycheLabel shopProductToPsycheLabel = new ShopProductToPsycheLabel();
|
||||||
|
shopProductToPsycheLabel.setProductId(Integer.valueOf(p));
|
||||||
|
shopProductToPsycheLabel.setPsycheLabelId(labelId);
|
||||||
|
shopProductToPsycheLabelDao.insert(shopProductToPsycheLabel);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void unbindProductAndPsycheLabel(int productId, int labelId) {
|
||||||
|
shopProductToPsycheLabelDao.delete(new LambdaQueryWrapper<ShopProductToPsycheLabel>().eq(ShopProductToPsycheLabel::getProductId, productId).eq(ShopProductToPsycheLabel::getPsycheLabelId, labelId));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void bindProductAndPsycheMarket(String[] productId, int marketId) {
|
||||||
|
for (String p:productId){
|
||||||
|
Integer integer = shopProductToPsycheMarketDao.selectCount(new LambdaQueryWrapper<ShopProductToPsycheMarket>().eq(ShopProductToPsycheMarket::getProductId, Integer.valueOf(p)).eq(ShopProductToPsycheMarket::getPsycheMarketId, marketId));
|
||||||
|
if(integer>0){
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
ShopProductToPsycheMarket shopProductToPsycheMarket = new ShopProductToPsycheMarket();
|
||||||
|
shopProductToPsycheMarket.setProductId(Integer.valueOf(p));
|
||||||
|
shopProductToPsycheMarket.setPsycheMarketId(marketId);
|
||||||
|
shopProductToPsycheMarketDao.insert(shopProductToPsycheMarket);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void unbindProductAndPsycheMarket(int product, int marketId) {
|
||||||
|
shopProductToPsycheMarketDao.delete(new LambdaQueryWrapper<ShopProductToPsycheMarket>().eq(ShopProductToPsycheMarket::getProductId,product).eq(ShopProductToPsycheMarket::getPsycheMarketId,marketId));
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void bindProductAndMedicineLabel(String[] productId, int labelId) {
|
public void bindProductAndMedicineLabel(String[] productId, int labelId) {
|
||||||
for (String p : productId){
|
for (String p : productId){
|
||||||
@@ -405,7 +451,34 @@ public class ShopProductServiceImpl extends ServiceImpl<ShopProductDao, ShopProd
|
|||||||
return (label1.getSort() == null ? 0 : label1.getSort()) - (label2.getSort() == null ? 0 : label2.getSort());
|
return (label1.getSort() == null ? 0 : label1.getSort()) - (label2.getSort() == null ? 0 : label2.getSort());
|
||||||
}).collect(Collectors.toList());
|
}).collect(Collectors.toList());
|
||||||
flag.put("medicineMarket",medicineMarket);
|
flag.put("medicineMarket",medicineMarket);
|
||||||
|
//心理学标签
|
||||||
|
List<Integer> psycheLabelIds = shopProductToPsycheLabelDao.selectList(new LambdaQueryWrapper<ShopProductToPsycheLabel>().eq(ShopProductToPsycheLabel::getProductId, productId)).stream().map(ShopProductToPsycheLabel::getPsycheLabelId).collect(Collectors.toList());
|
||||||
|
List<ShopProductPsycheLabel> shopProductPsycheLabels = shopProductPsycheLabelDao.selectList(null);
|
||||||
|
List<ShopProductPsycheLabel> psycheLabel = shopProductPsycheLabels.stream().filter(m -> m.getPid() == 0)
|
||||||
|
.map((m) -> {
|
||||||
|
if (m.getIsLast() == 1) {
|
||||||
|
m.setSelect(psycheLabelIds.contains(m.getId()));
|
||||||
|
}
|
||||||
|
m.setChildren(getPsycheLabelChildrens(m, shopProductPsycheLabels, psycheLabelIds));
|
||||||
|
return m;
|
||||||
|
}).sorted((label1, label2) -> {
|
||||||
|
return (label1.getSort() == null ? 0 : label1.getSort()) - (label2.getSort() == null ? 0 : label2.getSort());
|
||||||
|
}).collect(Collectors.toList());
|
||||||
|
flag.put("psycheLabel",psycheLabel);
|
||||||
|
//心理学运营标签
|
||||||
|
List<Integer> psycheMarketIds = shopProductToPsycheMarketDao.selectList(new LambdaQueryWrapper<ShopProductToPsycheMarket>().eq(ShopProductToPsycheMarket::getProductId, productId)).stream().map(ShopProductToPsycheMarket::getPsycheMarketId).collect(Collectors.toList());
|
||||||
|
List<ShopProductPsycheMarket> shopProductPsycheMarkets = shopProductPsycheMarketDao.selectList(null);
|
||||||
|
List<ShopProductPsycheMarket> psycheMarket = shopProductPsycheMarkets.stream().filter(m -> m.getPid() == 0)
|
||||||
|
.map((m) -> {
|
||||||
|
if (m.getIsLast() == 1) {
|
||||||
|
m.setSelect(psycheMarketIds.contains(m.getId()));
|
||||||
|
}
|
||||||
|
m.setChildren(getPsycheMarketChildrens(m, shopProductPsycheMarkets, psycheMarketIds));
|
||||||
|
return m;
|
||||||
|
}).sorted((label1, label2) -> {
|
||||||
|
return (label1.getSort() == null ? 0 : label1.getSort()) - (label2.getSort() == null ? 0 : label2.getSort());
|
||||||
|
}).collect(Collectors.toList());
|
||||||
|
flag.put("psycheMarket",psycheMarket);
|
||||||
return flag;
|
return flag;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -503,4 +576,35 @@ public class ShopProductServiceImpl extends ServiceImpl<ShopProductDao, ShopProd
|
|||||||
}).collect(Collectors.toList());
|
}).collect(Collectors.toList());
|
||||||
return children;
|
return children;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private List<ShopProductPsycheLabel> getPsycheLabelChildrens(ShopProductPsycheLabel root,List<ShopProductPsycheLabel> all,List<Integer> ids){
|
||||||
|
List<ShopProductPsycheLabel> children = all.stream().filter((m) -> {
|
||||||
|
return m.getPid().equals(root.getId());
|
||||||
|
})
|
||||||
|
.map((m) -> {
|
||||||
|
if (m.getIsLast() == 1) {
|
||||||
|
m.setSelect(ids.contains(m.getId()));
|
||||||
|
}
|
||||||
|
m.setChildren(getPsycheLabelChildrens(m, all, ids));
|
||||||
|
return m;
|
||||||
|
}).sorted((label1, label2) -> {
|
||||||
|
return (label1.getSort() == null ? 0 : label1.getSort()) - (label2.getSort() == null ? 0 : label2.getSort());
|
||||||
|
}).collect(Collectors.toList());
|
||||||
|
return children;
|
||||||
|
}
|
||||||
|
private List<ShopProductPsycheMarket> getPsycheMarketChildrens(ShopProductPsycheMarket root,List<ShopProductPsycheMarket> all,List<Integer> ids){
|
||||||
|
List<ShopProductPsycheMarket> children = all.stream().filter((m) -> {
|
||||||
|
return m.getPid().equals(root.getId());
|
||||||
|
})
|
||||||
|
.map((m) -> {
|
||||||
|
if (m.getIsLast() == 1) {
|
||||||
|
m.setSelect(ids.contains(m.getId()));
|
||||||
|
}
|
||||||
|
m.setChildren(getPsycheMarketChildrens(m, all, ids));
|
||||||
|
return m;
|
||||||
|
}).sorted((label1, label2) -> {
|
||||||
|
return (label1.getSort() == null ? 0 : label1.getSort()) - (label2.getSort() == null ? 0 : label2.getSort());
|
||||||
|
}).collect(Collectors.toList());
|
||||||
|
return children;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,8 +39,10 @@ public class PsycheCourseController {
|
|||||||
public R getUserCourseBuy(){
|
public R getUserCourseBuy(){
|
||||||
MPJLambdaWrapper<CourseEntity> wrapper = new MPJLambdaWrapper<>();
|
MPJLambdaWrapper<CourseEntity> wrapper = new MPJLambdaWrapper<>();
|
||||||
wrapper.leftJoin(CourseCatalogueEntity.class,CourseCatalogueEntity::getCourseId,CourseEntity::getId);
|
wrapper.leftJoin(CourseCatalogueEntity.class,CourseCatalogueEntity::getCourseId,CourseEntity::getId);
|
||||||
wrapper.leftJoin(CourseToPsyche.class,CourseToPsyche::getCourseId,CourseEntity::getId);
|
wrapper.rightJoin(CourseToPsyche.class,CourseToPsyche::getCourseId,CourseEntity::getId);
|
||||||
|
if (!userVipService.isPsycheVip()){
|
||||||
wrapper.leftJoin(UserCourseBuyEntity.class,UserCourseBuyEntity::getCourseId,CourseEntity::getId);
|
wrapper.leftJoin(UserCourseBuyEntity.class,UserCourseBuyEntity::getCourseId,CourseEntity::getId);
|
||||||
|
}
|
||||||
wrapper.eq(UserCourseBuyEntity::getUserId,ShiroUtils.getUId());
|
wrapper.eq(UserCourseBuyEntity::getUserId,ShiroUtils.getUId());
|
||||||
wrapper.selectAll(CourseEntity.class);
|
wrapper.selectAll(CourseEntity.class);
|
||||||
wrapper.selectAs(CourseCatalogueEntity::getId,"catalogueId");
|
wrapper.selectAs(CourseCatalogueEntity::getId,"catalogueId");
|
||||||
@@ -48,6 +50,12 @@ public class PsycheCourseController {
|
|||||||
wrapper.orderByAsc(CourseEntity::getSort);
|
wrapper.orderByAsc(CourseEntity::getSort);
|
||||||
wrapper.orderByAsc(CourseCatalogueEntity::getSort);
|
wrapper.orderByAsc(CourseCatalogueEntity::getSort);
|
||||||
List<Map<String,Object>> courseList = courseService.listMaps(wrapper);
|
List<Map<String,Object>> courseList = courseService.listMaps(wrapper);
|
||||||
|
for (Map<String,Object> map:courseList){
|
||||||
|
int i = userCourseStudyingService.count(new LambdaQueryWrapper<UserCourseStudying>()
|
||||||
|
.eq(UserCourseStudying::getCourseId,map.get("id"))
|
||||||
|
.eq(UserCourseStudying::getUserId,ShiroUtils.getUId()));
|
||||||
|
map.put("isStudying",i>0?1:0);
|
||||||
|
}
|
||||||
return R.ok().put("courseList",courseList);
|
return R.ok().put("courseList",courseList);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user