|
@@ -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());
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|