package com.unis.base.server.controller;

import com.github.pagehelper.PageInfo;
import com.unis.base.common.vo.NatureTransVo;
import com.unis.base.common.vo.ProfitVO;
import com.unis.base.common.vo.ReversePositionVo;
import com.unis.base.server.service.NatureTransService;
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.http.HttpStatus;
import org.springframework.web.bind.annotation.*;

/**
 * @author ceshi
 * @Title: ${file_name}
 * @Package ${package_name}
 * @Description:
 * @date 2019/10/3121:02
 */

@RestController
@Api(value = "性质转变数据", tags = "性质转变数据维护")
@Slf4j
@RequestMapping("/natureTrans")
public class NatureTransController {
    @Autowired
    private NatureTransService natureTransService;

    /**
     * @Title: getPageList
     * @Description: TODO方法描述:(这里用一句话描述这个方法的作用)
     * @param @param profitVO
     * @param @param pageNum
     * @param @param pageSize
     * @param @return    设定文件
     * @return ResponseWrapper    返回类型
     * @throws
     */
    @ApiOperation(value = "列表 根据条件【分页查询】",notes = "待定")
    @PostMapping(value = "/getPageListt/{pageNum}/{pageSize}")
    public ResponseWrapper getPageList(@RequestBody NatureTransVo natureTransVo,
                                       @PathVariable(value = "pageNum") Integer pageNum,
                                       @PathVariable(value = "pageSize") Integer pageSize){
        try {
            PageInfo<NatureTransVo> pageInfos = natureTransService.getPageList(natureTransVo,pageNum,pageSize);
            return ResponseWrapper.success(HttpStatus.OK.value(), "获取信息列表成功", pageInfos);
        } catch (Exception e) {
            log.error(e.getMessage());
            return ResponseWrapper.error(HttpStatus.INTERNAL_SERVER_ERROR.value(),"获取信息列表失败",null);
        }
    }

    /**
     *
     * @Title: deleteProfit
     * @Description: TODO方法描述:(通过编号删除)
     * @param @param sybh
     * @param @return    设定文件
     * @return ResponseWrapper    返回类型
     * @throws
     */
    @ApiOperation(value = "根据编号【删除】",notes = "编号")
    @DeleteMapping(value = "/deleteNatureTrans/{sybh}")
    public ResponseWrapper deleteNatureTrans(@PathVariable("xzzbdbh")String xzzbdbh) {
        try {
            int pro = natureTransService.deleteNatureTrans(xzzbdbh);
            return ResponseWrapper.success(HttpStatus.OK.value(), "获取信息列表成功", pro);
        } catch (Exception e) {
            log.error(e.getMessage());
            return ResponseWrapper.error(HttpStatus.INTERNAL_SERVER_ERROR.value(),"获取信息列表失败",null);
        }
    }


    @ApiOperation(value = "数据录入",notes = "数据录入")
    @DeleteMapping(value = "/infoNatureTrans")
    public ResponseWrapper infoNatureTrans(@RequestBody NatureTransVo natureTransVo) {
        try {
            int pro = natureTransService.infoNatureTrans(natureTransVo);
            return ResponseWrapper.success(HttpStatus.OK.value(), "获取信息列表成功", pro);
        } catch (Exception e) {
            log.error(e.getMessage());
            return ResponseWrapper.error(HttpStatus.INTERNAL_SERVER_ERROR.value(),"获取信息列表失败",null);
        }
    }
}
