package org.springblade.estate.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.estate.entity.Assets;
import org.springblade.estate.vo.AssetsVO;
import org.springblade.estate.wrapper.AssetsWrapper;
import org.springblade.estate.service.IAssetsService;
import org.springblade.core.boot.ctrl.BladeController;
import java.util.List;
/**
 *  client
 *
 * @author lianghanqiang
 * @since 2022-01-10
 */

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

public class AssetsClient implements IAssetsClient {

    private final IAssetsService assetsService;

        /**
     * 详情
     */
    @Override
    @GetMapping("/detail")
    public AssetsVO detail(Assets assets) {
        Assets detail = assetsService.getOne(Condition.getQueryWrapper(assets));
        return AssetsWrapper.build().entityVO(detail);
        }

    /**
     * 查询 
     */
    @Override
    @GetMapping("/list")
    public List<AssetsVO> list(Assets assets) {
        return AssetsWrapper.build().listVO(assetsService.list(Condition.getQueryWrapper(assets)));
        }

    

    /**
     * 新增 
     */
    @Override
    @PostMapping("/save")
    public boolean save(@Valid @RequestBody Assets assets) {
        return assetsService.save(assets);
        }

    /**
     * 修改 
     */
    @Override
    @PostMapping("/update")
    public boolean update(@Valid @RequestBody Assets assets) {
        return assetsService.updateById(assets);
        }

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

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

    
}
