package com.jwipc.inquiry.controller.rest;

import com.jwipc.inquiry.dto.InquiryParamDTO;
import com.jwipc.inquiry.dto.PriceInfoAuditParamDTO;
import com.jwipc.inquiry.logic.PriceInfoAuditLogic;
import com.jwipc.inquiry.model.query.InquiryQuery;
import com.jwipc.inquiry.model.query.PriceInfoAuditQuery;
import com.jwipc.log.annotation.AuditLogInter;
import com.jwipc.page.PageView;
import com.jwipc.security.LoginUtil;
import lombok.RequiredArgsConstructor;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;

import static com.jwipc.inquiry.constant.ModuleConst.MODULE_ROOT;

/**
 * <p>
 * 调价管理表 前端控制器
 * </p>
 *
 * @author shenyang.ou
 * @since 2024-03-08
 */
@RestController
@RequestMapping(MODULE_ROOT + "/price/audit/rest")
@RequiredArgsConstructor
public class PriceInfoAuditRestController {
    private final PriceInfoAuditLogic priceInfoAuditLogic;
    /**
     * 列表
     * @param query
     * @return
     */
    @AuditLogInter(value = "首页查询列表", module = "调价管理")
    @RequestMapping("/list")
    public PageView list(PriceInfoAuditQuery query) {
        query.setUserId(LoginUtil.getUserId());
        return priceInfoAuditLogic.findByPage(query);
    }

    /**
     * 保存更新
     *
     * @param param 参数
     */
    @PostMapping("/saveOrUpdate")
    public ResponseEntity saveOrUpdate(@RequestBody PriceInfoAuditParamDTO param) {
        priceInfoAuditLogic.saveOrUpdate(param);
        return ResponseEntity.ok(true);
    }

    /**
     * 删除
     *
     * @param id id
     */
    @PostMapping("/remove")
    public ResponseEntity remove(Long id) {
        priceInfoAuditLogic.remove(id);
        return ResponseEntity.ok(true);
    }

    /**
     * 提交oa审批
     *
     * @param id id
     */
    @PostMapping("/pushOa")
    public ResponseEntity pushOa(Long id) {
        priceInfoAuditLogic.pushOa(id);
        return ResponseEntity.ok(true);
    }


    /**
     * 授权通过
     *
     * @param id id
     */
    @PostMapping("/pass")
    public ResponseEntity pass(Long id) {
        priceInfoAuditLogic.pass(id);
        return ResponseEntity.ok(true);
    }
}
