package com.css.txw.gxzx.service.impl;

import cn.hutool.core.util.IdUtil;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.css.ggzc.framework.common.util.gy.GyUtils;
import com.css.ggzc.framework.common.util.object.BeanUtils;
import com.css.ggzc.framework.session.SessionUtils;
import com.css.txw.gxzx.pojo.vo.GxscReqVO;
import com.css.txw.gxzx.service.TxwGxzxGxscbService;
import com.css.txw.gxzx.pojo.domain.TxwGxzxGxscbDO;
import com.css.txw.gxzx.mapper.TxwGxzxGxscbMapper;
import org.springframework.stereotype.Service;

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

/**
* @author AirlH
* @description 针对表【txw_gxzx_gxscb(供需收藏表)】的数据库操作Service实现
* @createDate 2025-09-19 14:05:38
*/
@Service
public class TxwGxzxGxscbServiceImpl extends ServiceImpl<TxwGxzxGxscbMapper, TxwGxzxGxscbDO>
    implements TxwGxzxGxscbService {

    @Resource
    private TxwGxzxGxscbMapper gxscbMapper;

    @Override
    public String gxsc(GxscReqVO reqVO) {
        if ("add".equals(reqVO.getType())){
            List<TxwGxzxGxscbDO> byGxuuidandYhuuid = gxscbMapper.getByGxuuidandYhuuid(reqVO.getGxUuid(), SessionUtils.getYhUuid());
            if (!GyUtils.isNull(byGxuuidandYhuuid)) return "success";
            TxwGxzxGxscbDO gxscbDO = BeanUtils.toBean(reqVO,TxwGxzxGxscbDO.class);
            gxscbDO.setUuid(IdUtil.fastSimpleUUID());
            gxscbDO.setYhUuid(SessionUtils.getYhUuid());
            gxscbDO.setLrrq(new Date());
            this.save(gxscbDO);
        }else if ("remove".equals(reqVO.getType())){
            gxscbMapper.removeByGxuuidAndYhuuid(reqVO.getGxUuid(),SessionUtils.getYhUuid());
        }
        return "success";
    }
}




