package com.microservices.pms.product.controller;

import com.microservices.common.core.web.controller.BaseController;
import com.microservices.common.core.web.domain.AjaxResult;
import com.microservices.common.core.web.domain.GenericsAjaxResult;
import com.microservices.common.core.web.page.GenericsTableDataInfo;
import com.microservices.common.log.annotation.Log;
import com.microservices.common.log.enums.BusinessType;
import com.microservices.common.security.annotation.Logical;
import com.microservices.common.security.annotation.RequiresPermissions;
import com.microservices.pms.product.domain.PmsProductRequirementTag;
import com.microservices.pms.product.domain.vo.PmsProductRequirementTagInputVo;
import com.microservices.pms.product.domain.vo.PmsProductRequirementTagSearchVo;
import com.microservices.pms.product.domain.vo.PmsProductRequirementTagUpdateVo;
import com.microservices.pms.product.service.IPmsProductRequirementTagService;
import com.microservices.pms.utils.PmsConstants;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * 产品需求标记Controller
 * 
 * @author otto
 * @date 2023-10-10
 */
@RestController
@Api(tags = "项目管理-产品需求标记相关接口")
@RequestMapping("/{enterpriseIdentifier}/pmsProductRequirementTag")
@ApiImplicitParams({
        @ApiImplicitParam(name = "enterpriseIdentifier", value = "企业标识", paramType = "path", dataType = "String")
})
public class PmsProductRequirementTagController extends BaseController
{
    @Autowired
    private IPmsProductRequirementTagService pmsProductRequirementTagService;

    /**
     * 查询产品需求标记列表
     */
    @RequiresPermissions(value = {"pms:pmsProductRequirementTag:show", "pms:pmsProductRequirementTag:manage", "pms:pmsProduct:show"}, logical = Logical.OR)
    @GetMapping("/list")
    @ApiOperation(value = "查询产品需求标记列表")
    public GenericsTableDataInfo<PmsProductRequirementTag> list(
            @PathVariable String enterpriseIdentifier,
            @Validated PmsProductRequirementTagSearchVo pmsProductRequirementTagSearchVo)
    {
        startPage();
        return pmsProductRequirementTagService
                .selectPmsProductRequirementTagList(
                        enterpriseIdentifier
                        , pmsProductRequirementTagSearchVo.toPmsProductRequirementTag()
                        , PmsConstants.PRODUCT_TAG_AND_MODULE_TYPE);
    }

    /**
     * 获取产品需求标记详细信息
     */
    @RequiresPermissions(value = {"pms:pmsProductRequirementTag:show", "pms:pmsProductRequirementTag:manage", "pms:pmsProduct:show"}, logical = Logical.OR)
    @GetMapping(value = "/{id}")
    @ApiOperation(value = "获取产品需求标记详细信息")
    public GenericsAjaxResult<PmsProductRequirementTag> getInfo(@PathVariable("id") Long id)
    {
        return genericsSuccess(pmsProductRequirementTagService.selectPmsProductRequirementTagById(id));
    }

    /**
     * 新增产品需求标记
     */
    @RequiresPermissions("pms:pmsProductRequirementTag:manage")
    @Log(title = "产品需求标记", businessType = BusinessType.INSERT)
    @PostMapping
    @ApiOperation(value = "新增产品需求标记")
    public AjaxResult add(@RequestBody @Validated PmsProductRequirementTagInputVo pmsProductRequirementTagInputVo)
    {
        return toAjax(pmsProductRequirementTagService.insertPmsProductRequirementTag(pmsProductRequirementTagInputVo.toPmsProductRequirementTag(), PmsConstants.PRODUCT_TAG_AND_MODULE_TYPE));
    }

    /**
     * 修改产品需求标记
     */
    @RequiresPermissions("pms:pmsProductRequirementTag:manage")
    @Log(title = "产品需求标记", businessType = BusinessType.UPDATE)
    @PutMapping
    @ApiOperation(value = "修改产品需求标记")
    public AjaxResult edit(@RequestBody @Validated PmsProductRequirementTagUpdateVo pmsProductRequirementTagUpdateVo)
    {
        return toAjax(pmsProductRequirementTagService.updatePmsProductRequirementTag(pmsProductRequirementTagUpdateVo.toPmsProductRequirementTag()));
    }

    /**
     * 删除产品需求标记
     */
    @RequiresPermissions("pms:pmsProductRequirementTag:manage")
    @Log(title = "产品需求标记", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    @ApiOperation(value = "删除产品需求标记")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(pmsProductRequirementTagService.deletePmsProductRequirementTagByIds(ids));
    }
}
