package com.mcwl.system.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.mcwl.system.domain.Policy;
import com.mcwl.system.mapper.PolicyMapper;
import com.mcwl.system.service.PolicyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @Author：ChenYan
 * @Project：mcwl-ai
 * @Package：com.mcwl.system.service.impl
 * @Filename：PolicyServiceImpl
 * @Description TODO
 * @Date：2025/2/14 10:13
 */
@Service
public class PolicyServiceImpl extends ServiceImpl<PolicyMapper, Policy> implements PolicyService  {
        @Autowired
        private  PolicyMapper policyMapper;
    public Policy getPolicyByType(String type) {
        return policyMapper.findByType(type);
    }

    public void updatePolicyContent(String type, String content) {
        Policy policy = policyMapper.findByType(type);
        if (policy != null) {
            policy.setContent(content);
            policyMapper.insert(policy);
        } else {
            throw new RuntimeException("Policy not found for type: " + type);
        }
    }

}
