修改
This commit is contained in:
parent
b4b6d93e2f
commit
cfb9392068
@ -16,6 +16,7 @@ import com.ycwl.basic.model.pc.order.resp.OrderRespVO;
|
||||
import com.ycwl.basic.model.pc.scenic.entity.ScenicConfigEntity;
|
||||
import com.ycwl.basic.model.pc.scenic.entity.ScenicEntity;
|
||||
import com.ycwl.basic.model.pc.template.resp.TemplateRespVO;
|
||||
import com.ycwl.basic.model.pc.video.entity.VideoEntity;
|
||||
import com.ycwl.basic.model.pc.video.resp.VideoRespVO;
|
||||
import com.ycwl.basic.repository.FaceRepository;
|
||||
import com.ycwl.basic.repository.OrderRepository;
|
||||
@ -72,7 +73,7 @@ public class OrderBiz {
|
||||
}
|
||||
switch (goodsType) {
|
||||
case 0: // video
|
||||
VideoRespVO video = videoMapper.getById(goodsId);
|
||||
VideoEntity video = videoRepository.getVideo(goodsId);
|
||||
if (video == null) {
|
||||
return null;
|
||||
}
|
||||
|
201
src/main/java/com/ycwl/basic/controller/extern/LyCompatibleController.java
vendored
Normal file
201
src/main/java/com/ycwl/basic/controller/extern/LyCompatibleController.java
vendored
Normal file
@ -0,0 +1,201 @@
|
||||
package com.ycwl.basic.controller.extern;
|
||||
|
||||
import com.ycwl.basic.mapper.FaceMapper;
|
||||
import com.ycwl.basic.mapper.MemberMapper;
|
||||
import com.ycwl.basic.mapper.VideoMapper;
|
||||
import com.ycwl.basic.model.mobile.face.FaceRecognizeResp;
|
||||
import com.ycwl.basic.model.mobile.goods.GoodsDetailVO;
|
||||
import com.ycwl.basic.model.mobile.goods.GoodsReqQuery;
|
||||
import com.ycwl.basic.model.mobile.goods.VideoTaskStatusVO;
|
||||
import com.ycwl.basic.model.mobile.scenic.content.ContentPageVO;
|
||||
import com.ycwl.basic.model.pc.face.resp.FaceRespVO;
|
||||
import com.ycwl.basic.model.pc.member.entity.MemberEntity;
|
||||
import com.ycwl.basic.model.pc.member.resp.MemberRespVO;
|
||||
import com.ycwl.basic.model.pc.video.entity.VideoEntity;
|
||||
import com.ycwl.basic.model.pc.video.resp.VideoRespVO;
|
||||
import com.ycwl.basic.repository.VideoRepository;
|
||||
import com.ycwl.basic.repository.VideoTaskRepository;
|
||||
import com.ycwl.basic.service.mobile.AppScenicService;
|
||||
import com.ycwl.basic.service.mobile.GoodsService;
|
||||
import com.ycwl.basic.service.pc.FaceService;
|
||||
import com.ycwl.basic.service.task.impl.TaskTaskServiceImpl;
|
||||
import com.ycwl.basic.utils.ApiResponse;
|
||||
import com.ycwl.basic.utils.SnowFlakeUtil;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.Date;
|
||||
import java.util.Enumeration;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@RestController("/ly")
|
||||
public class LyCompatibleController {
|
||||
@Autowired
|
||||
private FaceService faceService;
|
||||
|
||||
@Autowired
|
||||
private MemberMapper memberMapper;
|
||||
@Autowired
|
||||
private GoodsService goodsService;
|
||||
@Autowired
|
||||
private FaceMapper faceMapper;
|
||||
@Autowired
|
||||
private AppScenicService appScenicService;
|
||||
@Autowired
|
||||
private VideoRepository videoRepository;
|
||||
@Autowired
|
||||
private VideoMapper videoMapper;
|
||||
@Autowired
|
||||
private TaskTaskServiceImpl taskTaskServiceImpl;
|
||||
|
||||
@PostMapping("sendPhoto")
|
||||
public R sendPhoto(@RequestParam(value = "file", required = false) MultipartFile file, HttpServletRequest request) {
|
||||
Map<String, String> headersMap = new HashMap<String, String>();
|
||||
Enumeration<String> headerNames = request.getHeaderNames();
|
||||
while (headerNames.hasMoreElements()) {
|
||||
String key = (String) headerNames.nextElement();
|
||||
String value = request.getHeader(key);
|
||||
headersMap.put(key, value);
|
||||
}
|
||||
if (!headersMap.containsKey("client")) {
|
||||
return R.error("请在Header中传入client!(client:用户OpenId)");
|
||||
}
|
||||
if (!headersMap.containsKey("secret")) {
|
||||
return R.error("请传入秘钥!");
|
||||
}
|
||||
String scid = request.getParameter("scid");
|
||||
Long scenicId = 0L;
|
||||
if (StringUtils.isBlank(scid)) {
|
||||
return R.error("景区ID为空!");
|
||||
}
|
||||
if (StringUtils.equals("288",scid)) {
|
||||
// 正式景区
|
||||
}
|
||||
String openId = headersMap.get("client");
|
||||
MemberRespVO member = memberMapper.getByOpenId(openId);
|
||||
if (member == null) {
|
||||
member = new MemberRespVO();
|
||||
MemberEntity memberEntity = new MemberEntity();
|
||||
memberEntity.setOpenId(openId);
|
||||
memberEntity.setScenicId(scenicId);
|
||||
memberEntity.setCreateDate(new Date());
|
||||
memberEntity.setId(SnowFlakeUtil.getLongId());
|
||||
memberEntity.setNickname("用户");
|
||||
memberMapper.add(memberEntity);
|
||||
member.setId(memberEntity.getId());
|
||||
}
|
||||
FaceRecognizeResp resp;
|
||||
try {
|
||||
resp = faceService.faceUpload(file, scenicId, member.getId());
|
||||
} catch (Exception e) {
|
||||
return R.error("上传失败!报错:"+e.getMessage());
|
||||
}
|
||||
if (resp.getFaceId() == null) {
|
||||
return R.error("上传失败!");
|
||||
}
|
||||
return R.ok().put("data", resp);
|
||||
}
|
||||
|
||||
@PostMapping("getIsVideo")
|
||||
public R getIsVideo(HttpServletRequest request) {
|
||||
Map<String, String> headersMap = new HashMap<String, String>();
|
||||
Enumeration<String> headerNames = request.getHeaderNames();
|
||||
while (headerNames.hasMoreElements()) {
|
||||
String key = (String) headerNames.nextElement();
|
||||
String value = request.getHeader(key);
|
||||
headersMap.put(key, value);
|
||||
}
|
||||
if (!headersMap.containsKey("client")) {
|
||||
return R.error("请在Header中传入client!(client:用户OpenId)");
|
||||
}
|
||||
if (!headersMap.containsKey("secret")) {
|
||||
return R.error("请传入秘钥!");
|
||||
}
|
||||
String openId = headersMap.get("client");
|
||||
MemberRespVO member = memberMapper.getByOpenId(openId);
|
||||
if (member == null) {
|
||||
return R.error("用户不存在!");
|
||||
}
|
||||
VideoTaskStatusVO taskStatusVO = goodsService.getTaskStatusByScenicId(member.getId(), member.getScenicId());
|
||||
if (taskStatusVO == null) {
|
||||
return R.ok().put("hasVideo", 0);
|
||||
}
|
||||
switch (taskStatusVO.getStatus()) {
|
||||
case 1:
|
||||
return R.ok().put("hasVideo", 1);
|
||||
case 2:
|
||||
return R.ok().put("hasVideo", 3);
|
||||
case 0:
|
||||
case 3:
|
||||
default:
|
||||
return R.ok().put("hasVideo", 0);
|
||||
}
|
||||
}
|
||||
|
||||
@PostMapping("getNewVideo")
|
||||
public R getNewVideo(HttpServletRequest request) {
|
||||
Map<String, String> headersMap = new HashMap<String, String>();
|
||||
Enumeration<String> headerNames = request.getHeaderNames();
|
||||
while (headerNames.hasMoreElements()) {
|
||||
String key = (String) headerNames.nextElement();
|
||||
String value = request.getHeader(key);
|
||||
headersMap.put(key, value);
|
||||
}
|
||||
if (!headersMap.containsKey("client")) {
|
||||
return R.error("请在Header中传入client!(client:用户OpenId)");
|
||||
}
|
||||
if (!headersMap.containsKey("secret")) {
|
||||
return R.error("请传入秘钥!");
|
||||
}
|
||||
String openId = headersMap.get("client");
|
||||
MemberRespVO member = memberMapper.getByOpenId(openId);
|
||||
if (member == null) {
|
||||
return R.error("用户不存在!");
|
||||
}
|
||||
FaceRespVO faceVO = faceMapper.getLatestByMemberId(member.getId(), member.getScenicId());
|
||||
if (faceVO == null) {
|
||||
return R.error("用户没有上传过照片!");
|
||||
}
|
||||
VideoTaskStatusVO taskStatusVO = goodsService.getTaskStatusByScenicId(member.getId(), member.getScenicId());
|
||||
List<ContentPageVO> listApiResponse = appScenicService.faceContentList(member.getId(), faceVO.getId());
|
||||
Map<Integer, List<ContentPageVO>> collect = listApiResponse.stream()
|
||||
.filter(contentPageVO -> contentPageVO.getLockType() < 0)
|
||||
.collect(Collectors.groupingBy(ContentPageVO::getGoodsType));
|
||||
List<Map<String, Object>> videoList = collect.get(0).stream().map(contentPageVO -> {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
VideoEntity videoRespVO = videoRepository.getVideo(contentPageVO.getContentId());
|
||||
map.put("template_cover_image", contentPageVO.getTemplateCoverUrl());
|
||||
Date taskShotDate = taskTaskServiceImpl.getTaskShotDate(videoRespVO.getTaskId());
|
||||
map.put("shoottime", taskShotDate);
|
||||
map.put("openid", openId);
|
||||
map.put("scenicname", contentPageVO.getScenicName());
|
||||
map.put("title", contentPageVO.getName());
|
||||
map.put("ossurldm", videoRespVO.getVideoUrl());
|
||||
return map;
|
||||
}).collect(Collectors.toList());
|
||||
GoodsReqQuery goodsReqQuery = new GoodsReqQuery();
|
||||
goodsReqQuery.setSourceType(1);
|
||||
List<GoodsDetailVO> sourceGoodsList = goodsService.sourceGoodsList(member.getId(), goodsReqQuery);
|
||||
List<Map<String, Object>> userVideoList = sourceGoodsList.stream().map(goodsDetailVO -> {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("openid", openId);
|
||||
map.put("template_cover_image", goodsDetailVO.getUrl());
|
||||
map.put("scenicname", goodsDetailVO.getScenicName());
|
||||
map.put("shoottime", goodsDetailVO.getCreateTime());
|
||||
map.put("ossurldm", goodsDetailVO.getVideoUrl());
|
||||
return map;
|
||||
}).collect(Collectors.toList());
|
||||
return R.ok()
|
||||
.put("isgen", taskStatusVO.getStatus() == 1 ? 0 : 1)
|
||||
.put("newvideo", videoList)
|
||||
.put("newuservideo", userVideoList);
|
||||
}
|
||||
}
|
55
src/main/java/com/ycwl/basic/controller/extern/R.java
vendored
Normal file
55
src/main/java/com/ycwl/basic/controller/extern/R.java
vendored
Normal file
@ -0,0 +1,55 @@
|
||||
package com.ycwl.basic.controller.extern;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 返回数据
|
||||
*
|
||||
* @author chenshun
|
||||
* @email sunlightcs@gmail.com
|
||||
* @date 2016年10月27日 下午9:59:27
|
||||
*/
|
||||
public class R extends HashMap<String, Object> {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public R() {
|
||||
put("code", 0);
|
||||
}
|
||||
|
||||
public static R error() {
|
||||
return error(500, "未知异常,请联系管理员");
|
||||
}
|
||||
|
||||
public static R error(String msg) {
|
||||
return error(500, msg);
|
||||
}
|
||||
|
||||
public static R error(int code, String msg) {
|
||||
R r = new R();
|
||||
r.put("code", code);
|
||||
r.put("msg", msg);
|
||||
return r;
|
||||
}
|
||||
|
||||
public static R ok(String msg) {
|
||||
R r = new R();
|
||||
r.put("msg", msg);
|
||||
return r;
|
||||
}
|
||||
|
||||
public static R ok(Map<String, Object> map) {
|
||||
R r = new R();
|
||||
r.putAll(map);
|
||||
return r;
|
||||
}
|
||||
|
||||
public static R ok() {
|
||||
return new R();
|
||||
}
|
||||
|
||||
public R put(String key, Object value) {
|
||||
super.put(key, value);
|
||||
return this;
|
||||
}
|
||||
}
|
@ -1,6 +1,7 @@
|
||||
package com.ycwl.basic.controller.mobile;
|
||||
|
||||
import com.ycwl.basic.model.jwt.JwtInfo;
|
||||
import com.ycwl.basic.model.mobile.face.FaceRecognizeResp;
|
||||
import com.ycwl.basic.model.pc.face.resp.FaceRespVO;
|
||||
import com.ycwl.basic.service.pc.FaceService;
|
||||
import com.ycwl.basic.utils.ApiResponse;
|
||||
@ -38,7 +39,11 @@ AppFaceController {
|
||||
@ApiOperation("人脸照片上传")
|
||||
@PostMapping("/faceUPload")
|
||||
public ApiResponse faceUpload(@RequestParam("file")MultipartFile file, @RequestParam("scenicId") Long scenicId) {
|
||||
return faceService.faceUpload(file,scenicId);
|
||||
//获取用户id
|
||||
JwtInfo worker = JwtTokenUtil.getWorker();
|
||||
Long userId = worker.getUserId();
|
||||
FaceRecognizeResp resp = faceService.faceUpload(file, scenicId, userId);
|
||||
return ApiResponse.success(resp);
|
||||
}
|
||||
|
||||
@GetMapping("/scenic/{scenicId}/list")
|
||||
|
@ -44,7 +44,8 @@ public class AppGoodsController {
|
||||
@ApiOperation("源素材(原片/照片)商品列表")
|
||||
@PostMapping("/sourceGoodsList")
|
||||
public ApiResponse<List<GoodsDetailVO>> sourceGoodsList(@RequestBody GoodsReqQuery query) {
|
||||
return goodsService.sourceGoodsList(Long.valueOf(BaseContextHandler.getUserId()), query);
|
||||
List<GoodsDetailVO> goodsDetailVOS = goodsService.sourceGoodsList(Long.valueOf(BaseContextHandler.getUserId()), query);
|
||||
return ApiResponse.success(goodsDetailVOS);
|
||||
}
|
||||
|
||||
@ApiOperation("成片vlog商品详情")
|
||||
|
@ -73,7 +73,8 @@ public class AppScenicController {
|
||||
@GetMapping("/face/{faceId}/contentList")
|
||||
public ApiResponse<List<ContentPageVO>> contentList(@PathVariable Long faceId) {
|
||||
JwtInfo worker = JwtTokenUtil.getWorker();
|
||||
return appScenicService.faceContentList(worker.getUserId(), faceId);
|
||||
List<ContentPageVO> contentPageVOS = appScenicService.faceContentList(worker.getUserId(), faceId);
|
||||
return ApiResponse.success(contentPageVOS);
|
||||
}
|
||||
|
||||
|
||||
|
@ -41,20 +41,5 @@ public class VideoController {
|
||||
public ApiResponse<VideoRespVO> getById(@PathVariable Long id) {
|
||||
return videoService.getById(id);
|
||||
}
|
||||
@ApiOperation("添加成片")
|
||||
@PostMapping("/add")
|
||||
public ApiResponse<Boolean> add(@RequestBody VideoEntity video) {
|
||||
return videoService.add(video);
|
||||
}
|
||||
@ApiOperation("删除成片")
|
||||
@DeleteMapping("/delete/{id}")
|
||||
public ApiResponse<Boolean> deleteById(@PathVariable Long id) {
|
||||
return videoService.deleteById(id);
|
||||
}
|
||||
@ApiOperation("修改成片")
|
||||
@PostMapping("/update")
|
||||
public ApiResponse<Boolean> update(@RequestBody VideoEntity video) {
|
||||
return videoService.update(video);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -45,4 +45,6 @@ public interface MemberMapper {
|
||||
* @return
|
||||
*/
|
||||
int addScenicServiceNoticeStatus(@Param("scenicId") Long scenicId,@Param("memberId") Long memberId);
|
||||
|
||||
MemberRespVO getByOpenId(String openId);
|
||||
}
|
||||
|
@ -48,4 +48,6 @@ public interface VideoMapper {
|
||||
int updateRelationWhenTaskSuccess(Long taskId, Long videoId, int isBuy);
|
||||
|
||||
List<MemberVideoEntity> listRelationByCreateTime(Date startTime, Date endTime);
|
||||
|
||||
VideoEntity getEntity(Long videoId);
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.ycwl.basic.repository;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.ycwl.basic.mapper.VideoMapper;
|
||||
import com.ycwl.basic.model.pc.video.entity.MemberVideoEntity;
|
||||
import com.ycwl.basic.model.pc.video.entity.VideoEntity;
|
||||
@ -18,6 +19,33 @@ public class VideoRepository {
|
||||
@Autowired
|
||||
private VideoMapper videoMapper;
|
||||
|
||||
public static final String VIDEO_CACHE_KEY = "video:%s";
|
||||
public static final String VIDEO_BY_TASK_ID_CACHE_KEY = "video:task:%s";
|
||||
|
||||
public VideoEntity getVideo(Long videoId) {
|
||||
if (redisTemplate.hasKey(String.format(VIDEO_CACHE_KEY, videoId))) {
|
||||
return JSON.parseObject(redisTemplate.opsForValue().get(String.format(VIDEO_CACHE_KEY, videoId)), VideoEntity.class);
|
||||
}
|
||||
VideoEntity video = videoMapper.getEntity(videoId);
|
||||
if (video != null) {
|
||||
redisTemplate.opsForValue().set(String.format(VIDEO_CACHE_KEY, videoId), JSON.toJSONString(video));
|
||||
redisTemplate.opsForValue().set(String.format(VIDEO_BY_TASK_ID_CACHE_KEY, video.getTaskId()), JSON.toJSONString(video));
|
||||
}
|
||||
return video;
|
||||
}
|
||||
|
||||
public VideoEntity getVideoByTaskId(Long taskId) {
|
||||
if (redisTemplate.hasKey(String.format(VIDEO_BY_TASK_ID_CACHE_KEY, taskId))) {
|
||||
return JSON.parseObject(redisTemplate.opsForValue().get(String.format(VIDEO_BY_TASK_ID_CACHE_KEY, taskId)), VideoEntity.class);
|
||||
}
|
||||
VideoEntity video = videoMapper.findByTaskId(taskId);
|
||||
if (video != null) {
|
||||
redisTemplate.opsForValue().set(String.format(VIDEO_BY_TASK_ID_CACHE_KEY, taskId), JSON.toJSONString(video));
|
||||
redisTemplate.opsForValue().set(String.format(VIDEO_CACHE_KEY, video.getId()), JSON.toJSONString(video));
|
||||
}
|
||||
return video;
|
||||
}
|
||||
|
||||
public void updateMeta(Long videoId, VideoInfoReq req) {
|
||||
VideoRespVO video = videoMapper.getById(videoId);
|
||||
if (video.getDuration() != null) {
|
||||
@ -31,6 +59,7 @@ public class VideoRepository {
|
||||
update.setWidth(req.getWidth());
|
||||
update.setDuration(req.getDuration());
|
||||
videoMapper.updateMeta(update);
|
||||
clearVideoCache(videoId);
|
||||
}
|
||||
|
||||
public void setUserIsBuyItem(Long memberId, Long videoId, Long orderId) {
|
||||
@ -58,4 +87,13 @@ public class VideoRepository {
|
||||
}
|
||||
return Integer.valueOf(1).equals(memberVideo.getIsBuy());
|
||||
}
|
||||
|
||||
public boolean clearVideoCache(Long videoId) {
|
||||
if (redisTemplate.hasKey(String.format(VIDEO_CACHE_KEY, videoId))) {
|
||||
VideoEntity video = getVideo(videoId);
|
||||
redisTemplate.delete(String.format(VIDEO_CACHE_KEY, videoId));
|
||||
redisTemplate.delete(String.format(VIDEO_BY_TASK_ID_CACHE_KEY, video.getTaskId()));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -1,13 +1,19 @@
|
||||
package com.ycwl.basic.repository;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.ycwl.basic.mapper.TaskMapper;
|
||||
import com.ycwl.basic.mapper.VideoMapper;
|
||||
import com.ycwl.basic.model.pc.task.entity.TaskEntity;
|
||||
import com.ycwl.basic.model.pc.task.resp.TaskRespVO;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@Component
|
||||
@ -34,4 +40,28 @@ public class VideoTaskRepository {
|
||||
public void clearTaskCache(Long taskId) {
|
||||
redisTemplate.delete(String.format(TASK_CACHE_KEY, taskId));
|
||||
}
|
||||
|
||||
|
||||
public Date getTaskShotDate(Long taskId) {
|
||||
TaskRespVO taskRespVO = taskMapper.getById(taskId);
|
||||
if (taskRespVO == null) {
|
||||
return null;
|
||||
}
|
||||
Date shotTime = taskRespVO.getCreateTime();
|
||||
JSONObject paramJson = JSON.parseObject(taskRespVO.getTaskParams());
|
||||
if (paramJson != null) {
|
||||
Optional<String> any = paramJson.keySet().stream().filter(StringUtils::isNumeric).findAny();
|
||||
if (any.isPresent()) {
|
||||
JSONArray jsonArray = paramJson.getJSONArray(any.get());
|
||||
if (!jsonArray.isEmpty()) {
|
||||
JSONObject jsonObject = jsonArray.getJSONObject(0);
|
||||
if (jsonObject.containsKey("createTime")) {
|
||||
shotTime = new Date(jsonObject.getLong("createTime"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return shotTime;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -25,22 +25,20 @@ import com.ycwl.basic.model.pc.source.req.SourceReqQuery;
|
||||
import com.ycwl.basic.model.pc.source.resp.SourceRespVO;
|
||||
import com.ycwl.basic.model.pc.task.entity.TaskEntity;
|
||||
import com.ycwl.basic.model.pc.video.entity.MemberVideoEntity;
|
||||
import com.ycwl.basic.model.pc.video.entity.VideoEntity;
|
||||
import com.ycwl.basic.model.pc.video.resp.VideoRespVO;
|
||||
import com.ycwl.basic.repository.ScenicRepository;
|
||||
import com.ycwl.basic.repository.VideoRepository;
|
||||
import com.ycwl.basic.repository.VideoTaskRepository;
|
||||
import com.ycwl.basic.service.mobile.AppScenicService;
|
||||
import com.ycwl.basic.repository.TemplateRepository;
|
||||
import com.ycwl.basic.utils.ApiResponse;
|
||||
import com.ycwl.basic.utils.JwtTokenUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
@ -75,6 +73,8 @@ public class AppScenicServiceImpl implements AppScenicService {
|
||||
private TemplateBiz templateBiz;
|
||||
@Autowired
|
||||
private VideoTaskRepository videoTaskRepository;
|
||||
@Autowired
|
||||
private VideoRepository videoRepository;
|
||||
|
||||
@Override
|
||||
public ApiResponse<PageInfo<ScenicAppVO>> pageQuery(ScenicReqQuery scenicReqQuery) {
|
||||
@ -106,10 +106,10 @@ public class AppScenicServiceImpl implements AppScenicService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ApiResponse<List<ContentPageVO>> faceContentList(Long userId, Long faceId) {
|
||||
public List<ContentPageVO> faceContentList(Long userId, Long faceId) {
|
||||
FaceRespVO faceRespVO = faceMapper.getById(faceId);
|
||||
if (faceRespVO == null) {
|
||||
return ApiResponse.success(new ArrayList<>());
|
||||
return Collections.emptyList();
|
||||
}
|
||||
List<ContentPageVO> contentList = templateMapper.listFor(faceRespVO.getScenicId());
|
||||
contentList.forEach(contentPageVO -> {
|
||||
@ -119,9 +119,9 @@ public class AppScenicServiceImpl implements AppScenicService {
|
||||
if (!memberVideoEntityList.isEmpty()) {
|
||||
contentPageVO.setIsBuy(memberVideoEntityList.get(0).getIsBuy());
|
||||
contentPageVO.setContentId(memberVideoEntityList.get(0).getVideoId());
|
||||
VideoRespVO videoMapperById = videoMapper.getById(contentPageVO.getContentId());
|
||||
if (videoMapperById != null) {
|
||||
contentPageVO.setDuration(videoMapperById.getDuration());
|
||||
VideoEntity video = videoRepository.getVideo(contentPageVO.getContentId());
|
||||
if (video != null) {
|
||||
contentPageVO.setDuration(video.getDuration());
|
||||
contentPageVO.setLockType(-1);
|
||||
} else {
|
||||
TaskEntity taskById = videoTaskRepository.getTaskById(memberVideoEntityList.get(0).getTaskId());
|
||||
@ -198,7 +198,7 @@ public class AppScenicServiceImpl implements AppScenicService {
|
||||
}
|
||||
});
|
||||
|
||||
return ApiResponse.success(contentList);
|
||||
return contentList;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -231,7 +231,8 @@ public class AppScenicServiceImpl implements AppScenicService {
|
||||
@Override
|
||||
public ApiResponse<List<ContentPageVO>> contentListUseDefaultFace() {
|
||||
FaceRespVO lastFaceByUserId = faceMapper.findLastFaceByUserId(BaseContextHandler.getUserId());
|
||||
return faceContentList(lastFaceByUserId.getMemberId(), lastFaceByUserId.getId());
|
||||
List<ContentPageVO> contentPageVOS = faceContentList(lastFaceByUserId.getMemberId(), lastFaceByUserId.getId());
|
||||
return ApiResponse.success(contentPageVOS);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -7,7 +7,6 @@ import com.ycwl.basic.biz.TaskStatusBiz;
|
||||
import com.ycwl.basic.constant.BaseContextHandler;
|
||||
import com.ycwl.basic.mapper.*;
|
||||
import com.ycwl.basic.model.mobile.goods.*;
|
||||
import com.ycwl.basic.model.mobile.order.IsBuyRespVO;
|
||||
import com.ycwl.basic.model.mobile.order.PriceObj;
|
||||
import com.ycwl.basic.model.pc.face.entity.FaceEntity;
|
||||
import com.ycwl.basic.model.pc.face.resp.FaceRespVO;
|
||||
@ -32,9 +31,6 @@ import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
@ -141,7 +137,7 @@ public class GoodsServiceImpl implements GoodsService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ApiResponse<List<GoodsDetailVO>> sourceGoodsList(Long userId, GoodsReqQuery query) {
|
||||
public List<GoodsDetailVO> sourceGoodsList(Long userId, GoodsReqQuery query) {
|
||||
Integer sourceType = query.getSourceType();
|
||||
SourceReqQuery sourceReqQuery = new SourceReqQuery();
|
||||
sourceReqQuery.setScenicId(query.getScenicId());
|
||||
@ -186,7 +182,7 @@ public class GoodsServiceImpl implements GoodsService {
|
||||
i++;
|
||||
}
|
||||
|
||||
return ApiResponse.success(goodsDetailVOList);
|
||||
return goodsDetailVOList;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -8,7 +8,6 @@ import com.ycwl.basic.mapper.FaceSampleMapper;
|
||||
import com.ycwl.basic.mapper.SourceMapper;
|
||||
import com.ycwl.basic.mapper.StatisticsMapper;
|
||||
import com.ycwl.basic.mapper.FaceMapper;
|
||||
import com.ycwl.basic.model.jwt.JwtInfo;
|
||||
import com.ycwl.basic.model.mobile.face.FaceRecognizeResp;
|
||||
import com.ycwl.basic.model.mobile.order.IsBuyRespVO;
|
||||
import com.ycwl.basic.model.mobile.statistic.req.StatisticsRecordAddReq;
|
||||
@ -113,12 +112,8 @@ public class FaceServiceImpl implements FaceService {
|
||||
}
|
||||
|
||||
@Override
|
||||
// @Transactional(rollbackFor = Exception.class)
|
||||
public ApiResponse faceUpload(MultipartFile file, Long scenicId) {
|
||||
//获取用户id
|
||||
JwtInfo worker = JwtTokenUtil.getWorker();
|
||||
Long userId = worker.getUserId();
|
||||
log.info("当前登录用户信息:{}",worker);
|
||||
public FaceRecognizeResp faceUpload(MultipartFile file, Long scenicId, Long userId) {
|
||||
|
||||
|
||||
//1、上传人脸照片
|
||||
IStorageAdapter adapter = StorageFactory.use("faces");
|
||||
@ -188,7 +183,7 @@ public class FaceServiceImpl implements FaceService {
|
||||
resp.setUrl(faceUrl);
|
||||
resp.setFaceId(newFaceId);
|
||||
matchFaceId(newFaceId, oldFaceId == null);
|
||||
return ApiResponse.success(resp);
|
||||
return resp;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -29,6 +29,8 @@ import com.ycwl.basic.model.pc.video.entity.VideoEntity;
|
||||
import com.ycwl.basic.model.pc.video.resp.VideoRespVO;
|
||||
import com.ycwl.basic.model.wx.WXPayOrderReqVO;
|
||||
import com.ycwl.basic.model.wx.WxPayRespVO;
|
||||
import com.ycwl.basic.repository.VideoRepository;
|
||||
import com.ycwl.basic.repository.VideoTaskRepository;
|
||||
import com.ycwl.basic.service.mobile.GoodsService;
|
||||
import com.ycwl.basic.service.mobile.WxPayService;
|
||||
import com.ycwl.basic.service.pc.OrderService;
|
||||
@ -76,6 +78,10 @@ public class OrderServiceImpl implements OrderService {
|
||||
private OrderBiz orderBiz;
|
||||
@Autowired
|
||||
private TaskTaskServiceImpl taskTaskServiceImpl;
|
||||
@Autowired
|
||||
private VideoRepository videoRepository;
|
||||
@Autowired
|
||||
private VideoTaskRepository videoTaskRepository;
|
||||
|
||||
@Override
|
||||
public ApiResponse<PageInfo<OrderRespVO>> pageQuery(OrderReqQuery query) {
|
||||
@ -109,9 +115,9 @@ public class OrderServiceImpl implements OrderService {
|
||||
}
|
||||
} else {
|
||||
item.setCoverList(Collections.singletonList(item.getCoverUrl()));
|
||||
VideoRespVO videoMapperById = videoMapper.getById(item.getGoodsId());
|
||||
VideoEntity videoMapperById = videoRepository.getVideoByTaskId(item.getGoodsId());
|
||||
if (videoMapperById != null) {
|
||||
item.setShootingTime(taskTaskServiceImpl.getTaskShotDate(videoMapperById.getTaskId()));
|
||||
item.setShootingTime(videoTaskRepository.getTaskShotDate(videoMapperById.getTaskId()));
|
||||
item.setVideoUrl(videoMapperById.getVideoUrl());
|
||||
}
|
||||
}
|
||||
@ -229,9 +235,9 @@ public class OrderServiceImpl implements OrderService {
|
||||
}
|
||||
} else {
|
||||
item.setCoverList(Collections.singletonList(item.getCoverUrl()));
|
||||
VideoRespVO videoMapperById = videoMapper.getById(item.getGoodsId());
|
||||
if (videoMapperById != null) {
|
||||
item.setShootingTime(taskTaskServiceImpl.getTaskShotDate(videoMapperById.getTaskId()));
|
||||
VideoEntity video = videoRepository.getVideo(item.getGoodsId());
|
||||
if (video != null) {
|
||||
item.setShootingTime(videoTaskRepository.getTaskShotDate(video.getTaskId()));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -42,34 +42,4 @@ public class VideoServiceImpl implements VideoService {
|
||||
return ApiResponse.success(videoMapper.getById(id));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ApiResponse<Boolean> add(VideoEntity video) {
|
||||
video.setId(SnowFlakeUtil.getLongId());
|
||||
int i = videoMapper.add(video);
|
||||
if (i > 0) {
|
||||
return ApiResponse.success(true);
|
||||
}else {
|
||||
return ApiResponse.fail("成片新增失败");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ApiResponse<Boolean> deleteById(Long id) {
|
||||
int i = videoMapper.deleteById(id);
|
||||
if (i > 0) {
|
||||
return ApiResponse.success(true);
|
||||
}else {
|
||||
return ApiResponse.fail("成片删除失败");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ApiResponse<Boolean> update(VideoEntity video) {
|
||||
int i = videoMapper.update(video);
|
||||
if (i > 0) {
|
||||
return ApiResponse.success(true);
|
||||
}else {
|
||||
return ApiResponse.fail("成片修改失败");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -34,7 +34,7 @@ public interface AppScenicService {
|
||||
ApiResponse<List<ScenicAppVO>> scenicList(ScenicIndexVO scenicIndexVO);
|
||||
|
||||
|
||||
ApiResponse<List<ContentPageVO>> faceContentList(Long userId, Long faceId);
|
||||
List<ContentPageVO> faceContentList(Long userId, Long faceId);
|
||||
|
||||
ApiResponse<ScenicLoginRespVO> login(ScenicLoginReq scenicLoginReq) throws Exception;
|
||||
|
||||
|
@ -25,7 +25,7 @@ public interface GoodsService {
|
||||
* @param query
|
||||
* @return
|
||||
*/
|
||||
ApiResponse<List<GoodsDetailVO>> sourceGoodsList(Long userId, GoodsReqQuery query);
|
||||
List<GoodsDetailVO> sourceGoodsList(Long userId, GoodsReqQuery query);
|
||||
|
||||
/**
|
||||
* @param userId 商品(vlog)id
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.ycwl.basic.service.pc;
|
||||
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.ycwl.basic.model.mobile.face.FaceRecognizeResp;
|
||||
import com.ycwl.basic.model.pc.face.entity.FaceEntity;
|
||||
import com.ycwl.basic.model.pc.face.req.FaceReqQuery;
|
||||
import com.ycwl.basic.model.pc.face.resp.FaceRespVO;
|
||||
@ -22,7 +23,7 @@ public interface FaceService {
|
||||
ApiResponse<Integer> deleteById(Long id);
|
||||
ApiResponse<Integer> deleteByIds(List<Long> ids);
|
||||
|
||||
ApiResponse faceUpload(MultipartFile file, Long scrnicId);
|
||||
FaceRecognizeResp faceUpload(MultipartFile file, Long scenicId, Long userId);
|
||||
|
||||
List<FaceRespVO> listByUser(Long userId, String scenicId);
|
||||
SearchFaceRespVo matchFaceId(Long faceId);
|
||||
|
@ -16,9 +16,6 @@ public interface VideoService {
|
||||
ApiResponse<PageInfo<VideoRespVO>> pageQuery(VideoReqQuery videoReqQuery);
|
||||
ApiResponse<List<VideoRespVO>> list(VideoReqQuery videoReqQuery);
|
||||
ApiResponse<VideoRespVO> getById(Long id);
|
||||
ApiResponse<Boolean> add(VideoEntity task);
|
||||
ApiResponse<Boolean> deleteById(Long id);
|
||||
ApiResponse<Boolean> update(VideoEntity task);
|
||||
|
||||
|
||||
}
|
||||
|
@ -316,8 +316,8 @@ public class TaskFaceServiceImpl implements TaskFaceService {
|
||||
listFaceEntitiesRequest.setOrder("asc");
|
||||
try {
|
||||
IAcsClient client = getClient();
|
||||
while (true) {
|
||||
AtomicBoolean flag = new AtomicBoolean(false);
|
||||
while (true) {
|
||||
ListFaceEntitiesResponse listFaceEntitiesResponse = client.getAcsResponse(listFaceEntitiesRequest);
|
||||
if (listFaceEntitiesResponse == null || listFaceEntitiesResponse.getData() == null || listFaceEntitiesResponse.getData().getEntities() == null || listFaceEntitiesResponse.getData().getEntities().isEmpty()) {
|
||||
break;
|
||||
@ -346,6 +346,8 @@ public class TaskFaceServiceImpl implements TaskFaceService {
|
||||
});
|
||||
if (!flag.get()) {
|
||||
break;
|
||||
} else {
|
||||
flag.set(false);
|
||||
}
|
||||
}
|
||||
} catch (Exception ignored) {
|
||||
|
@ -438,6 +438,8 @@ public class TaskTaskServiceImpl implements TaskService {
|
||||
}
|
||||
List<SourceEntity> videoSourceList = sourceMapper.listVideoByScenicFaceRelation(face.getScenicId(), faceId);
|
||||
Map<String, List<SourceEntity>> sourcesMap = videoSourceList.stream()
|
||||
.filter(Objects::nonNull)
|
||||
.filter(item -> Objects.nonNull(item.getVideoUrl()))
|
||||
.peek(item -> item.setUrl(item.getVideoUrl()))
|
||||
.filter(item -> {
|
||||
DeviceEntity device = deviceRepository.getDevice(item.getDeviceId());
|
||||
@ -555,6 +557,7 @@ public class TaskTaskServiceImpl implements TaskService {
|
||||
video.setDuration(req.getVideoInfo().getDuration());
|
||||
}
|
||||
videoMapper.update(video);
|
||||
videoRepository.clearVideoCache(video.getId());
|
||||
} else {
|
||||
video = new VideoEntity();
|
||||
video.setId(SnowFlakeUtil.getLongId());
|
||||
|
@ -27,6 +27,7 @@ import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
@Component
|
||||
@EnableScheduling
|
||||
@ -139,7 +140,7 @@ public class FaceCleaner {
|
||||
IStorageAdapter adapter = StorageFactory.use("assets-ext");
|
||||
List<StorageFileObject> fileObjectList = adapter.listDir("video-source");
|
||||
fileObjectList.parallelStream().forEach(fileObject -> {
|
||||
if (list.parallelStream().noneMatch(videoRespVO -> videoRespVO.getVideoUrl().contains(fileObject.getFullPath()))){
|
||||
if (list.parallelStream().filter(videoRespVO -> Objects.nonNull(videoRespVO.getVideoUrl())).noneMatch(videoRespVO -> videoRespVO.getVideoUrl().contains(fileObject.getFullPath()))){
|
||||
log.info("删除视频文件:{}", fileObject);
|
||||
adapter.deleteFile(fileObject.getFullPath());
|
||||
} else {
|
||||
|
@ -132,4 +132,21 @@
|
||||
from scenic_notification
|
||||
where member_id = #{memberId} and scenic_id = #{scenicId}
|
||||
</select>
|
||||
<select id="getByOpenId" resultType="com.ycwl.basic.model.pc.member.resp.MemberRespVO">
|
||||
select id,
|
||||
scenic_id,
|
||||
openid,
|
||||
avatar_url,
|
||||
nickname,
|
||||
real_name,
|
||||
promo_code,
|
||||
broker_id,
|
||||
agreement,
|
||||
phone,
|
||||
country,
|
||||
province,
|
||||
city
|
||||
from member
|
||||
where openid = #{openId}
|
||||
</select>
|
||||
</mapper>
|
@ -47,6 +47,7 @@
|
||||
<if test="endTime!= null">
|
||||
and create_time <= #{endTime}
|
||||
</if>
|
||||
group by member_id
|
||||
) AS subquery;
|
||||
</select>
|
||||
<select id="countClickPayOfMember" resultType="java.lang.Integer">
|
||||
|
@ -146,4 +146,9 @@
|
||||
from member_video
|
||||
where create_time >= #{startTime} and create_time <= #{endTime}
|
||||
</select>
|
||||
<select id="getEntity" resultType="com.ycwl.basic.model.pc.video.entity.VideoEntity">
|
||||
select *
|
||||
from video
|
||||
where id = #{id}
|
||||
</select>
|
||||
</mapper>
|
Loading…
x
Reference in New Issue
Block a user