package com.fjhx.oa.controller.daily;

import org.springframework.web.bind.annotation.*;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fjhx.oa.entity.daily.vo.DailyReportVo;
import com.fjhx.oa.entity.daily.dto.DailyReportSelectDto;
import com.fjhx.oa.entity.daily.dto.DailyReportDto;
import com.ruoyi.common.core.domain.BaseSelectDto;
import com.fjhx.oa.service.daily.DailyReportService;
import org.springframework.beans.factory.annotation.Autowired;


/**
 * <p>
 * 日报 前端控制器
 * </p>
 *
 * @author
 * @since 2023-04-04
 */
@RestController
@RequestMapping("/dailyReport")
public class DailyReportController {

    @Autowired
    private DailyReportService dailyReportService;

    /**
     * 日报分页
     */
    @PostMapping("/page")
    public Page<DailyReportVo> page(@RequestBody DailyReportSelectDto dto) {
        return dailyReportService.getPage(dto);
    }

    /**
     * 日报明细
     */
    @PostMapping("/detail")
    public DailyReportVo detail(@RequestBody BaseSelectDto dto) {
        return dailyReportService.detail(dto.getId());
    }

    /**
     * 日报新增
     */
    @PostMapping("/add")
    public void add(@RequestBody DailyReportDto dailyReportDto) {
        dailyReportService.add(dailyReportDto);
    }

    /**
     * 日报编辑
     */
    @PostMapping("/edit")
    public void edit(@RequestBody DailyReportDto dailyReportDto) {
        dailyReportService.edit(dailyReportDto);
    }

    /**
     * 日报删除
     */
    @PostMapping("/delete")
    public void delete(@RequestBody BaseSelectDto dto) {
        dailyReportService.delete(dto.getId());
    }

    /**
     * 个人日报统计
     */
    @PostMapping("/myCount")
    public DailyReportVo myCount() {
        return dailyReportService.myCount();
    }

    /**
     * 分享日报
     */
    @PostMapping("/share")
    public void share(@RequestBody DailyReportDto dto) {
        dailyReportService.share(dto.getId(), dto.getToUserId());
    }

}
