package com.zcloud.basic.info.command.query;

import com.alibaba.cola.dto.MultiResponse;
import com.alibaba.cola.dto.PageResponse;
import com.zcloud.basic.info.command.convertor.UserEmploymentLogCoConvertor;
import com.zcloud.basic.info.dto.UserEmploymentLogPageQry;
import com.zcloud.basic.info.dto.UserEmploymentLogQryCmd;
import com.zcloud.basic.info.dto.clientobject.UserEmploymentLogCO;
import com.zcloud.basic.info.persistence.dataobject.UserEmploymentLogDO;
import com.zcloud.basic.info.persistence.repository.UserEmploymentLogRepository;
import com.zcloud.gbscommon.utils.PageQueryHelper;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.Map;


/**
 * web-app
 *
 * @Author zhangyue
 * @Date 2025-11-06 19:15:37
 */
@Component
@AllArgsConstructor
public class UserEmploymentLogQueryExe {
    private final UserEmploymentLogRepository userEmploymentLogRepository;
    private final UserEmploymentLogCoConvertor userEmploymentLogCoConvertor;

    /**
     * 分页
     *
     * @param userEmploymentLogPageQry
     * @return
     */
    public PageResponse<UserEmploymentLogCO> execute(UserEmploymentLogPageQry userEmploymentLogPageQry) {
        Map<String, Object> params = PageQueryHelper.toHashMap(userEmploymentLogPageQry);
        PageResponse<UserEmploymentLogDO> pageResponse = userEmploymentLogRepository.listPage(params);
        List<UserEmploymentLogCO> examCenterCOS = userEmploymentLogCoConvertor.converDOsToCOs(pageResponse.getData());
        return PageResponse.of(examCenterCOS, pageResponse.getTotalCount(), pageResponse.getPageSize(), pageResponse.getPageIndex());
    }
    /**
     * 列表
     *
     * @param userEmploymentLogQryCmd
     * @return
     */
    public MultiResponse<UserEmploymentLogCO> executeListAll(UserEmploymentLogQryCmd userEmploymentLogQryCmd) {
        Map<String, Object> params = PageQueryHelper.toHashMap(userEmploymentLogQryCmd);
        List<UserEmploymentLogDO> userEmploymentLogDOList = userEmploymentLogRepository.listAll(params);
        List<UserEmploymentLogCO> userEmploymentLogCOList = userEmploymentLogCoConvertor.converDOsToCOs(userEmploymentLogDOList);
        return MultiResponse.of(userEmploymentLogCOList);
    }



}

