垃圾分类国际化逻辑移动到客户端完成

master
ZHD 5 years ago
parent 7619a31521
commit 460d84d5eb
  1. 3
      src/main/java/com/community/pocket/api/android/GarbageController.java
  2. 7
      src/main/java/com/community/pocket/entity/vo/android/GarbageSortingResponse.java
  3. 28
      src/main/java/com/community/pocket/repository/android/GarbageDao.java

@ -1,5 +1,6 @@
package com.community.pocket.api.android; package com.community.pocket.api.android;
import com.community.pocket.entity.po.android.Garbage;
import com.community.pocket.entity.po.android.GarbageWasteManage; import com.community.pocket.entity.po.android.GarbageWasteManage;
import com.community.pocket.entity.po.android.GarbageWastePrice; import com.community.pocket.entity.po.android.GarbageWastePrice;
import com.community.pocket.entity.vo.Result; import com.community.pocket.entity.vo.Result;
@ -27,7 +28,7 @@ public class GarbageController {
//检索垃圾 //检索垃圾
@GetMapping("/garbage/sorting") @GetMapping("/garbage/sorting")
public GarbageSortingResponse search(QueryGarbageForm garbageForm) { public GarbageSortingResponse search(QueryGarbageForm garbageForm) {
List<GarbageVo> garbageVoList = garbageDao.query(garbageForm); List<Garbage> garbageVoList = garbageDao.query(garbageForm);
GarbageSortingResponse response = new GarbageSortingResponse(Result.OK, GarbageSortingResponse.Msg.ok); GarbageSortingResponse response = new GarbageSortingResponse(Result.OK, GarbageSortingResponse.Msg.ok);
response.setGarbageSortings(garbageVoList); response.setGarbageSortings(garbageVoList);
return response; return response;

@ -1,5 +1,6 @@
package com.community.pocket.entity.vo.android; package com.community.pocket.entity.vo.android;
import com.community.pocket.entity.po.android.Garbage;
import com.community.pocket.entity.vo.Response; import com.community.pocket.entity.vo.Response;
import com.community.pocket.entity.vo.Result; import com.community.pocket.entity.vo.Result;
@ -9,17 +10,17 @@ import java.util.List;
* 垃圾分类信息 * 垃圾分类信息
*/ */
public class GarbageSortingResponse extends Response<GarbageSortingResponse.Msg> { public class GarbageSortingResponse extends Response<GarbageSortingResponse.Msg> {
private List<GarbageVo> garbageSortings; private List<Garbage> garbageSortings;
public GarbageSortingResponse(Result result, Msg message, Object... args) { public GarbageSortingResponse(Result result, Msg message, Object... args) {
super(result, message, args); super(result, message, args);
} }
public List<GarbageVo> getGarbageSortings() { public List<Garbage> getGarbageSortings() {
return garbageSortings; return garbageSortings;
} }
public void setGarbageSortings(List<GarbageVo> garbageSortings) { public void setGarbageSortings(List<Garbage> garbageSortings) {
this.garbageSortings = garbageSortings; this.garbageSortings = garbageSortings;
} }

@ -26,32 +26,8 @@ public class GarbageDao extends BaseDao<Garbage> {
private MessageService messageService; private MessageService messageService;
//查询垃圾分类信息 //查询垃圾分类信息
public List<GarbageVo> query(QueryGarbageForm garbageForm) { public List<Garbage> query(QueryGarbageForm garbageForm) {
List<GarbageVo> garbageVos = new ArrayList<>(); return mongoTemplate.find(new Query(Criteria.where("name").regex(Pattern.compile(".*" + garbageForm.getName() + ".*"))), entityClass());
List<Garbage> garbageList = mongoTemplate.find(new Query(Criteria.where("name").regex(Pattern.compile(".*" + garbageForm.getName() + ".*"))), entityClass());
for (Garbage garbage : garbageList) {
GarbageVo garbageVo = new GarbageVo();
garbageVo.setName(garbage.getName());
switch (garbage.getCategory()) {
case 1:
garbageVo.setSorting(messageService.getMessage(GarbageCateGory.type1));
break;
case 2:
garbageVo.setSorting(messageService.getMessage(GarbageCateGory.type2));
break;
case 4:
garbageVo.setSorting(messageService.getMessage(GarbageCateGory.type4));
break;
case 8:
garbageVo.setSorting(messageService.getMessage(GarbageCateGory.type8));
break;
case 16:
garbageVo.setSorting(messageService.getMessage(GarbageCateGory.type16));
break;
}
garbageVos.add(garbageVo);
}
return garbageVos;
} }
@Override @Override

Loading…
Cancel
Save