Search in sources :

Example 1 with AdminExample

use of com.itrus.portal.db.AdminExample in project portal by ixinportal.

the class AdminController method listjson.

// 列表所有信息
@RequestMapping(value = "/listjson", method = RequestMethod.GET)
@ResponseBody
public Map listjson() {
    AdminExample adminex = new AdminExample();
    List<Admin> adminall = sqlSession.selectList("com.itrus.portal.db.AdminMapper.selectByExample", adminex);
    ProjectExample projectex = new ProjectExample();
    Map projectmap = sqlSession.selectMap("com.itrus.portal.db.ProjectMapper.selectByExample", projectex, "id");
    return projectmap;
}
Also used : ProjectExample(com.itrus.portal.db.ProjectExample) Admin(com.itrus.portal.db.Admin) AdminExample(com.itrus.portal.db.AdminExample) Map(java.util.Map) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 2 with AdminExample

use of com.itrus.portal.db.AdminExample 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)

Example 3 with AdminExample

use of com.itrus.portal.db.AdminExample in project portal by ixinportal.

the class AdminLogController method acname.

/**
 * 模糊查询管理员姓名信息 用于自动补全功能
 *
 * @param term
 * @param response
 * @return
 */
@RequestMapping(value = "/acname", method = RequestMethod.GET)
@ResponseBody
public List acname(@RequestParam(value = "term", required = false) String term, HttpServletResponse response) {
    response.setHeader("Cache-Controll", "no-cache");
    response.setHeader("Cache-Controll", "max-age=15");
    SecurityContext securityContext = SecurityContextHolder.getContext();
    String adminName = securityContext.getAuthentication().getName();
    // 查询管理员信息
    AdminExample adminex0 = new AdminExample();
    adminex0.or().andAccountEqualTo(adminName);
    Admin admin0 = sqlSession.selectOne("com.itrus.portal.db.AdminMapper.selectByExample", adminex0);
    String term1 = "%" + term + "%";
    // amdinmap
    AdminExample adminex = new AdminExample();
    AdminExample.Criteria criteriaadmin = adminex.or();
    criteriaadmin.andNameLike(term1);
    // 超级用户可以处理所有请求,普通管理员仅可以处理本项目请求
    Integer projectCount = sqlSession.selectOne("com.itrus.portal.db.ProjectMapper.countByExample");
    if (getProjectLongIdsOfAdmin().length != projectCount) {
        // 项目总数量不等于当前管理员管理的项目数量,则不是超级管理员
        criteriaadmin.andProjectEqualTo(admin0.getProject());
    }
    adminex.setOrderByClause("name");
    List<Admin> admins = sqlSession.selectList("com.itrus.portal.db.AdminMapper.selectByExample", adminex);
    List<String> names = new ArrayList<String>();
    for (Admin admin : admins) names.add(admin.getName());
    return names;
}
Also used : SecurityContext(org.springframework.security.core.context.SecurityContext) Admin(com.itrus.portal.db.Admin) AdminExample(com.itrus.portal.db.AdminExample) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 4 with AdminExample

use of com.itrus.portal.db.AdminExample in project portal by ixinportal.

the class AdminLogController method acaccount.

/**
 * 模糊查询管理员帐号信息 用于自动补全功能
 *
 * @param term
 * @param response
 * @return
 */
@RequestMapping(value = "/acaccount", method = RequestMethod.GET)
@ResponseBody
public List acaccount(@RequestParam(value = "term", required = false) String term, HttpServletResponse response) {
    response.setHeader("Cache-Controll", "no-cache");
    response.setHeader("Cache-Controll", "max-age=15");
    SecurityContext securityContext = SecurityContextHolder.getContext();
    String adminName = securityContext.getAuthentication().getName();
    // 查询管理员信息
    AdminExample adminex0 = new AdminExample();
    adminex0.or().andAccountEqualTo(adminName);
    Admin admin0 = sqlSession.selectOne("com.itrus.portal.db.AdminMapper.selectByExample", adminex0);
    String term1 = "%" + term + "%";
    // amdinmap
    AdminExample adminex = new AdminExample();
    AdminExample.Criteria criteriaadmin = adminex.or();
    criteriaadmin.andAccountLike(term1);
    // 超级用户可以处理所有请求,普通管理员仅可以处理本项目请求
    Integer projectCount = sqlSession.selectOne("com.itrus.portal.db.ProjectMapper.countByExample");
    if (getProjectLongIdsOfAdmin().length != projectCount) {
        // 项目总数量不等于当前管理员管理的项目数量,则不是超级管理员
        criteriaadmin.andProjectEqualTo(admin0.getProject());
    }
    adminex.setOrderByClause("account");
    List<Admin> admins = sqlSession.selectList("com.itrus.portal.db.AdminMapper.selectByExample", adminex);
    List<String> accounts = new ArrayList<String>();
    for (Admin admin : admins) accounts.add(admin.getAccount());
    return accounts;
}
Also used : SecurityContext(org.springframework.security.core.context.SecurityContext) Admin(com.itrus.portal.db.Admin) AdminExample(com.itrus.portal.db.AdminExample) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 5 with AdminExample

use of com.itrus.portal.db.AdminExample in project portal by ixinportal.

the class ItrusPortalUserLoginSucess method onAuthenticationSuccess.

public void onAuthenticationSuccess(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, Authentication authentication) throws javax.servlet.ServletException, IOException {
    // 查询用户信息
    AdminExample adminex = new AdminExample();
    adminex.or().andAccountEqualTo(authentication.getName().toLowerCase());
    Admin admin = sqlSession.selectOne("com.itrus.portal.db.AdminMapper.selectByExample", adminex);
    if (admin != null) {
        AdminLog adminlog = new AdminLog();
        adminlog.setAdmin(admin.getId());
        adminlog.setCreateTime(new Date());
        adminlog.setType("登录成功");
        adminlog.setInfo("登录成功,管理员: " + admin.getAccount());
        adminlog.setIp(request.getRemoteAddr());
        int ret = sqlSession.insert("com.itrus.portal.db.AdminLogMapper.insert", adminlog);
    // System.out.println("insert ret  = " + ret);
    }
    setDefaultTargetUrl("/index");
    super.onAuthenticationSuccess(request, response, authentication);
}
Also used : AdminLog(com.itrus.portal.db.AdminLog) Admin(com.itrus.portal.db.Admin) AdminExample(com.itrus.portal.db.AdminExample) Date(java.util.Date)

Aggregations

Admin (com.itrus.portal.db.Admin)11 AdminExample (com.itrus.portal.db.AdminExample)11 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)6 Date (java.util.Date)3 SecurityContext (org.springframework.security.core.context.SecurityContext)3 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)3 ProjectExample (com.itrus.portal.db.ProjectExample)2 ArrayList (java.util.ArrayList)2 Map (java.util.Map)2 AdminLog (com.itrus.portal.db.AdminLog)1 AdminLogExample (com.itrus.portal.db.AdminLogExample)1 AdminRole (com.itrus.portal.db.AdminRole)1 AdminRoleExample (com.itrus.portal.db.AdminRoleExample)1 Agent (com.itrus.portal.db.Agent)1 BusinessLicense (com.itrus.portal.db.BusinessLicense)1 Certification (com.itrus.portal.db.Certification)1 DigitalCert (com.itrus.portal.db.DigitalCert)1 Enterprise (com.itrus.portal.db.Enterprise)1 IdentityCard (com.itrus.portal.db.IdentityCard)1 OrgCode (com.itrus.portal.db.OrgCode)1