package com.yonge.cooleshow.admin.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;

import com.yonge.cooleshow.biz.dal.support.PageUtil;
import com.yonge.cooleshow.common.controller.BaseController;
import com.yonge.cooleshow.common.entity.HttpResponseResult;
import com.yonge.toolset.mybatis.page.PageInfo;
import com.yonge.toolset.utils.string.StringUtil;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

import com.yonge.cooleshow.biz.dal.vo.UserOrderRefundsVo;
import com.yonge.cooleshow.biz.dal.dto.search.OrderRefundsSearch;
import com.yonge.cooleshow.biz.dal.entity.UserOrderRefunds;
import com.yonge.cooleshow.biz.dal.service.UserOrderRefundsService;

@RestController
@RequestMapping("/UserOrderRefunds")
@Api(value = "用户退款表", tags = "用户退款表")
public class UserOrderRefundsController extends BaseController {

    @Autowired
    private UserOrderRefundsService userOrderRefundsService;

	/**
     * 查询单条
     */
    @GetMapping("/detail/{id}")
    @ApiOperation(value = "详情", notes = "传入id")
    public HttpResponseResult<UserOrderRefundsVo> detail(@PathVariable("id") Long id) {
    	return succeed(userOrderRefundsService.detail(id));
	}
    
    /**
     * 查询分页
     */
    @PostMapping("/page")
    @ApiOperation(value = "查询分页", notes = "传入orderRefundsSearch")
    public HttpResponseResult<PageInfo<UserOrderRefundsVo>> page(@RequestBody OrderRefundsSearch query) {
		IPage<UserOrderRefundsVo> pages = userOrderRefundsService.selectPage(PageUtil.getPage(query), query);
        return succeed(PageUtil.pageInfo(pages));
	}
    
    /**
	 * 新增
	 */
	@PostMapping("/save")
	@ApiOperation(value = "新增", notes = "传入orderRefunds")
	public HttpResponseResult save(@Valid @RequestBody UserOrderRefunds userOrderRefunds) {
    	return status(userOrderRefundsService.save(userOrderRefunds));
	}
    
    /**
	 * 修改
	 */
	@PostMapping("/update")
	@ApiOperation(value = "修改", notes = "传入orderRefunds")
	public HttpResponseResult update(@Valid @RequestBody UserOrderRefunds userOrderRefunds) {
        return status(userOrderRefundsService.updateById(userOrderRefunds));
	}
    
    /**
	 * 新增或修改
	 */
    @PostMapping("/submit")
    @ApiOperation(value = "新增或修改", notes = "传入orderRefunds")
	public HttpResponseResult submit(@Valid @RequestBody UserOrderRefunds userOrderRefunds) {
        return status(userOrderRefundsService.saveOrUpdate(userOrderRefunds));
    }

 	/**
	 * 删除
	 */
	@PostMapping("/remove")
	@ApiOperation(value = "逻辑删除", notes = "传入ids")
	public HttpResponseResult remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) {
        if (StringUtil.isEmpty(ids)) {
			return failed("参数不能为空");
		}
		return status(userOrderRefundsService.removeByIds(StringUtil.toLongList(ids)));
	}
}