Ver Fonte

试玩模块创建和开发

zhaoxian há 4 anos atrás
pai
commit
6d18fcc86e

+ 7 - 0
jeecg-boot-module-system/pom.xml

@@ -106,6 +106,13 @@
         </dependency>
 
         <dependency>
+            <groupId>cn.com.ctop</groupId>
+            <artifactId>module-shiwan</artifactId>
+            <version>2.0.2</version>
+            <scope>compile</scope>
+        </dependency>
+
+        <dependency>
             <groupId>com.aliyun.oss</groupId>
             <artifactId>aliyun-sdk-oss</artifactId>
             <version>3.5.0</version>

+ 64 - 0
module-shiwan/pom.xml

@@ -0,0 +1,64 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <parent>
+        <artifactId>jeecg-boot-parent</artifactId>
+        <groupId>org.jeecgframework.boot</groupId>
+        <version>2.0.2</version>
+    </parent>
+    <modelVersion>4.0.0</modelVersion>
+
+    <groupId>cn.com.ctop</groupId>
+    <artifactId>module-shiwan</artifactId>
+
+    <name>module-shiwan</name>
+    <url>http://www.example.com</url>
+
+    <properties>
+        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+        <maven.compiler.source>1.7</maven.compiler.source>
+        <maven.compiler.target>1.7</maven.compiler.target>
+    </properties>
+
+    <dependencies>
+        <dependency>
+            <groupId>cn.com.ctop</groupId>
+            <artifactId>module-common</artifactId>
+            <version>2.0.2</version>
+        </dependency>
+        <dependency>
+            <groupId>cn.com.ctop</groupId>
+            <artifactId>module-crawler</artifactId>
+            <version>2.0.2</version>
+        </dependency>
+
+        <dependency>
+            <groupId>com.googlecode.plist</groupId>
+            <artifactId>dd-plist</artifactId>
+            <version>1.16</version>
+        </dependency>
+        <dependency>
+            <groupId>com.github.tony19</groupId>
+            <artifactId>apktool-lib</artifactId>
+            <version>1.4.4-3</version>
+        </dependency>
+    </dependencies>
+
+    <build>
+        <resources>
+            <!-- 解决MyBatis配置文件引入问题 -->
+            <resource>
+                <directory>src/main/java</directory>
+                <includes>
+                    <include>**/*.properties</include>
+                    <include>**/*.xml</include>
+                </includes>
+                <!-- 是否替换资源中的属性-->
+                <filtering>false</filtering>
+            </resource>
+            <resource>
+                <directory>src/main/resources</directory>
+            </resource>
+        </resources>
+    </build>
+</project>

+ 268 - 0
module-shiwan/src/main/java/cn/com/ctop/shiwan/modules/controller/ShiwanFileUploadController.java

