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;
}
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";
}
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;
}
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;
}
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);
}
Aggregations