diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..c4d414f --- /dev/null +++ b/.gitignore @@ -0,0 +1,35 @@ +target/ +!.mvn/wrapper/maven-wrapper.jar +!**/src/main/**/target/ +!**/src/test/**/target/ + +### IntelliJ IDEA ### +*.iws +*.iml +*.ipr +.idea/ + +### Eclipse ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache + +### NetBeans ### +/nbproject/private/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ +build/ +!**/src/main/**/build/ +!**/src/test/**/build/ + +### VS Code ### +.vscode/ + +### Mac OS ### +.DS_Store \ No newline at end of file diff --git a/README.en.md b/README.en.md new file mode 100644 index 0000000..9f53762 --- /dev/null +++ b/README.en.md @@ -0,0 +1,36 @@ +# DFB-web + +#### Description +{**When you're done, you can delete the content in this README and update the file with details for others getting started with your repository**} + +#### Software Architecture +Software architecture description + +#### Installation + +1. xxxx +2. xxxx +3. xxxx + +#### Instructions + +1. xxxx +2. xxxx +3. xxxx + +#### Contribution + +1. Fork the repository +2. Create Feat_xxx branch +3. Commit your code +4. Create Pull Request + + +#### Gitee Feature + +1. You can use Readme\_XXX.md to support different languages, such as Readme\_en.md, Readme\_zh.md +2. Gitee blog [blog.gitee.com](https://blog.gitee.com) +3. Explore open source project [https://gitee.com/explore](https://gitee.com/explore) +4. The most valuable open source project [GVP](https://gitee.com/gvp) +5. The manual of Gitee [https://gitee.com/help](https://gitee.com/help) +6. The most popular members [https://gitee.com/gitee-stars/](https://gitee.com/gitee-stars/) diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..12469f8 --- /dev/null +++ b/pom.xml @@ -0,0 +1,155 @@ + + 4.0.0 + + org.springframework.boot + spring-boot-starter-parent + 2.4.5 + + + com.DFB + dfb-web-admin + 1.0-SNAPSHOT + + 8 + + + + + org.springframework.boot + spring-boot-starter-web + compile + + + + + org.projectlombok + lombok + 1.18.20 + true + + + + + com.baomidou + mybatis-plus-boot-starter + 3.4.2 + + + + + org.junit.jupiter + junit-jupiter-api + 5.9.3 + test + + + + + com.microsoft.sqlserver + mssql-jdbc + 9.4.1.jre8 + + + + + com.alibaba + druid-spring-boot-starter + 1.1.23 + + + + + org.apache.velocity + velocity-engine-core + 2.3 + + + + + org.springframework.boot + spring-boot-starter-data-redis + + + + + org.springframework.boot + spring-boot-starter-cache + + + + + com.baomidou + mybatis-plus-generator + 3.3.2 + + + + + org.springframework.boot + spring-boot-starter-aop + + + + + com.alibaba + fastjson + 1.2.76 + + + + + com.baomidou + mybatis-plus-extension + 3.5.3.1 + compile + + + + + com.qcloud + cos_api + 5.6.133 + + + + + io.jsonwebtoken + jjwt + 0.9.1 + + + cn.hutool + hutool-all + 5.7.22 + + + + io.springfox + springfox-spring-web + 3.0.0 + + + + com.github.penggle + kaptcha + 2.3.2 + + + org.springframework.boot + spring-boot-test + 3.2.9 + test + + + + + + + org.springframework.boot + spring-boot-maven-plugin + 2.4.5 + + + + \ No newline at end of file diff --git a/settings.xml b/settings.xml new file mode 100644 index 0000000..4c0f96c --- /dev/null +++ b/settings.xml @@ -0,0 +1,46 @@ + + + + + + + + + + + + + + + + + + + alimaven + central + aliyun maven + http://maven.aliyun.com/nexus/content/repositories/central/ + + + + + + + JDK-8 + + true + 8 + + + 8 + 8 + 8 + + + + + + + \ No newline at end of file diff --git a/src/main/java/com/mijiu/DFBApplication.java b/src/main/java/com/mijiu/DFBApplication.java new file mode 100644 index 0000000..37159af --- /dev/null +++ b/src/main/java/com/mijiu/DFBApplication.java @@ -0,0 +1,19 @@ +package com.mijiu; + +import lombok.extern.slf4j.Slf4j; + + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.web.servlet.ServletComponentScan; + + +@Slf4j +@SpringBootApplication +@ServletComponentScan +public class DFBApplication { + public static void main(String[] args) { + SpringApplication.run(DFBApplication.class, args); + log.info("项目启动成功..."); + } +} diff --git a/src/main/java/com/mijiu/common/Util/AdminHolder.java b/src/main/java/com/mijiu/common/Util/AdminHolder.java new file mode 100644 index 0000000..8660e79 --- /dev/null +++ b/src/main/java/com/mijiu/common/Util/AdminHolder.java @@ -0,0 +1,23 @@ +package com.mijiu.common.Util; + + +import com.mijiu.entity.vo.Administrator; + +/** + * @author mijiupro + */ +public class AdminHolder { private static final ThreadLocal TOKEN_HOLDER = new ThreadLocal<>(); + + public static void setInfoByToken(Administrator administrator) { + TOKEN_HOLDER.set(administrator); + } + + public static Administrator getInfoByToken() { + return TOKEN_HOLDER.get(); + } + + public static void clear() { + TOKEN_HOLDER.remove(); + } + +} diff --git a/src/main/java/com/mijiu/common/Util/BaseContext.java b/src/main/java/com/mijiu/common/Util/BaseContext.java new file mode 100644 index 0000000..ccf5b9c --- /dev/null +++ b/src/main/java/com/mijiu/common/Util/BaseContext.java @@ -0,0 +1,26 @@ +package com.mijiu.common.Util; + +/** + * 基于ThreadLocal封装工具类,用户保存和获取当前登录用户id + */ +public class BaseContext { + private static ThreadLocal threadLocal = new ThreadLocal<>(); + + /** + * 获取值 + * + * @return + */ + public static Long getCurrentId() { + return threadLocal.get(); + } + + /** + * 设置值 + * + * @param id + */ + public static void setCurrentId(Long id) { + threadLocal.set(id); + } +} \ No newline at end of file diff --git a/src/main/java/com/mijiu/common/Util/JacksonObjectMapper.java b/src/main/java/com/mijiu/common/Util/JacksonObjectMapper.java new file mode 100644 index 0000000..515fc93 --- /dev/null +++ b/src/main/java/com/mijiu/common/Util/JacksonObjectMapper.java @@ -0,0 +1,56 @@ +package com.mijiu.common.Util; + +import com.fasterxml.jackson.databind.DeserializationFeature; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.module.SimpleModule; +import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; +import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateDeserializer; +import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer; +import com.fasterxml.jackson.datatype.jsr310.deser.LocalTimeDeserializer; +import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateSerializer; +import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer; +import com.fasterxml.jackson.datatype.jsr310.ser.LocalTimeSerializer; + +import java.math.BigInteger; +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.time.LocalTime; +import java.time.format.DateTimeFormatter; + +import static com.fasterxml.jackson.databind.DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES; + +/** + * 对象映射器:基于jackson将Java对象转为json,或者将json转为Java对象 + * 将JSON解析为Java对象的过程称为 [从JSON反序列化Java对象] + * 从Java对象生成JSON的过程称为 [序列化Java对象到JSON] + */ +public class JacksonObjectMapper extends ObjectMapper { + + public static final String DEFAULT_DATE_FORMAT = "yyyy-MM-dd"; + public static final String DEFAULT_DATE_TIME_FORMAT = "yyyy-MM-dd HH:mm:ss"; + public static final String DEFAULT_TIME_FORMAT = "HH:mm:ss"; + + public JacksonObjectMapper() { + super(); + //收到未知属性时不报异常 + this.configure(FAIL_ON_UNKNOWN_PROPERTIES, false); + + //反序列化时,属性不存在的兼容处理 + this.getDeserializationConfig().withoutFeatures(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES); + + + SimpleModule simpleModule = new SimpleModule() + .addDeserializer(LocalDateTime.class, new LocalDateTimeDeserializer(DateTimeFormatter.ofPattern(DEFAULT_DATE_TIME_FORMAT))) + .addDeserializer(LocalDate.class, new LocalDateDeserializer(DateTimeFormatter.ofPattern(DEFAULT_DATE_FORMAT))) + .addDeserializer(LocalTime.class, new LocalTimeDeserializer(DateTimeFormatter.ofPattern(DEFAULT_TIME_FORMAT))) + + .addSerializer(BigInteger.class, ToStringSerializer.instance) + .addSerializer(Long.class, ToStringSerializer.instance) + .addSerializer(LocalDateTime.class, new LocalDateTimeSerializer(DateTimeFormatter.ofPattern(DEFAULT_DATE_TIME_FORMAT))) + .addSerializer(LocalDate.class, new LocalDateSerializer(DateTimeFormatter.ofPattern(DEFAULT_DATE_FORMAT))) + .addSerializer(LocalTime.class, new LocalTimeSerializer(DateTimeFormatter.ofPattern(DEFAULT_TIME_FORMAT))); + + //注册功能模块 例如,可以添加自定义序列化器和反序列化器 + this.registerModule(simpleModule); + } +} diff --git a/src/main/java/com/mijiu/common/Util/JwtUtils.java b/src/main/java/com/mijiu/common/Util/JwtUtils.java new file mode 100644 index 0000000..2e08e70 --- /dev/null +++ b/src/main/java/com/mijiu/common/Util/JwtUtils.java @@ -0,0 +1,103 @@ +package com.mijiu.common.Util; + +import io.jsonwebtoken.Claims; +import io.jsonwebtoken.Jwts; +import io.jsonwebtoken.SignatureAlgorithm; +import lombok.Data; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.stereotype.Component; + +import java.util.Date; +import java.util.Map; + + +/** + * @author mijiupro + */ +@Data +public class JwtUtils { + + private static String secret="123456";//密钥 + private static long expiration=4320000000L;//过期时间 + + + /** + * 生成token令牌 + * @param claims JWT第二部分负载 payload 中存储的内容 + * @param subject 主题(用户类型) + * @return token + */ + public static String generateToken(Map claims, String subject) { + return Jwts.builder() + .setId(Claims.ID)//设置jti(JWT ID):是JWT的唯一标识,根据业务需要,这个可以设置为一个不重复的值,主要用来作为令牌的唯一标识。 + .setSubject("mijiu")//设置主题,一般为用户类型 + .setIssuedAt(new Date())//设置签发时间 + .addClaims(claims)//设置负载 + .signWith(SignatureAlgorithm.HS256, secret)//设置签名算法 + .setExpiration(new Date(System.currentTimeMillis() + expiration))//设置令牌过期时间 + .compact();//生成令牌 + } + + /** + * 解析token令牌 + * @param token token令牌 + * @return 负载 + */ + public static Claims parseToken(String token) { + + return Jwts.parser() + .setSigningKey(secret) + .parseClaimsJws(token) + .getBody(); + } + + /** + * 验证token令牌 + * @param token 令牌 + * @return 是否有效 + */ + public static boolean validateToken(String token) { + try { + Jwts.parser() + .setSigningKey(secret) + .parseClaimsJws(token) + .getBody(); + + return true; + } catch (Exception e) { + return false; + } + } + + /** + * 刷新Token + * @param token 旧的Token令牌 + * @return 新的Token令牌 + */ + public String refreshToken(String token) { + try { + // 解析旧的Token,获取负载信息 + Claims claims = parseToken(token); + // 生成新的Token,设置过期时间和签名算法等参数 + return generateToken(claims, claims.getSubject()); + } catch (Exception e) { + throw new RuntimeException("无法刷新令牌!", e); + } + } + + + /** + * 从令牌中获取主题信息 + * @param token 令牌 + * @return 主题信息(用户类型) + */ + public String getSubjectFromToken(String token) { + try { + Claims claims = parseToken(token); // 解析令牌,获取负载信息 + return claims.getSubject(); // 返回主题信息 + } catch (Exception e) { + throw new RuntimeException("无法从令牌中获取主题。", e); + } + } + +} \ No newline at end of file diff --git a/src/main/java/com/mijiu/common/Util/MyMetaObjecthandler.java b/src/main/java/com/mijiu/common/Util/MyMetaObjecthandler.java new file mode 100644 index 0000000..e78d817 --- /dev/null +++ b/src/main/java/com/mijiu/common/Util/MyMetaObjecthandler.java @@ -0,0 +1,48 @@ +package com.mijiu.common.Util; + +import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler; +import lombok.extern.slf4j.Slf4j; +import org.apache.ibatis.reflection.MetaObject; +import org.springframework.stereotype.Component; + +import java.time.LocalDateTime; + +/** + * 自定义元数据对象处理器 + */ +@Component +@Slf4j +public class MyMetaObjecthandler implements MetaObjectHandler { + /** + * 插入操作,自动填充 + * + * @param metaObject + */ + @Override + public void insertFill(MetaObject metaObject) { + log.info("公共字段自动填充[insert]..."); + log.info(metaObject.toString()); + + metaObject.setValue("createTime", LocalDateTime.now()); + metaObject.setValue("updateTime", LocalDateTime.now()); + metaObject.setValue("createStaff", BaseContext.getCurrentId()); + metaObject.setValue("updateStaff", BaseContext.getCurrentId()); + } + + /** + * 更新操作,自动填充 + * + * @param metaObject + */ + @Override + public void updateFill(MetaObject metaObject) { + log.info("公共字段自动填充[update]..."); + log.info(metaObject.toString()); + + long id = Thread.currentThread().getId(); + log.info("线程id为:{}", id); + + metaObject.setValue("updateTime", LocalDateTime.now()); + metaObject.setValue("updateStaff", BaseContext.getCurrentId()); + } +} diff --git a/src/main/java/com/mijiu/common/Util/ValidateCodeUtils.java b/src/main/java/com/mijiu/common/Util/ValidateCodeUtils.java new file mode 100644 index 0000000..081da60 --- /dev/null +++ b/src/main/java/com/mijiu/common/Util/ValidateCodeUtils.java @@ -0,0 +1,44 @@ +package com.mijiu.common.Util; + +import java.util.Random; + +/** + * 随机生成验证码工具类 + */ +public class ValidateCodeUtils { + /** + * 随机生成验证码 + * + * @param length 长度为4位或者6位 + * @return + */ + public static Integer generateValidateCode(int length) { + Integer code = null; + if (length == 4) { + code = new Random().nextInt(9999);//生成随机数,最大为9999 + if (code < 1000) { + code = code + 1000;//保证随机数为4位数字 + } + } else if (length == 6) { + code = new Random().nextInt(999999);//生成随机数,最大为999999 + if (code < 100000) { + code = code + 100000;//保证随机数为6位数字 + } + } else { + throw new RuntimeException("只能生成4位或6位数字验证码"); + } + return code; + } + + /** + * 随机生成指定长度字符串验证码 + * + * @param length 长度 + * @return + */ + public static String generateValidateCode4String(int length) { + Random rdm = new Random(); + String hash1 = Integer.toHexString(rdm.nextInt()); + return hash1.substring(0, length); + } +} diff --git a/src/main/java/com/mijiu/common/annotation/Log.java b/src/main/java/com/mijiu/common/annotation/Log.java new file mode 100644 index 0000000..cd8b9eb --- /dev/null +++ b/src/main/java/com/mijiu/common/annotation/Log.java @@ -0,0 +1,12 @@ +package com.mijiu.common.annotation; + + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.METHOD) +public @interface Log { +} diff --git a/src/main/java/com/mijiu/common/aop/LogAspect.java b/src/main/java/com/mijiu/common/aop/LogAspect.java new file mode 100644 index 0000000..8fe54cf --- /dev/null +++ b/src/main/java/com/mijiu/common/aop/LogAspect.java @@ -0,0 +1,59 @@ +package com.mijiu.common.annotation.aop; + +import com.alibaba.fastjson.JSONObject; +import lombok.extern.slf4j.Slf4j; +import org.aspectj.lang.ProceedingJoinPoint; +import org.aspectj.lang.annotation.Around; +import org.aspectj.lang.annotation.Aspect; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import javax.servlet.http.HttpServletRequest; +import java.time.LocalDateTime; +import java.util.Arrays; + +@Component +@Aspect +@Slf4j +public class LogAspect { + + @Autowired + private HttpServletRequest request; + + @Around("@annotation(com.mijiu.common.annotation.Log)") + public Object recordTime(ProceedingJoinPoint joinPoint) throws Throwable { + + //操作时间 + LocalDateTime operateTime = LocalDateTime.now(); + + //操作类名 + String className = joinPoint.getTarget().getClass().getName(); + + //操作方法名 + String methodName = joinPoint.getSignature().getName(); + + //操作返回参数 + Object[] args = joinPoint.getArgs(); + String methodParams = Arrays.toString(args); + + long begin = System.currentTimeMillis(); + + //原始方法运行 + Object result = joinPoint.proceed(); + long end = System.currentTimeMillis(); + + //操作方法返回值 + String returnValue = JSONObject.toJSONString(result); + + //操作耗时 + long costTime = end - begin; + + //操作id + Long operateUser = (Long) request.getSession().getAttribute("StaffDfb"); + log.info("操作者id: " + operateUser); + + //回写进表或者其他 + + return result; + } +} \ No newline at end of file diff --git a/src/main/java/com/mijiu/common/config/MybatisPlusConfig.java b/src/main/java/com/mijiu/common/config/MybatisPlusConfig.java new file mode 100644 index 0000000..0335dfc --- /dev/null +++ b/src/main/java/com/mijiu/common/config/MybatisPlusConfig.java @@ -0,0 +1,20 @@ +package com.mijiu.common.config; + +import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor; +import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +/** + * 配置MP的分页插件 + */ +@Configuration +public class MybatisPlusConfig { + + @Bean + public MybatisPlusInterceptor mybatisPlusInterceptor() { + MybatisPlusInterceptor mybatisPlusInterceptor = new MybatisPlusInterceptor(); + mybatisPlusInterceptor.addInnerInterceptor(new PaginationInnerInterceptor()); + return mybatisPlusInterceptor; + } +} diff --git a/src/main/java/com/mijiu/common/config/RedisConfig.java b/src/main/java/com/mijiu/common/config/RedisConfig.java new file mode 100644 index 0000000..5e5f001 --- /dev/null +++ b/src/main/java/com/mijiu/common/config/RedisConfig.java @@ -0,0 +1,27 @@ +package com.mijiu.common.config; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.data.redis.connection.RedisConnectionFactory; +import org.springframework.data.redis.core.RedisTemplate; +import org.springframework.data.redis.serializer.JdkSerializationRedisSerializer; +import org.springframework.data.redis.serializer.StringRedisSerializer; + +@Configuration +public class RedisConfig { + + @Bean + public RedisTemplate redisTemplate(RedisConnectionFactory connectionFactory) { + RedisTemplate redisTemplate = new RedisTemplate<>(); + redisTemplate.setConnectionFactory(connectionFactory); + + // 设置key和value的序列化方式 + redisTemplate.setKeySerializer(new StringRedisSerializer()); + redisTemplate.setValueSerializer(new JdkSerializationRedisSerializer()); + redisTemplate.setHashKeySerializer(new StringRedisSerializer()); + redisTemplate.setHashValueSerializer(new JdkSerializationRedisSerializer()); + redisTemplate.afterPropertiesSet(); + + return redisTemplate; + } +} diff --git a/src/main/java/com/mijiu/common/config/WebMvcConfig.java b/src/main/java/com/mijiu/common/config/WebMvcConfig.java new file mode 100644 index 0000000..561d055 --- /dev/null +++ b/src/main/java/com/mijiu/common/config/WebMvcConfig.java @@ -0,0 +1,43 @@ +package com.mijiu.common.config; + +import com.mijiu.common.Util.JacksonObjectMapper; +import lombok.extern.slf4j.Slf4j; +import org.springframework.context.annotation.Configuration; +import org.springframework.http.converter.HttpMessageConverter; +import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; +import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport; + + +import java.util.List; + +@Slf4j +@Configuration +public class WebMvcConfig extends WebMvcConfigurationSupport { + /** + * 设置静态资源映射 + * + * @param registry + */ + @Override + protected void addResourceHandlers(ResourceHandlerRegistry registry) { + registry.addResourceHandler("/**").addResourceLocations("classpath:/static/"); + } + + /** + * 扩展mvc框架的消息转换器 + * + * @param converters + */ + @Override + protected void extendMessageConverters(List> converters) { + //创建消息转换器对象 + MappingJackson2HttpMessageConverter messageConverter = new MappingJackson2HttpMessageConverter(); + //设置对象转换器,底层使用Jackson将Java对象转为json + messageConverter.setObjectMapper(new JacksonObjectMapper()); + //将上面的消息转换器对象追加到mvc框架的转换器集合中 + converters.add(0, messageConverter); + } + + +} diff --git a/src/main/java/com/mijiu/common/constant/CommonConstant.java b/src/main/java/com/mijiu/common/constant/CommonConstant.java new file mode 100644 index 0000000..81bc688 --- /dev/null +++ b/src/main/java/com/mijiu/common/constant/CommonConstant.java @@ -0,0 +1,18 @@ +package com.mijiu.common.constant; + +/** + * 通用常量 + */ +public interface CommonConstant { + + /** + * 升序 + */ + String SORT_ORDER_ASC = "ascend"; + + /** + * 降序 + */ + String SORT_ORDER_DESC = " descend"; + +} diff --git a/src/main/java/com/mijiu/common/constant/UserConstant.java b/src/main/java/com/mijiu/common/constant/UserConstant.java new file mode 100644 index 0000000..9d3e740 --- /dev/null +++ b/src/main/java/com/mijiu/common/constant/UserConstant.java @@ -0,0 +1,32 @@ +package com.mijiu.common.constant; + +/** + * 用户常量 + * + */ +public interface UserConstant { + + /** + * 用户登录态键 + */ + String USER_LOGIN_STATE = "user_login"; + + // region 权限 + + /** + * 默认角色 + */ + String DEFAULT_ROLE = "user"; + + /** + * 管理员角色 + */ + String ADMIN_ROLE = "admin"; + + /** + * 被封号 + */ + String BAN_ROLE = "ban"; + + // endregion +} diff --git a/src/main/java/com/mijiu/common/exception/AccountLockedException.java b/src/main/java/com/mijiu/common/exception/AccountLockedException.java new file mode 100644 index 0000000..3b1f167 --- /dev/null +++ b/src/main/java/com/mijiu/common/exception/AccountLockedException.java @@ -0,0 +1,15 @@ +package com.mijiu.common.exception; + +/** + * 账号被锁定异常 + */ +public class AccountLockedException extends CustomException { + + public AccountLockedException() { + } + + public AccountLockedException(String msg) { + super(msg); + } + +} diff --git a/src/main/java/com/mijiu/common/exception/AccountNotFoundException.java b/src/main/java/com/mijiu/common/exception/AccountNotFoundException.java new file mode 100644 index 0000000..f085646 --- /dev/null +++ b/src/main/java/com/mijiu/common/exception/AccountNotFoundException.java @@ -0,0 +1,12 @@ +package com.mijiu.common.exception; + +/** + * 账号不存在异常 + */ +public class AccountNotFoundException extends CustomException { + + public AccountNotFoundException(){} + public AccountNotFoundException(String msg) { + super(msg); + } +} diff --git a/src/main/java/com/mijiu/common/exception/CustomException.java b/src/main/java/com/mijiu/common/exception/CustomException.java new file mode 100644 index 0000000..7fc208c --- /dev/null +++ b/src/main/java/com/mijiu/common/exception/CustomException.java @@ -0,0 +1,12 @@ +package com.mijiu.common.exception; + +/** + * 自定义业务异常类 + */ +public class CustomException extends RuntimeException { + + public CustomException(){} + public CustomException(String message) { + super(message); + } +} diff --git a/src/main/java/com/mijiu/common/exception/GlobalExceptionHandler.java b/src/main/java/com/mijiu/common/exception/GlobalExceptionHandler.java new file mode 100644 index 0000000..2478b24 --- /dev/null +++ b/src/main/java/com/mijiu/common/exception/GlobalExceptionHandler.java @@ -0,0 +1,72 @@ +package com.mijiu.common.exception; + +import com.mijiu.common.model.Result; +import com.mijiu.common.model.ResultCode; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.ControllerAdvice; +import org.springframework.web.bind.annotation.ExceptionHandler; +import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.bind.annotation.RestController; +import org.springframework.http.HttpStatus; +import org.springframework.web.bind.annotation.ResponseStatus; + +import java.sql.SQLIntegrityConstraintViolationException; + +/** + * 全局异常处理 + */ +@ControllerAdvice(annotations = {RestController.class, Controller.class}) +@ResponseBody +@Slf4j +public class GlobalExceptionHandler { + + + //账号不存在异常 + @ExceptionHandler(AccountNotFoundException.class) + @ResponseStatus(HttpStatus.BAD_REQUEST) + public Result handleAccountNotFoundException(AccountNotFoundException ex) { + return Result.error(ResultCode.USER_NOT_EXIST); + } + + + //密码错误异常 + @ExceptionHandler(PasswordErrorException.class) + @ResponseStatus(HttpStatus.BAD_REQUEST) + public Result handlePasswordErrorException(PasswordErrorException ex) { + return Result.error(ResultCode.USER_LOGIN_ERROR); + } + + //登录状态过期异常 + @ExceptionHandler(TokenOverdueException.class) + @ResponseStatus(HttpStatus.UNAUTHORIZED) + public Result handleTokenOverdueException(TokenOverdueException ex){ + return Result.error(ResultCode.PERMISSION_EXPIRE); + } + + + //添加员工,管理员账号重复异常 + @ExceptionHandler(SQLIntegrityConstraintViolationException.class) + public Result exceptionHandler(SQLIntegrityConstraintViolationException ex) { + log.error(ex.getMessage()); + + if (ex.getMessage().contains("Duplicate entry")) { + String[] split = ex.getMessage().split(" "); + String msg = split[2] + "已存在"; + return Result.error(msg); + } + return Result.error(); + } + + /** + * 异常处理方法 + * + * @return + */ + @ExceptionHandler(CustomException.class) + public Result exceptionHandler(CustomException ex) { + log.error(ex.getMessage()); + + return Result.error(ex.getMessage()); + } +} diff --git a/src/main/java/com/mijiu/common/exception/PasswordErrorException.java b/src/main/java/com/mijiu/common/exception/PasswordErrorException.java new file mode 100644 index 0000000..a442a7d --- /dev/null +++ b/src/main/java/com/mijiu/common/exception/PasswordErrorException.java @@ -0,0 +1,15 @@ +package com.mijiu.common.exception; + +/** + * 密码错误异常 + */ +public class PasswordErrorException extends CustomException { + + public PasswordErrorException() { + } + + public PasswordErrorException(String msg) { + super(msg); + } + +} diff --git a/src/main/java/com/mijiu/common/exception/TokenOverdueException.java b/src/main/java/com/mijiu/common/exception/TokenOverdueException.java new file mode 100644 index 0000000..1d97a89 --- /dev/null +++ b/src/main/java/com/mijiu/common/exception/TokenOverdueException.java @@ -0,0 +1,9 @@ +package com.mijiu.common.exception; + +public class TokenOverdueException extends CustomException{ + public TokenOverdueException(){} + +public TokenOverdueException(String msg){ + super(msg); +} +} diff --git a/src/main/java/com/mijiu/common/interceptor/JwtTokenAdminInterceptor.java b/src/main/java/com/mijiu/common/interceptor/JwtTokenAdminInterceptor.java new file mode 100644 index 0000000..5d6b60d --- /dev/null +++ b/src/main/java/com/mijiu/common/interceptor/JwtTokenAdminInterceptor.java @@ -0,0 +1,52 @@ +package com.mijiu.common.interceptor; + +import com.mijiu.common.Util.JwtUtils; +import com.mijiu.common.model.Result; +import com.mijiu.common.model.ResultCode; +import com.alibaba.fastjson.JSON; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; +import org.springframework.web.method.HandlerMethod; +import org.springframework.web.servlet.HandlerInterceptor; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +/** + * jwt令牌校验的拦截器 + */ +@Component +@Slf4j +public class JwtTokenAdminInterceptor implements HandlerInterceptor { + + /** + * 通过拦截器 放行拦截器的某些请求 头部参数 add(未完成) + * + */ + //jwt校验 + public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { + //判断当前拦截到的是Controller的方法还是其他资源 + if (!(handler instanceof HandlerMethod)) { + //当前拦截到的不是动态方法,直接放行 + return true; + } + //1、从请求头中获取令牌 + String authorizationHeader = request.getHeader("Authorization"); + if (authorizationHeader == null) { + log.info("Authorization值为空"); + return false; + } + // 从第8个字符开始截取,去掉 "Bearer " 前缀 + String jwt = authorizationHeader.substring(7); + //2、校验令牌 + try { + JwtUtils.validateToken(jwt); + } catch (Exception e) {//jwt解析失败 + e.printStackTrace(); + response.getWriter().write(JSON.toJSONString(Result.error(ResultCode.USER_NOT_LOGGED_IN))); + + return false; + } + return false; + } +} diff --git a/src/main/java/com/mijiu/common/model/PageRequest.java b/src/main/java/com/mijiu/common/model/PageRequest.java new file mode 100644 index 0000000..d56fb46 --- /dev/null +++ b/src/main/java/com/mijiu/common/model/PageRequest.java @@ -0,0 +1,30 @@ +package com.mijiu.common.model; + +import com.mijiu.common.constant.CommonConstant; +import lombok.Data; + +/** + * 分页请求 + */ +@Data +public class PageRequest { + /** + * 当前页号 + */ + private long current = 1; + + /** + * 页面大小 + */ + private long pageSize = 10; + + /** + * 排序字段 + */ + private String sortField; + + /** + * 排序顺序(默认升序) + */ + private String sortOrder = CommonConstant.SORT_ORDER_ASC; +} diff --git a/src/main/java/com/mijiu/common/model/Result.java b/src/main/java/com/mijiu/common/model/Result.java new file mode 100644 index 0000000..42fa2ae --- /dev/null +++ b/src/main/java/com/mijiu/common/model/Result.java @@ -0,0 +1,61 @@ +package com.mijiu.common.model; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 统一响应结果集 + * + * @author crush + */ +@Data +@NoArgsConstructor +@AllArgsConstructor + +public class Result { + + //操作代码 + Integer code; + + //提示信息 + String message; + + //结果数据 + T data; + + public Result(ResultCode resultCode) { + this.code = resultCode.code(); + this.message = resultCode.message(); + } + + public Result(ResultCode resultCode, T data) { + this.code = resultCode.code(); + this.message = resultCode.message(); + this.data = data; + } + + public Result(String message) { + this.message = message; + } + + public static Result success() { + return new Result(ResultCode.SUCCESS); + } + + public static Result success(T data) { + return new Result(ResultCode.SUCCESS, data); + } + + public static Result error() { + return new Result(ResultCode.FAIL); + } + + public static Result error(ResultCode resultCode) { + return new Result(resultCode); + } + + public static Result error(String message) { + return new Result(message); + } +} diff --git a/src/main/java/com/mijiu/common/model/ResultCode.java b/src/main/java/com/mijiu/common/model/ResultCode.java new file mode 100644 index 0000000..23476df --- /dev/null +++ b/src/main/java/com/mijiu/common/model/ResultCode.java @@ -0,0 +1,82 @@ +package com.mijiu.common.model; + +import lombok.Getter; + +/** + * 通用响应状态 + */ +@Getter +public enum ResultCode { + + /* 成功状态码 */ + SUCCESS(0, "操作成功!"), + + /* 错误状态码 */ + FAIL(-1, "操作失败!"), + + /* 参数错误:10001-19999 */ + PARAM_IS_INVALID(10001, "参数无效"), + PARAM_IS_BLANK(10002, "参数为空"), + PARAM_TYPE_BIND_ERROR(10003, "参数格式错误"), + PARAM_NOT_COMPLETE(10004, "参数缺失"), + + /* 用户错误:20001-29999*/ + USER_NOT_LOGGED_IN(20001, "用户未登录,请先登录"), + USER_LOGIN_ERROR(20002, "账号不存在或密码错误"), + USER_ACCOUNT_FORBIDDEN(20003, "账号已被禁用"), + USER_NOT_EXIST(20004, "用户不存在"), + USER_HAS_EXISTED(20005, "用户已存在"), + + /* 系统错误:40001-49999 */ + FILE_MAX_SIZE_OVERFLOW(40003, "上传尺寸过大"), + FILE_ACCEPT_NOT_SUPPORT(40004, "上传文件格式不支持"), + + /* 数据错误:50001-599999 */ + RESULT_DATA_NONE(50001, "数据未找到"), + DATA_IS_WRONG(50002, "数据有误"), + DATA_ALREADY_EXISTED(50003, "数据已存在"), + AUTH_CODE_ERROR(50004, "验证码错误"), + + + /* 权限错误:70001-79999 */ + PERMISSION_UNAUTHENTICATED(70001, "此操作需要登陆系统!"), + + PERMISSION_UNAUTHORISE(70002, "权限不足,无权操作!"), + + PERMISSION_EXPIRE(70003, "登录状态过期!"), + + PERMISSION_TOKEN_EXPIRED(70004, "token已过期"), + + PERMISSION_LIMIT(70005, "访问次数受限制"), + + PERMISSION_TOKEN_INVALID(70006, "无效token"), + + PERMISSION_SIGNATURE_ERROR(70007, "签名失败"); + + //操作代码 + int code; + //提示信息 + String message; + + ResultCode(int code, String message) { + this.code = code; + this.message = message; + } + + public int code() { + return code; + } + + public String message() { + return message; + } + + public void setCode(int code) { + this.code = code; + } + + public void setMessage(String message) { + this.message = message; + } + +} diff --git a/src/main/java/com/mijiu/common/model/dto/staffDfb/StaffDfbAddRequest.java b/src/main/java/com/mijiu/common/model/dto/staffDfb/StaffDfbAddRequest.java new file mode 100644 index 0000000..64ca264 --- /dev/null +++ b/src/main/java/com/mijiu/common/model/dto/staffDfb/StaffDfbAddRequest.java @@ -0,0 +1,37 @@ +package com.mijiu.common.model.dto.staffDfb; + +import lombok.Data; + +import java.io.Serializable; + +@Data +public class StaffDfbAddRequest implements Serializable { + + /** + * 姓名 + */ + private String name; + + /** + * 用户名 + */ + private String username; + + /** + * 手机号 + */ + private String phone; + + /** + * 性别 + */ + private String sex; + + /** + * 身份证号 + */ + private String idCard; + + private static final long serialVersionUID = 1L; + +} diff --git a/src/main/java/com/mijiu/common/model/dto/staffDfb/StaffDfbQueryByIdRequest.java b/src/main/java/com/mijiu/common/model/dto/staffDfb/StaffDfbQueryByIdRequest.java new file mode 100644 index 0000000..4f39c7e --- /dev/null +++ b/src/main/java/com/mijiu/common/model/dto/staffDfb/StaffDfbQueryByIdRequest.java @@ -0,0 +1,16 @@ +package com.mijiu.common.model.dto.staffDfb; + +import com.mijiu.common.model.PageRequest; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.io.Serializable; + +@EqualsAndHashCode(callSuper = true) +@Data +public class StaffDfbQueryByIdRequest extends PageRequest implements Serializable { + /** + * id + */ + private Long id; +} diff --git a/src/main/java/com/mijiu/common/model/dto/staffDfb/StaffDfbQueryRequest.java b/src/main/java/com/mijiu/common/model/dto/staffDfb/StaffDfbQueryRequest.java new file mode 100644 index 0000000..476008f --- /dev/null +++ b/src/main/java/com/mijiu/common/model/dto/staffDfb/StaffDfbQueryRequest.java @@ -0,0 +1,48 @@ +package com.mijiu.common.model.dto.staffDfb; + +import com.mijiu.common.model.PageRequest; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.io.Serializable; + +/** + * 员工查询请求 + */ +@EqualsAndHashCode(callSuper = true) +@Data +public class StaffDfbQueryRequest extends PageRequest implements Serializable { + + /** + * id + */ + private Long id; + + /** + * 用户名 + */ + private String name; + + /** + * 用户昵称 + */ + private String userName; + + /** + * 手机号 + */ + private String phone; + + /** + * 性别 + */ + private String sex; + + /** + * 身份证号 + */ + private String idCard; + + + private static final long serialVersionUID = 1L; +} diff --git a/src/main/java/com/mijiu/controller/ConduitController.java b/src/main/java/com/mijiu/controller/ConduitController.java new file mode 100644 index 0000000..ca42ba8 --- /dev/null +++ b/src/main/java/com/mijiu/controller/ConduitController.java @@ -0,0 +1,61 @@ +package com.mijiu.controller; + +import com.mijiu.common.model.Result; +import com.mijiu.entity.dto.BaseDto; +import com.mijiu.entity.site.Conduit; +import com.mijiu.mapper.ConduitMapper; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +/** + * 管道站表 + */ +@RestController +@RequestMapping("/conduit") +@CrossOrigin(allowedHeaders = "*") +public class ConduitController { + + @Autowired + private ConduitMapper mapper; + + /** + * 查询列表 + */ + @GetMapping("/list") + public Result list() { + return Result.success(mapper.selectList(null)); + } + + /** + * 查询详情 + */ + @GetMapping("/{id}") + public Result detail(@PathVariable Long id) { + return Result.success(mapper.selectById(id)); + } + + /** + * 新增 + */ + @PostMapping ("/add") + public Result add(@RequestBody Conduit conduit) { + + return Result.success(mapper.insert(conduit)); + } + + /** + * 修改 + */ + @PutMapping("/update") + public Result update( @RequestBody Conduit conduit) { + return Result.success(mapper.updateById(conduit)); + } + + /** + * 删除 + */ + @DeleteMapping("/delete/{id}") + public Result delete(@PathVariable Long id) { + return Result.success(mapper.deleteById(id)); + } +} diff --git a/src/main/java/com/mijiu/controller/DownholeFillingController.java b/src/main/java/com/mijiu/controller/DownholeFillingController.java new file mode 100644 index 0000000..8e3c165 --- /dev/null +++ b/src/main/java/com/mijiu/controller/DownholeFillingController.java @@ -0,0 +1,225 @@ +package com.mijiu.controller; + +import com.alibaba.druid.sql.ast.statement.SQLForeignKeyImpl; +import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper; +import com.mijiu.common.model.Result; +import com.mijiu.entity.DayAccumulate; +import com.mijiu.entity.DownholeFilling; +import com.mijiu.entity.Gauges; +import com.mijiu.entity.site.Conduit; +import com.mijiu.entity.site.Gob; +import com.mijiu.entity.site.GroutingStation; +import com.mijiu.entity.site.PressureMonitoring; +import com.mijiu.mapper.*; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.CrossOrigin; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + + +@RestController +@RequestMapping("/downholeFilling") +@CrossOrigin(allowedHeaders = "*") +public class DownholeFillingController { + + @Autowired + private DownholeFillingMapper downholeFillingMapper; + + @Autowired + private GaugesMapper gaugesMapper; + + @Autowired + private DayAccumulateMapper dayAccumulateMapper; + + + + + @Autowired + private ConduitMapper conduitMapper;//管道 + + @Autowired + private GobMapper gobMapper;//采空区 + + @Autowired + private GroutingStationMapper groutingStationMapper;//注浆站 + + @Autowired + private PressureMonitoringMapper pressureMonitoringMapper;//压力监测 + + + /** + * 查询大屏实例 + */ + @GetMapping("/getScreenExample") + public Result getScreen(){ + //管道列表 + List conduitList = conduitMapper.selectList(null); + //采空区列表 + List gobList = gobMapper.selectList(null); + //注浆站列表 + List groutingStationList = groutingStationMapper.selectList(null); + //压力监测列表 + List pressureMonitoringList = pressureMonitoringMapper.selectList(null); + + + Map map = new HashMap<>(); + HashMap obj = new HashMap<>(); + List list = new ArrayList<>(); + //合并列表 + list.addAll(conduitList); + list.addAll(gobList); + list.addAll(groutingStationList); + list.addAll(pressureMonitoringList); + map.put("allList", list); + map.put("conduitList", conduitList); + map.put("gobList", gobList); + map.put("groutingStationList", groutingStationList); + map.put("pressureMonitoringList", pressureMonitoringList); + return Result.success(map); + } + + + + /** + * 查询压力监测统计信息 + */ + @GetMapping("/pressureMonitoring/count") + public Result getPressure(){ + Map map = new HashMap<>(); + List list = new LambdaQueryChainWrapper<>(gaugesMapper) + .in(Gauges::getG_ID, "AI_YL_CJX1GD1_VALUE", "AI_YL_CJX1GD2_VALUE", "AI_YL_CJX1GD3_VALUE" + , "AI_YL_CJX2GD1_VALUE", "AI_YL_CJX2GD2_VALUE", "AI_YL_CJX2GD3_VALUE", + "AI_YL_CJX3GD1_VALUE", "AI_YL_CJX3GD2_VALUE", "AI_YL_CJX3GD3_VALUE", + "AI_YL_CJX4GD1_VALUE", "AI_YL_CJX4GD2_VALUE", "AI_YL_CJX4GD3_VALUE", + "AI_YL_CJX5GD1_VALUE", "AI_YL_CJX5GD2_VALUE", "AI_YL_CJX5GD3_VALUE") + .list(); + for (Gauges g: list){ + switch (g.getG_ID()){ + case "AI_YL_CJX1GD1_VALUE": + map.put("box1pipe1", g.getG_Value()); + break; + case "AI_YL_CJX1GD2_VALUE": + map.put("box1pipe2", g.getG_Value()); + break; + case "AI_YL_CJX1GD3_VALUE": + map.put("box1pipe3", g.getG_Value()); + break; + case "AI_YL_CJX2GD1_VALUE": + map.put("box2pipe1", g.getG_Value()); + break; + case "AI_YL_CJX2GD2_VALUE": + map.put("box2pipe2", g.getG_Value()); + break; + case "AI_YL_CJX2GD3_VALUE": + map.put("box2pipe3", g.getG_Value()); + break; + case "AI_YL_CJX3GD1_VALUE": + map.put("box3pipe1", g.getG_Value()); + break; + case "AI_YL_CJX3GD2_VALUE": + map.put("box3pipe2", g.getG_Value()); + break; + case "AI_YL_CJX3GD3_VALUE": + map.put("box3pipe3", g.getG_Value()); + break; + case "AI_YL_CJX4GD1_VALUE": + map.put("box4pipe1", g.getG_Value()); + break; + case "AI_YL_CJX4GD2_VALUE": + map.put("box4pipe2", g.getG_Value()); + break; + case "AI_YL_CJX4GD3_VALUE": + map.put("box4pipe3", g.getG_Value()); + break; + case "AI_YL_CJX5GD1_VALUE": + map.put("box5pipe1", g.getG_Value()); + break; + case "AI_YL_CJX5GD2_VALUE": + map.put("box5pipe2", g.getG_Value()); + break; + case "AI_YL_CJX5GD3_VALUE": + map.put("box5pipe3", g.getG_Value()); + break; + } + + } + return Result.success(map); + } + + + /** + * 查询采空区统计信息 + */ + @GetMapping("/gob/count") + public Result getDownholeFilling(){ + + Map map = new HashMap<>(); + //钻头总数 + Long count = new LambdaQueryChainWrapper<>(downholeFillingMapper).count(); + map.put("allNum", count); + //已完成钻孔DF_Scheduleint >= 4的数值的条数 + Long count1 = new LambdaQueryChainWrapper<>(downholeFillingMapper) + .ge(DownholeFilling::getDF_Scheduleint, 4).count(); + map.put("completedNum", count1); + //管道压力 + List aiYlCjx6GD1Value = new LambdaQueryChainWrapper<>(gaugesMapper) + .in(Gauges::getG_ID, "AI_YL_CJX6GD1_VALUE","AI_YL_CJX6GD2_VALUE", "AI_YL_CJX6GD3_VALUE") + .list(); + for(Gauges g : aiYlCjx6GD1Value){ + switch (g.getG_ID()) { + case "AI_YL_CJX6GD1_VALUE": + map.put("pipe1", g.getG_Value()); + break; + case "AI_YL_CJX6GD2_VALUE": + map.put("pipe2", g.getG_Value()); + break; + case "AI_YL_CJX6GD3_VALUE": + map.put("pipe3", g.getG_Value()); + break; + } + } + //管道流量 + List aiLlCjx6GD1Value = new LambdaQueryChainWrapper<>(gaugesMapper) + .in(Gauges::getG_ID, "AI_LL_CJX6GD1_VALUE","AI_LL_CJX6GD2_VALUE", "AI_LL_CJX6GD3_VALUE") + .list(); + for(Gauges g : aiLlCjx6GD1Value){ + switch (g.getG_ID()) { + case "AI_LL_CJX6GD1_VALUE": + map.put("flow1", g.getG_Value()); + break; + case "AI_LL_CJX6GD2_VALUE": + map.put("flow2", g.getG_Value()); + break; + case "AI_LL_CJX6GD3_VALUE": + map.put("flow3", g.getG_Value()); + break; + } + } + + return Result.success(map); + } + + /** + * 查询注浆站统计信息 + */ + @GetMapping("/groutingStation/count") + public Result getDownholeFilling1(){ + return Result.success(dayAccumulateMapper.getAccumulate()); + } + /** + * 查询钻孔统计信息 + */ + @GetMapping("/drill/count") + public Result getDrill(){ + List list = new LambdaQueryChainWrapper<>(downholeFillingMapper) + .list(); + return Result.success(list); + } + +} diff --git a/src/main/java/com/mijiu/controller/GobController.java b/src/main/java/com/mijiu/controller/GobController.java new file mode 100644 index 0000000..8b4726c --- /dev/null +++ b/src/main/java/com/mijiu/controller/GobController.java @@ -0,0 +1,64 @@ +package com.mijiu.controller; + +import com.mijiu.common.model.Result; +import com.mijiu.entity.dto.BaseDto; +import com.mijiu.entity.site.Conduit; +import com.mijiu.entity.site.Gob; +import com.mijiu.entity.site.GroutingStation; +import com.mijiu.mapper.GobMapper; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +/** + * 采空区表 + */ +@RestController +@RequestMapping("/gob") +@CrossOrigin(allowedHeaders = "*") +public class GobController { + + @Autowired + private GobMapper mapper; + + /** + * 查询列表 + */ + @GetMapping("/list") + public Result list() { + return Result.success(mapper.selectList(null)); + } + + /** + * 查询详情 + */ + @GetMapping("/{id}") + public Result detail(@PathVariable Long id) { + return Result.success(mapper.selectById(id)); + } + + /** + * 新增 + */ + @PostMapping ("/add") + public Result add(@RequestBody Gob gob) { + + return Result.success(mapper.insert(gob)); + } + + /** + * 修改 + */ + @PutMapping("/update") + public Result update( @RequestBody Gob gob) { + + return Result.success(mapper.updateById(gob)); + } + + /** + * 删除 + */ + @DeleteMapping("/delete/{id}") + public Result delete(@PathVariable Long id) { + return Result.success(mapper.deleteById(id)); + } +} diff --git a/src/main/java/com/mijiu/controller/GroutingStationController.java b/src/main/java/com/mijiu/controller/GroutingStationController.java new file mode 100644 index 0000000..b983156 --- /dev/null +++ b/src/main/java/com/mijiu/controller/GroutingStationController.java @@ -0,0 +1,65 @@ +package com.mijiu.controller; + + +import com.mijiu.common.model.Result; +import com.mijiu.entity.dto.BaseDto; +import com.mijiu.entity.site.GroutingStation; +import com.mijiu.mapper.GroutingStationMapper; +import com.mijiu.service.GroutingStationServiceImpl; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +/** + * 注浆站表 + */ +@RestController +@RequestMapping("/groutingStation") +@CrossOrigin(allowedHeaders = "*") +public class GroutingStationController { + + @Autowired + private GroutingStationMapper mapper; + + /** + * 查询列表 + */ + @GetMapping("/list") + public Result list() { + return Result.success(mapper.selectList(null)); + } + + /** + * 查询详情 + */ + @GetMapping("/{id}") + public Result detail(@PathVariable Long id) { + return Result.success(mapper.selectById(id)); + } + + /** + * 新增 + */ + @PostMapping ("/add") + public Result add(@RequestBody GroutingStation groutingStation) { + + System.err.println(groutingStation); + return Result.success(mapper.insert(groutingStation)); + } + + /** + * 修改 + */ + @PutMapping("/update") + public Result update( @RequestBody GroutingStation groutingStation) { + + return Result.success(mapper.updateById(groutingStation)); + } + + /** + * 删除 + */ + @DeleteMapping("/delete/{id}") + public Result delete(@PathVariable Long id) { + return Result.success(mapper.deleteById(id)); + } +} \ No newline at end of file diff --git a/src/main/java/com/mijiu/controller/PressureMonitoringController.java b/src/main/java/com/mijiu/controller/PressureMonitoringController.java new file mode 100644 index 0000000..ea2548e --- /dev/null +++ b/src/main/java/com/mijiu/controller/PressureMonitoringController.java @@ -0,0 +1,62 @@ +package com.mijiu.controller; + +import com.mijiu.common.model.Result; +import com.mijiu.entity.dto.BaseDto; +import com.mijiu.entity.site.Gob; +import com.mijiu.entity.site.PressureMonitoring; +import com.mijiu.mapper.PressureMonitoringMapper; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +/** + * 压力监测站表 + */ +@RestController +@RequestMapping("/pressureMonitoring") +@CrossOrigin(allowedHeaders = "*") +public class PressureMonitoringController { + + @Autowired + private PressureMonitoringMapper mapper; + + /** + * 查询列表 + */ + @GetMapping("/list") + public Result list() { + return Result.success(mapper.selectList(null)); + } + + /** + * 查询详情 + */ + @GetMapping("/{id}") + public Result detail(@PathVariable Long id) { + return Result.success(mapper.selectById(id)); + } + + /** + * 新增 + */ + @PostMapping ("/add") + public Result add(@RequestBody PressureMonitoring pressureMonitoring) { + + return Result.success(mapper.insert(pressureMonitoring)); + } + + /** + * 修改 + */ + @PutMapping("/update") + public Result update( @RequestBody PressureMonitoring pressureMonitoring) { + return Result.success(mapper.updateById(pressureMonitoring)); + } + + /** + * 删除 + */ + @DeleteMapping("/delete/{id}") + public Result delete(@PathVariable Long id) { + return Result.success(mapper.deleteById(id)); + } +} diff --git a/src/main/java/com/mijiu/controller/UserManagementController.java b/src/main/java/com/mijiu/controller/UserManagementController.java new file mode 100644 index 0000000..f43d599 --- /dev/null +++ b/src/main/java/com/mijiu/controller/UserManagementController.java @@ -0,0 +1,53 @@ +package com.mijiu.controller; + +import com.mijiu.common.Util.JwtUtils; +import com.mijiu.common.exception.CustomException; +import com.mijiu.common.model.Result; +import com.mijiu.entity.UserManagement; +import com.mijiu.entity.dto.LoginRequest; +import com.mijiu.mapper.UserManagementMapper; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * 管理员表 + */ +@RestController +@RequestMapping("/admin") +@CrossOrigin(allowedHeaders = "*") +public class UserManagementController { + + @Autowired + private UserManagementMapper userManagementMapper; + + @PostMapping("/login") + public Result login(@RequestBody LoginRequest loginRequest) { + UserManagement user = new UserManagement(); + user.setUmName(loginRequest.getUsername()); + user.setUmPassword(loginRequest.getPassword()); + + // 根据用户名和密码查询用户 + List users = userManagementMapper.selectList(null); + for (UserManagement u : users) { + if (u.getUmName().equals(user.getUmName()) && u.getUmPassword().equals(user.getUmPassword())) { + + // 生成token + Map info=new HashMap<>(); + info.put("userId",u.getUmUid()); + info.put("userRole",u.getUmName()); + String token = JwtUtils.generateToken(info,"user"); + + // 登录成功逻辑 + Map rest= new HashMap<>(); + rest.put("token",token); + return Result.success(rest); + } + } + throw new CustomException("用户名或密码错误!"); + } +} + diff --git a/src/main/java/com/mijiu/entity/DayAccumulate.java b/src/main/java/com/mijiu/entity/DayAccumulate.java new file mode 100644 index 0000000..773700e --- /dev/null +++ b/src/main/java/com/mijiu/entity/DayAccumulate.java @@ -0,0 +1,76 @@ +package com.mijiu.entity; + + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; + +import java.io.Serializable; +import java.math.BigDecimal; +import java.time.LocalDateTime; + +@Data +@TableName("DayAccumulate") +public class DayAccumulate implements Serializable { + private static final long serialVersionUID = 1L; + + // 对应数据库表中的自增主键列DA_N,配置为自增类型的主键 + @TableId(type = IdType.AUTO) + private Integer DA_N; + + // DA_System是计算列,在实体类中一般不做常规映射,若业务有需求获取其值,可后续通过自定义查询来处理 + // 此处暂不添加映射 + + @TableField("DA_System1") + private Integer DA_System1; + + @TableField("DA_System2") + private Integer DA_System2; + + @TableField("DA_WriteTime") + private LocalDateTime DA_WriteTime; + + @TableField("DA_Filling") + private BigDecimal DA_Filling; + + @TableField("DA_Lime") + private BigDecimal DA_Lime; + + @TableField("DA_Sand") + private BigDecimal DA_Sand; + + @TableField("DA_Water") + private BigDecimal DA_Water; + + @TableField("DA_Concentration") + private BigDecimal DA_Concentration; + + @TableField("DA_UnitConsumption") + private BigDecimal DA_UnitConsumption; + + @TableField("DA_Electricity") + private BigDecimal DA_Electricity; + + @TableField("DA_FlocculatingAgents") + private BigDecimal DA_FlocculatingAgents; + + @TableField("DA_ComingSandVolume") + private BigDecimal DA_ComingSandVolume; + + @TableField("DA_ComingSandWetVolume") + private BigDecimal DA_ComingSandWetVolume; + + @TableField("DA_ComingSandQuality") + private BigDecimal DA_ComingSandQuality; + + @TableField("DA_ComingSandWetQuality") + private BigDecimal DA_ComingSandWetQuality; + + @TableField("DA_ComingSandFlux") + private BigDecimal DA_ComingSandFlux; + + @TableField("DA_ComingSandConcentration") + private BigDecimal DA_ComingSandConcentration; +} \ No newline at end of file diff --git a/src/main/java/com/mijiu/entity/DownholeFilling.java b/src/main/java/com/mijiu/entity/DownholeFilling.java new file mode 100644 index 0000000..bdac1c8 --- /dev/null +++ b/src/main/java/com/mijiu/entity/DownholeFilling.java @@ -0,0 +1,99 @@ +package com.mijiu.entity; + + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; + +import java.io.Serializable; +import java.math.BigDecimal; +import java.time.LocalDateTime; + +@Data +@TableName("DownholeFilling") // 指定对应的数据库表名 +public class DownholeFilling implements Serializable { + + private static final long serialVersionUID = 1L; + + @TableId(type = IdType.AUTO) // 配置主键自增,对应数据库中的自增列DF_ID + private Integer DF_ID; + + // 由于DF_System是计算列,在Java实体类中一般不需要映射它,除非有特殊业务需求去获取它的值 + // 如果需要,可以通过自定义查询等方式处理,这里暂不做映射 + + @TableField("DF_System1") + private Integer DF_System1; + + @TableField("DF_System2") + private Integer DF_System2; + + @TableField("DF_Name") + private String DF_Name; + + @TableField("DF_Space") + private BigDecimal DF_Space; + + @TableField("DF_Finished") + private BigDecimal DF_Finished; + + // DF_UnFinished同样是计算列,可按需处理,暂不做常规映射 + + @TableField("DF_WriteTime") + private LocalDateTime DF_WriteTime; + + @TableField("DF_Location") + private String DF_Location; + + @TableField("DF_Remarks") + private String DF_Remarks; + + @TableField("DF_Collect") + private Boolean DF_Collect; + + @TableField("DF_ModificationTime") + private LocalDateTime DF_ModificationTime; + + @TableField("DF_FillingTime") + private LocalDateTime DF_FillingTime; + + @TableField("DF_Schedule") + private String DF_Schedule; + + @TableField("DF_Scheduleint") + private Integer DF_Scheduleint; + + @TableField("DF_FillingDuration") + private Integer DF_FillingDuration; + + @TableField("DF_Elevation") + private Float DF_Elevation; + + @TableField("DF_Depth") + private Float DF_Depth; + + @TableField("DF_Diameter") + private Float DF_Diameter; + + @TableField("DF_StartDate") + private LocalDateTime DF_StartDate; + + @TableField("DF_EndDate") + private LocalDateTime DF_EndDate; + + @TableField("DF_Operator") + private String DF_Operator; + + @TableField("DF_ContactPhone") + private String DF_ContactPhone; + + @TableField("DF_VideoURL") + private String DF_VideoURL; + + @TableField("DF_Longitude") + private Float DF_Longitude; + + @TableField("DF_Latitude") + private Float DF_Latitude; +} \ No newline at end of file diff --git a/src/main/java/com/mijiu/entity/Gauges.java b/src/main/java/com/mijiu/entity/Gauges.java new file mode 100644 index 0000000..a0fb19b --- /dev/null +++ b/src/main/java/com/mijiu/entity/Gauges.java @@ -0,0 +1,52 @@ +package com.mijiu.entity; + + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; + +import java.io.Serializable; +import java.math.BigDecimal; +import java.time.LocalDateTime; + +@Data +@TableName("Gauges") // 指定对应的数据库表名 +public class Gauges implements Serializable { + + private static final long serialVersionUID = 1L; + + @TableId(type = IdType.AUTO) // 配置自增主键,对应数据库中的自增列G_N + private Integer G_N; + + // G_System是计算列,通常在实体类中可不做常规映射,若有获取其值的业务需求,可通过自定义查询等方式处理 + // 此处暂不做映射 + + @TableField("G_System1") + private Integer G_System1; + + @TableField("G_System2") + private Integer G_System2; + + @TableField("G_ID") + private String G_ID; + + @TableField("G_Name") + private String G_Name; + + @TableField("G_Value") + private BigDecimal G_Value; + + @TableField("G_Unit") + private String G_Unit; + + @TableField("G_WriteTime") + private LocalDateTime G_WriteTime; + + @TableField("G_Group") + private String G_Group; + + @TableField("G_ValuePrdfix") + private Integer G_ValuePrdfix; +} \ No newline at end of file diff --git a/src/main/java/com/mijiu/entity/UserManagement.java b/src/main/java/com/mijiu/entity/UserManagement.java new file mode 100644 index 0000000..c246c94 --- /dev/null +++ b/src/main/java/com/mijiu/entity/UserManagement.java @@ -0,0 +1,74 @@ +package com.mijiu.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; + +import java.io.Serializable; +import java.time.LocalDateTime; + +@TableName("UserManagement") +@Data +public class UserManagement implements Serializable { + + @TableId(value = "UM_UID", type = IdType.ASSIGN_ID) // 自增主键 + private Integer umUid; + + @TableField("UM_Name") + private String umName; + + @TableField("UM_Type") + private String umType; + + @TableField("UM_TEL") + private String umTel; + + @TableField("UM_WriteTime") + private LocalDateTime umWriteTime; + + @TableField("UM_IsFreeze") + private Boolean umIsFreeze; + + @TableField("UM_FreezeTime") + private LocalDateTime umFreezeTime; + + @TableField("UM_LastLoginTime") + private LocalDateTime umLastLoginTime; + + @TableField("UM_IsLogin") + private LocalDateTime umIsLogin; + + @TableField("UM_IsWrite") + private Boolean umIsWrite; + + @TableField("UM_Password") + private String umPassword; + + @TableField("UM_IsUserM") + private Boolean umIsUserM; + + @TableField("UM_IsEquipmentM") + private Boolean umIsEquipmentM; + + @TableField("UM_IsEnergy") + private Boolean umIsEnergy; + + @TableField("UM_IsProductionRF") + private Boolean umIsProductionRF; + + @TableField("UM_IsDownholeF") + private Boolean umIsDownholeF; + + @TableField("UM_isAlarmA") + private Boolean umIsAlarmA; + + @TableField("UM_IsRecipeM") + private Boolean umIsRecipeM; + + @TableField("UM_Section") + private String umSection; + + +} \ No newline at end of file diff --git a/src/main/java/com/mijiu/entity/dto/BaseDto.java b/src/main/java/com/mijiu/entity/dto/BaseDto.java new file mode 100644 index 0000000..565e38e --- /dev/null +++ b/src/main/java/com/mijiu/entity/dto/BaseDto.java @@ -0,0 +1,23 @@ +package com.mijiu.entity.dto; + +import lombok.Data; + +import java.io.Serializable; + +@Data +public class BaseDto implements Serializable { + private static final long serialVersionUID = 1L; + + private Long id; + + private Float longitude; + + private Float latitude; + + private String json; + + private String name; + + private String EntityId; + private String EntityName; +} diff --git a/src/main/java/com/mijiu/entity/dto/LoginRequest.java b/src/main/java/com/mijiu/entity/dto/LoginRequest.java new file mode 100644 index 0000000..ab93bbe --- /dev/null +++ b/src/main/java/com/mijiu/entity/dto/LoginRequest.java @@ -0,0 +1,11 @@ +package com.mijiu.entity.dto; + +import lombok.Data; + +@Data +public class LoginRequest { + private String username; + private String password; + + // 省略 getter 和 setter 方法 +} \ No newline at end of file diff --git a/src/main/java/com/mijiu/entity/site/Conduit.java b/src/main/java/com/mijiu/entity/site/Conduit.java new file mode 100644 index 0000000..0a5dffe --- /dev/null +++ b/src/main/java/com/mijiu/entity/site/Conduit.java @@ -0,0 +1,37 @@ +package com.mijiu.entity.site; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; + +import java.io.Serializable; + +@Data +@TableName("Conduit") +public class Conduit implements Serializable { + private static final long serialVersionUID = 1L; + + @TableId(type = IdType.AUTO) // 配置为主键自增,对应数据库表中的自增主键列C_ID + private Long id; + + + private Float longitude; + + private Float latitude; + + + private String json; + + + private String name; + + @TableField("entity_id") + private String entityId; + + @TableField("entity_name") + private String entityName; + + private String type; +} \ No newline at end of file diff --git a/src/main/java/com/mijiu/entity/site/Gob.java b/src/main/java/com/mijiu/entity/site/Gob.java new file mode 100644 index 0000000..6a374fd --- /dev/null +++ b/src/main/java/com/mijiu/entity/site/Gob.java @@ -0,0 +1,38 @@ +package com.mijiu.entity.site; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; + +import java.io.Serializable; + +@Data +@TableName("Gob") +public class Gob implements Serializable { + private static final long serialVersionUID = 1L; + + @TableId(type = IdType.AUTO) // 配置为主键自增,对应数据库表中的自增主键列C_ID + private Long id; + + + private Float longitude; + + private Float latitude; + + + private String json; + + + private String name; + + + @TableField("entity_id") + private String entityId; + + @TableField("entity_name") + private String entityName; + + private String type; +} \ No newline at end of file diff --git a/src/main/java/com/mijiu/entity/site/GroutingStation.java b/src/main/java/com/mijiu/entity/site/GroutingStation.java new file mode 100644 index 0000000..22bff72 --- /dev/null +++ b/src/main/java/com/mijiu/entity/site/GroutingStation.java @@ -0,0 +1,38 @@ +package com.mijiu.entity.site; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; + +import java.io.Serializable; + +@Data +@TableName("GroutingStation") +public class GroutingStation implements Serializable { + private static final long serialVersionUID = 1L; + + @TableId(type = IdType.AUTO) // 配置为主键自增,对应数据库表中的自增主键列C_ID + private Long id; + + + private Float longitude; + + private Float latitude; + + + private String json; + + + private String name; + + + @TableField("entity_id") + private String entityId; + + @TableField("entity_name") + private String entityName; + + private String type; +} \ No newline at end of file diff --git a/src/main/java/com/mijiu/entity/site/PressureMonitoring.java b/src/main/java/com/mijiu/entity/site/PressureMonitoring.java new file mode 100644 index 0000000..53697e3 --- /dev/null +++ b/src/main/java/com/mijiu/entity/site/PressureMonitoring.java @@ -0,0 +1,38 @@ +package com.mijiu.entity.site; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; + +import java.io.Serializable; + +@Data +@TableName("PressureMonitoring") +public class PressureMonitoring implements Serializable { + private static final long serialVersionUID = 1L; + + @TableId(type = IdType.AUTO) // 配置为主键自增,对应数据库表中的自增主键列C_ID + private Long id; + + + private Float longitude; + + private Float latitude; + + + private String json; + + + private String name; + + + @TableField("entity_id") + private String entityId; + + @TableField("entity_name") + private String entityName; + + private String type; +} \ No newline at end of file diff --git a/src/main/java/com/mijiu/entity/vo/Administrator.java b/src/main/java/com/mijiu/entity/vo/Administrator.java new file mode 100644 index 0000000..0f5a743 --- /dev/null +++ b/src/main/java/com/mijiu/entity/vo/Administrator.java @@ -0,0 +1,39 @@ +package com.mijiu.entity.vo; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import java.io.Serializable; +import lombok.Getter; +import lombok.Setter; + +/** + *

