/*
 * 文 件 名:  ObjTagController
 * 版    权:  华设设计集团股份有限公司
 * 描    述:  <描述>
 * 修 改 人:  lvwenbin
 * 修改时间:  2025/9/3
 * 跟踪单号:  <跟踪单号>
 * 修改单号:  <修改单号>
 * 修改内容:  <修改内容>
 */
package com.ruoyi.ems.controller;

import com.huashe.common.domain.AjaxResult;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.ems.domain.ObjTagRel;
import com.ruoyi.ems.service.IObjTagRelService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * <一句话功能简述>
 * <功能详细描述>
 *
 * @author lvwenbin
 * @version [版本号, 2025/9/3]
 * @see [相关类/方法]
 * @since [产品/模块版本]
 */
@RestController
@RequestMapping("/tag")
@Api(value = "ObjTagController", description = "对象标签接口")
public class ObjTagController extends BaseController {
    @Resource
    private IObjTagRelService objTagRelService;

    /**
     * 新增能源对象属性
     */
    @PostMapping(value = "/rel")
    @ApiOperation(value = "saveObjTagRel", notes = "保存标签-对象关系")
    public AjaxResult saveObjTagRel(ObjTagRel objTagRel) {
        return toAjax(objTagRelService.save(objTagRel));
    }

    /**
     * 删除能源对象属性
     */
    @DeleteMapping(value = "/rel")
    @ApiOperation(value = "removeObjTagRel", notes = "保存标签-对象关系")
    public AjaxResult removeObjTagRel(ObjTagRel objTagRel) {
        return toAjax(objTagRelService.remove(objTagRel));
    }

    /**
     * 查询对象&标签关系列表
     *
     * @param objType 标签类型
     * @return 对象&标签关系集合
     */
    @GetMapping(value = "/rel/getByObjType")
    @ApiOperation(value = "getRelByObjType", notes = "根据对象类型查询绑定关系")
    public AjaxResult getRelByObjType(@RequestParam(name = "objType") Integer objType) {
        List<ObjTagRel> list = objTagRelService.selectListByType(objType);
        return success(list);
    }

    /**
     * 查询对象&标签关系
     *
     * @param objType 标签类型
     * @param tagCode 标签代码
     * @return 结果
     */
    @GetMapping(value = "/rel/selectByTagCode")
    @ApiOperation(value = "selectRelByTagCode", notes = "根据标签代码查询绑定关系")
    public AjaxResult selectRelByTagCode(@RequestParam(name = "objType") Integer objType,
        @RequestParam(name = "tagCode") String tagCode) {
        List<ObjTagRel> list = objTagRelService.selectListByTagCode(objType, tagCode);
        return success(list);
    }

    /**
     * 查询对象&标签关系
     *
     * @param objType 标签类型
     * @param objCode 标签代码
     * @return 结果
     */
    @GetMapping(value = "/rel/selectByObjCode")
    @ApiOperation(value = "selectRelByObjCode", notes = "根据对象代码查询绑定关系")
    public AjaxResult selectRelByObjCode(@RequestParam(name = "objType") Integer objType,
        @RequestParam(name = "objCode") String objCode) {
        List<ObjTagRel> list = objTagRelService.selectListByObjCode(objType, objCode);
        return success(list);
    }
}