Parcourir la Source

手机端公告搜索

zhuhaiwen 3 ans auparavant
Parent
commit
78f5b33aaf

+ 20 - 4
oa-app/src/main/java/com/css/oa/exam/announce/bean/AnnoType.java

@ -2,12 +2,28 @@ package com.css.oa.exam.announce.bean;
2 2
3 3
public class AnnoType {
4 4
5
    public static int IMPORTANT = 1;
5
    public static final int IMPORTANT = 1;
6 6
7
    public static int EXAM_ANNO = 2;
7
    public static final int EXAM_ANNO = 2;
8 8
9
    public static int QUESTION = 3;
9
    public static final int QUESTION = 3;
10 10
11
    public static int NOTICE = 4;
11
    public static final int NOTICE = 4;
12
13
    public static boolean contains(int type) {
14
        boolean isContains = false;
15
        switch (type){
16
            case IMPORTANT:
17
            case EXAM_ANNO:
18
            case QUESTION:
19
            case NOTICE:
20
                isContains = true;
21
                break;
22
            default:
23
                break;
24
25
        }
26
        return isContains;
27
    }
12 28
13 29
}

+ 10 - 0
oa-app/src/main/java/com/css/oa/exam/announce/bean/SearchReq.java

@ -0,0 +1,10 @@
1
package com.css.oa.exam.announce.bean;
2
3
public class SearchReq {
4
5
    //关键字
6
    public String key;
7
    //公告类型
8
    public int type;
9
10
}

+ 15 - 0
oa-app/src/main/java/com/css/oa/exam/announce/controller/AnnounceController.java

@ -1,5 +1,6 @@
1 1
package com.css.oa.exam.announce.controller;
2 2
3
import com.css.oa.exam.announce.bean.SearchReq;
3 4
import com.css.oa.exam.base.BaseController;
4 5
import com.css.oa.exam.announce.bean.AnnoQueryReq;
5 6
import com.css.oa.exam.announce.repository.Announce;
@ -108,4 +109,18 @@ public class AnnounceController extends BaseController {
108 109
        return result;
109 110
    }
110 111
112
    @ApiOperation(value = "手机端搜索")
113
    @PostMapping("/search")
114
    public Result search(@RequestBody SearchReq req) {
115
        Result<Map> result;
116
        try {
117
            Map map = mService.search(req);
118
            result = setResult("res", map);
119
        } catch (Exception e) {
120
            result = setErr(e.getMessage());
121
            e.printStackTrace();
122
        }
123
        return result;
124
    }
125
111 126
}

+ 6 - 0
oa-app/src/main/java/com/css/oa/exam/announce/repository/IAnnounceRepository.java

@ -19,4 +19,10 @@ public interface IAnnounceRepository extends JpaRepository<Announce, String>, Jp
19 19
    @Query("delete from Announce an where an.uuid in :ids")
20 20
    void deleteRealByIds(@Param("ids") List<String> ids);
21 21
22
    @Modifying
23
    @Transactional
24
    @Query("select annou from Announce annou where annou.type = :type and (annou.title like :key or annou.content like :key)")
25
    List<Announce> findByKey(int type, String key);
26
27
22 28
}

+ 15 - 1
oa-app/src/main/java/com/css/oa/exam/announce/service/AnnounceService.java

@ -1,5 +1,7 @@
1 1
package com.css.oa.exam.announce.service;
2 2
3
import com.css.oa.exam.announce.bean.AnnoType;
4
import com.css.oa.exam.announce.bean.SearchReq;
3 5
import com.css.oa.exam.base.BaseService;
4 6
import com.css.oa.exam.announce.bean.AnnoQueryReq;
5 7
import com.css.oa.exam.announce.repository.Announce;
@ -76,7 +78,7 @@ public class AnnounceService extends BaseService implements IAnnounceService {
76 78
                    String pattern = "%" + req.condition.title + "%";
77 79
                    predicateList.add(criteriaBuilder.like(root.get("title").as(String.class), pattern));//模糊查询
78 80
                }
79
                if(!TextUtils.isEmpty(req.condition.start_time) && !TextUtils.isEmpty(req.condition.end_time)){
81
                if (!TextUtils.isEmpty(req.condition.start_time) && !TextUtils.isEmpty(req.condition.end_time)) {
80 82
                    Date startDate = DateUtils.stringToDate(req.condition.start_time, "yyyy-MM-dd");
81 83
                    Date endDate = DateUtils.stringToDate(req.condition.end_time, "yyyy-MM-dd");
82 84
                    predicateList.add(criteriaBuilder.between(root.get("publish_time").as(Date.class), startDate, endDate));
@ -110,5 +112,17 @@ public class AnnounceService extends BaseService implements IAnnounceService {
110 112
        repository.deleteRealByIds(ids);
111 113
    }
112 114
115
    @Override
116
    public Map search(SearchReq req) throws Exception {
117
        if (!AnnoType.contains(req.type)) {
118
            throw new Exception("req.type 参数错误");
119
        }
120
        List<Announce> list = repository.findByKey(req.type, req.key);
121
        Map map = new LinkedHashMap();
122
        map.put("total", list.size());
123
        map.put("list", list);
124
        return map;
125
    }
126
113 127
114 128
}

+ 3 - 0
oa-app/src/main/java/com/css/oa/exam/announce/service/IAnnounceService.java

@ -1,6 +1,7 @@
1 1
package com.css.oa.exam.announce.service;
2 2
3 3
import com.css.oa.exam.announce.bean.AnnoQueryReq;
4
import com.css.oa.exam.announce.bean.SearchReq;
4 5
import com.css.oa.exam.announce.repository.Announce;
5 6
6 7
import java.util.List;
@ -16,4 +17,6 @@ public interface IAnnounceService {
16 17
17 18
    void delete(List<String> ids);
18 19
20
    Map search(SearchReq req) throws Exception;
21
19 22
}

+ 1 - 1
oa-app/src/main/java/com/css/oa/exam/score/bean/MyScoreWrap.java

@ -19,5 +19,5 @@ public class MyScoreWrap {
19 19
20 20
    public int score;
21 21
    public String certi_state; //合格状态
22
22
    public String exam_id;
23 23
}