# SettingFirstDayController.java

    package cloud.wconnect.workperformance.controller.sva;

    import cloud.wconnect.commonlib.annotation.ApiId;
    import cloud.wconnect.commonlib.component.SessionContext;
    import cloud.wconnect.workperformance.entity.sva.setting.FirstDay;
    import cloud.wconnect.workperformance.pojo.dto.common.FirstDayDTO;
    import cloud.wconnect.workperformance.service.sva.setting.IFirstDayService;
    import com.google.common.collect.ImmutableMap;
    import jakarta.annotation.Resource;
    import jakarta.validation.Valid;
    import org.springframework.beans.factory.annotation.Value;
    import org.springframework.web.bind.annotation.*;

    import java.util.Collections;
    import java.util.Map;
    import java.util.Objects;

    /**
     * 控制器类：first day
     *
     * @author zc
     * @date 2023/03/20
     */
    @RestController
    @RequestMapping("/sva/setting/first-day")
    public class SettingFirstDayController {
        @Resource
        private IFirstDayService firstDayService;
        @Resource
        private SessionContext sessionContext;

        @Value("${default.first-day.sva-setting}")
        private Integer defaultFirstDayOfWeek;

        /**
         * 设置周起始日
         *
         * @param property    资产标识
         * @param firstDayDTO 周起始日
         * @return empty map
         * @author zc
         * @date 2023/3/20
         */
        @ApiId(84)
        @PostMapping
        public Map<Object, Object> save(@RequestParam String property, @RequestBody @Valid FirstDayDTO firstDayDTO) {
            int propertyId = sessionContext.getPropertyId(property);
            firstDayService.save(propertyId, sessionContext.getLoginUserId(), firstDayDTO);
            return Collections.emptyMap();
        }

        /**
         * 获取周起始日
         *
         * @param property 资产标识
         * @return 周起始日（1:Mon, 2:Tue, 3:Wed, 4:Thu, 5:Fri, 6:Sat, 7:Sun）
         * @author zc
         * @date 2023/3/20
         */
        @ApiId(89)
        @GetMapping
        public Map<String, Integer> get(@RequestParam String property) {
            int propertyId = sessionContext.getPropertyId(property);
            FirstDay result = firstDayService.get(propertyId);
            return ImmutableMap.of("firstDay", Objects.isNull(result) ? defaultFirstDayOfWeek : result.getFirstDay());
        }
    }