From e61a65c45a2a6a943be7ec56413162deefdda165 Mon Sep 17 00:00:00 2001
From: dengqingliu <2733574813@qq.com>
Date: 星期五, 02 十二月 2022 18:05:19 +0800
Subject: [PATCH] 资源存储升级成华为云OBS

---
 src/main/java/com/qxueyou/scc/portal/homepage/dao/ArticleDao.java                |  193 ++++++++
 src/main/java/com/qxueyou/scc/config/HweiOBSConfig.java                          |  135 +++++
 src/main/java/com/qxueyou/scc/portal/expert/service/imp/ExpertService.java       |   75 +++
 src/main/java/com/qxueyou/scc/controller/HweiYunOBSController.java               |  107 ++++
 src/main/java/com/qxueyou/scc/portal/expert/controller/ExpertController.java     |   71 ++
 pom.xml                                                                          |   36 +
 src/main/java/com/qxueyou/scc/portal/expert/model/Expert.java                    |  148 ++++++
 src/main/java/com/qxueyou/scc/teach/res/service/HweiYunOBSService.java           |   52 ++
 src/main/java/com/qxueyou/scc/portal/homepage/serivce/imp/HomepageService.java   |  140 +++++
 src/main/java/com/qxueyou/scc/portal/expert/vo/ExpertVO.java                     |  124 +++++
 src/main/java/com/qxueyou/scc/teach/res/service/impl/HweiYunOBSServiceImpl.java  |  185 +++++++
 src/main/java/com/qxueyou/scc/portal/homepage/controller/HomepageController.java |   63 ++
 src/main/java/com/qxueyou/scc/portal/homepage/serivce/IHomepageService.java      |   34 +
 src/main/java/com/qxueyou/scc/portal/expert/service/IExpertService.java          |   52 ++
 14 files changed, 1,412 insertions(+), 3 deletions(-)

diff --git a/pom.xml b/pom.xml
index 8df21a0..5462112 100644
--- a/pom.xml
+++ b/pom.xml
@@ -17,10 +17,10 @@
 		<version>1.5.10.RELEASE</version>
 		<relativePath/> <!-- lookup parent from repository -->
 	</parent>
-
 	<properties>
-		<project.build.sourceEncoding>GBK</project.build.sourceEncoding>
-		<project.reporting.outputEncoding>GBK</project.reporting.outputEncoding>
+		<!-- 涓�1.8閰嶇疆鍦ㄤ竴璧凤紝璁剧疆缂栫爜闆�-->
+		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+		<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
 		<java.version>1.8</java.version>
 	</properties>
 	<repositories>
@@ -66,6 +66,36 @@
 			<version>1.2</version>
 		</dependency>
 
+		<!--		鍗庝负浜慜BS渚濊禆/-->
+		<dependency>
+			<groupId>com.huaweicloud</groupId>
+			<artifactId>esdk-obs-java</artifactId>
+			<version>3.20.6.1</version>
+		</dependency>
+
+		<!--		<dependency>-->
+		<!--			<groupId>com.huaweicloud</groupId>-->
+		<!--			<artifactId>esdk-obs-java-bundle</artifactId>-->
+		<!--			<version>[3.21.11,)</version>-->
+		<!--		</dependency>-->
+		<!--		寮曞叆lombok/-->
+		<dependency>
+			<groupId>org.projectlombok</groupId>
+			<artifactId>lombok</artifactId>
+			<version>1.18.4</version>
+			<scope>provided</scope>
+		</dependency>
+		<!--		寮曞叆hutool宸ュ叿/-->
+		<!--		<dependency>-->
+		<!--			<groupId>cn.hutool</groupId>-->
+		<!--			<artifactId>hutool-all</artifactId>-->
+		<!--			<version>5.8.0.M4</version>-->
+		<!--		</dependency>-->
+		<dependency>
+			<groupId>cn.hutool</groupId>
+			<artifactId>hutool-core</artifactId>
+			<version>5.6.5</version>
+		</dependency>
 		<dependency>
 			<groupId>com.alibaba</groupId>
 			<artifactId>druid</artifactId>
