<output id="qn6qe"></output>

    1. <output id="qn6qe"><tt id="qn6qe"></tt></output>
    2. <strike id="qn6qe"></strike>

      亚洲 日本 欧洲 欧美 视频,日韩中文字幕有码av,一本一道av中文字幕无码,国产线播放免费人成视频播放,人妻少妇偷人无码视频,日夜啪啪一区二区三区,国产尤物精品自在拍视频首页,久热这里只有精品12

      1.14

      回顧javaweb敲代碼
      package com.it.mapper;

      import com.it.pojo.Brand;
      import org.apache.ibatis.annotations.Param;

      import java.util.List;
      import java.util.Map;

      public interface BrandMapper {

      //查詢所有
      List selectAll ();

      //查看詳情 根據id查詢信息
      Brand selectById(int id);

      /*條件查詢
      參數接受:
      1.散裝參數 :如果有多個參數 需要@Param("SQL參數占位符名稱")
      2.對象參數
      3.map集合參數
      */
      List selectByConditon(@Param("status") int status,@Param("companyName")String companyName,@Param("brandName") String brandName);

      /* List selectByCondition(Brand brand);

      List selectByCondition(Map map);*/

      //添加
      void add(Brand brand);

      //修改全部字段
      void update(Brand brand);

      //刪除一條數據
      void deleteById(int id);
      }

      package com.it.pojo;

      public class Brand {
      // id 主鍵
      private Integer id;
      // 品牌名稱
      private String brandName;
      // 企業名稱
      private String companyName;
      // 排序字段
      private Integer ordered;
      // 描述信息
      private String description;
      private Integer status;

      public Integer getId() {
          return id;
      }
      
      public void setId(Integer id) {
          this.id = id;
      }
      
      public String getBrandName() {
          return brandName;
      }
      
      public void setBrandName(String brandName) {
          this.brandName = brandName;
      }
      
      public String getCompanyName() {
          return companyName;
      }
      
      public void setCompanyName(String companyName) {
          this.companyName = companyName;
      }
      
      public Integer getOrdered() {
          return ordered;
      }
      
      public void setOrdered(Integer ordered) {
          this.ordered = ordered;
      }
      
      public String getDescription() {
          return description;
      }
      
      public void setDescription(String description) {
          this.description = description;
      }
      
      public Integer getStatus() {
          return status;
      }
      
      public void setStatus(Integer status) {
          this.status = status;
      }
      
      @Override
      public String toString() {
          return "Brand{" +
                  "id=" + id +
                  ", brandName='" + brandName + '\'' +
                  ", companyName='" + companyName + '\'' +
                  ", ordered=" + ordered +
                  ", description='" + description + '\'' +
                  ", status=" + status +
                  '}';
      }
      

      }

      <!--當數據庫表的字段名稱 與 實體類的屬性名稱不一樣 則不能自動封裝數據
      

      起別名 as
      特殊字符處理 sql語句 <號 不可用 需要CDATA區
      edg:
      -->

      <select id="selectAll" resultType="brand">
          select id, brand_name as brandName, company_name as companyName, ordered, description, status
          from tb_brand ;
      </select>
      
      <select id="selectById" resultType="Brand">
          select *
          from tb_brand where id = #{id};
      </select>
      
      <!--條件查詢-->
      <select id="selectByConditon" resultType="brand">
          select id, brand_name as brandName, company_name as companyName, ordered, description, status
          from tb_brand
          where status = #{status}
          and company_name like #{companyName}
          and brand_name like #{brandName};
      </select>
      
      <!--添加-->
      <!--當id為主鍵時 需要 useGeneratedKeys="true" keyProperty="id"-->
      <insert id="add" useGeneratedKeys="true" keyProperty="id">
          insert into tb_brand (brand_name, company_name, ordered, description, status)
          values (#{brandName},#{companyName},#{ordered},#{description},#{status});
      </insert>
      
      <!--修改-->
      <update id="update">
          update tb_brand
          set brand_name = #{brandName},
              company_name = #{companyName},
              ordered = #{ordered},
              description = #{description},
              status = #{status}
              where id = #{id} ;
      </update>
      
      <!--刪除一條數據 -->
      <delete id="deleteById">
          delete
          from tb_brand
          where id = #{id};
      </delete>
      

      package com.it.test;

      import com.it.mapper.BrandMapper;
      import com.it.pojo.Brand;
      import org.apache.ibatis.io.Resources;
      import org.apache.ibatis.session.SqlSession;
      import org.apache.ibatis.session.SqlSessionFactory;
      import org.apache.ibatis.session.SqlSessionFactoryBuilder;
      import org.junit.Test;

      import java.io.IOException;
      import java.io.InputStream;
      import java.util.List;

      public class BrandMapperTest {

      //查詢所有
      @Test
      public  void testSelectAll() throws IOException {
          //1.加載mybatis核心配置文件,獲取SqlSessionFactory
          String resource = "mybatis-config.xml";
          InputStream inputStream = Resources.getResourceAsStream(resource);
          SqlSessionFactory sqlSessionFactory = new SqlSessionFactoryBuilder().build(inputStream);
      
          //2.獲取SqlSession對象,用他來執行sql語句
          SqlSession sqlSession = sqlSessionFactory.openSession();
      
          //3.執行sql語句
          //獲取BrandMapper接口的代理對象
          BrandMapper brandMapper = sqlSession.getMapper(BrandMapper.class);
      
          //執行方法
          List<Brand> brands = brandMapper.selectAll();
          System.out.println(brands);
      
          //4.釋放資源
          sqlSession.close();
      }
      
      
      //查看詳情 根據id查詢信息
      @Test
      public  void testSelectById() throws IOException {
          //接受參數
          int id = 1;
      
          //1.加載mybatis核心配置文件,獲取SqlSessionFactory
          String resource = "mybatis-config.xml";
          InputStream inputStream = Resources.getResourceAsStream(resource);
          SqlSessionFactory sqlSessionFactory = new SqlSessionFactoryBuilder().build(inputStream);
      
          //2.獲取SqlSession對象,用他來執行sql語句
          SqlSession sqlSession = sqlSessionFactory.openSession();
      
          //3.執行sql語句
          //獲取BrandMapper接口的代理對象
          BrandMapper brandMapper = sqlSession.getMapper(BrandMapper.class);
          //執行方法
          Brand brand = brandMapper.selectById(id);
          System.out.println(brand);
      
          //4.釋放資源
          sqlSession.close();
      }
      
      //多條件查詢
      @Test
      public  void testSelectByCondition() throws IOException {
          //接受參數
          int status = 1;
          String companyName = "華為";
          String brandName = "華為";
      
          //處理參數
          companyName = "%" + companyName +"%";
          brandName = "%" + brandName +"%";
      
       /*封裝參數
         Brand brand = new Brand();
          brand.setStatus(status);
          brand.setCompanyName(companyName);
          brand.setBrandName(brandName);*/
      
         /*map集合參數
          Map map = new HashMap();
          map.put("status",status);
          map.put("companyName",companyName);
          map.put("brandName",brandName)
      

      */
      //1.加載mybatis核心配置文件,獲取SqlSessionFactory
      String resource = "mybatis-config.xml";
      InputStream inputStream = Resources.getResourceAsStream(resource);
      SqlSessionFactory sqlSessionFactory = new SqlSessionFactoryBuilder().build(inputStream);

          //2.獲取SqlSession對象,用他來執行sql語句
          SqlSession sqlSession = sqlSessionFactory.openSession();
      
          //3.執行sql語句
          //獲取BrandMapper接口的代理對象
          BrandMapper brandMapper = sqlSession.getMapper(BrandMapper.class);
           //執行方法
          List<Brand> brands = brandMapper.selectByConditon(status, companyName, brandName);
          //List<Brand> brands = brandMapper.selectByConditon(brand);
         //List<Brand> brands = brandMapper.selectByConditon(map);
      
          System.out.println(brands);
      
          //4.釋放資源
          sqlSession.close();
      }
      
      //添加
      @Test
      public  void testAdd() throws IOException {
          //接受參數
          int status = 1;
          String companyName = "111";
          String brandName = "11";
          String description ="aaa";
          int ordered = 100;
      
       //封裝對象
         Brand brand = new Brand();
          brand.setStatus(status);
          brand.setCompanyName(companyName);
          brand.setBrandName(brandName);
          brand.setDescription(description);
          brand.setOrdered(ordered);
      
          //1.加載mybatis核心配置文件,獲取SqlSessionFactory
          String resource = "mybatis-config.xml";
          InputStream inputStream = Resources.getResourceAsStream(resource);
          SqlSessionFactory sqlSessionFactory = new SqlSessionFactoryBuilder().build(inputStream);
      
          //2.獲取SqlSession對象,用他來執行sql語句
          SqlSession sqlSession = sqlSessionFactory.openSession();
      
          //3.執行sql語句
          //獲取BrandMapper接口的代理對象
          BrandMapper brandMapper = sqlSession.getMapper(BrandMapper.class);
      
          //執行方法
          brandMapper.add(brand);
          int id = brand.getId();
          System.out.println(id);
          //提交事務
          sqlSession.commit();
      
          //4.釋放資源
          sqlSession.close();
      }
      
      //修改
      @Test
      public  void testUpdate() throws IOException {
          //接受參數
          int status = 1;
          String companyName = "111";
          String brandName = "11";
          String description ="aaa";
          int ordered = 100;
          int id = 1;
          //封裝對象
          Brand brand = new Brand();
          brand.setStatus(status);
          brand.setCompanyName(companyName);
          brand.setBrandName(brandName);
          brand.setDescription(description);
          brand.setOrdered(ordered);
          brand.setId(id);
      
          //1.加載mybatis核心配置文件,獲取SqlSessionFactory
          String resource = "mybatis-config.xml";
          InputStream inputStream = Resources.getResourceAsStream(resource);
          SqlSessionFactory sqlSessionFactory = new SqlSessionFactoryBuilder().build(inputStream);
      
          //2.獲取SqlSession對象,用他來執行sql語句
          SqlSession sqlSession = sqlSessionFactory.openSession();
      
          //3.執行sql語句
          //獲取BrandMapper接口的代理對象
          BrandMapper brandMapper = sqlSession.getMapper(BrandMapper.class);
      
          //執行方法
          brandMapper.update(brand);
          //提交事務
          sqlSession.commit();
      
          //4.釋放資源
          sqlSession.close();
      }
      
      //刪除
      @Test
      public  void testDeleteById() throws IOException {
          //接受參數
          int id = 6;
      
          //1.加載mybatis核心配置文件,獲取SqlSessionFactory
          String resource = "mybatis-config.xml";
          InputStream inputStream = Resources.getResourceAsStream(resource);
          SqlSessionFactory sqlSessionFactory = new SqlSessionFactoryBuilder().build(inputStream);
      
          //2.獲取SqlSession對象,用他來執行sql語句
          SqlSession sqlSession = sqlSessionFactory.openSession();
      
          //3.執行sql語句
          //獲取BrandMapper接口的代理對象
          BrandMapper brandMapper = sqlSession.getMapper(BrandMapper.class);
      
          //執行方法
          brandMapper.deleteById(id);
          //提交事務
          sqlSession.commit();
      
          //4.釋放資源
          sqlSession.close();
      }
      

      }

      posted @ 2025-01-14 17:43  霸王雞  閱讀(38)  評論(0)    收藏  舉報
      主站蜘蛛池模板: 色一情一乱一区二区三区码| 欧美日韩综合网| 高中生粉嫩无套第一次| 人人入人人爱| 天啦噜国产精品亚洲精品| 国产精品福利自产拍在线观看 | 国产成人精品亚洲资源| 久久精品国产亚洲精品色婷婷| 韩国无码AV片午夜福利| 人妻无码中文字幕| 少妇高潮水多太爽了动态图| 精品少妇后入一区二区三区| 少妇粗大进出白浆嘿嘿视频 | 喷潮出白浆视频在线观看| 仪征市| 在线观看中文字幕码国产| 亚州中文字幕一区二区| 国产成人啪精品午夜网站| 国产在线观看免费观看| 国产精品黄色一区二区三区| 国产精品XXXX国产喷水| 人妻中文字幕亚洲一区| 亚洲欧洲日产国码久在线| 久久精品国产一区二区三区不卡| 色偷偷www.8888在线观看| 国产熟妇另类久久久久久| 欧美黑人性暴力猛交在线视频 | 欧美另类videossexo高潮| 亚洲人成亚洲人成在线观看| 一本一道av中文字幕无码| 亚洲香蕉av一区二区蜜桃 | 亚洲国产成人精品激情姿源| 国产一区二区高清不卡| 无码人妻精品一区二区三区东京热| 少妇人妻真实偷人精品| 国产二区三区不卡免费| 中文字幕色偷偷人妻久久| 无码精品人妻一区二区三区中| 亚洲人成网网址在线看| 西乌| 亚洲AV成人无码久久精品四虎|