feat: 增加socket通知并调整数据结构
parent
91ddd6483c
commit
6d0d1e1277
@ -1,57 +1,36 @@
|
|||||||
package com.shxy.xymanager_admin.controller;
|
package com.shxy.xymanager_admin.controller;
|
||||||
|
|
||||||
import com.shxy.xymanager_common.annotation.Log;
|
|
||||||
|
import com.shxy.xymanager_common.base.BaseController;
|
||||||
|
import com.shxy.xymanager_common.base.ResponseReult;
|
||||||
|
import com.shxy.xymanager_framework.socket.WebSocketServer;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
import io.swagger.annotations.ApiResponse;
|
|
||||||
import io.swagger.annotations.ApiResponses;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.stereotype.Controller;
|
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
|
||||||
@Api(value = "测试接口", tags = "测试接口tags")
|
@RestController
|
||||||
@Controller
|
@Api(tags = {"测试接口"})
|
||||||
|
@RequestMapping("test")
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class TestController {
|
public class TestController extends BaseController {
|
||||||
|
|
||||||
@ApiOperation(value = "测试", notes = "测试notes", httpMethod = "POST")
|
@Resource
|
||||||
@ApiResponses({@ApiResponse(code = 200, message = "请求成功"), @ApiResponse(code = 400, message = "请求参数没填好"), @ApiResponse(code = 404, message = "请求路径没有或页面跳转路径不对")})
|
WebSocketServer webSocketServer;
|
||||||
@RequestMapping("/user/login")
|
|
||||||
@Log(title = "测试", type = "查询")
|
|
||||||
public String gettest() {
|
|
||||||
log.info("有一个沙雕点了链接");
|
|
||||||
return "/api/index2";
|
|
||||||
}
|
|
||||||
|
|
||||||
@GetMapping("/user/logins")
|
@GetMapping("sendMsg")
|
||||||
@Log(title = "测试", type = "查询")
|
@ApiOperation("发送消息")
|
||||||
public String hhtest() {
|
public void sendMsg(String msg) {
|
||||||
log.info("有一个沙雕点了链接");
|
webSocketServer.sendNotice(msg);
|
||||||
return "/api/index2.html";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// @ApiOperation(value = "登录", notes = "登录", httpMethod = "POST")
|
@GetMapping("test")
|
||||||
//// @ApiResponses({@ApiResponse(code = 200, message = "请求成功"), @ApiResponse(code = 400, message = "请求参数没填好"), @ApiResponse(code = 404, message = "请求路径没有或页面跳转路径不对")})
|
@ApiOperation("test")
|
||||||
// @RequestMapping("/login")
|
public ResponseReult<String> test() {
|
||||||
// @Log(title = "登录", type = "查询")
|
return ResponseReult.success("OK");
|
||||||
// public String login(String username, String password) {
|
}
|
||||||
// //获取主题对象
|
|
||||||
// Subject subject = SecurityUtils.getSubject();
|
|
||||||
// try {
|
|
||||||
// subject.login(new UsernamePasswordToken(username,password));
|
|
||||||
// System.out.println("登录成功!!!");
|
|
||||||
// return "登录成功";
|
|
||||||
// } catch (UnknownAccountException e) {
|
|
||||||
// e.printStackTrace();
|
|
||||||
// System.out.println("用户错误!!!");
|
|
||||||
// } catch (IncorrectCredentialsException e) {
|
|
||||||
// System.out.println("密码错误!!!");
|
|
||||||
// }
|
|
||||||
// return "登录失败";
|
|
||||||
// }
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,9 @@
|
|||||||
|
package com.shxy.xymanager_common.model;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class MessageModel {
|
||||||
|
int type;
|
||||||
|
String content;
|
||||||
|
}
|
Loading…
Reference in New Issue