Search in sources :

Example 1 with SysOperation

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;
}
Also used : SysOperation(com.bc.pmpheep.back.po.SysOperation) PageResult(com.bc.pmpheep.back.plugin.PageResult) Date(java.util.Date)

Example 2 with SysOperation

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));
                }
            }
        }
    }
}
Also used : LogDetail(com.bc.pmpheep.annotation.LogDetail) SysOperation(com.bc.pmpheep.back.po.SysOperation) PmphUser(com.bc.pmpheep.back.po.PmphUser) HttpSession(javax.servlet.http.HttpSession) HandlerMethod(org.springframework.web.method.HandlerMethod) Method(java.lang.reflect.Method) HandlerMethod(org.springframework.web.method.HandlerMethod)

Example 3 with SysOperation

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;
}
Also used : SysOperation(com.bc.pmpheep.back.po.SysOperation) CmsContentVO(com.bc.pmpheep.back.vo.CmsContentVO) HashMap(java.util.HashMap) MaterialListVO(com.bc.pmpheep.back.vo.MaterialListVO) ArrayList(java.util.ArrayList) PageParameter(com.bc.pmpheep.back.plugin.PageParameter) Timestamp(java.sql.Timestamp) BookCorrectionAuditVO(com.bc.pmpheep.back.vo.BookCorrectionAuditVO) PmphRole(com.bc.pmpheep.back.po.PmphRole) PmphUser(com.bc.pmpheep.back.po.PmphUser) PmphIdentity(com.bc.pmpheep.back.vo.PmphIdentity) CheckedServiceException(com.bc.pmpheep.service.exception.CheckedServiceException) TopicDeclarationVO(com.bc.pmpheep.back.vo.TopicDeclarationVO) PageResult(com.bc.pmpheep.back.plugin.PageResult) BookUserCommentVO(com.bc.pmpheep.back.vo.BookUserCommentVO) PmphGroupListVO(com.bc.pmpheep.back.vo.PmphGroupListVO)

Example 4 with SysOperation

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());
}
Also used : SysOperation(com.bc.pmpheep.back.po.SysOperation) Test(org.junit.Test) BaseTest(com.bc.pmpheep.test.BaseTest) Rollback(org.springframework.test.annotation.Rollback)

Example 5 with SysOperation

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);
}
Also used : SysOperation(com.bc.pmpheep.back.po.SysOperation) PageParameter(com.bc.pmpheep.back.plugin.PageParameter) PageResult(com.bc.pmpheep.back.plugin.PageResult) Test(org.junit.Test) BaseTest(com.bc.pmpheep.test.BaseTest) Rollback(org.springframework.test.annotation.Rollback)

Aggregations

SysOperation (com.bc.pmpheep.back.po.SysOperation)5 PageResult (com.bc.pmpheep.back.plugin.PageResult)3 PageParameter (com.bc.pmpheep.back.plugin.PageParameter)2 PmphUser (com.bc.pmpheep.back.po.PmphUser)2 BaseTest (com.bc.pmpheep.test.BaseTest)2 Test (org.junit.Test)2 Rollback (org.springframework.test.annotation.Rollback)2 LogDetail (com.bc.pmpheep.annotation.LogDetail)1 PmphRole (com.bc.pmpheep.back.po.PmphRole)1 BookCorrectionAuditVO (com.bc.pmpheep.back.vo.BookCorrectionAuditVO)1 BookUserCommentVO (com.bc.pmpheep.back.vo.BookUserCommentVO)1 CmsContentVO (com.bc.pmpheep.back.vo.CmsContentVO)1 MaterialListVO (com.bc.pmpheep.back.vo.MaterialListVO)1 PmphGroupListVO (com.bc.pmpheep.back.vo.PmphGroupListVO)1 PmphIdentity (com.bc.pmpheep.back.vo.PmphIdentity)1 TopicDeclarationVO (com.bc.pmpheep.back.vo.TopicDeclarationVO)1 CheckedServiceException (com.bc.pmpheep.service.exception.CheckedServiceException)1 Method (java.lang.reflect.Method)1 Timestamp (java.sql.Timestamp)1 ArrayList (java.util.ArrayList)1