1.rename UserController to ManageUserController

main
Gary 10 months ago
parent 0335395776
commit 54c7f42cdd

@ -186,15 +186,4 @@ public class LoginController extends BaseController{
public Result<List<String>> getSupportedCountryCode(){
return Result.success(DEFAULT_SUPPORTED_COUNTRY_CODES);
}
/**
*
*
* @param id
*/
@DeleteMapping("/{id}")
public Result<Void> delete(@PathVariable String id) {
userInfoService.deleteById(id);
return Result.success();
}
}

@ -14,6 +14,7 @@ import annotation.VerifyParam;
import api.PageResult;
import api.Result;
import api.StatusCode;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
@ -28,7 +29,8 @@ import util.JwtUtil;
@RestController
@CrossOrigin
@RequestMapping("/admin")
public class AdminController {
@Api(tags = "ManageAdminController")
public class ManageAdminController {
@Autowired
private AdminService adminService;
@ -94,11 +96,10 @@ public class AdminController {
* @param ids
* @return
*/
@ApiOperation(value = "通过Admin用户ids批量查询Admin用户名称")
@ApiOperation(value = "通过Admin用户ids批量查询Admin用户信息")
@ApiImplicitParams({
@ApiImplicitParam(name = "ids", value = "多个id以','分隔", required = true) })
@GetMapping("/ids/{ids}")
@GlobalInterceptor(checkAdminLogin=true)
public Result<List<Admin>> findAllById(@PathVariable @VerifyParam(required=true) String ids){
List<String> idList=Arrays.stream(ids.split(",")).map(String::trim).collect(Collectors.toList());
return Result.success(adminService.findAllById(idList));

@ -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();
}
/**
* UserInfoidsUserInfo
* @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));
}
}

@ -1,263 +0,0 @@
/*
* package com.luoo.user.controller;
*
* import java.io.IOException; import java.util.HashMap; import java.util.List;
* import java.util.Map; import java.util.concurrent.TimeUnit;
*
* 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.User;
* import com.luoo.user.service.UserService; 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.ApiOperation;
* import util.IdWorker; import util.JwtUtil; import util.StringTools;
*
*//**
*
*
* @author Administrator
*
*/
/*
* @RestController
*
* @CrossOrigin
*
* @RequestMapping("/user")
*
* @Api(tags = "UserController") public class UserController {
*
* @Autowired private UserService userService;
*
* @Autowired private RedisTemplate redisTemplate;
*
* @Autowired private IdWorker idWorker;
*
* @Autowired private JwtUtil jwtUtil;
*
*//**
*
*
* @param
* @return
*/
/*
* @PutMapping("/{userid}/{friendid}/{x}") public void
* updatefanscountandfollowcount(@PathVariable String userid, @PathVariable
* String friendid,
*
* @PathVariable int x) { userService.updatefanscountandfollowcount(x, userid,
* friendid); }
*
* @PostMapping("/login")
*
* @Deprecated public Result login(@RequestBody User user) { user =
* userService.login(user.getMobile(), user.getPassword()); if (user == null) {
* // before there is a 'login error, intend to remvoe this interface' return
* Result.failed(); } String token = jwtUtil.createJWT(user.getId(),
* user.getMobile(), "user"); Map map = new HashMap(); map.put("userid",
* user.getId()); map.put("mobile", user.getMobile()); map.put("token", token);
* map.put("name", user.getLoginname()); map.put("avatar", user.getAvatar());
* map.put("roles", "user"); return Result.success(map); }
*
* @ApiOperation(value = "2.登录/注册",notes="成功后返回token")
*
* @PostMapping("/appLogin/{mobile}/{mobileCheckCode}")
*
* @GlobalInterceptor public Result
* appLogin( @PathVariable @VerifyParam(required=true,regex=VerifyRegexEnum.
* MOBILE)String mobile,
*
* @PathVariable @VerifyParam(required=true,regex=VerifyRegexEnum.
* MOBILE_CHECK_CODE) String mobileCheckCode ) { // 得到缓存中的验证码 String
* redisMobileCheckCodeKey=Constants.REDIS_KEY_MOBILE_CHECK_CODE+mobile; try {
* String redisMobileCheckCode = (String)
* redisTemplate.opsForValue().get(redisMobileCheckCodeKey); if
* (StringTools.isEmpty(redisMobileCheckCode)) { return
* Result.failed(StatusCode.USER_MOBILE_VERIFICATION_CODE_EXPIRED); } if
* (!redisMobileCheckCode.equals(mobileCheckCode)) { return
* Result.failed(StatusCode.USER_MOBILE_VERIFICATION_CODE_MISMATCH); } User user
* = userService.loginOrRegister(mobile); String token =
* jwtUtil.createJWT(user.getId(),user.getNickname(),Constants.
* TOKEN_ROLE_APP_USER); return Result.success(token); }finally {
* redisTemplate.delete(redisMobileCheckCodeKey); }
*
* }
*
* @Deprecated
*
* @ApiOperation(value = "3.游客登录返回token", notes =
* "token中的subject和roles均为tourist")
*
* @GetMapping("/touristLogin") public Result<String> touristLogin() { //String
* nickName="游客-"+NickNameUtil.getRandomNickName(); //String token =
* jwtUtil.createJWT(String.valueOf(idWorker.nextId()),nickName,Constants.
* TOKEN_ROLE_TOURIST); //return Result.success(token); return
* Result.success(""); }
*
*//**
*
*/
/*
* @ApiOperation(value = "1.发送短信验证码", notes = "有效期15分钟一个手机号一天内最多发送50个请求")
*
* @PostMapping("/sendsms/{mobile}")
*
* @GlobalInterceptor(frequencyType = RequestFrequencyTypeEnum.DAY,
* requestFrequencyThreshold = 50) public Result<Void>
* sendSms(@PathVariable @VerifyParam(required=true,regex=VerifyRegexEnum.MOBILE
* )String mobile) { userService.sendSms(mobile); return Result.success(); }
*
*//**
* token
*/
/*
* @ApiOperation(value = "5.token续期", notes = "有效期7天")
*
* @PostMapping("/autoLogin")
*
* @GlobalInterceptor public Result<String> autoLogin(@RequestHeader(value =
* "token", required = false) String token) { return
* Result.success(userService.autoLogin(token)); }
*
*//**
*
*/
/*
* @ApiOperation(value="4.获取图形验证码", notes = "4.三次短信验证失败后获取图形验证码有效期10分钟")
*
* @GetMapping("/imageCheckCode/{mobile}")
*
* @GlobalInterceptor public void imageCheckCode(HttpServletResponse response,
*
* @PathVariable @VerifyParam(required=true,regex=VerifyRegexEnum.MOBILE) String
* mobile) throws IOException { CreateImageCode vCode = new
* CreateImageCode(130,38,5,10); response.setHeader("Pragma", "no-cache");
* response.setHeader("Cache-Control", "no-cache");
* response.setDateHeader("Expires", 0); response.setContentType("image/jpeg");
* String code=vCode.getCode(); String
* redisKey=Constants.REDIS_KEY_IMAGE_CHECK_CODE+mobile;
* redisTemplate.opsForValue().set(redisKey,code,10,TimeUnit.MINUTES);
* vCode.write(response.getOutputStream()); }
*
* @ApiOperation(value = "6.图形验证码+短信验证码 登录/注册后返回token")
*
* @PostMapping("/appLogin/{mobile}/{mobileCheckCode}/{imageCheckCode}")
*
* @GlobalInterceptor public Result
* appLoginWithImageCheckCode( @PathVariable @VerifyParam(required=true,regex=
* VerifyRegexEnum.MOBILE)String mobile,
*
* @PathVariable @VerifyParam(required=true,regex=VerifyRegexEnum.
* MOBILE_CHECK_CODE) String mobileCheckCode,
*
* @PathVariable @VerifyParam(required=true) String imageCheckCode ) { //
* String
* redisImageCheckCodeKey=Constants.REDIS_KEY_IMAGE_CHECK_CODE+mobile; String
* redisImageCheckCode = (String)
* redisTemplate.opsForValue().get(redisImageCheckCodeKey); if
* (StringTools.isEmpty(redisImageCheckCode)) { return
* Result.failed(StatusCode.USER_IMAGE_VERIFICATION_CODE_EXPIRED); } if
* (!redisImageCheckCode.equalsIgnoreCase(imageCheckCode)) { return
* Result.failed(StatusCode.USER_IMAGE_VERIFICATION_CODE_MISMATCH); }
* redisTemplate.delete(redisImageCheckCodeKey); return
* appLogin(mobile,mobileCheckCode); }
*
*
* @PostMapping("/register/{code}") public Result regist(@PathVariable String
* code, @RequestBody User user) {
*
* // 得到缓存中的验证码 String checkcodeRedis = (String)
* redisTemplate.opsForValue().get("checkcode_" + user.getMobile()); if
* (checkcodeRedis.isEmpty()) { return
* Result.failed(StatusCode.USER_VERIFICATION_CODE_EXPIRED); } if
* (!checkcodeRedis.equals(code)) { return
* Result.failed(StatusCode.USER_VERIFICATION_CODE_MISMATCH); }
*
* userService.add(user); return Result.success(); }
*
*
*//**
*
*
* @return
*/
/*
* @GetMapping public Result<List<User>> findAll() { return
* Result.success(userService.findAll()); }
*
*//**
* ID
*
* @param id ID
* @return
*/
/*
* @GetMapping("/{id}") public Result<User> findById(@PathVariable String id) {
* return Result.success(userService.findById(id)); }
*
*//**
* +
*
* @param searchMap
* @param page
* @param size
* @return
*/
/*
* @PostMapping("/search/{page}/{size}") public Result<PageResult<User>>
* findSearch(@RequestBody Map searchMap, @PathVariable int page,
*
* @PathVariable int size) { Page<User> pageList =
* userService.findSearch(searchMap, page, size); return Result.success(new
* PageResult<User>(pageList.getTotalElements(), pageList.getContent())); }
*
*//**
*
*
* @param searchMap
* @return
*/
/*
* @PostMapping("/search") public Result<List<User>> findSearch(@RequestBody Map
* searchMap) { return Result.success(userService.findSearch(searchMap)); }
*
*//**
*
*
* @param user
*/
/*
* @PostMapping public Result<Void> add(@RequestBody User user) {
* userService.add(user); return Result.success(); }
*
*//**
*
*
* @param user
*/
/*
* @PutMapping("/{id}") public Result<Void> update(@RequestBody User
* user, @PathVariable String id) { user.setId(id); userService.update(user);
* return Result.success(); }
*
*//**
*
*
* @param id
*//*
* @DeleteMapping("/{id}") public Result<Void> delete(@PathVariable String id) {
* userService.deleteById(id); return Result.success(); }
*
* }
*/

@ -25,6 +25,7 @@ import util.IdWorker;
import constants.Constants;
import com.luoo.user.dao.UserInfoDao;
import com.luoo.user.pojo.Admin;
import com.luoo.user.pojo.UserInfo;
import com.luoo.user.util.NickNameUtil;
@ -303,4 +304,8 @@ public class UserInfoService {
userInfoDao.save(userInfo);
return jwtUtil.createJWT(user.getId(),user.getNickName(),Constants.TOKEN_ROLE_APP_USER);
}
public List<UserInfo> findAllById(List<String> idList) {
return userInfoDao.findAllById(idList);
}
}

Loading…
Cancel
Save