package com.iformall.controller;

import com.github.pagehelper.PageInfo;
import com.iformall.common.Result;
import com.iformall.common.ResultData;
import com.iformall.domain.po.WxBillOther;
import com.iformall.service.WxBillOtherService;
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("wxBillOther")
public class WxBillOtherController extends BaseController
{
	@Autowired
    private WxBillOtherService wxBillOtherService;

    private Logger logger = LoggerFactory.getLogger(this.getClass());

    @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 WxBillOther wxBillOther,Integer pageNum, Integer pageSize) {
        logger.debug("[" + getIpAddr() + "] WxBillOtherController::list");
    	if (null == wxBillOther) {
    	    wxBillOther = new WxBillOther();
    	}
        wxBillOther.setTenantId(getTenantId());
        final PageInfo<Map<String,Object>> page = wxBillOtherService.listAsPage(wxBillOther, pageNum, pageSize);
        return new ResultData(page);
    }

    @PostMapping("add")
    public ResultData add(@RequestBody WxBillOther wxBillOther) {
        logger.debug("[" + getIpAddr() + "] WxBillOtherController::add");
        wxBillOther.setTenantId(getTenantId());
        wxBillOther.setUserId(getUser().getId());
        return wxBillOtherService.saveOrUpdate(wxBillOther);
    }

    @PostMapping("update")
    public ResultData update(@RequestBody WxBillOther wxBillOther) {
        logger.debug("[" + getIpAddr() + "] WxBillOtherController::update");
        wxBillOther.setUserId(getUser().getId());
        return wxBillOtherService.saveOrUpdate(wxBillOther);
    }

    @GetMapping("/del")
     @ApiImplicitParam(name="id",value="id",dataType="Long", paramType = "query",required=true)
    public ResultData delete(Long id) {
        logger.debug("[" + getIpAddr() + "] WxBillOtherController::delete");
        wxBillOtherService.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() + "] WxBillOtherController::findById");
        return new ResultData(Result.SUCCESS,"查询成功",wxBillOtherService.getById(id));
    }

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