You've already forked FrameTour-BE
feat(source): 添加管理员关联管理功能
- 新增管理员取消关联接口,实现软删除功能 - 新增管理员恢复关联接口,支持已取消记录的重新激活 - 新增查询已取消关联记录的分页接口 - 在MemberSourceEntity实体类中添加deleted和deletedAt字段 - 更新多个Mapper XML文件中的查询条件,过滤已删除记录 - 实现在删除和恢复操作后清除相关缓存的逻辑 - 添加对已删除记录的时间格式化显示支持
This commit is contained in:
@@ -95,4 +95,34 @@ public class SourceController {
|
||||
return sourceService.pageByFaceId(sourceReqQuery);
|
||||
}
|
||||
|
||||
/**
|
||||
* 管理员取消关联(软删除)
|
||||
* @param id member_source 记录 ID
|
||||
* @return 操作结果
|
||||
*/
|
||||
@PostMapping("/admin/cancel/{id}")
|
||||
public ApiResponse cancelRelation(@PathVariable("id") Long id) {
|
||||
return sourceService.cancelRelation(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 管理员恢复已取消的关联
|
||||
* @param id member_source 记录 ID
|
||||
* @return 操作结果
|
||||
*/
|
||||
@PostMapping("/admin/reactivate/{id}")
|
||||
public ApiResponse reactivateRelation(@PathVariable("id") Long id) {
|
||||
return sourceService.reactivateRelation(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 管理员查询已取消的关联记录
|
||||
* @param sourceReqQuery 查询参数(需设置faceId,可选type/scenicId)
|
||||
* @return 分页已取消关联列表
|
||||
*/
|
||||
@PostMapping("/admin/pageDeletedByFaceId")
|
||||
public ApiResponse pageDeletedByFaceId(@RequestBody SourceReqQuery sourceReqQuery) {
|
||||
return sourceService.pageDeletedByFaceId(sourceReqQuery);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -195,4 +195,12 @@ public interface SourceMapper {
|
||||
* @return source响应列表
|
||||
*/
|
||||
List<SourceRespVO> pageByFaceId(SourceReqQuery sourceReqQuery);
|
||||
|
||||
int softDeleteRelation(Long id);
|
||||
|
||||
int reactivateRelation(Long id);
|
||||
|
||||
List<SourceRespVO> pageDeletedByFaceId(SourceReqQuery sourceReqQuery);
|
||||
|
||||
MemberSourceEntity getMemberSourceById(Long id);
|
||||
}
|
||||
|
||||
@@ -3,6 +3,8 @@ package com.ycwl.basic.model.pc.source.entity;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
@TableName("member_source")
|
||||
public class MemberSourceEntity {
|
||||
@@ -15,4 +17,6 @@ public class MemberSourceEntity {
|
||||
private Integer isBuy;
|
||||
private Long orderId;
|
||||
private Integer isFree;
|
||||
private Integer deleted;
|
||||
private Date deletedAt;
|
||||
}
|
||||
|
||||
@@ -46,4 +46,6 @@ public class SourceRespVO {
|
||||
// 是否购买:0未购买,1已购买
|
||||
private int isBuy;
|
||||
private int isFree;
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
private Date deletedAt;
|
||||
}
|
||||
|
||||
@@ -38,4 +38,25 @@ public interface SourceService {
|
||||
* @return 分页结果
|
||||
*/
|
||||
ApiResponse<PageInfo<SourceRespVO>> pageByFaceId(SourceReqQuery sourceReqQuery);
|
||||
|
||||
/**
|
||||
* 管理员软删除(取消)关联记录
|
||||
* @param id member_source 记录 ID
|
||||
* @return 操作结果
|
||||
*/
|
||||
ApiResponse<Void> cancelRelation(Long id);
|
||||
|
||||
/**
|
||||
* 管理员恢复已取消的关联记录
|
||||
* @param id member_source 记录 ID
|
||||
* @return 操作结果
|
||||
*/
|
||||
ApiResponse<Void> reactivateRelation(Long id);
|
||||
|
||||
/**
|
||||
* 分页查询已取消的关联记录(管理员用)
|
||||
* @param sourceReqQuery 查询参数(需设置faceId)
|
||||
* @return 分页结果
|
||||
*/
|
||||
ApiResponse<PageInfo<SourceRespVO>> pageDeletedByFaceId(SourceReqQuery sourceReqQuery);
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.ycwl.basic.service.pc.impl;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.ycwl.basic.exception.BaseException;
|
||||
import com.ycwl.basic.biz.FaceStatusManager;
|
||||
import com.ycwl.basic.integration.scenic.dto.scenic.ScenicV2DTO;
|
||||
import com.ycwl.basic.mapper.SourceMapper;
|
||||
import com.ycwl.basic.model.pc.device.entity.DeviceEntity;
|
||||
@@ -12,6 +13,7 @@ import com.ycwl.basic.model.pc.source.entity.SourceEntity;
|
||||
import com.ycwl.basic.model.pc.source.req.SourceReqQuery;
|
||||
import com.ycwl.basic.model.pc.source.resp.SourceRespVO;
|
||||
import com.ycwl.basic.repository.DeviceRepository;
|
||||
import com.ycwl.basic.repository.MemberRelationRepository;
|
||||
import com.ycwl.basic.repository.ScenicRepository;
|
||||
import com.ycwl.basic.repository.SourceRepository;
|
||||
import com.ycwl.basic.service.pc.ScenicService;
|
||||
@@ -54,6 +56,10 @@ public class SourceServiceImpl implements SourceService {
|
||||
private ScenicRepository scenicRepository;
|
||||
@Autowired
|
||||
private DeviceRepository deviceRepository;
|
||||
@Autowired
|
||||
private MemberRelationRepository memberRelationRepository;
|
||||
@Autowired
|
||||
private FaceStatusManager faceStatusManager;
|
||||
|
||||
@Override
|
||||
public ApiResponse<PageInfo<SourceRespVO>> pageQuery(SourceReqQuery sourceReqQuery) {
|
||||
@@ -232,4 +238,47 @@ public class SourceServiceImpl implements SourceService {
|
||||
PageInfo<SourceRespVO> pageInfo = new PageInfo<>(list);
|
||||
return ApiResponse.success(pageInfo);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ApiResponse<Void> cancelRelation(Long id) {
|
||||
MemberSourceEntity entity = sourceMapper.getMemberSourceById(id);
|
||||
if (entity == null) {
|
||||
return ApiResponse.fail("关联记录不存在");
|
||||
}
|
||||
int rows = sourceMapper.softDeleteRelation(id);
|
||||
if (rows == 0) {
|
||||
return ApiResponse.fail("记录已取消或不存在");
|
||||
}
|
||||
invalidateCacheByFace(entity.getFaceId());
|
||||
return ApiResponse.success(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ApiResponse<Void> reactivateRelation(Long id) {
|
||||
MemberSourceEntity entity = sourceMapper.getMemberSourceById(id);
|
||||
if (entity == null) {
|
||||
return ApiResponse.fail("关联记录不存在");
|
||||
}
|
||||
int rows = sourceMapper.reactivateRelation(id);
|
||||
if (rows == 0) {
|
||||
return ApiResponse.fail("记录未处于取消状态");
|
||||
}
|
||||
invalidateCacheByFace(entity.getFaceId());
|
||||
return ApiResponse.success(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ApiResponse<PageInfo<SourceRespVO>> pageDeletedByFaceId(SourceReqQuery sourceReqQuery) {
|
||||
PageHelper.startPage(sourceReqQuery.getPageNum(), sourceReqQuery.getPageSize());
|
||||
List<SourceRespVO> list = sourceMapper.pageDeletedByFaceId(sourceReqQuery);
|
||||
PageInfo<SourceRespVO> pageInfo = new PageInfo<>(list);
|
||||
return ApiResponse.success(pageInfo);
|
||||
}
|
||||
|
||||
private void invalidateCacheByFace(Long faceId) {
|
||||
if (faceId != null) {
|
||||
memberRelationRepository.clearSCacheByFace(faceId);
|
||||
faceStatusManager.invalidatePuzzleSourceVersion(faceId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user