Compare commits
No commits in common. 'c54f51f453e10bd6de39a612ec8991de87dd84e6' and 'd68f7b5d686f13aeb527f92dfc42f35e4ac7fd28' have entirely different histories.
c54f51f453
...
d68f7b5d68
@ -1,159 +0,0 @@ |
||||
package com.hfkj.controller; |
||||
|
||||
import com.alibaba.fastjson.JSONObject; |
||||
import com.github.pagehelper.PageHelper; |
||||
import com.github.pagehelper.PageInfo; |
||||
import com.hfkj.common.exception.ErrorCode; |
||||
import com.hfkj.common.exception.ErrorHelp; |
||||
import com.hfkj.common.exception.SysCode; |
||||
import com.hfkj.common.utils.ResponseMsgUtil; |
||||
import com.hfkj.entity.BsUser; |
||||
import com.hfkj.entity.BsUserParentRel; |
||||
import com.hfkj.model.ResponseData; |
||||
import com.hfkj.service.user.BsUserGradeService; |
||||
import com.hfkj.service.user.BsUserParentRelService; |
||||
import com.hfkj.service.user.BsUserService; |
||||
import com.hfkj.sysenum.user.UserGradeEnum; |
||||
import io.swagger.annotations.Api; |
||||
import io.swagger.annotations.ApiOperation; |
||||
import org.slf4j.Logger; |
||||
import org.slf4j.LoggerFactory; |
||||
import org.springframework.stereotype.Controller; |
||||
import org.springframework.web.bind.annotation.*; |
||||
|
||||
import javax.annotation.Resource; |
||||
import java.util.ArrayList; |
||||
import java.util.HashMap; |
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* @className: CmsController |
||||
* @author: HuRui |
||||
* @date: 2024/9/24 |
||||
**/ |
||||
@Controller |
||||
@RequestMapping(value = "/bsUser") |
||||
@Api(value = "用户管理") |
||||
public class BsUserController { |
||||
private static Logger log = LoggerFactory.getLogger(BsUserController.class); |
||||
@Resource |
||||
private BsUserService userService; |
||||
@Resource |
||||
private BsUserGradeService userGradeService; |
||||
@Resource |
||||
private BsUserParentRelService userParentRelService; |
||||
|
||||
@RequestMapping(value="/gradeAdjust",method = RequestMethod.POST) |
||||
@ResponseBody |
||||
@ApiOperation(value = "等级调整") |
||||
public ResponseData gradeAdjust(@RequestBody JSONObject body) { |
||||
try { |
||||
if (body == null || body.getLong("userId") == null || body.getInteger("grade") == null) { |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); |
||||
} |
||||
|
||||
userGradeService.gradeAdjust(body.getLong("userId"), UserGradeEnum.getDataByType(body.getInteger("grade"))); |
||||
|
||||
return ResponseMsgUtil.success("操作成功"); |
||||
|
||||
} catch (Exception e) { |
||||
return ResponseMsgUtil.exception(e); |
||||
} |
||||
} |
||||
|
||||
@RequestMapping(value="/ban",method = RequestMethod.POST) |
||||
@ResponseBody |
||||
@ApiOperation(value = "封禁") |
||||
public ResponseData ban(@RequestBody JSONObject body) { |
||||
try { |
||||
if (body == null || body.getLong("userId") == null) { |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); |
||||
} |
||||
|
||||
userService.ban(body.getLong("userId")); |
||||
|
||||
return ResponseMsgUtil.success("操作成功"); |
||||
|
||||
} catch (Exception e) { |
||||
return ResponseMsgUtil.exception(e); |
||||
} |
||||
} |
||||
|
||||
@RequestMapping(value="/restore",method = RequestMethod.POST) |
||||
@ResponseBody |
||||
@ApiOperation(value = "恢复") |
||||
public ResponseData restore(@RequestBody JSONObject body) { |
||||
try { |
||||
if (body == null || body.getLong("userId") == null) { |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); |
||||
} |
||||
|
||||
userService.restore(body.getLong("userId")); |
||||
|
||||
return ResponseMsgUtil.success("操作成功"); |
||||
|
||||
} catch (Exception e) { |
||||
return ResponseMsgUtil.exception(e); |
||||
} |
||||
} |
||||
|
||||
@RequestMapping(value="/getDetail",method = RequestMethod.GET) |
||||
@ResponseBody |
||||
@ApiOperation(value = "查询详情") |
||||
public ResponseData getDetail(@RequestParam(name = "userId", required = true) Long userId) { |
||||
try { |
||||
// 查询用户
|
||||
BsUser user = userService.getUser(userId); |
||||
if (user == null) { |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未知的用户"); |
||||
} |
||||
Map<String,Object> param = new HashMap<>(); |
||||
param.put("user", user); |
||||
// 授权
|
||||
param.put("platform_authorize", new ArrayList<>()); |
||||
// 邀请人
|
||||
param.put("inviteUser", user.getInviteUserId()!=null?userService.getUser(user.getInviteUserId()):null); |
||||
// 贡献关系
|
||||
Map<String,Object> contribute = new HashMap<>(); |
||||
param.put("contribute", contribute); |
||||
if (user.getInviteUserId() != null) { |
||||
// 查询用户上级
|
||||
BsUserParentRel parent = userParentRelService.getDetailByUserId(userId); |
||||
|
||||
} |
||||
|
||||
|
||||
return ResponseMsgUtil.success(param); |
||||
|
||||
} catch (Exception e) { |
||||
return ResponseMsgUtil.exception(e); |
||||
} |
||||
} |
||||
|
||||
@RequestMapping(value="/queryList",method = RequestMethod.GET) |
||||
@ResponseBody |
||||
@ApiOperation(value = "查询列表") |
||||
public ResponseData queryList(@RequestParam(name = "userId", required = false) Long userId, |
||||
@RequestParam(name = "name", required = false) String name, |
||||
@RequestParam(name = "phone", required = false) Integer phone, |
||||
@RequestParam(name = "grade", required = false) Integer grade, |
||||
@RequestParam(name = "status", required = false) Integer status, |
||||
@RequestParam(name = "pageNum", required = true) Integer pageNum, |
||||
@RequestParam(name = "pageSize", required = true) Integer pageSize) { |
||||
try { |
||||
Map<String,Object> param = new HashMap<>(); |
||||
param.put("id", userId); |
||||
param.put("name", name); |
||||
param.put("phone", phone); |
||||
param.put("grade", grade); |
||||
param.put("status", status); |
||||
|
||||
PageHelper.startPage(pageNum, pageSize); |
||||
return ResponseMsgUtil.success(new PageInfo<>(userService.getList(param))); |
||||
|
||||
} catch (Exception e) { |
||||
return ResponseMsgUtil.exception(e); |
||||
} |
||||
} |
||||
|
||||
} |
Loading…
Reference in new issue