tujidelv 3 lat temu
rodzic
commit
79d7adc31b

+ 6 - 2
src/main/java/top/lvzhiqiang/controller/BgController.java

@@ -322,8 +322,12 @@ public class BgController {
         if (StringUtils.isEmpty(identificationCode)) {
             throw new ParameterException("识别码不能为空");
         }
-        if (StringUtils.isEmpty(videoName) || StringUtils.isEmpty(parentName)) {
-            throw new ParameterException("videoUrl与type不能为空");
+        if (StringUtils.isEmpty(parentName)) {
+            throw new ParameterException("parentName不能为空");
+        }
+
+        if (StringUtils.isEmpty(videoName) && type == 1) {
+            throw new ParameterException("type为主体时videoName不可为空");
         }
 
         bgService.insertVideoInfo(identificationCode.trim().toUpperCase(), videoName, parentType, parentName, type);

+ 13 - 0
src/main/java/top/lvzhiqiang/mapper/VideoInfoMapper.java

@@ -45,6 +45,19 @@ public interface VideoInfoMapper {
     int insert(VideoInfo videoInfo);
 
     /**
+     * 新增或更新
+     *
+     * @param videoInfo
+     */
+    @Insert("INSERT INTO video_info(name, identification_code, issue_date, length, director, maker, issuer, img_url, video_url, type, main_who, create_time, modify_time) " +
+            "VALUES (#{name}, #{identificationCode}, #{issueDate}, #{length}, #{director}, #{maker}, #{issuer}, #{imgUrl}, #{videoUrl}, #{type}, #{mainWho} ,#{createTime}, now())" +
+            "ON DUPLICATE KEY UPDATE name=values(name),identification_code=values(identification_code),issue_date=values(issue_date),length=values(length),director=values(director)," +
+            "maker=values(maker),issuer=values(issuer),img_url=values(img_url),video_url=values(video_url),type=values(type),main_who=values(main_who),img_url=values(img_url)," +
+            "genres=values(genres),cast=values(cast),modify_time=now(),delete_flag=1,status=1")
+    @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")
+    int insertOrUpdate(VideoInfo videoInfo);
+
+    /**
      * 查询所有
      */
     @Select("select vi.*, IFNULL(vio.score, 0) AS score from video_info vi " +

+ 15 - 1
src/main/java/top/lvzhiqiang/service/impl/BgServiceImpl.java

@@ -543,6 +543,10 @@ public class BgServiceImpl implements BgService {
             videoInfoGenres.setName(parentName);
             videoInfoGenres.setType(type);
             videoInfoGenresMapper.insert(videoInfoGenres);
+
+            VideoGenres videoGenres = new VideoGenres();
+            videoGenres.setName(parentName);
+            videoGenresMapper.insertOrUpdate(videoGenres);
         } else if (parentType == 2) {
             parentFullName = "(男优)" + parentName;
 
@@ -551,6 +555,11 @@ public class BgServiceImpl implements BgService {
             videoInfoCast.setName(parentName);
             videoInfoCast.setType(type);
             videoInfoCastMapper.insert(videoInfoCast);
+
+            VideoCast videoCast = new VideoCast();
+            videoCast.setName(parentName);
+            videoCast.setType(1);
+            videoCastMapper.insertOrUpdate(videoCast);
         } else if (parentType == 3) {
             parentFullName = "(女优)" + parentName;
 
@@ -559,6 +568,11 @@ public class BgServiceImpl implements BgService {
             videoInfoCast.setName(parentName);
             videoInfoCast.setType(type);
             videoInfoCastMapper.insert(videoInfoCast);
+
+            VideoCast videoCast = new VideoCast();
+            videoCast.setName(parentName);
+            videoCast.setType(2);
+            videoCastMapper.insertOrUpdate(videoCast);
         } else {
             throw new RuntimeException("parentType类型错误");
         }
@@ -575,7 +589,7 @@ public class BgServiceImpl implements BgService {
             // 主体是谁
             videoInfo.setMainWho(parentFullName);
 
-            videoInfoMapper.insert(videoInfo);
+            videoInfoMapper.insertOrUpdate(videoInfo);
         }
     }
 

+ 1 - 1
src/main/resources/static/bg.html

@@ -240,7 +240,7 @@
             <span>identificationCode</span>
             <input type="text" name="identificationCode" placeholder="识别码,不可为空"/>
             <span>videoName</span>
-            <input type="text" name="videoName" placeholder="影片名称,不可为空"/>
+            <input type="text" name="videoName" placeholder="影片名称,type为主体时不可为空" style="width: 300px;"/>
             <span>parentType</span>
             <select name="parentType" style="height: 21.43px;">
                 <option value="1">类别</option>