|
@@ -3,16 +3,14 @@ package cn.rankin.userservice.controller;
|
|
import cn.rankin.common.utils.api.model.APIResult;
|
|
import cn.rankin.common.utils.api.model.APIResult;
|
|
import cn.rankin.common.utils.api.page.Page;
|
|
import cn.rankin.common.utils.api.page.Page;
|
|
import cn.rankin.common.utils.enums.BaseOrderEnum;
|
|
import cn.rankin.common.utils.enums.BaseOrderEnum;
|
|
|
|
+import cn.rankin.data.api.user.dto.WhiteUserDTO;
|
|
import cn.rankin.data.api.user.dto.WhiteUserSearchDTO;
|
|
import cn.rankin.data.api.user.dto.WhiteUserSearchDTO;
|
|
import cn.rankin.data.api.user.entity.WhiteUser;
|
|
import cn.rankin.data.api.user.entity.WhiteUser;
|
|
import cn.rankin.userservice.code.UserServiceAPICode;
|
|
import cn.rankin.userservice.code.UserServiceAPICode;
|
|
import cn.rankin.userservice.service.WhiteUserService;
|
|
import cn.rankin.userservice.service.WhiteUserService;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.util.StringUtils;
|
|
import org.springframework.util.StringUtils;
|
|
-import org.springframework.web.bind.annotation.PathVariable;
|
|
|
|
-import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
-import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
|
-import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import java.util.LinkedHashMap;
|
|
import java.util.LinkedHashMap;
|
|
|
|
|
|
@@ -32,6 +30,34 @@ public class WhiteUserController {
|
|
return APIResult.ok(whiteUser);
|
|
return APIResult.ok(whiteUser);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @RequestMapping(method = RequestMethod.POST)
|
|
|
|
+ public APIResult<WhiteUser> create(@RequestBody WhiteUserDTO whiteUserDTO) {
|
|
|
|
+ WhiteUser whiteUser = whiteUserService.addUser(whiteUserDTO);
|
|
|
|
+ if (whiteUser != null) {
|
|
|
|
+ return APIResult.ok(whiteUser);
|
|
|
|
+ }
|
|
|
|
+ return APIResult.error(UserServiceAPICode.error("创建失败"));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @RequestMapping(method = RequestMethod.PUT)
|
|
|
|
+ public APIResult<WhiteUser> update(@RequestBody WhiteUserDTO whiteUserDTO) {
|
|
|
|
+ WhiteUser whiteUser = whiteUserService.updateUser(whiteUserDTO);
|
|
|
|
+ if (whiteUser != null) {
|
|
|
|
+ return APIResult.ok(whiteUser);
|
|
|
|
+ }
|
|
|
|
+ return APIResult.error(UserServiceAPICode.error("更新失败"));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @RequestMapping(method = RequestMethod.DELETE)
|
|
|
|
+ public APIResult<Boolean> delete(@RequestBody WhiteUserDTO whiteUserDTO) {
|
|
|
|
+ String userId = whiteUserDTO.getUserId();
|
|
|
|
+ Boolean result = whiteUserService.deleteUser(userId);
|
|
|
|
+ if (Boolean.TRUE.equals(result)) {
|
|
|
|
+ return APIResult.ok(result);
|
|
|
|
+ }
|
|
|
|
+ return APIResult.error(UserServiceAPICode.NOT_EXISTS);
|
|
|
|
+ }
|
|
|
|
+
|
|
@RequestMapping(value = "/list", method = RequestMethod.GET)
|
|
@RequestMapping(value = "/list", method = RequestMethod.GET)
|
|
public APIResult<Page<WhiteUser>> search(WhiteUserSearchDTO searchDTO) {
|
|
public APIResult<Page<WhiteUser>> search(WhiteUserSearchDTO searchDTO) {
|
|
WhiteUser sample = new WhiteUser();
|
|
WhiteUser sample = new WhiteUser();
|
|
@@ -43,7 +69,7 @@ public class WhiteUserController {
|
|
Integer pageSize = searchDTO.getPageSize();
|
|
Integer pageSize = searchDTO.getPageSize();
|
|
LinkedHashMap<String, BaseOrderEnum> sort = new LinkedHashMap<>();
|
|
LinkedHashMap<String, BaseOrderEnum> sort = new LinkedHashMap<>();
|
|
sort.put("gmtModified", BaseOrderEnum.DESC);
|
|
sort.put("gmtModified", BaseOrderEnum.DESC);
|
|
-// return whiteUserService.search(sample, pageNo, pageSize, sort);
|
|
|
|
- return null;
|
|
|
|
|
|
+ Page<WhiteUser> page = whiteUserService.search(sample, pageNo, pageSize, sort);
|
|
|
|
+ return APIResult.ok(page);
|
|
}
|
|
}
|
|
}
|
|
}
|