最美情侣中文字幕电影,在线麻豆精品传媒,在线网站高清黄,久久黄色视频

歡迎光臨散文網(wǎng) 會(huì)員登陸 & 注冊(cè)

VBA制作jeecgboot代碼生成器

2021-08-26 05:31 作者:辦公自動(dòng)化學(xué)習(xí)  | 我要投稿

在jeecgboot中制作查詢報(bào)表非常方便,可以在online報(bào)表配置中快速完成。

圖片


在數(shù)據(jù)庫(kù)中可以看到對(duì)應(yīng)的兩張表存放這些配置,一張是onl_cgreport_head,存放查詢表的頭部信息。

圖片


另一張是明細(xì)表onl_cgreport_item,存放查詢報(bào)表的字段信息。

圖片


在開發(fā)數(shù)據(jù)大屏?xí)r需要很多查詢數(shù)據(jù),可以先在online報(bào)表中配置查詢SQL,通過報(bào)表查看需要的數(shù)據(jù),然后用VBA通過數(shù)據(jù)庫(kù)中的這兩張表可以生成jeecgboot后端接口代碼。

圖片


首先在MySQL 官網(wǎng)上下載 Excel 連接 MySQL 數(shù)據(jù)庫(kù)的工具,連接為:
https://dev.mysql.com/downloads/windows/excel/


連接mysql的方法



查詢SQL數(shù)據(jù)并顯示到listview的方法



將上面方法放到類模塊中,就可以實(shí)例化對(duì)象來使用方法。

如連接數(shù)據(jù)庫(kù),將編碼以"sql_"開頭的的SQL報(bào)表顯示到listview1中


msql.OpenMySQLConnection IP, PORT, DATABASE, USERNAME, PASSWORD msql.dataToListView?"select?*?from?onl_cgreport_head?where?left(code,4)=""sql_""",?ListView1


選擇SQL報(bào)表,顯示明細(xì)到listview2中。


