您当前的位置: 首页 > 

java持续实践

暂无认证

  • 2浏览

    0关注

    746博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

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

java持续实践 发布时间:2019-01-09 21:07:15 ,浏览量:2

文章目录
      • Controller层
      • service
      • dao
      • 测试

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 list = enterpriseService.hotList(HOTENTERPRISE);
        return new Result(true, StatusCode.OK, "查询成功", list);
    }

service

com.tensquare.recruit.service.EnterpriseService


public List 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
     * @author taohongchao
     * @throws
     */
    public List findByIshot(String ishot);

测试

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

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

关注
打赏
1658054974
查看更多评论
立即登录/注册

微信扫码登录

0.0355s