package cn.qinys.platform.mobile.service.impl;

import cn.qinys.platform.entity.wishing.WishingTreeExtension;
import cn.qinys.platform.mobile.mapper.ChatMessageMapper;
import cn.qinys.platform.mobile.mapper.SpringAiChatMemoryMapper;
import cn.qinys.platform.mobile.mapper.UserWishMapper;
import cn.qinys.platform.mobile.mapper.WishingTreeExtensionMapper;
import cn.qinys.platform.mobile.service.ImageService;
import jakarta.annotation.Resource;

/**
 * @author lie tan
 * @description
 * @date 2026-06-07 17:25
 **/
public abstract class AbstractUserWishService {

    @Resource
    WishingTreeExtensionMapper treeExtensionMapper;

    public void treeWishesCounter(Integer treeId, Integer isPublic) {
        WishingTreeExtension extension = treeExtensionMapper.selectByTreeId(treeId);
        if (extension == null) {
            extension = new WishingTreeExtension();
            extension.setTreeId(treeId);
            extension.setTotalCount(0);
            extension.setPublicCount(0);
            extension.setPrivateCount(0);
        }
        extension.setTotalCount(extension.getTotalCount() + 1);
        if (isPublic == 1) {
            extension.setPublicCount(extension.getPublicCount() + 1);
        } else {
            extension.setPrivateCount(extension.getPrivateCount() + 1);
        }
        treeExtensionMapper.insertOrUpdate(extension);
    }


}
