|
|
@@ -3,6 +3,9 @@ package com.uas.platform.b2c.prod.product.common.api;
|
|
|
import com.uas.platform.b2c.prod.product.common.model.CommonCount;
|
|
|
import com.uas.platform.b2c.prod.product.common.service.CommonCountService;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.data.repository.query.Param;
|
|
|
+import org.springframework.util.StringUtils;
|
|
|
+import org.springframework.web.bind.annotation.PathVariable;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
@@ -26,7 +29,37 @@ public class CommonCountController {
|
|
|
* @return
|
|
|
*/
|
|
|
@RequestMapping(method = RequestMethod.GET, params = "_status=actived")
|
|
|
- public List<CommonCount> findActived() {
|
|
|
- return commonCountService.findByStatus((short) 1, "b2c_index");
|
|
|
+ public List<CommonCount> findActived(@Param("userFor") String usedFor) {
|
|
|
+ usedFor = StringUtils.isEmpty(usedFor) ? "b2c_index" : usedFor;
|
|
|
+ return commonCountService.findByStatus((short) 1, usedFor);
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 根据ID获取计数器
|
|
|
+ * @author suntg
|
|
|
+ * @date 2017年11月7日17:03:28
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @RequestMapping(value ="/{id}", method = RequestMethod.GET)
|
|
|
+ public CommonCount findById(@PathVariable("id") Long id) {
|
|
|
+ CommonCount commonCount = commonCountService.findById(id);
|
|
|
+ if(commonCount == null)
|
|
|
+ throw new IllegalArgumentException("参数ID错误,数据不存在");
|
|
|
+ return commonCount;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 根据ID获取计数器的结果
|
|
|
+ * @author suntg
|
|
|
+ * @date 2017年11月7日17:03:34
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @RequestMapping(value ="/{id}/count", method = RequestMethod.GET)
|
|
|
+ public Long findCountById(@PathVariable("id") Long id) {
|
|
|
+ CommonCount commonCount = commonCountService.findById(id);
|
|
|
+ if(commonCount == null)
|
|
|
+ throw new IllegalArgumentException("参数ID错误,数据不存在");
|
|
|
+ return commonCount.getCount();
|
|
|
+ }
|
|
|
+
|
|
|
}
|