package com.mortals.xhx.module.platform.service.impl;

import cn.hutool.core.lang.PatternPool;
import com.mortals.framework.exception.AppException;
import com.mortals.framework.model.Context;
import com.mortals.framework.service.impl.AbstractCRUDCacheServiceImpl;
import com.mortals.xhx.module.platform.dao.PlatformDao;
import com.mortals.xhx.module.platform.model.PlatformEntity;
import com.mortals.xhx.module.platform.service.PlatformService;
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;

/**
* PlatformService
* 平台系统 service实现
*
* @author zxfei
* @date 2022-06-27
*/
@Service("platformService")
public class PlatformServiceImpl extends AbstractCRUDCacheServiceImpl<PlatformDao, PlatformEntity, Long> implements PlatformService {
    @Override
    protected void validData(PlatformEntity entity, Context context) throws AppException {

        if(!ObjectUtils.isEmpty(entity.getSendUrl())){
            if (!PatternPool.URL_HTTP.matcher(entity.getSendUrl()).find()) {
                throw new AppException("URL不合法");
            }
        }
        super.validData(entity, context);
    }
}