发表于: 2017-07-20 00:00:52

1 1109


今日完成:

萝卜多后端前台方案设计

明日计划:

后台方案


收获:

where 1=1  1= 0的作用

不使用where 1 = 1 

在多条件查询时如果查询条件都为false时,这时查不到数据并且会报错。

使用where 1 =1 

在多条件查询时如果查询条件都为false时,因为where 1 =1 是为true的语句,该条语句语法正确,所有可以查询到表中所有数据。

where 1 = 0 这个条件始终为false 结果不会返回任何数据,只有表结构。


sql语句in的用法 多项条件查询


首页模块:

首页Banner图

调用接口:GET /a/article{id}

按banner类型和状态查询,得到img和url

select img,url from article where type = 0 and status = 1

最新职位

调用接口:GET /a/profession/search

按上架状态,获取最新发布的职位的list 

select id from profession where status = 1 order by releaseAt DESC

得到一个ID集合,使用getObjectById方法获得所有对象属性,然后放到一个list集合

通过cid使用getObjectById 拿到公司logo,公司名字


点击职位名称跳转到职位介绍

调用接口:GET /a/profession/{id}

select from profession where name = ?


点击公司名称跳转到公司详情

调用接口:GET /a/company/{id}

select from company where name = ?


点击更多跳转到最新职位页面

调用接口:GET /a/profession/search

select id from profession where status = 1 order by releaseAt DESC 按发布时间倒序排

推荐职位

从推荐职位点击更多跳转到推荐职位搜索

调用接口:GET /a/profession/search

按上架状态,推荐状态 ,获取最新发布的职位的list 

select id from profession where status = 1 and recommend = 1 order by releaseAt DESC

得到一个ID集合,使用getObjectById方法获得所有对象属性,然后放到一个list集合

通过cid使用getObjectById 在公司表中拿到公司logo,公司名字

通过cid使用getObjectById 在公司标签表中拿到公司标签

最新职位

 从最新职位点击更多跳转到最新职位搜索

调用接口:GET /a/profession/search

按上架状态,获取最新发布的职位的list 

select id from profession where status = 1 order by releaseAt DESC

得到一个ID集合,使用getObjectById方法获得所有对象属性,然后放到一个list集合

通过cid使用getObjectById 在公司表中拿到公司logo,公司名字


找职位 

顶部搜索公司

输入公司名字模糊查询,并跳转到搜索公司页面

调用接口: /a/company/search

职位子分类

点击职位子分类,按分类标签跳转到搜索职位页面

调用接口: /a/profession/search


找职位Banner图

调用接口:GET /a/article{id}

按banner类型和状态查询,得到img和url

select img,url from article where type = 1 and status = 1

推荐职位

按上架状态,推荐状态 ,获取最新发布的职位的list 

调用接口 GET /a/profession/search

select id from profession where status = 1 and recommend = 1 order by releaseAt DESC

得到一个ID集合,使用getObjectById方法获得职位薪资和职位名字等所有对象属性,然后放到一个list集合

通过cid使用getObjectById 在公司表中拿到公司logo,公司名字


点击职位跳转到职位介绍

调用接口:GET /a/profession/{id}

select from profession where name = ?


点击查看更多跳转到推荐职位列表

调用接口:GET /a/profession/search

按上架状态,推荐状态 ,倒序排列,获取最新发布的职位的list 

select id from profession where status = 1 and recommend = 1 order by releaseAt DESC

推荐公司

展示普通公司

调用接口:GET /a/company/search

按未认证状态、获取最新录入的公司倒序排列

select id from company where approved = 0 order by createAt DESC

拿到普通公司,按录入时间倒序

2、展示一个最新推荐公司,背景为改行业大图

GET /a/company/{id}

拿到最新认证公司

select id from company where approved = 1 order by createAt DESC 

使用GET /a/article/{id}拿到行业大图





点击查看更多跳转到搜索公司页

调用接口:GET /a/company/search


点击公司进入公司详情

GET /a/company/{id}



最新发布职位的四个认证公司,按发布时间排序

GET /a/profession/search

select id from profession order by release_at DESC


通过职位表的getObjectById拿到cId

通过公司cId使用List<Long>定义一个变量,然后通过代码链接操作sql语句

select logo form company where id id(cId) = in(变量) order by update_at DESC



搜索公司页

GET /a/company/search

使用动态sql查询公司

如果关键字查不到的话,返回暂没搜索结果,并显示推荐公司

select id from company where approved = 1


公司详情

GET /a/company/search 


找精英

banner图

调用接口 GET /a/article/{id}


成功案例:


按认证公司最新发布的职位时间排序,认证公司不够,显示普通公司

1.调用接口GET /a/company/search

select id from company order by approved DESC, create_at DESC; 

按认证公司和发布时时间倒序排列

公司表添加发布时时间字段




更多合作公司:展示公司列表,按认证优先排序,其次是普通以创建时间排序

调用接口 GET /a/company/search


select id from company order by approved DESC, create_at DESC; 






遇到问题:

设计成功案例方案时,我们想的是先拿到认证公司和排序,再用去重sql语句去重,

这样就满足需求的最新发布职位的认证公司,认证公司不足的话用普通代替。

后来询问伟江师兄,发现这个方法不可以,因为公司框架的原因不支持去重的sql语句。





返回列表 返回列表
评论

    分享到