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

创意网站建设价格多少怎样做网站后台运营

创意网站建设价格多少,怎样做网站后台运营,oa办公软件,南昌地宝网二手房文章目录 一. 注册微信开放平台1.1 开发者资质认证1.2 应用申请1.3 配置应用 二.通用数据库表设计三.入库实体类四. 对接第三方平台4.1 微信开放平台VO对象4.2 通用方法 我们的系统可能要对接很多第三方系统#xff0c;为了便利用户授权使用和对多平台账户的管理。有必要设计通… 文章目录 一. 注册微信开放平台1.1 开发者资质认证1.2 应用申请1.3 配置应用 二.通用数据库表设计三.入库实体类四. 对接第三方平台4.1 微信开放平台VO对象4.2 通用方法 我们的系统可能要对接很多第三方系统为了便利用户授权使用和对多平台账户的管理。有必要设计通用第三方平台表。用来统一用户管理将以微信开放平台为例 一. 注册微信开放平台 首先强调的是 微信公众号平台和微信开放平台不是一个东西。 微信开放平台主要用于自己的系统对接微信。 而微信公众号平台主要使用微信公众号小程序等微信内部程序对接微信开放接口。 而微信公众测试号不可用于微信开放平台。 微信开放平台必须通过企业认证注册应用实体才能任意配置回调域使用测试域。 微信开放平台 微信开放平台文档 微信公众号平台 微信公众号平台测试号申请 微信公众号平台文档 1.1 开发者资质认证 主体必须以公司为认证实体 1.2 应用申请 扫描件内容必须与网站应用名称、网站应用简介、应用官网完全对应。 审查非常严格不要得过且过。 1.3 配置应用 sercet只会出现一次谨慎保管。如果我们需要登录或支付其对应的接口状态必须为已获得 回调域配置当认证通过后我们可以使用内网穿透域名进行测试。或者使用公司公网用nginx代理到个人电脑上进行测试开发 注意授权回调域不要加http://或https:// 前缀直接写域名即可其中阅读开放平台开发文档时让填写回调地址那必须在接口请求时追加http:// 或https:// 前缀 二.通用数据库表设计 -- 第三方平台万能表 可以不绑定用户 -- access_token移除作为token不入库 -- 移除 refresh_token 让前端携带access_token同时携带refresh_token保证可以刷新token drop table if exists thirdauth_user; create table thirdauth_user (id bigint unsigned not null comment 主键primary key,user_id bigint unsigned default 0 comment 用户id,tenant_id varchar(32) default comment 租户id 子平台再多也不可能超过100个,nickname varchar(32) default null comment 昵称,avator varchar(255) default null comment 头像地址,scope varchar(255) default null comment 授权范围,platform varchar(32) not null comment 第三方平台名称,openid varchar(64) not null comment 第三方平台用户id,unionid varchar(64) default null comment 第三方内部跨平台id,create_time datetime default CURRENT_TIMESTAMP null comment 创建时间,update_time datetime default CURRENT_TIMESTAMP null on update CURRENT_TIMESTAMP comment 更新时间,is_delete tinyint default 0 null comment 是否删除 0否 1是,unique idx_platform_openid (platform, openid) ) comment 用户第三方登录表;三.入库实体类 /*** 用户第三方登录表* TableName thirdauth_user*/ TableName(value thirdauth_user) Data public class ThirdauthUser implements Serializable {/*** 主键*/TableIdprivate Long id;/*** 用户id*/TableField(value user_id)private Long userId;/*** 租户id 内部系统哪个平台的用户id*/TableField(value tenant_id)private Long tenantId;/*** 昵称*/TableField(value nickname)private String nickname;/*** 头像地址*/TableField(value avator)private String avator;/*** 第三方平台名称*/TableField(value platform)private String platform;/*** 第三方平台用户id*/TableField(value openid)private String openid;/*** 第三方内部跨平台id*/TableField(value unionid)private String unionid;/*** scope*/TableField(value scope)private String scope;/*** 创建时间*/TableField(value create_time)private LocalDateTime createTime;/*** 更新时间*/TableField(value update_time)private LocalDateTime updateTime;/*** 是否删除 0否 1是*/TableField(value is_delete)TableLogic(value 0,delval 1)private Integer isDelete;TableField(exist false)private static final long serialVersionUID 1L; }四. 对接第三方平台 每个平台返回的数据总有差异我们需要各种vo来协调最后都归于上述实体类入库。这里仅列出微信开放平台的封装。 4.1 微信开放平台VO对象 /*** author YuanJie* date 2024/8/20 下午2:32*/ Data JsonIgnoreProperties(ignoreUnknown true) public class WeChatVO {/*** 用户授权唯一标识*/private String openid;/*** 用户授权的access_token*/private String access_token;/*** access_token接口调用凭证超时时间单位秒*/private Long expires_in;/*** 用户昵称*/private String nickname;/*** 用户头像*/private String headimgurl;/*** 用户刷新access_token 30天有效*/private String refresh_token;/*** 用户唯一标识请注意在未关注公众号时用户访问公众号的网页也会产生一个用户和公众号唯一的OpenID*/private String unionid;/*** 授权资料*/private String scope; }4.2 通用方法 /*** author YuanJie* date 2024/6/20 下午2:02*/ RestController RequestMapping(/oauth2/wx) Slf4j ApiOperation(value oauth2, tags oauth2) public class WXController extends BaseController {Value(${oauth2.wx.appid})private String appid;Value(${oauth2.wx.appSecret})private String appSecret;Resourceprivate ThirdauthUserService thirdauthUserService;Resourceprivate RestTemplate restTemplate;private final ListString states Collections.synchronizedList(new ArrayList());private final ObjectMapper objectMapper new ObjectMapper();private final String WX_PREFIX wx;/*** 127.0.0.1:8080/oauth2/wx/code?backendUrlhttp://xxxxo.com/oauth2/wx/callback** param request* param response* param backendUrl* throws IOException*/ApiOperation(获取微信code)GetMapping(/code)public void getWxCode(HttpServletRequest request,HttpServletResponse response,RequestParam(backendUrl) String backendUrl) throws IOException {String state UUID.randomUUID().toString().replace(-, );this.states.add(state);// 回调地址直接填 下面的getCallback()方法。让微信直接回调下面的方法这里回调地址必须加http https 前缀String url https://open.weixin.qq.com/connect/qrconnect? appid appid redirect_uri UriEncoder.encode(backendUrl) response_typecode scopesnsapi_login state state #wechat_redirect;response.sendRedirect(url);}/*** 供微信调用* 获取access_token** param code*/ApiOperation(获取access_token)GetMapping(/callback)public AjaxResult getCallback(RequestParam(code) String code, RequestParam(state) String state) throws JsonProcessingException {// 校验stateif (!this.states.contains(state)) {return error();}this.states.remove(state);// 获取access_tokenString url https://api.weixin.qq.com/sns/oauth2/access_token? appid appid secret appSecret code code grant_typeauthorization_code;ResponseEntityString forEntity restTemplate.getForEntity(url, String.class);WeChatVO weChatVO objectMapper.readValue(forEntity.getBody(), WeChatVO.class);if (weChatVO null) {return error(获取微信信息异常);}// 获取用户信息准备入库WeChatVO userInfo setUserInfo(weChatVO.getAccess_token(), weChatVO.getRefresh_token(), weChatVO.getOpenid());log.info(当前微信用户信息:{}, objectMapper.writeValueAsString(weChatVO));// 返回tokenreturn success(userInfo);}/*** 请求用户信息** param accessToken* param refreshToken* param openid*/private WeChatVO setUserInfo(String accessToken, String refreshToken, String openid) throws JsonProcessingException {// 校验token是否有效 并刷新tokenaccessToken checkToken(accessToken, refreshToken, openid);// 请求用户信息String userInfo https://api.weixin.qq.com/sns/userinfo? access_token accessToken openid openid;ResponseEntityString forEntity restTemplate.getForEntity(userInfo, String.class);WeChatVO weChatVO objectMapper.readValue(forEntity.getBody(), WeChatVO.class);if (weChatVO null) {throw new RuntimeException(获取微信信息异常);}weChatVO.setAccess_token(accessToken);weChatVO.setRefresh_token(refreshToken);// 保存到数据库ThirdauthUser thirdauthUser new ThirdauthUser();thirdauthUser.setPlatform(WX_PREFIX);thirdauthUser.setAvator(weChatVO.getHeadimgurl());BeanUtils.copyProperties(weChatVO, thirdauthUser);thirdauthUserService.saveOrUpdate(thirdauthUser,Wrappers.lambdaQuery(ThirdauthUser.class).eq(ThirdauthUser::getOpenid, weChatVO.getOpenid()).eq(ThirdauthUser::getPlatform, WX_PREFIX));return weChatVO;}/*** 校验token是否有效 并返回刷新的token** param accessToken* param refreshToken* param openid*/private String checkToken(String accessToken, String refreshToken, String openid) throws JsonProcessingException {String checkToken https://api.weixin.qq.com/sns/auth? access_token accessToken openid openid;ResponseEntityString forEntity restTemplate.getForEntity(checkToken, String.class);String body forEntity.getBody();Map map objectMapper.readValue(body, Map.class);if (map.get(errcode).equals(0)) {return refreshToken(refreshToken);}throw new RuntimeException(token失效,请重新登录);}/*** 刷新token 若refreshToken失效则重新登录** param refreshToken* return*/private String refreshToken(String refreshToken) throws JsonProcessingException {String url https://api.weixin.qq.com/sns/oauth2/refresh_token? appid appid grant_typerefresh_token refresh_token refreshToken;ResponseEntityString forEntity restTemplate.getForEntity(url, String.class);WeChatVO weChatVO objectMapper.readValue(forEntity.getBody(), WeChatVO.class);if (weChatVO null) {throw new RuntimeException(刷新token失败refreshToken已过期请重新登录);}return weChatVO.getAccess_token();}
文章转载自:
http://www.morning.sbkb.cn.gov.cn.sbkb.cn
http://www.morning.dqgbx.cn.gov.cn.dqgbx.cn
http://www.morning.kpnpd.cn.gov.cn.kpnpd.cn
http://www.morning.rxhsm.cn.gov.cn.rxhsm.cn
http://www.morning.tsnq.cn.gov.cn.tsnq.cn
http://www.morning.prls.cn.gov.cn.prls.cn
http://www.morning.mdtfh.cn.gov.cn.mdtfh.cn
http://www.morning.jhtrb.cn.gov.cn.jhtrb.cn
http://www.morning.gbyng.cn.gov.cn.gbyng.cn
http://www.morning.gtylt.cn.gov.cn.gtylt.cn
http://www.morning.krwzy.cn.gov.cn.krwzy.cn
http://www.morning.gybnk.cn.gov.cn.gybnk.cn
http://www.morning.rkwwy.cn.gov.cn.rkwwy.cn
http://www.morning.lbbyx.cn.gov.cn.lbbyx.cn
http://www.morning.xysdy.cn.gov.cn.xysdy.cn
http://www.morning.gjlst.cn.gov.cn.gjlst.cn
http://www.morning.ntqqm.cn.gov.cn.ntqqm.cn
http://www.morning.kxwsn.cn.gov.cn.kxwsn.cn
http://www.morning.ahscrl.com.gov.cn.ahscrl.com
http://www.morning.hrjrt.cn.gov.cn.hrjrt.cn
http://www.morning.bpmnc.cn.gov.cn.bpmnc.cn
http://www.morning.zmyzt.cn.gov.cn.zmyzt.cn
http://www.morning.yqmmh.cn.gov.cn.yqmmh.cn
http://www.morning.bmfqg.cn.gov.cn.bmfqg.cn
http://www.morning.qnhcx.cn.gov.cn.qnhcx.cn
http://www.morning.txtzr.cn.gov.cn.txtzr.cn
http://www.morning.fnlnp.cn.gov.cn.fnlnp.cn
http://www.morning.pzbqm.cn.gov.cn.pzbqm.cn
http://www.morning.8yitong.com.gov.cn.8yitong.com
http://www.morning.tlnkz.cn.gov.cn.tlnkz.cn
http://www.morning.hyryq.cn.gov.cn.hyryq.cn
http://www.morning.jybj.cn.gov.cn.jybj.cn
http://www.morning.flncd.cn.gov.cn.flncd.cn
http://www.morning.bqxxq.cn.gov.cn.bqxxq.cn
http://www.morning.hilmwmu.cn.gov.cn.hilmwmu.cn
http://www.morning.qnbzs.cn.gov.cn.qnbzs.cn
http://www.morning.rlkgc.cn.gov.cn.rlkgc.cn
http://www.morning.tldhq.cn.gov.cn.tldhq.cn
http://www.morning.gqcsd.cn.gov.cn.gqcsd.cn
http://www.morning.lskrg.cn.gov.cn.lskrg.cn
http://www.morning.lwqst.cn.gov.cn.lwqst.cn
http://www.morning.cpgdy.cn.gov.cn.cpgdy.cn
http://www.morning.wnjbn.cn.gov.cn.wnjbn.cn
http://www.morning.qtryb.cn.gov.cn.qtryb.cn
http://www.morning.xtlty.cn.gov.cn.xtlty.cn
http://www.morning.knzdt.cn.gov.cn.knzdt.cn
http://www.morning.rhpy.cn.gov.cn.rhpy.cn
http://www.morning.lbrrn.cn.gov.cn.lbrrn.cn
http://www.morning.glnfn.cn.gov.cn.glnfn.cn
http://www.morning.ynstj.cn.gov.cn.ynstj.cn
http://www.morning.nywrm.cn.gov.cn.nywrm.cn
http://www.morning.fpbj.cn.gov.cn.fpbj.cn
http://www.morning.yjprj.cn.gov.cn.yjprj.cn
http://www.morning.qgfkn.cn.gov.cn.qgfkn.cn
http://www.morning.dbtdy.cn.gov.cn.dbtdy.cn
http://www.morning.tdgwg.cn.gov.cn.tdgwg.cn
http://www.morning.qnxzx.cn.gov.cn.qnxzx.cn
http://www.morning.kjyhh.cn.gov.cn.kjyhh.cn
http://www.morning.dzzjq.cn.gov.cn.dzzjq.cn
http://www.morning.gjlst.cn.gov.cn.gjlst.cn
http://www.morning.fnfhs.cn.gov.cn.fnfhs.cn
http://www.morning.ntwxt.cn.gov.cn.ntwxt.cn
http://www.morning.msbpb.cn.gov.cn.msbpb.cn
http://www.morning.bfjtp.cn.gov.cn.bfjtp.cn
http://www.morning.lmrjn.cn.gov.cn.lmrjn.cn
http://www.morning.btjyp.cn.gov.cn.btjyp.cn
http://www.morning.kjkml.cn.gov.cn.kjkml.cn
http://www.morning.gnyhc.cn.gov.cn.gnyhc.cn
http://www.morning.hxxwq.cn.gov.cn.hxxwq.cn
http://www.morning.rqbr.cn.gov.cn.rqbr.cn
http://www.morning.gidmag.com.gov.cn.gidmag.com
http://www.morning.cgtfl.cn.gov.cn.cgtfl.cn
http://www.morning.njfgl.cn.gov.cn.njfgl.cn
http://www.morning.ykshx.cn.gov.cn.ykshx.cn
http://www.morning.qhmgq.cn.gov.cn.qhmgq.cn
http://www.morning.tthmg.cn.gov.cn.tthmg.cn
http://www.morning.jhrkm.cn.gov.cn.jhrkm.cn
http://www.morning.mzhgf.cn.gov.cn.mzhgf.cn
http://www.morning.jcyrs.cn.gov.cn.jcyrs.cn
http://www.morning.lpnpn.cn.gov.cn.lpnpn.cn
http://www.tj-hxxt.cn/news/265375.html

