package ${package.Controller};

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springblade.core.tool.api.R;
import ${cfg.entityName}.${entity};
import ${cfg.voPath}.${entity}Vo;
import ${package.Service}.${table.serviceName};
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
#if(${restControllerStyle})
import org.springframework.web.bind.annotation.RestController;
#else
import org.springframework.stereotype.Controller;
#end
#if(${superControllerClassPackage})
import ${superControllerClassPackage};
#end

import java.util.Map;

/**
 * <p>
 * $!{table.comment} 前端控制器
 * </p>
 *
 * @author ${author}
 * @since ${date}
 */
#if(${restControllerStyle})
@RestController
#else
@Controller
#end
@RequestMapping("/${table.entityPath}")
#if(${kotlin})
class ${table.controllerName}#if(${superControllerClass}) : ${superControllerClass}()#end

#else
#if(${superControllerClass})
public class ${table.controllerName} extends ${superControllerClass} {
#else
public class ${table.controllerName} {
#end

    @Autowired
    private ${table.serviceName} ${table.entityPath}Service;

    @PostMapping("/page")
    public R page(@RequestBody Map<String, Object> condition){
        Page<${entity}> result = ${table.entityPath}Service.getPage(condition);
        return R.success(result);
    }

    @PostMapping("/add")
    public R add(@RequestBody ${entity}Vo ${table.entityPath}Vo){
        ${table.entityPath}Service.add(${table.entityPath}Vo);
        return R.success();
    }

    @PostMapping("/edit")
    public R edit(@RequestBody ${entity}Vo ${table.entityPath}Vo){
        ${table.entityPath}Service.edit(${table.entityPath}Vo);
        return R.success();
    }

    @PostMapping("/delete")
    public R delete(@RequestBody ${entity}Vo ${table.entityPath}Vo){
        ${table.entityPath}Service.delete(${table.entityPath}Vo);
        return R.success();
    }

}

#end
