发表于: 2017-06-29 23:45:59

4 1187


今天完成的事:

1、将昨天评审不合适的地方改掉了

        1》找职位页面的接口改成了多个(之前在一个接口返回所有的数据)

       

找职位

         侧边栏点击关键词搜索(调用职位搜索接口

         公司搜索框(调用公司搜索接口

         Banner图调用统一接口                                              /a/article/search

8个推荐职位(使用推荐职位页的搜索接口

8个最新职位(使用最新职位页的搜索接口

GET           /a/company/images

10个普通公司的图标

Select id from company

where approved=0

and freezed =0

order by releaseAt limit 0,10;

1张最新认证公司的行业图

Select a.id from article a,company c

where a.industry=c.industry                              //连表(公司表和article表)

and c.approved=1                                                 //公司认证状态

order by c.releaseAt limit 0,1;                                     //公司发布时间倒序(最新)

 

  GET           /a/approved/company

4个最新发布职位的认证的公司(发布时间倒序)

Select c.id from company c,profession p

where c.id=p.cid                                                    //连表(公司表和职位表)

and p.status=1                                                      //职位是否上线

and c.approved=1                                                 //公司认证状态

order by p.releasedAt desc limit 0,4;       //职位发布时间倒序(最新)取4

        2》将职位列表页的接口,返回数据后台封装的数据结构变了下

       

搜索职位页

GET           /a/profession/search

 

搜索语句

Select p.id from profession p,company c,professionLabel l   //连表(职位,公司,职位标签

where p.cid=c.id p.id=l.pid

and p.name like ‘%keyword%’ or l.content like ‘%keyword%’         //

and c.industry in (parm1,parm2.parm3…)                                            //行业

and p.workexp in (parm1,parm2,parm3…)                                           //工作经验

and p.salary in (parm1,parm2…)                                                             //薪资水平

and p.status=1                                                                                                      //职位状态(上线)

and p.releasedAt>时间戳                                                                       //发布时间

limit ?,?     limit (page-1)*size,size                                                   //分页

 

后台逻辑

1、  通过搜索语句得到职位的列表(10条)pidList

2、  通过pidList查询职位对象列表PobjectList

3、  遍历职位PobjectList取出公司ID列表并去重得到cidList

or/写一条SQL语句通过职位ids查询公司ids

select distinct cid from profession where id =#{pidList}

4、  通过公司cidList取出公司对象列表CobjectList

5、  遍历公司对象CobjectList将取出的公司对象列表依次添加到CompanyMap集合里

其中key=公司idid,value=公司对象:Object

6、  遍历公司ID列表

 

List<Object> tagsArray=new ArrayList<>();

List<Long> tagIds;

Map<Long,Object> tagMap=new HashMap<>();

Long cid;

Iterator id=cidList.iterator();

 while (id.hasNext()){

     cid= (Long) id.next();

 

//通过公司ID获取该公司每个标签对应的自增ID

tagIds=service.getTagsIdsBycid(cid);

select id from professionLabel where cid=#{cid}

//通过标签ids获取标签Object列表

tagsArray=service.getObjectsByIds(tagIds);

//将公司ID和标签对象列表存在map里,

其中key=公司IDvalue=标签对象

 tagMap.put(cid,tagsArray);

 

    }

将第256步得到

职位列表PObjectList,公司companyMap,和标签tagsMap作为数据data返回前端

         疑问?这里是用map好还是用一个class来封装好

明天计划的事:还有些东西明天整完后,申请继续评审

遇到的问题:自己的思维一直有一个误区:一直认为接口,就是页面的URL,所以一直认为,写个接口就应该返回该页面的所有数据。

收获:嗯,说不出来啥

总结:今天搞得有点晚。对于搜索职位页的后台逻辑,思路不明确(对于使用dal框架,代码规则不清楚)


返回列表 返回列表
评论

    分享到