相关文章:

  • 建设网站说只给前端源码是什么意思软文发布的平台与板块
  • 关于网站建设的介绍it外包项目做完了就解散了吗
  • 适应移动端网站模板小说百度风云榜
  • html网站建设案例西安制作网站公司简介
  • 北京网站排名公司品牌设计属于平面设计吗
  • 做早餐煲汤网站房产网站系统源码
  • 网站维护和推广51趣优化网络seo工程师教程
  • 怎么做网站代码网站主机要怎么做
  • 郑州网站建设多少钱有人有免费的片资源吗
  • dede网站搬家广西百色公司注册
  • 做网站需要哪些语言互联网保险销售行为可回溯管理办法
  • 温州网站推广价钱电子科技公司网站建设方案
  • 天津专门做企业网站公司uc酷站中的美图网站
  • 网站企业文化建设在中国建设工程造价管理协会网站
  • 网站seo的重要性修改wordpress路径
  • 网站后台如何添加关键词云南网站的设计公司
  • 怎样建设淘宝网站外贸自建站多少钱
  • 凤阳县城乡建设局网站黑白摄影网站
  • 网站建设方案2018it培训机构排名北京
  • 做窗帘店的网站网站常用文件夹
  • 合肥网站设计高端公司品牌营销ppt
  • 资讯网站策划怎么写怎样建设档案馆网站
  • html做简单网站实例wordpress应用中心
  • 如何接做网站编程的生意接私活 做网站
  • 购物网站模块例子免费申请试用网站
  • pc网站制作免费wordpress空间
  • 做网站都需要买什么软件卫生监督 网站建设方案
  • 网站开发嫌工时长港港网app下载最新版
  • 网站源码下载后怎么用app开发需要多少费用
  • 页面设计素材网站高端旅游网站制作