feat:用户位置
This commit is contained in:
1 parent
45d6e2b1ce
commit
89e8e40ddf
21 files changed
+874
-50
No files matched your search
@@ -118,4 +118,27 @@ CREATE TABLE `member_photo`
|
||||
`deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除',
|
||||
`tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '租户编号',
|
||||
PRIMARY KEY (`id`) USING BTREE
|
||||
) ENGINE = InnoDB AUTO_INCREMENT = 32 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_bin COMMENT = '用户相册';
|
||||
) ENGINE = InnoDB AUTO_INCREMENT = 32 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_bin COMMENT = '用户相册';
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for member_location
|
||||
-- ----------------------------
|
||||
DROP TABLE IF EXISTS `member_location`;
|
||||
CREATE TABLE `member_location`
|
||||
(
|
||||
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '用户位置id',
|
||||
`member_id` bigint NOT NULL COMMENT '人员id',
|
||||
`long` double precision DEFAULT NULL COMMENT '经度',
|
||||
`lat` double precision DEFAULT NULL COMMENT '纬度',
|
||||
`province` varchar(64) DEFAULT NULL COMMENT '省',
|
||||
`city` varchar(64) DEFAULT NULL COMMENT '市',
|
||||
`district` varchar(64) DEFAULT NULL COMMENT '区',
|
||||
`address` varchar(256) DEFAULT NULL COMMENT '详细地址',
|
||||
`creator` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '创建者',
|
||||
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||
`updater` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '更新者',
|
||||
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
|
||||
`deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除',
|
||||
`tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '租户编号',
|
||||
PRIMARY KEY (`id`) USING BTREE
|
||||
) ENGINE = InnoDB AUTO_INCREMENT = 32 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_bin COMMENT = '用户位置记录';
|
||||
+2
@@ -4,6 +4,8 @@ import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.NumberUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
|
||||
import javax.validation.constraints.Size;
|
||||
import javax.xml.stream.Location;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
+7
@@ -65,4 +65,11 @@ public interface MemberErrorCode {
|
||||
//========== 用户图片、视频资源管理 1-004-013-000 ==========
|
||||
ErrorCode PHOTO_NOT_EXISTS = new ErrorCode(1_004_013_000, "用户资源不存在");
|
||||
ErrorCode PHOTO_TYPE_NOT_SUPPORT = new ErrorCode(1_004_013_001, "只有[{}]能删除");
|
||||
|
||||
//========== 审核管理 1-004-014-000 ==========
|
||||
ErrorCode CHECK_TEXT_NOT_PASS = new ErrorCode(1_004_014_001, "文字审核不通过,[{}]");
|
||||
ErrorCode CHECK_IMAGE_NOT_PASS = new ErrorCode(1_004_014_002, "图片审核不通过,[{}]");
|
||||
|
||||
//========== 用户位置管理 1-004-015-000 ==========
|
||||
ErrorCode LOCATION_NOT_EXISTS = new ErrorCode(1_004_015_000, "用户位置不存在");
|
||||
}
|
||||
@@ -86,6 +86,12 @@
|
||||
<artifactId>yudao-spring-boot-starter-biz-ip</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.aliyun</groupId>
|
||||
<artifactId>green20220302</artifactId>
|
||||
<version>2.21.1</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
+95
@@ -0,0 +1,95 @@
|
||||
package cn.iocoder.yudao.module.member.controller.admin.location;
|
||||
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import javax.annotation.Resource;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
|
||||
import javax.validation.constraints.*;
|
||||
import javax.validation.*;
|
||||
import javax.servlet.http.*;
|
||||
import java.util.*;
|
||||
import java.io.IOException;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
|
||||
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
||||
|
||||
import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
|
||||
import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.*;
|
||||
|
||||
import cn.iocoder.yudao.module.member.controller.admin.location.vo.*;
|
||||
import cn.iocoder.yudao.module.member.dal.dataobject.location.LocationDO;
|
||||
import cn.iocoder.yudao.module.member.service.location.LocationService;
|
||||
|
||||
@Tag(name = "管理后台 - 用户位置记录")
|
||||
@RestController
|
||||
@RequestMapping("/member/location")
|
||||
@Validated
|
||||
public class LocationController {
|
||||
|
||||
@Resource
|
||||
private LocationService locationService;
|
||||
|
||||
@PostMapping("/create")
|
||||
@Operation(summary = "创建用户位置记录")
|
||||
@PreAuthorize("@ss.hasPermission('member:location:create')")
|
||||
public CommonResult<Long> createLocation(@Valid @RequestBody LocationSaveReqVO createReqVO) {
|
||||
return success(locationService.createLocation(createReqVO));
|
||||
}
|
||||
|
||||
@PutMapping("/update")
|
||||
@Operation(summary = "更新用户位置记录")
|
||||
@PreAuthorize("@ss.hasPermission('member:location:update')")
|
||||
public CommonResult<Boolean> updateLocation(@Valid @RequestBody LocationSaveReqVO updateReqVO) {
|
||||
locationService.updateLocation(updateReqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete")
|
||||
@Operation(summary = "删除用户位置记录")
|
||||
@Parameter(name = "id", description = "编号", required = true)
|
||||
@PreAuthorize("@ss.hasPermission('member:location:delete')")
|
||||
public CommonResult<Boolean> deleteLocation(@RequestParam("id") Long id) {
|
||||
locationService.deleteLocation(id);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@GetMapping("/get")
|
||||
@Operation(summary = "获得用户位置记录")
|
||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||
@PreAuthorize("@ss.hasPermission('member:location:query')")
|
||||
public CommonResult<LocationRespVO> getLocation(@RequestParam("id") Long id) {
|
||||
LocationDO location = locationService.getLocation(id);
|
||||
return success(BeanUtils.toBean(location, LocationRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "获得用户位置记录分页")
|
||||
@PreAuthorize("@ss.hasPermission('member:location:query')")
|
||||
public CommonResult<PageResult<LocationRespVO>> getLocationPage(@Valid LocationPageReqVO pageReqVO) {
|
||||
PageResult<LocationDO> pageResult = locationService.getLocationPage(pageReqVO);
|
||||
return success(BeanUtils.toBean(pageResult, LocationRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/export-excel")
|
||||
@Operation(summary = "导出用户位置记录 Excel")
|
||||
@PreAuthorize("@ss.hasPermission('member:location:export')")
|
||||
@ApiAccessLog(operateType = EXPORT)
|
||||
public void exportLocationExcel(@Valid LocationPageReqVO pageReqVO,
|
||||
HttpServletResponse response) throws IOException {
|
||||
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
||||
List<LocationDO> list = locationService.getLocationPage(pageReqVO).getList();
|
||||
// 导出 Excel
|
||||
ExcelUtils.write(response, "用户位置记录.xls", "数据", LocationRespVO.class,
|
||||
BeanUtils.toBean(list, LocationRespVO.class));
|
||||
}
|
||||
|
||||
}
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
package cn.iocoder.yudao.module.member.controller.admin.location.vo;
|
||||
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
|
||||
@Schema(description = "管理后台 - 用户位置记录分页 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class LocationPageReqVO extends PageParam {
|
||||
|
||||
@Schema(description = "人员id", example = "2162")
|
||||
private Long memberId;
|
||||
|
||||
@Schema(description = "经度")
|
||||
private Double lon;
|
||||
|
||||
@Schema(description = "纬度")
|
||||
private Double lat;
|
||||
|
||||
@Schema(description = "省")
|
||||
private String province;
|
||||
|
||||
@Schema(description = "市")
|
||||
private String city;
|
||||
|
||||
@Schema(description = "区")
|
||||
private String district;
|
||||
|
||||
@Schema(description = "详细地址")
|
||||
private String address;
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime[] createTime;
|
||||
|
||||
}
|
||||
+51
@@ -0,0 +1,51 @@
|
||||
package cn.iocoder.yudao.module.member.controller.admin.location.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import java.time.LocalDateTime;
|
||||
import com.alibaba.excel.annotation.*;
|
||||
|
||||
@Schema(description = "管理后台 - 用户位置记录 Response VO")
|
||||
@Data
|
||||
@ExcelIgnoreUnannotated
|
||||
public class LocationRespVO {
|
||||
|
||||
@Schema(description = "用户位置id", requiredMode = Schema.RequiredMode.REQUIRED, example = "12953")
|
||||
@ExcelProperty("用户位置id")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "人员id", requiredMode = Schema.RequiredMode.REQUIRED, example = "2162")
|
||||
@ExcelProperty("人员id")
|
||||
private Long memberId;
|
||||
|
||||
@Schema(description = "经度")
|
||||
@ExcelProperty("经度")
|
||||
private Double lon;
|
||||
|
||||
@Schema(description = "纬度")
|
||||
@ExcelProperty("纬度")
|
||||
private Double lat;
|
||||
|
||||
@Schema(description = "省")
|
||||
@ExcelProperty("省")
|
||||
private String province;
|
||||
|
||||
@Schema(description = "市")
|
||||
@ExcelProperty("市")
|
||||
private String city;
|
||||
|
||||
@Schema(description = "区")
|
||||
@ExcelProperty("区")
|
||||
private String district;
|
||||
|
||||
@Schema(description = "详细地址")
|
||||
@ExcelProperty("详细地址")
|
||||
private String address;
|
||||
|
||||
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("创建时间")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
}
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
package cn.iocoder.yudao.module.member.controller.admin.location.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
|
||||
import java.util.*;
|
||||
import javax.validation.constraints.*;
|
||||
|
||||
@Schema(description = "管理后台 - 用户位置记录新增/修改 Request VO")
|
||||
@Data
|
||||
public class LocationSaveReqVO {
|
||||
|
||||
@Schema(description = "用户位置id")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "人员id")
|
||||
private Long memberId;
|
||||
|
||||
@Schema(description = "经度")
|
||||
@NotNull(message = "经度不能为空")
|
||||
private Double lon;
|
||||
|
||||
@Schema(description = "纬度")
|
||||
@NotNull(message = "纬度不能为空")
|
||||
private Double lat;
|
||||
|
||||
@Schema(description = "省")
|
||||
private String province;
|
||||
|
||||
@Schema(description = "市")
|
||||
private String city;
|
||||
|
||||
@Schema(description = "区")
|
||||
private String district;
|
||||
|
||||
@Schema(description = "详细地址")
|
||||
private String address;
|
||||
|
||||
}
|
||||
+18
-8
@@ -64,20 +64,30 @@ public class OperationRespVO {
|
||||
@ExcelProperty("创建时间")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
|
||||
private MemberVo member;
|
||||
|
||||
/**
|
||||
* 用户相关
|
||||
*/
|
||||
@Data
|
||||
public static class MemberVo {
|
||||
|
||||
@Schema(description = "用户头像")
|
||||
private String memberAvatar;
|
||||
@Schema(description = "用户编号")
|
||||
private Long memberId;
|
||||
|
||||
@Schema(description = "用户昵称")
|
||||
private String memberNickname;
|
||||
@Schema(description = "用户头像")
|
||||
private String memberAvatar;
|
||||
|
||||
@Schema(description = "用户年龄")
|
||||
private String memberAge;
|
||||
@Schema(description = "用户昵称")
|
||||
private String memberNickname;
|
||||
|
||||
@Schema(description = "用户职业")
|
||||
private String memberOcc;
|
||||
@Schema(description = "用户年龄")
|
||||
private String memberAge;
|
||||
|
||||
@Schema(description = "用户职业")
|
||||
private String memberOcc;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
+12
-1
@@ -10,9 +10,12 @@ public class RecentPageResVo extends RecentDO {
|
||||
@Schema(description = "用户朋友圈编号")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "用户信息")
|
||||
@Schema(description = "用户相关")
|
||||
private MemberVo member;
|
||||
|
||||
@Schema(description = "距离相关")
|
||||
private LocationVo location;
|
||||
|
||||
@Data
|
||||
public static class MemberVo {
|
||||
|
||||
@@ -33,4 +36,12 @@ public class RecentPageResVo extends RecentDO {
|
||||
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class LocationVo {
|
||||
|
||||
@Schema(description = "距离(千米)")
|
||||
private Double distance;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
package cn.iocoder.yudao.module.member.controller.app.location;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.module.member.controller.admin.location.vo.LocationSaveReqVO;
|
||||
import cn.iocoder.yudao.module.member.service.location.LocationService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.validation.Valid;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
|
||||
|
||||
@Tag(name = "用户 APP - 用户位置记录")
|
||||
@RestController
|
||||
@RequestMapping("/member/location")
|
||||
@Validated
|
||||
public class AppLocationController {
|
||||
|
||||
@Resource
|
||||
private LocationService locationService;
|
||||
|
||||
@PostMapping("/create")
|
||||
@Operation(summary = "创建用户位置记录")
|
||||
public CommonResult<Long> createLocation(@Valid @RequestBody LocationSaveReqVO createReqVO) {
|
||||
createReqVO.setMemberId(getLoginUserId());
|
||||
return success(locationService.createLocation(createReqVO));
|
||||
}
|
||||
|
||||
}
|
||||
-1
@@ -51,7 +51,6 @@ public class AppRecentController {
|
||||
return success(recentService.getByRecentId(recentId, getLoginUserId()));
|
||||
}
|
||||
|
||||
|
||||
@PostMapping("/operate")
|
||||
@Operation(summary = "朋友圈操作")
|
||||
public CommonResult<Long> operate(@Valid @RequestBody AppRecentOperateReqVo dto) {
|
||||
|
||||
+17
@@ -5,6 +5,8 @@ import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Schema(description = "用户 APP - 用户个人信息 Response VO")
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@@ -23,6 +25,21 @@ public class AppMemberUserInfoRespVO {
|
||||
@Schema(description = "用户手机号", requiredMode = Schema.RequiredMode.REQUIRED, example = "15601691300")
|
||||
private String mobile;
|
||||
|
||||
@Schema(description = "出生日期")
|
||||
private LocalDateTime birthday;
|
||||
|
||||
@Schema(description = "身高(cm)")
|
||||
private Double height;
|
||||
|
||||
@Schema(description = "体重(kg)")
|
||||
private Double weight;
|
||||
|
||||
@Schema(description = "职业")
|
||||
private String occ;
|
||||
|
||||
@Schema(description = "个人介绍")
|
||||
private String description;
|
||||
|
||||
@Schema(description = "用户性别", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
private Integer sex;
|
||||
|
||||
|
||||
+2
-2
@@ -27,9 +27,9 @@ public class AppMemberUserUpdateReqVO {
|
||||
private Double weight;
|
||||
|
||||
@Schema(description = "职业")
|
||||
private Double occ;
|
||||
private String occ;
|
||||
|
||||
@Schema(description = "个人介绍")
|
||||
private Double description;
|
||||
private String description;
|
||||
|
||||
}
|
||||
+61
@@ -0,0 +1,61 @@
|
||||
package cn.iocoder.yudao.module.member.dal.dataobject.location;
|
||||
|
||||
import lombok.*;
|
||||
|
||||
import java.util.*;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
||||
|
||||
/**
|
||||
* 用户位置记录 DO
|
||||
*
|
||||
* @author 聊天交友
|
||||
*/
|
||||
@TableName("member_location")
|
||||
@KeySequence("member_location_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class LocationDO extends BaseDO {
|
||||
|
||||
/**
|
||||
* 用户位置id
|
||||
*/
|
||||
@TableId
|
||||
private Long id;
|
||||
/**
|
||||
* 人员id
|
||||
*/
|
||||
private Long memberId;
|
||||
/**
|
||||
* 经度
|
||||
*/
|
||||
private Double lon;
|
||||
/**
|
||||
* 纬度
|
||||
*/
|
||||
private Double lat;
|
||||
/**
|
||||
* 省
|
||||
*/
|
||||
private String province;
|
||||
/**
|
||||
* 市
|
||||
*/
|
||||
private String city;
|
||||
/**
|
||||
* 区
|
||||
*/
|
||||
private String district;
|
||||
/**
|
||||
* 详细地址
|
||||
*/
|
||||
private String address;
|
||||
|
||||
}
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
package cn.iocoder.yudao.module.member.dal.mysql.location;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import cn.iocoder.yudao.module.member.dal.dataobject.location.LocationDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import cn.iocoder.yudao.module.member.controller.admin.location.vo.*;
|
||||
|
||||
/**
|
||||
* 用户位置记录 Mapper
|
||||
*
|
||||
* @author 聊天交友
|
||||
*/
|
||||
@Mapper
|
||||
public interface LocationMapper extends BaseMapperX<LocationDO> {
|
||||
|
||||
default PageResult<LocationDO> selectPage(LocationPageReqVO reqVO) {
|
||||
return selectPage(reqVO, new LambdaQueryWrapperX<LocationDO>()
|
||||
.eqIfPresent(LocationDO::getMemberId, reqVO.getMemberId())
|
||||
.eqIfPresent(LocationDO::getLon, reqVO.getLon())
|
||||
.eqIfPresent(LocationDO::getLat, reqVO.getLat())
|
||||
.eqIfPresent(LocationDO::getProvince, reqVO.getProvince())
|
||||
.eqIfPresent(LocationDO::getCity, reqVO.getCity())
|
||||
.eqIfPresent(LocationDO::getDistrict, reqVO.getDistrict())
|
||||
.eqIfPresent(LocationDO::getAddress, reqVO.getAddress())
|
||||
.betweenIfPresent(LocationDO::getCreateTime, reqVO.getCreateTime())
|
||||
.orderByDesc(LocationDO::getId));
|
||||
}
|
||||
|
||||
}
|
||||
+55
@@ -0,0 +1,55 @@
|
||||
package cn.iocoder.yudao.module.member.service.location;
|
||||
|
||||
import javax.validation.*;
|
||||
|
||||
import cn.iocoder.yudao.module.member.controller.admin.location.vo.*;
|
||||
import cn.iocoder.yudao.module.member.dal.dataobject.location.LocationDO;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 用户位置记录 Service 接口
|
||||
*/
|
||||
public interface LocationService {
|
||||
|
||||
/**
|
||||
* 创建用户位置记录
|
||||
*/
|
||||
Long createLocation(@Valid LocationSaveReqVO createReqVO);
|
||||
|
||||
/**
|
||||
* 更新用户位置记录
|
||||
*/
|
||||
void updateLocation(@Valid LocationSaveReqVO updateReqVO);
|
||||
|
||||
/**
|
||||
* 删除用户位置记录
|
||||
*/
|
||||
void deleteLocation(Long id);
|
||||
|
||||
/**
|
||||
* 获得用户位置记录
|
||||
*/
|
||||
LocationDO getLocation(Long id);
|
||||
|
||||
/**
|
||||
* 获得用户最后位置记录
|
||||
*/
|
||||
LocationDO getLastByMemberId(Long memberId);
|
||||
|
||||
/**
|
||||
* 获得当前用户位置记录
|
||||
*/
|
||||
LocationDO getCurrentUserLastLocation();
|
||||
|
||||
/**
|
||||
* 获得用户最后的位置记录列表
|
||||
*/
|
||||
List<LocationDO> getLastLocationList(List<Long> memberIds);
|
||||
|
||||
/**
|
||||
* 获得用户位置记录分页
|
||||
*/
|
||||
PageResult<LocationDO> getLocationPage(LocationPageReqVO pageReqVO);
|
||||
}
|
||||
+115
@@ -0,0 +1,115 @@
|
||||
package cn.iocoder.yudao.module.member.service.location;
|
||||
|
||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import cn.iocoder.yudao.module.member.enums.MemberErrorCode;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import cn.iocoder.yudao.module.member.controller.admin.location.vo.*;
|
||||
import cn.iocoder.yudao.module.member.dal.dataobject.location.LocationDO;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
|
||||
import cn.iocoder.yudao.module.member.dal.mysql.location.LocationMapper;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
|
||||
|
||||
/**
|
||||
* 用户位置记录 Service 实现类
|
||||
*/
|
||||
@Service
|
||||
@Validated
|
||||
public class LocationServiceImpl implements LocationService {
|
||||
|
||||
@Resource
|
||||
private LocationMapper locationMapper;
|
||||
|
||||
@Override
|
||||
public Long createLocation(LocationSaveReqVO createReqVO) {
|
||||
// 插入
|
||||
LocationDO location = BeanUtils.toBean(createReqVO, LocationDO.class);
|
||||
locationMapper.insert(location);
|
||||
// 返回
|
||||
return location.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateLocation(LocationSaveReqVO updateReqVO) {
|
||||
// 校验存在
|
||||
validateLocationExists(updateReqVO.getId());
|
||||
// 更新
|
||||
LocationDO updateObj = BeanUtils.toBean(updateReqVO, LocationDO.class);
|
||||
locationMapper.updateById(updateObj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteLocation(Long id) {
|
||||
// 校验存在
|
||||
validateLocationExists(id);
|
||||
// 删除
|
||||
locationMapper.deleteById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public LocationDO getLocation(Long id) {
|
||||
return locationMapper.selectById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得用户最后位置记录
|
||||
*/
|
||||
@Override
|
||||
public LocationDO getLastByMemberId(Long memberId) {
|
||||
return locationMapper.selectOne(new LambdaQueryWrapperX<LocationDO>()
|
||||
.eq(LocationDO::getMemberId, memberId)
|
||||
.orderByDesc(LocationDO::getCreateTime)
|
||||
.orderByDesc(LocationDO::getId)
|
||||
.last(" LIMIT 1")
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得当前用户位置记录
|
||||
*/
|
||||
@Override
|
||||
public LocationDO getCurrentUserLastLocation() {
|
||||
return locationMapper.selectOne(new LambdaQueryWrapperX<LocationDO>()
|
||||
.eq(LocationDO::getMemberId, getLoginUserId())
|
||||
.orderByDesc(LocationDO::getCreateTime)
|
||||
.orderByDesc(LocationDO::getId)
|
||||
.last(" LIMIT 1")
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得用户最后的位置记录列表
|
||||
*/
|
||||
@Override
|
||||
public List<LocationDO> getLastLocationList(List<Long> memberIds) {
|
||||
return locationMapper.selectList(new LambdaQueryWrapperX<LocationDO>()
|
||||
.eq(LocationDO::getMemberId, getLoginUserId())
|
||||
.orderByDesc(LocationDO::getCreateTime)
|
||||
.orderByDesc(LocationDO::getId)
|
||||
.groupBy(LocationDO::getMemberId)
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<LocationDO> getLocationPage(LocationPageReqVO pageReqVO) {
|
||||
return locationMapper.selectPage(pageReqVO);
|
||||
}
|
||||
|
||||
private void validateLocationExists(Long id) {
|
||||
if (locationMapper.selectById(id) == null) {
|
||||
throw exception(MemberErrorCode.LOCATION_NOT_EXISTS);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+126
-37
@@ -3,19 +3,27 @@ package cn.iocoder.yudao.module.member.service.recent;
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.IterUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.iocoder.yudao.framework.common.util.number.NumberUtils;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import cn.iocoder.yudao.module.member.controller.app.recent.vo.AppRecentLikeReqVo;
|
||||
import cn.iocoder.yudao.module.member.controller.app.recent.vo.AppRecentOperateReqVo;
|
||||
import cn.iocoder.yudao.module.member.dal.dataobject.location.LocationDO;
|
||||
import cn.iocoder.yudao.module.member.dal.dataobject.recent.OperationDO;
|
||||
import cn.iocoder.yudao.module.member.dal.dataobject.user.MemberUserDO;
|
||||
import cn.iocoder.yudao.module.member.dal.mysql.recent.OperationMapper;
|
||||
import cn.iocoder.yudao.module.member.enums.MemberErrorCode;
|
||||
import cn.iocoder.yudao.module.member.enums.MemberRecentOperateEnum;
|
||||
import cn.iocoder.yudao.module.member.service.location.LocationService;
|
||||
import cn.iocoder.yudao.module.member.service.thirdauth.ThirdAuthService;
|
||||
import cn.iocoder.yudao.module.member.service.user.MemberUserService;
|
||||
import com.aliyun.green20220302.models.ImageBatchModerationResponseBody;
|
||||
import com.aliyun.green20220302.models.TextModerationPlusResponseBody;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import cn.iocoder.yudao.module.member.controller.admin.recent.vo.*;
|
||||
@@ -27,9 +35,9 @@ import cn.iocoder.yudao.module.member.dal.mysql.recent.RecentMapper;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
@@ -39,6 +47,7 @@ import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionU
|
||||
*
|
||||
* @author 聊天交友
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
@Validated
|
||||
public class RecentServiceImpl implements RecentService {
|
||||
@@ -50,8 +59,17 @@ public class RecentServiceImpl implements RecentService {
|
||||
|
||||
@Resource
|
||||
private MemberUserService memberUserService;
|
||||
@Resource
|
||||
private LocationService locationService;
|
||||
|
||||
@Resource
|
||||
private ThirdAuthService thirdAuthService;
|
||||
|
||||
/**
|
||||
* 创建朋友圈
|
||||
*/
|
||||
@Override
|
||||
@Transactional
|
||||
public Long createRecent(RecentSaveReqVO vo) {
|
||||
// 查询用户
|
||||
MemberUserDO user = memberUserService.getUser(vo.getMemberId());
|
||||
@@ -61,6 +79,27 @@ public class RecentServiceImpl implements RecentService {
|
||||
// 插入
|
||||
RecentDO recent = BeanUtils.toBean(vo, RecentDO.class);
|
||||
recentMapper.insert(recent);
|
||||
|
||||
// 文字和图片违规处理
|
||||
CompletableFuture<TextModerationPlusResponseBody.TextModerationPlusResponseBodyData> textFuture = CompletableFuture.supplyAsync(() -> thirdAuthService.textAuditSync(vo.getDescription()));
|
||||
CompletableFuture<ImageBatchModerationResponseBody.ImageBatchModerationResponseBodyData> imageFuture = CompletableFuture.supplyAsync(() -> thirdAuthService.imageAuditSync(vo.getCoverPic()));
|
||||
|
||||
try {
|
||||
TextModerationPlusResponseBody.TextModerationPlusResponseBodyData textRes = textFuture.get();
|
||||
ImageBatchModerationResponseBody.ImageBatchModerationResponseBodyData imageRes = imageFuture.get();
|
||||
// 处理文字
|
||||
if (ObjectUtil.isEmpty(textRes)) {
|
||||
throw exception(MemberErrorCode.CHECK_TEXT_NOT_PASS, "未知错误");
|
||||
}
|
||||
// 处理图片
|
||||
if (ObjectUtil.isEmpty(imageRes)) {
|
||||
throw exception(MemberErrorCode.CHECK_IMAGE_NOT_PASS, "未知错误");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("|创建朋友圈|,以外的错误error:{}", e.getMessage());
|
||||
throw new RuntimeException(e.getMessage());
|
||||
}
|
||||
|
||||
// 返回
|
||||
return recent.getId();
|
||||
}
|
||||
@@ -74,8 +113,13 @@ public class RecentServiceImpl implements RecentService {
|
||||
// 查询朋友圈
|
||||
RecentDO recent = recentMapper.selectById(recentId);
|
||||
RecentPageResVo result = BeanUtil.toBean(recent, RecentPageResVo.class);
|
||||
|
||||
LocationDO currentUserLastLocation = locationService.getCurrentUserLastLocation();
|
||||
|
||||
// 查询发送朋友圈用户
|
||||
convertRecentPageResVoSetupMember(result);
|
||||
// 查询用户最新的位置
|
||||
convertRecentPageResVoSetupLocation(result, currentUserLastLocation);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -217,18 +261,8 @@ public class RecentServiceImpl implements RecentService {
|
||||
|
||||
List<OperationRespVO> resultList = BeanUtils.toBean(list, OperationRespVO.class);
|
||||
|
||||
for (OperationRespVO entity : resultList) {
|
||||
// 用户相关
|
||||
if (ObjectUtil.isNotEmpty(memberMap)) {
|
||||
MemberUserDO member = memberMap.get(entity.getMemberId());
|
||||
if (ObjectUtil.isNotEmpty(member)) {
|
||||
entity.setMemberAvatar(member.getAvatar());
|
||||
entity.setMemberNickname(member.getNickname());
|
||||
entity.setMemberAge(member.getAge());
|
||||
entity.setMemberOcc(member.getOcc());
|
||||
}
|
||||
}
|
||||
}
|
||||
// 为OperationRespVO设置Member信息
|
||||
convertOperationRespVOSetupMember(resultList);
|
||||
|
||||
resultPageList.setList(resultList);
|
||||
resultPageList.setTotal(pageList.getTotal());
|
||||
@@ -240,7 +274,6 @@ public class RecentServiceImpl implements RecentService {
|
||||
*/
|
||||
@Override
|
||||
public PageResult<OperationRespVO> likeMePage(AppRecentLikeReqVo dto) {
|
||||
PageResult<OperationRespVO> resultPageList = new PageResult<>();
|
||||
// 查询我喜欢
|
||||
PageResult<OperationDO> pageList = operationMapper.selectPage(dto, new LambdaQueryWrapperX<OperationDO>()
|
||||
.eq(OperationDO::getMemberId, dto.getMemberId())
|
||||
@@ -250,31 +283,13 @@ public class RecentServiceImpl implements RecentService {
|
||||
.orderByDesc(OperationDO::getId)
|
||||
);
|
||||
List<OperationDO> list = pageList.getList();
|
||||
if (ObjectUtil.isEmpty(list)) return resultPageList;
|
||||
|
||||
List<Long> operatorMemberIds = list.stream().map(OperationDO::getOperatorMemberId).collect(Collectors.toList());
|
||||
// 查询用户
|
||||
List<MemberUserDO> memberList = memberUserService.getUserList(operatorMemberIds);
|
||||
Map<Long, MemberUserDO> memberMap = IterUtil.toMap(memberList, MemberUserDO::getId);
|
||||
|
||||
if (ObjectUtil.isEmpty(list)) return new PageResult<>();
|
||||
List<OperationRespVO> resultList = BeanUtils.toBean(list, OperationRespVO.class);
|
||||
|
||||
for (OperationRespVO entity : resultList) {
|
||||
// 用户相关
|
||||
if (ObjectUtil.isNotEmpty(memberMap)) {
|
||||
MemberUserDO member = memberMap.get(entity.getMemberId());
|
||||
if (ObjectUtil.isNotEmpty(member)) {
|
||||
entity.setMemberAvatar(member.getAvatar());
|
||||
entity.setMemberNickname(member.getNickname());
|
||||
entity.setMemberAge(member.getAge());
|
||||
entity.setMemberOcc(member.getOcc());
|
||||
}
|
||||
}
|
||||
}
|
||||
// 为OperationRespVO设置Member信息
|
||||
convertOperationRespVOSetupMember(resultList);
|
||||
|
||||
resultPageList.setList(resultList);
|
||||
resultPageList.setTotal(pageList.getTotal());
|
||||
return resultPageList;
|
||||
return new PageResult<>(resultList, pageList.getTotal());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -298,7 +313,22 @@ public class RecentServiceImpl implements RecentService {
|
||||
*/
|
||||
@Override
|
||||
public PageResult<OperationRespVO> evaluatePage(AppRecentLikeReqVo dto) {
|
||||
return null;
|
||||
// 我的评价
|
||||
PageResult<OperationDO> pageList = operationMapper.selectPage(dto, new LambdaQueryWrapperX<OperationDO>()
|
||||
.eq(OperationDO::getOperatorMemberId, dto.getMemberId())
|
||||
.eq(OperationDO::getBizType, MemberRecentOperateEnum.MEMBER_RATING.getType())
|
||||
.isNull(OperationDO::getCancelTime)
|
||||
.orderByDesc(OperationDO::getTapTime)
|
||||
.orderByDesc(OperationDO::getId)
|
||||
);
|
||||
List<OperationDO> list = pageList.getList();
|
||||
if (ObjectUtil.isEmpty(list)) return new PageResult<>();
|
||||
List<OperationRespVO> resultList = BeanUtils.toBean(list, OperationRespVO.class);
|
||||
|
||||
// 为OperationRespVO设置Member信息
|
||||
convertOperationRespVOSetupMember(resultList);
|
||||
|
||||
return new PageResult<>(resultList, pageList.getTotal());
|
||||
}
|
||||
|
||||
private void validateRecentExists(Long id) {
|
||||
@@ -345,4 +375,63 @@ public class RecentServiceImpl implements RecentService {
|
||||
detail.setMember(memberVO);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 为RecentPageResVo设置Location信息
|
||||
*/
|
||||
private void convertRecentPageResVoSetupLocation(List<RecentPageResVo> list, LocationDO selfLocation) {
|
||||
if (ObjectUtil.isEmpty(list)) return;
|
||||
List<Long> memberIds = list.stream().map(RecentPageResVo::getMemberId).collect(Collectors.toList());
|
||||
List<LocationDO> LocationList = locationService.getLastLocationList(memberIds);
|
||||
Map<Long, LocationDO> LocationMap = IterUtil.toMap(LocationList, LocationDO::getId);
|
||||
for (RecentPageResVo entity : list) {
|
||||
// 位置相关
|
||||
if (ObjectUtil.isNotEmpty(LocationMap)) {
|
||||
LocationDO targetLocation = LocationMap.get(entity.getMemberId());
|
||||
if (ObjectUtil.isNotEmpty(targetLocation)) {
|
||||
RecentPageResVo.LocationVo locationVo = new RecentPageResVo.LocationVo();
|
||||
double distance = NumberUtils.getDistance(targetLocation.getLat(), targetLocation.getLon(), selfLocation.getLat(), selfLocation.getLon());
|
||||
locationVo.setDistance(distance);
|
||||
entity.setLocation(locationVo);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void convertRecentPageResVoSetupLocation(RecentPageResVo detail, LocationDO selfLocation) {
|
||||
if (ObjectUtil.isEmpty(detail)) return;
|
||||
LocationDO targetLocation = locationService.getLastByMemberId(detail.getMemberId());
|
||||
if (ObjectUtil.isNotEmpty(targetLocation)) {
|
||||
RecentPageResVo.LocationVo locationVo = new RecentPageResVo.LocationVo();
|
||||
double distance = NumberUtils.getDistance(targetLocation.getLat(), targetLocation.getLon(), selfLocation.getLat(), selfLocation.getLon());
|
||||
locationVo.setDistance(distance);
|
||||
detail.setLocation(locationVo);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 为OperationRespVO设置Member信息
|
||||
*/
|
||||
private void convertOperationRespVOSetupMember(List<OperationRespVO> list) {
|
||||
if (ObjectUtil.isEmpty(list)) return;
|
||||
List<Long> memberIds = list.stream().map(OperationRespVO::getMemberId).collect(Collectors.toList());
|
||||
List<MemberUserDO> memberList = memberUserService.getUserList(memberIds);
|
||||
Map<Long, MemberUserDO> memberMap = IterUtil.toMap(memberList, MemberUserDO::getId);
|
||||
for (OperationRespVO entity : list) {
|
||||
// 用户相关
|
||||
if (ObjectUtil.isNotEmpty(memberMap)) {
|
||||
MemberUserDO member = memberMap.get(entity.getMemberId());
|
||||
if (ObjectUtil.isNotEmpty(member)) {
|
||||
OperationRespVO.MemberVo memberVO = new OperationRespVO.MemberVo();
|
||||
memberVO.setMemberId(member.getId());
|
||||
memberVO.setMemberAvatar(member.getAvatar());
|
||||
memberVO.setMemberNickname(member.getNickname());
|
||||
memberVO.setMemberAge(member.getAge());
|
||||
memberVO.setMemberOcc(member.getOcc());
|
||||
entity.setMember(memberVO);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
package cn.iocoder.yudao.module.member.service.thirdauth;
|
||||
|
||||
import com.aliyun.green20220302.models.ImageBatchModerationResponseBody;
|
||||
import com.aliyun.green20220302.models.TextModerationPlusResponseBody;
|
||||
|
||||
/**
|
||||
* @author liusiyang_dxm
|
||||
* @since 2025/11/7
|
||||
*/
|
||||
public interface ThirdAuthService {
|
||||
|
||||
/**
|
||||
* 文本审核
|
||||
*/
|
||||
TextModerationPlusResponseBody.TextModerationPlusResponseBodyData textAuditSync(String text);
|
||||
|
||||
/**
|
||||
* 图片审核-同步
|
||||
*/
|
||||
ImageBatchModerationResponseBody.ImageBatchModerationResponseBodyData imageAuditSync(String imageUrl);
|
||||
|
||||
}
|
||||
+109
@@ -0,0 +1,109 @@
|
||||
package cn.iocoder.yudao.module.member.service.thirdauth;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.aliyun.green20220302.Client;
|
||||
import com.aliyun.green20220302.models.*;
|
||||
import com.aliyun.teaopenapi.models.Config;
|
||||
|
||||
import com.aliyun.teautil.models.RuntimeOptions;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* 第三方审核
|
||||
*/
|
||||
@Service
|
||||
@Valid
|
||||
@Slf4j
|
||||
public class ThirdAuthServiceImpl implements ThirdAuthService {
|
||||
|
||||
private volatile Client clientInstance;
|
||||
|
||||
/**
|
||||
* 初始化第三方审核
|
||||
*/
|
||||
private Client createClient() {
|
||||
if (clientInstance == null) {
|
||||
synchronized (ThirdAuthServiceImpl.class) {
|
||||
if (clientInstance == null) {
|
||||
try {
|
||||
Config config = new Config();
|
||||
config.setAccessKeyId("LTAI5tJ7sSxB96XaY9T3Vq3D");
|
||||
config.setAccessKeySecret("EVXWFTS2SB6UkjUVFLhTDBfIvIXgI3");
|
||||
config.setEndpoint("green-cip.cn-shanghai.aliyuncs.com");
|
||||
//读取时超时时间,单位毫秒(ms)
|
||||
config.setReadTimeout(6000);
|
||||
//连接时超时时间,单位毫秒(ms)
|
||||
config.setConnectTimeout(3000);
|
||||
clientInstance = new Client(config);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
log.error("|初始化第三方审核|,意外的错误:{}", e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return clientInstance;
|
||||
}
|
||||
|
||||
/**
|
||||
* 文本审核
|
||||
*/
|
||||
@Override
|
||||
public TextModerationPlusResponseBody.TextModerationPlusResponseBodyData textAuditSync(String text) {
|
||||
try {
|
||||
Client client = createClient();
|
||||
if (ObjectUtil.isEmpty(client)) return null;
|
||||
HashMap<String, Object> query = new HashMap<>();
|
||||
TextModerationPlusRequest textModerationPlusRequest = new TextModerationPlusRequest();
|
||||
// 检测类型
|
||||
textModerationPlusRequest.setService("comment_detection_pro");
|
||||
textModerationPlusRequest.setServiceParameters(JSONUtil.toJsonStr(query));
|
||||
TextModerationPlusResponse response = client.textModerationPlus(textModerationPlusRequest);
|
||||
if (response.getStatusCode() != 200) {
|
||||
throw new RuntimeException("文本审核失败code:" + response.getStatusCode());
|
||||
}
|
||||
TextModerationPlusResponseBody result = response.getBody();
|
||||
return result.getData();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
log.error("|文本审核|,意外的错误text:{}error:{}", text, e.getMessage());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 图片审核-同步
|
||||
*/
|
||||
@Override
|
||||
public ImageBatchModerationResponseBody.ImageBatchModerationResponseBodyData imageAuditSync(String imageUrl) {
|
||||
try {
|
||||
Client client = createClient();
|
||||
if (ObjectUtil.isEmpty(client)) return null;
|
||||
RuntimeOptions runtime = new RuntimeOptions();
|
||||
Map<String, String> query = new HashMap<>();
|
||||
query.put("imageUrl", imageUrl);
|
||||
query.put("dataId", UUID.randomUUID().toString());
|
||||
ImageBatchModerationRequest imageBatchModerationRequest = new ImageBatchModerationRequest();
|
||||
imageBatchModerationRequest.setService("baselineCheck,baselineCheck_pro");
|
||||
imageBatchModerationRequest.setServiceParameters(JSONUtil.toJsonStr(query));
|
||||
ImageBatchModerationResponse response = client.imageBatchModerationWithOptions(imageBatchModerationRequest, runtime);
|
||||
if (response.getStatusCode() != 200) {
|
||||
throw new RuntimeException("文本审核失败code:" + response.getStatusCode());
|
||||
}
|
||||
ImageBatchModerationResponseBody result = response.getBody();
|
||||
return result.getData();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
log.error("|图片审核-同步|,意外的错误text:{}error:{}", imageUrl, e.getMessage());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user