Commit 0050f04b by hanzepeng

删除现有代码

parent bd8ac716
Pipeline #2062 failed with stages
in 7 seconds
## MobDNA
**基于`springboot2` + `springsecurity` + `mybatis` + `redis` + `swagger` + `oauth2` 的脚手架工程(前后端分离)**
1. 配置了mybatis的通用mapper,单表操作无需写SQL,实现了批量插入、批量删除等功能。
2. 内含freemarker的代码生成器,可以一键根据表名直接生成controller、service、dao、mapper等基础代码,
大大提高了开发效率,让你更专注于对业务的开发。
3. spring-security目前使用的是基于权限的动态校验,采用黑名单的方式对接口权限的判断。
4. 框架内已包含许多工具类,MD5加密、json、POI的excel文档操作,以及时间和日期等常见工具类。
5. 采用了@Log对项目日志的记录。
6. 加入对OAuth2的支持
|依赖 |版本 |
|:------------- |:------------|
|[Spring Boot](http://mvnrepository.com/artifact/org.springframework.boot/spring-boot) |2.1.4.RELEASE|
|[Spring Web MVC](http://mvnrepository.com/artifact/org.springframework/spring-webmvc) |5.1.6.RELEASE|
|[Spring Security Web](http://mvnrepository.com/artifact/org.springframework.security/spring-security-web)|5.1.5.RELEASE|
|[MyBatis](http://mvnrepository.com/artifact/org.mybatis/mybatis) |3.5.0 |
|[通用mapper](https://mvnrepository.com/artifact/tk.mybatis/mapper-spring-boot-starter) |2.1.5|
|[Druid](http://mvnrepository.com/artifact/com.alibaba/druid-spring-boot-starter) |1.1.10 |
### 启动步骤
> 1. 创建数据库boot2-oauth, 执行web模块下resources/sql/init.sql文件
> 2. 使用postman测试登录接口 /login POST 方式 ,本项目返回均是JSON字符串,重定向到登录页面,需要前端做处理,若想要后端直接重定向到登录页面的话,需要配置WebSecurityConfig中引入的那几个Handler,将里面返回的json值改为重定向到登录页面即可。
### 完成模块
1. 用户管理
- [x] 用户的CRUD
- [x] 在线用户数量统计
2. 角色管理
- [x] 角色的CRUD
- [x] 角色权限树
3. 权限管理
- [x] 权限的CRUD
4. 日志管理
- [x] 日志的CRUD
### OAuth2.0 测试
1. 转到 oauth2 分支
2. 按照如下方式测试:
![OAuth2测试](https://img-blog.csdnimg.cn/20200320172751161.gif)
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>MobDNA</artifactId>
<groupId>com.reyun.saas</groupId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>backend</artifactId>
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>com.reyun.saas</groupId>
<artifactId>common</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
<!-- BCrypt 加密 -->
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-crypto</artifactId>
<version>5.1.2.RELEASE</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.jsoup/jsoup -->
<dependency>
<groupId>org.jsoup</groupId>
<artifactId>jsoup</artifactId>
<version>1.13.1</version>
</dependency>
</dependencies>
</project>
package com.reyun.saas.mob;
import org.apache.ibatis.annotations.Mapper;
/**
* @ClassName: NoWarnMapper
* @Description: 为了消除启动时mybatis的警告
* @date 2019-07-24 15:06
*/
@Mapper
public interface NoWarnMapper {
}
package com.reyun.saas.mob.async;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.io.FileUtil;
import cn.hutool.core.io.IoUtil;
import cn.hutool.http.HttpUtil;
import cn.hutool.json.JSONArray;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import com.reyun.saas.common.framework.component.AwsS3Component;
import com.reyun.saas.mob.user.dao.AppMapper;
import com.reyun.saas.mob.user.domain.App;
import lombok.extern.slf4j.Slf4j;
import org.jsoup.Jsoup;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;
import javax.annotation.Resource;
import java.io.File;
import java.io.FileInputStream;
@Component
@Slf4j
public class AsyncTask {
@Resource
private AppMapper appMapper;
@Value("${user.dir}")
private String tempFilePath;
@Autowired
private AwsS3Component awsS3Component;
@Async
public void getAppIcon(App app){
File file = null;
FileInputStream fileInputStream = null;
String iconNetUrl = null;
try {
if(app.getOs().equals("iOS")){
String body = Jsoup.connect("http://itunes.apple.com/lookup?bundleId="+app.getBid())
.header("Accept-Language", "zh-Hans-CN")
.header("User-Agent", "AppStore/2.0 iOS/10.0.2 model/iPhone7,2 hwp/t7000 build/14A456 (6; dt:106)")
.header("X-Apple-Connection-Type", "WiFi")
.header("X-Apple-Store-Front", "143465-19,29")
.timeout(14000)
.get().body().text();
if(JSONUtil.isJson(body)){
JSONObject jsonObject = JSONUtil.parseObj(body);
Integer resultCount = jsonObject.getInt("resultCount");
if(resultCount!=null && resultCount>0){
iconNetUrl = jsonObject.getByPath("results[0].artworkUrl60",String.class);
}
}
}else{
String body = Jsoup.connect("https://sj.qq.com/myapp/searchAjax.htm?kw="+app.getBid()+"&pns=&sid=")
.header("content-type","application/*+xml")
.ignoreContentType(true)
.timeout(14000)
.get().body().text();
if(JSONUtil.isJson(body)){
JSONObject jsonObject = JSONUtil.parseObj(body);
JSONObject objJson = jsonObject.getJSONObject("obj");
if(objJson!=null){
JSONArray items = objJson.getJSONArray("items");
if(!CollectionUtil.isEmpty(items)){
for (int i = 0; i < items.size(); i++) {
JSONObject itemJson = items.getJSONObject(i);
String pkgName = itemJson.getStr("pkgName");
if(app.getBid().equals(pkgName)){
iconNetUrl = itemJson.getByPath("appDetail.iconUrl",String.class);
break;
}
}
}
}
}
}
if(!StringUtils.isEmpty(iconNetUrl)){
file = HttpUtil.downloadFileFromUrl(iconNetUrl, getTempFilePath() + app.getRootParent()+File.separator+app.getAppkey()+".png");
fileInputStream = IoUtil.toStream(file);
String objKey = "icon/"+app.getRootParent()+"/"+app.getAppkey()+".png";
awsS3Component.upload(objKey,fileInputStream);
App appIcon = new App();
appIcon.setId(app.getId());
appIcon.setIconUrl(objKey);
appMapper.updateByPrimaryKeySelective(appIcon);
}
}catch (Exception e){
log.error("获取app图标失败:{},异常信息:{}",app.toString(),e);
}finally {
FileUtil.del(file);
IoUtil.close(fileInputStream);
}
}
public String getTempFilePath(){
String path = new File(tempFilePath)+File.separator+"mob-dna-temp-file"+File.separator;
File file = new File(path);
if (!file.exists()) {
file.mkdirs();
}
return path;
}
}
package com.reyun.saas.mob.log.dao;
import com.reyun.saas.common.core.Mapper;
import com.reyun.saas.mob.log.domain.SysLog;
import com.reyun.saas.mob.log.dto.SysLogExportDTO;
import com.reyun.saas.mob.log.dto.SysLogInputDTO;
import com.reyun.saas.mob.log.dto.SysLogOutpDTO;
import org.apache.ibatis.annotations.Param;
import java.util.List;
public interface SysLogMapper extends Mapper<SysLog> {
List<SysLogOutpDTO> selectLogByQuery(@Param("dto") SysLogInputDTO inputDTO);
List<SysLogExportDTO> exportLogList(@Param("dto") SysLogInputDTO inputDTO);
}
\ No newline at end of file
package com.reyun.saas.mob.log.domain;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.reyun.saas.common.utils.CoreUtils;
import lombok.Data;
import javax.persistence.*;
import java.io.Serializable;
import java.util.Date;
@Data
@Table(name = "sys_log")
@JsonInclude(JsonInclude.Include.NON_NULL)
public class SysLog implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
/**
* 日志类型 根据系统模块来定义日志类型
*/
@Column(name = "log_type")
private Integer logType;
/**
* 操作类型: 添加-1 删除-2 更新-3 查看-4
*/
private Integer operation;
/**
* 操作人员ID
*/
@Column(name = "log_user")
private Long logUser;
/**
* 访问IP
*/
@Column(name = "log_ip")
private String logIp;
/**
* 请求方法
*/
@Column(name = "log_method")
private String logMethod;
/**
* 请求参数
*/
@Column(name = "log_params")
private String logParams;
/**
* 日志描述
*/
@Column(name = "log_desc")
private String logDesc;
/**
* 响应时间
*/
@Column(name = "log_time")
private Long logTime;
/**
* 异常码
*/
@Column(name = "exception_code")
private String exceptionCode;
/**
* 异常描述
*/
@Column(name = "exception_detail")
private String exceptionDetail;
/**
* 创建时间
*/
@Column(name = "create_time")
private Date createTime;
/**
* 用户名
*/
@Transient
private String username;
/**
* 操作类型
*/
@Transient
private String logOperation;
public String getLog() {
return "用户 "+username + " 在" + CoreUtils.getModule(logType) + "模块调用了 " + logMethod + "方法," +
" ip: "+logIp + " 用户id: "+logUser + " 操作类型: " +logOperation
+ " 参数: " +logParams+ " 异常状态码: "+exceptionCode + " 异常信息: " +exceptionDetail +" 用时: "+logTime+"毫秒";
}
}
package com.reyun.saas.mob.log.dto;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
/**
* @ClassName: ExportOutpDTO
* @Description: 导出实体类
*/
@Data
public class SysLogExportDTO implements Serializable {
private Long id;
/**
* 操作类型: 添加-1 删除-2 更新-3 查看-4
*/
private String operation;
/**
* 操作人员名称
*/
private String username;
/**
* 日志描述
*/
private String logDesc;
/**
* 创建时间
*/
private Date createTime;
}
package com.reyun.saas.mob.log.dto;
import lombok.Data;
import java.io.Serializable;
/**
* @ClassName: SysLogInputDTO
* @Description: TODO
*/
@Data
public class SysLogInputDTO implements Serializable {
/**
* 日志详情
*/
private String logDesc;
/**
* 操作人员
*/
private String logType;
/**
* 操作类型
*/
private String operation;
/**
* 开始时间
*/
private String startTime;
/**
* 结束时间
*/
private String endTime;
}
package com.reyun.saas.mob.log.dto;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
/**
* @ClassName: SysLogOutpDTO
* @Description: 日志输出实体类
*/
@Data
public class SysLogOutpDTO implements Serializable {
private Long id;
/**
* 日志类型 根据系统模块来定义日志类型
*/
private Integer logType;
/**
* 操作类型: 添加-1 删除-2 更新-3 查看-4
*/
private Integer operation;
/**
* 操作人员ID
*/
private String logUser;
/**
* 操作人员名称
*/
private String username;
/**
* 访问IP
*/
private String logIp;
/**
* 请求方法
*/
private String logMethod;
/**
* 请求参数
*/
private String logParams;
/**
* 日志描述
*/
private String logDesc;
/**
* 响应时间
*/
private Long logTime;
/**
* 异常码
*/
private String exceptionCode;
/**
* 异常描述
*/
private String exceptionDetail;
/**
* 创建时间
*/
private Date createTime;
}
package com.reyun.saas.mob.log.service;
import com.reyun.saas.mob.log.domain.SysLog;
import com.reyun.saas.common.core.Service;
import com.reyun.saas.common.restResult.PageParam;
import com.reyun.saas.mob.log.dto.SysLogInputDTO;
import com.reyun.saas.mob.log.dto.SysLogOutpDTO;
import org.springframework.http.ResponseEntity;
import java.util.List;
/**
* @Description: // TODO 为类添加注释
*/
public interface SysLogService extends Service<SysLog> {
/**
* 根据分页、排序信息和检索条件查询 @size 条 字典表数据
* @param pageParam 分页参数
* @param inputDTO 查询关键字
* @return
*/
List<SysLogOutpDTO> list(PageParam pageParam, SysLogInputDTO inputDTO);
/**
* 保存日志
*/
void saveLog(SysLog sysLog);
/**
* 删除日志
*/
void deleteById(String ids);
/**
* 分页导出日志
* @param inputDTO
* @return
*/
ResponseEntity<byte[]> exportLogList(SysLogInputDTO inputDTO);
}
package com.reyun.saas.mob.log.service.impl;
import com.reyun.saas.common.core.AbstractService;
import com.reyun.saas.common.util.PoiUtils;
import com.reyun.saas.common.restResult.PageParam;
import com.reyun.saas.common.config.ApplicationConfig;
import com.reyun.saas.mob.log.dao.SysLogMapper;
import com.reyun.saas.mob.log.domain.SysLog;
import com.reyun.saas.mob.log.dto.SysLogExportDTO;
import com.reyun.saas.mob.log.dto.SysLogInputDTO;
import com.reyun.saas.mob.log.dto.SysLogOutpDTO;
import com.reyun.saas.mob.log.service.SysLogService;
import com.github.pagehelper.PageHelper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import tk.mybatis.mapper.entity.Example;
import javax.annotation.Resource;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* @Description: 日志业务层
*/
@Slf4j
@Service
@Transactional
public class SysLogServiceImpl extends AbstractService<SysLog> implements SysLogService {
@Resource
private SysLogMapper sysLogMapper;
@Resource
private ApplicationConfig applicationConfig;
private static final int FIND = 4;
/**
* 根据分页、排序信息和检索条件查询 @size 条 字典表数据
* @param pageParam 分页参数
* @param inputDTO 查询关键字
* @return
*/
@Override
public List<SysLogOutpDTO> list(PageParam pageParam, SysLogInputDTO inputDTO) {
PageHelper.startPage(pageParam.getPage(), pageParam.getSize(), pageParam.getOrderBy());
return sysLogMapper.selectLogByQuery(inputDTO);
}
/**
* 保存日志
* @param sysLog
*/
@Override
public void saveLog(SysLog sysLog) {
//todo 查看不做操作 Log注解上没写注释的也不保存
Integer operation = sysLog.getOperation();
if (operation != FIND && operation != 0){
sysLogMapper.insert(sysLog);
}
}
/**
* 删除日志k
* @param ids
*/
@Override
public void deleteById(String ids) {
List<String> list = Arrays.stream(ids.split(",")).collect(Collectors.toList());
Example example = new Example(SysLog.class);
example.and().andIn("id",list);
sysLogMapper.deleteByExample(example);
}
/**
* 分页导出日志
* @param inputDTO
* @return
*/
@Override
public ResponseEntity<byte[]> exportLogList(SysLogInputDTO inputDTO) {
List<SysLogOutpDTO> data = sysLogMapper.selectLogByQuery(inputDTO);
Map<Integer, String> sysLogMap = applicationConfig.getLogOperation();
List<SysLogExportDTO> list = new ArrayList<>();
Long logId=1L;
for (SysLogOutpDTO sysLog: data) {
SysLogExportDTO exportDTO = new SysLogExportDTO();
exportDTO.setId(logId);
logId+=1L;
exportDTO.setOperation(sysLogMap.get(sysLog.getOperation()));
exportDTO.setUsername(sysLog.getUsername());
exportDTO.setLogDesc(sysLog.getLogDesc());
exportDTO.setCreateTime(sysLog.getCreateTime());
list.add(exportDTO);
}
String[] headers = {"序号","操作类型","操作者","操作详情","操作时间"};
PoiUtils poiUtils = new PoiUtils("日志列表", "日志导出模板.xls");
poiUtils.setHeaders(headers, "日志列表");
// 为excel表生成数据
poiUtils.fillDataAndStyle(list,2);
// 将内容返回响应
ByteArrayOutputStream bos = new ByteArrayOutputStream();
try {
poiUtils.getWorkbook().write(bos);
} catch (IOException e) {
e.printStackTrace();
} finally {
if (bos != null) {
try {
bos.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
// 文件名
String filename = "日志列表";
try {
filename = new String(filename.getBytes("gbk"), "iso8859-1");
} catch (UnsupportedEncodingException e) {
log.warn("不支持编码格式");
e.printStackTrace();
}
// 设置http响应头
HttpHeaders header = new HttpHeaders();
header.add("Content-Disposition", "attachment;filename=" + filename + ".xls");
return new ResponseEntity<byte[]>(bos.toByteArray(), header, HttpStatus.OK);
}
}
package com.reyun.saas.mob.openapi.dao;
import com.reyun.saas.common.core.Mapper;
import com.reyun.saas.mob.openapi.domain.CollaborativeProject;
/**
* @author: hanzepeng
* @Date: 2022/02/09/15:01
* @Description: 合作项目持久层
*/
public interface CollaborativeProjectMapper extends Mapper<CollaborativeProject> {
}
package com.reyun.saas.mob.openapi.dao;
import com.reyun.saas.common.core.Mapper;
import com.reyun.saas.mob.openapi.domain.CollaborativeProjectUser;
/**
* @author: hanzepeng
* @Date: 2022/02/09/17:09
* @Description: 合作项目与用户关系持久层
*/
public interface CollaborativeProjectUserMapper extends Mapper<CollaborativeProjectUser> {
}
package com.reyun.saas.mob.openapi.domain;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.persistence.*;
import java.io.Serializable;
import java.util.Date;
/**
* @author: hanzepeng
* @Date: 2022/02/09/14:55
* @Description: 合作项目实体类
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
@Table(name = "collaborative_project")
public class CollaborativeProject implements Serializable {
/**
* 主键
*/
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
/**
* 合作项目名称
*/
@Column(name = "project_name")
private String projectName;
/**
* 合作项目公司名称
*/
@Column(name = "company")
private String company;
/**
* 合作项目token
*/
@Column(name = "token")
private String token;
/**
* 合作项目的oid
*/
@Column(name = "oid")
private String oid;
/**
* 合作项目访问ip
*/
@Column(name = "ip")
private String ip;
/**
* 创建时间
*/
@Column(name = "create_time")
private Date createTime;
/**
* 修改时间
*/
@Column(name = "modfiy_time")
private Date modfiyTime;
/**
* 删除标志 1为删除 0为未删除
*/
@Column(name = "del_flag")
private Boolean delFlag;
}
package com.reyun.saas.mob.openapi.domain;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.persistence.Column;
import javax.persistence.Id;
import javax.persistence.Table;
import java.io.Serializable;
/**
* @author: hanzepeng
* @Date: 2022/02/09/17:01
* @Description: 合作项目与用户关系实体对象
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
@Table(name = "collaborative_project_user")
public class CollaborativeProjectUser implements Serializable {
//合作项目id
@Id
@Column(name = "collaborative_project_id")
private Long projectId;
//用户id
@Column(name = "user_id")
private Long userId;
}
package com.reyun.saas.mob.openapi.dto;
import com.reyun.saas.common.exception.CustomException;
import com.reyun.saas.common.model.Constant;
import com.reyun.saas.common.restResult.ResultCode;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.util.StringUtils;
import java.io.Serializable;
/**
* @author: hanzepeng
* @Date: 2022/02/11/13:40
* @Description: app输入DTO
*/
@Data
@ApiModel(value = "AppInputDTO", description = "OpenApi APP入参对象")
public class AppInputDTO implements Serializable {
@ApiModelProperty(value = "应用包名")
private String bid;
@ApiModelProperty(value = "应用名称")
private String appName;
@ApiModelProperty(value = "系统类型 1为iOS 2位为Android")
private String os;
@ApiModelProperty(value = "用户唯一标识")
private String oid;
public String getStrOS(){
//校验系统类型
if(!(Constant.OS_IOS_CODE.equals(this.os)
|| Constant.OS_ANDROID_CODE.equals(this.os))){
throw new CustomException(ResultCode.OS_TYPE_ERROR);
}
return Constant.OS_IOS_CODE.equals(this.os)?"iOS":"Android";
}
/**
* 校验参数
*/
public void checkParam(){
//去空格
this.paramTrim();
//非空校验
if(StringUtils.isEmpty(bid)
|| StringUtils.isEmpty(appName)
|| StringUtils.isEmpty(oid)){
throw new CustomException(ResultCode.REQUEST_PARAM_ERROR);
}
//校验系统类型
try {
//校验浮点数参数
Integer.parseInt(this.os);
} catch (NumberFormatException e) {
throw new CustomException(ResultCode.REQUEST_PARAM_ERROR);
}
if(!(Constant.OS_ANDROID_CODE.equals(this.os)
|| Constant.OS_IOS_CODE.equals(this.os))){
throw new CustomException(ResultCode.OS_TYPE_ERROR);
}
//校验bid长度
if(bid.length() > 128){
throw new CustomException(ResultCode.BID_FORMAT_ERROR);
}
}
/**
* 参数去空格
*/
public void paramTrim(){
if(!StringUtils.isEmpty(this.bid)){
this.bid = this.bid.trim();
}
if(!StringUtils.isEmpty(this.appName)){
this.appName = this.appName.trim();
}
if(!StringUtils.isEmpty(this.oid)){
this.oid = this.oid.trim();
}
if(!StringUtils.isEmpty(this.os)){
this.os = this.os.trim();
}
}
}
package com.reyun.saas.mob.openapi.dto;
import io.swagger.annotations.ApiModel;
import lombok.Data;
import java.util.Date;
/**
* @author: hanzepeng
* @Date: 2022/02/11/19:10
* @Description: openApi app输出对象
*/
@Data
@ApiModel(value = "AppOutDTO", description = "openApi app输出对象")
public class AppOutDTO {
private String bid;
private String appNmae;
private String appkey;
private Date createTime;
}
package com.reyun.saas.mob.openapi.dto;
import com.reyun.saas.common.exception.CustomException;
import com.reyun.saas.common.restResult.ResultCode;
import com.reyun.saas.common.util.IPUtils;
import io.swagger.annotations.ApiModel;
import lombok.Data;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import java.util.Set;
/**
* @author: hanzepeng
* @Date: 2022/02/14/10:58
* @Description: OpenApi的rta白名单DTO对象
*/
@Data
@ApiModel(value = "RtaIpWhiteDTO", description = "openApi的rta白名单DTO对象")
public class RtaIpWhiteDTO {
/**
* 白名单ip
*/
private Set<String> ips;
/**
* 校验参数
*/
public void checkParam() {
if(!CollectionUtils.isEmpty(this.ips)){
for (String ip : ips) {
//去空格
if(!StringUtils.isEmpty(ip)){
ip = ip.trim();
}
//校验ip
if(!IPUtils.iPCheck(ip)){
throw new CustomException(ResultCode.IP_FROMAT_ERROR);
}
}
}
}
}
package com.reyun.saas.mob.openapi.dto;
import com.reyun.saas.common.exception.CustomException;
import com.reyun.saas.common.restResult.ResultCode;
import com.reyun.saas.common.util.PatternUtil;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.util.StringUtils;
import java.io.Serializable;
/**
* @author: hanzepeng
* @Date: 2022/02/09/14:48
* @Description: 用户注册DTO
*/
@Data
@ApiModel(value="SignupDTO",description="OpenApi注册DTO对象")
public class SignupDTO implements Serializable {
@ApiModelProperty(value="用户名")
private String username;
@ApiModelProperty(value="密码")
private String password;
@ApiModelProperty(value="公司")
private String company;
@ApiModelProperty(value="用户姓名")
private String actualName;
@ApiModelProperty(value="电话")
private String phone;
@ApiModelProperty(value="QQ")
private String qq;
@ApiModelProperty(value="微信")
private String wechat;
/**
* 校验参数
*/
public void checkParam() {
//去除空格
this.paramTrim();
//校验必传字段
if(StringUtils.isEmpty(this.username) ||
StringUtils.isEmpty(this.password) ||
StringUtils.isEmpty(this.company)){
throw new CustomException(ResultCode.REQUEST_PARAM_ERROR);
}
//校验用户名 目前只校验邮箱
if (!PatternUtil.isEmail(this.username)) {
throw new CustomException(ResultCode.USERNAME_FORMAT_ERROR);
}else{
//校验长度
if (this.username.length() > 64){
throw new CustomException(ResultCode.USERNAME_FORMAT_ERROR);
}
}
//校验密码格式
String passrowd = this.password;
if(!PatternUtil.checkSimplePassword(passrowd,6,20)){
throw new CustomException(ResultCode.PASSWORD_FORMAT_ERROR);
}
//校验手机号
if(!StringUtils.isEmpty(this.phone)){
if (!PatternUtil.isMobileNo(this.phone)) {
throw new CustomException(ResultCode.OPENAPI_PHONE_FORMAT_ERROR);
}
}
}
/**
* 参数去空格
*/
public void paramTrim(){
if(!StringUtils.isEmpty(this.username)){
this.username = this.username.trim();
}
if(!StringUtils.isEmpty(this.password)){
this.password = this.password.trim();
}
if(!StringUtils.isEmpty(this.company)){
this.company = this.company.trim();
}
if(!StringUtils.isEmpty(this.actualName)){
this.actualName = this.actualName.trim();
}
if(!StringUtils.isEmpty(this.phone)){
this.phone = this.phone.trim();
}
if(!StringUtils.isEmpty(this.qq)){
this.qq = this.qq.trim();
}
}
}
package com.reyun.saas.mob.openapi.dto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
/**
* @author: hanzepeng
* @Date: 2022/02/11/18:21
* @Description: openApi用户数据DTO对象
*/
@Data
@ApiModel(value = "UserOutDTO", description = "OpenApi 用户输出DTO对象")
public class UserOutDTO {
@ApiModelProperty(value="用户名")
private String username;
@ApiModelProperty(value="oid")
private String oid;
@ApiModelProperty(value="创建时间")
private Date createTime;
}
package com.reyun.saas.mob.openapi.service;
import com.reyun.saas.common.exception.CustomException;
import com.reyun.saas.mob.openapi.domain.CollaborativeProject;
/**
* @author: hanzepeng
* @Date: 2022/02/09/15:02
* @Description: openApi合作项目业务层接口
*/
public interface CollaborativeProjectService {
/**
* 根据token获取合作项目信息
*/
CollaborativeProject findProjectByToken(String token) throws CustomException;
}
package com.reyun.saas.mob.openapi.service;
import com.reyun.saas.mob.openapi.domain.CollaborativeProject;
import com.reyun.saas.mob.openapi.dto.AppInputDTO;
import com.reyun.saas.mob.user.domain.App;
import java.util.List;
/**
* @author: hanzepeng
* @Date: 2022/02/11/13:36
* @Description: openApi App业务层接口
*/
public interface OpenApiAppService {
/**
* 创建appdto
*/
App create(AppInputDTO appInputDTO, CollaborativeProject project);
/**
* 根據oid查询app
*/
List<App> findAppsByOid(String oid);
}
package com.reyun.saas.mob.openapi.service;
import com.reyun.saas.mob.openapi.domain.CollaborativeProject;
import java.util.Set;
/**
* @author: hanzepeng
* @Date: 2022/02/14/11:00
* @Description: RTA配置业务层接口
*/
public interface OpenApiRtaService {
/**
* 更新合作项目的RTA ip白名单
*/
void updateIpWhiteList(CollaborativeProject project, Set<String> ips);
/**
* 查询合作项目的rta ip白名单
*/
Set<String> ipWhiteList(CollaborativeProject project);
}
package com.reyun.saas.mob.openapi.service;
import com.reyun.saas.mob.openapi.domain.CollaborativeProject;
import com.reyun.saas.mob.openapi.dto.SignupDTO;
import com.reyun.saas.mob.user.domain.User;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
/**
* @author: hanzepeng
* @Date: 2022/02/09/13:51
* @Description: apenApi用户业务层接口
*/
public interface OpenApiUserService {
/**
* openApi注册用户
*/
User signup(SignupDTO signupDTO, CollaborativeProject project, HttpServletRequest request);
/**
* 查询合作项目创建的用户
*/
List<User> findUsers(CollaborativeProject project);
}
package com.reyun.saas.mob.openapi.service.impl;
import com.reyun.saas.common.exception.CustomException;
import com.reyun.saas.common.restResult.ResultCode;
import com.reyun.saas.mob.openapi.dao.CollaborativeProjectMapper;
import com.reyun.saas.mob.openapi.domain.CollaborativeProject;
import com.reyun.saas.mob.openapi.service.CollaborativeProjectService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import tk.mybatis.mapper.entity.Example;
/**
* @author: hanzepeng
* @Date: 2022/02/09/15:02
* @Description: openApi 合作项目业务层
*/
@Slf4j
@Service
public class CollaborativeProjectServiceImpl implements CollaborativeProjectService {
@Autowired
private CollaborativeProjectMapper projectMapper;
/**
* 根据token获取合作项目信息
* @param token token
* @return 合作项目实体对象
* @throws CustomException token不可用会抛出自定义异常
*/
@Override
public CollaborativeProject findProjectByToken(String token) throws CustomException {
if(StringUtils.isEmpty(token)){
throw new CustomException(ResultCode.TOKEN_NOT_AVAILABLE);
}
Example example = new Example(CollaborativeProject.class);
example.and().orEqualTo("token",token);
example.and().orEqualTo("delFlag",false);
CollaborativeProject collaborativeProject = projectMapper.selectOneByExample(example);
if(collaborativeProject == null){
throw new CustomException(ResultCode.TOKEN_NOT_AVAILABLE);
}
return collaborativeProject;
}
}
package com.reyun.saas.mob.openapi.service.impl;
import com.reyun.saas.common.constants.RoleEnumType;
import com.reyun.saas.common.exception.CustomException;
import com.reyun.saas.common.model.Constant;
import com.reyun.saas.common.restResult.ResultCode;
import com.reyun.saas.mob.openapi.domain.CollaborativeProject;
import com.reyun.saas.mob.openapi.dto.AppInputDTO;
import com.reyun.saas.mob.openapi.service.OpenApiAppService;
import com.reyun.saas.mob.user.dao.AppMapper;
import com.reyun.saas.mob.user.dao.UserMapper;
import com.reyun.saas.mob.user.domain.App;
import com.reyun.saas.mob.user.domain.User;
import com.reyun.saas.mob.user.service.AuthService;
import com.reyun.saas.mob.user.service.NoSqlService;
import com.reyun.saas.mob.util.RoleUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import tk.mybatis.mapper.entity.Example;
import java.util.Date;
import java.util.List;
import java.util.zip.CRC32;
/**
* @author: hanzepeng
* @Date: 2022/02/11/13:37
* @Description: openApi App业务层
*/
@Slf4j
@Service
@Transactional
public class OpenApiAppServiceImpl implements OpenApiAppService {
@Autowired
private AppMapper appMapper;
@Autowired
private AuthService authService;
@Autowired
private UserMapper userMapper;
@Autowired
private NoSqlService noSqlService;
@Override
public App create(AppInputDTO appInputDTO, CollaborativeProject project) {
//校验oid是否存在
String oid = appInputDTO.getOid();
Example example = new Example(User.class);
example.and().orEqualTo("oid", oid);
example.and().orEqualTo("delFlag", false);
User user = userMapper.selectOneByExample(example);
if (user == null) {
throw new CustomException(ResultCode.OID_NOT_EXIST);
} else {
//校验用户角色 通过改接口创建的app用户角色只能是主账号
if (!RoleUtil.isSupperUser(user)) {
throw new CustomException(ResultCode.OID_NOT_EXIST);
}
}
Long rootParent = RoleUtil.getRootUserId(user);
App app = new App();
app.setAppName(appInputDTO.getAppName());
app.setBid(appInputDTO.getBid());
app.setOs(appInputDTO.getStrOS());
app.setRootParent(rootParent);//主用户id
app.setDelFlag(false);//删除标志
app.setDisableFlag(false);//启用标志
app.setCreateTime(new Date());//创建时间
app.setCreateUser(-1L);//创建人id
app.setCreateEmail(project.getProjectName());//创建人邮箱
appMapper.insert(app);
CRC32 crc32 = new CRC32();
crc32.update(app.getBid().getBytes());
String appkey = rootParent + "D" + Long.toHexString(crc32.getValue()) + "N" + app.getId() + "A" + Constant.OSMap.get(app.getOs());
App app1 = new App();
app1.setId(app.getId());
app1.setAppkey(appkey);
appMapper.updateByPrimaryKeySelective(app1);
app.setAppkey(appkey);
//同步ddb appkey——oid.os.bid 关系
noSqlService.putAppInfo(app, oid);
return app;
}
/**
* 根據oid查询app
*/
@Override
public List<App> findAppsByOid(String oid) {
//校验oid对应的用户是否存在
Example userExample = new Example(User.class);
userExample.and().orEqualTo("oid", oid);
userExample.and().orEqualTo("roleCategory", RoleEnumType.SUPER_USER.getKey());
userExample.and().orEqualTo("delFlag", false);
User user = userMapper.selectOneByExample(userExample);
if (user == null || !RoleUtil.isSupperUser(user)) {
throw new CustomException(ResultCode.OID_NOT_EXIST);
}
//根据用户查询app
return authService.getAppByUser(user);
}
}
package com.reyun.saas.mob.openapi.service.impl;
import com.reyun.saas.common.model.NoSqlTableName;
import com.reyun.saas.mob.openapi.domain.CollaborativeProject;
import com.reyun.saas.mob.openapi.service.OpenApiRtaService;
import com.reyun.saas.mob.user.service.NoSqlService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import java.util.Map;
import java.util.Set;
/**
* @author: hanzepeng
* @Date: 2022/02/14/11:03
* @Description: RTA配置业务层
*/
@Slf4j
@Service
@Transactional
public class OpenApiRtaServiceImpl implements OpenApiRtaService {
@Autowired
private NoSqlService noSqlService;
//rta白名单表的主键
private static final String RTA_WHITELIST_KEY = "oid";
//rta 白名单ip属性名
private static final String WHITELIST_IPS_FIELD_NAME = "ip_whitelist";
/**
* 更新合作项目的RTA ip白名单
*/
@Override
public void updateIpWhiteList(CollaborativeProject project, Set<String> ips) {
noSqlService.putSet(NoSqlTableName.RTA_WHITELIST, RTA_WHITELIST_KEY, project.getOid(),
WHITELIST_IPS_FIELD_NAME, ips);
}
/**
* 查询合作项目的rta ip白名单
*/
@Override
public Set<String> ipWhiteList(CollaborativeProject project) {
Set<String> result = null;
Map<String, Object> item2Map = noSqlService.getItem2Map(NoSqlTableName.RTA_WHITELIST, RTA_WHITELIST_KEY, project.getOid());
if(item2Map != null){
Set<String> ips = (Set)item2Map.get(WHITELIST_IPS_FIELD_NAME);
if (!CollectionUtils.isEmpty(ips)){
result = ips;
}
}
return result;
}
}
package com.reyun.saas.mob.openapi.service.impl;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.RandomUtil;
import cn.hutool.crypto.SecureUtil;
import com.reyun.saas.common.constants.RoleEnumType;
import com.reyun.saas.common.exception.CustomException;
import com.reyun.saas.common.model.Constant;
import com.reyun.saas.common.restResult.ResultCode;
import com.reyun.saas.common.util.DingDingSendMsgUtil;
import com.reyun.saas.mob.openapi.dao.CollaborativeProjectUserMapper;
import com.reyun.saas.mob.openapi.domain.CollaborativeProject;
import com.reyun.saas.mob.openapi.domain.CollaborativeProjectUser;
import com.reyun.saas.mob.openapi.dto.SignupDTO;
import com.reyun.saas.mob.openapi.service.OpenApiUserService;
import com.reyun.saas.mob.user.dao.UserAndRoleMapper;
import com.reyun.saas.mob.user.dao.UserCoreConfigMapper;
import com.reyun.saas.mob.user.dao.UserMapper;
import com.reyun.saas.mob.user.domain.User;
import com.reyun.saas.mob.user.domain.UserAndRole;
import com.reyun.saas.mob.user.domain.UserCoreConfig;
import com.reyun.saas.mob.util.IPAddrUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Async;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import tk.mybatis.mapper.entity.Example;
import javax.servlet.http.HttpServletRequest;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
/**
* @author: hanzepeng
* @Date: 2022/02/09/13:56
* @Description: openApi用户业务层
*/
@Slf4j
@Service
@Transactional
public class OpenApiUserServiceImpl implements OpenApiUserService {
@Autowired
private CollaborativeProjectUserMapper projectUserMapper;
@Autowired
private UserMapper userMapper;
@Autowired
private UserCoreConfigMapper coreConfigMapper;
@Autowired
private UserAndRoleMapper userAndRoleMapper;
@Autowired
private PasswordEncoder passwordEncoder;
@Value("${spring.profiles.active}")
private String env;
/**
* openApi注册用户
*/
@Override
public User signup(SignupDTO signupDTO, CollaborativeProject project, HttpServletRequest request) {
//校验邮箱是否存在
Example example = new Example(User.class);
example.and().andEqualTo("username", signupDTO.getUsername());
example.and().andEqualTo("delFlag", false);
User userName = userMapper.selectOneByExample(example);
if (userName != null) {
throw new CustomException(ResultCode.OPENAPI_EMAIL_ALREADY_EXISTED);
}
User user = new User();
if (!StringUtils.isEmpty(signupDTO.getPhone())) {
user.setPhone(signupDTO.getPhone());//手机号
}
if (!StringUtils.isEmpty(signupDTO.getQq())) {
user.setQq(signupDTO.getQq());//QQ
}
if (!StringUtils.isEmpty(signupDTO.getWechat())) {
user.setWechat(signupDTO.getWechat());//微信
}
if (!StringUtils.isEmpty(signupDTO.getActualName())) {
user.setActualName(signupDTO.getActualName());//昵称
}
user.setUsername(signupDTO.getUsername());//邮箱(唯一的)
user.setPassword(passwordEncoder.encode(signupDTO.getPassword()));
user.setCreateUser(-1L);//创建人
user.setCreateTime(new Date());//创建时间
user.setOid(SecureUtil.md5(user.getUsername() + user.getCreateTime().getTime()));//oid
user.setSex(1);//性别
user.setCompany(signupDTO.getCompany());//公司
user.setHeadPortrait("avatar" + RandomUtil.randomInt(1, 27));//随机生存头像 头像在数据库中格式: avater+ 1 ~ 26数字
user.setStatus(Constant.STATUS_ENABLE);//通过改接口创建的用户是已审核的状态
user.setRootParent(0L);//主账号id
user.setRoleCategory(RoleEnumType.SUPER_USER.getKey());//用户角色
user.setIsCreateApp(true);//创建app的权限
user.setAuthConfig(true);//是否拥有权限
user.setDelFlag(false);//删除表示
user.setLeaderParent(0L);//父用户id
user.setUserSource(project.getProjectName());//用户来源
userMapper.insertSelective(user);
//保存合作项目与用户关系
CollaborativeProjectUser projectUser = new CollaborativeProjectUser();
projectUser.setUserId(user.getId());
projectUser.setProjectId(project.getId());
projectUserMapper.insertSelective(projectUser);
//保存用户配置
saveUserConfig(user);
//保存成功之后发送钉钉
pushUserInfo(user,project,request);
return user;
}
/**
* 保存用户配置
*/
private void saveUserConfig(User user){
UserCoreConfig coreConfig = new UserCoreConfig();
coreConfig.setRtaipNum(20);//rta白名单上限
coreConfig.setCreateTime(DateUtil.now());//创建时间
coreConfig.setRootParent(user.getId());//主用户id
coreConfig.setCreateUser(-1L); //创建人
coreConfig.setPackageLevelId(100); //用户套餐
coreConfig.setPubDate(DateUtil.today());//开通时间
coreConfig.setTrackFlow(0L);//自定义流量上限
coreConfig.setAppNum(0);//自定义最大app数量上限
Calendar instance = Calendar.getInstance();
instance.add(Calendar.YEAR,10);
coreConfig.setPastDate(DateUtil.format(instance.getTime(),"yyyy-MM-dd")); //到期时间
coreConfigMapper.insertSelective(coreConfig);
//保存用户与角色对应关系
UserAndRole userAndRole = new UserAndRole();
userAndRole.setRoleId(0L);
userAndRole.setUserId(user.getId());
userAndRoleMapper.insertSelective(userAndRole);
}
/**
* 将用户注册信息推送钉钉
*/
@Async
public void pushUserInfo(User user,CollaborativeProject project,HttpServletRequest request) {
if (env.equals("pro")) {//生产环境生效
StringBuilder sb = new StringBuilder("公司:");
sb.append(user.getCompany()).append("\n")
.append("用户来源: ").append(project.getProjectName()).append("\n")
.append("邮箱:").append(user.getUsername()).append("\n")
.append("姓名:").append(user.getActualName()).append("\n")
.append("电话:").append(user.getPhone()).append("\n")
.append("微信:").append(user.getWechat()).append("\n")
.append("QQ:").append(user.getQq()).append("\n")
.append("IP归属地:").append(IPAddrUtil.getLocationFromIpAddr(request));
// sb.append("开发测试 无视即可");
DingDingSendMsgUtil dingDingSendMsgUtil = new DingDingSendMsgUtil(DingDingSendMsgUtil.TOKEN_USER_REG_MSG, DingDingSendMsgUtil.KEY_USER_REG_MSG);
dingDingSendMsgUtil.sendMsg(sb.toString());
}
}
/**
* 查询合作项目创建的用户
*/
@Override
public List<User> findUsers(CollaborativeProject project) {
List<User> result = null;
//查询合作项目与用户对应关系表
Example example = new Example(CollaborativeProjectUser.class);
example.and().orEqualTo("projectId",project.getId());
List<CollaborativeProjectUser> projectUsers = projectUserMapper.selectByExample(example);
if(!CollectionUtils.isEmpty(projectUsers)){
List<Long> userIds =
projectUsers.stream().map(CollaborativeProjectUser::getUserId).collect(Collectors.toList());
//查询用户
Example userExample = new Example(User.class);
userExample.and().andIn("id",userIds);
userExample.and().orEqualTo("delFlag",false);
userExample.and().orEqualTo("roleCategory",RoleEnumType.SUPER_USER.getKey());
result = userMapper.selectByExample(userExample);
}
return result;
}
}
package com.reyun.saas.mob.user.dao;
import com.reyun.saas.common.core.Mapper;
import com.reyun.saas.mob.user.domain.AfficheAck;
public interface AfficheAckMapper extends Mapper<AfficheAck> {
}
package com.reyun.saas.mob.user.dao;
import com.reyun.saas.common.core.Mapper;
import com.reyun.saas.mob.user.domain.AppAuth;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;
public interface AppAuthMapper extends Mapper<AppAuth> {
/**
* 根据userid删除数据
* @param userId userid
* @return 受影响行数
*/
@Delete("DELETE FROM app_auth WHERE user_id = #{userId}")
public int deleteByUserId(@Param("userId") Long userId);
/**
* 根据appid删除对应的权限
* @param appId appid
* @return
*/
@Delete("DELETE FROM app_auth WHERE app_id = #{appId}")
int deleteByAppid(@Param("appId")Long appId);
}
package com.reyun.saas.mob.user.dao;
import com.reyun.saas.common.core.Mapper;
import com.reyun.saas.mob.user.domain.App;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map;
public interface AppMapper extends Mapper<App> {
List<Map<String,Object>> findAppsBySubAppManager(@Param("appIds") String appIds, @Param("cid") String cid,@Param("os") String os);
List<Map<String,Object>> selectBySuperUser(@Param("rootParent") Long rootParent, @Param("cid") String cid,@Param("os") String os);
List<App> findAppByAppkeyLinkChannel(@Param("appkeys") List<String> appkeys,@Param("isActive") Boolean isActive);
List<App> findAppByAppkeyLinkWorkOrder(@Param("appkeys") List<String> appkeys);
}
package com.reyun.saas.mob.user.dao;
import com.reyun.saas.common.core.Mapper;
import com.reyun.saas.common.restResult.PageParam;
import com.reyun.saas.mob.user.domain.Channel;
import org.apache.ibatis.annotations.Param;
import java.util.Date;
import java.util.List;
import java.util.Map;
public interface ChannelMapper extends Mapper<Channel> {
/**
* 渠道列表
*/
List<Channel> findChannelList(@Param("appkeys")List<String> appkeys, @Param("channelAlias")String channelAlias, @Param("cid")String cid,
@Param("bid")String bid, @Param("isCustomAlias")Boolean isCustomAlias, @Param("query")String query,
@Param("pageParam")PageParam param);
Integer findChannelListCount(@Param("appkeys")List<String> appkeys, @Param("channelAlias")String channelAlias, @Param("cid")String cid,
@Param("bid")String bid, @Param("isCustomAlias")Boolean isCustomAlias, @Param("query")String query);
/**
* 根据appkeys查渠道
*/
List<Channel> findByAppkey(@Param("appkey")String appkeys);
/**
* 根据appkey删除渠道
*/
int deleteChannel(@Param("appkey") String appkey,@Param("modifyUser")Long modifyUser,@Param("modifyDate")Date modifyTime);
List<Map<String,Object>> findByappkeysAndIsActive(@Param("appkeys")List<String> appkeys);
List<Channel> findByappkeysAndActive(@Param("appkeys")List<String> appkeys,@Param("active")Boolean active);
/**
* 根据appkey查找正常(非删除、非停用状态)的cid集合
*/
List<String> findNormalByAppkey(@Param("appkey")String appkey);
}
package com.reyun.saas.mob.user.dao;
import com.reyun.saas.common.core.Mapper;
import com.reyun.saas.mob.user.domain.ConfigParam;
public interface ConfigParamMapper extends Mapper<ConfigParam> {
}
package com.reyun.saas.mob.user.dao;
import com.reyun.saas.common.core.Mapper;
import com.reyun.saas.mob.user.domain.MenuRight;
import com.reyun.saas.mob.user.dto.MenuDTO;
import org.apache.ibatis.annotations.Param;
import java.util.List;
public interface MenuRightMapper extends Mapper<MenuRight> {
List<MenuDTO> getAllMenus();
List<MenuRight> getUserMenus(@Param("userId") Long userId);
}
\ No newline at end of file
package com.reyun.saas.mob.user.dao;
import com.reyun.saas.common.core.Mapper;
import com.reyun.saas.mob.user.domain.PackageLevel;
public interface PackageLevelMapper extends Mapper<PackageLevel> {
}
package com.reyun.saas.mob.user.dao;
import com.reyun.saas.common.core.TkMapper;
import com.reyun.saas.mob.user.domain.RoleAndMenu;
public interface RoleAndMenuMapper extends TkMapper<RoleAndMenu> {
}
\ No newline at end of file
package com.reyun.saas.mob.user.dao;
import com.reyun.saas.common.core.Mapper;
import com.reyun.saas.mob.user.domain.Role;
import com.reyun.saas.mob.user.dto.role.RoleDTO;
import org.apache.ibatis.annotations.Param;
public interface RoleMapper extends Mapper<Role> {
/**
* 获取所有角色信息与权限
* @return ArrayList<Role> 角色信息集合
*/
RoleDTO getMenusByRoleId(@Param("id") Long id);
}
\ No newline at end of file
package com.reyun.saas.mob.user.dao;
import com.reyun.saas.common.core.Mapper;
import com.reyun.saas.mob.user.domain.RtaPackageLevel;
public interface RtaPackageLevelMapper extends Mapper<RtaPackageLevel> {
}
package com.reyun.saas.mob.user.dao;
import com.reyun.saas.common.core.Mapper;
import com.reyun.saas.mob.user.domain.RtaWhiteList;
public interface RtaWhiteListMapper extends Mapper<RtaWhiteList> {
}
package com.reyun.saas.mob.user.dao;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import java.util.List;
import java.util.Map;
/**
* @author: hanzepeng
* @Date: 2021/10/27/17:43
* @Description: 同步sdk策略使用
*/
public interface SdkPolicyMapper {
/**
* 查询在c_policy_config 表中开启的 sdk与策略对应关系
*/
@Select("select t2.policy_name as 'policy_name',t2.sdk_version as 'sdk_version' " +
"from mob_dna_android_policy.c_policy_config t1 " +
"inner join mob_dna_android_policy.c_policy_sdk_version t2 " +
"on t1.policy = t2.policy_name " +
"where t1.`on` = '1'")
List<Map<String,Object>> findAndroidSdkVersionLinkConfig();
@Select("SELECT * FROM mob_dna_android_policy.c_policy_sdk_version WHERE sdk_version = #{sdkVersion}")
List<Map<String,Object>> findPolicyBySdkVersion(@Param("sdkVersion")String sdkVersion);
/**
* 查询 启用 的c_policy_config数据
*/
@Select("SELECT * FROM mob_dna_android_policy.c_policy_config WHERE `on` = '1'")
List<Map<String,Object>> findAndroidSdkPolicyConfigByOn();
@Select("SELECT * FROM mob_dna_android_policy.c_policy_battary WHERE `on` = '1' LIMIT #{page},#{size}")
List<Map<String,Object>> findBattaryPolicyLimit(@Param("page")Integer page, @Param("size")Integer size);
/**
* 查询启用的c_policy_screen策略
*/
@Select("SELECT * FROM mob_dna_android_policy.c_policy_screen WHERE `on` = '1'")
List<Map<String, Object>> findAndroidScreenPolicyByOn();
/**
* 查询启用的c_policy_battary策略
*/
@Select("SELECT * FROM mob_dna_android_policy.c_policy_battary WHERE `on` = '1'")
List<Map<String, Object>> findAndroidBattaryPolicyByOn();
/**
* 查询启用的c_policy_apps策略
* @return
*/
@Select("SELECT * FROM mob_dna_android_policy.c_policy_apps WHERE `on` = '1'")
List<Map<String, Object>> findAndroidAppsPolicyByOn();
/**
* 查询启用的c_policy_env策略
* @return
*/
@Select("SELECT * FROM mob_dna_android_policy.c_policy_env WHERE `on` = '1'")
List<Map<String, Object>> findAndroidEnvPolicyByOn();
/**
* 查询启用的c_policy_mem策略
* @return
*/
@Select("SELECT * FROM mob_dna_android_policy.c_policy_mem WHERE `on` = '1'")
List<Map<String, Object>> findAndroidMemPolicyByOn();
/**
* 查询启用的c_policy_camera策略
* @return
*/
@Select("SELECT * FROM mob_dna_android_policy.c_policy_camera WHERE `on` = '1'")
List<Map<String, Object>> findAndroidCameraPolicyByOn();
/**
* 查询启用的c_policy_bad_apps 策略
* @return
*/
@Select("SELECT * FROM mob_dna_android_policy.c_policy_bad_apps WHERE `on` = '1'")
List<Map<String, Object>> findAndroidBadAppsPolicyByOn();
/**
* 查询启用的c_policy_bad_acc 策略
* @return
*/
@Select("SELECT * FROM mob_dna_android_policy.c_policy_bad_acc WHERE `on` = '1'")
List<Map<String, Object>> findAndroidBadAccPolicyByOn();
/**
* 查询启用的安卓标签表
* @return
*/
@Select("SELECT * FROM mob_dna_android_policy.c_policy_tag_config WHERE `on` = '1'")
List<Map<String, Object>> findAndroidTagConfigByOn();
/**
* 查询启用的c_policy_bad_wifi 策略
* @return
*/
@Select("SELECT * FROM mob_dna_android_policy.c_policy_bad_wifi WHERE `on` = '1'")
List<Map<String, Object>> findAndroidBadWifiByOn();
/**
* 查询在i_policy_config 表中开启的 sdk与策略对应关系
*/
@Select("select t2.policy_name as 'policy_name',t2.sdk_version as 'sdk_version' " +
"from mob_dna_ios_policy.i_policy_config t1 " +
"inner join mob_dna_ios_policy.i_policy_sdk_version t2 " +
"on t1.policy = t2.policy_name " +
"where t1.`on` = '1'")
List<Map<String,Object>> findIosSdkVersionLinkConfig();
/**
* 查询 启用 的i_policy_config数据
*/
@Select("SELECT * FROM mob_dna_ios_policy.i_policy_config WHERE `on` = '1'")
List<Map<String, Object>> findIosSdkPolicyConfigByOn();
/**
* 查询启用的IOS标签表
* @return
*/
@Select("SELECT * FROM mob_dna_ios_policy.i_policy_tag_config WHERE `on` = '1'")
List<Map<String, Object>> findIosTagConfigByOn();
/**
* 查询启用的205策略
*/
@Select("SELECT model,build_ver,lib_vers FROM mob_dna_ios_policy.i_policy_205 WHERE `on` = 1")
List<Map<String, Object>> findIos205PolicyByOn();
}
package com.reyun.saas.mob.user.dao;
import com.reyun.saas.common.core.TkMapper;
import com.reyun.saas.mob.user.domain.UserAndRole;
public interface UserAndRoleMapper extends TkMapper<UserAndRole> {
}
\ No newline at end of file
package com.reyun.saas.mob.user.dao;
import com.reyun.saas.common.core.TkMapper;
import com.reyun.saas.mob.user.domain.UserCoreConfig;
public interface UserCoreConfigMapper extends TkMapper<UserCoreConfig> {
}
package com.reyun.saas.mob.user.dao;
import com.reyun.saas.common.core.Mapper;
import com.reyun.saas.mob.user.domain.User;
import com.reyun.saas.mob.user.dto.user.UserDTO;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import java.util.List;
import java.util.Map;
public interface UserMapper extends Mapper<User> {
/**
* 根据用户名获取权限
* @param username
* @return
*/
UserDTO getRolesByUsername(@Param("username") String username);
@Select("SELECT id,oid FROM user WHERE id = #{userId}")
User findOidById(@Param("userId") Long userId);
/**
* 查询角色的数量
* @param rootParent 主账号id
* @param roleCategory 角色
* @param leaderParent 上级账号id 该参数为null则不被拼接到sql中
* @return
*/
Long findRoleCount(@Param("rootParent")Long rootParent,@Param("roleCategory")Integer roleCategory,@Param("leaderParent")Long leaderParent);
/**
* 根据主账号id查询子账户的状态对应的子账号数量
* @param rootId 主账户id
* @return
*/
List<Map> findStatusCount(@Param("rootId") Long rootId);
@Select("select id from user where root_parent = #{id} or id = #{id}")
List<Long> selectBySuperUser(@Param("id") Long id);
@Select("select id from user where leader_parent = #{id} or id = #{id}")
List<Long> selectBySubManager(@Param("id")Long id);
@Select(" SELECT status,count(id) as 'count' FROM user WHERE leader_parent = #{userId} and del_flag is false GROUP BY status")
List<Map> findStatusCountByManager(@Param("userId") Long userId);
}
package com.reyun.saas.mob.user.dao;
import com.reyun.saas.common.core.Mapper;
import com.reyun.saas.mob.user.domain.ViewColumn;
public interface ViewColumnMapper extends Mapper<ViewColumn> {
}
package com.reyun.saas.mob.user.dao;
import com.reyun.saas.common.core.Mapper;
import com.reyun.saas.mob.user.domain.ViewColumnUser;
public interface ViewColumnUserMapper extends Mapper<ViewColumnUser> {
}
package com.reyun.saas.mob.user.dao;
import com.reyun.saas.common.core.Mapper;
import com.reyun.saas.mob.user.domain.WarningAddressee;
public interface WarningAddresseeMapper extends Mapper<WarningAddressee> {
}
package com.reyun.saas.mob.user.dao;
import com.reyun.saas.common.core.Mapper;
import com.reyun.saas.mob.user.domain.WarningColumn;
public interface WarningColumnMapper extends Mapper<WarningColumn> {
}
package com.reyun.saas.mob.user.dao;
import com.reyun.saas.common.core.Mapper;
import com.reyun.saas.mob.user.domain.WarningConfig;
import com.reyun.saas.mob.user.dto.WarningConfigDTO;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import java.util.List;
import java.util.Map;
public interface WarningConfigMapper extends Mapper<WarningConfig> {
List<WarningConfigDTO> selectTemplateByUserIds(@Param("userIds") String userIds, @Param("email") String email, @Param("searchText") String searchText,@Param("os") String os);
List<WarningConfigDTO> selectConfigByUserIds(@Param("userIds") String userIds, @Param("appkeys") String appkeys, @Param("channelIds") String channelIds, @Param("isusing") Boolean isusing, @Param("appkey") String appkey, @Param("channelId") Long channelId,@Param("os") String os);
@Select("select t0.id,t0.name from warning_config t0 left join app t1 where t0.template is true and t0.del_flag is false and t0.user_id in (${userIds}) and t0.appkey = #{appkey} and t0.cid = #{cid} and t1.os = #{os}")
Map<String,String> selectConfigTemplateByUserIdsAandAppkeyAndCid(@Param("userIds") String userIds, @Param("appkey") String appkey, @Param("cid") String cid,@Param("os") String os);
List<WarningConfigDTO> selectConfigAnalysisByUserIds(@Param("userIds") String userIds, @Param("appkeys") String appkeys, @Param("channelIds") String channelIds, @Param("startDate") String startDate, @Param("endDate") String endDate, @Param("appkey") String appkey, @Param("channelId") Long channelId,@Param("os") String os);
List<WarningConfigDTO> checkWarningReportList();
}
package com.reyun.saas.mob.user.dao;
import com.reyun.saas.common.core.Mapper;
import com.reyun.saas.mob.user.domain.WarningDataInfo;
import com.reyun.saas.mob.user.vo.WarningConfigParam;
import org.apache.ibatis.annotations.Select;
import java.util.List;
public interface WarningDataInfoMapper extends Mapper<WarningDataInfo> {
@Select("select * from warning_data_info where ds >= #{startDate} and ds <= #{endDate} and config_id = #{configId}")
List<WarningDataInfo> selectByConfigId(WarningConfigParam warningConfigParam);
}
package com.reyun.saas.mob.user.dao;
import com.reyun.saas.common.core.Mapper;
import com.reyun.saas.mob.user.domain.WarningAddressee;
import com.reyun.saas.mob.user.domain.WarningInformLog;
import org.apache.ibatis.annotations.Param;
public interface WarningInformLogMapper extends Mapper<WarningInformLog> {
WarningInformLog selectOneByCheckSended(@Param("addressee") WarningAddressee warningAddressee,@Param("date") String today);
}
package com.reyun.saas.mob.user.dao;
import com.reyun.saas.common.core.Mapper;
import com.reyun.saas.mob.user.domain.WorkOrderExport;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map;
public interface WorkOrderMapper extends Mapper<WorkOrderExport> {
/**
* 查询工单创建人
*/
List<Map<String,Object>> findCreateUser(@Param("appkeys") List<String> appkeys);
}
package com.reyun.saas.mob.user.domain;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.persistence.*;
import java.io.Serializable;
/**
* @author: hanzpeneg
* @Date: 2022/03/03/18:33
* @Description: 公告确认信息实体类
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
@Table(name = "affiche_ack")
public class AfficheAck implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
/**
* 公告名称
*/
@Column(name = "affiche_name")
private String afficheName;
/**
* 用户id
*/
@Column(name = "user_id")
private Long userId;
/**
* 确认时间
*/
@Column(name = "ack_time")
private String ackTime;
/**
* 确认时的ip
*/
@Column(name = "ip")
private String ip;
/**
* 确认时的地址
*/
@Column(name = "address")
private String address;
}
package com.reyun.saas.mob.user.domain;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.persistence.*;
import java.io.Serializable;
import java.util.Date;
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
@Table(name = "app")
public class App implements Serializable {
/**
* 主键id
*/
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
/**
*父ID
*/
@Column(name = "root_parent")
private Long rootParent;
/**
* app图标,后台异步抓取
*/
@Column(name = "icon_url")
private String iconUrl;
/**
*应用名称
*/
@Column(name = "app_name")
private String appName;
/**
*应用appkey:mobdna内唯一
*/
private String appkey;
/**
*应用系统:Android或iOS或Harmony
*/
private String os;
/**
*bundle_id(iOS)或package_name(Android)
*/
private String bid;
/**
*0-正常,1-被删除
*/
@Column(name = "del_flag")
private Boolean delFlag;
/**
*0-正常,1-禁用
*/
@Column(name = "disable_flag")
private Boolean disableFlag;
/**
*创建时间
*/
@Column(name = "create_time")
private Date createTime;
/**
*创建人
*/
@Column(name = "create_user")
private Long createUser;
/**
*创建人邮箱
*/
@Column(name = "create_email")
private String createEmail;
/**
*修改时间
*/
@Column(name = "modify_time")
private Date modifyTime;
/**
*修改人
*/
@Column(name = "modify_user")
private Long modifyUser;
}
package com.reyun.saas.mob.user.domain;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.persistence.*;
import java.util.Date;
/**
* @author: hanzepeng
* @Date: 2021/09/29/15:26
* @Description: app权限
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
@Table(name = "app_auth")
public class AppAuth {
/**
* 主键
*/
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
/**
* 用户id
*/
@Column(name = "user_id")
private Long userId;
/**
* appid
*/
@Column(name = "app_id")
private Long appId;
/**
* app权限
*/
@Column(name = "control_auth")
private String controlAuth;
/**
* 用户角色
*/
@Column(name = "role_category")
private Integer roleCategory;
/**
* 权限状态
*/
private Integer status;
/**
* 创建时间
*/
@Column(name = "create_time")
private Date createTime;
/**
* 创建人
*/
@Column(name = "create_user")
private Long createUser;
}
package com.reyun.saas.mob.user.domain;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.persistence.*;
import java.util.Date;
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
@Table(name = "channel")
public class Channel {
/**
* 主键id
*/
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
/**
* appkey
*/
private String appkey;
/**
* app名称
*/
@Transient
private String appName;
/**
* 渠道别名
*/
@Column(name = "channel_alias")
private String channelAlias;
/**
* 渠道id
*/
private String cid;
/**
* bundle_id(iOS)或 package_name(Android)
*/
@Transient
private String bid;
/**
* 从实时同步到web库的时间
*/
@Column(name = "sync_time")
private Date syncTime;
/**
* 修改人
*/
@Column(name = "modify_user")
private Long modifyUser;
/**
* 修改时间
*/
@Column(name = "modify_time")
private Date modifyTime;
/**
* 启用状态 0-未启用 1-启用
*/
private Boolean active;
/**
* 是否自定义过别名 0-未自定义别名 1-自定义过别名
*/
@Column(name = "is_custom_alias")
private Boolean isCustomAlias;
/**
* 删除标志
*/
@Column(name = "del_flag")
private Boolean delFlag;
}
package com.reyun.saas.mob.user.domain;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.persistence.*;
import java.io.Serializable;
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
@Table(name = "config_param")
public class ConfigParam implements Serializable {
/**
* 主键id
*/
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@Column(name = "key_param")
private String keyParam;
@Column(name = "value_param")
private String valueParam;
}
package com.reyun.saas.mob.user.domain;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.persistence.*;
import java.io.Serializable;
import java.util.Date;
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
@Table(name = "menu_right")
@ApiModel(value="MenuRight",description="权限实体类")
public class MenuRight implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@ApiModelProperty(value="权限主键ID")
private Long id;
@Column(name = "parent_id")
@ApiModelProperty(value="父ID")
private Long parentId;
@ApiModelProperty(value="权限名称")
private String name;
@ApiModelProperty(value="排序")
private Integer seq;
@ApiModelProperty(value="访问地址")
private String url;
@ApiModelProperty(value="是否启用 ")
private Integer status;
@ApiModelProperty(value="图标样式")
private String icon;
@ApiModelProperty(value="方法(get、post)")
private String method;
@ApiModelProperty(value="层级")
private Integer grades;
@Column(name = "modify_time")
@ApiModelProperty(value="修改时间")
private Date modifyTime;
@Column(name = "create_time")
@ApiModelProperty(value="创建时间")
private Date createTime;
}
\ No newline at end of file
package com.reyun.saas.mob.user.domain;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.persistence.*;
import java.util.Date;
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
@Table(name = "package_level")
public class PackageLevel {
/**
* 主键
*/
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
/**
* 套餐名
*/
@Column(name = "package_name")
private String packageName;
/**
* 流量包
*/
@Column(name = "track_flow")
private Long trackFlow;
/**
* app数量
*/
@Column(name = "app_num")
private Integer appNum;
/**
* 价格
*/
private Integer price;
/**
* 创建时间
*/
@Column(name = "create_time")
private Date createTime;
}
package com.reyun.saas.mob.user.domain;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.persistence.*;
import java.io.Serializable;
import java.util.Date;
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
@Table(name = "role")
@ApiModel(value="Role",description="角色实体类")
public class Role implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@ApiModelProperty(value="角色主键ID")
private Long id;
@ApiModelProperty(value="角色名称")
private String name;
@ApiModelProperty(value="角色描述")
private String description;
@ApiModelProperty(value="排序")
private Integer seq;
@ApiModelProperty(value="状态:0-禁用,1-启用")
private Integer status;
@Column(name = "create_time")
@ApiModelProperty(value="创建时间")
private Date createTime;
@Column(name = "modify_time")
@ApiModelProperty(value="修改时间")
private Date modifyTime;
}
\ No newline at end of file
package com.reyun.saas.mob.user.domain;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.persistence.Column;
import javax.persistence.Table;
import java.io.Serializable;
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
@Table(name = "role_right")
public class RoleAndMenu implements Serializable {
/**
* 角色id
*/
@Column(name = "role_id")
private Long roleId;
/**
* 菜单id
*/
@Column(name = "menu_id")
private Long menuId;
}
\ No newline at end of file
package com.reyun.saas.mob.user.domain;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.persistence.*;
import java.util.Date;
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
@Table(name = "package_level")
public class RtaPackageLevel {
/**
* 主键
*/
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
/**
* 套餐名
*/
@Column(name = "package_name")
private String packageName;
/**
* 流量包
*/
@Column(name = "track_flow")
private Long trackFlow;
/**
* 价格
*/
private Integer price;
/**
* 创建时间
*/
@Column(name = "create_time")
private Date createTime;
}
package com.reyun.saas.mob.user.domain;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.persistence.*;
import java.util.Date;
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
@Table(name = "rta_white_list")
public class RtaWhiteList {
/**
* 主键id
*/
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
/**
* 所属用户
*/
private String oid;
/**
* 白名单ip
*/
private String ip;
/**
* 备注
*/
@Column(name = "server_remarks")
private String serverRemarks;
/**
* 创建人
*/
@Column(name = "create_user")
private Long createUser;
/**
* 创建时间
*/
@Column(name = "create_time")
private Date createTime;
/**
* 修改人
*/
@Column(name = "modify_user")
private Long modifyUser;
/**
* 修改时间
*/
@Column(name = "modify_time")
private Date modifyTime;
/**
* 删除标志
*/
@Column(name = "del_flag")
private Boolean delFlag;
/**
* 启用状态
*/
private Boolean active;
}
package com.reyun.saas.mob.user.domain;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Data;
import javax.persistence.*;
import java.util.Date;
import java.util.List;
@Data
public class User {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
private String oid;
/**
* 用户名
*/
private String username;
/**
* 密码
*/
@JsonIgnore
private String password;
/**
* 真实姓名
*/
@Column(name = "actual_name")
private String actualName;
/**
* 性别 0:男 1:女
*/
private Integer sex;
/**
* 手机号码
*/
private String phone;
/**
* 公司
*/
private String company;
/**
* QQ
*/
private String qq;
/**
* 微信
*/
private String wechat;
/**
* 用户角色 例如 : 主账号 管理员 等
*/
@Column(name = "role_category")
private Integer roleCategory;
/**
* 所属主账号的id
*/
@Column(name = "root_parent")
private Long rootParent;
/**
* 上级用户
*/
@Column(name = "leader_parent")
private Long leaderParent;
/**
* 账号状态:0-禁用,1-启用,2-待审核,3-过期,4-流量用尽
*/
private Integer status;
/**
* 头像 头像存在前端 这里只保存头像的编号
*/
@Column(name = "head_portrait")
private String headPortrait;
/**
* 创建时间
*/
@Column(name = "create_time")
private Date createTime;
/**
* 创建人
*/
@Column(name = "create_user")
private Long createUser;
/**
* 修改时间
*/
@Column(name = "modify_time")
private Date modifyTime;
/**
* 修改人
*/
@Column(name = "modify_user")
private Long modifyUser;
/**
* 随机密码过期时间 默认为-1 邮箱发送密码后改为对应的到期时间 用户在个人中心修改密码后改为-1
*/
@JsonIgnore
@Column(name = "random_pwd_past_time")
private String randomPwdPastTime;
/**
* 是否可以创建app
*/
@Column(name = "is_create_app")
private Boolean isCreateApp;
/**
* 是否分配过权限
*/
@Column(name = "auth_config")
private Boolean authConfig;
/**
* 用户备注信息
*/
private String remark;
/**
* 用户来源
*/
@Column(name = "user_source")
private String userSource;
/**
* 删除标志
*/
@Column(name = "del_flag")
private Boolean delFlag;
/**
* app权限权限
*/
@Transient
private List<AppAuth> appAuths;
public Long getRealRootParent() {
return rootParent==0?id:rootParent;
}
}
package com.reyun.saas.mob.user.domain;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.persistence.Column;
import javax.persistence.Table;
import java.io.Serializable;
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
@Table(name = "user_role")
public class UserAndRole implements Serializable {
@Column(name = "role_id")
private Long roleId;
@Column(name = "user_id")
private Long userId;
}
\ No newline at end of file
package com.reyun.saas.mob.user.domain;
import lombok.Data;
import javax.persistence.Column;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import java.io.Serializable;
@Data
public class UserCoreConfig implements Serializable {
/**
* 主键ID
*/
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
/**
* 主用户id
*/
@Column(name = "root_parent")
private Long rootParent;
/**
* 开通时间
*/
@Column(name = "pub_date")
private String pubDate;
/**
* 过期时间
*/
@Column(name = "past_date")
private String pastDate;
/**
* 创建app上限数量(附加)-加上套餐的app数量才是全部流量
*/
@Column(name = "app_num")
private Integer appNum;
/**
* 套餐流量(附加)-加上套餐的流量才是全部流量
*/
@Column(name = "track_flow")
private Long trackFlow;
/**
* 套餐id
*/
@Column(name = "package_level_id")
private Integer packageLevelId;
/**
* rta套餐id
*/
@Column(name = "rta_package_level_id")
private Integer rtaPackageLevelId;
/**
* rta白名单ip数量
*/
@Column(name = "rtaip_num")
private Integer rtaipNum;
/**
* 创建时间
*/
@Column(name = "create_time")
private String createTime;
/**
* 创建人-运营人员
*/
@Column(name = "create_user")
private Long createUser;
/**
* 修改时间
*/
@Column(name = "modify_time")
private String modifyTime;
/**
* 修改人-运营人员
*/
@Column(name = "modify_user")
private Long modifyUser;
}
package com.reyun.saas.mob.user.domain;
import lombok.Data;
import javax.persistence.*;
import java.io.Serializable;
@Data
@Table(name = "view_column")
public class ViewColumn implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
private String fieldcode; //字段编码
private String fieldname; //字段名称
private Boolean ischeck; //是否缺省选中
private Boolean isedit; //是否可编辑
private String type;//指标类型
private String genre;
private String menu;//所属模块
@Column(name = "eng_fieldname")
private String engFieldname="";//英文字段名称
}
package com.reyun.saas.mob.user.domain;
import lombok.Data;
import javax.persistence.*;
import java.io.Serializable;
/**
* @desc 记录用户的指标点
*/
@Data
@Table(name = "view_column_user")
public class ViewColumnUser implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@Column(name = "user_id")
private Long userId;
private String os;
private String viewcolumn;
private String menu;
}
package com.reyun.saas.mob.user.domain;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.persistence.*;
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
@ApiModel(value="WarningAddressee",description="收信人")
@Table(name = "warning_addressee")
public class WarningAddressee {
@ApiModelProperty(value="无意义主键")
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@ApiModelProperty(value="预警配置表主键id")
@Column(name = "config_id")
private Long configId;
@ApiModelProperty(value="1:启用、0:停用")
private Boolean isusing;
@ApiModelProperty(value="是否自定义:true自定义、false用户")
private Boolean custom;
@ApiModelProperty(value="推送通知方式:-1全选、1邮件、2短信")
@Column(name = "push_type")
private Integer pushType;
@ApiModelProperty(value="推送频率:1当天仅推送一次2当天每小时均推送")
@Column(name = "push_frequency")
private Integer pushFrequency;
@ApiModelProperty(value="收信人姓名")
@Column(name = "addressee_name")
private String addresseeName;
@ApiModelProperty(value="收信人邮箱")
@Column(name = "addressee_email")
private String addresseeEmail;
@ApiModelProperty(value="收信人手机号")
@Column(name = "addressee_phone")
private String addresseePhone;
}
package com.reyun.saas.mob.user.domain;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.persistence.*;
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
@ApiModel(value="WarningColumn",description="预警指标对码表")
@Table(name = "warning_column")
public class WarningColumn {
@ApiModelProperty(value="无意义主键")
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@ApiModelProperty(value="预警数据名称")
@Column(name = "warning_name")
private String warningName;
@ApiModelProperty(value="预警数据标识")
@Column(name = "warning_code")
private String warningCode;
@ApiModelProperty(value="1数值2百分比")
@Column(name = "field_type")
private String fieldType;
@ApiModelProperty(value="数据库字段名")
@Column(name = "field_code")
private String fieldCode;
@ApiModelProperty(value="-1不限制,1为iOS,2为Android")
private String os;
}
package com.reyun.saas.mob.user.domain;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.persistence.*;
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
@ApiModel(value="WarningConfig",description="预警配置")
public class WarningConfig {
@ApiModelProperty(value="主键ID")
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@ApiModelProperty(value="预警配置名/模板名称")
private String name;
@ApiModelProperty(value="模板名称(同时保存模板时的模板名)")
@Transient
private String templateName;
@ApiModelProperty(value="appkey")
private String appkey;
@ApiModelProperty(value="渠道cid")
@Column(name = "cid")
private String cid;
@ApiModelProperty(value="渠道id")
@Column(name = "channel_id")
private Long channelId;
@ApiModelProperty(value="计算规则:day按天、hour按小时")
@Column(name = "data_cycle_rule")
private String dataCycleRule;
@ApiModelProperty(value="表达式")
private String eval;
@ApiModelProperty(value="关联用户id")
@Column(name = "user_id")
private Long userId;
@ApiModelProperty(value="主用户id")
@Column(name = "root_parent")
private Long rootParent;
@ApiModelProperty(value="1:启用、0:停用 (仅限配置)")
private Boolean isusing;
@ApiModelProperty(value="1:删除、0:正常")
@Column(name = "del_flag")
private Boolean delFlag;
@ApiModelProperty(value="最后修改人email")
@Column(name = "modify_email")
private String modifyEmail;
@ApiModelProperty(value="最后修改时间")
@Column(name = "modify_time")
private String modifyTime;
@ApiModelProperty(value="创建人email")
@Column(name = "create_email")
private String createEmail;
@ApiModelProperty(value="创建时间")
@Column(name = "create_time")
private String createTime;
@ApiModelProperty(value="1为模板,2为正常的配置")
private Boolean template;
@ApiModelProperty(value="备注")
private String remark;
@ApiModelProperty(value="系统类型:1-iOS;2-Android")
private String os;
}
package com.reyun.saas.mob.user.domain;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.persistence.*;
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
@ApiModel(value="WarningDataInfo",description="预警数据信息")
public class WarningDataInfo {
@ApiModelProperty(value="主键ID")
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@ApiModelProperty(value="日期")
private String ds;
@ApiModelProperty(value="预警配置的id")
@Column(name = "config_id")
private Long configId;
@ApiModelProperty(value="触发预警时段")
@Column(name = "time_frame")
private String timeFrame;
@ApiModelProperty(value="总量")
@Column(name = "volume_dose")
private Integer volumeDose;
@ApiModelProperty(value="作弊总数(异常+潜在风险(风险只有Android有))")
@Column(name = "volume_dose_exception_risk")
private Integer volumeDoseExceptionRisk;
@ApiModelProperty(value="作弊总数占比")
@Column(name = "rate_volume_dose_exception_risk")
private Double rateVolumeDoseExceptionRisk;
@ApiModelProperty(value="潜在风险总数")
@Column(name = "volume_dose_potential_risk")
private Integer volumeDosePotentialRisk;
@ApiModelProperty(value="正常总数")
@Column(name = "volume_dose_normal")
private Integer volumeDoseNormal;
@ApiModelProperty(value="异常总数")
@Column(name = "volume_dose_exception")
private Integer volumeDoseException;
@ApiModelProperty(value="异常总数占比")
@Column(name = "rate_volume_dose_exception")
private Double rateVolumeDoseException;
@ApiModelProperty(value="新增总数")
private Integer added;
@ApiModelProperty(value="异常新增")
@Column(name = "added_exception")
private Integer addedException;
@ApiModelProperty(value="异常新增占比")
@Column(name = "rate_added_exception")
private Double rateAddedException;
@ApiModelProperty(value="活跃总数")
private Integer dau;
@ApiModelProperty(value="异常活跃")
@Column(name = "dau_exception")
private Integer dauException;
@ApiModelProperty(value="异常活跃占比")
@Column(name = "rate_dau_exception")
private Double rateDauException;
@ApiModelProperty(value="更新总数")
private Integer updates;
@ApiModelProperty(value="异常更新")
@Column(name = "update_exception")
private Integer updateException;
@ApiModelProperty(value="异常更新占比")
@Column(name = "rate_update_exception")
private Double rateUpdateException;
@ApiModelProperty(value="插入时间")
@Column(name = "create_time")
private String createTime;
@ApiModelProperty(value="1已通知,0未通知")
private Integer informed;
@ApiModelProperty(value="执行时的当前hour")
private Integer hour;
@ApiModelProperty(value="预警阈值")
@Transient
private Integer warningLimit;
}
package com.reyun.saas.mob.user.domain;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.persistence.Column;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
@ApiModel(value="WarningInformLog",description="预警发信记录")
public class WarningInformLog {
@ApiModelProperty(value="无意义主键id")
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@Column(name = "data_info_id")
@ApiModelProperty(value="预警报表信息主键id")
private Long dataInfoId;
@Column(name = "config_id")
@ApiModelProperty(value="预警配置id")
private Long configId;
@ApiModelProperty(value="收信人姓名")
private String name;
@ApiModelProperty(value="收信人邮箱")
private String email;
@ApiModelProperty(value="收信人电话")
private String phone;
@Column(name = "create_time")
@ApiModelProperty(value="创建时间")
private String createTime;
}
package com.reyun.saas.mob.user.domain;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.persistence.*;
import java.util.Date;
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
@Table(name = "work_order_export")
public class WorkOrderExport {
/**
* 主键
*/
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
/**
* 工单名称
*/
@Column(name = "work_order_name")
private String workOrderName;
/**
* appkey
*/
private String appkey;
/**
* app名称
*/
@Transient
private String appName;
/**
* 工单类型
*/
private String type;
/**
* 报表名称
*/
@JsonIgnore
@Column(name = "report_name")
private String reportName;
/**
* 所属模块
*/
private String model;
/**
* 导出条件 json数据
*/
@JsonIgnore
private String source;
/**
* 文件大小
*/
@Column(name = "file_size")
private Long fileSize;
/**
* 开始时间
*/
@Column(name = "begin_date")
private String beginDate;
/**
* 结束时间
*/
@Column(name = "end_date")
private String endDate;
/**
* 创建时间
*/
@Column(name = "create_date")
private Date createDate;
/**
* 创建人id
*/
@Column(name = "create_user_id")
private Long createUserId;
/**
* 创建人
*/
@Transient
private String createUser;
/**
* 工单完成时间
*/
@JsonIgnore
@Column(name = "finish_date")
private Date finishDate;
/**
* 状态
*/
@Column(name = "status")
private String status;
/**
* 删除标识
*/
@Column(name = "del_flag")
private Boolean delFlag;
/**
* 下载人id
*/
@Column(name = "download_user_id")
private Long downloadUserId;
/**
* 下载人
*/
@Transient
private String downloadUser;
/**
* 下载时间
*/
@Column(name = "download_date")
private Date downloadDate;
/**
* 下载人ip
*/
@Column(name = "download_ip")
private String downloadip;
/**
* 异常信息
*/
@JsonIgnore
private String msg;
}
package com.reyun.saas.mob.user.dto;
import com.reyun.saas.mob.user.domain.MenuRight;
import lombok.Data;
import java.util.List;
/**
* @ClassName: LoginOutpDTO
* @Description: TODO
* @date 2019-08-15 15:39
*/
@Data
public class LoginOutpDTO {
/**
* 主键ID
*/
private Long id;
/**
* 主用户唯一oid且不可变
*/
private String oid;
/**
* 用户名
*/
private String username;
/**
* 真实姓名
*/
private String actualName;
/**
* 性别
*/
private int sex;
/**
* 电话
*/
private String phone;
/**
* 公司
*/
private String company;
/**
* 父用户id
*/
private Long rootParent;
/**
* 前端需要显示的菜单
*/
private List<MenuRight> menus;
}
package com.reyun.saas.mob.user.dto;
import com.reyun.saas.mob.user.domain.MenuRight;
import com.reyun.saas.mob.user.domain.Role;
import com.reyun.saas.mob.user.dto.user.UserDTO;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
@NoArgsConstructor
@AllArgsConstructor
@Data
@Builder
public class LoginUserDTO implements Serializable {
/**
* 主键ID
*/
private Long id;
/**
* 用户名
*/
private String username;
/**
* 密码
*/
private String password;
/**
* 真实姓名
*/
private String actualName;
/**
* 性别
*/
private int sex;
/**
* 电话
*/
private String phone;
/**
* 公司
*/
private String company;
/**
* 父用户id
*/
private Long rootParent;
/**
* 启用状态(0-禁用,1-启用)
*/
private Integer status;
/**
* 创建时间
*/
private Date createTime;
/**
* 修改时间
*/
private Date modifyTime;
/**
* 角色
*/
private List<Role> roles;
/**
* 权限菜单
*/
private List<MenuRight> menus;
public static LoginUserDTO user2LoginUserDTO(UserDTO user) {
return LoginUserDTO.builder()
.id(user.getId())
.username(user.getUsername())
.password(user.getPassword())
.actualName(user.getActualName())
.company(user.getCompany())
.rootParent(user.getRootParent())
.phone(user.getPhone())
.status(user.getStatus())
.createTime(user.getCreateTime())
.modifyTime(user.getModifyTime())
.roles(user.getRoles())
.menus(user.getMenus())
.build();
}
}
package com.reyun.saas.mob.user.dto;
import com.reyun.saas.mob.user.domain.Role;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
/**
* @ClassName: MenuDTO
* @Description: 前端展示的菜单
*/
@Data
public class MenuDTO implements Serializable {
private Long id;
private Long parentId;
private String name;
private Integer seq;
private String url;
private Integer status;
private String icon;
private String method;
private Integer grades;
private List<Role> roles;
}
package com.reyun.saas.mob.user.dto;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
/**
* @ClassName: TreeNodeDTO
* @Description: 树节点
* @date 2019-7-24 17:03:22
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
public class TreeNodeDTO implements Serializable, Comparable<TreeNodeDTO> {
private Long id;
private Long parentId;
private String name;
private Boolean checked;
private List<TreeNodeDTO> children = new ArrayList<>();
public void add(TreeNodeDTO node) {
//递归添加节点
if (0 == node.parentId) {
this.children.add(node);
} else if (node.parentId.equals(this.id)) {
this.children.add(node);
} else {
// 递归
for (TreeNodeDTO tmp_node : children) {
tmp_node.add(node);
}
}
}
/**
* 按照 ID 排序
*/
@Override
public int compareTo(TreeNodeDTO o) {
return this.getId().compareTo(o.getId());
}
}
package com.reyun.saas.mob.user.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class WarningConfigDTO {
@ApiModelProperty(value="主键ID")
private Long id;
@ApiModelProperty(value="预警配置名/模板名称")
private String name;
@ApiModelProperty(value="appkey")
private String appkey;
@ApiModelProperty(value="应用名称")
private String appName;
@ApiModelProperty(value="应用系统")
private String os;
@ApiModelProperty(value="渠道id")
private Long channelId;
@ApiModelProperty(value="渠道cid")
private String cid;
@ApiModelProperty(value="渠道别名")
private String channelAlias;
@ApiModelProperty(value="计算规则:day按天、hour按小时")
private String dataCycleRule;
@ApiModelProperty(value="表达式")
private String eval;
@ApiModelProperty(value="1:启用、0:停用 (仅限配置)")
private Boolean isusing;
@ApiModelProperty(value="备注")
private String remark;
@ApiModelProperty(value="创建时间")
private String createTime;
@ApiModelProperty(value="创建人邮箱")
private String createEmail;
@ApiModelProperty(value="创建人姓名")
private String actualName;
@ApiModelProperty(value="收信人")
private String addressNames;
@ApiModelProperty(value="累计预警次数")
private Integer historyCount;
@ApiModelProperty(value="警报发送次数")
private Integer informedSum;
}
package com.reyun.saas.mob.user.dto.role;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* @ClassName: RoleConditionDTO
* @Description: 角色筛选条件
* @date 2019-07-25 10:43
*/
@Data
@ApiModel(value="RoleConditionDTO",description="角色筛选条件")
public class RoleConditionDTO {
@ApiModelProperty(value="角色名称")
private String name;
@ApiModelProperty(value="启用状态(0-禁用,1-启用)")
private Integer status;
}
package com.reyun.saas.mob.user.dto.role;
import com.reyun.saas.mob.user.domain.MenuRight;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
@AllArgsConstructor
@NoArgsConstructor
@Data
@Builder
public class RoleDTO implements Serializable {
private Long id;
private String name;
private Integer seq;
private String description;
private Integer status;
private Date createTime;
private Date modifyTime;
private List<MenuRight> menus;
}
package com.reyun.saas.mob.user.dto.role;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
/**
* @ClassName: RoleInputDTO
* @Description: 角色输入实体类
* @date 2019-07-24 15:29
*/
@Data
@ApiModel(value="RoleInputDTO",description="角色输入类")
public class RoleInputDTO {
@ApiModelProperty(value="主键ID, 新增不传值, 修改传值")
private Long id;
@ApiModelProperty(value="角色描述")
private String description;
@ApiModelProperty(value="角色名称")
private String name;
@ApiModelProperty(value="排序号")
private Integer seq;
@ApiModelProperty(value="启用状态(0-禁用,1-启用)")
private Integer status;
@ApiModelProperty(value="创建时间")
private Date createTime;
@ApiModelProperty(value="修改时间")
private Date modifyTime;
@ApiModelProperty(value="权限ID集合")
private String menuIds;
}
package com.reyun.saas.mob.user.dto.role;
import com.reyun.saas.mob.user.dto.TreeNodeDTO;
import lombok.Data;
import java.util.Date;
import java.util.List;
/**
* @ClassName: RoleOutpDTO
* @Description: TODO
* @date 2019-07-24 15:30
*/
@Data
public class RoleOutpDTO {
/**
* Id
*/
private Long id;
/**
* 角色描述
*/
private String description;
/**
* 角色名称
*/
private String name;
/**
* 排序号
*/
private Integer seq;
/**
* 启用状态(0-禁用,1-启用)
*/
private Integer status;
/**
* 创建时间
*/
private Date createTime;
/**
* 修改时间
*/
private Date modifyTime;
/**
* 权限树
*/
private List<TreeNodeDTO> menus;
}
package com.reyun.saas.mob.user.dto.user;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* @ClassName: UserConditionDTO
* @Description: 用户列表筛选条件
* @date 2019-07-25 10:06
*/
@Data
@ApiModel(value="UserConditionDTO",description="用户筛选条件")
public class UserConditionDTO {
@ApiModelProperty(value="用户名")
private String username;
@ApiModelProperty(value="真实姓名")
private String actualName;
@ApiModelProperty(value="账号状态")
private Integer status;
}
package com.reyun.saas.mob.user.dto.user;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.persistence.Column;
import java.io.Serializable;
@AllArgsConstructor
@NoArgsConstructor
@Data
@Builder
public class UserCoreConfigDTO implements Serializable {
/**
* 主键ID
*/
private Long id;
/**
* 主用户id
*/
private Long rootParent;
/**
* 开通时间
*/
private String pubDate;
/**
* 过期时间
*/
private String pastDate;
/**
* 创建app上限数量(附加)-加上套餐的app数量才是全部流量
*/
private Integer appNum;
/**
* 套餐流量(附加)-加上套餐的流量才是全部流量
*/
private Long trackFlow;
/**
* 套餐id
*/
private Integer packageLevelId;
/**
* rta套餐id
*/
private Integer rtaPackageLevelId;
/**
* 创建时间
*/
private String createTime;
/**
* 创建人-运营人员
*/
private String createUser;
/**
* 修改时间
*/
private String modifyTime;
/**
* 修改人-运营人员
*/
@Column(name = "modify_user")
private String modifyUser;
}
package com.reyun.saas.mob.user.dto.user;
import com.reyun.saas.mob.user.domain.MenuRight;
import com.reyun.saas.mob.user.domain.Role;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
@AllArgsConstructor
@NoArgsConstructor
@Data
@Builder
public class UserDTO implements Serializable {
/**
* 主键ID
*/
private Long id;
/**
* 用户名
*/
private String username;
/**
* 密码
*/
private String password;
/**
* 真实姓名
*/
private String actualName;
/**
* 性别
*/
private int sex;
/**
* 电话
*/
private String phone;
/**
* 公司
*/
private String company;
/**
* QQ
*/
private String qq;
/**
* 微信
*/
private String wechat;
/**
* 头像
*/
private String headPortrait;
/**
* 父用户id
*/
private Long rootParent;
/**
* 启用状态(0-禁用,1-启用)
*/
private Integer status;
/**
* 创建时间
*/
private Date createTime;
/**
* 修改时间
*/
private Date modifyTime;
/**
* 角色
*/
private List<Role> roles;
/**
* 权限菜单
*/
private List<MenuRight> menus;
}
package com.reyun.saas.mob.user.dto.user;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.Email;
import javax.validation.constraints.NotNull;
import java.util.Date;
/**
* @ClassName: UserInputDTO
* @Description: 用户输入类
* @date 2019-07-24 11:21
*/
@Data
@ApiModel(value="UserInputDTO",description="用户输入类")
public class UserInputDTO {
@ApiModelProperty(value="主键ID, 新增不传值, 修改传值")
private Long id;
@NotNull(message = "用户名不能为空")
@Email
@ApiModelProperty(value="用户名")
private String username;
@NotNull(message = "密码不能为空")
@ApiModelProperty(value="密码")
private String password;
@ApiModelProperty(value="真实姓名")
private String actualName;
@ApiModelProperty(value="性别")
private int sex;
@ApiModelProperty(value="电话")
private String phone;
@ApiModelProperty(value="公司")
private String company;
@ApiModelProperty(value="QQ")
private String qq;
@ApiModelProperty(value="微信")
private String wechat;
@ApiModelProperty(value="头像")
private String headPortrait;
@ApiModelProperty(value="用户角色")
private Integer roleCategory;
@ApiModelProperty(value="主用户的id",hidden=true)
private Long rootParent;
@ApiModelProperty(value="上级用户")
private Long leaderParent;
@ApiModelProperty(value="启用状态(0-禁用,1-启用)",hidden=true)
private Integer status;
@ApiModelProperty(value = "客户端id",required =true)
private String clientId;
@ApiModelProperty(value = "客户端密码",required =true)
private String clientSecret;
@ApiModelProperty(value = "范围",hidden=true)
private String scope;
@ApiModelProperty(value = "授权类型",hidden=true)
private String grantType;
@ApiModelProperty(hidden=true)
private String refreshToken;
@ApiModelProperty(value="创建时间",hidden=true)
private Date createTime;
@ApiModelProperty(value="修改时间",hidden=true)
private Date modifyTime;
@ApiModelProperty(value="角色ID 集合(eg: 1,2,5,6)")
private String roleIds;
@ApiModelProperty(value="权限ID 集合(eg: 1,2,5,6)")
private String menuIds;
@ApiModelProperty(value="单点登录系统的token")
private String yucToken;
@ApiModelProperty(value="用户来源")
private Integer userSourceType;
}
package com.reyun.saas.mob.user.dto.user;
import com.fasterxml.jackson.annotation.JsonIgnore;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
/**
* @ClassName: UserOutpDTO
* @Description:
* @date 2019-07-24 11:21
*/
@Data
@ApiModel(value="UserOutpDTO",description="用户输出展示类")
public class UserOutpDTO {
@ApiModelProperty(value="主键ID, 新增不传值, 修改传值")
private Long id;
@ApiModelProperty(value="主用户唯一oid且不可变")
private String oid;
@ApiModelProperty(value="用户名")
private String username;
@JsonIgnore
@ApiModelProperty(value="密码")
private String password;
@ApiModelProperty(value="真实姓名")
private String actualName;
@ApiModelProperty(value="性别")
private int sex;
@ApiModelProperty(value="电话")
private String phone;
@ApiModelProperty(value="公司")
private String company;
@ApiModelProperty(value="QQ")
private String qq;
@ApiModelProperty(value="微信")
private String wechat;
@ApiModelProperty(value="头像")
private String headPortrait;
@ApiModelProperty(value="用户角色")
private Integer roleCategory;
@ApiModelProperty(value ="角色名称")
private String roleName;
@ApiModelProperty(value="主用户的id")
private Long rootParent;
@ApiModelProperty(value="上级用户")
private Long leaderParent;
@ApiModelProperty(value="启用状态(0-禁用,1-启用)")
private Integer status;
@ApiModelProperty(value="创建时间")
private Date createTime;
@ApiModelProperty(value="修改时间")
private Date modifyTime;
@ApiModelProperty(value="到期时间")
private String pastDate;
@ApiModelProperty(value="角色ID 集合(eg: 1,2,5,6)")
private String roleIds;
@ApiModelProperty(value="权限ID 集合(eg: 1,2,5,6)")
private String menuIds;
@ApiModelProperty(value="是否可以创建app")
private Boolean isCreateApp;
@ApiModelProperty(value="是否拥有权限")
private Boolean authConfig;
/**
* 随机密码过期时间 默认为-1 邮箱发送密码后改为对应的到期时间 用户在个人中心修改密码后改为-1
*/
@JsonIgnore
@ApiModelProperty(value="随机密码过期时间 ")
private String randomPwdPastTime;
@ApiModelProperty(value="用户备注信息")
private String remark;
}
package com.reyun.saas.mob.user.dto.user;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* @ClassName: UserPwdDTO
* @Description: 用户密码DTO
* @date 2019-07-25 15:36
*/
@Data
@ApiModel(value="UserPwdDTO",description="用户密码类")
public class UserPwdDTO {
@ApiModelProperty(value="主键ID")
private Long id;
@ApiModelProperty(value="旧密码")
private String password;
@ApiModelProperty(value="新密码")
private String newPassword;
}
package com.reyun.saas.mob.user.dto.user;
import com.reyun.saas.report.vo.ReportParamsVO;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.List;
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class WorkOrderLogDTO {
/**
* 系统
*/
@ApiModelProperty(value="系统类型")
private String os;
/**
* app
*/
@ApiModelProperty(value="appkey")
private String appkey;
/**
* 渠道
*/
@ApiModelProperty(value="渠道")
private List<String> cids;
/**
* 开始时间
*/
@ApiModelProperty(value="开始时间")
private String beginDate;
/**
* 结束时间
*/
@ApiModelProperty(value="结束时间")
private String endDate;
/**
* 所属模块 原来变量名叫model 前端因为变量名重复 要求改变量名
*/
@ApiModelProperty(value="所属模块")
private String workOrderModel;
/**
* 类型 原来变量名叫type 前端因为变量名重复 要求改变量名
*/
@ApiModelProperty(value="工单类型")
private String workOrderType;
/**
* 报表名称
*/
@ApiModelProperty(value="报表名称")
private String reportName;
@ApiModelProperty(value="报表参数")
private ReportParamsVO reportParams;
}
package com.reyun.saas.mob.user.service;
import com.reyun.saas.mob.user.domain.AfficheAck;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
/**
* @author: hanzepeng
* @Date: 2022/03/03/18:40
* @Description: 公告业务层接口
*/
public interface AfficheSerivce {
/**
* 根据用户id 查询公告确认情况
*/
List<AfficheAck> findAckByUserId(Long userId);
/**
* 创建公告确认记录
*/
AfficheAck createAfficheAck(Long loginUserId, String afficheName, HttpServletRequest request);
}
package com.reyun.saas.mob.user.service;
import com.reyun.saas.common.restResult.PageParam;
import com.reyun.saas.common.restResult.RestResult;
import com.reyun.saas.mob.user.domain.App;
import java.util.List;
import java.util.Map;
public interface AppService {
RestResult create(App app, Long loginUserId);
RestResult list(PageParam pageParam, String query, String os, Long createUser, Long loginUserId);
RestResult disable(Long appId, Boolean flag, Long loginUserId);
RestResult delete(Long appId, Long loginUserId);
RestResult update(App app, Long loginUserId);
List<Map<String,Object>> findAppsByUser(Long loginUserId, String os);
List<Map<String,Object>> findAppsByCid(Long loginUserId, String cid, String os);
}
package com.reyun.saas.mob.user.service;
import com.reyun.saas.mob.user.domain.App;
import com.reyun.saas.mob.user.domain.AppAuth;
import com.reyun.saas.mob.user.domain.Channel;
import com.reyun.saas.mob.user.domain.User;
import com.reyun.saas.mob.user.dto.user.UserOutpDTO;
import java.util.List;
/**
* @author: hanzepeng
* @Date: 2021/09/22/16:33
* @Description: 权限业务层
*/
public interface AuthService {
//============= 获取权限start =================
/**
* 查询该用户的app
* @param user 目标用户
* @return
*/
public List<App> getAppByUser(User user);
/**
* 查询该用户的app 包括用户已经删除的qpp
* @param user 目标用户
* @return
*/
public List<App> getAppByUserIncludeDel(User user);
/**
* 根据用户获取一套账号下的所有app数量
* @param user 目标用户
* @return 数量
*/
public Integer getRootUserAppNumByUser(User user);
/**
* 根据用户查询主用户
* @param user 用户
* @return 主用户
*/
public User getRootParent(User user);
//============= 获取权限end =================
//============ 权限校验start ==================
/**
* todo 校验当前登陆用户是否可以操作目标用户
* @param loginUser 当前登录用户
* @param targetUser 目标用户
* @return 如果权限不足返回false
*/
public boolean checkloginUserAuth(User loginUser,User targetUser);
boolean checkloginUserAuth(Long loginUserId,String email);
boolean checkloginUserAuth(Long loginUserId,Long targetUserId);
/**
* todo 校验当前登陆用户是否可以操作目标app
* 校验逻辑:
* 主账号/管理员 用appid查询出app 拿主账号id和app的root_parent字段比较 比较通过为有权限
* 其他角色 以userid 和 appid 为条件去app_auth表中查询数据 查到数据为有权限
*
* @param user 目标用户
* @param appId 目标app
* @return 是否可以操作 true为可以操作 false为无法操作
*/
public boolean checkUserAppAuth(User user,Long appId);
/**
* todo 校验当前登陆用户是否可以操作目标app
* 校验逻辑:
* 主账号/管理员 用appkey查询出app 拿主账号id和app的root_parent字段比较 比较通过为有权限
* 其他角色 用appkey查询出app 再用userid 和 appid 为条件去app_auth表中查询数据 查到数据为有权限
*
* @param user 当前登录用户
* @param appkey 目标app
* @return 是否可以操作 true为可以操作 false为无法操作
*/
public boolean checkUserAppAuth(User user,String appkey);
/**
* todo 过滤当前登陆用户没有权限的app
* 逻辑:
* 主要过滤逻辑是操作查询app的条件 该方法不会返回空
* 主账号/管理员: app表查询条件 where id in #{appids} and root_parent = #{rootParent} and del_flag is false
* 其他角色: app_auth表查询条件 where user_id = #{userId} and app_id in (#{appids}) and status = 1 之后根据查出来的app权限再去查app表
*
* @param user 目标用户
* @param appIds 待过滤app
* @return 过滤后用户有权限的app集合
*/
public List<App> filterUserAppAuthByAppId(User user, List<Long> appIds);
/**
* todo 过滤当前登陆用户没有权限的app
* 逻辑:
* 主要过滤逻辑是操作查询app的条件 该方法不会返回空
* 主账号/管理员: app表查询条件 where root_parent = #{rootParent} and appkey in (#{appkeys}) and del_flag is false
* 其他角色: app_auth表查询条件 where user_id = #{userId} and status = 1 查询出来权限之后封装appids
* 再去app表中 where id in (#{appAuth.appids}) and appkey in (appkeys) and del_flag is false
*
* @param user 目标用户
* @param appkeys 待过滤app
* @return 过滤后用户有权限的app集合
*/
public List<App> filterUserAppAuthByAppkey(User user, List<String> appkeys);
/**
* 校验用户是否拥有产品权限
* @param userOutpDTO 目标用户
* @return true为拥有权限 false为没有权限
*/
boolean isPossessAppAuth(UserOutpDTO userOutpDTO);
/**
* todo 校验用户渠道权限
*/
boolean checkUserChannelAuth(User user,Long channelId);
/**
* todo 过滤当前登陆用户没有权限的app
*/
List<Channel> filterUserChannelAuthByChannelId(User user,List<Long> channelIds);
//============ 权限校验end ==================
//============== 其他 ======================
/**
* 追加app权限
* @param user 用户
* @param app 要追加的app权限
* @return
*/
int appendAuth(User user, App app);
/**
* 根据用户查询app权限
* @param user 目标用户
* @return 权限
*/
List<AppAuth> findAppAuthByUser(User user);
/**
* 删除appauth表中的app权限
* @param appId appid
* @return 影响行数
*/
int deleteAppAuth(Long appId);
/**
* 功能描述:查询用户的所有有操作权限子用户id,包括本用户
*/
List<Long> getChildUserIdsAndOwn(Long userId);
/**
* 功能描述:查找user下的app,如果os=null则查全部平台,disable=null则查全部启用关闭状态的app
*/
List<App> getAppByUserAndOs(User user, String os,Boolean disable);
/**
* 功能描述:查找user下的渠道,如果os=null则查全部平台渠道,active=null则查全部启用关闭状态的渠道
*/
List<Channel> getChannelByUserAndOs(User user, String os,Boolean active);
}
package com.reyun.saas.mob.user.service;
import com.reyun.saas.common.restResult.RestResult;
import java.util.List;
import java.util.Map;
public interface ChannelService {
/**
* 渠道列表
* @param map 筛选条件
* @param loginUserId 当前登录用户id
* @return
*/
public RestResult list(Map<String,Object> map,Long loginUserId);
/**
* bid的筛选条件下拉列表
* 返回的结果为 " appname | bid " 的样式
* @param loginUserId 当前登录用户id
* @return
*/
RestResult appAndBidScreeningList(Long loginUserId);
/**
* 其他筛选条件下拉列表
* @param key 下拉列表类型
* @param bid 应用包名
* @param cid 渠道id
* @param channelAlias 渠道别名
* @param loginUserId 当前登录用户id
* @return
*/
public RestResult screeningList(String key,String bid,String cid,String channelAlias, Long loginUserId);
/**
* 修改渠道启用 / 禁用状态
* @param channelId 渠道id
* @param loginUserId 当前登录用户id
* @param status 启用状态 启用: true 禁用false
* @return
*/
public RestResult updateActiveStatus(Long channelId,Long loginUserId,Boolean status);
/**
* 修改渠道别名 支持批量修改
* 修改单个渠道 渠道id参数是size为1的集合
* @param map 渠道的id (List<Long>)
* @param loginUserId 当前登录用户id
* @return
*/
public RestResult updateChannelName(Map<String,Object> map, Long loginUserId);
/**
* 根据appkey查询渠道
* 目前用于工单中心的创建工单条件的下拉列表
* @param appkey appkey
* @param loginUserId 当前登录用户id
* @return
*/
RestResult findChannel(String appkey, Long loginUserId);
/**
* 功能描述:根据appkey查询关联用户下正常状态的渠道
*/
List<Map<String,Object>> findChannelsByAppkey(Long loginUserId, String appkey, String os);
}
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment