package cn.ey.biz.module.system.api.timesheet;

import cn.ey.biz.common.pojo.R;
import cn.ey.biz.module.system.api.timesheet.dto.TimesheetApproveRuleDTO;
import cn.ey.biz.module.system.convert.timesheet.TimesheetApproveRuleConvert;
import cn.ey.biz.module.system.dal.dataobject.timesheet.TimesheetApproveRuleDO;
import cn.ey.biz.module.system.service.timesheet.TimesheetApproveRuleService;
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 TimesheetApproveRuleApiImpl implements TimesheetApproveRuleApi {
    @Resource
    private TimesheetApproveRuleService timesheetApproveRuleService;

    @Override
    public R<List<TimesheetApproveRuleDTO>> listApproveRule() {
        List<TimesheetApproveRuleDO> timesheetApproveRuleDOS = timesheetApproveRuleService.listApproveRule();
        return R.success(TimesheetApproveRuleConvert.INSTANCE.convertField(timesheetApproveRuleDOS));
    }
}
