Explorar el Código

加入登录功能

吴学文 hace 6 años
padre
commit
4614752f0b
Se han modificado 18 ficheros con 646 adiciones y 32 borrados
  1. 95 0
      Api/src/main/java/com/java110/api/listener/user/ListUsersListener.java
  2. 22 12
      AppFrontService/src/main/java/com/java110/app/controller/WxLogin.java
  3. 49 0
      AppFrontService/src/main/java/com/java110/app/properties/WechatAuthProperties.java
  4. 1 1
      AppFrontService/src/main/java/com/java110/app/smo/wxLogin/IWxLoginSMO.java
  5. 138 16
      AppFrontService/src/main/java/com/java110/app/smo/wxLogin/impl/WxLoginSMOImpl.java
  6. 6 0
      AppFrontService/src/main/resources/wechatAuth.properties
  7. 19 0
      UserService/src/main/java/com/java110/user/dao/IUserServiceDao.java
  8. 21 0
      UserService/src/main/java/com/java110/user/dao/impl/UserServiceDaoImpl.java
  9. 24 0
      UserService/src/main/java/com/java110/user/smo/impl/UserInnerServiceSMOImpl.java
  10. 3 3
      java110-bean/src/main/java/com/java110/dto/wxLogin/UserInfo.java
  11. 116 0
      java110-bean/src/main/java/com/java110/vo/api/user/ApiUserDataVo.java
  12. 18 0
      java110-bean/src/main/java/com/java110/vo/api/user/ApiUserVo.java
  13. 20 0
      java110-config/src/main/java/com/java110/config/properties/code/Java110Properties.java
  14. 19 0
      java110-core/src/main/java/com/java110/core/component/BaseComponentSMO.java
  15. 22 0
      java110-core/src/main/java/com/java110/core/smo/user/IUserInnerServiceSMO.java
  16. 67 0
      java110-db/src/main/resources/mapper/user/UserServiceDaoImplMapper.xml
  17. BIN
      java110-front/src/main/resources/static/.DS_Store
  18. 6 0
      java110-utils/src/main/java/com/java110/utils/constant/ServiceCodeConstant.java

+ 95 - 0
Api/src/main/java/com/java110/api/listener/user/ListUsersListener.java

@@ -0,0 +1,95 @@
+package com.java110.api.listener.user;
+
+import com.alibaba.fastjson.JSONObject;
+import com.java110.api.listener.AbstractServiceApiListener;
+import com.java110.core.annotation.Java110Listener;
+import com.java110.core.context.DataFlowContext;
+import com.java110.core.smo.org.IOrgInnerServiceSMO;
+import com.java110.core.smo.user.IUserInnerServiceSMO;
+import com.java110.dto.UserDto;
+import com.java110.dto.org.OrgDto;
+import com.java110.event.service.api.ServiceDataFlowEvent;
+import com.java110.utils.constant.ServiceCodeConstant;
+import com.java110.utils.util.Assert;
+import com.java110.utils.util.BeanConvertUtil;
+import com.java110.vo.api.org.ApiOrgDataVo;
+import com.java110.vo.api.org.ApiOrgVo;
+import com.java110.vo.api.user.ApiUserDataVo;
+import com.java110.vo.api.user.ApiUserVo;
+import org.apache.catalina.User;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpMethod;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+
+import java.util.ArrayList;
+import java.util.List;
+
+
+/**
+ * 查询小区侦听类
+ */
+@Java110Listener("listUsersListener")
+public class ListUsersListener extends AbstractServiceApiListener {
+
+    @Autowired
+    private IUserInnerServiceSMO userInnerServiceSMOImpl;
+
+    @Override
+    public String getServiceCode() {
+        return ServiceCodeConstant.LIST_USERS;
+    }
+
+    @Override
+    public HttpMethod getHttpMethod() {
+        return HttpMethod.GET;
+    }
+
+
+    @Override
+    public int getOrder() {
+        return DEFAULT_ORDER;
+    }
+
+
+    public IUserInnerServiceSMO getUserInnerServiceSMOImpl() {
+        return userInnerServiceSMOImpl;
+    }
+
+    public void setUserInnerServiceSMOImpl(IUserInnerServiceSMO userInnerServiceSMOImpl) {
+        this.userInnerServiceSMOImpl = userInnerServiceSMOImpl;
+    }
+
+    @Override
+    protected void validate(ServiceDataFlowEvent event, JSONObject reqJson) {
+        super.validatePageInfo(reqJson);
+        //Assert.hasKeyAndValue(reqJson, "storeId", "必填,请填写商户ID");
+    }
+
+    @Override
+    protected void doSoService(ServiceDataFlowEvent event, DataFlowContext context, JSONObject reqJson) {
+
+        UserDto userDto = BeanConvertUtil.covertBean(reqJson, UserDto.class);
+
+        int count = userInnerServiceSMOImpl.getUserCount(userDto);
+
+        List<ApiUserDataVo> users = null;
+
+        if (count > 0) {
+            users = BeanConvertUtil.covertBeanList(userInnerServiceSMOImpl.getUsers(userDto), ApiUserDataVo.class);
+        } else {
+            users = new ArrayList<>();
+        }
+
+        ApiUserVo apiOrgVo = new ApiUserVo();
+
+        apiOrgVo.setTotal(count);
+        apiOrgVo.setRecords((int) Math.ceil((double) count / (double) reqJson.getInteger("row")));
+        apiOrgVo.setUsers(users);
+
+        ResponseEntity<String> responseEntity = new ResponseEntity<String>(JSONObject.toJSONString(apiOrgVo), HttpStatus.OK);
+
+        context.setResponseEntity(responseEntity);
+
+    }
+}

