package com.njcn.csharmonic.controller;


import com.njcn.common.pojo.annotation.OperateInfo;
import com.njcn.common.pojo.enums.common.LogEnum;
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.common.utils.HttpResultUtil;
import com.njcn.csharmonic.pojo.vo.ElementsVO;
import com.njcn.csharmonic.service.ICsElementService;
import com.njcn.web.controller.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.validation.annotation.Validated;
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 org.springframework.web.multipart.MultipartFile;
import springfox.documentation.annotations.ApiIgnore;

/**
 * <p>
 * 组态图元库 前端控制器
 * </p>
 *
 * @author xuyang
 * @since 2023-06-14
 */
@RestController
@RequestMapping("/csElement")
@Api(tags = "组态图元")
@AllArgsConstructor
@Deprecated
@ApiIgnore
public class CsElementController extends BaseController {

    private final ICsElementService csElementService;

    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("/add")
    @ApiOperation("组态图元新增")
    @ApiImplicitParam(name = "multipartFile", value = "组态图元数据流", required = true)
    public HttpResult<String> add(@RequestBody @Validated MultipartFile multipartFile){
        String methodDescribe = getMethodDescribe("add");
        csElementService.addElement(multipartFile);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, CommonResponseEnum.SUCCESS.getMessage(), methodDescribe);
    }

    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("/find")
    @ApiOperation("查询组态图元数据")
    public HttpResult<ElementsVO> find(){
        String methodDescribe = getMethodDescribe("find");
        ElementsVO elementsVo = csElementService.findElement();
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, elementsVo, methodDescribe);
    }

}

