package com.ycwl.basic.service.pc.impl;

import com.ycwl.basic.model.pc.scenic.entity.ScenicAccountEntity;
import com.ycwl.basic.model.pc.scenic.req.ScenicAccountReqQuery;
import com.ycwl.basic.service.pc.ScenicAccountService;
import com.ycwl.basic.utils.SnowFlakeUtil;
import org.springframework.stereotype.Service;
import com.ycwl.basic.mapper.ScenicAccountMapper;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

@Service
public class ScenicAccountServiceImpl implements ScenicAccountService {
    @Autowired
    private ScenicAccountMapper mapper;

    @Override
    public int addScenicAccount(ScenicAccountEntity entity) {
        if (entity.getId() == null) {
            entity.setId(SnowFlakeUtil.getLongId());
        }
        return mapper.add(entity);
    }

    @Override
    public int deleteScenicAccount(Long id) {
        return mapper.deleteById(id);
    }

    @Override
    public int updateScenicAccount(ScenicAccountEntity entity) {
        return mapper.update(entity);
    }

    @Override
    public ScenicAccountEntity getScenicAccountById(Long id) {
        return mapper.findAccountById(String.valueOf(id));
    }

    @Override
    public ScenicAccountEntity getSuperAccountByScenicId(Long scenicId) {
        return mapper.getSuperAccountOfScenic(scenicId);
    }

    // 新增分页查询实现
    @Override
    public List<ScenicAccountEntity> pageQuery(ScenicAccountReqQuery req) {
        return mapper.pageQuery(req);
    }

    @Override
    public int updateStatus(Long id) {
        return mapper.updateStatus(id);
    }
}