Преглед на файлове

add wfclient, add router of sso, user new directory structrue

huangrf преди 6 години
родител
ревизия
907a159292

+ 530 - 23
.idea/workspace.xml

@@ -2,11 +2,15 @@
 <project version="4">
   <component name="ChangeListManager">
     <list default="true" id="78f18399-6f6c-4260-8a6e-069182a713ff" name="Default Changelist" comment="">
-      <change beforePath="$PROJECT_DIR$/.idea/light-apiengine.iml" beforeDir="false" />
-      <change beforePath="$PROJECT_DIR$/.idea/misc.xml" beforeDir="false" />
-      <change beforePath="$PROJECT_DIR$/.idea/modules.xml" beforeDir="false" />
-      <change beforePath="$PROJECT_DIR$/.idea/vcs.xml" beforeDir="false" />
       <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/controllers/ApiController.go" beforeDir="false" afterPath="$PROJECT_DIR$/controllers/partial/ApiController.go" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/controllers/ApiController_gen.go" beforeDir="false" afterPath="$PROJECT_DIR$/controllers/gen/ApiController_gen.go" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/controllers/SysAttachmentController.go" beforeDir="false" afterPath="$PROJECT_DIR$/controllers/partial/SysAttachmentController.go" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/controllers/SysAttachmentController_gen.go" beforeDir="false" afterPath="$PROJECT_DIR$/controllers/gen/SysAttachmentController_gen.go" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/controllers/SystemController.go" beforeDir="false" afterPath="$PROJECT_DIR$/controllers/partial/SystemController.go" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/controllers/SystemController.go_new" beforeDir="false" />
+      <change beforePath="$PROJECT_DIR$/controllers/SystemController_gen.go" beforeDir="false" afterPath="$PROJECT_DIR$/controllers/gen/SystemController_gen.go" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/routers/router_gen.go" beforeDir="false" />
     </list>
     <option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
     <option name="SHOW_DIALOG" value="false" />
@@ -17,22 +21,151 @@
   <component name="FileEditorManager">
     <leaf SIDE_TABS_SIZE_LIMIT_KEY="300">
       <file pinned="false" current-in-tab="false">
-        <entry file="file://$PROJECT_DIR$/controllers/SysAttachmentController.go">
+        <entry file="file://$PROJECT_DIR$/controllers/partial/SysAttachmentController.go">
           <provider selected="true" editor-type-id="text-editor">
-            <state relative-caret-position="180">
-              <caret line="26" column="37" selection-start-line="26" selection-start-column="37" selection-end-line="26" selection-end-column="37" />
+            <state relative-caret-position="370">
+              <caret line="145" column="48" selection-start-line="145" selection-start-column="48" selection-end-line="145" selection-end-column="48" />
+              <folding>
+                <element signature="n#!!block;n#SysAttachment_Upload#0" />
+                <element signature="n#!!block;n#SysAttachment_Download#0" />
+                <element signature="n#!!block;n#SysAttachment_Delete#0" />
+              </folding>
+            </state>
+          </provider>
+        </entry>
+      </file>
+      <file pinned="false" current-in-tab="false">
+        <entry file="file://$PROJECT_DIR$/routers/aip_doc.go">
+          <provider selected="true" editor-type-id="text-editor">
+            <state relative-caret-position="195">
+              <caret line="13" column="34" selection-start-line="13" selection-start-column="34" selection-end-line="13" selection-end-column="34" />
+              <folding>
+                <element signature="e#17#214#0" expanded="true" />
+              </folding>
             </state>
           </provider>
         </entry>
       </file>
       <file pinned="false" current-in-tab="true">
-        <entry file="file://$PROJECT_DIR$/models/StorageResult_gen.go">
-          <provider selected="true" editor-type-id="text-editor" />
+        <entry file="file://$PROJECT_DIR$/routers/sso.go">
+          <provider selected="true" editor-type-id="text-editor">
+            <state relative-caret-position="255">
+              <caret line="17" column="54" selection-start-line="17" selection-start-column="54" selection-end-line="17" selection-end-column="54" />
+              <folding>
+                <element signature="e#17#214#0" expanded="true" />
+              </folding>
+            </state>
+          </provider>
+        </entry>
+      </file>
+      <file pinned="false" current-in-tab="false">
+        <entry file="file://$PROJECT_DIR$/controllers/gen/sso_controller_gen.go">
+          <provider selected="true" editor-type-id="text-editor">
+            <state relative-caret-position="448">
+              <caret line="42" column="22" selection-start-line="42" selection-start-column="22" selection-end-line="42" selection-end-column="22" />
+              <folding>
+                <element signature="e#14#210#0" expanded="true" />
+              </folding>
+            </state>
+          </provider>
+        </entry>
+      </file>
+      <file pinned="false" current-in-tab="false">
+        <entry file="file://$PROJECT_DIR$/controllers/partial/sso_controller.go">
+          <provider selected="true" editor-type-id="text-editor">
+            <state relative-caret-position="540">
+              <caret line="36" column="17" selection-start-line="36" selection-start-column="17" selection-end-line="36" selection-end-column="17" />
+              <folding>
+                <element signature="e#18#87#0" expanded="true" />
+              </folding>
+            </state>
+          </provider>
+        </entry>
+      </file>
+      <file pinned="false" current-in-tab="false">
+        <entry file="file://$PROJECT_DIR$/controllers/partial/ApiController.go">
+          <provider selected="true" editor-type-id="text-editor">
+            <state relative-caret-position="120">
+              <caret line="8" column="10" lean-forward="true" selection-end-line="28" />
+              <folding>
+                <element signature="e#18#87#0" expanded="true" />
+              </folding>
+            </state>
+          </provider>
+        </entry>
+      </file>
+      <file pinned="false" current-in-tab="false">
+        <entry file="file://$PROJECT_DIR$/routers/user.go">
+          <provider selected="true" editor-type-id="text-editor">
+            <state relative-caret-position="190">
+              <caret line="15" selection-end-line="32" selection-end-column="1" />
+              <folding>
+                <element signature="e#17#214#0" expanded="true" />
+              </folding>
+            </state>
+          </provider>
+        </entry>
+      </file>
+      <file pinned="false" current-in-tab="false">
+        <entry file="file://$PROJECT_DIR$/routers/menu.go">
+          <provider selected="true" editor-type-id="text-editor">
+            <state relative-caret-position="460">
+              <caret line="33" column="45" selection-start-line="33" selection-start-column="45" selection-end-line="33" selection-end-column="45" />
+              <folding>
+                <element signature="e#17#152#0" expanded="true" />
+              </folding>
+            </state>
+          </provider>
+        </entry>
+      </file>
+      <file pinned="false" current-in-tab="false">
+        <entry file="file://$PROJECT_DIR$/controllers/gen/SystemController_gen.go">
+          <provider selected="true" editor-type-id="text-editor">
+            <state relative-caret-position="120">
+              <caret line="8" column="1" selection-end-line="327" />
+              <folding>
+                <element signature="e#14#210#0" expanded="true" />
+              </folding>
+            </state>
+          </provider>
+        </entry>
+      </file>
+      <file pinned="false" current-in-tab="false">
+        <entry file="file://$PROJECT_DIR$/routers/attachment.go">
+          <provider selected="true" editor-type-id="text-editor">
+            <state relative-caret-position="300">
+              <caret line="20" selection-start-line="20" selection-end-line="20" />
+              <folding>
+                <element signature="e#17#178#0" expanded="true" />
+              </folding>
+            </state>
+          </provider>
         </entry>
       </file>
     </leaf>
   </component>
-  <component name="GOROOT" path="C:\Go" />
+  <component name="FileTemplateManagerImpl">
+    <option name="RECENT_TEMPLATES">
+      <list>
+        <option value="Go File" />
+      </list>
+    </option>
+  </component>
+  <component name="FindInProjectRecents">
+    <findStrings>
+      <find>sys_attachmentController_upload</find>
+      <find>_menu</find>
+      <find>AddMenu</find>
+      <find>systemController_add_menu</find>
+      <find>_org</find>
+      <find>systemController_add_role</find>
+      <find>_role</find>
+      <find>_role_menu</find>
+      <find>systemController_find_role_menu</find>
+      <find>apiController_api_doc</find>
+    </findStrings>
+  </component>
+  <component name="GOROOT" path="$USER_HOME$/go" />
   <component name="Git.Settings">
     <option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
   </component>
@@ -40,21 +173,41 @@
     <option name="CHANGED_PATHS">
       <list>
         <option value="$PROJECT_DIR$/utils/storage.go" />
+        <option value="$PROJECT_DIR$/.gitignore" />
+        <option value="$PROJECT_DIR$/middleware/login_ware.go" />
+        <option value="$PROJECT_DIR$/controllers/partial/ApiController.go" />
+        <option value="$PROJECT_DIR$/controllers/partial/SysAttachmentController.go" />
+        <option value="$PROJECT_DIR$/controllers/partial/SystemController.go" />
+        <option value="$PROJECT_DIR$/controllers/gen/SystemController_gen.go" />
+        <option value="$PROJECT_DIR$/controllers/gen/SysAttachmentController_gen.go" />
+        <option value="$PROJECT_DIR$/controllers/gen/ApiController_gen.go" />
+        <option value="$PROJECT_DIR$/models/model.go" />
+        <option value="$PROJECT_DIR$/routers/attachment.go" />
+        <option value="$PROJECT_DIR$/routers/router_gen.go" />
+        <option value="$PROJECT_DIR$/routers/menu.go" />
+        <option value="$PROJECT_DIR$/routers/user.go" />
+        <option value="$PROJECT_DIR$/routers/org.go" />
+        <option value="$PROJECT_DIR$/routers/router.go" />
+        <option value="$PROJECT_DIR$/routers/aip_doc.go" />
+        <option value="$PROJECT_DIR$/routers/system.go" />
+        <option value="$PROJECT_DIR$/routers/role.go" />
+        <option value="$PROJECT_DIR$/controllers/partial/sso_controller.go" />
+        <option value="$PROJECT_DIR$/controllers/gen/sso_controller_gen.go" />
+        <option value="$PROJECT_DIR$/routers/sso.go" />
       </list>
     </option>
   </component>
   <component name="ProjectFrameBounds" extendedState="6">
-    <option name="x" value="133" />
-    <option name="y" value="401" />
-    <option name="width" value="1121" />
-    <option name="height" value="662" />
+    <option name="x" value="85" />
+    <option name="y" value="25" />
+    <option name="width" value="1750" />
+    <option name="height" value="980" />
   </component>
   <component name="ProjectView">
     <navigator proportions="" version="1">
       <foldersAlwaysOnTop value="true" />
     </navigator>
     <panes>
-      <pane id="Scope" />
       <pane id="ProjectPane">
         <subPane>
           <expand>
@@ -65,15 +218,44 @@
             <path>
               <item name="light-apiengine" type="b2602c69:ProjectViewProjectNode" />
               <item name="light-apiengine" type="462c0819:PsiDirectoryNode" />
-              <item name="utils" type="462c0819:PsiDirectoryNode" />
+              <item name="controllers" type="462c0819:PsiDirectoryNode" />
+            </path>
+            <path>
+              <item name="light-apiengine" type="b2602c69:ProjectViewProjectNode" />
+              <item name="light-apiengine" type="462c0819:PsiDirectoryNode" />
+              <item name="controllers" type="462c0819:PsiDirectoryNode" />
+              <item name="gen" type="462c0819:PsiDirectoryNode" />
+            </path>
+            <path>
+              <item name="light-apiengine" type="b2602c69:ProjectViewProjectNode" />
+              <item name="light-apiengine" type="462c0819:PsiDirectoryNode" />
+              <item name="controllers" type="462c0819:PsiDirectoryNode" />
+              <item name="partial" type="462c0819:PsiDirectoryNode" />
+            </path>
+            <path>
+              <item name="light-apiengine" type="b2602c69:ProjectViewProjectNode" />
+              <item name="light-apiengine" type="462c0819:PsiDirectoryNode" />
+              <item name="middleware" type="462c0819:PsiDirectoryNode" />
+            </path>
+            <path>
+              <item name="light-apiengine" type="b2602c69:ProjectViewProjectNode" />
+              <item name="light-apiengine" type="462c0819:PsiDirectoryNode" />
+              <item name="models" type="462c0819:PsiDirectoryNode" />
+            </path>
+            <path>
+              <item name="light-apiengine" type="b2602c69:ProjectViewProjectNode" />
+              <item name="light-apiengine" type="462c0819:PsiDirectoryNode" />
+              <item name="routers" type="462c0819:PsiDirectoryNode" />
             </path>
           </expand>
           <select />
         </subPane>
       </pane>
+      <pane id="Scope" />
     </panes>
   </component>
   <component name="PropertiesComponent">
+    <property name="DefaultGoTemplateProperty" value="Go File" />
     <property name="WebServerToolWindowFactoryState" value="false" />
     <property name="go.gopath.indexing.explicitly.defined" value="true" />
     <property name="go.sdk.automatically.set" value="true" />
@@ -82,6 +264,12 @@
     <property name="nodejs_npm_path_reset_for_default_project" value="true" />
     <property name="settings.editor.selected.configurable" value="go" />
   </component>
+  <component name="RecentsManager">
+    <key name="MoveFile.RECENT_KEYS">
+      <recent name="$PROJECT_DIR$/controllers/partial" />
+      <recent name="$PROJECT_DIR$/controllers/gen" />
+    </key>
+  </component>
   <component name="RunDashboard">
     <option name="ruleStates">
       <list>
@@ -98,10 +286,9 @@
     <frame x="67" y="25" width="1299" height="743" extended-state="6" />
     <editor active="true" />
     <layout>
