Merge remote-tracking branch 'origin/main'

This commit is contained in:
biexiande 2024-11-21 10:24:03 +08:00
commit 7030656019
28 changed files with 838 additions and 360 deletions

View File

@ -176,7 +176,11 @@
<artifactId>okhttps-fastjson2</artifactId> <artifactId>okhttps-fastjson2</artifactId>
<version>4.0.3</version> <version>4.0.3</version>
</dependency> </dependency>
<dependency>
<groupId>com.banboocloud.Codec </groupId>
<artifactId>banboocloud_Codec</artifactId>
<version>0.0.1</version>
</dependency>
<!-- Spring框架基本的核心工具--> <!-- Spring框架基本的核心工具-->
<dependency> <dependency>
<groupId>org.springframework</groupId> <groupId>org.springframework</groupId>
@ -223,8 +227,41 @@
<version>3.2.1</version> <version>3.2.1</version>
</dependency> </dependency>
<dependency>
<groupId>com.banboocloud.Codec </groupId>
<artifactId>banboocloud_Codec</artifactId>
<version>0.0.1</version>
</dependency>
<dependency>
<groupId>org.jodd</groupId>
<artifactId>jodd-http</artifactId>
<version>6.3.0</version>
</dependency>
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-all</artifactId>
<version>5.8.15</version>
</dependency>
<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcprov-ext-jdk15on</artifactId>
<version>1.69</version>
</dependency>
<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcpkix-jdk15on</artifactId>
<version>1.69</version>
</dependency>
<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcprov-jdk15on</artifactId>
<version>1.69</version>
</dependency>
<!-- JAX-WS API --> <!-- JAX-WS API -->
<dependency> <dependency>
<groupId>javax.xml.ws</groupId> <groupId>javax.xml.ws</groupId>

View File

