/**  
 * @Title:ProfitController.java
 * @Package: com.unis.base.server.controller
 * @Description: TODO功能描述:(用一句话描述该文件做什么)
 * @Author ZHANGQI
 * @date 2019年10月30日 下午3:31:58
 * @version V1.0  
*/

package com.unis.base.server.controller;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.github.pagehelper.PageInfo;
import com.unis.base.common.vo.ProfitVO;
import com.unis.base.server.service.ProfitService;
import com.unis.common.utils.ResponseWrapper;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
@RestController
@Api(value = "损溢单", tags = "损溢单信息维护")
@Slf4j
@RequestMapping("/profit")
public class ProfitController {
	@Autowired
	private ProfitService profitService;
	
	/**
	 * @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 ProfitVO profitVO,
			   @PathVariable(value = "pageNum") Integer pageNum,
			   @PathVariable(value = "pageSize") Integer pageSize){
		try {
			PageInfo<ProfitVO> pageInfos = profitService.getPageList(profitVO,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 = "/deleteProfit/{sybh}")
	public ResponseWrapper deleteProfit(@PathVariable("sybh")String sybh) {
		try {
			int pro = profitService.deleteProfit(sybh);
			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 = "/infoProfit")
	public ResponseWrapper infoProfit(@RequestBody ProfitVO  profitVO) {
		try {
			int pro = profitService.infoProfit(profitVO);
			return ResponseWrapper.success(HttpStatus.OK.value(), "获取信息列表成功", pro);
		} catch (Exception e) {
			log.error(e.getMessage());
			return ResponseWrapper.error(HttpStatus.INTERNAL_SERVER_ERROR.value(),"获取信息列表失败",null);
		}
	}
	
}
