package com.emoon.openplatform.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.emoon.openplatform.domain.AskInfoDo;
import com.emoon.openplatform.mapper.AskInfoMapper;
import com.emoon.openplatform.service.IAskInfoService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

/**
 * @author destiny
 * @description:
 * @date 2025/9/29 10:27
 */
@Slf4j
@Service
@RequiredArgsConstructor
public class AskInfoServiceImpl implements IAskInfoService {

    private final AskInfoMapper askInfoMapper;

    @Override
    public Integer insertAskInfo(AskInfoDo askInfoDo) {
        return askInfoMapper.insert(askInfoDo);
    }

    @Override
    public AskInfoDo findByToken(String token) {
        return askInfoMapper.selectOne(new LambdaQueryWrapper<>(AskInfoDo.class).eq(AskInfoDo::getToken, token));
    }

    @Override
    public Integer updateReplyByToken(String token, String reply) {
        return askInfoMapper.update(AskInfoDo.builder().reply(reply).build(),
            new LambdaQueryWrapper<>(AskInfoDo.class).eq(AskInfoDo::getToken, token));
    }
}