@@ -0,0 +1,268 @@
+package cn.com.ctop.shiwan.modules.controller;
+
+import cn.com.ctop.common.module.annotation.AutoLog;
+import cn.com.ctop.shiwan.modules.entity.ShiwanFileUpload;
+import cn.com.ctop.shiwan.modules.service.IShiwanFileUploadService;
+import com.alibaba.fastjson.JSON;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import lombok.extern.slf4j.Slf4j;
+import org.jeecg.common.api.vo.Result;
+import org.jeecg.common.system.query.QueryGenerator;
+import org.jeecg.common.util.oConvertUtils;
+import org.jeecgframework.poi.excel.ExcelImportUtil;
+import org.jeecgframework.poi.excel.def.NormalExcelConstants;
+import org.jeecgframework.poi.excel.entity.ExportParams;
+import org.jeecgframework.poi.excel.entity.ImportParams;
+import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.DeleteMapping;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.PutMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.multipart.MultipartFile;
+import org.springframework.web.multipart.MultipartHttpServletRequest;
+import org.springframework.web.servlet.ModelAndView;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.net.URLDecoder;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 试玩平台,文件信息
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2020-10-21
+ */
+@Slf4j
+@Api(tags = "试玩平台,文件信息")
+@RestController
+@RequestMapping("/shiwan/shiwanFileUpload")
+public class ShiwanFileUploadController {
+    @Autowired
+    private IShiwanFileUploadService shiwanFileUploadService;
+
+    /**
+     * 分页列表查询
+     *
+     * @param shiwanFileUpload
+     * @param pageNo
+     * @param pageSize
+     * @param req
+     * @return
+     */
+    @AutoLog(value = "试玩平台,文件信息-分页列表查询")
+    @ApiOperation(value = "试玩平台,文件信息-分页列表查询", notes = "试玩平台,文件信息-分页列表查询")
+    @GetMapping(value = "/list")
+    public Result<IPage<ShiwanFileUpload>> queryPageList(ShiwanFileUpload shiwanFileUpload,
+                                                         @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
+                                                         @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
+                                                         HttpServletRequest req) {
+        Result<IPage<ShiwanFileUpload>> result = new Result<>();
+        QueryWrapper<ShiwanFileUpload> queryWrapper = QueryGenerator.initQueryWrapper(shiwanFileUpload, req.getParameterMap());
+        Page<ShiwanFileUpload> page = new Page<ShiwanFileUpload>(pageNo, pageSize);
+        IPage<ShiwanFileUpload> pageList = shiwanFileUploadService.page(page, queryWrapper);
+        result.setSuccess(true);
+        result.setResult(pageList);
+        return result;
+    }
+
+
+
+    @PostMapping("/fileSave")
+    public Result<String> fileSave(@RequestBody MultipartFile file, String _w_userid, HttpServletRequest request){
+        Result<String> result = new Result<>();
+        log.info("上传文件新版本");
+        String fileId = request.getHeader("x-weboffice-file-id");
+        String data = shiwanFileUploadService.fileSave(file,_w_userid,fileId);
+        result.setResult(data);
+        return result;
+    }
+    /**
+     * 添加
+     *
+     * @param shiwanFileUpload
+     * @return
+     */
+    @AutoLog(value = "试玩平台,文件信息-添加")
+    @ApiOperation(value = "试玩平台,文件信息-添加", notes = "试玩平台,文件信息-添加")
+    @PostMapping(value = "/add")
+    public Result<ShiwanFileUpload> add(@RequestBody ShiwanFileUpload shiwanFileUpload) {
+        Result<ShiwanFileUpload> result = new Result<>();
+        try {
+            shiwanFileUploadService.save(shiwanFileUpload);
+            result.success("添加成功!");
+        } catch (Exception e) {
+            log.error(e.getMessage(), e);
+            result.error500("操作失败");
+        }
+        return result;
+    }
+
+    /**
+     * 编辑
+     *
+     * @param shiwanFileUpload
+     * @return
+     */
+    @AutoLog(value = "试玩平台,文件信息-编辑")
+    @ApiOperation(value = "试玩平台,文件信息-编辑", notes = "试玩平台,文件信息-编辑")
+    @PutMapping(value = "/edit")
+    public Result<ShiwanFileUpload> edit(@RequestBody ShiwanFileUpload shiwanFileUpload) {
+        Result<ShiwanFileUpload> result = new Result<ShiwanFileUpload>();
+        ShiwanFileUpload shiwanFileUploadEntity = shiwanFileUploadService.getById(shiwanFileUpload.getId());
+        if (shiwanFileUploadEntity == null) {
+            result.error500("未找到对应实体");
+        } else {
+            boolean ok = shiwanFileUploadService.updateById(shiwanFileUpload);
+            if (ok) {
+                result.success("修改成功!");
+            }
+        }
+
+        return result;
+    }
+
+    /**
+     * 通过id删除
+     *
+     * @param id
+     * @return
+     */
+    @AutoLog(value = "试玩平台,文件信息-通过id删除")
+    @ApiOperation(value = "试玩平台,文件信息-通过id删除", notes = "试玩平台,文件信息-通过id删除")
+    @DeleteMapping(value = "/delete")
+    public Result<?> delete(@RequestParam(name = "id", required = true) String id) {
+        try {
+            shiwanFileUploadService.removeById(id);
+        } catch (Exception e) {
+            log.error("删除失败", e.getMessage());
+            return Result.error("删除失败!");
+        }
+        return Result.ok("删除成功!");
+    }
+
+    /**
+     * 批量删除
+     *
+     * @param ids
+     * @return
+     */
+    @AutoLog(value = "试玩平台,文件信息-批量删除")
+    @ApiOperation(value = "试玩平台,文件信息-批量删除", notes = "试玩平台,文件信息-批量删除")
+    @DeleteMapping(value = "/deleteBatch")
+    public Result<ShiwanFileUpload> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
+        Result<ShiwanFileUpload> result = new Result<>();
+        if (ids == null || "".equals(ids.trim())) {
+            result.error500("参数不识别!");
+        } else {
+            this.shiwanFileUploadService.removeByIds(Arrays.asList(ids.split(",")));
+            result.success("删除成功!");
+        }
+        return result;
+    }
+
+    /**
+     * 通过id查询
+     *
+     * @param id
+     * @return
+     */
+    @AutoLog(value = "试玩平台,文件信息-通过id查询")
+    @ApiOperation(value = "试玩平台,文件信息-通过id查询", notes = "试玩平台,文件信息-通过id查询")
+    @GetMapping(value = "/queryById")
+    public Result<ShiwanFileUpload> queryById(@RequestParam(name = "id", required = true) String id) {
+        Result<ShiwanFileUpload> result = new Result<>();
+        ShiwanFileUpload shiwanFileUpload = shiwanFileUploadService.getById(id);
+        if (shiwanFileUpload == null) {
+            result.error500("未找到对应实体");
+        } else {
+            result.setResult(shiwanFileUpload);
+            result.setSuccess(true);
+        }
+        return result;
+    }
+
+    /**
+     * 导出excel
+     *
+     * @param request
+     * @param response
+     */
+    @RequestMapping(value = "/exportXls")
+    public ModelAndView exportXls(HttpServletRequest request, HttpServletResponse response) {
+        // Step.1 组装查询条件
+        QueryWrapper<ShiwanFileUpload> queryWrapper = null;
+        try {
+            String paramsStr = request.getParameter("paramsStr");
+            if (oConvertUtils.isNotEmpty(paramsStr)) {
+                String deString = URLDecoder.decode(paramsStr, "UTF-8");
+                ShiwanFileUpload shiwanFileUpload = JSON.parseObject(deString, ShiwanFileUpload.class);
+                queryWrapper = QueryGenerator.initQueryWrapper(shiwanFileUpload, request.getParameterMap());
+            }
+        } catch (UnsupportedEncodingException e) {
+            e.printStackTrace();
+        }
+
+        //Step.2 AutoPoi 导出Excel
+        ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
+        List<ShiwanFileUpload> pageList = shiwanFileUploadService.list(queryWrapper);
+        //导出文件名称
+        mv.addObject(NormalExcelConstants.FILE_NAME, "试玩平台,文件信息列表");
+        mv.addObject(NormalExcelConstants.CLASS, ShiwanFileUpload.class);
+        mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("试玩平台,文件信息列表数据", "导出人:Jeecg", "导出信息"));
+        mv.addObject(NormalExcelConstants.DATA_LIST, pageList);
+        return mv;
+    }
+
+    /**
+     * 通过excel导入数据
+     *
+     * @param request
+     * @param response
+     * @return
+     */
+    @RequestMapping(value = "/importExcel", method = RequestMethod.POST)
+    public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
+        MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
+        Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
+        for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
+            MultipartFile file = entity.getValue();
+            ImportParams params = new ImportParams();
+            params.setTitleRows(2);
+            params.setHeadRows(1);
+            params.setNeedSave(true);
+            try {
+                List<ShiwanFileUpload> listShiwanFileUploads = ExcelImportUtil.importExcel(file.getInputStream(), ShiwanFileUpload.class, params);
+                shiwanFileUploadService.saveBatch(listShiwanFileUploads);
+                return Result.ok("文件导入成功!数据行数:" + listShiwanFileUploads.size());
+            } catch (Exception e) {
+                log.error(e.getMessage(), e);
+                return Result.error("文件导入失败:" + e.getMessage());
+            } finally {
+                try {
+                    file.getInputStream().close();
+                } catch (IOException e) {
+                    e.printStackTrace();
+                }
+            }
+        }
+        return Result.ok("文件导入失败!");
+    }
+
+}

