package com.ruoyi.gysl.controller;


import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.gysl.entity.WysmxInformation;
import com.ruoyi.gysl.entity.request.ZwIdPageReq;
import com.ruoyi.gysl.service.BasicInformationService;
import com.ruoyi.gysl.service.WysmxInformationService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;

/**
 * 五要素模型信息(WysmxInformation)表控制层
 *
 * @author makejava
 * @since 2025-02-24 14:29:58
 */
@Api(tags ="五要素模型信息 no" )
@RestController
@RequestMapping("/gysl/wysmxInformation")
public class WysmxInformationController extends BaseController {
    /**
     * 服务对象
     */
    @Resource
    private WysmxInformationService wysmxInformationService;

    /**
     * 基本信息
     */
    @Resource
    private BasicInformationService basicInformationService;

    /**
     * 根据项目id查询该项目的五要素模型信息
     *
     * @param zwIdPageReq 查询实体
     * @return 所有数据
     */
    @GetMapping("/selectOne")
    @ApiOperation("根据项目id查询该项目的五要素模型信息")
    public AjaxResult list(@Valid  ZwIdPageReq zwIdPageReq) {
        basicInformationService.testXmId(zwIdPageReq.getXmId());
        return success(wysmxInformationService.list(zwIdPageReq));
    }

    /**
     * 新增数据
     *
     * @param wysmxInformation 实体对象
     * @return 新增结果
     */
    @PreAuthorize("@ss.hasAnyRoles('admin,common,gov')")
    @PostMapping("/add")
    @ApiOperation("新增数据")
    public AjaxResult insert(@RequestBody WysmxInformation wysmxInformation) {
        return success(wysmxInformationService.save(wysmxInformation));
    }

    /**
     * 修改数据
     *
     * @param wysmxInformation 实体对象
     * @return 修改结果
     */
    @PostMapping("/edit")
    @ApiOperation("修改数据")
    public AjaxResult update(@RequestBody WysmxInformation wysmxInformation) {
        basicInformationService.testXmId(wysmxInformation.getXmId());
        return success(wysmxInformationService.updateById(wysmxInformation));
    }
}

