package com.cyksj.service.user.impl;

import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.cyksj.common.util.Jsons;
import com.cyksj.mapper.UserBenefitsMapper;
import com.cyksj.model.entity.UserBenefits;
import com.cyksj.service.user.UserBenefitsBackService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 项目名: yhlxj2
 * 文件名: UserBenefitsBackServiceImpl
 * 创建者: JavaZou
 * 创建时间:2024/9/23 15:22
 */
@Service
public class UserBenefitsBackServiceImpl extends ServiceImpl<UserBenefitsMapper, UserBenefits> implements UserBenefitsBackService {

	@Override
	public void saveOrUpdatePojo(UserBenefits userBenefits) throws Exception {
		List<UserBenefits.RenewConfig> renewConfigList = userBenefits.getRenewConfigList();
		if (CollUtil.isNotEmpty(renewConfigList)) {
			userBenefits.setRenewConfig(Jsons.toJson(renewConfigList));
		}
		this.saveOrUpdate(userBenefits);
	}
}
