package com.trade.client.enterprise.companyrelated.controller;

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

import com.trade.client.enterprise.companyrelated.service.CBizEntityRelatedService;
import org.springframework.http.HttpStatus;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestController;

import com.trade.common.validate.OnCreate;
import com.trade.common.validate.OnUpdate;
import com.trade.service.enterprise.companyrelated.domain.vo.BizEntityRelatedSearch;
import com.trade.service.enterprise.companyrelated.domain.vo.BizEntityRelatedVO;

/**
 * <p>
 * 关系企业信息 前端控制器
 * </p>
 *
 * @author baomidou
 * @since 2024-05-28
 */
@RestController
@RequestMapping("/companyRelated")
public class BizEntityRelatedController {

    @Resource
    private CBizEntityRelatedService cBizEntityRelatedService;

    /**
     * 获取关系企业信息列表
     */
    @RequestMapping("/queryList")
    public Object queryList(BizEntityRelatedSearch search) {
        return cBizEntityRelatedService.queryListBySearch(search);
    }

    /**
     * 新增关系企业信息
     */
    @RequestMapping("/add")
    @Validated(OnCreate.class)
    public void add(@RequestBody @Valid BizEntityRelatedVO addBizEntity) {
        cBizEntityRelatedService.add(addBizEntity);
    }

    /**
     * 根据用户ID获取关系企业信息列表
     */
    @RequestMapping("/getByUserId")
    public Object getRelatedListByUserId(@NotNull(message = "用户ID不能为空") Long userId) {
        return cBizEntityRelatedService.getRelatedListByUserId(userId);
    }

    /**
     * 修改关系企业信息
     */
    @RequestMapping("/update")
    @Validated(OnUpdate.class)
    public void update(@RequestBody @Valid BizEntityRelatedVO updateBizEntity) {
        cBizEntityRelatedService.update(updateBizEntity);
    }

    /**
     * 根据关系企业ID获取关系企业信息
     */
    @RequestMapping("/getByBizEntityId")
    public Object getByBizEntityId(@NotNull(message = "关系企业ID不能为空") Long bizEntityId) {
        return cBizEntityRelatedService.getByBizEntityId(bizEntityId);
    }

    /**
     * 根据关系企业ID获取关系企业信息
     */
    @RequestMapping("/delete")
    public void deleteByBizEntityId(@NotNull(message = "关系企业ID不能为空") Long bizEntityId) {
        cBizEntityRelatedService.deleteByBizEntityId(bizEntityId);
    }
}