+ 22 - 12
AppFrontService/src/main/java/com/java110/app/controller/WxLogin.java

@@ -1,10 +1,15 @@
 package com.java110.app.controller;
 
+import com.alibaba.fastjson.JSONObject;
+import com.java110.app.smo.wxLogin.IWxLoginSMO;
 import com.java110.core.base.controller.BaseController;
+import com.java110.core.context.IPageData;
+import com.java110.core.context.PageData;
 import com.java110.dto.wxLogin.UserInfo;
 import com.java110.dto.wxLogin.WxLoginInfo;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.http.HttpStatus;
 import org.springframework.http.ResponseEntity;
 import org.springframework.web.bind.annotation.RequestBody;
@@ -21,6 +26,9 @@ import javax.servlet.http.HttpServletRequest;
 public class WxLogin extends BaseController {
     private final static Logger logger = LoggerFactory.getLogger(WxLogin.class);
 
+    @Autowired
+    private IWxLoginSMO wxLoginSMOImpl;
+
 
     /**
      * 微信登录接口
@@ -40,17 +48,19 @@ public class WxLogin extends BaseController {
         }
         String sessionKey = null;
         String openId = null;
-        try {
-            /*WxMaJscode2SessionResult result = this.wxMaService.getUserService().getSessionInfo(code);
-            sessionKey = result.getSessionKey();
-            openId = result.getOpenid();*/
-        } catch (Exception e) {
-            logger.error("login fail by wx", e);
-            e.printStackTrace();
-        }
-        if (sessionKey == null || openId == null) {
-            responseEntity = new ResponseEntity<>("code is null", HttpStatus.BAD_REQUEST);
-        }
+//        try {
+//            /*WxMaJscode2SessionResult result = this.wxMaService.getUserService().getSessionInfo(code);
+//            sessionKey = result.getSessionKey();
+//            openId = result.getOpenid();*/
+//        } catch (Exception e) {
+//            logger.error("login fail by wx", e);
+//            e.printStackTrace();
+//        }
+
+        IPageData pd = PageData.newInstance().builder("","", JSONObject.toJSONString(wxLoginInfo),"","","","");
+
+       return wxLoginSMOImpl.doLogin(pd);
+
         //login first
         /*User user = userService.queryByOpenid(openId);
         if (user == null) {
@@ -90,7 +100,7 @@ public class WxLogin extends BaseController {
         //LogUtil.info(jsonObject);
         return ResponseUtil.ok(jsonObject);*/
 
