# SalesWidgetController.java

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

    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.sales.widget.SalesAmountsDTO;
    import cloud.wconnect.workperformance.pojo.query.mor.sales.SalesAmountQuery;
    import cloud.wconnect.workperformance.service.mor.ISalesWidgetService;
    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: widget
     *
     * @author zc
     * @date 2023/12/09
     */
    @RestController
    @RequestMapping("/mor/sales-sources/widget")
    public class SalesWidgetController {
        @Resource
        private ISalesWidgetService widgetService;
        @Resource
        private PropertyI18nRedisService propertyI18nRedisService;
        @Resource
        private SessionContext sessionContext;

        /**
         * 获取销售金额
         *
         * @param query 查询条件
         * @return SalesAmountsDTO 集合
         * @author zc
         * @date 2023/12/9
         */
        @ApiId(982)
        @GetMapping("/amount")
        public List<SalesAmountsDTO> listAmounts(@Valid SalesAmountQuery 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);
        }
    }