<repo_name>iScript/spring-boot-example<file_sep>/src/main/java/com/macro/app/model/User.java
package com.macro.app.model;


import java.io.Serializable;
import java.util.Date;
import javax.validation.constraints.NotEmpty;

public class User implements Serializable {
    
    private Long id;

    @NotEmpty(message="用户名不能为空")
    private String username;

    @NotEmpty(message="密码不能为空")
    private String password;
    
    private String zzz;

    public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public String getUsername() {
		return username;
    }

    public void setUsername(String username){
        this.username = username;
    }

    public void setPassword(String password){
        this.password = password;
    }

    public String getZzz() {
		return zzz;
    }

    public String getPassword() {
		return <PASSWORD>;
    }

    public String getTest(){
        return "test!!!!";
        //return username;
    }

    public Integer getStatus(){
        return 1;
    }

    @Override
    public String toString() {
        return ("username=" + this.username + ",password=" + this.password);
    }

}<file_sep>/src/main/java/com/macro/app/common/HttpResult.java
// package com.macro.app.common;

// public class HttpResult<T> {


// }<file_sep>/src/main/java/com/macro/app/mapper/UserMapper.java

package com.macro.app.mapper;

import com.macro.app.model.User;
import org.apache.ibatis.annotations.*;
import java.util.List;

@Mapper
public interface UserMapper {
	
    @Select("SELECT * FROM user ")
    //将数据库查询到的zza字段，映射到模型的zzz
    @Results({
        @Result(property = "zzz", column = "zza")
    })
    List<User> getAll();

    @Select("SELECT * FROM user ")
    List<User> list();
    
    //
    @Delete("delete from user where id=#{id}")
    int delete(long id);

    //返回记录条数
    @Insert("INSERT INTO user(username,password) VALUES(#{username}, #{password})")
    int insert(User user);

    //注解+xml的方式
    @Update({"<script> ",
        "update user " ,
        "<set>" ,
        " <if test='username != null'>userName=#{username},</if>" ,
        " <if test='password != null'>nick_name=#{password},</if>" ,
        " </set> ",
        "where id=#{id} " ,
        "</script>"})
    int update(User user);

    @Select("SELECT * FROM user where username=#{username}")
    List<User> selectByUsername(User user);
}