diff --git a/src/main/java/com/qxueyou/scc/config/HweiOBSConfig.java b/src/main/java/com/qxueyou/scc/config/HweiOBSConfig.java
new file mode 100644
index 0000000..0886d06
--- /dev/null
+++ b/src/main/java/com/qxueyou/scc/config/HweiOBSConfig.java
@@ -0,0 +1,135 @@
+package com.qxueyou.scc.config;
+ 
+import com.obs.services.ObsClient;
+import com.obs.services.exception.ObsException;
+import com.qxueyou.scc.teach.res.service.impl.HweiYunOBSServiceImpl;
+import lombok.Data;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.context.annotation.Configuration;
+ 
+import java.text.SimpleDateFormat;
+import java.util.Date;
+ 
+/**
+ * @ClassName: HweiOBSConfig
+ * @Description: 鍗庝负浜慜BS閰嶇疆绫�
+ * @Author: wuhuiju
+ * @Date: 2021-12-21 15:56
+ * @Version: 1.0
+ */
+//@Data
+//@Slf4j
+@Configuration
+public class HweiOBSConfig {
+
+    private final Logger log = LogManager.getLogger(HweiOBSConfig.class);
+    public HweiOBSConfig() {
+    }
+
+    public HweiOBSConfig(String accessKey, String securityKey, String endPoint, String bucketName) {
+        this.accessKey = accessKey;
+        this.securityKey = securityKey;
+        this.endPoint = endPoint;
+        this.bucketName = bucketName;
+    }
+
+    public String getAccessKey() {
+        return accessKey;
+    }
+
+    public void setAccessKey(String accessKey) {
+        this.accessKey = accessKey;
+    }
+
+    public String getSecurityKey() {
+        return securityKey;
+    }
+
+    public void setSecurityKey(String securityKey) {
+        this.securityKey = securityKey;
+    }
+
+    public String getEndPoint() {
+        return endPoint;
+    }
+
+    public void setEndPoint(String endPoint) {
+        this.endPoint = endPoint;
+    }
+
+    public String getBucketName() {
+        return bucketName;
+    }
+
+    public void setBucketName(String bucketName) {
+        this.bucketName = bucketName;
+    }
+
+    /**
+     * 璁块棶瀵嗛挜AK
+     */
+    @Value("${hwyun.obs.accessKey}")
+    private String accessKey;
+ 
+    /**
+     * 璁块棶瀵嗛挜SK
+     */
+    @Value("${hwyun.obs.securityKey}")
+    private String securityKey;
+ 
+    /**
+     * 缁堢鑺傜偣
+     */
+    @Value("${hwyun.obs.endPoint}")
+    private String endPoint;
+ 
+    /**
+     * 妗�
+     */
+    @Value("${hwyun.obs.bucketName}")
+    private String bucketName;
+ 
+    /**
+     * @Description 鑾峰彇OBS瀹㈡埛绔疄渚�
+     * @author wuhuiju
+     * @date 2022/12/2 15:57
+     * @return
+     * @return: com.obs.services.ObsClient
+     */
+    public ObsClient getInstance() {
+        return new ObsClient(accessKey, securityKey, endPoint);
+    }
+ 
+ 
+    /**
+     * @Description 閿�姣丱BS瀹㈡埛绔疄渚�
+     * @author wuhuiju
+     * @date 2022/12/2 17:32
+     * @param: obsClient
+     * @return
+     */
+    public void destroy(ObsClient obsClient){
+        try {
+            obsClient.close();
+        } catch (ObsException e) {
+            log.error("obs鎵ц澶辫触", e);
+        } catch (Exception e) {
+            log.error("鎵ц澶辫触", e);
+        }
+    }
+ 
+    /**
+     * @Description 寰湇鍔℃枃浠跺瓨鏀捐矾寰�
+     * @author wuhuiju
+     * @date 2022/12/2 15:57
+     * @return
+     * @return: java.lang.String
+     */
+    public static String getObjectKey() {
+        // 椤圭洰鎴栬�呮湇鍔″悕绉� + 鏃ユ湡瀛樺偍鏂瑰紡
+        return "Hwei" + "/" + new SimpleDateFormat("yyyy-MM-dd").format(new Date() )+ "/";
+    }
+}
\ No newline at end of file
diff --git a/src/main/java/com/qxueyou/scc/controller/HweiYunOBSController.java b/src/main/java/com/qxueyou/scc/controller/HweiYunOBSController.java
new file mode 100644
index 0000000..6bf662a
--- /dev/null
+++ b/src/main/java/com/qxueyou/scc/controller/HweiYunOBSController.java
@@ -0,0 +1,107 @@
+package com.qxueyou.scc.controller;
+ 
+import cn.hutool.core.io.FileUtil;
+import cn.hutool.core.io.IoUtil;
+import cn.hutool.core.util.ArrayUtil;
+import cn.hutool.core.util.StrUtil;
+
+//import cn.hutool.core.io.FileUtil;
+import com.obs.services.exception.ObsException;
+import com.qxueyou.scc.base.model.Result;
+import com.qxueyou.scc.teach.res.service.HweiYunOBSService;
+import org.springframework.util.ObjectUtils;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
+ 
+import javax.annotation.Resource;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.BufferedOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URLEncoder;
+import java.util.List;
+ 
+/**
+ * @ClassName: ObsController
+ * @Description: OBS鏈嶅姟鍣–ontroller
+ * @Author: wuhuiju
+ * @Date: 2021-12-21 15:20
+ * @Version: 1.0
+ */
+@RestController
+@RequestMapping({ "file" })// @RequestMapping("/file")
+public class HweiYunOBSController {
+ 
+    @Resource
+    private HweiYunOBSService hweiYunOBSService;
+ 
+    @RequestMapping(value = "upload", method = RequestMethod.POST)
+    public Result save(@RequestParam(value = "file", required = false) MultipartFile file) {
+
+        if (ObjectUtils.isEmpty(file) || file.getSize() <= 0) {
+            return new Result(false,"鏂囦欢涓虹┖");
+        }
+//        if (FileUtil.isEmpty(file)) {
+//            return new Result(false,"鏂囦欢涓虹┖");
+//        }
+        final String test = hweiYunOBSService.fileUpload(file, file.getOriginalFilename());
+//        return ResponseVO.ok("鎵ц鎴愬姛",test);
+        return new Result(true,"success",test);
+    }
+ 
+    @RequestMapping(value = "delete", method = RequestMethod.POST)
+    public Result delete(@RequestParam(value = "fileName", required = false)  String fileName) {
+        if (StrUtil.isEmpty(fileName)) {
+            return new Result(false,"鍒犻櫎鏂囦欢涓虹┖");
+        }
+        final boolean delete = hweiYunOBSService.delete(fileName);
+        return delete?new Result(true,"success"):new Result(false,"鍒犻櫎澶辫触");
+    }
+ 
+    @RequestMapping(value = "deletes", method = RequestMethod.POST)
+    //@RequestParam 鑾峰彇List锛屾暟缁勫垯涓嶉渶瑕�
+    public Result delete(@RequestParam("fileNames") List<String> fileNames) {
+        if (ArrayUtil.isEmpty(fileNames)) {
+            return new Result(false,"鍒犻櫎鏂囦欢涓虹┖");
+        }
+        final boolean delete = hweiYunOBSService.delete(fileNames);
+        return delete?new Result(true,"success"):new Result(false,"鍒犻櫎澶辫触");
+    }
+ 
+ 
+    @RequestMapping(value = "download", method = RequestMethod.POST)
+    public Result download(HttpServletRequest request, HttpServletResponse response, @RequestParam(value = "fileName", required = false) String fileName) {
+        if (StrUtil.isEmpty(fileName)) {
+            return new Result(false,"涓嬭浇鏂囦欢涓虹┖");
+        }
+        try (
+                InputStream inputStream = hweiYunOBSService.fileDownload(fileName);
+             BufferedOutputStream outputStream = new BufferedOutputStream(response.getOutputStream())){
+            if(inputStream == null) {
+                return new Result(false);
+            }
+            // 涓洪槻姝� 鏂囦欢鍚嶅嚭鐜颁贡鐮�
+            final String userAgent = request.getHeader("USER-AGENT");
+            // IE娴忚鍣�
+            if (StrUtil.contains(userAgent, "MSIE")) {
+                fileName = URLEncoder.encode(fileName, "UTF-8");
+            } else {
+                // google,鐏嫄娴忚鍣�
+                if (StrUtil.contains(userAgent, "Mozilla")) {
+                    fileName = new String(fileName.getBytes(), "ISO8859-1");
+                } else {
+                    // 鍏朵粬娴忚鍣�
+                    fileName = URLEncoder.encode(fileName, "UTF-8");
+                }
+            }
+            response.setContentType("application/x-download");
+            // 璁剧疆璁╂祻瑙堝櫒寮瑰嚭涓嬭浇鎻愮ず妗嗭紝鑰屼笉鏄洿鎺ュ湪娴忚鍣ㄤ腑鎵撳紑
+            response.addHeader("Content-Disposition", "attachment;filename=" + fileName);
+            IoUtil.copy(inputStream, outputStream);
+            return null;
+        } catch (IOException | ObsException e) {
+            return new Result(false);
+        }
+    }
+}
\ No newline at end of file
diff --git a/src/main/java/com/qxueyou/scc/portal/expert/controller/ExpertController.java b/src/main/java/com/qxueyou/scc/portal/expert/controller/ExpertController.java
new file mode 100644
index 0000000..3ed6b75
--- /dev/null
+++ b/src/main/java/com/qxueyou/scc/portal/expert/controller/ExpertController.java
@@ -0,0 +1,71 @@
+package com.qxueyou.scc.portal.expert.controller;
+
+
+import com.qxueyou.scc.base.model.Result;
+import com.qxueyou.scc.portal.expert.service.IExpertService;
+import com.qxueyou.scc.portal.expert.vo.ExpertVO;
+import com.qxueyou.scc.portal.information.service.IInformationService;
+import com.qxueyou.scc.portal.information.vo.ListArticleVO;
+import com.qxueyou.scc.portal.information.vo.SaveArticleVO;
+import com.qxueyou.scc.portal.information.vo.UpdateArticleVO;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiImplicitParam;
+import io.swagger.annotations.ApiOperation;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+/**
+ * 涓撳鎺у埗鍣�
+ *
+ * @author angy
+ * @created by 2021/3/1
+ */
+@RestController
+@RequestMapping("/expert")
+@Api(tags = "涓撳鎺у埗鍣�")
+public class ExpertController {
+
+    @Autowired
+    private IExpertService iExpertService;
+
+
+    @GetMapping("/list")
+    @ApiOperation("鑾峰彇涓撳鍒楄〃")
+    public Result listExpert(@RequestBody ExpertVO vo) {
+        return iExpertService.listExpert(vo);
+    }
+    //
+    @PostMapping("/add")
+    @ApiOperation("鏂板")
+    public Result save(@RequestBody ExpertVO vo) {
+        return iExpertService.save(vo);
+    }
+
+    @DeleteMapping("/delete")
+    @ApiOperation("鍒犻櫎")
+    @ApiImplicitParam(name = "ids", value = "涓撳id", dataType = "string", required = true)
+    public Result delete( String ids) {
+
+        if (StringUtils.isBlank(ids)) {
+            return new Result(false, "id is not blank!");
+        }
+        return iExpertService.delete(ids);
+    }
+    //
+    @PutMapping("/update")
+    @ApiOperation("鏇存柊")
+    public Result update(@RequestBody ExpertVO vo) {
+        return iExpertService.update(vo);
+    }
+    //
+    @GetMapping("/getArticleById")
+    @ApiOperation("鑾峰彇涓撳璇︽儏")
+    @ApiImplicitParam(name = "id", value = "鏂囩珷id", dataType = "string", required = true)
+    public Result getExpertById(  String id) {
+        if (StringUtils.isBlank(id)) {
+            return new Result(false, "id is not blank!");
+        }
+        return iExpertService.getExpertById(id);
+    }
+}
diff --git a/src/main/java/com/qxueyou/scc/portal/expert/model/Expert.java b/src/main/java/com/qxueyou/scc/portal/expert/model/Expert.java
new file mode 100644
index 0000000..50b75c3
--- /dev/null
+++ b/src/main/java/com/qxueyou/scc/portal/expert/model/Expert.java
@@ -0,0 +1,148 @@
+package com.qxueyou.scc.portal.expert.model;
+
+
+//sa_information
+
+
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import org.hibernate.annotations.GenericGenerator;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import javax.persistence.*;
+import java.io.Serializable;
+import java.util.Date;
+
+//@Proxy(lazy = false)
+@Entity
+@Table( name = "sa_expert")
+public class Expert implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    public Expert() {
+
+    }
+
+
+    private  String id;
+    public void setId(String id) {
+        this.id = id;
+    }
+
+    @Id
+    @GeneratedValue(generator = "hibernate-uuid")
+    @GenericGenerator(name = "hibernate-uuid", strategy = "uuid")
+    @Column(name = "ID", unique = true, nullable = false, length = 32)
+    public String getId() {
+        return id;
+    }
+
+    private String nameExpert;
+    private String job;
+    private String domesticUnit;
+    private String dispatchedUnit;
+    private String expertImg;
+    private String personalInformation;
+    private Date createTime;
+    private Date updateTime;
+    private Integer deleteFlag;
+
+
+    public Expert(String id, String nameExpert, String job, String domesticUnit, String dispatchedUnit, String expertImg, Date createTime, Date updateTime, Integer deleteFlag) {
+        this.id = id;
+        this.nameExpert = nameExpert;
+        this.job = job;
+        this.domesticUnit = domesticUnit;
+        this.dispatchedUnit = dispatchedUnit;
+        this.expertImg = expertImg;
+        this.createTime = createTime;
+        this.updateTime = updateTime;
+        this.deleteFlag = deleteFlag;
+    }
+
+    @Column(name = "PERSONAL_INFORMATION", nullable = false)
+    public String getPersonalInformation() {
+        return personalInformation;
+    }
+
+    public void setPersonalInformation(String personalInformation) {
+        this.personalInformation = personalInformation;
+    }
+    @Column(name = "NAME_EXPERT", nullable = false, length = 20)
+    public String getNameExpert() {
+        return nameExpert;
+    }
+
+    public void setNameExpert(String nameExpert) {
+        this.nameExpert = nameExpert;
+    }
+    @Column(name = "JOB", nullable = false, length = 20)
+    public String getJob() {
+        return job;
+    }
+
+    public void setJob(String job) {
+        this.job = job;
+    }
+    @Column(name = "DOMESTIC_UNIT", nullable = false, length = 20)
+    public String getDomesticUnit() {
+        return domesticUnit;
+    }
+
+    public void setDomesticUnit(String domesticUnit) {
+        this.domesticUnit = domesticUnit;
+    }
+
+    @Column(name = "DISPATCHED_UNIT", nullable = false, length = 20)
+    public String getDispatchedUnit() {
+        return dispatchedUnit;
+    }
+
+    public void setDispatchedUnit(String dispatchedUnit) {
+        this.dispatchedUnit = dispatchedUnit;
+    }
+
+    @Column(name = "EXPERT_IMG", nullable = false, length = 50)
+    public String getExpertImg() {
+        return expertImg;
+    }
+
+    public void setExpertImg(String expertImg) {
+        this.expertImg = expertImg;
+    }
+
+    @Column(name = "CREATE_TIME")
+    @Temporal(TemporalType.TIMESTAMP)
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @JsonIgnore
+    public Date getCreateTime() {
+        return createTime;
+    }
+
+
+    public void setCreateTime(Date createTime) {
+        this.createTime = createTime;
+    }
+
+    @Column(name = "UPDATE_TIME")
+    @Temporal(TemporalType.TIMESTAMP)
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @JsonIgnore
+    public Date getUpdateTime() {
+        return updateTime;
+    }
+
+    public void setUpdateTime(Date updateTime) {
+        this.updateTime = updateTime;
+    }
+
+    @Column(name = "DELTE_FLAG" )
+    public Integer getDeleteFlag() {
+        return deleteFlag;
+    }
+    public void setDeleteFlag(Integer deleteFlag) {
+        this.deleteFlag = deleteFlag;
+    }
+
+
+}
diff --git a/src/main/java/com/qxueyou/scc/portal/expert/service/IExpertService.java b/src/main/java/com/qxueyou/scc/portal/expert/service/IExpertService.java
new file mode 100644
index 0000000..124ad76
--- /dev/null
+++ b/src/main/java/com/qxueyou/scc/portal/expert/service/IExpertService.java
@@ -0,0 +1,52 @@
+package com.qxueyou.scc.portal.expert.service;
+
+import com.qxueyou.scc.base.model.Result;
+import com.qxueyou.scc.portal.expert.vo.ExpertVO;
+import com.qxueyou.scc.portal.information.vo.ListArticleVO;
+import com.qxueyou.scc.portal.information.vo.SaveArticleVO;
+import com.qxueyou.scc.portal.information.vo.UpdateArticleVO;
+
+public interface IExpertService {
+
+
+    /**
+     * 鏌ヨ涓撳鍒楄〃
+     */
+
+    Result listExpert(ExpertVO vo);
+
+    /**
+     *鑾峰彇涓撳鎬绘潯鏁�
+     * @param
+     * @return
+     */
+    int findExpertCount(ExpertVO vo) ;
+    /**
+     * 娣诲姞涓撳
+     *
+     * @param vo
+     * @return
+     */
+    Result save(ExpertVO vo);
+    /**
+     * 鍒犻櫎涓撳
+     *
+     * @param ids
+     * @return
+     */
+    Result delete(String ids);
+    /**
+     * 鏇存柊涓撳淇℃伅
+     *
+     * @param vo
+     * @return
+     */
+    Result update(ExpertVO vo);
+    /**
+     * 鑾峰彇涓撳淇℃伅
+     *
+     * @param id
+     * @return
+     */
+    Result getExpertById(String id);
+}
diff --git a/src/main/java/com/qxueyou/scc/portal/expert/service/imp/ExpertService.java b/src/main/java/com/qxueyou/scc/portal/expert/service/imp/ExpertService.java
new file mode 100644
index 0000000..7e15be4
--- /dev/null
+++ b/src/main/java/com/qxueyou/scc/portal/expert/service/imp/ExpertService.java
@@ -0,0 +1,75 @@
+package com.qxueyou.scc.portal.expert.service.imp;
+
+import com.qxueyou.scc.base.model.Pager;
+import com.qxueyou.scc.base.model.Result;
+import com.qxueyou.scc.base.service.impl.CommonAppService;
+import com.qxueyou.scc.base.util.CollectionUtils;
+import com.qxueyou.scc.portal.expert.model.Expert;
+import com.qxueyou.scc.portal.expert.service.IExpertService;
+import com.qxueyou.scc.portal.expert.vo.ExpertVO;
+import com.qxueyou.scc.portal.information.dto.ArticleInfoDTO;
+import com.qxueyou.scc.portal.information.model.Information;
+import com.qxueyou.scc.portal.information.service.IInformationService;
+import org.springframework.beans.BeanUtils;
+import org.springframework.stereotype.Service;
+
+import java.util.Date;
+import java.util.List;
+
+@Service
+public class ExpertService extends CommonAppService implements IExpertService {
+
+
+
+    @Override
+    public Result listExpert(ExpertVO vo) {
+
+        String hql = "from Expert where  deleteFlag=0 and nameExpert like ?  order by createTime desc";
+        int count =findExpertCount( vo);//涓撳鎬绘潯鏁�
+        List<Expert> list = findList(hql, new Pager(vo.getSize(), vo.getPage()), CollectionUtils.newList(vo.getKeyword().concat("%")), Expert.class);
+        return  new Result(true,"success", CollectionUtils.newObjectMap("list", list, "count", count));
+    }
+
+    @Override
+    public int findExpertCount(ExpertVO vo) {
+        String hql = "from Expert where  deleteFlag=0 and nameExpert like :nameExpert";
+        return findCountByComplexHql(hql, CollectionUtils.newObjectMap("nameExpert",vo.getKeyword().concat("%")));
+    }
+
+    @Override
+    public Result save(ExpertVO vo) {
+        Expert expert = new Expert();
+        BeanUtils.copyProperties(vo, expert);
+        expert.setDeleteFlag(0);
+        expert.setCreateTime(new Date());
+        expert.setUpdateTime(new Date());
+        save(expert);
+        return Result.SUCCESS;
+    }
+
+    @Override
+    public Result delete(String ids) {
+
+        Result result = new Result(true);
+        String[] arrStr = ids.split(",");
+        if (arrStr != null && arrStr.length > 0) {
+            String hql = "update Expert set deleteFlag = 1 where Id=?";
+            result = bulkUpdateInLoop(hql, arrStr);
+        }
+        return result;
+    }
+
+    @Override
+    public Result update(ExpertVO vo) {
+        Expert expert = read(Expert.class, vo.getId());
+        BeanUtils.copyProperties(vo, expert);
+        save(expert);
+        return Result.SUCCESS;
+    }
+
+    @Override
+    public Result getExpertById(String id) {
+        Expert expert = read(Expert.class, id);
+        return new Result(true, "expertDTO",expert);
+    }
+}
diff --git a/src/main/java/com/qxueyou/scc/portal/expert/vo/ExpertVO.java b/src/main/java/com/qxueyou/scc/portal/expert/vo/ExpertVO.java
new file mode 100644
index 0000000..3fcfc13
--- /dev/null
+++ b/src/main/java/com/qxueyou/scc/portal/expert/vo/ExpertVO.java
@@ -0,0 +1,124 @@
+package com.qxueyou.scc.portal.expert.vo;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import org.hibernate.validator.constraints.NotBlank;
+
+import javax.validation.constraints.NotNull;
+
+/**
+ * @author angy
+ * @created by 2021/3/1
+ */
+@ApiModel("ExpertVO")
+public class ExpertVO {
+    @NotBlank(message = "涓撳ID涓嶈兘涓虹┖锛�")
+    @ApiModelProperty(name = "id", value = "涓撳Id", dataType = "string", required = true)
+    private String id;
+
+    public String getId() {
+        return id;
+    }
+
+    public void setId(String id) {
+        this.id = id;
+    }
+
+    //椤电爜
+    @NotNull(message = "椤电爜涓嶈兘涓虹┖锛�")
+    @ApiModelProperty(value = "椤电爜", name = "page", dataType = "integer", required = true)
+    private Integer page;
+
+    //椤垫暟
+    @NotNull(message = "椤垫暟涓嶈兘涓虹┖锛�")
+    @ApiModelProperty(value = "椤垫暟", name = "size", dataType = "integer", required = true)
+    private Integer size;
+
+    //鍏抽敭瀛�
+    @ApiModelProperty(value = "鎼滅储鍏抽敭瀛�", name = "keyword", dataType = "string")
+    private String keyword;
+    @ApiModelProperty(value = "涓撳鍚嶇О", name = "nameExpert", dataType = "string")
+    private String nameExpert;
+    @ApiModelProperty(value = "鑱屽姟", name = "job", dataType = "string")
+    private String job;
+    @ApiModelProperty(value = "鍥藉唴鍗曚綅", name = "domesticUnit", dataType = "string")
+    private String domesticUnit;
+    @ApiModelProperty(value = "澶栨淳鍗曚綅", name = "dispatchedUnit", dataType = "string")
+    private String dispatchedUnit;
+    @ApiModelProperty(value = "涓撳鐓х墖", name = "expertImg", dataType = "string")
+    private String expertImg;
+    @ApiModelProperty(value = "涓汉绠�浠�", name = "personalInformation", dataType = "string")
+    private String personalInformation;
+
+    public Integer getPage() {
+        return page;
+    }
+
+    public void setPage(Integer page) {
+        this.page = page;
+    }
+
+    public Integer getSize() {
+        return size;
+    }
+
+    public void setSize(Integer size) {
+        this.size = size;
+    }
+
+    public String getKeyword() {
+        return keyword;
+    }
+
+    public void setKeyword(String keyword) {
+        this.keyword = keyword;
+    }
+
+    public String getNameExpert() {
+        return nameExpert;
+    }
+
+    public void setNameExpert(String nameExpert) {
+        this.nameExpert = nameExpert;
+    }
+
+    public String getJob() {
+        return job;
+    }
+
+    public void setJob(String job) {
+        this.job = job;
+    }
+
+    public String getDomesticUnit() {
+        return domesticUnit;
+    }
+
+    public void setDomesticUnit(String domesticUnit) {
+        this.domesticUnit = domesticUnit;
+    }
+
+    public String getDispatchedUnit() {
+        return dispatchedUnit;
+    }
+
+    public void setDispatchedUnit(String dispatchedUnit) {
+        this.dispatchedUnit = dispatchedUnit;
+    }
+
+    public String getExpertImg() {
+        return expertImg;
+    }
+
+    public void setExpertImg(String expertImg) {
+        this.expertImg = expertImg;
+    }
+
+    public String getPersonalInformation() {
+        return personalInformation;
+    }
+
+    public void setPersonalInformation(String personalInformation) {
+        this.personalInformation = personalInformation;
+    }
+}
diff --git a/src/main/java/com/qxueyou/scc/portal/homepage/controller/HomepageController.java b/src/main/java/com/qxueyou/scc/portal/homepage/controller/HomepageController.java
new file mode 100644
index 0000000..cb69dc3
--- /dev/null
+++ b/src/main/java/com/qxueyou/scc/portal/homepage/controller/HomepageController.java
@@ -0,0 +1,63 @@
+package com.qxueyou.scc.portal.homepage.controller;
+
+//import com.qxueyou.appraisal.web.homepage.serivce.IHomepageService;
+//import com.qxueyou.model.Result;
+import com.qxueyou.scc.base.model.Result;
+import com.qxueyou.scc.portal.homepage.serivce.IHomepageService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+/**
+ * @author ZERO 2021-03-03 09:06
+ */
+@RestController
+@RequestMapping("/homepage")
+@Api(tags = "棣栭〉鐩稿叧鎺ュ彛")
+public class HomepageController {
+
+    @Autowired
+    private IHomepageService homepageService;
+
+    @GetMapping(value = "/tab",produces = "application/json;charset=utf-8")
+    @ApiOperation("鑾峰彇鏍囩")
+    public Result getTabs() {
+
+        return new Result(true, "tab",homepageService.getTabs());
+    }
+
+//    @GetMapping
+//    @ApiOperation("鑾峰彇鍒楄〃")
+//    public Result getIndexDetail() {
+////        System.err.println("=====>鑾峰彇鍒楄〃");
+//        return new Result(true,"", homepageService.getIndexDetail());
+//    }
+
+    @GetMapping("/article")
+    @ApiOperation("鑾峰彇鏂囩珷鍒楄〃")
+    public Result getArticle(String type, String subColumn, String numbers, int page, int size, String keyword) {
+        System.err.println("=====>鑾峰彇鏂囩珷鍒楄〃");
+        return new Result(true, "article",homepageService.getArticle(type, subColumn, numbers, page, size, keyword));
+    }
+
+    @GetMapping("/article/detail")
+    @ApiOperation("鑾峰彇鏂囩珷璇︽儏")
+    public Result getArticleDetail(String id) {
+
+        return new Result(true,"detail", homepageService.getArticleDetail(id));
+    }
+
+    @GetMapping("/getArticle")
+    @ApiOperation("鑾峰彇鏂囩珷")
+    public Result getGetArticle(String type, String subColumn) {
+        return new Result(true,"getArticle", homepageService.getArticlesType(type, subColumn));
+    }
+
+    @GetMapping("/video")
+    public Result getVideo(String type, String subColumn, int page, int size) {
+        return new Result(true, "video",homepageService.getVideo(type, subColumn, page, size));
+    }
+}
diff --git a/src/main/java/com/qxueyou/scc/portal/homepage/dao/ArticleDao.java b/src/main/java/com/qxueyou/scc/portal/homepage/dao/ArticleDao.java
new file mode 100644
index 0000000..9c549a5
--- /dev/null
+++ b/src/main/java/com/qxueyou/scc/portal/homepage/dao/ArticleDao.java
@@ -0,0 +1,193 @@
+package com.qxueyou.scc.portal.homepage.dao;
+
+//import com.qxueyou.entity.article.ArticleDO;
+//import com.qxueyou.service.MongoService;
+//import com.qxueyou.util.CollectionUtils;
+import com.qxueyou.scc.base.dao.BaseDAO;
+import com.qxueyou.scc.base.model.Pager;
+import com.qxueyou.scc.base.util.ClientUtils;
+import com.qxueyou.scc.base.util.CollectionUtils;
+import com.qxueyou.scc.portal.information.model.Information;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.domain.PageRequest;
+import org.springframework.data.domain.Sort;
+//import org.springframework.data.mongodb.core.query.Criteria;
+//import org.springframework.data.mongodb.core.query.Query;
+//import org.springframework.data.mongodb.core.query.Update;
+import org.springframework.stereotype.Repository;
+
+import javax.annotation.PostConstruct;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+
+/**
+ * @author ZERO 2021-03-03 16:36
+ */
+@Repository
+public class ArticleDao  extends BaseDAO {
+
+
+
+
+
+    public Map<String, Object> moreOccupation(String type, String subColumn, String numbers,int page, int size, String keyword) {
+
+        StringBuffer hql = new StringBuffer(500);
+         hql.append( "from Information where  deleteFlag=0 and type = ? and status= ?");
+        List<Object> params = CollectionUtils.newList(type, Information.UP_STATUS);
+
+       // Map<String, Object> condition = CollectionUtils.newObjectMap("type", type, "status", Information.UP_STATUS);
+        if(StringUtils.isNotEmpty(keyword)){
+            hql.append( " and title = ? ");
+            params.add(keyword);
+        }
+        if (type.equals("examBriefing")) {
+            hql.append( "and subColumn = ? ");
+            params.add( subColumn);
+        }
+//        if(subColumn!=null) {
+//            if (subColumn.equals("previousContest")) {
+//                condition.put("numbers", numbers);
+//            }
+//        }
+
+
+        long totalCount = findCount(hql.toString(),params);
+        hql.append( "order by dateTime desc");
+
+        List<Information> articleList = findList(hql.toString(),new Pager(page,size),params,Information.class);
+
+
+        List<Map<String, Object>> data = articleList
+                .stream()
+                .map(article -> CollectionUtils.newObjectMap(
+                        "id", article.getId(),
+                        "content", article.getContent(),
+                        "title", article.getTitle(),
+                        "attachment", article.getAttachment(),
+                        "browseCount", article.getBrowseCount(),
+                        "status", article.getStatus(),
+                        "thumbnailUrl", article.getThumbnailUrl(),
+                        "type", article.getType(),
+                        "dateTime", article.getDateTime(),
+                        "competition",article.getCompetition()))
+                .collect(Collectors.toList());
+
+        return CollectionUtils.newObjectMap("totalCount", totalCount, "data", data);
+    }
+
+    public Map<String, Object> getVideoList(String type, String subColumn,int page, int size){
+        StringBuffer hql = new StringBuffer(500);
+        hql.append( "from Information where  deleteFlag=0 and type = ? and status= ?  ");
+        List<Object> params = CollectionUtils.newList(type, Information.UP_STATUS);
+//        Map<String, Object> condition = CollectionUtils.newObjectMap("type", type, "status", Information.UP_STATUS);
+
+        if (type.equals("examBriefing")) {
+            hql.append( "and subColumn = ? ");
+            params.add( subColumn);
+        }
+        long totalCount = findCount(hql.toString(),params);
+        hql.append( "order by dateTime desc");
+
+
+        List<Information> articleList =findList(hql.toString(),new Pager(page,size),params,Information.class);
+        List<Map<String, Object>> data = articleList
+                .stream()
+                .map(article -> CollectionUtils.newObjectMap(
+                        "title", article.getTitle(),
+                        "type", article.getType(),
+                        "dateTime", article.getDateTime(),
+                        "videoUrl",article.getVideoUrl(),
+                        "name",article.getNumbers()))
+                .collect(Collectors.toList());
+
+        return CollectionUtils.newObjectMap("totalCount", totalCount, "data", data);
+    }
+//
+    public boolean exist(String type) {
+        String hql= "from Information where  deleteFlag=0 and type = ? and status= ? ";
+        long totalCount = findCount(hql,CollectionUtils.newList(type, Information.UP_STATUS));
+        return totalCount>0?true:false;
+    }
+//
+    public boolean existsubColumn(String type, String subColumn) {
+
+
+        String hql= "from Information where  deleteFlag=0 and type = ? and status= ? and subColumn=?";
+        long totalCount = findCount(hql,CollectionUtils.newList(type, Information.UP_STATUS,subColumn));
+        return totalCount>0?true:false;
+    }
+
+    public Map<String, Object> getPreAndBehindArticle(String currentArticleId, String type) {
+        StringBuffer hql = new StringBuffer(500);
+        hql.append("from Information where  deleteFlag=0 and type = ? and status= ?  order by updateTime desc");
+        List<Object> params = CollectionUtils.newList(type, Information.UP_STATUS);
+//        Query query = Query.query(Criteria.where("type").is(type)
+//                .and("status").is(ArticleDO.UP_STATUS)
+//                .and("deleteFlag").is(false))
+//                .with(Sort.by(Sort.Direction.DESC, "updateTime"));
+//        query.fields().include("id");
+//        List<Information> articleList =find(hql.toString(),params,Information.class);
+        List<String> articleIdList = find(hql.toString(),params,Information.class)
+                .stream()
+                .map(Information::getId)
+                .collect(Collectors.toList());
+
+        int currentIndex = articleIdList.indexOf(currentArticleId);
+
+        Map<String, Object> data = CollectionUtils.newObjectMap("previous", null, "behind", null);
+
+        if (currentIndex != 0) {
+            Information preArticle = read(Information.class,articleIdList.get(currentIndex - 1));
+            data.put("previous", CollectionUtils.newObjectMap(
+                    "id", preArticle.getId(),
+                    "title", preArticle.getTitle(),
+                    "type", preArticle.getType()));
+        }
+
+        if (currentIndex != articleIdList.size() - 1) {
+            Information behindArticle = read(Information.class,articleIdList.get(currentIndex + 1));
+            data.put("previous", CollectionUtils.newObjectMap(
+                    "id", behindArticle.getId(),
+                    "title", behindArticle.getTitle(),
+                    "type", behindArticle.getType()));
+        }
+
+        return data;
+    }
+//
+    public void incBrowseCount(String id) {
+//        Query query = Query.query(Criteria.where("id").is(id));
+//        Update update = new Update();
+//        update.inc("browseCount", 1);
+//        template.updateFirst(query, update, clz);
+        Information behindArticle = read(Information.class,id);
+        behindArticle.setBrowseCount(behindArticle.getBrowseCount()+1);
+        saveOrUpdate(behindArticle);
+    }
+
+    public Information getArticle(String type,String subColumn)
+    {
+        StringBuffer hql = new StringBuffer(500);
+        hql.append( "from Information where  deleteFlag=0 and type = ? and status= ?  order by updateTime desc");
+        List<Object> params = CollectionUtils.newList(type, Information.UP_STATUS);
+
+        if (type.equals("examBriefing")) {
+            hql.append( "and subColumn = ? ");
+            params.add( subColumn);
+        }
+//        Query query = Query.query(Criteria.where("type").is(type)
+//                .and("status").is(ArticleDO.UP_STATUS)
+//                .and("deleteFlag").is(false))
+//                .with(Sort.by(Sort.Direction.DESC, "updateTime"));
+//        System.out.println(type);
+//        if (type.equals("examBriefing")) {
+//            query.addCriteria(Criteria.where("subColumn").is(subColumn));
+//        }
+        Information articleDO = findUnique(hql.toString(), params, Information.class);
+//        ArticleDO articleDO =findOne(query,ArticleDO.class);
+        return articleDO;
+    }
+}
diff --git a/src/main/java/com/qxueyou/scc/portal/homepage/serivce/IHomepageService.java b/src/main/java/com/qxueyou/scc/portal/homepage/serivce/IHomepageService.java
new file mode 100644
index 0000000..f2598b8
--- /dev/null
+++ b/src/main/java/com/qxueyou/scc/portal/homepage/serivce/IHomepageService.java
@@ -0,0 +1,34 @@
+package com.qxueyou.scc.portal.homepage.serivce;
+
+import com.qxueyou.scc.portal.information.model.Information;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @author ZERO 2021-03-03 09:16
+ */
+public interface IHomepageService {
+
+    /**
+     * 鑾峰彇棣栭〉鏁版嵁
+//     */
+//    Map<String, Object> getIndexDetail();
+
+    /**
+     * 鑾峰彇棣栭〉鏍囩
+     */
+    List<Map<String, Object>> getTabs();
+
+    /**
+     * 鑾峰彇鏂囩珷鍒楄〃
+     */
+    Map<String, Object> getArticle(String type,String subColumn,String numbers, int page, int size, String keyword);
+
+    Map<String, Object> getArticleDetail(String id);
+
+    Information getArticlesType(String type, String subColumn);
+
+    Map<String,Object> getVideo(String type,String subColumn,int page, int size);
+
+}
diff --git a/src/main/java/com/qxueyou/scc/portal/homepage/serivce/imp/HomepageService.java b/src/main/java/com/qxueyou/scc/portal/homepage/serivce/imp/HomepageService.java
new file mode 100644
index 0000000..7b06e0a
--- /dev/null
+++ b/src/main/java/com/qxueyou/scc/portal/homepage/serivce/imp/HomepageService.java
@@ -0,0 +1,140 @@
+package com.qxueyou.scc.portal.homepage.serivce.imp;
+
+//import com.qxueyou.appraisal.web.homepage.dao.AppraisalBatchDao;
+
+//import com.qxueyou.appraisal.web.homepage.dao.ArticleDao;
+//import com.qxueyou.appraisal.web.homepage.dao.ContestsBatchDao;
+//import com.qxueyou.appraisal.web.homepage.dao.OccupationDao;
+//import com.qxueyou.appraisal.web.homepage.serivce.IHomepageService;
+//import com.qxueyou.entity.article.ArticleDO;
+//import com.qxueyou.util.CollectionUtils;
+import com.qxueyou.scc.base.util.CollectionUtils;
+import com.qxueyou.scc.portal.homepage.dao.ArticleDao;
+import com.qxueyou.scc.portal.homepage.serivce.IHomepageService;
+import com.qxueyou.scc.portal.information.model.Information;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.domain.Sort;
+import org.springframework.stereotype.Service;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @author ZERO 2021-03-03 09:16
+ */
+@Service
+public class HomepageService implements IHomepageService {
+
+    @Autowired
+    private ArticleDao articleDao;
+
+//    @Autowired
+//    private AppraisalBatchDao batchDao;
+
+//    @Autowired
+//    private ContestsBatchDao batchDao;
+
+//    @Autowired
+//    private OccupationDao occupationDao;
+
+    /**
+     * 鑾峰彇棣栭〉鏁版嵁
+     */
+//    @Override
+//    public Map<String, Object> getIndexDetail() {
+////        System.err.println("================>鑾峰彇棣栭〉鏁版嵁");
+//        return CollectionUtils.newObjectMap(
+//                "appraisalBatchInfo", batchDao.findBatches(1, 24, null).get("data"), // createTime  browseCount dateTime
+//                "occupationInfo", articleDao.findPage(CollectionUtils.newObjectMap("type", "qualifiedSet", "status", ArticleDO.UP_STATUS), 1, 8, "dateTime", Sort.Direction.DESC).get("data"),
+//                "news", articleDao.findPage(CollectionUtils.newObjectMap("type", "policiesRegulations", "status", ArticleDO.UP_STATUS), 1, 8, "dateTime", Sort.Direction.DESC).get("data"));
+//    }
+
+
+    /**
+     * 鑾峰彇棣栭〉鏍囩
+     */
+    @Override
+    public List<Map<String, Object>> getTabs() {
+
+        boolean exist;
+        List<Map<String, Object>> tabs = new ArrayList<>();
+
+        List<Map<String,String>> sub=new ArrayList<>();
+
+
+        exist = articleDao.exist("examBriefing");
+        if (exist) tabs.add(CollectionUtils.newObjectMap("name", "濯掍綋鑱氱劍", "type", "examBriefing","list",sub));
+
+        exist = articleDao.exist("qualifiedSet");
+        if (exist) tabs.add(CollectionUtils.newObjectMap("name", "鍗庢暀鏂伴矞浜�", "type", "qualifiedSet"));
+
+        exist = articleDao.exist("policiesRegulations");
+        if (exist) tabs.add(CollectionUtils.newObjectMap("name", "鏂伴椈涓績", "type", "policiesRegulations"));
+
+        exist = articleDao.exist("examinationGuide");
+        if (exist) tabs.add(CollectionUtils.newObjectMap("name", "涓撳椋庨噰", "type", "examinationGuide"));
+
+        exist = articleDao.exist("popularInformation");
+        if (exist) tabs.add(CollectionUtils.newObjectMap("name", "鑱旂郴鎴戜滑", "type", "popularInformation"));
+
+        exist =articleDao.existsubColumn("examBriefing","introduce");
+        if(exist) sub.add(CollectionUtils.newStringMap("name", "娴峰璧勮", "subColumn", "introduce") );
+
+        exist =articleDao.existsubColumn("examBriefing","contestFile");
+        if(exist) sub.add(CollectionUtils.newStringMap("name", "娴峰璧勮", "subColumn", "contestFile"));
+
+        exist =articleDao.existsubColumn("examBriefing","previousContest");
+        if(exist) sub.add(CollectionUtils.newStringMap("name", "寰�灞婂ぇ璧�", "subColumn", "previousContest"));
+
+        return tabs;
+    }
+
+    /**
+     * 鑾峰彇鏂囩珷鍒楄〃
+     */
+    @Override
+    public Map<String, Object> getArticle(String type,String subColumn,String numbers,int page, int size, String keyword) {
+        return articleDao.moreOccupation(type,subColumn,numbers,page, size, keyword);
+    }
+
+
+    /**
+     * @param id
+     * @return
+     */
+
+    @Override
+    public Map<String, Object> getArticleDetail(String id) {
+
+        //inc娴忚鏁�
+        articleDao.incBrowseCount(id);
+
+        Information article = articleDao.read(Information.class,id);
+
+        Map<String, Object> data = CollectionUtils.newObjectMap(
+                "title", article.getTitle(),
+                "dateTime", article.getDateTime(),
+                "browseCount", article.getBrowseCount(),
+                "content", article.getContent(),
+                "attachment", article.getAttachment());
+
+        Map<String, Object> preAndBehindArticle = articleDao.getPreAndBehindArticle(id, article.getType());
+
+
+        data.putAll(preAndBehindArticle);
+
+        return data;
+    }
+
+    public Information getArticlesType(String type,String subColumn) {
+        Information articleDO=articleDao.getArticle(type,subColumn);
+        return articleDO;
+    }
+
+    @Override
+    public Map<String, Object> getVideo(String type, String subColumn, int page, int size) {
+        return articleDao.getVideoList(type,subColumn,page, size);
+    }
+}
diff --git a/src/main/java/com/qxueyou/scc/teach/res/service/HweiYunOBSService.java b/src/main/java/com/qxueyou/scc/teach/res/service/HweiYunOBSService.java
new file mode 100644
index 0000000..0b83fa3
--- /dev/null
+++ b/src/main/java/com/qxueyou/scc/teach/res/service/HweiYunOBSService.java
@@ -0,0 +1,52 @@
+package com.qxueyou.scc.teach.res.service;
+ 
+import org.springframework.web.multipart.MultipartFile;
+ 
+import java.io.InputStream;
+import java.util.List;
+ 
+/**
+ * @Description 鍗庝负浜慜BS鏈嶅姟鎺ュ彛
+ * @author wuhuiju
+ * @date 2022/12/2 17:01
+ */
+public interface HweiYunOBSService {
+ 
+    /**
+     * @Description 鍒犻櫎鏂囦欢
+     * @author wuhuiju
+     * @date 2022/12/2 17:02
+     * @param: objectKey 鏂囦欢鍚�
+     * @return: boolean 鎵ц缁撴灉
+     */
+    boolean delete(String objectKey);
+ 
+    /**
+     * @Description 鎵归噺鍒犻櫎鏂囦欢
+     * @author wuhuiju
+     * @date 2022/12/2 17:02
+     * @param: objectKeys 鏂囦欢鍚嶉泦鍚�
+     * @return: boolean 鎵ц缁撴灉
+     */
+    boolean delete(List<String> objectKeys);
+ 
+    /**
+     * @Description 涓婁紶鏂囦欢
+     * @author wuhuiju
+     * @date 2022/12/2 17:03
+     * @param: uploadFile 涓婁紶鏂囦欢
+     * @param: objectKey 鏂囦欢鍚嶇О
+     * @return: java.lang.String url璁块棶璺緞
+     */
+    String fileUpload(MultipartFile uploadFile, String objectKey);
+ 
+    /**
+     * @Description 鏂囦欢涓嬭浇
+     * @author wuhuiju
+     * @date 2022/12/2 17:04
+     * @param: objectKey
+     * @return: java.io.InputStream
+     */
+    InputStream fileDownload(String objectKey);
+}
+ 
\ No newline at end of file
diff --git a/src/main/java/com/qxueyou/scc/teach/res/service/impl/HweiYunOBSServiceImpl.java b/src/main/java/com/qxueyou/scc/teach/res/service/impl/HweiYunOBSServiceImpl.java
new file mode 100644
index 0000000..9f3ab60
--- /dev/null
+++ b/src/main/java/com/qxueyou/scc/teach/res/service/impl/HweiYunOBSServiceImpl.java
@@ -0,0 +1,185 @@
+package com.qxueyou.scc.teach.res.service.impl;
+ 
+//import com.example.study.springboot.background.service.HweiYunOBSService;
+//import com.example.study.springboot.config.HweiOBSConfig;
+import com.obs.services.ObsClient;
+import com.obs.services.exception.ObsException;
+import com.obs.services.model.*;
+import com.qxueyou.scc.base.util.CollectionUtils;
+import com.qxueyou.scc.base.util.QFileUtils;
+import com.qxueyou.scc.base.util.UUIDUtils;
+import com.qxueyou.scc.config.HweiOBSConfig;
+import com.qxueyou.scc.teach.res.service.HweiYunOBSService;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.web.multipart.MultipartFile;
+ 
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Calendar;
+import java.util.GregorianCalendar;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @ClassName: HweiYunOBSServiceImpl
+ * @Description: 鍗庝负浜慜BS鏈嶅姟涓氬姟灞�
+ * @Author: wuhuiju
+ * @Date: 2021-12-21 17:05
+ * @Version: 1.0
+ */
+@Slf4j
+@Service
+public class HweiYunOBSServiceImpl implements HweiYunOBSService {
+
+    private final Logger log = LogManager.getLogger(HweiYunOBSServiceImpl.class);
+    @Autowired
+    private HweiOBSConfig hweiOBSConfig;
+
+    public final static String FILE_TYPE_VIDEO = "video";
+
+    public final static String FILE_TYPE_DOC = "doc";
+
+    public final static String FILE_TYPE_AUDIO = "audio";
+
+    public final static String FILE_TYPE_DATA = "data";
+
+    public final static String FILE_TYPE_IMG = "img";
+
+    private static final Map<String, String> fileFormatMap = CollectionUtils.newStringMap("MPEG", FILE_TYPE_VIDEO,
+            "AVI", FILE_TYPE_VIDEO, "MOV", FILE_TYPE_VIDEO, "ASF", FILE_TYPE_VIDEO, "WMV", FILE_TYPE_VIDEO, "NAVI",
+            FILE_TYPE_VIDEO, "3GP", FILE_TYPE_VIDEO, "RAM", FILE_TYPE_VIDEO, "RA", FILE_TYPE_VIDEO, "MKV",
+            FILE_TYPE_VIDEO, "F4V", FILE_TYPE_VIDEO, "RMVB", FILE_TYPE_VIDEO, "MP4", FILE_TYPE_VIDEO,
+
+            "DOC", FILE_TYPE_DOC, "DOCX", FILE_TYPE_DOC, "PDF", FILE_TYPE_DOC, "PPT", FILE_TYPE_DOC, "PPTX",
+            FILE_TYPE_DOC, "XLS", FILE_TYPE_DOC, "XLSX", FILE_TYPE_DOC,
+
+            "MP3", FILE_TYPE_AUDIO, "WMA", FILE_TYPE_AUDIO, "WAV", FILE_TYPE_AUDIO,
+
+            "DATA", FILE_TYPE_DATA,
+
+            "JPG", FILE_TYPE_IMG,"JPEG", FILE_TYPE_IMG, "GIF", FILE_TYPE_IMG, "BMP", FILE_TYPE_IMG, "PNG", FILE_TYPE_IMG
+
+    );
+ 
+    @Override
+    public boolean delete(String objectKey) {
+        ObsClient obsClient = null;
+        try {
+            // 鍒涘缓ObsClient瀹炰緥
+            obsClient = hweiOBSConfig.getInstance();
+            // obs鍒犻櫎
+            obsClient.deleteObject(hweiOBSConfig.getBucketName(),objectKey);
+        } catch (ObsException e) {
+            log.error("obs鍒犻櫎淇濆瓨澶辫触", e);
+        } finally {
+            hweiOBSConfig.destroy(obsClient);
+        }
+        return true;
+    }
+ 
+    @Override
+    public boolean delete(List<String> objectKeys) {
+        ObsClient obsClient = null;
+        try {
+            obsClient = hweiOBSConfig.getInstance();
+            DeleteObjectsRequest deleteObjectsRequest = new DeleteObjectsRequest(hweiOBSConfig.getBucketName());
+            objectKeys.forEach(x -> deleteObjectsRequest.addKeyAndVersion(x));
+            // 鎵归噺鍒犻櫎璇锋眰
+            obsClient.deleteObjects(deleteObjectsRequest);
+            return true;
+        } catch (ObsException e) {
+            log.error("obs鍒犻櫎淇濆瓨澶辫触", e);
+        } finally {
+            hweiOBSConfig.destroy(obsClient);
+        }
+        return false;
+    }
+ 
+    @Override
+    public String fileUpload(MultipartFile uploadFile, String objectKey) {
+        ObsClient obsClient = null;
+        try {
+            String destPath = getDestPath(objectKey);
+            String bucketName = hweiOBSConfig.getBucketName();
+            obsClient = hweiOBSConfig.getInstance();
+
+            // 鍒ゆ柇妗舵槸鍚﹀瓨鍦�
+            boolean exists = obsClient.headBucket(bucketName);
+
+            if(!exists){
+                // 鑻ヤ笉瀛樺湪锛屽垯鍒涘缓妗�
+                HeaderResponse response = obsClient.createBucket(bucketName);
+                log.info("鍒涘缓妗舵垚鍔�" + response.getRequestId());
+            }
+            InputStream inputStream = uploadFile.getInputStream();
+            long available = inputStream.available();
+//            PutObjectRequest request = new PutObjectRequest(bucketName,objectKey,inputStream);
+            PutObjectRequest request = new PutObjectRequest(bucketName,destPath,inputStream);
+            ObjectMetadata objectMetadata = new ObjectMetadata();
+            objectMetadata.setContentLength(available);
+            request.setMetadata(objectMetadata);
+//            request.
+            // 璁剧疆瀵硅薄璁块棶鏉冮檺涓哄叕鍏辫
+            request.setAcl(AccessControlList.REST_CANNED_PUBLIC_READ);
+            PutObjectResult result = obsClient.putObject(request);
+ 
+            // 璇诲彇璇ュ凡涓婁紶瀵硅薄鐨刄RL
+            log.info("宸蹭笂浼犲璞$殑URL" + result.getObjectUrl());
+            return result.getObjectUrl();
+        } catch (ObsException e) {
+            log.error("obs涓婁紶澶辫触", e);
+        } catch (IOException e) {
+            log.error("涓婁紶澶辫触", e);
+        } finally {
+            hweiOBSConfig.destroy(obsClient);
+        }
+        return null;
+    }
+
+    private String getDestPath(String name) {
+        String fileType = getFileType(name);
+
+        StringBuffer path = new StringBuffer(128);
+        path.append(fileType);
+
+        Calendar now = new GregorianCalendar();
+
+        path.append('/');
+        path.append(now.get(Calendar.YEAR));
+        path.append(StringUtils.leftPad(String.valueOf(now.get(Calendar.MONTH)), 2, '0'));
+        path.append('/');
+        path.append(now.get(Calendar.DAY_OF_MONTH));
+        path.append('/');
+        path.append(UUIDUtils.UUID());
+        path.append('.');
+        path.append(QFileUtils.getFileFormat(name));
+
+        return path.toString();
+
+    }
+    private String getFileType(String name) {
+        String fileType = fileFormatMap.get(QFileUtils.getFileFormat(name));
+        return StringUtils.isEmpty(fileType) ? FILE_TYPE_DATA : fileType;
+    }
+
+    @Override
+    public InputStream fileDownload(String objectKey) {
+        ObsClient obsClient = null;
+        try {
+            String bucketName = hweiOBSConfig.getBucketName();
+            obsClient = hweiOBSConfig.getInstance();
+            ObsObject obsObject = obsClient.getObject(bucketName, objectKey);
+            return obsObject.getObjectContent();
+        } catch (ObsException e) {
+            log.error("obs鏂囦欢涓嬭浇澶辫触", e);
+        } finally {
+            hweiOBSConfig.destroy(obsClient);
+        }
+        return null;
+    }
+}
\ No newline at end of file

--
Gitblit v1.8.0