数据库与后端的映射
后端对数据库的操作
查:
@Select("select * from adminuser where username = #{userName} and password = #{password}")
public AdminUser login(@Param("userName") String userName ,@Param("password") String password);
改:
@Update("update adminuser set `password` = #{password}")
public void resetPassword(String password);
增
@Insert("insert into document(title,content) values(#{title},#{content})")
public void addDocument(Document d);
删
DELETE FROM 表名 [WHERE result<60]
后端与数据库的映射
public class AdminUser implements Serializable { //序列化,网络传输
@TableId("id") //主键
private int id;
@TableField("username") //要查询的字段列表,非主键
private String userName;
@TableField("password")
private String password;
}
后端中的技巧
@Data
//自动生成了get,set,equal等方法(获取值,重置,比较)定义在class类中