package com.iformall.controller;

import com.github.pagehelper.PageInfo;
import com.iformall.common.Result;
import com.iformall.common.ResultData;
import com.iformall.domain.po.WxBillOtherDeposit;
import com.iformall.domain.po.WxBillPropertyDeposit;
import com.iformall.service.WxBillPropertyDepositService;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * @author gongbiao
 */
@RestController
@RequestMapping("wxBillPropertyDeposit")
public class WxBillPropertyDepositController extends BaseController
{
	@Autowired
    private WxBillPropertyDepositService wxBillPropertyDepositService;

    private Logger logger = LoggerFactory.getLogger(WxBillPropertyDepositController.class);

    @GetMapping("list")
        @ApiImplicitParams({
    	  @ApiImplicitParam(name="pageNum",value="页数",dataType="int", paramType = "query",required=true),
    	  @ApiImplicitParam(name="pageSize",value="每页条数",dataType="int", paramType = "query",required=true)})
    public ResultData list(@ModelAttribute WxBillPropertyDeposit wxBillPropertyDeposit, Integer pageNum, Integer pageSize) {
        logger.debug("[" + getIpAddr() + "] WxBillPropertyDepositController::list");
    	if (null == wxBillPropertyDeposit) {
    	    wxBillPropertyDeposit = new WxBillPropertyDeposit();
        }
        wxBillPropertyDeposit.setTenantId(getTenantId());
        PageInfo<Map<String, Object>> result = wxBillPropertyDepositService.listAsPage(wxBillPropertyDeposit, pageNum, pageSize);
        return new ResultData(result);
    }

    @PostMapping("add")
    public ResultData add(@RequestBody WxBillPropertyDeposit wxBillPropertyDeposit) {
        logger.debug("[" + getIpAddr() + "] WxBillPropertyDepositController::add");
        wxBillPropertyDeposit.setTenantId(getTenantId());
        wxBillPropertyDepositService.saveOrUpdate(wxBillPropertyDeposit);
        return new ResultData();
    }

    @PostMapping("update")
    public ResultData update(@RequestBody WxBillPropertyDeposit wxBillPropertyDeposit) {
        logger.debug("[" + getIpAddr() + "] WxBillPropertyDepositController::update");
        return wxBillPropertyDepositService.saveOrUpdate(wxBillPropertyDeposit);
    }

    @GetMapping("/del")
     @ApiImplicitParam(name="id",value="id",dataType="Long", paramType = "query",required=true)
    public ResultData delete(Long id) {
        logger.debug("[" + getIpAddr() + "] WxBillPropertyDepositController::delete");
        wxBillPropertyDepositService.deleteById(id);
        return new ResultData(Result.SUCCESS, "删除成功", null);
    }
    
     @GetMapping("/findById")
     @ApiImplicitParam(name="id",value="id",dataType="Long", paramType = "query",required=true)
    public ResultData findById(Long id) {
        logger.debug("[" + getIpAddr() + "] WxBillPropertyDepositController::findById");
    	return new ResultData(Result.SUCCESS,"查询成功",wxBillPropertyDepositService.getById(id));
    }

    @GetMapping("/updatePaid")
    @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true)
    public ResultData updatePaid(Long id) {
        logger.debug("[" + getIpAddr() + "] WxBillPropertyDepositController::updatePaid");
        return wxBillPropertyDepositService.updatePaid(id);
    }

    @PostMapping("returnDeposit")
    public ResultData returnDeposit(@RequestBody WxBillPropertyDeposit wxBillPropertyDeposit) {
        logger.debug("[" + getIpAddr() + "] WxBillPropertyDepositController::returnDeposit");
        return wxBillPropertyDepositService.returnDeposit(wxBillPropertyDeposit);

    }


    @PostMapping("adjustDeposit")
    public ResultData adjustDeposit(@RequestBody WxBillPropertyDeposit wxBillPropertyDeposit) {
        logger.debug("[" + getIpAddr() + "] WxBillPropertyDepositController::adjustDeposit");
        return wxBillPropertyDepositService.adjustDeposit(wxBillPropertyDeposit);

    }


	
}
