数据源管理
parent
da5642e477
commit
3045e343e2
|
@ -0,0 +1,65 @@
|
||||||
|
package com.muyu.common.core.utils;
|
||||||
|
|
||||||
|
import org.apache.commons.lang3.ObjectUtils;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author yangle
|
||||||
|
* @description: 对象工具类
|
||||||
|
* @Date 2023-10-9 下午 04:56
|
||||||
|
*/
|
||||||
|
public class ObjUtils {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 兼容
|
||||||
|
* CharSequence: 如果长度为零,则认为为空。
|
||||||
|
* Array: 如果长度为零,则认为为空。
|
||||||
|
* Collection: 如果元素为零,则认为为空。
|
||||||
|
* Map: 如果键值映射为零,则认为为空。
|
||||||
|
* @param o 对象
|
||||||
|
* @return 如果对象具有受支持的类型并且为空或null,则为true,否则为false
|
||||||
|
*/
|
||||||
|
public static boolean notNull(Object o){
|
||||||
|
return ObjectUtils.isNotEmpty(o);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 判断long类型不为0
|
||||||
|
* @param val 值
|
||||||
|
* @return 返回值不为0
|
||||||
|
*/
|
||||||
|
public static boolean notNull(Long val){
|
||||||
|
return ObjectUtils.isNotEmpty(val) && val != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 判断Integer类型不为0
|
||||||
|
* @param val 值
|
||||||
|
* @return 返回值不为0
|
||||||
|
*/
|
||||||
|
public static boolean notNull(Integer val){
|
||||||
|
return ObjectUtils.isNotEmpty(val) && val != 0;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 判断BigDecimal类型不为0
|
||||||
|
* @param val 值
|
||||||
|
* @return 返回值不为0
|
||||||
|
*/
|
||||||
|
public static boolean notNull(BigDecimal val){
|
||||||
|
return ObjectUtils.isNotEmpty(val) && val.doubleValue() == 0.00;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 判断BigDecimal类型不为0
|
||||||
|
* @param val 值
|
||||||
|
* @return 返回值不为0
|
||||||
|
*/
|
||||||
|
public static boolean notChildNull(Object[] val){
|
||||||
|
for (Object o : val) {
|
||||||
|
if (!notNull(o)){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,10 @@
|
||||||
|
因为每个数据库的地址数据库名不同
|
||||||
|
找到多数据MybatisPlus多数据源依赖
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.baomidou</groupId>
|
||||||
|
<artifactId>dynamic-datasource-spring-boot-starter</artifactId>
|
||||||
|
<version>3.3.1</version>
|
||||||
|
</dependency>
|
||||||
|
在spring字段下添加datasource字段 用来区分不同的数据库
|
||||||
|
在业务层上添加@DS注解(区分名)
|
||||||
|
一个业务类不能同时调用多个数据源 解决方法是将业务类拆分 组合成多个业务类来连接多个数据库
|
|
@ -0,0 +1,19 @@
|
||||||
|
package com.muyu.kvt.domain;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 数据库类型 dataType
|
||||||
|
*
|
||||||
|
* @author LeYang
|
||||||
|
* on 2024/4/21
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
public class DataType {
|
||||||
|
private Integer id;
|
||||||
|
private String typeName;
|
||||||
|
}
|
|
@ -0,0 +1,185 @@
|
||||||
|
package com.muyu.kvt.domain;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import com.muyu.kvt.domain.req.KvtEditReq;
|
||||||
|
import com.muyu.kvt.domain.req.KvtQueryReq;
|
||||||
|
import com.muyu.kvt.domain.req.KvtSaveReq;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.experimental.SuperBuilder;
|
||||||
|
import io.swagger.annotations.*;
|
||||||
|
import com.muyu.common.core.annotation.Excel;
|
||||||
|
|
||||||
|
import com.muyu.common.core.web.domain.BaseEntity;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* kvt
|
||||||
|
对象 kvt
|
||||||
|
*
|
||||||
|
* @author muyu
|
||||||
|
* @date 2024-04-20
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@SuperBuilder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
@TableName("kvt")
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@ApiModel(value = "Kvt", description = "kvt")
|
||||||
|
public class Kvt extends BaseEntity {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/** 主键 */
|
||||||
|
@TableId(value = "id",type = IdType.AUTO)
|
||||||
|
@ApiModelProperty(name = "主键", value = "主键")
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
/** 接入源名称 */
|
||||||
|
@Excel(name = "接入源名称")
|
||||||
|
@ApiModelProperty(name = "接入源名称", value = "接入源名称")
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
/** 数据来源系统名称 */
|
||||||
|
@Excel(name = "数据来源系统名称")
|
||||||
|
@ApiModelProperty(name = "数据来源系统名称", value = "数据来源系统名称")
|
||||||
|
private String systemName;
|
||||||
|
|
||||||
|
/** 数据接入类型 */
|
||||||
|
@Excel(name = "数据接入类型")
|
||||||
|
@ApiModelProperty(name = "数据接入类型", value = "数据接入类型")
|
||||||
|
private Long type;
|
||||||
|
|
||||||
|
/** 主机地址 */
|
||||||
|
@Excel(name = "主机地址")
|
||||||
|
@ApiModelProperty(name = "主机地址", value = "主机地址")
|
||||||
|
private String host;
|
||||||
|
|
||||||
|
/** 端口地址 */
|
||||||
|
@Excel(name = "端口地址")
|
||||||
|
@ApiModelProperty(name = "端口地址", value = "端口地址")
|
||||||
|
private String port;
|
||||||
|
|
||||||
|
/** 数据库名称 */
|
||||||
|
@Excel(name = "数据库名称")
|
||||||
|
@ApiModelProperty(name = "数据库名称", value = "数据库名称")
|
||||||
|
private String databaseName;
|
||||||
|
|
||||||
|
/** 数据连接参数 */
|
||||||
|
@Excel(name = "数据连接参数")
|
||||||
|
@ApiModelProperty(name = "数据连接参数", value = "数据连接参数")
|
||||||
|
private String connectionParam;
|
||||||
|
|
||||||
|
/** 初始连接数量 */
|
||||||
|
@Excel(name = "初始连接数量")
|
||||||
|
@ApiModelProperty(name = "初始连接数量", value = "初始连接数量")
|
||||||
|
private Long initNum;
|
||||||
|
|
||||||
|
/** 最大连接数量 */
|
||||||
|
@Excel(name = "最大连接数量")
|
||||||
|
@ApiModelProperty(name = "最大连接数量", value = "最大连接数量")
|
||||||
|
private Long maxNum;
|
||||||
|
|
||||||
|
/** 最大等待时间 */
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||||
|
@Excel(name = "最大等待时间", width = 30, dateFormat = "yyyy-MM-dd")
|
||||||
|
@ApiModelProperty(name = "最大等待时间", value = "最大等待时间")
|
||||||
|
private Date maxWaitTime;
|
||||||
|
|
||||||
|
/** 最大等待次数 */
|
||||||
|
@Excel(name = "最大等待次数")
|
||||||
|
@ApiModelProperty(name = "最大等待次数", value = "最大等待次数")
|
||||||
|
private Long maxWaitSize;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户名
|
||||||
|
*/
|
||||||
|
@Excel(name = "用户名")
|
||||||
|
@ApiModelProperty(name = "用户名",value = "用户名")
|
||||||
|
private String username;
|
||||||
|
/**
|
||||||
|
* 密码
|
||||||
|
*/
|
||||||
|
@Excel(name = "密码")
|
||||||
|
@ApiModelProperty(name = "密码",value = "密码")
|
||||||
|
private String password;
|
||||||
|
|
||||||
|
@Excel(name = "数据库类型")
|
||||||
|
@ApiModelProperty(name = "数据库类型",value = "数据库类型")
|
||||||
|
private Integer dateTypeId;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询构造器
|
||||||
|
*/
|
||||||
|
public static Kvt queryBuild( KvtQueryReq kvtQueryReq){
|
||||||
|
return Kvt.builder()
|
||||||
|
.name(kvtQueryReq.getName())
|
||||||
|
.systemName(kvtQueryReq.getSystemName())
|
||||||
|
.type(kvtQueryReq.getType())
|
||||||
|
.host(kvtQueryReq.getHost())
|
||||||
|
.port(kvtQueryReq.getPort())
|
||||||
|
.databaseName(kvtQueryReq.getDatabaseName())
|
||||||
|
.connectionParam(kvtQueryReq.getConnectionParam())
|
||||||
|
.initNum(kvtQueryReq.getInitNum())
|
||||||
|
.maxNum(kvtQueryReq.getMaxNum())
|
||||||
|
.maxWaitTime(kvtQueryReq.getMaxWaitTime())
|
||||||
|
.maxWaitSize(kvtQueryReq.getMaxWaitSize())
|
||||||
|
.username(kvtQueryReq.getUsername())
|
||||||
|
.password(kvtQueryReq.getPassword())
|
||||||
|
.dateTypeId(kvtQueryReq.getDateTypeId())
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 添加构造器
|
||||||
|
*/
|
||||||
|
public static Kvt saveBuild(KvtSaveReq kvtSaveReq){
|
||||||
|
return Kvt.builder()
|
||||||
|
.name(kvtSaveReq.getName())
|
||||||
|
.systemName(kvtSaveReq.getSystemName())
|
||||||
|
.type(kvtSaveReq.getType())
|
||||||
|
.host(kvtSaveReq.getHost())
|
||||||
|
.port(kvtSaveReq.getPort())
|
||||||
|
.databaseName(kvtSaveReq.getDatabaseName())
|
||||||
|
.connectionParam(kvtSaveReq.getConnectionParam())
|
||||||
|
.initNum(kvtSaveReq.getInitNum())
|
||||||
|
.maxNum(kvtSaveReq.getMaxNum())
|
||||||
|
.maxWaitTime(kvtSaveReq.getMaxWaitTime())
|
||||||
|
.maxWaitSize(kvtSaveReq.getMaxWaitSize())
|
||||||
|
.username(kvtSaveReq.getUsername())
|
||||||
|
.password(kvtSaveReq.getPassword())
|
||||||
|
.dateTypeId(kvtSaveReq.getDateTypeId())
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改构造器
|
||||||
|
*/
|
||||||
|
public static Kvt editBuild(Long id, KvtEditReq kvtEditReq){
|
||||||
|
return Kvt.builder()
|
||||||
|
.id(id)
|
||||||
|
.name(kvtEditReq.getName())
|
||||||
|
.systemName(kvtEditReq.getSystemName())
|
||||||
|
.type(kvtEditReq.getType())
|
||||||
|
.host(kvtEditReq.getHost())
|
||||||
|
.port(kvtEditReq.getPort())
|
||||||
|
.databaseName(kvtEditReq.getDatabaseName())
|
||||||
|
.connectionParam(kvtEditReq.getConnectionParam())
|
||||||
|
.initNum(kvtEditReq.getInitNum())
|
||||||
|
.maxNum(kvtEditReq.getMaxNum())
|
||||||
|
.maxWaitTime(kvtEditReq.getMaxWaitTime())
|
||||||
|
.maxWaitSize(kvtEditReq.getMaxWaitSize())
|
||||||
|
.username(kvtEditReq.getUsername())
|
||||||
|
.password(kvtEditReq.getPassword())
|
||||||
|
.dateTypeId(kvtEditReq.getDateTypeId())
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,86 @@
|
||||||
|
package com.muyu.kvt.domain.req;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.experimental.SuperBuilder;
|
||||||
|
import io.swagger.annotations.*;
|
||||||
|
import com.muyu.common.core.web.domain.BaseEntity;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* kvt
|
||||||
|
对象 kvt
|
||||||
|
*
|
||||||
|
* @author muyu
|
||||||
|
* @date 2024-04-20
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@SuperBuilder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
@ApiModel(value = "KvtEditReq", description = "kvt ")
|
||||||
|
public class KvtEditReq extends BaseEntity {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/** 接入源名称 */
|
||||||
|
@ApiModelProperty(name = "接入源名称", value = "接入源名称")
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
/** 数据来源系统名称 */
|
||||||
|
@ApiModelProperty(name = "数据来源系统名称", value = "数据来源系统名称")
|
||||||
|
private String systemName;
|
||||||
|
|
||||||
|
/** 数据接入类型 */
|
||||||
|
@ApiModelProperty(name = "数据接入类型", value = "数据接入类型")
|
||||||
|
private Long type;
|
||||||
|
|
||||||
|
/** 主机地址 */
|
||||||
|
@ApiModelProperty(name = "主机地址", value = "主机地址")
|
||||||
|
private String host;
|
||||||
|
|
||||||
|
/** 端口地址 */
|
||||||
|
@ApiModelProperty(name = "端口地址", value = "端口地址")
|
||||||
|
private String port;
|
||||||
|
|
||||||
|
/** 数据库名称 */
|
||||||
|
@ApiModelProperty(name = "数据库名称", value = "数据库名称")
|
||||||
|
private String databaseName;
|
||||||
|
|
||||||
|
/** 数据连接参数 */
|
||||||
|
@ApiModelProperty(name = "数据连接参数", value = "数据连接参数")
|
||||||
|
private String connectionParam;
|
||||||
|
|
||||||
|
/** 初始连接数量 */
|
||||||
|
@ApiModelProperty(name = "初始连接数量", value = "初始连接数量")
|
||||||
|
private Long initNum;
|
||||||
|
|
||||||
|
/** 最大连接数量 */
|
||||||
|
@ApiModelProperty(name = "最大连接数量", value = "最大连接数量")
|
||||||
|
private Long maxNum;
|
||||||
|
|
||||||
|
/** 最大等待时间 */
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||||
|
@ApiModelProperty(name = "最大等待时间", value = "最大等待时间")
|
||||||
|
private Date maxWaitTime;
|
||||||
|
|
||||||
|
/** 最大等待次数 */
|
||||||
|
@ApiModelProperty(name = "最大等待次数", value = "最大等待次数")
|
||||||
|
private Long maxWaitSize;
|
||||||
|
/*
|
||||||
|
用户名
|
||||||
|
*/
|
||||||
|
@ApiModelProperty(name = "用户名",value = "用户名")
|
||||||
|
public String username;
|
||||||
|
/*
|
||||||
|
密码
|
||||||
|
*/
|
||||||
|
@ApiModelProperty(name = "密码",value = "密码")
|
||||||
|
public String password;
|
||||||
|
|
||||||
|
@ApiModelProperty(name = "数据库类型",value = "数据库类型")
|
||||||
|
private Integer dateTypeId;
|
||||||
|
}
|
|
@ -0,0 +1,88 @@
|
||||||
|
package com.muyu.kvt.domain.req;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
|
import com.muyu.common.core.annotation.Excel;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.experimental.SuperBuilder;
|
||||||
|
import io.swagger.annotations.*;
|
||||||
|
import com.muyu.common.core.web.domain.BaseEntity;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* kvt
|
||||||
|
对象 kvt
|
||||||
|
*
|
||||||
|
* @author muyu
|
||||||
|
* @date 2024-04-20
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@SuperBuilder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
@ApiModel(value = "KvtQueryReq", description = "kvt ")
|
||||||
|
public class KvtQueryReq extends BaseEntity {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/** 接入源名称 */
|
||||||
|
@ApiModelProperty(name = "接入源名称", value = "接入源名称")
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
/** 数据来源系统名称 */
|
||||||
|
@ApiModelProperty(name = "数据来源系统名称", value = "数据来源系统名称")
|
||||||
|
private String systemName;
|
||||||
|
|
||||||
|
/** 数据接入类型 */
|
||||||
|
@ApiModelProperty(name = "数据接入类型", value = "数据接入类型")
|
||||||
|
private Long type;
|
||||||
|
|
||||||
|
/** 主机地址 */
|
||||||
|
@ApiModelProperty(name = "主机地址", value = "主机地址")
|
||||||
|
private String host;
|
||||||
|
|
||||||
|
/** 端口地址 */
|
||||||
|
@ApiModelProperty(name = "端口地址", value = "端口地址")
|
||||||
|
private String port;
|
||||||
|
|
||||||
|
/** 数据库名称 */
|
||||||
|
@ApiModelProperty(name = "数据库名称", value = "数据库名称")
|
||||||
|
private String databaseName;
|
||||||
|
|
||||||
|
/** 数据连接参数 */
|
||||||
|
@ApiModelProperty(name = "数据连接参数", value = "数据连接参数")
|
||||||
|
private String connectionParam;
|
||||||
|
|
||||||
|
/** 初始连接数量 */
|
||||||
|
@ApiModelProperty(name = "初始连接数量", value = "初始连接数量")
|
||||||
|
private Long initNum;
|
||||||
|
|
||||||
|
/** 最大连接数量 */
|
||||||
|
@ApiModelProperty(name = "最大连接数量", value = "最大连接数量")
|
||||||
|
private Long maxNum;
|
||||||
|
|
||||||
|
/** 最大等待时间 */
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||||
|
@ApiModelProperty(name = "最大等待时间", value = "最大等待时间")
|
||||||
|
private Date maxWaitTime;
|
||||||
|
|
||||||
|
/** 最大等待次数 */
|
||||||
|
@ApiModelProperty(name = "最大等待次数", value = "最大等待次数")
|
||||||
|
private Long maxWaitSize;
|
||||||
|
/*
|
||||||
|
用户名
|
||||||
|
*/
|
||||||
|
@ApiModelProperty(name = "用户名",value = "用户名")
|
||||||
|
public String username;
|
||||||
|
/*
|
||||||
|
密码
|
||||||
|
*/
|
||||||
|
@ApiModelProperty(name = "密码",value = "密码")
|
||||||
|
public String password;
|
||||||
|
|
||||||
|
|
||||||
|
@ApiModelProperty(name = "数据库类型",value = "数据库类型")
|
||||||
|
private Integer dateTypeId;
|
||||||
|
}
|
|
@ -0,0 +1,103 @@
|
||||||
|
package com.muyu.kvt.domain.req;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.experimental.SuperBuilder;
|
||||||
|
import io.swagger.annotations.*;
|
||||||
|
import com.muyu.common.core.web.domain.BaseEntity;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* kvt
|
||||||
|
对象 kvt
|
||||||
|
*
|
||||||
|
* @author muyu
|
||||||
|
* @date 2024-04-20
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@SuperBuilder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
@ApiModel(value = "KvtSaveReq", description = "kvt")
|
||||||
|
public class KvtSaveReq extends BaseEntity {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/** 主键 */
|
||||||
|
|
||||||
|
@ApiModelProperty(name = "主键", value = "主键")
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
/** 接入源名称 */
|
||||||
|
|
||||||
|
@ApiModelProperty(name = "接入源名称", value = "接入源名称")
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
/** 数据来源系统名称 */
|
||||||
|
|
||||||
|
@ApiModelProperty(name = "数据来源系统名称", value = "数据来源系统名称")
|
||||||
|
private String systemName;
|
||||||
|
|
||||||
|
/** 数据接入类型 */
|
||||||
|
|
||||||
|
@ApiModelProperty(name = "数据接入类型", value = "数据接入类型")
|
||||||
|
private Long type;
|
||||||
|
|
||||||
|
/** 主机地址 */
|
||||||
|
|
||||||
|
@ApiModelProperty(name = "主机地址", value = "主机地址")
|
||||||
|
private String host;
|
||||||
|
|
||||||
|
/** 端口地址 */
|
||||||
|
|
||||||
|
@ApiModelProperty(name = "端口地址", value = "端口地址")
|
||||||
|
private String port;
|
||||||
|
|
||||||
|
/** 数据库名称 */
|
||||||
|
|
||||||
|
@ApiModelProperty(name = "数据库名称", value = "数据库名称")
|
||||||
|
private String databaseName;
|
||||||
|
|
||||||
|
/** 数据连接参数 */
|
||||||
|
|
||||||
|
@ApiModelProperty(name = "数据连接参数", value = "数据连接参数")
|
||||||
|
private String connectionParam;
|
||||||
|
|
||||||
|
/** 初始连接数量 */
|
||||||
|
|
||||||
|
@ApiModelProperty(name = "初始连接数量", value = "初始连接数量")
|
||||||
|
private Long initNum;
|
||||||
|
|
||||||
|
/** 最大连接数量 */
|
||||||
|
|
||||||
|
@ApiModelProperty(name = "最大连接数量", value = "最大连接数量")
|
||||||
|
private Long maxNum;
|
||||||
|
|
||||||
|
/** 最大等待时间 */
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||||
|
|
||||||
|
@ApiModelProperty(name = "最大等待时间", value = "最大等待时间")
|
||||||
|
private Date maxWaitTime;
|
||||||
|
|
||||||
|
/** 最大等待次数 */
|
||||||
|
|
||||||
|
@ApiModelProperty(name = "最大等待次数", value = "最大等待次数")
|
||||||
|
private Long maxWaitSize;
|
||||||
|
|
||||||
|
/*
|
||||||
|
用户名
|
||||||
|
*/
|
||||||
|
@ApiModelProperty(name = "用户名",value = "用户名")
|
||||||
|
public String username;
|
||||||
|
/*
|
||||||
|
密码
|
||||||
|
*/
|
||||||
|
@ApiModelProperty(name = "密码",value = "密码")
|
||||||
|
public String password;
|
||||||
|
|
||||||
|
@ApiModelProperty(name = "数据库类型",value = "数据库类型")
|
||||||
|
private Integer dateTypeId;
|
||||||
|
}
|
|
@ -0,0 +1,20 @@
|
||||||
|
<?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">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<parent>
|
||||||
|
<groupId>com.muyu</groupId>
|
||||||
|
<artifactId>muyu-kvt</artifactId>
|
||||||
|
<version>3.6.3</version>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<artifactId>muyu-kvt-remote</artifactId>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<maven.compiler.source>17</maven.compiler.source>
|
||||||
|
<maven.compiler.target>17</maven.compiler.target>
|
||||||
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
</project>
|
|
@ -0,0 +1,23 @@
|
||||||
|
package com.muyu.kvt;
|
||||||
|
|
||||||
|
import com.muyu.common.security.annotation.EnableCustomConfig;
|
||||||
|
import com.muyu.common.security.annotation.EnableMyFeignClients;
|
||||||
|
import com.muyu.common.swagger.annotation.EnableCustomSwagger2;
|
||||||
|
import org.springframework.boot.SpringApplication;
|
||||||
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* MuyuApplication
|
||||||
|
*
|
||||||
|
* @author LeYang
|
||||||
|
* on 2024/4/21
|
||||||
|
*/
|
||||||
|
@EnableCustomConfig
|
||||||
|
@EnableCustomSwagger2
|
||||||
|
@EnableMyFeignClients
|
||||||
|
@SpringBootApplication
|
||||||
|
public class MuyuApplication {
|
||||||
|
public static void main(String[] args) {
|
||||||
|
SpringApplication.run(MuyuApplication.class);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,138 @@
|
||||||
|
package com.muyu.kvt.controller;
|
||||||
|
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
|
import com.muyu.common.core.domain.Result;
|
||||||
|
import com.muyu.common.core.utils.poi.ExcelUtil;
|
||||||
|
import com.muyu.common.core.web.controller.BaseController;
|
||||||
|
import com.muyu.common.core.web.page.TableDataInfo;
|
||||||
|
import com.muyu.common.log.annotation.Log;
|
||||||
|
import com.muyu.common.log.enums.BusinessType;
|
||||||
|
import com.muyu.common.security.annotation.RequiresPermissions;
|
||||||
|
import com.muyu.kvt.domain.DataType;
|
||||||
|
import com.muyu.kvt.domain.Kvt;
|
||||||
|
import com.muyu.kvt.domain.req.KvtEditReq;
|
||||||
|
import com.muyu.kvt.domain.req.KvtQueryReq;
|
||||||
|
import com.muyu.kvt.domain.req.KvtSaveReq;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiImplicitParam;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import com.muyu.kvt.service.KvtService;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* kvt
|
||||||
|
Controller
|
||||||
|
*
|
||||||
|
* @author muyu
|
||||||
|
* @date 2024-04-20
|
||||||
|
*/
|
||||||
|
@Api(tags = "kvt")
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/kvt")
|
||||||
|
public class KvtController extends BaseController {
|
||||||
|
@Autowired
|
||||||
|
private KvtService kvtService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询kvt列表
|
||||||
|
*/
|
||||||
|
@ApiOperation("获取kvt列表")
|
||||||
|
@RequiresPermissions("kvt:kvt:list")
|
||||||
|
@GetMapping("/list")
|
||||||
|
public Result<TableDataInfo<Kvt>> list(KvtQueryReq kvtQueryReq) {
|
||||||
|
startPage();
|
||||||
|
List<Kvt> list = kvtService.list(Kvt.queryBuild(kvtQueryReq));
|
||||||
|
return getDataTable(list);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导出kvt列表
|
||||||
|
*/
|
||||||
|
@ApiOperation("导出kvt列表")
|
||||||
|
@RequiresPermissions("kvt:kvt:export")
|
||||||
|
@Log(title = "kvt", businessType = BusinessType.EXPORT)
|
||||||
|
@PostMapping("/export")
|
||||||
|
public void export(HttpServletResponse response, Kvt kvt) {
|
||||||
|
List<Kvt> list = kvtService.list(kvt);
|
||||||
|
ExcelUtil<Kvt> util = new ExcelUtil<Kvt>(Kvt.class);
|
||||||
|
util.exportExcel(response, list, "kvt数据");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取kvt详细信息
|
||||||
|
*/
|
||||||
|
@ApiOperation("获取kvt详细信息")
|
||||||
|
@RequiresPermissions("kvt:kvt:query")
|
||||||
|
@GetMapping(value = "/{id}")
|
||||||
|
@ApiImplicitParam(name = "id", value = "id", required = true, dataType = "Long", paramType = "path", dataTypeClass = Long.class)
|
||||||
|
public Result<Kvt> getInfo(@PathVariable("id") Long id) {
|
||||||
|
return Result.success(kvtService.getById(id));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增kvt
|
||||||
|
|
||||||
|
*/
|
||||||
|
@RequiresPermissions("kvt:kvt:add")
|
||||||
|
@Log(title = "kvt ", businessType = BusinessType.INSERT)
|
||||||
|
@PostMapping
|
||||||
|
@ApiOperation("新增kvt ")
|
||||||
|
public Result<String> add(@RequestBody KvtSaveReq kvtSaveReq) {
|
||||||
|
return toAjax(kvtService.save(Kvt.saveBuild(kvtSaveReq)));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改kvt
|
||||||
|
|
||||||
|
*/
|
||||||
|
@RequiresPermissions("kvt:kvt:edit")
|
||||||
|
@Log(title = "kvt ", businessType = BusinessType.UPDATE)
|
||||||
|
@PutMapping("/{id}")
|
||||||
|
@ApiOperation("修改kvt")
|
||||||
|
public Result<String> edit(@PathVariable Long id, @RequestBody KvtEditReq kvtEditReq) {
|
||||||
|
return toAjax(kvtService.updateById(Kvt.editBuild(id,kvtEditReq)));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除kvt
|
||||||
|
|
||||||
|
*/
|
||||||
|
@RequiresPermissions("kvt:kvt:remove")
|
||||||
|
@Log(title = "kvt ", businessType = BusinessType.DELETE)
|
||||||
|
@DeleteMapping("/{ids}")
|
||||||
|
@ApiOperation("删除kvt")
|
||||||
|
@ApiImplicitParam(name = "id", value = "id", required = true, dataType = "Long", paramType = "path", dataTypeClass = String.class, example = "1,2,3,4")
|
||||||
|
public Result<String> remove(@PathVariable List<Long> ids) {
|
||||||
|
return toAjax(kvtService.removeBatchByIds(ids));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 测试连接
|
||||||
|
*/
|
||||||
|
@PostMapping("/connectionTest")
|
||||||
|
public Result connectionTest(@RequestBody Kvt kvt) throws SQLException, ClassNotFoundException {
|
||||||
|
boolean test= kvtService.connectionTest(kvt);
|
||||||
|
if (test){
|
||||||
|
return Result.success("测试成功");
|
||||||
|
}else {
|
||||||
|
return Result.error("测试失败");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@PostMapping("/dataTypeList")
|
||||||
|
public Result<List<DataType>> dataTypeList(){
|
||||||
|
List<DataType> dataTypeList=kvtService.dataTypeList();
|
||||||
|
return Result.success(dataTypeList);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,21 @@
|
||||||
|
package com.muyu.kvt.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.muyu.kvt.domain.DataType;
|
||||||
|
import com.muyu.kvt.domain.Kvt;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* kvt
|
||||||
|
Mapper接口
|
||||||
|
*
|
||||||
|
* @author muyu
|
||||||
|
* @date 2024-04-20
|
||||||
|
*/
|
||||||
|
public interface KvtMapper extends BaseMapper<Kvt> {
|
||||||
|
|
||||||
|
List<DataType> dataTypeList();
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,34 @@
|
||||||
|
package com.muyu.kvt.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.muyu.kvt.domain .DataType;
|
||||||
|
import com.muyu.kvt.domain.Kvt;
|
||||||
|
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* kvt
|
||||||
|
Service接口
|
||||||
|
*
|
||||||
|
* @author muyu
|
||||||
|
* @date 2024-04-20
|
||||||
|
*/
|
||||||
|
public interface KvtService extends IService<Kvt> {
|
||||||
|
/**
|
||||||
|
* 查询kvt
|
||||||
|
列表
|
||||||
|
*
|
||||||
|
* @param kvt kvt
|
||||||
|
|
||||||
|
* @return kvt
|
||||||
|
集合
|
||||||
|
*/
|
||||||
|
public List<Kvt> list(Kvt kvt);
|
||||||
|
|
||||||
|
boolean connectionTest(Kvt kvt) throws ClassNotFoundException, SQLException;
|
||||||
|
|
||||||
|
List<DataType> dataTypeList();
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,109 @@
|
||||||
|
package com.muyu.kvt.service.impl;
|
||||||
|
|
||||||
|
import java.sql.Connection;
|
||||||
|
import java.sql.DriverManager;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.muyu.common.core.utils.ObjUtils;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.muyu.kvt.domain.DataType;
|
||||||
|
import com.muyu.kvt.domain.Kvt;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import com.muyu.kvt.mapper.KvtMapper;
|
||||||
|
import com.muyu.kvt.service.KvtService;
|
||||||
|
/**
|
||||||
|
* kvt
|
||||||
|
Service业务层处理
|
||||||
|
*
|
||||||
|
* @author muyu
|
||||||
|
* @date 2024-04-20
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
@Service
|
||||||
|
public class KvtServiceImpl extends ServiceImpl<KvtMapper, Kvt> implements KvtService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询kvt列表
|
||||||
|
*
|
||||||
|
* @param kvt kvt
|
||||||
|
* @return kvt
|
||||||
|
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<Kvt> list(Kvt kvt) {
|
||||||
|
LambdaQueryWrapper<Kvt> queryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
|
||||||
|
|
||||||
|
if (ObjUtils.notNull(kvt.getName())){
|
||||||
|
queryWrapper.like(Kvt::getName, kvt.getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ObjUtils.notNull(kvt.getSystemName())){
|
||||||
|
queryWrapper.like(Kvt::getSystemName, kvt.getSystemName());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ObjUtils.notNull(kvt.getType())){
|
||||||
|
queryWrapper.eq(Kvt::getType, kvt.getType());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ObjUtils.notNull(kvt.getHost())){
|
||||||
|
queryWrapper.eq(Kvt::getHost, kvt.getHost());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ObjUtils.notNull(kvt.getPort())){
|
||||||
|
queryWrapper.eq(Kvt::getPort, kvt.getPort());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ObjUtils.notNull(kvt.getDatabaseName())){
|
||||||
|
queryWrapper.like(Kvt::getDatabaseName, kvt.getDatabaseName());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ObjUtils.notNull(kvt.getConnectionParam())){
|
||||||
|
queryWrapper.eq(Kvt::getConnectionParam, kvt.getConnectionParam());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ObjUtils.notNull(kvt.getInitNum())){
|
||||||
|
queryWrapper.eq(Kvt::getInitNum, kvt.getInitNum());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ObjUtils.notNull(kvt.getMaxNum())){
|
||||||
|
queryWrapper.eq(Kvt::getMaxNum, kvt.getMaxNum());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ObjUtils.notNull(kvt.getMaxWaitTime())){
|
||||||
|
queryWrapper.eq(Kvt::getMaxWaitTime, kvt.getMaxWaitTime());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ObjUtils.notNull(kvt.getMaxWaitSize())){
|
||||||
|
queryWrapper.eq(Kvt::getMaxWaitSize, kvt.getMaxWaitSize());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
return list(queryWrapper);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean connectionTest(Kvt kvt) throws ClassNotFoundException, SQLException {
|
||||||
|
String user = kvt.getUsername();
|
||||||
|
String password = kvt.getPassword();
|
||||||
|
String jdbcDriver = "com.mysql.cj.jdbc.Driver";
|
||||||
|
String jdbcUrl = "jdbc:mysql://"+kvt.getHost()+":"+kvt.getPort()+"/"+kvt.getDatabaseName()+"?"+kvt.getConnectionParam();
|
||||||
|
Class.forName(jdbcDriver);
|
||||||
|
Connection connection = DriverManager.getConnection(jdbcUrl, user, password);
|
||||||
|
if (connection==null){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<DataType> dataTypeList() {
|
||||||
|
return baseMapper.dataTypeList();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,2 @@
|
||||||
|
Spring Boot Version: ${spring-boot.version}
|
||||||
|
Spring Application Name: ${spring.application.name}
|
|
@ -0,0 +1,31 @@
|
||||||
|
# Tomcat
|
||||||
|
server:
|
||||||
|
port: 9567
|
||||||
|
|
||||||
|
# Spring
|
||||||
|
spring:
|
||||||
|
main:
|
||||||
|
allow-circular-references: true
|
||||||
|
application:
|
||||||
|
# 应用名称
|
||||||
|
name: muyu-kvt
|
||||||
|
profiles:
|
||||||
|
# 环境配置
|
||||||
|
active: dev
|
||||||
|
cloud:
|
||||||
|
nacos:
|
||||||
|
discovery:
|
||||||
|
# 服务注册地址
|
||||||
|
server-addr: 115.159.211.196:8848
|
||||||
|
config:
|
||||||
|
# 配置中心地址
|
||||||
|
server-addr: 115.159.211.196:8848
|
||||||
|
namespace: b8ace5a6-28a3-4126-b109-9b6623c58dc0
|
||||||
|
# 配置文件格式
|
||||||
|
file-extension: yml
|
||||||
|
# 共享配置
|
||||||
|
shared-configs:
|
||||||
|
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
|
||||||
|
logging:
|
||||||
|
level:
|
||||||
|
com.muyu.kvt.mapper: DEBUG
|
|
@ -0,0 +1,74 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<configuration scan="true" scanPeriod="60 seconds" debug="false">
|
||||||
|
<!-- 日志存放路径 -->
|
||||||
|
<property name="log.path" value="logs/muyu-system"/>
|
||||||
|
<!-- 日志输出格式 -->
|
||||||
|
<property name="log.pattern" value="%d{HH:mm:ss.SSS} [%thread] %-5level %logger{20} - [%method,%line] - %msg%n"/>
|
||||||
|
|
||||||
|
<!-- 控制台输出 -->
|
||||||
|
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
|
||||||
|
<encoder>
|
||||||
|
<pattern>${log.pattern}</pattern>
|
||||||
|
</encoder>
|
||||||
|
</appender>
|
||||||
|
|
||||||
|
<!-- 系统日志输出 -->
|
||||||
|
<appender name="file_info" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||||
|
<file>${log.path}/info.log</file>
|
||||||
|
<!-- 循环政策:基于时间创建日志文件 -->
|
||||||
|
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||||
|
<!-- 日志文件名格式 -->
|
||||||
|
<fileNamePattern>${log.path}/info.%d{yyyy-MM-dd}.log</fileNamePattern>
|
||||||
|
<!-- 日志最大的历史 60天 -->
|
||||||
|
<maxHistory>60</maxHistory>
|
||||||
|
</rollingPolicy>
|
||||||
|
<encoder>
|
||||||
|
<pattern>${log.pattern}</pattern>
|
||||||
|
</encoder>
|
||||||
|
<filter class="ch.qos.logback.classic.filter.LevelFilter">
|
||||||
|
<!-- 过滤的级别 -->
|
||||||
|
<level>INFO</level>
|
||||||
|
<!-- 匹配时的操作:接收(记录) -->
|
||||||
|
<onMatch>ACCEPT</onMatch>
|
||||||
|
<!-- 不匹配时的操作:拒绝(不记录) -->
|
||||||
|
<onMismatch>DENY</onMismatch>
|
||||||
|
</filter>
|
||||||
|
</appender>
|
||||||
|
|
||||||
|
<appender name="file_error" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||||
|
<file>${log.path}/error.log</file>
|
||||||
|
<!-- 循环政策:基于时间创建日志文件 -->
|
||||||
|
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||||
|
<!-- 日志文件名格式 -->
|
||||||
|
<fileNamePattern>${log.path}/error.%d{yyyy-MM-dd}.log</fileNamePattern>
|
||||||
|
<!-- 日志最大的历史 60天 -->
|
||||||
|
<maxHistory>60</maxHistory>
|
||||||
|
</rollingPolicy>
|
||||||
|
<encoder>
|
||||||
|
<pattern>${log.pattern}</pattern>
|
||||||
|
</encoder>
|
||||||
|
<filter class="ch.qos.logback.classic.filter.LevelFilter">
|
||||||
|
<!-- 过滤的级别 -->
|
||||||
|
<level>ERROR</level>
|
||||||
|
<!-- 匹配时的操作:接收(记录) -->
|
||||||
|
<onMatch>ACCEPT</onMatch>
|
||||||
|
<!-- 不匹配时的操作:拒绝(不记录) -->
|
||||||
|
<onMismatch>DENY</onMismatch>
|
||||||
|
</filter>
|
||||||
|
</appender>
|
||||||
|
|
||||||
|
<!-- 系统模块日志级别控制 -->
|
||||||
|
<logger name="com.muyu" level="info"/>
|
||||||
|
<!-- Spring日志级别控制 -->
|
||||||
|
<logger name="org.springframework" level="warn"/>
|
||||||
|
|
||||||
|
<root level="info">
|
||||||
|
<appender-ref ref="console"/>
|
||||||
|
</root>
|
||||||
|
|
||||||
|
<!--系统操作日志-->
|
||||||
|
<root level="info">
|
||||||
|
<appender-ref ref="file_info"/>
|
||||||
|
<appender-ref ref="file_error"/>
|
||||||
|
</root>
|
||||||
|
</configuration>
|
|
@ -0,0 +1,38 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
<!DOCTYPE mapper
|
||||||
|
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="com.muyu.kvt.mapper.KvtMapper">
|
||||||
|
|
||||||
|
<resultMap type="com.muyu.kvt.domain.Kvt" id="KvtResult">
|
||||||
|
<result property="id" column="id" />
|
||||||
|
<result property="name" column="name" />
|
||||||
|
<result property="systemName" column="system_name" />
|
||||||
|
<result property="type" column="type" />
|
||||||
|
<result property="host" column="host" />
|
||||||
|
<result property="port" column="port" />
|
||||||
|
<result property="databaseName" column="database_name" />
|
||||||
|
<result property="connectionParam" column="connection_param" />
|
||||||
|
<result property="initNum" column="init_num" />
|
||||||
|
<result property="maxNum" column="max_num" />
|
||||||
|
<result property="maxWaitTime" column="max_wait_time" />
|
||||||
|
<result property="maxWaitSize" column="max_wait_size" />
|
||||||
|
<result property="remark" column="remark" />
|
||||||
|
<result property="createBy" column="create_by" />
|
||||||
|
<result property="createTime" column="create_time" />
|
||||||
|
<result property="updateBy" column="update_by" />
|
||||||
|
<result property="updateTime" column="update_time" />
|
||||||
|
<result property="username" column="username" />
|
||||||
|
<result property="password" column="password" />
|
||||||
|
<result property="password" column="password" />
|
||||||
|
<result property="dateTypeId" column="data_type_id" />
|
||||||
|
</resultMap>
|
||||||
|
|
||||||
|
<sql id="selectKvtVo">
|
||||||
|
select id, name, system_name, type, host, port, database_name, connection_param, init_num, max_num, max_wait_time, max_wait_size, remark, create_by, create_time, update_by, update_time,date_type_id
|
||||||
|
from kvt
|
||||||
|
</sql>
|
||||||
|
<select id="dataTypeList" resultType="com.muyu.kvt.domain.DataType">
|
||||||
|
select * from data_type
|
||||||
|
</select>
|
||||||
|
</mapper>
|
|
@ -0,0 +1,111 @@
|
||||||
|
package com.muyu.system.controller;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
|
import com.muyu.system.domain.AsUserDept;
|
||||||
|
import com.muyu.system.domain.resp.AsUserDeotNumResponse;
|
||||||
|
import com.muyu.system.service.service.IAsUserDeptService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
import com.muyu.common.log.annotation.Log;
|
||||||
|
import com.muyu.common.log.enums.BusinessType;
|
||||||
|
import com.muyu.common.security.annotation.RequiresPermissions;
|
||||||
|
import com.muyu.common.core.web.controller.BaseController;
|
||||||
|
import com.muyu.common.core.domain.Result;
|
||||||
|
import com.muyu.common.core.utils.poi.ExcelUtil;
|
||||||
|
import com.muyu.common.core.web.page.TableDataInfo;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户与部门中间Controller
|
||||||
|
*
|
||||||
|
* @author muyu
|
||||||
|
* @date 2024-04-14
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/userDept")
|
||||||
|
public class AsUserDeptController extends BaseController
|
||||||
|
{
|
||||||
|
@Autowired
|
||||||
|
private IAsUserDeptService asUserDeptService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询用户与部门中间列表
|
||||||
|
*/
|
||||||
|
@RequiresPermissions("product:dept:list")
|
||||||
|
@GetMapping("/list")
|
||||||
|
public Result<TableDataInfo<AsUserDept>> list(AsUserDept asUserDept)
|
||||||
|
{
|
||||||
|
startPage();
|
||||||
|
List<AsUserDept> list = asUserDeptService.selectAsUserDeptList(asUserDept);
|
||||||
|
return getDataTable(list);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导出用户与部门中间列表
|
||||||
|
*/
|
||||||
|
@RequiresPermissions("product:dept:export")
|
||||||
|
@Log(title = "用户与部门中间", businessType = BusinessType.EXPORT)
|
||||||
|
@PostMapping("/export")
|
||||||
|
public void export(HttpServletResponse response, AsUserDept asUserDept)
|
||||||
|
{
|
||||||
|
List<AsUserDept> list = asUserDeptService.selectAsUserDeptList(asUserDept);
|
||||||
|
ExcelUtil<AsUserDept> util = new ExcelUtil<AsUserDept>(AsUserDept.class);
|
||||||
|
util.exportExcel(response, list, "用户与部门中间数据");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取用户与部门中间详细信息
|
||||||
|
*/
|
||||||
|
@RequiresPermissions("product:dept:query")
|
||||||
|
@GetMapping(value = "/{id}")
|
||||||
|
public Result getInfo(@PathVariable("id") Long id)
|
||||||
|
{
|
||||||
|
return success(asUserDeptService.selectAsUserDeptById(id));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增用户与部门中间
|
||||||
|
*/
|
||||||
|
@RequiresPermissions("product:dept:add")
|
||||||
|
@Log(title = "用户与部门中间", businessType = BusinessType.INSERT)
|
||||||
|
@PostMapping
|
||||||
|
public Result add(@RequestBody AsUserDept asUserDept)
|
||||||
|
{
|
||||||
|
return toAjax(asUserDeptService.insertAsUserDept(asUserDept));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改用户与部门中间
|
||||||
|
*/
|
||||||
|
@RequiresPermissions("product:dept:edit")
|
||||||
|
@Log(title = "用户与部门中间", businessType = BusinessType.UPDATE)
|
||||||
|
@PutMapping
|
||||||
|
public Result edit(@RequestBody AsUserDept asUserDept)
|
||||||
|
{
|
||||||
|
return toAjax(asUserDeptService.updateAsUserDept(asUserDept));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除用户与部门中间
|
||||||
|
*/
|
||||||
|
@RequiresPermissions("product:dept:remove")
|
||||||
|
@Log(title = "用户与部门中间", businessType = BusinessType.DELETE)
|
||||||
|
@DeleteMapping("/{ids}")
|
||||||
|
public Result remove(@PathVariable Long[] ids)
|
||||||
|
{
|
||||||
|
return toAjax(asUserDeptService.deleteAsUserDeptByIds(ids));
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/UpdateAsUserDept")
|
||||||
|
public Result list(@RequestParam("id") Long id)
|
||||||
|
{
|
||||||
|
return asUserDeptService.updateAsUserDeptRead(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/GetNum")
|
||||||
|
public Result<AsUserDeotNumResponse> getNum(@RequestParam("noticeId") Long noticeId)
|
||||||
|
{
|
||||||
|
return asUserDeptService.getNum(noticeId);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,84 @@
|
||||||
|
package com.muyu.system.domain;
|
||||||
|
|
||||||
|
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||||
|
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||||
|
import com.muyu.common.core.annotation.Excel;
|
||||||
|
import com.muyu.common.core.web.domain.BaseEntity;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户与部门中间对象 as_user_dept
|
||||||
|
*
|
||||||
|
* @author muyu
|
||||||
|
* @date 2024-04-14
|
||||||
|
*/
|
||||||
|
public class AsUserDept extends BaseEntity
|
||||||
|
{
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/** $column.columnComment */
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
/** $column.columnComment */
|
||||||
|
@Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()")
|
||||||
|
private Long userId;
|
||||||
|
|
||||||
|
/** $column.columnComment */
|
||||||
|
@Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()")
|
||||||
|
private Long noticeId;
|
||||||
|
|
||||||
|
/** $column.columnComment */
|
||||||
|
@Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()")
|
||||||
|
private String isRead;
|
||||||
|
|
||||||
|
public void setId(Long id)
|
||||||
|
{
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getId()
|
||||||
|
{
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
public void setUserId(Long userId)
|
||||||
|
{
|
||||||
|
this.userId = userId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getUserId()
|
||||||
|
{
|
||||||
|
return userId;
|
||||||
|
}
|
||||||
|
public void setNoticeId(Long noticeId)
|
||||||
|
{
|
||||||
|
this.noticeId = noticeId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getNoticeId()
|
||||||
|
{
|
||||||
|
return noticeId;
|
||||||
|
}
|
||||||
|
public void setIsRead(String isRead)
|
||||||
|
{
|
||||||
|
this.isRead = isRead;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getIsRead()
|
||||||
|
{
|
||||||
|
return isRead;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||||
|
.append("id", getId())
|
||||||
|
.append("userId", getUserId())
|
||||||
|
.append("noticeId", getNoticeId())
|
||||||
|
.append("isRead", getIsRead())
|
||||||
|
.append("createBy", getCreateBy())
|
||||||
|
.append("createTime", getCreateTime())
|
||||||
|
.append("updateBy", getUpdateBy())
|
||||||
|
.append("updateTime", getUpdateTime())
|
||||||
|
.append("remark", getRemark())
|
||||||
|
.toString();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,21 @@
|
||||||
|
package com.muyu.system.domain.req;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* SysNoticeRequest
|
||||||
|
*
|
||||||
|
* @author LeYang
|
||||||
|
* on 2024/4/14
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
public class SysNoticeRequest {
|
||||||
|
private Long noticeId;
|
||||||
|
private Long userId;
|
||||||
|
private String noticeType;
|
||||||
|
private String isRead;
|
||||||
|
}
|
|
@ -0,0 +1,22 @@
|
||||||
|
package com.muyu.system.domain.resp;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.experimental.SuperBuilder;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* AsUserDeotNumResponse
|
||||||
|
*
|
||||||
|
* @author LeYang
|
||||||
|
* on 2024/4/14
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
@SuperBuilder
|
||||||
|
public class AsUserDeotNumResponse {
|
||||||
|
private Long num;
|
||||||
|
private Long readNum;
|
||||||
|
private Long noReadNum;
|
||||||
|
}
|
|
@ -0,0 +1,32 @@
|
||||||
|
package com.muyu.system.domain.resp;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.experimental.SuperBuilder;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* SysNoticeResponse
|
||||||
|
*
|
||||||
|
* @author LeYang
|
||||||
|
* on 2024/4/14
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
@SuperBuilder
|
||||||
|
public class SysNoticeResponse{
|
||||||
|
|
||||||
|
private Date createTime;
|
||||||
|
private String createBy;
|
||||||
|
private String noticeType;
|
||||||
|
private String isRead;
|
||||||
|
private String noticeTitle;
|
||||||
|
private String noticeContent;
|
||||||
|
private Long noticeId;
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,71 @@
|
||||||
|
package com.muyu.system.mapper;
|
||||||
|
|
||||||
|
import com.muyu.system.domain.AsUserDept;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户与部门中间Mapper接口
|
||||||
|
*
|
||||||
|
* @author muyu
|
||||||
|
* @date 2024-04-14
|
||||||
|
*/
|
||||||
|
public interface AsUserDeptMapper
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 查询用户与部门中间
|
||||||
|
*
|
||||||
|
* @param id 用户与部门中间主键
|
||||||
|
* @return 用户与部门中间
|
||||||
|
*/
|
||||||
|
public AsUserDept selectAsUserDeptById(Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询用户与部门中间列表
|
||||||
|
*
|
||||||
|
* @param asUserDept 用户与部门中间
|
||||||
|
* @return 用户与部门中间集合
|
||||||
|
*/
|
||||||
|
public List<AsUserDept> selectAsUserDeptList(AsUserDept asUserDept);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增用户与部门中间
|
||||||
|
*
|
||||||
|
* @param asUserDept 用户与部门中间
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int insertAsUserDept(AsUserDept asUserDept);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改用户与部门中间
|
||||||
|
*
|
||||||
|
* @param asUserDept 用户与部门中间
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int updateAsUserDept(AsUserDept asUserDept);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除用户与部门中间
|
||||||
|
*
|
||||||
|
* @param id 用户与部门中间主键
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int deleteAsUserDeptById(Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量删除用户与部门中间
|
||||||
|
*
|
||||||
|
* @param ids 需要删除的数据主键集合
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int deleteAsUserDeptByIds(Long[] ids);
|
||||||
|
|
||||||
|
void insertBachAsUserDept(@Param("asUserDepts") List<AsUserDept> asUserDepts);
|
||||||
|
|
||||||
|
Long selectAsUserDeptNum(Long noticeId);
|
||||||
|
|
||||||
|
void updateAsUserDeptRead(Long id);
|
||||||
|
|
||||||
|
Long selectAsUserDeptReadNum(Long noticeId);
|
||||||
|
}
|
|
@ -0,0 +1,68 @@
|
||||||
|
package com.muyu.system.service.service;
|
||||||
|
|
||||||
|
import com.muyu.common.core.domain.Result;
|
||||||
|
import com.muyu.system.domain.AsUserDept;
|
||||||
|
import com.muyu.system.domain.resp.AsUserDeotNumResponse;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户与部门中间Service接口
|
||||||
|
*
|
||||||
|
* @author muyu
|
||||||
|
* @date 2024-04-14
|
||||||
|
*/
|
||||||
|
public interface IAsUserDeptService
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 查询用户与部门中间
|
||||||
|
*
|
||||||
|
* @param id 用户与部门中间主键
|
||||||
|
* @return 用户与部门中间
|
||||||
|
*/
|
||||||
|
public AsUserDept selectAsUserDeptById(Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询用户与部门中间列表
|
||||||
|
*
|
||||||
|
* @param asUserDept 用户与部门中间
|
||||||
|
* @return 用户与部门中间集合
|
||||||
|
*/
|
||||||
|
public List<AsUserDept> selectAsUserDeptList(AsUserDept asUserDept);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增用户与部门中间
|
||||||
|
*
|
||||||
|
* @param asUserDept 用户与部门中间
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int insertAsUserDept(AsUserDept asUserDept);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改用户与部门中间
|
||||||
|
*
|
||||||
|
* @param asUserDept 用户与部门中间
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int updateAsUserDept(AsUserDept asUserDept);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量删除用户与部门中间
|
||||||
|
*
|
||||||
|
* @param ids 需要删除的用户与部门中间主键集合
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int deleteAsUserDeptByIds(Long[] ids);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除用户与部门中间信息
|
||||||
|
*
|
||||||
|
* @param id 用户与部门中间主键
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int deleteAsUserDeptById(Long id);
|
||||||
|
|
||||||
|
Result updateAsUserDeptRead(Long id);
|
||||||
|
|
||||||
|
Result<AsUserDeotNumResponse> getNum(Long noticeId);
|
||||||
|
}
|
|
@ -0,0 +1,118 @@
|
||||||
|
package com.muyu.system.service.service.impl;
|
||||||
|
|
||||||
|
|
||||||
|
import com.muyu.common.core.domain.Result;
|
||||||
|
import com.muyu.common.core.utils.DateUtils;
|
||||||
|
import com.muyu.system.domain.AsUserDept;
|
||||||
|
import com.muyu.system.domain.resp.AsUserDeotNumResponse;
|
||||||
|
import com.muyu.system.mapper.AsUserDeptMapper;
|
||||||
|
import com.muyu.system.service.service.IAsUserDeptService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户与部门中间Service业务层处理
|
||||||
|
*
|
||||||
|
* @author muyu
|
||||||
|
* @date 2024-04-14
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class AsUserDeptServiceImpl implements IAsUserDeptService
|
||||||
|
{
|
||||||
|
@Autowired
|
||||||
|
private AsUserDeptMapper asUserDeptMapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询用户与部门中间
|
||||||
|
*
|
||||||
|
* @param id 用户与部门中间主键
|
||||||
|
* @return 用户与部门中间
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public AsUserDept selectAsUserDeptById(Long id)
|
||||||
|
{
|
||||||
|
return asUserDeptMapper.selectAsUserDeptById(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询用户与部门中间列表
|
||||||
|
*
|
||||||
|
* @param asUserDept 用户与部门中间
|
||||||
|
* @return 用户与部门中间
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<AsUserDept> selectAsUserDeptList(AsUserDept asUserDept)
|
||||||
|
{
|
||||||
|
return asUserDeptMapper.selectAsUserDeptList(asUserDept);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增用户与部门中间
|
||||||
|
*
|
||||||
|
* @param asUserDept 用户与部门中间
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public int insertAsUserDept(AsUserDept asUserDept)
|
||||||
|
{
|
||||||
|
asUserDept.setCreateTime(DateUtils.getNowDate());
|
||||||
|
return asUserDeptMapper.insertAsUserDept(asUserDept);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改用户与部门中间
|
||||||
|
*
|
||||||
|
* @param asUserDept 用户与部门中间
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public int updateAsUserDept(AsUserDept asUserDept)
|
||||||
|
{
|
||||||
|
asUserDept.setUpdateTime(DateUtils.getNowDate());
|
||||||
|
return asUserDeptMapper.updateAsUserDept(asUserDept);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量删除用户与部门中间
|
||||||
|
*
|
||||||
|
* @param ids 需要删除的用户与部门中间主键
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public int deleteAsUserDeptByIds(Long[] ids)
|
||||||
|
{
|
||||||
|
return asUserDeptMapper.deleteAsUserDeptByIds(ids);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除用户与部门中间信息
|
||||||
|
*
|
||||||
|
* @param id 用户与部门中间主键
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public int deleteAsUserDeptById(Long id)
|
||||||
|
{
|
||||||
|
return asUserDeptMapper.deleteAsUserDeptById(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Result updateAsUserDeptRead(Long id) {
|
||||||
|
asUserDeptMapper.updateAsUserDeptRead(id);
|
||||||
|
return Result.success();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Result<AsUserDeotNumResponse> getNum(Long noticeId) {
|
||||||
|
Long num = asUserDeptMapper.selectAsUserDeptNum(noticeId);
|
||||||
|
Long readNum = asUserDeptMapper.selectAsUserDeptReadNum(noticeId);
|
||||||
|
long noreadNum= num-readNum;
|
||||||
|
return Result.success(AsUserDeotNumResponse.builder()
|
||||||
|
.num(num)
|
||||||
|
.readNum(readNum)
|
||||||
|
.noReadNum(noreadNum)
|
||||||
|
.build());
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,104 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
<!DOCTYPE mapper
|
||||||
|
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="com.muyu.system.mapper.AsUserDeptMapper">
|
||||||
|
|
||||||
|
<resultMap type="com.muyu.system.domain.AsUserDept" id="AsUserDeptResult">
|
||||||
|
<result property="id" column="id" />
|
||||||
|
<result property="userId" column="user_id" />
|
||||||
|
<result property="noticeId" column="notice_id" />
|
||||||
|
<result property="isRead" column="is_read" />
|
||||||
|
<result property="createBy" column="create_by" />
|
||||||
|
<result property="createTime" column="create_time" />
|
||||||
|
<result property="updateBy" column="update_by" />
|
||||||
|
<result property="updateTime" column="update_time" />
|
||||||
|
<result property="remark" column="remark" />
|
||||||
|
</resultMap>
|
||||||
|
|
||||||
|
<sql id="selectAsUserDeptVo">
|
||||||
|
select id, user_id, notice_id, is_read, create_by, create_time, update_by, update_time, remark from as_user_dept
|
||||||
|
</sql>
|
||||||
|
|
||||||
|
<select id="selectAsUserDeptList" parameterType="com.muyu.system.domain.AsUserDept" resultMap="AsUserDeptResult">
|
||||||
|
<include refid="selectAsUserDeptVo"/>
|
||||||
|
<where>
|
||||||
|
<if test="userId != null "> and user_id = #{userId}</if>
|
||||||
|
<if test="noticeId != null "> and notice_id = #{noticeId}</if>
|
||||||
|
<if test="isRead != null and isRead != ''"> and is_read = #{isRead}</if>
|
||||||
|
</where>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="selectAsUserDeptById" parameterType="Long" resultMap="AsUserDeptResult">
|
||||||
|
<include refid="selectAsUserDeptVo"/>
|
||||||
|
where id = #{id}
|
||||||
|
</select>
|
||||||
|
<select id="selectAsUserDeptNum" resultType="java.lang.Long">
|
||||||
|
select count(*) from as_user_dept where notice_id -#{noticeId}
|
||||||
|
</select>
|
||||||
|
<select id="selectAsUserDeptReadNum" resultType="java.lang.Long">
|
||||||
|
select count(*) from as_user_dept where notice_id - #{noticeId} and is_read = '0'
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<insert id="insertAsUserDept" parameterType="com.muyu.system.domain.AsUserDept" useGeneratedKeys="true" keyProperty="id">
|
||||||
|
insert into as_user_dept
|
||||||
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||||
|
<if test="userId != null">user_id,</if>
|
||||||
|
<if test="noticeId != null">notice_id,</if>
|
||||||
|
<if test="isRead != null">is_read,</if>
|
||||||
|
<if test="createBy != null">create_by,</if>
|
||||||
|
<if test="createTime != null">create_time,</if>
|
||||||
|
<if test="updateBy != null">update_by,</if>
|
||||||
|
<if test="updateTime != null">update_time,</if>
|
||||||
|
<if test="remark != null">remark,</if>
|
||||||
|
</trim>
|
||||||
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||||
|
<if test="userId != null">#{userId},</if>
|
||||||
|
<if test="noticeId != null">#{noticeId},</if>
|
||||||
|
<if test="isRead != null">#{isRead},</if>
|
||||||
|
<if test="createBy != null">#{createBy},</if>
|
||||||
|
<if test="createTime != null">#{createTime},</if>
|
||||||
|
<if test="updateBy != null">#{updateBy},</if>
|
||||||
|
<if test="updateTime != null">#{updateTime},</if>
|
||||||
|
<if test="remark != null">#{remark},</if>
|
||||||
|
</trim>
|
||||||
|
</insert>
|
||||||
|
<insert id="insertBachAsUserDept">
|
||||||
|
INSERT INTO `as_user_dept` (`user_id`, `notice_id`, `create_by`, `create_time`)
|
||||||
|
VALUES
|
||||||
|
<foreach collection="asUserDepts" separator="," item="asUserDept">
|
||||||
|
(#{asUserDept.userId}, #{asUserDept.noticeId}, #{asUserDept.createBy}, #{asUserDept.createTime})
|
||||||
|
</foreach>
|
||||||
|
|
||||||
|
|
||||||
|
</insert>
|
||||||
|
|
||||||
|
<update id="updateAsUserDept" parameterType="com.muyu.system.domain.AsUserDept">
|
||||||
|
update as_user_dept
|
||||||
|
<trim prefix="SET" suffixOverrides=",">
|
||||||
|
<if test="userId != null">user_id = #{userId},</if>
|
||||||
|
<if test="noticeId != null">notice_id = #{noticeId},</if>
|
||||||
|
<if test="isRead != null">is_read = #{isRead},</if>
|
||||||
|
<if test="createBy != null">create_by = #{createBy},</if>
|
||||||
|
<if test="createTime != null">create_time = #{createTime},</if>
|
||||||
|
<if test="updateBy != null">update_by = #{updateBy},</if>
|
||||||
|
<if test="updateTime != null">update_time = #{updateTime},</if>
|
||||||
|
<if test="remark != null">remark = #{remark},</if>
|
||||||
|
</trim>
|
||||||
|
where id = #{id}
|
||||||
|
</update>
|
||||||
|
<update id="updateAsUserDeptRead">
|
||||||
|
update as_user_dept set is_read =0 where id =#{id}
|
||||||
|
</update>
|
||||||
|
|
||||||
|
<delete id="deleteAsUserDeptById" parameterType="Long">
|
||||||
|
delete from as_user_dept where id = #{id}
|
||||||
|
</delete>
|
||||||
|
|
||||||
|
<delete id="deleteAsUserDeptByIds" parameterType="String">
|
||||||
|
delete from as_user_dept where id in
|
||||||
|
<foreach item="id" collection="array" open="(" separator="," close=")">
|
||||||
|
#{id}
|
||||||
|
</foreach>
|
||||||
|
</delete>
|
||||||
|
</mapper>
|
Loading…
Reference in New Issue