提交 d8c90b4b 编写于 作者: sq3536's avatar sq3536

minicode

上级 b4e627d9
......@@ -113,7 +113,7 @@ public class {{pascalCase dict.codeName}}Dict {
}
}
@ApiModelProperty(value = "字典:{{dict.name}},示例", position = 1)
@ApiModelProperty(value = "字典:{{dict.name}},示例<a href='/xftong/link/dict/{{pascalCase dict.codeName}}Dict.html' target='_blank'>view</a>", position = 1)
public ENUM example;
@ApiModelProperty(value = "字典项清单", position = 2)
......
{{#eq apps "link"}}
package {{packageName}}.api.{{apps}}.dict;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.github.xiaoymin.knife4j.annotations.ApiSupport;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import cn.ibizlab.edge.api.link.annotation.G1;
import java.util.ArrayList;
import java.util.List;
@Slf4j
@Api(tags = {"数据字典" })
@RestController("link-DictAllResource")
@RequestMapping("/link/dict")
@G1
@ApiSupport(order = 98)
public class DictAllResource {
private String html="<html lang=\"en\"><head><meta charset=\"UTF-8\"><title></title>" +
"<style>table.reference,table.tecspec {table-layout:fixed;word-break:break-all;border-collapse: collapse;width:100%%;margin: 4px} table.reference .fa {font-size: 24px;} table.reference td:nth-child(odd) {background-color: #f2f7f9} table.reference td:nth-child(even) {background-color: #fff} table.reference tr.fixzebra {background-color: #f6f4f0} table.reference th {line-height: 2em;min-width: 24px;color: #fff;background-color: #555;border: 1px solid #555;font-size: 12px;padding: 3px;vertical-align: top;text-align: left} table.reference td {line-height: 2em;min-width: 24px;border: 1px solid #d4d4d4;padding: 5px;padding-top: 7px;padding-bottom: 7px;font-size: 12px;vertical-align: top;color: #606266;} .captr{height:0px;border: 0px;margin:0px;padding:0px}" +
"</style></header><body>%s<br/></body></html>";
private String template="<table class=\"reference\" id=\"%s\"><tr><th colspan=\"3\" align=\"center\">%s</th></tr>" +
"<tr><th></th><th>显示</th><th>上级值</th></tr>%s</table>";
private String templateItem="<tr><td>%s</td><td>%s</td><td>%s</td></tr>";
@ApiOperationSupport(order = 1)
@ApiOperation(value = "全部字典", tags = {"数据字典" }, notes = "<a href=\"/xftong/link/dict/all.html\" target=\"_blank\">view</a>")
@RequestMapping(method = RequestMethod.GET, value = "/all.html")
public ResponseEntity<String> getDict() {
List<String> all=new ArrayList<>();
{{#each app.dicts}}
{
List<String> tr=new ArrayList<>();
new {{pascalCase codeName}}Dict().getAllItems().forEach(item->tr.add(String.format(templateItem,item.getValue(),item.getLabel(),item.getParent()==null?"":item.getParent())));
all.add(String.format(template,"{{pascalCase codeName}}Dict","字典:{{name}}[{{pascalCase codeName}}Dict]",String.join("",tr)));
}
{{/each}}
return ResponseEntity.ok(String.format(html,String.join("",all)));
}
}
{{/eq}}
\ No newline at end of file
{{#eq apps "link"}}
package {{packageName}}.api.{{apps}}.dict;
import com.github.xiaoymin.knife4j.annotations.ApiSupport;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import java.util.ArrayList;
import java.util.List;
@Slf4j
@Api(tags = {"数据字典" })
@RestController("link-DictHtmlResource")
@RequestMapping("/link/dict")
@ApiSupport(order = 99)
public class DictHtmlResource {
private String html="<html lang=\"en\"><head><meta charset=\"UTF-8\"><title></title>" +
"<style>table.reference,table.tecspec {table-layout:fixed;word-break:break-all;border-collapse: collapse;width:100%%;margin: 4px} table.reference .fa {font-size: 24px;} table.reference td:nth-child(odd) {background-color: #f2f7f9} table.reference td:nth-child(even) {background-color: #fff} table.reference tr.fixzebra {background-color: #f6f4f0} table.reference th {line-height: 2em;min-width: 24px;color: #fff;background-color: #555;border: 1px solid #555;font-size: 12px;padding: 3px;vertical-align: top;text-align: left} table.reference td {line-height: 2em;min-width: 24px;border: 1px solid #d4d4d4;padding: 5px;padding-top: 7px;padding-bottom: 7px;font-size: 12px;vertical-align: top;color: #606266;} .captr{height:0px;border: 0px;margin:0px;padding:0px}" +
"</style></header><body>%s<br/></body></html>";
private String template="<table class=\"reference\" id=\"%s\"><tr><th colspan=\"3\" align=\"center\">%s</th></tr>" +
"<tr><th></th><th>显示</th><th>上级值</th></tr>%s</table>";
private String templateItem="<tr><td>%s</td><td>%s</td><td>%s</td></tr>";
{{#each app.dicts}}
@ApiOperation(value = "字典:{{name}}[{{pascalCase codeName}}Dict]", tags = {"数据字典" }, notes = "字典:{{name}}[{{pascalCase codeName}}Dict]")
@RequestMapping(method = RequestMethod.GET, value = "/{{pascalCase codeName}}Dict.html")
public ResponseEntity<String> get{{pascalCase codeName}}Dict() {
List<String> tr=new ArrayList<>();
new {{pascalCase codeName}}Dict().getAllItems().forEach(item->tr.add(String.format(templateItem,item.getValue(),item.getLabel(),item.getParent()==null?"":item.getParent())));
return ResponseEntity.ok(String.format(html,String.format(template,"{{pascalCase codeName}}Dict","字典:{{name}}[{{pascalCase codeName}}Dict]",String.join("",tr))));
}
{{/each}}
}
{{/eq}}
\ No newline at end of file
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册