Pārlūkot izejas kodu

更新app查询成绩,朋友圈问题

Administrator 1 gadu atpakaļ
vecāks
revīzija
4cc9f7a163

+ 25 - 0
ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/domain/notice/vo/XiaoyuanNoticeVo.java

@@ -2,6 +2,8 @@ package org.dromara.system.domain.notice.vo;
 
 import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
 import com.alibaba.excel.annotation.ExcelProperty;
+import com.baomidou.mybatisplus.annotation.FieldFill;
+import com.baomidou.mybatisplus.annotation.TableField;
 import org.dromara.common.excel.annotation.ExcelDictFormat;
 import org.dromara.common.excel.convert.ExcelDictConvert;
 import io.github.linpeilie.annotations.AutoMapper;
@@ -138,5 +140,28 @@ public class XiaoyuanNoticeVo implements Serializable {
     @ExcelProperty(value = "收藏")
     private String collect;
 
+    /**
+     * 创建者
+     */
+
+    private Long createBy;
+
+    /**
+     * 创建时间
+     */
+
+    private Date createTime;
+
+    /**
+     * 更新者
+     */
+
+    private Long updateBy;
+
+    /**
+     * 更新时间
+     */
+
+    private Date updateTime;
 
 }

+ 2 - 0
ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/mapper/notice/XiaoyuanNoticeMapper.java

@@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.core.toolkit.Constants;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import org.apache.ibatis.annotations.Param;
 import org.dromara.common.mybatis.core.mapper.BaseMapperPlus;
+import org.dromara.common.mybatis.core.page.PageQuery;
 import org.dromara.system.domain.notice.XiaoyuanNotice;
 import org.dromara.system.domain.notice.bo.XiaoyuanNoticeBo;
 import org.dromara.system.domain.notice.vo.XiaoyuanNoticeVo;
@@ -23,4 +24,5 @@ public interface XiaoyuanNoticeMapper extends BaseMapperPlus<XiaoyuanNotice, Xia
     Page<XiaoyuanNoticeVo> selectXiaoyuanNoticeByMyCollect(@Param("page") Page<XiaoyuanNotice> page, @Param(Constants.WRAPPER) Wrapper<XiaoyuanNoticeBo> queryWrapper);
 
     public List<XiaoyuanNoticeVo> selectXiaoyuanNoticeMyList(XiaoyuanNotice xiaoyuanNotice);
+
 }

+ 25 - 12
ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/impl/notice/XiaoyuanNoticeServiceImpl.java

@@ -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) {

+ 1 - 1
ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/impl/score/ScoreDataServiceImpl.java

@@ -169,10 +169,10 @@ public class ScoreDataServiceImpl implements IScoreDataService {
         LambdaQueryWrapper<ScoreData> lqw = Wrappers.lambdaQuery();
         lqw.eq(StringUtils.isNotBlank(bo.getScoreTitle()), ScoreData::getScoreTitle, bo.getScoreTitle());
         lqw.eq(bo.getScoreTime() != null, ScoreData::getScoreTime, bo.getScoreTime());
-        lqw.eq(StringUtils.isNotBlank(bo.getScoreClassId()), ScoreData::getScoreClassId, bo.getScoreClassId());
         lqw.like(StringUtils.isNotBlank(bo.getScoreClassName()), ScoreData::getScoreClassName, bo.getScoreClassName());
         lqw.eq(StringUtils.isNotBlank(bo.getPrivacyType()), ScoreData::getPrivacyType, bo.getPrivacyType());
         lqw.eq(StringUtils.isNotBlank(bo.getAvg()), ScoreData::getAvg, bo.getAvg());
+        lqw.apply("find_in_set(score_class_id,'"+bo.getScoreClassId()+"')");
         return lqw;
     }