package com.ruoyi.web.controller.liandao;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.query.LambdaQueryWrapperX;
import com.ruoyi.liandao.domain.ComplaintSuggestions;
import com.ruoyi.liandao.dto.complaintSuggestions.ComplaintSuggestionsPageReqDto;
import com.ruoyi.liandao.service.ComplaintSuggestionsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 投诉建议接口
 *
 * @Author : chenzhengyu
 * @create 2024/3/20 14:57
 */
@RestController
@RequestMapping("/liandao/complaint/suggestions")
public class ComplaintSuggestionsController extends BaseController {

    @Autowired
    private ComplaintSuggestionsService service;

    /**
     * 分页查询
     *
     * @param dto
     * @return
     */
    @GetMapping("/page")
    public TableDataInfo page(ComplaintSuggestionsPageReqDto dto) {
        IPage<ComplaintSuggestions> iPage = service.page((IPage<ComplaintSuggestions>) dto.getPage(),
                new LambdaQueryWrapperX<ComplaintSuggestions>()
                        .eqIfPresent(ComplaintSuggestions::getType, dto.getType())
                        .betweenIfPresent(ComplaintSuggestions::getCreateTime, dto.getStartTime(), dto.getEndTime())
                        .orderByDesc(ComplaintSuggestions::getCreateTime));
        return getDataTable(iPage);
    }

}