@ -2,6 +2,10 @@ package com.ruoyi.common.OAuth;
import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import com.ruoyi.common.constant.Constants;
import com.ruoyi.framework.security.service.SysLoginService;
import com.ruoyi.framework.web.domain.AjaxResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestMethod;
@ -15,6 +19,7 @@ import java.net.HttpURLConnection;
import java.net.MalformedURLException; import java.net.MalformedURLException;
import java.net.URL; import java.net.URL;
import java.net.URLEncoder; import java.net.URLEncoder;
import java.util.ArrayList;
/** /**
* Author:Zhenggang * Author:Zhenggang
@ -29,23 +34,24 @@ public class OauthDemo {
//认证地址 //认证地址
public static final String BASE_URL = "http://utuum.sd-gold.com:7021/idp/oauth2"; public static final String BASE_URL = "http://utuum.sd-gold.com:7021/idp/oauth2";
//应用注册id //应用注册id
public static final String CLIENT_ID = "ERM"; public static final String CLIENT_ID = "hfxyjwzxjc";
//应用注册key //应用注册key
public static final String CLIENT_SECRET = "ermsecret"; public static final String CLIENT_SECRET = "2c9ecb1b6b1f47d297abb6ffa7ede060";
//获取access_token的url //获取access_token的url
public static final String GET_ACCESS_TOKEN_URL = BASE_URL + "/getToken"; public static final String GET_ACCESS_TOKEN_URL = BASE_URL + "/getToken";
//获取用户信息的url //获取用户信息的url
public static final String GET_USERINFO_URL = BASE_URL + "/getUserInfo?client_id=" + CLIENT_ID + "&access_token="; public static final String GET_USERINFO_URL = BASE_URL + "/getUserInfo?client_id=" + CLIENT_ID + "&access_token=";
@Autowired
private SysLoginService loginService;
/** /**
* 访问ip:port/root/redirectToAuth时拼接并且重定向到 * 访问ip:port/root/redirectToAuth时拼接并且重定向到
* http://utuum.sd-gold.com:7021/idp/oauth2/authorize?redirect_uri=ip:port/root/getAccountName&state=sso&client_id=ECD&response_type=code * http://utuum.sd-gold.com:7021/idp/oauth2/authorize?redirect_uri=ip:port/root/getAccountName&state=sso&client_id=ECD&response_type=code
*/ */
@RequestMapping("/redirectToAuth") @RequestMapping("/redirectToAuth")
public void reToAuth(HttpServletRequest request, HttpServletResponse response) { public void reToAuth(HttpServletRequest request, HttpServletResponse response) {
String url = request.getRequestURL().toString().replaceAll("/redirectToAuth", "/getAccountName"); String url = request.getRequestURL().toString().replaceAll("/prod-api/redirectToAuth", "/prod-api/getAccountName");
String re_url = BASE_URL + "/authorize?redirect_uri=" + url + "&state=sso&client_id=" + CLIENT_ID + "&response_type=code"; String re_url = BASE_URL + "/authorize?redirect_uri=" + url + "&state=sso&client_id=" + CLIENT_ID + "&response_type=code";
try { try {
response.sendRedirect(re_url); response.sendRedirect(re_url);
@ -61,7 +67,7 @@ public class OauthDemo {
*/ */
@ResponseBody @ResponseBody
@RequestMapping(value = "/getAccountName", method = RequestMethod.GET) @RequestMapping(value = "/getAccountName", method = RequestMethod.GET)
public String getAccountName(@RequestParam(name = "code") String code) { public AjaxResult getAccountName(@RequestParam(name = "code") String code) {
String accessTokenParam = null; String accessTokenParam = null;
System.out.println("1).authorize code is" + code); System.out.println("1).authorize code is" + code);
try { try {
@ -88,12 +94,18 @@ public class OauthDemo {
} }
System.out.println("3).userInfo is :" + userInfo); System.out.println("3).userInfo is :" + userInfo);
String acc = getValueFromJson(userInfo, "spRoleList"); String acc = getValueFromJson(userInfo, "spRoleList");
String userName = getValueFromJson(userInfo, "userName");
String passWord = getValueFromJson(userInfo, "passWord");
if (acc == null || acc.equals("")) { if (acc == null || acc.equals("")) {
System.out.println("cannot get acc"); System.out.println("cannot get acc");
return null; return null;
} }
System.out.println("the acc is :" + acc); System.out.println("the acc is :" + acc);
return "the acc is : " + acc; String s = loginService.loginNoCaptcha(userName, passWord, null);
AjaxResult success = AjaxResult.success();
success.put(Constants.TOKEN,s);
success.put("mgs","登录成功");
return success;
} }

View File

@ -6,10 +6,12 @@ import cn.zhxu.okhttps.HttpResult;
import cn.zhxu.okhttps.OkHttps; import cn.zhxu.okhttps.OkHttps;
import com.alibaba.fastjson2.JSONArray; import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject; import com.alibaba.fastjson2.JSONObject;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.ruoyi.common.task.forest.MyTaskClient; import com.ruoyi.common.task.forest.MyTaskClient;
import com.ruoyi.common.utils.http.HttpUtils; import com.ruoyi.common.utils.http.HttpUtils;
import com.ruoyi.common.utils.sign.Md5Utils; import com.ruoyi.common.utils.sign.Md5Utils;
import com.ruoyi.project.oil.domain.monitor.ThDevice; import com.ruoyi.project.oil.domain.monitor.ThDevice;
import com.ruoyi.project.oil.mapper.ThDeviceMapper;
import com.ruoyi.project.outside.service.OutSideService; import com.ruoyi.project.outside.service.OutSideService;
import org.apache.http.client.HttpClient; import org.apache.http.client.HttpClient;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -18,6 +20,7 @@ import org.springframework.stereotype.Component;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List;
@Component @Component
public class EquTask { public class EquTask {
@ -28,10 +31,12 @@ public class EquTask {
private MyTaskClient myClient; private MyTaskClient myClient;
@Autowired @Autowired
private OutSideService outSideService; private OutSideService outSideService;
@Autowired
private ThDeviceMapper thDeviceMapper;
/** /**
* 港口原有设备对接 * 港口原有设备对接
*/ */
@Scheduled(fixedRate = 10000) // @Scheduled(fixedRate = 10000)
public void equ(){ public void equ(){
String hash = "16EA8A305FB58BE0730DD67F04F022F4"; String hash = "16EA8A305FB58BE0730DD67F04F022F4";
@ -42,11 +47,9 @@ public class EquTask {
JSONObject tokenByJson = httpResult.getBody().toBean(JSONObject.class); JSONObject tokenByJson = httpResult.getBody().toBean(JSONObject.class);
JSONObject dataByJson = tokenByJson.getJSONObject("data"); JSONObject dataByJson = tokenByJson.getJSONObject("data");
String token = dataByJson.getString("token"); String token = dataByJson.getString("token");
ArrayList<ThDevice> equLists = new ArrayList<>(); //查询 数据库 获取 港口以前的 设备信息
ThDevice thDevice = new ThDevice(); ThDevice thDevice = new ThDevice();
thDevice.setSn("e75153fd53d243289057ffec33f36cb9"); thDevice.setDeptId(5l);
thDevice.setName("油气回收voc监测设备3#"); List<ThDevice> equLists = thDeviceMapper.selectDeviceList(thDevice);
equLists.add(thDevice);
equLists.forEach(e->{ equLists.forEach(e->{
HashMap<String, Object> map = new HashMap<>(); HashMap<String, Object> map = new HashMap<>();
@ -60,7 +63,12 @@ public class EquTask {
JSONObject vocByJson = result.getBody().toBean(JSONObject.class); JSONObject vocByJson = result.getBody().toBean(JSONObject.class);
JSONObject vocDataByJson = vocByJson.getJSONObject("data"); JSONObject vocDataByJson = vocByJson.getJSONObject("data");
JSONArray vocByArray = vocDataByJson.getJSONArray("array"); JSONArray vocByArray = vocDataByJson.getJSONArray("array");
System.out.println(vocByArray.toJSONString()); System.out.println(vocByArray.toString());
try {
Integer integer = outSideService.insertOldDeviceData(vocByArray.toJSONString());
} catch (JsonProcessingException jsonProcessingException) {
jsonProcessingException.printStackTrace();
}
}); });
} }

View File

@ -1,5 +1,6 @@
package com.ruoyi.common.wsdl; package com.ruoyi.common.wsdl;
import cn.hutool.core.lang.Console;
import cn.hutool.http.webservice.SoapClient; import cn.hutool.http.webservice.SoapClient;
@ -12,24 +13,24 @@ import javax.xml.soap.SOAPMessage;
*/ */
public class TestWsdl { public class TestWsdl {
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
// 创建SoapClient实例 wsdl协议请求地址:http://xxx.cn/services/GanSuInterface (去掉?wsdl)
SoapClient client = SoapClient.create("http://10.171.19.193:8080/dxpt/ws/shortMessageWs")
// 设置方法名和命名空间命名空间url:http://webservice.xxx.xxx 方法名:getSydwJsonList
// tns 命名空间targetNamespace没有命名空间时直接写方法名即可
.setMethod("tns:returnMassages", "http://service.cxf.com")
// 设置参数最后的false参数表示参数不加命名空间的前缀web
.setParam("in0", "afe9cff39173ff8901917a54c90e448d", false);
//获取SOAPMessage实例此步作用是输出请求的XML参数实际开发并不需要 // 新建客户端
SOAPMessage message = client.getMessage(); SoapClient client = SoapClient.create("http://www.webxml.com.cn/WebServices/IpAddressSearchWebService.asmx")
System.out.println(client.getMsgStr(true)); // 设置要请求的方法此接口方法前缀为web传入对应的命名空间
.setMethod("web:getCountryCityByIp", "http://WebXml.com.cn/")
// 设置参数此处自动添加方法的前缀web
.setParam("phone", "18437762352")
.setParam("msg", "1112121")
.setParam("dwdm", "SGJT-山港集团");
// 发送请求参数true表示返回一个格式化后的XML内容
// 返回内容为XML字符串可以配合XmlUtil解析这个响应
Console.log(client.send(true));
// 发送请求true表示输出的结果格式化处理
String send = client.send(true);
// Document document = DocumentHelper.parseText(send);
// Element root = document.getRootElement();
// String value = root.getStringValue();
System.out.println(send);
// System.out.println(value);
} }
} }

View File

@ -111,7 +111,8 @@ public class SecurityConfig
.authorizeHttpRequests((requests) -> { .authorizeHttpRequests((requests) -> {
permitAllUrl.getUrls().forEach(url -> requests.antMatchers(url).permitAll()); permitAllUrl.getUrls().forEach(url -> requests.antMatchers(url).permitAll());
// 对于登录login 注册register 验证码captchaImage 允许匿名访问 // 对于登录login 注册register 验证码captchaImage 允许匿名访问
requests.antMatchers("/login", "/register", "/captchaImage","/outside/*").permitAll() requests.antMatchers("/login","/bbc/**",
"/register", "/captchaImage","/outside/*","/redirectToAuth","/getAccountName").permitAll()
// 静态资源可匿名访问 // 静态资源可匿名访问
.antMatchers(HttpMethod.GET, "/", "/*.html", "/**/*.html", "/**/*.css", "/**/*.js", "/profile/**").permitAll() .antMatchers(HttpMethod.GET, "/", "/*.html", "/**/*.html", "/**/*.css", "/**/*.js", "/profile/**").permitAll()
.antMatchers("/swagger-ui.html", "/swagger-resources/**", "/webjars/**", "/*/api-docs", "/druid/**").permitAll() .antMatchers("/swagger-ui.html", "/swagger-resources/**", "/webjars/**", "/*/api-docs", "/druid/**").permitAll()

View File

@ -100,6 +100,48 @@ public class SysLoginService
return tokenService.createToken(loginUser); return tokenService.createToken(loginUser);
} }
/**
* 无需验证码登录
* 重写login方法将验证码模块去掉
* @param username
* @param password
* @param uuid
* @return
*/
public String loginNoCaptcha(String username, String password, String uuid)
{
// 用户验证
Authentication authentication = null;
try
{
UsernamePasswordAuthenticationToken authenticationToken = new UsernamePasswordAuthenticationToken(username, password);
AuthenticationContextHolder.setContext(authenticationToken);
// 该方法会去调用UserDetailsServiceImpl.loadUserByUsername
authentication = authenticationManager.authenticate(authenticationToken);
}
catch (Exception e)
{
if (e instanceof BadCredentialsException)
{
AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_FAIL, MessageUtils.message("user.password.not.match")));
throw new UserPasswordNotMatchException();
}
else
{
AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_FAIL, e.getMessage()));
throw new ServiceException(e.getMessage());
}
}
AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_SUCCESS, MessageUtils.message("user.login.success")));
LoginUser loginUser = (LoginUser) authentication.getPrincipal();
recordLoginInfo(loginUser.getUserId());
// 生成token
return tokenService.createToken(loginUser);
}
/** /**
* 校验验证码 * 校验验证码
* *

View File

@ -1,268 +1,331 @@
//package com.ruoyi.project.system.controller; package com.ruoyi.project.system.controller;
//
//
//import com.alibaba.fastjson2.JSON; import com.alibaba.fastjson2.JSON;
//import com.alibaba.fastjson2.JSONObject; import com.alibaba.fastjson2.JSONObject;
//import com.banboocloud.Codec.BamboocloudFacade; import com.banboocloud.Codec.BamboocloudFacade;
//import com.ruoyi.common.utils.reflect.ReflectUtils; import com.ruoyi.common.utils.reflect.ReflectUtils;
//import com.ruoyi.framework.web.controller.BaseController; import com.ruoyi.framework.web.controller.BaseController;
//import com.ruoyi.project.system.domain.SysUser; import com.ruoyi.project.system.domain.SysUser;
//import com.ruoyi.project.system.service.ISysDeptService; import com.ruoyi.project.system.service.ISysDeptService;
//import com.ruoyi.project.system.service.ISysPostService; import com.ruoyi.project.system.service.ISysPostService;
//import com.ruoyi.project.system.service.ISysRoleService; import com.ruoyi.project.system.service.ISysRoleService;
//import com.ruoyi.project.system.service.ISysUserService; import com.ruoyi.project.system.service.ISysUserService;
//import com.ruoyi.project.system.utils.BamboocloudUtils; import com.ruoyi.project.system.utils.BamboocloudUtils;
//
//import org.slf4j.Logger; import org.slf4j.Logger;
//import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
//import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.web.bind.annotation.PostMapping; import org.springframework.security.core.userdetails.User;
//import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.security.core.userdetails.UserDetails;
//import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.PostMapping;
//import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RequestMapping;
// import org.springframework.web.bind.annotation.ResponseBody;
//import javax.servlet.ServletException; import org.springframework.web.bind.annotation.RestController;
//import javax.servlet.http.HttpServletRequest;
//import javax.servlet.http.HttpServletResponse; import javax.servlet.ServletException;
//import java.io.BufferedReader; import javax.servlet.http.HttpServletRequest;
//import java.io.IOException; import javax.servlet.http.HttpServletResponse;
//import java.io.PrintWriter; import java.io.BufferedReader;
//import java.util.*; import java.io.IOException;
// import java.io.PrintWriter;
///** import java.util.*;
// * swagger 用户测试方法
// * 加密认证 /**
// * @author ruoyi * swagger 用户测试方法
// */ * 加密认证
// * @author ruoyi
//@RestController */
//@RequestMapping("/bbc/user")
//public class BbcController extends BaseController { @RestController
// @RequestMapping("/bbc/user")
// private String bimRequestId; public class BbcController extends BaseController {
//
// private static Logger logger = LoggerFactory.getLogger(ReflectUtils.class); private String bimRequestId;
//
// private static Logger logger = LoggerFactory.getLogger(ReflectUtils.class);
// @Autowired
// private ISysUserService userService;
// @Autowired
// @Autowired private ISysUserService userService;
// private ISysRoleService roleService;
// @Autowired
// @Autowired private ISysRoleService roleService;
// private ISysDeptService deptService;
// @Autowired
// @Autowired private ISysDeptService deptService;
// private ISysPostService postService;
// @Autowired
//// @ApiOperation("测试") private ISysPostService postService;
// @RequestMapping()
// public JSONObject bbcUser() { // @ApiOperation("测试")
// @RequestMapping()
// JSONObject jsonObject = new JSONObject(); public JSONObject bbcUser() {
// jsonObject.put("resultCode", "0");
// jsonObject.put("message", "success"); JSONObject jsonObject = new JSONObject();
// return jsonObject; jsonObject.put("resultCode", "0");
// jsonObject.put("message", "success");
// } return jsonObject;
//
//// @ApiOperation("对象属性字段查询") }
// @PostMapping("/schemaService")
// public String SchemaService(HttpServletRequest req, HttpServletResponse resp) { // @ApiOperation("对象属性字段查询")
// @PostMapping("/SchemaService")
// JSONObject jsonObject = new JSONObject(); public String SchemaService(HttpServletRequest req, HttpServletResponse resp) {
//
// // StringBuilder sb = stringBuilder(req); JSONObject jsonObject = new JSONObject();
// String bodyparam= BamboocloudUtils.getRequestBody(req);
// logger.info("json--param-->" + bodyparam);
// // String bodyparam = sb.toString();
// //解密json字符传
// bodyparam = BamboocloudUtils.getPlaintext(bodyparam, "123456", "AES");
// logger.info("json--param-->" + bodyparam);
// Map<String, Object> reqmap = (Map<String, Object>) JSON.parse(bodyparam);
// //验证签名
// if (BamboocloudUtils.verify(reqmap, "MD5").booleanValue()) {
// String username = (String) reqmap.get("bimRemoteUser");
// String password = (String) reqmap.get("bimRemotePwd");
// //判断接口中的调用名及调用密码是否正确
// if (BamboocloudUtils.checkUsernamePassword(username, password)) {
//// //添加返回的对象及属性字段名
//// MapJson mapJson = new MapJson();
//// Map<String, List<Map<String, Object>>> map = new HashMap<>();
//// jsonObject.put("account", mapJson.accountList());
//// jsonObject.put("organization", mapJson.organizationList());
//// jsonObject.put("role", mapJson.roleList());
//// jsonObject.put("post", mapJson.postList());
//// jsonObject.put("dict", mapJson.dictDataList());
//// jsonObject.put("bimRequestId", reqmap.get("bimRequestId"));
// String mapJs = JSON.toJSONString(jsonObject);
// logger.info(jsonObject.toJSONString());
// //返回加密的json字符串
// mapJs = BamboocloudFacade.encrypt(mapJs, "123456", "AES");
// //jsonObject.put(map);
// //<Object> values = jsonObject.values();
// return mapJs;
// }
// }
// jsonObject.put("bimRequestId", bimRequestId);
// jsonObject.put("resultCode", "505");
// jsonObject.put("message", "连接失败,请检查连接器配置的参数");
// logger.info(jsonObject.toJSONString());
// String mapJs = JSON.toJSONString(jsonObject);
// //返回加密的json字符串
// mapJs = BamboocloudFacade.encrypt(mapJs, "123456", "AES");
// return mapJs;
// }
//
//// @ApiOperation("新增用户")
//// @ApiImplicitParam(name = "user", value = "新增用户信息", dataType = "User")
// @PostMapping("/UserCreateService")
// @ResponseBody
// public String userCreateService(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
//
// Map<String, Object> schema = new HashMap<String, Object>();
//
// JSONObject jsonObject = new JSONObject();
//
// StringBuilder sb = stringBuilder(req); // StringBuilder sb = stringBuilder(req);
// //修改多值的属性格式方便转换 String bodyparam= BamboocloudUtils.getRequestBody(req);
logger.info("json--param-->" + bodyparam);
// String bodyparam = sb.toString(); // String bodyparam = sb.toString();
// bodyparam = BamboocloudUtils.getPlaintext(bodyparam, "123456", "AES"); //解密json字符传
// String p = bodyparam; bodyparam = BamboocloudUtils.getPlaintext(bodyparam, "123456", "AES");
// String z = "[\""; logger.info("json--param-->" + bodyparam);
// String y = "\"]"; Map<String, Object> reqmap = (Map<String, Object>) JSON.parse(bodyparam);
// bodyparam.indexOf(z); //验证签名
// bodyparam.indexOf(y); if (BamboocloudUtils.verify(reqmap, "MD5").booleanValue()) {
// while (bodyparam.contains(z)) { String username = (String) reqmap.get("bimRemoteUser");
// p = bodyparam.substring(bodyparam.indexOf(z), bodyparam.indexOf(y) + 2).replace(z, "\"").replace(y, "\"").replace("\",\"", ","); String password = (String) reqmap.get("bimRemotePwd");
// bodyparam = bodyparam.substring(0, bodyparam.indexOf(z)) + p + bodyparam.substring(bodyparam.indexOf(y) + 2, bodyparam.length()); //判断接口中的调用名及调用密码是否正确
// } if (BamboocloudUtils.checkUsernamePassword(username, password)) {
// logger.info("json--param-->" + bodyparam); // //添加返回的对象及属性字段名
// Map<String, Object> reqmap = (Map<String, Object>) JSON.parse(bodyparam); // MapJson mapJson = new MapJson();
// String username = (String) reqmap.get("bimRemoteUser"); Map<String, List<Map<String, Object>>> map = new HashMap<>();
// String password = (String) reqmap.get("bimRemotePwd"); ArrayList<HashMap<String,Object>> accountList = new ArrayList<>();
// HashMap<String, Object> nameMap = new HashMap<>();
// if (BamboocloudUtils.checkUsernamePassword(username, password)) { nameMap.put("multivalued",false);
// /** nameMap.put("name","userName");
// * 新增用户 nameMap.put("required",true);
// */ nameMap.put("type","String");
// //获取用户创建所需的参数 HashMap<String, Object> passMap = new HashMap<>();
//// User user = createUpdateUser(reqmap); passMap.put("multivalued",false);
// SysUser user = new SysUser(); passMap.put("name","password");
// //用户创建 passMap.put("required",true);
// userService.insertUser(user); passMap.put("type","String");
// //获取返回给IAM连接器的唯一标识用于后续该条数据的更新修改删除 HashMap<String, Object> mobileMap = new HashMap<>();
// String uid = user.getUserId() + ""; mobileMap.put("multivalued",false);
// if (uid != null) { mobileMap.put("name","mobile");
// schema.put("uid", uid); mobileMap.put("required",true);
// schema.put("bimRequestId", reqmap.get("bimRequestId")); mobileMap.put("type","String");
// schema.put("resultCode", "0"); HashMap<String, Object> statusMap = new HashMap<>();
// schema.put("message", "success"); statusMap.put("multivalued",false);
// } else { statusMap.put("name","status");
// schema.put("bimRequestId", reqmap.get("bimRequestId")); statusMap.put("required",true);
// schema.put("resultCode", "500"); statusMap.put("type","String");
// schema.put("message", "账号创建失败"); HashMap<String, Object> nickNameMap = new HashMap<>();
// } nickNameMap.put("multivalued",false);
// String mapJson = JSON.toJSONString(schema); nickNameMap.put("name","nickName");
// mapJson = BamboocloudFacade.encrypt(mapJson, "123456", "AES"); nickNameMap.put("required",true);
// return mapJson; nickNameMap.put("type","String");
// } accountList.add(nameMap);
// schema.put("bimRequestId", reqmap.get("bimRequestId")); accountList.add(passMap);
// schema.put("resultCode", "500"); accountList.add(mobileMap);
// schema.put("message", "账号创建失败,请检查连接器配置的参数"); accountList.add(statusMap);
// String mapJson = JSON.toJSONString(schema); accountList.add(nickNameMap);
// //返回加密的json字符串 jsonObject.put("account", accountList);
// mapJson = BamboocloudFacade.encrypt(mapJson, "123456", "AES"); // jsonObject.put("organization", mapJson.organizationList());
// return mapJson; // jsonObject.put("role", mapJson.roleList());
// } // jsonObject.put("post", mapJson.postList());
// // jsonObject.put("dict", mapJson.dictDataList());
// jsonObject.put("bimRequestId", reqmap.get("bimRequestId"));
//// @ApiOperation("修改用户") String mapJs = JSON.toJSONString(jsonObject);
//// @ApiImplicitParam(name = "user", value = "修改用户信息", dataType = "User") logger.info(jsonObject.toJSONString());
// @PostMapping("/UserUpdateService") //返回加密的json字符串
// @ResponseBody mapJs = BamboocloudFacade.encrypt(mapJs, "123456", "AES");
// public String userUpdateService(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { //jsonObject.put(map);
// //<Object> values = jsonObject.values();
// Map<String, Object> schema = new HashMap<String, Object>(); return mapJs;
// }
// JSONObject jsonObject = new JSONObject(); }
// jsonObject.put("bimRequestId", bimRequestId);
// StringBuilder sb = stringBuilder(req); jsonObject.put("resultCode", "505");
// jsonObject.put("message", "连接失败,请检查连接器配置的参数");
// String bodyparam = sb.toString(); logger.info(jsonObject.toJSONString());
// String mapJs = JSON.toJSONString(jsonObject);
// bodyparam = BamboocloudUtils.getPlaintext(bodyparam, "123456", "AES"); //返回加密的json字符串
// //修改多值的属性格式方便转换 mapJs = BamboocloudFacade.encrypt(mapJs, "123456", "AES");
// String p = bodyparam; return mapJs;
// String bdp = bodyparam; }
// String z = "[\"";
// String y = "\"]"; // @ApiOperation("新增用户")
// bodyparam.indexOf(z); // @ApiImplicitParam(name = "user", value = "新增用户信息", dataType = "User")
// bodyparam.indexOf(y); @PostMapping("/UserCreateService")
// while (bodyparam.contains(z)) { @ResponseBody
// p = bodyparam.substring(bodyparam.indexOf(z), bodyparam.indexOf(y) + 2).replace(z, "\"").replace(y, "\"").replace("\",\"", ","); public String userCreateService(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
// bodyparam = bodyparam.substring(0, bodyparam.indexOf(z)) + p + bodyparam.substring(bodyparam.indexOf(y) + 2, bodyparam.length());
// } Map<String, Object> schema = new HashMap<String, Object>();
// logger.info("json--param-->" + bodyparam);
// Map<String, Object> reqmap = (Map<String, Object>) JSON.parse(bodyparam); JSONObject jsonObject = new JSONObject();
// String username = (String) reqmap.get("bimRemoteUser");
// String password = (String) reqmap.get("bimRemotePwd"); StringBuilder sb = stringBuilder(req);
// if (BamboocloudUtils.checkUsernamePassword(username, password)) { logger.info("json--bodyStr-->"+sb);
// SysUser user = new SysUser(); //修改多值的属性格式方便转换
// //获取用于更新的参数 String bodyparam = sb.toString();
//// user = createUpdateUser(reqmap); bodyparam = BamboocloudUtils.getPlaintext(bodyparam, "123456", "AES");
// //获取用于更新的唯一标识 String p = bodyparam;
// user.setUserId(Long.valueOf(String.valueOf(reqmap.get("bimUid")))); String z = "[\"";
// //更新用户 String y = "\"]";
// userService.updateUser(user); bodyparam.indexOf(z);
// schema.put("bimRequestId", reqmap.get("bimRequestId")); bodyparam.indexOf(y);
// schema.put("resultCode", "0"); while (bodyparam.contains(z)) {
// schema.put("message", "success"); p = bodyparam.substring(bodyparam.indexOf(z), bodyparam.indexOf(y) + 2).replace(z, "\"").replace(y, "\"").replace("\",\"", ",");
// String mapJson = JSON.toJSONString(schema); bodyparam = bodyparam.substring(0, bodyparam.indexOf(z)) + p + bodyparam.substring(bodyparam.indexOf(y) + 2, bodyparam.length());
// mapJson = BamboocloudFacade.encrypt(mapJson, "123456", "AES"); }
// logger.info("response----->" + schema); logger.info("json--param-->" + bodyparam);
// return mapJson; Map<String, Object> reqmap = (Map<String, Object>) JSON.parse(bodyparam);
// } String username = (String) reqmap.get("bimRemoteUser");
// schema.put("bimRequestId", reqmap.get("bimRequestId")); String password = (String) reqmap.get("bimRemotePwd");
// schema.put("resultCode", "500");
// schema.put("message", "账号更新失败,请检查连接器配置的参数"); if (BamboocloudUtils.checkUsernamePassword(username, password)) {
// String mapJson = JSON.toJSONString(schema); /**
// mapJson = BamboocloudFacade.encrypt(mapJson, "123456", "AES"); * 新增用户
// logger.info("response----->" + schema); */
// return mapJson; //获取用户创建所需的参数
// } // User user = createUpdateUser(reqmap);
// String userName = (String) reqmap.get("userName");
// String pass = (String) reqmap.get("password");
// public StringBuilder stringBuilder(HttpServletRequest req) { String mobile = (String) reqmap.get("mobile");
// BufferedReader br = null; String status = (String) reqmap.get("status");
// StringBuilder sb = new StringBuilder(); String nickName = (String) reqmap.get("nickName");
// String str = "";
// try { logger.info("reqmap---------->"+reqmap);
// br = req.getReader(); SysUser user = new SysUser();
// while ((str = br.readLine()) != null) { user.setUserName(userName);
// sb.append(str); user.setPassword(pass);
// } user.setPhonenumber(mobile);
// br.close(); user.setStatus(status);
// } catch (IOException e) { user.setNickName(nickName);
// e.printStackTrace(); Random random = new Random();
// if (br != null) int min = 8000;
// try { int max = 9000;
// br.close(); int randomNumber = random.nextInt(max - min + 1) + min;
// } catch (IOException eo) { user.setUserId(Long.valueOf(randomNumber));
// eo.printStackTrace(); //用户创建
// } userService.registerUser(user);
// } finally { //获取返回给IAM连接器的唯一标识用于后续该条数据的更新修改删除
// if (br != null) { String uid = user.getUserId() + "";
// try { if (uid != null) {
// br.close(); schema.put("uid", uid);
// } catch (IOException e) { schema.put("bimRequestId", reqmap.get("bimRequestId"));
// e.printStackTrace(); schema.put("resultCode", "0");
// } schema.put("message", "success");
// } } else {
// } schema.put("bimRequestId", reqmap.get("bimRequestId"));
// return sb; schema.put("resultCode", "500");
// } schema.put("message", "账号创建失败");
// }
//} String mapJson = JSON.toJSONString(schema);
// mapJson = BamboocloudFacade.encrypt(mapJson, "123456", "AES");
return mapJson;
}
schema.put("bimRequestId", reqmap.get("bimRequestId"));
schema.put("resultCode", "500");
schema.put("message", "账号创建失败,请检查连接器配置的参数");
String mapJson = JSON.toJSONString(schema);
//返回加密的json字符串
mapJson = BamboocloudFacade.encrypt(mapJson, "123456", "AES");
return mapJson;
}
// @ApiOperation("修改用户")
// @ApiImplicitParam(name = "user", value = "修改用户信息", dataType = "User")
@PostMapping("/UserUpdateService")
@ResponseBody
public String userUpdateService(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
Map<String, Object> schema = new HashMap<String, Object>();
JSONObject jsonObject = new JSONObject();
StringBuilder sb = stringBuilder(req);
String bodyparam = sb.toString();
logger.info("json--bodyStr-->"+sb);
bodyparam = BamboocloudUtils.getPlaintext(bodyparam, "123456", "AES");
//修改多值的属性格式方便转换
String p = bodyparam;
String bdp = bodyparam;
String z = "[\"";
String y = "\"]";
bodyparam.indexOf(z);
bodyparam.indexOf(y);
while (bodyparam.contains(z)) {
p = bodyparam.substring(bodyparam.indexOf(z), bodyparam.indexOf(y) + 2).replace(z, "\"").replace(y, "\"").replace("\",\"", ",");
bodyparam = bodyparam.substring(0, bodyparam.indexOf(z)) + p + bodyparam.substring(bodyparam.indexOf(y) + 2, bodyparam.length());
}
logger.info("json--param-->" + bodyparam);
Map<String, Object> reqmap = (Map<String, Object>) JSON.parse(bodyparam);
String username = (String) reqmap.get("bimRemoteUser");
String password = (String) reqmap.get("bimRemotePwd");
if (BamboocloudUtils.checkUsernamePassword(username, password)) {
//获取用于更新的参数
// user = createUpdateUser(reqmap);
String userName = (String) reqmap.get("userName");
String pass = (String) reqmap.get("password");
String mobile = (String) reqmap.get("mobile");
String status = (String) reqmap.get("status");
String nickName = (String) reqmap.get("nickName");
logger.info("reqmap---------->"+reqmap);
SysUser user = new SysUser();
user.setUserName(userName);
user.setPassword(pass);
user.setPhonenumber(mobile);
user.setStatus(status);
user.setNickName(nickName);
//获取用于更新的唯一标识
user.setUserId(Long.valueOf(String.valueOf(reqmap.get("bimUid"))));
//更新用户
userService.updateUserStatus(user);
schema.put("bimRequestId", reqmap.get("bimRequestId"));
schema.put("resultCode", "0");
schema.put("message", "success");
String mapJson = JSON.toJSONString(schema);
mapJson = BamboocloudFacade.encrypt(mapJson, "123456", "AES");
logger.info("response----->" + schema);
return mapJson;
}
schema.put("bimRequestId", reqmap.get("bimRequestId"));
schema.put("resultCode", "500");
schema.put("message", "账号更新失败,请检查连接器配置的参数");
String mapJson = JSON.toJSONString(schema);
mapJson = BamboocloudFacade.encrypt(mapJson, "123456", "AES");
logger.info("response----->" + schema);
return mapJson;
}
public StringBuilder stringBuilder(HttpServletRequest req) {
BufferedReader br = null;
StringBuilder sb = new StringBuilder();
String str = "";
try {
br = req.getReader();
while ((str = br.readLine()) != null) {
sb.append(str);
}
br.close();
} catch (IOException e) {
e.printStackTrace();
if (br != null)
try {
br.close();
} catch (IOException eo) {
eo.printStackTrace();
}
} finally {
if (br != null) {
try {
br.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
return sb;
}
}

View File

@ -7,7 +7,7 @@ ruoyi:
# 版权年份 # 版权年份
copyrightYear: 2024 copyrightYear: 2024
# 文件路径 示例( Windows配置D:/ruoyi/uploadPathLinux配置 /home/ruoyi/uploadPath # 文件路径 示例( Windows配置D:/ruoyi/uploadPathLinux配置 /home/ruoyi/uploadPath
profile: D:/ruoyi/uploadPath profile: /home/admin
# 获取ip地址开关 # 获取ip地址开关
addressEnabled: false addressEnabled: false
# 验证码类型 math 数字计算 char 字符验证 # 验证码类型 math 数字计算 char 字符验证
@ -16,7 +16,7 @@ ruoyi:
file: file:
domain: domain:
# path: /home/file/upload # path: /home/file/upload
path: D:/ruoyi/uploadPath path: /home/admin
prefix: /statics prefix: /statics
# 开发环境配置 # 开发环境配置
server: server:

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<configuration> <configuration>
<!-- 日志存放路径 --> <!-- 日志存放路径 -->
<property name="log.path" value="/home/ruoyi/logs" /> <property name="log.path" value="/home/admin/logs" />
<!-- 日志输出格式 --> <!-- 日志输出格式 -->
<property name="log.pattern" value="%d{HH:mm:ss.SSS} [%thread] %-5level %logger{20} - [%method,%line] - %msg%n" /> <property name="log.pattern" value="%d{HH:mm:ss.SSS} [%thread] %-5level %logger{20} - [%method,%line] - %msg%n" />

View File

@ -145,10 +145,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
select user_id, email from sys_user where email = #{email} and del_flag = '0' and rownum <![CDATA[ <= ]]> 1 select user_id, email from sys_user where email = #{email} and del_flag = '0' and rownum <![CDATA[ <= ]]> 1
</select> </select>
<insert id="insertUser" parameterType="SysUser" useGeneratedKeys="true" keyProperty="userId"> <!-- <selectKey keyProperty="userId" order="BEFORE" resultType="Long">-->
<selectKey keyProperty="userId" order="BEFORE" resultType="Long"> <!-- select seq_sys_user.nextval as userId from DUAL-->
select seq_sys_user.nextval as userId from DUAL <!-- </selectKey>-->
</selectKey> <!-- <insert id="insertUser" parameterType="SysUser" useGeneratedKeys="true" keyProperty="userId">-->
<insert id="insertUser" parameterType="SysUser" >
insert into sys_user( insert into sys_user(
<if test="userId != null and userId != 0">user_id,</if> <if test="userId != null and userId != 0">user_id,</if>
<if test="deptId != null and deptId != 0">dept_id,</if> <if test="deptId != null and deptId != 0">dept_id,</if>

File diff suppressed because one or more lines are too long

View File

@ -58,3 +58,11 @@ export function getCodeImg() {
timeout: 20000 timeout: 20000
}) })
} }
export function getAccountName(data) {
return request({
url: '/getAccountName',
method: 'get',
params: data
})
}

View File

@ -8,7 +8,7 @@ import { isRelogin } from '@/utils/request'
NProgress.configure({ showSpinner: false }) NProgress.configure({ showSpinner: false })
const whiteList = ['/login', '/register'] const whiteList = ['/login', '/register', '/LoginSso']
router.beforeEach((to, from, next) => { router.beforeEach((to, from, next) => {
NProgress.start() NProgress.start()

View File

@ -46,6 +46,11 @@ export const constantRoutes = [
component: () => import('@/views/login'), component: () => import('@/views/login'),
hidden: true hidden: true
}, },
{
path: '/LoginSso',
component: () => import('@/views/login-sso'),
hidden: true
},
{ {
path: '/register', path: '/register',
component: () => import('@/views/register'), component: () => import('@/views/register'),

View File

@ -1,4 +1,4 @@
import { login, logout, getInfo } from '@/api/login' import { login, logout, getInfo, getAccountName } from '@/api/login'
import { getToken, setToken, removeToken } from '@/utils/auth' import { getToken, setToken, removeToken } from '@/utils/auth'
import {encrypt, decrypt} from '@/utils/secret' import {encrypt, decrypt} from '@/utils/secret'
const user = { const user = {
@ -95,6 +95,22 @@ const user = {
removeToken() removeToken()
resolve() resolve()
}) })
},
LoginSso({ commit }, code) {
return new Promise((resolve, reject) => {
getAccountName({"code": code}).then((res) => {
if (res.code == 200) {
setToken(res.token)
commit('SET_TOKEN', res.token)
resolve()
} else {
reject(res)
}
}).catch(error => {
reject(error)
})
})
} }
} }
} }

