package com.ycwl.basic.controller.pc;

import com.github.pagehelper.PageInfo;
import com.ycwl.basic.model.pc.member.entity.MemberEntity;
import com.ycwl.basic.model.pc.member.req.MemberReqQuery;
import com.ycwl.basic.model.pc.member.resp.MemberRespVO;
import com.ycwl.basic.service.pc.MemberService;
import com.ycwl.basic.utils.ApiResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Author：longbinbin
 * @Date：2024/12/2 17:21
 */
@RestController
@RequestMapping("/api/member/v1")
@Api(tags = "前台用户管理")
public class MemberController {
    @Autowired
    private MemberService memberService;

    @ApiOperation("前台用户分页查询")
    @PostMapping("/page")
    public ApiResponse<PageInfo<MemberRespVO>> pageQuery(@RequestBody MemberReqQuery memberReqQuery) {
        return memberService.pageQuery(memberReqQuery);
    }
    @ApiOperation("前台用户列表查询")
    @PostMapping("/list")
    public ApiResponse<List<MemberRespVO>> list(@RequestBody MemberReqQuery memberReqQuery) {
        return memberService.list(memberReqQuery);
    }
    @ApiOperation("前台用户详情查询")
    @GetMapping("/getDetail/{id}")
    public ApiResponse<MemberRespVO> getDetail(@PathVariable("id") Long id) {
        return memberService.getById(id);
    }
    @ApiOperation("前台用户删除")
    @DeleteMapping("/delete/{id}")
    public ApiResponse<Integer> delete(@PathVariable("id") Long id) {
        return memberService.deleteById(id);
    }
    @ApiOperation("前台用户新增")
    @PostMapping("/add")
    public ApiResponse<Integer> add(@RequestBody MemberEntity member) {
        return memberService.add(member);
    }
    @ApiOperation("前台用户修改")
    @PostMapping("/update")
    public ApiResponse<Integer> update(@RequestBody MemberEntity member) {
        return memberService.update(member);
    }

}
