package com.mzl.flower.web.customer;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.mzl.flower.base.BaseController;
|
import com.mzl.flower.base.R;
|
import com.mzl.flower.base.ReturnDataDTO;
|
import com.mzl.flower.config.security.SecurityUtils;
|
import com.mzl.flower.dto.request.customer.CreateFollowDTO;
|
import com.mzl.flower.dto.response.customer.FollowDTO;
|
import com.mzl.flower.service.customer.FollowService;
|
import io.swagger.annotations.Api;
|
import io.swagger.annotations.ApiOperation;
|
import lombok.extern.slf4j.Slf4j;
|
import org.springframework.http.ResponseEntity;
|
import org.springframework.validation.annotation.Validated;
|
import org.springframework.web.bind.annotation.*;
|
|
import javax.validation.constraints.NotNull;
|
|
@RestController
|
@RequestMapping("/api/follow")
|
@Api(value = "关注管理", tags = "关注管理")
|
@Validated
|
@Slf4j
|
public class FollowController extends BaseController {
|
|
private final FollowService followService;
|
|
public FollowController(FollowService followService) {
|
this.followService = followService;
|
}
|
|
|
@PostMapping("/add")
|
@ApiOperation(value = "新增关注", notes = "新增关注")
|
public ResponseEntity<ReturnDataDTO> add(@Validated @RequestBody CreateFollowDTO dto) {
|
followService.add(dto);
|
return returnData(R.SUCCESS.getCode(),null);
|
}
|
|
|
@GetMapping("/delete")
|
@ApiOperation(value = "取消关注", notes = "取消关注")
|
public ResponseEntity<ReturnDataDTO> delete(@NotNull(message = "supplierId不能为空") Long supplierId) {
|
followService.delete(supplierId);
|
return returnData(R.SUCCESS.getCode(),null);
|
}
|
|
@GetMapping("/list")
|
@ApiOperation(value = "我的关注列表", notes = "我的关注列表")
|
public ResponseEntity<ReturnDataDTO<Page<FollowDTO>>> myFollow(Page page) {
|
return returnData(R.SUCCESS.getCode(),followService.myFollow(page,SecurityUtils.getUserId()));
|
}
|
|
@GetMapping("/fans/statis/{supplierId}")
|
@ApiOperation(value = "我的关注列表", notes = "我的关注列表")
|
public ResponseEntity<ReturnDataDTO<Integer>> myFansStatis(@NotNull(message = "supplierId不能为空") @PathVariable("supplierId") Long supplierId) {
|
return returnData(R.SUCCESS.getCode(),followService.getStatisFansCount(supplierId));
|
}
|
|
}
|