|
@@ -1,6 +1,7 @@
|
|
|
package org.jeecg.modules.ctop.controller;
|
|
|
|
|
|
import cn.com.ctop.common.module.utils.Check;
|
|
|
+import cn.com.ctop.common.module.utils.CloudVideoProcessUtil;
|
|
|
import cn.com.ctop.common.module.utils.KuaishouInterfaceConstant;
|
|
|
import cn.com.ctop.manage.modules.actor.entity.Actor;
|
|
|
import cn.com.ctop.manage.modules.actor.entity.ActorComment;
|
|
@@ -10,16 +11,24 @@ import cn.com.ctop.manage.modules.actor.service.IActorCommentService;
|
|
|
import cn.com.ctop.manage.modules.actor.service.IActorPhotoService;
|
|
|
import cn.com.ctop.manage.modules.actor.service.IActorService;
|
|
|
import cn.com.ctop.manage.modules.actor.service.IActorVideoService;
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.checkerframework.checker.units.qual.A;
|
|
|
+import org.checkerframework.checker.units.qual.C;
|
|
|
import org.jeecg.common.api.vo.Result;
|
|
|
import org.jeecg.common.system.query.QueryGenerator;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
+import java.net.URLDecoder;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.List;
|
|
|
+import java.util.UUID;
|
|
|
|
|
|
/**
|
|
|
* @author jeecg-boot
|
|
@@ -42,6 +51,15 @@ public class ActorController {
|
|
|
public Result<Actor> getDetail(@RequestParam(name = "actorId") Long actorId) {
|
|
|
Result<Actor> result = new Result<>();
|
|
|
Actor actor = actorService.getById(actorId);
|
|
|
+ List<String> tags = actorCommentService.getTagsNames(actorId);
|
|
|
+ actor.setTagNameList(tags);
|
|
|
+ String phone = actor.getPhone();
|
|
|
+ if (!Check.isNull(phone)) {
|
|
|
+ String encPhone = getEncPhone(phone);
|
|
|
+ if (!Check.isNull(encPhone)) {
|
|
|
+ actor.setEncPhone(encPhone);
|
|
|
+ }
|
|
|
+ }
|
|
|
result.setResult(actor);
|
|
|
result.setSuccess(true);
|
|
|
return result;
|
|
@@ -62,15 +80,73 @@ public class ActorController {
|
|
|
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
|
|
|
HttpServletRequest req) {
|
|
|
Result<IPage<Actor>> result = new Result<>();
|
|
|
+ String parm = actor.getName();
|
|
|
+ actor.setName(null);
|
|
|
QueryWrapper<Actor> queryWrapper = QueryGenerator.initQueryWrapper(actor, req.getParameterMap());
|
|
|
+ if (!Check.isNull(parm)) {
|
|
|
+ JSONObject jsonObject = JSONObject.parseObject(parm);
|
|
|
+ if (!Check.isNull(jsonObject)) {
|
|
|
+ String name = jsonObject.getString("name");
|
|
|
+ if (!Check.isNull(name)) {
|
|
|
+ queryWrapper.like("name", name);
|
|
|
+ }
|
|
|
+ Integer cityId = jsonObject.getInteger("cityId");
|
|
|
+ if (!Check.isNull(cityId) && cityId != 0) {
|
|
|
+ queryWrapper.eq("actor_city_id", cityId);
|
|
|
+ }
|
|
|
+
|
|
|
+ JSONArray tagList = jsonObject.getJSONArray("tagList");
|
|
|
+ if (!Check.isNull(tagList)) {
|
|
|
+ List<Long> tagIds = new ArrayList<>();
|
|
|
+ for (int i = 0; i < tagList.size(); i++) {
|
|
|
+ Long aLong = tagList.getLong(i);
|
|
|
+ tagIds.add(aLong);
|
|
|
+ }
|
|
|
+ List<Long> actorIds = actorCommentService.getActorIds(tagIds);
|
|
|
+ queryWrapper.in("id", actorIds);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
queryWrapper.orderByDesc("create_time");
|
|
|
Page<Actor> page = new Page<>(pageNo, pageSize);
|
|
|
IPage<Actor> pageList = actorService.page(page, queryWrapper);
|
|
|
+
|
|
|
+ List<Actor> records = pageList.getRecords();
|
|
|
+ for (int i = 0; i < records.size(); i++) {
|
|
|
+ Actor actor1 = records.get(i);
|
|
|
+ Long id = actor1.getId();
|
|
|
+ List<Long> tags = actorCommentService.getTagListBy(id);
|
|
|
+ actor1.setTagList(tags);
|
|
|
+
|
|
|
+ String phone = actor1.getPhone();
|
|
|
+ if (!Check.isNull(phone)) {
|
|
|
+ String encPhone = getEncPhone(phone);
|
|
|
+ if (!Check.isNull(encPhone)) {
|
|
|
+ actor1.setEncPhone(encPhone);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
result.setSuccess(true);
|
|
|
result.setResult(pageList);
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ private String getEncPhone(String phoneNumber) {
|
|
|
+ //截取前三位
|
|
|
+ String beginStr = phoneNumber.substring(0, 3);
|
|
|
+ //截取后四位
|
|
|
+ String endStr = phoneNumber.substring(7);
|
|
|
+ String encPhone = beginStr + "****" + endStr;
|
|
|
+ return encPhone;
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
@GetMapping(value = "/photo/list")
|
|
|
public Result<IPage<ActorPhoto>> queryPhotoPageList(ActorPhoto actorPhoto,
|
|
|
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
|
|
@@ -99,6 +175,26 @@ public class ActorController {
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ @GetMapping(value = "/getCityList")
|
|
|
+ public Result<List<JSONObject>> getCityList() {
|
|
|
+ Result<List<JSONObject>> result = new Result<>();
|
|
|
+ List<JSONObject> cityList = actorCommentService.getCityList();
|
|
|
+ result.setSuccess(true);
|
|
|
+ result.setResult(cityList);
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping(value = "/getTagList")
|
|
|
+ public Result<List<JSONObject>> getTagList() {
|
|
|
+ Result<List<JSONObject>> result = new Result<>();
|
|
|
+ List<JSONObject> cityList = actorCommentService.getTagList();
|
|
|
+ result.setSuccess(true);
|
|
|
+ result.setResult(cityList);
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
@DeleteMapping(value = "/comment/delete")
|
|
|
public Result<ActorComment> deleteComment(@RequestParam(name = "id", required = true) String id) {
|
|
|
Result<ActorComment> result = new Result<>();
|
|
@@ -161,11 +257,36 @@ public class ActorController {
|
|
|
public Result<ActorVideo> addVideo(ActorVideo actorVideo) {
|
|
|
Result<ActorVideo> result = new Result<>();
|
|
|
try {
|
|
|
+ Long actorId = actorVideo.getActorId();
|
|
|
String videoUrl = actorVideo.getVideoUrl();
|
|
|
- if (!Check.isNull(videoUrl) && !videoUrl.contains(KuaishouInterfaceConstant.HTTPS_PREFIX)) {
|
|
|
- actorVideo.setVideoUrl(KuaishouInterfaceConstant.HTTPS_PREFIX + videoUrl);
|
|
|
+ if (Check.isNull(videoUrl)) {
|
|
|
+ throw new Exception("请选择需要上传的图片");
|
|
|
+ }
|
|
|
+ String[] split = videoUrl.split(",");
|
|
|
+ if (Check.isNull(split)) {
|
|
|
+ throw new Exception("图片格式不正确");
|
|
|
+ }
|
|
|
+ for (int i = 0; i < split.length; i++) {
|
|
|
+ String video = split[i];
|
|
|
+ String newVideoUrl = null;
|
|
|
+ if (!video.contains(KuaishouInterfaceConstant.HTTPS_PREFIX)) {
|
|
|
+ newVideoUrl = KuaishouInterfaceConstant.HTTPS_PREFIX + video;
|
|
|
+ }
|
|
|
+ ActorVideo addActorVideo = new ActorVideo();
|
|
|
+
|
|
|
+ String url = URLDecoder.decode(newVideoUrl).replace("https://live-1301855440.cos.ap-chongqing.myqcloud.com/", "");
|
|
|
+
|
|
|
+ String uuid = UUID.randomUUID().toString();
|
|
|
+ String loadImage = "cutFrame/" + uuid + ".jpg";
|
|
|
+ String coverUrl = CloudVideoProcessUtil.videoCutPictureHandleLive(url, loadImage);
|
|
|
+
|
|
|
+
|
|
|
+ addActorVideo.setCoverUrl(coverUrl);
|
|
|
+ addActorVideo.setActorId(actorId);
|
|
|
+ addActorVideo.setVideoUrl(newVideoUrl);
|
|
|
+ actorVideoService.save(addActorVideo);
|
|
|
}
|
|
|
- actorVideoService.save(actorVideo);
|
|
|
+
|
|
|
result.success("添加成功!");
|
|
|
} catch (Exception e) {
|
|
|
log.error(e.getMessage(), e);
|
|
@@ -178,15 +299,33 @@ public class ActorController {
|
|
|
public Result<ActorPhoto> addPhoto(ActorPhoto actorPhoto) {
|
|
|
Result<ActorPhoto> result = new Result<>();
|
|
|
try {
|
|
|
+
|
|
|
+ Long actorId = actorPhoto.getActorId();
|
|
|
String photoUrl = actorPhoto.getPhotoUrl();
|
|
|
- if (!Check.isNull(photoUrl) && !photoUrl.contains(KuaishouInterfaceConstant.HTTPS_PREFIX)) {
|
|
|
- actorPhoto.setPhotoUrl(KuaishouInterfaceConstant.HTTPS_PREFIX + photoUrl);
|
|
|
+ if (Check.isNull(photoUrl)) {
|
|
|
+ throw new Exception("请选择需要上传的图片");
|
|
|
}
|
|
|
- actorPhotoService.save(actorPhoto);
|
|
|
+ String[] split = photoUrl.split(",");
|
|
|
+ if (Check.isNull(split)) {
|
|
|
+ throw new Exception("图片格式不正确");
|
|
|
+ }
|
|
|
+ for (int i = 0; i < split.length; i++) {
|
|
|
+ String photo = split[i];
|
|
|
+ String newPhotoUrl = null;
|
|
|
+ if (!photo.contains(KuaishouInterfaceConstant.HTTPS_PREFIX)) {
|
|
|
+ newPhotoUrl = KuaishouInterfaceConstant.HTTPS_PREFIX + photo;
|
|
|
+ }
|
|
|
+ ActorPhoto addActorPhoto = new ActorPhoto();
|
|
|
+ addActorPhoto.setActorId(actorId);
|
|
|
+ addActorPhoto.setPhotoUrl(newPhotoUrl);
|
|
|
+ actorPhotoService.save(addActorPhoto);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
result.success("添加成功!");
|
|
|
} catch (Exception e) {
|
|
|
log.error(e.getMessage(), e);
|
|
|
- result.error500("操作失败");
|
|
|
+ result.error500(e.getMessage());
|
|
|
}
|
|
|
return result;
|
|
|
}
|
|
@@ -220,6 +359,10 @@ public class ActorController {
|
|
|
if (!Check.isNull(coverUrl) && !coverUrl.contains(KuaishouInterfaceConstant.HTTPS_PREFIX)) {
|
|
|
actor.setCoverUrl(KuaishouInterfaceConstant.HTTPS_PREFIX + coverUrl);
|
|
|
}
|
|
|
+
|
|
|
+ Integer actorCityId = actor.getActorCityId();
|
|
|
+ String cityName = actorCommentService.getCityName(actorCityId);
|
|
|
+ actor.setActorCityName(cityName);
|
|
|
actorService.save(actor);
|
|
|
if (null != actor.getImageUrl() && !actor.getImageUrl().isEmpty()) {
|
|
|
for (String url : actor.getImageUrl()) {
|
|
@@ -235,12 +378,27 @@ public class ActorController {
|
|
|
for (String url : actor.getVideoUrl()) {
|
|
|
ActorVideo video = new ActorVideo();
|
|
|
video.setActorId(actor.getId());
|
|
|
+ String videoUrl = null;
|
|
|
if (!Check.isNull(url) && !url.contains(KuaishouInterfaceConstant.HTTPS_PREFIX)) {
|
|
|
+ videoUrl = KuaishouInterfaceConstant.HTTPS_PREFIX + url;
|
|
|
video.setVideoUrl(KuaishouInterfaceConstant.HTTPS_PREFIX + url);
|
|
|
}
|
|
|
+ String newUrl = URLDecoder.decode(videoUrl).replace("https://live-1301855440.cos.ap-chongqing.myqcloud.com/", "");
|
|
|
+ String uuid = UUID.randomUUID().toString();
|
|
|
+ String loadImage = "cutFrame/" + uuid + ".jpg";
|
|
|
+ String videoCoverUrl = CloudVideoProcessUtil.videoCutPictureHandleLive(newUrl, loadImage);
|
|
|
+ video.setCoverUrl(videoCoverUrl);
|
|
|
actorVideoService.save(video);
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ if (actor.getTagList() != null && !actor.getTagList().isEmpty()) {
|
|
|
+ for (Long tagId : actor.getTagList()) {
|
|
|
+ String tagName = actorCommentService.geTagName(tagId);
|
|
|
+ actorCommentService.addTag(actor.getId(), tagId, tagName);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
result.success("添加成功!");
|
|
|
} catch (Exception e) {
|
|
|
log.error(e.getMessage(), e);
|
|
@@ -267,9 +425,21 @@ public class ActorController {
|
|
|
if (!Check.isNull(coverUrl) && !coverUrl.contains(KuaishouInterfaceConstant.HTTPS_PREFIX)) {
|
|
|
actor.setCoverUrl(KuaishouInterfaceConstant.HTTPS_PREFIX + coverUrl);
|
|
|
}
|
|
|
+ Integer actorCityId = actor.getActorCityId();
|
|
|
+ if (!Check.isNull(actorCityId)) {
|
|
|
+ String cityName = actorCommentService.getCityName(actorCityId);
|
|
|
+ actor.setActorCityName(cityName);
|
|
|
|
|
|
+ }
|
|
|
boolean ok = actorService.updateById(actor);
|
|
|
if (ok) {
|
|
|
+ if (actor.getTagList() != null && !actor.getTagList().isEmpty()) {
|
|
|
+ actorCommentService.deleteTagByActorId(actor.getId());
|
|
|
+ for (Long tagId : actor.getTagList()) {
|
|
|
+ String tagName = actorCommentService.geTagName(tagId);
|
|
|
+ actorCommentService.addTag(actor.getId(), tagId, tagName);
|
|
|
+ }
|
|
|
+ }
|
|
|
result.success("修改成功!");
|
|
|
}
|
|
|
}
|
|
@@ -281,7 +451,7 @@ public class ActorController {
|
|
|
try {
|
|
|
actorService.removeById(id);
|
|
|
} catch (Exception e) {
|
|
|
- log.error("删除失败",e.getMessage());
|
|
|
+ log.error("删除失败", e.getMessage());
|
|
|
return Result.error("删除失败!");
|
|
|
}
|
|
|
return Result.ok("删除成功!");
|