mirror of
				https://github.com/FreeeBird/hotel.git
				synced 2025-11-04 14:34:47 +08:00 
			
		
		
		
	完成WorkerService类编写,通过单元测试
This commit is contained in:
		@@ -1,132 +0,0 @@
 | 
			
		||||
package cn.mafangui.hotel.controller;
 | 
			
		||||
 | 
			
		||||
import cn.mafangui.hotel.entity.Admin;
 | 
			
		||||
import cn.mafangui.hotel.service.AdminService;
 | 
			
		||||
import org.springframework.beans.factory.annotation.Autowired;
 | 
			
		||||
import org.springframework.web.bind.annotation.RequestMapping;
 | 
			
		||||
import org.springframework.web.bind.annotation.RequestMethod;
 | 
			
		||||
import org.springframework.web.bind.annotation.RestController;
 | 
			
		||||
 | 
			
		||||
import java.util.HashMap;
 | 
			
		||||
 | 
			
		||||
@RestController
 | 
			
		||||
@RequestMapping(value = "/admin")
 | 
			
		||||
public class AdminController {
 | 
			
		||||
    @Autowired
 | 
			
		||||
    private AdminService adminService;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 管理员登录
 | 
			
		||||
     * @param username
 | 
			
		||||
     * @param password
 | 
			
		||||
     * @return
 | 
			
		||||
     */
 | 
			
		||||
    @RequestMapping(method = RequestMethod.POST, value = "/login")
 | 
			