+ 99 - 0
module-shiwan/src/main/java/cn/com/ctop/shiwan/modules/entity/ShiwanFileUpload.java

@@ -0,0 +1,99 @@
+package cn.com.ctop.shiwan.modules.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+import org.jeecgframework.poi.excel.annotation.Excel;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import java.util.Date;
+
+/**
+ * 试玩平台,文件信息
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2020-10-21
+ */
+@Data
+@TableName("ctop_shiwan_file_upload")
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+@ApiModel(value = "ctop_shiwan_file_upload对象", description = "试玩平台,文件信息")
+public class ShiwanFileUpload {
+
+    /**
+     * 主键
+     */
+    @TableId(type = IdType.AUTO)
+    @ApiModelProperty(value = "主键")
+    private Long id;
+    /**
+     * 文件类型
+     */
+    @Excel(name = "文件类型", width = 15)
+    @ApiModelProperty(value = "文件类型")
+    private String fileType;
+    /**
+     * 文件级别
+     */
+    @Excel(name = "文件级别", width = 15)
+    @ApiModelProperty(value = "文件级别")
+    private Integer fileLevel;
+    /**
+     * 文件名称
+     */
+    @Excel(name = "文件名称", width = 15)
+    @ApiModelProperty(value = "文件名称")
+    private String fileName;
+    /**
+     * 存储路径
+     */
+    @Excel(name = "存储路径", width = 15)
+    @ApiModelProperty(value = "存储路径")
+    private String fileUrl;
+    /**
+     * 文件状态,0-无效,1有效
+     */
+    @Excel(name = "文件状态,0-无效,1有效", width = 15)
+    @ApiModelProperty(value = "文件状态,0-无效,1有效")
+    private String fileStatus;
+    /**
+     * 文件大小
+     */
+    @Excel(name = "文件大小", width = 15)
+    @ApiModelProperty(value = "文件大小")
+    private String fileSize;
+    /**
+     * 上传时间
+     */
+    @Excel(name = "上传时间", width = 20, format = "yyyy-MM-dd HH:mm:ss")
+    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @ApiModelProperty(value = "上传时间")
+    private Date uploadTime;
+    /**
+     * 操作人
+     */
+    @Excel(name = "操作人", width = 15)
+    @ApiModelProperty(value = "操作人")
+    private String userId;
+    /**
+     * remake
+     */
+    @Excel(name = "remake", width = 15)
+    @ApiModelProperty(value = "remake")
+    private String remake;
+
+    private String functionType;
+
+    private String fileSuffix;
+
+    private String cfileName;
+}