Private Sub ListView1_ItemClick(ByVal Item As MSComctlLib.ListItem) ? ? msql.dataToListView "select * from onl_cgreport_item where cgrhead_id=""" & Item.Text & """", ListView2 End Sub
圖片


一鍵生成文件夾、java和xml文件


If ListView1.SelectedItem Is Nothing Then Else ? ? folderPath = ThisWorkbook.Path & "\api" ? ? entity = Replace(ListView1.SelectedItem.SubItems(1), "sql_", "") ? ? desc = ListView1.SelectedItem.SubItems(2) ? ? cf.MakeFolder folderPath ? ? cf.MakeFolder folderPath & "\" & entity ? ? cf.MakeFolder folderPath & "\" & entity & "\controller" ? ? createController ? ? cf.MakeFolder folderPath & "\" & entity & "\entity" ? ? createEntity ? ? cf.MakeFolder folderPath & "\" & entity & "\mapper" ? ? cf.MakeFolder folderPath & "\" & entity & "\mapper\xml" ? ? createXML ? ? createMapper ? ? cf.MakeFolder folderPath & "\" & entity & "\service" ? ? createService ? ? cf.MakeFolder folderPath & "\" & entity & "\service\impl" ? ? createImpl End If


其中生成實(shí)體類的代碼


Dim cf As New CFileAction With cf ? ? .Clear ????.WriteText?"package?org.jeecg.modules.demo.api."?&?entity?&?".entity;"?&?vbCrLf ????.WriteText?"import?lombok.Data;"?&?vbCrLf ? ? .WriteText "@Data" & vbCrLf ? ? .WriteText "public class " & entity & " {" & vbCrLf ? ? For i = 1 To ListView2.ListItems.Count ? ? ? ? .WriteText " ? ?private " & ListView2.ListItems(i).SubItems(5) & " " & ListView2.ListItems(i).SubItems(2) & ";" & vbCrLf ? ? Next i ? ? .WriteText "}" & vbCrLf ? ? WriteUTF8File .txt, folderPath & "\" & entity & "\entity\" & entity & ".java" End With Set cf = Nothing
圖片


生成java代碼時(shí)需要的是沒有BOM的UTF-8編碼,一開始使用ADODB.Stream對(duì)象來保存java文件,IDEA打開后每個(gè)文件都要切換GBK再換回UTF-8編碼才能正常使用。后來用以下api函數(shù)來保存java文件,默認(rèn)bBOM為false,生成的代碼可以直接運(yùn)行使用。


Public Declare PtrSafe Function MultiByteToWideChar Lib "kernel32" ( _ ByVal CodePage As Long, _ ByVal dwFlags As Long, _ ByRef lpMultiByteStr As Any, _ ByVal cchMultiByte As Long, _ ByVal lpWideCharStr As Long, _ ByVal cchWideChar As Long) As Long Public Declare PtrSafe Function WideCharToMultiByte Lib "kernel32" ( _ ByVal CodePage As Long, _ ByVal dwFlags As Long, _ ByVal lpWideCharStr As LongPtr, _ ByVal cchWideChar As Long, _ ByRef lpMultiByteStr As Any, _ ByVal cchMultiByte As Long, _ ByVal lpDefaultChar As String, _ ByVal lpUsedDefaultChar As Long) As Long Public Const CP_UTF8 = 65001 ' 將輸入文本寫進(jìn)UTF8格式的文本文件 ' 輸入 ' strInput:文本字符串 ' strFile:保存的UTF8格式文件路徑 ' bBOM:True表示文件帶"EFBBBF"頭,F(xiàn)alse表示不 Public Sub WriteUTF8File(strInput As String, strFile As String, Optional bBOM As Boolean = False) ? ? Dim bByte As Byte ? ? Dim ReturnByte() As Byte ? ? Dim lngBufferSize As Long ? ? Dim lngResult As Long ? ? Dim TLen As Long ? ? ' 判斷輸入字符串是否為空 ? ? If Len(strInput) = 0 Then Exit Sub ? ? 'On Error GoTo errHandle ? ? ' 判斷文件是否存在,如存在則刪除 ? ? If Dir(strFile) <> "" Then Kill strFile ? ? TLen = Len(strInput) ? ? lngBufferSize = TLen * 3 + 1 ? ? ReDim ReturnByte(lngBufferSize - 1) ? ? lngResult = WideCharToMultiByte(CP_UTF8, 0, StrPtr(strInput), TLen, ReturnByte(0), lngBufferSize, vbNullString, 0) ? ? If lngResult Then ? ? ? ? lngResult = lngResult - 1 ? ? ? ? ReDim Preserve ReturnByte(lngResult) ? ? ? ? Open strFile For Binary As #1 ? ? ? ? ? ? If bBOM = True Then ? ? ? ? ? ? ? ? bByte = 239 ? ? ? ? ? ? ? ? Put #1, , bByte ? ? ? ? ? ? ? ? bByte = 187 ? ? ? ? ? ? ? ? Put #1, , bByte ? ? ? ? ? ? ? ? bByte = 191 ? ? ? ? ? ? ? ? Put #1, , bByte ? ? ? ? ? ? End If ? ? ? ? ? ? Put #1, , ReturnByte ? ? ? ? Close #1 ? ? End If End Sub


api接口測(cè)試成功。

圖片


本文使用 文章同步助手 同步


VBA制作jeecgboot代碼生成器的評(píng)論 (共 條)

分享到微博請(qǐng)遵守國(guó)家法律
高州市| 阜新市| 全南县| 西充县| 安徽省| 阿鲁科尔沁旗| 兴山县| 栾川县| 都昌县| 雷山县| 双峰县| 德清县| 平谷区| 台中县| 永平县| 蚌埠市| 张掖市| 获嘉县| 天水市| 利川市| 乌兰察布市| 航空| 汉源县| 东海县| 平安县| 含山县| 南丹县| 中牟县| 青海省| 岳普湖县| 正镶白旗| 长乐市| 松江区| 绥江县| 体育| 甘肃省| 萝北县| 陵川县| 曲阜市| 泰安市| 城口县|