+ * 管理员表 + *

+ * + * @author 蒾酒 + * @since 2024-03-07 + */ +@Getter +@Setter +public class Administrator implements Serializable { + + private static final long serialVersionUID = 1L; + + @TableId(value = "id", type = IdType.AUTO) + private Integer id; + + @TableField("admin_account") + private String adminAccount; + + @TableField("admin_password") + private String adminPassword; + + @TableField("admin_name") + private String adminName; + + @TableField("merchant_id") + private Integer adminId; +} diff --git a/src/main/java/com/mijiu/mapper/ConduitMapper.java b/src/main/java/com/mijiu/mapper/ConduitMapper.java new file mode 100644 index 0000000..8a497d9 --- /dev/null +++ b/src/main/java/com/mijiu/mapper/ConduitMapper.java @@ -0,0 +1,11 @@ +package com.mijiu.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.mijiu.entity.site.Conduit; +import org.apache.ibatis.annotations.Mapper; + + +@Mapper +public interface ConduitMapper extends BaseMapper { + // 可以根据具体业务需求在这里添加自定义的SQL方法,目前继承BaseMapper已具备基本的CRUD方法 +} \ No newline at end of file diff --git a/src/main/java/com/mijiu/mapper/DayAccumulateMapper.java b/src/main/java/com/mijiu/mapper/DayAccumulateMapper.java new file mode 100644 index 0000000..1cafd8b --- /dev/null +++ b/src/main/java/com/mijiu/mapper/DayAccumulateMapper.java @@ -0,0 +1,18 @@ +package com.mijiu.mapper; + + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.mijiu.entity.DayAccumulate; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Select; + +import java.util.Map; + +@Mapper +public interface DayAccumulateMapper extends BaseMapper { + /** + * 统计矸石处理量(本月和本日) + */ + @Select("SELECT SUM(CASE WHEN CONVERT(DATE, DA_WriteTime) = CONVERT(DATE, GETDATE()) THEN DA_Filling ELSE 0 END) AS TotalFillingQualityToday, SUM(CASE WHEN YEAR(DA_WriteTime) = YEAR(GETDATE()) AND MONTH(DA_WriteTime) = MONTH(GETDATE()) THEN DA_Filling ELSE 0 END) AS TotalFillingQualityThisMonth FROM DayAccumulate;") + Map getAccumulate(); +} \ No newline at end of file diff --git a/src/main/java/com/mijiu/mapper/DownholeFillingMapper.java b/src/main/java/com/mijiu/mapper/DownholeFillingMapper.java new file mode 100644 index 0000000..9876402 --- /dev/null +++ b/src/main/java/com/mijiu/mapper/DownholeFillingMapper.java @@ -0,0 +1,9 @@ +package com.mijiu.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.mijiu.entity.DownholeFilling; +import org.apache.ibatis.annotations.Mapper; + +@Mapper +public interface DownholeFillingMapper extends BaseMapper { +} diff --git a/src/main/java/com/mijiu/mapper/GaugesMapper.java b/src/main/java/com/mijiu/mapper/GaugesMapper.java new file mode 100644 index 0000000..3602d81 --- /dev/null +++ b/src/main/java/com/mijiu/mapper/GaugesMapper.java @@ -0,0 +1,10 @@ +package com.mijiu.mapper; + + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.mijiu.entity.Gauges; +import org.apache.ibatis.annotations.Mapper; + +@Mapper +public interface GaugesMapper extends BaseMapper { +} \ No newline at end of file diff --git a/src/main/java/com/mijiu/mapper/GobMapper.java b/src/main/java/com/mijiu/mapper/GobMapper.java new file mode 100644 index 0000000..893b11e --- /dev/null +++ b/src/main/java/com/mijiu/mapper/GobMapper.java @@ -0,0 +1,10 @@ +package com.mijiu.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.mijiu.entity.site.Gob; +import org.apache.ibatis.annotations.Mapper; + +@Mapper +public interface GobMapper extends BaseMapper { + // 这里可以根据具体业务需求添加自定义的SQL方法,目前继承BaseMapper已经具备基本的CRUD方法 +} \ No newline at end of file diff --git a/src/main/java/com/mijiu/mapper/GroutingStationMapper.java b/src/main/java/com/mijiu/mapper/GroutingStationMapper.java new file mode 100644 index 0000000..ff9c6d1 --- /dev/null +++ b/src/main/java/com/mijiu/mapper/GroutingStationMapper.java @@ -0,0 +1,28 @@ +package com.mijiu.mapper; + + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.mijiu.entity.site.GroutingStation; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Select; + +import java.util.List; + +@Mapper +public interface GroutingStationMapper extends BaseMapper { +// // 根据主键查询注浆站信息 +// GroutingStation selectById(Long GS_Id); +// +// // 查询所有注浆站信息 +//// @Select("SELECT GS_ID id,GS_Longitude longitude FROM GroutingStation") +// List selectAll(); +// +// // 插入注浆站信息 +// int insert(GroutingStation groutingStation); +// +// // 根据主键更新注浆站信息 +// int updateById(GroutingStation groutingStation); +// +// // 根据主键删除注浆站信息 +// int deleteById(Long GS_Id); +} \ No newline at end of file diff --git a/src/main/java/com/mijiu/mapper/PressureMonitoringMapper.java b/src/main/java/com/mijiu/mapper/PressureMonitoringMapper.java new file mode 100644 index 0000000..193b106 --- /dev/null +++ b/src/main/java/com/mijiu/mapper/PressureMonitoringMapper.java @@ -0,0 +1,11 @@ +package com.mijiu.mapper; + + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.mijiu.entity.site.PressureMonitoring; +import org.apache.ibatis.annotations.Mapper; + +@Mapper +public interface PressureMonitoringMapper extends BaseMapper { + // 这里可以根据具体业务需求添加自定义的SQL方法,目前继承BaseMapper已经具备基本的CRUD方法 +} \ No newline at end of file diff --git a/src/main/java/com/mijiu/mapper/UserManagementMapper.java b/src/main/java/com/mijiu/mapper/UserManagementMapper.java new file mode 100644 index 0000000..88559f1 --- /dev/null +++ b/src/main/java/com/mijiu/mapper/UserManagementMapper.java @@ -0,0 +1,9 @@ +package com.mijiu.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.mijiu.entity.UserManagement; +import org.apache.ibatis.annotations.Mapper; + +@Mapper +public interface UserManagementMapper extends BaseMapper { +} diff --git a/src/main/java/com/mijiu/service/GroutingStationServiceImpl.java b/src/main/java/com/mijiu/service/GroutingStationServiceImpl.java new file mode 100644 index 0000000..2e9b210 --- /dev/null +++ b/src/main/java/com/mijiu/service/GroutingStationServiceImpl.java @@ -0,0 +1,45 @@ +package com.mijiu.service; + +import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper; +import com.mijiu.common.exception.CustomException; +import com.mijiu.entity.site.GroutingStation; +import com.mijiu.mapper.GroutingStationMapper; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import java.util.List; + +@Service +public class GroutingStationServiceImpl { + + @Autowired + private GroutingStationMapper groutingStationMapper; + + public GroutingStation getById(Long GS_Id) { + return groutingStationMapper.selectById(GS_Id); + } + + public List getAll() { + return new LambdaQueryChainWrapper<>(groutingStationMapper).list(); + } + + public void save(GroutingStation groutingStation) { + int inserted = groutingStationMapper.insert(groutingStation); + if (inserted == 0) { + throw new CustomException("保存失败!"); + } + } + + public void update(GroutingStation groutingStation) { + int i = groutingStationMapper.updateById(groutingStation); + if (i == 0) { + throw new CustomException("更新失败!"); + } + } + + public void deleteById(Long GS_Id) { + int i = groutingStationMapper.deleteById(GS_Id); + if (i == 0) { + throw new CustomException("删除失败!"); + } + } +} \ No newline at end of file diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml new file mode 100644 index 0000000..867eb89 --- /dev/null +++ b/src/main/resources/application.yml @@ -0,0 +1,36 @@ +server: + port: 8080 + +spring: + redis: + host: localhost + port: 6379 + # password: WU3w7dK.f[X6xz;4I1hs*90PFS^D}c5o + database: 0 + datasource: + druid: + driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver + url: jdbc:sqlserver://wlml.a1.luyouxia.net:21023;databaseName=JKWLML + username: sa + password: JK@123456 + + #关spring的没必要日志 + main: + banner-mode: off + +mybatis-plus: + configuration: + #在映射实体或者属性时,将数据库中表名和字段名中的下划线去掉,按照驼峰命名法映射 + map-underscore-to-camel-case: false + #开启mybatisplus日志(输出到控制台) + log-impl: org.apache.ibatis.logging.stdout.StdOutImpl + global-config: +# db-config: +# #id自增配置 +# id-type: ASSIGN_ID + #逻辑删除字段 +# logic-delete-field: isExist +# logic-not-delete-value: 1 +# logic-delete-value: 0 + #关没必要的mp日志输出 + banner: false \ No newline at end of file diff --git a/src/main/resources/images/merchant/1.jpeg b/src/main/resources/images/merchant/1.jpeg new file mode 100644 index 0000000..ac35a47 Binary files /dev/null and b/src/main/resources/images/merchant/1.jpeg differ diff --git a/src/main/resources/images/product/10004.png b/src/main/resources/images/product/10004.png new file mode 100644 index 0000000..929086e Binary files /dev/null and b/src/main/resources/images/product/10004.png differ diff --git a/src/main/resources/images/product/10005.png b/src/main/resources/images/product/10005.png new file mode 100644 index 0000000..9415638 Binary files /dev/null and b/src/main/resources/images/product/10005.png differ diff --git a/src/main/resources/images/product/10006.png b/src/main/resources/images/product/10006.png new file mode 100644 index 0000000..669cc1a Binary files /dev/null and b/src/main/resources/images/product/10006.png differ diff --git a/src/main/resources/images/product/10007.png b/src/main/resources/images/product/10007.png new file mode 100644 index 0000000..98793c4 Binary files /dev/null and b/src/main/resources/images/product/10007.png differ diff --git a/src/main/resources/images/product/10008.png b/src/main/resources/images/product/10008.png new file mode 100644 index 0000000..7856b1a Binary files /dev/null and b/src/main/resources/images/product/10008.png differ diff --git a/src/main/resources/images/product/10009.png b/src/main/resources/images/product/10009.png new file mode 100644 index 0000000..c35df24 Binary files /dev/null and b/src/main/resources/images/product/10009.png differ diff --git a/src/main/resources/images/product/10010.png b/src/main/resources/images/product/10010.png new file mode 100644 index 0000000..aef100f Binary files /dev/null and b/src/main/resources/images/product/10010.png differ diff --git a/src/main/resources/images/product/10011.png b/src/main/resources/images/product/10011.png new file mode 100644 index 0000000..2903632 Binary files /dev/null and b/src/main/resources/images/product/10011.png differ diff --git a/src/main/resources/images/product/10012.png b/src/main/resources/images/product/10012.png new file mode 100644 index 0000000..0e25258 Binary files /dev/null and b/src/main/resources/images/product/10012.png differ diff --git a/src/main/resources/images/product/10013.png b/src/main/resources/images/product/10013.png new file mode 100644 index 0000000..37cc694 Binary files /dev/null and b/src/main/resources/images/product/10013.png differ diff --git a/src/main/resources/images/product/10014.png b/src/main/resources/images/product/10014.png new file mode 100644 index 0000000..86509da Binary files /dev/null and b/src/main/resources/images/product/10014.png differ diff --git a/src/main/resources/images/product/10015.png b/src/main/resources/images/product/10015.png new file mode 100644 index 0000000..27f4816 Binary files /dev/null and b/src/main/resources/images/product/10015.png differ diff --git a/src/main/resources/images/product/10016.png b/src/main/resources/images/product/10016.png new file mode 100644 index 0000000..0bb60b7 Binary files /dev/null and b/src/main/resources/images/product/10016.png differ diff --git a/src/main/resources/images/product/10017.png b/src/main/resources/images/product/10017.png new file mode 100644 index 0000000..0339ca6 Binary files /dev/null and b/src/main/resources/images/product/10017.png differ diff --git a/src/main/resources/images/product/10018.png b/src/main/resources/images/product/10018.png new file mode 100644 index 0000000..dc4b6ef Binary files /dev/null and b/src/main/resources/images/product/10018.png differ diff --git a/src/main/resources/images/product/10019.png b/src/main/resources/images/product/10019.png new file mode 100644 index 0000000..4e02e3c Binary files /dev/null and b/src/main/resources/images/product/10019.png differ diff --git a/src/main/resources/images/product/10020.png b/src/main/resources/images/product/10020.png new file mode 100644 index 0000000..bf0a277 Binary files /dev/null and b/src/main/resources/images/product/10020.png differ diff --git a/src/main/resources/static/script.js b/src/main/resources/static/script.js new file mode 100644 index 0000000..334ded7 --- /dev/null +++ b/src/main/resources/static/script.js @@ -0,0 +1,57 @@ +// 获取文件上传表单元素 +const fileInput = document.getElementById('fileInput'); + +// 监听文件上传表单的change事件 +fileInput.addEventListener('change', (event) => { + // 创建FormData对象 + const formData = new FormData(); + + // 将文件添加到FormData对象中 + const file = event.target.files[0]; + formData.append('file', file); + + // 发送文件上传请求 + fetch('/upload', { + method: 'POST', + body: formData + }) + .then(response => response.json()) + .then(data => { + // 处理上传成功后的响应数据 + console.log(data); + }) + .catch(error => { + // 处理上传失败的情况 + console.error(error); + }); +}); + +// 创建一个a标签用于下载 +const downloadLink = document.createElement('a'); + +// 点击下载按钮时触发的事件 +function downloadFile() { + // 发送文件下载请求 + fetch('/download', { + method: 'GET' + }) + .then(response => response.blob()) + .then(blob => { + // 创建URL对象 + const url = window.URL.createObjectURL(blob); + + // 设置下载链接的属性 + downloadLink.href = url; + downloadLink.download = 'filename.ext'; + + // 模拟点击下载链接 + downloadLink.click(); + + // 释放URL对象 + window.URL.revokeObjectURL(url); + }) + .catch(error => { + // 处理下载失败的情况 + console.error(error); + }); +} diff --git a/src/main/resources/static/upload.html b/src/main/resources/static/upload.html new file mode 100644 index 0000000..ed8ffcd --- /dev/null +++ b/src/main/resources/static/upload.html @@ -0,0 +1,21 @@ + + + + + + + 文件上传和下载 + + + +
+ + +
+ + + + + + + diff --git a/src/test/java/com/mijiu/test/DFBAppTest.java b/src/test/java/com/mijiu/test/DFBAppTest.java new file mode 100644 index 0000000..257b485 --- /dev/null +++ b/src/test/java/com/mijiu/test/DFBAppTest.java @@ -0,0 +1,12 @@ +package com.mijiu.test; + +import org.junit.jupiter.api.Test; + +public class DFBAppTest { + @Test + public void test1() { + String fileName = "ererewe.jpg"; + String suffix = fileName.substring(fileName.lastIndexOf(".")); + System.out.println(suffix); + } +} \ No newline at end of file diff --git a/src/test/java/com/mijiu/test/mapper/TestMapper.java b/src/test/java/com/mijiu/test/mapper/TestMapper.java new file mode 100644 index 0000000..cb3ecb4 --- /dev/null +++ b/src/test/java/com/mijiu/test/mapper/TestMapper.java @@ -0,0 +1,9 @@ +package com.mijiu.test.mapper; + +import com.mijiu.test.pojo.Test; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import org.apache.ibatis.annotations.Mapper; + +@Mapper +public interface TestMapper extends BaseMapper { +} diff --git a/src/test/java/com/mijiu/test/pojo/Test.java b/src/test/java/com/mijiu/test/pojo/Test.java new file mode 100644 index 0000000..183d9b8 --- /dev/null +++ b/src/test/java/com/mijiu/test/pojo/Test.java @@ -0,0 +1,15 @@ +package com.mijiu.test.pojo; + + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@NoArgsConstructor +@AllArgsConstructor +public class Test { + private String name; + private Integer age; + +}