+ 15 - 0
module-shiwan/src/main/java/cn/com/ctop/shiwan/modules/mapper/xml/ShiwanFileUploadMapper.java

@@ -0,0 +1,15 @@
+package cn.com.ctop.shiwan.modules.mapper;
+
+import cn.com.ctop.shiwan.modules.entity.ShiwanFileUpload;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+ * 试玩平台,文件信息
+ *
+ * @author: jeecg-boot
+ * @date: 2020-10-21
+ * @cersion: V1.0
+ */
+public interface ShiwanFileUploadMapper extends BaseMapper<ShiwanFileUpload> {
+
+}

+ 5 - 0
module-shiwan/src/main/java/cn/com/ctop/shiwan/modules/mapper/xml/ShiwanFileUploadMapper.xml

@@ -0,0 +1,5 @@
+<?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="cn.com.ctop.shiwan.mapper.ShiwanFileUploadMapper">
+
+</mapper>

+ 16 - 0
module-shiwan/src/main/java/cn/com/ctop/shiwan/modules/service/impl/IShiwanFileUploadService.java

@@ -0,0 +1,16 @@
+package cn.com.ctop.shiwan.modules.service;
+
+import cn.com.ctop.shiwan.modules.entity.ShiwanFileUpload;
+import com.baomidou.mybatisplus.extension.service.IService;
+import org.springframework.web.multipart.MultipartFile;
+
+/**
+ * @Description: 试玩平台,文件信息
+ * @Author: jeecg-boot
+ * @Date:   2020-10-21
+ * @Version: V1.0
+ */
+public interface IShiwanFileUploadService extends IService<ShiwanFileUpload> {
+
+    String fileSave(MultipartFile file, String w_userid, String fileId);
+}

