Java Code Examples for org.jeecg.modules.system.entity.SysUser#getOrgCode()

The following examples show how to use org.jeecg.modules.system.entity.SysUser#getOrgCode() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LoginController.java    From jeecg-cloud with Apache License 2.0 4 votes vote down vote up
/**
 * app登录
 * @param sysLoginModel
 * @return
 * @throws Exception
 */
@RequestMapping(value = "/mLogin", method = RequestMethod.POST)
public Result<JSONObject> mLogin(@RequestBody SysLoginModel sysLoginModel) throws Exception {
	Result<JSONObject> result = new Result<JSONObject>();
	String username = sysLoginModel.getUsername();
	String password = sysLoginModel.getPassword();
	
	//1. 校验用户是否有效
	SysUser sysUser = sysUserService.getUserByName(username);
	result = sysUserService.checkUserIsEffective(sysUser);
	if(!result.isSuccess()) {
		return result;
	}
	
	//2. 校验用户名或密码是否正确
	String userpassword = PasswordUtil.encrypt(username, password, sysUser.getSalt());
	String syspassword = sysUser.getPassword();
	if (!syspassword.equals(userpassword)) {
		result.error500("用户名或密码错误");
		return result;
	}
	
	String orgCode = sysUser.getOrgCode();
	if(oConvertUtils.isEmpty(orgCode)) {
		//如果当前用户无选择部门 查看部门关联信息
		List<SysDepart> departs = sysDepartService.queryUserDeparts(sysUser.getId());
		if (departs == null || departs.size() == 0) {
			result.error500("用户暂未归属部门,不可登录!");
			return result;
		}
		orgCode = departs.get(0).getOrgCode();
		sysUser.setOrgCode(orgCode);
		this.sysUserService.updateUserDepart(username, orgCode);
	}
	JSONObject obj = new JSONObject();
	//用户登录信息
	obj.put("userInfo", sysUser);
	
	// 生成token
	String token = JwtUtil.sign(username, syspassword);
	// 设置超时时间
	redisUtil.set(CommonConstant.PREFIX_USER_TOKEN + token, token);
	redisUtil.expire(CommonConstant.PREFIX_USER_TOKEN + token, JwtUtil.EXPIRE_TIME*2 / 1000);
	//token 信息
	obj.put("token", token);
	result.setResult(obj);
	result.setSuccess(true);
	result.setCode(200);
	sysBaseAPI.addLog("用户名: " + username + ",登录成功[移动端]!", CommonConstant.LOG_TYPE_1, null);
	return result;
}
 
Example 2
Source File: LoginController.java    From jeecg-boot-with-activiti with MIT License 4 votes vote down vote up
/**
 * app登录
 * @param sysLoginModel
 * @return
 * @throws Exception
 */
@RequestMapping(value = "/mLogin", method = RequestMethod.POST)
public Result<JSONObject> mLogin(@RequestBody SysLoginModel sysLoginModel) throws Exception {
	Result<JSONObject> result = new Result<JSONObject>();
	String username = sysLoginModel.getUsername();
	String password = sysLoginModel.getPassword();
	
	//1. 校验用户是否有效
	SysUser sysUser = sysUserService.getUserByName(username);
	result = sysUserService.checkUserIsEffective(sysUser);
	if(!result.isSuccess()) {
		return result;
	}
	
	//2. 校验用户名或密码是否正确
	String userpassword = PasswordUtil.encrypt(username, password, sysUser.getSalt());
	String syspassword = sysUser.getPassword();
	if (!syspassword.equals(userpassword)) {
		result.error500("用户名或密码错误");
		return result;
	}
	
	String orgCode = sysUser.getOrgCode();
	if(oConvertUtils.isEmpty(orgCode)) {
		//如果当前用户无选择部门 查看部门关联信息
		List<SysDepart> departs = sysDepartService.queryUserDeparts(sysUser.getId());
		if (departs == null || departs.size() == 0) {
			result.error500("用户暂未归属部门,不可登录!");
			return result;
		}
		orgCode = departs.get(0).getOrgCode();
		sysUser.setOrgCode(orgCode);
		this.sysUserService.updateUserDepart(username, orgCode);
	}
	JSONObject obj = new JSONObject();
	//用户登录信息
	obj.put("userInfo", sysUser);
	
	// 生成token
	String token = JwtUtil.sign(username, syspassword);
	// 设置超时时间
	redisUtil.set(CommonConstant.PREFIX_USER_TOKEN + token, token);
	redisUtil.expire(CommonConstant.PREFIX_USER_TOKEN + token, JwtUtil.EXPIRE_TIME*2 / 1000);
	//token 信息
	obj.put("token", token);
	result.setResult(obj);
	result.setSuccess(true);
	result.setCode(200);
	sysBaseAPI.addLog("用户名: " + username + ",登录成功[移动端]!", CommonConstant.LOG_TYPE_1, null);
	return result;
}
 
