package com.its.op.controller.its.database;

import com.its.op.dto.its.oper.TbWwwMemberDto;
import com.its.op.service.its.oper.TbWwwMemberService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;

@Api(tags = "09.기초데이터관리-14.홈페이지관리자관리")
@Validated
@RestController
@RequiredArgsConstructor
@RequestMapping("/api/database/web-member")
public class TbWwwMemberController {

    private final TbWwwMemberService service;

    @ApiOperation(value = "홈페이지관리자 전체조회(TB_WWW_MEMBER)", response = TbWwwMemberDto.class, responseContainer = "ArrayList")
    @GetMapping(value = "", produces = {"application/json; charset=utf8"})
    public List<TbWwwMemberDto> findAll() {
        return this.service.findAll();
    }

//    @ApiOperation(value = "홈페이지관리자 전체조회(TB_WWW_MEMBER)", response = TbWwwMemberDto.class, responseContainer = "ArrayList")
//    @GetMapping(value = "/list", produces = {"application/json; charset=utf8"})
//    public List<TbWwwMemberDto> findAllList() {
//        return this.service.findAllList();
//    }

    @ApiOperation(value = "홈페이지관리자 개별조회(TB_WWW_MEMBER)", response = TbWwwMemberDto.class)
    @GetMapping(value = "/{email}", produces = {"application/json; charset=utf8"})
    public TbWwwMemberDto findById(@PathVariable("email") final String email) {
        return this.service.findById(email);
    }

    @ApiOperation(value = "홈페이지관리자 계정잠금 해제", response = TbWwwMemberDto.class)
    @PutMapping(value = "/{id}", produces = {"application/json; charset=utf8"})
    public TbWwwMemberDto accountLockFree(@PathVariable final String id) {
        return this.service.accountLockFree(id);
    }

//    @ApiOperation(value = "홈페이지관리자 정보변경(TB_WWW_MEMBER)", response = TbWwwMemberDto.class)
//    @PutMapping(value = "/{email}", produces = {"application/json; charset=utf8"})
//    public TbWwwMemberDto updateById(@PathVariable("email") final String email, @RequestBody @Valid final TbWwwMemberDto.TbWwwMemberUpdReq req) {
//        return this.service.updateById(email, req);
//    }

    @ApiOperation(value = "홈페이지관리자 정보변경/생성-목록(TB_WWW_MEMBER)", response = TbWwwMemberDto.class, responseContainer = "ArrayList")
    @PostMapping(value = "", produces = {"application/json; charset=utf8"})
    public List<TbWwwMemberDto> mergeInfoList(@RequestBody @Valid final List<TbWwwMemberDto.TbWwwMemberUpdReq> listReq) {
        return this.service.mergeInfoList(listReq);
    }

    @ApiOperation(value = "웹 사용자 정보 정보변경/생성-개별(TB_WWW_MEMBER)", response = TbWwwMemberDto.class)
    @PostMapping(value = "/{email}", produces = {"application/json; charset=utf8"})
    public TbWwwMemberDto mergeInfo(@PathVariable("email") final String email, @RequestBody @Valid final TbWwwMemberDto.TbWwwMemberUpdReq req) {
        return this.service.mergeInfo(req);
    }

    @ApiOperation(value = "웹 사용자 정보 정보삭제-개별(TB_WWW_MEMBER)", response = TbWwwMemberDto.class)
    @DeleteMapping(value = "/{email}", produces = {"application/json; charset=utf8"})
    public TbWwwMemberDto deleteDataById(@PathVariable("email") final String email) {
        return this.service.deleteById(email);
    }

    @ApiOperation(value = "웹 사용자 정보 정보삭제-목록(TB_WWW_MEMBER)", response = TbWwwMemberDto.class, responseContainer = "ArrayList")
    @DeleteMapping(value = "", produces = {"application/json; charset=utf8"})
    public List<TbWwwMemberDto> deleteDataByIds(@RequestBody @Valid final List<String> ids) {
        return this.service.deleteByIds(ids);
    }

}