-        return new ResponseEntity<>("",HttpStatus.OK);
+        //return new ResponseEntity<>("",HttpStatus.OK);
 
 
     }

+ 49 - 0
AppFrontService/src/main/java/com/java110/app/properties/WechatAuthProperties.java

@@ -0,0 +1,49 @@
+package com.java110.app.properties;
+
+
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.context.annotation.PropertySource;
+import org.springframework.stereotype.Component;
+
+@Component
+@ConfigurationProperties(prefix = "java110")
+@PropertySource("classpath:java110.auth.wechat.properties")
+public class WechatAuthProperties {
+
+    private String sessionHost;
+    private String appId;
+    private String secret;
+    private String grantType;
+
+    public String getSessionHost() {
+        return sessionHost;
+    }
+
+    public void setSessionHost(String sessionHost) {
+        this.sessionHost = sessionHost;
+    }
+
+    public String getAppId() {
+        return appId;
+    }
+
+    public void setAppId(String appId) {
+        this.appId = appId;
+    }
+
+    public String getSecret() {
+        return secret;
+    }
+
+    public void setSecret(String secret) {
+        this.secret = secret;
+    }
+
+    public String getGrantType() {
+        return grantType;
+    }
+
+    public void setGrantType(String grantType) {
+        this.grantType = grantType;
+    }
+}

+ 1 - 1
AppFrontService/src/main/java/com/java110/app/smo/wxLogin/IWxLoginSMO.java

@@ -18,5 +18,5 @@ public interface IWxLoginSMO {
      * @return ResponseEntity 对象数据
      * @throws SMOException 业务代码层
      */
-    ResponseEntity<String> getSessionInfo(IPageData pd) throws SMOException;
+    ResponseEntity<String> doLogin(IPageData pd) throws SMOException;
 }

+ 138 - 16
AppFrontService/src/main/java/com/java110/app/smo/wxLogin/impl/WxLoginSMOImpl.java

@@ -1,20 +1,32 @@
 package com.java110.app.smo.wxLogin.impl;
 
+import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.ObjectReader;
+import com.java110.app.controller.WxLogin;
+import com.java110.app.properties.WechatAuthProperties;
 import com.java110.app.smo.wxLogin.IWxLoginSMO;
 import com.java110.core.component.AbstractComponentSMO;
 import com.java110.core.context.IPageData;
+import com.java110.core.factory.AuthenticationFactory;
 import com.java110.entity.component.ComponentValidateResult;
-import com.java110.utils.constant.PrivilegeCodeConstant;
-import com.java110.utils.constant.ServiceConstant;
+import com.java110.utils.cache.MappingCache;
+import com.java110.utils.constant.*;
 import com.java110.utils.exception.SMOException;
+import com.java110.utils.util.Assert;
 import com.java110.utils.util.BeanConvertUtil;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.http.HttpMethod;
+import org.springframework.http.HttpStatus;
 import org.springframework.http.ResponseEntity;
 import org.springframework.stereotype.Service;
 import org.springframework.web.client.RestTemplate;
 
