use of com.bc.pmpheep.back.po.SysOperation in project pmph by BCSquad.
the class SysOperationServiceImpl method getListSysOperation.
@Override
public PageResult<SysOperation> getListSysOperation(PageParameter<SysOperation> pageParameter) throws CheckedServiceException {
PageResult<SysOperation> pageResult = new PageResult<SysOperation>();
String startTime = pageParameter.getParameter().getStartTime();
String endTime = pageParameter.getParameter().getEndTime();
// 查询近一个月操作日志
String startDate = DateUtil.date2Str(new Date());
String endDate = DateUtil.getAfterDayDate("-30");
if (StringUtil.isEmpty(startTime) && StringUtil.isEmpty(endTime)) {
pageParameter.getParameter().setStartTime(endDate);
pageParameter.getParameter().setEndTime(startDate);
} else {
if (StringUtil.isEmpty(startTime)) {
pageParameter.getParameter().setStartTime(DateUtil.date2Str(DateUtil.getDateBefore(DateUtil.str2Date(endTime), 30)));
pageParameter.getParameter().setEndTime(endTime);
}
if (StringUtil.isEmpty(endTime)) {
pageParameter.getParameter().setStartTime(startTime);
pageParameter.getParameter().setEndTime(DateUtil.date2Str(DateUtil.getDateBefore(DateUtil.str2Date(startTime), -30)));
}
}
// 将页面大小和页面页码拷贝
PageParameterUitl.CopyPageParameter(pageParameter, pageResult);
// 包含数据总条数的数据集
List<SysOperation> sysOperations = sysOperationDao.getListSysOperation(pageParameter);
if (CollectionUtil.isNotEmpty(sysOperations)) {
Integer count = sysOperations.get(0).getCount();
pageResult.setTotal(count);
pageResult.setRows(sysOperations);
}
return pageResult;
}
use of com.bc.pmpheep.back.po.SysOperation in project pmph by BCSquad.
the class OperationLogInterceptor method postHandle.
/**
* <pre>
* 功能描述:在调用controller具体方法中,返回前拦截
* 使用示范:
*
* @param request HttpServletRequest
* @param response HttpServletRequest
* @param object Object
* @throws Exception
* </pre>
*/
@SuppressWarnings("rawtypes")
@Override
public void postHandle(HttpServletRequest request, HttpServletResponse response, Object object, ModelAndView modelAndView) throws Exception {
if (object instanceof HandlerMethod) {
// 完整请求路径
String requestUri = request.getRequestURI();
// 项目路径
String contextPath = request.getContextPath();
// 模块路径
String url = requestUri.substring(contextPath.length());
Boolean isAccess = false;
// 不拦截excludeUrls中配置的url请求
for (String requestUrl : excludeUrls) {
if (requestUrl.endsWith("/**")) {
if (url.startsWith(requestUrl.substring(0, requestUrl.length() - 3))) {
isAccess = true;
break;
}
} else if (url.startsWith(requestUrl)) {
isAccess = true;
break;
}
}
if (!isAccess) {
HandlerMethod handlerMethod = (HandlerMethod) object;
// 类名
Class cls = handlerMethod.getBeanType();
// 类中的所有方法
Method[] methods = cls.getMethods();
// 方法用途
String logRemark = "";
// 业务类型
String businessType = "";
HttpSession session = null;
try {
session = request.getSession();
} catch (Exception e) {
logger.warn("session为空时出现异常:{}", e.getMessage());
}
if (ObjectUtil.notNull(session)) {
PmphUser pmphUser = (PmphUser) session.getAttribute(Const.SESSION_PMPH_USER);
if (ObjectUtil.notNull(pmphUser)) {
// 调用接口方法
String subUrl = url.substring(url.lastIndexOf("/") + 1, url.length());
for (Method method : methods) {
LogDetail logObj = method.getAnnotation(LogDetail.class);
if (ObjectUtil.notNull(logObj) && method.getName().equals(subUrl)) {
logRemark = logObj.logRemark();
businessType = logObj.businessType();
break;
}
}
// 获取用户访问设备类型
String deviceType = DeviceUtils.isMobileDevice(request);
// 此处调用 sysOperationService 保存方法
sysOperationService.addSysOperation(new SysOperation(pmphUser.getId(), pmphUser.getUsername(), pmphUser.getRealname(), DateUtil.getCurrentTime(), url + "-" + logRemark, StringUtil.getClientIP(request), businessType, deviceType));
}
}
}
}
}
use of com.bc.pmpheep.back.po.SysOperation in project pmph by BCSquad.
the class PmphUserServiceImpl method getPersonalCenter.
@Override
public Map<String, Object> getPersonalCenter(HttpServletRequest request, String state, String materialName, String groupName, String title, String bookname, String name, String authProgress, String topicBookname) {
String sessionId = CookiesUtil.getSessionId(request);
PmphUser sessionPmphUser = SessionUtil.getPmphUserBySessionId(sessionId);
if (null == sessionPmphUser) {
throw new CheckedServiceException(CheckedExceptionBusiness.MATERIAL, CheckedExceptionResult.NULL_PARAM, "请求用户不存在");
}
// 获取用户角色
List<PmphRole> rolelist = roleService.getPmphRoleByUserId(sessionPmphUser.getId());
// 用于装所有的数据map
Map<String, Object> map = new HashMap<>();
// 教师认证总数量
Integer writerUserCount = writerUserService.getCount();
// 机构认证数量orgList
Integer orgerCount = orgUserService.getCount();
// 小组
PmphGroupListVO pmphGroup = new PmphGroupListVO();
PageParameter<PmphGroupListVO> pageParameterPmphGroup = new PageParameter<>();
pageParameterPmphGroup.setParameter(pmphGroup);
// 小组结果
PageResult<PmphGroupListVO> pageResultPmphGroup = pmphGroupService.getlistPmphGroup(pageParameterPmphGroup, sessionId);
// 教材申报
PageParameter<MaterialListVO> pageParameter2 = new PageParameter<>();
MaterialListVO materialListVO = new MaterialListVO();
materialListVO.setState(state);
materialListVO.setMaterialName(materialName);
pageParameter2.setParameter(materialListVO);
// 教材申报的结果
PageResult<MaterialListVO> pageResultMaterialListVO = materialService.listMaterials(pageParameter2, sessionId);
// 文章审核
PageParameter<CmsContentVO> pageParameter1 = new PageParameter<>();
CmsContentVO cmsContentVO = new CmsContentVO();
cmsContentVO.setTitle(title);
cmsContentVO.setCategoryId(Const.CMS_CATEGORY_ID_1);
pageParameter1.setParameter(cmsContentVO);
// 文章审核的结果
PageResult<CmsContentVO> pageResultCmsContentVO = cmsContentService.listCmsContent(pageParameter1, sessionId);
map.put("cmsContent", pageResultCmsContentVO);
// 图书纠错审核
PageResult<BookCorrectionAuditVO> pageResultBookCorrectionAuditVO = bookCorrectionService.listBookCorrectionAudit(request, Const.PAGE_NUMBER, Const.PAGE_SIZE, bookname, null, null);
map.put("bookCorrectionAudit", pageResultBookCorrectionAuditVO);
// 图书评论审核
PageParameter<BookUserCommentVO> pageParameter = new PageParameter<>();
BookUserCommentVO bookUserCommentVO = new BookUserCommentVO();
// 去除空格
bookUserCommentVO.setName(name.replaceAll(" ", ""));
pageParameter.setParameter(bookUserCommentVO);
PageResult<BookUserCommentVO> pageResultBookUserCommentVO = bookUserCommentService.listBookUserCommentAdmin(pageParameter);
map.put("bookUserComment", pageResultBookUserCommentVO);
// 选题申报
PageParameter<TopicDeclarationVO> pageParameter3 = new PageParameter<>();
// 选题申报当前用户角色
PmphIdentity pmphIdentity = pmphUserService.identity(sessionId);
TopicDeclarationVO topicDeclarationVO = new TopicDeclarationVO();
// 是否由主任受理
if (pmphIdentity.getIsDirector()) {
topicDeclarationVO.setIsDirectorHandling(true);
}
// 是否由运维人员受理
if (pmphIdentity.getIsOpts()) {
topicDeclarationVO.setIsOptsHandling(true);
}
// 是否由编辑受理
if (pmphIdentity.getIsEditor()) {
topicDeclarationVO.setIsEditorHandling(true);
}
for (PmphRole pmphRole : rolelist) {
// 编辑
if (2 == pmphRole.getId()) {
topicDeclarationVO.setIsEditorHandling(true);
}
// 主任
if (9 == pmphRole.getId()) {
topicDeclarationVO.setIsDirectorHandling(true);
}
}
String[] strs = authProgress.split(",");
List<Long> progress = new ArrayList<>();
for (String str : strs) {
progress.add(Long.valueOf(str));
}
topicDeclarationVO.setBookname(topicBookname);
pageParameter3.setParameter(topicDeclarationVO);
//
if (sessionPmphUser.getIsAdmin()) {
PageResult<TopicDeclarationVO> pageResultTopicDeclarationVO = topicService.listMyTopic(progress, pageParameter3, null);
// topicService.listCheckTopic(progress, pageParameter3);
map.put("topicList", pageResultTopicDeclarationVO);
} else {
if (2 == rolelist.get(0).getId() || 9 == rolelist.get(0).getId() || 1 == rolelist.get(0).getId()) {
PageResult<TopicDeclarationVO> pageResultTopicDeclarationVO = topicService.listMyTopic(progress, pageParameter3, sessionPmphUser.getId());
// topicService.listCheckTopic(progress, pageParameter3);
map.put("topicList", pageResultTopicDeclarationVO);
} else {
PageResult<TopicDeclarationVO> pageResultTopicDeclarationVO = new PageResult<>();
List<TopicDeclarationVO> list = new ArrayList<>();
pageResultTopicDeclarationVO.setPageNumber(0);
pageResultTopicDeclarationVO.setRows(list);
pageResultTopicDeclarationVO.setPageTotal(0);
pageResultTopicDeclarationVO.setStart(0);
pageResultTopicDeclarationVO.setTotal(0);
;
map.put("topicList", pageResultTopicDeclarationVO);
}
}
// 获取用户上次登录时间
List<SysOperation> listSysOperation = sysOperationService.getSysOperation(sessionPmphUser.getId());
Timestamp loginTime = DateUtil.getCurrentTime();
if (!listSysOperation.isEmpty()) {
loginTime = listSysOperation.get(0).getOperateDate();
}
// 把其他模块的数据都装入map中返回给前端
map.put("materialList", pageResultMaterialListVO);
map.put("pmphGroup", pageResultPmphGroup);
map.put("writerUserCount", writerUserCount);
map.put("orgUserCount", orgerCount);
// 把用户信息存入map
map.put("pmphUser", sessionPmphUser);
// 把用户角色存入map
map.put("pmphRole", rolelist);
// 把选题申报的当前身份存入map
map.put("pmphIdentity", pmphIdentity);
// 存入用户上次操作时间
map.put("loginTime", loginTime);
return map;
}
use of com.bc.pmpheep.back.po.SysOperation in project pmph by BCSquad.
the class SysOperationSeviceTest method testServiceAllMethodTest.
/**
* <pre>
* 功能描述:所有方法测试
* 使用示范:
*
* </pre>
*/
@Test
@Rollback(Const.ISROLLBACK)
public void testServiceAllMethodTest() {
// add
SysOperation sysOperation = sysOperationService.addSysOperation(new SysOperation(1L, "a", "a", DateUtil.getCurrentTime(), "/cms/content", "192.168.200.209", "aaaa", "pc"));
logger.info(sysOperation.toString());
Assert.assertNotNull("插入内容后返回的sysOperation.id不应为空", sysOperation.getId());
}
use of com.bc.pmpheep.back.po.SysOperation in project pmph by BCSquad.
the class SysOperationSeviceTest method testGetListSysOperation.
@Test
@Rollback(Const.ISROLLBACK)
public void testGetListSysOperation() {
PageParameter<SysOperation> pageParameter = new PageParameter<SysOperation>();
PageResult<SysOperation> pageResult = new PageResult<SysOperation>();
SysOperation sysOperation = new SysOperation(1L, "a", "a", DateUtil.getCurrentTime(), "/cms/content", "192.168.200.209", "aaaa", "pc");
pageParameter.setPageNumber(1);
pageParameter.setPageSize(10);
pageParameter.setParameter(sysOperation);
pageResult = sysOperationService.getListSysOperation(pageParameter);
Assert.assertNotNull("获取SysOperation列表失败", pageResult);
}
Aggregations