食堂管理系统
创建实体类
public class Food{
private int id;
private String name;
private String price;
private String msg;
private Date date;
// 省略 get/set
}
创建Dao层
public interface FoodDao {
// 通过账号和密码查询用户
public int addFood(Food food);
// 查询全部
public List<Food> findAllFood();
// 根据ID删除
public void delFood(int id);
// 修改方法
public int updateFood(Food food);
}
创建DaoMapper(sql)
<insert id="addFood" parameterType="Food" >
insert into food(id,name,price,msg,date)
values(#{id},#{name},#{price},#{msg},#{date})
</insert>
<select id="findAllFood" resultType="Food">
select * from food
</select>
<delete id="delFood" parameterType="Integer">
delete from food where id=#{id}
</delete>
<update id="updateFood" parameterType="Food">
update food set name=#{name},price=#{price},msg=#{msg},date=#{date} where id=#{id}
</update>
创建service层
public class FoodService{
// 通过账号和密码查询