Jelajahi Sumber

添加个人生平 时光留影视频,修改个人详情列表加入图片列表

Alex 4 tahun lalu
induk
melakukan
9c41349242

+ 1 - 1
ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/TPersonalImgController.java

@@ -139,7 +139,7 @@ public class TPersonalImgController extends BaseController {
     public AjaxResult uploadFile(MultipartFile file, String personalId) throws Exception {
         try {
             // 上传文件路径
-            String filePath = RuoYiConfig.getProfile() + "/personal";
+            String filePath = RuoYiConfig.getProfile() + "/personal/img/"+personalId;
             // 上传并返回新文件名称
             String fileName = FileUploadUtils.upload(filePath, file);
             String url = serverConfig.getUrl() + fileName;

+ 174 - 0
ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/TPersonalVideoController.java

@@ -0,0 +1,174 @@
+package com.ruoyi.web.controller.system;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+
+import java.util.List;
+import java.util.Arrays;
+
+import com.ruoyi.common.config.RuoYiConfig;
+import com.ruoyi.common.utils.file.FileUploadUtils;
+import com.ruoyi.framework.config.ServerConfig;
+import com.ruoyi.system.domain.TPersonalVideo;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import com.ruoyi.common.utils.StringUtils;
+import lombok.RequiredArgsConstructor;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.beans.factory.annotation.Autowired;
+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.DeleteMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+import com.ruoyi.common.annotation.Log;
+import com.ruoyi.common.core.controller.BaseController;
+import com.ruoyi.common.core.domain.AjaxResult;
+import com.ruoyi.common.enums.BusinessType;
+import com.ruoyi.system.domain.TPersonalVideo;
+import com.ruoyi.system.service.ITPersonalVideoService;
+import com.ruoyi.common.utils.poi.ExcelUtil;
+import com.ruoyi.common.core.page.TableDataInfo;
+import org.springframework.web.multipart.MultipartFile;
+
+/**
+ * 个人页  视频
+ * 
+ * @author Alex
+ * @date 2020-11-07
+ */
+@Api(value = "个人页  视频", tags = "个人页  视频")
+@RequiredArgsConstructor(onConstructor_ = @Autowired)
+@RestController
+@RequestMapping("/system/personal/video" )
+public class TPersonalVideoController extends BaseController {
+
+    private final ITPersonalVideoService iTPersonalVideoService;
+    private final ServerConfig serverConfig;
+
+    /**
+     * 查询个人页  视频列表
+     */
+    @ApiOperation("查询个人页视频列表")
+    @PreAuthorize("@ss.hasPermi('system:personal:video:list')")
+    @GetMapping("/list")
+    public TableDataInfo list(TPersonalVideo tPersonalVideo)
+    {
+        startPage();
+        LambdaQueryWrapper<TPersonalVideo> lqw = new LambdaQueryWrapper<TPersonalVideo>();
+        if (tPersonalVideo.getPersonalId() != null){
+            lqw.eq(TPersonalVideo::getPersonalId ,tPersonalVideo.getPersonalId());
+        }
+        if (StringUtils.isNotBlank(tPersonalVideo.getUrl())){
+            lqw.eq(TPersonalVideo::getUrl ,tPersonalVideo.getUrl());
+        }
+        if (StringUtils.isNotBlank(tPersonalVideo.getEnable())){
+            lqw.eq(TPersonalVideo::getEnable ,tPersonalVideo.getEnable());
+        }
+        List<TPersonalVideo> list = iTPersonalVideoService.list(lqw);
+        return getDataTable(list);
+    }
+    /**
+     * 查询个人页  视频列表
+     */
+    @ApiOperation("查询个人页视频列表 all")
+    @PreAuthorize("@ss.hasPermi('system:personal:video:list')")
+    @GetMapping("/all")
+    public AjaxResult all(TPersonalVideo tPersonalVideo) {
+        LambdaQueryWrapper<TPersonalVideo> lqw = new LambdaQueryWrapper<>();
+        if (tPersonalVideo.getPersonalId() != null){
+            lqw.eq(TPersonalVideo::getPersonalId ,tPersonalVideo.getPersonalId());
+        }
+        if (StringUtils.isNotBlank(tPersonalVideo.getUrl())){
+            lqw.eq(TPersonalVideo::getUrl ,tPersonalVideo.getUrl());
+        }
+        lqw.eq(TPersonalVideo::getEnable ,'0');
+        List<TPersonalVideo> list = iTPersonalVideoService.list(lqw);
+        return AjaxResult.success(list);
+    }
+
+    /**
+     * 导出个人页  视频列表
+     */
+    @ApiOperation("导出个人页  视频列表")
+    @PreAuthorize("@ss.hasPermi('system:personal:video:export')" )
+    @Log(title = "个人页  视频" , businessType = BusinessType.EXPORT)
+    @GetMapping("/export" )
+    public AjaxResult export(TPersonalVideo tPersonalVideo) {
+        LambdaQueryWrapper<TPersonalVideo> lqw = new LambdaQueryWrapper<TPersonalVideo>(tPersonalVideo);
+        List<TPersonalVideo> list = iTPersonalVideoService.list(lqw);
+        ExcelUtil<TPersonalVideo> util = new ExcelUtil<TPersonalVideo>(TPersonalVideo. class);
+        return util.exportExcel(list, "video" );
+    }
+
+    /**
+     * 获取个人页  视频详细信息
+     */
+    @ApiOperation("获取个人页  视频详细信息")
+    @PreAuthorize("@ss.hasPermi('system:personal:video:query')" )
+    @GetMapping(value = "/{id}" )
+    public AjaxResult getInfo(@PathVariable("id" ) Long id) {
+        return AjaxResult.success(iTPersonalVideoService.getById(id));
+    }
+
+    /**
+     * 新增个人页  视频
+     */
+    @ApiOperation("新增个人页  视频")
+    @PreAuthorize("@ss.hasPermi('system:personal:video:add')" )
+    @Log(title = "个人页  视频" , businessType = BusinessType.INSERT)
+    @PostMapping
+    public AjaxResult add(@RequestBody TPersonalVideo tPersonalVideo) {
+        return toAjax(iTPersonalVideoService.save(tPersonalVideo) ? 1 : 0);
+    }
+
+    /**
+     * 修改个人页  视频
+     */
+    @ApiOperation("修改个人页视频")
+    @PreAuthorize("@ss.hasPermi('system:personal:video:edit')" )
+    @Log(title = "个人页  视频" , businessType = BusinessType.UPDATE)
+    @PutMapping
+    public AjaxResult edit(@RequestBody TPersonalVideo tPersonalVideo) {
+        return toAjax(iTPersonalVideoService.updateById(tPersonalVideo) ? 1 : 0);
+    }
+
+    /**
+     * 删除个人页  视频
+     */
+    @ApiOperation("删除个人页视频")
+    @PreAuthorize("@ss.hasPermi('system:personal:video:remove')" )
+    @Log(title = "个人页  视频" , businessType = BusinessType.DELETE)
+    @DeleteMapping("/{id}" )
+    public AjaxResult remove(@PathVariable Long id) {
+        return toAjax(iTPersonalVideoService.removeById(id) ? 1 : 0);
+    }
+
+    @PreAuthorize("@ss.hasPermi('system:personal:img:add')" )
+    @PostMapping("/upload")
+    public AjaxResult uploadFile(MultipartFile file, String personalId) throws Exception {
+        if (personalId == null || "undefined".equals(personalId)) {
+            return AjaxResult.error("个人id不能为空");
+        }
+        try {
+            // 上传文件路径
+            String filePath = RuoYiConfig.getProfile() + "/personal/video/"+ personalId;
+            // 上传并返回新文件名称
+            String fileName = FileUploadUtils.upload(filePath, file);
+            String url = serverConfig.getUrl() + fileName;
+            AjaxResult ajax = AjaxResult.success();
+            TPersonalVideo item = new TPersonalVideo();
+            item.setPersonalId(Long.parseLong(personalId));
+            item.setUrl(fileName);
+            iTPersonalVideoService.save(item);
+            ajax.put("fileName", fileName);
+            ajax.put("url", url);
+            ajax.put("id",item.getId());
+            return ajax;
+        } catch (Exception e) {
+            return AjaxResult.error(e.getMessage());
+        }
+    }
+}

+ 21 - 0
ruoyi-app/src/main/java/com/ruoyi/app/controller/MyProfileController.java

@@ -21,6 +21,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.web.bind.annotation.*;
 
+import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
 
@@ -49,6 +50,26 @@ public class MyProfileController extends AppBaseController {
         List<TbMyProfile> profileList = profileService.list(new LambdaQueryWrapper<TbMyProfile>()
             .eq(TbMyProfile::getAppUserId, appUserId)
         );
+        if (profileList.size() > 0) {
+            List<Long> ids = new ArrayList<>();
+            profileList.forEach(item -> {
+                ids.add(item.getId());
+            });
+            List<TbProfileImg> imgList = profileImgService.list(new LambdaQueryWrapper<TbProfileImg>()
+                .in(TbProfileImg::getProfileId, ids)
+            );
+            if (imgList.size() > 0) {
+                profileList.forEach(item -> {
+                    List<TbProfileImg> newList = new ArrayList<>();
+                    imgList.forEach(img -> {
+                        if (item.getId().equals(img.getProfileId())) {
+                            newList.add(img);
+                        }
+                    });
+                    item.setImgList(newList);
+                });
+            }
+        }
         return AjaxResult.success(profileList);
     }
 

+ 78 - 0
ruoyi-system/src/main/java/com/ruoyi/system/domain/TPersonalVideo.java

@@ -0,0 +1,78 @@
+package com.ruoyi.system.domain;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.NoArgsConstructor;
+import lombok.ToString;
+import lombok.experimental.Accessors;
+import com.ruoyi.common.annotation.Excel;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.baomidou.mybatisplus.annotation.IdType;
+import java.io.Serializable;
+import java.util.Date;
+import java.math.BigDecimal;
+import com.ruoyi.common.core.domain.BaseEntity;
+
+/**
+ * 个人页  视频
+ * 
+ * @author Alex
+ * @date 2020-11-07
+ */
+@Data
+@ApiModel(value = "个人页视频")
+@ToString
+@EqualsAndHashCode
+@NoArgsConstructor
+@Accessors(chain = true)
+@TableName("t_personal_video")
+public class TPersonalVideo implements Serializable {
+
+    private static final long serialVersionUID=1L;
+
+
+    /** id */
+    @ApiModelProperty(value="主键id")
+    @TableId(value = "id")
+    private Long id;
+
+    /** 个人id */
+    @ApiModelProperty(value="个人id")
+    @Excel(name = "个人id")
+    private Long personalId;
+
+    /** 视频url */
+    @ApiModelProperty(value="视频url")
+    @Excel(name = "视频url")
+    private String url;
+
+    /** 是否启用  0是  1否 */
+    @ApiModelProperty(value="是否启用  0是  1否")
+    @Excel(name = "是否启用  0是  1否")
+    private String enable;
+
+    /** 创建者 */
+    @ApiModelProperty(value="创建者")
+    private String createBy;
+
+    /** 创建时间 */
+    @ApiModelProperty(value="创建时间")
+    private Date createTime;
+
+    /** 更新者 */
+    @ApiModelProperty(value="更新者")
+    private String updateBy;
+
+    /** 更新时间 */
+    @ApiModelProperty(value="更新时间")
+    private Date updateTime;
+
+    /** 备注 */
+    @ApiModelProperty(value="备注")
+    @Excel(name = "备注")
+    private String remark;
+}

+ 14 - 0
ruoyi-system/src/main/java/com/ruoyi/system/mapper/TPersonalVideoMapper.java

@@ -0,0 +1,14 @@
+package com.ruoyi.system.mapper;
+
+import com.ruoyi.system.domain.TPersonalVideo;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+ * 个人页  视频
+ *
+ * @author Administrator
+ * @date 2020-11-07
+ */
+public interface TPersonalVideoMapper extends BaseMapper<TPersonalVideo> {
+
+}

+ 14 - 0
ruoyi-system/src/main/java/com/ruoyi/system/service/ITPersonalVideoService.java

@@ -0,0 +1,14 @@
+package com.ruoyi.system.service;
+
+import com.ruoyi.system.domain.TPersonalVideo;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+/**
+ * 个人页  视频
+ *
+ * @author Alex
+ * @date 2020-11-07
+ */
+public interface ITPersonalVideoService extends IService<TPersonalVideo> {
+
+}

+ 18 - 0
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TPersonalVideoServiceImpl.java

@@ -0,0 +1,18 @@
+package com.ruoyi.system.service.impl;
+
+import org.springframework.stereotype.Service;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.ruoyi.system.mapper.TPersonalVideoMapper;
+import com.ruoyi.system.domain.TPersonalVideo;
+import com.ruoyi.system.service.ITPersonalVideoService;
+
+/**
+ * 个人页  视频
+ *
+ * @author Alex
+ * @date 2020-11-07
+ */
+@Service
+public class TPersonalVideoServiceImpl extends ServiceImpl<TPersonalVideoMapper, TPersonalVideo> implements ITPersonalVideoService {
+
+}

+ 20 - 0
ruoyi-system/src/main/resources/mapper/system/TPersonalVideoMapper.xml

@@ -0,0 +1,20 @@
+<?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.ruoyi.system.mapper.TPersonalVideoMapper">
+    
+    <resultMap type="TPersonalVideo" id="TPersonalVideoResult">
+        <result property="id"    column="id"    />
+        <result property="personalId"    column="personal_id"    />
+        <result property="url"    column="url"    />
+        <result property="enable"    column="enable"    />
+        <result property="createBy"    column="create_by"    />
+        <result property="createTime"    column="create_time"    />
+        <result property="updateBy"    column="update_by"    />
+        <result property="updateTime"    column="update_time"    />
+        <result property="remark"    column="remark"    />
+    </resultMap>
+
+
+</mapper>