12.13
UserMapper
package com.example.mapper; import com.example.pojo.Agent; import com.example.pojo.Customer; import com.example.pojo.House; import com.example.pojo.Users; import org.apache.ibatis.annotations.*; import java.util.List; @Mapper public interface UserMapper { //根据用户名和密码查询用户 //根据用户名和密码查询用户,并返回用户所在部门 @Select("select * from house.users where ID = #{username} and password = #{password}") Users getByUser(@Param("username") String username, @Param("password") String password); @Insert("insert into house.user (ID, Name, sex, IdNumber, Phone, Position, state) VALUES (#{id},#{name},#{sex},#{idNumber},#{phone},#{position},#{state})") void add(String id, String name, String sex, String phone, String idNumber, String position, int state); @Select("select * from house.user where state=#{state}") List<Customer> getAll(int state); @Select("select * from house.user where ID=#{id}") Customer selectid(String id); @Update("update house.user set state=#{state} where ID=#{id}") void updateById(String id, String state); @Insert("insert into house.users (ID, password, position) VALUES (#{id},#{password},#{position})") void addUser(String id, String password, String position); @Insert("insert into house.houseinformation(ID, Type, Position, Year, Area, much, State) VALUES (#{id},#{type},#{position},#{year},#{area},#{much},#{state})") void addHouse(String id, String type, String position, String year, String area, String much, String state); @Insert("insert into house.houseagent(AgentID, AgentName, AgentAddress, Phone) VALUES (#{id},#{name},#{address},#{phone})") void addAgent(String id, String name, String address, String phone); @Select("select * from house.users where ID=#{id}") Users selectUsers(String id); @Select("select * from house.houseagent where AgentID=#{id}") Agent select1(String id); @Select("select * from house.user where ID=#{id}") Customer select2(String id); @Update("update house.users set password=#{password} where ID=#{id}") void updatePassword(String id, String password); @Select("select * from house.houseinformation") List<House> selectHouse(); @Select("select * from house.houseinformation where State=#{type}") List<House> selectHouse2(String type); @Select("select * from house.houseinformation where AgentID=#{username}") List<House> selectHouse3(String username); }
Agent
package com.example.pojo; import lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor; @Data @AllArgsConstructor @NoArgsConstructor public class Agent { private String agentID; private String agentName; private String agentAddress; private String phone; }
Customer
package com.example.pojo; import lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor; @Data @AllArgsConstructor @NoArgsConstructor public class Customer { private String id; private String name; private String sex; private String phone; private String idNumber; private String position; private int state; }
House
package com.example.pojo; import lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor; @Data @AllArgsConstructor @NoArgsConstructor public class House { private String id; private String type; private String position; private String year; private String area; private String much; private String state; private String agentID; private String userID; }
Users
package com.example.pojo; import lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor; @Data @AllArgsConstructor @NoArgsConstructor public class Users { private String id; private String password; private String position; }