|
@@ -11,20 +11,27 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
|
import org.springframework.web.bind.annotation.ResponseBody;
|
|
import org.springframework.web.bind.annotation.ResponseBody;
|
|
|
|
|
|
/**
|
|
/**
|
|
- * @date 2023/8/11
|
|
|
|
|
|
+ * 实现用户服务
|
|
*/
|
|
*/
|
|
@Service
|
|
@Service
|
|
public class UserServiceImpl implements UserService {
|
|
public class UserServiceImpl implements UserService {
|
|
@Autowired
|
|
@Autowired
|
|
private UserMapper userMapper;
|
|
private UserMapper userMapper;
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 用户登录服务
|
|
|
|
+ * @param username 用户名
|
|
|
|
+ * @param password 密码
|
|
|
|
+ * @return 登录结果
|
|
|
|
+ */
|
|
@Override
|
|
@Override
|
|
public SaResult login(String username, String password) {
|
|
public SaResult login(String username, String password) {
|
|
User user = userMapper.selectUserByUsernameAndPassword(username, password);
|
|
User user = userMapper.selectUserByUsernameAndPassword(username, password);
|
|
if (user != null) {
|
|
if (user != null) {
|
|
StpUtil.login(user.getId());
|
|
StpUtil.login(user.getId());
|
|
- return SaResult.ok("success");
|
|
|
|
|
|
+ return SaResult.ok("success").set("error_message", "success");
|
|
}
|
|
}
|
|
- return SaResult.error("error");
|
|
|
|
|
|
+ return SaResult.ok("failed").set("error_message", "用户名或密码错误");
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|