数据源管理

master
rouchen 2024-04-21 14:31:20 +08:00
parent 028ad38f45
commit da5642e477
14 changed files with 296 additions and 3 deletions

View File

@ -0,0 +1,26 @@
<?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-common</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>
<dependencies>
<dependency>
<groupId>com.muyu</groupId>
<artifactId>muyu-common-core</artifactId>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,116 @@
<?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-server</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>
<dependencies>
<!-- SpringCloud Alibaba Nacos -->
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
</dependency>
<!-- SpringCloud Alibaba Nacos Config -->
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
</dependency>
<!-- SpringCloud Alibaba Sentinel -->
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
</dependency>
<!-- SpringBoot Actuator -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<!-- Swagger UI -->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>${swagger.fox.version}</version>
</dependency>
<!-- Mysql Connector -->
<dependency>
<groupId>com.mysql</groupId>
<artifactId>mysql-connector-j</artifactId>
</dependency>
<!-- MuYu Common DataSource -->
<dependency>
<groupId>com.muyu</groupId>
<artifactId>muyu-common-datasource</artifactId>
</dependency>
<!-- MuYu Common DataScope -->
<dependency>
<groupId>com.muyu</groupId>
<artifactId>muyu-common-datascope</artifactId>
</dependency>
<!-- MuYu Common Log -->
<dependency>
<groupId>com.muyu</groupId>
<artifactId>muyu-common-log</artifactId>
</dependency>
<!-- MuYu Common Swagger -->
<dependency>
<groupId>com.muyu</groupId>
<artifactId>muyu-common-swagger</artifactId>
</dependency>
<dependency>
<groupId>com.muyu</groupId>
<artifactId>muyu-kvt-common</artifactId>
<version>3.6.3</version>
<scope>compile</scope>
</dependency>
</dependencies>
<build>
<finalName>${project.artifactId}</finalName>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- 加入maven deploy插件当在deploy时忽略些model-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
</plugins>
</build>
</project>

View File

@ -0,0 +1,26 @@
<?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-modules</artifactId>
<version>3.6.3</version>
</parent>
<artifactId>muyu-kvt</artifactId>
<packaging>pom</packaging>
<modules>
<module>muyu-kvt-common</module>
<module>muyu-kvt-remote</module>
<module>muyu-kvt-server</module>
</modules>
<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>

View File

@ -45,6 +45,7 @@ public class SysDictTypeController extends BaseController {
util.exportExcel(response, list, "字典类型");
}
/**
*
*/

View File

@ -8,6 +8,8 @@ import com.muyu.common.log.enums.BusinessType;
import com.muyu.common.security.annotation.RequiresPermissions;
import com.muyu.common.security.utils.SecurityUtils;
import com.muyu.system.domain.SysNotice;
import com.muyu.system.domain.req.SysNoticeRequest;
import com.muyu.system.domain.resp.SysNoticeResponse;
import com.muyu.system.service.SysNoticeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
@ -36,6 +38,10 @@ public class SysNoticeController extends BaseController {
List<SysNotice> list = noticeService.selectNoticeList(notice);
return getDataTable(list);
}
@PostMapping("/GetNoticeList")
public Result<List<SysNoticeResponse>> getNoticeList(@RequestBody SysNoticeRequest sysNoticeRequest){
return noticeService.getNoticeList(sysNoticeRequest);
}
/**
*

View File

@ -12,6 +12,7 @@ import org.apache.commons.lang3.builder.ToStringStyle;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Size;
import java.util.List;
/**
* sys_notice
@ -50,7 +51,14 @@ public class SysNotice extends BaseEntity {
* 0 1
*/
private String status;
/**
* id
*/
private List<List<Long>> sectionList;
/**
* id
*/
private List<Long> personnelList;
public Long getNoticeId () {
return noticeId;
}

View File

@ -2,6 +2,8 @@ package com.muyu.system.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.muyu.system.domain.SysNotice;
import com.muyu.system.domain.req.SysNoticeRequest;
import com.muyu.system.domain.resp.SysNoticeResponse;
import java.util.List;
@ -64,4 +66,10 @@ public interface SysNoticeMapper extends BaseMapper<SysNotice> {
* @return
*/
public int deleteNoticeByIds (Long[] noticeIds);
List<SysNoticeResponse> getNoticeList(SysNoticeRequest sysNoticeRequest);
List<Long> selectUser();
}

View File

@ -139,4 +139,6 @@ public interface SysUserMapper extends BaseMapper<SysUser> {
* @return
*/
public SysUser checkEmailUnique (String email);
List<Long> selectDtptUser(@Param("sectionIds") List<Long> sectionIds);
}

View File

@ -1,7 +1,10 @@
package com.muyu.system.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.muyu.common.core.domain.Result;
import com.muyu.system.domain.SysNotice;
import com.muyu.system.domain.req.SysNoticeRequest;
import com.muyu.system.domain.resp.SysNoticeResponse;
import java.util.List;
@ -64,4 +67,6 @@ public interface SysNoticeService extends IService<SysNotice> {
* @return
*/
public int deleteNoticeByIds (Long[] noticeIds);
Result<List<SysNoticeResponse>> getNoticeList(SysNoticeRequest sysNoticeRequest);
}

View File

