package org.springblade.party.feign;

import io.swagger.annotations.ApiParam;
import lombok.AllArgsConstructor;
import javax.validation.Valid;
import org.springblade.core.mp.support.Condition;
import org.springblade.core.tool.utils.Func;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RequestParam;
import org.springblade.party.entity.Comment;
import org.springblade.party.vo.CommentVO;
import org.springblade.party.wrapper.CommentWrapper;
import org.springblade.party.service.ICommentService;
import org.springblade.core.boot.ctrl.BladeController;
import java.util.List;
/**
 *  client
 *
 * @author lianghanqiang
 * @since 2021-04-19
 */

@AllArgsConstructor
@RestController
@RequestMapping("/feign/comment")

public class CommentClient implements ICommentClient {

    private final ICommentService commentService;

        /**
     * 详情
     */
    @Override
    @GetMapping("/detail")
    public CommentVO detail(Comment comment) {
        Comment detail = commentService.getOne(Condition.getQueryWrapper(comment));
        return CommentWrapper.build().entityVO(detail);
        }

    /**
     * 查询
     */
    @Override
    @GetMapping("/list")
    public List<CommentVO> list(Comment comment) {
        return CommentWrapper.build().listVO(commentService.list(Condition.getQueryWrapper(comment)));
        }



    /**
     * 新增
     */
    @Override
    @PostMapping("/save")
    public boolean save(@Valid @RequestBody Comment comment) {
        return commentService.save(comment);
        }

    /**
     * 修改
     */
    @Override
    @PostMapping("/update")
    public boolean update(@Valid @RequestBody Comment comment) {
        return commentService.updateById(comment);
        }

    /**
     * 新增或修改
     */
    @Override
    @PostMapping("/submit")
    public boolean submit(@Valid @RequestBody Comment comment) {
        return commentService.saveOrUpdate(comment);
        }


    /**
     * 删除
     */
    @Override
    @PostMapping("/remove")
    public boolean remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) {
        return commentService.deleteLogic(Func.toLongList(ids));
        }


}
