#set($packegeFeign=$package.Entity.replace("entity","feign"))
package $!{packegeFeign};

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.*;
#if($!{superEntityClass})
import org.springframework.web.bind.annotation.RequestParam;
#end
import $!{package.Entity}.$!{entity};
#set($voPackage=$package.Entity.replace("entity","vo"))
import $!{voPackage}.$!{entity}VO;
#set($wrapperPackage=$package.Entity.replace("entity","wrapper"))
#if($!{cfg.hasWrapper})
import $!{wrapperPackage}.$!{entity}Wrapper;
#end
import $!{package.Service}.$!{table.serviceName};
#if($!{superControllerClassPackage})
import $!{superControllerClassPackage};
#end
#if(!$!{superEntityClass})
#end
import java.util.List;
/**
 * $!{table.comment} client
 *
 * @author lianghanqiang
 * @since $!{date}
 */

@AllArgsConstructor
@RestController
@RequestMapping("/feign#if($!{package.ModuleName})/$!{package.ModuleName}#end/$!{cfg.entityKey}")

public class $!{entity}Client implements I$!{entity}Client {

    private final $!{table.serviceName} $!{table.entityPath}Service;

    #if($!{cfg.hasWrapper})
    /**
     * 详情
     */
    @Override
    @GetMapping("/detail")
    public $!{entity}VO detail($!{entity} $!{table.entityPath}) {
        $!{entity} detail = $!{table.entityPath}Service.getOne(Condition.getQueryWrapper($!{table.entityPath}));
        return $!{entity}Wrapper.build().entityVO(detail);
        }

    /**
     * 查询 $!{table.comment}
     */
    @Override
    @GetMapping("/list")
    public List<$!{entity}VO> list($!{entity} $!{table.entityPath}) {
        return $!{entity}Wrapper.build().listVO($!{table.entityPath}Service.list(Condition.getQueryWrapper($!{table.entityPath})));
        }

    #else
    /**
     * 详情
     */
    @Override
    @GetMapping("/detail")
    public $!{entity} detail($!{entity} $!{table.entityPath}) {
        $!{entity} detail = $!{table.entityPath}Service.getOne(Condition.getQueryWrapper($!{table.entityPath}));
        return detail;
        }

    /**
     * 查询 $!{table.comment}
     */
    @Override
    @GetMapping("/list")
    public List<$!{entity}> list($!{entity} $!{table.entityPath}) {
        return $!{table.entityPath}Service.list(Condition.getQueryWrapper($!{table.entityPath}));
        }
    #end


    /**
     * 新增 $!{table.comment}
     */
    @Override
    @PostMapping("/save")
    public boolean save(@Valid @RequestBody $!{entity} $!{table.entityPath}) {
        return $!{table.entityPath}Service.save($!{table.entityPath});
        }

    /**
     * 修改 $!{table.comment}
     */
    @Override
    @PostMapping("/update")
    public boolean update(@Valid @RequestBody $!{entity} $!{table.entityPath}) {
        return $!{table.entityPath}Service.updateById($!{table.entityPath});
        }

    /**
     * 新增或修改 $!{table.comment}
     */
    @Override
    @PostMapping("/submit")
    public boolean submit(@Valid @RequestBody $!{entity} $!{table.entityPath}) {
        return $!{table.entityPath}Service.saveOrUpdate($!{table.entityPath});
        }

    #if($!{superEntityClass})

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

    #else

    /**
     * 删除 $!{table.comment}
     */
    @Override
    @PostMapping("/remove")
    public boolean remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) {
        return $!{table.entityPath}Service.removeByIds(Func.toLongList(ids));
        }

    #end

}