-      <window_info active="true" content_ui="combo" id="Project" order="0" visible="true" weight="0.254589" />
+      <window_info active="true" content_ui="combo" id="Project" order="0" visible="true" weight="0.264166" />
       <window_info id="Structure" order="1" side_tool="true" weight="0.25" />
       <window_info id="Favorites" order="2" side_tool="true" />
-      <window_info anchor="bottom" id="Docker" show_stripe_button="false" />
       <window_info anchor="bottom" id="Message" order="0" />
       <window_info anchor="bottom" id="Find" order="1" />
       <window_info anchor="bottom" id="Run" order="2" />
@@ -110,9 +297,10 @@
       <window_info anchor="bottom" id="Inspection" order="5" weight="0.4" />
       <window_info anchor="bottom" id="TODO" order="6" />
       <window_info anchor="bottom" id="Database Changes" order="7" show_stripe_button="false" />
-      <window_info anchor="bottom" id="Version Control" order="8" show_stripe_button="false" />
+      <window_info anchor="bottom" id="Version Control" order="8" />
       <window_info anchor="bottom" id="Terminal" order="9" />
       <window_info anchor="bottom" id="Event Log" order="10" side_tool="true" />
+      <window_info anchor="bottom" id="Docker" order="11" show_stripe_button="false" />
       <window_info anchor="right" id="Commander" internal_type="SLIDING" order="0" type="SLIDING" weight="0.4" />
       <window_info anchor="right" id="Ant Build" order="1" weight="0.25" />
       <window_info anchor="right" content_ui="combo" id="Hierarchy" order="2" weight="0.25" />
@@ -124,15 +312,334 @@
   </component>
   <component name="editorHistoryManager">
     <entry file="file://$PROJECT_DIR$/utils/storage.go" />
-    <entry file="file://$PROJECT_DIR$/controllers/SysAttachmentController.go">
+    <entry file="file://$PROJECT_DIR$/models/StorageResult_gen.go">
       <provider selected="true" editor-type-id="text-editor">
-        <state relative-caret-position="180">
-          <caret line="26" column="37" selection-start-line="26" selection-start-column="37" selection-end-line="26" selection-end-column="37" />
+        <state relative-caret-position="330">
+          <caret line="24" selection-start-line="24" selection-end-line="24" />
         </state>
       </provider>
     </entry>
-    <entry file="file://$PROJECT_DIR$/models/StorageResult_gen.go">
+    <entry file="file://$PROJECT_DIR$/utils/token_store.go">
+      <provider selected="true" editor-type-id="text-editor" />
+    </entry>
+    <entry file="file://$PROJECT_DIR$/utils/utils.go">
+      <provider selected="true" editor-type-id="text-editor" />
+    </entry>
+    <entry file="file://$PROJECT_DIR$/utils/filedb.go">
+      <provider selected="true" editor-type-id="text-editor" />
+    </entry>
+    <entry file="file://$PROJECT_DIR$/utils/http_util.go">
+      <provider selected="true" editor-type-id="text-editor" />
+    </entry>
+    <entry file="file://$PROJECT_DIR$/utils/paths.go">
+      <provider selected="true" editor-type-id="text-editor" />
+    </entry>
+    <entry file="file://$PROJECT_DIR$/utils/pwd.go">
+      <provider selected="true" editor-type-id="text-editor" />
+    </entry>
+    <entry file="file://$PROJECT_DIR$/utils/safemap.go">
+      <provider selected="true" editor-type-id="text-editor">
+        <state relative-caret-position="195">
+          <caret line="16" column="7" selection-start-line="16" selection-start-column="7" selection-end-line="16" selection-end-column="7" />
+          <folding>
+            <element signature="e#628#646#0" expanded="true" />
+          </folding>
+        </state>
+      </provider>
+    </entry>
+    <entry file="file://$PROJECT_DIR$/entitys/ctrl_context.go">
+      <provider selected="true" editor-type-id="text-editor">
+        <state relative-caret-position="30">
+          <caret line="2" column="6" selection-start-line="2" selection-start-column="6" selection-end-line="2" selection-end-column="6" />
+        </state>
+      </provider>
+    </entry>
+    <entry file="file://$PROJECT_DIR$/entitys/token.go">
+      <provider selected="true" editor-type-id="text-editor" />
+    </entry>
+    <entry file="file://$PROJECT_DIR$/env/env.go">
+      <provider selected="true" editor-type-id="text-editor">
+        <state relative-caret-position="-770" />
+      </provider>
+    </entry>
+    <entry file="file://$PROJECT_DIR$/logs/logs.go">
+      <provider selected="true" editor-type-id="text-editor" />
+    </entry>
+    <entry file="file://$PROJECT_DIR$/.gitignore">
+      <provider selected="true" editor-type-id="text-editor">
+        <state relative-caret-position="15">
+          <caret line="1" selection-start-line="1" selection-end-line="1" />
+        </state>
+      </provider>
+    </entry>
+    <entry file="file://$PROJECT_DIR$/models/UserInfo_gen.go">
+      <provider selected="true" editor-type-id="text-editor" />
+    </entry>
+    <entry file="file://$PROJECT_DIR$/models/Filter_gen.go">
+      <provider selected="true" editor-type-id="text-editor" />
+    </entry>
+    <entry file="file://$PROJECT_DIR$/models/Filter.go">
+      <provider selected="true" editor-type-id="text-editor">
+        <state relative-caret-position="435">
+          <caret line="547" column="35" selection-start-line="547" selection-start-column="35" selection-end-line="547" selection-end-column="35" />
+        </state>
+      </provider>
+    </entry>
+    <entry file="file://$PROJECT_DIR$/middleware/login_ware.go">
+      <provider selected="true" editor-type-id="text-editor">
+        <state relative-caret-position="300">
+          <caret line="24" column="9" selection-start-line="24" selection-start-column="9" selection-end-line="24" selection-end-column="9" />
+        </state>
+      </provider>
+    </entry>
+    <entry file="file://$PROJECT_DIR$/models/Sql_SysPermission.go">
+      <provider selected="true" editor-type-id="text-editor" />
+    </entry>
+    <entry file="file://$PROJECT_DIR$/models/Sql_SysOrg_gen.go">
+      <provider selected="true" editor-type-id="text-editor" />
+    </entry>
+    <entry file="file://$PROJECT_DIR$/models/Sql_SysMenu_gen.go">
+      <provider selected="true" editor-type-id="text-editor" />
+    </entry>
+    <entry file="file://$PROJECT_DIR$/controllers/SystemController.go_new" />
+    <entry file="file://$PROJECT_DIR$/wfclient/client.go">
+      <provider selected="true" editor-type-id="text-editor">
+        <state relative-caret-position="30">
+          <caret line="2" column="7" selection-start-line="2" selection-start-column="7" selection-end-line="2" selection-end-column="7" />
+          <folding>
+            <element signature="e#18#115#0" expanded="true" />
+          </folding>
+        </state>
+      </provider>
+    </entry>
+    <entry file="file://$PROJECT_DIR$/wfclient/http.go">
       <provider selected="true" editor-type-id="text-editor" />
     </entry>
+    <entry file="file://$PROJECT_DIR$/models/Sql_SysMenu.go">
+      <provider selected="true" editor-type-id="text-editor" />
+    </entry>
+    <entry file="file://$PROJECT_DIR$/controllers/gen/SysAttachmentController_gen.go">
+      <provider selected="true" editor-type-id="text-editor">
+        <state relative-caret-position="240">
+          <caret line="16" column="43" selection-start-line="16" selection-start-column="43" selection-end-line="16" selection-end-column="43" />
+          <folding>
+            <element signature="e#14#210#0" expanded="true" />
+          </folding>
+        </state>
+      </provider>
+    </entry>
+    <entry file="file://$PROJECT_DIR$/controllers/partial/SystemController.go">
+      <provider selected="true" editor-type-id="text-editor">
+        <state relative-caret-position="426">
+          <caret line="938" column="42" selection-start-line="938" selection-start-column="42" selection-end-line="938" selection-end-column="42" />
+        </state>
+      </provider>
+    </entry>
+    <entry file="file://$PROJECT_DIR$/models/Sql_SysAttachment_gen.go">
+      <provider selected="true" editor-type-id="text-editor" />
+    </entry>
+    <entry file="file://$PROJECT_DIR$/models/model.go">
+      <provider selected="true" editor-type-id="text-editor">
+        <state relative-caret-position="195">
+          <caret line="13" column="26" selection-start-line="13" selection-start-column="26" selection-end-line="13" selection-end-column="26" />
+          <folding>
+            <element signature="e#17#142#0" expanded="true" />
+          </folding>
+        </state>
+      </provider>
+    </entry>
+    <entry file="file://$PROJECT_DIR$/controllers/gen/ApiController_gen.go">
+      <provider selected="true" editor-type-id="text-editor">
+        <state relative-caret-position="225">
+          <caret line="15" column="21" selection-start-line="15" selection-start-column="5" selection-end-line="15" selection-end-column="21" />
+          <folding>
+            <element signature="e#14#210#0" expanded="true" />
+          </folding>
+        </state>
+      </provider>
+    </entry>
+    <entry file="file://$PROJECT_DIR$/routers/router_gen.go">
+      <provider selected="true" editor-type-id="text-editor">
+        <state relative-caret-position="495">
+          <caret line="58" selection-start-line="58" selection-end-line="58" />
+          <folding>
+            <element signature="e#17#361#0" expanded="true" />
+            <element signature="n#!!block;n#sys_attachmentController_upload#0" />
+            <element signature="n#!!block;n#sys_attachmentController_download#0" />
+            <element signature="n#!!block;n#sys_attachmentController_delete#0" />
+            <element signature="n#!!block;n#systemController_login#0" />
+            <element signature="n#!!block;n#systemController_logout#0" />
+            <element signature="n#!!block;n#systemController_get_nav_tree#0" />
+            <element signature="n#!!block;n#systemController_get_menu_tree#0" />
+            <element signature="n#!!block;n#systemController_find_user_page#0" />
+            <element signature="n#!!block;n#systemController_get_org_tree#0" />
+            <element signature="n#!!block;n#systemController_add_user#0" />
+            <element signature="n#!!block;n#systemController_del_user#0" />
+            <element signature="n#!!block;n#systemController_update_user#0" />
+            <element signature="n#!!block;n#systemController_add_role#0" />
+            <element signature="n#!!block;n#systemController_del_role#0" />
+            <element signature="n#!!block;n#systemController_update_role#0" />
+            <element signature="n#!!block;n#systemController_find_role_page#0" />
+            <element signature="n#!!block;n#systemController_find_role_menu#0" />
+            <element signature="n#!!block;n#systemController_save_role_menu#0" />
+            <element signature="n#!!block;n#systemController_role_all#0" />
+            <element signature="n#!!block;n#systemController_find_permissions#0" />
+            <element signature="n#!!block;n#systemController_add_menu#0" />
+            <element signature="n#!!block;n#systemController_del_menu#0" />
+            <element signature="n#!!block;n#systemController_update_menu#0" />
+            <element signature="n#!!block;n#systemController_add_org#0" />
+            <element signature="n#!!block;n#systemController_del_org#0" />
+            <element signature="n#!!block;n#systemController_update_org#0" />
+            <element signature="n#!!block;n#systemController_get_org#0" />
+            <element signature="n#!!block;n#systemController_page_org#0" />
+            <element signature="n#!!block;n#apiController_api_doc#0" />
+            <element signature="n#!!block;n#SyncDb#0" />
+            <element signature="n#!!block;n#InitRouter#0" />
+          </folding>
+        </state>
+      </provider>
+    </entry>
+    <entry file="file://$PROJECT_DIR$/routers/system.go">
+      <provider selected="true" editor-type-id="text-editor">
+        <state relative-caret-position="285">
+          <caret line="19" selection-start-line="19" selection-end-line="19" />
+          <folding>
+            <element signature="e#17#152#0" expanded="true" />
+          </folding>
+        </state>
+      </provider>
+    </entry>
+    <entry file="file://$PROJECT_DIR$/routers/router.go">
+      <provider selected="true" editor-type-id="text-editor">
+        <state relative-caret-position="510">
+          <caret line="34" column="15" selection-start-line="34" selection-start-column="15" selection-end-line="34" selection-end-column="15" />
+          <folding>
+            <element signature="e#18#116#0" expanded="true" />
+          </folding>
+        </state>
+      </provider>
+    </entry>
+    <entry file="file://$PROJECT_DIR$/routers/role.go">
+      <provider selected="true" editor-type-id="text-editor">
+        <state relative-caret-position="180">
+          <caret line="12" column="17" selection-start-line="12" selection-start-column="17" selection-end-line="12" selection-end-column="17" />
+          <folding>
+            <element signature="e#17#214#0" expanded="true" />
+          </folding>
+        </state>
+      </provider>
+    </entry>
+    <entry file="file://$PROJECT_DIR$/routers/org.go">
+      <provider selected="true" editor-type-id="text-editor">
+        <state relative-caret-position="555">
+          <caret line="37" column="1" selection-start-line="37" selection-start-column="1" selection-end-line="37" selection-end-column="1" />
+          <folding>
+            <element signature="e#17#214#0" expanded="true" />
+          </folding>
+        </state>
+      </provider>
+    </entry>
+    <entry file="file://$PROJECT_DIR$/routers/menu.go">
+      <provider selected="true" editor-type-id="text-editor">
+        <state relative-caret-position="460">
+          <caret line="33" column="45" selection-start-line="33" selection-start-column="45" selection-end-line="33" selection-end-column="45" />
+          <folding>
+            <element signature="e#17#152#0" expanded="true" />
+          </folding>
+        </state>
+      </provider>
+    </entry>
+    <entry file="file://$PROJECT_DIR$/routers/attachment.go">
+      <provider selected="true" editor-type-id="text-editor">
+        <state relative-caret-position="300">
+          <caret line="20" selection-start-line="20" selection-end-line="20" />
+          <folding>
+            <element signature="e#17#178#0" expanded="true" />
+          </folding>
+        </state>
+      </provider>
+    </entry>
+    <entry file="file://$PROJECT_DIR$/routers/aip_doc.go">
+      <provider selected="true" editor-type-id="text-editor">
+        <state relative-caret-position="195">
+          <caret line="13" column="34" selection-start-line="13" selection-start-column="34" selection-end-line="13" selection-end-column="34" />
+          <folding>
+            <element signature="e#17#214#0" expanded="true" />
+          </folding>
+        </state>
+      </provider>
+    </entry>
+    <entry file="file://$PROJECT_DIR$/routers/user.go">
+      <provider selected="true" editor-type-id="text-editor">
+        <state relative-caret-position="190">
+          <caret line="15" selection-end-line="32" selection-end-column="1" />
+          <folding>
+            <element signature="e#17#214#0" expanded="true" />
+          </folding>
+        </state>
+      </provider>
+    </entry>
+    <entry file="file://$PROJECT_DIR$/controllers/gen/SystemController_gen.go">
+      <provider selected="true" editor-type-id="text-editor">
+        <state relative-caret-position="120">
+          <caret line="8" column="1" selection-end-line="327" />
+          <folding>
+            <element signature="e#14#210#0" expanded="true" />
+          </folding>
+        </state>
+      </provider>
+    </entry>
+    <entry file="file://$PROJECT_DIR$/controllers/partial/ApiController.go">
+      <provider selected="true" editor-type-id="text-editor">
+        <state relative-caret-position="120">
+          <caret line="8" column="10" lean-forward="true" selection-end-line="28" />
+          <folding>
+            <element signature="e#18#87#0" expanded="true" />
+          </folding>
+        </state>
+      </provider>
+    </entry>
+    <entry file="file://$PROJECT_DIR$/controllers/partial/SysAttachmentController.go">
+      <provider selected="true" editor-type-id="text-editor">
+        <state relative-caret-position="370">
+          <caret line="145" column="48" selection-start-line="145" selection-start-column="48" selection-end-line="145" selection-end-column="48" />
+          <folding>
+            <element signature="n#!!block;n#SysAttachment_Upload#0" />
+            <element signature="n#!!block;n#SysAttachment_Download#0" />
+            <element signature="n#!!block;n#SysAttachment_Delete#0" />
+          </folding>
+        </state>
+      </provider>
+    </entry>
+    <entry file="file://$PROJECT_DIR$/controllers/gen/sso_controller_gen.go">
+      <provider selected="true" editor-type-id="text-editor">
+        <state relative-caret-position="448">
+          <caret line="42" column="22" selection-start-line="42" selection-start-column="22" selection-end-line="42" selection-end-column="22" />
+          <folding>
+            <element signature="e#14#210#0" expanded="true" />
+          </folding>
+        </state>
+      </provider>
+    </entry>
+    <entry file="file://$PROJECT_DIR$/controllers/partial/sso_controller.go">
+      <provider selected="true" editor-type-id="text-editor">
+        <state relative-caret-position="540">
+          <caret line="36" column="17" selection-start-line="36" selection-start-column="17" selection-end-line="36" selection-end-column="17" />
+          <folding>
+            <element signature="e#18#87#0" expanded="true" />
+          </folding>
+        </state>
+      </provider>
+    </entry>
+    <entry file="file://$PROJECT_DIR$/routers/sso.go">
+      <provider selected="true" editor-type-id="text-editor">
+        <state relative-caret-position="255">
+          <caret line="17" column="54" selection-start-line="17" selection-start-column="54" selection-end-line="17" selection-end-column="54" />
+          <folding>
+            <element signature="e#17#214#0" expanded="true" />
+          </folding>
+        </state>
+      </provider>
+    </entry>
   </component>
 </project>

