微服务版后端初始化
This commit is contained in:
16
xjrsoft-service/xjrsoft-service-bi/Dockerfile
Normal file
16
xjrsoft-service/xjrsoft-service-bi/Dockerfile
Normal file
@ -0,0 +1,16 @@
|
||||
# 基础镜像
|
||||
FROM nexus.gdyditc.com:8082/openjdk:11-arm64
|
||||
# author
|
||||
MAINTAINER xjrsoft
|
||||
|
||||
# 挂载目录
|
||||
VOLUME /home/xjrsoft
|
||||
# 创建目录
|
||||
RUN mkdir -p /home/xjrsoft
|
||||
# 指定路径
|
||||
WORKDIR /home/xjrsoft
|
||||
# 复制jar文件到路径
|
||||
RUN ls
|
||||
COPY ./target/xjrsoft-service-bi.jar /home/xjrsoft/xjrsoft-service-bi.jar
|
||||
# 启动认证服务
|
||||
ENTRYPOINT ["java","-Dfile.encoding=utf-8","--add-opens","java.base/java.lang.reflect=ALL-UNNAMED","-jar","xjrsoft-service-bi.jar"]
|
||||
75
xjrsoft-service/xjrsoft-service-bi/pom.xml
Normal file
75
xjrsoft-service/xjrsoft-service-bi/pom.xml
Normal file
@ -0,0 +1,75 @@
|
||||
<?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>xjrsoft-service</artifactId>
|
||||
<groupId>com.xjrsoft</groupId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>xjrsoft-service-bi</artifactId>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>${java.version}</maven.compiler.source>
|
||||
<maven.compiler.target>${java.version}</maven.compiler.target>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.xjrsoft</groupId>
|
||||
<artifactId>xjrsoft-service-system-api</artifactId>
|
||||
<version>${xjrsoft.framework.version}</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>com.xjrsoft</groupId>
|
||||
<artifactId>xjrsoft-common-core</artifactId>
|
||||
<version>${xjrsoft.framework.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.xjrsoft</groupId>
|
||||
<artifactId>xjrsoft-common-mybatis</artifactId>
|
||||
<version>${xjrsoft.framework.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.xjrsoft</groupId>
|
||||
<artifactId>xjrsoft-service-bi-api</artifactId>
|
||||
<version>${xjrsoft.framework.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>${lombok.version}</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-loadbalancer</artifactId>
|
||||
</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>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
||||
@ -0,0 +1,23 @@
|
||||
package com.xjrsoft.bi;
|
||||
|
||||
import org.mybatis.spring.annotation.MapperScan;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
|
||||
import org.springframework.cloud.openfeign.EnableFeignClients;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
|
||||
/**
|
||||
* @Author: tzx
|
||||
* @Date: 2023/10/17 9:40
|
||||
*/
|
||||
@SpringBootApplication
|
||||
@EnableDiscoveryClient
|
||||
@EnableFeignClients(basePackages = "com.xjrsoft")
|
||||
@MapperScan(value = "com.xjrsoft.**.mapper")
|
||||
@ComponentScan(value = "com.xjrsoft")
|
||||
public class BiApplication {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(BiApplication.class, args);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,122 @@
|
||||
package com.xjrsoft.bi.controller;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import com.xjrsoft.bi.dto.*;
|
||||
import com.xjrsoft.bi.entity.Project;
|
||||
import com.xjrsoft.bi.service.IProjectService;
|
||||
import com.xjrsoft.bi.vo.ProjectInfoVo;
|
||||
import com.xjrsoft.common.core.constant.GlobalConstant;
|
||||
import com.xjrsoft.common.core.domain.result.R;
|
||||
import com.xjrsoft.common.core.enums.YesOrNoEnum;
|
||||
import com.xjrsoft.system.client.IMenuClient;
|
||||
import com.xjrsoft.system.entity.Menu;
|
||||
import com.xjrsoft.system.vo.MenuVo;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 项目表 前端控制器
|
||||
* </p>
|
||||
*
|
||||
* @author tzx
|
||||
* @since 2022-11-06
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping(GlobalConstant.BI_MODULE_PREFIX + "/project")
|
||||
@Tag(name = GlobalConstant.BI_MODULE_PREFIX + "/project", description = "BI大屏设计模块")
|
||||
@AllArgsConstructor
|
||||
public class ProjectController {
|
||||
|
||||
private final IProjectService projectService;
|
||||
|
||||
private final IMenuClient menuClient;
|
||||
|
||||
|
||||
@GetMapping(value = "/page")
|
||||
@Operation(summary = "查询bi大屏列表(分页)")
|
||||
public R page(@Valid ProjectPageDto dto) {
|
||||
return R.ok(projectService.getPage(dto));
|
||||
}
|
||||
|
||||
@GetMapping(value = "/info")
|
||||
@Operation(summary = "查看详情")
|
||||
public R info(@RequestParam Long id) {
|
||||
Project project = projectService.getById(id);
|
||||
return R.ok(BeanUtil.toBean(project, ProjectInfoVo.class));
|
||||
}
|
||||
|
||||
@GetMapping(value = "/old")
|
||||
@Operation(summary = "获取以前发布菜单的数据")
|
||||
public R getOldValue(@RequestParam Long menuId) {
|
||||
Menu menu = menuClient.getMenuByIdFeign(menuId);
|
||||
|
||||
return R.ok(BeanUtil.toBean(menu, MenuVo.class));
|
||||
}
|
||||
|
||||
|
||||
@PutMapping("/index-image")
|
||||
@Operation(summary = "修改项目首页图片")
|
||||
public R updateIndexImage(@Valid @RequestBody UpdateProjectIndexImageDto dto) {
|
||||
Project project = BeanUtil.toBean(dto, Project.class);
|
||||
return R.ok(projectService.updateById(project));
|
||||
}
|
||||
|
||||
@PutMapping("/content")
|
||||
@Operation(summary = "修改项目json")
|
||||
public R updateContent(@Valid @RequestBody UpdateProjectContentDto dto) {
|
||||
Project project = BeanUtil.toBean(dto, Project.class);
|
||||
return R.ok(projectService.updateById(project));
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
@Operation(summary = "创建项目")
|
||||
public R add(@Valid @RequestBody AddProjectDto dto) {
|
||||
Project project = BeanUtil.toBean(dto, Project.class);
|
||||
// project.setContent("{}");
|
||||
project.setState(YesOrNoEnum.YES.getCode());
|
||||
projectService.save(project);
|
||||
return R.ok(project.getId());
|
||||
}
|
||||
|
||||
@PutMapping
|
||||
@Operation(summary = "保存项目")
|
||||
public R update(@Valid @RequestBody UpdateProjectDto dto) {
|
||||
Project project = BeanUtil.toBean(dto, Project.class);
|
||||
projectService.updateById(project);
|
||||
return R.ok(project.getId());
|
||||
}
|
||||
|
||||
@PutMapping("/publish")
|
||||
@Operation(summary = "发布/不发布")
|
||||
public R publish(@Valid @RequestBody PublishProjectDto dto) {
|
||||
Project project = BeanUtil.toBean(dto, Project.class);
|
||||
return R.ok(projectService.updateById(project));
|
||||
}
|
||||
|
||||
@PostMapping("/publish-menu")
|
||||
@Operation(summary = "发布菜单")
|
||||
public R publishMenu(@Valid @RequestBody PublishMenuDto dto) {
|
||||
return R.ok(projectService.publishMenu(dto));
|
||||
}
|
||||
|
||||
@PostMapping("/cancel-menu")
|
||||
@Operation(summary = "取消发布菜单")
|
||||
public R cancelMenu(@Valid @RequestBody CancelMenuDto dto) {
|
||||
return R.ok(projectService.cancelMenu(dto));
|
||||
}
|
||||
|
||||
@DeleteMapping
|
||||
@Operation(summary = "删除")
|
||||
public R delete(@RequestBody List<Long> ids) {
|
||||
return R.ok(projectService.deleteProject(ids));
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,46 @@
|
||||
package com.xjrsoft.bi.service;
|
||||
|
||||
import com.github.yulichang.base.MPJBaseService;
|
||||
import com.xjrsoft.bi.dto.CancelMenuDto;
|
||||
import com.xjrsoft.bi.dto.ProjectPageDto;
|
||||
import com.xjrsoft.bi.dto.PublishMenuDto;
|
||||
import com.xjrsoft.bi.entity.Project;
|
||||
import com.xjrsoft.bi.vo.ProjectPageVo;
|
||||
import com.xjrsoft.common.core.domain.page.PageOutput;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 项目表 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author tzx
|
||||
* @since 2022-11-06
|
||||
*/
|
||||
public interface IProjectService extends MPJBaseService<Project> {
|
||||
|
||||
|
||||
PageOutput<ProjectPageVo> getPage(ProjectPageDto dto);
|
||||
|
||||
/**
|
||||
* 发布菜单
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
boolean publishMenu(PublishMenuDto dto);
|
||||
|
||||
/**
|
||||
* 取消发布
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
boolean cancelMenu(CancelMenuDto dto);
|
||||
|
||||
/**
|
||||
* 删除项目
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
boolean deleteProject(List<Long> ids);
|
||||
}
|
||||
@ -0,0 +1,170 @@
|
||||
package com.xjrsoft.bi.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.db.DbUtil;
|
||||
import cn.hutool.db.Entity;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.github.yulichang.base.MPJBaseServiceImpl;
|
||||
import com.xjrsoft.bi.dto.CancelMenuDto;
|
||||
import com.xjrsoft.bi.dto.ProjectPageDto;
|
||||
import com.xjrsoft.bi.dto.PublishMenuDto;
|
||||
import com.xjrsoft.bi.entity.Project;
|
||||
import com.xjrsoft.bi.mapper.ProjectMapper;
|
||||
import com.xjrsoft.bi.service.IProjectService;
|
||||
import com.xjrsoft.bi.vo.ProjectPageVo;
|
||||
import com.xjrsoft.common.core.constant.GlobalConstant;
|
||||
import com.xjrsoft.common.core.domain.page.PageOutput;
|
||||
import com.xjrsoft.common.core.enums.MenuType;
|
||||
import com.xjrsoft.common.core.enums.PublishStateType;
|
||||
import com.xjrsoft.common.core.enums.YesOrNoEnum;
|
||||
import com.xjrsoft.common.core.uitls.VoToColumnUtil;
|
||||
import com.xjrsoft.common.mybatis.utils.ConventPage;
|
||||
import com.xjrsoft.common.mybatis.utils.DatasourceUtil;
|
||||
import com.xjrsoft.system.client.IMenuClient;
|
||||
import com.xjrsoft.system.entity.Menu;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.SneakyThrows;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 项目表 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author tzx
|
||||
* @since 2022-11-06
|
||||
*/
|
||||
@Service
|
||||
@AllArgsConstructor
|
||||
public class ProjectServiceImpl extends MPJBaseServiceImpl<ProjectMapper, Project> implements IProjectService {
|
||||
|
||||
private final static String PREVIEW_URL_PRE = "/#/chart/preview/";
|
||||
|
||||
private final static String IFARME_STRING = "IFrame";
|
||||
private final IMenuClient menuClient;
|
||||
|
||||
@Override
|
||||
public PageOutput<ProjectPageVo> getPage(ProjectPageDto dto) {
|
||||
|
||||
LambdaQueryWrapper<Project> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.like(StrUtil.isNotBlank(dto.getKeyword()), Project::getProjectName, dto.getKeyword())
|
||||
.select(Project.class, x -> VoToColumnUtil.fieldsToColumns(ProjectPageVo.class).contains(x.getProperty()));
|
||||
|
||||
IPage<Project> page = page(ConventPage.getPage(dto), queryWrapper);
|
||||
PageOutput<ProjectPageVo> pageOutput = ConventPage.getPageOutput(page, ProjectPageVo.class);
|
||||
|
||||
List<Long> allMenuId = pageOutput.getList().stream().map(ProjectPageVo::getMenuId).collect(Collectors.toList());
|
||||
|
||||
List<Menu> menuList = menuClient.getMenuListByIdsFeign(allMenuId);
|
||||
|
||||
for (ProjectPageVo projectPageVo : pageOutput.getList()) {
|
||||
Optional<Menu> menuOptional = menuList.stream().filter(x -> x.getId().equals(projectPageVo.getMenuId())).findFirst();
|
||||
|
||||
//如果能查询到菜单数据 代表 要么 发布过 要么 正在发布
|
||||
if (menuOptional.isPresent()) {
|
||||
// 如果式已删除状态 属于 发布过已经取消状态
|
||||
if (menuOptional.get().getDeleteMark() == YesOrNoEnum.YES.getCode()) {
|
||||
projectPageVo.setPublishState(PublishStateType.PT.getCode());
|
||||
} else {
|
||||
projectPageVo.setPublishState(PublishStateType.ING.getCode());
|
||||
}
|
||||
|
||||
} else {
|
||||
projectPageVo.setPublishState(PublishStateType.NO.getCode());
|
||||
}
|
||||
|
||||
}
|
||||
return pageOutput;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@SneakyThrows
|
||||
public boolean publishMenu(PublishMenuDto dto) {
|
||||
|
||||
Menu menu = BeanUtil.toBean(dto, Menu.class);
|
||||
|
||||
if (ObjectUtil.isEmpty(menu.getParentId())){
|
||||
menu.setParentId(0L);
|
||||
}
|
||||
if (ObjectUtil.isEmpty(menu.getSystemId())){
|
||||
menu.setSystemId(1L);
|
||||
}
|
||||
menu.setComponent(IFARME_STRING);
|
||||
menu.setComponentType(YesOrNoEnum.YES.getCode());
|
||||
menu.setPath(dto.getUrl() + PREVIEW_URL_PRE + dto.getProjectId());
|
||||
menu.setMenuType(MenuType.FUNCTION.getCode());
|
||||
menu.setDisplay(YesOrNoEnum.YES.getCode());
|
||||
menu.setAllowDelete(YesOrNoEnum.YES.getCode());
|
||||
menu.setAllowModify(YesOrNoEnum.YES.getCode());
|
||||
menu.setOutLink(YesOrNoEnum.YES.getCode());
|
||||
menu.setKeepAlive(YesOrNoEnum.NO.getCode());
|
||||
menu.setName(menu.getTitle());
|
||||
|
||||
//如果没有传入 menuId 默认是新增 如果传入了 就是修改
|
||||
if (ObjectUtil.isNotNull(dto.getMenuId())) {
|
||||
// menu.setDeleteMark(YesOrNoEnum.NO.getCode());
|
||||
menuClient.updateMenuFeign(menu);
|
||||
|
||||
String tableName = "xjr_menu";
|
||||
|
||||
DataSource datasourceMaster = DatasourceUtil.getDatasourceMaster();
|
||||
Entity entity = Entity.create(tableName).set(GlobalConstant.DELETE_MARK, YesOrNoEnum.NO.getCode());
|
||||
Entity where = Entity.create(tableName).set(GlobalConstant.DEFAULT_PK, menu.getId());
|
||||
DbUtil.use(datasourceMaster).update(entity, where);
|
||||
} else {
|
||||
menuClient.insertMenuFeign(menu);
|
||||
}
|
||||
|
||||
Project project = new Project();
|
||||
project.setId(dto.getProjectId());
|
||||
project.setMenuId(menu.getId());
|
||||
|
||||
updateById(project);
|
||||
|
||||
return Boolean.TRUE;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public boolean cancelMenu(CancelMenuDto dto) {
|
||||
|
||||
Project project = new Project();
|
||||
project.setId(dto.getId());
|
||||
|
||||
updateById(project);
|
||||
|
||||
menuClient.deleteMenuFeign(dto.getMenuId());
|
||||
|
||||
|
||||
return Boolean.TRUE;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public boolean deleteProject(List<Long> ids) {
|
||||
|
||||
LambdaQueryWrapper<Project> select = Wrappers.lambdaQuery(Project.class).in(Project::getId, ids).isNotNull(Project::getMenuId).select(Project::getMenuId);
|
||||
List<Project> list = list(select);
|
||||
|
||||
if (list.size() > 0) {
|
||||
List<Long> menuId = list.stream().map(Project::getMenuId).collect(Collectors.toList());
|
||||
|
||||
menuClient.deleteMenuBatchFeign(menuId);
|
||||
}
|
||||
|
||||
|
||||
removeByIds(ids);
|
||||
return Boolean.TRUE;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,3 @@
|
||||
spring:
|
||||
profiles:
|
||||
active: public
|
||||
@ -0,0 +1,75 @@
|
||||
server:
|
||||
port: 3005
|
||||
|
||||
|
||||
spring:
|
||||
application:
|
||||
name: bi-service
|
||||
main:
|
||||
allow-bean-definition-overriding: true
|
||||
autoconfigure:
|
||||
#自动化配置 例外处理
|
||||
exclude: com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure
|
||||
datasource:
|
||||
type: com.alibaba.druid.pool.DruidDataSource
|
||||
dynamic:
|
||||
primary: master
|
||||
datasource:
|
||||
master:
|
||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
url: jdbc:mysql://new-energy-mysqlt.itc.gdyd.com:3307/fcd2-msat-init?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&nullCatalogMeansCurrent=true
|
||||
username: learun4dev
|
||||
password: ABcd1234@
|
||||
|
||||
cloud:
|
||||
nacos: #nacos监控
|
||||
discovery:
|
||||
server-addr: 10.0.252.1:8848
|
||||
namespace: ITC
|
||||
group: DNE
|
||||
username: nacos
|
||||
password: ABcd1234@
|
||||
config:
|
||||
server-addr: 10.0.252.1:8848 # nacos 配置中心地址
|
||||
namespace: ITC
|
||||
group: DNE
|
||||
username: nacos
|
||||
password: ABcd1234@
|
||||
file-extension: yml # 指定格式 xjrsoft-demo-service-dev.yml
|
||||
extension-configs:
|
||||
- data-id: global-config.yml #导入全局配置
|
||||
refresh: true
|
||||
group: DNE
|
||||
- data-id: mybatis-plus-config.yml #导入mybatisplus 配置
|
||||
refresh: true
|
||||
group: DNE
|
||||
- data-id: sa-token-client-config.yml #导入sa-token配置
|
||||
refresh: true
|
||||
group: DNE
|
||||
- data-id: redis-config.yml #导入redis配置
|
||||
refresh: true
|
||||
group: DNE
|
||||
- data-id: seata-config.yml #导入seata配置
|
||||
refresh: true
|
||||
group: DNE
|
||||
sentinel:
|
||||
transport:
|
||||
dashboard: localhost:8080 #sentinel dashboard 地址
|
||||
port: 8719 #默认端口, 如果 被占用,会一直+1 直到未被占用为止
|
||||
|
||||
|
||||
|
||||
|
||||
springdoc:
|
||||
swagger-ui:
|
||||
path: /swagger-ui.html
|
||||
tags-sorter: alpha
|
||||
operations-sorter: alpha
|
||||
show-extensions: true
|
||||
api-docs:
|
||||
path: /bi/v3/api-docs
|
||||
group-configs:
|
||||
- group: 'default'
|
||||
paths-to-match: '/bi/**'
|
||||
packages-to-scan: com.xjrsoft.bi
|
||||
default-flat-param-object: false
|
||||
Reference in New Issue
Block a user