package com.easyproject.web.controller.member;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.easyproject.common.core.domain.entity.ClientMember;
import com.easyproject.system.domain.vo.ClientMemberVo;
import com.easyproject.system.service.member.IClientMemberService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.easyproject.common.annotation.Log;
import com.easyproject.common.core.controller.BaseController;
import com.easyproject.common.core.domain.AjaxResult;
import com.easyproject.common.enums.BusinessType;
import com.easyproject.common.utils.poi.ExcelUtil;
import com.easyproject.common.core.page.TableDataInfo;

/**
 * 用户列表Controller
 *
 * @author easyproject
 * @date 2024-05-23
 */
@RestController
@RequestMapping("/system/member")
public class ClientMemberController extends BaseController
{
    @Autowired
    private IClientMemberService clientMemberService;

    /**
     * 查询用户列表列表
     */
    @PreAuthorize("@ss.hasPermi('system:member:list')")
    @GetMapping("/list")
    public TableDataInfo list(ClientMember clientMember)
    {
        startPage();
        TableDataInfo data = clientMemberService.selectClientMemberList(clientMember);
        return data;
    }

    /**
     * 导出用户列表列表
     */
    @PreAuthorize("@ss.hasPermi('system:member:export')")
    @Log(title = "用户列表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ClientMember clientMember)
    {
        List<ClientMemberVo> list = clientMemberService.selectClientMemberExportList(clientMember);
        ExcelUtil<ClientMemberVo> util = new ExcelUtil<ClientMemberVo>(ClientMemberVo.class);
        util.exportExcel(response, list, "用户列表数据");
    }

    /**
     * 获取用户列表详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:member:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(clientMemberService.selectClientMemberById(id));
    }

    /**
     * 修改用户列表
     */
    @PreAuthorize("@ss.hasPermi('system:member:edit')")
    @Log(title = "用户列表", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ClientMember clientMember)
    {
        return toAjax(clientMemberService.updateClientMember(clientMember));
    }
}
