{{#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")
@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\">查看展示清单</a>&nbsp;&nbsp;<a href=\"/xftong/link/dict/all\" target=\"_blank\">查看json</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}}