Commit 847c3e16 authored by luzhuang's avatar luzhuang

feat: lable 添加 newCount

parent be46f5b5
...@@ -276,6 +276,7 @@ public class BCourseServiceImpl implements BCourseService { ...@@ -276,6 +276,7 @@ public class BCourseServiceImpl implements BCourseService {
continue; continue;
} }
} }
secNum+=num;//添加分类直属 new课程的数量
if (dto.getChildren() == null) if (dto.getChildren() == null)
continue; continue;
for (QueryCourseResDTO dto1 : dto.getChildren()){ //二级分类 for (QueryCourseResDTO dto1 : dto.getChildren()){ //二级分类
...@@ -307,9 +308,9 @@ public class BCourseServiceImpl implements BCourseService { ...@@ -307,9 +308,9 @@ public class BCourseServiceImpl implements BCourseService {
secNum += secNum1;//将二级分类下三级分类中的数量添加到 二级分类中 secNum += secNum1;//将二级分类下三级分类中的数量添加到 二级分类中
} }
dto.setNewCount(secNum);
} }
return resDTOS; return resDTOS;
} }
......
...@@ -25,4 +25,8 @@ public class BLabel extends IdEntity<BLabel> { ...@@ -25,4 +25,8 @@ public class BLabel extends IdEntity<BLabel> {
@ApiModelProperty(value = "标签名") @ApiModelProperty(value = "标签名")
private String lName; private String lName;
@Transient
@ApiModelProperty(value = "新消息的个数")
private int newCount;
} }
...@@ -2,8 +2,11 @@ package org.rcisoft.business.blabel.service.impl; ...@@ -2,8 +2,11 @@ package org.rcisoft.business.blabel.service.impl;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.rcisoft.business.blabel.dao.BLabelRepository; import org.rcisoft.business.blabel.dao.BLabelRepository;
import org.rcisoft.business.blabel.dto.QueryLabelResDTO;
import org.rcisoft.business.blabel.entity.BLabel; import org.rcisoft.business.blabel.entity.BLabel;
import org.rcisoft.business.blabel.service.BLabelService; import org.rcisoft.business.blabel.service.BLabelService;
import org.rcisoft.business.blesson.entity.BLesson;
import org.rcisoft.business.blesson.service.impl.BLessonServiceImpl;
import org.rcisoft.core.aop.PageUtil; import org.rcisoft.core.aop.PageUtil;
import org.rcisoft.core.constant.MessageConstant; import org.rcisoft.core.constant.MessageConstant;
import org.rcisoft.core.exception.ServiceException; import org.rcisoft.core.exception.ServiceException;
...@@ -17,44 +20,68 @@ import org.springframework.transaction.annotation.Propagation; ...@@ -17,44 +20,68 @@ import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.util.List; import java.util.List;
@Service @Service
public class BLabelServiceImpl implements BLabelService { public class BLabelServiceImpl implements BLabelService {
@Autowired @Autowired
private BLabelRepository bLabelRepository; private BLabelRepository bLabelRepository;
@Autowired
private BLessonServiceImpl bLessonService;
@Override @Override
public List<BLabel> queryBlabelsByPagination(PageUtil pageUtil, String lName,String corpId) { public List<BLabel> queryBlabelsByPagination(PageUtil pageUtil, String lName, String corpId) {
return bLabelRepository.queryBlabels(lName,corpId); return bLabelRepository.queryBlabels(lName, corpId);
} }
@Override @Override
public List<BLabel> queryBlabels(String lName,String corpId) { public List<BLabel> queryBlabels(String lName, String corpId) {
return bLabelRepository.queryBlabels(lName,corpId);
List<BLabel> labels = bLabelRepository.queryBlabels(lName, corpId);
List<BLesson> lessons = bLessonService.queryHomeBLessons();
for (BLabel label : labels) {
int num = 0;
for (BLesson lesson : lessons) {
List<QueryLabelResDTO> labelResDTOS = lesson.getLabelList();
if (labelResDTOS.size() > 0) {
for (QueryLabelResDTO dto : labelResDTOS) {
if (dto.getBusinessId() == label.getBusinessId()) {
num++;
} else {
continue;
}
}
}
}
label.setNewCount(num);
}
return labels;
} }
@Override @Override
@Transactional(propagation = Propagation.REQUIRED,readOnly = false) @Transactional(propagation = Propagation.REQUIRED, readOnly = false)
public PersistModel insertLabel(BLabel bLabel, CurUser curUser) { public PersistModel insertLabel(BLabel bLabel, CurUser curUser) {
if(StringUtils.isBlank(bLabel.getLName())){ if (StringUtils.isBlank(bLabel.getLName())) {
throw new ServiceException("标签名称不能为空"); throw new ServiceException("标签名称不能为空");
} }
int line = bLabelRepository.checknameByName(bLabel.getLName(),bLabel.getBusinessId(),curUser.getCorpId()); int line = bLabelRepository.checknameByName(bLabel.getLName(), bLabel.getBusinessId(), curUser.getCorpId());
if(line > 0){ if (line > 0) {
throw new ServiceException(ResultServiceEnums.NAME_IS_EXISTS); throw new ServiceException(ResultServiceEnums.NAME_IS_EXISTS);
} }
UserUtil.setCurrentPersistOperation(bLabel); UserUtil.setCurrentPersistOperation(bLabel);
return new PersistModel(bLabelRepository.insert(bLabel),MessageConstant.MESSAGE_ALERT_SUCCESS) ; return new PersistModel(bLabelRepository.insert(bLabel), MessageConstant.MESSAGE_ALERT_SUCCESS);
} }
@Override @Override
@Transactional(propagation = Propagation.REQUIRED,readOnly = false) @Transactional(propagation = Propagation.REQUIRED, readOnly = false)
public PersistModel updateLabel(BLabel bLabel, CurUser curUser) { public PersistModel updateLabel(BLabel bLabel, CurUser curUser) {
if(StringUtils.isBlank(bLabel.getLName())){ if (StringUtils.isBlank(bLabel.getLName())) {
throw new ServiceException("标签名称不能为空"); throw new ServiceException("标签名称不能为空");
} }
int line = bLabelRepository.checknameByName(bLabel.getLName(),bLabel.getBusinessId(),curUser.getCorpId()); int line = bLabelRepository.checknameByName(bLabel.getLName(), bLabel.getBusinessId(), curUser.getCorpId());
if(line > 0){ if (line > 0) {
throw new ServiceException(ResultServiceEnums.NAME_IS_EXISTS); throw new ServiceException(ResultServiceEnums.NAME_IS_EXISTS);
} }
UserUtil.setCurrentMergeOperation(bLabel); UserUtil.setCurrentMergeOperation(bLabel);
...@@ -62,7 +89,7 @@ public class BLabelServiceImpl implements BLabelService { ...@@ -62,7 +89,7 @@ public class BLabelServiceImpl implements BLabelService {
} }
@Override @Override
@Transactional(propagation = Propagation.REQUIRED,readOnly = false) @Transactional(propagation = Propagation.REQUIRED, readOnly = false)
public PersistModel removeLabel(String id) { public PersistModel removeLabel(String id) {
int line = bLabelRepository.removeLabel(id); int line = bLabelRepository.removeLabel(id);
return new PersistModel(line, MessageConstant.MESSAGE_ALERT_SUCCESS); return new PersistModel(line, MessageConstant.MESSAGE_ALERT_SUCCESS);
......
...@@ -784,7 +784,7 @@ public class BLessonController extends PaginationController<BLesson> { ...@@ -784,7 +784,7 @@ public class BLessonController extends PaginationController<BLesson> {
@ApiOperation(value = "645555 点击课程", notes = "取消new显示") @ApiOperation(value = "645555 点击课程", notes = "取消new显示")
@PostMapping(value = "/test") @PostMapping(value = "/test")
public Result test (CurUser curUser) { public Result test () {
return Result.builder(bLessonService.test(), return Result.builder(bLessonService.test(),
MessageConstant.MESSAGE_ALERT_SUCCESS, MessageConstant.MESSAGE_ALERT_SUCCESS,
MessageConstant.MESSAGE_ALERT_ERROR, MessageConstant.MESSAGE_ALERT_ERROR,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment