Pārlūkot izejas kodu

Merge branch 'master' of https://git.qianqiusoft.com/qianqiusoft/light-apiengine

yjw 6 gadi atpakaļ
vecāks
revīzija
a623328427

+ 19 - 0
.drone.yml

@@ -0,0 +1,19 @@
+clone:
+  depth: 50
+  recursive: true
+  path: light-apiengine
+build:
+  image: docker.qianqiusoft.com/golang:1.12
+  commands:
+    - git clone https://git.qianqiusoft.com/qianqiusoft/light-apiengine.git $GOPATH/src/git.qianqiusoft.com/qianqiusoft/light-apiengine
+    - git clone https://git.qianqiusoft.com/qianqiusoft/light-apiengine-client.git $GOPATH/src/git.qianqiusoft.com/qianqiusoft/light-apiengine-client
+    - godep
+    - CGO_ENABLED=0 go build -a -ldflags '-s'
+    - tar zcf light-apiengine.tar.gz conf sqlconfig doc web light-apiengine
+publish:
+  docker:
+    registry: docker.qianqiusoft.com
+    email: develop@qianqiusoft.com
+    repo: docker.qianqiusoft.com/light-apiengine
+    tag:
+      - latest

+ 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>

+ 8 - 0
Dockerfile

@@ -0,0 +1,8 @@
+FROM alpine
+
+ADD light-apiengine.tar.gz /app/
+
+VOLUME [ "/app/conf" ]
+EXPOSE 6166
+WORKDIR /app
+CMD ["/app/light-apiengine"]

+ 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
-}

+ 0 - 268
controllers/SystemController_gen.go

@@ -1,268 +0,0 @@
-
-package controllers
-
-import (
-	"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}
-	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 *SystemController) Login() {
-	//
-	System_Login(c)
-}
-
-// Logout
-// @Title Logout
-// @Description 用户退出         
-// @Success 200 {object} models.Account
-// @Failure 403 :id is empty
-// @router /logout  [post,get]
-func (c *SystemController) Logout() {
-	//
-	System_Logout(c)
-}
-
-// GetNavTree
-// @Title GetNavTree
-// @Description 获取导航菜单         
-// @Param	user    string  false  "用户id"  
-// @Success 200 {object} models.Account
-// @Failure 403 :id is empty
-// @router /get_nav_tree  [post,get]
-func (c *SystemController) GetNavTree() {
-	//
-	System_GetNavTree(c)
-}
-
-// GetMenuTree
-// @Title GetMenuTree
-// @Description 获取系统菜单         
-// @Param	user    string  false  "用户id"  
-// @Success 200 {object} models.Account
-// @Failure 403 :id is empty
-// @router /get_menu_tree  [post,get]
-func (c *SystemController) GetMenuTree() {
-	//
-	System_GetMenuTree(c)
-}
-
-// FindUserPage
-// @Title FindUserPage
-// @Description 获取用户分布数据         
-// @Param	page      false  "分页参数"  
-// @Success 200 {object} models.Account
-// @Failure 403 :id is empty
-// @router /find_user_page  [post,get]
-func (c *SystemController) FindUserPage() {
-	//
-	System_FindUserPage(c)
-}
-
-// GetOrgTree
-// @Title GetOrgTree
-// @Description 获取组织架构树         
-// @Success 200 {object} models.Account
-// @Failure 403 :id is empty
-// @router /get_org_tree  [post,get]
-func (c *SystemController) GetOrgTree() {
-	//
-	System_GetOrgTree(c)
-}
-
-// AddUser
-// @Title AddUser
-// @Description 添加用户         
-// @Param	login_id    string  false  "登录ID"  
-// @Param	password    string  false  "密码"  
-// @Param	org_id    string  false  "组织ID"  
-// @Param	email    string  false  "邮箱"  
-// @Success 200 {object} models.Account
-// @Failure 403 :id is empty
-// @router /add_user  [post,get,put]
-func (c *SystemController) AddUser() {
-	//
-	System_AddUser(c)
-}
-
-// DelUser
-// @Title DelUser
-// @Description 删除用户         
-// @Param	id    string  false  "用户ID"  
-// @Success 200 {object} models.Account
-// @Failure 403 :id is empty
-// @router /del_user  [post,get,put]
-func (c *SystemController) DelUser() {
-	//
-	System_DelUser(c)
-}
-
-// UpdateUser
-// @Title UpdateUser
-// @Description 修改用户         
-// @Param	login_id    string  false  "登录ID"  
-// @Param	password    string  false  "密码"  
-// @Param	org_id    string  false  "组织ID"  
-// @Param	email    string  false  "邮箱"  
-// @Success 200 {object} models.Account
-// @Failure 403 :id is empty
-// @router /update_user  [post,get,put]
-func (c *SystemController) UpdateUser() {
-	//
-	System_UpdateUser(c)
-}
-
-// AddRole
-// @Title AddRole
-// @Description 添加角色         
-// @Param	name    string  false  "角色名称"  
-// @Param	remark    string  false  "备注"  
-// @Success 200 {object} models.Account
-// @Failure 403 :id is empty
-// @router /add_role  [post,get,put]
-func (c *SystemController) AddRole() {
-	//
-	System_AddRole(c)
-}
-
-// DelRole
-// @Title DelRole
-// @Description 添加角色         
-// @Param	id    string  false  "角色ID"  
-// @Success 200 {object} models.Account
-// @Failure 403 :id is empty
-// @router /del_role  [post,get,put]
-func (c *SystemController) DelRole() {
-	//
-	System_DelRole(c)
-}
-
-// UpdateRole
-// @Title UpdateRole
-// @Description 修改角色         
-// @Param	id    string  false  "角色ID"  
-// @Param	name    string  false  "角色名称"  
-// @Param	remark    string  false  "备注"  
-// @Success 200 {object} models.Account
-// @Failure 403 :id is empty
-// @router /update_role  [post,get,put]
-func (c *SystemController) UpdateRole() {
-	//
-	System_UpdateRole(c)
-}
-
-// FindRolePage
-// @Title FindRolePage
-// @Description 角色分页         
-// @Param	page      false  "分页参数"  
-// @Success 200 {object} models.Account
-// @Failure 403 :id is empty
-// @router /find_role_page  [post,get,put]
-func (c *SystemController) FindRolePage() {
-	//
-	System_FindRolePage(c)
-}
-
-// FindRoleMenu
-// @Title FindRoleMenu
-// @Description 查找角色权限         
-// @Param	role_id    string  false  "角色id"  
-// @Success 200 {object} models.Account
-// @Failure 403 :id is empty
-// @router /find_role_menu  [post,get,put]
-func (c *SystemController) FindRoleMenu() {
-	//
-	System_FindRoleMenu(c)
-}
-
-// SaveRoleMenu
-// @Title SaveRoleMenu
-// @Description 保存角色权限         
-// @Param	role_menu    string  false  "角色权限"  
-// @Success 200 {object} models.Account
-// @Failure 403 :id is empty
-// @router /save_role_menu  [post,get,put]
-func (c *SystemController) SaveRoleMenu() {
-	//
-	System_SaveRoleMenu(c)
-}
-
-// RoleAll
-// @Title RoleAll
-// @Description 查找所有角色         
-// @Success 200 {object} models.Account
-// @Failure 403 :id is empty
-// @router /role_all  [post,get,put]
-func (c *SystemController) RoleAll() {
-	//
-	System_RoleAll(c)
-}
-
-// FindPermissions
-// @Title FindPermissions
-// @Description 查找用户权限         
-// @Success 200 {object} models.Account
-// @Failure 403 :id is empty
-// @router /find_permissions  [post,get,put]
-func (c *SystemController) FindPermissions() {
-	//
-	System_FindPermissions(c)
-}
-
-// AddMenu
-// @Title AddMenu
-// @Description 添加菜单         
-// @Param	    string  false  "菜单"  
-// @Success 200 {object} models.Account
-// @Failure 403 :id is empty
-// @router /add_menu  [post,get,put]
-func (c *SystemController) AddMenu() {
-	//
-	System_AddMenu(c)
-}
-
-// DelMenu
-// @Title DelMenu
-// @Description 删除菜单         
-// @Param	id    string  false  "菜单ID"  
-// @Success 200 {object} models.Account
-// @Failure 403 :id is empty
-// @router /del_menu  [post,get,put]
-func (c *SystemController) DelMenu() {
-	//
-	System_DelMenu(c)
-}
-
-// UpdateMenu
-// @Title UpdateMenu
-// @Description 更新菜单         
-// @Param	    string  false  "菜单"  
-// @Success 200 {object} models.Account
-// @Failure 403 :id is empty
-// @router /update_menu  [post,get,put]
-func (c *SystemController) UpdateMenu() {
-	//
-	System_UpdateMenu(c)
-}
-

