package org.fkit.oa.identity.service.impl;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.JoinType;
import javax.persistence.criteria.Path;
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;
import javax.servlet.http.HttpSession;
import org.fkit.common.util.CommonContants;
import org.fkit.common.util.pager.PageModel;
import org.fkit.oa.identity.domain.Dept;
import org.fkit.oa.identity.domain.Module;
import org.fkit.oa.identity.domain.Popedom;
import org.fkit.oa.identity.domain.Role;
import org.fkit.oa.identity.domain.User;
import org.fkit.oa.identity.dto.UserModule;
import org.fkit.oa.identity.repository.DeptRepository;
import org.fkit.oa.identity.repository.JobRepository;
import org.fkit.oa.identity.repository.ModuleRepository;
import org.fkit.oa.identity.repository.PopedomRepository;
import org.fkit.oa.identity.repository.RoleRepository;
import org.fkit.oa.identity.repository.UserRepository;
import org.fkit.oa.identity.service.IdentityService;
import org.fkit.oa.identity.vo.TreeData;
import org.fkit.oa.util.OaContants;
import org.fkit.oa.util.OaException;
import org.fkit.oa.util.UserHolder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils;
//import org.fkjava.common.Repository.GeneratorRepository;
/**
* @author xlei
* @Email dlei0006@163.com
* @QQ 251425887
* @Tel 18665616520
* @Date 2017年1月14日上午9:39:25
* @From http://www.fkjava.org
* 系统管理的业务层实现类
*/
@Service("identityService") // 配置业务层的bean
//@Transactional(readOnly=false,rollbackFor=java.lang.RuntimeException.class)
@Transactional(readOnly=true)
public class IdentityServiceImpl implements IdentityService {
// session
/** 定义Repository对象 */
@Autowired // bytype
@Qualifier("deptRepository") // byName
private DeptRepository deptRepository;
@Autowired // bytype
@Qualifier("jobRepository") // byName
private JobRepository jobRepository;
@Autowired // bytype
@Qualifier("userRepository") // byName
private UserRepository userRepository;
@Autowired // bytype
@Qualifier("moduleRepository") // byName
private ModuleRepository moduleRepository;
@Autowired // bytype
@Qualifier("roleRepository") // byName
private RoleRepository roleRepository;
@Autowired // bytype
@Qualifier("popedomRepository") // byName
private PopedomRepository popedomRepository;
@Transactional(readOnly=true)
@Override
public List<Dept> getAllDepts(){
try {
List<Dept> depts = deptRepository.findAll();
// 取延迟加载的属性 ,会话此时并没有关闭
for(Dept dept : depts){
if(dept.getCreater()!=null)dept.getCreater().getName();
if(dept.getModifier()!=null)dept.getModifier().getName();
}
return depts;
} catch (Exception e) {
throw new OaException("查询部门失败了", e);
}
}
@Override
public Map<String , Object> login(Map<String, Object> params) {
Map<String , Object> result = new HashMap<>();
try {
/** 处理登录的业务逻辑 */
/** 1.参数非空校验 */
String userId = (String) params.get("userId");
String passWord = (String) params.get("passWord");
String vcode = (String) params.get("vcode");
HttpSession session = (HttpSession) params.get("session");
// userId!=null&&!userId.equals("")
if(StringUtils.isEmpty(userId) || StringUtils.isEmpty(passWord)
|| StringUtils.isEmpty(vcode) ){
/** 参数有为空的 */
result.put("status", 0);
result.put("tip", "参数有为空的");
}else{
/** 参数不为空 */
/** 校验验证码是否正确
* 获取session中当前用户对应的验证码
* */
String sysCode = (String) session.getAttribute(CommonContants.VERIFY_SESSION);
if(vcode.equalsIgnoreCase(sysCode)){
/** 验证码正确了 */
/** 根据登录的用户名去查询用户: 判断登录名是否存在 */
User user = getUserById(userId);
if(user!=null){
/** 登录名存在 */
/** 判断密码 */
if(user.getPassWord().equals(passWord)){
/** 判断用户是否已经被激活了 */
if(user.getStatus() == 1){
/** 登录成功 */
/** 1.把登录成功的用户放入当前用户的session会话中 */
session.setAttribute(OaContants.USER_SESSION, user);
System.out.println("设置用户 ---------------->:" + user);
result.put("status",1);
result.put("tip", "登录成功");
/** 把登录成功的用户存入到UserHolder*/
UserHolder.addCurrentUser(user);
/** 2.当用户一登录进入系统的时候,就应该立即去查询该用户所拥有
的全部操作权限 --> 存入到当前用户的Session会话中 */
Map<String,List<String>> userAllOperasPopedomUrls = getUserAllOperasPopedomUrls();
session.setAttribute(OaContants.USER_ALL_OPERAS_POPEDOM_URLS, userAllOperasPopedomUrls);
}else{
result.put("status",5);
result.put("tip", "您的账号未被激活,请联系管理员激活!");
}
}else{
/** 密码错误 */
result.put("status", 2);
result.put("tip", "密码错误了");
}
}else{
/** 登录名不存在 */
result.put("status", 3);
result.put("tip", "没有该账户");
}
}else{
/** 验证码不正确 */
result.put("status", 4);
result.put("tip", "验证码不正确");
}
}
return result;
} catch (Exception e) {
throw new OaException("异步登录业务层抛出异常了", e);
}
}
private Map<String, List<String>> getUserAllOperasPopedomUrls() {
try {
/** 查询用户所拥有的所有操作权限编号
* */
List<String> userAllPopedomOperasCodes = popedomRepository.getUserPopedomOperasCodes(UserHolder.getCurrentUser().getUserId());
if(userAllPopedomOperasCodes!=null && userAllPopedomOperasCodes.size()>0 ){
Map<String, List<String>> userAllOperasPopedomUrls = new HashMap<>();
String moduleUrl = "" ;
List<String> moduleOperaUrls = null;
for(String operaCode : userAllPopedomOperasCodes){
/** 先得到模块的编号 */
String parentModuleCode = operaCode.substring(0, operaCode.length() - OaContants.CODE_LEN);
/** 父模块地址 */
moduleUrl = getModuleByCode(parentModuleCode).getUrl();
/** 判断map集合中是否已经存在该父模块地址 */
if(!userAllOperasPopedomUrls.containsKey(moduleUrl)){
moduleOperaUrls = new ArrayList<String>();
userAllOperasPopedomUrls.put(moduleUrl, moduleOperaUrls);
}
moduleOperaUrls.add(getModuleByCode(operaCode).getUrl());
}
return userAllOperasPopedomUrls;
}
return null;
} catch (Exception e) {
throw new OaException("登录查询用户的操作权限出现异常", e);
}
}
public User getUserById(String userId) {
try {
User user = userRepository.findById(userId).get();
if(user != null){
// 获取延迟加载的属性
if(user.getDept()!=null)user.getD
没有合适的资源?快使用搜索试试~ 我知道了~
信息管理系统springboot版本.zip
共624个文件
png:304个
js:66个
gif:52个
需积分: 11 11 下载量 31 浏览量
2019-06-26
23:30:39
上传
评论
收藏 11.04MB ZIP 举报
温馨提示
基于springboot实现的信息管理系统,数据库为mysql,使用时需要将.sql导入到数据库
资源推荐
资源详情
资源评论
收起资源包目录
信息管理系统springboot版本.zip (624个子文件)
IdentityServiceImpl.class 25KB
User.class 6KB
PagerTag.class 5KB
UserController.class 5KB
RoleController.class 5KB
IdentityServiceImpl$1.class 4KB
VerifyAction.class 4KB
ModuleController.class 4KB
Role.class 4KB
PopedomInterceptor.class 4KB
Dept.class 3KB
PopedomController.class 3KB
IdentityServiceImpl$2.class 3KB
IdentityServiceImpl$3.class 3KB
IdentityServiceImpl$4.class 3KB
IdentityService.class 3KB
Module.class 3KB
Popedom.class 3KB
LoginInterceptor.class 2KB
DeptController.class 2KB
InterceptorConfig.class 2KB
LoginController.class 2KB
RequestController.class 2KB
PopedomRepository.class 2KB
PageModel.class 1KB
ModuleRepository.class 1KB
Job.class 1KB
UserModule.class 1KB
UserHolder.class 1KB
OaException.class 1010B
UserRepository.class 989B
LogoutController.class 935B
TreeData.class 902B
JobRepository.class 684B
App.class 651B
DeptRepository.class 638B
OaContants.class 559B
RoleRepository.class 524B
CommonContants.class 399B
.classpath 1KB
org.eclipse.wst.common.component 563B
org.eclipse.wst.jsdt.ui.superType.container 49B
bootstrap.min.css 118KB
bootstrap.min.css 118KB
bootstrap.css 117KB
bootstrap.css 117KB
style.css 100KB
style.css 100KB
docs.css 97KB
docs.css 97KB
easyui.css 53KB
easyui.css 53KB
video-js.css 20KB
video-js.css 20KB
chosen.css 16KB
chosen.css 16KB
iconfont.css 12KB
iconfont.css 12KB
jquery-ui-1.8.20.custom.css 10KB
jquery-ui-1.8.20.custom.css 10KB
jplayer.css 9KB
jplayer.css 9KB
platform.css 7KB
platform.css 7KB
login.css 6KB
login.css 6KB
style.css 4KB
style.css 4KB
base.css 4KB
base.css 4KB
jslider.css 3KB
jslider.css 3KB
demo.css 3KB
demo.css 3KB
prettify.css 1KB
prettify.css 1KB
dtree.css 795B
dtree.css 795B
iconfont.eot 158KB
iconfont.eot 158KB
glyphicons-halflings-regular.eot 20KB
glyphicons-halflings-regular.eot 20KB
glyphicons-halflings-regular.eot 14KB
glyphicons-halflings-regular.eot 14KB
loading.gif 9KB
loading.gif 9KB
loading.gif 9KB
loading.gif 9KB
seeking.gif 3KB
seeking.gif 3KB
loading.gif 2KB
loading.gif 2KB
globe.gif 1KB
globe.gif 1KB
trash.gif 1KB
trash.gif 1KB
question.gif 1KB
question.gif 1KB
base.gif 1KB
base.gif 1KB
共 624 条
- 1
- 2
- 3
- 4
- 5
- 6
- 7
资源评论
也耶
- 粉丝: 65
- 资源: 11
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功