You've already forked FrameTour-BE
AioDevice
This commit is contained in:
82
src/main/java/com/ycwl/basic/controller/extern/AioDeviceController.java
vendored
Normal file
82
src/main/java/com/ycwl/basic/controller/extern/AioDeviceController.java
vendored
Normal file
@@ -0,0 +1,82 @@
|
||||
package com.ycwl.basic.controller.extern;
|
||||
|
||||
import com.ycwl.basic.annotation.IgnoreToken;
|
||||
import com.ycwl.basic.mapper.AioDeviceMapper;
|
||||
import com.ycwl.basic.mapper.MemberMapper;
|
||||
import com.ycwl.basic.model.aio.entity.AioDeviceEntity;
|
||||
import com.ycwl.basic.model.jwt.JwtInfo;
|
||||
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.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.service.mobile.GoodsService;
|
||||
import com.ycwl.basic.service.pc.FaceService;
|
||||
import com.ycwl.basic.utils.ApiResponse;
|
||||
import com.ycwl.basic.utils.JwtTokenUtil;
|
||||
import com.ycwl.basic.utils.SnowFlakeUtil;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import jakarta.servlet.ServletRequest;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@Slf4j
|
||||
@IgnoreToken
|
||||
@RestController
|
||||
@RequestMapping("/api/aio")
|
||||
public class AioDeviceController {
|
||||
@Autowired
|
||||
private GoodsService goodsService;
|
||||
@Autowired
|
||||
private FaceService faceService;
|
||||
@Autowired
|
||||
private MemberMapper memberMapper;
|
||||
@Autowired
|
||||
private AioDeviceMapper aioDeviceMapper;
|
||||
|
||||
@Autowired
|
||||
@PostMapping("/faceUpload")
|
||||
public ApiResponse<FaceRecognizeResp> faceUpload(@RequestParam("file") MultipartFile file, HttpServletRequest request) {
|
||||
String deviceId = request.getHeader("X-DeviceId");
|
||||
AioDeviceEntity aioDevice = aioDeviceMapper.getByKey(deviceId);
|
||||
if (aioDevice == null) {
|
||||
return ApiResponse.fail("设备不存在");
|
||||
}
|
||||
MemberEntity memberEntity = new MemberEntity();
|
||||
memberEntity.setScenicId(aioDevice.getScenicId());
|
||||
memberEntity.setCreateDate(new Date());
|
||||
memberEntity.setId(SnowFlakeUtil.getLongId());
|
||||
memberEntity.setNickname("用户");
|
||||
memberMapper.add(memberEntity);
|
||||
FaceRecognizeResp resp = faceService.faceUpload(file, aioDevice.getScenicId(), memberEntity.getId());
|
||||
return ApiResponse.success(resp);
|
||||
}
|
||||
|
||||
@ApiOperation("人脸信息")
|
||||
@GetMapping("/{faceId}")
|
||||
public ApiResponse<FaceRespVO> faceInfo(@PathVariable Long faceId) {
|
||||
return faceService.getById(faceId);
|
||||
}
|
||||
@ApiOperation("照片商品列表")
|
||||
@GetMapping("/{faceId}/photo")
|
||||
public ApiResponse<List<GoodsDetailVO>> sourceGoodsList(@PathVariable Long faceId) {
|
||||
GoodsReqQuery query = new GoodsReqQuery();
|
||||
query.setSourceType(2);
|
||||
query.setFaceId(faceId);
|
||||
List<GoodsDetailVO> goodsDetailVOS = goodsService.sourceGoodsList(query);
|
||||
return ApiResponse.success(goodsDetailVOS);
|
||||
}
|
||||
|
||||
}
|
8
src/main/java/com/ycwl/basic/mapper/AioDeviceMapper.java
Normal file
8
src/main/java/com/ycwl/basic/mapper/AioDeviceMapper.java
Normal file
@@ -0,0 +1,8 @@
|
||||
package com.ycwl.basic.mapper;
|
||||
|
||||
import com.ycwl.basic.model.aio.entity.AioDeviceEntity;
|
||||
|
||||
public interface AioDeviceMapper {
|
||||
AioDeviceEntity getById(Long id);
|
||||
AioDeviceEntity getByKey(String key);
|
||||
}
|
@@ -0,0 +1,45 @@
|
||||
package com.ycwl.basic.model.aio.entity;
|
||||
|
||||
import lombok.Data;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 智能设备实体类
|
||||
*/
|
||||
@Data
|
||||
public class AioDeviceEntity {
|
||||
/**
|
||||
* 主键ID
|
||||
*/
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 景区ID
|
||||
*/
|
||||
private Long scenicId;
|
||||
|
||||
/**
|
||||
* 设备名称
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 设备类型
|
||||
*/
|
||||
private String type;
|
||||
|
||||
/**
|
||||
* 接入密钥
|
||||
*/
|
||||
private String accessKey;
|
||||
|
||||
/**
|
||||
* 状态 (0-离线 1-在线)
|
||||
*/
|
||||
private Integer status;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private Date createAt;
|
||||
}
|
@@ -15,8 +15,6 @@ public class GoodsReqQuery {
|
||||
private Integer isBuy;
|
||||
private Long faceId;
|
||||
private Long goodsId;
|
||||
@ApiModelProperty("景区id")
|
||||
private Long scenicId;
|
||||
@ApiModelProperty("源素材商品类型 1视频 2图像")
|
||||
private Integer sourceType;
|
||||
}
|
||||
|
@@ -98,12 +98,16 @@ public class GoodsServiceImpl implements GoodsService {
|
||||
private DeviceRepository deviceRepository;
|
||||
|
||||
public ApiResponse<List<GoodsPageVO>> goodsList(GoodsReqQuery query) {
|
||||
FaceEntity face = faceRepository.getFace(query.getFaceId());
|
||||
if (face == null) {
|
||||
return ApiResponse.success(Collections.emptyList());
|
||||
}
|
||||
//查询原素材
|
||||
List<GoodsPageVO> goodsList = new ArrayList<>();
|
||||
VideoReqQuery videoReqQuery = new VideoReqQuery();
|
||||
videoReqQuery.setScenicId(query.getScenicId());
|
||||
videoReqQuery.setScenicId(face.getScenicId());
|
||||
videoReqQuery.setIsBuy(query.getIsBuy());
|
||||
videoReqQuery.setFaceId(query.getFaceId());
|
||||
videoReqQuery.setFaceId(face.getId());
|
||||
videoReqQuery.setMemberId(Long.valueOf(BaseContextHandler.getUserId()));
|
||||
//查询成片vlog
|
||||
List<VideoRespVO> videoList = videoMapper.queryByRelation(videoReqQuery);
|
||||
@@ -121,13 +125,13 @@ public class GoodsServiceImpl implements GoodsService {
|
||||
});
|
||||
|
||||
SourceReqQuery sourceReqQuery = new SourceReqQuery();
|
||||
sourceReqQuery.setScenicId(query.getScenicId());
|
||||
sourceReqQuery.setScenicId(face.getScenicId());
|
||||
sourceReqQuery.setIsBuy(query.getIsBuy());
|
||||
sourceReqQuery.setFaceId(query.getFaceId());
|
||||
sourceReqQuery.setFaceId(face.getId());
|
||||
sourceReqQuery.setMemberId(Long.valueOf(BaseContextHandler.getUserId()));
|
||||
//查询源素材
|
||||
List<SourceRespVO> sourceList = sourceMapper.queryByRelation(sourceReqQuery);
|
||||
ScenicConfigEntity scenicConfig = scenicRepository.getScenicConfig(query.getScenicId());
|
||||
ScenicConfigEntity scenicConfig = scenicRepository.getScenicConfig(face.getScenicId());
|
||||
List<GoodsPageVO> sourceGoods = sourceList.stream().collect(Collectors.groupingBy(SourceRespVO::getFaceId)).entrySet().stream().flatMap((faceEntry) -> {
|
||||
Long faceId = faceEntry.getKey();
|
||||
List<SourceRespVO> goods = faceEntry.getValue();
|
||||
@@ -153,7 +157,7 @@ public class GoodsServiceImpl implements GoodsService {
|
||||
goodsPageVO.setGoodsName("照片集");
|
||||
goodsPageVO.setGoodsType(2);
|
||||
}
|
||||
goodsPageVO.setScenicId(query.getScenicId());
|
||||
goodsPageVO.setScenicId(face.getScenicId());
|
||||
return goodsPageVO;
|
||||
});
|
||||
}).collect(Collectors.toList());
|
||||
@@ -175,11 +179,11 @@ public class GoodsServiceImpl implements GoodsService {
|
||||
}
|
||||
Integer sourceType = query.getSourceType();
|
||||
SourceReqQuery sourceReqQuery = new SourceReqQuery();
|
||||
sourceReqQuery.setScenicId(query.getScenicId());
|
||||
sourceReqQuery.setScenicId(face.getScenicId());
|
||||
sourceReqQuery.setIsBuy(query.getIsBuy());
|
||||
sourceReqQuery.setMemberId(face.getMemberId());
|
||||
sourceReqQuery.setType(sourceType);
|
||||
sourceReqQuery.setFaceId(query.getFaceId());
|
||||
sourceReqQuery.setFaceId(face.getId());
|
||||
List<SourceRespVO> list = sourceMapper.listUser(sourceReqQuery);
|
||||
List<GoodsDetailVO> goodsDetailVOList = new ArrayList<>();
|
||||
|
||||
@@ -512,11 +516,11 @@ public class GoodsServiceImpl implements GoodsService {
|
||||
}
|
||||
Integer sourceType = query.getSourceType();
|
||||
SourceReqQuery sourceReqQuery = new SourceReqQuery();
|
||||
sourceReqQuery.setScenicId(query.getScenicId());
|
||||
sourceReqQuery.setScenicId(face.getScenicId());
|
||||
sourceReqQuery.setIsBuy(query.getIsBuy());
|
||||
sourceReqQuery.setMemberId(face.getMemberId());
|
||||
sourceReqQuery.setType(sourceType);
|
||||
sourceReqQuery.setFaceId(query.getFaceId());
|
||||
sourceReqQuery.setFaceId(face.getId());
|
||||
List<SourceRespVO> list = sourceMapper.listUser(sourceReqQuery);
|
||||
if (!Integer.valueOf(2).equals(query.getSourceType())) {
|
||||
return list.stream().map(source -> {
|
||||
@@ -536,7 +540,7 @@ public class GoodsServiceImpl implements GoodsService {
|
||||
goodsUrlVO.setCreateTime(source.getCreateTime());
|
||||
return goodsUrlVO;
|
||||
}).collect(Collectors.toList());
|
||||
IsBuyRespVO isBuy = orderBiz.isBuy(face.getMemberId(), query.getScenicId(), query.getSourceType(), query.getFaceId());
|
||||
IsBuyRespVO isBuy = orderBiz.isBuy(face.getMemberId(), face.getScenicId(), query.getSourceType(), face.getId());
|
||||
if (!isBuy.isBuy()) {
|
||||
ScenicConfigEntity scenicConfig = scenicRepository.getScenicConfig(face.getScenicId());
|
||||
if (scenicConfig != null && ((scenicConfig.getAntiScreenRecordType() & 2) == 0)) {
|
||||
@@ -630,7 +634,7 @@ public class GoodsServiceImpl implements GoodsService {
|
||||
return true;
|
||||
}).count();
|
||||
if (count > 0) {
|
||||
IsBuyRespVO isBuy = orderBiz.isBuy(face.getMemberId(), query.getScenicId(), query.getSourceType(), query.getFaceId());
|
||||
IsBuyRespVO isBuy = orderBiz.isBuy(face.getMemberId(), face.getScenicId(), query.getSourceType(), face.getId());
|
||||
if (!isBuy.isBuy()) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
@@ -734,7 +738,7 @@ public class GoodsServiceImpl implements GoodsService {
|
||||
}
|
||||
Integer sourceType = query.getSourceType();
|
||||
SourceReqQuery sourceReqQuery = new SourceReqQuery();
|
||||
sourceReqQuery.setScenicId(query.getScenicId());
|
||||
sourceReqQuery.setScenicId(face.getScenicId());
|
||||
sourceReqQuery.setIsBuy(query.getIsBuy());
|
||||
sourceReqQuery.setMemberId(face.getMemberId());
|
||||
sourceReqQuery.setType(sourceType);
|
||||
|
10
src/main/resources/mapper/AioDeviceMapper.xml
Normal file
10
src/main/resources/mapper/AioDeviceMapper.xml
Normal file
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
||||
<mapper namespace="com.ycwl.basic.mapper.AioDeviceMapper">
|
||||
<select id="getById" resultType="com.ycwl.basic.model.aio.entity.AioDeviceEntity">
|
||||
select * from aio_device where id = #{id} limit 1
|
||||
</select>
|
||||
<select id="getByKey" resultType="com.ycwl.basic.model.aio.entity.AioDeviceEntity">
|
||||
select * from aio_device where access_key = #{accessKey} limit 1
|
||||
</select>
|
||||
</mapper>
|
Reference in New Issue
Block a user