陶杰
2024-09-11 c12817442862a466d8219cbd0fce04f0695d76ee
1.粉丝数
已修改4个文件
31 ■■■■ 文件已修改
src/main/java/com/mzl/flower/mapper/customer/FollowMapper.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/mzl/flower/service/customer/FollowService.java 10 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/mzl/flower/web/customer/FollowController.java 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/mapper/customer/FollowMapper.xml 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/mzl/flower/mapper/customer/FollowMapper.java
@@ -12,4 +12,6 @@
@Repository
public interface FollowMapper extends BaseMapper<Follow> {
    List<FollowDTO> myFollow(Page page, @Param("userId") String userId);
    Integer getStatisFansCount(@Param("supplierId")  Long supplierId);
}
src/main/java/com/mzl/flower/service/customer/FollowService.java
@@ -2,13 +2,11 @@
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.mzl.flower.config.exception.ValidationException;
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.entity.customer.Follow;
import com.mzl.flower.mapper.customer.FollowMapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -65,4 +63,12 @@
                .eq(Follow::getSupplierId, supplierId));
        return count;
    }
    public Integer getStatisFansCount(Long supplierId) {
        Integer count = followMapper.getStatisFansCount(supplierId);
        return count;
    }
}
src/main/java/com/mzl/flower/web/customer/FollowController.java
@@ -5,12 +5,8 @@
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.CreateAddressDTO;
import com.mzl.flower.dto.request.customer.CreateFollowDTO;
import com.mzl.flower.dto.request.customer.UpdateAddressDTO;
import com.mzl.flower.dto.response.customer.FollowDTO;
import com.mzl.flower.dto.response.supplier.SupplierDTO;
import com.mzl.flower.entity.customer.Address;
import com.mzl.flower.service.customer.FollowService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
@@ -20,7 +16,6 @@
import org.springframework.web.bind.annotation.*;
import javax.validation.constraints.NotNull;
import java.util.List;
@RestController
@RequestMapping("/api/follow")
@@ -56,4 +51,11 @@
    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));
    }
}
src/main/resources/mapper/customer/FollowMapper.xml
@@ -21,4 +21,11 @@
        </if>
        ORDER BY f.create_time DESC
    </select>
    <select id="getStatisFansCount" resultType="java.lang.Integer">
        SELECT IFNULL(COUNT(DISTINCT f.user_id), 0)
        FROM t_follow_supplier f
        WHERE f.deleted = 0
        AND f.supplier_id = #{supplierId};
    </select>
</mapper>