记得上下班打卡 | git大法好,push需谨慎

Commit deccfdae authored by wangyifan's avatar wangyifan

关联/取消关联时增加艺人操作日志

parent 0e22266b
......@@ -16,7 +16,11 @@ import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.HashSet;
import java.util.HashMap;
import java.util.stream.Collectors;
import com.liquidnet.service.kylin.service.admin.IKylinArtistOperationLogService;
@Slf4j
......@@ -32,6 +36,9 @@ public class KylinArtistPerformanceServiceImpl extends ServiceImpl<KylinArtistPe
@Autowired
private DataUtils dataUtils;
@Autowired
private IKylinArtistOperationLogService operationLogService;
@Override
public List<KylinArtistPerformanceDao> getSessionArtists(String performancesId, String timesId) {
// 查询该场次的艺人
......@@ -60,9 +67,30 @@ public class KylinArtistPerformanceServiceImpl extends ServiceImpl<KylinArtistPe
@Override
public int deletePerformanceArtist(Long mid, String performanceId) {
KylinArtistPerformance association = artistPerformanceMapper.selectById(mid);
if (association == null) {
return 0;
}
String artistId = association.getArtistId();
// 记录删除前的关联数量
Integer beforeCount = artistPerformanceMapper.selectCount(new QueryWrapper<KylinArtistPerformance>().eq("artist_id", artistId));
beforeCount = beforeCount == null ? 0 : beforeCount;
// 删除缓存演出阵容
dataUtils.delPerformanceArtists(performanceId);
return artistPerformanceMapper.deleteById(mid);
int result = artistPerformanceMapper.deleteById(mid);
// 记录删除后的关联数量
Integer afterCount = artistPerformanceMapper.selectCount(new QueryWrapper<KylinArtistPerformance>().eq("artist_id", artistId));
afterCount = afterCount == null ? 0 : afterCount;
if (!beforeCount.equals(afterCount)) {
String logContent = String.format("更新关联演出数量:从[%d]场改为[%d]场,", beforeCount, afterCount);
operationLogService.recordLog(artistId, 2, logContent);
}
return result;
}
@Override
......@@ -100,6 +128,34 @@ public class KylinArtistPerformanceServiceImpl extends ServiceImpl<KylinArtistPe
@Override
public boolean updateArtistAssociations(String performancesId, String timesId, List<Map<String, Object>> artistOrders) {
// 先查询该演出、场次下关联的旧艺人
List<KylinArtistPerformance> oldAssociations = artistPerformanceMapper.selectList(new QueryWrapper<KylinArtistPerformance>()
.eq("performances_id", performancesId)
.eq("times_id", timesId));
Set<String> affectedArtistIds = new HashSet<>(); // 旧关联的艺人ID set
if (oldAssociations != null) {
for (KylinArtistPerformance a : oldAssociations) {
affectedArtistIds.add(a.getArtistId());
}
}
if (artistOrders != null && !artistOrders.isEmpty()) {
for (Map<String, Object> item : artistOrders) {
String artistId = (String) item.get("artistId");
if (artistId != null) {
affectedArtistIds.add(artistId);
}
}
}
// Record before counts
Map<String, Integer> beforeCounts = new HashMap<>();
for (String artistId : affectedArtistIds) {
Integer count = artistPerformanceMapper.selectCount(new QueryWrapper<KylinArtistPerformance>().eq("artist_id", artistId));
beforeCounts.put(artistId, count == null ? 0 : count);
}
// 1. 删除当前场次所有已关联的艺人
artistPerformanceMapper.delete(new QueryWrapper<KylinArtistPerformance>()
.eq("performances_id", performancesId)
......@@ -120,6 +176,18 @@ public class KylinArtistPerformanceServiceImpl extends ServiceImpl<KylinArtistPe
artistPerformanceMapper.insert(newAssociation);
}
}
// 3. Compare and log
for (String artistId : affectedArtistIds) {
Integer afterCount = artistPerformanceMapper.selectCount(new QueryWrapper<KylinArtistPerformance>().eq("artist_id", artistId));
afterCount = afterCount == null ? 0 : afterCount;
Integer beforeCount = beforeCounts.get(artistId);
if (!beforeCount.equals(afterCount)) {
String logContent = String.format("更新关联演出数量:从[%d]场改为[%d]场,", beforeCount, afterCount);
operationLogService.recordLog(artistId, 2, logContent);
}
}
// 删除缓存演出阵容
dataUtils.delPerformanceArtists(performancesId);
return true;
......
......@@ -58,8 +58,8 @@ info:
artifactId: '@project.artifactId@'
version: '@project.version@'
# -----------------------------------------------------------
#mybatis-plus:
# mapper-locations: classpath*:com.liquidnet.service.*.mapper/*Mapper.xml
mybatis-plus:
mapper-locations: classpath*:com.liquidnet.service.*.mapper/*Mapper.xml
# -----------------------------------------------------------
spring:
application:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment