package cn.ey.biz.module.system.api.engagement.task;

import cn.ey.biz.common.pojo.R;
import cn.ey.biz.module.system.api.engagement.code.EngagementCodeRuleApi;
import cn.ey.biz.module.system.api.engagement.code.dto.EngagementCodeRuleSimpleRespDTO;
import cn.ey.biz.module.system.api.engagement.task.dto.EngagementTaskRuleSimpleRespDTO;
import cn.ey.biz.module.system.convert.engagement.code.EngagementCodeRuleConvert;
import cn.ey.biz.module.system.convert.engagement.task.EngagementTaskRuleConvert;
import cn.ey.biz.module.system.dal.dataobject.engagement.code.SystemEngagementCodeRuleDO;
import cn.ey.biz.module.system.dal.dataobject.engagement.task.SystemEngagementTaskRuleDO;
import cn.ey.biz.module.system.service.engagement.code.EngagementCodeRuleService;
import cn.ey.biz.module.system.service.engagement.task.EngagementTaskRuleService;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

import static cn.ey.biz.module.system.enums.ApiConstants.VERSION;

@RestController // 提供 RESTful API 接口，给 Feign 调用
@DubboService(version = VERSION) // 提供 Dubbo RPC 接口，给 Dubbo Consumer 调用
@Validated
public class EngagementTaskRuleApiImpl implements EngagementTaskRuleApi {

    @Resource
    private EngagementTaskRuleService taskRuleService;


    @Override
    public R<List<EngagementTaskRuleSimpleRespDTO>> getTaskRuleList() {
        List<SystemEngagementTaskRuleDO> taskRuleSimpleList = taskRuleService.getTaskRuleSimpleList();
        List<EngagementTaskRuleSimpleRespDTO> dto = EngagementTaskRuleConvert.INSTANCE.doConvertDto(taskRuleSimpleList);
        return R.success(dto);
    }
}