+import java.io.IOException;
+import java.util.HashMap;
 import java.util.Map;
 
 /**
@@ -23,36 +35,138 @@ import java.util.Map;
 @Service("wxLoginSMOImpl")
 public class WxLoginSMOImpl extends AbstractComponentSMO implements IWxLoginSMO {
 
+    private final static Logger logger = LoggerFactory.getLogger(WxLoginSMOImpl.class);
+
     @Autowired
     private RestTemplate restTemplate;
 
+    @Autowired
+    private WechatAuthProperties wechatAuthProperties;
+
     @Override
-    public ResponseEntity<String> getSessionInfo(IPageData pd) throws SMOException {
+    public ResponseEntity<String> doLogin(IPageData pd) throws SMOException {
         return businessProcess(pd);
     }
 
     @Override
     protected void validate(IPageData pd, JSONObject paramIn) {
 
-        super.validatePageInfo(pd);
+        //super.validatePageInfo(pd);
 
-        super.checkUserHasPrivilege(pd, restTemplate, PrivilegeCodeConstant.LIST_ORG);
+        Assert.hasKeyAndValue(paramIn, "code", "请求报文中未包含code信息");
+        //super.checkUserHasPrivilege(pd, restTemplate, PrivilegeCodeConstant.LIST_ORG);
     }
 
     @Override
     protected ResponseEntity<String> doBusinessProcess(IPageData pd, JSONObject paramIn) {
-        ComponentValidateResult result = super.validateStoreStaffCommunityRelationship(pd, restTemplate);
-
-        Map paramMap = BeanConvertUtil.beanCovertMap(result);
-        paramIn.putAll(paramMap);
-
-        String apiUrl = ServiceConstant.SERVICE_API_URL + "/api/org.listOrgs" + mapToUrlParam(paramIn);
-
-
-        ResponseEntity<String> responseEntity = this.callCenterService(restTemplate, pd, "",
-                apiUrl,
-                HttpMethod.GET);
 
+        logger.debug("doLogin入参:" + paramIn.toJSONString());
+        ResponseEntity<String> responseEntity;
+        String code = paramIn.getString("code");
+        String urlString = "?appid={appid}&secret={srcret}&js_code={code}&grant_type={grantType}";
+        String response = restTemplate.getForObject(
+                wechatAuthProperties.getSessionHost() + urlString, String.class,
+                wechatAuthProperties.getAppId(),
+                wechatAuthProperties.getSecret(),
+                code,
+                wechatAuthProperties.getGrantType());
+        logger.debug("微信返回报文:" + response);
+
+        Assert.jsonObjectHaveKey(response, "errcode", "返回报文中未包含 错误编码,接口出错");
+        JSONObject responseObj = JSONObject.parseObject(response);
+
+        if (!"0".equals(responseObj.getString("errcode"))) {
+            throw new IllegalArgumentException("微信验证失败,可能是code失效");
+        }
+
+        String openId = responseObj.getString("openid");
+        String sessionKey = responseObj.getString("session_key");
+
+        responseEntity = super.getUserInfoByOpenId(pd, restTemplate, openId);
+
+        logger.debug("查询用户信息返回报文:" + responseEntity);
+        if (responseEntity.getStatusCode() != HttpStatus.OK) {
+            throw new IllegalArgumentException("根绝openId 查询用户信息异常" + openId);
+        }
+
+        JSONObject userResult = JSONObject.parseObject(responseEntity.getBody());
+        int total = userResult.getIntValue("total");
+
+        if (total == 0) {
+            //保存用户信息
+            JSONObject registerInfo = new JSONObject();
+
+            JSONObject userInfo = paramIn.getJSONObject("userInfo");
+
+            //设置默认密码
+            String userDefaultPassword = MappingCache.getValue(MappingConstant.KEY_STAFF_DEFAULT_PASSWORD);
+            Assert.hasLength(userDefaultPassword, "映射表中未设置员工默认密码,请检查" + MappingConstant.KEY_STAFF_DEFAULT_PASSWORD);
+            userDefaultPassword = AuthenticationFactory.passwdMd5(userDefaultPassword);
+
+            /**
+             * {
+             *      "userId": "-1",
+             *      "name": "张三",
+             *      "email": "928255095@qq.com",
+             *      "address": "青海省西宁市城中区129号",
+             *      "password": "ERCBHDUYFJDNDHDJDNDJDHDUDHDJDDKDK",
+             *      "locationCd": "001",
+             *      "age": 19,
+             *      "sex": "0",
+             *      "tel": "17797173943",
+             *      "level_cd": "1",
+             *      "businessUserAttr": [{
+             *      "attrId":"-1",
+             *      "specCd":"1001",
+             *      "value":"01"
+             *      }]
+             *      }
+             */
+            registerInfo.put("userId", "-1");
+            registerInfo.put("email", "");
+            registerInfo.put("address", userInfo.getString("country") + userInfo.getString("province") + userInfo.getString("city"));
+            registerInfo.put("locationCd", "001");
+            registerInfo.put("age", "1");
+            registerInfo.put("sex", "2".equals(userInfo.getString("gender")) ? "1" : "0");
+            registerInfo.put("tel", "-1");
+            registerInfo.put("level_cd", "1");
+            registerInfo.put("name", userInfo.getString("nickName"));
+            registerInfo.put("password", userDefaultPassword);
+            JSONArray userAttr = new JSONArray();
+            JSONObject userAttrObj = new JSONObject();
+            userAttrObj.put("attrId","-1");
+            userAttrObj.put("specCd","100201911001");
+            userAttrObj.put("value",openId);
+            userAttr.add(userAttrObj);
+            registerInfo.put("businessUserAttr", userAttr);
+            responseEntity = this.callCenterService(restTemplate, pd, registerInfo.toJSONString(), ServiceConstant.SERVICE_API_URL + "/api/user.service.register", HttpMethod.POST);
+            if(responseEntity.getStatusCode() != HttpStatus.OK){
+                throw new IllegalArgumentException("保存用户信息失败");
+            }
+            responseEntity = super.getUserInfoByOpenId(pd, restTemplate, openId);
+
+            logger.debug("查询用户信息返回报文:" + responseEntity);
+            if (responseEntity.getStatusCode() != HttpStatus.OK) {
+                throw new IllegalArgumentException("根绝openId 查询用户信息异常" + openId);
+            }
+             userResult = JSONObject.parseObject(responseEntity.getBody());
+        }
+
+        try {
+            Map userMap = new HashMap();
+            userMap.put(CommonConstant.LOGIN_USER_ID,userResult.getString("userId"));
+            String token = AuthenticationFactory.createAndSaveToken(userMap);
+            JSONObject paramOut = new JSONObject();
+            paramOut.putAll(userResult);
+            paramOut.put("token",token);
+            paramOut.put("sessionKey",sessionKey);
+            pd.setToken(token);
+            responseEntity = new ResponseEntity<String>(paramOut.toJSONString(), HttpStatus.OK);
+        }catch (Exception e){
+            logger.error("登录异常:",e);
+            throw new IllegalArgumentException("鉴权失败");
+        }
+        //根据openId 查询用户信息,是否存在用户
         return responseEntity;
     }
 
