package com.unis.base.app.controller;

import com.unis.base.client.SinkpointFeign;
import com.unis.base.common.vo.DKdxxsjyVO;
import com.unis.common.utils.ResponseWrapper;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author huangxing
 * @version 1.0
 * @Title DKdxxsjyController
 * @ProjectName 库点信息 Controller
 * @date 2019/07/22 17点26分
 */
@RestController
@Api(value = "库点信息", tags = "库点信息")
@Slf4j
public class SinkpointController {

	@Autowired
	private SinkpointFeign sinkpointFeign;

	@ApiOperation(value = "获取库点信息列表", notes = "参数：库点名称，粮库类别，企业编号，企业名称，库点企业性质")
	@PostMapping(value = "/sinkpointList")
    public ResponseWrapper getDKdxxsjyList(@RequestBody DKdxxsjyVO dKdxxsjyVO){
        return sinkpointFeign.getDKdxxsjyList(dKdxxsjyVO);
    }

	@ApiOperation(value = "分页获取库点信息列表", notes = "参数：库点名称，粮库类别，企业编号，企业名称，库点企业性质")
	@PostMapping(value = "/sinkpointPage/{pageNum}/{pageSize}")
    public ResponseWrapper getDKdxxsjyPage(@RequestBody DKdxxsjyVO dKdxxsjyVO, @PathVariable("pageNum")Integer pageNum, @PathVariable("pageSize") Integer pageSize){
        return sinkpointFeign.getDKdxxsjyPage(dKdxxsjyVO,pageNum,pageSize);
    }

	@ApiOperation(value = "根据库点编码获取库点信息", notes = "参数：库点编号")
	@GetMapping(value = "/sinkpoint/{kddm}")
    public ResponseWrapper getDKdxxsjyInfoBykddm(@PathVariable("kddm") String kddm){
        return sinkpointFeign.getDKdxxsjyInfoBykddm(kddm);
    }

	@ApiOperation(value = "获取库点信息列表", notes = "参数：统一社会信用代码")
	@GetMapping(value = "/sinkpointList/{tyshxydm}")
	public ResponseWrapper getDKdxxsjyInfoBytyshxydm(@PathVariable("tyshxydm") String tyshxydm){
		return sinkpointFeign.getDKdxxsjyInfoBytyshxydm(tyshxydm);
	}

	@DeleteMapping(value="/sinkpoint/{tyshxydm}")
	@ApiOperation(value = "根据统一社会信用代码删除库点信息", notes = "参数：统一社会信用代码")
	public ResponseWrapper deleteList(@PathVariable("tyshxydm") String tyshxydm) {
		return sinkpointFeign.deleteList(tyshxydm);
	}

	@PostMapping(value = "/sinkpoint")
	@ApiOperation(value = "新增库点信息", notes = "参数：库点名称，统一社会信用代码")
    public ResponseWrapper insert(@RequestBody DKdxxsjyVO dKdxxsjyVO) {
        return sinkpointFeign.insert(dKdxxsjyVO);
    }

	@PutMapping(value = "/sinkpoint")
	@ApiOperation(value = "更新库点信息", notes = "参数：库点代码")
    public ResponseWrapper update(@RequestBody DKdxxsjyVO dKdxxsjyVO) {
        return sinkpointFeign.update(dKdxxsjyVO);
    }

	@DeleteMapping(value="/sinkpoint/{kddm}")
	@ApiOperation(value = "根据库点编号删除库点信息", notes = "参数：库点编号")
	public ResponseWrapper delete(@PathVariable("kddm") String kddm) {
        return sinkpointFeign.delete(kddm);
    }

    @ApiOperation(value = "获取库点信息列表", notes = "参数：库点名称，粮库类别，企业编号，企业名称，库点企业性质")
    @PostMapping(value = "/sinkpointTree")
    public ResponseWrapper getDKdxxsjyTree(@RequestBody DKdxxsjyVO dKdxxsjyVO) {
        return sinkpointFeign.getDKdxxsjyTree(dKdxxsjyVO);
    }
}
