日志
工作者:Black_YeJing
工作目标:实现卖家dao层的商品的增删改查(只能对自己发布的进行增删改查)。
工作进程追踪:
①创建了Shop类(卖家类)
②创建了ShopDao的接口里面编写了 查看所有商品,根据商品货名查看商品,增加商品,删除商品和修改商品。
③创建ShopDaoMapper的xml文件,在里面编写了查询所有商品,根据商品名,称查询商品,根据商品pid删除商品,根据商品pid修改商品的代码。
Shop.java
public class Shop {
private Integer sid; //卖家id
private String s_code; //卖家账户
private String s_password; //卖家密码
private String s_name; //卖家姓名
private String s_admin; //卖家管理员
private String s_telephone; //卖家电话
private String s_mail; //卖家邮箱
private String s_address; //卖家地址
public Shop()
{
}
public Integer getSid() {
return sid;
}
public void setSid(Integer sid) {
this.sid = sid;
}
public String getS_code() {
return s_code;
}
public void setS_code(String s_code) {
this.s_code = s_code;
}
public String getS_password() {
return s_password;
}
public void setS_password(String s_password) {
this.s_password = s_password;
}
public String getS_name() {
return s_name;
}
public void setS_name(String s_name) {
this.s_name = s_name;
}
public String getS_admin() {
return s_admin;
}
public void setS_admin(String s_admin) {
this.s_admin = s_admin;
}
public String getS_telephone() {
return s_telephone;
}
public void setS_telephone(String s_telephone) {
this.s_telephone = s_telephone;
}
public String getS_mail() {
return s_mail;
}
public void setS_mail(String s_mail) {
this.s_mail = s_mail;
}
public String getS_address() {
return s_address;
}
public void setS_address(String s_address) {
this.s_address = s_address;
}
}
ShopDao.java
public interface ShopDao {
//查看所有商品
public Product getAllProduct(Product product);
//根据货名查看商品
public Product getProductById(String name);
//增加商品
public int createProduct(Product product);
//删除商品
public int deleteProduct(Integer pid);
//修改商品
public int updateProduct(Product product);
}
ShopDaoMapper.java
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.aaa.dao.ShopDao">
<!-- 查看所有商品 -->
<select id="getAllProduct" resultType="Product">
select * from product
</select>
<!-- 根据商品名称查看商品 -->
<select id="getProductById" parameterType="Product" >
select * from product where name=#{name}
</select>
<!-- 根据商品pid修改商品 -->
<update id="updateProduct" parameterType="Product">
update product set sid=#{sid},name=#{name},price=#{price},stock=#{stock},img=#{img} where pid=#{pid}
</update>
<!-- 根据商品pid删除商品 -->
<delete id="deleteProduct" parameterType="Integer">
delete from product where pid=#{pid}
</delete>
<!-- 增加商品 -->
<insert id="createProduct" parameterType="Product">
insert into product(sid,name,price,pdesc,stock,img)
values(#{sid},#{name},#{price},#{pdesc},#{stock},#{img})
</insert>
</mapper>