@@ -63,4 +177,12 @@ public class WxLoginSMOImpl extends AbstractComponentSMO implements IWxLoginSMO
     public void setRestTemplate(RestTemplate restTemplate) {
         this.restTemplate = restTemplate;
     }
+
+    public WechatAuthProperties getWechatAuthProperties() {
+        return wechatAuthProperties;
+    }
+
+    public void setWechatAuthProperties(WechatAuthProperties wechatAuthProperties) {
+        this.wechatAuthProperties = wechatAuthProperties;
+    }
 }

+ 6 - 0
AppFrontService/src/main/resources/wechatAuth.properties

@@ -0,0 +1,6 @@
+java110.auth.wechat.sessionHost=https://api.weixin.qq.com/sns/jscode2session
+java110.auth.wechat.appId=wxf83d66b0e9f5964d
+java110.auth.wechat.secret=7e813e047be61ce07514634f98dc94f9
+java110.auth.wechat.grantType=authorization_code
+
+

+ 19 - 0
UserService/src/main/java/com/java110/user/dao/IUserServiceDao.java

@@ -367,4 +367,23 @@ public interface IUserServiceDao {
      * @throws DAOException DAO异常
      */
     List<Map> getStaffs(Map info) throws DAOException;
+
+
+    /**
+     * 查询用户总量
+     * @param businessUser
+     * @return
+     * @throws DAOException
+     */
+    public int getUserCount(Map businessUser) throws DAOException;
+
+
+    /**
+     * 查询用户信息(instance过程)
+     * 根据bId 查询组织信息
+     * @param info bId 信息
+     * @return 组织信息
+     * @throws DAOException DAO异常
+     */
+    List<Map> getUsers(Map info) throws DAOException;
 }