Example 3
Source File: LoginController.java    From teaching with Apache License 2.0 4 votes vote down vote up
/**
 * app登录
 * @param sysLoginModel
 * @return
 * @throws Exception
 */
@RequestMapping(value = "/mLogin", method = RequestMethod.POST)
public Result<JSONObject> mLogin(@RequestBody SysLoginModel sysLoginModel) throws Exception {
	Result<JSONObject> result = new Result<JSONObject>();
	String username = sysLoginModel.getUsername();
	String password = sysLoginModel.getPassword();
	
	//1. 校验用户是否有效
	SysUser sysUser = sysUserService.getUserByName(username);
	result = sysUserService.checkUserIsEffective(sysUser);
	if(!result.isSuccess()) {
		return result;
	}
	
	//2. 校验用户名或密码是否正确
	String userpassword = PasswordUtil.encrypt(username, password, sysUser.getSalt());
	String syspassword = sysUser.getPassword();
	if (!syspassword.equals(userpassword)) {
		result.error500("用户名或密码错误");
		return result;
	}
	
	String orgCode = sysUser.getOrgCode();
	if(oConvertUtils.isEmpty(orgCode)) {
		//如果当前用户无选择部门 查看部门关联信息
		List<SysDepart> departs = sysDepartService.queryUserDeparts(sysUser.getId());
		if (departs == null || departs.size() == 0) {
			result.error500("用户暂未归属部门,不可登录!");
			return result;
		}
		orgCode = departs.get(0).getOrgCode();
		sysUser.setOrgCode(orgCode);
		this.sysUserService.updateUserDepart(username, orgCode);
	}
	JSONObject obj = new JSONObject();
	//用户登录信息
	obj.put("userInfo", sysUser);
	
	// 生成token
	String token = JwtUtil.sign(username, syspassword);
	// 设置超时时间
	redisUtil.set(CommonConstant.PREFIX_USER_TOKEN + token, token);
	redisUtil.expire(CommonConstant.PREFIX_USER_TOKEN + token, JwtUtil.EXPIRE_TIME*2 / 1000);
	//token 信息
	obj.put("token", token);
	result.setResult(obj);
	result.setSuccess(true);
	result.setCode(200);
	sysBaseAPI.addLog("用户名: " + username + ",登录成功[移动端]!", CommonConstant.LOG_TYPE_1, null);
	return result;
}
 
Example 4
Source File: LoginController.java    From jeecg-boot with Apache License 2.0 4 votes vote down vote up
/**
 * app登录
 * @param sysLoginModel
 * @return
 * @throws Exception
 */
@RequestMapping(value = "/mLogin", method = RequestMethod.POST)
public Result<JSONObject> mLogin(@RequestBody SysLoginModel sysLoginModel) throws Exception {
	Result<JSONObject> result = new Result<JSONObject>();
	String username = sysLoginModel.getUsername();
	String password = sysLoginModel.getPassword();
	
	//1. 校验用户是否有效
	SysUser sysUser = sysUserService.getUserByName(username);
	result = sysUserService.checkUserIsEffective(sysUser);
	if(!result.isSuccess()) {
		return result;
	}
	
	//2. 校验用户名或密码是否正确
	String userpassword = PasswordUtil.encrypt(username, password, sysUser.getSalt());
	String syspassword = sysUser.getPassword();
	if (!syspassword.equals(userpassword)) {
		result.error500("用户名或密码错误");
		return result;
	}
	
	String orgCode = sysUser.getOrgCode();
	if(oConvertUtils.isEmpty(orgCode)) {
		//如果当前用户无选择部门 查看部门关联信息
		List<SysDepart> departs = sysDepartService.queryUserDeparts(sysUser.getId());
		if (departs == null || departs.size() == 0) {
			result.error500("用户暂未归属部门,不可登录!");
			return result;
		}
		orgCode = departs.get(0).getOrgCode();
		sysUser.setOrgCode(orgCode);
		this.sysUserService.updateUserDepart(username, orgCode);
	}
	JSONObject obj = new JSONObject();
	//用户登录信息
	obj.put("userInfo", sysUser);
	
	// 生成token
	String token = JwtUtil.sign(username, syspassword);
	// 设置超时时间
	redisUtil.set(CommonConstant.PREFIX_USER_TOKEN + token, token);
	redisUtil.expire(CommonConstant.PREFIX_USER_TOKEN + token, JwtUtil.EXPIRE_TIME*2 / 1000);
	//token 信息
	obj.put("token", token);
	result.setResult(obj);
	result.setSuccess(true);
	result.setCode(200);
	sysBaseAPI.addLog("用户名: " + username + ",登录成功[移动端]!", CommonConstant.LOG_TYPE_1, null);
	return result;
}