增加管理员修改用户信息和状态接口
This commit is contained in:
parent
a6d07feda6
commit
e771a9a5ae
|
@ -6,15 +6,13 @@ import cn.iocoder.mall.user.application.vo.admins.AdminsUserPageVO;
|
|||
import cn.iocoder.mall.user.service.api.UserService;
|
||||
import cn.iocoder.mall.user.service.api.bo.UserPageBO;
|
||||
import cn.iocoder.mall.user.service.api.dto.UserPageDTO;
|
||||
import cn.iocoder.mall.user.service.api.dto.UserUpdateDTO;
|
||||
import com.alibaba.dubbo.config.annotation.Reference;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiImplicitParams;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/admins/user")
|
||||
|
@ -26,7 +24,7 @@ public class AdminsUserController {
|
|||
|
||||
// 分页
|
||||
@GetMapping("/page")
|
||||
@ApiOperation(value = "管理员分页")
|
||||
@ApiOperation(value = "用户分页")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "nickname", value = "昵称,模糊匹配", example = "小王"),
|
||||
@ApiImplicitParam(name = "pageNo", value = "页码,从 0 开始", example = "0"),
|
||||
|
@ -35,7 +33,6 @@ public class AdminsUserController {
|
|||
public CommonResult<AdminsUserPageVO> page(@RequestParam(value = "nickname", required = false) String nickname,
|
||||
@RequestParam(value = "pageNo", defaultValue = "0") Integer pageNo,
|
||||
@RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) {
|
||||
// 创建 UserPageDTO
|
||||
UserPageDTO userPageDTO = new UserPageDTO().setNickname(nickname).setPageNo(pageNo).setPageSize(pageSize);
|
||||
// 查询分页
|
||||
CommonResult<UserPageBO> result = userService.getUserPage(userPageDTO);
|
||||
|
@ -43,8 +40,30 @@ public class AdminsUserController {
|
|||
return UserConvert.INSTANCE.convert(result);
|
||||
}
|
||||
|
||||
// 更新用户信息
|
||||
@PostMapping("/update")
|
||||
@ApiOperation(value = "更新用户基本信息")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "id", value = "用户编号", required = true, example = "1"),
|
||||
@ApiImplicitParam(name = "nickname", value = "昵称", required = true, example = "小王"),
|
||||
@ApiImplicitParam(name = "avatar", value = "头像", required = true, example = "http://www.iocoder.cn/xxx.jpg"),
|
||||
})
|
||||
public CommonResult<Boolean> update(@RequestParam("id") Integer id,
|
||||
@RequestParam("nickname") String nickname,
|
||||
@RequestParam("avatar") String avatar) {
|
||||
UserUpdateDTO userUpdateDTO = new UserUpdateDTO().setId(id).setNickname(nickname).setNickname(nickname).setAvatar(avatar);
|
||||
// 更新
|
||||
return userService.updateUser(userUpdateDTO);
|
||||
}
|
||||
|
||||
// 开启禁用
|
||||
@PostMapping("/update_status")
|
||||
@ApiOperation(value = "更新用户状态")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "id", value = "用户编号", required = true, example = "1"),
|
||||
@ApiImplicitParam(name = "status", value = "状态。1 - 开启;2 - 禁用", required = true, example = "1"),
|
||||
})
|
||||
public CommonResult<Boolean> updateStatus(@RequestParam("id") Integer id,
|
||||
@RequestParam("status") Integer status) {
|
||||
return userService.updateUserStatus(id, status);
|
||||
}
|
||||
|
||||
}
|
|
@ -4,4 +4,6 @@ spring:
|
|||
|
||||
# server
|
||||
server:
|
||||
port: 8082
|
||||
port: 18082
|
||||
servlet:
|
||||
context-path: /user-api/
|
|
@ -6,12 +6,6 @@ spring:
|
|||
username: root
|
||||
password: ${MALL_MYSQL_PASSWORD}
|
||||
|
||||
# server
|
||||
server:
|
||||
port: 18082
|
||||
servlet:
|
||||
context-path: /user-api/
|
||||
|
||||
# mybatis
|
||||
mybatis:
|
||||
config-location: classpath:mybatis-config.xml
|
||||
|
|
Loading…
Reference in New Issue