package com.zehong.web.controller.checktask;

import com.zehong.common.annotation.Log;
import com.zehong.common.core.controller.BaseController;
import com.zehong.common.core.domain.AjaxResult;
import com.zehong.common.core.page.TableDataInfo;
import com.zehong.common.enums.BusinessType;
import com.zehong.common.utils.poi.ExcelUtil;
import com.zehong.system.domain.TRectifyGroupMemberInfo;
import com.zehong.system.service.ITRectifyGroupMemberInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * 整改组内成员信息Controller
 * 
 * @author zehong
 * @date 2026-07-16
 */
@RestController
@RequestMapping("/danger/member")
public class TRectifyGroupMemberInfoController extends BaseController
{
    @Autowired
    private ITRectifyGroupMemberInfoService tRectifyGroupMemberInfoService;

    /**
     * 查询整改组内成员信息列表
     */
    //@PreAuthorize("@ss.hasPermi('system:info:list')")
    @GetMapping("/list")
    public TableDataInfo list(TRectifyGroupMemberInfo tRectifyGroupMemberInfo)
    {
        startPage();
        List<TRectifyGroupMemberInfo> list = tRectifyGroupMemberInfoService.selectTRectifyGroupMemberInfoList(tRectifyGroupMemberInfo);
        return getDataTable(list);
    }

    /**
     * 导出整改组内成员信息列表
     */
    //@PreAuthorize("@ss.hasPermi('system:info:export')")
    @Log(title = "整改组内成员信息", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(TRectifyGroupMemberInfo tRectifyGroupMemberInfo)
    {
        List<TRectifyGroupMemberInfo> list = tRectifyGroupMemberInfoService.selectTRectifyGroupMemberInfoList(tRectifyGroupMemberInfo);
        ExcelUtil<TRectifyGroupMemberInfo> util = new ExcelUtil<TRectifyGroupMemberInfo>(TRectifyGroupMemberInfo.class);
        return util.exportExcel(list, "整改组内成员信息数据");
    }

    /**
     * 获取整改组内成员信息详细信息
     */
    //@PreAuthorize("@ss.hasPermi('system:info:query')")
    @GetMapping(value = "/{memberId}")
    public AjaxResult getInfo(@PathVariable("memberId") Long memberId)
    {
        return AjaxResult.success(tRectifyGroupMemberInfoService.selectTRectifyGroupMemberInfoById(memberId));
    }

    /**
     * 新增整改组内成员信息
     */
    //@PreAuthorize("@ss.hasPermi('system:info:add')")
    @Log(title = "整改组内成员信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TRectifyGroupMemberInfo tRectifyGroupMemberInfo)
    {
        return toAjax(tRectifyGroupMemberInfoService.insertTRectifyGroupMemberInfo(tRectifyGroupMemberInfo));
    }

    /**
     * 修改整改组内成员信息
     */
    //@PreAuthorize("@ss.hasPermi('system:info:edit')")
    @Log(title = "整改组内成员信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TRectifyGroupMemberInfo tRectifyGroupMemberInfo)
    {
        return toAjax(tRectifyGroupMemberInfoService.updateTRectifyGroupMemberInfo(tRectifyGroupMemberInfo));
    }

    /**
     * 删除整改组内成员信息
     */
    //@PreAuthorize("@ss.hasPermi('system:info:remove')")
    @Log(title = "整改组内成员信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{memberIds}")
    public AjaxResult remove(@PathVariable Long[] memberIds)
    {
        return toAjax(tRectifyGroupMemberInfoService.deleteTRectifyGroupMemberInfoByIds(memberIds));
    }

    /**
     * 根据职位获取整改人信息
     * @param map
     * @return
     */
    @PostMapping("/selectRectifyUserByPostCode")
    public AjaxResult selectRectifyUserByPostCode(@RequestBody Map<String,Object> map) {
        return AjaxResult.success(tRectifyGroupMemberInfoService.selectRectifyUserByPostCode(map));
    }


    /**
     * 根据登录人职位获取可选成员小程序接口
     * @return
     */
    @GetMapping("/selectMemberByUserPost")
    public AjaxResult selectMemberByUserPost(String dealMethod){
        return AjaxResult.success(tRectifyGroupMemberInfoService.selectMemberByUserPost(dealMethod));
    }
}
