发表于: 2020-01-12 23:49:43

2 1222


今天完成的事情:


一直在修改  

同时查询作品集(oneworkName)状态(state)的语法 


一直没改好


搜索要求


数据库字段(下划线)

实体

private int id;

private String oneworkName;

private int state;

private int createAt;

private String createBy;

private int updateAt;

private String updateBy;


resultMap对应

<resultMap id="oneWorkMap" type="pojo.onework" >
   <id property="id" column="id" jdbcType="BIGINT"/>
   <result property="oneworkName" column="onework_name" jdbcType="VARCHAR" />
   <result property="state" column="state" jdbcType="TINYINT"/>
   <result property="createAt" column="create_at" jdbcType="BIGINT"/>
   <result property="createBy" column="create_by" jdbcType="VARCHAR"/>
   <result property="updateAt" column="update_at" jdbcType="BIGINT"/>
   <result property="updateBy" column="update_by" jdbcType="VARCHAR"/>
</resultMap>


mapper接口

service

mapper.xml

<!--    姓名和状态-->
<select id="search"  resultMap="oneWorkMap" >
   SELECT * FROM onework
<where>
   <if  test="oneworkName != null">
   onework_name = #{oneworkName}
</if>
   <if  test="state != null">
   AND state = #{state}
</if>
   </where>
   limit 0,10
</select>

controller

@ResponseBody
@RequestMapping(value = "/search",method = RequestMethod.GET)
public Map search(@RequestParam (value = "onework_name")String oneworkName,
                 @RequestParam (value = "state") int state) {

Map<String,Object> map = new HashMap<>();
   logger.info(oneworkName);
   logger.info(state);

   try {
List<onework> data = os.search(oneworkName,state);
       logger.info(data);
       map.put("data", data);
       map.put("code", 200);
       map.put("msg","查询成功");
       return map;
   }catch (Exception e) {

map.put("code",201);
       map.put("msg","查询失败");
       return map;
   }


postman测试


一直是到执行sql语句  201失败

debug    看到参数是传进去的


错误选项


org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.binding.BindingException: Parameter 'oneworkName' not found. Available parameters are [0, 1, param1, param2]


没有找到参数oneworkName


但我调试了很久都没用    不知道这个错误是哪部分出了问题


明天计划的事情:


改错误


完成其他部分代码



返回列表 返回列表
评论

    分享到