+ 0 - 125
controllers/SystemController.go_new

@@ -1,125 +0,0 @@
-
-package controllers
-
-import (
-	//"git.qianqiusoft.com/qianqiusoft/light-apiengine/models"
-	//sysmodel "git.qianqiusoft.com/qianqiusoft/light-apiengine/models"
-)
-
-
-// _Login
-// @Title _Login
-// @Description 用户登录         
-// @Param	logininfo      false  "登录信息"  
-// @Success 200 {object} models.Account
-// @Failure 403 :id is empty
-func System_Login(c *SystemController) {
-	var logininfo models.LoginInfo 
-	c.Ctx.BindJSON(&logininfo)
-	ret := __none_func_system__(logininfo)
-	if ret {
-		c.Ctx.JSON(200, sysmodel.SysReturn{200, "", nil})
-	}else{
-		c.Ctx.JSON(200, sysmodel.SysReturn{500, "", nil})
-	}
-}
-
-// _Logout
-// @Title _Logout
-// @Description 用户退出         
-// @Success 200 {object} models.Account
-// @Failure 403 :id is empty
-func System_Logout(c *SystemController) {
-	
-	ret := __none_func_system__()
-	if ret {
-		c.Ctx.JSON(200, sysmodel.SysReturn{200, "", nil})
-	}else{
-		c.Ctx.JSON(200, sysmodel.SysReturn{500, "", nil})
-	}
-}
-
-// _GetMenuTree
-// @Title _GetMenuTree
-// @Description 获取系统菜单         
-// @Param	user    string  false  "用户id"  
-// @Success 200 {object} models.Account
-// @Failure 403 :id is empty
-func System_GetMenuTree(c *SystemController) {
-	user := c.Ctx.Param(":user")
-	ret := __none_func_system__(user)
-	if ret {
-		c.Ctx.JSON(200, sysmodel.SysReturn{200, "", nil})
-	}else{
-		c.Ctx.JSON(200, sysmodel.SysReturn{500, "", nil})
-	}
-}
-
-// _FindUserPage
-// @Title _FindUserPage
-// @Description 获取用户分布数据         
-// @Param	page      false  "分页参数"  
-// @Success 200 {object} models.Account
-// @Failure 403 :id is empty
-func System_FindUserPage(c *SystemController) {
-	var getpageinfo models.GetPageInfo 
-	c.Ctx.BindJSON(&getpageinfo)
-	ret := __none_func_system__(getpageinfo)
-	if ret {
-		c.Ctx.JSON(200, sysmodel.SysReturn{200, "", nil})
-	}else{
-		c.Ctx.JSON(200, sysmodel.SysReturn{500, "", nil})
-	}
-}
-
-// _GetOrgTree
-// @Title _GetOrgTree
-// @Description 获取组织架构树         
-// @Success 200 {object} models.Account
-// @Failure 403 :id is empty
-func System_GetOrgTree(c *SystemController) {
-	
-	ret := __none_func_system__()
-	if ret {
-		c.Ctx.JSON(200, sysmodel.SysReturn{200, "", nil})
-	}else{
-		c.Ctx.JSON(200, sysmodel.SysReturn{500, "", nil})
-	}
-}
-
-// _FindPermissions
-// @Title _FindPermissions
-// @Description 查找用户的菜单权限标识集合         
-// @Param	user    string  false  "用户id"  
-// @Success 200 {object} models.Account
-// @Failure 403 :id is empty
-func System_FindPermissions(c *SystemController) {
-	user := c.Ctx.Param(":user")
-	ret := __none_func_system__(user)
-	if ret {
-		c.Ctx.JSON(200, sysmodel.SysReturn{200, "", nil})
-	}else{
-		c.Ctx.JSON(200, sysmodel.SysReturn{500, "", nil})
-	}
-}
-
-// _AddPermission
-// @Title _AddPermission
-// @Description 查找用户的菜单权限标识集合         
-// @Param	user    string  false  "用户id"  
-// @Success 200 {object} models.Account
-// @Failure 403 :id is empty
-func System_AddPermission(c *SystemController) {
-	user := c.Ctx.Param(":user")
-	ret := __none_func_system__(user)
-	if ret {
-		c.Ctx.JSON(200, sysmodel.SysReturn{200, "", nil})
-	}else{
-		c.Ctx.JSON(200, sysmodel.SysReturn{500, "", nil})
-	}
-}
-
-
-func __none_func_system__(params ... interface{}) bool{
-	return true
-}

+ 7 - 8
controllers/ApiController_gen.go → controllers/gen/ApiController_gen.go

@@ -1,21 +1,20 @@
 
-package controllers
+package gen
 
 import (
+	"git.qianqiusoft.com/qianqiusoft/light-apiengine/controllers/partial"
+	"git.qianqiusoft.com/qianqiusoft/light-apiengine/entitys"
 	"github.com/gin-gonic/gin"
 	"github.com/xormplus/xorm"
-	"git.qianqiusoft.com/qianqiusoft/light-apiengine/engine"
 )
 
 // ApiController operations for Api
 type ApiController struct {
-	Ctx *gin.Context
 	Db *xorm.Engine
-	engine *engine.ApiEngine
 }
 
