v0.0.18 #13
+4
-4
@@ -46,8 +46,8 @@ public class TempFileServiceImplement implements TempFileService {
|
||||
|
||||
public List<TempFileResp> create(List<MultipartFile> files, Long ttl) throws TimiException {
|
||||
Logger logger = new Logger();
|
||||
logger.setModule("TEMP_FILE");
|
||||
logger.setOperation("STORE");
|
||||
logger.setModule(Logger.Module.COMMON);
|
||||
logger.setOperation("TEMP_FILE_STORE");
|
||||
logger.setIp(TimiSpring.getRequestIP());
|
||||
try {
|
||||
logger.setContent(jackson.writeValueAsString(logRequestArgs(files, ttl)));
|
||||
@@ -116,8 +116,8 @@ public class TempFileServiceImplement implements TempFileService {
|
||||
@Override
|
||||
public void save(TempFileSaveReq request) {
|
||||
Logger logger = new Logger();
|
||||
logger.setModule("TEMP_FILE");
|
||||
logger.setOperation("SAVE");
|
||||
logger.setModule(Logger.Module.COMMON);
|
||||
logger.setOperation("TEMP_FILE_SAVE");
|
||||
logger.setIp(TimiSpring.getRequestIP());
|
||||
try {
|
||||
logger.setContent(jackson.writeValueAsString(request));
|
||||
|
||||
+131
-30
@@ -1,5 +1,6 @@
|
||||
package com.imyeyu.api.modules.gao.service.implement;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.imyeyu.api.config.dbsource.TimiServerDBConfig;
|
||||
import com.imyeyu.api.modules.common.entity.Attachment;
|
||||
import com.imyeyu.api.modules.common.service.AttachmentService;
|
||||
@@ -7,21 +8,25 @@ import com.imyeyu.api.modules.common.vo.attach.BizUpdateReq;
|
||||
import com.imyeyu.api.modules.gao.entity.GaoCustomer;
|
||||
import com.imyeyu.api.modules.gao.mapper.GaoCustomerMapper;
|
||||
import com.imyeyu.api.modules.gao.service.GaoCustomerService;
|
||||
import com.imyeyu.api.modules.user.service.UserLoginService;
|
||||
import com.imyeyu.api.modules.user.service.UserService;
|
||||
import com.imyeyu.api.modules.gao.vo.GaoCustomerDailyStatView;
|
||||
import com.imyeyu.api.modules.gao.vo.GaoCustomerGenderStatView;
|
||||
import com.imyeyu.api.modules.gao.vo.GaoCustomerInviteUpdateReq;
|
||||
import com.imyeyu.api.modules.gao.vo.GaoCustomerSearchReq;
|
||||
import com.imyeyu.api.modules.gao.vo.GaoCustomerTrendStatReq;
|
||||
import com.imyeyu.api.modules.system.entity.Logger;
|
||||
import com.imyeyu.api.modules.system.service.LoggerService;
|
||||
import com.imyeyu.api.modules.user.service.UserLoginService;
|
||||
import com.imyeyu.api.modules.user.service.UserService;
|
||||
import com.imyeyu.java.TimiJava;
|
||||
import com.imyeyu.java.bean.timi.TimiCode;
|
||||
import com.imyeyu.java.bean.timi.TimiException;
|
||||
import com.imyeyu.spring.TimiSpring;
|
||||
import com.imyeyu.spring.bean.Page;
|
||||
import com.imyeyu.spring.bean.PageResult;
|
||||
import com.imyeyu.spring.mapper.BaseMapper;
|
||||
import com.imyeyu.spring.service.AbstractEntityService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.poi.ss.usermodel.CellStyle;
|
||||
import org.apache.poi.ss.usermodel.Font;
|
||||
import org.apache.poi.ss.usermodel.Row;
|
||||
@@ -50,6 +55,7 @@ import java.util.stream.Collectors;
|
||||
///
|
||||
/// @author Codex
|
||||
/// @since 2026-07-27
|
||||
@Slf4j
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class GaoCustomerServiceImplement extends AbstractEntityService<GaoCustomer, String> implements GaoCustomerService {
|
||||
@@ -58,7 +64,9 @@ public class GaoCustomerServiceImplement extends AbstractEntityService<GaoCustom
|
||||
private static final DateTimeFormatter EXPORT_TIME_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss").withZone(ZoneId.systemDefault());
|
||||
|
||||
private final GaoCustomerMapper mapper;
|
||||
private final ObjectMapper jackson;
|
||||
private final AttachmentService attachmentService;
|
||||
private final LoggerService loggerService;
|
||||
private final UserLoginService userLoginService;
|
||||
private final UserService userService;
|
||||
|
||||
@@ -69,29 +77,80 @@ public class GaoCustomerServiceImplement extends AbstractEntityService<GaoCustom
|
||||
|
||||
@Override
|
||||
public void create(GaoCustomer entity) {
|
||||
checkEntity(entity, false);
|
||||
entity.setCreatorUserId(userLoginService.getRequireLoginUserId());
|
||||
entity.setInvitedCount(0L);
|
||||
super.create(entity);
|
||||
saveAttachment(entity.getId(), resolveAttachmentList(entity));
|
||||
changeInvitedCount(entity.getIntroducerCustomerId(), 1L);
|
||||
loadDetailTransient(entity);
|
||||
Logger logger = buildLogger("GAO_CUSTOMER_CREATE");
|
||||
try {
|
||||
logger.setContent(jackson.writeValueAsString(entity));
|
||||
checkEntity(entity, false);
|
||||
entity.setCreatorUserId(userLoginService.getRequireLoginUserId());
|
||||
entity.setInvitedCount(0L);
|
||||
super.create(entity);
|
||||
saveAttachment(entity.getId(), resolveAttachmentList(entity));
|
||||
changeInvitedCount(entity.getIntroducerCustomerId(), 1L);
|
||||
loadDetailTransient(entity);
|
||||
logger.setLevel(Logger.Level.INFO);
|
||||
logger.setResult(entity.getId());
|
||||
} catch (TimiException e) {
|
||||
logger.setLevel(Logger.Level.WARN);
|
||||
logger.setException(e.getMessage());
|
||||
throw e;
|
||||
} catch (Exception e) {
|
||||
logger.setLevel(Logger.Level.ERROR);
|
||||
logger.setException(TimiJava.serializeThrowable(e));
|
||||
log.error("新增 GAO 客户失败", e);
|
||||
throw new TimiException(TimiCode.ERROR, "新增 GAO 客户失败", e);
|
||||
} finally {
|
||||
loggerService.create(logger);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(GaoCustomer entity) {
|
||||
GaoCustomer dbCustomer = checkEntity(entity, true);
|
||||
super.update(entity);
|
||||
saveAttachment(entity.getId(), resolveAttachmentList(entity));
|
||||
syncIntroducerInvitedCount(dbCustomer.getIntroducerCustomerId(), entity.getIntroducerCustomerId());
|
||||
Logger logger = buildLogger("GAO_CUSTOMER_UPDATE");
|
||||
try {
|
||||
logger.setContent(jackson.writeValueAsString(entity));
|
||||
GaoCustomer dbCustomer = checkEntity(entity, true);
|
||||
super.update(entity);
|
||||
saveAttachment(entity.getId(), resolveAttachmentList(entity));
|
||||
syncIntroducerInvitedCount(dbCustomer.getIntroducerCustomerId(), entity.getIntroducerCustomerId());
|
||||
logger.setLevel(Logger.Level.INFO);
|
||||
logger.setResult(entity.getId());
|
||||
} catch (TimiException e) {
|
||||
logger.setLevel(Logger.Level.WARN);
|
||||
logger.setException(e.getMessage());
|
||||
throw e;
|
||||
} catch (Exception e) {
|
||||
logger.setLevel(Logger.Level.ERROR);
|
||||
logger.setException(TimiJava.serializeThrowable(e));
|
||||
log.error("修改 GAO 客户失败", e);
|
||||
throw new TimiException(TimiCode.ERROR, "修改 GAO 客户失败", e);
|
||||
} finally {
|
||||
loggerService.create(logger);
|
||||
}
|
||||
}
|
||||
|
||||
@Transactional(TimiServerDBConfig.ROLLBACKER)
|
||||
@Override
|
||||
public void delete(String id) {
|
||||
GaoCustomer customer = super.get(id);
|
||||
super.delete(id);
|
||||
changeInvitedCount(customer.getIntroducerCustomerId(), -1L);
|
||||
Logger logger = buildLogger("GAO_CUSTOMER_DELETE");
|
||||
try {
|
||||
logger.setContent(id);
|
||||
GaoCustomer customer = super.get(id);
|
||||
super.delete(id);
|
||||
changeInvitedCount(customer.getIntroducerCustomerId(), -1L);
|
||||
logger.setLevel(Logger.Level.INFO);
|
||||
logger.setResult(id);
|
||||
} catch (TimiException e) {
|
||||
logger.setLevel(Logger.Level.WARN);
|
||||
logger.setException(e.getMessage());
|
||||
throw e;
|
||||
} catch (Exception e) {
|
||||
logger.setLevel(Logger.Level.ERROR);
|
||||
logger.setException(TimiJava.serializeThrowable(e));
|
||||
log.error("删除 GAO 客户失败", e);
|
||||
throw new TimiException(TimiCode.ERROR, "删除 GAO 客户失败", e);
|
||||
} finally {
|
||||
loggerService.create(logger);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -215,25 +274,59 @@ public class GaoCustomerServiceImplement extends AbstractEntityService<GaoCustom
|
||||
@Transactional(TimiServerDBConfig.ROLLBACKER)
|
||||
@Override
|
||||
public void saveInviteRelation(GaoCustomerInviteUpdateReq req) {
|
||||
TimiException.required(req, "not found invite req");
|
||||
TimiException.required(req.getCustomerId(), "not found invite req.customerId");
|
||||
GaoCustomer customer = super.get(req.getCustomerId());
|
||||
String oldIntroducerCustomerId = customer.getIntroducerCustomerId();
|
||||
customer.setIntroducerCustomerId(req.getIntroducerCustomerId());
|
||||
checkEntity(customer, true);
|
||||
super.update(customer);
|
||||
syncIntroducerInvitedCount(oldIntroducerCustomerId, customer.getIntroducerCustomerId());
|
||||
Logger logger = buildLogger("GAO_CUSTOMER_SAVE_INVITE_RELATION");
|
||||
try {
|
||||
logger.setContent(jackson.writeValueAsString(req));
|
||||
TimiException.required(req, "not found invite req");
|
||||
TimiException.required(req.getCustomerId(), "not found invite req.customerId");
|
||||
GaoCustomer customer = super.get(req.getCustomerId());
|
||||
String oldIntroducerCustomerId = customer.getIntroducerCustomerId();
|
||||
customer.setIntroducerCustomerId(req.getIntroducerCustomerId());
|
||||
checkEntity(customer, true);
|
||||
super.update(customer);
|
||||
syncIntroducerInvitedCount(oldIntroducerCustomerId, customer.getIntroducerCustomerId());
|
||||
logger.setLevel(Logger.Level.INFO);
|
||||
logger.setResult(req.getCustomerId());
|
||||
} catch (TimiException e) {
|
||||
logger.setLevel(Logger.Level.WARN);
|
||||
logger.setException(e.getMessage());
|
||||
throw e;
|
||||
} catch (Exception e) {
|
||||
logger.setLevel(Logger.Level.ERROR);
|
||||
logger.setException(TimiJava.serializeThrowable(e));
|
||||
log.error("保存 GAO 客户邀请关系失败", e);
|
||||
throw new TimiException(TimiCode.ERROR, "保存 GAO 客户邀请关系失败", e);
|
||||
} finally {
|
||||
loggerService.create(logger);
|
||||
}
|
||||
}
|
||||
|
||||
@Transactional(TimiServerDBConfig.ROLLBACKER)
|
||||
@Override
|
||||
public void deleteInviteRelation(String customerId) {
|
||||
TimiException.required(customerId, "not found customerId");
|
||||
GaoCustomer customer = super.get(customerId);
|
||||
String oldIntroducerCustomerId = customer.getIntroducerCustomerId();
|
||||
customer.setIntroducerCustomerId(null);
|
||||
super.update(customer);
|
||||
changeInvitedCount(oldIntroducerCustomerId, -1L);
|
||||
Logger logger = buildLogger("GAO_CUSTOMER_DELETE_INVITE_RELATION");
|
||||
try {
|
||||
logger.setContent(customerId);
|
||||
TimiException.required(customerId, "not found customerId");
|
||||
GaoCustomer customer = super.get(customerId);
|
||||
String oldIntroducerCustomerId = customer.getIntroducerCustomerId();
|
||||
customer.setIntroducerCustomerId(null);
|
||||
super.update(customer);
|
||||
changeInvitedCount(oldIntroducerCustomerId, -1L);
|
||||
logger.setLevel(Logger.Level.INFO);
|
||||
logger.setResult(customerId);
|
||||
} catch (TimiException e) {
|
||||
logger.setLevel(Logger.Level.WARN);
|
||||
logger.setException(e.getMessage());
|
||||
throw e;
|
||||
} catch (Exception e) {
|
||||
logger.setLevel(Logger.Level.ERROR);
|
||||
logger.setException(TimiJava.serializeThrowable(e));
|
||||
log.error("删除 GAO 客户邀请关系失败", e);
|
||||
throw new TimiException(TimiCode.ERROR, "删除 GAO 客户邀请关系失败", e);
|
||||
} finally {
|
||||
loggerService.create(logger);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -453,4 +546,12 @@ public class GaoCustomerServiceImplement extends AbstractEntityService<GaoCustom
|
||||
private String text(Object value) {
|
||||
return value == null ? "" : value.toString();
|
||||
}
|
||||
|
||||
private Logger buildLogger(String operation) {
|
||||
Logger logger = new Logger();
|
||||
logger.setModule(Logger.Module.GAO);
|
||||
logger.setOperation(operation);
|
||||
logger.setIp(TimiSpring.getRequestIP());
|
||||
return logger;
|
||||
}
|
||||
}
|
||||
|
||||
+113
-39
@@ -1,5 +1,6 @@
|
||||
package com.imyeyu.api.modules.gao.service.implement;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.imyeyu.api.config.dbsource.TimiServerDBConfig;
|
||||
import com.imyeyu.api.bean.ModuleCode;
|
||||
import com.imyeyu.api.modules.common.entity.Attachment;
|
||||
@@ -25,18 +26,23 @@ import com.imyeyu.api.modules.gao.vo.GaoRegistrationEventRecordPeriodReq;
|
||||
import com.imyeyu.api.modules.gao.vo.GaoRegistrationEventRecordRangeReq;
|
||||
import com.imyeyu.api.modules.gao.vo.GaoRegistrationEventRecordStatReq;
|
||||
import com.imyeyu.api.modules.gao.vo.GaoRegistrationEventRecordTrendStatReq;
|
||||
import com.imyeyu.api.modules.system.entity.Logger;
|
||||
import com.imyeyu.api.modules.system.service.LoggerService;
|
||||
import com.imyeyu.api.modules.user.service.RoleChecker;
|
||||
import com.imyeyu.api.modules.user.service.UserLoginService;
|
||||
import com.imyeyu.api.modules.user.service.UserService;
|
||||
import com.imyeyu.api.modules.user.mapper.UserMapper;
|
||||
import com.imyeyu.java.TimiJava;
|
||||
import com.imyeyu.java.bean.timi.TimiCode;
|
||||
import com.imyeyu.java.bean.timi.TimiException;
|
||||
import com.imyeyu.spring.TimiSpring;
|
||||
import com.imyeyu.spring.bean.Page;
|
||||
import com.imyeyu.spring.bean.PageResult;
|
||||
import com.imyeyu.spring.mapper.BaseMapper;
|
||||
import com.imyeyu.spring.service.AbstractEntityService;
|
||||
import com.imyeyu.utils.Time;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.poi.ss.usermodel.CellStyle;
|
||||
import org.apache.poi.ss.usermodel.Font;
|
||||
import org.apache.poi.ss.usermodel.Row;
|
||||
@@ -68,6 +74,7 @@ import java.util.stream.Collectors;
|
||||
///
|
||||
/// @author Codex
|
||||
/// @since 2026-07-27
|
||||
@Slf4j
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class GaoRegistrationEventRecordServiceImplement extends AbstractEntityService<GaoRegistrationEventRecord, String> implements GaoRegistrationEventRecordService {
|
||||
@@ -76,10 +83,12 @@ public class GaoRegistrationEventRecordServiceImplement extends AbstractEntitySe
|
||||
private static final DateTimeFormatter EXPORT_TIME_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss").withZone(ZoneId.systemDefault());
|
||||
|
||||
private final GaoRegistrationEventRecordMapper mapper;
|
||||
private final ObjectMapper jackson;
|
||||
private final GaoCustomerMapper customerMapper;
|
||||
private final GaoRegistrationEventMapper registrationEventMapper;
|
||||
private final UserMapper userMapper;
|
||||
private final AttachmentService attachmentService;
|
||||
private final LoggerService loggerService;
|
||||
private final RoleChecker roleChecker;
|
||||
private final UserLoginService userLoginService;
|
||||
private final UserService userService;
|
||||
@@ -94,56 +103,90 @@ public class GaoRegistrationEventRecordServiceImplement extends AbstractEntitySe
|
||||
@Transactional(TimiServerDBConfig.ROLLBACKER)
|
||||
@Override
|
||||
public GaoRegistrationEventRecord createRecord(GaoRegistrationEventRecordCreateReq req) {
|
||||
TimiException.required(req, "not found req");
|
||||
TimiException.required(req.getRegistrationEventId(), "not found req.registrationEventId");
|
||||
String customerId = resolveCustomerId(req);
|
||||
GaoRegistrationEvent registrationEvent = registrationEventService.get(req.getRegistrationEventId());
|
||||
checkRegistrationEventPermission(registrationEvent);
|
||||
long registeredAt = TimiJava.defaultIfNull(req.getRegisteredAt(), Time.now());
|
||||
checkRegistrationEventCreatable(registrationEvent, customerId, registeredAt);
|
||||
if (Boolean.TRUE.equals(registrationEvent.getRequirePhoto())) {
|
||||
TimiException.requiredTrue(req.getAttachmentIdList() != null && !req.getAttachmentIdList().isEmpty(), "required record photo");
|
||||
Logger logger = buildLogger("GAO_REGISTRATION_EVENT_RECORD_CREATE");
|
||||
try {
|
||||
logger.setContent(jackson.writeValueAsString(req));
|
||||
GaoRegistrationEventRecord record = doCreateRecord(req);
|
||||
logger.setLevel(Logger.Level.INFO);
|
||||
logger.setResult(record.getId());
|
||||
return record;
|
||||
} catch (TimiException e) {
|
||||
logger.setLevel(Logger.Level.WARN);
|
||||
logger.setException(e.getMessage());
|
||||
throw e;
|
||||
} catch (Exception e) {
|
||||
logger.setLevel(Logger.Level.ERROR);
|
||||
logger.setException(TimiJava.serializeThrowable(e));
|
||||
log.error("新增 GAO 登记记录失败", e);
|
||||
throw new TimiException(TimiCode.ERROR, "新增 GAO 登记记录失败", e);
|
||||
} finally {
|
||||
loggerService.create(logger);
|
||||
}
|
||||
|
||||
GaoRegistrationEventRecord record = new GaoRegistrationEventRecord();
|
||||
record.setCustomerId(customerId);
|
||||
record.setRegistrationEventId(req.getRegistrationEventId());
|
||||
record.setOperatorUserId(userLoginService.getRequireLoginUserId());
|
||||
record.setRemark(req.getRemark());
|
||||
record.setRegisteredAt(registeredAt);
|
||||
super.create(record);
|
||||
saveAttachment(record.getId(), buildPhotoAttachmentList(req.getAttachmentIdList()));
|
||||
return get(record.getId());
|
||||
}
|
||||
|
||||
@Transactional(TimiServerDBConfig.ROLLBACKER)
|
||||
@Override
|
||||
public GaoRegistrationEventRecord quickRegister(GaoQuickRegistrationEventRecordReq req) {
|
||||
TimiException.required(req, "not found req");
|
||||
TimiException.required(req.getCustomerCode(), "not found req.customerCode");
|
||||
TimiException.required(req.getRegistrationEventId(), "not found req.registrationEventId");
|
||||
GaoCustomer customer = customerService.getOrQuickCreateByCode(req.getCustomerCode());
|
||||
GaoRegistrationEventRecordCreateReq recordReq = new GaoRegistrationEventRecordCreateReq();
|
||||
recordReq.setCustomerId(customer.getId());
|
||||
recordReq.setRegistrationEventId(req.getRegistrationEventId());
|
||||
recordReq.setRemark(req.getRemark());
|
||||
recordReq.setAttachmentIdList(req.getAttachmentIdList());
|
||||
return createRecord(recordReq);
|
||||
Logger logger = buildLogger("GAO_REGISTRATION_EVENT_RECORD_QUICK_REGISTER");
|
||||
try {
|
||||
logger.setContent(jackson.writeValueAsString(req));
|
||||
TimiException.required(req, "not found req");
|
||||
TimiException.required(req.getCustomerCode(), "not found req.customerCode");
|
||||
TimiException.required(req.getRegistrationEventId(), "not found req.registrationEventId");
|
||||
GaoCustomer customer = customerService.getOrQuickCreateByCode(req.getCustomerCode());
|
||||
GaoRegistrationEventRecordCreateReq recordReq = new GaoRegistrationEventRecordCreateReq();
|
||||
recordReq.setCustomerId(customer.getId());
|
||||
recordReq.setRegistrationEventId(req.getRegistrationEventId());
|
||||
recordReq.setRemark(req.getRemark());
|
||||
recordReq.setAttachmentIdList(req.getAttachmentIdList());
|
||||
GaoRegistrationEventRecord record = doCreateRecord(recordReq);
|
||||
logger.setLevel(Logger.Level.INFO);
|
||||
logger.setResult(record.getId());
|
||||
return record;
|
||||
} catch (TimiException e) {
|
||||
logger.setLevel(Logger.Level.WARN);
|
||||
logger.setException(e.getMessage());
|
||||
throw e;
|
||||
} catch (Exception e) {
|
||||
logger.setLevel(Logger.Level.ERROR);
|
||||
logger.setException(TimiJava.serializeThrowable(e));
|
||||
log.error("GAO 快速登记失败", e);
|
||||
throw new TimiException(TimiCode.ERROR, "GAO 快速登记失败", e);
|
||||
} finally {
|
||||
loggerService.create(logger);
|
||||
}
|
||||
}
|
||||
|
||||
@Transactional(TimiServerDBConfig.ROLLBACKER)
|
||||
@Override
|
||||
public void update(GaoRegistrationEventRecord entity) {
|
||||
TimiException.required(entity, "not found record");
|
||||
TimiException.required(entity.getId(), "not found record.id");
|
||||
TimiException.required(entity.getCustomerId(), "not found record.customerId");
|
||||
TimiException.required(entity.getRegistrationEventId(), "not found record.registrationEventId");
|
||||
customerService.get(entity.getCustomerId());
|
||||
GaoRegistrationEvent registrationEvent = registrationEventService.get(entity.getRegistrationEventId());
|
||||
checkRegistrationEventPermission(registrationEvent);
|
||||
entity.setRegisteredAt(TimiJava.defaultIfNull(entity.getRegisteredAt(), Time.now()));
|
||||
super.update(entity);
|
||||
saveAttachment(entity.getId(), resolveAttachmentList(entity));
|
||||
Logger logger = buildLogger("GAO_REGISTRATION_EVENT_RECORD_UPDATE");
|
||||
try {
|
||||
logger.setContent(jackson.writeValueAsString(entity));
|
||||
TimiException.required(entity, "not found record");
|
||||
TimiException.required(entity.getId(), "not found record.id");
|
||||
TimiException.required(entity.getCustomerId(), "not found record.customerId");
|
||||
TimiException.required(entity.getRegistrationEventId(), "not found record.registrationEventId");
|
||||
customerService.get(entity.getCustomerId());
|
||||
GaoRegistrationEvent registrationEvent = registrationEventService.get(entity.getRegistrationEventId());
|
||||
checkRegistrationEventPermission(registrationEvent);
|
||||
entity.setRegisteredAt(TimiJava.defaultIfNull(entity.getRegisteredAt(), Time.now()));
|
||||
super.update(entity);
|
||||
saveAttachment(entity.getId(), resolveAttachmentList(entity));
|
||||
logger.setLevel(Logger.Level.INFO);
|
||||
logger.setResult(entity.getId());
|
||||
} catch (TimiException e) {
|
||||
logger.setLevel(Logger.Level.WARN);
|
||||
logger.setException(e.getMessage());
|
||||
throw e;
|
||||
} catch (Exception e) {
|
||||
logger.setLevel(Logger.Level.ERROR);
|
||||
logger.setException(TimiJava.serializeThrowable(e));
|
||||
log.error("修改 GAO 登记记录失败", e);
|
||||
throw new TimiException(TimiCode.ERROR, "修改 GAO 登记记录失败", e);
|
||||
} finally {
|
||||
loggerService.create(logger);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -311,6 +354,29 @@ public class GaoRegistrationEventRecordServiceImplement extends AbstractEntitySe
|
||||
return customer.getId();
|
||||
}
|
||||
|
||||
private GaoRegistrationEventRecord doCreateRecord(GaoRegistrationEventRecordCreateReq req) {
|
||||
TimiException.required(req, "not found req");
|
||||
TimiException.required(req.getRegistrationEventId(), "not found req.registrationEventId");
|
||||
String customerId = resolveCustomerId(req);
|
||||
GaoRegistrationEvent registrationEvent = registrationEventService.get(req.getRegistrationEventId());
|
||||
checkRegistrationEventPermission(registrationEvent);
|
||||
long registeredAt = TimiJava.defaultIfNull(req.getRegisteredAt(), Time.now());
|
||||
checkRegistrationEventCreatable(registrationEvent, customerId, registeredAt);
|
||||
if (Boolean.TRUE.equals(registrationEvent.getRequirePhoto())) {
|
||||
TimiException.requiredTrue(req.getAttachmentIdList() != null && !req.getAttachmentIdList().isEmpty(), "required record photo");
|
||||
}
|
||||
|
||||
GaoRegistrationEventRecord record = new GaoRegistrationEventRecord();
|
||||
record.setCustomerId(customerId);
|
||||
record.setRegistrationEventId(req.getRegistrationEventId());
|
||||
record.setOperatorUserId(userLoginService.getRequireLoginUserId());
|
||||
record.setRemark(req.getRemark());
|
||||
record.setRegisteredAt(registeredAt);
|
||||
super.create(record);
|
||||
saveAttachment(record.getId(), buildPhotoAttachmentList(req.getAttachmentIdList()));
|
||||
return get(record.getId());
|
||||
}
|
||||
|
||||
private void checkRegistrationEventPermission(GaoRegistrationEvent registrationEvent) {
|
||||
List<String> roleCodeList = registrationEventService.listRoleCode(registrationEvent.getId());
|
||||
TimiException.requiredTrue(roleCodeList != null && !roleCodeList.isEmpty(), "登记事件未配置可登记角色");
|
||||
@@ -576,4 +642,12 @@ public class GaoRegistrationEventRecordServiceImplement extends AbstractEntitySe
|
||||
private String text(Object value) {
|
||||
return value == null ? "" : value.toString();
|
||||
}
|
||||
|
||||
private Logger buildLogger(String operation) {
|
||||
Logger logger = new Logger();
|
||||
logger.setModule(Logger.Module.GAO);
|
||||
logger.setOperation(operation);
|
||||
logger.setIp(TimiSpring.getRequestIP());
|
||||
return logger;
|
||||
}
|
||||
}
|
||||
|
||||
+88
-20
@@ -1,19 +1,25 @@
|
||||
package com.imyeyu.api.modules.gao.service.implement;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.imyeyu.api.config.dbsource.TimiServerDBConfig;
|
||||
import com.imyeyu.api.modules.gao.entity.GaoRegistrationEventRoleRelation;
|
||||
import com.imyeyu.api.modules.gao.entity.GaoRegistrationEvent;
|
||||
import com.imyeyu.api.modules.gao.mapper.GaoRegistrationEventRoleRelationMapper;
|
||||
import com.imyeyu.api.modules.gao.mapper.GaoRegistrationEventMapper;
|
||||
import com.imyeyu.api.modules.gao.service.GaoRegistrationEventService;
|
||||
import com.imyeyu.api.modules.system.entity.Logger;
|
||||
import com.imyeyu.api.modules.system.service.LoggerService;
|
||||
import com.imyeyu.java.TimiJava;
|
||||
import com.imyeyu.java.bean.timi.TimiCode;
|
||||
import com.imyeyu.java.bean.timi.TimiException;
|
||||
import com.imyeyu.spring.TimiSpring;
|
||||
import com.imyeyu.spring.bean.Page;
|
||||
import com.imyeyu.spring.bean.PageResult;
|
||||
import com.imyeyu.spring.mapper.BaseMapper;
|
||||
import com.imyeyu.spring.service.AbstractEntityService;
|
||||
import com.imyeyu.utils.Time;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@@ -29,11 +35,14 @@ import java.util.stream.Collectors;
|
||||
///
|
||||
/// @author Codex
|
||||
/// @since 2026-07-27
|
||||
@Slf4j
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class GaoRegistrationEventServiceImplement extends AbstractEntityService<GaoRegistrationEvent, String> implements GaoRegistrationEventService {
|
||||
|
||||
private final GaoRegistrationEventMapper mapper;
|
||||
private final ObjectMapper jackson;
|
||||
private final LoggerService loggerService;
|
||||
private final GaoRegistrationEventRoleRelationMapper roleRelationMapper;
|
||||
|
||||
@Override
|
||||
@@ -54,36 +63,87 @@ public class GaoRegistrationEventServiceImplement extends AbstractEntityService<
|
||||
@Transactional(TimiServerDBConfig.ROLLBACKER)
|
||||
@Override
|
||||
public void create(GaoRegistrationEvent entity) {
|
||||
checkEntity(entity, false);
|
||||
super.create(entity);
|
||||
saveRoleRelation(entity.getId(), entity.getRoleCodeList());
|
||||
Logger logger = buildLogger("GAO_REGISTRATION_EVENT_CREATE");
|
||||
try {
|
||||
logger.setContent(jackson.writeValueAsString(entity));
|
||||
checkEntity(entity, false);
|
||||
super.create(entity);
|
||||
saveRoleRelation(entity.getId(), entity.getRoleCodeList());
|
||||
logger.setLevel(Logger.Level.INFO);
|
||||
logger.setResult(entity.getId());
|
||||
} catch (TimiException e) {
|
||||
logger.setLevel(Logger.Level.WARN);
|
||||
logger.setException(e.getMessage());
|
||||
throw e;
|
||||
} catch (Exception e) {
|
||||
logger.setLevel(Logger.Level.ERROR);
|
||||
logger.setException(TimiJava.serializeThrowable(e));
|
||||
log.error("新增 GAO 登记事件失败", e);
|
||||
throw new TimiException(TimiCode.ERROR, "新增 GAO 登记事件失败", e);
|
||||
} finally {
|
||||
loggerService.create(logger);
|
||||
}
|
||||
}
|
||||
|
||||
@Transactional(TimiServerDBConfig.ROLLBACKER)
|
||||
@Override
|
||||
public void update(GaoRegistrationEvent entity) {
|
||||
checkEntity(entity, true);
|
||||
GaoRegistrationEvent current = get(entity.getId());
|
||||
current.setName(entity.getName());
|
||||
current.setDescription(entity.getDescription());
|
||||
current.setColor(entity.getColor());
|
||||
current.setStatus(entity.getStatus());
|
||||
current.setRequirePhoto(entity.getRequirePhoto());
|
||||
current.setLimitType(entity.getLimitType());
|
||||
current.setLimitValue(entity.getLimitValue());
|
||||
current.setBeginAt(entity.getBeginAt());
|
||||
current.setEndAt(entity.getEndAt());
|
||||
current.setSort(entity.getSort());
|
||||
mapper.update(current);
|
||||
saveRoleRelation(entity.getId(), entity.getRoleCodeList());
|
||||
Logger logger = buildLogger("GAO_REGISTRATION_EVENT_UPDATE");
|
||||
try {
|
||||
logger.setContent(jackson.writeValueAsString(entity));
|
||||
checkEntity(entity, true);
|
||||
GaoRegistrationEvent current = get(entity.getId());
|
||||
current.setName(entity.getName());
|
||||
current.setDescription(entity.getDescription());
|
||||
current.setColor(entity.getColor());
|
||||
current.setStatus(entity.getStatus());
|
||||
current.setRequirePhoto(entity.getRequirePhoto());
|
||||
current.setLimitType(entity.getLimitType());
|
||||
current.setLimitValue(entity.getLimitValue());
|
||||
current.setBeginAt(entity.getBeginAt());
|
||||
current.setEndAt(entity.getEndAt());
|
||||
current.setSort(entity.getSort());
|
||||
mapper.update(current);
|
||||
saveRoleRelation(entity.getId(), entity.getRoleCodeList());
|
||||
logger.setLevel(Logger.Level.INFO);
|
||||
logger.setResult(entity.getId());
|
||||
} catch (TimiException e) {
|
||||
logger.setLevel(Logger.Level.WARN);
|
||||
logger.setException(e.getMessage());
|
||||
throw e;
|
||||
} catch (Exception e) {
|
||||
logger.setLevel(Logger.Level.ERROR);
|
||||
logger.setException(TimiJava.serializeThrowable(e));
|
||||
log.error("修改 GAO 登记事件失败", e);
|
||||
throw new TimiException(TimiCode.ERROR, "修改 GAO 登记事件失败", e);
|
||||
} finally {
|
||||
loggerService.create(logger);
|
||||
}
|
||||
}
|
||||
|
||||
@Transactional(TimiServerDBConfig.ROLLBACKER)
|
||||
@Override
|
||||
public void delete(String id) {
|
||||
GaoRegistrationEvent entity = get(id);
|
||||
entity.setStatus(GaoRegistrationEvent.Status.DELETED);
|
||||
super.update(entity);
|
||||
Logger logger = buildLogger("GAO_REGISTRATION_EVENT_DELETE");
|
||||
try {
|
||||
logger.setContent(id);
|
||||
GaoRegistrationEvent entity = get(id);
|
||||
entity.setStatus(GaoRegistrationEvent.Status.DELETED);
|
||||
super.update(entity);
|
||||
logger.setLevel(Logger.Level.INFO);
|
||||
logger.setResult(id);
|
||||
} catch (TimiException e) {
|
||||
logger.setLevel(Logger.Level.WARN);
|
||||
logger.setException(e.getMessage());
|
||||
throw e;
|
||||
} catch (Exception e) {
|
||||
logger.setLevel(Logger.Level.ERROR);
|
||||
logger.setException(TimiJava.serializeThrowable(e));
|
||||
log.error("删除 GAO 登记事件失败", e);
|
||||
throw new TimiException(TimiCode.ERROR, "删除 GAO 登记事件失败", e);
|
||||
} finally {
|
||||
loggerService.create(logger);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -196,4 +256,12 @@ public class GaoRegistrationEventServiceImplement extends AbstractEntityService<
|
||||
registrationEvent.setRoleCodeList(roleCodeMap.getOrDefault(registrationEvent.getId(), List.of()));
|
||||
}
|
||||
}
|
||||
|
||||
private Logger buildLogger(String operation) {
|
||||
Logger logger = new Logger();
|
||||
logger.setModule(Logger.Module.GAO);
|
||||
logger.setOperation(operation);
|
||||
logger.setIp(TimiSpring.getRequestIP());
|
||||
return logger;
|
||||
}
|
||||
}
|
||||
|
||||
+59
-9
@@ -1,10 +1,13 @@
|
||||
package com.imyeyu.api.modules.gao.service.implement;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.imyeyu.api.bean.ModuleCode;
|
||||
import com.imyeyu.api.config.dbsource.TimiServerDBConfig;
|
||||
import com.imyeyu.api.modules.gao.entity.GaoUser;
|
||||
import com.imyeyu.api.modules.gao.mapper.GaoUserMapper;
|
||||
import com.imyeyu.api.modules.gao.service.GaoUserService;
|
||||
import com.imyeyu.api.modules.system.entity.Logger;
|
||||
import com.imyeyu.api.modules.system.service.LoggerService;
|
||||
import com.imyeyu.api.modules.user.entity.Role;
|
||||
import com.imyeyu.api.modules.user.entity.User;
|
||||
import com.imyeyu.api.modules.user.mapper.UserMapper;
|
||||
@@ -14,12 +17,14 @@ import com.imyeyu.api.modules.user.vo.role.UserRoleAuthorizeReq;
|
||||
import com.imyeyu.java.TimiJava;
|
||||
import com.imyeyu.java.bean.timi.TimiCode;
|
||||
import com.imyeyu.java.bean.timi.TimiException;
|
||||
import com.imyeyu.spring.TimiSpring;
|
||||
import com.imyeyu.spring.bean.Page;
|
||||
import com.imyeyu.spring.bean.PageResult;
|
||||
import com.imyeyu.spring.mapper.BaseMapper;
|
||||
import com.imyeyu.spring.service.AbstractEntityService;
|
||||
import com.imyeyu.utils.Time;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@@ -34,11 +39,14 @@ import java.util.stream.Collectors;
|
||||
///
|
||||
/// @author Codex
|
||||
/// @since 2026-07-30
|
||||
@Slf4j
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class GaoUserServiceImplement extends AbstractEntityService<GaoUser, String> implements GaoUserService {
|
||||
|
||||
private final GaoUserMapper mapper;
|
||||
private final ObjectMapper jackson;
|
||||
private final LoggerService loggerService;
|
||||
private final UserMapper userMapper;
|
||||
private final UserService userService;
|
||||
private final RoleService roleService;
|
||||
@@ -51,20 +59,54 @@ public class GaoUserServiceImplement extends AbstractEntityService<GaoUser, Stri
|
||||
@Transactional(TimiServerDBConfig.ROLLBACKER)
|
||||
@Override
|
||||
public void create(GaoUser entity) {
|
||||
prepareUser(entity);
|
||||
checkEntity(entity, false);
|
||||
super.create(entity);
|
||||
saveUserRole(entity);
|
||||
loadUser(entity);
|
||||
Logger logger = buildLogger("GAO_USER_CREATE");
|
||||
try {
|
||||
logger.setContent(jackson.writeValueAsString(entity));
|
||||
prepareUser(entity);
|
||||
checkEntity(entity, false);
|
||||
super.create(entity);
|
||||
saveUserRole(entity);
|
||||
loadUser(entity);
|
||||
logger.setLevel(Logger.Level.INFO);
|
||||
logger.setResult(entity.getId());
|
||||
} catch (TimiException e) {
|
||||
logger.setLevel(Logger.Level.WARN);
|
||||
logger.setException(e.getMessage());
|
||||
throw e;
|
||||
} catch (Exception e) {
|
||||
logger.setLevel(Logger.Level.ERROR);
|
||||
logger.setException(TimiJava.serializeThrowable(e));
|
||||
log.error("新增 GAO 用户失败", e);
|
||||
throw new TimiException(TimiCode.ERROR, "新增 GAO 用户失败", e);
|
||||
} finally {
|
||||
loggerService.create(logger);
|
||||
}
|
||||
}
|
||||
|
||||
@Transactional(TimiServerDBConfig.ROLLBACKER)
|
||||
@Override
|
||||
public void update(GaoUser entity) {
|
||||
checkEntity(entity, true);
|
||||
updateUser(entity);
|
||||
super.update(entity);
|
||||
saveUserRole(entity);
|
||||
Logger logger = buildLogger("GAO_USER_UPDATE");
|
||||
try {
|
||||
logger.setContent(jackson.writeValueAsString(entity));
|
||||
checkEntity(entity, true);
|
||||
updateUser(entity);
|
||||
super.update(entity);
|
||||
saveUserRole(entity);
|
||||
logger.setLevel(Logger.Level.INFO);
|
||||
logger.setResult(entity.getId());
|
||||
} catch (TimiException e) {
|
||||
logger.setLevel(Logger.Level.WARN);
|
||||
logger.setException(e.getMessage());
|
||||
throw e;
|
||||
} catch (Exception e) {
|
||||
logger.setLevel(Logger.Level.ERROR);
|
||||
logger.setException(TimiJava.serializeThrowable(e));
|
||||
log.error("修改 GAO 用户失败", e);
|
||||
throw new TimiException(TimiCode.ERROR, "修改 GAO 用户失败", e);
|
||||
} finally {
|
||||
loggerService.create(logger);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -171,4 +213,12 @@ public class GaoUserServiceImplement extends AbstractEntityService<GaoUser, Stri
|
||||
gaoUser.setRoleList(roleList);
|
||||
}
|
||||
}
|
||||
|
||||
private Logger buildLogger(String operation) {
|
||||
Logger logger = new Logger();
|
||||
logger.setModule(Logger.Module.GAO);
|
||||
logger.setOperation(operation);
|
||||
logger.setIp(TimiSpring.getRequestIP());
|
||||
return logger;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,21 @@ import lombok.NoArgsConstructor;
|
||||
@NoArgsConstructor
|
||||
public class Logger implements IDEntity<String>, Creatable {
|
||||
|
||||
///
|
||||
///
|
||||
/// @author 夜雨
|
||||
/// @since 2026-08-03 11:43
|
||||
public enum Module {
|
||||
|
||||
SYSTEM,
|
||||
|
||||
COMMON,
|
||||
|
||||
USER,
|
||||
|
||||
GAO,
|
||||
}
|
||||
|
||||
/**
|
||||
* 日志级别
|
||||
*
|
||||
@@ -43,7 +58,7 @@ public class Logger implements IDEntity<String>, Creatable {
|
||||
private Level level;
|
||||
|
||||
/** 模块名称 */
|
||||
private String module;
|
||||
private Module module;
|
||||
|
||||
/** 操作描述 */
|
||||
private String operation;
|
||||
|
||||
@@ -16,41 +16,41 @@ public interface LoggerService extends GettableService<Logger, String>, Pageable
|
||||
|
||||
void createSync(Logger logger);
|
||||
|
||||
void create(Logger.Level level, String module, String operation, String userId, String content, String result);
|
||||
void create(Logger.Level level, Logger.Module module, String operation, String userId, String content, String result);
|
||||
|
||||
default void info(String module, String operation, String userId) {
|
||||
default void info(Logger.Module module, String operation, String userId) {
|
||||
create(Logger.Level.INFO, module, operation, userId, null, null);
|
||||
}
|
||||
|
||||
default void info(String module, String operation, String content, String result) {
|
||||
default void info(Logger.Module module, String operation, String content, String result) {
|
||||
create(Logger.Level.INFO, module, operation, null, content, result);
|
||||
}
|
||||
|
||||
default void info(String module, String operation, String userId, String content, String result) {
|
||||
default void info(Logger.Module module, String operation, String userId, String content, String result) {
|
||||
create(Logger.Level.INFO, module, operation, userId, content, result);
|
||||
}
|
||||
|
||||
default void warning(String module, String operation, String userId) {
|
||||
default void warning(Logger.Module module, String operation, String userId) {
|
||||
create(Logger.Level.WARN, module, operation, userId, null, null);
|
||||
}
|
||||
|
||||
default void warning(String module, String operation, String content, String result) {
|
||||
default void warning(Logger.Module module, String operation, String content, String result) {
|
||||
create(Logger.Level.WARN, module, operation, null, content, result);
|
||||
}
|
||||
|
||||
default void warning(String module, String operation, String userId, String content, String result) {
|
||||
default void warning(Logger.Module module, String operation, String userId, String content, String result) {
|
||||
create(Logger.Level.WARN, module, operation, userId, content, result);
|
||||
}
|
||||
|
||||
default void error(String module, String operation, String userId) {
|
||||
default void error(Logger.Module module, String operation, String userId) {
|
||||
create(Logger.Level.ERROR, module, operation, userId, null, null);
|
||||
}
|
||||
|
||||
default void error(String module, String operation, String content, String result) {
|
||||
default void error(Logger.Module module, String operation, String content, String result) {
|
||||
create(Logger.Level.ERROR, module, operation, null, content, result);
|
||||
}
|
||||
|
||||
default void error(String module, String operation, String userId, String content, String result) {
|
||||
default void error(Logger.Module module, String operation, String userId, String content, String result) {
|
||||
create(Logger.Level.ERROR, module, operation, userId, content, result);
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -36,7 +36,7 @@ public class LoggerServiceImplement extends AbstractEntityService<Logger, String
|
||||
super.create(logger);
|
||||
}
|
||||
|
||||
public void create(Logger.Level level, String module, String operation, String userId, String content, String result) {
|
||||
public void create(Logger.Level level, Logger.Module module, String operation, String userId, String content, String result) {
|
||||
Logger log = new Logger(level);
|
||||
log.setModule(module);
|
||||
log.setOperation(operation);
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
package com.imyeyu.api.util;
|
||||
|
||||
import com.imyeyu.api.config.dbsource.TimiServerDBConfig;
|
||||
import com.imyeyu.api.bean.ModuleCode;
|
||||
import com.imyeyu.api.config.dbsource.TimiServerDBConfig;
|
||||
import com.imyeyu.api.modules.common.bean.ImageType;
|
||||
import com.imyeyu.api.modules.gao.bean.GaoPermissionCode;
|
||||
import com.imyeyu.api.modules.gao.bean.GaoRoleCode;
|
||||
import com.imyeyu.api.modules.system.entity.Logger;
|
||||
import com.imyeyu.api.modules.system.service.LoggerService;
|
||||
import com.imyeyu.api.modules.user.bean.BootstrapData;
|
||||
import com.imyeyu.api.modules.user.bean.BuiltinAuthRegistry;
|
||||
@@ -92,7 +93,7 @@ public class InitBuiltinUser implements ApplicationRunner {
|
||||
userService.create(user);
|
||||
|
||||
String logContent = "初始化 %s 自举用户成功,请立即修改密码:%s".formatted(BootstrapData.SYS_USER_NAME, password);
|
||||
loggerService.info("SYSTEM", "INITIALIZE_SYSTEM_USER", user.getId(), logContent, null);
|
||||
loggerService.info(Logger.Module.SYSTEM, "INITIALIZE_SYSTEM_USER", user.getId(), logContent, null);
|
||||
}
|
||||
// 授权系统用户角色
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user