package com.zehong.web.controller.detector;

import java.util.List;

import com.zehong.system.domain.vo.TDetectorUserVO;
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.zehong.common.annotation.Log;
import com.zehong.common.core.controller.BaseController;
import com.zehong.common.core.domain.AjaxResult;
import com.zehong.common.enums.BusinessType;
import com.zehong.system.domain.TDetectorUser;
import com.zehong.system.service.ITDetectorUserService;
import com.zehong.common.utils.poi.ExcelUtil;
import com.github.pagehelper.PageInfo;
import com.zehong.common.core.page.TableDataInfo;

/**
 * 探测器用户Controller
 * 
 * @author zehong
 * @date 2021-11-02
 */
@RestController
@RequestMapping("/detector/detectorUser")
public class TDetectorUserController extends BaseController
{
    @Autowired
    private ITDetectorUserService tDetectorUserService;

     /**
     * 查询探测器用户列表
     */
    @PreAuthorize("@ss.hasPermi('detector:detectorUser:list')")
    @GetMapping("/list")
    public TableDataInfo list(TDetectorUser tDetectorUser)
    {
        startPage();
        PageInfo<TDetectorUser> list = tDetectorUserService.selectTDetectorUserPage(tDetectorUser);
        return getDataTable(list);
    }

    /**
     * 获取探测器用户列表
     * @param tDetectorUser
     * @return
     */
    @GetMapping("/detectorUserList")
    public AjaxResult detectorUserList(TDetectorUser tDetectorUser){
        return AjaxResult.success(tDetectorUserService.detectorUserList(tDetectorUser));
    }

    /**
     * 导出探测器用户列表
     */
    @PreAuthorize("@ss.hasPermi('detector:detectorUser:export')")
    @Log(title = "探测器用户", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(TDetectorUser tDetectorUser)
    {
        List<TDetectorUserVO> list = tDetectorUserService.detectorUserList(tDetectorUser);
        ExcelUtil<TDetectorUserVO> util = new ExcelUtil<TDetectorUserVO>(TDetectorUserVO.class);
        return util.exportExcel(list, "探测器用户数据");
    }

    /**
     * 获取探测器用户详细信息
     */
    @PreAuthorize("@ss.hasPermi('detector:detectorUser:query')")
    @GetMapping(value = "/{userId}")
    public AjaxResult getInfo(@PathVariable("userId") Long userId)
    {
        return AjaxResult.success(tDetectorUserService.selectTDetectorUserById(userId));
    }

    /**
     * 新增探测器用户
     */
    @PreAuthorize("@ss.hasPermi('detector:detectorUser:add')")
    @Log(title = "探测器用户", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TDetectorUser tDetectorUser)
    {
        return toAjax(tDetectorUserService.insertTDetectorUser(tDetectorUser));
    }

    /**
     * 修改探测器用户
     */
    @PreAuthorize("@ss.hasPermi('detector:detectorUser:edit')")
    @Log(title = "探测器用户", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TDetectorUser tDetectorUser)
    {
        return toAjax(tDetectorUserService.updateTDetectorUser(tDetectorUser));
    }

    /**
     * 删除探测器用户
     */
    @PreAuthorize("@ss.hasPermi('detector:detectorUser:remove')")
    @Log(title = "探测器用户", businessType = BusinessType.DELETE)
	@DeleteMapping("/{userIds}")
    public AjaxResult remove(@PathVariable Long[] userIds)
    {
        return toAjax(tDetectorUserService.deleteTDetectorUserByIds(userIds));
    }
}
