Pārlūkot izejas kodu

fix (model): 支持json数据结构

1538940682@qq.com 3 gadi atpakaļ
vecāks
revīzija
a1c952eb46

+ 7 - 2
src/main/resources/template/AddPO.java.vm

@@ -1,6 +1,6 @@
 package ${package}.${moduleName}.biz.po;
 
-
+import com.alibaba.fastjson.JSONObject;
 #if(${hasBigDecimal})
 import java.math.BigDecimal;
 #end
@@ -39,8 +39,13 @@ public class ${className}AddPO implements Serializable {
 #elseif($column.attrType != "String" && $column.nullable == "NO")
 	@NotNull(message = "$column.comments 不能为空")
 #end
+#if($column.attrType == "Json")
 	@ApiModelProperty(value = "$column.comments")
-	private $column.attrType $column.attrname;
+	private JSONObject $column.attrname;
+#else
+    @ApiModelProperty(value = "$column.comments")
+    private $column.attrType $column.attrname;
+#end
 	#end
 #end
 

+ 6 - 6
src/main/resources/template/Controller.java.vm

@@ -34,7 +34,7 @@ import java.util.Arrays;
  */
 @Api(tags="${comments}")
 @RestController
-@RequestMapping(value = "${moduleName}/${pathName}", produces = {MediaType.APPLICATION_JSON_UTF8_VALUE})
+@RequestMapping(value = "/${moduleName}/${pathName}")
 public class ${className}Controller extends BaseController {
 
     @Resource
@@ -43,7 +43,7 @@ public class ${className}Controller extends BaseController {
     /**
      * 分页
      */
-    @GetMapping("page")
+    @GetMapping("/page")
     @ApiOperation("分页")
     @RequiresPermissions("${moduleName}:${pathName}:page")
     public ApiResponse<Pagination<${className}VO>> page(${className}PagePO request) {
@@ -55,7 +55,7 @@ public class ${className}Controller extends BaseController {
     /**
      * 信息
      */
-    @GetMapping("getById/{id}")
+    @GetMapping("/getById/{id}")
     @ApiOperation("信息")
     @RequiresPermissions("${moduleName}:${pathName}:info")
     public ApiResponse<${className}VO> getById(@PathVariable("id") Long id) {
@@ -67,7 +67,7 @@ public class ${className}Controller extends BaseController {
     /**
      * 保存
      */
-    @PostMapping("save")
+    @PostMapping("/save")
     @ApiOperation("保存")
     @RequiresPermissions("${moduleName}:${pathName}:save")
     @Transactional(rollbackFor = Exception.class)
@@ -80,7 +80,7 @@ public class ${className}Controller extends BaseController {
     /**
      * 修改
      */
-    @PutMapping("update")
+    @PutMapping("/update")
     @ApiOperation("修改")
     @RequiresPermissions("${moduleName}:${pathName}:update")
     @Transactional(rollbackFor = Exception.class)
@@ -93,7 +93,7 @@ public class ${className}Controller extends BaseController {
     /**
      * 删除
      */
-    @DeleteMapping("delete")
+    @DeleteMapping("/delete")
     @ApiOperation("删除")
     @RequiresPermissions("${moduleName}:${pathName}:delete")
     @Transactional(rollbackFor = Exception.class)

+ 5 - 0
src/main/resources/template/DTO.java.vm

@@ -1,5 +1,6 @@
 package ${package}.${moduleName}.biz.dto;
 
+import com.alibaba.fastjson.JSONObject;
 #if(${hasBigDecimal})
 import java.math.BigDecimal;
 #end
@@ -25,7 +26,11 @@ public class ${className}DTO implements Serializable {
     /**
 	 * $column.comments
 	 */
+#if($column.attrType == "Json")
+	private JSONObject $column.attrname;
+#else
 	private $column.attrType $column.attrname;
 #end
+#end
 
 }

+ 8 - 0
src/main/resources/template/Entity.java.vm

@@ -1,5 +1,8 @@
 package ${package}.${moduleName}.biz.entity;
 
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.extension.handlers.FastjsonTypeHandler;
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
 import ${package}.common.database.entity.BaseEntity;
@@ -34,8 +37,13 @@ public class ${className}Entity extends BaseEntity implements Serializable {
     /**
 	 * $column.comments
 	 */
+#if($column.attrType == "Json")
+    @TableField(typeHandler = FastjsonTypeHandler.class)
+	private JSONObject $column.attrname;
+#else
 	private $column.attrType $column.attrname;
 #end
 #end
+#end
 
 }

+ 5 - 0
src/main/resources/template/UpdatePO.java.vm

@@ -1,5 +1,6 @@
 package ${package}.${moduleName}.api.web.request;
 
+import com.alibaba.fastjson.JSONObject;
 import ${package}.api.core.request.BaseRequest;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
@@ -42,7 +43,11 @@ public class ${className}UpdatePO implements Serializable {
 	@NotNull(message = "${column.comments}不能为空")
 #end
 	@ApiModelProperty(value = "$column.comments")
+#if($column.attrType == "Json")
+	private JSONObject $column.attrname;
+#else
 	private $column.attrType $column.attrname;
+#end
 	#end
 #end
 

+ 5 - 3
src/main/resources/template/VO.java.vm

@@ -1,5 +1,6 @@
 package ${package}.${moduleName}.biz.vo;
 
+import com.alibaba.fastjson.JSONObject;
 #if(${hasBigDecimal})
 import java.math.BigDecimal;
 #end
@@ -33,11 +34,12 @@ public class ${className}VO extends BaseVO implements Serializable {
      * $column.comments
      */
 	@ApiModelProperty(value = "$column.comments")
-#if($column.attrType == "LocalDateTime")
-	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
-#end
+#if($column.attrType == "Json")
+	private JSONObject $column.attrname;
+#else
 	private $column.attrType $column.attrname;
 #end
 #end
+#end
 
 }