package org.springblade.person.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.person.entity.Adolescent;
import org.springblade.person.vo.AdolescentVO;
import org.springblade.person.wrapper.AdolescentWrapper;
import org.springblade.person.service.IAdolescentService;
import org.springblade.core.boot.ctrl.BladeController;
import java.util.List;
/**
 *  client
 *
 * @author lianghanqiang
 * @since 2021-05-28
 */

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

public class AdolescentClient implements IAdolescentClient {

    private final IAdolescentService adolescentService;

        /**
     * 详情
     */
    @Override
    @GetMapping("/detail")
    public AdolescentVO detail(@SpringQueryMap Adolescent adolescent) {
        Adolescent detail = adolescentService.getOne(Condition.getQueryWrapper(adolescent));
        return AdolescentWrapper.build().entityVO(detail);
        }

    /**
     * 查询
     */
    @Override
    @GetMapping("/list")
    public List<AdolescentVO> list(Adolescent adolescent) {
        return AdolescentWrapper.build().listVO(adolescentService.list(Condition.getQueryWrapper(adolescent)));
        }



    /**
     * 新增
     */
    @Override
    @PostMapping("/save")
    public boolean save(@Valid @RequestBody Adolescent adolescent) {
        return adolescentService.save(adolescent);
        }

    /**
     * 修改
     */
    @Override
    @PostMapping("/update")
    public boolean update(@Valid @RequestBody Adolescent adolescent) {
        return adolescentService.updateById(adolescent);
        }

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


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


}