+ 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})
 }
 

+ 339 - 0
controllers/gen/SystemController_gen.go

@@ -0,0 +1,339 @@
+
+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 SystemController struct {
+	Db *xorm.Engine
+}
+
+func NewSystemController(db *xorm.Engine) *SystemController {
+	controller := &SystemController{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 *SystemController) Login(ctx *gin.Context) {
+	//
+	partial.System_Login(&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 *SystemController) Logout(ctx *gin.Context) {
+	//
+	partial.System_Logout(&entitys.CtrlContext{ctx, c.Db})
+}
+
+// GetNavTree
+// @Title GetNavTree
+// @Description 获取导航菜单
+// @Param	user    string  false  "用户id"
+// @Success 200 {object} models.Account
+// @Failure 403 :id is empty
+// @router /get_nav_tree  [post,get]
+func (c *SystemController) GetNavTree(ctx *gin.Context) {
+	//
+	partial.System_GetNavTree(&entitys.CtrlContext{ctx, c.Db})
+}
+
+// GetMenuTree
+// @Title GetMenuTree
+// @Description 获取系统菜单
+// @Param	user    string  false  "用户id"
+// @Success 200 {object} models.Account
+// @Failure 403 :id is empty
+// @router /get_menu_tree  [post,get]
+func (c *SystemController) GetMenuTree(ctx *gin.Context) {
+	//
+	partial.System_GetMenuTree(&entitys.CtrlContext{ctx, c.Db})
+}
+
+// FindUserPage
+// @Title FindUserPage
+// @Description 获取用户分布数据
+// @Param	page      false  "分页参数"
+// @Success 200 {object} models.Account
+// @Failure 403 :id is empty
+// @router /find_user_page  [post,get]
+func (c *SystemController) FindUserPage(ctx *gin.Context) {
+	//
+	partial.System_FindUserPage(&entitys.CtrlContext{ctx, c.Db})
+}
+
+// GetOrgTree
+// @Title GetOrgTree
+// @Description 获取组织架构树
+// @Success 200 {object} models.Account
+// @Failure 403 :id is empty
+// @router /get_org_tree  [post,get]
+func (c *SystemController) GetOrgTree(ctx *gin.Context) {
+	//
+	partial.System_GetOrgTree(&entitys.CtrlContext{ctx, c.Db})
+}
+
+// AddUser
+// @Title AddUser
+// @Description 添加用户
+// @Param	login_id    string  false  "登录ID"
+// @Param	password    string  false  "密码"
+// @Param	org_id    string  false  "组织ID"
+// @Param	email    string  false  "邮箱"
+// @Success 200 {object} models.Account
+// @Failure 403 :id is empty
+// @router /add_user  [post,get,put]
+func (c *SystemController) AddUser(ctx *gin.Context) {
+	//
+	partial.System_AddUser(&entitys.CtrlContext{ctx, c.Db})
+}
+
+// DelUser
+// @Title DelUser
+// @Description 删除用户
+// @Param	id    string  false  "用户ID"
+// @Success 200 {object} models.Account
+// @Failure 403 :id is empty
+// @router /del_user  [post,get,put]
+func (c *SystemController) DelUser(ctx *gin.Context) {
+	//
+	partial.System_DelUser(&entitys.CtrlContext{ctx, c.Db})
+}
+
+// UpdateUser
+// @Title UpdateUser
+// @Description 修改用户
+// @Param	login_id    string  false  "登录ID"
+// @Param	password    string  false  "密码"
+// @Param	org_id    string  false  "组织ID"
+// @Param	email    string  false  "邮箱"
+// @Success 200 {object} models.Account
+// @Failure 403 :id is empty
+// @router /update_user  [post,get,put]
+func (c *SystemController) UpdateUser(ctx *gin.Context) {
+	//
+	partial.System_UpdateUser(&entitys.CtrlContext{ctx, c.Db})
+}
+
+// AddRole
+// @Title AddRole
+// @Description 添加角色
+// @Param	name    string  false  "角色名称"
+// @Param	remark    string  false  "备注"
+// @Success 200 {object} models.Account
+// @Failure 403 :id is empty
+// @router /add_role  [post,get,put]
+func (c *SystemController) AddRole(ctx *gin.Context) {
+	//
+	partial.System_AddRole(&entitys.CtrlContext{ctx, c.Db})
+}
+
+// DelRole
+// @Title DelRole
+// @Description 添加角色
+// @Param	id    string  false  "角色ID"
+// @Success 200 {object} models.Account
+// @Failure 403 :id is empty
+// @router /del_role  [post,get,put]
+func (c *SystemController) DelRole(ctx *gin.Context) {
+	//
+	partial.System_DelRole(&entitys.CtrlContext{ctx, c.Db})
+}
+
+// UpdateRole
+// @Title UpdateRole
+// @Description 修改角色
+// @Param	id    string  false  "角色ID"
+// @Param	name    string  false  "角色名称"
+// @Param	remark    string  false  "备注"
+// @Success 200 {object} models.Account
+// @Failure 403 :id is empty
+// @router /update_role  [post,get,put]
+func (c *SystemController) UpdateRole(ctx *gin.Context) {
+	//
+	partial.System_UpdateRole(&entitys.CtrlContext{ctx, c.Db})
+}
+
+// FindRolePage
+// @Title FindRolePage
+// @Description 角色分页
+// @Param	page      false  "分页参数"
+// @Success 200 {object} models.Account
+// @Failure 403 :id is empty
+// @router /find_role_page  [post,get,put]
+func (c *SystemController) FindRolePage(ctx *gin.Context) {
+	//
+	partial.System_FindRolePage(&entitys.CtrlContext{ctx, c.Db})
+}
+
+// FindRoleMenu
+// @Title FindRoleMenu
+// @Description 查找角色权限
+// @Param	role_id    string  false  "角色id"
+// @Success 200 {object} models.Account
+// @Failure 403 :id is empty
+// @router /find_role_menu  [post,get,put]
+func (c *SystemController) FindRoleMenu(ctx *gin.Context) {
+	//
+	partial.System_FindRoleMenu(&entitys.CtrlContext{ctx, c.Db})
+}
+
+// SaveRoleMenu
+// @Title SaveRoleMenu
+// @Description 保存角色权限
+// @Param	role_menu    string  false  "角色权限"
+// @Success 200 {object} models.Account
+// @Failure 403 :id is empty
+// @router /save_role_menu  [post,get,put]
+func (c *SystemController) SaveRoleMenu(ctx *gin.Context) {
+	//
+	partial.System_SaveRoleMenu(&entitys.CtrlContext{ctx, c.Db})
+}
+
+// RoleAll
+// @Title RoleAll
+// @Description 查找所有角色
+// @Success 200 {object} models.Account
+// @Failure 403 :id is empty
+// @router /role_all  [post,get,put]
+func (c *SystemController) RoleAll(ctx *gin.Context) {
+	//
+	partial.System_RoleAll(&entitys.CtrlContext{ctx, c.Db})
+}
+
+// FindPermissions
+// @Title FindPermissions
+// @Description 查找用户权限
+// @Success 200 {object} models.Account
+// @Failure 403 :id is empty
+// @router /find_permissions  [post,get,put]
+func (c *SystemController) FindPermissions(ctx *gin.Context) {
+	//
+	partial.System_FindPermissions(&entitys.CtrlContext{ctx, c.Db})
+}
+
+// AddMenu
+// @Title AddMenu
+// @Description 添加菜单
+// @Param	    string  false  "菜单"
+// @Success 200 {object} models.Account
+// @Failure 403 :id is empty
+// @router /add_menu  [post,get,put]
+func (c *SystemController) AddMenu(ctx *gin.Context) {
+	//
+	partial.System_AddMenu(&entitys.CtrlContext{ctx, c.Db})
+}
+
+// DelMenu
+// @Title DelMenu
+// @Description 删除菜单
+// @Param	id    string  false  "菜单ID"
+// @Success 200 {object} models.Account
+// @Failure 403 :id is empty
+// @router /del_menu  [post,get,put]
+func (c *SystemController) DelMenu(ctx *gin.Context) {
+	//
+	partial.System_DelMenu(&entitys.CtrlContext{ctx, c.Db})
+}
+
+// UpdateMenu
+// @Title UpdateMenu
+// @Description 更新菜单
+// @Param	    string  false  "菜单"
+// @Success 200 {object} models.Account
+// @Failure 403 :id is empty
+// @router /update_menu  [post,get,put]
+func (c *SystemController) UpdateMenu(ctx *gin.Context) {
+	//
+	partial.System_UpdateMenu(&entitys.CtrlContext{ctx, c.Db})
+}
+
+// AddOrg
+// @Title AddOrg
+// @Description 添加组织
+// @Param	    string  false  "组织"
+// @Success 200 {object} models.Account
+// @Failure 403 :id is empty
+// @router /add_org  [post,get,put]
+func (c *SystemController) AddOrg(ctx *gin.Context) {
+	//
+	partial.System_AddOrg(&entitys.CtrlContext{ctx, c.Db})
+}
+
+// DelOrg
+// @Title DelOrg
+// @Description 删除组织
+// @Param	id    string  false  "组织ID"
+// @Success 200 {object} models.Account
+// @Failure 403 :id is empty
+// @router /del_org  [post,get,put]
+func (c *SystemController) DelOrg(ctx *gin.Context) {
+	//
+	partial.System_DelOrg(&entitys.CtrlContext{ctx, c.Db})
+}
+
+// UpdateOrg
+// @Title UpdateOrg
+// @Description 更新组织
+// @Param	    string  false  "组织"
+// @Success 200 {object} models.Account
+// @Failure 403 :id is empty
+// @router /update_org  [post,get,put]
+func (c *SystemController) UpdateOrg(ctx *gin.Context) {
+	//
+	partial.System_UpdateOrg(&entitys.CtrlContext{ctx, c.Db})
+}
+
+// GetOrg
+// @Title GetOrg
+// @Description 根据ID获取组织
+// @Param	    string  false  "组织"
+// @Success 200 {object} models.Account
+// @Failure 403 :id is empty
+// @router /get_org  [post,get,put]
+func (c *SystemController) GetOrg(ctx *gin.Context) {
+	//
+	partial.System_GetOrg(&entitys.CtrlContext{ctx, c.Db})
+}
+
+// UpdateOrg
+// @Title UpdateOrg
+// @Description 更新组织
+// @Param	    string  false  "组织"
+// @Success 200 {object} models.Account
+// @Failure 403 :id is empty
+// @router /page_org  [post,get,put]
+func (c *SystemController) PageOrg(ctx *gin.Context) {
+	//
+	partial.System_PageOrg(&entitys.CtrlContext{ctx, c.Db})
+}
+
+// TreeList
+// @Title TreeList
+// @Description 获取树形数据
+// @Param	    string  false  ""
+// @Success 200 {object} models.Account
+// @Failure 403 :id is empty
+// @router /tree_list  [post,get,put]
+func (c *SystemController) TreeList(ctx *gin.Context) {
+	//
+	partial.System_TreeList(&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)

+ 287 - 40
controllers/SystemController.go → controllers/partial/SystemController.go

@@ -1,4 +1,4 @@
-package controllers
+package partial
 
 import (
 	"encoding/json"
@@ -7,9 +7,9 @@ import (
 	"strings"
 	"time"
 
-	"git.qianqiusoft.com/qianqiusoft/light-apiengine/models"
-
+	"git.qianqiusoft.com/qianqiusoft/light-apiengine/db"
 	"git.qianqiusoft.com/qianqiusoft/light-apiengine/entitys"
+	"git.qianqiusoft.com/qianqiusoft/light-apiengine/models"
 	sysmodel "git.qianqiusoft.com/qianqiusoft/light-apiengine/models"
 	"git.qianqiusoft.com/qianqiusoft/light-apiengine/utils"
 )
@@ -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,14 +93,14 @@ 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")
 
 	var menus []sysmodel.SysMenuTree
-	if user_id == "187c50a4-caad-4557-80c8-aca81af9f370"{
+	if user_id == "187c50a4-caad-4557-80c8-aca81af9f370" {
 		c.Db.SQL(sysmodel.Selectall_nav_tree_admin).Find(&menus)
-	}else{
+	} else {
 		c.Db.SQL(sysmodel.Selectall_nav_tree, user_id).Find(&menus)
 	}
 
@@ -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)
@@ -212,14 +212,14 @@ func System_FindUserPage(c *SystemController) {
 	var users []sysmodel.UserInfo
 
 	dbSession := c.Db.Table("sys_user")
-	dbSession.Select("sys_user.*, sys_org.name org_name")
+	dbSession.Select("sys_user.*, sys_organization.name org_name")
 
 	countSession := c.Db.Table("sys_user")
 
 	JoinTables := []models.Join{}
 	//JoinTables = append(JoinTables, models.Join{TabelName: "sys_user_role", Condition: "sys_user_role.user_id = sys_user.id", JoinOperator: "left"})
 	//JoinTables = append(JoinTables, models.Join{TabelName: "sys_role", Condition: "sys_user_role.role_id = sys_role.id", JoinOperator: "left"})
-	JoinTables = append(JoinTables, models.Join{TabelName: "sys_org", Condition: "sys_org.id = sys_user.org_id", JoinOperator: "left"})
+	JoinTables = append(JoinTables, models.Join{TabelName: "sys_organization", Condition: "sys_organization.id = sys_user.org_id", JoinOperator: "left"})
 
 	for _, join := range JoinTables {
 		dbSession = dbSession.Join(join.JoinOperator, join.TabelName, join.Condition)
@@ -285,13 +285,13 @@ 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)
-	if err != nil{
+	if err != nil {
 		c.Ctx.JSON(500, sysmodel.SysReturn{200, "c.Ctx.ShouldBindJSON error " + err.Error(), nil})
-		return;
+		return
 	}
 
 	fmt.Println(user.LoginId, "-----add user-----", user.Password, " --- ", user.OrgId)
@@ -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,14 +391,14 @@ 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
 	err := c.Ctx.BindJSON(&userInfo)
-	if err != nil{
+	if err != nil {
 		c.Ctx.JSON(500, sysmodel.SysReturn{500, err.Error(), nil})
-		return;
+		return
 	}
 
 	session := c.Db.NewSession()
@@ -413,8 +413,9 @@ func System_UpdateUser(c *SystemController) {
 
 	//2、修改角色
 	userRoles := []models.SysUserRole{}
+	roles := []string{}
 	if userInfo.UserRole != "" {
-		err = json.Unmarshal([]byte(userInfo.UserRole), &userRoles)
+		err = json.Unmarshal([]byte(userInfo.UserRole), &roles)
 		if err != nil {
 			session.Rollback()
 			c.Ctx.JSON(200, sysmodel.SysReturn{500, err.Error(), nil})
@@ -422,13 +423,17 @@ func System_UpdateUser(c *SystemController) {
 		}
 	}
 
-	for i, _ := range userRoles {
-		userRoles[i].Id = utils.NewUUID()
-		userRoles[i].CreateBy = user_id
-		userRoles[i].LastUpdateBy = user_id
-		userRoles[i].CreateTime = time.Now()
-		userRoles[i].LastUpdateDate = time.Now()
-		userRoles[i].DelFlag = 0
+	for _, role := range roles {
+		userRole := models.SysUserRole{}
+		userRole.Id = utils.NewUUID()
+		userRole.RoleId = role
+		userRole.UserId = userInfo.Id
+		userRole.CreateBy = user_id
+		userRole.LastUpdateBy = user_id
+		userRole.CreateTime = time.Now()
+		userRole.LastUpdateDate = time.Now()
+		userRole.DelFlag = 0
+		userRoles = append(userRoles, userRole)
 	}
 	_, err = c.Db.Insert(userRoles)
 	if err != nil {
@@ -478,7 +483,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)
 
@@ -507,7 +512,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"`
 	}
@@ -542,7 +547,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)
@@ -568,11 +573,11 @@ 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)
 
-	page := sysmodel.SysRolePageInfo{}
+	page := sysmodel.PageResult{}
 	var roles []sysmodel.SysRole
 	err := c.Db.SQL(sysmodel.Selectall_sys_role).Limit(getpageinfo.PageSize, (getpageinfo.PageNum-1)*getpageinfo.PageSize).Find(&roles)
 	if err != nil {
@@ -599,7 +604,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 {
@@ -624,7 +629,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)
@@ -674,7 +679,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)
@@ -692,7 +697,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")
 
@@ -726,7 +731,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)
 
@@ -759,7 +764,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"`
 	}
@@ -792,7 +797,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)
 
@@ -816,6 +821,248 @@ func System_UpdateMenu(c *SystemController) {
 	}
 }
 
+// _AddOrg
+// @Title _AddOrg
+// @Description 添加组织
+// @Param	    string  false  "组织"
+// @Success 200 {object} models.Account
+// @Failure 403 :id is empty
+func System_AddOrg(c *entitys.CtrlContext) {
+	var sysorg models.SysOrganization
+	c.Ctx.BindJSON(&sysorg)
+
+	user_id := c.Ctx.GetString("user_id")
+
+	sysorg.Id = utils.NewUUID()
+	sysorg.CreateBy = user_id
+	sysorg.LastUpdateBy = user_id
+	sysorg.LastUpdateDate = time.Now()
+	sysorg.CreateTime = time.Now()
+	sysorg.DelFlag = 0
+
+	_, err := c.Db.Insert(&sysorg)
+	if err != nil {
+		c.Ctx.JSON(500, sysmodel.SysReturn{500, err.Error(), nil})
+		return
+	}
+
+	ret := __none_func_system__(sysorg)
+	if ret {
+		c.Ctx.JSON(200, sysmodel.SysReturn{200, "", nil})
+	} else {
+		c.Ctx.JSON(500, sysmodel.SysReturn{500, "", nil})
+	}
+}
+
+// _DelOrg
+// @Title _DelOrg
+// @Description 删除组织
+// @Param	id    string  false  "组织ID"
+// @Success 200 {object} models.Account
+// @Failure 403 :id is empty
+func System_DelOrg(c *entitys.CtrlContext) {
+	type Param struct {
+		Id string `json:"id"`
+	}
+
+	var params []Param
+	c.Ctx.BindJSON(&params)
+	fmt.Println(params, "-----------")
+	ids := []string{}
+	for _, param := range params {
+		ids = append(ids, param.Id)
+	}
+
+	_, err := c.Db.Table(new(models.SysOrganization)).In("id", ids).Update(map[string]interface{}{"del_flag": 0})
+	if err != nil {
+		c.Ctx.JSON(200, sysmodel.SysReturn{500, err.Error(), nil})
+		return
+	}
+
+	ret := __none_func_system__()
+	if ret {
+		c.Ctx.JSON(200, sysmodel.SysReturn{200, "", nil})
+	} else {
+		c.Ctx.JSON(200, sysmodel.SysReturn{500, "", nil})
+	}
+}
+
+// _UpdateOrg
+// @Title _UpdateOrg
+// @Description 更新组织
+// @Param	    string  false  "组织"
+// @Success 200 {object} models.Account
+// @Failure 403 :id is empty
+func System_UpdateOrg(c *entitys.CtrlContext) {
+	var sysorg models.SysOrganization
+	c.Ctx.BindJSON(&sysorg)
+
+	user_id := c.Ctx.GetString("user_id")
+
+	sysorg.LastUpdateBy = user_id
+	sysorg.LastUpdateDate = time.Now()
+
+	_, err := c.Db.ID(sysorg.Id).Update(&sysorg)
+
+	if err != nil {
+		c.Ctx.JSON(200, sysmodel.SysReturn{500, err.Error(), nil})
+		return
+	}
+
+	ret := __none_func_system__(sysorg)
+	if ret {
+		c.Ctx.JSON(200, sysmodel.SysReturn{200, "", nil})
+	} else {
+		c.Ctx.JSON(200, sysmodel.SysReturn{500, "", nil})
+	}
+}
+
+// _GetOrg
+// @Title _GetOrg
+// @Description 根据ID获取组织
+// @Param	    string  false  "组织ID"
+// @Success 200 {object} models.Account
+// @Failure 403 :id is empty
+func System_GetOrg(c *entitys.CtrlContext) {
+	var param struct {
+		Id string `json:"id"`
+	}
+
+	c.Ctx.BindJSON(&param)
+	fmt.Println(param, "-----------")
+
+	org := models.SysOrganization{}
+	err := c.Db.Table(new(sysmodel.SysOrganization)).ID(param.Id).Find(&org)
+	if err != nil {
+		c.Ctx.JSON(200, sysmodel.SysReturn{500, err.Error(), nil})
+		return
+	}
+
+	ret := __none_func_system__()
+	if ret {
+		c.Ctx.JSON(200, sysmodel.SysReturn{200, "", org})
+	} else {
+		c.Ctx.JSON(200, sysmodel.SysReturn{500, "", nil})
+	}
+}
+
+// _PageOrg
+// @Title _PageOrg
+// @Description 分页获取组织
+// @Param	    string  false  "组织"
+// @Success 200 {object} models.Account
+// @Failure 403 :id is empty
+func System_PageOrg(c *entitys.CtrlContext) {
+	var getpageinfo models.GetPageInfo
+	c.Ctx.BindJSON(&getpageinfo)
+
+	ret := __none_func_system__(getpageinfo)
+
+	page := sysmodel.PageResult{}
+	var orgs []sysmodel.SysOrganization
+	dbSession := c.Db.Table("sys_organization")
+	dbSession = dbSession.Select("sys_organization.*")
+
+	countSession := c.Db.Table("sys_organization")
+
+	JoinTables := []sysmodel.Join{}
+	//JoinTables = append(JoinTables, sysmodel.Join{TabelName: "subject", Condition: "lesson.subject_id = subject.id", JoinOperator: "left"})
+
+	for _, join := range JoinTables {
+		dbSession = dbSession.Join(join.JoinOperator, join.TabelName, join.Condition)
+		countSession = countSession.Join(join.JoinOperator, join.TabelName, join.Condition)
+	}
+
+	whereStr, datas, err := getpageinfo.Filter.Parse("")
+
+	if err != nil {
+		c.Ctx.JSON(200, sysmodel.SysReturn{500, err.Error(), nil})
+		return
+	}
+
+	dbSession = dbSession.Where(whereStr, datas...)
+	countSession = countSession.Where(whereStr, datas...)
+
+	sidx := strings.Split(getpageinfo.Sidx, ",")
+	for _, order := range sidx {
+		order = strings.TrimSpace(order)
+		if len(order) == 0 {
+			continue
+		}
+
+		if strings.ToLower(getpageinfo.Sord) == "desc" {
+			dbSession = dbSession.OrderBy(order + " desc")
+		} else {
+			dbSession = dbSession.OrderBy(order + " asc")
+		}
+
+	}
+
+	totalPage, _ := countSession.Count()
+	err = dbSession.Limit(getpageinfo.PageSize, (getpageinfo.PageNum-1)*getpageinfo.PageSize).Find(&orgs)
+	if err != nil {
+		c.Ctx.JSON(200, sysmodel.SysReturn{500, err.Error(), nil})
+	}
+	page.Content = orgs
+	page.PageSize = getpageinfo.PageSize
+	page.PageNum = getpageinfo.PageNum
+	page.TotalSize = int(totalPage)
+
+	if ret {
+		c.Ctx.JSON(200, sysmodel.SysReturn{200, "", page})
+	} else {
+		c.Ctx.JSON(200, sysmodel.SysReturn{500, "", nil})
+	}
+}
+
+func System_TreeList(c *entitys.CtrlContext) {
+	tbName := c.Ctx.Query("tb_name")
+	parentFiled := c.Ctx.Query("parent_filed")
+	if parentFiled == "" {
+		parentFiled = c.Ctx.Query("parent_field")
+	}
+	parentValue := c.Ctx.Query("parent_value")
+	textFiled := c.Ctx.Query("text_filed")
+	if textFiled == "" {
+		textFiled = c.Ctx.Query("text_field")
+		if textFiled == "" {
+			textFiled = c.Ctx.Query("name_field")
+		}
+	}
+	valueFiled := c.Ctx.Query("value_filed")
+	if valueFiled == "" {
+		valueFiled = c.Ctx.Query("value_field")
+		if valueFiled == "" {
+			valueFiled = c.Ctx.Query("id_field")
+		}
+	}
+	domainchk := c.Ctx.Query("domainchk")
+	if domainchk == "" {
+		domainchk = "1" // 默认需要domain过滤
+	}
+	cntparent := c.Ctx.Query("cnt_parent")
+	if cntparent == "" {
+		cntparent = "0"
+	}
+	filter := c.Ctx.Query("filters")
+	if filter == "" {
+		filter = c.Ctx.Query("filter")
+	}
+	sord := c.Ctx.Query("sord")
+
+	user, exists := c.Ctx.Get("token")
+	if !exists {
+		c.Ctx.JSON(200, sysmodel.SysReturn{500, "token is not exists", nil})
+		return
+	}
+	nodes, err := sysdb.TreeList(c, user.(*entitys.Token), tbName, parentFiled, parentValue, textFiled, valueFiled, cntparent, domainchk, filter, sord)
+	if err != nil {
+		c.Ctx.JSON(200, sysmodel.SysReturn{200, "", nodes})
+	} else {
+		c.Ctx.JSON(200, sysmodel.SysReturn{500, "", nil})
+	}
+}
+
 func __none_func_system__(params ...interface{}) bool {
 	return true
 }

+ 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
+}

+ 10 - 0
db/common.go

@@ -0,0 +1,10 @@
+package sysdb
+
+import "git.qianqiusoft.com/qianqiusoft/light-apiengine/entitys"
+
+func IsSuperUser(user *entitys.Token) bool {
+	if user == nil {
+		return false
+	}
+	return user.UserId == "003bf0c1-f491-43d8-a4f4-1537f168e000"
+}

+ 257 - 0
db/tree.go

@@ -0,0 +1,257 @@
+package sysdb
+
+import (
+	"container/list"
+	"encoding/json"
+	"errors"
+	"fmt"
+	"git.qianqiusoft.com/qianqiusoft/light-apiengine/entitys"
+	"git.qianqiusoft.com/qianqiusoft/light-apiengine/models"
+	"strings"
+)
+
+type TreeNode struct {
+	ID     string      `json:"id"`
+	Text   string      `json:"text"`
+	Parent string      `json:"-"`
+	Nodes  []*TreeNode `json:"nodes"`
+}
+
+type ZTreeNode struct {
+	Id     string `json:"id"`
+	Parent string `json:"parent"`
+	Name   string `json:"name"`
+}
+
+type ZTreeConvertor struct {
+	IdField     string
+	NameField   string
+	ParentField string
+	CntParent   string
+
+	Maps           []map[string]string
+	ZTreeNodeArray []*ZTreeNode
+	TreeNodeArray  []*TreeNode
+}
+
+func TreeList(c *entitys.CtrlContext, user *entitys.Token, tbName, parentField, parentValue, textFiled, valueFiled, cntParent, domainchk, filter, sord string) ([]*TreeNode, error) {
+	ztConvertor := &ZTreeConvertor{}
+	domain := ""
+	if !IsSuperUser(user) {
+		if domainchk == "1" {
+			domain = user.Domain
+		}
+	}
+
+	pv := ""
+	if !IsSuperUser(user) {
+		pv = parentValue
+		if cntParent != "1" {
+			pv = ""
+		}
+	}
+
+	filterObj := &models.Filter{}
+	if len(filter) > 0 {
+		if err := json.Unmarshal([]byte(filter), filterObj); err != nil {
+			return ztConvertor.TreeNodeArray, errors.New(`filters parameter only allows {"groupOp":"AND","rules":[{"field":"org_name","op":"eq","data":"测试"}]}`)
+		}
+	}
+	paramsArr, err := GetTreeList(c, domain, tbName, parentField, textFiled, valueFiled, pv, filterObj, sord)
+	if err != nil {
+		return ztConvertor.TreeNodeArray, err
+	}
+
+	ztConvertor.IdField = valueFiled
+	ztConvertor.NameField = textFiled
+	ztConvertor.ParentField = parentField
+	ztConvertor.CntParent = cntParent
+	ztConvertor.Maps = paramsArr
+
+	if !ztConvertor.BuildTreeArray(strings.TrimSpace(pv)) {
+		return ztConvertor.TreeNodeArray, errors.New("orm.params convert to ztree error")
+	}
+
+	return ztConvertor.TreeNodeArray, nil
+
+}
+
+func GetTreeList(c *entitys.CtrlContext, domain, tbName, parentFiled, textFiled, valueFiled, parentValue string, filter *models.Filter, sord string) ([]map[string]string, error) {
+	sql := fmt.Sprintf("SELECT `%s`, `%s`, `%s` FROM `%s`", valueFiled, textFiled, parentFiled, tbName)
+
+	where := " where ("
+	groupOp := strings.ToLower(filter.GroupOp)
+
+	datas := make([]interface{}, 0)
+	isAnd := true
+	if groupOp == "or" {
+		isAnd = false
+		where += "1 <> 1"
+	} else {
+		isAnd = true
+		where += "1 = 1"
+	}
+	for _, field := range filter.Rules {
+		fData := models.FormatData(field.Op, field.Data)
+		switch fData.(type) {
+		case string:
+			{
+				if len(fData.(string)) >= 0 {
+					datas = append(datas, fData)
+				}
+			}
+		case []string:
+			{
+				fDataArr := fData.([]string)
+				for _, arr := range fDataArr {
+					if len(arr) > 0 {
+						datas = append(datas, arr)
+					}
+				}
+			}
+		}
+
+		whereStr := models.FormatOp(tbName, field.Op, field.Field, field.Data)
+
+		if len(whereStr) > 0 {
+			if isAnd {
+				where += " and "
+			} else {
+				where += " or "
+			}
+			where += whereStr
+		}
+	}
+	where += ")"
+	if domain != "" {
+		where += " and ("
+		where += fmt.Sprintf(" domain = '%s')", domain)
+	}
+
+	sql = sql + where
+
+	if parentValue != "" {
+		sql1 := fmt.Sprintf("select `%s`, `%s`, `%s` from `%s` where `%s` = ?", valueFiled, textFiled, parentFiled, tbName, valueFiled)
+		sql = sql + " union " + sql1
+		datas = append(datas, parentValue)
+	}
+
+	if strings.TrimSpace(sord) == "" {
+		sql = sql + " order by " + parentFiled
+	} else {
+		sql = sql + " order by " + sord
+	}
+
+	if len(datas) > 0 {
+		//result, err := c.Db.QueryInterface(sql, datas)
+		result, err := c.Db.QueryString(sql, datas)
+		return result, err
+	} else {
+		result, err := c.Db.QueryString(sql)
+		return result, err
+	}
+
+}
+
+func (this *ZTreeConvertor) BuildTreeArray(root string) bool {
+	rootArr := []*TreeNode{}
+	if len(this.Maps) <= 0 {
+		this.TreeNodeArray = rootArr
+		return true
+	}
+
+	paramsArr := this.Maps
+	valueFiled := this.IdField
+	parentField := this.ParentField
+	textFiled := this.NameField
+	parentValue := root
+
+	treeNodeList := list.New()
+	originNodeList := list.New()
+
+	if root != "" && this.CntParent == "1" {
+		for _, params := range paramsArr {
+			value := getStringValueByInterface(params[valueFiled], "")
+			parent := getStringValueByInterface(params[parentField], "")
+			text := getStringValueByInterface(params[textFiled], "")
+			//fmt.Println("========" + text + "-----" + value + "======" + parentValue)
+			if value == parentValue {
+				//fmt.Println("root ========" + text + "-----" + value)
+				node := &TreeNode{
+					ID:     value,
+					Text:   text,
+					Parent: parent,
+				}
+				treeNodeList.PushBack(node)
+				rootArr = append(rootArr, node)
+			} else {
+				originNodeList.PushBack(&TreeNode{
+					ID:     value,
+					Text:   text,
+					Parent: parent,
+				})
+			}
+		}
+	} else {
+		for _, params := range paramsArr {
+			value := getStringValueByInterface(params[valueFiled], "")
+			parent := getStringValueByInterface(params[parentField], "")
+			text := getStringValueByInterface(params[textFiled], "")
+			//fmt.Println("========" + text + "-----" + value + "======" + parentValue)
+			if parent == parentValue {
+				//fmt.Println("root ========" + text + "-----" + value)
+				node := &TreeNode{
+					ID:     value,
+					Text:   text,
+					Parent: parent,
+				}
+				treeNodeList.PushBack(node)
+				rootArr = append(rootArr, node)
+			} else {
+				originNodeList.PushBack(&TreeNode{
+					ID:     value,
+					Text:   text,
+					Parent: parent,
+				})
+			}
+		}
+	}
+
+	fmt.Println(len(rootArr))
+
+	for ele := treeNodeList.Front(); ele != nil; ele = ele.Next() {
+		treeNode := ele.Value.(*TreeNode)
+		//fmt.Println("=================" + treeNode.ID + "===========" + treeNode.Text)
+		originEle := originNodeList.Front()
+		if originEle == nil {
+			break
+		}
+		flag := false
+		for originEle != nil {
+			originNextEle := originEle.Next()
+			originNode := originEle.Value.(*TreeNode)
+			//fmt.Println("---------------" + originNode.ID + "------------" + originNode.Text)
+			if originNode.Parent == treeNode.ID {
+				flag = true
+				treeNodeList.InsertAfter(originNode, ele)
+				treeNode.Nodes = append(treeNode.Nodes, originNode)
+
+				originNodeList.Remove(originEle)
+			} else if flag {
+				break
+			}
+			originEle = originNextEle
+		}
+	}
+
+	this.TreeNodeArray = rootArr
+	return true
+}
+
+func getStringValueByInterface(vali interface{}, nilVal string) string {
+	if vali == nil {
+		return nilVal
+	}
+
+	return vali.(string)
+}

+ 62 - 63
engine/system_init.go

@@ -1,117 +1,116 @@
 package engine
 
 import (
-	"git.qianqiusoft.com/qianqiusoft/light-apiengine/models"
-	"regexp"
 	"fmt"
+	"git.qianqiusoft.com/qianqiusoft/light-apiengine/models"
 	"github.com/xormplus/xorm"
+	"regexp"
 )
 
-
-func CreateDatabase(engine *ApiEngine)  {
-	if engine.OrmEngine.DriverName() == "mysql"{
-		dbname :=engine.OrmEngine.DataSourceName()
-		reg:= regexp.MustCompile("(.*)/(.*)(\\?.*)")
+func CreateDatabase(engine *ApiEngine) {
+	if engine.OrmEngine.DriverName() == "mysql" {
+		dbname := engine.OrmEngine.DataSourceName()
+		reg := regexp.MustCompile("(.*)/(.*)(\\?.*)")
 		//strings := reg.FindAllStringSubmatch(s, -1)
 		strings := reg.FindStringSubmatch(dbname)
 		fmt.Println(strings)
-		if len(strings) >3{
-			dbname= strings[2]
-			db,_:= xorm.NewEngine(engine.OrmEngine.DriverName(), strings[1]+"/")
+		if len(strings) > 3 {
+			dbname = strings[2]
+			db, _ := xorm.NewEngine(engine.OrmEngine.DriverName(), strings[1]+"/")
 			db.ShowSQL(true)
-			_,err:=db.Sql("CREATE DATABASE IF NOT EXISTS `"+dbname+"` default charset utf8 COLLATE utf8_general_ci").Execute()
-			if err!=nil{
-				fmt.Println("create database error",err)
-			}else {
-				fmt.Println("create database success:",dbname)
+			_, err := db.Sql("CREATE DATABASE IF NOT EXISTS `" + dbname + "` default charset utf8 COLLATE utf8_general_ci").Execute()
+			if err != nil {
+				fmt.Println("create database error", err)
+			} else {
+				fmt.Println("create database success:", dbname)
 			}
 		}
 	}
 }
 
-func InitDbData(engine *ApiEngine)  {
+func InitDbData(engine *ApiEngine) {
 
-	orgs:= []models.SysOrg{
+	orgs := []models.SysOrganization{
 		{
-			Id:"287c50a4-caad-4557-80c8-aca81af9f370",
-			Name:"千秋软件",
+			Id:   "287c50a4-caad-4557-80c8-aca81af9f370",
+			Name: "千秋软件",
 		},
 	}
-	users:= []models.SysUser{
+	users := []models.SysUser{
 		{
-			Id:"187c50a4-caad-4557-80c8-aca81af9f370",
-			Name:"管理员",
-			LoginId:"admin",
-			OrgId:"287c50a4-caad-4557-80c8-aca81af9f370",
-			Password:"123456",
+			Id:       "187c50a4-caad-4557-80c8-aca81af9f370",
+			Name:     "管理员",
+			LoginId:  "admin",
+			OrgId:    "287c50a4-caad-4557-80c8-aca81af9f370",
+			Password: "123456",
 		},
 	}
 
 	roles := []models.SysRole{
 		{
-			Id:	"487c50a4-caad-4557-80c8-aca81af9f370",
-			Name:"超级管理员",
+			Id:   "487c50a4-caad-4557-80c8-aca81af9f370",
+			Name: "超级管理员",
 		},
 	}
 
-	userRoles:=[]models.SysUserRole{
+	userRoles := []models.SysUserRole{
 		{
-			Id:"587c50a4-caad-4557-80c8-aca81af9f370",
-			RoleId:"387c50a4-caad-4557-80c8-aca81af9f370",
-			UserId:"187c50a4-caad-4557-80c8-aca81af9f370",
+			Id:     "587c50a4-caad-4557-80c8-aca81af9f370",
+			RoleId: "387c50a4-caad-4557-80c8-aca81af9f370",
+			UserId: "187c50a4-caad-4557-80c8-aca81af9f370",
 		},
 	}
 
-	menus:= []models.SysMenu{
+	menus := []models.SysMenu{
 		{
-			Id:"387c50a4-caad-4557-80c8-aca81af9f370",
-			Name:"系统管理",
+			Id:   "387c50a4-caad-4557-80c8-aca81af9f370",
+			Name: "系统管理",
 		},
 		{
-			Id:"387c50a4-caad-4557-80c8-aca81af9f371",
-			Name:"用户管理",
-			Parent:"387c50a4-caad-4557-80c8-aca81af9f370",
-			Url:"/sys/user",
+			Id:     "387c50a4-caad-4557-80c8-aca81af9f371",
+			Name:   "用户管理",
+			Parent: "387c50a4-caad-4557-80c8-aca81af9f370",
+			Url:    "/sys/user",
 		},
 		{
-			Id:"387c50a4-caad-4557-80c8-aca81af9f372",
-			Name:"组织架构",
-			Parent:"387c50a4-caad-4557-80c8-aca81af9f370",
-			Url:"/sys/org",
+			Id:     "387c50a4-caad-4557-80c8-aca81af9f372",
+			Name:   "组织架构",
+			Parent: "387c50a4-caad-4557-80c8-aca81af9f370",
+			Url:    "/sys/org",
 		},
 		{
-			Id:"387c50a4-caad-4557-80c8-aca81af9f373",
-			Name:"角色管理",
-			Parent:"387c50a4-caad-4557-80c8-aca81af9f370",
-			Url:"/sys/role",
+			Id:     "387c50a4-caad-4557-80c8-aca81af9f373",
+			Name:   "角色管理",
+			Parent: "387c50a4-caad-4557-80c8-aca81af9f370",
+			Url:    "/sys/role",
 		},
 		{
-			Id:"387c50a4-caad-4557-80c8-aca81af9f374",
-			Name:"菜单管理",
-			Parent:"387c50a4-caad-4557-80c8-aca81af9f370",
-			Url:"/sys/menu",
+			Id:     "387c50a4-caad-4557-80c8-aca81af9f374",
+			Name:   "菜单管理",
+			Parent: "387c50a4-caad-4557-80c8-aca81af9f370",
+			Url:    "/sys/menu",
 		},
 		{
-			Id:"387c50a4-caad-4557-80c8-aca81af9f375",
-			Name:"字典管理",
-			Parent:"387c50a4-caad-4557-80c8-aca81af9f370",
-			Url:"/sys/dict",
+			Id:     "387c50a4-caad-4557-80c8-aca81af9f375",
+			Name:   "字典管理",
+			Parent: "387c50a4-caad-4557-80c8-aca81af9f370",
+			Url:    "/sys/dict",
 		},
 		{
-			Id:"387c50a4-caad-4557-80c8-aca81af9f376",
-			Name:"日志管理",
-			Parent:"387c50a4-caad-4557-80c8-aca81af9f370",
-			Url:"/sys/log",
+			Id:     "387c50a4-caad-4557-80c8-aca81af9f376",
+			Name:   "日志管理",
+			Parent: "387c50a4-caad-4557-80c8-aca81af9f370",
+			Url:    "/sys/log",
 		},
 	}
-	_,err := engine.OrmEngine.Insert(orgs)
+	_, err := engine.OrmEngine.Insert(orgs)
 	printError(err)
-	_,err = engine.OrmEngine.Insert(users)
+	_, err = engine.OrmEngine.Insert(users)
 	printError(err)
-	_,err = engine.OrmEngine.Insert(roles)
+	_, err = engine.OrmEngine.Insert(roles)
 	printError(err)
-	_,err = engine.OrmEngine.Insert(userRoles)
+	_, err = engine.OrmEngine.Insert(userRoles)
 	printError(err)
-	_,err = engine.OrmEngine.Insert(menus)
+	_, err = engine.OrmEngine.Insert(menus)
 	printError(err)
 }

+ 34 - 0
godep.yaml

@@ -0,0 +1,34 @@
+package: light-apiengine
+ignore:
+  - git.qianqiusoft.com/qianqiusoft/light-apiengine
+import:
+  - package: github.com/go-sql-driver/mysql
+    repo: https://git.qianqiusoft.com/github.com/go-sql-driver__mysql.git
+  - package: github.com/gin-gonic/gin
+    repo: https://git.qianqiusoft.com/github.com/gin-gonic__gin.git
+  - package: github.com/xormplus/xorm
+    repo: https://git.qianqiusoft.com/github.com/xormplus__xorm.git
+  - package: golang.org/x/sys
+    repo: https://git.qianqiusoft.com/golang.org/sys.git
+  - package: git.qianqiusoft.com/qianqiusoft/go-uuid
+    repo: https://git.qianqiusoft.com/qianqiusoft/go-uuid.git
+  - package: github.com/mattn/go-isatty
+    repo: https://git.qianqiusoft.com/github.com/mattn__go-isatty.git
+  - package: github.com/gin-contrib/sse
+    repo: https://git.qianqiusoft.com/github.com/gin-contrib__sse.git
+  - package: github.com/gin-contrib/cors
+    repo: https://git.qianqiusoft.com/github.com/gin-contrib__cors.git
+  - package: github.com/golang/protobuf
+    repo: https://git.qianqiusoft.com/github.com/golang__protobuf.git
+  - package: github.com/mattn/go-sqlite3
+    repo: https://git.qianqiusoft.com/public/go-sqlite3.git
+  - package: gopkg.in/go-playground/validator.v8
+    repo: https://git.qianqiusoft.com/gopkg.in/go-playground__validator.v8.git
+  - package: github.com/ugorji/go
+    repo: https://git.qianqiusoft.com/github.com/ugorji__go.git
+  - package: gopkg.in/yaml.v2
+    repo: https://git.qianqiusoft.com/gopkg.in/yaml.v2.git
+  - package: github.com/xormplus/builder
+    repo: https://git.qianqiusoft.com/github.com/xormplus__builder.git
+  - package: github.com/xormplus/core
+    repo: https://git.qianqiusoft.com/github.com/xormplus__core.git

+ 0 - 41
models/SysOrg_gen.go

@@ -1,41 +0,0 @@
-
-package models
-import (
-"time"
-)
-
-type SysOrg struct {
-	//主键
-	Id   string    `xorm:"'id' varchar(36) pk notnull "json:"id"`
-	//上级组织
-	Parent   string    `xorm:"'parent' varchar(36) null "json:"parent"`
-	//名称
-	Name   string    `xorm:"'name' varchar(36) notnull "json:"name"`
-	//全名
-	FullName   string    `xorm:"'full_name' varchar(36) notnull "json:"full_name"`
-	//领导人
-	Leader   string    `xorm:"'leader' varchar(36) notnull "json:"leader"`
-	//组织类型
-	Type   int32    `xorm:"'type' notnull "json:"type"`
-	//排序
-	Order   int32    `xorm:"'order' notnull "json:"order"`
-	//状态 0:禁用   1:正常
-	Status   int32    `xorm:"'status' notnull "json:"status"`
-	//域
-	Domain   string    `xorm:"'domain' varchar(36) notnull "json:"domain"`
-	//创建人
-	CreateBy   string    `xorm:"'create_by' varchar(36) notnull "json:"create_by"`
-	//创建时间
-	CreateTime   time.Time    `xorm:"'create_time' notnull "json:"create_time"`
-	//最后更新人
-	LastUpdateBy   string    `xorm:"'last_update_by' varchar(36) notnull "json:"last_update_by"`
-	//最后更新时间
-	LastUpdateDate   time.Time    `xorm:"'last_update_date' notnull "json:"last_update_date"`
-	//是否删除 0:删除   1:正常
-	DelFlag   int32    `xorm:"'del_flag' notnull "json:"del_flag"`
-
-}
-
-func (t *SysOrg) TableName() string {
-	return "sys_org"
-}

+ 46 - 0
models/SysOrganization_gen.go

@@ -0,0 +1,46 @@
+package models
+
+import (
+	"time"
+)
+
+type SysOrganization struct {
+	//主键
+	Id string `xorm:"'id' varchar(36) pk notnull "json:"id"`
+
+	Inheritance string `xorm:"'inheritance' varchar(3000) notnull "json:"inheritance"`
+	//上级组织
+	Parent string `xorm:"'parent' varchar(36) null "json:"parent"`
+	//名称
+	Name string `xorm:"'name' varchar(36) notnull "json:"name"`
+	//全名
+	FullName string `xorm:"'full_name' varchar(36) notnull "json:"full_name"`
+	//领导人
+	Leader string `xorm:"'leader' varchar(36) notnull "json:"leader"`
+	//组织类型
+	Type int32 `xorm:"'type' notnull "json:"type"`
+	//排序
+	Order int32 `xorm:"'order' notnull "json:"order"`
+	//状态 0:禁用   1:正常
+	Status int32 `xorm:"'status' notnull "json:"status"`
+	//域
+	Domain string `xorm:"'domain' varchar(36) notnull "json:"domain"`
+	//创建人
+	CreateBy string `xorm:"'create_by' varchar(36) notnull "json:"create_by"`
+	//创建时间
+	CreateTime time.Time `xorm:"'create_time' notnull "json:"create_time"`
+	//最后更新人
+	LastUpdateBy string `xorm:"'last_update_by' varchar(36) notnull "json:"last_update_by"`
+	//最后更新时间
+	LastUpdateDate time.Time `xorm:"'last_update_date' notnull "json:"last_update_date"`
+	//是否删除 0:删除   1:正常
+	DelFlag int32 `xorm:"'del_flag' notnull "json:"del_flag"`
+
+	PY string `xorm:"'py' varchar(100) notnull "json:"py"`
+
+	PinYin string `xorm:"'pinyin' varchar(255) notnull "json:"pinyin"`
+}
+
+func (t *SysOrganization) TableName() string {
+	return "sys_organization"
+}

+ 31 - 0
models/model.go

@@ -0,0 +1,31 @@
+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(SysOrganization))
+
+	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)
+
+}

+ 24 - 0
routers/common.go

@@ -0,0 +1,24 @@
+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(registerCommonRouter)
+}
+
+func registerCommonRouter(e *engine.ApiEngine){
+	api:=e.GinEngine.Group("/api")
+	v1:=api.Group("/v1")
+
+	v1.Use(middleware.LoginWare())
+
+	ctrler := gen.NewSystemController(e.OrmEngine)
+
+	v1.GET("/system/tree_list", ctrler.TreeList)
+	v1.POST("/system/tree_list", ctrler.TreeList)
+
+}

+ 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 - 243
routers/router_gen.go

@@ -1,243 +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 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("/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
+}