瀏覽代碼

行业新品牌接口年份范围可由前端定值

云殇忆 1 年之前
父節點
當前提交
b103f6105b

+ 3 - 4
ruoyi-demo/src/main/java/com/ruoyi/demo/controller/BrandController.java

@@ -240,12 +240,11 @@ public class BrandController extends BaseController {
     /**
      * 行业新品牌
      *
-     * @param bo 地址码和网点类型(犇云)查询体
+     * @param years 范围/年
      * @return
      */
     @GetMapping("/new")
-    public R newBrand(ListQueryBody bo) {
-        List<String> industryCodes = bo.getIndustryCode();
-        return R.ok(brandService.searchNew(industryCodes));
+    public R newBrand(Integer years) {
+        return R.ok(brandService.searchNewByYears(years));
     }
 }

+ 2 - 0
ruoyi-demo/src/main/java/com/ruoyi/demo/service/BrandService.java

@@ -47,4 +47,6 @@ public interface BrandService {
     List<BrandCityTier> getCityTier(String brandId);
 
     List<TimeVo> searchNew(List<String> industryCodes);
+
+    List<TimeVo> searchNewByYears(Integer years);
 }

+ 18 - 0
ruoyi-demo/src/main/java/com/ruoyi/demo/service/impl/BrandServiceImpl.java

@@ -561,4 +561,22 @@ public class BrandServiceImpl implements BrandService {
         }
         return vos;
     }
+
+    @Override
+    public List<TimeVo> searchNewByYears(Integer years) {
+        // 默认3年
+        if (years == null)
+            years = 3;
+        if ("".equals(years.toString()))
+            years = 3;
+
+        List<TimeVo> vos = new ArrayList<>();
+        for (int i = 0; i < years; i++) {
+            TimeVo timeVo = new TimeVo();
+            timeVo.setTime(DateUtil.offset(DateUtil.date(), DateField.YEAR, -i).toString("yyyy"));
+            timeVo.setCount(brandMapper.selectCountByYear(timeVo.getTime(), null));
+            vos.add(timeVo);
+        }
+        return vos;
+    }
 }