黑马十次方项目day02-06之查询热门企业

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_33229669/article/details/86179564

Controller层

在com.tensquare.recruit.controller.EnterpriseController中写如下的方法
视频中查询热门企业,直接传递的参数为1,写死的, 个人认为不太好,改为了静态常量.这样一处修改,就可以了.
如果直接在方法内部写死, 可能要改很多的地方

private final static String HOTENTERPRISE= "1";

    /**
     * 方法名: hotList
     * 方法描述: 查询所有的热门企业
     * 修改日期: 2019/1/9 20:58
      * @param
     * @return entity.Result
     * @author taohongchao
     * @throws
     */
    @RequestMapping(value = "/search/hotlist",method = RequestMethod.GET)
	public Result hotList(){
        List<Enterprise> list = enterpriseService.hotList(HOTENTERPRISE);
        return new Result(true, StatusCode.OK, "查询成功", list);
    }

service

com.tensquare.recruit.service.EnterpriseService


public List<Enterprise> hotList(String ishot){
	    return enterpriseDao.findByIshot(ishot) ;
    }

dao

com.tensquare.recruit.dao.EnterpriseDao

 /**
     * 方法名: findByIshot
     * 方法描述: 查找热门企业  findByIshot 相当于sql  where isHot=?
     * 修改日期: 2019/1/9 20:48
      * @param ishot
     * @return java.util.List<com.tensquare.recruit.pojo.Enterprise>
     * @author taohongchao
     * @throws
     */
    public List<Enterprise> findByIshot(String ishot);

测试

数据库中信息如下
id为1 的是热门企业

启动项目进行发送请求
响应的数据如下

猜你喜欢

转载自blog.csdn.net/qq_33229669/article/details/86179564