parent
0335395776
commit
54c7f42cdd
@ -0,0 +1,149 @@
|
||||
|
||||
package com.luoo.user.controller;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import constants.Constants;
|
||||
import com.luoo.user.dto.response.CreateImageCode;
|
||||
import com.luoo.user.pojo.Admin;
|
||||
import com.luoo.user.pojo.UserInfo;
|
||||
import com.luoo.user.service.UserInfoService;
|
||||
import com.luoo.user.util.NickNameUtil;
|
||||
|
||||
import annotation.GlobalInterceptor;
|
||||
import annotation.VerifyParam;
|
||||
import api.PageResult;
|
||||
import api.Result;
|
||||
import api.StatusCode;
|
||||
import enums.RequestFrequencyTypeEnum;
|
||||
import enums.VerifyRegexEnum;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiImplicitParams;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import util.IdWorker;
|
||||
import util.JwtUtil;
|
||||
import util.StringTools;
|
||||
|
||||
/**
|
||||
* 控制器层
|
||||
*
|
||||
* @author Administrator
|
||||
*
|
||||
*/
|
||||
|
||||
@RestController
|
||||
@CrossOrigin
|
||||
@RequestMapping("/manage_user")
|
||||
@Api(tags = "ManageUserInfoController")
|
||||
public class ManageUserController {
|
||||
|
||||
@Autowired
|
||||
private UserInfoService userInfoService;
|
||||
|
||||
/**
|
||||
* 查询全部数据
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "查询全部数据")
|
||||
@GetMapping
|
||||
public Result<List<UserInfo>> findAll() {
|
||||
return Result.success(userInfoService.findAll());
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据ID查询
|
||||
*
|
||||
* @param id ID
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "根据ID查询")
|
||||
@GetMapping("/{id}")
|
||||
public Result<UserInfo> findById(@PathVariable String id) {
|
||||
return Result.success(userInfoService.findById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页+多条件查询
|
||||
*
|
||||
* @param searchMap 查询条件封装
|
||||
* @param page 页码
|
||||
* @param size 页大小
|
||||
* @return 分页结果
|
||||
*/
|
||||
@ApiOperation(value = "分页+多条件查询")
|
||||
@ApiImplicitParams({ @ApiImplicitParam(name = "searchMap", value = "查询条件封装", required = true),
|
||||
@ApiImplicitParam(name = "page", value = "页码", required = true),
|
||||
@ApiImplicitParam(name = "size", value = "页大小", required = true)})
|
||||
@PostMapping("/search/{page}/{size}")
|
||||
public Result<PageResult<UserInfo>> findSearch(@RequestBody Map searchMap, @PathVariable int page,
|
||||
@PathVariable int size) {
|
||||
Page<UserInfo> pageList = userInfoService.findSearch(searchMap, page, size);
|
||||
return Result.success(new PageResult<UserInfo>(pageList.getTotalElements(), pageList.getContent()));
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据条件查询
|
||||
*
|
||||
* @param searchMap
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "根据条件查询")
|
||||
@PostMapping("/search")
|
||||
public Result<List<UserInfo>> findSearch(@RequestBody Map searchMap) {
|
||||
return Result.success(userInfoService.findSearch(searchMap));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改
|
||||
*
|
||||
* @param user
|
||||
*/
|
||||
@ApiOperation(value = "修改")
|
||||
@PutMapping("/{id}")
|
||||
public Result<Void> update(@RequestBody UserInfo user, @PathVariable String id) {
|
||||
user.setId(id);
|
||||
userInfoService.update(user);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*
|
||||
* @param id
|
||||
*/
|
||||
@ApiOperation(value = "删除")
|
||||
@DeleteMapping("/{id}")
|
||||
public Result<Void> delete(@PathVariable String id) {
|
||||
userInfoService.deleteById(id);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过UserInfo用户ids批量查询UserInfo
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "通过UserInfo用户ids批量查询UserInfo")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "ids", value = "多个id以','分隔", required = true) })
|
||||
@GetMapping("/ids/{ids}")
|
||||
public Result<List<UserInfo>> findAllById(@PathVariable @VerifyParam(required=true) String ids){
|
||||
List<String> idList=Arrays.stream(ids.split(",")).map(String::trim).collect(Collectors.toList());
|
||||
return Result.success(userInfoService.findAllById(idList));
|
||||
}
|
||||
}
|
Loading…
Reference in new issue