Browse Source

通讯录关联账户

Lgx 4 years ago
parent
commit
48c9611c2d

+ 66 - 4
UI/src/pages/user/wechatUsers.js

@@ -8,7 +8,9 @@ import {Modal,
   Col,
   Button,
   Icon,
-  Upload
+  Upload,
+  Model,
+  message
 } from 'antd';
 class tag_setting extends React.Component {
   constructor(props) {
@@ -19,11 +21,17 @@ class tag_setting extends React.Component {
       formVisiable:false,
       formVisiable2:false,
       getdDisdatas:[],
+      userId:"",
       fileName:"",
       fileName2:""
     }
   }
 
+  cancelClick(){
+    this.setState({
+      formVisiable:false
+    })
+  }
   render() {
     let user=util.auth.getUser();
     let self = this;
@@ -72,17 +80,71 @@ class tag_setting extends React.Component {
     ],
       columns: [
         { title: "ID", data: "id", type: "text", editor: {},query:false },
-        { title: "姓名(昵称)", data: "name", type: "text",editor: {},source: { data:genderbase }, query: true},
-        { title: "性别", data: "gender", type: "dropdown", editor: {},query:true },
+        { title: "姓名(昵称)", data: "name", type: "text",editor: {}, query: true},
+        { title: "性别", data: "gender", type: "dropdown", editor: {},source: { data:genderbase },query:true },
         { title: "手机", data: "mobile", type: "text",  editor: {},query:true},
         { title: "添加时间", data: "create_time", type: "datetime", editor: {},query:true,hide:true},
         { title: "企业用户ID", data: "user_id", type: "text", editor: {},query:true,hide:true},
         { title: "职位", data: "position", type: "text", editor: {},query:true,hide:true},
-        { title: "状态", data: "status", type: "dropdown", editor: {},source: { data:database },query:true}
+        { title: "状态", data: "status", type: "dropdown", editor: {},source: { data:database },query:true},
+        {
+          title: "操作选项", type: "command", actions: [{
+            name: '关联账户',
+            onClick: (data) => {
+                self.setState({
+                  formVisiable:true,
+                  userId:data.id
+                })
+            }
+          }]
+        }
+      ]
+    };
+    let gridOption0 = {
+      title: "账户列表",
+      
+      url: {
+        read:WXAPIV5+"/api/users/getAccountList"
+      },
+      actions: [
+        {name:"关联",color:"red",
+        onClick:function(checkedValues, checkedDatas){  
+          let dto={};
+          let userId=self.state.userId;
+          if(userId!=null&&userId!=""){
+            dto.userId=userId;
+            if(checkedDatas!=null&&checkedDatas.length==1){
+              dto.account=checkedDatas[0]
+              console.log(dto)
+              //请求后台保存企业用户关联登录账户
+
+            }else{
+              message.error("单选!")
+            }
+            
+          }else{
+            message.error("请先选择!")
+          }    
+        }
+      }
+    ],
+    checkable: true,
+      columns: [
+        { title: "ID", data: "id", type: "text", editor: {},query:false },
+        { title: "姓名", data: "nickName", type: "text",editor: {}, query: true},
+        { title: "账户", data: "loginId", type: "text", editor: {},query:true },
       ]
     };
+
     return <div>
                 <BirdGrid gridOption={gridOption} ref="grid"></BirdGrid>
+                <Modal title="关联账户"
+                  width="50%"
+                  visible={self.state.formVisiable}
+                  onCancel={() => self.cancelClick()}
+                  onOk={() => self.cancelClick()}>    
+                    <BirdGrid gridOption={gridOption0} ref="grid0"></BirdGrid>
+                </Modal>
            </div>
   }
 }

+ 2 - 2
src/main/java/com/liangjiang11/wx/cp/WxCpDemoApplication.java

@@ -5,13 +5,13 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
 import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
 import org.springframework.boot.autoconfigure.jdbc.DataSourceTransactionManagerAutoConfiguration;
 import org.springframework.boot.autoconfigure.jdbc.JdbcTemplateAutoConfiguration;
-import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
+//import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
 
 /**
  * @author Binary Wang(https://github.com/binarywang)
  */
 @SpringBootApplication(exclude = {DataSourceAutoConfiguration.class, DataSourceTransactionManagerAutoConfiguration.class, JdbcTemplateAutoConfiguration.class})
-@EnableDiscoveryClient
+//@EnableDiscoveryClient
 public class WxCpDemoApplication {
 
   public static void main(String[] args) {

+ 11 - 0
src/main/java/com/liangjiang11/wx/cp/controller/QiyeUsersController.java

@@ -1,5 +1,6 @@
 package com.liangjiang11.wx.cp.controller;
 
+import com.liangjiang11.wx.cp.service.impl.AccountService;
 import com.liangjiang11.wx.cp.service.impl.QiyeUsersService;
 import com.liangjiang11.wx.cp.utils.FiltersData;
 import org.apache.logging.log4j.LogManager;
@@ -14,6 +15,8 @@ import java.util.Map;
 public class QiyeUsersController {
     @Autowired
     private QiyeUsersService qiyeUsersService;
+    @Autowired
+    private AccountService accountService;
     private static final Logger log = LogManager.getLogger(QiyeUsersController.class);
 
     //获取列表
@@ -24,5 +27,13 @@ public class QiyeUsersController {
         return qiyeUsersService.getQiyeUsersList(data);
     }
 
+    //获取列表
+    @CrossOrigin
+    @ResponseBody
+    @RequestMapping(value = "/getAccountList", method = RequestMethod.POST)
+    public Map<String,Object> getAccountList(@RequestBody FiltersData data){
+        return accountService.getAccountList(data);
+    }
+
 
 }

+ 9 - 0
src/main/java/com/liangjiang11/wx/cp/dao/foo/UserMapper.java

@@ -3,8 +3,17 @@ package com.liangjiang11.wx.cp.dao.foo;
 import com.baomidou.mybatisplus.mapper.BaseMapper;
 import com.liangjiang11.wx.cp.model.Account;
 import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+import org.apache.ibatis.annotations.Select;
+
+import java.util.List;
 
 @Mapper
 public interface UserMapper extends BaseMapper<Account> {
 
+    @Select("SELECT * from (select  row_number() over (  order by u.CreationDate DESC)  as rownum,u.Id,u.loginId,u.Nickname from [appauthtest].[dbo].[Account] u  ${sqlStr}) A where A.rownum>#{index} AND A.rownum<#{size} ")
+    List<Account> queryAccountList(@Param("sqlStr")String sqlStr, @Param("index")Integer index, @Param("size")Integer size);
+
+    @Select("select count(1) from [appauthtest].[dbo].[Account] u ${sqlStr} ")
+    int queryAccountCount(@Param("sqlStr")String sqlStr);
 }

+ 11 - 0
src/main/java/com/liangjiang11/wx/cp/service/IAccountService.java

@@ -0,0 +1,11 @@
+package com.liangjiang11.wx.cp.service;
+
+import com.baomidou.mybatisplus.service.IService;
+import com.liangjiang11.wx.cp.model.Account;
+import com.liangjiang11.wx.cp.utils.FiltersData;
+
+import java.util.Map;
+
+public interface IAccountService extends IService<Account> {
+     Map<String,Object> getAccountList(FiltersData data);
+}

+ 39 - 0
src/main/java/com/liangjiang11/wx/cp/service/impl/AccountService.java

@@ -0,0 +1,39 @@
+package com.liangjiang11.wx.cp.service.impl;
+
+import com.baomidou.mybatisplus.service.impl.ServiceImpl;
+import com.liangjiang11.wx.cp.dao.foo.QiyeUsersMapper;
+import com.liangjiang11.wx.cp.dao.foo.UserMapper;
+import com.liangjiang11.wx.cp.model.Account;
+import com.liangjiang11.wx.cp.model.Users;
+import com.liangjiang11.wx.cp.service.IAccountService;
+import com.liangjiang11.wx.cp.service.IQiyeUsersService;
+import com.liangjiang11.wx.cp.utils.FiltersData;
+import org.springframework.stereotype.Service;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 账户管理器
+ */
+@Service
+public class AccountService extends ServiceImpl<UserMapper, Account> implements IAccountService {
+
+    @Override
+    public Map<String,Object> getAccountList(FiltersData data) {
+        Map<String,Object> map=new HashMap<String,Object>();
+        int start = (data.getPageIndex()-1) * data.getPageSize();
+        int end = (start + 1 + data.getPageSize());
+        //动态条件
+        String sqlStr=data.getFilterString();
+        Integer totalCount=0;
+        List<Account> list = this.baseMapper.queryAccountList(sqlStr,start,end);
+        if(list.size()>0){
+            totalCount=this.baseMapper.queryAccountCount(sqlStr);
+        }
+        map.put("items",list);
+        map.put("totalCount",totalCount);
+        return map;
+    }
+}

+ 1 - 1
src/main/java/com/liangjiang11/wx/cp/service/impl/QiyeUsersService.java

@@ -43,7 +43,7 @@ public class QiyeUsersService extends ServiceImpl<QiyeUsersMapper, Users> implem
                     user.setMobile("--");
                 }
             }
-            this.baseMapper.getQiyeUsersCount(sqlStr);
+            totalCount=this.baseMapper.getQiyeUsersCount(sqlStr);
         }
         map.put("items",list);
         map.put("totalCount",totalCount);