• 【1024练习】Mybatis练习三


     

     

     

     

     

     

    package cn.kgc.pojo;
    
    import java.math.BigDecimal;
    import java.util.Date;
    
    /**
     * Created with IntelliJ IDEA.
     * User: L
     * Date: 2019/10/24
     * Time: 17:31
     * Description: No Description
     */
    public class Bill {
        private Integer id;   //id
        private String billCode; //账单编码
        private String productName; //商品名称
        private String productDesc; //商品描述
        private String productUnit; //商品单位
        private String productCount; //商品数量
        private String totalPrice; //总金额
        private Integer isPayment; //是否支付
        private Integer providerId; //供应商ID
        private Integer createdBy; //创建者
        private Date creationDate; //创建时间
        private Integer modifyBy; //更新者
        private Date modifyDate;//更新时间
    
        private String providerName;//供应商名称
    
        public Integer getId() {
            return id;
        }
    
        public void setId(Integer id) {
            this.id = id;
        }
    
        public String getBillCode() {
            return billCode;
        }
    
        public void setBillCode(String billCode) {
            this.billCode = billCode;
        }
    
        public String getProductName() {
            return productName;
        }
    
        public void setProductName(String productName) {
            this.productName = productName;
        }
    
        public String getProductDesc() {
            return productDesc;
        }
    
        public void setProductDesc(String productDesc) {
            this.productDesc = productDesc;
        }
    
        public String getProductUnit() {
            return productUnit;
        }
    
        public void setProductUnit(String productUnit) {
            this.productUnit = productUnit;
        }
    
        public String getProductCount() {
            return productCount;
        }
    
        public void setProductCount(String productCount) {
            this.productCount = productCount;
        }
    
        public String getTotalPrice() {
            return totalPrice;
        }
    
        public void setTotalPrice(String totalPrice) {
            this.totalPrice = totalPrice;
        }
    
        public Integer getIsPayment() {
            return isPayment;
        }
    
        public void setIsPayment(Integer isPayment) {
            this.isPayment = isPayment;
        }
    
        public Integer getProviderId() {
            return providerId;
        }
    
        public void setProviderId(Integer providerId) {
            this.providerId = providerId;
        }
    
        public Integer getCreatedBy() {
            return createdBy;
        }
    
        public void setCreatedBy(Integer createdBy) {
            this.createdBy = createdBy;
        }
    
        public Date getCreationDate() {
            return creationDate;
        }
    
        public void setCreationDate(Date creationDate) {
            this.creationDate = creationDate;
        }
    
        public Integer getModifyBy() {
            return modifyBy;
        }
    
        public void setModifyBy(Integer modifyBy) {
            this.modifyBy = modifyBy;
        }
    
        public Date getModifyDate() {
            return modifyDate;
        }
    
        public void setModifyDate(Date modifyDate) {
            this.modifyDate = modifyDate;
        }
    
        public String getProviderName() {
            return providerName;
        }
    
        public void setProviderName(String providerName) {
            this.providerName = providerName;
        }
    }
    Bill.java
    package cn.kgc.pojo;
    
    import java.util.Date;
    
    /**
     * Created with IntelliJ IDEA.
     * User: L
     * Date: 2019/10/24
     * Time: 17:32
     * Description: No Description
     */
    public class Provider {
        private Integer id;   //id
        private String proCode; //供应商编码
        private String proName; //供应商名称
        private String proDesc; //供应商描述
        private String proContact; //供应商联系人
        private String proPhone; //供应商电话
        private String proAddress; //供应商地址
        private String proFax; //供应商传真
        private Integer createdBy; //创建者
        private Date creationDate; //创建时间
        private Integer modifyBy; //更新者
        private Date modifyDate;//更新时间
    
        public Integer getId() {
            return id;
        }
    
        public void setId(Integer id) {
            this.id = id;
        }
    
        public String getProCode() {
            return proCode;
        }
    
        public void setProCode(String proCode) {
            this.proCode = proCode;
        }
    
        public String getProName() {
            return proName;
        }
    
        public void setProName(String proName) {
            this.proName = proName;
        }
    
        public String getProDesc() {
            return proDesc;
        }
    
        public void setProDesc(String proDesc) {
            this.proDesc = proDesc;
        }
    
        public String getProContact() {
            return proContact;
        }
    
        public void setProContact(String proContact) {
            this.proContact = proContact;
        }
    
        public String getProPhone() {
            return proPhone;
        }
    
        public void setProPhone(String proPhone) {
            this.proPhone = proPhone;
        }
    
        public String getProAddress() {
            return proAddress;
        }
    
        public void setProAddress(String proAddress) {
            this.proAddress = proAddress;
        }
    
        public String getProFax() {
            return proFax;
        }
    
        public void setProFax(String proFax) {
            this.proFax = proFax;
        }
    
        public Integer getCreatedBy() {
            return createdBy;
        }
    
        public void setCreatedBy(Integer createdBy) {
            this.createdBy = createdBy;
        }
    
        public Date getCreationDate() {
            return creationDate;
        }
    
        public void setCreationDate(Date creationDate) {
            this.creationDate = creationDate;
        }
    
        public Integer getModifyBy() {
            return modifyBy;
        }
    
        public void setModifyBy(Integer modifyBy) {
            this.modifyBy = modifyBy;
        }
    
        public Date getModifyDate() {
            return modifyDate;
        }
    
        public void setModifyDate(Date modifyDate) {
            this.modifyDate = modifyDate;
        }
    }
    Provider.java
    package cn.kgc.dao;
    
    import cn.kgc.pojo.Bill;
    import org.apache.ibatis.annotations.Param;
    
    import java.util.List;
    
    public interface BillMapper {
        /**
         * 根据条件查询订单表
         * @param productName
         * @param providerId
         * @param isPayment
         * @return
         */
        public List<Bill> getBillList(@Param("productName")String productName,
                                      @Param("providerId")Integer providerId,
                                      @Param("isPayment")Integer isPayment);
    }
    BillMapper.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="cn.kgc.dao.BillMapper">
    
        <!-- 根据条件查询订单表 -->
        <select id="getBillList" resultType="Bill">
            select b.*,p.proName as providerName from smbms_bill b,smbms_provider p where b.providerId = p.id
            <if test="productName != null and productName != ''">
                and b.productName like CONCAT ('%',#{productName},'%')
            </if>
            <if test="providerId != null">
                and b.providerId = #{providerId}
            </if>
            <if test="isPayment != null">
                and b.isPayment = #{isPayment}
            </if>
        </select>
    
    </mapper>
    BillMapper.xml
    package cn.kgc.dao;
    
    import cn.kgc.pojo.Provider;
    import org.apache.ibatis.annotations.Param;
    
    import java.util.List;
    
    public interface ProviderMapper {
        /**
         * 查询供应商表记录数
         * @return
         */
        public int count();
        /**
         * 查询供应商列表
         * @return
         */
        public List<Provider> getProviderList();
        /**
         * 根据供应商名称查询供应商列表(模糊查询)
         * @param proName
         * @return
         */
        public List<Provider> getProviderListByProName(String proName);
        /**
         * 增加供应商
         * @param provider
         * @return
         */
        public int add(Provider provider);
        /**
         * 修改供应商信息
         * @param provider
         * @return
         */
        public int modify(Provider provider);
        /**
         * 根据供应商ID删除供应商信息
         * @param delId
         * @return
         */
        public int deleteProviderById(@Param("id")Integer delId);
    }
    ProviderMapper.java
    ProviderMapper.xml
    <?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="cn.kgc.dao.ProviderMapper">
    
        <!-- 查询供应商表记录数 -->
        <select id="count" resultType="int">
            select count(1) as count from smbms_provider
        </select>
    
        <!-- 查询供应商列表 -->
        <select id="getProviderList" resultType="cn.kgc.pojo.Provider">
            select * from smbms_provider
        </select>
    
        <!-- 根据供应商名称查询供应商列表(模糊查询) -->
        <select id="getProviderListByProName" resultType="cn.kgc.pojo.Provider" parameterType="String">
            select * from smbms_provider where proName like CONCAT ('%',#{proName},'%')
        </select>
    
        <!-- 增加供应商 -->
        <insert id="add" parameterType="Provider">
            insert into smbms_provider (proCode,proName,proDesc,proContact,proPhone,
                                    proAddress,proFax,createdBy,creationDate)
                    values (#{proCode},#{proName},#{proDesc},#{proContact},#{proPhone},#{proAddress},
                    #{proFax},#{createdBy},#{creationDate})
        </insert>
    
        <!-- 修改供应商信息 -->
        <update id="modify" parameterType="Provider">
            update smbms_provider set proCode=#{proCode},proName=#{proName},proDesc=#{proDesc},
                        proContact=#{proContact},proPhone=#{proPhone},proAddress=#{proAddress},
                        proFax=#{proFax},modifyBy=#{modifyBy},modifyDate=#{modifyDate}
                     where id = #{id}
        </update>
    
        <!-- 根据供应商ID删除供应商信息 -->
        <delete id="deleteProviderById" parameterType="int">
            delete from smbms_provider where id = #{id}
        </delete>
    
    </mapper>

     

  • 相关阅读:
    创建对象_原型(Prototype)模式_深拷贝
    创建对象_工厂方法(Factory Method)模式 与 静态工厂方法
    创建对象——单例(Singleton)模式
    模板方法模式
    移除HTML5 input在type="number"时的上下小箭头
    颜色名列表
    什么是盒模型?
    JQuery中$.ajax()方法参数详解
    zsh下docker命令tab补全方法
    ubuntu14.04 搭建gitlab服务
  • 原文地址:https://www.cnblogs.com/yanglanlan/p/11733730.html
Copyright © 2020-2023  润新知