短信搜索,完成后台管理操作。

master
Administrator 11 months ago
parent be0f197160
commit 383d04babd

@ -30,7 +30,8 @@ public enum ExceptionEnums {
KAPACHA_ERROR(-100,"验证码错误!"),
AUTHEN_ERROR(-101,"用户名或密码错误!"),
NOT_LOGIN(-102,"用户未登录!"),
USER_MENU_ERROR(-103,"查询用户的菜单信息失败!")
USER_MENU_ERROR(-103,"查询用户的菜单信息失败!"),
SMS_NO_AUTHOR(-104,"当前登录用户没有权限查询当前短信信息")
;
private Integer code;

@ -30,6 +30,17 @@ public class R {
return vo;
}
/**
*
* @return
*/
public static ResultVO ok(Long total ,Object rows){
ResultVO vo = ok();
vo.setTotal(total);
vo.setRows(rows);
return vo;
}
/**
*
* @param enums

@ -1,5 +1,6 @@
package com.mashibing.common.vo;
import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.Data;
import lombok.NoArgsConstructor;
@ -16,8 +17,15 @@ public class ResultVO {
private String msg;
@JsonInclude(value = JsonInclude.Include.NON_EMPTY)
private Object data;
@JsonInclude(value = JsonInclude.Include.NON_EMPTY)
private Long total;
@JsonInclude(value = JsonInclude.Include.NON_EMPTY)
private Object rows;
public ResultVO(Integer code, String msg) {
this.code = code;

@ -28,9 +28,6 @@ public class SmsWriteLogListener {
private SearchService searchService;
@RabbitListener(queues = RabbitMQConstants.SMS_WRITE_LOG)
public void consume(StandardSubmit submit, Channel channel, Message message) throws IOException {
//1、调用搜索模块的添加方法完成添加操作

@ -5,6 +5,7 @@ import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.web.bind.annotation.GetMapping;
import java.util.concurrent.*;
import java.util.concurrent.locks.Condition;
@ -26,5 +27,4 @@ public class TestStarterApp {
}

@ -61,6 +61,11 @@
<artifactId>hibernate-validator</artifactId>
<version>6.1.5.Final</version>
</dependency>
<!-- 需要调用其他模块-->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-openfeign</artifactId>
</dependency>
</dependencies>
<build>

@ -4,6 +4,7 @@ import org.apache.shiro.crypto.hash.Md5Hash;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.openfeign.EnableFeignClients;
import java.util.UUID;
@ -13,6 +14,7 @@ import java.util.UUID;
*/
@SpringBootApplication
@MapperScan(basePackages = "com.mashibing.webmaster.mapper")
@EnableFeignClients
public class WebMasterStarterApp {
public static void main(String[] args) {

@ -0,0 +1,18 @@
package com.mashibing.webmaster.client;
import org.springframework.cloud.openfeign.FeignClient;
import java.util.Map;
/**
* @author zjw
* @description
*/
@FeignClient(value = "beacon-search")
public interface SearchClient {
Map<String,Object> findSmsByParameters(Map<String,Object> parameters);
}

@ -0,0 +1,115 @@
package com.mashibing.webmaster.controller;
import com.mashibing.common.constant.WebMasterConstants;
import com.mashibing.common.enums.ExceptionEnums;
import com.mashibing.common.util.R;
import com.mashibing.common.vo.ResultVO;
import com.mashibing.webmaster.client.SearchClient;
import com.mashibing.webmaster.entity.ClientBusiness;
import com.mashibing.webmaster.entity.SmsUser;
import com.mashibing.webmaster.service.ClientBusinessService;
import com.mashibing.webmaster.service.SmsRoleService;
import com.mashibing.webmaster.vo.SearchSmsVO;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.beanutils.BeanUtils;
import org.apache.shiro.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Set;
/**
*
*
* @author zjw
* @description
*/
@RestController
@Slf4j
public class SearchController {
@Autowired
private SmsRoleService roleService;
@Autowired
private SearchClient searchClient;
@Autowired
private ClientBusinessService clientBusinessService;
@GetMapping("/sys/search/list")
public ResultVO list(@RequestParam Map map) {
//1、判断当前登录用户的角色能否查询对应的客户信息
//1.1 查看用户是否登录
SmsUser smsUser = (SmsUser) SecurityUtils.getSubject().getPrincipal();
if (smsUser == null) {
log.info("【获取客户信息】 用户未登录!!");
return R.error(ExceptionEnums.NOT_LOGIN);
}
String clientIDStr = (String) map.get("clientID");
Long clientID = null;
if (!StringUtils.isEmpty(clientIDStr)) {
clientID = Long.parseLong(clientIDStr);
}
//1.2 拿到用户的id标识查看用户的角色是否是管理员
Set<String> roleNames = roleService.getRoleName(smsUser.getId());
if (roleNames != null && !roleNames.contains(WebMasterConstants.ROOT)) {
//1.3 如果不是管理员需要查询当前用户对应的公司信息匹配参数中的公司id是否一致
// 查询当前登录用户所包含的全部客户id公司信息
List<ClientBusiness> clients = clientBusinessService.findByUserId(smsUser.getId());
// 查看请求参数中携带的clientID
if (clientID == null) {
// 客户没有传递clientID查询当前用户锁拥有的全部客户的短信信息
List<Long> list = new ArrayList<>();
for (ClientBusiness client : clients) {
list.add(client.getId());
}
map.put("clientID", list);
} else {
boolean flag = false;
// 客户传递了clientID判断当前登录用户是否包含当前clientID
for (ClientBusiness client : clients) {
if (client.getId() == clientID) {
// 满足当前登录用户的操作,可以查询
flag = true;
break;
}
}
if (!flag) {
// 请求参数不满足当前登录用户的信息
log.info("【搜索短信信息】 用户权限不足!!");
return R.error(ExceptionEnums.SMS_NO_AUTHOR);
}
}
}
//2、调用搜索模块查询数据返回total和rows
Map<String, Object> data = searchClient.findSmsByParameters(map);
//3、判断返回的total如果total为0正常返回
Long total = Long.parseLong(data.get("total") + "");
if (total == 0) {
return R.ok();
}
//4、如果数据正常做返回数据的封装声明SearchSmsVO的实体类
List<Map> list = (List<Map>) data.get("rows");
List<SearchSmsVO> rows = new ArrayList<>();
try {
BeanUtils.copyProperties(list, rows);
} catch (Exception e) {
e.printStackTrace();
}
//5、响应数据
return R.ok(total, rows);
}
}

@ -1,6 +1,5 @@
package com.mashibing.webmaster.controller;
import com.alibaba.druid.util.StringUtils;
import com.mashibing.common.constant.WebMasterConstants;
import com.mashibing.common.enums.ExceptionEnums;
import com.mashibing.common.util.R;

@ -1,9 +1,7 @@
package com.mashibing.webmaster.service.impl;
import com.mashibing.webmaster.entity.SmsRoleExample;
import com.mashibing.webmaster.mapper.SmsRoleMapper;
import com.mashibing.webmaster.service.SmsRoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;

@ -0,0 +1,36 @@
package com.mashibing.webmaster.vo;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @author zjw
* @description
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
public class SearchSmsVO {
// ok
private String corpname;
// 格式待定
private Long sendTimeStr;
// 修改页面
private Integer reportState;
// 全网通改成未知
private Integer operatorId;
// 原errorCode
private String errorMsg;
// ok
private String srcNumber;
// ok
private String mobile;
// ok
private String text;
}

@ -39,9 +39,9 @@ $(function () {
}},
{field: 'reportState', title: '状态', formatter: function (v, r, i) {
if (v == 0) {
return "成功";
} else if(v == 1) {
return "等待";
} else if(v == 1) {
return "成功";
} else {
return "失败";
}
@ -49,7 +49,7 @@ $(function () {
},
{field: 'operatorId', title: '运营商', formatter: function (v, r, i) {
if (v == 0) {
return "全网";
return "未知";
} else if(v == 1) {
return "移动";
} else if(v == 2) {
@ -61,8 +61,8 @@ $(function () {
},
{field: 'errorCode', title: '错误码'},
{field: 'srcNumber', title: '发送号'},
{field: 'destMobile', title: '手机号'},
{field: 'messageContent', title: '短信内容'}
{field: 'mobile', title: '手机号'},
{field: 'text', title: '短信内容'}
]
};
$('#table').bootstrapTable(option);

Loading…
Cancel
Save