+ 62 - 0
module-shiwan/src/main/java/cn/com/ctop/shiwan/modules/service/impl/ShiwanFileUploadServiceImpl.java

@@ -0,0 +1,62 @@
+package cn.com.ctop.shiwan.modules.service.impl;
+
+import cn.com.ctop.common.module.utils.Check;
+import cn.com.ctop.common.module.utils.CosUtils;
+import cn.com.ctop.common.module.vo.ResFileDTO;
+import cn.com.ctop.shiwan.modules.entity.ShiwanFileUpload;
+import cn.com.ctop.shiwan.modules.mapper.ShiwanFileUploadMapper;
+import cn.com.ctop.shiwan.modules.service.IShiwanFileUploadService;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.xxl.job.core.enums.NoEn;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.web.multipart.MultipartFile;
+
+import java.util.Date;
+
+/**
+ * 试玩平台,文件信息
+ * try-play
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2020-10-21
+ */
+@Service
+public class ShiwanFileUploadServiceImpl extends ServiceImpl<ShiwanFileUploadMapper, ShiwanFileUpload> implements IShiwanFileUploadService {
+
+    @Autowired
+    private ShiwanFileUploadMapper shiwanFileUploadMapper;
+
+
+    @Override
+    public String fileSave(MultipartFile file, String w_userid, String fileId) {
+        ResFileDTO resultFile = CosUtils.uploadMultipartFile(file, "try-play/zip/");
+        if (Check.isNull(resultFile)) {
+            return null;
+        }
+        ShiwanFileUpload fileUpload = new ShiwanFileUpload();
+        fileUpload.setCfileName(resultFile.getCFileName());
+        String filename = file.getOriginalFilename();
+        fileUpload.setFileName(filename);
+        String fileSuffix = filename.substring(filename.lastIndexOf(".") + 1).toLowerCase();
+        fileUpload.setFileSuffix(fileSuffix);
+        fileUpload.setFileName(file.getOriginalFilename());
+        if ("zip".equals(fileSuffix)) {
+            fileUpload.setFileLevel(NoEn.NO0.valueInt());
+        } else {
+            fileUpload.setFileLevel(NoEn.NO1.valueInt());
+        }
+        fileUpload.setFileStatus(NoEn.NO1.valueStr());
+
+        fileUpload.setFileSize(Math.random() + "kb");
+        fileUpload.setFileUrl(resultFile.getFileUrl());
+        fileUpload.setUploadTime(new Date());
+        //TODO
+        fileUpload.setUserId(null);
+        fileUpload.setFileType(null);
+        fileUpload.setFunctionType(null);
+        shiwanFileUploadMapper.insert(fileUpload);
+        return resultFile.getFileUrl();
+    }
+}

+ 1 - 0
pom.xml

@@ -21,6 +21,7 @@
         <module>module-crawler</module>
         <module>module-kuaishou</module>
         <module>module-toutiao</module>
+        <module>module-shiwan</module>
         <module>module-media</module>
         <module>module-ctop</module>
         <module>performance-appraisal</module>