refac[litemall-admin-api]: 对小商场后台服务的GET参数进行校验。
This commit is contained in:
@@ -9,8 +9,10 @@ import org.linlinjava.litemall.db.service.LitemallRegionService;
|
||||
import org.linlinjava.litemall.core.util.ResponseUtil;
|
||||
import org.linlinjava.litemall.wx.annotation.LoginUser;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
@@ -19,6 +21,7 @@ import java.util.Map;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/wx/address")
|
||||
@Validated
|
||||
public class WxAddressController {
|
||||
private final Log logger = LogFactory.getLog(WxAddressController.class);
|
||||
|
||||
@@ -93,13 +96,10 @@ public class WxAddressController {
|
||||
* 失败则 { errno: XXX, errmsg: XXX }
|
||||
*/
|
||||
@GetMapping("detail")
|
||||
public Object detail(@LoginUser Integer userId, Integer id) {
|
||||
public Object detail(@LoginUser Integer userId, @NotNull Integer id) {
|
||||
if(userId == null){
|
||||
return ResponseUtil.unlogin();
|
||||
}
|
||||
if(id == null){
|
||||
return ResponseUtil.badArgument();
|
||||
}
|
||||
|
||||
LitemallAddress address = addressService.findById(id);
|
||||
if(address == null){
|
||||
|
||||
@@ -20,6 +20,7 @@ import org.linlinjava.litemall.wx.service.CaptchaCodeManager;
|
||||
import org.linlinjava.litemall.wx.service.UserTokenManager;
|
||||
import org.linlinjava.litemall.wx.util.IpUtil;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
@@ -33,6 +34,7 @@ import java.util.Map;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/wx/auth")
|
||||
@Validated
|
||||
public class WxAuthController {
|
||||
private final Log logger = LogFactory.getLog(WxAuthController.class);
|
||||
|
||||
|
||||
@@ -6,17 +6,20 @@ import org.linlinjava.litemall.db.domain.LitemallBrand;
|
||||
import org.linlinjava.litemall.db.service.LitemallBrandService;
|
||||
import org.linlinjava.litemall.core.util.ResponseUtil;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/wx/brand")
|
||||
@Validated
|
||||
public class WxBrandController {
|
||||
private final Log logger = LogFactory.getLog(WxBrandController.class);
|
||||
|
||||
@@ -42,14 +45,14 @@ public class WxBrandController {
|
||||
* 失败则 { errno: XXX, errmsg: XXX }
|
||||
*/
|
||||
@GetMapping("list")
|
||||
public Object list(@RequestParam(value = "page", defaultValue = "1") Integer page,
|
||||
@RequestParam(value = "size", defaultValue = "10") Integer size) {
|
||||
public Object list(@RequestParam(defaultValue = "1") Integer page,
|
||||
@RequestParam(defaultValue = "10") Integer size) {
|
||||
|
||||
List<LitemallBrand> brandList = brandService.query(page, size);
|
||||
int total = brandService.queryTotalCount();
|
||||
int totalPages = (int) Math.ceil((double) total / size);
|
||||
|
||||
Map<String, Object> data = new HashMap();
|
||||
Map<String, Object> data = new HashMap<String, Object>();
|
||||
data.put("brandList", brandList);
|
||||
data.put("totalPages", totalPages);
|
||||
return ResponseUtil.ok(data);
|
||||
@@ -72,17 +75,13 @@ public class WxBrandController {
|
||||
* 失败则 { errno: XXX, errmsg: XXX }
|
||||
*/
|
||||
@GetMapping("detail")
|
||||
public Object detail(Integer id) {
|
||||
if(id == null){
|
||||
return ResponseUtil.badArgument();
|
||||
}
|
||||
|
||||
public Object detail(@NotNull Integer id) {
|
||||
LitemallBrand entity = brandService.findById(id);
|
||||
if(entity == null){
|
||||
return ResponseUtil.badArgumentValue();
|
||||
}
|
||||
|
||||
Map<String, Object> data = new HashMap();
|
||||
Map<String, Object> data = new HashMap<String, Object>();
|
||||
data.put("brand",entity);
|
||||
return ResponseUtil.ok(data);
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ import org.linlinjava.litemall.core.util.ResponseUtil;
|
||||
import org.linlinjava.litemall.wx.annotation.LoginUser;
|
||||
import org.linlinjava.litemall.core.system.SystemConfig;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
@@ -20,6 +21,7 @@ import java.util.Map;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/wx/cart")
|
||||
@Validated
|
||||
public class WxCartController {
|
||||
private final Log logger = LogFactory.getLog(WxCartController.class);
|
||||
|
||||
@@ -316,7 +318,7 @@ public class WxCartController {
|
||||
if(checkValue == null){
|
||||
return ResponseUtil.badArgument();
|
||||
}
|
||||
Boolean isChecked = ((checkValue.intValue()) == 1);
|
||||
Boolean isChecked = (checkValue == 1);
|
||||
|
||||
cartService.updateCheck(userId, productIds, isChecked);
|
||||
return index(userId);
|
||||
@@ -369,7 +371,7 @@ public class WxCartController {
|
||||
* }
|
||||
* 失败则 { errno: XXX, errmsg: XXX }
|
||||
*/
|
||||
@RequestMapping("goodscount")
|
||||
@GetMapping("goodscount")
|
||||
public Object goodscount(@LoginUser Integer userId) {
|
||||
if(userId == null){
|
||||
return ResponseUtil.ok(0);
|
||||
|
||||
@@ -4,17 +4,20 @@ import org.linlinjava.litemall.core.util.ResponseUtil;
|
||||
import org.linlinjava.litemall.db.domain.LitemallCategory;
|
||||
import org.linlinjava.litemall.db.service.LitemallCategoryService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/wx/catalog")
|
||||
@Validated
|
||||
public class WxCatalogController {
|
||||
@Autowired
|
||||
private LitemallCategoryService categoryService;
|
||||
@@ -43,8 +46,8 @@ public class WxCatalogController {
|
||||
*/
|
||||
@GetMapping("index")
|
||||
public Object index(Integer id,
|
||||
@RequestParam(value = "page", defaultValue = "1") Integer page,
|
||||
@RequestParam(value = "size", defaultValue = "10") Integer size) {
|
||||
@RequestParam(defaultValue = "1") Integer page,
|
||||
@RequestParam(defaultValue = "10") Integer size) {
|
||||
|
||||
// 所有一级分类目录
|
||||
List<LitemallCategory> l1CatList = categoryService.queryL1();
|
||||
@@ -63,7 +66,7 @@ public class WxCatalogController {
|
||||
currentSubCategory = categoryService.queryByPid(currentCategory.getId());
|
||||
}
|
||||
|
||||
Map<String, Object> data = new HashMap();
|
||||
Map<String, Object> data = new HashMap<String, Object>();
|
||||
data.put("categoryList", l1CatList);
|
||||
data.put("currentCategory", currentCategory);
|
||||
data.put("currentSubCategory", currentSubCategory);
|
||||
@@ -97,7 +100,7 @@ public class WxCatalogController {
|
||||
currentSubCategory = categoryService.queryByPid(currentCategory.getId());
|
||||
}
|
||||
|
||||
Map<String, Object> data = new HashMap();
|
||||
Map<String, Object> data = new HashMap<String, Object>();
|
||||
data.put("categoryList", l1CatList);
|
||||
data.put("allList", allList);
|
||||
data.put("currentCategory", currentCategory);
|
||||
@@ -123,16 +126,12 @@ public class WxCatalogController {
|
||||
* 失败则 { errno: XXX, errmsg: XXX }
|
||||
*/
|
||||
@GetMapping("current")
|
||||
public Object current(Integer id) {
|
||||
if (id == null) {
|
||||
return ResponseUtil.badArgument();
|
||||
}
|
||||
|
||||
public Object current(@NotNull Integer id) {
|
||||
// 当前分类
|
||||
LitemallCategory currentCategory = categoryService.findById(id);
|
||||
List<LitemallCategory> currentSubCategory = categoryService.queryByPid(currentCategory.getId());
|
||||
|
||||
Map<String, Object> data = new HashMap();
|
||||
Map<String, Object> data = new HashMap<String, Object>();
|
||||
data.put("currentCategory", currentCategory);
|
||||
data.put("currentSubCategory", currentSubCategory);
|
||||
return ResponseUtil.ok(data);
|
||||
|
||||
@@ -9,8 +9,10 @@ import org.linlinjava.litemall.core.util.JacksonUtil;
|
||||
import org.linlinjava.litemall.core.util.ResponseUtil;
|
||||
import org.linlinjava.litemall.wx.annotation.LoginUser;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
@@ -19,6 +21,7 @@ import java.util.Map;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/wx/collect")
|
||||
@Validated
|
||||
public class WxCollectController {
|
||||
@Autowired
|
||||
private LitemallCollectService collectService;
|
||||
@@ -47,15 +50,13 @@ public class WxCollectController {
|
||||
* 失败则 { errno: XXX, errmsg: XXX }
|
||||
*/
|
||||
@GetMapping("list")
|
||||
public Object list(@LoginUser Integer userId, Byte type,
|
||||
@RequestParam(value = "page", defaultValue = "1") Integer page,
|
||||
@RequestParam(value = "size", defaultValue = "10") Integer size) {
|
||||
public Object list(@LoginUser Integer userId,
|
||||
@NotNull Byte type,
|
||||
@RequestParam(defaultValue = "1") Integer page,
|
||||
@RequestParam(defaultValue = "10") Integer size) {
|
||||
if(userId == null){
|
||||
return ResponseUtil.unlogin();
|
||||
}
|
||||
if(type == null){
|
||||
return ResponseUtil.badArgument();
|
||||
}
|
||||
|
||||
List<LitemallCollect> collectList = collectService.queryByType(userId, type, page, size);
|
||||
int count = collectService.countByType(userId, type);
|
||||
@@ -63,7 +64,7 @@ public class WxCollectController {
|
||||
|
||||
List<Object> collects = new ArrayList<>(collectList.size());
|
||||
for(LitemallCollect collect : collectList){
|
||||
Map<String, Object> c = new HashMap();
|
||||
Map<String, Object> c = new HashMap<String, Object>();
|
||||
c.put("id", collect.getId());
|
||||
c.put("type", collect.getType());
|
||||
c.put("valueId", collect.getValueId());
|
||||
@@ -77,7 +78,7 @@ public class WxCollectController {
|
||||
collects.add(c);
|
||||
}
|
||||
|
||||
Map<String, Object> result = new HashMap();
|
||||
Map<String, Object> result = new HashMap<String, Object>();
|
||||
result.put("collectList", collects);
|
||||
result.put("totalPages", totalPages);
|
||||
return ResponseUtil.ok(result);
|
||||
@@ -132,7 +133,7 @@ public class WxCollectController {
|
||||
collectService.add(collect);
|
||||
}
|
||||
|
||||
Map<String, Object> data = new HashMap();
|
||||
Map<String, Object> data = new HashMap<String, Object>();
|
||||
data.put("type", handleType);
|
||||
return ResponseUtil.ok(data);
|
||||
}
|
||||
|
||||
@@ -9,8 +9,10 @@ import org.linlinjava.litemall.wx.annotation.LoginUser;
|
||||
import org.linlinjava.litemall.wx.service.UserInfoService;
|
||||
import org.linlinjava.litemall.wx.dao.UserInfo;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
@@ -19,6 +21,7 @@ import java.util.Map;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/wx/comment")
|
||||
@Validated
|
||||
public class WxCommentController {
|
||||
@Autowired
|
||||
private LitemallCommentService commentService;
|
||||
@@ -79,10 +82,10 @@ public class WxCommentController {
|
||||
* 失败则 { errno: XXX, errmsg: XXX }
|
||||
*/
|
||||
@GetMapping("count")
|
||||
public Object count(Byte type, Integer valueId) {
|
||||
public Object count(@NotNull Byte type, @NotNull Integer valueId) {
|
||||
int allCount = commentService.count(type, valueId, 0, 0, 0);
|
||||
int hasPicCount = commentService.count(type, valueId, 1, 0, 0);
|
||||
Map<String, Object> data = new HashMap();
|
||||
Map<String, Object> data = new HashMap<String, Object>();
|
||||
data.put("allCount", allCount);
|
||||
data.put("hasPicCount", hasPicCount);
|
||||
return ResponseUtil.ok(data);
|
||||
@@ -111,13 +114,11 @@ public class WxCommentController {
|
||||
* 失败则 { errno: XXX, errmsg: XXX }
|
||||
*/
|
||||
@GetMapping("list")
|
||||
public Object list(Byte type, Integer valueId, Integer showType,
|
||||
@RequestParam(value = "page", defaultValue = "1") Integer page,
|
||||
@RequestParam(value = "size", defaultValue = "10") Integer size) {
|
||||
if(!ObjectUtils.allNotNull(type, valueId, showType)){
|
||||
return ResponseUtil.badArgument();
|
||||
}
|
||||
|
||||
public Object list(@NotNull Byte type,
|
||||
@NotNull Integer valueId,
|
||||
@NotNull Integer showType,
|
||||
@RequestParam(defaultValue = "1") Integer page,
|
||||
@RequestParam(defaultValue = "10") Integer size) {
|
||||
List<LitemallComment> commentList = commentService.query(type, valueId, showType, page, size);
|
||||
int count = commentService.count(type, valueId, showType, page, size);
|
||||
|
||||
@@ -132,7 +133,7 @@ public class WxCommentController {
|
||||
|
||||
commentVoList.add(commentVo);
|
||||
}
|
||||
Map<String, Object> data = new HashMap();
|
||||
Map<String, Object> data = new HashMap<String, Object>();
|
||||
data.put("data", commentVoList);
|
||||
data.put("count", count);
|
||||
data.put("currentPage", page);
|
||||
|
||||
@@ -8,6 +8,7 @@ import org.linlinjava.litemall.core.util.JacksonUtil;
|
||||
import org.linlinjava.litemall.core.util.ResponseUtil;
|
||||
import org.linlinjava.litemall.wx.annotation.LoginUser;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
@@ -21,10 +22,11 @@ import java.util.Map;
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/wx/express")
|
||||
@Validated
|
||||
public class WxExpressController {
|
||||
|
||||
@Autowired
|
||||
ExpressService expressService;
|
||||
private ExpressService expressService;
|
||||
|
||||
@PostMapping("query")
|
||||
public Object query(@LoginUser Integer userId, @RequestBody String body) {
|
||||
|
||||
@@ -8,6 +8,7 @@ import org.linlinjava.litemall.core.util.JacksonUtil;
|
||||
import org.linlinjava.litemall.core.util.ResponseUtil;
|
||||
import org.linlinjava.litemall.wx.annotation.LoginUser;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -17,6 +18,7 @@ import java.util.Map;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/wx/footprint")
|
||||
@Validated
|
||||
public class WxFootprintController {
|
||||
@Autowired
|
||||
private LitemallFootprintService footprintService;
|
||||
@@ -78,8 +80,8 @@ public class WxFootprintController {
|
||||
*/
|
||||
@GetMapping("list")
|
||||
public Object list(@LoginUser Integer userId,
|
||||
@RequestParam(value = "page", defaultValue = "1") Integer page,
|
||||
@RequestParam(value = "size", defaultValue = "10") Integer size) {
|
||||
@RequestParam(defaultValue = "1") Integer page,
|
||||
@RequestParam(defaultValue = "10") Integer size) {
|
||||
if(userId == null){
|
||||
return ResponseUtil.unlogin();
|
||||
}
|
||||
@@ -90,7 +92,7 @@ public class WxFootprintController {
|
||||
|
||||
List<Object> footprintVoList = new ArrayList<>(footprintList.size());
|
||||
for(LitemallFootprint footprint : footprintList){
|
||||
Map<String, Object> c = new HashMap();
|
||||
Map<String, Object> c = new HashMap<String, Object>();
|
||||
c.put("id", footprint.getId());
|
||||
c.put("goodsId", footprint.getGoodsId());
|
||||
c.put("addTime", footprint.getAddTime());
|
||||
|
||||
@@ -5,15 +5,19 @@ import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.linlinjava.litemall.core.system.SystemConfig;
|
||||
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.*;
|
||||
import org.linlinjava.litemall.db.service.*;
|
||||
import org.linlinjava.litemall.wx.annotation.LoginUser;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
@@ -22,6 +26,7 @@ import java.util.Map;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/wx/goods")
|
||||
@Validated
|
||||
public class WxGoodsController {
|
||||
private final Log logger = LogFactory.getLog(WxGoodsController.class);
|
||||
|
||||
@@ -79,11 +84,7 @@ public class WxGoodsController {
|
||||
* 失败则 { errno: XXX, errmsg: XXX }
|
||||
*/
|
||||
@GetMapping("detail")
|
||||
public Object detail(@LoginUser Integer userId, Integer id) {
|
||||
if (id == null) {
|
||||
return ResponseUtil.badArgument();
|
||||
}
|
||||
|
||||
public Object detail(@LoginUser Integer userId, @NotNull Integer id) {
|
||||
// 商品信息
|
||||
LitemallGoods info = goodsService.findById(id);
|
||||
|
||||
@@ -174,10 +175,7 @@ public class WxGoodsController {
|
||||
* 失败则 { errno: XXX, errmsg: XXX }
|
||||
*/
|
||||
@GetMapping("category")
|
||||
public Object category(Integer id) {
|
||||
if (id == null) {
|
||||
return ResponseUtil.badArgument();
|
||||
}
|
||||
public Object category(@NotNull Integer id) {
|
||||
LitemallCategory cur = categoryService.findById(id);
|
||||
LitemallCategory parent = null;
|
||||
List<LitemallCategory> children = null;
|
||||
@@ -230,9 +228,9 @@ public class WxGoodsController {
|
||||
@GetMapping("list")
|
||||
public Object list(Integer categoryId, Integer brandId, String keyword, Boolean isNew, Boolean isHot,
|
||||
@LoginUser Integer userId,
|
||||
@RequestParam(value = "page", defaultValue = "1") Integer page,
|
||||
@RequestParam(value = "size", defaultValue = "10") Integer size,
|
||||
String sort, String order) {
|
||||
@RequestParam(defaultValue = "1") Integer page,
|
||||
@RequestParam(defaultValue = "10") Integer size,
|
||||
@Sort String sort, @Order String order) {
|
||||
|
||||
//添加到搜索历史
|
||||
if (userId != null && !StringUtils.isNullOrEmpty(keyword)) {
|
||||
@@ -335,11 +333,7 @@ public class WxGoodsController {
|
||||
* 失败则 { errno: XXX, errmsg: XXX }
|
||||
*/
|
||||
@GetMapping("related")
|
||||
public Object related(Integer id) {
|
||||
if (id == null) {
|
||||
return ResponseUtil.badArgument();
|
||||
}
|
||||
|
||||
public Object related(@NotNull Integer id) {
|
||||
LitemallGoods goods = goodsService.findById(id);
|
||||
if (goods == null) {
|
||||
return ResponseUtil.badArgumentValue();
|
||||
|
||||
@@ -5,6 +5,7 @@ import org.linlinjava.litemall.db.domain.*;
|
||||
import org.linlinjava.litemall.db.service.*;
|
||||
import org.linlinjava.litemall.core.system.SystemConfig;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
@@ -16,6 +17,7 @@ import java.util.Map;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/wx/home")
|
||||
@Validated
|
||||
public class WxHomeController {
|
||||
@Autowired
|
||||
private LitemallAdService adService;
|
||||
@@ -86,7 +88,7 @@ public class WxHomeController {
|
||||
categoryGoods = goodsService.queryByCategory(l2List, 0, SystemConfig.getCatlogMoreLimit());
|
||||
}
|
||||
|
||||
Map catGoods = new HashMap();
|
||||
Map<String, Object> catGoods = new HashMap<String, Object>();
|
||||
catGoods.put("id", catL1.getId());
|
||||
catGoods.put("name", catL1.getName());
|
||||
catGoods.put("goodsList", categoryGoods);
|
||||
|
||||
@@ -27,10 +27,12 @@ import org.springframework.transaction.TransactionDefinition;
|
||||
import org.springframework.transaction.TransactionStatus;
|
||||
import org.springframework.transaction.support.DefaultTransactionDefinition;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
@@ -59,6 +61,7 @@ import java.util.Map;
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/wx/order")
|
||||
@Validated
|
||||
public class WxOrderController {
|
||||
private final Log logger = LogFactory.getLog(WxOrderController.class);
|
||||
|
||||
@@ -87,7 +90,7 @@ public class WxOrderController {
|
||||
private NotifyService notifyService;
|
||||
|
||||
@Autowired
|
||||
LitemallUserFormIdService formIdService;
|
||||
private LitemallUserFormIdService formIdService;
|
||||
|
||||
public WxOrderController() {
|
||||
}
|
||||
@@ -129,15 +132,13 @@ public class WxOrderController {
|
||||
* 失败则 { errno: XXX, errmsg: XXX }
|
||||
*/
|
||||
@RequestMapping("list")
|
||||
public Object list(@LoginUser Integer userId, Integer showType,
|
||||
@RequestParam(value = "page", defaultValue = "1") Integer page,
|
||||
@RequestParam(value = "size", defaultValue = "10") Integer size) {
|
||||
public Object list(@LoginUser Integer userId,
|
||||
@RequestParam(defaultValue = "0") Integer showType,
|
||||
@RequestParam(defaultValue = "1") Integer page,
|
||||
@RequestParam(defaultValue = "10") Integer size) {
|
||||
if (userId == null) {
|
||||
return ResponseUtil.unlogin();
|
||||
}
|
||||
if (showType == null) {
|
||||
showType = 0;
|
||||
}
|
||||
|
||||
List<Short> orderStatus = OrderUtil.orderStatus(showType);
|
||||
List<LitemallOrder> orderList = orderService.queryByOrderStatus(userId, orderStatus);
|
||||
@@ -192,13 +193,10 @@ public class WxOrderController {
|
||||
* 失败则 { errno: XXX, errmsg: XXX }
|
||||
*/
|
||||
@GetMapping("detail")
|
||||
public Object detail(@LoginUser Integer userId, Integer orderId) {
|
||||
public Object detail(@LoginUser Integer userId, @NotNull Integer orderId) {
|
||||
if (userId == null) {
|
||||
return ResponseUtil.unlogin();
|
||||
}
|
||||
if (orderId == null) {
|
||||
return ResponseUtil.badArgument();
|
||||
}
|
||||
|
||||
// 订单信息
|
||||
LitemallOrder order = orderService.findById(orderId);
|
||||
@@ -737,13 +735,12 @@ public class WxOrderController {
|
||||
* 失败则 { errno: XXX, errmsg: XXX }
|
||||
*/
|
||||
@GetMapping("comment")
|
||||
public Object comment(@LoginUser Integer userId, Integer orderId, Integer goodsId) {
|
||||
public Object comment(@LoginUser Integer userId,
|
||||
@NotNull Integer orderId,
|
||||
@NotNull Integer goodsId) {
|
||||
if (userId == null) {
|
||||
return ResponseUtil.unlogin();
|
||||
}
|
||||
if (orderId == null) {
|
||||
return ResponseUtil.badArgument();
|
||||
}
|
||||
|
||||
List<LitemallOrderGoods> orderGoodsList = orderGoodsService.findByOidAndGid(orderId, goodsId);
|
||||
int size = orderGoodsList.size();
|
||||
|
||||
@@ -6,14 +6,17 @@ import org.linlinjava.litemall.db.domain.LitemallRegion;
|
||||
import org.linlinjava.litemall.db.service.LitemallRegionService;
|
||||
import org.linlinjava.litemall.core.util.ResponseUtil;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/wx/region")
|
||||
@Validated
|
||||
public class WxRegionController {
|
||||
private final Log logger = LogFactory.getLog(WxRegionController.class);
|
||||
|
||||
@@ -37,14 +40,8 @@ public class WxRegionController {
|
||||
* 失败则 { errno: XXX, errmsg: XXX }
|
||||
*/
|
||||
@GetMapping("list")
|
||||
public Object list(Integer pid) {
|
||||
if(pid == null){
|
||||
return ResponseUtil.badArgument();
|
||||
}
|
||||
|
||||
public Object list(@NotNull Integer pid) {
|
||||
List<LitemallRegion> regionList = regionService.queryByPid(pid);
|
||||
return ResponseUtil.ok(regionList);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package org.linlinjava.litemall.wx.web;
|
||||
|
||||
import org.hibernate.validator.constraints.NotEmpty;
|
||||
import org.linlinjava.litemall.db.domain.LitemallKeyword;
|
||||
import org.linlinjava.litemall.db.domain.LitemallSearchHistory;
|
||||
import org.linlinjava.litemall.db.service.LitemallKeywordService;
|
||||
@@ -7,10 +8,8 @@ import org.linlinjava.litemall.db.service.LitemallSearchHistoryService;
|
||||
import org.linlinjava.litemall.core.util.ResponseUtil;
|
||||
import org.linlinjava.litemall.wx.annotation.LoginUser;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
@@ -18,6 +17,7 @@ import java.util.Map;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/wx/search")
|
||||
@Validated
|
||||
public class WxSearchController {
|
||||
@Autowired
|
||||
private LitemallKeywordService keywordsService;
|
||||
@@ -80,13 +80,9 @@ public class WxSearchController {
|
||||
* 失败则 { errno: XXX, errmsg: XXX }
|
||||
*/
|
||||
@GetMapping("helper")
|
||||
public Object helper(String keyword) {
|
||||
if(keyword == null){
|
||||
return ResponseUtil.badArgument();
|
||||
}
|
||||
|
||||
Integer page = 1;
|
||||
Integer size = 10;
|
||||
public Object helper(@NotEmpty String keyword,
|
||||
@RequestParam(defaultValue = "1") Integer page,
|
||||
@RequestParam(defaultValue = "10") Integer size) {
|
||||
List<LitemallKeyword> keywordsList = keywordsService.queryByKeyword(keyword, page, size);
|
||||
String[] keys = new String[keywordsList.size()];
|
||||
int index = 0;
|
||||
|
||||
@@ -10,6 +10,7 @@ import org.springframework.core.io.Resource;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
@@ -22,6 +23,7 @@ import java.util.Map;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/wx/storage")
|
||||
@Validated
|
||||
public class WxStorageController {
|
||||
|
||||
@Autowired
|
||||
|
||||
@@ -4,17 +4,20 @@ import org.linlinjava.litemall.db.domain.LitemallTopic;
|
||||
import org.linlinjava.litemall.db.service.LitemallTopicService;
|
||||
import org.linlinjava.litemall.core.util.ResponseUtil;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/wx/topic")
|
||||
@Validated
|
||||
public class WxTopicController {
|
||||
@Autowired
|
||||
private LitemallTopicService topicService;
|
||||
@@ -38,11 +41,11 @@ public class WxTopicController {
|
||||
* 失败则 { errno: XXX, errmsg: XXX }
|
||||
*/
|
||||
@GetMapping("list")
|
||||
public Object list(@RequestParam(value = "page", defaultValue = "1") Integer page,
|
||||
@RequestParam(value = "size", defaultValue = "10") Integer size) {
|
||||
public Object list(@RequestParam(defaultValue = "1") Integer page,
|
||||
@RequestParam(defaultValue = "10") Integer size) {
|
||||
List<LitemallTopic> topicList = topicService.queryList(page, size);
|
||||
int total = topicService.queryTotal();
|
||||
Map<String, Object> data = new HashMap();
|
||||
Map<String, Object> data = new HashMap<String, Object>();
|
||||
data.put("data", topicList);
|
||||
data.put("count", total);
|
||||
return ResponseUtil.ok(data);
|
||||
@@ -62,11 +65,7 @@ public class WxTopicController {
|
||||
* 失败则 { errno: XXX, errmsg: XXX }
|
||||
*/
|
||||
@GetMapping("detail")
|
||||
public Object detail(Integer id) {
|
||||
if(id == null){
|
||||
return ResponseUtil.badArgument();
|
||||
}
|
||||
|
||||
public Object detail(@NotNull Integer id) {
|
||||
LitemallTopic topic = topicService.findById(id);
|
||||
return ResponseUtil.ok(topic);
|
||||
}
|
||||
@@ -85,11 +84,7 @@ public class WxTopicController {
|
||||
* 失败则 { errno: XXX, errmsg: XXX }
|
||||
*/
|
||||
@GetMapping("related")
|
||||
public Object related(Integer id) {
|
||||
if(id == null){
|
||||
return ResponseUtil.badArgument();
|
||||
}
|
||||
|
||||
public Object related(@NotNull Integer id) {
|
||||
List<LitemallTopic> topicRelatedList = topicService.queryRelatedList(id, 0, 4);
|
||||
return ResponseUtil.ok(topicRelatedList);
|
||||
}
|
||||
|
||||
@@ -7,31 +7,30 @@ import org.linlinjava.litemall.db.service.LitemallUserFormIdService;
|
||||
import org.linlinjava.litemall.db.service.LitemallUserService;
|
||||
import org.linlinjava.litemall.wx.annotation.LoginUser;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/wx/formid")
|
||||
@Validated
|
||||
public class WxUserFormId {
|
||||
@Autowired
|
||||
LitemallUserService userService;
|
||||
private LitemallUserService userService;
|
||||
|
||||
@Autowired
|
||||
LitemallUserFormIdService formIdService;
|
||||
private LitemallUserFormIdService formIdService;
|
||||
|
||||
@GetMapping("create")
|
||||
public Object create(@LoginUser Integer userId, String formId) {
|
||||
public Object create(@LoginUser Integer userId, @NotNull String formId) {
|
||||
if (userId == null) {
|
||||
return ResponseUtil.unlogin();
|
||||
}
|
||||
|
||||
if (formId == null) {
|
||||
return ResponseUtil.badArgument();
|
||||
}
|
||||
|
||||
LitemallUser user = userService.findById(userId);
|
||||
LitemallUserFormid userFormid = new LitemallUserFormid();
|
||||
userFormid.setOpenid(user.getWeixinOpenid());
|
||||
|
||||
Reference in New Issue
Block a user