diff --git a/luoo_user/src/main/java/com/luoo/user/controller/LoginController.java b/luoo_user/src/main/java/com/luoo/user/controller/LoginController.java index ec0f91f..c65d7e6 100644 --- a/luoo_user/src/main/java/com/luoo/user/controller/LoginController.java +++ b/luoo_user/src/main/java/com/luoo/user/controller/LoginController.java @@ -186,15 +186,4 @@ public class LoginController extends BaseController{ public Result> getSupportedCountryCode(){ return Result.success(DEFAULT_SUPPORTED_COUNTRY_CODES); } - - /** - * 删除 - * - * @param id - */ - @DeleteMapping("/{id}") - public Result delete(@PathVariable String id) { - userInfoService.deleteById(id); - return Result.success(); - } } diff --git a/luoo_user/src/main/java/com/luoo/user/controller/AdminController.java b/luoo_user/src/main/java/com/luoo/user/controller/ManageAdminController.java similarity index 97% rename from luoo_user/src/main/java/com/luoo/user/controller/AdminController.java rename to luoo_user/src/main/java/com/luoo/user/controller/ManageAdminController.java index 89ee421..d7ae12d 100644 --- a/luoo_user/src/main/java/com/luoo/user/controller/AdminController.java +++ b/luoo_user/src/main/java/com/luoo/user/controller/ManageAdminController.java @@ -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> findAllById(@PathVariable @VerifyParam(required=true) String ids){ List idList=Arrays.stream(ids.split(",")).map(String::trim).collect(Collectors.toList()); return Result.success(adminService.findAllById(idList)); diff --git a/luoo_user/src/main/java/com/luoo/user/controller/ManageUserController.java b/luoo_user/src/main/java/com/luoo/user/controller/ManageUserController.java new file mode 100644 index 0000000..1ef832d --- /dev/null +++ b/luoo_user/src/main/java/com/luoo/user/controller/ManageUserController.java @@ -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> findAll() { + return Result.success(userInfoService.findAll()); + } + + /** + * 根据ID查询 + * + * @param id ID + * @return + */ + @ApiOperation(value = "根据ID查询") + @GetMapping("/{id}") + public Result 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> findSearch(@RequestBody Map searchMap, @PathVariable int page, + @PathVariable int size) { + Page pageList = userInfoService.findSearch(searchMap, page, size); + return Result.success(new PageResult(pageList.getTotalElements(), pageList.getContent())); + } + + /** + * 根据条件查询 + * + * @param searchMap + * @return + */ + @ApiOperation(value = "根据条件查询") + @PostMapping("/search") + public Result> findSearch(@RequestBody Map searchMap) { + return Result.success(userInfoService.findSearch(searchMap)); + } + + /** + * 修改 + * + * @param user + */ + @ApiOperation(value = "修改") + @PutMapping("/{id}") + public Result update(@RequestBody UserInfo user, @PathVariable String id) { + user.setId(id); + userInfoService.update(user); + return Result.success(); + } + + /** + * 删除 + * + * @param id + */ + @ApiOperation(value = "删除") + @DeleteMapping("/{id}") + public Result 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> findAllById(@PathVariable @VerifyParam(required=true) String ids){ + List idList=Arrays.stream(ids.split(",")).map(String::trim).collect(Collectors.toList()); + return Result.success(userInfoService.findAllById(idList)); + } +} diff --git a/luoo_user/src/main/java/com/luoo/user/controller/UserController.java b/luoo_user/src/main/java/com/luoo/user/controller/UserController.java deleted file mode 100644 index e309ffd..0000000 --- a/luoo_user/src/main/java/com/luoo/user/controller/UserController.java +++ /dev/null @@ -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 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 - * 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 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> findAll() { return - * Result.success(userService.findAll()); } - * - *//** - * 根据ID查询 - * - * @param id ID - * @return - */ -/* - * @GetMapping("/{id}") public Result findById(@PathVariable String id) { - * return Result.success(userService.findById(id)); } - * - *//** - * 分页+多条件查询 - * - * @param searchMap 查询条件封装 - * @param page 页码 - * @param size 页大小 - * @return 分页结果 - */ -/* - * @PostMapping("/search/{page}/{size}") public Result> - * findSearch(@RequestBody Map searchMap, @PathVariable int page, - * - * @PathVariable int size) { Page pageList = - * userService.findSearch(searchMap, page, size); return Result.success(new - * PageResult(pageList.getTotalElements(), pageList.getContent())); } - * - *//** - * 根据条件查询 - * - * @param searchMap - * @return - */ -/* - * @PostMapping("/search") public Result> findSearch(@RequestBody Map - * searchMap) { return Result.success(userService.findSearch(searchMap)); } - * - *//** - * 增加 - * - * @param user - */ -/* - * @PostMapping public Result add(@RequestBody User user) { - * userService.add(user); return Result.success(); } - * - *//** - * 修改 - * - * @param user - */ -/* - * @PutMapping("/{id}") public Result update(@RequestBody User - * user, @PathVariable String id) { user.setId(id); userService.update(user); - * return Result.success(); } - * - *//** - * 删除 - * - * @param id - *//* - * @DeleteMapping("/{id}") public Result delete(@PathVariable String id) { - * userService.deleteById(id); return Result.success(); } - * - * } - */ \ No newline at end of file diff --git a/luoo_user/src/main/java/com/luoo/user/service/UserInfoService.java b/luoo_user/src/main/java/com/luoo/user/service/UserInfoService.java index 906a011..03a80ee 100644 --- a/luoo_user/src/main/java/com/luoo/user/service/UserInfoService.java +++ b/luoo_user/src/main/java/com/luoo/user/service/UserInfoService.java @@ -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 findAllById(List idList) { + return userInfoDao.findAllById(idList); + } }