一、创建Dto和ViewModel
package com.yhh.common.entity.member.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.time.LocalDateTime;
@Data
public class UserDto implements Serializable {
private Integer pageNum;
private Integer pageSize;
private Integer orderby;
private Long id;
private Integer status;
private LocalDateTime createTime;
private LocalDateTime modifyTime;
private String phoneNumber;
private String email;
private String openId;
private String password;
private Integer sex;
private String name;
private Integer age;
private String pic;
private Integer isVip;
private Integer score;
}
package com.yhh.common.entity.member.view;
import com.yhh.common.entity.member.model.User;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.time.LocalDateTime;
@Data
@ApiModel(value = "UserView",description = "")
public class UserView implements Serializable {
public UserView() {
}
public UserView(User user){
this.id = user.getId();
this.status = user.getStatus();
this.createTime = user.getCreateTime();
this.modifyTime = user.getModifyTime();
this.phoneNumber = user.getPhoneNumber();
this.email = user.getEmail();
this.openId = user.getOpenId();
this.password = user.getPassword();
this.sex = user.getSex();
this.name = user.getName();
this.age =user.getAge();
this.pic = user.getPic();
this.isVip = user.getIsVip();
this.score = user.getScore();
}
@ApiModelProperty(value = "用户ID")
private Long id;
@ApiModelProperty(value = "使用状态(0:禁用 1:正常)")
private Integer status;
@ApiModelProperty(value = "创建时间")
private LocalDateTime createTime;
@ApiModelProperty(value = "修改时间")
private LocalDateTime modifyTime;
@ApiModelProperty(value = "电话号码")
private String phoneNumber;
@ApiModelProperty(value = "用户邮箱")
private String email;
@ApiModelProperty(value = "微信ID")
private String openId;
@ApiModelProperty(value = "用户密码")
private String password;
@ApiModelProperty(value = "用户性别(0:男 1:女)")
private Integer sex;
@ApiModelProperty(value = "用户性别:男/女)")
private String strSex;
public String getStrSex() {
return this.sex == 0 ? "男":"女";
}
@ApiModelProperty(value = "用户名称")
private String name;
@ApiModelProperty(value = "用户年龄")
private Integer age;
@ApiModelProperty(value = "用户头像")
private String pic;
@ApiModelProperty(value = "是否是vip(0:普通用户 1:vip)")
private Integer isVip;
@ApiModelProperty(value = "用户积分")
private Integer score;
}
二、实现业务逻辑
2.1创建getByPage 服务接口
2.2 编写业务实现
2.3 控制器调用Business
三、编写过滤器
3.1 编写utils.FieldsFilter
3.2 MemberController调用过滤器