package com.fs.his.controller;

import java.util.List;

import com.fs.his.param.FsInquiryOrderDoctorPingParam;
import com.fs.his.vo.FsInquiryOrderPingExportListVO;
import com.fs.his.vo.FsInquiryOrderPingListVO;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.fs.common.annotation.Log;
import com.fs.common.core.controller.BaseController;
import com.fs.common.core.domain.AjaxResult;
import com.fs.common.enums.BusinessType;
import com.fs.his.domain.FsInquiryOrderPing;
import com.fs.his.service.IFsInquiryOrderPingService;
import com.fs.common.utils.poi.ExcelUtil;
import com.fs.common.core.page.TableDataInfo;

/**
 * 评价管理Controller
 *
 * @author fs
 * @date 2023-08-15
 */
@RestController
@RequestMapping("/his/inquiryOrderPing")
public class FsInquiryOrderPingController extends BaseController
{
    @Autowired
    private IFsInquiryOrderPingService fsInquiryOrderPingService;

    /**
     * 查询评价管理列表
     */
    @PreAuthorize("@ss.hasPermi('his:inquiryOrderPing:list')")
    @GetMapping("/list")
    public TableDataInfo list(FsInquiryOrderDoctorPingParam fsInquiryOrderPing)
    {
        startPage();
        List<FsInquiryOrderPingListVO> list = fsInquiryOrderPingService.selectFsInquiryOrderPingListVO(fsInquiryOrderPing);
        for (FsInquiryOrderPingListVO vo:list){
            if (vo.getPhone()!=null){
                vo.setPhone(vo.getPhone().replaceAll("(\\d{3})\\d*(\\d{4})", "$1****$2"));
            }
        }
        return getDataTable(list);
    }

    /**
     * 导出评价管理列表
     */
    @PreAuthorize("@ss.hasPermi('his:inquiryOrderPing:export')")
    @Log(title = "评价管理", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(FsInquiryOrderDoctorPingParam fsInquiryOrderPing)
    {
        List<FsInquiryOrderPingExportListVO> list = fsInquiryOrderPingService.selectFsInquiryOrderPingExportListVO(fsInquiryOrderPing);
        for (FsInquiryOrderPingExportListVO vo:list){
            if (vo.getPhone()!=null){
                vo.setPhone(vo.getPhone().replaceAll("(\\d{3})\\d*(\\d{4})", "$1****$2"));
            }
        }
        ExcelUtil<FsInquiryOrderPingExportListVO> util = new ExcelUtil<FsInquiryOrderPingExportListVO>(FsInquiryOrderPingExportListVO.class);
        return util.exportExcel(list, "评价管理数据");
    }

    /**
     * 获取评价管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('his:inquiryOrderPing:query')")
    @GetMapping(value = "/{pingId}")
    public AjaxResult getInfo(@PathVariable("pingId") Long pingId)
    {
        return AjaxResult.success(fsInquiryOrderPingService.selectFsInquiryOrderPingByPingId(pingId));
    }

    /**
     * 新增评价管理
     */
    @PreAuthorize("@ss.hasPermi('his:inquiryOrderPing:add')")
    @Log(title = "评价管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FsInquiryOrderPing fsInquiryOrderPing)
    {
        return toAjax(fsInquiryOrderPingService.insertFsInquiryOrderPing(fsInquiryOrderPing));
    }

    /**
     * 修改评价管理
     */
    @PreAuthorize("@ss.hasPermi('his:inquiryOrderPing:edit')")
    @Log(title = "评价管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FsInquiryOrderPing fsInquiryOrderPing)
    {
        return toAjax(fsInquiryOrderPingService.updateFsInquiryOrderPing(fsInquiryOrderPing));
    }

    /**
     * 删除评价管理
     */
    @PreAuthorize("@ss.hasPermi('his:inquiryOrderPing:remove')")
    @Log(title = "评价管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{pingIds}")
    public AjaxResult remove(@PathVariable Long[] pingIds)
    {
        return toAjax(fsInquiryOrderPingService.deleteFsInquiryOrderPingByPingIds(pingIds));
    }
}
