This commit is contained in:
裴浩宇 2020-05-21 21:46:21 +08:00
parent 6c02d62343
commit 1c5661e442
6 changed files with 56 additions and 15 deletions

View File

@ -33,11 +33,15 @@ public class trafficController {
/**登录验证*/ /**登录验证*/
@RequestMapping(value = "/login", method = {RequestMethod.POST, RequestMethod.GET}) @RequestMapping(value = "/logon", method = {RequestMethod.POST, RequestMethod.GET})
@ResponseBody @ResponseBody
public Map<String,Object> login(@RequestBody Map<String,Object> param) { public Map<String,Object> login(@RequestBody Map<String,Object> param) {
Map<String,Object> result = new HashMap<>(); Map<String,Object> result = new HashMap<>();
result = trafficService.getUser(); try {
result = trafficService.getUser(param);
} catch(Exception e){
e.printStackTrace();
}
return result; return result;
} }

View File

@ -1,6 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?> <?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"> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.springboot.traffic.dao.trafficMapper"> <mapper namespace="com.springboot.traffic.dao.trafficMapper">
<!--用户注册-->
<insert id="userRegister" parameterType="map"> <insert id="userRegister" parameterType="map">
insert into traffic_user(user_id,user_name,user_password,user_phone) insert into traffic_user(user_id,user_name,user_password,user_phone)
values values
@ -11,8 +12,9 @@
#{formName.phone} #{formName.phone}
) )
</insert> </insert>
<!--用户登录-->
<select id="getUser" parameterType="map" resultType="map"> <select id="getUser" parameterType="map" resultType="map">
select * from traffic_user select * from traffic_user where user_name = #{formName.name} and user_password = #{formName.pass}
</select> </select>
</mapper> </mapper>

View File

@ -8,11 +8,19 @@ import java.util.Map;
@Mapper @Mapper
public interface trafficMapper { public interface trafficMapper {
/**用户注册 /**
* @param param**/ * 用户注册
* @param 用户名密码手机号
* @return 1注册成功 0注册失败
*/
int userRegister(Map<String, Object> param); int userRegister(Map<String, Object> param);
List<Map<String, Object>> getUser(); /**
* 用户登录
* @param 用户名密码
* @return 用户是否注册
*/
List<Map<String, Object>> getUser(Map<String, Object> param);
} }

View File

@ -14,6 +14,11 @@ public class trafficServiceImpl implements trafficService {
@Autowired @Autowired
trafficMapper trafficMapper; trafficMapper trafficMapper;
/**
* 用户注册
* @param 用户名密码手机号
* @return 成功与否数据
*/
@Override @Override
public Map<String, Object> register(Map<String, Object> param) { public Map<String, Object> register(Map<String, Object> param) {
Map<String,Object> result = new HashMap<>(); Map<String,Object> result = new HashMap<>();
@ -28,10 +33,20 @@ public class trafficServiceImpl implements trafficService {
return result; return result;
} }
/**
* 用户登录
* @param 用户名密码
* @return 用户是否注册
*/
@Override @Override
public Map<String, Object> getUser() { public Map<String, Object> getUser(Map<String, Object> param) {
Map<String,Object> result = new HashMap<>(); Map<String,Object> result = new HashMap<>();
List<Map<String,Object>> res = trafficMapper.getUser(); List<Map<String,Object>> res = null;
try {
res = trafficMapper.getUser(param);
} catch(Exception e){
e.printStackTrace();
}
result.put("success", true); result.put("success", true);
result.put("data", res); result.put("data", res);
return result; return result;

View File

@ -3,15 +3,20 @@ package com.springboot.traffic.service;
import java.util.Map; import java.util.Map;
public interface trafficService { public interface trafficService {
/**用户注册**/ /**
* 用户注册
* @param 用户名密码手机号
* @return 成功与否数据
*/
Map<String, Object> register(Map<String, Object> param); Map<String, Object> register(Map<String, Object> param);
/** /**
* * 用户登录
* @return * @param 用户名密码
* @return 用户是否注册
*/ */
Map<String, Object> getUser(); Map<String, Object> getUser(Map<String, Object> param);
} }

View File

@ -37,7 +37,7 @@
<el-input type="password" v-model="logonForm.pass"></el-input> <el-input type="password" v-model="logonForm.pass"></el-input>
</el-form-item> </el-form-item>
<el-form-item> <el-form-item>
<el-button type="primary" @click="submitForm('logonForm')">登录</el-button> <el-button type="primary" @click="submitLogon(logonForm)">登录</el-button>
</el-form-item> </el-form-item>
</el-form> </el-form>
</el-dialog> </el-dialog>
@ -181,7 +181,14 @@ export default {
this.$message.error('用户名已存在!'); this.$message.error('用户名已存在!');
} }
},r=>{ },r=>{
this.$message.error('注册失败!');
})
},
//
submitLogon(formName){
this.$ajax.post("/traffic/logon",{formName},r=>{
debugger
}) })
}, },
@ -210,6 +217,6 @@ export default {
.menu{ .menu{
height:4rem; height:4rem;
width:100% width: %
} }
</style> </style>