package com.elephant.framework.galaxy.aroad.module.attendance.controller;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.elephant.framework.galaxy.aroad.response.R;
import com.elephant.framework.galaxy.aroad.module.common.annotation.SysLog;
import com.elephant.framework.galaxy.aroad.module.attendance.entity.AttendanceLogs;
import com.elephant.framework.galaxy.aroad.module.attendance.service.AttendanceLogsService;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;
import com.elephant.framework.galaxy.aroad.module.common.controller.BaseController;


/**
 * 值班日志表
 *
 * @author songwenjie
 * @date 2019-04-23 08:38:53
 */
@RestController
@AllArgsConstructor
@RequestMapping("/attendancelogs")
public class AttendanceLogsController extends BaseController  {

  private final  AttendanceLogsService attendanceLogsService;

  /**
   * 分页查询
   * @param page 分页对象
   * @param deptId 部门id
   * @return
   */
  @GetMapping("/page")
  public R getAttendanceLogsPage(Page page, Integer deptId) {
    return  new R<>(attendanceLogsService.getAttendanceLogsPage(page,deptId));
  }


  /**
   * 通过id查询值班日志表
   * @param logId id
   * @return R
   */
  @GetMapping("/{logId}")
  public R getById(@PathVariable("logId") Integer logId){
    return new R<>(attendanceLogsService.getById(logId));
  }

  /**
   * 新增值班日志表
   * @param attendanceLogs 值班日志表
   * @return R
   */
  @SysLog("新增值班日志表")
  @PostMapping
  public R save(@RequestBody AttendanceLogs attendanceLogs){
    return new R<>(attendanceLogsService.save(attendanceLogs));
  }

  /**
   * 修改值班日志表
   * @param attendanceLogs 值班日志表
   * @return R
   */
  @SysLog("修改值班日志表")
  @PutMapping
  public R updateById(@RequestBody AttendanceLogs attendanceLogs){
    return new R<>(attendanceLogsService.updateById(attendanceLogs));
  }

  /**
   * 通过id删除值班日志表
   * @param logId id
   * @return R
   */
  @SysLog("删除值班日志表")
  @DeleteMapping("/{logId}")
  public R removeById(@PathVariable Integer logId){
    return new R<>(attendanceLogsService.removeById(logId));
  }

}
