|
|
@@ -5,6 +5,8 @@ import org.apache.commons.logging.Log;
|
|
|
import org.apache.commons.logging.LogFactory;
|
|
|
import org.linlinjava.litemall.core.util.JacksonUtil;
|
|
|
import org.linlinjava.litemall.core.util.ResponseUtil;
|
|
|
+import org.linlinjava.litemall.core.validator.Order;
|
|
|
+import org.linlinjava.litemall.core.validator.Sort;
|
|
|
import org.linlinjava.litemall.db.domain.LitemallCollect;
|
|
|
import org.linlinjava.litemall.db.domain.LitemallGoods;
|
|
|
import org.linlinjava.litemall.db.service.LitemallCollectService;
|
|
|
@@ -47,14 +49,14 @@ public class WxCollectController {
|
|
|
public Object list(@LoginUser Integer userId,
|
|
|
@NotNull Byte type,
|
|
|
@RequestParam(defaultValue = "1") Integer page,
|
|
|
- @RequestParam(defaultValue = "10") Integer limit) {
|
|
|
+ @RequestParam(defaultValue = "10") Integer limit,
|
|
|
+ @Sort @RequestParam(defaultValue = "add_time") String sort,
|
|
|
+ @Order @RequestParam(defaultValue = "desc") String order) {
|
|
|
if (userId == null) {
|
|
|
return ResponseUtil.unlogin();
|
|
|
}
|
|
|
|
|
|
- List<LitemallCollect> collectList = collectService.queryByType(userId, type, page, limit);
|
|
|
- int count = collectService.countByType(userId, type);
|
|
|
- int totalPages = (int) Math.ceil((double) count / limit);
|
|
|
+ List<LitemallCollect> collectList = collectService.queryByType(userId, type, page, limit, sort, order);
|
|
|
|
|
|
List<Object> collects = new ArrayList<>(collectList.size());
|
|
|
for (LitemallCollect collect : collectList) {
|
|
|
@@ -72,10 +74,7 @@ public class WxCollectController {
|
|
|
collects.add(c);
|
|
|
}
|
|
|
|
|
|
- Map<String, Object> result = new HashMap<String, Object>();
|
|
|
- result.put("collectList", collects);
|
|
|
- result.put("totalPages", totalPages);
|
|
|
- return ResponseUtil.ok(result);
|
|
|
+ return ResponseUtil.okList(collects, collectList);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -101,12 +100,9 @@ public class WxCollectController {
|
|
|
|
|
|
LitemallCollect collect = collectService.queryByTypeAndValue(userId, type, valueId);
|
|
|
|
|
|
- String handleType = null;
|
|
|
if (collect != null) {
|
|
|
- handleType = "delete";
|
|
|
collectService.deleteById(collect.getId());
|
|
|
} else {
|
|
|
- handleType = "add";
|
|
|
collect = new LitemallCollect();
|
|
|
collect.setUserId(userId);
|
|
|
collect.setValueId(valueId);
|
|
|
@@ -114,8 +110,6 @@ public class WxCollectController {
|
|
|
collectService.add(collect);
|
|
|
}
|
|
|
|
|
|
- Map<String, Object> data = new HashMap<String, Object>();
|
|
|
- data.put("type", handleType);
|
|
|
- return ResponseUtil.ok(data);
|
|
|
+ return ResponseUtil.ok();
|
|
|
}
|
|
|
}
|