package com.owrawww.service;

import com.owrawww.domain.Quote;
import com.owrawww.domain.mapper.QuoteMapper;
import com.owrawww.util.AesUtil;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

@Service
@RequiredArgsConstructor
public class QuoteService {

    private final QuoteMapper quoteMapper;
    private final AesUtil aesUtil;

    public boolean submit(Quote quote) {
        Quote saved = new Quote();
            saved.setCode("3");
            saved.setTitle(quote.getTitle());
            saved.setComment(quote.getContent());
            saved.setName(quote.getName());
            saved.setTel(aesUtil.encrypt(quote.getTel()));
            saved.setTelHash(aesUtil.hash(quote.getTel()));
            saved.setEmail(aesUtil.encrypt(quote.getEmail()));
            saved.setEmailHash(aesUtil.hash(quote.getEmail()));
            saved.setTopCode(1);
            saved.setLeftCode(5);
            saved.setSubGubun(1);
            saved.setDepth(1);
            saved.setSolutionGubun("SOL001");

        return quoteMapper.insert(saved) > 0;
    }
}