View File

@ -84,7 +84,7 @@
</el-table> </el-table>
<!-- <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize" <!-- <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
@pagination="handleQuery" /> --> @pagination="getList" /> -->
<el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange" <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange"
:current-page="queryParams.pageNum" :page-sizes="[10, 20, 30, 50]" :page-size="queryParams.pageSize" :current-page="queryParams.pageNum" :page-sizes="[10, 20, 30, 50]" :page-size="queryParams.pageSize"
layout="total, sizes, prev, pager, next, jumper" :total="total"> layout="total, sizes, prev, pager, next, jumper" :total="total">

View File

@ -94,7 +94,7 @@
</el-table> </el-table>
<pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize" <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
@pagination="handleQuery" /> @pagination="getList" />
<!--发送通知--> <!--发送通知-->
<send-msg :deviceInfo="deviceInfo" v-if="isOpenMsg" :isOpenMsg="isOpenMsg" @closeMsg="closeMsg"></send-msg> <send-msg :deviceInfo="deviceInfo" v-if="isOpenMsg" :isOpenMsg="isOpenMsg" @closeMsg="closeMsg"></send-msg>
<!--处理报警--> <!--处理报警-->

View File

@ -94,7 +94,7 @@
</el-table> </el-table>
<pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize" <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
@pagination="handleQuery" /> @pagination="getList" />
<!--发送通知--> <!--发送通知-->
<send-msg :deviceInfo="deviceInfo" v-if="isOpenMsg" :isOpenMsg="isOpenMsg" @closeMsg="closeMsg"></send-msg> <send-msg :deviceInfo="deviceInfo" v-if="isOpenMsg" :isOpenMsg="isOpenMsg" @closeMsg="closeMsg"></send-msg>
<!--处理报警--> <!--处理报警-->

