Compare commits
2 Commits
main
...
develop-20
Author | SHA1 | Date | |
---|---|---|---|
48d399d11c | |||
|
7e6cebdaa2 |
@ -4,6 +4,7 @@ import com.salpa.common.constant.UserConstants;
|
|||||||
import com.salpa.common.core.controller.BaseController;
|
import com.salpa.common.core.controller.BaseController;
|
||||||
import com.salpa.common.core.domain.AjaxResult;
|
import com.salpa.common.core.domain.AjaxResult;
|
||||||
import com.salpa.common.core.page.TableDataInfo;
|
import com.salpa.common.core.page.TableDataInfo;
|
||||||
|
import com.salpa.subject.domain.MonitorDataSource;
|
||||||
import com.salpa.subject.domain.MonitorOperationLog;
|
import com.salpa.subject.domain.MonitorOperationLog;
|
||||||
import com.salpa.subject.domain.MonitorProject;
|
import com.salpa.subject.domain.MonitorProject;
|
||||||
import com.salpa.subject.domain.vo.MonitorDataSourceVo;
|
import com.salpa.subject.domain.vo.MonitorDataSourceVo;
|
||||||
@ -41,6 +42,19 @@ public class ProjectController extends BaseController {
|
|||||||
return getDataTable(list);
|
return getDataTable(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取项目列表
|
||||||
|
* @author zhuff
|
||||||
|
* @param monitorDataSourceVo
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@PostMapping("pageList")
|
||||||
|
public TableDataInfo getPageList(@RequestBody MonitorDataSourceVo monitorDataSourceVo) {
|
||||||
|
List<Map<String , Object>> list = projectService.getPageList(monitorDataSourceVo);
|
||||||
|
return getDataTable(list);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 创建项目
|
* 创建项目
|
||||||
* @author zhuff
|
* @author zhuff
|
||||||
@ -68,6 +82,21 @@ public class ProjectController extends BaseController {
|
|||||||
return toAjax(projectService.addProject(monitorProject));
|
return toAjax(projectService.addProject(monitorProject));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建项目
|
||||||
|
* @author zhuff
|
||||||
|
* @param monitorProject
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@PostMapping("addProject")
|
||||||
|
public AjaxResult addProject(@RequestBody MonitorProject monitorProject) {
|
||||||
|
if (UserConstants.NOT_UNIQUE.equals(projectService.checkProjectNameUnique(monitorProject.getProjectName()))) {
|
||||||
|
return AjaxResult.error("新增项目模型'" + monitorProject.getProjectName() + "'失败,该项目模型已存在");
|
||||||
|
}
|
||||||
|
monitorProject.setSubjectId(111111);
|
||||||
|
return toAjax(projectService.addProjectNew(monitorProject));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改项目
|
* 修改项目
|
||||||
* @author zhuff
|
* @author zhuff
|
||||||
@ -99,6 +128,22 @@ public class ProjectController extends BaseController {
|
|||||||
return toAjax(projectService.updateProject(monitorProject));
|
return toAjax(projectService.updateProject(monitorProject));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改项目
|
||||||
|
* @author zhuff
|
||||||
|
* @param monitorProject
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@PostMapping("updateNewProject")
|
||||||
|
public AjaxResult updateNewProject(@RequestBody MonitorProject monitorProject) {
|
||||||
|
if (!projectService.getById(monitorProject.getId()).getProjectName().equals(monitorProject.getProjectName())) {
|
||||||
|
if (UserConstants.NOT_UNIQUE.equals(projectService.checkProjectNameUnique(monitorProject.getProjectName()))) {
|
||||||
|
return AjaxResult.error("修改项目模型'" + monitorProject.getProjectName() + "'失败,该项目模型已存在");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return toAjax(projectService.updateNewProject(monitorProject));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据id获取项目
|
* 根据id获取项目
|
||||||
* @author zhuff
|
* @author zhuff
|
||||||
@ -110,6 +155,17 @@ public class ProjectController extends BaseController {
|
|||||||
return AjaxResult.success(projectService.getProjectById(id));
|
return AjaxResult.success(projectService.getProjectById(id));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据id获取项目
|
||||||
|
* @author zhuff
|
||||||
|
* @param id
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@GetMapping("getNewProjectById")
|
||||||
|
public AjaxResult getNewProjectById(@RequestParam Integer id) {
|
||||||
|
return AjaxResult.success(projectService.getById(id));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除项目
|
* 删除项目
|
||||||
* @param id
|
* @param id
|
||||||
@ -120,6 +176,16 @@ public class ProjectController extends BaseController {
|
|||||||
return toAjax(projectService.deleteProject(id));
|
return toAjax(projectService.deleteProject(id));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除项目
|
||||||
|
* @param id
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@DeleteMapping("deleteNewProject")
|
||||||
|
public AjaxResult deleteNewProject(Integer id){
|
||||||
|
return toAjax(projectService.deleteNewProject(id));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 测试连接
|
* 测试连接
|
||||||
@ -151,4 +217,14 @@ public class ProjectController extends BaseController {
|
|||||||
return getDataTable(list);
|
return getDataTable(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PostMapping("createDataSource")
|
||||||
|
public AjaxResult createDataSource(@RequestBody MonitorDataSource monitorDataSource) {
|
||||||
|
if (UserConstants.NOT_UNIQUE.equals(projectService.checkDatabaseNameUnique(monitorDataSource.getDatabaseName())))
|
||||||
|
{
|
||||||
|
return AjaxResult.error("新增数据库'" + monitorDataSource.getDatabaseName() + "'失败,该数据库已存在");
|
||||||
|
}
|
||||||
|
projectService.addDataSource(monitorDataSource);
|
||||||
|
return AjaxResult.success();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -109,7 +109,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter
|
|||||||
// 过滤请求
|
// 过滤请求
|
||||||
.authorizeRequests()
|
.authorizeRequests()
|
||||||
// 对于登录login 注册register 验证码captchaImage 允许匿名访问
|
// 对于登录login 注册register 验证码captchaImage 允许匿名访问
|
||||||
.antMatchers("/login", "/register", "/captchaImage").anonymous()
|
.antMatchers("/login", "/register", "/captchaImage", "/subject/project/*","/subject/**").anonymous()
|
||||||
// 静态资源,可匿名访问
|
// 静态资源,可匿名访问
|
||||||
.antMatchers(HttpMethod.GET, "/", "/*.html", "/**/*.html", "/**/*.css", "/**/*.js", "/profile/**").permitAll()
|
.antMatchers(HttpMethod.GET, "/", "/*.html", "/**/*.html", "/**/*.css", "/**/*.js", "/profile/**").permitAll()
|
||||||
.antMatchers("/swagger-ui.html", "/swagger-resources/**", "/webjars/**", "/*/api-docs", "/druid/**").permitAll()
|
.antMatchers("/swagger-ui.html", "/swagger-resources/**", "/webjars/**", "/*/api-docs", "/druid/**").permitAll()
|
||||||
|
@ -26,4 +26,6 @@ public interface ProjectMapper {
|
|||||||
int updateProject(MonitorProject monitorProject);
|
int updateProject(MonitorProject monitorProject);
|
||||||
|
|
||||||
int deleteProject(Integer id);
|
int deleteProject(Integer id);
|
||||||
|
|
||||||
|
List<Map<String, Object>> getPageList(MonitorDataSourceVo monitorDataSourceVo);
|
||||||
}
|
}
|
||||||
|
@ -38,4 +38,14 @@ public interface ProjectService {
|
|||||||
List<MonitorOperationLog> getLogList(OperationLogVo operationLogVo);
|
List<MonitorOperationLog> getLogList(OperationLogVo operationLogVo);
|
||||||
|
|
||||||
Connection create(MonitorDataSource dataSource, List<Map<String, Object>> properties);
|
Connection create(MonitorDataSource dataSource, List<Map<String, Object>> properties);
|
||||||
|
|
||||||
|
void addDataSource(MonitorDataSource monitorDataSource);
|
||||||
|
|
||||||
|
List<Map<String, Object>> getPageList(MonitorDataSourceVo monitorDataSourceVo);
|
||||||
|
|
||||||
|
int addProjectNew(MonitorProject monitorProject);
|
||||||
|
|
||||||
|
int updateNewProject(MonitorProject monitorProject);
|
||||||
|
|
||||||
|
int deleteNewProject(Integer id);
|
||||||
}
|
}
|
||||||
|
@ -388,4 +388,33 @@ public class ProjectServiceImpl implements ProjectService {
|
|||||||
}
|
}
|
||||||
return connection;
|
return connection;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void addDataSource(MonitorDataSource monitorDataSource){
|
||||||
|
databaseMapper.addDatabaseSource(monitorDataSource);
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public List<Map<String, Object>> getPageList(MonitorDataSourceVo monitorDataSourceVo) {
|
||||||
|
PageHelper.startPage(monitorDataSourceVo.getPageNum(),monitorDataSourceVo.getPageSize());
|
||||||
|
List<Map<String , Object>> list = projectMapper.getPageList(monitorDataSourceVo);
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int addProjectNew(MonitorProject monitorProject) {
|
||||||
|
/*新增项目*/
|
||||||
|
int resultInt = projectMapper.addProject(monitorProject);
|
||||||
|
return resultInt;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int updateNewProject(MonitorProject monitorProject) {
|
||||||
|
return projectMapper.updateProject(monitorProject);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int deleteNewProject(Integer id) {
|
||||||
|
/*删除项目*/
|
||||||
|
return projectMapper.deleteProject(id);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -31,6 +31,20 @@
|
|||||||
</if>
|
</if>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<!-- 15:39-->
|
||||||
|
<select id="getPageList" resultType="map">
|
||||||
|
SELECT p.id id,p.project_name projectName,p.project_description projectDescription,DATE_FORMAT(p.create_at, '%Y-%m-%d') createAt,p.subject_id subjectId
|
||||||
|
FROM monitor_project p
|
||||||
|
WHERE p.deleted = 0
|
||||||
|
<if test="projectName != null and projectName != ''">
|
||||||
|
AND p.project_name like concat('%', #{projectName}, '%')
|
||||||
|
</if>
|
||||||
|
<if test="subjectId != null and subjectId != ''">
|
||||||
|
AND p.subject_id like concat('%', #{subjectId}, '%')
|
||||||
|
</if>
|
||||||
|
|
||||||
|
</select>
|
||||||
|
|
||||||
<select id="checkProjectNameUnique" resultType="int">
|
<select id="checkProjectNameUnique" resultType="int">
|
||||||
SELECT count(1) from monitor_project where project_name = #{projectName} and deleted = 0 limit 1
|
SELECT count(1) from monitor_project where project_name = #{projectName} and deleted = 0 limit 1
|
||||||
</select>
|
</select>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user