摘要:實(shí)現(xiàn)功能小程序訪(fǎng)問(wèn)后臺(tái)服務(wù)器實(shí)現(xiàn)通過(guò)查詢(xún)數(shù)據(jù)并反饋,登錄校驗(yàn),注冊(cè)添加數(shù)據(jù)功能開(kāi)發(fā)工具微信開(kāi)發(fā)工具,,微信開(kāi)發(fā)上的代碼比較簡(jiǎn)單,先寫(xiě)后臺(tái)的,上文件結(jié)構(gòu)從上至下,后接得是訪(fǎng)問(wèn)的地址,在客戶(hù)端也就是小程序端訪(fǎng)問(wèn)就
實(shí)現(xiàn)功能:小程序訪(fǎng)問(wèn)后臺(tái)服務(wù)器實(shí)現(xiàn)通過(guò)ID查詢(xún)數(shù)據(jù)并反饋,登錄校驗(yàn),注冊(cè)添加數(shù)據(jù)功能
開(kāi)發(fā)工具:微信開(kāi)發(fā)工具,IDEA,Mysql
微信開(kāi)發(fā)上的代碼比較簡(jiǎn)單,先寫(xiě)Idea后臺(tái)的,
上文件結(jié)構(gòu)
從上至下,UserController
package com.example.testsql.controller;import com.example.testsql.service.UserService;import org.springframework.beans.factory.annotation.Autowired;import org.springframework.boot.autoconfigure.EnableAutoConfiguration;import org.springframework.web.bind.annotation.RequestMapping;import org.springframework.web.bind.annotation.RestController;@RestController@EnableAutoConfigurationpublic class UserController {@AutowiredUserService userService;//@RequestMapping后接得是訪(fǎng)問(wèn)url的地址,在客戶(hù)端也就是小程序端訪(fǎng)問(wèn)url=http://localhost:8080/login就是查詢(xún),訪(fǎng)問(wèn)url=http://localhost:8080/getlogin就是登錄,訪(fǎng)問(wèn)url=http://localhost:8080/getUser就是注冊(cè), @RequestMapping("/login") public String GetUser(Integer id){ System.out.println("id:"+id); return userService.Sel(id).toString(); } @RequestMapping("/getlogin") public int GetLogin(String userName,String passWord){ System.out.println("注冊(cè)"+userName+passWord); int count=userService.login(userName,passWord); return count; } @RequestMapping("/getUser") public String GetUser(String userName,String passWord){ System.out.println("注冊(cè)"+userName+passWord); userService.getUserByLoginName(userName,passWord); return "success"; }}
User
package com.example.testsql.entity;public class User { private Integer id; private String userName; private String passWord; private String realName; public Integer getId() { return id; } public void setId(Integer id) { this.id = id; } public String getUserName() { return userName; } public void setUserName(String userName) { this.userName = userName; } public String getPassWord() { return passWord; } public void setPassWord(String passWord) { this.passWord = passWord; } public String getRealName() { return realName; } public void setRealName(String realName) { this.realName = realName; } @Override public String toString() { return "{" + "/"id/":" + id + ",/"userName/":/"" + userName + "/"" + ",/"passWord/":/"" + passWord + "/"" + ",/"realName/":/"" + realName + "/"" + "}"; }}
UserMapper
package com.example.testsql.mapper;import com.example.testsql.entity.User;import org.apache.ibatis.annotations.Param;import org.springframework.stereotype.Repository;@Repositorypublic interface UserMapper { User Sel(@Param("id") int id); User getUserByLoginName(@Param("userName") String userName,@Param("passWord") String password); int login(@Param("userName") String userName,@Param("passWord") String password);}
UserService
package com.example.testsql.service;import com.example.testsql.entity.User;import com.example.testsql.mapper.UserMapper;import org.springframework.beans.factory.annotation.Autowired;import org.springframework.stereotype.Service;@Servicepublic class UserService { @Autowired UserMapper userMapper; public User Sel(int id){ return userMapper.Sel(id); } public User getUserByLoginName(String userName,String passWord){ return userMapper.getUserByLoginName(userName,passWord); } public int login(String userName,String passWord){ return userMapper.login(userName,passWord); }}
TestsqlAppliation
package com.example.testsql;import org.mybatis.spring.annotation.MapperScan;import org.springframework.boot.SpringApplication;import org.springframework.boot.autoconfigure.SpringBootApplication;import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;import org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration;@MapperScan("com.example.testsql.mapper")@SpringBootApplication(exclude={DataSourceAutoConfiguration.class, HibernateJpaAutoConfiguration.class})public class TestsqlApplication{ public static void main(String[] args) throws Exception { System.out.println(("success")); SpringApplication.run(TestsqlApplication.class, args); }}
UserMapping
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"><mapper namespace="com.example.testsql.mapper.UserMapper"> <resultMap id="BaseResultMap" type="com.example.testsql.entity.User"> <result column="id" jdbcType="INTEGER" property="id" /> <result column="userName" jdbcType="VARCHAR" property="userName" /> <result column="passWord" jdbcType="VARCHAR" property="passWord" /> <result column="realName" jdbcType="VARCHAR" property="realName" /> </resultMap> <select id="Sel" resultType="com.example.testsql.entity.User"> select * from user where id = #{id} </select> <select id="login" resultType="java.lang.Integer"> select count(id) from user where userName = #{userName} and passWord=#{passWord} </select> <insert id="getUserByLoginName" parameterType="com.example.testsql.entity.User"> insert into user (userName,passWord) values(#{userName},#{passWord}) </insert></mapper>
文章版權(quán)歸作者所有,未經(jīng)允許請(qǐng)勿轉(zhuǎn)載,若此文章存在違規(guī)行為,您可以聯(lián)系管理員刪除。
轉(zhuǎn)載請(qǐng)注明本文地址:http://specialneedsforspecialkids.com/yun/123137.html
摘要:注冊(cè)流程是從小程序簡(jiǎn)稱(chēng),以下替代獲取用戶(hù)的,給到服務(wù)器,服務(wù)器會(huì)用還有自己的等信息一起去微信服務(wù)器請(qǐng)求用戶(hù)數(shù)據(jù),注意每一個(gè)所對(duì)應(yīng)的用戶(hù)都是不一樣的。 本博客 貓叔的博客,轉(zhuǎn)載請(qǐng)申明出處閱讀本文約 5分鐘適讀人群:Java后端、Java初級(jí)、小程序前端 前后端項(xiàng)目的地址 ShareBookServer ShareBookClient 小程序前端 showImg(https://seg...
問(wèn)題 1. - 釘釘開(kāi)發(fā)需要哪些資質(zhì),需要申請(qǐng)哪些賬號(hào)、走哪些流程(像微信小程序的話(huà),一大堆申請(qǐng)、一大堆企業(yè)認(rèn)證)——這些需要提前準(zhǔn)備了解清楚 怎么開(kāi)發(fā)? 有哪些功能? 目前市場(chǎng)上有哪些別人的框架 收集學(xué)習(xí)材料 有哪些功能有,但是存在限制(例如小程序的打開(kāi) app 功能) 有哪些功能自身存在限制性(如小程序的地圖) 開(kāi)發(fā)邊界是什么?有哪些需求是做不到的 有哪些功能是需要特殊資質(zhì)的(如...
摘要:一級(jí)享有折優(yōu)惠,二級(jí)享有折優(yōu)惠,三級(jí)享有折優(yōu)惠,四級(jí)享有折優(yōu)惠,五級(jí)享有折優(yōu)惠管理員模塊管理員不需要注冊(cè),為高級(jí)管理員,可以添加普通管理員。訂房模塊查詢(xún)查看選擇日期訂房訂房后管理員同意取消訂單取消訂單退款是會(huì)根據(jù)時(shí)間節(jié)點(diǎn)收取相應(yīng)手續(xù)費(fèi)。 開(kāi)發(fā)工具(eclipse/idea): eclipse...
摘要:實(shí)現(xiàn)功能發(fā)數(shù)據(jù)給后臺(tái),后臺(tái)根據(jù)獲取到的數(shù)據(jù)查詢(xún)數(shù)據(jù)庫(kù)并將對(duì)應(yīng)的數(shù)據(jù)發(fā)回客戶(hù)端顯示在界面開(kāi)發(fā)工具,,端以下為需要新建或者修改的文件,以便新手學(xué)習(xí)客戶(hù)端運(yùn)行示例代碼展示登錄用戶(hù)名輸入框登錄密碼輸入框登錄按鈕 ...
摘要:利用中間件實(shí)現(xiàn)異步請(qǐng)求,實(shí)現(xiàn)兩個(gè)用戶(hù)角色實(shí)時(shí)通信。目前還未深入了解的一些概念。往后會(huì)寫(xiě)更多的前后臺(tái)聯(lián)通的項(xiàng)目。刪除分組會(huì)連同組內(nèi)的所有圖片一起刪除。算是對(duì)自己上次用寫(xiě)后臺(tái)的一個(gè)強(qiáng)化,項(xiàng)目文章在這里。后來(lái)一直沒(méi)動(dòng),前些日子才把后續(xù)的完善。 歡迎訪(fǎng)問(wèn)我的個(gè)人網(wǎng)站:http://www.neroht.com/? 剛學(xué)vue和react時(shí),利用業(yè)余時(shí)間寫(xiě)的關(guān)于這兩個(gè)框架的訓(xùn)練,都相對(duì)簡(jiǎn)單,有的...
閱讀 2591·2021-11-18 10:02
閱讀 2627·2021-11-15 11:38
閱讀 3697·2021-11-12 10:36
閱讀 695·2021-11-12 10:34
閱讀 2887·2021-10-21 09:38
閱讀 1478·2021-09-29 09:48
閱讀 1492·2021-09-29 09:34
閱讀 1088·2021-09-22 10:02