package com.dayou.controller;

import com.dayou.vo.BusinessReplyVO;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springframework.web.bind.annotation.RestController;
import com.dayou.controller.BaseController;
import com.dayou.service.IBusinessReplyService;
import com.dayou.entity.BusinessReply;
import com.dayou.common.RestResponse;
import org.springframework.web.bind.annotation.*;
import com.dayou.utils.ConvertUtil;
import com.dayou.utils.HttpKit;
import com.dayou.exception.ErrorCode;
import java.util.Date;
import java.util.List;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.springframework.http.MediaType;
import org.springframework.web.multipart.MultipartFile;
/**
 * 业务回复表
 *
 * @author wucl
 * @since 2023-03-23
 */
@RestController
@RequestMapping("businessReply")
@Slf4j
public class BusinessReplyController extends BaseController {
    @Autowired
    private IBusinessReplyService businessReplyService;

    /**
    * 业务回复表列表
    */
    @GetMapping("")
    public RestResponse<Page<BusinessReplyVO>> page(BusinessReply businessReply, Page page){
        Page<BusinessReplyVO> pages=businessReplyService.selectPage(page,businessReply);
        return RestResponse.data(pages);
    }

    /**
     * 业务回复表详情
     */
    @GetMapping("/{id}")
    public RestResponse<BusinessReply> detail(@PathVariable Long id){
        BusinessReply xBusinessReply =businessReplyService.detail(id);
        return RestResponse.data(xBusinessReply);
     }

    /**
     * 业务回复表新增
     */
    @PostMapping("")
    public RestResponse<Boolean> save(@RequestBody BusinessReply businessReply) {
        Boolean ret = businessReplyService.reply(businessReply);
        return RestResponse.data(ret);
    }

    /**
     * 业务回复表更新
     */
    @PutMapping("")
    public RestResponse<Boolean> update(@RequestBody BusinessReply businessReply) {
        Boolean ret = businessReplyService.update(businessReply);
        return RestResponse.data(ret);
    }

    /**
     * 业务回复表删除
     */
    @DeleteMapping("/{id}")
    public RestResponse<Boolean> delete(@PathVariable Long id) {
        Boolean ret = businessReplyService.delete(id);
        return RestResponse.data(ret);
    }

    /**
     * 获取未读消息个数
     * @param businessReply
     * @return
     */
    @GetMapping("/notRead")
    public RestResponse<Integer> getNotReadCount(BusinessReply businessReply){
        Integer notReadCount = businessReplyService.getNotReadCount(businessReply);
        return RestResponse.data(notReadCount);
    }

}

