package com.yuchen.saas.park.service.service.work.impl;

import com.yuchen.saas.park.api.dto.work.SaasWorkOrderCategorySettingDto;
import com.yuchen.saas.park.api.entity.work.SaasWorkOrderCategorySetting;
import com.yuchen.saas.park.api.vo.work.SaasWorkOrderCategorySettingVo;
import com.yuchen.saas.park.service.mapper.work.SaasWorkOrderCategorySettingMapper;
import com.yuchen.saas.park.service.service.work.ISaasWorkOrderCategorySettingService;
import org.nest.springwrap.core.mp.base.BaseServiceImpl;
import org.nest.springwrap.core.tool.utils.BeanUtil;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 工单大类设置表 服务实现类
 * </p>
 *
 * @author caiwq
 * @since 2024-10-12
 */
@Service
public class SaasWorkOrderCategorySettingServiceImpl extends BaseServiceImpl<SaasWorkOrderCategorySettingMapper, SaasWorkOrderCategorySetting> implements ISaasWorkOrderCategorySettingService {

    @Override
    public Boolean add(SaasWorkOrderCategorySettingDto dto) {
        SaasWorkOrderCategorySetting workOrderCategorySetting = BeanUtil.copyProperties(dto, SaasWorkOrderCategorySetting.class);
        return saveOrUpdate(workOrderCategorySetting);
    }

    @Override
    public SaasWorkOrderCategorySettingVo getDetail(Long customerId) {
        SaasWorkOrderCategorySetting workOrderCategorySetting = this.lambdaQuery().eq(SaasWorkOrderCategorySetting::getCustomerId, customerId).last("LIMIT 1").one();
        return BeanUtil.copyProperties(workOrderCategorySetting, SaasWorkOrderCategorySettingVo.class);
    }

}