@ -1,13 +1,24 @@
package com.muyu.system.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.muyu.common.core.domain.Result;
import com.muyu.common.security.utils.SecurityUtils;
import com.muyu.system.domain.AsUserDept;
import com.muyu.system.domain.SysNotice;
import com.muyu.system.domain.req.SysNoticeRequest;
import com.muyu.system.domain.resp.SysNoticeResponse;
import com.muyu.system.mapper.AsUserDeptMapper;
import com.muyu.system.mapper.SysNoticeMapper;
import com.muyu.system.mapper.SysUserMapper;
import com.muyu.system.service.SysNoticeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
/**
*
@ -19,6 +30,10 @@ public class SysNoticeServiceImpl extends ServiceImpl<SysNoticeMapper, SysNotice
@Autowired
private SysNoticeMapper noticeMapper;
@Autowired
private SysUserMapper sysUserMapper;
@Autowired
private AsUserDeptMapper asUserDeptMapper;
/**
*
*
@ -39,10 +54,40 @@ public class SysNoticeServiceImpl extends ServiceImpl<SysNoticeMapper, SysNotice
* @return
*/
@Override
public List<SysNotice> selectNoticeList (SysNotice notice) {
public List<SysNotice> selectNoticeList(SysNotice notice) {
return noticeMapper.selectNoticeList(notice);
}
public List<AsUserDept> handleList(List<Long> personnelList ,List<List<Long>> sectionList,Long noticeId){
ArrayList<Long> longs = new ArrayList<>();
if (sectionList!=null && sectionList.size()!=0){
sectionList.stream()
.map(section -> {
for (Long aLong : section) {
longs.add(aLong);
}
return null;
}).collect(Collectors.toList());
List<Long> sectionIds =longs.stream().distinct().toList();
List<Long> userIds= sysUserMapper.selectDtptUser(sectionIds);
if (userIds !=null){
personnelList.addAll(userIds);
}
}
personnelList= personnelList.stream().distinct().toList();
System.out.println(personnelList);
List<AsUserDept> asUserDepts = personnelList.stream()
.map(personnel -> {
AsUserDept asUserDept = new AsUserDept();
asUserDept.setNoticeId(personnel);
asUserDept.setNoticeId(noticeId);
asUserDept.setCreateBy(SecurityUtils.getUsername());
asUserDept.setCreateTime(new Date());
return asUserDept;
}).toList();
return asUserDepts;
}
/**
*
*
@ -51,8 +96,28 @@ public class SysNoticeServiceImpl extends ServiceImpl<SysNoticeMapper, SysNotice
* @return
*/
@Override
@Transactional
public int insertNotice (SysNotice notice) {
return noticeMapper.insertNotice(notice);
int i = noticeMapper.insertNotice(notice);
if (notice.getNoticeType().equals("1")){
Long noticeId = notice.getNoticeId();
List<Long> personnnelList = notice.getPersonnelList();
List<List<Long>> sectionList = notice.getSectionList();
List<AsUserDept> asUserDepts = handleList(personnnelList, sectionList, noticeId);
asUserDeptMapper.insertBachAsUserDept(asUserDepts);
}else {
List<Long> userIds = noticeMapper.selectUser();
List<AsUserDept> asUserDepts = userIds.stream().map(id -> {
AsUserDept asUserDept = new AsUserDept();
asUserDept.setNoticeId(notice.getNoticeId());
asUserDept.setCreateTime(new Date());
asUserDept.setUserId(id);
asUserDept.setCreateBy(SecurityUtils.getUsername());
return asUserDept;
}).toList();
asUserDeptMapper.insertBachAsUserDept(asUserDepts);
}
return i;
}
/**
@ -90,4 +155,13 @@ public class SysNoticeServiceImpl extends ServiceImpl<SysNoticeMapper, SysNotice
public int deleteNoticeByIds (Long[] noticeIds) {
return noticeMapper.deleteNoticeByIds(noticeIds);
}
@Override
public Result<List<SysNoticeResponse>> getNoticeList(SysNoticeRequest sysNoticeRequest) {
sysNoticeRequest.setNoticeId(
SecurityUtils.getUserId()
);
List<SysNoticeResponse> noticeList= noticeMapper.getNoticeList(sysNoticeRequest);
return Result.success(noticeList);
}
}

View File

@ -26,6 +26,7 @@ public class SysPostServiceImpl extends ServiceImpl<SysPostMapper, SysPost> impl
@Autowired
private SysUserPostMapper userPostMapper;
/**
*
*

View File

@ -50,6 +50,18 @@
</if>
</where>
</select>
<select id="getNoticeList" resultType="com.muyu.system.domain.resp.SysNoticeResponse">
select id,a.notice_id,is_read,a.create_by,a.create_time,notice_title,notice_content,notice_type
from as_user_dept a join sys_notice n on a.notice_id=n.notice_id
where a.user_id=#{userId}
<if test="isRead !=null and isRead!= ''">
and is_read =#{isRead}
</if>
<if test="noticeType !=null and noticeType!= ''">
and n.notice_type =#{noticeType}
</if>
</select>
<insert id="insertNotice" parameterType="com.muyu.system.domain.SysNotice">
insert into sys_notice (

View File

@ -183,6 +183,13 @@
and del_flag = '0'
limit 1
</select>
<select id="selectDtptUser" resultType="java.lang.Long">
select user_id from sys_user where dept_id in (
<foreach collection="sectionIds" separator="-" item="id">
#{id}
</foreach>
)
</select>
<insert id="insertUser" parameterType="com.muyu.common.system.domain.SysUser" useGeneratedKeys="true" keyProperty="userId">
insert into sys_user(

View File

@ -13,6 +13,7 @@
<module>muyu-gen</module>
<module>muyu-job</module>
<module>muyu-file</module>
<module>muyu-kvt</module>
</modules>
<artifactId>muyu-modules</artifactId>