mirror of
				https://gitee.com/coder-xiaomo/flashsale
				synced 2025-11-04 14:13:14 +08:00 
			
		
		
		
	改正telephone拼写错误;添加viewobject;修正age类型错误
This commit is contained in:
		@@ -1,8 +1,10 @@
 | 
			
		||||
package com.cxyxiaomo.flashsale.controller;
 | 
			
		||||
 | 
			
		||||
import com.cxyxiaomo.flashsale.controller.viewobject.UserVO;
 | 
			
		||||
import com.cxyxiaomo.flashsale.service.UserService;
 | 
			
		||||
import com.cxyxiaomo.flashsale.service.model.UserModel;
 | 
			
		||||
import org.apache.catalina.User;
 | 
			
		||||
import org.springframework.beans.BeanUtils;
 | 
			
		||||
import org.springframework.beans.factory.annotation.Autowired;
 | 
			
		||||
import org.springframework.stereotype.Controller;
 | 
			
		||||
import org.springframework.web.bind.annotation.RequestMapping;
 | 
			
		||||
@@ -18,9 +20,20 @@ public class UserController {
 | 
			
		||||
 | 
			
		||||
    @RequestMapping("/get")
 | 
			
		||||
    @ResponseBody
 | 
			
		||||
    public UserModel getUser(@RequestParam(name = "id") Integer id) {
 | 
			
		||||
    public UserVO getUser(@RequestParam(name = "id") Integer id) {
 | 
			
		||||
        // 调用Services服务获取对应id的用户对象并返回给前端
 | 
			
		||||
        UserModel userModel = userService.getUserById(id);
 | 
			
		||||
        return userModel;
 | 
			
		||||
        // 将核心领域模型用户对象转化为可供UI使用的viewobject
 | 
			
		||||
        return convertFromModel(userModel);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private UserVO convertFromModel(UserModel userModel) {
 | 
			
		||||
        if (userModel == null) {
 | 
			
		||||
            return null;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        UserVO userVO = new UserVO();
 | 
			
		||||
        BeanUtils.copyProperties(userModel, userVO);
 | 
			
		||||
        return userVO;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -0,0 +1,50 @@
 | 
			
		||||
package com.cxyxiaomo.flashsale.controller.viewobject;
 | 
			
		||||
 | 
			
		||||
public class UserVO {
 | 
			
		||||
    private Integer id;
 | 
			
		||||
    private String name;
 | 
			
		||||
    private Byte gender;
 | 
			
		||||
    private Integer age;
 | 
			
		||||
 | 
			
		||||
    public Integer getId() {
 | 
			
		||||
        return id;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setId(Integer id) {
 | 
			
		||||
        this.id = id;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public String getName() {
 | 
			
		||||
        return name;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setName(String name) {
 | 
			
		||||
        this.name = name;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public Byte getGender() {
 | 
			
		||||
        return gender;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setGender(Byte gender) {
 | 
			
		||||
        this.gender = gender;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public Integer getAge() {
 | 
			
		||||
        return age;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setAge(Integer age) {
 | 
			
		||||
        this.age = age;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public String getTelephone() {
 | 
			
		||||
        return telephone;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setTelephone(String telephone) {
 | 
			
		||||
        this.telephone = telephone;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private String telephone;
 | 
			
		||||
}
 | 
			
		||||
@@ -4,8 +4,8 @@ public class UserModel {
 | 
			
		||||
    private Integer id;
 | 
			
		||||
    private String name;
 | 
			
		||||
    private Byte gender;
 | 
			
		||||
    private String age;
 | 
			
		||||
    private String telphone;
 | 
			
		||||
    private Integer age;
 | 
			
		||||
    private String telephone;
 | 
			
		||||
    private String registerMode;
 | 
			
		||||
    private String thirdPartyId;
 | 
			
		||||
 | 
			
		||||
@@ -35,20 +35,20 @@ public class UserModel {
 | 
			
		||||
        this.gender = gender;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public String getAge() {
 | 
			
		||||
    public Integer getAge() {
 | 
			
		||||
        return age;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setAge(String age) {
 | 
			
		||||
    public void setAge(Integer age) {
 | 
			
		||||
        this.age = age;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public String getTelphone() {
 | 
			
		||||
        return telphone;
 | 
			
		||||
    public String getTelephone() {
 | 
			
		||||
        return telephone;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setTelphone(String telphone) {
 | 
			
		||||
        this.telphone = telphone;
 | 
			
		||||
    public void setTelephone(String telephone) {
 | 
			
		||||
        this.telephone = telephone;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public String getRegisterMode() {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user