From 0057ef145ab05b6c34802deb4ff575f975b6283a Mon Sep 17 00:00:00 2001
From: 龚焕茏 <2842157468@qq.com>
Date: 星期四, 16 五月 2024 18:19:15 +0800
Subject: [PATCH] feat:部门管理员功能权限控制
---
src/main/java/com/mindskip/xzs/service/impl/OnlineStudySeerviceImpl.java | 43 +++++++++++++++++++++++++++++++++++++++----
1 files changed, 39 insertions(+), 4 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..b62c392 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.repository.OnlineStudyMapper;
import com.mindskip.xzs.service.OnlineStudyService;
+import com.mindskip.xzs.utility.JsonUtil;
+import jdk.nashorn.internal.ir.IfNode;
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;
+import java.util.stream.Collectors;
/**
* @author锛歺p
@@ -22,13 +33,32 @@
@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("淇敼鎴愬姛");
}
@@ -41,7 +71,12 @@
@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());
}
}
--
Gitblit v1.8.0