package org.springblade.system.expand.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.cloud.openfeign.SpringQueryMap;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RequestParam;
import org.springblade.system.expand.entity.Operation;
import org.springblade.system.expand.vo.OperationVO;
import org.springblade.system.expand.wrapper.OperationWrapper;
import org.springblade.system.expand.service.IOperationService;
import org.springblade.core.boot.ctrl.BladeController;
import java.util.List;
/**
 * 操作密码 client
 *
 * @author lianghanqiang
 * @since 2021-03-29
 */

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

public class OperationClient implements IOperationClient {

    private final IOperationService operationService;

        /**
     * 详情
     */
    @Override
    @GetMapping("/detail")
    public OperationVO detail(@SpringQueryMap Operation operation) {
        Operation detail = operationService.getOne(Condition.getQueryWrapper(operation));
        return OperationWrapper.build().entityVO(detail);
        }

    /**
     * 查询 操作密码
     */
    @Override
    @GetMapping("/list")
    public List<OperationVO> list(@SpringQueryMap Operation operation) {
        return OperationWrapper.build().listVO(operationService.list(Condition.getQueryWrapper(operation)));
        }



    /**
     * 新增 操作密码
     */
    @Override
    @PostMapping("/save")
    public boolean save(@Valid @RequestBody Operation operation) {
        return operationService.save(operation);
        }

    /**
     * 修改 操作密码
     */
    @Override
    @PostMapping("/update")
    public boolean update(@Valid @RequestBody Operation operation) {
        return operationService.updateById(operation);
        }

    /**
     * 新增或修改 操作密码
     */
    @Override
    @PostMapping("/submit")
    public boolean submit(@Valid @RequestBody Operation operation) {
        return operationService.saveOrUpdate(operation);
        }


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


}