View File

@ -94,7 +94,7 @@
</el-table> </el-table>
<pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize" <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
@pagination="handleQuery" /> @pagination="getList" />
<!--发送通知--> <!--发送通知-->
<send-msg :deviceInfo="deviceInfo" v-if="isOpenMsg" :isOpenMsg="isOpenMsg" @closeMsg="closeMsg"></send-msg> <send-msg :deviceInfo="deviceInfo" v-if="isOpenMsg" :isOpenMsg="isOpenMsg" @closeMsg="closeMsg"></send-msg>
<!--处理报警--> <!--处理报警-->

View File

@ -62,7 +62,7 @@
</el-table> </el-table>
<pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize" <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
@pagination="handleQuery" /> @pagination="getList" />
</div> </div>
</template> </template>

View File

@ -57,7 +57,7 @@
</el-table> </el-table>
<pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize" <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
@pagination="handleQuery" /> @pagination="getList" />
</div> </div>
</template> </template>

View File

@ -60,7 +60,7 @@
</el-table> </el-table>
<pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize" <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
@pagination="handleQuery" /> @pagination="getList" />
</div> </div>
</template> </template>

View File

@ -60,7 +60,7 @@
</el-table> </el-table>
<pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize" <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
@pagination="handleQuery" /> @pagination="getList" />
</div> </div>
</template> </template>

