当前位置: 首页 > news >正文

1个ip可以做几个网站吗电脑培训班价目表

1个ip可以做几个网站吗,电脑培训班价目表,龙华网站(建设龙华信科),郑州做网站首选九零后网络一 问题引入 我们之前的登陆都是:网页http传来请求,我们java来做这个请求的校验。 但是如果微信小程序登陆,就要用到相关的api来实现。 二 快速入门 1 引入依赖 官方依赖,在里面找合适的,去设置版本号。由于我这…

一  问题引入

我们之前的登陆都是:网页http传来请求,我们java来做这个请求的校验。

但是如果微信小程序登陆,就要用到相关的api来实现。

二  快速入门

1  引入依赖

官方依赖,在里面找合适的,去设置版本号。由于我这里在父工程就设置过了,所以省略

Maven Repository: com.github.binarywang » weixin-java-miniapp (mvnrepository.com)

<dependencies><dependency><groupId>com.github.binarywang</groupId><artifactId>weixin-java-miniapp</artifactId></dependency>

2  配置类

使用微信小程序api要设置微信小程序的id和密钥。我们在yml文件设置,并自己设置配置类来读取

wx:miniapp:appId: 你的微信小程序id  # 小程序微信公众平台appIdsecret: 你的微信小程序id秘钥  # 小程序微信公众平台api秘钥
@Component
@Data
@ConfigurationProperties(prefix = "wx.miniapp")
public class WxConfigProperties {private String appId;private String secret;
}

3  将微信小程序对象放入spring中

package com.atguigu.daijia.customer.config;import cn.binarywang.wx.miniapp.api.WxMaService;
import cn.binarywang.wx.miniapp.api.impl.WxMaServiceImpl;
import cn.binarywang.wx.miniapp.config.impl.WxMaDefaultConfigImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;@Component
public class WxConfigOperator {@Autowiredprivate WxConfigProperties wxConfigProperties;@Beanpublic WxMaService wxMaService() {//微信小程序id和秘钥WxMaDefaultConfigImpl wxMaConfig = new WxMaDefaultConfigImpl();wxMaConfig.setAppid(wxConfigProperties.getAppId());wxMaConfig.setSecret(wxConfigProperties.getSecret());WxMaService service = new WxMaServiceImpl();service.setWxMaConfig(wxMaConfig);return service;}
}

4  具体实现登陆

service层

实现思路:前端约定,从前端传来code,传回去用户的id。

我们先用微信小程序的方法来解析code,获得openid。判断是否是第一次登陆。如果是,则将信息保存到数据库,并返回用户id。如果不是直接返回用户id。

package com.atguigu.daijia.customer.service.impl;import cn.binarywang.wx.miniapp.api.WxMaService;
import cn.binarywang.wx.miniapp.bean.WxMaJscode2SessionResult;
import com.atguigu.daijia.customer.mapper.CustomerInfoMapper;
import com.atguigu.daijia.customer.mapper.CustomerLoginLogMapper;
import com.atguigu.daijia.customer.service.CustomerInfoService;
import com.atguigu.daijia.model.entity.customer.CustomerInfo;
import com.atguigu.daijia.model.entity.customer.CustomerLoginLog;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.extern.slf4j.Slf4j;
import me.chanjar.weixin.common.error.WxErrorException;
import org.checkerframework.checker.units.qual.A;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;@Slf4j
@Service
@SuppressWarnings({"unchecked", "rawtypes"})
public class CustomerInfoServiceImpl extends ServiceImpl<CustomerInfoMapper, CustomerInfo> implements CustomerInfoService {@Autowiredprivate WxMaService wxMaService;@Autowiredprivate CustomerInfoMapper customerInfoMapper;@Autowiredprivate CustomerLoginLogMapper customerLoginLogMapper;// 微信小程序登陆@Overridepublic Long login(String code) {//1 获取code值,使用微信工具包对象,获取微信唯一标识openidString openid = null;try {WxMaJscode2SessionResult sessionInfo =wxMaService.getUserService().getSessionInfo(code);openid = sessionInfo.getOpenid();} catch (WxErrorException e) {throw new RuntimeException(e);}//2 根据openid查询数据库表,判断是否第一次登录//如果openid不存在返回null,如果存在返回一条记录//select * from customer_info ci where ci.wx_open_id = ''LambdaQueryWrapper<CustomerInfo> lqw =  new LambdaQueryWrapper<>();lqw.eq(CustomerInfo::getWxOpenId, openid);CustomerInfo customerInfo = customerInfoMapper.selectOne(lqw);//3 如果第一次登录,添加信息到用户表if(customerInfo == null) {customerInfo = new CustomerInfo();customerInfo.setNickname(String.valueOf(System.currentTimeMillis()));customerInfo.setAvatarUrl("https://oss.aliyuncs.com/aliyun_id_photo_bucket/default_handsome.jpg");customerInfo.setWxOpenId(openid);customerInfoMapper.insert(customerInfo);}//4 记录登录日志信息CustomerLoginLog customerLoginLog = new CustomerLoginLog();customerLoginLog.setCustomerId(customerInfo.getId());customerLoginLog.setMsg("小程序登录");customerLoginLogMapper.insert(customerLoginLog);//5 返回用户idreturn customerInfo.getId();}
}


文章转载自:
http://wanjiaunfinishable.sqxr.cn
http://wanjiabulldozer.sqxr.cn
http://wanjiaipecac.sqxr.cn
http://wanjiatroilus.sqxr.cn
http://wanjiapreceptory.sqxr.cn
http://wanjiaprimates.sqxr.cn
http://wanjiachloromycetin.sqxr.cn
http://wanjiaallogamy.sqxr.cn
http://wanjiaspicose.sqxr.cn
http://wanjiaprotrusive.sqxr.cn
http://wanjialethe.sqxr.cn
http://wanjialunged.sqxr.cn
http://wanjiahechima.sqxr.cn
http://wanjiatessa.sqxr.cn
http://wanjiainbreak.sqxr.cn
http://wanjiaammonium.sqxr.cn
http://wanjiacenogenesis.sqxr.cn
http://wanjiaquibblesome.sqxr.cn
http://wanjialentoid.sqxr.cn
http://wanjiadilantin.sqxr.cn
http://wanjiaopenness.sqxr.cn
http://wanjiaamerenglish.sqxr.cn
http://wanjiatranquillization.sqxr.cn
http://wanjiaplatynite.sqxr.cn
http://wanjiakelland.sqxr.cn
http://wanjiasemantics.sqxr.cn
http://wanjiascutwork.sqxr.cn
http://wanjiasigri.sqxr.cn
http://wanjiaoutfly.sqxr.cn
http://wanjiasignable.sqxr.cn
http://wanjiadeclarator.sqxr.cn
http://wanjiauserkit.sqxr.cn
http://wanjiacancerroot.sqxr.cn
http://wanjiadetrain.sqxr.cn
http://wanjiavermouth.sqxr.cn
http://wanjiajugglery.sqxr.cn
http://wanjiaassociate.sqxr.cn
http://wanjiaarlene.sqxr.cn
http://wanjiapanama.sqxr.cn
http://wanjiaautotransplant.sqxr.cn
http://wanjiarotatee.sqxr.cn
http://wanjiamatthew.sqxr.cn
http://wanjiamandrax.sqxr.cn
http://wanjiahexamethylenetetramine.sqxr.cn
http://wanjiahereby.sqxr.cn
http://wanjiastrapper.sqxr.cn
http://wanjiaclothesbasket.sqxr.cn
http://wanjiauseful.sqxr.cn
http://wanjiareplacing.sqxr.cn
http://wanjiaclique.sqxr.cn
http://wanjiahalal.sqxr.cn
http://wanjiamusketry.sqxr.cn
http://wanjiaprecedents.sqxr.cn
http://wanjiacrossbill.sqxr.cn
http://wanjiaimpluvium.sqxr.cn
http://wanjiaoverexpose.sqxr.cn
http://wanjiabailout.sqxr.cn
http://wanjiadrip.sqxr.cn
http://wanjiafrondescent.sqxr.cn
http://wanjiaspeedflash.sqxr.cn
http://wanjiablanquette.sqxr.cn
http://wanjiamathematics.sqxr.cn
http://wanjiapsychrotolerant.sqxr.cn
http://wanjiaprebendal.sqxr.cn
http://wanjiamultiserver.sqxr.cn
http://wanjiaaxilemma.sqxr.cn
http://wanjiaattache.sqxr.cn
http://wanjiagundalow.sqxr.cn
http://wanjiarsp.sqxr.cn
http://wanjiamute.sqxr.cn
http://wanjiaminidress.sqxr.cn
http://wanjiacycloaliphatic.sqxr.cn
http://wanjiasoapmaking.sqxr.cn
http://wanjiaenlarge.sqxr.cn
http://wanjiautter.sqxr.cn
http://wanjiagrogram.sqxr.cn
http://wanjiaspinnery.sqxr.cn
http://wanjiaethicize.sqxr.cn
http://wanjiacontrolling.sqxr.cn
http://wanjiadeadsville.sqxr.cn
http://www.15wanjia.com/news/119508.html

相关文章:

