From 1608c32e1d46dc7465c7628c4fe765ebdd26bd12 Mon Sep 17 00:00:00 2001
From: liuhaonan <konodioda2333@vip.qq.com>
Date: 星期四, 13 一月 2022 17:08:41 +0800
Subject: [PATCH] 功能完善

---
 dao/src/main/java/com/sandu/ximon/dao/domain/LedSFile.java                         |   71 ++++++++++++++
 dao/src/main/resources/mapper/LedSFileMapper.xml                                   |   26 +++++
 dao/src/main/java/com/sandu/ximon/dao/mapper/LedSFileMapper.java                   |   17 +++
 ximon-admin/src/main/java/com/sandu/ximon/admin/service/LedSFileService.java       |   61 ++++++++++++
 sandu-common/src/main/java/com/sandu/common/file/impl/AliOssFileServiceImpl.java   |   13 +-
 ximon-admin/src/main/java/com/sandu/ximon/admin/controller/LedSFileController.java |   55 +++++++++++
 6 files changed, 237 insertions(+), 6 deletions(-)

diff --git a/dao/src/main/java/com/sandu/ximon/dao/domain/LedSFile.java b/dao/src/main/java/com/sandu/ximon/dao/domain/LedSFile.java
new file mode 100644
index 0000000..183ea2a
--- /dev/null
+++ b/dao/src/main/java/com/sandu/ximon/dao/domain/LedSFile.java
@@ -0,0 +1,71 @@
+package com.sandu.ximon.dao.domain;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import java.io.Serializable;
+import java.time.LocalDateTime;
+import lombok.Data;
+
+/**
+ * led鐔欒鏂囦欢琛�
+ * @TableName led_s_file
+ */
+@TableName(value ="led_s_file")
+@Data
+public class LedSFile implements Serializable {
+    /**
+     * 
+     */
+    @TableId(type = IdType.AUTO)
+    private Long fileId;
+
+    /**
+     * 瀹㈡埛ID
+     */
+    private Long cilentId;
+
+    /**
+     * 涓婁紶浜哄鍚�
+     */
+    private String userName;
+
+    /**
+     * 鏂囦欢鍚嶇О
+     */
+    private String originname;
+
+    /**
+     * 鏂囦欢url
+     */
+    private String fileUrl;
+
+    /**
+     * 鏂囦欢绫诲瀷
+     */
+    private String fileType;
+
+    /**
+     * 鏂囦欢澶у皬
+     */
+    private Long fileSize;
+
+    /**
+     * 鍥剧墖楂樺害
+     */
+    private Integer height;
+
+    /**
+     * 鍥剧墖瀹藉害
+     */
+    private Integer width;
+
+    /**
+     * 
+     */
+    private LocalDateTime createTime;
+
+    @TableField(exist = false)
+    private static final long serialVersionUID = 1L;
+}
\ No newline at end of file
diff --git a/dao/src/main/java/com/sandu/ximon/dao/mapper/LedSFileMapper.java b/dao/src/main/java/com/sandu/ximon/dao/mapper/LedSFileMapper.java
new file mode 100644
index 0000000..f79d979
--- /dev/null
+++ b/dao/src/main/java/com/sandu/ximon/dao/mapper/LedSFileMapper.java
@@ -0,0 +1,17 @@
+package com.sandu.ximon.dao.mapper;
+
+import com.sandu.ximon.dao.domain.LedSFile;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Mapper;
+
+/**
+ * @Entity com.sandu.ximon.dao.domain.LedSFile
+ */
+@Mapper
+public interface LedSFileMapper extends BaseMapper<LedSFile> {
+
+}
+
+
+
+
diff --git a/dao/src/main/resources/mapper/LedSFileMapper.xml b/dao/src/main/resources/mapper/LedSFileMapper.xml
new file mode 100644
index 0000000..2e10592
--- /dev/null
+++ b/dao/src/main/resources/mapper/LedSFileMapper.xml
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper
+        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.sandu.ximon.dao.mapper.LedSFileMapper">
+
+    <resultMap id="BaseResultMap" type="com.sandu.ximon.dao.domain.LedSFile">
+            <id property="fileId" column="file_id" jdbcType="BIGINT"/>
+            <result property="cilentId" column="cilent_id" jdbcType="BIGINT"/>
+            <result property="userName" column="user_name" jdbcType="VARCHAR"/>
+            <result property="originname" column="originName" jdbcType="VARCHAR"/>
+            <result property="fileUrl" column="file_url" jdbcType="VARCHAR"/>
+            <result property="fileType" column="file_type" jdbcType="VARCHAR"/>
+            <result property="fileSize" column="file_size" jdbcType="BIGINT"/>
+            <result property="height" column="height" jdbcType="INTEGER"/>
+            <result property="width" column="width" jdbcType="INTEGER"/>
+            <result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
+    </resultMap>
+
+    <sql id="Base_Column_List">
+        file_id,cilent_id,user_name,
+        originName,file_url,file_type,
+        file_size,height,width,
+        create_time
+    </sql>
+</mapper>
diff --git a/sandu-common/src/main/java/com/sandu/common/file/impl/AliOssFileServiceImpl.java b/sandu-common/src/main/java/com/sandu/common/file/impl/AliOssFileServiceImpl.java
index 6f927bc..882ba59 100644
--- a/sandu-common/src/main/java/com/sandu/common/file/impl/AliOssFileServiceImpl.java
+++ b/sandu-common/src/main/java/com/sandu/common/file/impl/AliOssFileServiceImpl.java
@@ -15,6 +15,7 @@
 import com.sandu.common.file.IFileUpload;
 import lombok.AllArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Component;
 import org.springframework.web.multipart.MultipartFile;
 
 import javax.imageio.ImageIO;