View File

@ -0,0 +1,43 @@
<template>
<div></div>
</template>
<script>
export default {
name: "LoginSso",
data() {
return {
loginRules: {},
//
captchaOnOff: true,
//
register: false,
//
redirect: undefined
};
},
created() {
//
this.loginSso();
},
methods: {
loginSso() {
//code
const code = this.$route.query.code;
console.log("code="+code)
//
if(code==''||code==undefined||code==null){
//code
} else {
this.$store.dispatch("LoginSso", code).then(() => {
this.$router.push({ path: this.redirect || "/" }).catch(()=>{});
}).catch((error) => {
console.error(error);
this.$message.error("单点登录失败");
this.$router.push({ path: "/login" }).catch(()=>{});
});
}
},
}
};
</script>

View File

@ -60,7 +60,7 @@
</el-table> </el-table>
<pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize" <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
@pagination="handleQuery" /> @pagination="getList" />
</div> </div>
</template> </template>

View File

@ -60,7 +60,7 @@
</el-table> </el-table>
<pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize" <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
@pagination="handleQuery" /> @pagination="getList" />
</div> </div>
</template> </template>

View File

@ -60,7 +60,7 @@
</el-table> </el-table>
<pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize" <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
@pagination="handleQuery" /> @pagination="getList" />
</div> </div>
</template> </template>

