Search in sources :

Example 1 with AdminLogExampleExt

use of com.itrus.portal.sql.AdminLogExampleExt in project portal by ixinportal.

the class AdminLogController method list.

// 列表所有信息
@RequestMapping(produces = "text/html")
public String list(@RequestParam(value = "admin", required = false) String admin, @RequestParam(value = "type", required = false) String type, @RequestParam(value = "info", required = false) String info, @RequestParam(value = "page", required = false) Integer page, @RequestParam(value = "size", required = false) Integer size, @RequestParam(value = "queryDate1", required = false) Date queryDate1, @RequestParam(value = "queryDate2", required = false) Date queryDate2, Model uiModel) {
    // admin,type
    if (queryDate1 == null && queryDate2 == null) {
        Calendar calendar = Calendar.getInstance();
        calendar.add(Calendar.DATE, 1);
        calendar.set(Calendar.HOUR_OF_DAY, 0);
        calendar.set(Calendar.MINUTE, 0);
        calendar.set(Calendar.SECOND, 0);
        calendar.set(Calendar.MILLISECOND, 0);
        calendar.add(Calendar.MILLISECOND, -1);
        queryDate2 = calendar.getTime();
        calendar.add(Calendar.MILLISECOND, 1);
        calendar.add(Calendar.MONTH, -1);
        queryDate1 = calendar.getTime();
    }
    uiModel.addAttribute("admin", admin);
    uiModel.addAttribute("type", type);
    uiModel.addAttribute("info", info);
    uiModel.addAttribute("queryDate1", queryDate1);
    uiModel.addAttribute("queryDate2", queryDate2);
    // page,size
    if (page == null || page < 1)
        page = 1;
    if (size == null || size < 1)
        size = 10;
    AdminLogExampleExt adminlogex = new AdminLogExampleExt();
    AdminLogExample.Criteria criteria = adminlogex.or();
    // admin
    AdminExample adminex = new AdminExample();
    AdminExample.Criteria criteriaadmin = adminex.or();
    if (StringUtils.isNotBlank(admin))
        criteriaadmin.andAccountLike("%" + admin.trim() + "%");
    Long[] adminPro = getProjectLongIdsOfAdmin();
    // 超级用户可以处理所有请求,普通管理员仅可以处理本项目所管理的项目
    if (adminPro != null) {
        criteriaadmin.andProjectIn(Arrays.asList(adminPro));
    }
    List<Admin> admins = sqlSession.selectList("com.itrus.portal.db.AdminMapper.selectByExample", adminex);
    List ids = new ArrayList();
    for (Admin adminobj : admins) ids.add(adminobj.getId());
    ids.add(-1);
    criteria.andAdminIn(ids);
    // type
    if (type != null && type.length() > 0) {
        criteria.andTypeLike("%" + type + "%");
    }
    // info
    if (StringUtils.isNotBlank(info)) {
        criteria.andInfoLike("%" + info.trim() + "%");
    }
    if (queryDate1 != null)
        criteria.andCreateTimeGreaterThanOrEqualTo(queryDate1);
    if (queryDate2 != null)
        criteria.andCreateTimeLessThanOrEqualTo(queryDate2);
    adminlogex.setOrderByClause("id desc");
    // count,pages
    Integer count = sqlSession.selectOne("com.itrus.portal.db.AdminLogMapper.countByExample", adminlogex);
    uiModel.addAttribute("count", count);
    uiModel.addAttribute("pages", (count + size - 1) / size);
    // page, size
    if (page > 1 && size * (page - 1) >= count) {
        page = (count + size - 1) / size;
    }
    uiModel.addAttribute("page", page);
    uiModel.addAttribute("size", size);
    // query data
    Integer offset = size * (page - 1);
    adminlogex.setOffset(offset);
    adminlogex.setLimit(size);
    List adminlogall = sqlSession.selectList("com.itrus.portal.db.AdminLogMapper.selectByExampleLimit", adminlogex);
    uiModel.addAttribute("adminlogs", adminlogall);
    // itemcount
    uiModel.addAttribute("itemcount", adminlogall.size());
    // amdinmap
    // AdminExample adminex = new AdminExample();
    Map adminmap = sqlSession.selectMap("com.itrus.portal.db.AdminMapper.selectByExample", null, "id");
    uiModel.addAttribute("adminmap", adminmap);
    return "adminlogs/list";
}
Also used : AdminLogExample(com.itrus.portal.db.AdminLogExample) Admin(com.itrus.portal.db.Admin) AdminLogExampleExt(com.itrus.portal.sql.AdminLogExampleExt) AdminExample(com.itrus.portal.db.AdminExample) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

Admin (com.itrus.portal.db.Admin)1 AdminExample (com.itrus.portal.db.AdminExample)1 AdminLogExample (com.itrus.portal.db.AdminLogExample)1 AdminLogExampleExt (com.itrus.portal.sql.AdminLogExampleExt)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1