package com.gxwebsoft.tower.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gxwebsoft.tower.mapper.TowerSecurityMapper;
import com.gxwebsoft.tower.service.TowerSecurityService;
import com.gxwebsoft.tower.entity.TowerSecurity;
import com.gxwebsoft.tower.param.TowerSecurityParam;
import com.gxwebsoft.common.core.web.PageParam;
import com.gxwebsoft.common.core.web.PageResult;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 安全检查Service实现
 *
 * @author 科技小王子
 * @since 2024-02-22 13:44:23
 */
@Service
public class TowerSecurityServiceImpl extends ServiceImpl<TowerSecurityMapper, TowerSecurity> implements TowerSecurityService {

    @Override
    public PageResult<TowerSecurity> pageRel(TowerSecurityParam param) {
        PageParam<TowerSecurity, TowerSecurityParam> page = new PageParam<>(param);
        page.setDefaultOrder("create_time desc");
        List<TowerSecurity> list = baseMapper.selectPageRel(page, param);
        return new PageResult<>(list, page.getTotal());
    }

    @Override
    public List<TowerSecurity> listRel(TowerSecurityParam param) {
        List<TowerSecurity> list = baseMapper.selectListRel(param);
        // 排序
        PageParam<TowerSecurity, TowerSecurityParam> page = new PageParam<>();
        //page.setDefaultOrder("create_time desc");
        return page.sortRecords(list);
    }

    @Override
    public TowerSecurity getByIdRel(Integer securityId) {
        TowerSecurityParam param = new TowerSecurityParam();
        param.setSecurityId(securityId);
        return param.getOne(baseMapper.selectListRel(param));
    }

}