View File

@ -0,0 +1,239 @@
<template>
<div>
<el-tabs type="border-card" v-model="activeTab" @tab-click="getListData">
<el-tab-pane v-for="item in choseList " :label="item">
<div class="main-box" v-if="dataList.length>0">
<div class="main" v-for="item in dataList" >
<div class="left" @click="read(item)" >
<div :class="item.isRead === '0' ? 'not-read' : 'readed'"></div>
{{ item.sendText }}
</div>
<div style="display: inline-flex;">
<div class="right">{{ '发送时间:' + item.sendTime }}</div>
<div class="right" style="margin-left: 10px;">{{ '发送人:' + item.sender }}</div>
</div>
</div>
<pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
@pagination="getList" />
</div>
<div v-else class="content"> <img class="img" src="@/assets/home/not-data.png" ></div>
</el-tab-pane>
</el-tabs>
<el-dialog
title="查看消息详情"
:visible.sync="isShowMsg"
width="50%"
:before-close="handleClose">
<div class="title">消息时间轴 </div>
<el-timeline>
<el-timeline-item v-for="item in infoList" :timestamp="item.sendTime" placement="top" >
<el-card >
<h4>{{item.infoType}}{{item.sendText}}</h4>
<p>{{item.sender}} 提交于 {{item.sendTime}}</p>
</el-card>
</el-timeline-item>
</el-timeline>
<div class="title">添加回复 </div>
<div style="margin:10px">
<el-input type="textarea" :rows="2" placeholder="请输入回复内容..." v-model="shareContent">
</el-input>
</div>
<div> <el-button class="agreeButton" @click="sendMsg">发送</el-button></div>
<!-- <span slot="footer" class="dialog-footer">
<el-button @click="handleClose"> </el-button>
<el-button type="primary" @click="dialogVisible = false"> </el-button>
</span> -->
</el-dialog>
</div>
</template>
<script>
import { listMsg, readMsg,getMsgDetail } from "@/api/home";
import { sendMessage} from "@/api/home";
export default {
name: "SendMsg",
data() {
return {
shareContent:'',
repayUser:{},
infoList:[],
isShowMsg:false,
activeTab: '0',
choseList: ['未读消息', '已读消息', '全部消息'],
queryParams: {
pageNum: 1,
pageSize: 10,
isRead: '0',
},
total: 4,
dataList: []
}
},
mounted() {
this.getList();
},
methods: {
getListData() {
if (this.activeTab == 0) {//
this.queryParams.isRead = '0'
} else if (this.activeTab == 1) {//
this.queryParams.isRead = '1'
} else {
this.queryParams.isRead = ''
}
this.getList();
},
/** 查询消息列表 */
getList() {
this.loading = true;
listMsg(this.queryParams).then(response => {
this.dataList = response.rows;
this.total = response.total;
this.loading = false;
});
},
//
read(item){
this.isShowMsg=true;
this.repayUser=item
getMsgDetail(item.id).then(response => {
if(response.code !=500){
this.infoList=response.data
}
});
},
sendMsg(){
let readList=[]
readList.push(this.repayUser.sender)
let params={
readerList: readList,
sendText:this.shareContent,
parentId:this.infoList[0].id
}
sendMessage(params).then(response => {
if(response.code==200){
this.$message.success("消息回复成功!")
}else{
this.$message.error("消息回复失败!")
}
});
},
//
handleClose(){
this.isShowMsg=false
readMsg(this.repayUser.id).then(response => {
if(response.code !=500){
// this.$Message.info("")
this.getList()
}
});
}
}
};
</script>
<style lang="scss" scoped>
.agreeButton {
display: inline-block;
line-height: 8px;
width: 80px;
height: 32px;
white-space: nowrap;
cursor: pointer;
color: #ffffff;
-webkit-appearance: none;
text-align: center;
-webkit-box-sizing: border-box;
box-sizing: border-box;
outline: 0;
margin-left: 10px;
-webkit-transition: .1s;
transition: .1s;
font-weight: 500;
//padding: 12px 20px;
font-size: 14px;
border-radius: 4px;
background-color: #068f5c;
}
.agreeButton:hover {
background: #65a5f9;
border-color: #65a5f9;
color: #FFF;
}
.title {
padding-left: 20px;
color: #212121;
font-size: 16px;
margin-bottom: 10px;
margin-top: 10px;
background: url("~@/assets/ucs/biaoti.png") no-repeat;
background-position-y: 7px;
}
.content{
height: 800px;
position: relative;
}
.img{
position: absolute;
top:50%;
left:50%;
transform:translate(-50%,-50%);
}
.main-box {
width: 100%;
background: #fff;
height: 800px;
.main {
background: #fff;
margin: 0 5px;
// min-height: 80px;
// overflow-y: scroll;
border-top: 1px solid #dddee1;
.readed {
width: 10px;
height: 10px;
border-radius: 5px;
display: inline-flex;
background: green;
}
.not-read {
display: inline-flex;
width: 10px;
height: 10px;
border-radius: 5px;
background: red;
}
.left {
margin-top: 5px;
width: 90%;
max-height: 43px;
overflow: hidden;
text-overflow: ellipsis;
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
word-break: break-all;
cursor: pointer;
}
.left:hover{
color:#068f5c;
text-decoration: underline;
}
.right {
margin-top: 5px;
height: 30px;
}
}
}
</style>