|
@@ -0,0 +1,53 @@
|
|
|
+package com.chelvc.cloud.maintain.controller;
|
|
|
+
|
|
|
+import com.chelvc.cloud.vehicle.api.dto.FavoriteDTO;
|
|
|
+import com.chelvc.cloud.vehicle.api.param.FavoriteModifyParam;
|
|
|
+import com.chelvc.cloud.vehicle.api.service.FavoriteService;
|
|
|
+import com.chelvc.framework.base.annotation.UnifiedResponseBody;
|
|
|
+import com.chelvc.framework.base.util.ErrorUtils;
|
|
|
+import org.apache.dubbo.config.annotation.DubboReference;
|
|
|
+import org.springframework.validation.annotation.Validated;
|
|
|
+import org.springframework.web.bind.annotation.GetMapping;
|
|
|
+import org.springframework.web.bind.annotation.PathVariable;
|
|
|
+import org.springframework.web.bind.annotation.PostMapping;
|
|
|
+import org.springframework.web.bind.annotation.RestController;
|
|
|
+import javax.validation.Valid;
|
|
|
+import javax.validation.constraints.Min;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 收藏接口
|
|
|
+ *
|
|
|
+ * @author liude
|
|
|
+ * @date 2023/7/20
|
|
|
+ */
|
|
|
+@Validated
|
|
|
+@RestController
|
|
|
+@UnifiedResponseBody
|
|
|
+public class FavoriteController {
|
|
|
+
|
|
|
+ @DubboReference
|
|
|
+ private FavoriteService favoriteService;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取收藏信息
|
|
|
+ *
|
|
|
+ * @param id 收藏主键
|
|
|
+ * @return 收藏信息
|
|
|
+ */
|
|
|
+ @GetMapping("/favorite/{id}")
|
|
|
+ public FavoriteDTO getFavorite(@PathVariable("id") @Min(value = 1, message = "商家主键不能小于1") Long id) {
|
|
|
+ FavoriteDTO favorite = this.favoriteService.getFavorite(id);
|
|
|
+ ErrorUtils.requireResource(favorite, "收藏信息不存在");
|
|
|
+ return favorite;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 收藏
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @PostMapping("/favorite/add")
|
|
|
+ public Long addFavorite(@Valid FavoriteModifyParam param) {
|
|
|
+ Long id = this.favoriteService.addFavorite(param);
|
|
|
+ return id;
|
|
|
+ }
|
|
|
+}
|