2023-05-25 21:00:12 +08:00

112 lines
3.4 KiB
Smarty
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#set(tableComment = table.getComment())
#set(entityClassName = table.buildEntityClassName())
#set(entityVarName = firstCharToLowerCase(entityClassName))
#set(serviceVarName = firstCharToLowerCase(table.buildServiceClassName()))
package #(packageConfig.controllerPackage);
import com.mybatisflex.core.paginate.Page;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.beans.factory.annotation.Autowired;
import #(packageConfig.entityPackage).#(entityClassName);
import #(packageConfig.servicePackage).#(table.buildServiceClassName());
#if(controllerConfig.restStyle)
import org.springframework.web.bind.annotation.RestController;
#else
import org.springframework.stereotype.Controller;
#end
#if(controllerConfig.supperClass)
import #(controllerConfig.buildSuperClassImport());
#end
import java.io.Serializable;
import java.util.List;
/**
* #(tableComment) 控制层。
*
* @author #(javadocConfig.getAuthor())
* @since #(javadocConfig.getSince())
*/
#if(controllerConfig.restStyle)
@RestController
#else
@Controller
#end
@RequestMapping("/#(firstCharToLowerCase(entityClassName))")
public class #(table.buildControllerClassName()) #if(controllerConfig.supperClass)extends #(controllerConfig.buildSuperClassName()) #end {
@Autowired
private #(table.buildServiceClassName()) #(serviceVarName);
/**
* #(tableComment)
*
* @param #(entityVarName) #(tableComment)
* @return {@code true} {@code false}
*/
@PostMapping("save")
public boolean save(@RequestBody #(entityClassName) #(entityVarName)) {
return #(serviceVarName).save(#(entityVarName));
}
/**
* #(tableComment)
*
* @param id
* @return {@code true} {@code false}
*/
@DeleteMapping("remove/{id}")
public boolean remove(@PathVariable Serializable id) {
return #(serviceVarName).removeById(id);
}
/**
* #(tableComment)
*
* @param #(entityVarName) #(tableComment)
* @return {@code true} {@code false}
*/
@PutMapping("update")
public boolean update(@RequestBody #(entityClassName) #(entityVarName)) {
return #(serviceVarName).updateById(#(entityVarName));
}
/**
* #(tableComment)
*
* @return
*/
@GetMapping("list")
public List<#(entityClassName)> list() {
return #(serviceVarName).list();
}
/**
* #(tableComment)
*
* @param id #(tableComment)
* @return #(tableComment)
*/
@GetMapping("getInfo/{id}")
public #(entityClassName) getInfo(@PathVariable Serializable id) {
return #(serviceVarName).getById(id);
}
/**
* #(tableComment)
*
* @param page
* @return
*/
@GetMapping("page")
public Page<#(entityClassName)> page(Page<#(entityClassName)> page) {
return #(serviceVarName).page(page);
}
}