|
@@ -17,6 +17,7 @@ import org.dromara.common.mybatis.core.page.TableDataInfo;
|
|
|
import org.dromara.common.mybatis.core.page.PageQuery;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
+import org.dromara.common.mybatis.helper.DataBaseHelper;
|
|
|
import org.dromara.common.satoken.utils.LoginHelper;
|
|
|
import org.dromara.system.domain.FormalParentsStudent;
|
|
|
import org.dromara.system.domain.FormalTeacherClass;
|
|
@@ -57,7 +58,7 @@ public class XiaoyuanNoticeServiceImpl implements IXiaoyuanNoticeService {
|
|
|
* 查询校园新闻
|
|
|
*/
|
|
|
@Override
|
|
|
- public XiaoyuanNoticeVo queryById(Long noticeId){
|
|
|
+ public XiaoyuanNoticeVo queryById(Long noticeId) {
|
|
|
return baseMapper.selectVoById(noticeId);
|
|
|
}
|
|
|
|
|
@@ -88,10 +89,10 @@ public class XiaoyuanNoticeServiceImpl implements IXiaoyuanNoticeService {
|
|
|
}
|
|
|
//查询出所有班级id
|
|
|
bo.setSenderDept(classId.toString());
|
|
|
- LambdaQueryWrapper<XiaoyuanNotice> lqw = buildQueryWrapper(bo);
|
|
|
+ bo.setSenderId(String.valueOf(LoginHelper.getUserId()));
|
|
|
+ LambdaQueryWrapper<XiaoyuanNotice> lqw = buildListWrapper(bo);
|
|
|
result = baseMapper.selectVoPage(pageQuery.build(), lqw);
|
|
|
- }
|
|
|
- else if ("parents".equals(role)) {
|
|
|
+ } else if ("parents".equals(role)) {
|
|
|
FormalParentsStudent formalParentsStudent = new FormalParentsStudent();
|
|
|
formalParentsStudent.setParentsId(LoginHelper.getUserId());
|
|
|
List<FormalParentsStudent> formalParentsStudents = formalParentsStudentMapper.selectFormalParentsStudentList(formalParentsStudent);
|
|
@@ -103,18 +104,29 @@ public class XiaoyuanNoticeServiceImpl implements IXiaoyuanNoticeService {
|
|
|
}
|
|
|
//查询出所有班级id
|
|
|
bo.setSenderDept(classId.toString());
|
|
|
- LambdaQueryWrapper<XiaoyuanNotice> lqw = buildQueryWrapper(bo);
|
|
|
+ bo.setSenderId(String.valueOf(LoginHelper.getUserId()));
|
|
|
+ LambdaQueryWrapper<XiaoyuanNotice> lqw = buildListWrapper(bo);
|
|
|
result = baseMapper.selectVoPage(pageQuery.build(), lqw);
|
|
|
- }
|
|
|
- else if ("admin".equals(role)){
|
|
|
- LambdaQueryWrapper<XiaoyuanNotice> lqw = buildQueryWrapper(bo);
|
|
|
+ } else if ("admin".equals(role)) {
|
|
|
+ LambdaQueryWrapper<XiaoyuanNotice> lqw = Wrappers.lambdaQuery();
|
|
|
result = baseMapper.selectVoPage(pageQuery.build(), lqw);
|
|
|
}
|
|
|
return TableDataInfo.build(result);
|
|
|
}
|
|
|
|
|
|
+ private LambdaQueryWrapper<XiaoyuanNotice> buildListWrapper(XiaoyuanNoticeBo bo) {
|
|
|
+ LambdaQueryWrapper<XiaoyuanNotice> lqw = Wrappers.lambdaQuery();
|
|
|
+ lqw.eq(XiaoyuanNotice::getType, "0")
|
|
|
+ .or(i -> i.eq(XiaoyuanNotice::getType, "3").eq(XiaoyuanNotice::getSenderId, bo.getSenderId()))
|
|
|
+ .or(i -> i.eq(XiaoyuanNotice::getType, "1").apply("find_in_set_multiple('" + bo.getSenderDept() + "',class_id_kejian)"))
|
|
|
+ .or(i -> i.eq(XiaoyuanNotice::getType, "2").apply("!find_in_set_multiple('" + bo.getSenderDept() + "',class_id_bukejian)"));
|
|
|
+ lqw.orderByDesc(XiaoyuanNotice::getCreateTime);
|
|
|
+ return lqw;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 我的校园新闻列表
|
|
|
+ *
|
|
|
* @param bo
|
|
|
* @param pageQuery
|
|
|
* @return
|
|
@@ -286,7 +298,7 @@ public class XiaoyuanNoticeServiceImpl implements IXiaoyuanNoticeService {
|
|
|
/**
|
|
|
* 保存前的数据校验
|
|
|
*/
|
|
|
- private void validEntityBeforeSave(XiaoyuanNotice entity){
|
|
|
+ private void validEntityBeforeSave(XiaoyuanNotice entity) {
|
|
|
//TODO 做一些数据校验,如唯一约束
|
|
|
}
|
|
|
|
|
@@ -295,7 +307,7 @@ public class XiaoyuanNoticeServiceImpl implements IXiaoyuanNoticeService {
|
|
|
*/
|
|
|
@Override
|
|
|
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
|
|
|
- if(isValid){
|
|
|
+ if (isValid) {
|
|
|
//TODO 做一些业务上的校验,判断是否需要校验
|
|
|
}
|
|
|
return baseMapper.deleteBatchIds(ids) > 0;
|
|
@@ -303,15 +315,16 @@ public class XiaoyuanNoticeServiceImpl implements IXiaoyuanNoticeService {
|
|
|
|
|
|
/**
|
|
|
* 我的收藏
|
|
|
+ *
|
|
|
* @param bo
|
|
|
* @param pageQuery
|
|
|
* @return
|
|
|
*/
|
|
|
@Override
|
|
|
public TableDataInfo<XiaoyuanNoticeVo> myCollect(XiaoyuanNoticeBo bo, PageQuery pageQuery) {
|
|
|
- bo.setCollect("\"userId\":" + LoginHelper.getUserId());
|
|
|
+ bo.setCollect("\"userId\":\"" + LoginHelper.getUserId()+"\"");
|
|
|
Page<XiaoyuanNoticeVo> xiaoyuanNoticePage = baseMapper.selectXiaoyuanNoticeByMyCollect(pageQuery.build(), this.buildQueryWrapperCollect(bo));
|
|
|
- return TableDataInfo.build(xiaoyuanNoticePage);
|
|
|
+ return TableDataInfo.build(xiaoyuanNoticePage);
|
|
|
}
|
|
|
|
|
|
private Wrapper<XiaoyuanNoticeBo> buildQueryWrapperCollect(XiaoyuanNoticeBo bo) {
|