package com.jeesharp.business.modules.setting.service.impl;

import com.jeesharp.business.modules.setting.entity.CfgClientAppVersion;
import com.jeesharp.business.modules.setting.enums.ClientAppVersionStatusEnum;
import com.jeesharp.business.modules.setting.mapper.ClientAppVersionMapper;
import com.jeesharp.business.modules.setting.service.ClientAppVersionService;
import com.jeesharp.business.modules.setting.vo.ClientAppVersionQueryVO;
import com.jeesharp.framework.mybatis.core.service.CrudService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * C 端客户端版本发布领域服务实现。
 *
 * @author jeesharp
 * @since 2026-05-13
 */
@Service
@Transactional(readOnly = true)
public class ClientAppVersionServiceImpl extends CrudService<ClientAppVersionMapper, CfgClientAppVersion, ClientAppVersionQueryVO>
        implements ClientAppVersionService {

    @Override
    public List<CfgClientAppVersion> findPublishedOrderByVersionCodeDesc() {
        return this.lambdaQuery()
                .eq(CfgClientAppVersion::getStatus, ClientAppVersionStatusEnum.PUBLISHED.getValue())
                .eq(CfgClientAppVersion::getDelFlag, "0")
                .orderByDesc(CfgClientAppVersion::getVersionCode)
                .list();
    }

    @Override
    @Transactional(readOnly = false)
    public void createClientAppVersion(CfgClientAppVersion entity) {
        save(entity);
    }

    @Override
    @Transactional(readOnly = false)
    public void updateClientAppVersion(CfgClientAppVersion entity) {
        update(entity);
    }

}
