调整 User 项目结构
增加管理后台查看 User 分页接口
This commit is contained in:
@@ -1,25 +0,0 @@
|
||||
package cn.iocoder.mall.user.application.controller;
|
||||
|
||||
import cn.iocoder.common.framework.vo.CommonResult;
|
||||
import cn.iocoder.mall.user.sdk.context.UserSecurityContextHolder;
|
||||
import cn.iocoder.mall.user.application.vo.UserInfoVO;
|
||||
import io.swagger.annotations.Api;
|
||||
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.RestController;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/user")
|
||||
@Api("用户模块")
|
||||
public class UserController {
|
||||
|
||||
@GetMapping("/info")
|
||||
@ApiOperation(value = "用户信息")
|
||||
public CommonResult<UserInfoVO> info() {
|
||||
// TODO 芋艿,正在实现中
|
||||
UserInfoVO user = new UserInfoVO().setId(UserSecurityContextHolder.getContext().getUid());
|
||||
return CommonResult.success(user);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
package cn.iocoder.mall.user.application.controller.admins;
|
||||
|
||||
import cn.iocoder.common.framework.vo.CommonResult;
|
||||
import cn.iocoder.mall.user.application.convert.UserConvert;
|
||||
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 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;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/admins/user")
|
||||
@Api("用户模块")
|
||||
public class AdminsUserController {
|
||||
|
||||
@Reference(validation = "true")
|
||||
private UserService userService;
|
||||
|
||||
// 分页
|
||||
@GetMapping("/page")
|
||||
@ApiOperation(value = "管理员分页")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "nickname", value = "昵称,模糊匹配", example = "小王"),
|
||||
@ApiImplicitParam(name = "pageNo", value = "页码,从 0 开始", example = "0"),
|
||||
@ApiImplicitParam(name = "pageSize", value = "每页条数", required = true, example = "10"),
|
||||
})
|
||||
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);
|
||||
// 转换结果
|
||||
return UserConvert.INSTANCE.convert(result);
|
||||
}
|
||||
|
||||
// 更新用户信息
|
||||
|
||||
// 开启禁用
|
||||
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package cn.iocoder.mall.user.application.controller;
|
||||
package cn.iocoder.mall.user.application.controller.users;
|
||||
|
||||
import cn.iocoder.common.framework.vo.CommonResult;
|
||||
import cn.iocoder.mall.user.application.convert.PassportConvert;
|
||||
@@ -51,13 +51,15 @@ public class PassportController {
|
||||
}
|
||||
|
||||
@PermitAll
|
||||
@PostMapping("mobile/send")
|
||||
@PostMapping("mobile/send_register_code")
|
||||
@ApiOperation(value = "发送手机验证码")
|
||||
@ApiImplicitParam(name = "mobile", value = "手机号", required = true, example = "15601691300")
|
||||
public CommonResult<Void> mobileSend(@RequestParam("mobile") String mobile) {
|
||||
return mobileCodeService.send(mobile);
|
||||
}
|
||||
|
||||
// TODO 芋艿,改绑手机号
|
||||
|
||||
// TODO 功能:qq 登陆
|
||||
@PermitAll
|
||||
@PostMapping("/qq/login")
|
||||
@@ -0,0 +1,49 @@
|
||||
package cn.iocoder.mall.user.application.controller.users;
|
||||
|
||||
import cn.iocoder.common.framework.vo.CommonResult;
|
||||
import cn.iocoder.mall.user.sdk.context.UserSecurityContextHolder;
|
||||
import cn.iocoder.mall.user.application.vo.UsersUserVO;
|
||||
import cn.iocoder.mall.user.service.api.UserService;
|
||||
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.ApiOperation;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/users/user")
|
||||
@Api("用户模块")
|
||||
public class UserController {
|
||||
|
||||
@Reference
|
||||
private UserService userService;
|
||||
|
||||
@GetMapping("/info")
|
||||
@ApiOperation(value = "用户信息")
|
||||
public CommonResult<UsersUserVO> info() {
|
||||
// TODO 芋艿,正在实现中
|
||||
UsersUserVO user = new UsersUserVO().setId(UserSecurityContextHolder.getContext().getUserId());
|
||||
return CommonResult.success(user);
|
||||
}
|
||||
|
||||
@PostMapping("/update_avatar")
|
||||
@ApiOperation(value = "更新头像")
|
||||
public CommonResult<Boolean> updateAvatar(@RequestParam("avatar") String avatar) {
|
||||
// 创建
|
||||
UserUpdateDTO userUpdateDTO = new UserUpdateDTO().setId(UserSecurityContextHolder.getContext().getUserId())
|
||||
.setAvatar(avatar);
|
||||
// 更新头像
|
||||
return userService.updateUser(userUpdateDTO);
|
||||
}
|
||||
|
||||
@PostMapping("/update_nickname")
|
||||
@ApiOperation(value = "更新昵称")
|
||||
public CommonResult<Boolean> updateNickname(@RequestParam("nickname") String nickname) {
|
||||
// 创建
|
||||
UserUpdateDTO userUpdateDTO = new UserUpdateDTO().setId(UserSecurityContextHolder.getContext().getUserId())
|
||||
.setNickname(nickname);
|
||||
// 更新头像
|
||||
return userService.updateUser(userUpdateDTO);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package cn.iocoder.mall.user.application.convert;
|
||||
|
||||
import cn.iocoder.common.framework.vo.CommonResult;
|
||||
import cn.iocoder.mall.user.application.vo.admins.AdminsUserPageVO;
|
||||
import cn.iocoder.mall.user.service.api.bo.UserPageBO;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.Mappings;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
@Mapper
|
||||
public interface UserConvert {
|
||||
|
||||
UserConvert INSTANCE = Mappers.getMapper(UserConvert.class);
|
||||
|
||||
@Mappings({})
|
||||
CommonResult<AdminsUserPageVO> convert(CommonResult<UserPageBO> result);
|
||||
|
||||
}
|
||||
@@ -4,16 +4,16 @@ import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
@ApiModel("用户信息 VO")
|
||||
public class UserInfoVO {
|
||||
public class UsersUserVO {
|
||||
|
||||
@ApiModelProperty(value = "用户编号", required = true, example = "123")
|
||||
private Long id;
|
||||
private Integer id;
|
||||
|
||||
public Long getId() {
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public UserInfoVO setId(Long id) {
|
||||
public UsersUserVO setId(Integer id) {
|
||||
this.id = id;
|
||||
return this;
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package cn.iocoder.mall.user.application.vo.admins;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@ApiModel("用户分页 VO")
|
||||
public class AdminsUserPageVO {
|
||||
|
||||
@ApiModelProperty(value = "用户数组")
|
||||
private List<AdminsUserVO> users;
|
||||
@ApiModelProperty(value = "用户总数")
|
||||
private Integer count;
|
||||
|
||||
public List<AdminsUserVO> getUsers() {
|
||||
return users;
|
||||
}
|
||||
|
||||
public AdminsUserPageVO setUsers(List<AdminsUserVO> users) {
|
||||
this.users = users;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Integer getCount() {
|
||||
return count;
|
||||
}
|
||||
|
||||
public AdminsUserPageVO setCount(Integer count) {
|
||||
this.count = count;
|
||||
return this;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
package cn.iocoder.mall.user.application.vo.admins;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@ApiModel("用户 VO")
|
||||
public class AdminsUserVO {
|
||||
|
||||
@ApiModelProperty(value = "用户编号", required = true, example = "1")
|
||||
private Integer id;
|
||||
@ApiModelProperty(value = "手机号", required = true, example = "15601691300")
|
||||
private String mobile;
|
||||
@ApiModelProperty(value = "昵称", required = true, example = "小王")
|
||||
private String nickname;
|
||||
@ApiModelProperty(value = "头像", required = true, example = "http://www.iocoder.cn/xxx.jpg")
|
||||
private String avatar;
|
||||
@ApiModelProperty(value = "账号状态", required = true, example = "1")
|
||||
private Integer status;
|
||||
@ApiModelProperty(value = "创建时间", required = true, example = "时间戳格式")
|
||||
private Date createTime;
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public AdminsUserVO setId(Integer id) {
|
||||
this.id = id;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getMobile() {
|
||||
return mobile;
|
||||
}
|
||||
|
||||
public AdminsUserVO setMobile(String mobile) {
|
||||
this.mobile = mobile;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getNickname() {
|
||||
return nickname;
|
||||
}
|
||||
|
||||
public AdminsUserVO setNickname(String nickname) {
|
||||
this.nickname = nickname;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getAvatar() {
|
||||
return avatar;
|
||||
}
|
||||
|
||||
public AdminsUserVO setAvatar(String avatar) {
|
||||
this.avatar = avatar;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Integer getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public AdminsUserVO setStatus(Integer status) {
|
||||
this.status = status;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Date getCreateTime() {
|
||||
return createTime;
|
||||
}
|
||||
|
||||
public AdminsUserVO setCreateTime(Date createTime) {
|
||||
this.createTime = createTime;
|
||||
return this;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user