Browse Source

处理空值

xueyiming 3 months ago
parent
commit
0e062a64f8

+ 15 - 0
api-module/src/main/java/com/tzld/piaoquan/api/service/impl/GhDetailServiceImpl.java

@@ -20,6 +20,7 @@ import org.springframework.stereotype.Service;
 import org.springframework.util.CollectionUtils;
 
 import java.util.ArrayList;
+import java.util.Date;
 import java.util.List;
 import java.util.Objects;
 
@@ -148,6 +149,20 @@ public class GhDetailServiceImpl implements GhDetailService {
             ghDetail.setGhName(ghDetailVo.getAccountName());
             ghDetail.setVideoIds(JSONObject.toJSONString(ghDetailVo.getVideoIds()));
             ghDetailMapper.updateByPrimaryKeySelective(ghDetail);
+
+            if (StringUtils.isEmpty(ghDetail.getContentDetail()) || StringUtils.isEmpty(ghDetail.getRate())) {
+                GhDetail updateGhDetail = ghDetailMapper.selectByPrimaryKey(ghDetail.getId());
+                if (StringUtils.isEmpty(ghDetail.getContentDetail())) {
+                    updateGhDetail.setContentDetail(null);
+                }
+                if (StringUtils.isEmpty(ghDetail.getRate())) {
+                    updateGhDetail.setRate(null);
+                }
+                updateGhDetail.setUpdateTime(new Date());
+                ghDetailMapper.updateByPrimaryKey(updateGhDetail);
+            }
+
+
             return CommonResponse.success();
         } catch (Exception e) {
             log.error("updateDetail error", e);