修改权限认证方式。
This commit is contained in:
parent
b6067330e1
commit
5ff1978fa1
@ -86,24 +86,22 @@ public class BackstageController {
|
||||
@GetMapping("/getAllUserInfo")
|
||||
public TableDataInfo getAllUserInfo(){
|
||||
|
||||
// 这里面是不是就没有user_type啊,直接解码的token不包含user_type
|
||||
SysUser user = SecurityUtils.getLoginUser().getUser();
|
||||
Long userId = user.getUserId();
|
||||
if(isAuthority(Constants.USER_MANAGE)) {
|
||||
|
||||
SysUser user1 = sysUserService.selectUserById(userId);
|
||||
String userType = user1.getUserType();
|
||||
// 这里面是不是就没有user_type啊,直接解码的token不包含user_type
|
||||
SysUser user = SecurityUtils.getLoginUser().getUser();
|
||||
Long userId = user.getUserId();
|
||||
|
||||
|
||||
if (userType.equals(Constants.USER_TYPE_ADMIN)){
|
||||
SysUser user1 = sysUserService.selectUserById(userId);
|
||||
String userType = user1.getUserType();
|
||||
// 分页
|
||||
startPage();
|
||||
List<UserInfo> userInfoList = userInfoService.selectAllUserInfo();
|
||||
|
||||
return getDataTable(userInfoList);
|
||||
|
||||
}
|
||||
else{
|
||||
return noAuthority();
|
||||
}
|
||||
return noAuthority();
|
||||
|
||||
|
||||
|
||||
@ -113,7 +111,7 @@ public class BackstageController {
|
||||
@PostMapping("/changeUserStatus")
|
||||
public AjaxResult changeUserState(@RequestBody UpdateUserStateDto updateUserStateDto){
|
||||
|
||||
if(isAuthority(Constants.USER_TYPE_ADMIN)){
|
||||
if(isAuthority(Constants.USER_MANAGE)){
|
||||
String username = updateUserStateDto.getUsername();
|
||||
String status = updateUserStateDto.getStatus();
|
||||
|
||||
@ -137,7 +135,7 @@ public class BackstageController {
|
||||
@GetMapping("/getUserCount")
|
||||
public AjaxResult getUserCount(){
|
||||
|
||||
if(isAuthority(Constants.USER_TYPE_ADMIN)) {
|
||||
if(isAuthority(Constants.USER_MANAGE)) {
|
||||
|
||||
AjaxResult ajax = new AjaxResult();
|
||||
|
||||
@ -155,7 +153,7 @@ public class BackstageController {
|
||||
// 获取近7天用户总数
|
||||
@GetMapping("/getSeUserCount")
|
||||
public AjaxResult getSeUserCount(){
|
||||
if(isAuthority(Constants.USER_TYPE_ADMIN)){
|
||||
if(isAuthority(Constants.USER_MANAGE)){
|
||||
AjaxResult ajax = new AjaxResult();
|
||||
// startPage();
|
||||
List<SeUserCountDto> seUserCount = sysUserCountService.getSeUserCount();
|
||||
@ -171,7 +169,7 @@ public class BackstageController {
|
||||
// 获取所有用户作品
|
||||
@GetMapping("/getAllUserWork")
|
||||
public AjaxResult getAllUserWork(){
|
||||
if(isAuthority(Constants.USER_TYPE_ADMIN)){
|
||||
if(isAuthority(Constants.CONTENT_AUDIT)){
|
||||
AjaxResult ajax = new AjaxResult();
|
||||
startPage();
|
||||
List<UserWork> userWorkList = userWorkService.selectUserWorkList(new UserWork());
|
||||
@ -187,7 +185,7 @@ public class BackstageController {
|
||||
// 获取近7天作品总数
|
||||
@GetMapping("/getSeUserWorkCount")
|
||||
public AjaxResult getSeUserWorkCount(){
|
||||
if(isAuthority(Constants.USER_TYPE_ADMIN)){
|
||||
if(isAuthority(Constants.CONTENT_AUDIT)){
|
||||
AjaxResult ajax = new AjaxResult();
|
||||
startPage();
|
||||
List<SeUserWorkCountDto> seUserWorkCount = sysUserWorkCountService.getSeUserWorkCount();
|
||||
@ -209,12 +207,10 @@ public class BackstageController {
|
||||
Long userId = SecurityUtils.getUserId();
|
||||
SysUser user = sysUserService.selectUserById(userId);
|
||||
|
||||
if(!user.getUserType().equals(Constants.USER_TYPE_ADMIN)){
|
||||
|
||||
if(!isAuthority(Constants.CONTENT_AUDIT)){
|
||||
return error("无权限访问");
|
||||
}
|
||||
|
||||
|
||||
Long workId = reviewWorkDto.getWorkId();
|
||||
String workStatus = reviewWorkDto.getWorkStatus();
|
||||
String auditOpinion = reviewWorkDto.getAuditOpinion();
|
||||
@ -264,7 +260,7 @@ public class BackstageController {
|
||||
* 获取所有城市数景区数资源位数*/
|
||||
@GetMapping("stCityScenicSource")
|
||||
public AjaxResult getAllCity(){
|
||||
if(isAuthority(Constants.USER_TYPE_ADMIN)) {
|
||||
if(isAuthority(Constants.PRODUCT_MANAGE)) {
|
||||
int city_count = sysCityService.selectSysCityList(new SysCity()).size();
|
||||
|
||||
int scenic_count = sysScenicService.selectSysScenicList(new SysScenic()).size();
|
||||
@ -286,7 +282,7 @@ public class BackstageController {
|
||||
* 获取所有资源位详情*/
|
||||
@GetMapping("getAllSource")
|
||||
public TableDataInfo getAllSource(){
|
||||
if(isAuthority(Constants.USER_TYPE_ADMIN)){
|
||||
if(isAuthority(Constants.PRODUCT_MANAGE)){
|
||||
startPage();
|
||||
List<SysSource> sysSourceList = sysSourceService.selectSysSourceList(new SysSource());
|
||||
|
||||
@ -301,7 +297,7 @@ public class BackstageController {
|
||||
@PostMapping("/changeSourceBackground")
|
||||
public AjaxResult updateUserInfo(@RequestParam("changeSourceBackgroundDto") String changeSourceBackgroundDt,@RequestParam("work") MultipartFile work)
|
||||
{
|
||||
if(isAuthority(Constants.USER_TYPE_ADMIN)) {
|
||||
if(isAuthority(Constants.PRODUCT_MANAGE)) {
|
||||
|
||||
|
||||
|
||||
@ -359,7 +355,7 @@ public class BackstageController {
|
||||
// 参数: 城市,景区,区域,价格
|
||||
@PostMapping("/changeSourcePrice")
|
||||
public AjaxResult changeSourcePrice(@RequestBody ChangeSourcePriceDto changeSourcePriceDto){
|
||||
if(isAuthority(Constants.USER_TYPE_ADMIN)) {
|
||||
if(isAuthority(Constants.PRODUCT_MANAGE)) {
|
||||
String city = changeSourcePriceDto.getCity();
|
||||
String scenic = changeSourcePriceDto.getScenic();
|
||||
String part = changeSourcePriceDto.getPart();
|
||||
@ -384,7 +380,7 @@ public class BackstageController {
|
||||
//获取系统所有用户
|
||||
@GetMapping("/getAllUserType")
|
||||
public TableDataInfo getAllUser(){
|
||||
if(isAuthority(Constants.USER_TYPE_ADMIN)){
|
||||
if(isAuthority(Constants.SYSTEM_MANAGE)){
|
||||
startPage();
|
||||
List<UserType> userTypeList = userTypeService.selectUserTypeList(new UserType());
|
||||
return getDataTable(userTypeList);
|
||||
@ -397,7 +393,7 @@ public class BackstageController {
|
||||
//修改用户类型内容
|
||||
@PostMapping("/changeUserType")
|
||||
public AjaxResult changeUserType(@RequestBody UserType userType){
|
||||
if(isAuthority(Constants.USER_TYPE_ADMIN)){
|
||||
if(isAuthority(Constants.SYSTEM_MANAGE)){
|
||||
int back = userTypeService.updateUserType(userType);
|
||||
if(back > 0){
|
||||
return success("修改用户类型成功");
|
||||
@ -413,7 +409,7 @@ public class BackstageController {
|
||||
// 新建用户类型
|
||||
@PostMapping("/createUserType")
|
||||
public AjaxResult createUserType(@RequestBody UserType userType){
|
||||
if(isAuthority(Constants.USER_TYPE_ADMIN)){
|
||||
if(isAuthority(Constants.SYSTEM_MANAGE)){
|
||||
int back = userTypeService.insertUserType(userType);
|
||||
if(back > 0){
|
||||
return success("新建用户类型成功");
|
||||
@ -429,7 +425,7 @@ public class BackstageController {
|
||||
//删除用户类型
|
||||
@PostMapping("/deleteUserType")
|
||||
public AjaxResult deleteUserType(@RequestParam("typeId") Long typeId){
|
||||
if(isAuthority(Constants.USER_TYPE_ADMIN)){
|
||||
if(isAuthority(Constants.SYSTEM_MANAGE)){
|
||||
int back = userTypeService.deleteUserTypeByTypeId(typeId);
|
||||
if(back > 0){
|
||||
return success("删除用户类型成功");
|
||||
@ -465,7 +461,7 @@ public class BackstageController {
|
||||
//人员管理---获取所有后台系统用户
|
||||
@GetMapping("/getAllBackstageUser")
|
||||
public TableDataInfo getAllBackstageUser() {
|
||||
if(isAuthority(Constants.USER_TYPE_ADMIN)){
|
||||
if(isAuthority(Constants.SYSTEM_MANAGE)){
|
||||
startPage();
|
||||
List<BackstageUserDto> sysUserList = sysUserService.selectBackstageUserList();
|
||||
return getDataTable(sysUserList);
|
||||
@ -478,7 +474,7 @@ public class BackstageController {
|
||||
@Log(title = "系统管理--人员管理--新建后台用户", businessType = BusinessType.INSERT)
|
||||
@PostMapping("/createBackstageUser")
|
||||
public AjaxResult createBackstageUser(@RequestBody BackstageUserDto backstageUserDto){
|
||||
if(isAuthority(Constants.USER_TYPE_ADMIN)){
|
||||
if(isAuthority(Constants.SYSTEM_MANAGE)){
|
||||
String nickName = backstageUserDto.getNickName();
|
||||
String phone = backstageUserDto.getPhone();
|
||||
String realName = backstageUserDto.getRealName();
|
||||
@ -542,7 +538,7 @@ public class BackstageController {
|
||||
// 删除后台用户
|
||||
@PostMapping("/deleteBackstageUser")
|
||||
public AjaxResult deleteBackstageUser(@RequestParam("userId") Long userId){
|
||||
if(isAuthority(Constants.USER_TYPE_ADMIN)){
|
||||
if(isAuthority(Constants.SYSTEM_MANAGE)){
|
||||
int back = sysUserService.deleteUserById(userId);
|
||||
if(back > 0){
|
||||
return success("删除用户成功");
|
||||
@ -623,13 +619,16 @@ public class BackstageController {
|
||||
rspData.setMsg("无权限");
|
||||
return rspData;
|
||||
}
|
||||
private boolean isAuthority(String type){
|
||||
private boolean isAuthority(int startI){
|
||||
|
||||
SysUser user = SecurityUtils.getLoginUser().getUser();
|
||||
Long userId = user.getUserId();
|
||||
SysUser user1 = sysUserService.selectUserById(userId);
|
||||
String userType = user1.getUserType();
|
||||
|
||||
if(userType.equals(type)){
|
||||
String type = userType.substring(startI, startI+2);
|
||||
|
||||
if(type.equals("11")){
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@ -45,7 +45,7 @@ public class SysOperlogController extends BaseController
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(SysOperLog operLog)
|
||||
{
|
||||
if(isAuthority(Constants.USER_TYPE_ADMIN)){
|
||||
if(isAuthority(Constants.SYSTEM_MANAGE)){
|
||||
startPage();
|
||||
List<SysOperLog> list = operLogService.selectOperLogList(operLog);
|
||||
return getDataTable(list);
|
||||
@ -69,7 +69,7 @@ public class SysOperlogController extends BaseController
|
||||
@DeleteMapping("/{operIds}")
|
||||
public AjaxResult remove(@PathVariable Long[] operIds)
|
||||
{
|
||||
if(isAuthority(Constants.USER_TYPE_ADMIN)) {
|
||||
if(isAuthority(Constants.SYSTEM_MANAGE)) {
|
||||
return toAjax(operLogService.deleteOperLogByIds(operIds));
|
||||
}
|
||||
return error("无权限操作, 以记录登录ip");
|
||||
@ -84,18 +84,20 @@ public class SysOperlogController extends BaseController
|
||||
return success();
|
||||
}
|
||||
|
||||
private boolean isAuthority(String type){
|
||||
private boolean isAuthority(int startI){
|
||||
|
||||
SysUser user = SecurityUtils.getLoginUser().getUser();
|
||||
Long userId = user.getUserId();
|
||||
SysUser user1 = sysUserService.selectUserById(userId);
|
||||
String userType = user1.getUserType();
|
||||
|
||||
if(userType.equals(type)){
|
||||
String type = userType.substring(startI, startI+2);
|
||||
|
||||
if(type.equals("11")){
|
||||
return true;
|
||||
}
|
||||
|
||||
String ip = IpUtils.getIpAddr();
|
||||
// LOGGER.info("无权限用户认证,ip:"+ip);
|
||||
|
||||
return false;
|
||||
|
||||
|
||||
@ -150,7 +150,33 @@ public class Constants
|
||||
/**
|
||||
* 管理员用户类型
|
||||
*/
|
||||
public static final String USER_TYPE_ADMIN = "66";
|
||||
public static final String USER_TYPE_ADMIN = "1111111111";
|
||||
|
||||
/*
|
||||
* 用户管理0-1
|
||||
* */
|
||||
public static final int USER_MANAGE=0;
|
||||
|
||||
/*
|
||||
* 内容审核
|
||||
* */
|
||||
public static final int CONTENT_AUDIT=2;
|
||||
|
||||
/*
|
||||
* 产品管理
|
||||
* */
|
||||
public static final int PRODUCT_MANAGE=4;
|
||||
|
||||
/*
|
||||
*客服管理
|
||||
* */
|
||||
public static final int SERVICE_MANAGE=6;
|
||||
|
||||
/*
|
||||
* 系统管理
|
||||
* */
|
||||
public static final int SYSTEM_MANAGE=8;
|
||||
|
||||
|
||||
/**
|
||||
* 定时任务违规的字符
|
||||
|
||||
Loading…
Reference in New Issue
Block a user