+ 21 - 0
UserService/src/main/java/com/java110/user/dao/impl/UserServiceDaoImpl.java

@@ -669,4 +669,25 @@ public class UserServiceDaoImpl extends BaseServiceDao implements IUserServiceDa
 
         return businessStaffs;
     }
+
+    @Override
+    public int getUserCount(Map businessUser) throws DAOException {
+        logger.debug("查询组织数据 入参 info : {}",businessUser);
+
+        List<Map> businessStaffInfos = sqlSessionTemplate.selectList("userServiceDaoImpl.getUserCount", businessUser);
+        if (businessStaffInfos.size() < 1) {
+            return 0;
+        }
+
+        return Integer.parseInt(businessStaffInfos.get(0).get("count").toString());
+    }
+
+    @Override
+    public List<Map> getUsers(Map info) throws DAOException {
+        logger.debug("查询组织信息 入参 info : {}",info);
+
+        List<Map> businessStaffs = sqlSessionTemplate.selectList("userServiceDaoImpl.getUsers",info);
+
+        return businessStaffs;
+    }
 }

+ 24 - 0
UserService/src/main/java/com/java110/user/smo/impl/UserInnerServiceSMOImpl.java

@@ -68,6 +68,30 @@ public class UserInnerServiceSMOImpl implements IUserInnerServiceSMO {
     }
 
 
+
+    @Override
+    public int getUserCount(@RequestBody UserDto userDto) {
+
+        return userServiceDaoImpl.getUserCount(BeanConvertUtil.beanCovertMap(userDto));
+    }
+
+    @Override
+    public List<UserDto> getUsers(@RequestBody UserDto userDto) {
+        //校验是否传了 分页信息
+
+        int page = userDto.getPage();
+
+        if (page != PageDto.DEFAULT_PAGE) {
+            userDto.setPage((page - 1) * userDto.getRow());
+        }
+
+        List<UserDto> staffs = BeanConvertUtil.covertBeanList(userServiceDaoImpl.getUsers(BeanConvertUtil.beanCovertMap(userDto)), UserDto.class);
+
+
+        return staffs;
+    }
+
+
     public IUserServiceDao getUserServiceDaoImpl() {
         return userServiceDaoImpl;
     }

+ 3 - 3
java110-bean/src/main/java/com/java110/dto/wxLogin/UserInfo.java

