Commit 24e78e5d by 墨竹

feat:操作日志新增字段

parent c699df7d
package com.gic.haoban.manage.api.dto.qdto.hm;
import com.gic.haoban.base.api.common.pojo.dto.WebLoginDTO;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
......@@ -100,9 +102,13 @@ public class HmQrcodeQDTO implements Serializable {
* 调用类型来源 0:不记录,1:来源为后台操作 其他查看枚举 HbBindEnum
*/
private Integer invokingType = 0;
/**
* 多人活码新增员工
*/
private String addStaffName;
private WebLoginDTO webLoginDTO;
public Long getHmId() {
return hmId;
......@@ -375,5 +381,13 @@ public class HmQrcodeQDTO implements Serializable {
public void setAddStaffName(String addStaffName) {
this.addStaffName = addStaffName;
}
public WebLoginDTO getWebLoginDTO() {
return webLoginDTO;
}
public void setWebLoginDTO(WebLoginDTO webLoginDTO) {
this.webLoginDTO = webLoginDTO;
}
}
......@@ -3,6 +3,7 @@ package com.gic.haoban.manage.api.service.hm;
import com.gic.api.base.commons.BasePageInfo;
import com.gic.api.base.commons.Page;
import com.gic.api.base.commons.ServiceResponse;
import com.gic.haoban.base.api.common.pojo.dto.WebLoginDTO;
import com.gic.haoban.manage.api.dto.hm.HmClerkRelationDTO;
import com.gic.haoban.manage.api.dto.hm.HmQrcodeDTO;
import com.gic.haoban.manage.api.dto.hm.HmQrcodeStoreDTO;
......@@ -78,7 +79,7 @@ public interface HmQrcodeApiService {
* @author mozhu
* @date 2022-07-22 15:10:42
*/
ServiceResponse delById(Long hmId,Integer invokingType);
ServiceResponse delById(Long hmId, Integer invokingType, WebLoginDTO loginDTO);
/**
* 导购解绑作废
......
......@@ -20,5 +20,7 @@ public class LogRecordAfterServiceImpl extends LogRecordAfterService {
gicLogRecordBean.setWxEnterpriseId(GicLogRecordEvaluationContext.getAttribute("wxEnterpriseId", String.class));
gicLogRecordBean.setUserId(GicLogRecordEvaluationContext.getAttribute("userId", String.class));
gicLogRecordBean.setUserName(GicLogRecordEvaluationContext.getAttribute("userName", String.class));
gicLogRecordBean.setPhoneNumber(GicLogRecordEvaluationContext.getAttribute("phoneNumber", String.class));
gicLogRecordBean.setYwName(GicLogRecordEvaluationContext.getAttribute("ywName", String.class));
}
}
......@@ -12,6 +12,7 @@ import com.gic.commons.util.UniqueIdUtils;
import com.gic.enterprise.api.dto.StoreDTO;
import com.gic.enterprise.api.service.StoreService;
import com.gic.haoban.base.api.common.errCode.HaoBanErrCodeCommon;
import com.gic.haoban.base.api.common.pojo.dto.WebLoginDTO;
import com.gic.haoban.common.utils.PageUtil;
import com.gic.haoban.manage.api.dto.StaffClerkRelationDTO;
import com.gic.haoban.manage.api.dto.WxEnterpriseDTO;
......@@ -156,7 +157,7 @@ public class HmQrcodeApiServiceImpl implements HmQrcodeApiService {
hmQrcodeQDTO.setWxConfigId(qywxExternalcontactResultDTO.getConfig_id());
//操作日志
addLog(hmQrcodeQDTO, wxEnterpriseId, hmId);
addLog(hmQrcodeQDTO);
int saveResult = hmQrcodeService.insert(hmQrcodeQDTO);
if (saveResult == 1) {
......@@ -167,14 +168,19 @@ public class HmQrcodeApiServiceImpl implements HmQrcodeApiService {
return ServiceResponse.success();
}
private void addLog(HmQrcodeQDTO hmQrcodeQDTO, String wxEnterpriseId, Long hmId) {
/**
* 新增操作日志
*
* @param hmQrcodeQDTO
*/
private void addLog(HmQrcodeQDTO hmQrcodeQDTO) {
Integer invokingType = hmQrcodeQDTO.getInvokingType();
if (invokingType == 0) {
GicLogRecordEvaluationContext.noWriteLog();
} else {
//操作日志
setLoggerContext(hmQrcodeQDTO.getEnterpriseId(), wxEnterpriseId, hmQrcodeQDTO.getCreatorId(), hmQrcodeQDTO.getCreatorName());
String logContent = "【" + hmId + "-" + hmQrcodeQDTO.getName() + "】";
setLoggerContext(hmQrcodeQDTO.getEnterpriseId(), hmQrcodeQDTO.getWxEnterpriseId(), hmQrcodeQDTO.getWebLoginDTO());
String logContent = "【" + hmQrcodeQDTO.getHmId() + "-" + hmQrcodeQDTO.getName() + "】";
if (StringUtils.isBlank(logContent)) {
GicLogRecordEvaluationContext.noWriteLog();
} else {
......@@ -223,7 +229,7 @@ public class HmQrcodeApiServiceImpl implements HmQrcodeApiService {
add(hmQrcodeQDTO);
}
setLoggerContext(enterpriseId, wxEnterpriseId, hmQrcodeQDTO.getCreatorId(), hmQrcodeQDTO.getCreatorName());
setLoggerContext(enterpriseId, wxEnterpriseId, hmQrcodeQDTO.getWebLoginDTO());
String logContent = "【" + "批量创建数量" + clerkIdList.size() + "】";
GicLogRecordEvaluationContext.putAttribute("logContent", logContent);
logger.info("批量新增活码日志:logText:{}", logContent);
......@@ -236,16 +242,24 @@ public class HmQrcodeApiServiceImpl implements HmQrcodeApiService {
*
* @param enterpriseId 企业标识
* @param wxEnterpriseId wx企业标识
* @param userId 用户id
* @param userName 用户名
* @param webLoginDTO 网络登录dto
* @author mozhu
* @date 2022-07-12 14:20:44
* @date 2022-07-28 15:34:50
*/
private void setLoggerContext(String enterpriseId, String wxEnterpriseId, String userId, String userName) {
private void setLoggerContext(String enterpriseId, String wxEnterpriseId, WebLoginDTO webLoginDTO) {
GicLogRecordEvaluationContext.putAttribute("enterpriseId", enterpriseId);
GicLogRecordEvaluationContext.putAttribute("wxEnterpriseId", wxEnterpriseId);
GicLogRecordEvaluationContext.putAttribute("userId", StringUtils.isNotBlank(userId) ? userId : "0");
GicLogRecordEvaluationContext.putAttribute("userName", StringUtils.isNotBlank(userName) ? userName : "系统");
if (webLoginDTO != null) {
GicLogRecordEvaluationContext.putAttribute("userId", webLoginDTO.getClerkId());
GicLogRecordEvaluationContext.putAttribute("userName", webLoginDTO.getClerkFullName());
GicLogRecordEvaluationContext.putAttribute("phoneNumber", webLoginDTO.getClerkPhone());
GicLogRecordEvaluationContext.putAttribute("ywName", webLoginDTO.getOperationUserName());
} else {
GicLogRecordEvaluationContext.putAttribute("userId", "-1");
GicLogRecordEvaluationContext.putAttribute("userName", "系统");
GicLogRecordEvaluationContext.putAttribute("phoneNumber", "--");
GicLogRecordEvaluationContext.putAttribute("ywName", "系统");
}
}
......@@ -292,7 +306,7 @@ public class HmQrcodeApiServiceImpl implements HmQrcodeApiService {
return ServiceResponse.failure(Convert.toStr(HaoBanErrCodeCommon.ERR_0.getCode()), qywxResponseDTO.getErrmsg());
}
setLoggerContext(hmQrcodeQDTO.getEnterpriseId(), wxEnterpriseId, hmQrcodeQDTO.getModifierId(), hmQrcodeQDTO.getModifierName());
setLoggerContext(hmQrcodeQDTO.getEnterpriseId(), wxEnterpriseId, hmQrcodeQDTO.getWebLoginDTO());
//操作日志
updateSystemLog(hmQrcodeQDTO, hmId);
......@@ -449,7 +463,7 @@ public class HmQrcodeApiServiceImpl implements HmQrcodeApiService {
if (hmType == 2) {
//多人活码
insertHmClerkRelation(hmQrcodeQDTO,enterpriseId, wxEnterpriseId, hmId, clerkIdList, addFlag);
insertHmClerkRelation(hmQrcodeQDTO, enterpriseId, wxEnterpriseId, hmId, clerkIdList, addFlag);
} else if (hmType == 1) {
//单人活码
HmQrcodeBO hmQrcodeBO = hmQrcodeService.queryByClerkId(clerkId, wxEnterpriseId);
......@@ -485,20 +499,21 @@ public class HmQrcodeApiServiceImpl implements HmQrcodeApiService {
/**
* 多人活码关联关系
*
* @param enterpriseId
* @param wxEnterpriseId
* @param hmId
* @param clerkIdList
* @param addFlag
*/
private void insertHmClerkRelation(HmQrcodeQDTO hmQrcodeQDTO,String enterpriseId,String wxEnterpriseId, Long hmId, List<String> clerkIdList, Boolean addFlag) {
private void insertHmClerkRelation(HmQrcodeQDTO hmQrcodeQDTO, String enterpriseId, String wxEnterpriseId, Long hmId, List<String> clerkIdList, Boolean addFlag) {
Date now = new Date();
if (!addFlag) {
//修改,删除其余无效导购
List<HmClerkRelationBO> hmClerkRelationBOS = hmClerkRelationService.queryByHmIdNotInClerkIds(hmId, clerkIdList);
if (CollectionUtils.isNotEmpty(hmClerkRelationBOS)) {
for (HmClerkRelationBO hmClerkRelationBO : hmClerkRelationBOS) {
hmClerkRelationService.updateStatusById(0,hmClerkRelationBO.getRelationId());
hmClerkRelationService.updateStatusById(0, hmClerkRelationBO.getRelationId());
}
}
}
......@@ -547,7 +562,7 @@ public class HmQrcodeApiServiceImpl implements HmQrcodeApiService {
hmClerkRelationQDTO.setAddNum(0);
hmClerkRelationService.insert(hmClerkRelationQDTO);
}
if (addStaffName != null && addStaffName.length() > 0){
if (addStaffName != null && addStaffName.length() > 0) {
hmQrcodeQDTO.setAddStaffName(addStaffName.toString());
}
......@@ -606,7 +621,7 @@ public class HmQrcodeApiServiceImpl implements HmQrcodeApiService {
afterFunc = LogRecordAfterServiceImpl.class)
@Override
@Transactional(rollbackFor = Exception.class)
public ServiceResponse delById(Long hmId, Integer invokingType) {
public ServiceResponse delById(Long hmId, Integer invokingType, WebLoginDTO loginDTO) {
HmQrcodeBO hmQrcodeBO = hmQrcodeService.queryById(hmId);
if (hmQrcodeBO == null) {
return ServiceResponse.failure(Convert.toStr(HaoBanErrCodeCommon.ERR_8.getCode()), "活码不存在");
......@@ -623,13 +638,12 @@ public class HmQrcodeApiServiceImpl implements HmQrcodeApiService {
}
//操作日志
setLoggerContext(hmQrcodeBO.getEnterpriseId(), hmQrcodeBO.getWxEnterpriseId(), hmQrcodeBO.getModifierId(), hmQrcodeBO.getModifierName());
setLoggerContext(hmQrcodeBO.getEnterpriseId(), hmQrcodeBO.getWxEnterpriseId(), loginDTO);
String logContent = "【" + hmId + "-" + hmQrcodeBO.getName() + "】";
if (invokingType != 1) {
logContent = logContent + "——" + ChannelCodeEnum.getNameByCode(invokingType);
}
GicLogRecordEvaluationContext.putAttribute("logContent", logContent);
hmQrcodeService.deleteById(hmId);
return ServiceResponse.success();
}
......@@ -639,7 +653,7 @@ public class HmQrcodeApiServiceImpl implements HmQrcodeApiService {
// 单人活码 直接废弃,多人活码,更新
HmQrcodeBO hmQrcodeBO = hmQrcodeService.queryByClerkId(clerkId, wxEnterpriseId);
if (hmQrcodeBO != null) {
delById(hmQrcodeBO.getHmId(), invokingType);
delById(hmQrcodeBO.getHmId(), invokingType, null);
}
// 多人活码逻辑
......@@ -661,7 +675,7 @@ public class HmQrcodeApiServiceImpl implements HmQrcodeApiService {
hmQrcodeQDTO.setClerkIdList(clerkIds);
update(hmQrcodeQDTO);
} else {
delById(hmId, invokingType);
delById(hmId, invokingType, null);
}
}
return ServiceResponse.success();
......@@ -671,7 +685,7 @@ public class HmQrcodeApiServiceImpl implements HmQrcodeApiService {
public int updateAddNumById(Long hmId, String clerkId) {
StaffClerkRelationDTO staffClerkRelationDTO = staffClerkRelationService.getByClerkId(clerkId);
if (staffClerkRelationDTO == null) {
logger.error("未绑定好办:{}",clerkId);
logger.error("未绑定好办:{}", clerkId);
return 0;
}
HmQrcodeBO hmQrcodeBO = hmQrcodeService.queryById(hmId);
......
......@@ -84,6 +84,7 @@ public class HmQrcodeController {
hmQrcodeQDTO.setWxEnterpriseId(loginUser.getWxEnterpriseId());
hmQrcodeQDTO.setEnterpriseId(loginUser.getEnterpriseId());
hmQrcodeQDTO.setInvokingType(1);
hmQrcodeQDTO.setWebLoginDTO(loginUser);
ServiceResponse serviceResponse = this.hmQrcodeApiService.add(hmQrcodeQDTO);
if (!"0000".equals(serviceResponse.getCode())) {
return RestResponse.failure(Convert.toStr(HaoBanErrCode.ERR_DEFINE.getCode()), serviceResponse.getMessage());
......@@ -100,6 +101,7 @@ public class HmQrcodeController {
hmQrcodeQDTO.setModifierName(loginUser.getClerkName());
hmQrcodeQDTO.setWxEnterpriseId(loginUser.getWxEnterpriseId());
hmQrcodeQDTO.setEnterpriseId(loginUser.getEnterpriseId());
hmQrcodeQDTO.setWebLoginDTO(loginUser);
ServiceResponse serviceResponse = this.hmQrcodeApiService.addList(hmQrcodeQDTO);
if (!"0000".equals(serviceResponse.getCode())) {
return RestResponse.failure(Convert.toStr(HaoBanErrCode.ERR_DEFINE.getCode()), serviceResponse.getMessage());
......@@ -121,6 +123,7 @@ public class HmQrcodeController {
hmQrcodeQDTO.setWxEnterpriseId(loginUser.getWxEnterpriseId());
hmQrcodeQDTO.setEnterpriseId(loginUser.getEnterpriseId());
hmQrcodeQDTO.setInvokingType(1);
hmQrcodeQDTO.setWebLoginDTO(loginUser);
ServiceResponse serviceResponse = this.hmQrcodeApiService.update(hmQrcodeQDTO);
if (!"0000".equals(serviceResponse.getCode())) {
return RestResponse.failure(Convert.toStr(HaoBanErrCode.ERR_DEFINE.getCode()), serviceResponse.getMessage());
......@@ -247,7 +250,7 @@ public class HmQrcodeController {
*/
@RequestMapping(value = "del", method = RequestMethod.DELETE)
public RestResponse del(Long hmId) {
ServiceResponse serviceResponse = this.hmQrcodeApiService.delById(hmId,1);
ServiceResponse serviceResponse = this.hmQrcodeApiService.delById(hmId,1,AuthWebRequestUtil.getLoginUser());
if (!"0000".equals(serviceResponse.getCode())) {
return RestResponse.failure(Convert.toStr(HaoBanErrCode.ERR_DEFINE.getCode()), serviceResponse.getMessage());
}
......
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