查询个人信息

master
zxy19971014 6 years ago
parent 4c8b9f506a
commit a003b437ce

@ -1,7 +1,11 @@
{ {
"pages": [ "pages": [
<<<<<<< Updated upstream
"denglu/denglu", "denglu/denglu",
=======
>>>>>>> Stashed changes
"wode/wode", "wode/wode",
"gerenxinxi/gerenxinxi", "gerenxinxi/gerenxinxi",
"shuji/shuji", "shuji/shuji",

@ -2,7 +2,7 @@ Page({
shujichzhao: function (e) { shujichzhao: function (e) {
var that = this var that = this
wx.request({ wx.request({
url: 'http://localhost:9527/zxbook/find1', url: 'http://localhost:9528/zxbook/find1',
data: { data: {
'search': e.detail.value.search, 'search': e.detail.value.search,
}, },

@ -1,52 +1,68 @@
Page({ Page({
formSubmit: function (e) { formSubmit: function (e) {
wx.request({ wx.request({
url: 'http://localhost:9527/zxlogin/login', url: 'http://localhost:9528/zxlogin/login',
data: { data: {
'userid': e.detail.value.userid, 'userid': e.detail.value.userid,
'userpassword': e.detail.value.userpassword, 'userpassword': e.detail.value.userpassword,
}, },
header: { header: {
"Content-Type": "application/x-www-form-urlencoded" "Content-Type": "application/x-www-form-urlencoded"
}, },
methods: { methods: {
method: "POST", method: "POST",
}, },
success: function (res) { success: function (res) {
console.log(res.data); var book = res.data
if (res.data == "111") { let bookstr = JSON.stringify(book);
wx.showModal({ console.log(book);
title: '登录消息', if (res.data == "100") {
content: '登录成功', wx.showModal({
confirmColor: "rgba(253, 153, 65, 1)", title: '登录消息',
success: function (res) { content: '密码错误',
if (res.confirm) { confirmColor: "rgba(253, 153, 65, 1)"
wx.switchTab({ })
url: '../shouye/shouye', }
})
} else if (res.data == "001") {
} wx.showModal({
}) title: '登录消息',
} content: '用户名不存在',
else if (res.data == "100") { confirmColor: "rgba(253, 153, 65, 1)"
wx.showModal({ })
title: '登录消息', }
content: '密码错误', else {
confirmColor: "rgba(253, 153, 65, 1)" wx.showModal({
}) title: '登录消息',
} content: '登录成功',
else if (res.data == "001") { confirmColor: "rgba(253, 153, 65, 1)",
wx.showModal({ success: function (res) {
title: '登录消息', if (res.confirm) {
content: '用户名不存在', wx.switchTab({
confirmColor: "rgba(253, 153, 65, 1)" url: '../shouye/shouye',
}) })
} }
}, }
fail: function (res) { })
console.log("失败"); }
}
}) },
} fail: function (res) {
console.log("失败");
}
})
},
wx.request({
url: 'http://localhost:9528/zxbook/find2',
data: {
'search': e.target.id,
},
header: {
"Content-Type": "application/json"
},
methods: {
method: "POST",
},
}) })

@ -1,4 +1,4 @@
// 获取全局应用程序实例对象 // 获取全局应用程序实例对象
const app = getApp(); const app = getApp();
@ -60,7 +60,7 @@ Page({
}, },
//以下为自定义点击事件 //以下为自定义点击事件
}) })

@ -1,4 +1,5 @@
<image class="wx-image_TCMtbw" mode="scaleToFill" src="//o3bnyc.creatby.com/diazo/images/image-placeholder.svg" style="background-size: 100% 100%; background-position: 0% 0%; background-repeat: no-repeat; background-image: url(http://o3bnyc.creatby.com/diazo/images/image-placeholder.svg);"/> <image class="wx-image_TCMtbw" mode="scaleToFill" src="//o3bnyc.creatby.com/diazo/images/image-placeholder.svg" style="background-size: 100% 100%; background-position: 0% 0%; background-repeat: no-repeat; background-image: url(http://o3bnyc.creatby.com/diazo/images/image-placeholder.svg);"/>
<text class="c-block wx-text_3ayXhS" > 姓名:</text> <text class="c-block wx-text_3ayXhS" > 姓名:</text>
<text class="c-block wx-text_cEEG0A" > 学号:</text> <input class="inputText" maxlength="15" name="userid"value="{{userid}}" />
<text class="c-block wx-text_lkXRAs" > 密码:</text> <text class="c-block wx-text_cEEG0A" > 学号:${userpassword}</text>
<text class="c-block wx-text_lkXRAs" > 密码:${username}</text>

@ -13,7 +13,7 @@
"compileType": "miniprogram", "compileType": "miniprogram",
"libVersion": "2.4.0", "libVersion": "2.4.0",
"appid": "wxb280d1925541c356", "appid": "wxb280d1925541c356",
"projectname": "33", "projectname": "34",
"debugOptions": { "debugOptions": {
"hidedInDevtools": [] "hidedInDevtools": []
}, },

@ -22,6 +22,25 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xs
<version>3.8.1</version> <version>3.8.1</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency>
<groupId>com.github.binarywang</groupId>
<artifactId>weixin-java-miniapp</artifactId>
<version>${weixin.java.miniapp.version}</version>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.44</version>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.2</version>
</dependency>
<!-- mysql数据库驱动类 --> <!-- mysql数据库驱动类 -->
<dependency> <dependency>
<groupId>mysql</groupId> <groupId>mysql</groupId>

@ -1,57 +1,61 @@
package controller; package controller;
import java.io.IOException; import java.io.IOException;
import java.io.Writer; import java.io.Writer;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import service.LoginService; import com.google.gson.Gson;
import domain.UserPO;
import service.LoginService;
@Controller import domain.UserPO;
public class LoginController {
@Autowired@Qualifier("LoginServiceImpl") @Controller
private LoginService loginService; public class LoginController {
@RequestMapping("/login") @Autowired@Qualifier("LoginServiceImpl")
public void login(int userid, int userpassword, private LoginService loginService;
HttpServletRequest request, HttpServletResponse response) throws IOException { @RequestMapping("/login")
UserPO userPO=this.loginService.FindByUserid(userid); public void login(int userid, int userpassword,
response.setContentType("text/html;charset=utf-8"); HttpServletRequest request, HttpServletResponse response) throws IOException {
/* 设置响应头允许ajax跨域访问 */ UserPO userPO=this.loginService.FindByUserid(userid);
response.setHeader("Access-Control-Allow-Origin", "*"); response.setContentType("text/html;charset=utf-8");
/* 星号表示所有的异域请求都可以接受, */ /* 设置响应头允许ajax跨域访问 */
response.setHeader("Access-Control-Allow-Methods", "GET,POST"); response.setHeader("Access-Control-Allow-Origin", "*");
System.out.println(userid); /* 星号表示所有的异域请求都可以接受, */
if(userPO!=null) response.setHeader("Access-Control-Allow-Methods", "GET,POST");
if(userpassword==userPO.getUserpassword()) System.out.println(userid);
{ if(userPO!=null)
System.out.println("密码正确"); if(userpassword==userPO.getUserpassword())
Writer out = response.getWriter(); {
out.write("111"); System.out.println("密码正确");
out.flush(); String ss = new Gson().toJson(userPO);
} Writer out = response.getWriter();
out.write(ss);
out.flush();
else{ }
System.out.println("密码错误");
Writer out = response.getWriter();
out.write("100");
out.flush(); else{
} System.out.println("密码错误");
else{ Writer out = response.getWriter();
System.out.println("不存在用户名"); out.write("100");
Writer out = response.getWriter(); out.flush();
out.write("001"); }
out.flush(); else{
} System.out.println("不存在用户名");
Writer out = response.getWriter();
} out.write("001");
} out.flush();
}
}
}

@ -1,12 +1,12 @@
package mapperDAO; package mapperDAO;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
import domain.UserPO; import domain.UserPO;
@Repository("UserDAO") @Repository("UserDAO")
public interface UserDAO { public interface UserDAO {
public UserPO FindByUserid(int userid); public UserPO FindByUserid(int userid);
} }

@ -1,9 +1,9 @@
package service; package service;
import domain.UserPO; import domain.UserPO;
public interface LoginService{ public interface LoginService{
public UserPO FindByUserid(int userid); public UserPO FindByUserid(int userid);
} }

@ -1,23 +1,23 @@
package serviceimpl; package serviceimpl;
import mapperDAO.UserDAO; import mapperDAO.UserDAO;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import domain.UserPO; import domain.UserPO;
import service.LoginService; import service.LoginService;
@Component("LoginServiceImpl") @Component("LoginServiceImpl")
public class LoginServiceImpl implements LoginService{ public class LoginServiceImpl implements LoginService{
@Autowired@Qualifier("UserDAO") @Autowired@Qualifier("UserDAO")
private UserDAO userDAO; private UserDAO userDAO;
public UserPO FindByUserid(int userid){ public UserPO FindByUserid(int userid){
return this.userDAO.FindByUserid(userid); return this.userDAO.FindByUserid(userid);
} }
} }

@ -17,7 +17,18 @@
driverClass="com.mysql.jdbc.Driver" driverClass="com.mysql.jdbc.Driver"
connectionURL="jdbc:mysql://127.0.0.1:3306/zx" connectionURL="jdbc:mysql://127.0.0.1:3306/zx"
userId="root" userId="root"
password="zjh19990323"> password="zxy19971014"
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.44</version>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.2</version>
</dependency>19990323">
</jdbcConnection> </jdbcConnection>
<javaTypeResolver> <javaTypeResolver>

@ -13,7 +13,7 @@
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"> <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName" value="com.mysql.jdbc.Driver" /> <property name="driverClassName" value="com.mysql.jdbc.Driver" />
<property name="username" value="root" /> <property name="username" value="root" />
<property name="password" value="zjh19990323" /> <property name="password" value="zxy19971014" />
<property name="url" <property name="url"
value="jdbc:mysql://127.0.0.1:3306/zx?useUnicode=true&amp;characterEncoding=utf8" /> value="jdbc:mysql://127.0.0.1:3306/zx?useUnicode=true&amp;characterEncoding=utf8" />
</bean> </bean>

@ -17,7 +17,18 @@
driverClass="com.mysql.jdbc.Driver" driverClass="com.mysql.jdbc.Driver"
connectionURL="jdbc:mysql://127.0.0.1:3306/zx" connectionURL="jdbc:mysql://127.0.0.1:3306/zx"
userId="root" userId="root"
password="zjh19990323"> password="zxy19971014"
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.44</version>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.2</version>
</dependency>19990323">
</jdbcConnection> </jdbcConnection>
<javaTypeResolver> <javaTypeResolver>

@ -13,7 +13,7 @@
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"> <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName" value="com.mysql.jdbc.Driver" /> <property name="driverClassName" value="com.mysql.jdbc.Driver" />
<property name="username" value="root" /> <property name="username" value="root" />
<property name="password" value="zjh19990323" /> <property name="password" value="zxy19971014" />
<property name="url" <property name="url"
value="jdbc:mysql://127.0.0.1:3306/zx?useUnicode=true&amp;characterEncoding=utf8" /> value="jdbc:mysql://127.0.0.1:3306/zx?useUnicode=true&amp;characterEncoding=utf8" />
</bean> </bean>

Loading…
Cancel
Save