发表于: 2019-11-02 22:12:01

1 975


今天完成的事情:

补充接口的一些功能

1.搜索返回对应图片信息

WorksDao.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="com.dao.WorksDao">
 <resultMap id="BaseResultMap" type="com.pojo.Works">
   <id column="works_id" jdbcType="INTEGER" property="worksId" />
   <result column="works_name" jdbcType="VARCHAR" property="worksName" />
   <result column="works_url" jdbcType="VARCHAR" property="worksUrl" />
   <result column="works_video" jdbcType="VARCHAR" property="worksVideo" />
   <result column="workshop" jdbcType="VARCHAR" property="workshop" />
   <result column="works_introduce" jdbcType="VARCHAR" property="worksIntroduce" />
   <result column="works_stayus" jdbcType="INTEGER" property="worksStayus" />
   <result column="creat_at" jdbcType="BIGINT" property="creatAt" />
   <result column="creat_by" jdbcType="VARCHAR" property="creatBy" />
   <result column="update_at" jdbcType="BIGINT" property="updateAt" />
   <result column="update_by" jdbcType="VARCHAR" property="updateBy" />
   <result column="putaway_at" jdbcType="BIGINT" property="putawayAt" />
   <result column="putaway_by" jdbcType="VARCHAR" property="putawayBy" />
   <result column="first_id" jdbcType="INTEGER" property="firstId" />
   <result column="second_id" jdbcType="INTEGER" property="secondId" />
 </resultMap>
 <sql id="Base_Column_List">
   works_id, works_name, works_url, works_video, workshop, works_introduce, works_stayus,
creat_at, creat_by, update_at, update_by, putaway_at, putaway_by, first_id, second_id
</sql>
 <!--输入搜索-->
 <!--得到所有的作品名称-->
 <select id="selectName" resultType="String">
select works_name from works
</select>

 <!--通过作品名,得到需要返回的作品表的内容-->
 <select id="selectWorksByName" resultMap="BaseResultMap" parameterType="String">
   select
<include refid="Base_Column_List" />
   from works
where works_name = #{worksName,jdbcType=INTEGER}
</select>

 <!--通过作品简介,得到需要返回的作品表的内容-->
 <select id="selectWorksByIntroduce" resultMap="BaseResultMap" parameterType="String">
   select
<include refid="Base_Column_List" />
   from works
where works_introduce LIKE #{worksItroduce,jdbcType=INTEGER}
</select>
</mapper>

postman

输入标题名

输入简介中包含的内容

2.根据一级导航栏返回对应的二级导航栏内容及作品内容

使用连表查询三个表

SearchDao.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="com.dao.SearchDao">
   <resultMap id="BaseResultMap" type="com.pojo.Search">
       <id column="first_id" jdbcType="INTEGER" property="firstId" />
       <result column="first_name" jdbcType="VARCHAR" property="firstName" />
       <result column="second_name" jdbcType="VARCHAR" property="secondName" />
       <result column="works_id" jdbcType="VARCHAR" property="worksId" />
       <result column="works_name" jdbcType="VARCHAR" property="worksName" />
       <result column="works_url" jdbcType="VARCHAR" property="worksUrl" />
       <result column="works_video" jdbcType="VARCHAR" property="worksVideo" />
       <result column="workshop" jdbcType="VARCHAR" property="workshop" />
       <result column="works_introduce" jdbcType="VARCHAR" property="worksIntroduce" />
       <result column="works_stayus" jdbcType="INTEGER" property="worksStatus" />
   </resultMap>

   <select id="findByFirst" resultMap="BaseResultMap">
      SELECT f.first_id,f.first_name,s.second_name,w.works_id,w.works_name,w.works_url,w.works_video,w.workshop,w.works_introduce,w.works_introduce,w.works_stayus FROM first_bar f,second_bar s,works w
WHERE f.first_id = s.fir_id
AND f.first_id = w.first_id
AND w.second_id=s.second_id
AND f.first_id=2;
</select>

</mapper>

通过一级导航栏得到作品信息

postman

明天计划的事情:完成后续接口功能
遇到的问题:连表查询时一个字段名写错捣鼓了好久。。。近期出现的问题都是细节上的
收获:

学会关联查询三表


返回列表 返回列表
评论

    分享到