大屏获取试验室
This commit is contained in:
@@ -3,15 +3,13 @@ package com.dc.dc_project;
|
||||
import org.mybatis.spring.annotation.MapperScan;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
|
||||
@SpringBootApplication
|
||||
@MapperScan("com.dc.dc_project.mapper")
|
||||
@ComponentScan(basePackages = {"com.dc.dc_project.service"})
|
||||
public class DcProjectApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(DcProjectApplication.class, args);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
99
src/main/java/com/dc/dc_project/common/ResponseResult.java
Normal file
99
src/main/java/com/dc/dc_project/common/ResponseResult.java
Normal file
@@ -0,0 +1,99 @@
|
||||
package com.dc.dc_project.common;
|
||||
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import static com.dc.dc_project.common.ResultCode.*;
|
||||
|
||||
/**
|
||||
* <p> 统一返回结果类 </p>
|
||||
*
|
||||
* @description :
|
||||
* @author : blue
|
||||
*/
|
||||
@Schema(description = "统一返回结果类")
|
||||
@Data
|
||||
public class ResponseResult {
|
||||
/**
|
||||
* 消息内容
|
||||
*/
|
||||
@Schema(description = "响应消息", required = false)
|
||||
private String message;
|
||||
|
||||
/**
|
||||
* 响应码:参考`ResultCode`
|
||||
*/
|
||||
@Schema(description = "响应码", required = true)
|
||||
private Integer code;
|
||||
|
||||
/**
|
||||
* 响应中的数据
|
||||
*/
|
||||
@Schema(description = "响应数据", required = false)
|
||||
private Object data;
|
||||
|
||||
@Schema(description = "响应数据", required = false)
|
||||
private Map<String,Object> extra = new HashMap<>();
|
||||
|
||||
public ResponseResult putExtra(String key, Object value) {
|
||||
this.extra.put(key, value);
|
||||
return this;
|
||||
}
|
||||
|
||||
public static ResponseResult error(String message) {
|
||||
return new ResponseResult(FAILURE.getCode(), message, null);
|
||||
}
|
||||
|
||||
public static ResponseResult error() {
|
||||
return new ResponseResult(FAILURE.getCode(), ERROR.getDesc(), null);
|
||||
}
|
||||
|
||||
public static ResponseResult error(Integer code, String message) {
|
||||
return new ResponseResult(code, message, null);
|
||||
}
|
||||
|
||||
public static ResponseResult success() {
|
||||
return new ResponseResult(SUCCESS.getCode(), SUCCESS.getDesc(), null);
|
||||
}
|
||||
|
||||
public static ResponseResult success(Object data) {
|
||||
return new ResponseResult(SUCCESS.getCode(),SUCCESS.getDesc(), data);
|
||||
}
|
||||
|
||||
public static ResponseResult success(String message, Object data) {
|
||||
return new ResponseResult(SUCCESS.getCode(), message, data);
|
||||
}
|
||||
|
||||
public static ResponseResult success(Integer code, String message, Object data) {
|
||||
return new ResponseResult(code, message, data);
|
||||
}
|
||||
|
||||
public static ResponseResult success(Integer code, String message) {
|
||||
return new ResponseResult(code, message,null);
|
||||
}
|
||||
|
||||
public static ResponseResult check(Integer ...result) {
|
||||
if(Arrays.stream(result).anyMatch(r -> r == 0)){
|
||||
return error("数据库更新失败");
|
||||
};
|
||||
return success();
|
||||
}
|
||||
|
||||
public static ResponseResult check(boolean f) {
|
||||
if(f){
|
||||
return success();
|
||||
};
|
||||
return error("数据操作失败");
|
||||
}
|
||||
|
||||
public ResponseResult(Integer code, String msg, Object data) {
|
||||
this.code = code;
|
||||
this.message = msg;
|
||||
this.data = data;
|
||||
}
|
||||
}
|
||||
61
src/main/java/com/dc/dc_project/common/ResultCode.java
Normal file
61
src/main/java/com/dc/dc_project/common/ResultCode.java
Normal file
@@ -0,0 +1,61 @@
|
||||
package com.dc.dc_project.common;
|
||||
|
||||
|
||||
/**
|
||||
* <p> 响应码枚举 - 可参考HTTP状态码的语义 </p>
|
||||
*
|
||||
* @description :
|
||||
* @author : by blue
|
||||
* @date : 2021/8/22 11:09
|
||||
*/
|
||||
public enum ResultCode {
|
||||
//成功
|
||||
SUCCESS( 200, "成功" ),
|
||||
//失败
|
||||
FAILURE( 400, "失败" ),
|
||||
|
||||
|
||||
// 系统级别错误码
|
||||
ERROR(-1, "操作异常"),
|
||||
ERROR_DEFAULT(500,"系统繁忙,请稍后重试"),
|
||||
NOT_LOGIN(401, "当前会话已过期,请重新登录"),
|
||||
NO_PERMISSION(-7,"无权限"),
|
||||
ERROR_PASSWORD(-8,"用户帐号或者密码错误!"),
|
||||
DISABLE_ACCOUNT(-12,"该账号已被管理员禁止登录!"),
|
||||
|
||||
|
||||
// 服务层面
|
||||
ERROR_EXCEPTION_MOBILE_CODE(10003,"验证码不正确或已过期,请重新输入"),
|
||||
ERROR_USER_NOT_EXIST(10009, "用户不存在"),
|
||||
PARAMS_ILLEGAL(10018,"参数不合法!!"),
|
||||
CATEGORY_IS_EXIST(10019,"该分类名称已存在!"),
|
||||
CATEGORY_IS_TOP(10020,"该分类已经在顶端!!"),
|
||||
DATA_TAG_IS_EXIST(10021,"该数据标签已存在!"),
|
||||
CRAWLING_ARTICLE_FAILED(10022,"抓取文章失败!"),
|
||||
ARTICLE_NOT_EXIST(10023,"文章不存在!"),
|
||||
EMAIL_PATTERN_ERROR(10024,"邮箱格式错误!");
|
||||
|
||||
public int code;
|
||||
public String desc;
|
||||
|
||||
ResultCode(int code, String desc) {
|
||||
this.code = code;
|
||||
this.desc = desc;
|
||||
}
|
||||
|
||||
public int getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public void setCode(int code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public String getDesc() {
|
||||
return desc;
|
||||
}
|
||||
|
||||
public void setDesc(String desc) {
|
||||
this.desc = desc;
|
||||
}
|
||||
}
|
||||
@@ -11,17 +11,17 @@ import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
|
||||
|
||||
@Configuration
|
||||
@ConditionalOnWebApplication(type = ConditionalOnWebApplication.Type.SERVLET)
|
||||
public class SaTokenConfigure implements WebMvcConfigurer {
|
||||
|
||||
@Override
|
||||
public void addInterceptors(InterceptorRegistry registry) {
|
||||
registry.addInterceptor(new SaInterceptor(h -> {
|
||||
|
||||
SaManager.getLog().debug("----- 请求path={} 提交token={}", SaHolder.getRequest().getRequestPath(), StpUtil.getTokenValue());
|
||||
SaRouter.match("/project/**").check(StpUtil::checkLogin);
|
||||
})).addPathPatterns("/**");
|
||||
}
|
||||
|
||||
}
|
||||
//@Configuration
|
||||
//@ConditionalOnWebApplication(type = ConditionalOnWebApplication.Type.SERVLET)
|
||||
//public class SaTokenConfigure implements WebMvcConfigurer {
|
||||
//
|
||||
// @Override
|
||||
// public void addInterceptors(InterceptorRegistry registry) {
|
||||
// registry.addInterceptor(new SaInterceptor(h -> {
|
||||
//
|
||||
// SaManager.getLog().debug("----- 请求path={} 提交token={}", SaHolder.getRequest().getRequestPath(), StpUtil.getTokenValue());
|
||||
// SaRouter.match("/project/**").check(StpUtil::checkLogin);
|
||||
// })).addPathPatterns("/**");
|
||||
// }
|
||||
//
|
||||
//}
|
||||
|
||||
@@ -1,46 +1,46 @@
|
||||
package com.dc.dc_project.config;
|
||||
|
||||
import cn.dev33.satoken.stp.StpInterface;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.dc.dc_project.model.pojo.Role;
|
||||
import com.dc.dc_project.model.pojo.UserRole;
|
||||
import com.dc.dc_project.service.RoleService;
|
||||
import com.dc.dc_project.service.UserRoleService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 权限加载接口实现类
|
||||
*/
|
||||
@Component
|
||||
//package com.dc.dc_project.config;
|
||||
//
|
||||
//import cn.dev33.satoken.stp.StpInterface;
|
||||
//import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
//import com.dc.dc_project.model.pojo.Role;
|
||||
//import com.dc.dc_project.model.pojo.UserRole;
|
||||
//import com.dc.dc_project.service.RoleService;
|
||||
//import com.dc.dc_project.service.UserRoleService;
|
||||
//import lombok.RequiredArgsConstructor;
|
||||
//import org.springframework.beans.factory.annotation.Autowired;
|
||||
//import org.springframework.stereotype.Component;
|
||||
//import java.util.List;
|
||||
//
|
||||
///**
|
||||
// * 权限加载接口实现类
|
||||
// */
|
||||
//@Component
|
||||
//@RequiredArgsConstructor(onConstructor_ = {@Autowired})
|
||||
public class StpInterfaceImpl implements StpInterface {
|
||||
|
||||
@Autowired
|
||||
private UserRoleService userRoleService;
|
||||
|
||||
@Autowired
|
||||
private RoleService roleService;
|
||||
/**
|
||||
* 返回一个账号所拥有的权限码集合
|
||||
*/
|
||||
@Override
|
||||
public List<String> getPermissionList(Object loginId, String loginType) {
|
||||
LambdaQueryWrapper<UserRole> lambdaQueryWrapper = new LambdaQueryWrapper<UserRole>().eq(UserRole::getUserId, Long.valueOf(loginId.toString()));
|
||||
List<Long> roleIds = userRoleService.list(lambdaQueryWrapper).stream().map(UserRole::getRoleId).toList();
|
||||
return roleService.list(new LambdaQueryWrapper<Role>().in(Role::getId, roleIds)).stream().map(Role::getCode).toList();
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回一个账号所拥有的角色标识集合 (权限与角色可分开校验)
|
||||
*/
|
||||
@Override
|
||||
public List<String> getRoleList(Object loginId, String loginType) {
|
||||
LambdaQueryWrapper<UserRole> lambdaQueryWrapper = new LambdaQueryWrapper<UserRole>().eq(UserRole::getUserId, Long.valueOf(loginId.toString()));
|
||||
List<Long> roleIds = userRoleService.list(lambdaQueryWrapper).stream().map(UserRole::getRoleId).toList();
|
||||
return roleService.list(new LambdaQueryWrapper<Role>().in(Role::getId, roleIds)).stream().map(Role::getCode).toList();
|
||||
}
|
||||
|
||||
}
|
||||
//public class StpInterfaceImpl implements StpInterface {
|
||||
//
|
||||
// @Autowired
|
||||
// private UserRoleService userRoleService;
|
||||
//
|
||||
// @Autowired
|
||||
// private RoleService roleService;
|
||||
// /**
|
||||
// * 返回一个账号所拥有的权限码集合
|
||||
// */
|
||||
// @Override
|
||||
// public List<String> getPermissionList(Object loginId, String loginType) {
|
||||
// LambdaQueryWrapper<UserRole> lambdaQueryWrapper = new LambdaQueryWrapper<UserRole>().eq(UserRole::getUserId, Long.valueOf(loginId.toString()));
|
||||
// List<Long> roleIds = userRoleService.list(lambdaQueryWrapper).stream().map(UserRole::getRoleId).toList();
|
||||
// return roleService.list(new LambdaQueryWrapper<Role>().in(Role::getId, roleIds)).stream().map(Role::getCode).toList();
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 返回一个账号所拥有的角色标识集合 (权限与角色可分开校验)
|
||||
// */
|
||||
// @Override
|
||||
// public List<String> getRoleList(Object loginId, String loginType) {
|
||||
// LambdaQueryWrapper<UserRole> lambdaQueryWrapper = new LambdaQueryWrapper<UserRole>().eq(UserRole::getUserId, Long.valueOf(loginId.toString()));
|
||||
// List<Long> roleIds = userRoleService.list(lambdaQueryWrapper).stream().map(UserRole::getRoleId).toList();
|
||||
// return roleService.list(new LambdaQueryWrapper<Role>().in(Role::getId, roleIds)).stream().map(Role::getCode).toList();
|
||||
// }
|
||||
//
|
||||
//}
|
||||
|
||||
33
src/main/java/com/dc/dc_project/config/SwaggerConfig.java
Normal file
33
src/main/java/com/dc/dc_project/config/SwaggerConfig.java
Normal file
@@ -0,0 +1,33 @@
|
||||
// 你自己的包名
|
||||
package com.dc.dc_project.config;
|
||||
|
||||
import io.swagger.v3.oas.models.ExternalDocumentation;
|
||||
import io.swagger.v3.oas.models.OpenAPI;
|
||||
import io.swagger.v3.oas.models.info.Contact;
|
||||
import io.swagger.v3.oas.models.info.Info;
|
||||
import io.swagger.v3.oas.models.info.License;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
/**
|
||||
* @Author HHHY
|
||||
* @ClassName
|
||||
* @Date: 2024/4/2 14:21
|
||||
* @Description: Swagger 配置
|
||||
*/
|
||||
|
||||
@Configuration
|
||||
public class SwaggerConfig {
|
||||
@Bean
|
||||
public OpenAPI springShopOpenAPI() {
|
||||
return new OpenAPI()
|
||||
.info(new Info().title("Spring Boot 中使用 Swagger UI 构建 RESTful API")
|
||||
.contact(new Contact())
|
||||
.description(" RESTful API")
|
||||
.version("v1.0.0")
|
||||
.license(new License().name("Apache 2.0").url("http://springdoc.org")))
|
||||
.externalDocs(new ExternalDocumentation()
|
||||
.description("外部文档")
|
||||
.url("https://springshop.wiki.github.org/docs"));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.dc.dc_project.controller;
|
||||
|
||||
|
||||
import com.dc.dc_project.service.LaboratoryService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/laboratory")
|
||||
@RequiredArgsConstructor(onConstructor_ = {@Autowired})
|
||||
@Tag(name = "试验室管理")
|
||||
public class LaboratoryController {
|
||||
private final LaboratoryService laboratoryService;
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
16
src/main/java/com/dc/dc_project/controller/test.java
Normal file
16
src/main/java/com/dc/dc_project/controller/test.java
Normal file
@@ -0,0 +1,16 @@
|
||||
package com.dc.dc_project.controller;
|
||||
|
||||
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/test")
|
||||
public class test {
|
||||
|
||||
@GetMapping("/test")
|
||||
public String test(){
|
||||
return "test";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package com.dc.dc_project.enums.laboratory;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
public enum LaboratoryType {
|
||||
|
||||
Center (1, "中心实验室"),
|
||||
ConstructionSite(2, "工地实验室");
|
||||
|
||||
LaboratoryType(Integer code, String name){
|
||||
this.code = code;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
private final Integer code;
|
||||
private final String name;
|
||||
|
||||
public static LaboratoryType getLaboratoryType(Integer code){
|
||||
for (LaboratoryType value : LaboratoryType.values()) {
|
||||
if(value.getCode().equals(code)){
|
||||
return value;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public LaboratoryType getLaboratoryType(String name){
|
||||
for (LaboratoryType value : LaboratoryType.values()) {
|
||||
if(value.getName().equals(name)){
|
||||
return value;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -3,6 +3,8 @@ package com.dc.dc_project.mapper;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.dc.dc_project.model.pojo.Laboratory;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author ADMIN
|
||||
* @description 针对表【sys_laboratory(试验室信息表)】的数据库操作Mapper
|
||||
@@ -11,6 +13,9 @@ import com.dc.dc_project.model.pojo.Laboratory;
|
||||
*/
|
||||
public interface LaboratoryMapper extends BaseMapper<Laboratory> {
|
||||
|
||||
List<Laboratory> getList(Long id, String name, int type, Long standardId);
|
||||
|
||||
List<Integer> getCategoryIds(Long id);
|
||||
}
|
||||
|
||||
|
||||
|
||||
30
src/main/java/com/dc/dc_project/model/dto/LaboratoryDto.java
Normal file
30
src/main/java/com/dc/dc_project/model/dto/LaboratoryDto.java
Normal file
@@ -0,0 +1,30 @@
|
||||
package com.dc.dc_project.model.dto;
|
||||
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class LaboratoryDto{
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 实验室名称
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 实验室类型
|
||||
*/
|
||||
private int type;
|
||||
|
||||
/**
|
||||
* 行业
|
||||
*/
|
||||
private Long standardCategoryId;
|
||||
|
||||
|
||||
}
|
||||
@@ -37,34 +37,21 @@ public class Laboratory {
|
||||
@TableField(value = "org_id")
|
||||
private Long orgId;
|
||||
|
||||
@Override
|
||||
public boolean equals(Object that) {
|
||||
if (this == that) {
|
||||
return true;
|
||||
}
|
||||
if (that == null) {
|
||||
return false;
|
||||
}
|
||||
if (getClass() != that.getClass()) {
|
||||
return false;
|
||||
}
|
||||
Laboratory other = (Laboratory) that;
|
||||
return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
|
||||
&& (this.getCoordinateA() == null ? other.getCoordinateA() == null : this.getCoordinateA().equals(other.getCoordinateA()))
|
||||
&& (this.getCoordinateB() == null ? other.getCoordinateB() == null : this.getCoordinateB().equals(other.getCoordinateB()))
|
||||
&& (this.getOrgId() == null ? other.getOrgId() == null : this.getOrgId().equals(other.getOrgId()));
|
||||
}
|
||||
/**
|
||||
* 实验室类型
|
||||
*/
|
||||
@TableField(value = "type")
|
||||
private Integer type;
|
||||
|
||||
/**
|
||||
* 名称
|
||||
*/
|
||||
@TableField(value = "name")
|
||||
private String name;
|
||||
|
||||
@TableField(exist = false)
|
||||
private Integer standardCategoryId;
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
|
||||
result = prime * result + ((getCoordinateA() == null) ? 0 : getCoordinateA().hashCode());
|
||||
result = prime * result + ((getCoordinateB() == null) ? 0 : getCoordinateB().hashCode());
|
||||
result = prime * result + ((getOrgId() == null) ? 0 : getOrgId().hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
|
||||
69
src/main/java/com/dc/dc_project/model/vo/LaboratoryVo.java
Normal file
69
src/main/java/com/dc/dc_project/model/vo/LaboratoryVo.java
Normal file
@@ -0,0 +1,69 @@
|
||||
package com.dc.dc_project.model.vo;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.dc.dc_project.enums.laboratory.LaboratoryType;
|
||||
import com.dc.dc_project.model.pojo.Laboratory;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
@Data
|
||||
public class LaboratoryVo {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 坐标
|
||||
*/
|
||||
@TableField(value = "coordinate_a")
|
||||
private String coordinateA;
|
||||
|
||||
/**
|
||||
* 坐标2
|
||||
*/
|
||||
@TableField(value = "coordinate_b")
|
||||
private String coordinateB;
|
||||
|
||||
/**
|
||||
* 关联组织
|
||||
*/
|
||||
@TableField(value = "org_id")
|
||||
private Long orgId;
|
||||
|
||||
/**
|
||||
* 实验室类型
|
||||
*/
|
||||
@TableField(value = "type")
|
||||
private Integer type;
|
||||
private String typeName;
|
||||
|
||||
/**
|
||||
* 行业
|
||||
*/
|
||||
private List<Map<Integer, String>> standardCategorys;
|
||||
|
||||
/**
|
||||
* 名称
|
||||
*/
|
||||
@TableField(value = "name")
|
||||
private String name;
|
||||
|
||||
public static LaboratoryVo getLaboratoryVo(Laboratory laboratory){
|
||||
LaboratoryVo laboratoryVo = new LaboratoryVo();
|
||||
laboratoryVo.setId(laboratory.getId());
|
||||
laboratoryVo.setCoordinateA(laboratory.getCoordinateA());
|
||||
laboratoryVo.setCoordinateB(laboratory.getCoordinateB());
|
||||
laboratoryVo.setOrgId(laboratory.getOrgId());
|
||||
laboratoryVo.setType(laboratory.getType());
|
||||
laboratoryVo.setTypeName(Objects.requireNonNull(LaboratoryType.getLaboratoryType(laboratory.getType())).getName());
|
||||
return laboratoryVo;
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.dc.dc_project.service;
|
||||
|
||||
import com.dc.dc_project.common.ResponseResult;
|
||||
import com.dc.dc_project.model.dto.LaboratoryDto;
|
||||
import com.dc.dc_project.model.pojo.Laboratory;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
@@ -10,4 +12,10 @@ import com.baomidou.mybatisplus.extension.service.IService;
|
||||
*/
|
||||
public interface LaboratoryService extends IService<Laboratory> {
|
||||
|
||||
/**
|
||||
* 大屏获取实验室列表
|
||||
* @param laboratoryDto
|
||||
* @return
|
||||
*/
|
||||
ResponseResult getList(LaboratoryDto laboratoryDto);
|
||||
}
|
||||
|
||||
@@ -1,10 +1,25 @@
|
||||
package com.dc.dc_project.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.dc.dc_project.common.ResponseResult;
|
||||
import com.dc.dc_project.model.dto.LaboratoryDto;
|
||||
import com.dc.dc_project.model.pojo.Laboratory;
|
||||
import com.dc.dc_project.model.pojo.Standard;
|
||||
import com.dc.dc_project.model.pojo.StandardCategory;
|
||||
import com.dc.dc_project.model.vo.LaboratoryVo;
|
||||
import com.dc.dc_project.service.LaboratoryService;
|
||||
import com.dc.dc_project.mapper.LaboratoryMapper;
|
||||
import com.dc.dc_project.service.StandardCategoryService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.dc.dc_project.enums.laboratory.LaboratoryType;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author ADMIN
|
||||
@@ -12,11 +27,42 @@ import org.springframework.stereotype.Service;
|
||||
* @createDate 2025-11-12 10:49:22
|
||||
*/
|
||||
@Service
|
||||
@RequiredArgsConstructor(onConstructor_ = {@Autowired})
|
||||
public class LaboratoryServiceImpl extends ServiceImpl<LaboratoryMapper, Laboratory>
|
||||
implements LaboratoryService{
|
||||
|
||||
}
|
||||
|
||||
|
||||
private final StandardCategoryService standardCategoryService;
|
||||
|
||||
@Override
|
||||
public ResponseResult getList(LaboratoryDto laboratoryDto) {
|
||||
List<Laboratory> laboratorys = baseMapper.getList(
|
||||
laboratoryDto.getId(),
|
||||
laboratoryDto.getName(),
|
||||
laboratoryDto.getType(),
|
||||
laboratoryDto.getStandardCategoryId()
|
||||
);
|
||||
if (laboratorys.isEmpty()) {
|
||||
return ResponseResult.success();
|
||||
}
|
||||
List<LaboratoryVo> laboratoryVos = new ArrayList<>();
|
||||
for (Laboratory laboratory : laboratorys) {
|
||||
LaboratoryVo laboratoryVo = LaboratoryVo.getLaboratoryVo(laboratory);
|
||||
List<Integer> standardIds = new ArrayList<>();
|
||||
standardIds = baseMapper.getCategoryIds(laboratory.getId());
|
||||
LambdaQueryWrapper<StandardCategory> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.in(StandardCategory::getId, standardIds);
|
||||
List<StandardCategory> standardCategories = standardCategoryService.list(queryWrapper);
|
||||
// 将StandardCategory的id与name组合为map
|
||||
List<Map<Integer, String>> standardCategoryMaps = new ArrayList<>();
|
||||
for (StandardCategory category : standardCategories) {
|
||||
Map<Integer, String> categoryMap = new HashMap<>();
|
||||
categoryMap.put(category.getId().intValue(), category.getName());
|
||||
standardCategoryMaps.add(categoryMap);
|
||||
}
|
||||
laboratoryVo.setStandardCategorys(standardCategoryMaps);
|
||||
laboratoryVos.add(laboratoryVo);
|
||||
}
|
||||
|
||||
return ResponseResult.success(laboratoryVos);
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,7 @@
|
||||
server:
|
||||
port: 8800
|
||||
servlet:
|
||||
context-path: /dc
|
||||
spring:
|
||||
data:
|
||||
redis:
|
||||
@@ -33,8 +37,20 @@ mybatis-plus:
|
||||
# 数据库配置
|
||||
id-type: auto
|
||||
sa-token:
|
||||
token-name: token
|
||||
token-style: random-128
|
||||
# token 名称(同时也是 cookie 名称)
|
||||
token-name: satoken
|
||||
# token 有效期(单位:秒) 默认30天,-1 代表永久有效
|
||||
timeout: 2592000
|
||||
# token 最低活跃频率(单位:秒),如果 token 超过此时间没有访问系统就会被冻结,默认-1 代表不限制,永不冻结
|
||||
active-timeout: -1
|
||||
# 是否允许同一账号多地同时登录 (为 true 时允许一起登录, 为 false 时新登录挤掉旧登录)
|
||||
is-concurrent: true
|
||||
# 在多人登录同一账号时,是否共用一个 token (为 true 时所有登录共用一个 token, 为 false 时每次登录新建一个 token)
|
||||
is-share: false
|
||||
# token 风格(默认可取值:uuid、simple-uuid、random-32、random-64、random-128、tik)
|
||||
token-style: uuid
|
||||
# 是否输出操作日志
|
||||
is-log: true
|
||||
logging:
|
||||
level:
|
||||
io:
|
||||
@@ -44,3 +60,11 @@ logging:
|
||||
springframework:
|
||||
data:
|
||||
redis=DEBUG:
|
||||
|
||||
springdoc:
|
||||
api-docs:
|
||||
enabled: true # 开启OpenApi接口
|
||||
path: /v3/api-docs # 自定义路径,默认为 "/v3/api-docs"
|
||||
swagger-ui:
|
||||
enabled: true # 开启swagger界面,依赖OpenApi,需要OpenApi同时开启
|
||||
path: /swagger-ui/index.html # 自定义路径,默认为"/swagger-ui/index.html"
|
||||
|
||||
@@ -14,4 +14,26 @@
|
||||
<sql id="Base_Column_List">
|
||||
id,coordinate_a,coordinate_b,org_id
|
||||
</sql>
|
||||
|
||||
<select id="getList" resultType="com.dc.dc_project.model.pojo.Laboratory">
|
||||
select sl.* from sys_laboratory sl
|
||||
left join sys_org_laboratory_standard sols on sl.id = sols.laboratory_id
|
||||
<where>
|
||||
<if test="name != null">
|
||||
and sl.name like concat('%',#{name},'%')
|
||||
</if>
|
||||
<if test="type != null">
|
||||
and sl.type = #{type}
|
||||
</if>
|
||||
<if test="standardId != null">
|
||||
and sols.standard_category_id = #{standardId}
|
||||
</if>
|
||||
<if test="id != null">
|
||||
and sl.id = #{id}
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
<select id="getCategoryIds" resultType="java.lang.Integer">
|
||||
select standard_category_id from sys_org_laboratory_standard where laboratory_id = #{id}
|
||||
</select>
|
||||
</mapper>
|
||||
|
||||
Reference in New Issue
Block a user