package com.jeethink.system.controller;

import java.util.HashMap;
import java.util.List;
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.jeethink.common.annotation.Log;
import com.jeethink.common.core.controller.BaseController;
import com.jeethink.common.core.domain.AjaxResult;
import com.jeethink.common.enums.BusinessType;
import com.jeethink.system.domain.CeshiInfo;
import com.jeethink.system.service.ICeshiInfoService;
import com.jeethink.common.utils.poi.ExcelUtil;
import com.jeethink.common.core.page.TableDataInfo;

/**
 * 测试Controller
 * 
 * @author sh
 * @date 2022-03-01
 */
@RestController
@RequestMapping("/system/ceshiInfo")
public class CeshiInfoController extends BaseController
{
    @Autowired
    private ICeshiInfoService ceshiInfoService;

    /**
     * 查询测试列表
     */
    @PreAuthorize("@ss.hasPermi('system:ceshiInfo:list')")
    @GetMapping("/list")
    public TableDataInfo list(CeshiInfo ceshiInfo)
    {
        startPage();
        List<CeshiInfo> list = ceshiInfoService.selectCeshiInfoList(ceshiInfo);
        return getDataTable(list);
    }

    /**
     * 导出测试列表
     */
    @PreAuthorize("@ss.hasPermi('system:ceshiInfo:export')")
    @Log(title = "测试", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(CeshiInfo ceshiInfo)
    {
        List<CeshiInfo> list = ceshiInfoService.selectCeshiInfoList(ceshiInfo);
        ExcelUtil<CeshiInfo> util = new ExcelUtil<CeshiInfo>(CeshiInfo.class);
        return util.exportExcel(list, "ceshiInfo");
    }

    /**
     * 获取测试详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:ceshiInfo:query')")
    @GetMapping(value = "/{ceshiId}")
    public AjaxResult getInfo(@PathVariable("ceshiId") String ceshiId)
    {
        String sql=" select ceshi_id as ceshiId, name, phone, age, time from ceshi_info  where ceshi_id ='1' ";
        /*HashMap hashMap=new HashMap();
        hashMap.put("sql",sql);*/
        return AjaxResult.success(ceshiInfoService.selectCeshiInfoById(sql));
    }

    /**
     * 新增测试
     */
    @PreAuthorize("@ss.hasPermi('system:ceshiInfo:add')")
    @Log(title = "测试", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CeshiInfo ceshiInfo)
    {
        return toAjax(ceshiInfoService.insertCeshiInfo(ceshiInfo));
    }

    /**
     * 修改测试
     */
    @PreAuthorize("@ss.hasPermi('system:ceshiInfo:edit')")
    @Log(title = "测试", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CeshiInfo ceshiInfo)
    {
        return toAjax(ceshiInfoService.updateCeshiInfo(ceshiInfo));
    }

    /**
     * 删除测试
     */
    @PreAuthorize("@ss.hasPermi('system:ceshiInfo:remove')")
    @Log(title = "测试", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ceshiIds}")
    public AjaxResult remove(@PathVariable String[] ceshiIds)
    {
        return toAjax(ceshiInfoService.deleteCeshiInfoByIds(ceshiIds));
    }
}