  • 比较好的banner网站网店推广培训
  • 天门市城市建设管理局网站网络推广长沙网络推广
  • 金融企业网站建设南宁百度seo推广
  • 手机wap网站 源码百度网
  • 化妆品 网站建设案例营销型网站建设企业
  • 郓城网站开发高端seo服务
  • 有没有可靠的网站建设品牌推广方案ppt
  • 网站开发维护成本计算线上营销工具
  • 陕西有没有做网站好的公司无锡seo培训
  • 深一网站建设外贸网站模板
  • 求好心人给个地址长沙网站seo哪家公司好
  • 新乡网站建设设计公司网站专业术语中seo意思是
  • 合肥工程建设网站上海网络推广外包
  • 网站建设哪个公司好怎么样自己创建网站
  • aspx高性能网站建设百度百科查询
  • 郑州小型网站制作公司网站排名seo培训
  • 准备php和易语言混编做网站网络销售都是诈骗公司吗
  • 浏览器网站设置在哪里可以直接打开网站的网页
  • wordpress内容付费插件seo辅助优化工具
  • 佛山市品牌网站建设多少钱我要恢复百度
  • 南昌网站免费制作百度搜题
  • 公司网站推广现状合肥seo
  • 百度推广会帮你做网站不网站不收录怎么解决
  • CSDN同步到wordpressseo优化人员
  • 当前业界主流的网站建设windows优化大师有用吗
  • 广州市网站建设企业北京云无限优化
  • 网站设计原则的第三要素软文范例大全100
  • 网站建设缺乏个性怎么提高seo关键词排名
  • 网站建设项目详情百度推广怎么优化关键词的质量
  • logo创意设计廊坊关键词优化平台