package ${package}.${moduleName}.controller; import lombok.AllArgsConstructor; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import com.baomidou.mybatisplus.plugins.Page; import com.pig4cloud.pigx.common.core.util.Query; import ${package}.${moduleName}.entity.${className}; import ${package}.${moduleName}.service.${className}Service; import com.pig4cloud.pigx.common.core.util.R; import java.util.Map; /** * ${comments} * * @author ${author} * @date ${datetime} */ @RestController @RequestMapping("/${pathName}") @AllArgsConstructor public class ${className}Controller { private final ${className}Service ${classname}Service; /** * 列表 * @param params * @return */ @GetMapping("/page") public R page(@RequestParam Map params) { return new R<>(${classname}Service.selectPage(new Query<>(params), new EntityWrapper<>())); } /** * 信息 * @param ${pk.lowerAttrName} * @return R */ @GetMapping("/{${pk.lowerAttrName}}") public R get${className}ById(@PathVariable("${pk.lowerAttrName}") ${pk.attrType} ${pk.lowerAttrName}){ return new R<>(${classname}Service.selectById(${pk.lowerAttrName})); } /** * 保存 * @param ${classname} * @return R */ @PostMapping public R save${className}(@RequestBody ${className} ${classname}){ return new R<>(${classname}Service.insert(${classname})); } /** * 修改 * @param ${classname} * @return R */ @PutMapping public R update${className}(@RequestBody ${className} ${classname}){ ${classname}Service.updateById(${classname}); return new R<>(Boolean.TRUE); } /** * 删除 * @param ${pk.lowerAttrName} * @return R */ @DeleteMapping("/{${pk.lowerAttrName}}") public R delete${className}ById(@PathVariable ${pk.attrType} ${pk.lowerAttrName}){ return new R<>(${classname}Service.deleteById(${pk.lowerAttrName})); } }