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

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

public class TenantTypeClient implements ITenantTypeClient {

    private final ITenantTypeService tenantTypeService;

        /**
     * 详情
     */
    @Override
    @GetMapping("/detail")
    public TenantTypeVO detail(@SpringQueryMap TenantType tenantType) {
        TenantType detail = tenantTypeService.getOne(Condition.getQueryWrapper(tenantType));
        return TenantTypeWrapper.build().entityVO(detail);
        }

    /**
     * 查询
     */
    @Override
    @GetMapping("/list")
    public List<TenantTypeVO> list(@SpringQueryMap TenantType tenantType) {
        return TenantTypeWrapper.build().listVO(tenantTypeService.list(Condition.getQueryWrapper(tenantType)));
        }



    /**
     * 新增
     */
    @Override
    @PostMapping("/save")
    public boolean save(@Valid @RequestBody TenantType tenantType) {
        return tenantTypeService.save(tenantType);
        }

    /**
     * 修改
     */
    @Override
    @PostMapping("/update")
    public boolean update(@Valid @RequestBody TenantType tenantType) {
        return tenantTypeService.updateById(tenantType);
        }

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


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


}
