VPS参考测评推荐
专注分享VPS主机优惠信息
衡天云优惠活动
华纳云优惠活动
荫云优惠活动

分享微信小程序后端代码(微信小程序源代码)

主机参考:VPS测评参考推荐/专注分享VPS服务器优惠信息!若您是商家可以在本站进行投稿,查看详情!此外我们还提供软文收录、PayPal代付、广告赞助等服务,查看详情!
我们发布的部分优惠活动文章可能存在时效性,购买时建议在本站搜索商家名称可查看相关文章充分了解该商家!若非中文页面可使用Edge浏览器同步翻译!PayPal代付/收录合作

相关推荐:《小程序开发教程》

鉴于很多小伙伴都给我发私信询问后端代码的问题。我很高兴能帮助这么多人。然而,由于某些原因,它以前没有与客户端代码一起发布。在这里,代码被发布到GitHub供每个人下载和学习。这里使用Java Servlet,它是在Web服务器或应用程序服务器上运行的程序,作为来自Web浏览器或其他HTTP客户端的请求与HTTP服务器上的数据库或应用程序之间的中间层。数据库使用MySQL,持久层使用JDBC和Java的本地API。没有使用框架,便于初学者学习,可以更好地理解web的运行机制和原理。GitHub地址:portal以下是关键代码:

/** * Servlet实现类登录*/@ web Servlet(“/log in“)公共类登录扩展http Servlet { private static final long serialVersionUID = 1L;私有静态最终字符串APPID =“xxxxxxxxxxx“;private static final String SECRET =“xxxxxxxxxxxxxxxxxxxxxxxxxx“;/** *默认构造函数。*/public log in(){//TODO auto -generated constructor stub }/* * * @ see http servlet # doGet(http servlet request,HttpServletResponse响应)*/protected void doGet(http servlet request,HttpServletResponse响应)throws ServletException,io exception {//e =“请求”,setcharacter encoding(“ut F-8”);response . set content type(“text/html;charset = ut F-8“);/* Access-control -allow -Origin“,“*“);/* access -control -allow -Methods“,“GET,POST“);string flag = request . getparameter(“flag“);//system . out . println(flag);if(“登录”。equals(flag)){ String code = request . getparameter(“js _ code“);string URL =“https://API . weixin . QQ . com/SNS/jscode 2 session?APPID =“+APPID+“& SECRET =“+SECRET+“& js _ code =“+code+“& grant _ type = authorization _ code“;JSON object sjs on = common util . https request(URL,“GET”,null);/* String OpenID =““;string session _ key =““;if(SJ son!= null){ try { OpenID = sjson . getstring(“OpenID“);session _ key = sjson . getstring(“session _ key“);} catch(Exception e){ system . out . println(“宋体×);e . printstacktrace();} } else { system . out . println(“codeí“);} system . out . println(session _ key+““+OpenID);*//* Map result = new HashMap();result . put(“RES”、“test”);result . put(“msg““ó“““);*/ // String json = new Gson()。托伊森(SJ son);//system . out . println(JSON);writer out = response . get writer();out . write(sjs on . tostring());out . flush();} if(“init”。equals(flag)){ student Dao student Dao = new student Dao();string userid = request . getparameter(“userid“);boolean res = true请尝试{ RES = student Dao . find check(userid);} catch(Exception e){ e . printstacktrace();} Map result = new HashMap();result . put(“RES“,RES);result . put(“msg““ó“““);String json = new Gson()。toJson(结果);//Writer out = response . get Writer();out . write(JSON);out . flush();} if(“学生”。equals(flag)){ student Dao student Dao = new student Dao();string userid = request . getparameter(“userid“);string student name = request . getparameter(“sname“);string student num = request . getparameter(“snum“);Student student =新学生(userid,studentName,studentNum,new Date());请尝试{ int a = student Dao . create(student);如果(a!= 0){ system . out . println(“);} } catch(Exception e){ e . printstacktrace();} } if(“老师”。equals(flag)){ TeacherDAO TeacherDAO = new TeacherDAO();string userid = request . getparameter(“userid“);string teacher name = request . getparameter(“tname“);string teacheid = request . getparameter(“tnum“);Teacher = new Teacher(userid,teacherID,teacherName,new Date());试试{ int a = teacher Dao . create(tea);如果(a!= 0){ system . out . println(“);} } catch(Exception e){ e . printstacktrace();} } if(“指南”。equals(flag)){ student Dao student Dao = new student Dao();string userid = request . getparameter(“userid“);system . out . println(userid);boolean res = true字符串状态=““;请尝试{ RES = student Dao . find check(userid);} catch(Exception e){ e . printstacktrace();} if(RES){ state =“student“;} else { TeacherDAO TeacherDAO = new TeacherDAO();请尝试{ RES = teacher Dao . find check(userid);} catch(Exception e){ e . printstacktrace();} if(RES){ state =“teacher“;} else { state =“none“;}} String json = new Gson()。托吉森(州);//Writer out = response . get Writer();out . write(JSON);out . flush();} if(“myInfo”。equals(flag)){ String userid = request . getparameter(“userid“);student Dao student Dao = new student Dao();请尝试{ List List = student Dao . myinfo(userid);map result = new HashMap();result . put(“back name“,list . get(0));result . put(“backNum“,list . get(1));String json = new Gson()。toJson(结果);//Writer out = response . get Writer();out . write(JSON);out . flush();} catch(Exception e){ e . printstacktrace();} } }/* * * * * see HttpServlet # doPost(http servlet请求,http servlet响应)*/protected void doPost(http servlet请求,http servlet响应)抛出ServletException,io exception {//TODO auto -生成的方法stubdoGet(请求,响应);}}这里的APPID和SECRET应该使用您自己的。最近很少关注博客,咨询的人也很多。很多私信来不及回复,其他的我们就自己探索了。本程序纯属个人兴趣,不应用于商业目的。

以上是分享微信小程序签到考勤后端代码的详细内容。更多资讯请关注主机参考其他相关文章!

这几篇文章你可能也喜欢:

本文由主机参考刊发,转载请注明:分享微信小程序后端代码(微信小程序源代码) https://zhujicankao.com/102577.html

【腾讯云】领8888元采购礼包,抢爆款云服务器 每月 9元起,个人开发者加享折上折!
打赏
转载请注明原文链接:主机参考 » 分享微信小程序后端代码(微信小程序源代码)
主机参考仅做资料收集,不对商家任何信息及交易做信用担保,购买前请注意风险,有交易纠纷请自行解决!请查阅:特别声明

评论 抢沙发

评论前必须登录!