Commit 8f66ab29 by 田超

Merge branch 'feature/1006906' into 'master'

feat:[1006906]操作日志

See merge request rays/pcloud-book!1540
parents b0c168fc 0a5d159c
...@@ -175,7 +175,7 @@ public interface BookAdviserBiz { ...@@ -175,7 +175,7 @@ public interface BookAdviserBiz {
* @param adviserId 编辑标识 * @param adviserId 编辑标识
* @param channelId 渠道标识 * @param channelId 渠道标识
*/ */
public void deleteBook4Adviser(Long bookId, Long adviserId, Long channelId); public void deleteBook4Adviser(Long bookId, Long adviserId, Long channelId, String ipAddress, Long userId);
/** /**
* 恢复书籍-编辑 * 恢复书籍-编辑
...@@ -186,7 +186,7 @@ public interface BookAdviserBiz { ...@@ -186,7 +186,7 @@ public interface BookAdviserBiz {
* @param secondTempletId 模板第二阶级标识 * @param secondTempletId 模板第二阶级标识
*/ */
public void recoverBook4Adviser(Long bookId, Long adviserId, Long channelId, Long templetId,Long secondTempletId, Long graLabelId, Long subLabelId, public void recoverBook4Adviser(Long bookId, Long adviserId, Long channelId, Long templetId,Long secondTempletId, Long graLabelId, Long subLabelId,
Long verLabelId, Long areaLabelId, Boolean recoverScene, Long thirdTempletId); Long verLabelId, Long areaLabelId, Boolean recoverScene, Long thirdTempletId, String ipAddress, Long userId);
/** /**
* 获取编辑的图书总数 * 获取编辑的图书总数
......
...@@ -47,6 +47,7 @@ import com.pcloud.book.consumer.user.AdviserConsr; ...@@ -47,6 +47,7 @@ import com.pcloud.book.consumer.user.AdviserConsr;
import com.pcloud.book.consumer.user.AgentConsr; import com.pcloud.book.consumer.user.AgentConsr;
import com.pcloud.book.consumer.user.BookcaseConsr; import com.pcloud.book.consumer.user.BookcaseConsr;
import com.pcloud.book.consumer.user.ChannelConsr; import com.pcloud.book.consumer.user.ChannelConsr;
import com.pcloud.book.consumer.user.OperationConsr;
import com.pcloud.book.consumer.wechatgroup.WechatGroupConsr; import com.pcloud.book.consumer.wechatgroup.WechatGroupConsr;
import com.pcloud.book.es.biz.ESBookAndAdviserBiz; import com.pcloud.book.es.biz.ESBookAndAdviserBiz;
import com.pcloud.book.es.entity.ESBookAndAdviser; import com.pcloud.book.es.entity.ESBookAndAdviser;
...@@ -232,6 +233,8 @@ public class BookAdviserBizImpl implements BookAdviserBiz { ...@@ -232,6 +233,8 @@ public class BookAdviserBizImpl implements BookAdviserBiz {
private BookMapper bookMapper; private BookMapper bookMapper;
@Autowired @Autowired
private DataConsr dataConsr; private DataConsr dataConsr;
@Autowired
private OperationConsr operationConsr;
@Override @Override
public List<BookDto> listByAdviserId(Long adviserId) { public List<BookDto> listByAdviserId(Long adviserId) {
...@@ -280,7 +283,7 @@ public class BookAdviserBizImpl implements BookAdviserBiz { ...@@ -280,7 +283,7 @@ public class BookAdviserBizImpl implements BookAdviserBiz {
recoverBook4Adviser(bookAdviser.getBookId(), bookAdviser.getAdviserId(), bookAdviser.getChannelId(), recoverBook4Adviser(bookAdviser.getBookId(), bookAdviser.getAdviserId(), bookAdviser.getChannelId(),
bookAdviser.getTempletId(), bookAdviser.getSecondTempletId(), bookAdviser.getTempletId(), bookAdviser.getSecondTempletId(),
bookAdviser.getGraLabelId(), bookAdviser.getSubLabelId(), bookAdviser.getVerLabelId(), bookAdviser.getAreaLabelId(), bookAdviser.getGraLabelId(), bookAdviser.getSubLabelId(), bookAdviser.getVerLabelId(), bookAdviser.getAreaLabelId(),
false,bookAdviser.getThirdTempletId()); false,bookAdviser.getThirdTempletId(),null, null);
bookAdviser.setBookAdviserId(bookAdviserDto.getBookAdviserId()); bookAdviser.setBookAdviserId(bookAdviserDto.getBookAdviserId());
} else { } else {
// 判断是否配置过该书籍推广信息 // 判断是否配置过该书籍推广信息
...@@ -815,7 +818,7 @@ public class BookAdviserBizImpl implements BookAdviserBiz { ...@@ -815,7 +818,7 @@ public class BookAdviserBizImpl implements BookAdviserBiz {
*/ */
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public void deleteBook4Adviser(Long bookId, Long adviserId, Long channelId) { public void deleteBook4Adviser(Long bookId, Long adviserId, Long channelId, String ipAddress, Long userId) {
LOGGER.info("删除书籍(编辑端)<START>.[bookId]=" + bookId + ",[adviserId]=" + adviserId + ",channelId=" + channelId); LOGGER.info("删除书籍(编辑端)<START>.[bookId]=" + bookId + ",[adviserId]=" + adviserId + ",channelId=" + channelId);
Map<String, Long> paramMap = new HashMap<>(); Map<String, Long> paramMap = new HashMap<>();
paramMap.put("bookId", bookId); paramMap.put("bookId", bookId);
...@@ -830,7 +833,14 @@ public class BookAdviserBizImpl implements BookAdviserBiz { ...@@ -830,7 +833,14 @@ public class BookAdviserBizImpl implements BookAdviserBiz {
} }
//更新超级搜索es //更新超级搜索es
searchProducer.deleteBook(bookId, adviserId, channelId); searchProducer.deleteBook(bookId, adviserId, channelId);
//发送操作日志
ThreadPoolUtils.SEND_MESSAGE_THREAD_POOL.execute(()->{
BookDto book = bookBiz.getBaseById(bookId);
String adviserName = adviserConsr.getNameById(adviserId);
Long agentId = adviserConsr.getAgentIdByAdviser(adviserId);
String content = String.format("【编辑】『%s』删除书刊%s", adviserName, StringUtil.addBracket(book.getBookName()));
operationConsr.send(agentId, userId,content, ipAddress);
});
} }
/** /**
...@@ -887,7 +897,7 @@ public class BookAdviserBizImpl implements BookAdviserBiz { ...@@ -887,7 +897,7 @@ public class BookAdviserBizImpl implements BookAdviserBiz {
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public void recoverBook4Adviser(Long bookId, Long adviserId, Long channelId, Long templetId,Long secondTempletId, public void recoverBook4Adviser(Long bookId, Long adviserId, Long channelId, Long templetId,Long secondTempletId,
Long graLabelId, Long subLabelId, Long verLabelId, Long areaLabelId, Long graLabelId, Long subLabelId, Long verLabelId, Long areaLabelId,
Boolean recoverScene, Long thirdTempletId) { Boolean recoverScene, Long thirdTempletId, String ipAddress, Long userId) {
LOGGER.info("恢复书籍-编辑 <START>.[bookId]=" + bookId + ",adviserId=" + adviserId + ",channelId=" + channelId + " templetId= " + templetId + "secondTempletId=" + secondTempletId); LOGGER.info("恢复书籍-编辑 <START>.[bookId]=" + bookId + ",adviserId=" + adviserId + ",channelId=" + channelId + " templetId= " + templetId + "secondTempletId=" + secondTempletId);
checkIsHaveOtherAdviser(bookId, channelId, adviserId); checkIsHaveOtherAdviser(bookId, channelId, adviserId);
// 恢复书籍编辑的状态 // 恢复书籍编辑的状态
...@@ -897,7 +907,14 @@ public class BookAdviserBizImpl implements BookAdviserBiz { ...@@ -897,7 +907,14 @@ public class BookAdviserBizImpl implements BookAdviserBiz {
bookGroupBiz.recoverByBookId(bookId, channelId, adviserId); bookGroupBiz.recoverByBookId(bookId, channelId, adviserId);
qrcodeSceneConsr.recoverByBook(bookId, channelId, adviserId); qrcodeSceneConsr.recoverByBook(bookId, channelId, adviserId);
} }
//发送操作日志
ThreadPoolUtils.SEND_MESSAGE_THREAD_POOL.execute(()->{
BookDto book = bookBiz.getBaseById(bookId);
String adviserName = adviserConsr.getNameById(adviserId);
Long agentId = adviserConsr.getAgentIdByAdviser(adviserId);
String content = String.format("【编辑】『%s』恢复书刊%s", adviserName, StringUtil.addBracket(book.getBookName()));
operationConsr.send(agentId, userId,content, ipAddress);
});
} }
/** /**
......
...@@ -19,6 +19,8 @@ import org.springframework.web.bind.annotation.*; ...@@ -19,6 +19,8 @@ import org.springframework.web.bind.annotation.*;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import javax.servlet.http.HttpServletRequest;
/** /**
* @描述:编辑推广书籍接口类 * @描述:编辑推广书籍接口类
* @作者:songx * @作者:songx
...@@ -147,7 +149,7 @@ public interface BookAdviserFacade { ...@@ -147,7 +149,7 @@ public interface BookAdviserFacade {
@RequestMapping(value = "deleteBook4Adviser", method = RequestMethod.GET) @RequestMapping(value = "deleteBook4Adviser", method = RequestMethod.GET)
ResponseDto<?> deleteBook4Adviser(@RequestHeader("token") String token, ResponseDto<?> deleteBook4Adviser(@RequestHeader("token") String token,
@RequestParam("bookId") Long bookId, @RequestParam("bookId") Long bookId,
@RequestParam("channelId") Long channelId) @RequestParam("channelId") Long channelId, HttpServletRequest request)
throws BizException, PermissionException, JsonParseException; throws BizException, PermissionException, JsonParseException;
/** /**
...@@ -168,7 +170,7 @@ public interface BookAdviserFacade { ...@@ -168,7 +170,7 @@ public interface BookAdviserFacade {
@RequestMapping(value = "deleteBook4Adviser", method = RequestMethod.GET) @RequestMapping(value = "deleteBook4Adviser", method = RequestMethod.GET)
ResponseDto<?> recoverBook4Adviser(@RequestHeader("token") String token, ResponseDto<?> recoverBook4Adviser(@RequestHeader("token") String token,
@RequestParam(value = "bookId", required = false) Long bookId, @RequestParam(value = "bookId", required = false) Long bookId,
@RequestParam(value = "channelId", required = false) Long channelId) @RequestParam(value = "channelId", required = false) Long channelId, HttpServletRequest request)
throws BizException, PermissionException, JsonParseException; throws BizException, PermissionException, JsonParseException;
/** /**
......
...@@ -35,6 +35,7 @@ import com.pcloud.common.permission.PermissionException; ...@@ -35,6 +35,7 @@ import com.pcloud.common.permission.PermissionException;
import com.pcloud.common.utils.ParamChecker; import com.pcloud.common.utils.ParamChecker;
import com.pcloud.common.utils.SessionUtil; import com.pcloud.common.utils.SessionUtil;
import com.pcloud.common.utils.cookie.Cookie; import com.pcloud.common.utils.cookie.Cookie;
import com.pcloud.common.utils.nginx.NginxUtils;
import com.pcloud.data.domain.dto.BookScanCountParamDTO; import com.pcloud.data.domain.dto.BookScanCountParamDTO;
import com.pcloud.labelcenter.label.dto.LabelDto; import com.pcloud.labelcenter.label.dto.LabelDto;
import com.pcloud.readercenter.userlabel.dto.UserGradeLabelIdDTO; import com.pcloud.readercenter.userlabel.dto.UserGradeLabelIdDTO;
...@@ -59,6 +60,8 @@ import java.util.List; ...@@ -59,6 +60,8 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Objects; import java.util.Objects;
import javax.servlet.http.HttpServletRequest;
/** /**
* @描述:顾问书籍管理接口实现类 * @描述:顾问书籍管理接口实现类
* @作者:songx * @作者:songx
...@@ -165,10 +168,12 @@ public class BookAdviserFacadeImpl implements BookAdviserFacade { ...@@ -165,10 +168,12 @@ public class BookAdviserFacadeImpl implements BookAdviserFacade {
@RequestMapping(value = "deleteBook4Adviser", method = RequestMethod.GET) @RequestMapping(value = "deleteBook4Adviser", method = RequestMethod.GET)
public ResponseDto<?> deleteBook4Adviser(@RequestHeader("token") String token, public ResponseDto<?> deleteBook4Adviser(@RequestHeader("token") String token,
@RequestParam("bookId") Long bookId, @RequestParam("bookId") Long bookId,
@RequestParam("channelId") Long channelId) @RequestParam("channelId") Long channelId,
HttpServletRequest request)
throws BizException, PermissionException, JsonParseException { throws BizException, PermissionException, JsonParseException {
Long adviserId = (Long) SessionUtil.getVlaue(token, SessionUtil.PARTY_ID); Long adviserId = (Long) SessionUtil.getVlaue(token, SessionUtil.PARTY_ID);
bookAdviserBiz.deleteBook4Adviser(bookId, adviserId, channelId); Long userId = (Long) SessionUtil.getVlaue(token,SessionUtil.USER_ID);
bookAdviserBiz.deleteBook4Adviser(bookId, adviserId, channelId, NginxUtils.getClientIp(request), userId);
return new ResponseDto<>(); return new ResponseDto<>();
} }
...@@ -179,10 +184,12 @@ public class BookAdviserFacadeImpl implements BookAdviserFacade { ...@@ -179,10 +184,12 @@ public class BookAdviserFacadeImpl implements BookAdviserFacade {
@RequestMapping(value = "recoverBook4Adviser", method = RequestMethod.GET) @RequestMapping(value = "recoverBook4Adviser", method = RequestMethod.GET)
public ResponseDto<?> recoverBook4Adviser(@RequestHeader("token") String token, public ResponseDto<?> recoverBook4Adviser(@RequestHeader("token") String token,
@RequestParam(value = "bookId", required = false) Long bookId, @RequestParam(value = "bookId", required = false) Long bookId,
@RequestParam(value = "channelId", required = false) Long channelId) @RequestParam(value = "channelId", required = false) Long channelId,
HttpServletRequest request)
throws BizException, PermissionException, JsonParseException { throws BizException, PermissionException, JsonParseException {
Long adviserId = (Long) SessionUtil.getVlaue(token, SessionUtil.PARTY_ID); Long adviserId = (Long) SessionUtil.getVlaue(token, SessionUtil.PARTY_ID);
bookAdviserBiz.recoverBook4Adviser(bookId, adviserId, channelId, null,null, null, null, null, null, true, null); Long userId = (Long) SessionUtil.getVlaue(token,SessionUtil.USER_ID);
bookAdviserBiz.recoverBook4Adviser(bookId, adviserId, channelId, null,null, null, null, null, null, true, null, NginxUtils.getClientIp(request), userId);
return new ResponseDto<>(); return new ResponseDto<>();
} }
......
/**
*
*/
package com.pcloud.book.consumer.user;
import com.pcloud.common.core.biz.OperationLogQueueBiz;
import com.pcloud.common.core.dto.OperationLogDto;
import com.pcloud.common.exceptions.BizException;
import com.pcloud.common.utils.DateUtils;
import com.pcloud.common.utils.string.StringUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
/**
* @描述:操作日志记录
* @作者:songx
* @创建时间:2016年11月28日,下午8:55:57
* @版本:1.0
*/
@Component("operationQueue")
public class OperationConsr {
/**
*
*/
private static final Logger LOGGER = LoggerFactory.getLogger(OperationConsr.class);
@Autowired
private OperationLogQueueBiz operationLogQueueBiz;
/**
* 发送操作日志记录topic消息
*/
public void send(Long agentId, Long editorId, String content, String ip) throws BizException {
LOGGER.info("【操作日志(消)】发送操作日志记录topic消息,<START>.[agentId]=" + agentId + ",[editorId]=" + editorId + ",[content]="
+ content + ",[ip]=" + ip);
if (StringUtil.isEmpty(content) || null == editorId) {
return;
}
// 组装参数对象
OperationLogDto operationLogDto = new OperationLogDto();
operationLogDto.setAgentId(agentId);
operationLogDto.setEditorId(editorId);
operationLogDto.setContent(content);
operationLogDto.setTime(DateUtils.nowTimeStamp());
operationLogDto.setIp(ip);
// 开发发送消息
try {
operationLogQueueBiz.send(operationLogDto);
} catch (Exception e) {
LOGGER.error("【操作日志(消)】发送操作日志记录topic消息.[send]:" + e.getMessage(), e);
}
LOGGER.info("【操作日志(消)】发送操作日志记录topic消息,<END>");
}
}
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