Commit 2fa9545bbeaa0faad72f92c398386dba7b55c035
1 parent
98dcb0ed24
Exists in
master
and in
8 other branches
孕妇分娩后 变成产妇
Showing 2 changed files with 75 additions and 33 deletions
platform-common/src/main/java/com/lyms/platform/common/dao/operator/MongoCondition.java
View file @
2fa9545
... | ... | @@ -5,15 +5,15 @@ |
5 | 5 | import java.util.Collection; |
6 | 6 | |
7 | 7 | /** |
8 | - * 封装mongo 条件属性的操作 对于模糊查询的时候 obj为一个正则表达式 如: <code> | |
9 | - * <ui> | |
10 | - * <li>1.MongoCondition.newInstance("name", "^小七测试",MongoOper.LIKE) '^小七测试' 查询名字为小七测试开头</li> | |
11 | - * <li>2.MongoCondition.newInstance("name", "小七测试$",MongoOper.LIKE) '小七测试$' 查询名字为小七测试结尾</li> | |
12 | - * </ui> | |
8 | + * 封装mongo 条件属性的操作 对于模糊查询的时候 obj为一个正则表达式 如: <code> | |
9 | + * <ui> | |
10 | + * <li>1.MongoCondition.newInstance("name", "^小七测试",MongoOper.LIKE) '^小七测试' 查询名字为小七测试开头</li> | |
11 | + * <li>2.MongoCondition.newInstance("name", "小七测试$",MongoOper.LIKE) '小七测试$' 查询名字为小七测试结尾</li> | |
12 | + * </ui> | |
13 | 13 | * </code> |
14 | - * | |
15 | - * @link MongoOper | |
14 | + * | |
16 | 15 | * @author Administrator |
16 | + * @link MongoOper | |
17 | 17 | */ |
18 | 18 | public class MongoCondition { |
19 | 19 | |
... | ... | @@ -29,13 +29,10 @@ |
29 | 29 | |
30 | 30 | /** |
31 | 31 | * 创建一个实例 |
32 | - * | |
33 | - * @param key | |
34 | - * 字段名 | |
35 | - * @param obj | |
36 | - * 值 | |
37 | - * @param oper | |
38 | - * 查询运算符 | |
32 | + * | |
33 | + * @param key 字段名 | |
34 | + * @param obj 值 | |
35 | + * @param oper 查询运算符 | |
39 | 36 | * @return |
40 | 37 | */ |
41 | 38 | public static MongoCondition newInstance(String key, Object obj, MongoOper oper) { |
42 | 39 | |
... | ... | @@ -53,19 +50,17 @@ |
53 | 50 | public MongoCondition() { |
54 | 51 | criteria = new Criteria(); |
55 | 52 | } |
53 | + | |
56 | 54 | public MongoCondition(Criteria c) { |
57 | 55 | criteria = c; |
58 | 56 | } |
59 | 57 | |
60 | 58 | /** |
61 | 59 | * and 条件查询 |
62 | - * | |
63 | - * @param key | |
64 | - * 数据库中的字段名 | |
65 | - * @param obj | |
66 | - * 值 | |
67 | - * @param oper | |
68 | - * 运算符 @link MongoOper | |
60 | + * | |
61 | + * @param key 数据库中的字段名 | |
62 | + * @param obj 值 | |
63 | + * @param oper 运算符 @link MongoOper | |
69 | 64 | * @return |
70 | 65 | */ |
71 | 66 | public MongoCondition and(String key, Object obj, MongoOper oper) { |
... | ... | @@ -81,7 +76,7 @@ |
81 | 76 | return this; |
82 | 77 | } |
83 | 78 | |
84 | - public MongoCondition all(Collection<?> o,String key) { | |
79 | + public MongoCondition all(Collection<?> o, String key) { | |
85 | 80 | if (criteria == null) { |
86 | 81 | criteria = Criteria.where(key); |
87 | 82 | set(MongoOper.ALL, o, criteria); |
88 | 83 | |
89 | 84 | |
... | ... | @@ -97,19 +92,19 @@ |
97 | 92 | |
98 | 93 | /** |
99 | 94 | * Query query = new Query(Criteria.where("b").elemMatch( Criteria.where("startDate").gte(date) .and("endDate").lte(date) ); |
100 | - * | |
95 | + * | |
101 | 96 | * @param c |
102 | 97 | * @return |
103 | 98 | */ |
104 | 99 | @SuppressWarnings("static-access") |
105 | - public MongoCondition elemMatch(String field,MongoCondition c) { | |
100 | + public MongoCondition elemMatch(String field, MongoCondition c) { | |
106 | 101 | criteria.where(field).elemMatch(c.criteria); |
107 | 102 | return this; |
108 | 103 | } |
109 | 104 | |
110 | 105 | /** |
111 | 106 | * Query query = new Query(Criteria.where("b").elemMatch( Criteria.where("startDate").gte(date) .and("endDate").lte(date) ); |
112 | - * | |
107 | + * | |
113 | 108 | * @param c |
114 | 109 | * @return |
115 | 110 | */ |
116 | 111 | |
... | ... | @@ -117,9 +112,10 @@ |
117 | 112 | criteria.elemMatch(c.criteria); |
118 | 113 | return this; |
119 | 114 | } |
115 | + | |
120 | 116 | /** |
121 | 117 | * 2个查询条件的交集 |
122 | - * | |
118 | + * | |
123 | 119 | * @param con |
124 | 120 | * @return |
125 | 121 | */ |
... | ... | @@ -131,7 +127,7 @@ |
131 | 127 | |
132 | 128 | /** |
133 | 129 | * 2个查询条件的并集 |
134 | - * | |
130 | + * | |
135 | 131 | * @param con |
136 | 132 | * @return |
137 | 133 | */ |
... | ... | @@ -169,7 +165,7 @@ |
169 | 165 | |
170 | 166 | /** |
171 | 167 | * 如果是模糊匹配,obj则为需要匹配的正则表达式 |
172 | - * | |
168 | + * | |
173 | 169 | * @param oper |
174 | 170 | * @param obj |
175 | 171 | * @param criteria |
176 | 172 | |
... | ... | @@ -185,12 +181,14 @@ |
185 | 181 | criteria.regex(String.valueOf(obj), "m"); |
186 | 182 | } else if (MongoOper.LT == oper) { |
187 | 183 | criteria.lt(obj); |
184 | + } else if (MongoOper.LTE == oper) { | |
185 | + criteria.lte(obj); | |
188 | 186 | } else if (MongoOper.NE == oper) { |
189 | 187 | criteria.ne(obj); |
190 | - }else if(MongoOper.ALL==oper){ | |
191 | - if(obj instanceof Collection){ | |
192 | - criteria.all((Collection)obj); | |
193 | - }else{ | |
188 | + } else if (MongoOper.ALL == oper) { | |
189 | + if (obj instanceof Collection) { | |
190 | + criteria.all((Collection) obj); | |
191 | + } else { | |
194 | 192 | criteria.all(obj); |
195 | 193 | } |
196 | 194 | } |
... | ... | @@ -198,7 +196,7 @@ |
198 | 196 | |
199 | 197 | /** |
200 | 198 | * 把当前条件转成查询对象 |
201 | - * | |
199 | + * | |
202 | 200 | * @return |
203 | 201 | */ |
204 | 202 | public MongoQuery toMongoQuery() { |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/GuideLineController.java
View file @
2fa9545
1 | +package com.lyms.platform.operate.web.controller; | |
2 | + | |
3 | +import com.lyms.platform.biz.service.GuidelinesService; | |
4 | +import com.lyms.platform.common.base.BaseController; | |
5 | +import com.lyms.platform.operate.web.request.GuideQuery; | |
6 | +import com.lyms.platform.pojo.Guidelines; | |
7 | +import com.lyms.platform.query.GuidelinesQuery; | |
8 | +import org.apache.commons.collections.CollectionUtils; | |
9 | +import org.springframework.beans.factory.annotation.Autowired; | |
10 | +import org.springframework.stereotype.Controller; | |
11 | +import org.springframework.web.bind.annotation.RequestMapping; | |
12 | +import org.springframework.web.bind.annotation.RequestMethod; | |
13 | +import org.springframework.web.bind.annotation.ResponseBody; | |
14 | + | |
15 | +import javax.validation.Valid; | |
16 | +import java.util.List; | |
17 | + | |
18 | +/** | |
19 | + * | |
20 | + * 指导意见 | |
21 | + * | |
22 | + * Created by Administrator on 2016/8/4 0004. | |
23 | + */ | |
24 | +@Controller | |
25 | +public class GuideLineController extends BaseController { | |
26 | + @Autowired | |
27 | + private GuidelinesService guidelinesService; | |
28 | + @ResponseBody | |
29 | + @RequestMapping(method = RequestMethod.GET,value = "/guide") | |
30 | + public String matchGuide(@Valid GuideQuery guideQuery){ | |
31 | + GuidelinesQuery guidelinesQuery=new GuidelinesQuery(); | |
32 | + guidelinesQuery.setType(guideQuery.getType()); | |
33 | + guidelinesQuery.setMaxStart(guideQuery.getNum()); | |
34 | + guidelinesQuery.setMinEnd(guideQuery.getNum()); | |
35 | + List<Guidelines> list = guidelinesService.queryGuidelines(guidelinesQuery); | |
36 | + StringBuilder stringBuilder=new StringBuilder(128); | |
37 | + if(CollectionUtils.isNotEmpty(list)){ | |
38 | + for(Guidelines guidelines:list){ | |
39 | + stringBuilder.append(guidelines.getCategory()).append(" ").append(guidelines.getContent()).append("\r\n"); | |
40 | + } | |
41 | + } | |
42 | + return stringBuilder.toString(); | |
43 | + } | |
44 | +} |