@@ -29,14 +30,14 @@
  * @date 2020/12/17 15:31
  */
 @Slf4j
-@AllArgsConstructor
+@Component
 public class AliOssFileServiceImpl implements IFileUpload {
 
-    private final String endPoint;
-    private final String keyId;
-    private final String keySecret;
-    private final String bucketName;
-    private final String host;
+    private final String endPoint="oss-cn-shanghai.aliyuncs.com";
+    private final String keyId="LTAI5tPdpt5wvJyLipRijFSP";
+    private final String keySecret="1ahYfCKd0yTddsUnuDLQzI23MLh4VQ";
+    private final String bucketName= "ximonsmart";
+    private String host;
 
     @Override
     public FileUploadDto uploadFile(MultipartFile multipartFile) {
diff --git a/ximon-admin/src/main/java/com/sandu/ximon/admin/controller/LedSFileController.java b/ximon-admin/src/main/java/com/sandu/ximon/admin/controller/LedSFileController.java
new file mode 100644
index 0000000..010af57
--- /dev/null
+++ b/ximon-admin/src/main/java/com/sandu/ximon/admin/controller/LedSFileController.java
@@ -0,0 +1,55 @@
+package com.sandu.ximon.admin.controller;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.github.pagehelper.PageHelper;
+import com.sandu.common.domain.ResponseVO;
+import com.sandu.common.file.impl.AliOssFileServiceImpl;
+import com.sandu.common.object.BaseConditionVO;
+import com.sandu.common.util.ResponseUtil;
+import com.sandu.ximon.admin.param.LEDProgramFileParam;
+import com.sandu.ximon.admin.service.LEDProgramFileService;
+import com.sandu.ximon.admin.service.LedSFileService;
+import com.sandu.ximon.dao.domain.LEDProgramFile;
+import lombok.AllArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
+
+/**
+ * @Author liuhaonan
+ * @Date 2022/1/13 17:02
+ * @Version 1.0
+ */
+@Slf4j
+@RestController
+@AllArgsConstructor
+@RequestMapping("/v1/file")
+public class LedSFileController {
+
+    private final LedSFileService ledProgramFileService;
+    private final AliOssFileServiceImpl aliOssFileService;
+
+    @PostMapping("/add")
+    public ResponseVO<Object> addLEDProgram(@RequestParam("file") MultipartFile file) {
+
+
+        //return ResponseUtil.success(ledProgramFileService.addProgramFile(file));
+        return ResponseUtil.success(aliOssFileService.uploadFile(file));
+    }
+
+  /*  @PostMapping("/delete/{fileId}")
+    public ResponseVO<Object> deleteLEDProgram(@PathVariable Long fileId) {
+        return ResponseUtil.success(ledProgramFileService.deleteFile(fileId));
+    }
+
+    @GetMapping("/list")
+    public ResponseVO<Object> listfile(BaseConditionVO baseConditionVO, @RequestParam(value = "keyword", required = false) String keyword) {
+        PageHelper.startPage(baseConditionVO.getPageNo(), baseConditionVO.getPageSize());
+        LambdaQueryWrapper<LEDProgramFile> wrapper = ledProgramFileService.listFile();
+        if (null != keyword) {
+            wrapper.like(LEDProgramFile::getName, keyword);
+        }
+        return ResponseUtil.successPage(ledProgramFileService.list(wrapper));
+    }*/
+}
diff --git a/ximon-admin/src/main/java/com/sandu/ximon/admin/service/LedSFileService.java b/ximon-admin/src/main/java/com/sandu/ximon/admin/service/LedSFileService.java
new file mode 100644
index 0000000..378dc64
--- /dev/null
+++ b/ximon-admin/src/main/java/com/sandu/ximon/admin/service/LedSFileService.java
@@ -0,0 +1,61 @@
+package com.sandu.ximon.admin.service;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import com.sandu.common.execption.BusinessException;
+import com.sandu.common.file.FileUploadDto;
+import com.sandu.common.file.impl.AliOssFileServiceImpl;
+import com.sandu.common.service.impl.BaseServiceImpl;
+import com.sandu.ximon.admin.param.LEDProgramFileParam;
+import com.sandu.ximon.admin.security.SecurityUtils;
+import com.sandu.ximon.dao.domain.LEDProgramFile;
+import com.sandu.ximon.dao.domain.LedSFile;
+import com.sandu.ximon.dao.mapper.LedSFileMapper;
+import lombok.AllArgsConstructor;
+import org.springframework.beans.BeanUtils;
+import org.springframework.stereotype.Service;
+import org.springframework.web.multipart.MultipartFile;
+
+/**
+ * @Author liuhaonan
+ * @Date 2022/1/13 16:27
+ * @Version 1.0
+ */
+@Service
+@AllArgsConstructor
+public class LedSFileService extends BaseServiceImpl<LedSFileMapper, LedSFile> {
+    private final LedSFileMapper ledSFileMapper;
+    private final AliOssFileServiceImpl aliOssFileService;
+
+    public FileUploadDto addProgramFile(MultipartFile file) {
+        FileUploadDto fileUploadDto = aliOssFileService.uploadFile(file);
+        LedSFile sFile = new LedSFile();
+        BeanUtils.copyProperties(fileUploadDto, sFile);
+        sFile.setCilentId(SecurityUtils.getClientId());
+        if (SecurityUtils.getClientId() != null) {
+            sFile.setUserName(SecurityUtils.getUsername());
+        }
+        save(sFile);
+//        return save(sFile);
+        return fileUploadDto;
+    }
+
+    public boolean deleteFile(Long id) {
+        LedSFile byId = getById(id);
+        if (byId == null) {
+            throw new BusinessException("鏈壘鍒拌鑺傜洰");
+        }
+        return removeById(id);
+    }
+
+    public LambdaQueryWrapper<LedSFile> listFile(){
+        LambdaQueryWrapper<LedSFile> ledProgramFileLambdaQueryWrapper = Wrappers.lambdaQuery(LedSFile.class);
+        if(SecurityUtils.getClientId()!=null){
+            return ledProgramFileLambdaQueryWrapper.eq(LedSFile::getCilentId,SecurityUtils.getUserId());
+        }else {
+            return ledProgramFileLambdaQueryWrapper;
+        }
+
+    }
+
+}

--
Gitblit v1.9.3