Commit 847c3e16 authored by luzhuang's avatar luzhuang

feat: lable 添加 newCount

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