package com.xinelu.applet.controller.appgoodsorder;

import com.xinelu.common.core.controller.BaseController;
import com.xinelu.common.core.domain.R;
import com.xinelu.common.core.page.TableDataInfo;
import com.xinelu.manage.dto.goodsorder.GoodsOrderDTO;
import com.xinelu.manage.service.goodsOrder.IGoodsOrderService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import javax.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
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;

/**
 * @description: APP工单控制器
 * @author: haown
 * @create: 2023-10-20 10:02
 **/
@Api(tags = "APP工单控制器")
@RestController
@RequestMapping("/nurseApp/orders")
public class AppGoodsOrderController extends BaseController {

	@Resource
	private IGoodsOrderService goodsOrderService;

	/**
	 * 工单列表
	 */
	@GetMapping("/getList")
	@ApiOperation(value = "查询工单列表")
	public TableDataInfo getList(GoodsOrderDTO goodsOrderDTO) {
		startPage();
		return getDataTable(goodsOrderService.getConsultationOrders(goodsOrderDTO));
	}

	@PostMapping("/updateStatus")
	@ApiOperation(value = "修改订单状态")
	public R<String> updateStatus(@RequestBody GoodsOrderDTO goodsOrderDTO) {
		if(goodsOrderDTO.getGoodsOrderId() ==  null || goodsOrderDTO.getGoodsOrderId() == 0) {
			return R.fail("数据不正确");
		}
		int flag = goodsOrderService.updateStatus(goodsOrderDTO);
		return flag < 0 ? R.fail() : R.ok();
	}
}
