package com.sptg.gateway.controller.estate;


import com.baomidou.mybatisplus.plugins.Page;
import com.sptg.common.security.annotation.Security;
import com.sptg.estate.api.constant.EstateSecurityToken;
import com.sptg.estate.api.entity.Bills;
import com.sptg.estate.api.entity.BillsItem;
import com.sptg.estate.api.feigns.BillsFeign;
import com.sptg.estate.api.feigns.BillsItemFeign;
import com.sptg.estate.api.vo.BillsVO;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;

import java.util.List;

@RestController
@RequestMapping("/billsItem/manage")
@RequiredArgsConstructor
public class BillsItemController {
    private final BillsItemFeign billsItemFeign;

    /**
     *  根据账单id获取缴费项列表
     * */
    @GetMapping("/list")
    @Security(token = EstateSecurityToken.ESTATE_BILLS_MANAGER)
    public List<BillsItem> list(@RequestParam("pid") Long pid){
        return billsItemFeign.list(pid);
    }

    /**
     *  获取缴费项详情
     * */
    @GetMapping("/detail")
    @Security(token = EstateSecurityToken.ESTATE_BILLS_MANAGER)
    public BillsItem detail (@RequestParam("id") Long id){
        return billsItemFeign.detail(id);
    }

    /**
     *  根据id删除缴费项
     * */
    @GetMapping("/delete")
    @Security(token = EstateSecurityToken.ESTATE_BILLS_DELETE)
    public boolean delete(@RequestParam("id") Long id){
        return billsItemFeign.delete(id);
    }

    /**
     *  根据id修改缴费项
     * */
    @PostMapping("/edit")
    @Security(token = EstateSecurityToken.ESTATE_BILLS_EDIT)
    public boolean edit(@RequestBody BillsItem billsItem){
        return billsItemFeign.edit(billsItem);
    }
}
