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.Setting;
import org.springblade.system.expand.vo.SettingVO;
import org.springblade.system.expand.wrapper.SettingWrapper;
import org.springblade.system.expand.service.ISettingService;
import org.springblade.core.boot.ctrl.BladeController;
import java.util.List;
/**
 *  client
 *
 * @author lianghanqiang
 * @since 2021-03-29
 */

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

public class SettingClient implements ISettingClient {

    private final ISettingService settingService;

        /**
     * 详情
     */
    @Override
    @GetMapping("/detail")
    public SettingVO detail(@SpringQueryMap Setting setting) {
        Setting detail = settingService.getOne(Condition.getQueryWrapper(setting));
        return SettingWrapper.build().entityVO(detail);
        }

    /**
     * 查询
     */
    @Override
    @GetMapping("/list")
    public List<SettingVO> list(@SpringQueryMap Setting setting) {
        return SettingWrapper.build().listVO(settingService.list(Condition.getQueryWrapper(setting)));
        }



    /**
     * 新增
     */
    @Override
    @PostMapping("/save")
    public boolean save(@Valid @RequestBody Setting setting) {
        return settingService.save(setting);
        }

    /**
     * 修改
     */
    @Override
    @PostMapping("/update")
    public boolean update(@Valid @RequestBody Setting setting) {
        return settingService.updateById(setting);
        }

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


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


}
