From c25d93c39975f84ca411da16b82ab556648a50e0 Mon Sep 17 00:00:00 2001
From: 龚焕茏 <2842157468@qq.com>
Date: 星期三, 22 五月 2024 15:21:44 +0800
Subject: [PATCH] feat:用户状况新增审核
---
src/main/java/com/mindskip/xzs/service/impl/OnlineStudySeerviceImpl.java | 62 ++++++++++++++++++++++++++++--
1 files changed, 57 insertions(+), 5 deletions(-)
diff --git a/src/main/java/com/mindskip/xzs/service/impl/OnlineStudySeerviceImpl.java b/src/main/java/com/mindskip/xzs/service/impl/OnlineStudySeerviceImpl.java
index 3af5f30..7cb8fb0 100644
--- a/src/main/java/com/mindskip/xzs/service/impl/OnlineStudySeerviceImpl.java
+++ b/src/main/java/com/mindskip/xzs/service/impl/OnlineStudySeerviceImpl.java
@@ -1,14 +1,25 @@
package com.mindskip.xzs.service.impl;
+import com.alibaba.fastjson.JSON;
import com.github.pagehelper.PageHelper;
+import com.github.pagehelper.PageInfo;
import com.mindskip.xzs.base.RestResponse;
+import com.mindskip.xzs.domain.OnlineStudy;
+import com.mindskip.xzs.domain.question.QuestionObject;
import com.mindskip.xzs.domain.vo.OnlineStudyVO;
+import com.mindskip.xzs.domain.vo.StudentOnlineVO;
+import com.mindskip.xzs.domain.vo.StudyTypeVO;
import com.mindskip.xzs.repository.OnlineStudyMapper;
+import com.mindskip.xzs.repository.StudyTypeMapper;
import com.mindskip.xzs.service.OnlineStudyService;
import lombok.RequiredArgsConstructor;
+import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
+import org.springframework.util.CollectionUtils;
+import java.util.Date;
import java.util.List;
+import java.util.Objects;
/**
* @author锛歺p
@@ -19,16 +30,36 @@
public class OnlineStudySeerviceImpl implements OnlineStudyService {
private final OnlineStudyMapper mapper;
+ private final StudyTypeMapper studyTypeMapper;
@Override
public RestResponse add(OnlineStudyVO form) {
- mapper.add(form);
+ OnlineStudy onlineStudy = new OnlineStudy();
+ BeanUtils.copyProperties(form, onlineStudy);
+ onlineStudy.setContentUrl(JSON.toJSONString(form.getContentUrl()));
+ if (! CollectionUtils.isEmpty(form.getAttachment())) {
+ onlineStudy.setAttachment(JSON.toJSONString(form.getAttachment()));
+ }
+ onlineStudy.setCreateTime(new Date());
+ onlineStudy.setUpdateTime(new Date());
+ mapper.add(onlineStudy);
return RestResponse.ok("娣诲姞鎴愬姛");
}
@Override
public RestResponse update(OnlineStudyVO form) {
- mapper.update(form);
+ if (Objects.isNull(form.getId())) {
+ throw new RuntimeException("璇烽�夋嫨瑕佷慨鏀圭殑鏁版嵁");
+ }
+ OnlineStudy onlineStudy = new OnlineStudy();
+ BeanUtils.copyProperties(form, onlineStudy);
+ onlineStudy.setContentUrl(JSON.toJSONString(form.getContentUrl()));
+ if (! CollectionUtils.isEmpty(form.getAttachment())) {
+ onlineStudy.setAttachment(JSON.toJSONString(form.getAttachment()));
+ } else {
+ onlineStudy.setAttachment("");
+ }
+ mapper.update(onlineStudy);
return RestResponse.ok("淇敼鎴愬姛");
}
@@ -40,8 +71,29 @@
@Override
public RestResponse page(OnlineStudyVO query) {
- PageHelper.startPage(query.getPageNum(), query.getPageSize());
- List<OnlineStudyVO> data = mapper.page(query);
- return RestResponse.ok(data);
+ PageInfo<OnlineStudyVO> page = PageHelper.startPage(query.getPageNum(), query.getPageSize()).doSelectPageInfo(() ->
+ mapper.page(query));
+ page.getList().stream().forEach(item -> {
+ item.setContentUrl(JSON.parseObject(item.getContentUrlString(), OnlineStudyVO.UploadFile.class));
+ item.setAttachment(JSON.parseArray(item.getAttachmentString(), OnlineStudyVO.UploadFile.class));
+ });
+ return RestResponse.ok(page.getList()).put("total", page.getTotal());
+ }
+
+ @Override
+ public RestResponse byType(StudentOnlineVO query) {
+ PageInfo<OnlineStudyVO> page = PageHelper.startPage(query.getPageNum(), query.getPageSize()).doSelectPageInfo(() ->
+ mapper.byType(query));
+ page.getList().stream().forEach(item -> {
+ item.setContentUrl(JSON.parseObject(item.getContentUrlString(), OnlineStudyVO.UploadFile.class));
+ item.setAttachment(JSON.parseArray(item.getAttachmentString(), OnlineStudyVO.UploadFile.class));
+ });
+ return RestResponse.ok(page.getList()).put("total", page.getTotal());
+ }
+
+ @Override
+ public RestResponse typeList() {
+ List<StudyTypeVO> list = studyTypeMapper.list();
+ return RestResponse.ok(list);
}
}
--
Gitblit v1.8.0