mirror of
https://github.com/FreeeBird/hotel.git
synced 2025-05-06 19:49:26 +08:00
test
This commit is contained in:
parent
132506deef
commit
ebbc2671b2
@ -1 +1,6 @@
|
|||||||
# hotel
|
# 酒店管理系统
|
||||||
|
|
||||||
|
### 背景说明
|
||||||
|
【整体背景】
|
||||||
|
|
||||||
|
随着旅游业的发展,以及世界商贸活动的频繁举行,其周边行业如酒店、餐饮、娱乐等行业也日趋发达。其中酒店宾馆组织庞大、服务项目多、信息量庞大,传统的人工管理方式已经无法满足要求。此时需要借助于计算机来进行现代化信息管理,从而提高服务质量和管理水平,同时降低管理成本。
|
@ -23,7 +23,7 @@ public class AdminController {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@RequestMapping(method = RequestMethod.POST, value = "/login")
|
@RequestMapping(method = RequestMethod.POST, value = "/login")
|
||||||
public int Login(String userName, String password){
|
public int login(String userName, String password){
|
||||||
Admin admin = new Admin();
|
Admin admin = new Admin();
|
||||||
admin.setUserName(userName);
|
admin.setUserName(userName);
|
||||||
admin.setPassword(password);
|
admin.setPassword(password);
|
||||||
@ -47,6 +47,12 @@ public class AdminController {
|
|||||||
return adminService.register(admin);
|
return adminService.register(admin);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新资料
|
||||||
|
* @param userName
|
||||||
|
* @param password
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
@RequestMapping(method = RequestMethod.POST, value = "/updateProfile")
|
@RequestMapping(method = RequestMethod.POST, value = "/updateProfile")
|
||||||
public int updateProfile(String userName, String password){
|
public int updateProfile(String userName, String password){
|
||||||
Admin admin = new Admin();
|
Admin admin = new Admin();
|
||||||
|
@ -15,7 +15,7 @@ public interface AdminMapper {
|
|||||||
int updateByPrimaryKeySelective(Admin record);
|
int updateByPrimaryKeySelective(Admin record);
|
||||||
int updateByPrimaryKey(Admin record);
|
int updateByPrimaryKey(Admin record);
|
||||||
Admin selectByUserName(String userName);
|
Admin selectByUserName(String userName);
|
||||||
Admin selectByUserNameAndPassword(Admin admin);
|
Admin selectByUserNameAndPassword(Admin record);
|
||||||
int updateByUserNameSelective(Admin record);
|
int updateByUserNameSelective(Admin record);
|
||||||
List<Admin> findAll();
|
List<Admin> findAll();
|
||||||
}
|
}
|
@ -86,7 +86,7 @@
|
|||||||
select * from admin
|
select * from admin
|
||||||
where user_name = #{userName,jdbcType=VARCHAR}
|
where user_name = #{userName,jdbcType=VARCHAR}
|
||||||
</select>
|
</select>
|
||||||
<select id="selectByUserNameAndPassword" parameterType="cn.mafangui.hotel.entity.Admin">
|
<select id="selectByUserNameAndPassword" parameterType="cn.mafangui.hotel.entity.Admin" resultMap="BaseResultMap">
|
||||||
select * from admin
|
select * from admin
|
||||||
where user_name = #{userName,jdbcType=VARCHAR} and password = #{password,jdbcType=VARCHAR}
|
where user_name = #{userName,jdbcType=VARCHAR} and password = #{password,jdbcType=VARCHAR}
|
||||||
</select>
|
</select>
|
||||||
|
@ -0,0 +1,57 @@
|
|||||||
|
package cn.mafangui.hotel.controller;
|
||||||
|
|
||||||
|
import org.junit.After;
|
||||||
|
import org.junit.Assert;
|
||||||
|
import org.junit.Before;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
|
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||||
|
|
||||||
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
|
@RunWith(SpringJUnit4ClassRunner.class)
|
||||||
|
@SpringBootTest
|
||||||
|
public class AdminControllerTest {
|
||||||
|
@Autowired
|
||||||
|
private AdminController adminController;
|
||||||
|
|
||||||
|
@Before
|
||||||
|
public void setUp() throws Exception {
|
||||||
|
}
|
||||||
|
|
||||||
|
@After
|
||||||
|
public void tearDown() throws Exception {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void login() {
|
||||||
|
String userName = "admin";
|
||||||
|
Assert.assertEquals(0, adminController.login(userName, userName));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void register() {
|
||||||
|
String userName = "test";
|
||||||
|
Assert.assertEquals(1, adminController.register(userName, userName));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void updateProfile() {
|
||||||
|
String userName = "test";
|
||||||
|
String password = "1234";
|
||||||
|
Assert.assertEquals(1, adminController.updateProfile(userName, password));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void getAdmin() {
|
||||||
|
String userName = "test";
|
||||||
|
Assert.assertNotNull(adminController.getAdmin(userName));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void getAllAdmin() {
|
||||||
|
Assert.assertNotNull(adminController.getAllAdmin());
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user