package com.mortals.xhx.modules.data.dao.ibatis;

import com.mortals.framework.model.ParamDto;
import com.mortals.xhx.common.pdu.ApiRespPdu;
import com.mortals.xhx.modules.data.dao.DataAreaDao;
import com.mortals.xhx.modules.data.model.DataAreaEntity;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Repository;
import com.mortals.framework.dao.ibatis.BaseCRUDDaoMybatis;

import java.util.List;

/**
* <p>Title: 地区表</p>
* <p>Description: DataAreaDaoImpl DAO接口 </p>
* @author
* @version 1.0.0
*/
@Repository("dataAreaDao")
@Slf4j
public class DataAreaDaoImpl extends BaseCRUDDaoMybatis<DataAreaEntity,Long> implements DataAreaDao {

    @Override
    public ApiRespPdu queryArea(Long id) {
        ParamDto paramDto = new ParamDto();
        paramDto.getCondition().put("id", id);
        ApiRespPdu<Object> objectApiRespPdu = new ApiRespPdu<>();
        try {
            List<DataAreaEntity> areaEntityList = this.getSqlSession().selectList(getSqlId("queryZone"), paramDto);
            objectApiRespPdu.setCode(1);
            objectApiRespPdu.setData(areaEntityList);
        }catch (Exception e){
            objectApiRespPdu.setCode(500);
            log.error("查询出错，错误原因："+e.getMessage());
        }
        return objectApiRespPdu;
    }
}
