use of com.itrus.portal.db.Project in project portal by ixinportal.
the class UserInfoController method detail.
/**
* 查看用户详情
*
* @param id
* 用户id
* @param item
* 用户关联的项(0企业、1证书、2订单、3认证)
* @param page
* @param size
* @param uiModel
* @return
*/
@RequestMapping("/detail")
public String detail(@RequestParam(value = "id", required = true) Long id, @RequestParam(value = "item", required = false) Integer item, @RequestParam(value = "page", required = false) Integer page, @RequestParam(value = "size", required = false) Integer size, Model uiModel) {
UserInfo userInfo = sqlSession.selectOne("com.itrus.portal.db.UserInfoMapper.selectByPrimaryKey", id);
// 判断查询的用户是否属于当前管理员所管理的范围
Long[] manageProjectIds = getProjectLongIdsOfAdmin();
// 默认不属于当前管理员管理范围
boolean flag = false;
for (Long projectId : manageProjectIds) {
if (userInfo.getProject() == projectId) {
flag = true;
}
}
if (!flag) {
// 没有管理权限
return "status403";
}
// 根据省市区code值获取省市区最新名称
String regionCodes = userInfo.getRegionCodes();
String userAdds = userInfo.getUserAdds();
if (StringUtils.isNotBlank(regionCodes) && regionCodes.indexOf("@") >= 0) {
String[] codes = regionCodes.split("@");
String regionName = sysRegionService.getAllName(codes[1], codes[2], codes[3]);
userAdds = regionName + userAdds;
userInfo.setUserAdds(userAdds);
}
uiModel.addAttribute("userInfo", userInfo);
if (page == null || page < 1) {
page = 1;
}
if (size == null || size < 1) {
size = 10;
}
// 总记录数
Integer count = 0;
// 当前页记录数
Integer itemcount = 0;
// null、0关联企业,1证书信息,2订单列表
if (null == item || 0 == item) {
item = 0;
// 关联企业
List<Enterprise> enterprises = new ArrayList<Enterprise>();
List<Long> enterpriseIds = userInfoEnterpriseService.getEnterpriseByUserInfo(userInfo.getId());
if (null != enterpriseIds && !enterpriseIds.isEmpty()) {
count = enterpriseIds.size();
EnterpriseExample enterpriseExample = new EnterpriseExample();
EnterpriseExample.Criteria criteria = enterpriseExample.or();
criteria.andIdIn(enterpriseIds);
if (page > 1 && size * (page - 1) >= count) {
page = (count + size - 1) / size;
}
Integer offset = size * (page - 1);
enterpriseExample.setOffset(offset);
enterpriseExample.setLimit(size);
enterpriseExample.setOrderByClause("create_time desc");
enterprises = sqlSession.selectList("com.itrus.portal.db.EnterpriseMapper.selectByExample", enterpriseExample);
}
itemcount = enterprises.size();
uiModel.addAttribute("enterprises", enterprises);
} else if (1 == item) {
item = 1;
// TODO 证书信息
Map<String, Object> map = new HashMap<String, Object>();
map.put("id", userInfo.getId());
count = sqlSession.selectOne("com.itrus.portal.db.UserCertMapper.countByUserInfoID", userInfo.getId());
if (page > 1 && size * (page - 1) >= count) {
page = (count + size - 1) / size;
}
Integer offset = size * (page - 1);
map.put("offset", offset);
map.put("limit", size);
List<UserCert> userCertList = sqlSession.selectList("com.itrus.portal.db.UserCertMapper.selectByUserInfoID", map);
itemcount = userCertList.size();
uiModel.addAttribute("userCertList", userCertList);
} else if (2 == item) {
item = 2;
// 订单列表
BillExample billExample = new BillExample();
BillExample.Criteria criteria = billExample.or();
criteria.andUniqueIdEqualTo(userInfo.getId());
// criteria.andIsDeleteEqualTo(false);
count = sqlSession.selectOne("com.itrus.portal.db.BillMapper.countByExample", billExample);
if (page > 1 && size * (page - 1) >= count) {
page = (count + size - 1) / size;
}
Integer offset = size * (page - 1);
billExample.setOffset(offset);
billExample.setLimit(size);
billExample.setOrderByClause("create_time desc");
List<Bill> billList = sqlSession.selectList("com.itrus.portal.db.BillMapper.selectByExample", billExample);
itemcount = billList.size();
uiModel.addAttribute("billList", billList);
Map<Long, Project> projectMap = billService.getProjectMapByUserInfoId(userInfo.getId());
uiModel.addAttribute("projectMap", projectMap);
Map<Long, Product> productMap = billService.getProductMapByUserInfoId(userInfo.getId());
uiModel.addAttribute("productMap", productMap);
Map<Long, Enterprise> enterpriseMap = billService.getEnterpriseMapByUserInfoId(userInfo.getId());
uiModel.addAttribute("enterpriseMap", enterpriseMap);
} else if (3 == item) {
item = 3;
Agent agent = sqlSession.selectOne("com.itrus.portal.db.AgentMapper.selectNewAgentByUserId", id);
uiModel.addAttribute("agent", agent);
}
uiModel.addAttribute("count", count);
uiModel.addAttribute("pages", (count + size - 1) / size);
uiModel.addAttribute("page", page);
uiModel.addAttribute("size", size);
uiModel.addAttribute("itemcount", itemcount);
uiModel.addAttribute("item", item);
return "userInfo/detail";
}
use of com.itrus.portal.db.Project in project portal by ixinportal.
the class CustomerServerClientController method onLine.
/**
* 用户登录后的客服在线
* @param certSn
* @param keySn
* @param enterpriseName
* @param session
* @param uiModel
* @return
*/
@RequestMapping("/online")
public String onLine(@RequestParam(value = "certSn", required = false) String certSn, @RequestParam(value = "keySn", required = false) String keySn, @RequestParam(value = "enterpriseName", required = false) String enterpriseName, HttpSession session, Model uiModel) {
// TODO
Boolean verifyCodeStatus = (Boolean) session.getAttribute(ComNames.WEB_VERIFY_CODE_STATUS);
Enterprise enterprise = (Enterprise) session.getAttribute(ComNames.WEB_ENTERPRISE);
UserInfo userInfo = (UserInfo) session.getAttribute(ComNames.WEB_USER_INFO);
if (null == verifyCodeStatus || !verifyCodeStatus || null == userInfo) {
// 登录状态失效,跳转到登录页面
return ComNames.DENG_LU_CLIENT;
}
// 先根据key序列号取项目,若没有,则根据用户所属项目取项目信息
Project project = null;
if (StringUtils.isNotBlank(keySn)) {
ProjectKeyInfo projectKeyInfo = cacheCustomer.findProjectByKey(keySn);
if (null == projectKeyInfo) {
uiModel.addAttribute("errorMsg", "无法识别的key序列号:" + keySn + ", 请联系系统管理员进行配置");
return ComNames.CLIENTFW_ERRORPAGE;
}
project = projectService.selectByPrimaryKey(projectKeyInfo.getProject());
}
// 若项目为Null,而certsn不为null,则尝试从数据库获取keysn,查找项目
if (null == project && StringUtils.isNotBlank(certSn)) {
UserCert userCert = userCertService.getUserCertByCertSn(certSn);
if (null != userCert && StringUtils.isNotBlank(userCert.getKeySn())) {
ProjectKeyInfo projectKeyInfo = cacheCustomer.findProjectByKey(userCert.getKeySn());
if (null != projectKeyInfo) {
project = projectService.selectByPrimaryKey(projectKeyInfo.getProject());
}
}
}
if (null == project) {
project = projectService.selectByPrimaryKey(userInfo.getProject());
}
Map<String, String> map = questionService.auth(project.getId());
if (map != null && !map.isEmpty()) {
uiModel.addAttribute("qq", map.get("qq"));
uiModel.addAttribute("phone", map.get("phone"));
uiModel.addAttribute("questionUrl", map.get("questionUrl"));
uiModel.addAttribute("downloadUrl", map.get("downloadUrl"));
}
return "clientFW/kefuzaixian";
}
use of com.itrus.portal.db.Project in project portal by ixinportal.
the class ProjectController method updateForm.
// 返回修改页面
@RequestMapping(value = "/{id}", params = "form", produces = "text/html")
public String updateForm(@PathVariable("id") Long id, Model uiModel) {
List raaccountall = sqlSession.selectList("com.itrus.portal.db.RaAccountMapper.selectByExample");
uiModel.addAttribute("raaccounts", raaccountall);
Project project = sqlSession.selectOne("com.itrus.portal.db.ProjectMapper.selectByPrimaryKey", id);
uiModel.addAttribute("project", project);
// orgCode
uiModel.addAttribute("orgCode", project.getOrgCode());
return "projects/update";
}
use of com.itrus.portal.db.Project in project portal by ixinportal.
the class ProjectController method delete.
// 删除
@RequestMapping(value = "/{id}", method = RequestMethod.DELETE, produces = "text/html")
public String delete(@PathVariable("id") Long id, HttpServletRequest request, Model uiModel) {
Project project = sqlSession.selectOne("com.itrus.portal.db.ProjectMapper.selectByPrimaryKey", id);
if (project == null) {
uiModel.addAttribute("message", "未找到要删除项目");
} else {
try {
sqlSession.delete("com.itrus.portal.db.ProjectMapper.deleteByPrimaryKey", id);
String oper = "删除项目";
String info = "项目名称: " + project.getName();
LogUtil.adminlog(sqlSession, oper, info);
cacheCustomer.initProjectMap();
} catch (Exception e) {
uiModel.addAttribute("message", "要删除项目【" + project.getName() + "】存在关联,无法删除");
}
}
return getReferer(request, "redirect:/projects", true);
}
use of com.itrus.portal.db.Project in project portal by ixinportal.
the class ProjectKeyInfoController method create.
// 新建处理
@RequestMapping(method = RequestMethod.POST, produces = "text/html")
public String create(@Valid ProjectKeyInfo projectkeyinfo, @RequestParam(value = "retpath", required = false) String retpath, BindingResult bindingResult, Model uiModel, HttpServletRequest httpServletRequest) throws Exception {
if (bindingResult.hasErrors()) {
return "projectkeyinfos/create";
}
// 检查是否有权限操作
Long[] projects = getProjectLongIdsOfAdmin();
List<Long> list = Arrays.asList(projects);
if (list != null && !list.contains(projectkeyinfo.getProject())) {
return "status403";
}
projectkeyinfo.setCreateTime(new Date());
projectkeyinfo.setId(null);
// 加密adminPinValue信息
if (projectkeyinfo.getAdminPinValue() != null && !projectkeyinfo.getAdminPinValue().equals("")) {
String unlockCipher = "AES";
SecretKeySpec skeySpec = new SecretKeySpec(this.adminPinEncKey.substring(0, 16).getBytes(), unlockCipher);
IvParameterSpec ivSpec = new IvParameterSpec(this.adminPinEncKey.substring(16, 32).getBytes());
Cipher cipher = Cipher.getInstance(unlockCipher + "/CBC/PKCS5Padding");
cipher.init(Cipher.ENCRYPT_MODE, skeySpec, ivSpec, null);
byte[] encadminpin = cipher.doFinal(projectkeyinfo.getAdminPinValue().getBytes());
String sencadminpin = new String(Base64.encode(encadminpin));
projectkeyinfo.setAdminPinValue(sencadminpin);
}
if (projectkeyinfo.getAdminPinValue2() != null && !projectkeyinfo.getAdminPinValue2().equals("")) {
String unlockCipher = "AES";
SecretKeySpec skeySpec = new SecretKeySpec(this.adminPinEncKey.substring(0, 16).getBytes(), unlockCipher);
IvParameterSpec ivSpec = new IvParameterSpec(this.adminPinEncKey.substring(16, 32).getBytes());
Cipher cipher = Cipher.getInstance(unlockCipher + "/CBC/PKCS5Padding");
cipher.init(Cipher.ENCRYPT_MODE, skeySpec, ivSpec, null);
byte[] encadminpin = cipher.doFinal(projectkeyinfo.getAdminPinValue2().getBytes());
String sencadminpin = new String(Base64.encode(encadminpin));
projectkeyinfo.setAdminPinValue2(sencadminpin);
}
sqlSession.insert("com.itrus.portal.db.ProjectKeyInfoMapper.insert", projectkeyinfo);
Project project = sqlSession.selectOne("com.itrus.portal.db.ProjectMapper.selectByPrimaryKey", projectkeyinfo.getProject());
String oper = "添加序列号";
String info = "项目名称: " + project.getName() + ", 序列号1: " + projectkeyinfo.getSn1() + ", 序列号2: " + projectkeyinfo.getSn2();
LogUtil.adminlog(sqlSession, oper, info);
cacheCustomer.initProjectKeyInfos();
if (retpath != null && retpath.length() > 0)
return retpath;
else
return "redirect:/projectkeyinfos";
}
Aggregations