-func NewApiController(c *gin.Context, e *engine.ApiEngine) *ApiController {
-	controller := &ApiController{c,e.OrmEngine,e}
+func NewApiController(db *xorm.Engine) *ApiController {
+	controller := &ApiController{db}
 	return controller
 }
 
@@ -28,8 +27,8 @@ func NewApiController(c *gin.Context, e *engine.ApiEngine) *ApiController {
 // @Success 200 {object} models.Account
 // @Failure 403 :id is empty
 // @router /api_doc  [get]
-func (c *ApiController) ApiDoc() {
+func (c *ApiController) ApiDoc(ctx *gin.Context) {
 	//
-	Api_ApiDoc(c)
+	partial.Api_ApiDoc(&entitys.CtrlContext{ctx, c.Db})
 }
 

+ 11 - 12
controllers/SysAttachmentController_gen.go → controllers/gen/SysAttachmentController_gen.go

@@ -1,21 +1,20 @@
 
-package controllers
+package gen
 
 import (
+	"git.qianqiusoft.com/qianqiusoft/light-apiengine/controllers/partial"
+	"git.qianqiusoft.com/qianqiusoft/light-apiengine/entitys"
 	"github.com/gin-gonic/gin"
 	"github.com/xormplus/xorm"
-	"git.qianqiusoft.com/qianqiusoft/light-apiengine/engine"
 )
 
 // SysAttachmentController operations for SysAttachment
 type SysAttachmentController struct {
-	Ctx *gin.Context
 	Db *xorm.Engine
-	engine *engine.ApiEngine
 }
 
-func NewSysAttachmentController(c *gin.Context, e *engine.ApiEngine) *SysAttachmentController {
-	controller := &SysAttachmentController{c,e.OrmEngine,e}
+func NewSysAttachmentController(db *xorm.Engine) *SysAttachmentController {
+	controller := &SysAttachmentController{db}
 	return controller
 }
 
@@ -27,9 +26,9 @@ func NewSysAttachmentController(c *gin.Context, e *engine.ApiEngine) *SysAttachm
 // @Success 200 {object} models.Account
 // @Failure 403 :id is empty
 // @router /upload  [post]
-func (c *SysAttachmentController) Upload() {
+func (c *SysAttachmentController) Upload(ctx *gin.Context) {
 	//
-	SysAttachment_Upload(c)
+	partial.SysAttachment_Upload(&entitys.CtrlContext{ctx, c.Db})
 }
 
 // Download
@@ -39,9 +38,9 @@ func (c *SysAttachmentController) Upload() {
 // @Success 200 {object} models.Account
 // @Failure 403 :id is empty
 // @router /download  [get]
-func (c *SysAttachmentController) Download() {
+func (c *SysAttachmentController) Download(ctx *gin.Context) {
 	//
-	SysAttachment_Download(c)
+	partial.SysAttachment_Download(&entitys.CtrlContext{ctx, c.Db})
 }
 
 // Delete
@@ -51,8 +50,8 @@ func (c *SysAttachmentController) Download() {
 // @Success 200 {object} models.Account
 // @Failure 403 :id is empty
 // @router /delete  [get]
-func (c *SysAttachmentController) Delete() {
+func (c *SysAttachmentController) Delete(ctx *gin.Context) {
 	//
-	SysAttachment_Delete(c)
+	partial.SysAttachment_Delete(&entitys.CtrlContext{ctx, c.Db})
 }
 

+ 55 - 56
controllers/SystemController_gen.go → controllers/gen/SystemController_gen.go

@@ -1,21 +1,20 @@
 
-package controllers
+package gen
 
 import (
+	"git.qianqiusoft.com/qianqiusoft/light-apiengine/controllers/partial"
+	"git.qianqiusoft.com/qianqiusoft/light-apiengine/entitys"
 	"github.com/gin-gonic/gin"
 	"github.com/xormplus/xorm"
-	"git.qianqiusoft.com/qianqiusoft/light-apiengine/engine"
 )
 
 // SystemController operations for System
 type SystemController struct {
-	Ctx *gin.Context
 	Db *xorm.Engine
-	engine *engine.ApiEngine
 }
 
-func NewSystemController(c *gin.Context, e *engine.ApiEngine) *SystemController {
-	controller := &SystemController{c,e.OrmEngine,e}
+func NewSystemController(db *xorm.Engine) *SystemController {
+	controller := &SystemController{db}
 	return controller
 }
 
@@ -28,9 +27,9 @@ func NewSystemController(c *gin.Context, e *engine.ApiEngine) *SystemController
 // @Success 200 {object} models.Account
 // @Failure 403 :id is empty
 // @router /login  [post,get,put]
-func (c *SystemController) Login() {
+func (c *SystemController) Login(ctx *gin.Context) {
 	//
-	System_Login(c)
+	partial.System_Login(&entitys.CtrlContext{ctx, c.Db})
 }
 
 // Logout
@@ -39,9 +38,9 @@ func (c *SystemController) Login() {
 // @Success 200 {object} models.Account
 // @Failure 403 :id is empty
 // @router /logout  [post,get]
-func (c *SystemController) Logout() {
+func (c *SystemController) Logout(ctx *gin.Context) {
 	//
-	System_Logout(c)
+	partial.System_Logout(&entitys.CtrlContext{ctx, c.Db})
 }
 
 // GetNavTree
@@ -51,9 +50,9 @@ func (c *SystemController) Logout() {
 // @Success 200 {object} models.Account
 // @Failure 403 :id is empty
 // @router /get_nav_tree  [post,get]
-func (c *SystemController) GetNavTree() {
+func (c *SystemController) GetNavTree(ctx *gin.Context) {
 	//
-	System_GetNavTree(c)
+	partial.System_GetNavTree(&entitys.CtrlContext{ctx, c.Db})
 }
 
 // GetMenuTree
@@ -63,9 +62,9 @@ func (c *SystemController) GetNavTree() {
 // @Success 200 {object} models.Account
 // @Failure 403 :id is empty
 // @router /get_menu_tree  [post,get]
-func (c *SystemController) GetMenuTree() {
+func (c *SystemController) GetMenuTree(ctx *gin.Context) {
 	//
-	System_GetMenuTree(c)
+	partial.System_GetMenuTree(&entitys.CtrlContext{ctx, c.Db})
 }
 
 // FindUserPage
@@ -75,9 +74,9 @@ func (c *SystemController) GetMenuTree() {
 // @Success 200 {object} models.Account
 // @Failure 403 :id is empty
 // @router /find_user_page  [post,get]
-func (c *SystemController) FindUserPage() {
+func (c *SystemController) FindUserPage(ctx *gin.Context) {
 	//
-	System_FindUserPage(c)
+	partial.System_FindUserPage(&entitys.CtrlContext{ctx, c.Db})
 }
 
 // GetOrgTree
@@ -86,9 +85,9 @@ func (c *SystemController) FindUserPage() {
 // @Success 200 {object} models.Account
 // @Failure 403 :id is empty
 // @router /get_org_tree  [post,get]
-func (c *SystemController) GetOrgTree() {
+func (c *SystemController) GetOrgTree(ctx *gin.Context) {
 	//
-	System_GetOrgTree(c)
+	partial.System_GetOrgTree(&entitys.CtrlContext{ctx, c.Db})
 }
 
 // AddUser
@@ -101,9 +100,9 @@ func (c *SystemController) GetOrgTree() {
 // @Success 200 {object} models.Account
 // @Failure 403 :id is empty
 // @router /add_user  [post,get,put]
-func (c *SystemController) AddUser() {
+func (c *SystemController) AddUser(ctx *gin.Context) {
 	//
-	System_AddUser(c)
+	partial.System_AddUser(&entitys.CtrlContext{ctx, c.Db})
 }
 
 // DelUser
@@ -113,9 +112,9 @@ func (c *SystemController) AddUser() {
 // @Success 200 {object} models.Account
 // @Failure 403 :id is empty
 // @router /del_user  [post,get,put]
-func (c *SystemController) DelUser() {
+func (c *SystemController) DelUser(ctx *gin.Context) {
 	//
-	System_DelUser(c)
+	partial.System_DelUser(&entitys.CtrlContext{ctx, c.Db})
 }
 
 // UpdateUser
@@ -128,9 +127,9 @@ func (c *SystemController) DelUser() {
 // @Success 200 {object} models.Account
 // @Failure 403 :id is empty
 // @router /update_user  [post,get,put]
-func (c *SystemController) UpdateUser() {
+func (c *SystemController) UpdateUser(ctx *gin.Context) {
 	//
-	System_UpdateUser(c)
+	partial.System_UpdateUser(&entitys.CtrlContext{ctx, c.Db})
 }
 
 // AddRole
@@ -141,9 +140,9 @@ func (c *SystemController) UpdateUser() {
 // @Success 200 {object} models.Account
 // @Failure 403 :id is empty
 // @router /add_role  [post,get,put]
-func (c *SystemController) AddRole() {
+func (c *SystemController) AddRole(ctx *gin.Context) {
 	//
-	System_AddRole(c)
+	partial.System_AddRole(&entitys.CtrlContext{ctx, c.Db})
 }
 
 // DelRole
@@ -153,9 +152,9 @@ func (c *SystemController) AddRole() {
 // @Success 200 {object} models.Account
 // @Failure 403 :id is empty
 // @router /del_role  [post,get,put]
-func (c *SystemController) DelRole() {
+func (c *SystemController) DelRole(ctx *gin.Context) {
 	//
-	System_DelRole(c)
+	partial.System_DelRole(&entitys.CtrlContext{ctx, c.Db})
 }
 
 // UpdateRole
@@ -167,9 +166,9 @@ func (c *SystemController) DelRole() {
 // @Success 200 {object} models.Account
 // @Failure 403 :id is empty
 // @router /update_role  [post,get,put]
-func (c *SystemController) UpdateRole() {
+func (c *SystemController) UpdateRole(ctx *gin.Context) {
 	//
-	System_UpdateRole(c)
+	partial.System_UpdateRole(&entitys.CtrlContext{ctx, c.Db})
 }
 
 // FindRolePage
@@ -179,9 +178,9 @@ func (c *SystemController) UpdateRole() {
 // @Success 200 {object} models.Account
 // @Failure 403 :id is empty
 // @router /find_role_page  [post,get,put]
-func (c *SystemController) FindRolePage() {
+func (c *SystemController) FindRolePage(ctx *gin.Context) {
 	//
-	System_FindRolePage(c)
+	partial.System_FindRolePage(&entitys.CtrlContext{ctx, c.Db})
 }
 
 // FindRoleMenu
@@ -191,9 +190,9 @@ func (c *SystemController) FindRolePage() {
 // @Success 200 {object} models.Account
 // @Failure 403 :id is empty
 // @router /find_role_menu  [post,get,put]
-func (c *SystemController) FindRoleMenu() {
+func (c *SystemController) FindRoleMenu(ctx *gin.Context) {
 	//
-	System_FindRoleMenu(c)
+	partial.System_FindRoleMenu(&entitys.CtrlContext{ctx, c.Db})
 }
 
 // SaveRoleMenu
@@ -203,9 +202,9 @@ func (c *SystemController) FindRoleMenu() {
 // @Success 200 {object} models.Account
 // @Failure 403 :id is empty
 // @router /save_role_menu  [post,get,put]
-func (c *SystemController) SaveRoleMenu() {
+func (c *SystemController) SaveRoleMenu(ctx *gin.Context) {
 	//
-	System_SaveRoleMenu(c)
+	partial.System_SaveRoleMenu(&entitys.CtrlContext{ctx, c.Db})
 }
 
 // RoleAll
@@ -214,9 +213,9 @@ func (c *SystemController) SaveRoleMenu() {
 // @Success 200 {object} models.Account
 // @Failure 403 :id is empty
 // @router /role_all  [post,get,put]
-func (c *SystemController) RoleAll() {
+func (c *SystemController) RoleAll(ctx *gin.Context) {
 	//
-	System_RoleAll(c)
+	partial.System_RoleAll(&entitys.CtrlContext{ctx, c.Db})
 }
 
 // FindPermissions
@@ -225,9 +224,9 @@ func (c *SystemController) RoleAll() {
 // @Success 200 {object} models.Account
 // @Failure 403 :id is empty
 // @router /find_permissions  [post,get,put]
-func (c *SystemController) FindPermissions() {
+func (c *SystemController) FindPermissions(ctx *gin.Context) {
 	//
-	System_FindPermissions(c)
+	partial.System_FindPermissions(&entitys.CtrlContext{ctx, c.Db})
 }
 
 // AddMenu
@@ -237,9 +236,9 @@ func (c *SystemController) FindPermissions() {
 // @Success 200 {object} models.Account
 // @Failure 403 :id is empty
 // @router /add_menu  [post,get,put]
-func (c *SystemController) AddMenu() {
+func (c *SystemController) AddMenu(ctx *gin.Context) {
 	//
-	System_AddMenu(c)
+	partial.System_AddMenu(&entitys.CtrlContext{ctx, c.Db})
 }
 
 // DelMenu
@@ -249,9 +248,9 @@ func (c *SystemController) AddMenu() {
 // @Success 200 {object} models.Account
 // @Failure 403 :id is empty
 // @router /del_menu  [post,get,put]
-func (c *SystemController) DelMenu() {
+func (c *SystemController) DelMenu(ctx *gin.Context) {
 	//
-	System_DelMenu(c)
+	partial.System_DelMenu(&entitys.CtrlContext{ctx, c.Db})
 }
 
 // UpdateMenu
@@ -261,9 +260,9 @@ func (c *SystemController) DelMenu() {
 // @Success 200 {object} models.Account
 // @Failure 403 :id is empty
 // @router /update_menu  [post,get,put]
-func (c *SystemController) UpdateMenu() {
+func (c *SystemController) UpdateMenu(ctx *gin.Context) {
 	//
-	System_UpdateMenu(c)
+	partial.System_UpdateMenu(&entitys.CtrlContext{ctx, c.Db})
 }
 
 // AddOrg
@@ -273,9 +272,9 @@ func (c *SystemController) UpdateMenu() {
 // @Success 200 {object} models.Account
 // @Failure 403 :id is empty
 // @router /add_org  [post,get,put]
-func (c *SystemController) AddOrg() {
+func (c *SystemController) AddOrg(ctx *gin.Context) {
 	//
-	System_AddOrg(c)
+	partial.System_AddOrg(&entitys.CtrlContext{ctx, c.Db})
 }
 
 // DelOrg
@@ -285,9 +284,9 @@ func (c *SystemController) AddOrg() {
 // @Success 200 {object} models.Account
 // @Failure 403 :id is empty
 // @router /del_org  [post,get,put]
-func (c *SystemController) DelOrg() {
+func (c *SystemController) DelOrg(ctx *gin.Context) {
 	//
-	System_DelOrg(c)
+	partial.System_DelOrg(&entitys.CtrlContext{ctx, c.Db})
 }
 
 // UpdateOrg
@@ -297,9 +296,9 @@ func (c *SystemController) DelOrg() {
 // @Success 200 {object} models.Account
 // @Failure 403 :id is empty
 // @router /update_org  [post,get,put]
-func (c *SystemController) UpdateOrg() {
+func (c *SystemController) UpdateOrg(ctx *gin.Context) {
 	//
-	System_UpdateOrg(c)
+	partial.System_UpdateOrg(&entitys.CtrlContext{ctx, c.Db})
 }
 
 // GetOrg
@@ -309,9 +308,9 @@ func (c *SystemController) UpdateOrg() {
 // @Success 200 {object} models.Account
 // @Failure 403 :id is empty
 // @router /get_org  [post,get,put]
-func (c *SystemController) GetOrg() {
+func (c *SystemController) GetOrg(ctx *gin.Context) {
 	//
-	System_GetOrg(c)
+	partial.System_GetOrg(&entitys.CtrlContext{ctx, c.Db})
 }
 
 // UpdateOrg
@@ -321,8 +320,8 @@ func (c *SystemController) GetOrg() {
 // @Success 200 {object} models.Account
 // @Failure 403 :id is empty
 // @router /page_org  [post,get,put]
-func (c *SystemController) PageOrg() {
+func (c *SystemController) PageOrg(ctx *gin.Context) {
 	//
-	System_PageOrg(c)
+	partial.System_PageOrg(&entitys.CtrlContext{ctx, c.Db})
 }
 

+ 44 - 0
controllers/gen/sso_controller_gen.go

@@ -0,0 +1,44 @@
+
+package gen
+
+import (
+	"git.qianqiusoft.com/qianqiusoft/light-apiengine/controllers/partial"
+	"git.qianqiusoft.com/qianqiusoft/light-apiengine/entitys"
+	"github.com/gin-gonic/gin"
+	"github.com/xormplus/xorm"
+)
+
+// SystemController operations for System
+type SSOController struct {
+	Db *xorm.Engine
+}
+
+func NewSSOController(db *xorm.Engine) *SSOController {
+	controller := &SSOController{db}
+	return controller
+}
+
+
+
+// Login
+// @Title Login
+// @Description 用户登录
+// @Param	logininfo      false  "登录信息"
+// @Success 200 {object} models.Account
+// @Failure 403 :id is empty
+// @router /login  [post,get,put]
+func (c *SSOController) SSOClient(ctx *gin.Context) {
+	//
+	partial.SSOClient(&entitys.CtrlContext{ctx, c.Db})
+}
+
+// Logout
+// @Title Logout
+// @Description 用户退出
+// @Success 200 {object} models.Account
+// @Failure 403 :id is empty
+// @router /logout  [post,get]
+func (c *SSOController) SSOLogout(ctx *gin.Context) {
+	//
+	partial.SSOLogout(&entitys.CtrlContext{ctx, c.Db})
+}

+ 3 - 4
controllers/ApiController.go → controllers/partial/ApiController.go

@@ -1,9 +1,8 @@
 
-package controllers
+package partial
 
 import (
-//"git.qianqiusoft.com/qianqiusoft/light-apiengine/models"
-//sysmodel "git.qianqiusoft.com/qianqiusoft/light-apiengine/models"
+	"git.qianqiusoft.com/qianqiusoft/light-apiengine/entitys"
 )
 
 
@@ -13,7 +12,7 @@ import (
 // @Param	sys    string  false  "是否包含用户管理相关接口"
 // @Success 200 {object} models.Account
 // @Failure 403 :id is empty
-func Api_ApiDoc(c *ApiController) {
+func Api_ApiDoc(c *entitys.CtrlContext) {
 	sys := c.Ctx.Param(":sys")
 	ret := __none_func_api__(sys)
 

+ 5 - 4
controllers/SysAttachmentController.go → controllers/partial/SysAttachmentController.go

@@ -1,8 +1,9 @@
-package controllers
+package partial
 
 import (
 	"bytes"
 	"fmt"
+	"git.qianqiusoft.com/qianqiusoft/light-apiengine/entitys"
 	"git.qianqiusoft.com/qianqiusoft/light-apiengine/logs"
 	"io"
 	"mime"
@@ -21,7 +22,7 @@ import (
 // @Description 上传文件
 // @Success 200 {object} models.Account
 // @Failure 403 :id is empty
-func SysAttachment_Upload(c *SysAttachmentController) {
+func SysAttachment_Upload(c *entitys.CtrlContext) {
 
 	// 单文件
 	file, _ := c.Ctx.FormFile("file")
@@ -67,7 +68,7 @@ func SysAttachment_Upload(c *SysAttachmentController) {
 // @Param	id      false  "文件ID"
 // @Success 200 {object} models.Account
 // @Failure 403 :id is empty
-func SysAttachment_Download(c *SysAttachmentController) {
+func SysAttachment_Download(c *entitys.CtrlContext) {
 	gt := c.Ctx.GetString("get_thumb")
 	attrId := c.Ctx.Param("attrId")
 	fmt.Println("--------", attrId)
@@ -142,7 +143,7 @@ func SysAttachment_Download(c *SysAttachmentController) {
 // @Param	id      false  "文件ID"
 // @Success 200 {object} models.Account
 // @Failure 403 :id is empty
-func SysAttachment_Delete(c *SysAttachmentController) {
+func SysAttachment_Delete(c *entitys.CtrlContext) {
 	attrId := c.Ctx.Param("attrId")
 	var attach sysmodel.SysAttachment
 	_, err := c.Db.ID(attrId).Delete(&attach)

+ 26 - 26
controllers/SystemController.go → controllers/partial/SystemController.go

@@ -1,4 +1,4 @@
-package controllers
+package partial
 
 import (
 	"encoding/json"
@@ -22,7 +22,7 @@ import (
 // @Param	logininfo      false  "登录信息"
 // @Success 200 {object} sysmodel.Account
 // @Failure 403 :id is empty
-func System_Login(c *SystemController) {
+func System_Login(c *entitys.CtrlContext) {
 	var logininfo sysmodel.LoginInfo
 	c.Ctx.BindJSON(&logininfo)
 	__none_func_system__(logininfo)
@@ -78,7 +78,7 @@ func System_Login(c *SystemController) {
 // @Description 用户退出
 // @Success 200 {object} sysmodel.Account
 // @Failure 403 :id is empty
-func System_Logout(c *SystemController) {
+func System_Logout(c *entitys.CtrlContext) {
 
 	token := c.Ctx.GetHeader("token")
 	fmt.Println("delete token: ", token)
@@ -93,7 +93,7 @@ func System_Logout(c *SystemController) {
 // @Param	user    string  false  "用户id"
 // @Success 200 {object} models.Account
 // @Failure 403 :id is empty
-func System_GetNavTree(c *SystemController) {
+func System_GetNavTree(c *entitys.CtrlContext) {
 	// set in the login_ware.go
 	user_id := c.Ctx.GetString("user_id")
 
@@ -119,7 +119,7 @@ func System_GetNavTree(c *SystemController) {
 // @Param	user    string  false  "用户id"
 // @Success 200 {object} sysmodel.Account
 // @Failure 403 :id is empty
-func System_GetMenuTree(c *SystemController) {
+func System_GetMenuTree(c *entitys.CtrlContext) {
 
 	user := c.Ctx.Param(":user")
 	ret := __none_func_system__(user)
@@ -144,7 +144,7 @@ func System_GetMenuTree(c *SystemController) {
 // @Description 获取组织架构树
 // @Success 200 {object} sysmodel.Account
 // @Failure 403 :id is empty
-func System_GetOrgTree(c *SystemController) {
+func System_GetOrgTree(c *entitys.CtrlContext) {
 
 	ret := __none_func_system__()
 
@@ -202,7 +202,7 @@ func finChildrenMenu(menus *[]sysmodel.SysMenuTree, parent string, parent_menu *
 // @Param	page      false  "分页参数"
 // @Success 200 {object} sysmodel.Account
 // @Failure 403 :id is empty
-func System_FindUserPage(c *SystemController) {
+func System_FindUserPage(c *entitys.CtrlContext) {
 
 	var getpageinfo sysmodel.GetPageInfo
 	c.Ctx.BindJSON(&getpageinfo)
@@ -285,7 +285,7 @@ func System_FindUserPage(c *SystemController) {
 // @Param	email    string  false  "邮箱"
 // @Success 200 {object} models.Account
 // @Failure 403 :id is empty
-func System_AddUser(c *SystemController) {
+func System_AddUser(c *entitys.CtrlContext) {
 
 	var user sysmodel.SysUser
 	err := c.Ctx.ShouldBindJSON(&user)
@@ -341,7 +341,7 @@ func System_AddUser(c *SystemController) {
 // @Param	id    string  false  "用户ID"
 // @Success 200 {object} models.Account
 // @Failure 403 :id is empty
-func System_DelUser(c *SystemController) {
+func System_DelUser(c *entitys.CtrlContext) {
 	type Param struct {
 		Id string `json:"id"`
 	}
@@ -391,7 +391,7 @@ func System_DelUser(c *SystemController) {
 // @Param	email    string  false  "邮箱"
 // @Success 200 {object} models.Account
 // @Failure 403 :id is empty
-func System_UpdateUser(c *SystemController) {
+func System_UpdateUser(c *entitys.CtrlContext) {
 	user_id := c.Ctx.GetString("user_id")
 
 	var userInfo sysmodel.UserInfo
@@ -467,7 +467,7 @@ func System_UpdateUser(c *SystemController) {
 // @Param	remark    string  false  "备注"
 // @Success 200 {object} models.Account
 // @Failure 403 :id is empty
-func System_AddRole(c *SystemController) {
+func System_AddRole(c *entitys.CtrlContext) {
 	var role models.SysRole
 	c.Ctx.BindJSON(&role)
 
@@ -496,7 +496,7 @@ func System_AddRole(c *SystemController) {
 // @Param	id    string  false  "角色ID"
 // @Success 200 {object} models.Account
 // @Failure 403 :id is empty
-func System_DelRole(c *SystemController) {
+func System_DelRole(c *entitys.CtrlContext) {
 	type Param struct {
 		Id string `json:"id"`
 	}
@@ -531,7 +531,7 @@ func System_DelRole(c *SystemController) {
 // @Param	remark    string  false  "备注"
 // @Success 200 {object} models.Account
 // @Failure 403 :id is empty
-func System_UpdateRole(c *SystemController) {
+func System_UpdateRole(c *entitys.CtrlContext) {
 
 	var role models.SysRole
 	c.Ctx.BindJSON(&role)
@@ -557,7 +557,7 @@ func System_UpdateRole(c *SystemController) {
 // @Param	page      false  "分页参数"
 // @Success 200 {object} models.Account
 // @Failure 403 :id is empty
-func System_FindRolePage(c *SystemController) {
+func System_FindRolePage(c *entitys.CtrlContext) {
 	var getpageinfo models.GetPageInfo
 	c.Ctx.BindJSON(&getpageinfo)
 
@@ -588,7 +588,7 @@ func System_FindRolePage(c *SystemController) {
 // @Param	user    string  false  "用户id"
 // @Success 200 {object} models.Account
 // @Failure 403 :id is empty
-func System_FindRoleMenu(c *SystemController) {
+func System_FindRoleMenu(c *entitys.CtrlContext) {
 
 	role_id, b := c.Ctx.GetQuery("roleId")
 	if !b {
@@ -613,7 +613,7 @@ func System_FindRoleMenu(c *SystemController) {
 // @Param	role_menu    string  false  "角色权限"
 // @Success 200 {object} models.Account
 // @Failure 403 :id is empty
-func System_SaveRoleMenu(c *SystemController) {
+func System_SaveRoleMenu(c *entitys.CtrlContext) {
 	var saverolemenu []models.SysRoleMenu
 
 	c.Ctx.BindJSON(&saverolemenu)
@@ -663,7 +663,7 @@ func System_SaveRoleMenu(c *SystemController) {
 // @Description 查找所有角色
 // @Success 200 {object} models.Account
 // @Failure 403 :id is empty
-func System_RoleAll(c *SystemController) {
+func System_RoleAll(c *entitys.CtrlContext) {
 
 	var roles []sysmodel.SysRole
 	err := c.Db.SQL(sysmodel.Selectall_sys_role).Find(&roles)
@@ -681,7 +681,7 @@ func System_RoleAll(c *SystemController) {
 // @Description 查找用户权限
 // @Success 200 {object} models.Account
 // @Failure 403 :id is empty
-func System_FindPermissions(c *SystemController) {
+func System_FindPermissions(c *entitys.CtrlContext) {
 
 	user_id := c.Ctx.GetString("user_id")
 
@@ -715,7 +715,7 @@ func System_FindPermissions(c *SystemController) {
 // @Param	    string  false  "菜单"
 // @Success 200 {object} models.Account
 // @Failure 403 :id is empty
-func System_AddMenu(c *SystemController) {
+func System_AddMenu(c *entitys.CtrlContext) {
 	var sysmenu models.SysMenu
 	c.Ctx.BindJSON(&sysmenu)
 
@@ -748,7 +748,7 @@ func System_AddMenu(c *SystemController) {
 // @Param	id    string  false  "菜单ID"
 // @Success 200 {object} models.Account
 // @Failure 403 :id is empty
-func System_DelMenu(c *SystemController) {
+func System_DelMenu(c *entitys.CtrlContext) {
 	type Param struct {
 		Id string `json:"id"`
 	}
@@ -781,7 +781,7 @@ func System_DelMenu(c *SystemController) {
 // @Param	    string  false  "菜单"
 // @Success 200 {object} models.Account
 // @Failure 403 :id is empty
-func System_UpdateMenu(c *SystemController) {
+func System_UpdateMenu(c *entitys.CtrlContext) {
 	var sysmenu models.SysMenu
 	c.Ctx.BindJSON(&sysmenu)
 
@@ -811,7 +811,7 @@ func System_UpdateMenu(c *SystemController) {
 // @Param	    string  false  "组织"
 // @Success 200 {object} models.Account
 // @Failure 403 :id is empty
-func System_AddOrg(c *SystemController) {
+func System_AddOrg(c *entitys.CtrlContext) {
 	var sysorg models.SysOrg
 	c.Ctx.BindJSON(&sysorg)
 
@@ -844,7 +844,7 @@ func System_AddOrg(c *SystemController) {
 // @Param	id    string  false  "组织ID"
 // @Success 200 {object} models.Account
 // @Failure 403 :id is empty
-func System_DelOrg(c *SystemController) {
+func System_DelOrg(c *entitys.CtrlContext) {
 	type Param struct {
 		Id string `json:"id"`
 	}
@@ -877,7 +877,7 @@ func System_DelOrg(c *SystemController) {
 // @Param	    string  false  "组织"
 // @Success 200 {object} models.Account
 // @Failure 403 :id is empty
-func System_UpdateOrg(c *SystemController) {
+func System_UpdateOrg(c *entitys.CtrlContext) {
 	var sysorg models.SysOrg
 	c.Ctx.BindJSON(&sysorg)
 
@@ -907,7 +907,7 @@ func System_UpdateOrg(c *SystemController) {
 // @Param	    string  false  "组织ID"
 // @Success 200 {object} models.Account
 // @Failure 403 :id is empty
-func System_GetOrg(c *SystemController) {
+func System_GetOrg(c *entitys.CtrlContext) {
 	var param struct {
 		Id string `json:"id"`
 	}
@@ -936,7 +936,7 @@ func System_GetOrg(c *SystemController) {
 // @Param	    string  false  "组织"
 // @Success 200 {object} models.Account
 // @Failure 403 :id is empty
-func System_PageOrg(c *SystemController) {
+func System_PageOrg(c *entitys.CtrlContext) {
 	var getpageinfo models.GetPageInfo
 	c.Ctx.BindJSON(&getpageinfo)
 

+ 45 - 0
controllers/partial/sso_controller.go

@@ -0,0 +1,45 @@
+
+package partial
+
+import (
+	"git.qianqiusoft.com/qianqiusoft/light-apiengine/entitys"
+)
+
+
+// SSOClient
+// @Title _ApiDoc
+// @Description api文档
+// @Param	sys    string  false  "是否包含用户管理相关接口"
+// @Success 200 {object} models.Account
+// @Failure 403 :id is empty
+func SSOClient(c *entitys.CtrlContext) {
+	sys := c.Ctx.Param(":sys")
+	ret := __none_func_api__(sys)
+
+	if ret{
+		//c.Ctx.String(200,"")
+		c.Ctx.HTML(200, "api.tpl","")
+	}
+}
+
+
+// _ApiDoc
+// @Title _ApiDoc
+// @Description api文档
+// @Param	sys    string  false  "是否包含用户管理相关接口"
+// @Success 200 {object} models.Account
+// @Failure 403 :id is empty
+func SSOLogout(c *entitys.CtrlContext) {
+	sys := c.Ctx.Param(":sys")
+	ret := __none_func_api__(sys)
+
+	if ret{
+		//c.Ctx.String(200,"")
+		c.Ctx.HTML(200, "api.tpl","")
+	}
+}
+
+
+func __none_func_sso__(params ... interface{}) bool{
+	return true
+}

+ 32 - 0
models/model.go

@@ -0,0 +1,32 @@
+
+package models
+
+import (
+	"git.qianqiusoft.com/qianqiusoft/light-apiengine/config"
+	"github.com/xormplus/xorm"
+)
+
+func SyncDb(db *xorm.Engine) {
+	if !config.AppConfig.SyncDb {
+		return
+	}
+
+	db.Sync2(new(SysUser))
+
+	db.Sync2(new(SysOrg))
+
+	db.Sync2(new(SysRole))
+
+	db.Sync2(new(SysUserRole))
+
+	db.Sync2(new(SysMenu))
+
+	db.Sync2(new(SysRoleMenu))
+
+	db.Sync2(new(SysPermission))
+
+	db.Sync2(new(SysRolePermission))
+
+	db.Sync2(new(SysAttachment))
+
+}

+ 22 - 0
routers/aip_doc.go

@@ -0,0 +1,22 @@
+package routers
+
+import (
+	"git.qianqiusoft.com/qianqiusoft/light-apiengine/controllers/gen"
+	"git.qianqiusoft.com/qianqiusoft/light-apiengine/engine"
+	"git.qianqiusoft.com/qianqiusoft/light-apiengine/middleware"
+)
+
+func init(){
+	addRegisterHandler(registerApiDocRouter)
+}
+
+func registerApiDocRouter(e *engine.ApiEngine){
+	api:=e.GinEngine.Group("/api")
+	v1:=api.Group("/v1")
+
+	v1.Use(middleware.LoginWare())
+
+	ctrler := gen.NewApiController(e.OrmEngine)
+
+	v1.GET("/api_doc", ctrler.ApiDoc)
+}

+ 22 - 0
routers/attachment.go

@@ -0,0 +1,22 @@
+package routers
+
+import (
+	"git.qianqiusoft.com/qianqiusoft/light-apiengine/controllers/gen"
+	"git.qianqiusoft.com/qianqiusoft/light-apiengine/engine"
+)
+
+func init(){
+	addRegisterHandler(registerSysAttachmentRouter)
+}
+
+func registerSysAttachmentRouter(e *engine.ApiEngine){
+	api:=e.GinEngine.Group("/api")
+	system:=api.Group("/v1/system")
+
+	ctrler := gen.NewSysAttachmentController(e.OrmEngine)
+
+	system.POST("/upload", ctrler.Upload)
+	system.GET("/download/:attrId", ctrler.Download)
+	system.GET("/delete/:attrId", ctrler.Delete)
+
+}

+ 36 - 0
routers/menu.go

@@ -0,0 +1,36 @@
+package routers
+
+import (
+	"git.qianqiusoft.com/qianqiusoft/light-apiengine/controllers/gen"
+	"git.qianqiusoft.com/qianqiusoft/light-apiengine/engine"
+	"git.qianqiusoft.com/qianqiusoft/light-apiengine/middleware"
+)
+
+func init(){
+	addRegisterHandler(registerMenuRouter)
+}
+
+func registerMenuRouter(e *engine.ApiEngine){
+	api:=e.GinEngine.Group("/api")
+	v1:=api.Group("/v1")
+
+	v1.Use(middleware.LoginWare())
+
+	ctrler := gen.NewSystemController(e.OrmEngine)
+	v1.GET("/system/get_nav_tree", ctrler.GetNavTree)
+	v1.GET("/system/sidebar", ctrler.GetNavTree)
+
+	v1.GET("/system/get_menu_tree", ctrler.GetMenuTree)
+	v1.POST("/system/get_menu_tree", ctrler.GetMenuTree)
+
+
+	v1.GET("/system/add_menu", ctrler.AddMenu)
+	v1.POST("/system/add_menu", ctrler.AddMenu)
+
+	v1.GET("/system/del_menu", ctrler.DelMenu)
+	v1.POST("/system/del_menu", ctrler.DelMenu)
+
+	v1.GET("/system/update_menu", ctrler.UpdateMenu)
+	v1.POST("/system/update_menu", ctrler.UpdateMenu)
+
+}

+ 38 - 0
routers/org.go

@@ -0,0 +1,38 @@
+package routers
+
+import (
+	"git.qianqiusoft.com/qianqiusoft/light-apiengine/controllers/gen"
+	"git.qianqiusoft.com/qianqiusoft/light-apiengine/engine"
+	"git.qianqiusoft.com/qianqiusoft/light-apiengine/middleware"
+)
+
+func init(){
+	addRegisterHandler(registerOrgRouter)
+}
+
+func registerOrgRouter(e *engine.ApiEngine){
+	api:=e.GinEngine.Group("/api")
+	v1:=api.Group("/v1")
+
+	v1.Use(middleware.LoginWare())
+
+	ctrler := gen.NewSystemController(e.OrmEngine)
+
+	v1.GET("/system/get_org_tree", ctrler.GetOrgTree)
+	v1.POST("/system/get_org_tree", ctrler.GetOrgTree)
+
+	v1.POST("/system/add_org", ctrler.AddOrg)
+	v1.PUT("/system/add_org", ctrler.AddOrg)
+
+	v1.GET("/system/del_org", ctrler.DelOrg)
+	v1.POST("/system/del_org", ctrler.DelOrg)
+
+	v1.POST("/system/update_org", ctrler.UpdateOrg)
+	v1.PUT("/system/update_org", ctrler.UpdateOrg)
+
+	v1.GET("/system/get_org", ctrler.GetOrg)
+	v1.POST("/system/get_org", ctrler.GetOrg)
+
+	v1.GET("/system/page_org", ctrler.PageOrg)
+	v1.POST("/system/page_org", ctrler.PageOrg)
+}

+ 45 - 0
routers/role.go

@@ -0,0 +1,45 @@
+package routers
+
+import (
+	"git.qianqiusoft.com/qianqiusoft/light-apiengine/controllers/gen"
+	"git.qianqiusoft.com/qianqiusoft/light-apiengine/engine"
+	"git.qianqiusoft.com/qianqiusoft/light-apiengine/middleware"
+)
+
+func init(){
+	addRegisterHandler(registerRoleRouter)
+}
+
+func registerRoleRouter(e *engine.ApiEngine){
+	api:=e.GinEngine.Group("/api")
+	v1:=api.Group("/v1")
+
+	v1.Use(middleware.LoginWare())
+
+	ctrler := gen.NewSystemController(e.OrmEngine)
+
+	v1.POST("/system/add_role", ctrler.AddRole)
+	v1.PUT("/system/add_role", ctrler.AddRole)
+
+	v1.GET("/system/del_role", ctrler.DelRole)
+	v1.POST("/system/del_role", ctrler.DelRole)
+
+	v1.POST("/system/update_role", ctrler.UpdateRole)
+	v1.PUT("/system/update_role", ctrler.UpdateRole)
+
+	v1.GET("/system/find_role_page", ctrler.FindRolePage)
+	v1.POST("/system/find_role_page", ctrler.FindRolePage)
+
+
+	v1.GET("/system/role_all", ctrler.RoleAll)
+	v1.POST("/system/role_all", ctrler.RoleAll)
+
+	v1.GET("/system/find_permissions", ctrler.FindPermissions)
+	v1.POST("/system/find_permissions", ctrler.FindPermissions)
+
+	v1.GET("/system/find_role_menu", ctrler.FindRoleMenu)
+	v1.POST("/system/find_role_menu", ctrler.FindRoleMenu)
+
+	v1.GET("/system/save_role_menu", ctrler.SaveRoleMenu)
+	v1.POST("/system/save_role_menu", ctrler.SaveRoleMenu)
+}

+ 37 - 0
routers/router.go

@@ -0,0 +1,37 @@
+
+package routers
+
+import (
+	"git.qianqiusoft.com/qianqiusoft/light-apiengine/engine"
+	"git.qianqiusoft.com/qianqiusoft/light-apiengine/models"
+	"sync"
+)
+
+var (
+	_registerHandlers []func(e *engine.ApiEngine) = nil
+	_registerHandlerMutex sync.Mutex
+)
+
+func addRegisterHandler(handler func(e *engine.ApiEngine)){
+	_registerHandlerMutex.Lock()
+	_registerHandlerMutex.Unlock()
+	if _registerHandlers == nil{
+		_registerHandlers = make([]func(e *engine.ApiEngine), 0)
+	}
+	_registerHandlers = append(_registerHandlers, handler)
+}
+
+func Register(e *engine.ApiEngine){
+	models.SyncDb(e.OrmEngine)
+
+	_registerHandlerMutex.Lock()
+	_registerHandlerMutex.Unlock()
+	for i := range _registerHandlers{
+		_registerHandlers[i](e)
+	}
+}
+
+func InitRouter(e *engine.ApiEngine){
+	Register(e)
+}
+

+ 0 - 284
routers/router_gen.go

@@ -1,284 +0,0 @@
-package routers
-
-import (
-	"fmt"
-	"git.qianqiusoft.com/qianqiusoft/light-apiengine/config"
-	"git.qianqiusoft.com/qianqiusoft/light-apiengine/controllers"
-	"git.qianqiusoft.com/qianqiusoft/light-apiengine/engine"
-	"git.qianqiusoft.com/qianqiusoft/light-apiengine/middleware"
-	"git.qianqiusoft.com/qianqiusoft/light-apiengine/models"
-	"github.com/gin-gonic/gin"
-)
-
-var g_engine *engine.ApiEngine
-
-func sys_attachmentController_upload(c *gin.Context) {
-	controllers.NewSysAttachmentController(c, g_engine).Upload()
-}
-
-func sys_attachmentController_download(c *gin.Context) {
-	controllers.NewSysAttachmentController(c, g_engine).Download()
-}
-
-func sys_attachmentController_delete(c *gin.Context) {
-	controllers.NewSysAttachmentController(c, g_engine).Delete()
-}
-
-func systemController_login(c *gin.Context) {
-	controllers.NewSystemController(c, g_engine).Login()
-}
-
-func systemController_logout(c *gin.Context) {
-	controllers.NewSystemController(c, g_engine).Logout()
-}
-
-func systemController_get_nav_tree(c *gin.Context) {
-	controllers.NewSystemController(c, g_engine).GetNavTree()
-}
-
-func systemController_get_menu_tree(c *gin.Context) {
-	controllers.NewSystemController(c, g_engine).GetMenuTree()
-}
-
-func systemController_find_user_page(c *gin.Context) {
-	controllers.NewSystemController(c, g_engine).FindUserPage()
-}
-
-func systemController_get_org_tree(c *gin.Context) {
-	controllers.NewSystemController(c, g_engine).GetOrgTree()
-}
-
-func systemController_add_user(c *gin.Context) {
-	controllers.NewSystemController(c, g_engine).AddUser()
-}
-
-func systemController_del_user(c *gin.Context) {
-	controllers.NewSystemController(c, g_engine).DelUser()
-}
-
-func systemController_update_user(c *gin.Context) {
-	controllers.NewSystemController(c, g_engine).UpdateUser()
-}
-
-func systemController_add_role(c *gin.Context) {
-	controllers.NewSystemController(c, g_engine).AddRole()
-}
-
-func systemController_del_role(c *gin.Context) {
-	controllers.NewSystemController(c, g_engine).DelRole()
-}
-
-func systemController_update_role(c *gin.Context) {
-	controllers.NewSystemController(c, g_engine).UpdateRole()
-}
-
-func systemController_find_role_page(c *gin.Context) {
-	controllers.NewSystemController(c, g_engine).FindRolePage()
-}
-
-func systemController_find_role_menu(c *gin.Context) {
-	controllers.NewSystemController(c, g_engine).FindRoleMenu()
-}
-
-func systemController_save_role_menu(c *gin.Context) {
-	controllers.NewSystemController(c, g_engine).SaveRoleMenu()
-}
-
-func systemController_role_all(c *gin.Context) {
-	controllers.NewSystemController(c, g_engine).RoleAll()
-}
-
-func systemController_find_permissions(c *gin.Context) {
-	controllers.NewSystemController(c, g_engine).FindPermissions()
-}
-
-func systemController_add_menu(c *gin.Context) {
-	controllers.NewSystemController(c, g_engine).AddMenu()
-}
-
-func systemController_del_menu(c *gin.Context) {
-	controllers.NewSystemController(c, g_engine).DelMenu()
-}
-
-func systemController_update_menu(c *gin.Context) {
-	controllers.NewSystemController(c, g_engine).UpdateMenu()
-}
-
-
-func systemController_add_org(c *gin.Context) {
-	controllers.NewSystemController(c, g_engine).AddOrg()
-}
-
-func systemController_del_org(c *gin.Context) {
-	controllers.NewSystemController(c, g_engine).DelOrg()
-}
-
-func systemController_update_org(c *gin.Context) {
-	controllers.NewSystemController(c, g_engine).UpdateOrg()
-}
-
-func systemController_get_org(c *gin.Context) {
-	controllers.NewSystemController(c, g_engine).GetOrg()
-}
-
-func systemController_page_org(c *gin.Context) {
-	controllers.NewSystemController(c, g_engine).PageOrg()
-}
-
-func apiController_api_doc(c *gin.Context) {
-	controllers.NewApiController(c, g_engine).ApiDoc()
-}
-
-func SyncDb(e *engine.ApiEngine) {
-	if !config.AppConfig.SyncDb {
-		return
-	}
-
-	e.OrmEngine.Sync2(new(models.SysUser))
-
-	e.OrmEngine.Sync2(new(models.SysOrg))
-
-	e.OrmEngine.Sync2(new(models.SysRole))
-
-	e.OrmEngine.Sync2(new(models.SysUserRole))
-
-	e.OrmEngine.Sync2(new(models.SysMenu))
-
-	e.OrmEngine.Sync2(new(models.SysRoleMenu))
-
-	e.OrmEngine.Sync2(new(models.SysPermission))
-
-	e.OrmEngine.Sync2(new(models.SysRolePermission))
-
-	e.OrmEngine.Sync2(new(models.SysAttachment))
-
-}
-
-func InitRouter(e *engine.ApiEngine) {
-	g_engine = e
-	SyncDb(e)
-
-	api := e.GinEngine.Group("/api")
-	v1 := api.Group("/v1")
-
-	system := v1.Group("/system")
-	system.GET("/login", systemController_login)
-	system.POST("/login", systemController_login)
-	system.PUT("/login", systemController_login)
-	system.GET("/logout", systemController_logout)
-	system.POST("/logout", systemController_logout)
-
-	//system.GET("/sys_attachment/upload",sys_attachmentController_upload)
-	system.POST("/upload", sys_attachmentController_upload)
-	//system.PUT("/sys_attachment/upload",sys_attachmentController_upload)
-
-	system.GET("/download/:attrId", sys_attachmentController_download)
-	//system.POST("/sys_attachment/download",sys_attachmentController_download)
-	//system.PUT("/sys_attachment/download",sys_attachmentController_download)
-
-	system.GET("/delete/:attrId", sys_attachmentController_delete)
-	//system.POST("/sys_attachment/delete",sys_attachmentController_delete)
-	//system.PUT("/sys_attachment/delete",sys_attachmentController_delete)
-
-	v1.Use(middleware.LoginWare())
-
-	v1.GET("/system/get_nav_tree", systemController_get_nav_tree)
-	v1.GET("/system/sidebar", systemController_get_nav_tree)
-	//v1.POST("/system/get_nav_tree", systemController_get_nav_tree)
-	//v1.PUT("/system/get_nav_tree",systemController_get_nav_tree)
-
-	v1.GET("/system/get_menu_tree", systemController_get_menu_tree)
-	v1.POST("/system/get_menu_tree", systemController_get_menu_tree)
-	//v1.PUT("/system/get_menu_tree",systemController_get_menu_tree)
-
-	v1.GET("/system/find_user_page", systemController_find_user_page)
-	v1.POST("/system/find_user_page", systemController_find_user_page)
-	//v1.PUT("/system/find_user_page",systemController_find_user_page)
-
-	v1.GET("/system/get_org_tree", systemController_get_org_tree)
-	v1.POST("/system/get_org_tree", systemController_get_org_tree)
-	//v1.PUT("/system/get_org_tree",systemController_get_org_tree)
-
-	v1.GET("/system/add_user", systemController_add_user)
-	v1.POST("/system/add_user", systemController_add_user)
-	v1.PUT("/system/add_user", systemController_add_user)
-	fmt.Println("-------------------------------------------------------add /users router")
-	v1.POST("/users", systemController_add_user)
-
-	v1.GET("/system/del_user", systemController_del_user)
-	v1.POST("/system/del_user", systemController_del_user)
-	v1.PUT("/system/del_user", systemController_del_user)
-
-	v1.GET("/system/update_user", systemController_update_user)
-	v1.POST("/system/update_user", systemController_update_user)
-	v1.PUT("/system/update_user", systemController_update_user)
-
-	v1.GET("/system/add_role", systemController_add_role)
-	v1.POST("/system/add_role", systemController_add_role)
-	v1.PUT("/system/add_role", systemController_add_role)
-
-	v1.GET("/system/del_role", systemController_del_role)
-	v1.POST("/system/del_role", systemController_del_role)
-	v1.PUT("/system/del_role", systemController_del_role)
-
-	v1.GET("/system/update_role", systemController_update_role)
-	v1.POST("/system/update_role", systemController_update_role)
-	v1.PUT("/system/update_role", systemController_update_role)
-
-	v1.GET("/system/find_role_page", systemController_find_role_page)
-	v1.POST("/system/find_role_page", systemController_find_role_page)
-	v1.PUT("/system/find_role_page", systemController_find_role_page)
-
-	v1.GET("/system/find_role_menu", systemController_find_role_menu)
-	v1.POST("/system/find_role_menu", systemController_find_role_menu)
-	v1.PUT("/system/find_role_menu", systemController_find_role_menu)
-
-	v1.GET("/system/save_role_menu", systemController_save_role_menu)
-	v1.POST("/system/save_role_menu", systemController_save_role_menu)
-	v1.PUT("/system/save_role_menu", systemController_save_role_menu)
-
-	v1.GET("/system/role_all", systemController_role_all)
-	v1.POST("/system/role_all", systemController_role_all)
-	v1.PUT("/system/role_all", systemController_role_all)
-
-	v1.GET("/system/find_permissions", systemController_find_permissions)
-	v1.POST("/system/find_permissions", systemController_find_permissions)
-	v1.PUT("/system/find_permissions", systemController_find_permissions)
-
-	v1.GET("/system/add_menu", systemController_add_menu)
-	v1.POST("/system/add_menu", systemController_add_menu)
-	v1.PUT("/system/add_menu", systemController_add_menu)
-
-	v1.GET("/system/del_menu", systemController_del_menu)
-	v1.POST("/system/del_menu", systemController_del_menu)
-	v1.PUT("/system/del_menu", systemController_del_menu)
-
-	v1.GET("/system/update_menu", systemController_update_menu)
-	v1.POST("/system/update_menu", systemController_update_menu)
-	v1.PUT("/system/update_menu", systemController_update_menu)
-
-	v1.GET("/system/add_org", systemController_add_org)
-	v1.POST("/system/add_org", systemController_add_org)
-	v1.PUT("/system/add_org", systemController_add_org)
-
-	v1.GET("/system/del_org", systemController_del_org)
-	v1.POST("/system/del_org", systemController_del_org)
-	v1.PUT("/system/del_org", systemController_del_org)
-
-	v1.GET("/system/update_org", systemController_update_org)
-	v1.POST("/system/update_org", systemController_update_org)
-	v1.PUT("/system/update_org", systemController_update_org)
-
-	v1.GET("/system/get_org", systemController_get_org)
-	v1.POST("/system/get_org", systemController_get_org)
-	v1.PUT("/system/get_org", systemController_get_org)
-
-	v1.GET("/system/page_org", systemController_page_org)
-	v1.POST("/system/page_org", systemController_page_org)
-	v1.PUT("/system/page_org", systemController_page_org)
-
-	v1.GET("/api/api_doc", apiController_api_doc)
-	//v1.POST("/api/api_doc",apiController_api_doc)
-	//v1.PUT("/api/api_doc",apiController_api_doc)
-
-}

+ 19 - 0
routers/sso.go

@@ -0,0 +1,19 @@
+package routers
+
+import (
+	"git.qianqiusoft.com/qianqiusoft/light-apiengine/controllers/gen"
+	"git.qianqiusoft.com/qianqiusoft/light-apiengine/engine"
+)
+
+func init(){
+	addRegisterHandler(registerSSORouter)
+}
+
+func registerSSORouter(e *engine.ApiEngine){
+	ssoGroup:=e.GinEngine.Group("/api")
+
+	ctrler := gen.NewSSOController(e.OrmEngine)
+
+	ssoGroup.GET("/ssoclient", ctrler.SSOClient)
+	ssoGroup.GET("/ssoclient/logout", ctrler.SSOLogout)
+}

+ 24 - 0
routers/system.go

@@ -0,0 +1,24 @@
+package routers
+
+import (
+	"git.qianqiusoft.com/qianqiusoft/light-apiengine/controllers/gen"
+	"git.qianqiusoft.com/qianqiusoft/light-apiengine/engine"
+)
+
+func init(){
+	addRegisterHandler(registerSystemRouter)
+}
+
+func registerSystemRouter(e *engine.ApiEngine){
+	api:=e.GinEngine.Group("/api")
+	system:=api.Group("/v1/system")
+
+	ctrler := gen.NewSystemController(e.OrmEngine)
+
+	system.GET("/login", ctrler.Login)
+	system.POST("/login", ctrler.Login)
+
+	system.GET("/logout", ctrler.Logout)
+	system.POST("/logout", ctrler.Logout)
+
+}

+ 33 - 0
routers/user.go

@@ -0,0 +1,33 @@
+package routers
+
+import (
+	"git.qianqiusoft.com/qianqiusoft/light-apiengine/controllers/gen"
+	"git.qianqiusoft.com/qianqiusoft/light-apiengine/engine"
+	"git.qianqiusoft.com/qianqiusoft/light-apiengine/middleware"
+)
+
+func init(){
+	addRegisterHandler(registerUserRouter)
+}
+
+func registerUserRouter(e *engine.ApiEngine){
+	api:=e.GinEngine.Group("/api")
+	v1:=api.Group("/v1")
+
+	v1.Use(middleware.LoginWare())
+
+	ctrler := gen.NewSystemController(e.OrmEngine)
+
+	v1.GET("/system/find_user_page", ctrler.FindUserPage)
+	v1.POST("/system/find_user_page", ctrler.FindUserPage)
+
+	v1.POST("/system/add_user", ctrler.AddUser)
+	v1.PUT("/system/add_user", ctrler.AddUser)
+	v1.POST("/users", ctrler.AddUser)
+
+	v1.GET("/system/del_user", ctrler.DelUser)
+	v1.POST("/system/del_user", ctrler.DelUser)
+
+	v1.POST("/system/update_user", ctrler.UpdateUser)
+	v1.PUT("/system/update_user", ctrler.UpdateUser)
+}

+ 416 - 0
wfclient/client.go

@@ -0,0 +1,416 @@
+package wfclient
+
+import (
+	"encoding/base64"
+	"encoding/json"
+	"errors"
+	"fmt"
+	"net/http"
+	"strconv"
+	"strings"
+)
+
+type Filter struct {
+	GroupOp string         `json:"groupOp"`
+	Rules   []*FilterField `json:"rules"`
+}
+
+type FilterField struct {
+	Field string `json:"field"`
+	Op    string `json:"op"`
+	Data  string `json:"data"`
+}
+
+type CallbackArg struct {
+	DefineId   string
+	InstanceId string
+	DefineName string
+	FormData   string
+	Choice     string
+	Executor   string
+	UserId     string
+}
+
+type WFClient struct {
+	endpoint      string
+	authorization string
+	userId        string
+	username      string
+	token         string
+	domain        string
+	callbackMap   map[string]func(CallbackArg)
+}
+
+var instance *WFClient = nil
+
+/**
+ * @brief: single instance
+ */
+func Instance() *WFClient {
+	if instance == nil {
+		instance = &WFClient{}
+		instance.endpoint = ""
+		instance.authorization = ""
+		instance.userId = ""
+		instance.callbackMap = make(map[string]func(CallbackArg))
+		HttpClientInstance().setRequestInterseptor(instance.wfReqInterseptor)
+	}
+	return instance
+}
+
+/**
+ * @brief: init
+ * @param1 endpoint: endpoint of wf service, do not end with /; such as http://wf.qianqiusoft.com
+ * @param2 userId: user's id
+ * @param3 username: username
+ * @param4 token: token
+ * @param5 domain: domain, its default value is qianqiusoft.com
+ * @return1: information of error, nil if everything is all right
+ */
+func (w *WFClient) Init(endpoint, userId, username, token, domain string) error {
+	if w.token == token && w.authorization != "" {
+		fmt.Println("wfclient token", w.token, "does already exist, token is", w.authorization)
+		return nil
+	}
+
+	var err error = nil
+	w.endpoint = endpoint
+	w.userId = userId
+	w.authorization, err = w.createAuthorization(username, token, domain)
+	if err != nil {
+		return err
+	} else {
+		return nil
+	}
+}
+
+/**
+ * @brief: add callback
+ * @param1: key
+ * @param2: callback
+ */
+func (w *WFClient) AddCallback(key string, cb func(CallbackArg)) {
+	if _, ok := w.callbackMap[key]; !ok {
+		w.callbackMap[key] = cb
+	} else {
+		fmt.Println("callback", key, "does already exist")
+	}
+}
+
+/**
+ * @brief: create or update the define,
+ * @param1 defineId: id of define, if the define with id does already exist, update the define
+ * @param2 defineName: name of define
+ * @param3 defineDesc: description of define
+ * @param4 diagram: diagram of define
+ * @param5 formName: name of the form
+ * @return1 information of error
+ */
+func (w *WFClient) CreateOrUpdateDefine(defineId, defineName, defineDesc, diagram, formName, tag, code string) ([]byte, error) {
+	url := w.getFullUrl(fmt.Sprintf("api/wf_define/%s", defineId))
+	fmt.Println("----url:", url)
+	params := make(map[string]string)
+	params["define_id"] = defineId
+	params["name"] = defineName
+	params["descript"] = defineDesc
+	params["data"] = diagram
+	params["form"] = formName
+	params["code"] = code
+	params["tag"] = tag
+
+	return HttpClientInstance().post(url, params, nil)
+}
+
+func (w *WFClient) FetchDefine(defineId string) ([]byte, error) {
+	url := w.getFullUrl("api/wf_define/" + defineId)
+
+	fmt.Println(url)
+
+	return HttpClientInstance().get(url, nil, nil)
+}
+
+func (w *WFClient) FetchAllDefines() ([]byte, error) {
+	url := w.getFullUrl("api/wf_define/all")
+
+	return HttpClientInstance().get(url, nil, nil)
+}
+
+/**
+ * @brief: get the flow define by tag
+ * @param1 tag: tag of the define, split by ,
+ * @return1: content of response
+ * @return2: information of error, nil if everything is all right
+ */
+func (w *WFClient) FetchDefinesByTag(tag string) ([]byte, error) {
+	url := w.getFullUrl("api/wf_define/list/tag")
+	params := make(map[string]string)
+	params["tag"] = tag
+
+	return HttpClientInstance().get(url, params, nil)
+}
+
+/**
+ * @brief: get the flow design diagram
+ * @param1 id: id of flow define
+ * @return1: content of response
+ * @return2: information of error, nil if everything is all right
+ */
+func (w *WFClient) FetchDesignDiagram(defineId string) ([]byte, error) {
+	url := w.getFullUrl(fmt.Sprintf("api/wf_define/designer/%s", defineId))
+
+	return HttpClientInstance().get(url, nil, nil)
+}
+
+/**
+ * @brief: create a wf instance
+ * @param1 defineId: id of wf define
+ * @param2 name: name of instance
+ * @param3 formData: data to submit
+ * @return1: content of response
+ * @return2: error
+ */
+func (w *WFClient) CreateInstance(defineId, name, formData string) ([]byte, error) {
+	url := w.getFullUrl("api/wf_instance")
+
+	params := make(map[string]string)
+	params["define_id"] = defineId
+	params["name"] = name
+	params["form_data"] = formData
+
+	return HttpClientInstance().post(url, params, nil)
+}
+
+/**
+ * @brief: run the wf instance
+ * @param1 instanceId: id of instance
+ * @param2 userId: approver id
+ * @param3 choice: choice
+ * @param4 options: options
+ * @return1 content of response
+ * @return2 error
+ */
+func (w *WFClient) Run(instanceId, userId, choice, options, nextStep string) ([]byte, error) {
+	url := w.getFullUrl("api/wf_instance/run")
+
+	params := make(map[string]string)
+	params["instance_id"] = instanceId
+	params["users"] = userId
+	if choice != "" {
+		params["choice"] = choice
+	}
+	if options != "" {
+		params["opinion"] = options
+	}
+	if nextStep != "" {
+		params["nextStep"] = nextStep
+	}
+
+	var RunRespInfo struct {
+		DefineId      string `json:"define_id"`
+		InstanceId    string `json:"instance_id"`
+		DefineName    string `json:"define_name"`
+		Choice        string `json:"choice"`
+		FormData      string `json:"form_data"`
+		StepName      string `json:"step_name"`
+		ActorType     string `json:"actor_type"`
+		Executor      string `json:"executor"`
+		StartCallback string `json:"start_callback"`
+	}
+
+	bytess, err := HttpClientInstance().post(url, params, nil)
+	if err != nil {
+		return nil, err
+	}
+
+	err = json.Unmarshal(bytess, &RunRespInfo)
+	if err != nil {
+		return nil, err
+	}
+
+	fmt.Println("------------------------------------->121", RunRespInfo.StartCallback)
+
+	callbacks := strings.Split(RunRespInfo.StartCallback, ",")
+
+	for _, callbackKye := range callbacks {
+		callback, ok := w.callbackMap[callbackKye]
+		if ok {
+			fmt.Println("------------------------------------->121")
+			callback(CallbackArg{
+				DefineId:   RunRespInfo.DefineId,
+				InstanceId: RunRespInfo.InstanceId,
+				DefineName: RunRespInfo.DefineName,
+				FormData:   RunRespInfo.FormData,
+				Choice:     RunRespInfo.Choice,
+				Executor:   RunRespInfo.Executor,
+				UserId:     w.userId,
+			})
+		}
+	}
+
+	return []byte{}, nil
+}
+
+/**
+ * @brief: pre the wf instance
+ * @param1 instanceId: id of instance
+ * @param2 choice: choice of step
+ * @return1 content of response
+ * @return2 error
+ */
+func (w *WFClient) PreRun(instanceId, choice string) ([]byte, error) {
+	url := w.getFullUrl("api/wf_instance/prerun")
+
+	params := make(map[string]string)
+	params["instance_id"] = instanceId
+	params["choice"] = choice
+
+	return HttpClientInstance().post(url, params, nil)
+}
+
+/**
+ * @brief: fetch my instances
+ * @param1 page: page num, start from 1
+ * @param2 rows: count per page, its default value is 10000
+ * @return1: content of response
+ * @return2: information of error
+ */
+func (w *WFClient) FetchMyInstances(page, rows int) ([]byte, error) {
+	url := w.getFullUrl("/api/wf_instance/mime")
+
+	params := make(map[string]string)
+	params["page"] = strconv.FormatInt(int64(page), 10)
+	params["pageSize"] = strconv.FormatInt(int64(rows), 10)
+
+	return HttpClientInstance().get(url, params, nil)
+}
+
+/**
+ * @brief: fetch current step of login user
+ * @param1 instanceId: id of instance
+ * @return1 content of response
+ * @return2 error
+ */
+func (w *WFClient) FetchCurrentStepByLoginUser(instanceId string) ([]byte, error) {
+	url := w.getFullUrl("/api/wf_instance/user/current")
+
+	params := make(map[string]string)
+	params["instance_id"] = instanceId
+
+	return HttpClientInstance().get(url, params, nil)
+}
+
+/**
+ * @brief: fetch current step of instance
+ * @param1 instanceId: id of instance
+ * @return1 content of response
+ * @return2 error
+ */
+func (w *WFClient) FetchCurrentStep(instanceId string) ([]byte, error) {
+	url := w.getFullUrl("/api/wf_instance/current")
+
+	params := make(map[string]string)
+	params["instance_id"] = instanceId
+
+	return HttpClientInstance().get(url, params, nil)
+}
+
+/**
+ * @brief: fetch my to do list
+ * @param1 page: page num, start from 1
+ * @param2 rows: count per page, its default value is 10000
+ * @return1: content of response
+ * @return2: information of error
+ */
+func (w *WFClient) FetchToDoList(page, rows int) ([]byte, error) {
+	url := w.getFullUrl("/api/wf_instance/todo")
+
+	params := make(map[string]string)
+	params["page"] = strconv.FormatInt(int64(page), 10)
+	params["pageSize"] = strconv.FormatInt(int64(rows), 10)
+
+	return HttpClientInstance().get(url, params, nil)
+}
+
+/**
+ * @brief: fetch my done list
+ * @param1 page: page num, start from 1
+ * @param2 rows: count per page, its default value is 10000
+ * @return1: content of response
+ * @return2: information of error
+ */
+func (w *WFClient) FetchDoneList(page, rows int) ([]byte, error) {
+	url := w.getFullUrl("/api/wf_instance/done")
+
+	params := make(map[string]string)
+	params["page"] = strconv.FormatInt(int64(page), 10)
+	params["pageSize"] = strconv.FormatInt(int64(rows), 10)
+
+	return HttpClientInstance().get(url, params, nil)
+}
+
+func (w *WFClient) FetchWFINstances(page, rows int, filters, sidx, sord string) ([]byte, error) {
+	url := w.getFullUrl("/api/wf_instance/list")
+
+	params := make(map[string]string)
+	params["page"] = strconv.FormatInt(int64(page), 10)
+	params["rows"] = strconv.FormatInt(int64(rows), 10)
+	params["sidx"] = sidx
+	params["sord"] = sord
+	params["filters"] = filters
+
+	return HttpClientInstance().get(url, params, nil)
+}
+
+/**
+ * @brief: wf req interseptor
+ * @param1 r: http req
+ */
+func (w *WFClient) wfReqInterseptor(r *http.Request) {
+	r.Header.Add("Authorization", w.authorization)
+}
+
+/**
+ * @brief: create the authorization by username, token and domain
+ * @param2 username: username
+ * @param3 token: token
+ * @param4 domain: domain, its default value is qianqiusoft.com
+ * @return1 authorization, such as Bearer adfeadfsdfsdffds
+ * @return2 information of error, nil if everything is all right
+ */
+func (w *WFClient) createAuthorization(username, token, domain string) (string, error) {
+	if username == "" || token == "" {
+		return "", errors.New("username or token is empty")
+	}
+	if domain == "" {
+		domain = "qianqiusoft.com"
+	}
+	w.username = username
+	w.token = token
+	w.domain = domain
+
+	tstr := fmt.Sprintf("%s:%s:%s", username, token, domain)
+	tbase64str := base64.StdEncoding.EncodeToString([]byte(tstr))
+
+	finalStr := "sso-auth-token:" + tbase64str
+	return "Bearer " + base64.StdEncoding.EncodeToString([]byte(finalStr)), nil
+}
+
+/**
+ * @brief: get full url
+ * @param1 path: api path, such as /api/wf_instance/done
+ * @return1 url with query params
+ */
+func (w *WFClient) getFullUrl(path string) string {
+	path = strings.TrimLeft(path, "/")
+	return fmt.Sprintf("%s/%s", w.endpoint, path)
+}
+
+//撤回
+func (w *WFClient) Recall(definedId string) ([]byte, error) {
+	url := w.getFullUrl("/api/wf_instance/recall")
+
+	params := make(map[string]string)
+	params["instance_id"] = definedId
+
+	return HttpClientInstance().post(url, params, nil)
+}

+ 165 - 0
wfclient/http.go

@@ -0,0 +1,165 @@
+package wfclient
+
+import (
+	"bytes"
+	"crypto/tls"
+	"errors"
+	"fmt"
+	"io"
+	"io/ioutil"
+	"mime/multipart"
+	"net/http"
+	"net/url"
+	"os"
+	"strings"
+	"time"
+)
+
+type HttpClient struct {
+	reqInterseptor func(r *http.Request)
+}
+
+var httpInstance *HttpClient = nil
+
+/**
+ * @brief: single instance
+ */
+func HttpClientInstance()*HttpClient{
+	if httpInstance == nil{
+		httpInstance = &HttpClient{}
+	}
+	return httpInstance
+}
+
+/**
+ * @brief: set interseptor of request
+ * @param1 interseptor: interseptor
+ */
+func (h *HttpClient)setRequestInterseptor(interseptor func(r *http.Request)){
+	h.reqInterseptor = interseptor
+}
+
+/**
+ * @brief http get
+ * @param1 url: url
+ * @param2 params: param array, key-value
+ * @param3 headers: header array
+ * @return1: content of response
+ * @return2: error
+ */
+func (h *HttpClient)get(url string, params map[string]string, headers map[string]string) ([]byte, error) {
+	return h.doRequest("GET", url, params, headers)
+}
+
+// post
+func (h *HttpClient)post(url string, params map[string]string, headers map[string]string) ([]byte, error) {
+	return h.doRequest("POST", url, params, headers)
+}
+
+// 模拟form提交数据,包含,上传文件
+func (h *HttpClient)postFormWithFile(url string, params map[string]string, paramName, path string) ([]byte, error) {
+	file, err := os.Open(path)
+	if err != nil {
+		return nil, err
+	}
+	defer file.Close()
+	return h.postFormWithReader(url, params, paramName, path, file)
+}
+
+// 模拟form提交数据,包含,上传文件
+func (h *HttpClient)postFormWithReader(url string, params map[string]string, fileField, fileName string, r io.Reader) ([]byte, error) {
+	body := &bytes.Buffer{}
+	writer := multipart.NewWriter(body)
+	part, err := writer.CreateFormFile(fileField, fileName)
+	if err != nil {
+		return nil, err
+	}
+	_, err = io.Copy(part, r)
+	for key, val := range params {
+		_ = writer.WriteField(key, val)
+	}
+	err = writer.Close()
+	if err != nil {
+		return nil, err
+	}
+	request, err := http.NewRequest("POST", url, body)
+	request.Header.Set("Content-Type", writer.FormDataContentType())
+	return h.getResponse(request)
+}
+
+func (h *HttpClient)doRequest(method string, url string, params map[string]string, headers map[string]string) ([]byte, error) {
+	bodystr := ""
+	var r http.Request
+	if method == "GET"{
+		url = h.getUrlWithParams(url, params)
+	}else {
+		bodystr = h.getBobyStr(&r, params)
+	}
+	request, err := http.NewRequest(method, url, strings.NewReader(bodystr))
+	if err != nil {
+		return []byte(""), err
+	}
+	if headers == nil || len(headers) <= 0 {
+		request.Header.Set("Content-Type", "application/x-www-form-urlencoded")
+		request.Header.Set("Connection", "Keep-Alive")
+	} else {
+		for k, v := range headers {
+			request.Header.Set(k, v)
+		}
+	}
+	if h.reqInterseptor != nil{
+		h.reqInterseptor(request)
+	}
+	return h.getResponse(request)
+}
+
+func (h *HttpClient)getResponse(request *http.Request) ([]byte, error) {
+	if request == nil {
+		return []byte(""), errors.New("request is nil")
+	}
+	tr := &http.Transport{
+		TLSClientConfig:       &tls.Config{InsecureSkipVerify: true},
+		ResponseHeaderTimeout: time.Second * 60,
+		DisableKeepAlives:     true,
+	}
+	client := http.Client{Transport: tr}
+	var resp *http.Response
+	var err error
+	resp, err = client.Do(request)
+	if err != nil {
+		//log.Println("http.Do failed,[err=%s][url=%s]", err, url)
+		return []byte(""), err
+	}
+	defer resp.Body.Close()
+	b, err := ioutil.ReadAll(resp.Body)
+	if err != nil {
+		return []byte(""), err
+	}
+	return b, err
+}
+
+func (h *HttpClient)getBobyStr(r *http.Request, params map[string]string)string{
+	r.ParseForm()
+	if params != nil {
+		for k, v := range params {
+			r.Form.Add(k, v)
+		}
+	}
+	return strings.TrimSpace(r.Form.Encode())
+}
+
+func (h *HttpClient)getUrlWithParams(urlstr string, params map[string]string)string {
+	if params != nil && len(params) > 0 {
+		i := strings.Index(urlstr, "?")
+		if i < 0 {
+			urlstr += "?"
+		} else {
+			urlstr += "&"
+		}
+		for k, v := range params {
+			urlstr += fmt.Sprintf("%s=%s&", k, url.QueryEscape(v))
+		}
+		urlstr = urlstr[:len(urlstr)-1]
+	}
+	return urlstr
+}