You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
hospital/src/controller/LoginController.java

50 lines
1.5 KiB

package com.example.hosdata.controller;
import com.example.hosdata.pojo.RegisterRecord;
import com.example.hosdata.pojo.User;
import com.example.hosdata.result.Result;
import com.example.hosdata.service.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.util.HtmlUtils;
import java.util.List;
@Controller
public class LoginController {
@Autowired
UserService userService;
@CrossOrigin
@PostMapping(value = "/api/login")
@ResponseBody
public Result login(@RequestBody User requestUser) {
String username = requestUser.getUsername();
username = HtmlUtils.htmlEscape(username);
String id = requestUser.getId();
id = HtmlUtils.htmlEscape(id);
String realname = requestUser.getRealname();
realname = HtmlUtils.htmlEscape(realname);
User user = userService.getall(id,username, requestUser.getPassword(),realname);
//String id=requestUser.getId();
RegisterService.username = username;
DocyzService.ghname = realname;
DocyzService.doctorname = realname;
ShopService.myzh = username;
InService.userna = username;
if (null == user) {
return new Result(400);
} else if(id.equals("医务人员")){
return new Result(100);
} else if(id.equals("管理员")){
return new Result(300);
}else {
return new Result(200);
}
}
}