ソースを参照

add: insertVideoInfo v1

tujidelv 3 年 前
コミット
cc44b10d13

+ 25 - 0
src/main/java/top/lvzhiqiang/controller/BgController.java

@@ -277,4 +277,29 @@ public class BgController {
         bgService.delVideoInfo(identificationCode, parentTypeName, allFlag);
         return R.ok();
     }
+
+    /**
+     * 增加影片
+     *
+     * @param identificationCode
+     * @param videoName
+     * @param parentType
+     * @param parentName
+     * @param type
+     * @author lvzhiqiang
+     * 2022/9/27 20:54
+     */
+    @RequestMapping("/insertVideoInfo")
+    @ResponseBody
+    public R insertVideoInfo(String identificationCode, String videoName, Integer parentType, String parentName, Integer type) {
+        if (StringUtils.isEmpty(identificationCode)) {
+            throw new ParameterException("识别码不能为空");
+        }
+        if (StringUtils.isEmpty(videoName) || StringUtils.isEmpty(parentName)) {
+            throw new ParameterException("videoUrl与type不能为空");
+        }
+
+        bgService.insertVideoInfo(identificationCode.trim().toUpperCase(), videoName, parentType, parentName, type);
+        return R.ok();
+    }
 }

+ 13 - 0
src/main/java/top/lvzhiqiang/service/BgService.java

@@ -110,4 +110,17 @@ public interface BgService {
      * 2022/5/29 12:59
      */
     void delVideoInfo(String identificationCode, String parentTypeName, String allFlag);
+
+    /**
+     * 增加影片
+     *
+     * @param identificationCode
+     * @param videoName
+     * @param parentType
+     * @param parentName
+     * @param type
+     * @author lvzhiqiang
+     * 2022/9/27 20:54
+     */
+    void insertVideoInfo(String identificationCode, String videoName, Integer parentType, String parentName, Integer type);
 }

+ 59 - 0
src/main/java/top/lvzhiqiang/service/impl/BgServiceImpl.java

@@ -464,6 +464,65 @@ public class BgServiceImpl implements BgService {
     }
 
     /**
+     * 增加影片
+     *
+     * @param identificationCode
+     * @param videoName
+     * @param parentType
+     * @param parentName
+     * @param type
+     * @author lvzhiqiang
+     * 2022/9/27 20:54
+     */
+    @Override
+    @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
+    public void insertVideoInfo(String identificationCode, String videoName, Integer parentType, String parentName, Integer type) {
+        String parentFullName;
+        if (parentType == 1) {
+            parentFullName = "(类别)" + parentName;
+
+            VideoInfoGenres videoInfoGenres = new VideoInfoGenres();
+            videoInfoGenres.setIdentificationCode(identificationCode);
+            videoInfoGenres.setName(parentName);
+            videoInfoGenres.setType(type);
+            videoInfoGenresMapper.insert(videoInfoGenres);
+        } else if (parentType == 2) {
+            parentFullName = "(男优)" + parentName;
+
+            VideoInfoCast videoInfoCast = new VideoInfoCast();
+            videoInfoCast.setIdentificationCode(identificationCode);
+            videoInfoCast.setName(parentName);
+            videoInfoCast.setType(type);
+            videoInfoCastMapper.insert(videoInfoCast);
+        } else if (parentType == 3) {
+            parentFullName = "(女优)" + parentName;
+
+            VideoInfoCast videoInfoCast = new VideoInfoCast();
+            videoInfoCast.setIdentificationCode(identificationCode);
+            videoInfoCast.setName(parentName);
+            videoInfoCast.setType(type);
+            videoInfoCastMapper.insert(videoInfoCast);
+        } else {
+            throw new RuntimeException("parentType类型错误");
+        }
+
+        // 主体
+        if (type == 1) {
+            VideoInfo videoInfo = new VideoInfo();
+            videoInfo.setIdentificationCode(identificationCode);
+            videoInfo.setType(1);
+            // 视频URL
+            videoInfo.setVideoUrl(parentFullName.concat("/").concat(videoName));
+            // 修改时间
+            videoInfo.setCreateTime(LocalDateTime.now());
+            // 主体是谁
+            videoInfo.setMainWho(parentFullName);
+
+            videoInfoMapper.insert(videoInfo);
+        }
+    }
+
+    /**
      * 初始化骑兵数据
      */
     @Override

+ 23 - 0
src/main/resources/static/bg.html

@@ -194,6 +194,29 @@
             <input type="submit" value="提交">
         </form>
     </div>
+    <div style="margin-right:20px;">
+        <span class="font">insertVideoInfo</span>
+        <form method="post" action="bg/insertVideoInfo">
+            <span>identificationCode</span>
+            <input type="text" name="identificationCode" placeholder="识别码,不可为空"/>
+            <span>videoName</span>
+            <input type="text" name="videoName" placeholder="影片名称,不可为空"/>
+            <span>parentType</span>
+            <select name="parentType" style="height: 21.43px;">
+                <option value="1">类别</option>
+                <option value="2">男优</option>
+                <option value="3">女优</option>
+            </select>
+            <span>parentName</span>
+            <input type="text" name="parentName" placeholder="上级名称,不可为空"/>
+            <span>type</span>
+            <select name="type" style="height: 21.43px;">
+                <option value="1">主体</option>
+                <option value="2">链接</option>
+            </select>
+            <input type="submit" value="提交">
+        </form>
+    </div>
 </div>
 </body>
 </html>