@@ -9,7 +9,7 @@ public class UserInfo implements Serializable {
     private String province;
     private String city;
     private String language;
-    private Byte gender;
+    private String gender;
 
     public String getCountry() {
         return country;
@@ -43,11 +43,11 @@ public class UserInfo implements Serializable {
         this.language = language;
     }
 
-    public Byte getGender() {
+    public String getGender() {
         return gender;
     }
 
-    public void setGender(Byte gender) {
+    public void setGender(String gender) {
         this.gender = gender;
     }
 

+ 116 - 0
java110-bean/src/main/java/com/java110/vo/api/user/ApiUserDataVo.java

@@ -0,0 +1,116 @@
+package com.java110.vo.api.user;
+
+import java.io.Serializable;
+
+public class ApiUserDataVo implements Serializable {
+
+    private String userId;
+
+    private String userName;
+
+    private String name;
+
+    private String tel;
+
+    private String email;
+
+    private String address;
+
+    private String password;
+
+    private String locationCd;
+
+    private int age;
+
+    private String sex;
+
+    private String levelCd;
+
+    public String getUserId() {
+        return userId;
+    }
+
+    public void setUserId(String userId) {
+        this.userId = userId;
+    }
+
+    public String getUserName() {
+        return userName;
+    }
+
+    public void setUserName(String userName) {
+        this.userName = userName;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public String getTel() {
+        return tel;
+    }
+
+    public void setTel(String tel) {
+        this.tel = tel;
+    }
+
+    public String getEmail() {
+        return email;
+    }
+
+    public void setEmail(String email) {
+        this.email = email;
+    }
+
+    public String getAddress() {
+        return address;
+    }
+
+    public void setAddress(String address) {
+        this.address = address;
+    }
+
+    public String getPassword() {
+        return password;
+    }
+
+    public void setPassword(String password) {
+        this.password = password;
+    }
+
+    public String getLocationCd() {
+        return locationCd;
+    }
+
+    public void setLocationCd(String locationCd) {
+        this.locationCd = locationCd;
+    }
+
+    public int getAge() {
+        return age;
+    }
+
+    public void setAge(int age) {
+        this.age = age;
+    }
+
+    public String getSex() {
+        return sex;
+    }
+
+    public void setSex(String sex) {
+        this.sex = sex;
+    }
+
+    public String getLevelCd() {
+        return levelCd;
+    }
+
+    public void setLevelCd(String levelCd) {
+        this.levelCd = levelCd;
+    }
+}

+ 18 - 0
java110-bean/src/main/java/com/java110/vo/api/user/ApiUserVo.java

@@ -0,0 +1,18 @@
+package com.java110.vo.api.user;
+
+import com.java110.vo.MorePageVo;
+
+import java.io.Serializable;
+import java.util.List;
+
+public class ApiUserVo extends MorePageVo implements Serializable {
+    List<ApiUserDataVo> users;
+
+    public List<ApiUserDataVo> getUsers() {
+        return users;
+    }
+
+    public void setUsers(List<ApiUserDataVo> users) {
+        this.users = users;
+    }
+}

+ 20 - 0
java110-config/src/main/java/com/java110/config/properties/code/Java110Properties.java

@@ -14,6 +14,10 @@ public class Java110Properties {
 
     private String mappingPath;
 
+    private String wxAppId;
+
+    private String wxAppSecret;
+
     public String getMappingPath() {
         return mappingPath;
     }
@@ -21,4 +25,20 @@ public class Java110Properties {
     public void setMappingPath(String mappingPath) {
         this.mappingPath = mappingPath;
     }
+
+    public String getWxAppId() {
+        return wxAppId;
+    }
+
+    public void setWxAppId(String wxAppId) {
+        this.wxAppId = wxAppId;
+    }
+
+    public String getWxAppSecret() {
+        return wxAppSecret;
+    }
+
+    public void setWxAppSecret(String wxAppSecret) {
+        this.wxAppSecret = wxAppSecret;
+    }
 }

+ 19 - 0
java110-core/src/main/java/com/java110/core/component/BaseComponentSMO.java

@@ -86,6 +86,25 @@ public class BaseComponentSMO extends BaseServiceSMO {
 
     }
 
+    /**
+     * 获取用户信息
+     *
+     * @param pd
+     * @param restTemplate
+     * @return
+     */
+    protected ResponseEntity<String> getUserInfoByOpenId(IPageData pd, RestTemplate restTemplate,String openId) {
+        Assert.hasLength(pd.getUserId(), "用户未登录请先登录");
+        ResponseEntity<String> responseEntity = null;
+        responseEntity = this.callCenterService(restTemplate, pd, "",
+                ServiceConstant.SERVICE_API_URL + "/api/user.listUsers?openId=" + openId+"&page=1&row=1", HttpMethod.GET);
+        // 过滤返回报文中的字段,只返回name字段
+        //{"address":"","orderTypeCd":"Q","serviceCode":"","responseTime":"20190401194712","sex":"","localtionCd":"","userId":"302019033054910001","levelCd":"00","transactionId":"-1","dataFlowId":"-1","response":{"code":"0000","message":"成功"},"name":"996icu","tel":"18909780341","bId":"-1","businessType":"","email":""}
+
+        return responseEntity;
+
+    }
+
     /**
      * 查询商户信息
      *

+ 22 - 0
java110-core/src/main/java/com/java110/core/smo/user/IUserInnerServiceSMO.java

@@ -57,4 +57,26 @@ public interface IUserInnerServiceSMO {
      */
     @RequestMapping(value = "/getStaffs", method = RequestMethod.POST)
     List<UserDto> getStaffs(@RequestBody UserDto userDto);
+
+
+    /**
+     * 查询用户总数
+     *
+     * @param userDto 用户ID
+     *                支持 多个查询
+     * @return 用户封装信息
+     */
+    @RequestMapping(value = "/getUserCount", method = RequestMethod.POST)
+    int getUserCount(@RequestBody UserDto userDto);
+
+
+    /**
+     * 查询员工信息
+     *
+     * @param userDto 用户ID
+     *                支持 多个查询
+     * @return 用户封装信息
+     */
+    @RequestMapping(value = "/getUsers", method = RequestMethod.POST)
+    List<UserDto> getUsers(@RequestBody UserDto userDto);
 }

+ 67 - 0
java110-db/src/main/resources/mapper/user/UserServiceDaoImplMapper.xml

@@ -505,4 +505,71 @@
         </if>
     </select>
 
+    <!-- 查询用户 -->
+    <select id="getUsers" parameterType="Map">
+        select u.user_id, u.user_id userId,u.name,u.name userName,u.email,u.address,u.password,u.location_cd,u.location_cd locationCd,
+        u.age,u.sex,u.tel,u.level_cd,u.b_id
+        from u_user u
+        <if test="openId != null and openId !=''">
+            ,u_user_attr ua
+        </if>
+        where 1= 1
+        <if test="openId != null and openId != ''">
+            and u.user_id = ua.user_id
+            and ua.spec_cd = '100201911001'
+            and ua.value = #{openId}
+            and ua.status_cd = '0'
+        </if>
+        <if test="bId != null and bId !=''">
+            and u.b_id = #{bId}
+        </if>
+        <if test="userId != null and userId != ''">
+            and u.user_id = #{userId}
+        </if>
+        <if test="statusCd !=null and statusCd != ''">
+            and u.status_cd = #{statusCd}
+        </if>
+        <if test="userIds != null and userIds != null">
+            and u.user_id in
+            <foreach collection="userIds" item="item" open="(" close=")" separator=",">
+                #{item}
+            </foreach>
+        </if>
+        order by u.create_time desc
+        <if test="page != -1 and page != null ">
+            limit #{page}, #{row}
+        </if>
+    </select>
+
+    <select id="getUserCount" parameterType="Map" resultType="Map">
+        select count(1) count
+        from u_user u
+        <if test="openId != null and openId !=''">
+            ,u_user_attr ua
+        </if>
+        where 1= 1
+        <if test="openId != null and openId != ''">
+            and u.user_id = ua.user_id
+            and ua.spec_cd = '100201911001'
+            and ua.value = #{openId}
+            and ua.status_cd = '0'
+        </if>
+        <if test="bId != null and bId !=''">
+            and u.b_id = #{bId}
+        </if>
+        <if test="userId != null and userId != ''">
+            and u.user_id = #{userId}
+        </if>
+        <if test="statusCd !=null and statusCd != ''">
+            and u.status_cd = #{statusCd}
+        </if>
+        <if test="userIds != null and userIds != null">
+            and u.user_id in
+            <foreach collection="userIds" item="item" open="(" close=")" separator=",">
+                #{item}
+            </foreach>
+        </if>
+
+    </select>
+
 </mapper>

BIN
java110-front/src/main/resources/static/.DS_Store


+ 6 - 0
java110-utils/src/main/java/com/java110/utils/constant/ServiceCodeConstant.java

@@ -116,6 +116,12 @@ public class ServiceCodeConstant {
      */
     public static final String SERVICE_CODE_QUERY_USER_USERINFO = "query.user.userInfo";
 
+
+    /**
+     * 查询 组织管理
+     */
+    public static final String LIST_USERS = "user.listUsers";
+
     /**
      * 保存商户信息
      */