# OvertimeWidgetController.java

    package cloud.wconnect.workperformance.controller.mor.overtime;

    import cloud.wconnect.commonlib.annotation.ApiId;
    import cloud.wconnect.commonlib.component.SessionContext;
    import cloud.wconnect.commonlib.cons.BaseErrorCodeEnum;
    import cloud.wconnect.commonlib.exception.ForbiddenException;
    import cloud.wconnect.commonlib.pojo.dto.PropertyDTO;
    import cloud.wconnect.commonlib.redis.PropertyI18nRedisService;
    import cloud.wconnect.workperformance.pojo.dto.mor.overtime.widget.OvertimeAmountsDTO;
    import cloud.wconnect.workperformance.pojo.query.mor.overtime.OvertimeAmountQuery;
    import cloud.wconnect.workperformance.service.mor.IOvertimeWidgetService;
    import com.google.common.collect.Sets;
    import jakarta.annotation.Resource;
    import jakarta.validation.Valid;
    import org.springframework.web.bind.annotation.GetMapping;
    import org.springframework.web.bind.annotation.RequestMapping;
    import org.springframework.web.bind.annotation.RestController;

    import java.util.List;

    /**
     * Controller: overtime widget
     *
     * @author zc
     * @date 2023/12/09
     */
    @RestController
    @RequestMapping("/mor/overtime/widget")
    public class OvertimeWidgetController {
        @Resource
        private IOvertimeWidgetService widgetService;
        @Resource
        private PropertyI18nRedisService propertyI18nRedisService;
        @Resource
        private SessionContext sessionContext;

        /**
         * 统计不同资产下的加班费用
         *
         * @param query 查询条件
         * @return OvertimeAmountsDTO 集合
         * @author zc
         * @date 2023/12/9
         */
        @ApiId(981)
        @GetMapping("/amount")
        public List<OvertimeAmountsDTO> listAmounts(@Valid OvertimeAmountQuery query) {
            if (!Sets.newHashSet(sessionContext.getPropertyIds()).containsAll(query.getPropertyIds())) {
                throw new ForbiddenException(BaseErrorCodeEnum.DATA_FORBIDDEN.getI18nCode(),
                        BaseErrorCodeEnum.DATA_FORBIDDEN.getCode(),
                        "Cannot be operated others property data; propertyIds: " + query.getPropertyIds());
            }
            List<PropertyDTO> propertyDTOList = propertyI18nRedisService.list(query.getPropertyIds());
            return widgetService.listAmounts(propertyDTOList, query);
        }
    }