package com.cim.idm.controller;

import com.cim.idm.model.AssignAndDessignDto;
import com.cim.idm.model.HoldAndReleaseDto;
import com.cim.idm.response.BaseResponse;
import com.cim.idm.response.RespGenerator;
import com.cim.idm.service.AssignAndDessignService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.stereotype.Controller;
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 javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@RestController
@RequestMapping("/AssignAndDessign")
@EnableAutoConfiguration
@Api(tags = "PC端单据绑定与解绑控制器")
@Slf4j
public class AssignAndDessignController {

    @Autowired
    private AssignAndDessignService assignAndDessignService;

    @PostMapping(value = "/AssignAndDessignM")
    @ApiOperation(value = "PC端单据绑定与解绑")
    public BaseResponse<Object> AssignAndDessign(HttpServletRequest request,
                                                 HttpServletResponse response,
                                                 @ApiParam(value = "绑定解绑参数", required = true) @RequestBody AssignAndDessignDto AssignAndDessignDto) {
        try {
            assignAndDessignService.AssignAndDessign(AssignAndDessignDto);
        } catch (Exception e) {
            return RespGenerator.returnError(e.getMessage());
        }
        return RespGenerator.returnOK(null);
    }
}
