package com.ruoyi.cms.controller.app;


import com.ruoyi.cms.domain.vo.CompanyContactVo;
import com.ruoyi.cms.service.CompanyContactService;
import com.ruoyi.cms.util.ListUtil;
import com.ruoyi.common.annotation.BussinessLog;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.entity.CompanyContact;
import com.ruoyi.common.core.page.TableDataInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;


/**
 * 公司联系人
 *
 * @author 
 * @email 
 * @date 2025-09-30 15:57:06
 */
@RestController
@RequestMapping("/app/companycontact")
@Api(tags = "移动端：公司联系人")
public class AppCompanyContactController extends BaseController {
    @Autowired
    private CompanyContactService companyContactService;

    /**
     * 列表
     */
    @ApiOperation("公司联系人列表")
    @GetMapping("/list")
    public TableDataInfo list(CompanyContact companyContact){
        List<CompanyContact> list=companyContactService.getSelectList(companyContact);
        return getDataTable(list);
    }

    @BussinessLog(title = "移动端保存企业联系人")
    @PostMapping("/batchInsertUpdate")
    public AjaxResult batchInsertUpdate(@RequestBody CompanyContactVo contactVo)
    {
        if (contactVo == null) {
            return AjaxResult.error("请求参数不能为空");
        }
        List<CompanyContact> contactList = contactVo.getCompanyContactList();
        if (ListUtil.isListObjectEmptyOrNull(contactList)) { // 假设 ListUtil 工具类判断 null 或空集合
            return AjaxResult.error("请至少填写一条联系人信息");
        }
        companyContactService.insertUpadteCompanyContact(contactList);
        return success();
    }
}
