# AttendanceEmployeeController.java

    package cloud.wconnect.workperformance.controller.sva.employees;

    import cloud.wconnect.commonlib.annotation.ApiId;
    import cloud.wconnect.commonlib.component.SessionContext;
    import cloud.wconnect.commonlib.cons.BaseErrorCodeEnum;
    import cloud.wconnect.commonlib.cons.CommonErrorI18nConstant;
    import cloud.wconnect.commonlib.exception.BadRequestException;
    import cloud.wconnect.commonlib.pojo.dto.ListPagedDTO;
    import cloud.wconnect.workperformance.entity.sva.employees.AttendanceEmployee;
    import cloud.wconnect.workperformance.pojo.dto.sva.employee.AttendanceEmployeeListDTO;
    import cloud.wconnect.workperformance.pojo.dto.sva.employee.UpdateShownDTO;
    import cloud.wconnect.workperformance.pojo.query.sva.employee.AttendanceEmployeeQuery;
    import cloud.wconnect.workperformance.service.sva.employees.IAttendanceEmployeeService;
    import jakarta.annotation.Resource;
    import jakarta.validation.Valid;
    import org.springframework.web.bind.annotation.*;

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

    /**
     * <p>
     * 控制器类: 考勤系统员工信息表相关的接口
     * </p>
     *
     * @author zc
     * @since 2023-02-21
     */
    @RestController
    @RequestMapping("/sva/employees")
    public class AttendanceEmployeeController {

        @Resource
        private IAttendanceEmployeeService employeeService;
        @Resource
        private SessionContext sessionContext;

        /**
         * 获取指定检索条件下的Employee集合
         *
         * @param property 资产标识
         * @param query    检索条件
         * @return Employee集合
         * @author zc
         * @date 2023/2/21
         */
        @ApiId(62)
        @GetMapping
        public ListPagedDTO<AttendanceEmployeeListDTO> list(@RequestParam String property, @Valid AttendanceEmployeeQuery query) {
            int propertyId = sessionContext.getPropertyId(property);
            query.setPropertyId(propertyId);
            return employeeService.list(query);
        }

        /**
         * 修改 Employee 信息的可见性
         *
         * @param property       资产标识
         * @param updateShownDTO 更新所需内容
         * @author zc
         * @date 2023/2/23
         */
        @ApiId(65)
        @PutMapping("/visibleness")
        public Map<Object, Object> updateVisibleness(@RequestParam String property, @Valid @RequestBody UpdateShownDTO updateShownDTO) {
            AttendanceEmployee employee = employeeService.getById(updateShownDTO.getId());
            if (employee == null) {
                throw new BadRequestException(CommonErrorI18nConstant.DATA_NOT_FOUND,
                        BaseErrorCodeEnum.DATA_VALIDATION_ERROR.getCode(),
                        "Cannot found employee by this id; employeeId: " + updateShownDTO.getId());
            }
            int propertyId = sessionContext.getPropertyId(property);
            // 校验数据归属
            employeeService.checkBelong(propertyId, employee);

            if (!employee.getShown().equals(updateShownDTO.getShownValue())) {
                employeeService.updateVisibility(sessionContext.getLoginUserId(), updateShownDTO);
            }
            return Collections.emptyMap();
        }

    }