		||||
    public HashMap login(String username, String password){
 | 
			
		||||
        HashMap result = new HashMap();
 | 
			
		||||
        Admin admin = new Admin();
 | 
			
		||||
        admin.setUserName(username);
 | 
			
		||||
        admin.setPassword(password);
 | 
			
		||||
        System.out.println(admin);
 | 
			
		||||
        if (adminService.selectByUserName(username) == null){
 | 
			
		||||
            result.put("data","用户名不存在!");
 | 
			
		||||
        }else if (adminService.login(admin) == null){
 | 
			
		||||
            result.put("data","用户名或密码不正确!");
 | 
			
		||||
        }else {
 | 
			
		||||
            result.put("data","登录成功!");
 | 
			
		||||
        }
 | 
			
		||||
        result.put("code",20000);
 | 
			
		||||
        result.put("token","admin");
 | 
			
		||||
        return result;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @RequestMapping(value = "/logout")
 | 
			
		||||
    public HashMap logout(String token) {
 | 
			
		||||
        HashMap result = new HashMap();
 | 
			
		||||
        result.put("code",20000);
 | 
			
		||||
        result.put("data",token);
 | 
			
		||||
        return result;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @RequestMapping(value = "/info")
 | 
			
		||||
    public HashMap info(String token, String username) {
 | 
			
		||||
        HashMap result = new HashMap();
 | 
			
		||||
        HashMap data = new HashMap();
 | 
			
		||||
        Admin admin = adminService.selectByUserName(username);
 | 
			
		||||
        if (admin == null){
 | 
			
		||||
            data.put("data","用户名不存在!");
 | 
			
		||||
        }else {
 | 
			
		||||
            data.put("data",admin);
 | 
			
		||||
        }
 | 
			
		||||
        result.put("code",20000);
 | 
			
		||||
        String[] roles = {"admin"};
 | 
			
		||||
        data.put("roles",roles);
 | 
			
		||||
        result.put("data",data);
 | 
			
		||||
        return result;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 管理员注册
 | 
			
		||||
     * @param userName
 | 
			
		||||
     * @param password
 | 
			
		||||
     * @return
 | 
			
		||||
     */
 | 
			
		||||
    @RequestMapping(method = RequestMethod.POST, value = "/register")
 | 
			
		||||
    public int register(String userName, String password){
 | 
			
		||||
        Admin admin = new Admin();
 | 
			
		||||
        admin.setUserName(userName);
 | 
			
		||||
        admin.setPassword(password);
 | 
			
		||||
        return adminService.register(admin);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 更新资料
 | 
			
		||||
     * @param userName
 | 
			
		||||
     * @param password
 | 
			
		||||
     * @return
 | 
			
		||||
     */
 | 
			
		||||
    @RequestMapping(method = RequestMethod.POST, value = "/updateProfile")
 | 
			
		||||
    public int updateProfile(String userName, String password){
 | 
			
		||||
        Admin admin = new Admin();
 | 
			
		||||
        admin.setUserName(userName);
 | 
			
		||||
        admin.setPassword(password);
 | 
			
		||||
        return adminService.updateProfile(admin);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 更改密码
 | 
			
		||||
     * @param userName
 | 
			
		||||
     * @param password
 | 
			
		||||
     * @param newPassword
 | 
			
		||||
     * @return
 | 
			
		||||
     */
 | 
			
		||||
    @RequestMapping(method = RequestMethod.POST,value = "/updatePassword")
 | 
			
		||||
    public int updatePassword(String userName, String password,String newPassword){
 | 
			
		||||
        Admin admin = new Admin();
 | 
			
		||||
        admin.setUserName(userName);
 | 
			
		||||
        admin.setPassword(password);
 | 
			
		||||
        return adminService.updatePassword(admin,newPassword);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 查找管理员
 | 
			
		||||
     * @param userName
 | 
			
		||||
     * @return
 | 
			
		||||
     */
 | 
			
		||||
    @RequestMapping(value = "/getAdmin")
 | 
			
		||||
    public Admin getAdmin(String userName){
 | 
			
		||||
        return adminService.selectByUserName(userName);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 查找所有管理员
 | 
			
		||||
     * @return
 | 
			
		||||
     */
 | 
			
		||||
    @RequestMapping(value = "/getAllAdmin")
 | 
			
		||||
    public HashMap getAllAdmin(){
 | 
			
		||||
        HashMap result = new HashMap();
 | 
			
		||||
        result.put("code",1);
 | 
			
		||||
        result.put("data",adminService.findAll());
 | 
			
		||||
        return result;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -1,114 +0,0 @@
 | 
			
		||||
package cn.mafangui.hotel.controller;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
import cn.mafangui.hotel.entity.Hotel;
 | 
			
		||||
import cn.mafangui.hotel.service.HotelService;
 | 
			
		||||
import org.springframework.beans.factory.annotation.Autowired;
 | 
			
		||||
import org.springframework.web.bind.annotation.RequestMapping;
 | 
			
		||||
import org.springframework.web.bind.annotation.RestController;
 | 
			
		||||
 | 
			
		||||
import java.util.List;
 | 
			
		||||
 | 
			
		||||
@RestController
 | 
			
		||||
@RequestMapping(value = "/hotelInfo")
 | 
			
		||||
public class HotelController {
 | 
			
		||||
    @Autowired
 | 
			
		||||
    private HotelService hotelService;
 | 
			
		||||
    /**
 | 
			
		||||
     * 添加酒店信息
 | 
			
		||||
     * @param hotelName
 | 
			
		||||
     * @param phone
 | 
			
		||||
     * @param telephone
 | 
			
		||||
     * @param email
 | 
			
		||||
     * @param address
 | 
			
		||||
     * @param website
 | 
			
		||||
     * @return
 | 
			
		||||
     */
 | 
			
		||||
    @RequestMapping(value = "/add")
 | 
			
		||||
    public int addHotel(String hotelName,String phone,String telephone,String email,String address,String website){
 | 
			
		||||
        int result = 0;
 | 
			
		||||
        Hotel hotel = new Hotel(hotelName,phone,telephone,email,address,website);
 | 
			
		||||
        try {
 | 
			
		||||
            result = hotelService.addHotel(hotel);
 | 
			
		||||
        }catch (Exception e){
 | 
			
		||||
            result = -1;
 | 
			
		||||
        }
 | 
			
		||||
        return result;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 删除酒店信息
 | 
			
		||||
     * @param hotelId
 | 
			
		||||
     * @return
 | 
			
		||||
     */
 | 
			
		||||
    @RequestMapping(value = "/delete")
 | 
			
		||||
    public int deleteHotel(int hotelId){
 | 
			
		||||
        int result = 0;
 | 
			
		||||
        try {
 | 
			
		||||
            result = hotelService.deleteHotel(hotelId);
 | 
			
		||||
        }catch (Exception e){
 | 
			
		||||
            result = -1;
 | 
			
		||||
        }
 | 
			
		||||
        return result;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 更改酒店信息
 | 
			
		||||
     * @param hotelName
 | 
			
		||||
     * @param phone
 | 
			
		||||
     * @param telephone
 | 
			
		||||
     * @param email
 | 
			
		||||
     * @param address
 | 
			
		||||
     * @param website
 | 
			
		||||
     * @return
 | 
			
		||||
     */
 | 
			
		||||
    @RequestMapping(value = "/update")
 | 
			
		||||
    public int updateHotel(int hotelId,String hotelName,String phone,String telephone,String email,String address,String website){
 | 
			
		||||
        int result = 0;
 | 
			
		||||
        Hotel hotel = new Hotel(hotelName,phone,telephone,email,address,website);
 | 
			
		||||
        hotel.setHotelId(hotelId);
 | 
			
		||||
        try{
 | 
			
		||||
            result = hotelService.updateHotel(hotel);
 | 
			
		||||
        }catch (Exception e){
 | 
			
		||||
            result = -1;
 | 
			
		||||
        }
 | 
			
		||||
        return result;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 根据id查询
 | 
			
		||||
     * @param hotelId
 | 
			
		||||
     * @return
 | 
			
		||||
     */
 | 
			
		||||
    @RequestMapping(value = "/withId")
 | 
			
		||||
    public Hotel selectHotel(int hotelId){
 | 
			
		||||
        try {
 | 
			
		||||
            return hotelService.selectHotelById(hotelId);
 | 
			
		||||
        }catch (Exception e){
 | 
			
		||||
            return null;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 根据酒店名查询
 | 
			
		||||
     * @param hotelName
 | 
			
		||||
     * @return
 | 
			
		||||
     */
 | 
			
		||||
    @RequestMapping(value = "/withName")
 | 
			
		||||
    public Hotel selectHotel(String hotelName){
 | 
			
		||||
        try {
 | 
			
		||||
            return hotelService.selectHotelByName(hotelName);
 | 
			
		||||
        }catch (Exception e){
 | 
			
		||||
            return null;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 所有酒店信息
 | 
			
		||||
     * @return
 | 
			
		||||
     */
 | 
			
		||||
    @RequestMapping(value = "/all")
 | 
			
		||||
    public List<Hotel> allHotel(){
 | 
			
		||||
        return hotelService.findAllHotel();
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -1,179 +0,0 @@
 | 
			
		||||
package cn.mafangui.hotel.controller;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
import cn.mafangui.hotel.entity.Room;
 | 
			
		||||
import cn.mafangui.hotel.service.RoomService;
 | 
			
		||||
import cn.mafangui.hotel.utils.StaticString;
 | 
			
		||||
import org.springframework.beans.factory.annotation.Autowired;
 | 
			
		||||
import org.springframework.web.bind.annotation.RequestMapping;
 | 
			
		||||
import org.springframework.web.bind.annotation.RestController;
 | 
			
		||||
 | 
			
		||||
import java.util.HashMap;
 | 
			
		||||
 | 
			
		||||
@RestController
 | 
			
		||||
@RequestMapping(value = "/roomInfo")
 | 
			
		||||
public class RoomController {
 | 
			
		||||
    @Autowired
 | 
			
		||||
    private RoomService roomService;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 增加房间
 | 
			
		||||
     * @param roomNumber
 | 
			
		||||
     * @param roomFloor
 | 
			
		||||
     * @param typeName
 | 
			
		||||
     * @param roomPrice
 | 
			
		||||
     * @param roomDiscount
 | 
			
		||||
     * @param roomStatus
 | 
			
		||||
     * @param remark
 | 
			
		||||
     * @return
 | 
			
		||||
     */
 | 
			
		||||
    @RequestMapping(value = "/add")
 | 
			
		||||
    public HashMap addRoom(String roomNumber, int roomFloor, String typeName,
 | 
			
		||||
                           double roomPrice,double roomDiscount,String roomStatus,String remark){
 | 
			
		||||
        HashMap result = new HashMap();
 | 
			
		||||
        int data = 0;
 | 
			
		||||
        Room room = new Room(roomNumber,roomFloor,typeName,roomPrice,roomDiscount,roomStatus,remark);
 | 
			
		||||
        try {
 | 
			
		||||
            data = roomService.addRoom(room);
 | 
			
		||||
        }catch (Exception e){
 | 
			
		||||
            data = -1;
 | 
			
		||||
        }
 | 
			
		||||
        result.put(StaticString.CODE,20000);
 | 
			
		||||
        result.put(StaticString.DATA,data);
 | 
			
		||||
        return result;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 根据房间id或者房间号码删除房间
 | 
			
		||||
     * @param roomId
 | 
			
		||||
     * @param roomNumber
 | 
			
		||||
     * @return
 | 
			
		||||
     */
 | 
			
		||||
    @RequestMapping(value = "/delete")
 | 
			
		||||
    public HashMap deleteRoom(int roomId,String roomNumber){
 | 
			
		||||
        HashMap result = new HashMap();
 | 
			
		||||
        int data = 0;
 | 
			
		||||
        try {
 | 
			
		||||
            if (roomNumber == null || "".equals(roomNumber)){
 | 
			
		||||
                data = roomService.deleteRoom(roomId);
 | 
			
		||||
            }else {
 | 
			
		||||
                data = roomService.deleteRoom(roomNumber);
 | 
			
		||||
            }
 | 
			
		||||
        }catch (Exception e){
 | 
			
		||||
            data = -1;
 | 
			
		||||
        }
 | 
			
		||||
        result.put(StaticString.CODE,20000);
 | 
			
		||||
        result.put(StaticString.DATA,data);
 | 
			
		||||
        return result;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 更改房间信息
 | 
			
		||||
     * @param roomId
 | 
			
		||||
     * @param roomNumber
 | 
			
		||||
     * @param roomFloor
 | 
			
		||||
     * @param typeName
 | 
			
		||||
     * @param roomPrice
 | 
			
		||||
     * @param roomDiscount
 | 
			
		||||
     * @param roomStatus
 | 
			
		||||
     * @param remark
 | 
			
		||||
     * @return
 | 
			
		||||
     */
 | 
			
		||||
    @RequestMapping(value = "/update")
 | 
			
		||||
    public HashMap updateRoom(int roomId,String roomNumber, int roomFloor, String typeName,
 | 
			
		||||
                              double roomPrice,double roomDiscount,String roomStatus,String remark){
 | 
			
		||||
        HashMap result = new HashMap();
 | 
			
		||||
        int data = 0;
 | 
			
		||||
        Room room = new Room(roomNumber,roomFloor,typeName,roomPrice,roomDiscount,roomStatus,remark);
 | 
			
		||||
        room.setRoomId(roomId);
 | 
			
		||||
        try {
 | 
			
		||||
            data = roomService.updateRoom(room);
 | 
			
		||||
        }catch (Exception e){
 | 
			
		||||
            data = -1;
 | 
			
		||||
        }
 | 
			
		||||
        result.put(StaticString.CODE,20000);
 | 
			
		||||
        result.put(StaticString.DATA,data);
 | 
			
		||||
        return result;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 查询所有房间
 | 
			
		||||
     * @return
 | 
			
		||||
     */
 | 
			
		||||
    @RequestMapping(value = "/all")
 | 
			
		||||
    public HashMap allRoom(){
 | 
			
		||||
        HashMap result = new HashMap();
 | 
			
		||||
        result.put(StaticString.DATA,roomService.findAll());
 | 
			
		||||
        result.put(StaticString.CODE,20000);
 | 
			
		||||
        return result;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 根据id
 | 
			
		||||
     * 查询房间信息
 | 
			
		||||
     * @param roomId
 | 
			
		||||
     * @return
 | 
			
		||||
     */
 | 
			
		||||
    @RequestMapping(value = "/withId")
 | 
			
		||||
    public HashMap findRoomById(int roomId){
 | 
			
		||||
        HashMap result = new HashMap();
 | 
			
		||||
        result.put(StaticString.CODE,20000);
 | 
			
		||||
        try{
 | 
			
		||||
            result.put(StaticString.DATA,roomService.findById(roomId));
 | 
			
		||||
        }catch (Exception e){
 | 
			
		||||
            result.put(StaticString.DATA,-1);
 | 
			
		||||
        }
 | 
			
		||||
        return result;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 根据房号查询房间信息
 | 
			
		||||
     * @param roomNumber
 | 
			
		||||
     * @return
 | 
			
		||||
     */
 | 
			
		||||
    @RequestMapping(value = "/withRoomNumber")
 | 
			
		||||
    public HashMap findRoomByNumber(String roomNumber){
 | 
			
		||||
        HashMap result = new HashMap();
 | 
			
		||||
        result.put(StaticString.CODE,20000);
 | 
			
		||||
        try{
 | 
			
		||||
            result.put(StaticString.DATA,roomService.findByNumber(roomNumber));
 | 
			
		||||
        }catch (Exception e){
 | 
			
		||||
            result.put(StaticString.DATA,-1);
 | 
			
		||||
        }
 | 
			
		||||
        return result;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 根据状态查询房间信息
 | 
			
		||||
     * @param roomStatus
 | 
			
		||||
     * @return
 | 
			
		||||
     */
 | 
			
		||||
    @RequestMapping(value = "/withStatus")
 | 
			
		||||
    public HashMap findRoomByStatus(String roomStatus){
 | 
			
		||||
        HashMap result = new HashMap();
 | 
			
		||||
        result.put(StaticString.CODE,20000);
 | 
			
		||||
        try{
 | 
			
		||||
            result.put(StaticString.DATA,roomService.findByStatus(roomStatus));
 | 
			
		||||
        }catch (Exception e){
 | 
			
		||||
            result.put(StaticString.DATA,-1);
 | 
			
		||||
        }
 | 
			
		||||
        return result;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 根据类型查询房间信息
 | 
			
		||||
     * @param typeName
 | 
			
		||||
     * @return
 | 
			
		||||
     */
 | 
			
		||||
    @RequestMapping(value = "/withType")
 | 
			
		||||
    public HashMap findRoomByType(String typeName){
 | 
			
		||||
        HashMap result = new HashMap();
 | 
			
		||||
        result.put(StaticString.CODE,20000);
 | 
			
		||||
        try{
 | 
			
		||||
            result.put(StaticString.DATA,roomService.findByType(typeName));
 | 
			
		||||
        }catch (Exception e){
 | 
			
		||||
            result.put(StaticString.DATA,-1);
 | 
			
		||||
        }
 | 
			
		||||
        return result;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -1,101 +0,0 @@
 | 
			
		||||
package cn.mafangui.hotel.controller;
 | 
			
		||||
 | 
			
		||||
import cn.mafangui.hotel.entity.RoomType;
 | 
			
		||||
import cn.mafangui.hotel.service.RoomTypeService;
 | 
			
		||||
import org.springframework.beans.factory.annotation.Autowired;
 | 
			
		||||
import org.springframework.web.bind.annotation.RequestMapping;
 | 
			
		||||
import org.springframework.web.bind.annotation.RequestMethod;
 | 
			
		||||
import org.springframework.web.bind.annotation.RestController;
 | 
			
		||||
 | 
			
		||||
import java.util.HashMap;
 | 
			
		||||
 | 
			
		||||
@RestController
 | 
			
		||||
@RequestMapping(value = "/roomType")
 | 
			
		||||
public class RoomTypeController {
 | 
			
		||||
    private final String CODE = "code";
 | 
			
		||||
    private final String DATA = "data";
 | 
			
		||||
 | 
			
		||||
    @Autowired
 | 
			
		||||
    private RoomTypeService roomTypeService;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 添加房间类型
 | 
			
		||||
     * @param roomType
 | 
			
		||||
     * @param typeName
 | 
			
		||||
     * @param bookingPrice
 | 
			
		||||
     * @param bookingDiscount
 | 
			
		||||
     * @param remark
 | 
			
		||||
     * @return
 | 
			
		||||
     */
 | 
			
		||||
    @RequestMapping(method = RequestMethod.POST,value = "/add")
 | 
			
		||||
    public HashMap addNewType(int roomType,String typeName,double bookingPrice,double bookingDiscount,String remark){
 | 
			
		||||
        HashMap result = new HashMap();
 | 
			
		||||
        result.put(CODE,20000);
 | 
			
		||||
        RoomType rt = new RoomType(roomType,typeName,bookingPrice,bookingDiscount,remark);
 | 
			
		||||
        result.put(DATA,roomTypeService.addRoomType(rt));
 | 
			
		||||
        return result;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 根据id
 | 
			
		||||
     * 删除房间类型
 | 
			
		||||
     * @param typeId
 | 
			
		||||
     * @return
 | 
			
		||||
     */
 | 
			
		||||
    @RequestMapping(method = RequestMethod.POST,value = "/del")
 | 
			
		||||
    public HashMap delType(int typeId){
 | 
			
		||||
        HashMap result = new HashMap();
 | 
			
		||||
        result.put(CODE,20000);
 | 
			
		||||
        result.put(DATA,roomTypeService.delById(typeId));
 | 
			
		||||
        return result;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public HashMap massDeletion(int[] typeId){
 | 
			
		||||
        HashMap result = new HashMap();
 | 
			
		||||
        result.put(CODE,20000);
 | 
			
		||||
        return result;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 更改房间类型
 | 
			
		||||
     * @param roomType
 | 
			
		||||
     * @param typeName
 | 
			
		||||
     * @param bookingPrice
 | 
			
		||||
     * @param bookingDiscount
 | 
			
		||||
     * @return
 | 
			
		||||
     */
 | 
			
		||||
    @RequestMapping(method = RequestMethod.POST,value = "/update")
 | 
			
		||||
    public HashMap updateType(int typeId,int roomType,String typeName,double bookingPrice,double bookingDiscount,String remark){
 | 
			
		||||
        HashMap result = new HashMap();
 | 
			
		||||
        result.put(CODE,20000);
 | 
			
		||||
        RoomType rt = new RoomType(roomType,typeName,bookingPrice,bookingDiscount,remark);
 | 
			
		||||
        rt.setTypeId(typeId);
 | 
			
		||||
        result.put(DATA,roomTypeService.updateRoomType(rt));
 | 
			
		||||
        return result;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 查询房间类型
 | 
			
		||||
     * @param typeId
 | 
			
		||||
     * @return
 | 
			
		||||
     */
 | 
			
		||||
    @RequestMapping(value = "/withId")
 | 
			
		||||
    public HashMap findByRoomType(int typeId){
 | 
			
		||||
        HashMap result = new HashMap();
 | 
			
		||||
        result.put(CODE,20000);
 | 
			
		||||
        result.put(DATA, roomTypeService.selectById(typeId));
 | 
			
		||||
        return result;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 查询所有房间类型
 | 
			
		||||
     * @return
 | 
			
		||||
     */
 | 
			
		||||
    @RequestMapping(value = "/all")
 | 
			
		||||
    public HashMap findAllRoomType(){
 | 
			
		||||
        HashMap result = new HashMap();
 | 
			
		||||
        result.put("code",20000);
 | 
			
		||||
        result.put("data",roomTypeService.findAllType());
 | 
			
		||||
        return result;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -1,98 +0,0 @@
 | 
			
		||||
package cn.mafangui.hotel.controller;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
import cn.mafangui.hotel.entity.User;
 | 
			
		||||
import cn.mafangui.hotel.service.UserService;
 | 
			
		||||
import cn.mafangui.hotel.utils.StaticString;
 | 
			
		||||
import org.springframework.beans.factory.annotation.Autowired;
 | 
			
		||||
import org.springframework.web.bind.annotation.RequestMapping;
 | 
			
		||||
import org.springframework.web.bind.annotation.RequestMethod;
 | 
			
		||||
import org.springframework.web.bind.annotation.RestController;
 | 
			
		||||
 | 
			
		||||
import java.util.HashMap;
 | 
			
		||||
import java.util.List;
 | 
			
		||||
 | 
			
		||||
@RestController
 | 
			
		||||
@RequestMapping(value = "/user")
 | 
			
		||||
public class UserController {
 | 
			
		||||
 | 
			
		||||
    @Autowired
 | 
			
		||||
    private UserService userService;
 | 
			
		||||
    /**
 | 
			
		||||
     * 更新资料
 | 
			
		||||
     * @param username
 | 
			
		||||
     * @param password
 | 
			
		||||
     * @param name
 | 
			
		||||
     * @param phone
 | 
			
		||||
     * @param email
 | 
			
		||||
     * @param address
 | 
			
		||||
     * @param idcard
 | 
			
		||||
     * @return
 | 
			
		||||
     */
 | 
			
		||||
    @RequestMapping(method = RequestMethod.POST,value = "/updateProfile")
 | 
			
		||||
    public int updateProfile(String username, String password, String name,String gender,
 | 
			
		||||
                              String phone, String email, String address, String idcard){
 | 
			
		||||
        User user = new User(username,password,name,gender,phone,email,address,idcard);
 | 
			
		||||
        return userService.updateProfile(user);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    public HashMap updatePassword(String username, String oldPassword, String newPassword){
 | 
			
		||||
        HashMap response = new HashMap();
 | 
			
		||||
        if (userService.login(username,oldPassword) == null){
 | 
			
		||||
            response.put(StaticString.CODE,200);
 | 
			
		||||
            response.put(StaticString.STATUS,"密码错误");
 | 
			
		||||
        }else {
 | 
			
		||||
            User user = new User();
 | 
			
		||||
            user.setPassword(newPassword);
 | 
			
		||||
            int result = userService.updateProfile(user);
 | 
			
		||||
            response.put(StaticString.DATA,result);
 | 
			
		||||
        }
 | 
			
		||||
        return response;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     *
 | 
			
		||||
     * @param username
 | 
			
		||||
     * @param password
 | 
			
		||||
     * @param name
 | 
			
		||||
     * @param gender
 | 
			
		||||
     * @param phone
 | 
			
		||||
     * @param email
 | 
			
		||||
     * @param address
 | 
			
		||||
     * @param idcard
 | 
			
		||||
     * @return
 | 
			
		||||
     */
 | 
			
		||||
    @RequestMapping(method = RequestMethod.POST, value = "/register")
 | 
			
		||||
    public HashMap userRegister(String username, String password, String name,String gender,
 | 
			
		||||
                                String phone, String email, String address, String idcard){
 | 
			
		||||
        HashMap response = new HashMap();
 | 
			
		||||
        User user = new User(username,password,name,phone,gender,email,address,idcard);
 | 
			
		||||
        response.put(StaticString.CODE,200);
 | 
			
		||||
        response.put(StaticString.DATA,userService.register(user));
 | 
			
		||||
        return response;
 | 
			
		||||
    }
 | 
			
		||||
    /**
 | 
			
		||||
     * 登录
 | 
			
		||||
     * @param username
 | 
			
		||||
     * @param password
 | 
			
		||||
     * @return
 | 
			
		||||
     */
 | 
			
		||||
    @RequestMapping(method = RequestMethod.POST, value = "/login")
 | 
			
		||||
    public HashMap userLogin(String username, String password){
 | 
			
		||||
        HashMap response = new HashMap();
 | 
			
		||||
        response.put(StaticString.CODE,200);
 | 
			
		||||
        response.put(StaticString.DATA,userService.login(username,password));
 | 
			
		||||
        return response;
 | 
			
		||||
    }
 | 
			
		||||
    /**
 | 
			
		||||
     * 查看用户资料
 | 
			
		||||
     * @param userName
 | 
			
		||||
     * @return
 | 
			
		||||
     */
 | 
			
		||||
    @RequestMapping(method = RequestMethod.POST, value = "/getProfile")
 | 
			
		||||
    public User getProfile(String userName){
 | 
			
		||||
        return userService.selectByUserName(userName);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@@ -1,101 +0,0 @@
 | 
			
		||||
package cn.mafangui.hotel.controller;
 | 
			
		||||
 | 
			
		||||
import cn.mafangui.hotel.entity.Worker;
 | 
			
		||||
import cn.mafangui.hotel.service.WorkerService;
 | 
			
		||||
import org.springframework.beans.factory.annotation.Autowired;
 | 
			
		||||
import org.springframework.web.bind.annotation.RequestMapping;
 | 
			
		||||
import org.springframework.web.bind.annotation.RequestMethod;
 | 
			
		||||
import org.springframework.web.bind.annotation.RestController;
 | 
			
		||||
 | 
			
		||||
import java.util.HashMap;
 | 
			
		||||
import java.util.List;
 | 
			
		||||
 | 
			
		||||
@RestController
 | 
			
		||||
@RequestMapping(value = "/worker")
 | 
			
		||||
public class WorkerController {
 | 
			
		||||
    private final String CODE = "code";
 | 
			
		||||
    private final String DATA = "data";
 | 
			
		||||
    @Autowired
 | 
			
		||||
    private WorkerService workerService;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 操作员登录
 | 
			
		||||
     * @param userName
 | 
			
		||||
     * @param password
 | 
			
		||||
     * @return
 | 
			
		||||
     */
 | 
			
		||||
    @RequestMapping(method = RequestMethod.POST,value = "/login")
 | 
			
		||||
    public int login(String userName,String password){
 | 
			
		||||
        Worker worker = new Worker(userName,password);
 | 
			
		||||
        if (workerService.login(worker) !=null ){
 | 
			
		||||
            return 1;
 | 
			
		||||
        }else {
 | 
			
		||||
            return 0;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 添加操作员
 | 
			
		||||
     * @param userName
 | 
			
		||||
     * @param password
 | 
			
		||||
     * @param workerName
 | 
			
		||||
     * @param phone
 | 
			
		||||
     * @param email
 | 
			
		||||
     * @param address
 | 
			
		||||
     * @return
 | 
			
		||||
     */
 | 
			
		||||
    @RequestMapping(method = RequestMethod.POST,value = "/add")
 | 
			
		||||
    public int addWorker(String userName,String password,String workerName,String phone,String email,String address){
 | 
			
		||||
        Worker worker = new Worker(userName,password,workerName,phone,email,address);
 | 
			
		||||
        return workerService.addWorker(worker);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 删除操作员
 | 
			
		||||
     * @param userName
 | 
			
		||||
     * @return
 | 
			
		||||
     */
 | 
			
		||||
    @RequestMapping(method = RequestMethod.POST,value = "/del")
 | 
			
		||||
    public int delWorker(String userName){
 | 
			
		||||
        return workerService.delWorker(userName);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 更改操作员信息
 | 
			
		||||
     * @param userName
 | 
			
		||||
     * @param password
 | 
			
		||||
     * @param workerName
 | 
			
		||||
     * @param phone
 | 
			
		||||
     * @param email
 | 
			
		||||
     * @param address
 | 
			
		||||
     * @return
 | 
			
		||||
     */
 | 
			
		||||
    @RequestMapping(method = RequestMethod.POST,value = "/update")
 | 
			
		||||
    public int updateWorker(String userName,String password,String workerName,String phone,String email,String address){
 | 
			
		||||
        Worker worker = new Worker(userName,password,workerName,phone,email,address);
 | 
			
		||||
        return workerService.updateWorker(worker);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 查找操作员
 | 
			
		||||
     * @param userName
 | 
			
		||||
     * @return
 | 
			
		||||
     */
 | 
			
		||||
    @RequestMapping(value = "/query")
 | 
			
		||||
    public Worker queryWorker(String userName){
 | 
			
		||||
        return workerService.selectWorker(userName);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 查找所有操作员
 | 
			
		||||
     * @return
 | 
			
		||||
     */
 | 
			
		||||
    @RequestMapping(value = "/all")
 | 
			
		||||
    public HashMap findAllWorkers(){
 | 
			
		||||
        HashMap result = new HashMap();
 | 
			
		||||
        result.put(CODE,20000);
 | 
			
		||||
        result.put(DATA,workerService.findAllWorker());
 | 
			
		||||
        return result;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@@ -1,66 +0,0 @@
 | 
			
		||||
package cn.mafangui.hotel.entity;
 | 
			
		||||
 | 
			
		||||
import java.util.Date;
 | 
			
		||||
 | 
			
		||||
public class Admin {
 | 
			
		||||
    private Integer adminId;
 | 
			
		||||
 | 
			
		||||
    private String userName;
 | 
			
		||||
 | 
			
		||||
    private String password;
 | 
			
		||||
 | 
			
		||||
    private Date createTime;
 | 
			
		||||
 | 
			
		||||
    private Date updateTime;
 | 
			
		||||
 | 
			
		||||
    public Integer getAdminId() {
 | 
			
		||||
        return adminId;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setAdminId(Integer adminId) {
 | 
			
		||||
        this.adminId = adminId;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public String getUserName() {
 | 
			
		||||
        return userName;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setUserName(String userName) {
 | 
			
		||||
        this.userName = userName == null ? null : userName.trim();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public String getPassword() {
 | 
			
		||||
        return password;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setPassword(String password) {
 | 
			
		||||
        this.password = password == null ? null : password.trim();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public Date getCreateTime() {
 | 
			
		||||
        return createTime;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setCreateTime(Date createTime) {
 | 
			
		||||
        this.createTime = createTime;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public Date getUpdateTime() {
 | 
			
		||||
        return updateTime;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setUpdateTime(Date updateTime) {
 | 
			
		||||
        this.updateTime = updateTime;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public String toString() {
 | 
			
		||||
        return "Admin{" +
 | 
			
		||||
                "adminId=" + adminId +
 | 
			
		||||
                ", userName='" + userName + '\'' +
 | 
			
		||||
                ", password='" + password + '\'' +
 | 
			
		||||
                ", createTime=" + createTime +
 | 
			
		||||
                ", updateTime=" + updateTime +
 | 
			
		||||
                '}';
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -25,20 +25,6 @@ public class User {
 | 
			
		||||
 | 
			
		||||
    private Date updateTime;
 | 
			
		||||
 | 
			
		||||
    public User() {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public User(String username, String password, String name, String gender, String phone, String email, String address, String idcard) {
 | 
			
		||||
        this.username = username;
 | 
			
		||||
        this.password = password;
 | 
			
		||||
        this.name = name;
 | 
			
		||||
        this.gender = gender;
 | 
			
		||||
        this.phone = phone;
 | 
			
		||||
        this.email = email;
 | 
			
		||||
        this.address = address;
 | 
			
		||||
        this.idcard = idcard;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public Integer getUserId() {
 | 
			
		||||
        return userId;
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -122,4 +122,22 @@ public class Worker {
 | 
			
		||||
    public void setUpdateTime(Date updateTime) {
 | 
			
		||||
        this.updateTime = updateTime;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public String toString() {
 | 
			
		||||
        return "Worker{" +
 | 
			
		||||
                "workerId=" + workerId +
 | 
			
		||||
                ", role='" + role + '\'' +
 | 
			
		||||
                ", username='" + username + '\'' +
 | 
			
		||||
                ", password='" + password + '\'' +
 | 
			
		||||
                ", name='" + name + '\'' +
 | 
			
		||||
                ", gender='" + gender + '\'' +
 | 
			
		||||
                ", phone='" + phone + '\'' +
 | 
			
		||||
                ", department=" + department +
 | 
			
		||||
                ", email='" + email + '\'' +
 | 
			
		||||
                ", address='" + address + '\'' +
 | 
			
		||||
                ", createTime=" + createTime +
 | 
			
		||||
                ", updateTime=" + updateTime +
 | 
			
		||||
                '}';
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -1,21 +0,0 @@
 | 
			
		||||
package cn.mafangui.hotel.mapper;
 | 
			
		||||
 | 
			
		||||
import cn.mafangui.hotel.entity.Admin;
 | 
			
		||||
import jdk.internal.dynalink.linker.LinkerServices;
 | 
			
		||||
import org.springframework.stereotype.Component;
 | 
			
		||||
 | 
			
		||||
import java.util.List;
 | 
			
		||||
 | 
			
		||||
@Component
 | 
			
		||||
public interface AdminMapper {
 | 
			
		||||
    int deleteByPrimaryKey(Integer adminId);
 | 
			
		||||
    int insert(Admin record);
 | 
			
		||||
    int insertSelective(Admin record);
 | 
			
		||||
    Admin selectByPrimaryKey(Integer adminId);
 | 
			
		||||
    int updateByPrimaryKeySelective(Admin record);
 | 
			
		||||
    int updateByPrimaryKey(Admin record);
 | 
			
		||||
    Admin selectByUserName(String userName);
 | 
			
		||||
    Admin selectByUserNameAndPassword(Admin record);
 | 
			
		||||
    int updateByUserNameSelective(Admin record);
 | 
			
		||||
    List<Admin> findAll();
 | 
			
		||||
}
 | 
			
		||||
@@ -1,11 +1,8 @@
 | 
			
		||||
package cn.mafangui.hotel.mapper;
 | 
			
		||||
 | 
			
		||||
import cn.mafangui.hotel.entity.User;
 | 
			
		||||
import org.apache.ibatis.annotations.Param;
 | 
			
		||||
import org.springframework.stereotype.Component;
 | 
			
		||||
 | 
			
		||||
import java.util.List;
 | 
			
		||||
 | 
			
		||||
@Component
 | 
			
		||||
public interface UserMapper {
 | 
			
		||||
    int deleteByPrimaryKey(Integer userId);
 | 
			
		||||
@@ -19,12 +16,4 @@ public interface UserMapper {
 | 
			
		||||
    int updateByPrimaryKeySelective(User record);
 | 
			
		||||
 | 
			
		||||
    int updateByPrimaryKey(User record);
 | 
			
		||||
 | 
			
		||||
    int count();
 | 
			
		||||
 | 
			
		||||
    List<User> selectAll();
 | 
			
		||||
 | 
			
		||||
    User selectByUsernameAndPassword(@Param("username") String username, @Param("password") String password);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@@ -1,7 +1,12 @@
 | 
			
		||||
package cn.mafangui.hotel.mapper;
 | 
			
		||||
 | 
			
		||||
import cn.mafangui.hotel.entity.Worker;
 | 
			
		||||
import org.apache.ibatis.annotations.Param;
 | 
			
		||||
import org.springframework.stereotype.Component;
 | 
			
		||||
 | 
			
		||||
import java.util.List;
 | 
			
		||||
 | 
			
		||||
@Component
 | 
			
		||||
public interface WorkerMapper {
 | 
			
		||||
    int deleteByPrimaryKey(Integer workerId);
 | 
			
		||||
 | 
			
		||||
@@ -14,4 +19,10 @@ public interface WorkerMapper {
 | 
			
		||||
    int updateByPrimaryKeySelective(Worker record);
 | 
			
		||||
 | 
			
		||||
    int updateByPrimaryKey(Worker record);
 | 
			
		||||
 | 
			
		||||
    Worker selectByUsernameAndPassword(@Param("username") String username, @Param("password") String password);
 | 
			
		||||
 | 
			
		||||
    List<Worker> selectByRole(String role);
 | 
			
		||||
 | 
			
		||||
    List<Worker> selectAll();
 | 
			
		||||
}
 | 
			
		||||
@@ -1,14 +0,0 @@
 | 
			
		||||
package cn.mafangui.hotel.service;
 | 
			
		||||
 | 
			
		||||
import cn.mafangui.hotel.entity.Admin;
 | 
			
		||||
 | 
			
		||||
import java.util.List;
 | 
			
		||||
 | 
			
		||||
public interface AdminService {
 | 
			
		||||
    Admin login(Admin admin);
 | 
			
		||||
    int register(Admin admin);
 | 
			
		||||
    Admin selectByUserName(String userName);
 | 
			
		||||
    int updateProfile(Admin admin);
 | 
			
		||||
    int updatePassword(Admin admin,String newPassword);
 | 
			
		||||
    List<Admin> findAll();
 | 
			
		||||
}
 | 
			
		||||
@@ -15,10 +15,10 @@ public interface UserService {
 | 
			
		||||
 | 
			
		||||
    User selectByUserName(String userName);
 | 
			
		||||
 | 
			
		||||
    int count();
 | 
			
		||||
 | 
			
		||||
    List<User> findAll();
 | 
			
		||||
 | 
			
		||||
    int updateProfile(User user);
 | 
			
		||||
//    int count();
 | 
			
		||||
//
 | 
			
		||||
//    List<User> findAll();
 | 
			
		||||
//
 | 
			
		||||
//    int updateProfile(User user);
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -5,13 +5,11 @@ import cn.mafangui.hotel.entity.Worker;
 | 
			
		||||
import java.util.List;
 | 
			
		||||
 | 
			
		||||
public interface WorkerService {
 | 
			
		||||
 | 
			
		||||
    int addWorker(Worker worker);
 | 
			
		||||
    int delWorker(String userName);
 | 
			
		||||
    int updateWorker(Worker worker);
 | 
			
		||||
    Worker selectWorker(String userName);
 | 
			
		||||
    List<Worker> findAllWorker();
 | 
			
		||||
    Worker login(Worker worker);
 | 
			
		||||
    int logout(Worker worker);
 | 
			
		||||
 | 
			
		||||
    int insert(Worker worker);
 | 
			
		||||
    int delete(int workerId);
 | 
			
		||||
    int updateById(Worker worker);
 | 
			
		||||
    Worker selectById(int workerId);
 | 
			
		||||
    List<Worker> findAll();
 | 
			
		||||
    List<Worker> selectByRole(String role);
 | 
			
		||||
    Worker login(String username,String password);
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,90 +0,0 @@
 | 
			
		||||
package cn.mafangui.hotel.service.impl;
 | 
			
		||||
 | 
			
		||||
import cn.mafangui.hotel.entity.Admin;
 | 
			
		||||
import cn.mafangui.hotel.mapper.AdminMapper;
 | 
			
		||||
import cn.mafangui.hotel.service.AdminService;
 | 
			
		||||
import org.springframework.beans.factory.annotation.Autowired;
 | 
			
		||||
import org.springframework.stereotype.Service;
 | 
			
		||||
 | 
			
		||||
import java.util.List;
 | 
			
		||||
 | 
			
		||||
@Service
 | 
			
		||||
public class AdminServiceImpl implements AdminService {
 | 
			
		||||
    @Autowired
 | 
			
		||||
    private AdminMapper adminMapper;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 登录
 | 
			
		||||
     * @param admin
 | 
			
		||||
     * @return
 | 
			
		||||
     */
 | 
			
		||||
    @Override
 | 
			
		||||
    public Admin login(Admin admin) {
 | 
			
		||||
        return adminMapper.selectByUserNameAndPassword(admin);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 注册
 | 
			
		||||
     * @param admin
 | 
			
		||||
     * @return
 | 
			
		||||
     */
 | 
			
		||||
    @Override
 | 
			
		||||
    public int register(Admin admin) {
 | 
			
		||||
        return adminMapper.insertSelective(admin);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 根据username查找
 | 
			
		||||
     * @param userName
 | 
			
		||||
     * @return
 | 
			
		||||
     */
 | 
			
		||||
    @Override
 | 
			
		||||
    public Admin selectByUserName(String userName) {
 | 
			
		||||
        Admin result = adminMapper.selectByUserName(userName);
 | 
			
		||||
        if (result != null){
 | 
			
		||||
            result.setPassword(null);
 | 
			
		||||
        }
 | 
			
		||||
        return result;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 更新信息
 | 
			
		||||
     * @param admin
 | 
			
		||||
     * @return
 | 
			
		||||
     */
 | 
			
		||||
    @Override
 | 
			
		||||
    public int updateProfile(Admin admin) {
 | 
			
		||||
        return adminMapper.updateByUserNameSelective(admin);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 更改密码
 | 
			
		||||
     * @param admin
 | 
			
		||||
     * @param newPassword
 | 
			
		||||
     * @return
 | 
			
		||||
     */
 | 
			
		||||
    @Override
 | 
			
		||||
    public int updatePassword(Admin admin, String newPassword) {
 | 
			
		||||
        int result = 0;
 | 
			
		||||
        if(adminMapper.selectByUserNameAndPassword(admin) != null){
 | 
			
		||||
            admin.setPassword(newPassword);
 | 
			
		||||
            result = adminMapper.updateByUserNameSelective(admin);
 | 
			
		||||
        }
 | 
			
		||||
        return result;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 列出所有管理员
 | 
			
		||||
     * @return
 | 
			
		||||
     */
 | 
			
		||||
    @Override
 | 
			
		||||
    public List<Admin> findAll() {
 | 
			
		||||
        List<Admin> result;
 | 
			
		||||
        result = adminMapper.findAll();
 | 
			
		||||
        for (Admin admin : result) {
 | 
			
		||||
            admin.setPassword(null);
 | 
			
		||||
        }
 | 
			
		||||
        return result;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -1,45 +0,0 @@
 | 
			
		||||
package cn.mafangui.hotel.service.impl;
 | 
			
		||||
 | 
			
		||||
import cn.mafangui.hotel.entity.Hotel;
 | 
			
		||||
import cn.mafangui.hotel.mapper.HotelMapper;
 | 
			
		||||
import cn.mafangui.hotel.service.HotelService;
 | 
			
		||||
import org.springframework.beans.factory.annotation.Autowired;
 | 
			
		||||
import org.springframework.stereotype.Service;
 | 
			
		||||
 | 
			
		||||
import java.util.List;
 | 
			
		||||
 | 
			
		||||
@Service
 | 
			
		||||
public class HotelServiceImpl implements HotelService {
 | 
			
		||||
    @Autowired
 | 
			
		||||
    private HotelMapper hotelMapper;
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public int addHotel(Hotel hotel) {
 | 
			
		||||
        return hotelMapper.insertSelective(hotel);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public int deleteHotel(int hotelId) {
 | 
			
		||||
        return hotelMapper.deleteByPrimaryKey(hotelId);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public int updateHotel(Hotel hotel) {
 | 
			
		||||
        return hotelMapper.updateByPrimaryKeySelective(hotel);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public Hotel selectHotelByName(String hotelName) {
 | 
			
		||||
        return hotelMapper.selectByName(hotelName);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public Hotel selectHotelById(int hotelId) {
 | 
			
		||||
        return hotelMapper.selectByPrimaryKey(hotelId);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public List<Hotel> findAllHotel() {
 | 
			
		||||
        return hotelMapper.selectAll();
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -1,60 +0,0 @@
 | 
			
		||||
package cn.mafangui.hotel.service.impl;
 | 
			
		||||
 | 
			
		||||
import cn.mafangui.hotel.entity.Room;
 | 
			
		||||
import cn.mafangui.hotel.mapper.RoomMapper;
 | 
			
		||||
import cn.mafangui.hotel.service.RoomService;
 | 
			
		||||
import org.springframework.beans.factory.annotation.Autowired;
 | 
			
		||||
import org.springframework.stereotype.Service;
 | 
			
		||||
 | 
			
		||||
import java.util.List;
 | 
			
		||||
 | 
			
		||||
@Service
 | 
			
		||||
public class RoomServiceImpl implements RoomService {
 | 
			
		||||
    @Autowired
 | 
			
		||||
    private RoomMapper roomMapper;
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public int addRoom(Room room) {
 | 
			
		||||
        return roomMapper.insert(room);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public int deleteRoom(int roomId) {
 | 
			
		||||
        return roomMapper.deleteByPrimaryKey(roomId);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public int deleteRoom(String roomNumber) {
 | 
			
		||||
        return roomMapper.deleteByRoomNumber(roomNumber);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public int updateRoom(Room room) {
 | 
			
		||||
        return roomMapper.updateByPrimaryKeySelective(room);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public Room findById(int roomId) {
 | 
			
		||||
        return roomMapper.selectByPrimaryKey(roomId);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public Room findByNumber(String roomNumber) {
 | 
			
		||||
        return roomMapper.selectByRoomNumber(roomNumber);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public List<Room> findByStatus(String status) {
 | 
			
		||||
        return roomMapper.selectByStatus(status);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public List<Room> findByType(String typeName) {
 | 
			
		||||
        return roomMapper.selectByType(typeName);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public List<Room> findAll() {
 | 
			
		||||
        return roomMapper.selectAllRoom();
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -1,50 +0,0 @@
 | 
			
		||||
package cn.mafangui.hotel.service.impl;
 | 
			
		||||
 | 
			
		||||
import cn.mafangui.hotel.entity.RoomType;
 | 
			
		||||
import cn.mafangui.hotel.mapper.RoomTypeMapper;
 | 
			
		||||
import cn.mafangui.hotel.service.RoomTypeService;
 | 
			
		||||
import org.springframework.beans.factory.annotation.Autowired;
 | 
			
		||||
import org.springframework.stereotype.Service;
 | 
			
		||||
 | 
			
		||||
import java.util.List;
 | 
			
		||||
 | 
			
		||||
@Service
 | 
			
		||||
public class RoomTypeServiceImpl implements RoomTypeService {
 | 
			
		||||
    @Autowired
 | 
			
		||||
    private RoomTypeMapper roomTypeMapper;
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public int addRoomType(RoomType roomType) {
 | 
			
		||||
        return roomTypeMapper.insertSelective(roomType);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public int delRoomType(RoomType roomType) {
 | 
			
		||||
        return roomTypeMapper.deleteByRoomType(roomType);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public int delById(int typeId) {
 | 
			
		||||
        return roomTypeMapper.deleteByPrimaryKey(typeId);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public int updateRoomType(RoomType roomType) {
 | 
			
		||||
        return roomTypeMapper.updateByPrimaryKeySelective(roomType);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public RoomType selectByName(RoomType roomType) {
 | 
			
		||||
        return roomTypeMapper.selectByRoomType(roomType);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public RoomType selectById(int typeId) {
 | 
			
		||||
        return roomTypeMapper.selectByPrimaryKey(typeId);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public List<RoomType> findAllType() {
 | 
			
		||||
        return roomTypeMapper.findAll();
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -1,54 +0,0 @@
 | 
			
		||||
package cn.mafangui.hotel.service.impl;
 | 
			
		||||
 | 
			
		||||
import cn.mafangui.hotel.entity.User;
 | 
			
		||||
 | 
			
		||||
import cn.mafangui.hotel.mapper.UserMapper;
 | 
			
		||||
import cn.mafangui.hotel.service.UserService;
 | 
			
		||||
import org.springframework.beans.factory.annotation.Autowired;
 | 
			
		||||
import org.springframework.stereotype.Service;
 | 
			
		||||
 | 
			
		||||
import java.util.List;
 | 
			
		||||
 | 
			
		||||
@Service
 | 
			
		||||
public class UserServiceImpl implements UserService {
 | 
			
		||||
 | 
			
		||||
    @Autowired
 | 
			
		||||
    private UserMapper userMapper;
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public User selectById(int id) {
 | 
			
		||||
        return userMapper.selectByPrimaryKey(id);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public int register(User user) {
 | 
			
		||||
        return userMapper.insertSelective(user);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public User login(String username, String password) {
 | 
			
		||||
        return userMapper.selectByUsernameAndPassword(username,password);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public User selectByUserName(String userName) {
 | 
			
		||||
        return null;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public int count() {
 | 
			
		||||
        return userMapper.count();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public List<User> findAll() {
 | 
			
		||||
        return userMapper.selectAll();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public int updateProfile(User user) {
 | 
			
		||||
        return userMapper.updateByPrimaryKeySelective(user);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@@ -15,37 +15,37 @@ public class WorkerServiceImpl implements WorkerService {
 | 
			
		||||
    private WorkerMapper workerMapper;
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public int addWorker(Worker worker) {
 | 
			
		||||
    public int insert(Worker worker) {
 | 
			
		||||
        return workerMapper.insertSelective(worker);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public int delWorker(String userName) {
 | 
			
		||||
        return workerMapper.deleteByUserName(userName);
 | 
			
		||||
    public int delete(int workerId) {
 | 
			
		||||
        return workerMapper.deleteByPrimaryKey(workerId);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public int updateWorker(Worker worker) {
 | 
			
		||||
        return workerMapper.updateByUserNameSelective(worker);
 | 
			
		||||
    public int updateById(Worker worker) {
 | 
			
		||||
        return workerMapper.updateByPrimaryKeySelective(worker);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public Worker selectWorker(String userName) {
 | 
			
		||||
        return workerMapper.selectByUserName(userName);
 | 
			
		||||
    public Worker selectById(int workerId) {
 | 
			
		||||
        return workerMapper.selectByPrimaryKey(workerId);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public List<Worker> findAllWorker() {
 | 
			
		||||
        return workerMapper.findAll();
 | 
			
		||||
    public List<Worker> findAll() {
 | 
			
		||||
        return workerMapper.selectAll();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public Worker login(Worker worker) {
 | 
			
		||||
        return workerMapper.selectByUserNameAndPassword(worker);
 | 
			
		||||
    public List<Worker> selectByRole(String role) {
 | 
			
		||||
        return workerMapper.selectByRole(role);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public int logout(Worker worker) {
 | 
			
		||||
        return 0;
 | 
			
		||||
    public Worker login(String username, String password) {
 | 
			
		||||
        return workerMapper.selectByUsernameAndPassword(username,password);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -5,4 +5,9 @@ public class StaticString {
 | 
			
		||||
    public static final String STATUS = "status";
 | 
			
		||||
    public static final String DATA = "data";
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 工作人员角色
 | 
			
		||||
     */
 | 
			
		||||
    public static final String ADMIN = "admin";
 | 
			
		||||
    public static final String OPERATOR = "operator";
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user