123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143 |
- package com.caimei.controller.admin.auth;
- import com.alibaba.fastjson.JSONObject;
- import com.caimei.annotation.CurrentUser;
- import com.caimei.model.ResponseJson;
- import com.caimei.model.po.SysUser;
- import com.caimei.model.vo.ClubUserVo;
- import com.caimei.model.vo.ClubVo;
- import com.caimei.service.auth.AuthClubService;
- import com.github.pagehelper.PageInfo;
- import io.swagger.annotations.Api;
- import io.swagger.annotations.ApiImplicitParam;
- import io.swagger.annotations.ApiImplicitParams;
- import io.swagger.annotations.ApiOperation;
- import lombok.RequiredArgsConstructor;
- import lombok.extern.slf4j.Slf4j;
- import org.apache.commons.lang3.StringUtils;
- import org.springframework.web.bind.annotation.*;
- import java.util.Map;
- /**
- * 供应商API
- *
- * @author : Aslee
- * @date : 2021/5/11
- */
- @Api(tags = "机构用户API")
- @Slf4j
- @RestController
- @RequiredArgsConstructor
- @RequestMapping("/club")
- public class AuthClubApi {
- private final AuthClubService authClubService;
- @ApiOperation("机构列表")
- @ApiImplicitParams({
- @ApiImplicitParam(name = "authParty", required = false, value = "机构名称"),
- @ApiImplicitParam(name = "pageNum", required = false, value = "第几页"),
- @ApiImplicitParam(name = "pageSize", required = false, value = "一页多少条")
- })
- @GetMapping("/list")
- public ResponseJson<PageInfo<ClubVo>> getClubList(@CurrentUser SysUser sysUser, String authParty,
- @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
- @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) {
- if (null == sysUser) {
- return ResponseJson.error("用户信息异常", null);
- }
- // 获取供应商用户id
- Integer userIdentity = sysUser.getUserIdentity();
- Integer authUserId = 2 == userIdentity ? sysUser.getId() : 3 == userIdentity ? sysUser.getParentId() : null;
- if (null == authUserId) {
- return ResponseJson.error("供应商用户id不能为空", null);
- }
- return authClubService.getClubList(authUserId, authParty, pageNum, pageSize);
- }
- @ApiOperation("机构用户列表")
- @GetMapping("/user/list")
- @ApiImplicitParams({
- @ApiImplicitParam(name = "mobile", required = false, value = "手机号"),
- @ApiImplicitParam(name = "name", required = false, value = "姓名"),
- @ApiImplicitParam(name = "status", required = false, value = "状态:0停用,1启用"),
- @ApiImplicitParam(name = "pageNum", required = false, value = "第几页"),
- @ApiImplicitParam(name = "pageSize", required = false, value = "一页多少条")
- })
- public ResponseJson<PageInfo<ClubUserVo>> getClubUserList(@CurrentUser SysUser sysUser, String mobile, String name, Integer status,
- @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
- @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) {
- if (null == sysUser) {
- return ResponseJson.error("用户信息异常", null);
- }
- // 获取供应商用户id
- Integer userIdentity = sysUser.getUserIdentity();
- Integer authUserId = 2 == userIdentity ? sysUser.getId() : 3 == userIdentity ? sysUser.getParentId() : null;
- if (null == authUserId) {
- return ResponseJson.error("供应商用户id不能为空", null);
- }
- return authClubService.getClubUserList(authUserId, mobile, name, status, pageNum, pageSize);
- }
- @ApiOperation("添加/编辑机构用户")
- @PostMapping("/user/save")
- @ApiImplicitParam(name = "params", value = "clubUserId:机构用户id;mobile:手机号", required = true)
- public ResponseJson saveClubUser(@CurrentUser SysUser sysUser, @RequestBody String params) {
- if (null == sysUser) {
- return ResponseJson.error("用户信息异常", null);
- }
- // 获取供应商用户id
- Integer userIdentity = sysUser.getUserIdentity();
- Integer authUserId = 2 == userIdentity ? sysUser.getId() : 3 == userIdentity ? sysUser.getParentId() : null;
- if (null == authUserId) {
- return ResponseJson.error("供应商用户id不能为空", null);
- }
- JSONObject paramsMap = JSONObject.parseObject(params);
- Integer clubUserId = paramsMap.getInteger("clubUserId");
- String mobile = paramsMap.getString("mobile");
- if (StringUtils.isEmpty(mobile)) {
- return ResponseJson.error("参数异常,请输入手机号");
- }
- return authClubService.saveClubUser(clubUserId, authUserId, mobile);
- }
- @ApiOperation("删除机构用户")
- @PostMapping("/user/delete")
- @ApiImplicitParam(name = "params", value = "clubUserId:机构用户id", required = true)
- public ResponseJson deleteClubUser(@RequestBody String params) {
- JSONObject paramsMap = JSONObject.parseObject(params);
- Integer clubUserId = paramsMap.getInteger("clubUserId");
- if (null == clubUserId) {
- return ResponseJson.error("参数异常,机构用户id不能为空");
- }
- return authClubService.deleteClubUser(clubUserId);
- }
- @ApiOperation("更新用户状态")
- @PostMapping("/user/status/update")
- @ApiImplicitParam(name = "params", value = "clubUserId:机构用户id;status:状态:0停用,1启用", required = true)
- public ResponseJson updateStatus(@RequestBody String params) {
- JSONObject paramsMap = JSONObject.parseObject(params);
- Integer clubUserId = paramsMap.getInteger("clubUserId");
- Integer status = paramsMap.getInteger("status");
- if (null == clubUserId) {
- return ResponseJson.error("参数异常,机构用户id不能为空");
- }
- if (null == status) {
- return ResponseJson.error("参数异常,状态不能为空");
- }
- return authClubService.updateStatus(clubUserId, status);
- }
- @ApiOperation("重置密码")
- @ApiImplicitParam(name = "params", value = "clubUserId:机构用户id", required = true)
- @PostMapping("/user/reset/password")
- public ResponseJson resetShopPassword(@RequestBody Map<String,Integer> params) {
- Integer clubUserId = params.get("clubUserId");
- return authClubService.resetClubUserPassword(clubUserId);
- }
- }
|