package com.landtool.lanbase.modules.sys.controller;
|
|
import javax.servlet.http.HttpServletRequest;
|
|
import org.apache.shiro.SecurityUtils;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.ResponseBody;
|
import org.springframework.web.bind.annotation.RestController;
|
|
import com.landtool.lanbase.config.SysTemPropertyConfig;
|
import com.landtool.lanbase.modules.org.entity.OrgUnit;
|
import com.landtool.lanbase.modules.org.entity.OrgUser;
|
|
import springfox.documentation.annotations.ApiIgnore;
|
|
/**
|
* @author lanbase
|
* @Description: TODO(系统用户)
|
* @date 2017-6-23 15:07
|
*/
|
@RestController
|
@RequestMapping("/sys/user")
|
@ApiIgnore()
|
public class SysUserController extends AbstractController {
|
@Autowired
|
private SysTemPropertyConfig sysConfig;
|
|
/**
|
* JS获取登录的用户信息
|
*/
|
@RequestMapping("/jsinfo")
|
public String jsinfo() {
|
return "var userid=" + getUserId() + ";";
|
}
|
|
/**
|
* JSONP获取登录用户ID
|
* @param request
|
* @return
|
*/
|
@ResponseBody
|
@RequestMapping("/getUserInfo")
|
public String getUserInfo(HttpServletRequest request) {
|
String callbackFunName = request.getParameter("callback");
|
if (callbackFunName == null || callbackFunName.isEmpty()) {
|
callbackFunName = "callback";
|
}
|
String result = "";
|
try {
|
OrgUser orgUser = getUser();
|
OrgUnit orgUnit = getUnit();
|
result = "{success: true, info: { userid: " + orgUser.getUserid() + ", chinesename: '" + orgUser.getChinesename()
|
+ "', unitname: '" + (orgUnit != null ? orgUnit.getUnitname() : "") + "', useradmin: " + SecurityUtils.getSubject().isPermitted("org_user_admin")
|
+ ", userprintaudit: " + SecurityUtils.getSubject().isPermitted("portal:print:audit") + "}}";
|
} catch (Exception e) {
|
// TODO: handle exception
|
result = "{success: false, msg: '获取用户信息失败!'}";
|
}
|
return callbackFunName + "([" + result + "])";
|
}
|
|
/**
|
* JSONP获取登录用户中文名
|
* @param request
|
* @return
|
*/
|
@ResponseBody
|
@RequestMapping("/getUserName")
|
public String getUserName(HttpServletRequest request) {
|
//String username = request.getRemoteUser();
|
OrgUser orgUser = getUser();
|
String username = orgUser.getChinesename();
|
String callbackFunName = request.getParameter("callback");
|
if (callbackFunName == null || callbackFunName.isEmpty()) {
|
callbackFunName = "callback";
|
}
|
String result = "";
|
try {
|
//result = "{success: true, msg: '" + getUser().getChinesename() + "'}";
|
result = "{success: true, msg: '" + username + "'}";
|
} catch (Exception e) {
|
// TODO: handle exception
|
result = "{success: false, msg: '获取用户信息失败!'}";
|
}
|
return callbackFunName + "(" + result + ")";
|
}
|
}
|