hym 4 năm trước cách đây
mục cha
commit
956e9989eb

+ 2 - 0
src/main/java/com/zoniot/ccrc/commom/model/ResultStatus.java

@@ -23,7 +23,9 @@ public enum ResultStatus {
     ACCESS_UNVERIFIED_ERROR(-406, "身份未认证,请重新登录"),
     APPLICATION_ERROR(-900, "应用异常"),
     SERVICE_ERROR(-901, "业务逻辑验证错误"),
+    CLEARING_DATA_QUERY_NO_CUSTOMER(-602,"查询客户不存在"),
     SYSTEM_ERROR(-999, "系统错误");
+
     private final int status;
 
     private final String message;

+ 11 - 0
src/main/java/com/zoniot/ccrc/controller/applets/AppletsUserController.java

@@ -4,6 +4,7 @@ import com.zoniot.ccrc.commom.model.AjaxMessage;
 import com.zoniot.ccrc.commom.model.Pagination;
 import com.zoniot.ccrc.commom.model.ResultStatus;
 import com.zoniot.ccrc.dto.ClientUserDto;
+import com.zoniot.ccrc.dto.LoginUser;
 import com.zoniot.ccrc.entity.ClientUser;
 import com.zoniot.ccrc.service.AppletsService;
 import io.swagger.annotations.ApiOperation;
@@ -66,4 +67,14 @@ public class AppletsUserController {
         }
 
     }
+    @PostMapping ("getUser")
+    @ApiOperation(value = "用户信息")
+    public AjaxMessage<LoginUser> getUser() {
+        int result=appletsService.getUser();
+        if(result==0){
+            return new AjaxMessage<>(ResultStatus.OK);
+        }else{
+            return new AjaxMessage(ResultStatus.CLEARING_DATA_QUERY_NO_CUSTOMER);
+        }
+    }
 }

+ 2 - 0
src/main/java/com/zoniot/ccrc/dao/UserMapper.java

@@ -73,5 +73,7 @@ public interface UserMapper {
     String getDefaultNumer(@Param("id") int id);
 
     List<ClientUser> findClientUserByOpenid(@Param("openid") String openid, @Param("type") Integer type);
+
+    Integer getUser(String openid);
 }
 

+ 2 - 0
src/main/java/com/zoniot/ccrc/dto/GridUser.java

@@ -1,6 +1,7 @@
 package com.zoniot.ccrc.dto;
 
 import io.swagger.annotations.ApiModelProperty;
+import io.swagger.models.auth.In;
 import lombok.Data;
 
 @Data
@@ -22,4 +23,5 @@ public class GridUser {
     @ApiModelProperty(value = "机构id")
     private Integer orgId;
     private Integer siteId;
+    private Integer roleType;
 }

+ 2 - 3
src/main/java/com/zoniot/ccrc/security/openid/OpenidLoginAuthenticationFilter.java

@@ -23,8 +23,7 @@ public class OpenidLoginAuthenticationFilter extends AbstractAuthenticationProce
     private String codeParameter = SPRING_SECURITY_FORM_CODE_KEY;
     private String customerParameter = SPRING_SECURITY_FORM_CUSTOMER_KEY;
     private boolean postOnly = true;
-    @Autowired
-    private WechatService wechatService;
+
 
     // ~ Constructors
     // ===================================================================================================
@@ -51,7 +50,7 @@ public class OpenidLoginAuthenticationFilter extends AbstractAuthenticationProce
             code = "";
         }
 
-        String openid = wechatService.getOpenid(code,customerId);
+        String openid = WechatService.getOpenid(code,customerId);
 
 
         OpenidLoginAuthenticationToken authRequest = new OpenidLoginAuthenticationToken(openid);

+ 3 - 0
src/main/java/com/zoniot/ccrc/service/AppletsService.java

@@ -21,4 +21,7 @@ public interface AppletsService {
 
 
     void updateByPrimaryKeySelective(ClientUser clientUser);
+
+    int getUser();
+
 }

+ 7 - 7
src/main/java/com/zoniot/ccrc/service/WechatService.java

@@ -31,12 +31,12 @@ public class WechatService {
 
 
     //水查查小程序
-    @Value("${wechat.mp.app-secret}")
-    private    String APP_SECRET;
-    @Value("${wechat.mp.appid}")
-    private    String APP_ID ;
 
-    public    String getSessionkey(String code) {
+    private  static  String APP_SECRET="a01d7f75f15e1a6b7fa28a317f97ef1b";
+
+    private  static  String APP_ID="wx27f831675081e293" ;
+
+    public  static   String getSessionkey(String code) {
         JSONObject oppidObj=getWechatAuthInfo(code);
         Integer errcode = (Integer) oppidObj.get("errcode");
         if(errcode == null){
@@ -49,7 +49,7 @@ public class WechatService {
         }
 
     }
-    private   JSONObject getWechatAuthInfo(String code){
+    private static  JSONObject getWechatAuthInfo(String code){
         String url = "https://api.weixin.qq.com/sns/jscode2session?appid=" + APP_ID + "&secret="
                 + APP_SECRET + "&js_code=" + code + "&grant_type=authorization_code";
         String reusult = null;
@@ -62,7 +62,7 @@ public class WechatService {
         JSONObject oppidObj = JSONObject.parseObject(reusult);
         return oppidObj;
     }
-    public  String getOpenid(String code,String customerId) {
+    public static String getOpenid(String code,String customerId) {
         JSONObject oppidObj=getWechatAuthInfo(code);
         Integer errcode = (Integer) oppidObj.get("errcode");
         if(errcode == null){

+ 12 - 0
src/main/java/com/zoniot/ccrc/service/impl/AppletsServiceImpl.java

@@ -239,4 +239,16 @@ public class AppletsServiceImpl implements AppletsService {
     public void updateByPrimaryKeySelective(ClientUser clientUser) {
         userMapper.setDefault(clientUser.getId());
     }
+
+    @Override
+    public int getUser() {
+
+        int result=0;
+        LoginUser currentUser = UserUtil.getCurrentUser();
+        Integer id=userMapper.getUser(currentUser.getOpenid());
+        if(id==null){
+            result=-1;
+        }
+        return result;
+    }
 }

+ 2 - 1
src/main/resources/mapper/GridManagementMapper.xml

@@ -187,7 +187,8 @@
         from sc_grid_management
     </select>
     <select id="selectGirdUserInfo" resultType="com.zoniot.ccrc.dto.GridUser">
-        select  b.id orgId,a.id,username,mobile_phone,a.name,b.name org_name,b.address,ifnull(c.peoples,0) peoples from
+        select  b.id orgId,a.id,username,mobile_phone,a.name,b.name org_name,
+               b.address,ifnull(c.peoples,0) peoples ,e.type roleType from
          sc_site_user ssu   join    sc_user a on ssu.user_id=a.id
          join sc_organization b on ssu.organ_id=b.id
         join sc_user_role d on d.uid=a.id join sc_role e on e.id=d.rid

+ 3 - 0
src/main/resources/mapper/UserMapper.xml

@@ -318,6 +318,9 @@
         </if>
 
 
+    </select>
+    <select id="getUser" resultType="java.lang.Integer">
+        select id from sc_user where openid=#{openid} and status=1
     </select>
     <update id="setDefault">
         update sc_grid_management set is_default = 1 where   id = #{id}