diff --git a/nex-be/pom.xml b/nex-be/pom.xml index c8e3bdc..39fe7c4 100644 --- a/nex-be/pom.xml +++ b/nex-be/pom.xml @@ -37,8 +37,40 @@ spring-boot-configuration-processor true - + org.apache.commons + commons-lang3 + 3.18.0 + + + cn.hutool + hutool-all + 5.8.24 + + + com.alibaba + fastjson + 2.0.49 + + + + org.postgresql + postgresql + 42.7.7 + + + com.baomidou + mybatis-plus-extension + 3.4.3.1 + + + + com.baomidou + mybatis-plus-boot-starter + 3.4.3.1 + + + com.dampcake bencode 1.4 @@ -49,6 +81,11 @@ knife4j-spring-boot-starter 3.0.3 + + org.projectlombok + lombok + provided + diff --git a/nex-be/src/main/java/com/unisinsight.project/Application.java b/nex-be/src/main/java/com/unisinsight/project/Application.java similarity index 76% rename from nex-be/src/main/java/com/unisinsight.project/Application.java rename to nex-be/src/main/java/com/unisinsight/project/Application.java index 29e1534..b1fdf4d 100644 --- a/nex-be/src/main/java/com/unisinsight.project/Application.java +++ b/nex-be/src/main/java/com/unisinsight/project/Application.java @@ -1,5 +1,6 @@ package com.unisinsight.project; +import org.mybatis.spring.annotation.MapperScan; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; @@ -7,6 +8,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication; * 分片上传应用启动类 */ @SpringBootApplication +@MapperScan(basePackages = "com.unisinsight.project.mapper") public class Application { public static void main(String[] args) { diff --git a/nex-be/src/main/java/com/unisinsight.project/config/Knife4jConfig.java b/nex-be/src/main/java/com/unisinsight/project/config/Knife4jConfig.java similarity index 100% rename from nex-be/src/main/java/com/unisinsight.project/config/Knife4jConfig.java rename to nex-be/src/main/java/com/unisinsight/project/config/Knife4jConfig.java diff --git a/nex-be/src/main/java/com/unisinsight/project/config/MyBatisPlusPageConfig.java b/nex-be/src/main/java/com/unisinsight/project/config/MyBatisPlusPageConfig.java new file mode 100644 index 0000000..40255dc --- /dev/null +++ b/nex-be/src/main/java/com/unisinsight/project/config/MyBatisPlusPageConfig.java @@ -0,0 +1,23 @@ +package com.unisinsight.project.config; + +import com.baomidou.mybatisplus.annotation.DbType; +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; + +/** + * @description: + * @author: rdpnr_puzhi + * @create: 2025/08/06 + */ +@Configuration +public class MyBatisPlusPageConfig { + // 最新版 + @Bean + public MybatisPlusInterceptor mybatisPlusInterceptor() { + MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor(); + interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.POSTGRE_SQL)); + return interceptor; + } +} diff --git a/nex-be/src/main/java/com/unisinsight/project/config/MyMetaObjectHandler.java b/nex-be/src/main/java/com/unisinsight/project/config/MyMetaObjectHandler.java new file mode 100644 index 0000000..28effb1 --- /dev/null +++ b/nex-be/src/main/java/com/unisinsight/project/config/MyMetaObjectHandler.java @@ -0,0 +1,30 @@ +package com.unisinsight.project.config; + +import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler; +import org.apache.ibatis.reflection.MetaObject; +import org.springframework.stereotype.Component; + +import java.util.Date; + +/** + * @description: + * @author: rdpnr_puzhi + * @create: 2025/08/06 + */ + +@Component +public class MyMetaObjectHandler implements MetaObjectHandler { + + @Override + public void insertFill(MetaObject metaObject) { + this.strictInsertFill(metaObject, "createTime", Date.class, new Date()); + this.strictInsertFill(metaObject, "updateTime", Date.class, new Date()); + + } + + @Override + public void updateFill(MetaObject metaObject) { + this.strictUpdateFill(metaObject, "updateTime", Date.class, new Date()); + + } +} diff --git a/nex-be/src/main/java/com/unisinsight.project/controller/FileChunkController.java b/nex-be/src/main/java/com/unisinsight/project/controller/FileChunkController.java similarity index 100% rename from nex-be/src/main/java/com/unisinsight.project/controller/FileChunkController.java rename to nex-be/src/main/java/com/unisinsight/project/controller/FileChunkController.java diff --git a/nex-be/src/main/java/com/unisinsight/project/controller/UserController.java b/nex-be/src/main/java/com/unisinsight/project/controller/UserController.java new file mode 100644 index 0000000..092d0b9 --- /dev/null +++ b/nex-be/src/main/java/com/unisinsight/project/controller/UserController.java @@ -0,0 +1,75 @@ +package com.unisinsight.project.controller; + +import cn.hutool.json.JSONUtil; +import com.unisinsight.project.entity.req.DeleteIdReq; +import com.unisinsight.project.entity.req.UserReq; +import com.unisinsight.project.exception.BaseErrorCode; +import com.unisinsight.project.exception.Result; +import com.unisinsight.project.service.UserService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.extern.slf4j.Slf4j; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import javax.annotation.Resource; +import java.util.Objects; + +/** + * @description: + * @author: rdpnr_puzhi + * @create: 2025/08/06 + */ +@Slf4j +@RestController +@RequestMapping("/api/nex/v1/user") +@Api(tags = "用户处理Controller") +public class UserController { + + + @Resource + private UserService userService; + + @ApiOperation(value = "用户新增") + @PostMapping("/add") + public Result insertUser(@RequestBody UserReq userReq) { + if (Objects.isNull(userReq)) { + return Result.errorResult(BaseErrorCode.PARAMS_CHK_ERROR); + } + log.info("用户新增请求参数为:{}", JSONUtil.toJsonStr(userReq)); + return userService.insert(userReq); + } + + @ApiOperation(value = "用户修改") + @PostMapping("/update") + public Result updateUser(@RequestBody UserReq userReq) { + if (Objects.isNull(userReq)) { + return Result.errorResult(BaseErrorCode.PARAMS_CHK_ERROR); + } + log.info("用户修改请求参数为:{}", JSONUtil.toJsonStr(userReq)); + return userService.update(userReq); + } + + @ApiOperation(value = "用户删除") + @PostMapping("/delete") + public Result deleteUser(@RequestBody DeleteIdReq deleteIdReq) { + if (Objects.isNull(deleteIdReq)) { + return Result.errorResult(BaseErrorCode.PARAMS_CHK_ERROR); + } + log.info("用户删除请求参数为:{}", JSONUtil.toJsonStr(deleteIdReq)); + return userService.delete(deleteIdReq); + } + + @ApiOperation(value = "分页查询用户") + @PostMapping("/select/page") + public Result selectPageUser(@RequestBody UserReq userReq) { + if (Objects.isNull(userReq)) { + return Result.errorResult(BaseErrorCode.PARAMS_CHK_ERROR); + } + log.info("分页查询用户请求参数为:{}", JSONUtil.toJsonStr(userReq)); + return userService.selectPageUser(userReq); + } + +} diff --git a/nex-be/src/main/java/com/unisinsight/project/entity/dao/Device.java b/nex-be/src/main/java/com/unisinsight/project/entity/dao/Device.java new file mode 100644 index 0000000..14cd7c9 --- /dev/null +++ b/nex-be/src/main/java/com/unisinsight/project/entity/dao/Device.java @@ -0,0 +1,97 @@ +package com.unisinsight.project.entity.dao; + +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.util.Date; + +/** + * + * @TableName device + */ +@TableName(value ="device") +@Data +public class Device implements Serializable { + /** + * + */ + @TableId(type = IdType.AUTO) + private Long id; + + /** + * + */ + private String deviceId; + + /** + * + */ + private String deviceName; + + /** + * + */ + private Long deviceGroupId; + + /** + * + */ + private String deviceGroupName; + + /** + * + */ + private Integer deviceType; + + /** + * + */ + private String ipAddr; + + /** + * + */ + private String macAddr; + + /** + * + */ + private String model; + + /** + * + */ + private Date createTime; + + /** + * + */ + private String createUser; + + /** + * + */ + private Date updateTime; + + /** + * + */ + private String updateUser; + + /** + * + */ + private Integer deleted; + + /** + * + */ + private String description; + + @TableField(exist = false) + private static final long serialVersionUID = 1L; +} \ No newline at end of file diff --git a/nex-be/src/main/java/com/unisinsight/project/entity/dao/DeviceImageMapping.java b/nex-be/src/main/java/com/unisinsight/project/entity/dao/DeviceImageMapping.java new file mode 100644 index 0000000..49d0639 --- /dev/null +++ b/nex-be/src/main/java/com/unisinsight/project/entity/dao/DeviceImageMapping.java @@ -0,0 +1,77 @@ +package com.unisinsight.project.entity.dao; + +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.util.Date; + +/** + * + * @TableName device_image_mapping + */ +@TableName(value ="device_image_mapping") +@Data +public class DeviceImageMapping implements Serializable { + /** + * + */ + @TableId(type = IdType.AUTO) + private Long id; + + /** + * + */ + private String deviceId; + + /** + * + */ + private Long deviceGroupId; + + /** + * + */ + private Long imageId; + + /** + * + */ + private Integer restoreType; + + /** + * + */ + private Date createTime; + + /** + * + */ + private String createUser; + + /** + * + */ + private Date updateTime; + + /** + * + */ + private String updateUser; + + /** + * + */ + private String description; + + /** + * + */ + private Integer deleted; + + @TableField(exist = false) + private static final long serialVersionUID = 1L; +} \ No newline at end of file diff --git a/nex-be/src/main/java/com/unisinsight/project/entity/dao/DeviceUserMapping.java b/nex-be/src/main/java/com/unisinsight/project/entity/dao/DeviceUserMapping.java new file mode 100644 index 0000000..b2e1565 --- /dev/null +++ b/nex-be/src/main/java/com/unisinsight/project/entity/dao/DeviceUserMapping.java @@ -0,0 +1,77 @@ +package com.unisinsight.project.entity.dao; + +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.util.Date; + +/** + * + * @TableName device_user_mapping + */ +@TableName(value ="device_user_mapping") +@Data +public class DeviceUserMapping implements Serializable { + /** + * + */ + @TableId(type = IdType.AUTO) + private Long id; + + /** + * + */ + private String deviceId; + + /** + * + */ + private Long deviceGroupId; + + /** + * + */ + private Long userGroupId; + + /** + * + */ + private Long userId; + + /** + * + */ + private Date createTime; + + /** + * + */ + private String createUser; + + /** + * + */ + private Date updateTime; + + /** + * + */ + private String updateUser; + + /** + * + */ + private String description; + + /** + * + */ + private Integer deleted; + + @TableField(exist = false) + private static final long serialVersionUID = 1L; +} \ No newline at end of file diff --git a/nex-be/src/main/java/com/unisinsight/project/entity/dao/Image.java b/nex-be/src/main/java/com/unisinsight/project/entity/dao/Image.java new file mode 100644 index 0000000..2e12151 --- /dev/null +++ b/nex-be/src/main/java/com/unisinsight/project/entity/dao/Image.java @@ -0,0 +1,92 @@ +package com.unisinsight.project.entity.dao; + +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.util.Date; + +/** + * + * @TableName image + */ +@TableName(value ="image") +@Data +public class Image implements Serializable { + /** + * + */ + @TableId(type = IdType.AUTO) + private Long id; + + /** + * + */ + private String imageName; + + /** + * + */ + private Integer imageType; + + /** + * + */ + private Integer imageStatus; + + /** + * + */ + private String imageVersion; + + /** + * + */ + private String osVersion; + + /** + * + */ + private String btPath; + + /** + * + */ + private String storagePath; + + /** + * + */ + private Date createTime; + + /** + * + */ + private String createUser; + + /** + * + */ + private Date updateTime; + + /** + * + */ + private String updateUser; + + /** + * + */ + private Integer deleted; + + /** + * + */ + private String description; + + @TableField(exist = false) + private static final long serialVersionUID = 1L; +} \ No newline at end of file diff --git a/nex-be/src/main/java/com/unisinsight/project/entity/dao/User.java b/nex-be/src/main/java/com/unisinsight/project/entity/dao/User.java new file mode 100644 index 0000000..3e65a1d --- /dev/null +++ b/nex-be/src/main/java/com/unisinsight/project/entity/dao/User.java @@ -0,0 +1,111 @@ +package com.unisinsight.project.entity.dao; + +import com.baomidou.mybatisplus.annotation.*; +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; + +/** + * + * @TableName user + */ +@TableName(value ="\"user\"") +@Data +public class User implements Serializable { + /** + * + */ + @TableId(type = IdType.AUTO) + private Long id; + + /** + * + */ + private Long userGroupId; + + /** + * + */ + private String userName; + + /** + * + */ + private String password; + + /** + * + */ + private String birthday; + + /** + * + */ + private String cellPhone; + + /** + * + */ + private String email; + + /** + * + */ + private Integer gender; + + /** + * + */ + private String identityNo; + + /** + * + */ + private Long priority; + + /** + * + */ + private Integer userType; + + /** + * + */ + private Integer status; + + /** + * + */ + @TableField(fill = FieldFill.INSERT) + private Date createTime; + + /** + * + */ + private String createUser; + + /** + * + */ + @TableField(fill = FieldFill.INSERT_UPDATE) + private Date updateTime; + + /** + * + */ + private String updateUser; + + /** + * + */ + private Integer deleted; + + /** + * + */ + private String description; + + @TableField(exist = false) + private static final long serialVersionUID = 1L; +} \ No newline at end of file diff --git a/nex-be/src/main/java/com/unisinsight/project/entity/dao/UserDeviceGroup.java b/nex-be/src/main/java/com/unisinsight/project/entity/dao/UserDeviceGroup.java new file mode 100644 index 0000000..1a2b050 --- /dev/null +++ b/nex-be/src/main/java/com/unisinsight/project/entity/dao/UserDeviceGroup.java @@ -0,0 +1,83 @@ +package com.unisinsight.project.entity.dao; + +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.util.Date; + +/** + * + * @TableName user_device_group + */ +@TableName(value ="user_device_group") +@Data +public class UserDeviceGroup implements Serializable { + /** + * + */ + @TableId(type = IdType.AUTO) + private Long id; + + /** + * + */ + private String name; + + /** + * + */ + private Long parentId; + + /** + * + */ + private String parentName; + + /** + * + */ + private String index; + + /** + * + */ + private Integer type; + + /** + * + */ + private Date createTime; + + /** + * + */ + private String createUser; + + /** + * + */ + private Date updateTime; + + /** + * + */ + private String updateUser; + + /** + * + */ + private String path; + + /** + * + */ + private Integer deleted; + + + @TableField(exist = false) + private static final long serialVersionUID = 1L; +} \ No newline at end of file diff --git a/nex-be/src/main/java/com/unisinsight/project/entity/req/DeleteIdReq.java b/nex-be/src/main/java/com/unisinsight/project/entity/req/DeleteIdReq.java new file mode 100644 index 0000000..84aae9f --- /dev/null +++ b/nex-be/src/main/java/com/unisinsight/project/entity/req/DeleteIdReq.java @@ -0,0 +1,18 @@ +package com.unisinsight.project.entity.req; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + * @description: + * @author: rdpnr_puzhi + * @create: 2025/08/06 + */ +@ApiModel("删除ID类") +@Data +public class DeleteIdReq { + + @ApiModelProperty(value = "ID", dataType = "Long") + public Long id; +} diff --git a/nex-be/src/main/java/com/unisinsight/project/entity/req/UserReq.java b/nex-be/src/main/java/com/unisinsight/project/entity/req/UserReq.java new file mode 100644 index 0000000..92dddf7 --- /dev/null +++ b/nex-be/src/main/java/com/unisinsight/project/entity/req/UserReq.java @@ -0,0 +1,101 @@ +package com.unisinsight.project.entity.req; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; + +/** + * @TableName user + */ +@ApiModel("用户新增类") +@Data +public class UserReq implements Serializable { + + /** + * ID + */ + @ApiModelProperty(value = "ID", dataType = "Long") + private Long id; + + /** + * 用户组ID + */ + @ApiModelProperty(value = "用户组ID", dataType = "Long") + private Long userGroupId; + + /** + * 用户名 + */ + @ApiModelProperty(value = "用户名", dataType = "String") + private String userName; + + /** + * 密码 + */ + @ApiModelProperty(value = "密码", dataType = "String") + private String password; + + /** + * 生日 + */ + @ApiModelProperty(value = "生日", dataType = "String") + private String birthday; + + /** + * 电话 + */ + @ApiModelProperty(value = "电话", dataType = "String") + private String cellPhone; + + /** + * 邮箱 + */ + @ApiModelProperty(value = "邮箱", dataType = "String") + private String email; + + /** + * 身份证 + */ + + @ApiModelProperty(value = "身份证", dataType = "Integer") + private Integer gender; + + /** + * 身份证 + */ + @ApiModelProperty(value = "身份证", dataType = "String") + private String identityNo; + + /** + * + */ + @ApiModelProperty(value = "暂时不清楚", dataType = "Integer") + private Integer priority; + + /** + * 用户类型 + */ + @ApiModelProperty(value = "用户类型", dataType = "Integer") + private Integer userType; + + /** + * 状态 + */ + @ApiModelProperty(value = "状态", dataType = "Integer") + private Integer status; + + /** + * 查询页 + */ + @ApiModelProperty(value = "查询页", notes = "分页查询时再传", dataType = "Integer") + private Integer pageNum; + + /** + * 每页数量 + */ + @ApiModelProperty(value = "每页数量", notes = "分页查询时再传", dataType = "Integer") + private Integer pageSize; + +} \ No newline at end of file diff --git a/nex-be/src/main/java/com/unisinsight/project/entity/res/UserRes.java b/nex-be/src/main/java/com/unisinsight/project/entity/res/UserRes.java new file mode 100644 index 0000000..3c1f5fc --- /dev/null +++ b/nex-be/src/main/java/com/unisinsight/project/entity/res/UserRes.java @@ -0,0 +1,88 @@ +package com.unisinsight.project.entity.res; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; + +/** + * @TableName user + */ +@ApiModel("用户响应类") +@Data +public class UserRes implements Serializable { + /** + * ID + */ + @ApiModelProperty(value = "ID", dataType = "Long") + private Long id; + + /** + * 用户组ID + */ + @ApiModelProperty(value = "用户组ID", dataType = "Long") + private Long userGroupId; + + /** + * 用户名 + */ + @ApiModelProperty(value = "用户名", dataType = "String") + private String userName; + + /** + * 密码 + */ + @ApiModelProperty(value = "密码", dataType = "String") + private String password; + + /** + * 生日 + */ + @ApiModelProperty(value = "生日", dataType = "String") + private String birthday; + + /** + * 电话 + */ + @ApiModelProperty(value = "电话", dataType = "String") + private String cellPhone; + + /** + * 邮箱 + */ + @ApiModelProperty(value = "邮箱", dataType = "String") + private String email; + + /** + * 身份证 + */ + + @ApiModelProperty(value = "身份证", dataType = "Integer") + private Integer gender; + + /** + * 身份证 + */ + @ApiModelProperty(value = "身份证", dataType = "String") + private String identityNo; + + /** + * + */ + @ApiModelProperty(value = "", dataType = "Integer") + private Integer priority; + + /** + * 用户类型 + */ + @ApiModelProperty(value = "用户类型", dataType = "Integer") + private Integer userType; + + /** + * 状态 + */ + @ApiModelProperty(value = "状态", dataType = "Integer") + private Integer status; + +} \ No newline at end of file diff --git a/nex-be/src/main/java/com/unisinsight/project/exception/BaseErrorCode.java b/nex-be/src/main/java/com/unisinsight/project/exception/BaseErrorCode.java new file mode 100644 index 0000000..3da804e --- /dev/null +++ b/nex-be/src/main/java/com/unisinsight/project/exception/BaseErrorCode.java @@ -0,0 +1,172 @@ +package com.unisinsight.project.exception; + +/** + * @author zhangmengfei [yf_zhang.mengfei@unisinsight.com] + * @description 通用错误码定义 + * @date 2020/8/10 19:53 + * @since 1.0 + */ +public enum BaseErrorCode implements ErrorCode{ + INTERNAL_EXCEPTION("00001", "系统内部异常"), + INIT_EXCEPTION("00002", "系统初始化异常"), + UNKNOWN_ERROR("00003", "未知错误"), + MEMORY_ALLOCA_ERROR("00004", "内存分配失败"), + OUT_OF_MEMORY("00005", "内存溢出"), + REQUEST_TIMEOUT("00006", "请求超时"), + ILLEGAL_HANDLE("00007", "非法句柄"), + ENVIRONMENT_GET_FAIL("00008", "环境变量获取失败"), + FREQUENT_SYSTEM("00009", "系统繁忙"), + ILLEGAL_DATASOURCE("00010", "数据源异常"), + FREQUENT_OPERATION("00011", "当前操作频繁"), + UNKNOWN_REQUEST("00012", "未知的请求源"), + REQUEST_EXCEEDED("00013", "请求超过次数限制"), + CONFIG_GET_ERROR("00014", "获取配置错误"), + CONFIG_SET_ERROR("00015", "设置配置错误"), + PROGRAM_NEED_RESTART("00016", "需要重启程序"), + SYSTEM_NEED_RESTART("00017", "需要重启系统"), + CHARACTERISTICS_NOT_SUPPORT("00018", "特性不支持"), + VERIFY_FAILURE("00019", "验证失败"), + CALL_FAILURE("00020", "调用失败"), + MESSAGE_COMPONENT_EXCEPTION("00021", "消息组件异常"), + INSUFFICIENT_STORAGE_CAPACITY("00022", "存储容量不足"), + STORAGE_SERVICE_ERROR("00023", "存储服务错误"), + NETWORK_ERROR("00024", "网络错误"), + IP_ILLEGAL_ADDRESS("00025", "非法IP错误"), + IP_FORBIDDEN("00026", "被禁止的IP"), + IP_RESOLVE_DOMAIN("00027", "解析域名获取IP错误"), + PORT_ERROR("00028", "端口错误"), + API_DOMAIN_ERROR("00029", "域名错误"), + IP_ACCESS_EXCEEDED("00030", "当前IP请求超过限制"), + IP_NULL_ERROR("00031", "IP地址不能为空"), + CONNECTION_FAILURE("00032", "连接失败"), + DATA_SEND_FAILURE("00033", "数据发送失败"), + DATA_RECE_FAILURE("00034", "数据接收失败"), + HTTP_CLIENT_INIT_FAILURE("00035", "HTTP客户端初始化失败"), + HTTP_REQUEST_FAILURE("00036", "HTTP请求失败"), + HTTP_REQUEST_TIME_OUT("00037", "HTTP请求超时"), + HTTP_ERROR_CODE_400("00038", "HTTP错误码400"), + HTTP_ERROR_CODE_404("00039", "HTTP错误码404"), + HTTP_ERROR_CODE_500("00040", "HTTP错误码500"), + KAFKA_TOPICE_INVALID("00041", "kafka的topic无效"), + KAFKA_MESSAGE_SEND_FAILURE("00042", " kafka消息发送失败"), + DATABASE_ERROR("00043", "数据库错误"), + DATABASE_OPERATION_FAILED("00044", "数据库操作失败"), + QUERIER_EMPTY_RESULT("00045", "查询无结果"), + ID_REQUIRE("00046", "ID不能为空"), + DATA_DUPLICATED("00047", "数据重复"), + DATA_IN_UPDATING("00048", "数据更新中"), + QUERY_RESULT_NOT_UNIQURE("00049", "查询结果不唯一"), + DICTIONARY_GET_FAILED("00050", "字典获取失败"), + INTERFACE_NOT_EXISTS("00051", "接口不存在"), + PARAMS_CHK_ERROR("00052", "参数校验错误"), + PARAMETERS_INVALID("00053", "无效入参"), + NECESSARY_PARAMS_REQURIED("00054", "必填参数缺失,核对后重试"), + TYPE_NOT_SUPPORTED("00055", "类型不支持"), + NAME_REPEATED("00056", "名称重复"), + PARAMETERS_EMPTY("00057", "参数为空"), + LANGUAGE_NOT_SUPPORT("00058", "不支持该语言"), + API_ABANDONED("00059", "接口停用"), + API_MAINTENANCE("00060", "接口维护"), + API_VER_ERROR("00061", "版本号错误"), + VERIFICATION_CODE_WRONG("00062", "验证码错误"), + FORMAT_NOT_EMPTY("00063", "%s不能为空"), + MOBILE_FORMAT_ERROR("00064", "手机号码格式错误"), + IDCARD_FORMAT_ERROR("00065", "身份证错误"), + EMAIL_FORMAT_ERROR("00066", "邮箱错误"), + LONGITUDE_LATITUDE_ERROR("00067", "经纬度错误"), + REQUEST_PATH_ERROR("00068", "请求路径错误"), + DATA_FORMAT_ERROR("00069", "数据格式错误"), + TIME_PARAMS_ERROR("00070", "时间参数错误"), + CAR_LICENSE_ERROR("00071", "车牌号错误"), + CAMERA_NUMBER_ERROR("00072", "摄像头编号错误"), + CALLBACK_ADDR_ERROR("00073", "回调地址URL错误"), + TIME_FORMAT_ERROR("00074", "时间格式必须是ISO-8601"), + PAGE_NUM_OVERLIMIT("00075", "页码超出限制"), + PAGE_SIZE_OVERLIMIT("00076", "分页大小超出限制"), + THRID_PARTY_INTERFACE_FAILURE("00077", "调用第三方接口失败"), + JSON_PARSE_ERROR("00078", "json解析错误"), + JSON_MESSAGE_FIELD_TYPE_WRONG("00079", "json消息字段类型错误"), + JSON_MESSAGE_FIELD_VALUE_WRONG("00080", "json消息字段取值错误"), + JSON_MESSAGE_FIELD_MISSING("00081", "json消息字段缺失"), + CREATING_JSON_OBJECT_FAILED("00082", "创建json对象失败"), + CREATING_JSON_ARRAY_FAILED("00083", "创建json数组失败"), + JSON_FORMAT_CONTENT_WRONG("00084", "json格式或内容错误"), + FILENAME_ERROR("00085", "文件名错误"), + FILE_ADDRESS_ERROR("00086", "文件地址不存在"), + FILE_ID_NOT_EXIST("00087", "文件ID不存在"), + FILE_ID_LONG("00088", "文件ID过长"), + FILE_TYPE_WRONG("00089", "文件类型错误"), + FILE_CREATE_FAILED("00090", "创建文件失败"), + FILE_OPEN_FAILED("00091", "打开文件失败"), + FILE_DOWNLOAD_FAILED("00092", "下载文件失败"), + FILE_READ_FAILED("00093", "读取文件失败"), + FILE_WRITE_FAILED("00094", "写入文件失败"), + FILE_FORMAT_ERROR("00095", "文件格式错误"), + FILE_ENCRYPTED("00096", "文件被加密"), + EXEL_GENERATE_FAILED("00097", "EXEL生成失败"), + EXEL_IMPORT_FAILED("00098", "EXEL导入失败"), + TEXT_ENCODING_CONVERSION_FAILED("00099", "文本编码转换失败"), + FILE_NOT_RECOGNIZED("00100", "未识别文件"), + FILE_SIZE_EXCEEDS_LIMIT("00101", "文件大小超过限制"), + FILE_UPLOAD_FAILED("00102", "文件上传失败"), + OTHER_USER_UPLOAD_FILE("00103", "其他用户正在上传该文件"), + USER_NOT_FOUND("00104", "用户不存在"), + USER_NOT_LOGIN("00105", "用户未登录"), + USER_NOT_PERMISSON("00106", "用户没权限"), + PASSWORD_ERROR("00107", "密码错误"), + USER_NAME_EXIST("00108", "用户名已存在"), + USER_NAME_WRONG_LENGTH("00109", "用户名长度错误"), + PASSWORD_WRONG_LENGTH("00110", "密码长度错误"), + USER_NAME_OR_PASSWORD_WRONG_FORMAT("00111", "用户名或密码格式错误"), + USER_NAME_OR_PASSWORD_EMPTY("00112", "用户名或密码为空"), + USER_LOGIN_EXPIRED("00113", "用户登录已过期"), + SECURITY_AUTHENTICATION_FAILED("00114", "安全认证失败"), + ACCOUNT_NUMBER_LOCKED("00115", "账号被锁定"), + USER_ADD_FAILED("00116", "添加用户失败"), + USER_DELETE_FAILED("00117", "删除用户失败"), + USER_UPDATE_FAILED("00118", "修改用户失败"), + USER_QUERY_FAILED("00119", "查询用户失败"), + PASSWORD_UPDATE_FAILED("00120", "修改密码失败"), + PASSWORD_NEW_WRONG("00121", "新密码错误"), + PASSWORD_NEW_WRONG_LENGTH("00122", "新密码长度错误"), + PASSWORD_OLD_WRONG_LENGTH("00123", "原密码长度错误"), + PASSWORD_OLD_WRONG("00124", "原密码错误"), + PASSWORD_OLD_NEW_SAME("00125", "新密码和原密码相同"), + USER_NAME_OR_PASSWORD_INCORRECT("00126", "用户名或密码错误,需重新配置"), + DEVICE_GET_FAILED("00127", "设备获取失败"), + CHANNEL_GET_FAILED("00128", "通道获取失败"), + DEVICE_OFFLINE("00129", "设备离线"), + RESOURCES_TREE_GET_FAILED("00130", "资源树获取失败"), + RESOURCES_EXIST("00131", "资源已经存在"), + DEVICE_NOT_EXIST("00132", "设备不存在"), + DEVICE_EXIST("00133", "设备已经存在"), + DEVICE_NUMBER_REACHE_MAX("00134", "设备数达到上限"), + CHANNEL_NUMBER_REACHE_MAX("00135", "设备数达到上限"), + CAMERA_ID_WRONG("00136", "相机ID错误"), + CAMERA_NAME_WRONG("00137", "相机名错误"), + IPC_DEVICE_CODE_EXCEEDS_LONG("00138", "IPC设备编码超长"), + IPC_DEVICE_NAME_EXCEEDS_LONG("00139", "IPC设备名称超长"), + IPC_TYPE_GET_FAILED("00140", "获取IPC款型失败"), + FORMAT_VALIDATE_ERROR("00141", "%s"), + EXPORT_ERROR("00142", "导出EXCEL失败"), + SUCCESS("0000000000", "处理成功"); + + private String errorCode; + private String message; + + BaseErrorCode(String errorCode, String message) { + this.errorCode = errorCode; + this.message = message; + } + + + @Override + public String getErrorCode() { + return this.errorCode; + } + + @Override + public String getMessage() { + return this.message; + } +} diff --git a/nex-be/src/main/java/com/unisinsight/project/exception/BizException.java b/nex-be/src/main/java/com/unisinsight/project/exception/BizException.java new file mode 100644 index 0000000..c51868c --- /dev/null +++ b/nex-be/src/main/java/com/unisinsight/project/exception/BizException.java @@ -0,0 +1,117 @@ +package com.unisinsight.project.exception; + +/** + * @author zhangmengfei [yf_zhang.mengfei@unisinsight.com] + * @description BizExceptions + * @date 2020/9/2 14:21 + * @since 1.0 + */ +public class BizException extends RuntimeException { + private int httpStatus = 500; + private String errorCode; + private Object body; + + public BizException(String message, Throwable cause, int httpStatus, String errorCode, Object body) { + super(message, cause); + this.httpStatus = httpStatus; + this.errorCode = errorCode; + this.body = body; + } + + public BizException(ErrorCode errorCode) { + super(errorCode.getMessage()); + this.errorCode = errorCode.getErrorCode(); + } + + public BizException(ErrorCode errorCode, Object data) { + super(errorCode.getMessage()); + this.errorCode = errorCode.getErrorCode(); + this.body = data; + } + + public BizException(ErrorCode errorCode, Object... params) { + super(String.format(errorCode.getMessage(), params)); + this.errorCode = errorCode.getErrorCode(); + } + + public BizException(ErrorCode errorCode, Throwable cause, Object... params) { + super(String.format(errorCode.getMessage(), params), cause); + this.errorCode = errorCode.getErrorCode(); + } + + public static BizExceptionBuilder builder() { + return new BizExceptionBuilder(); + } + + public static BizException of(ErrorCode errorCode) { + return new BizException(errorCode); + } + + public static BizException of(ErrorCode errorCode, Object... params) { + return new BizException(errorCode, params); + } + + public int getHttpStatus() { + return this.httpStatus; + } + + public void setHttpStatus(int httpStatus) { + this.httpStatus = httpStatus; + } + + public String getErrorCode() { + return this.errorCode; + } + + public void setErrorCode(String errorCode) { + this.errorCode = errorCode; + } + + public Object getBody() { + return this.body; + } + + public void setBody(Object body) { + this.body = body; + } + + public static class BizExceptionBuilder { + private ErrorCode errorCode; + private Object[] params; + private Throwable cause; + private int status; + private T body; + + public BizExceptionBuilder() { + } + + public BizExceptionBuilder errorCode(ErrorCode errorCode) { + this.errorCode = errorCode; + return this; + } + + public BizExceptionBuilder params(Object... params) { + this.params = params; + return this; + } + + public BizExceptionBuilder cause(Throwable cause) { + this.cause = cause; + return this; + } + + public BizExceptionBuilder status(int status) { + this.status = status; + return this; + } + + public BizExceptionBuilder body(T body) { + this.body = body; + return this; + } + + public BizException build() { + return new BizException(String.format(this.errorCode.getMessage(), this.params), this.cause, this.status, this.errorCode.getErrorCode(), this.body); + } + } +} diff --git a/nex-be/src/main/java/com/unisinsight/project/exception/ErrorCode.java b/nex-be/src/main/java/com/unisinsight/project/exception/ErrorCode.java new file mode 100644 index 0000000..5938bcb --- /dev/null +++ b/nex-be/src/main/java/com/unisinsight/project/exception/ErrorCode.java @@ -0,0 +1,13 @@ +package com.unisinsight.project.exception; + +/** + * @author zhangmengfei [yf_zhang.mengfei@unisinsight.com] + * @description 错误码接口 + * @date 2020/8/10 19:53 + * @since 1.0 + */ +public interface ErrorCode { + String getErrorCode(); + + String getMessage(); +} \ No newline at end of file diff --git a/nex-be/src/main/java/com/unisinsight/project/exception/Result.java b/nex-be/src/main/java/com/unisinsight/project/exception/Result.java new file mode 100644 index 0000000..96afea7 --- /dev/null +++ b/nex-be/src/main/java/com/unisinsight/project/exception/Result.java @@ -0,0 +1,73 @@ +package com.unisinsight.project.exception; + +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Data; + +/** + * @author zhangmengfei [yf_zhang.mengfei@unisinsight.com] + * @description 返回结果类 + * @date 2020/8/10 19:53 + * @since 1.0 + */ +@Data +public class Result implements ErrorCode { + + /** + * 返回码 + */ + @JsonProperty(value = "error_code") + private String errorCode; + + /** + * 返回信息 + */ + @JsonProperty(value = "message") + private String message; + + /** + * 返回数据 + */ + @JsonProperty(value = "data") + private T data; + + public Result() { + } + + public Result(String errorCode, String message) { + this.errorCode = errorCode; + this.message = message; + } + + public Result(String errorCode, String message, T data) { + this.errorCode = errorCode; + this.message = message; + this.data = data; + } + + public static Result successResult(T data) { + return new Result<>(BaseErrorCode.SUCCESS.getErrorCode(), BaseErrorCode.SUCCESS.getMessage(), data); + } + + public static Result successResult() { + return new Result<>(BaseErrorCode.SUCCESS.getErrorCode(), BaseErrorCode.SUCCESS.getMessage()); + } + + public static Result errorResult(ErrorCode errorCode) { + return new Result<>(errorCode.getErrorCode(), errorCode.getMessage()); + } + + public static Result errorResult(ErrorCode errorCode, T data) { + return new Result<>(errorCode.getErrorCode(), errorCode.getMessage(), data); + } + + public static Result errorResultMessage(ErrorCode errorCode, String message) { + return new Result<>(errorCode.getErrorCode(), message); + } + + /** + * 判断当前返回是否成功 + */ + public boolean success() { + return BaseErrorCode.SUCCESS.getErrorCode().equals(this.errorCode); + } +} diff --git a/nex-be/src/main/java/com/unisinsight/project/mapper/DeviceImageMappingMapper.java b/nex-be/src/main/java/com/unisinsight/project/mapper/DeviceImageMappingMapper.java new file mode 100644 index 0000000..0c1a90c --- /dev/null +++ b/nex-be/src/main/java/com/unisinsight/project/mapper/DeviceImageMappingMapper.java @@ -0,0 +1,18 @@ +package com.unisinsight.project.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.unisinsight.project.entity.dao.DeviceImageMapping; + +/** +* @author rdpnr_puzhi +* @description 针对表【device_image_mapping】的数据库操作Mapper +* @createDate 2025-08-06 11:07:16 +* @Entity com.unisinsight.project.entity.DeviceImageMapping +*/ +public interface DeviceImageMappingMapper extends BaseMapper { + +} + + + + diff --git a/nex-be/src/main/java/com/unisinsight/project/mapper/DeviceMapper.java b/nex-be/src/main/java/com/unisinsight/project/mapper/DeviceMapper.java new file mode 100644 index 0000000..5227977 --- /dev/null +++ b/nex-be/src/main/java/com/unisinsight/project/mapper/DeviceMapper.java @@ -0,0 +1,18 @@ +package com.unisinsight.project.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.unisinsight.project.entity.dao.Device; + +/** +* @author rdpnr_puzhi +* @description 针对表【device】的数据库操作Mapper +* @createDate 2025-08-06 11:04:49 +* @Entity com.unisinsight.project.entity.Device +*/ +public interface DeviceMapper extends BaseMapper { + +} + + + + diff --git a/nex-be/src/main/java/com/unisinsight/project/mapper/DeviceUserMappingMapper.java b/nex-be/src/main/java/com/unisinsight/project/mapper/DeviceUserMappingMapper.java new file mode 100644 index 0000000..5541d68 --- /dev/null +++ b/nex-be/src/main/java/com/unisinsight/project/mapper/DeviceUserMappingMapper.java @@ -0,0 +1,18 @@ +package com.unisinsight.project.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.unisinsight.project.entity.dao.DeviceUserMapping; + +/** +* @author rdpnr_puzhi +* @description 针对表【device_user_mapping】的数据库操作Mapper +* @createDate 2025-08-06 11:07:39 +* @Entity com.unisinsight.project.entity.DeviceUserMapping +*/ +public interface DeviceUserMappingMapper extends BaseMapper { + +} + + + + diff --git a/nex-be/src/main/java/com/unisinsight/project/mapper/ImageMapper.java b/nex-be/src/main/java/com/unisinsight/project/mapper/ImageMapper.java new file mode 100644 index 0000000..3f9a210 --- /dev/null +++ b/nex-be/src/main/java/com/unisinsight/project/mapper/ImageMapper.java @@ -0,0 +1,18 @@ +package com.unisinsight.project.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.unisinsight.project.entity.dao.Image; + +/** +* @author rdpnr_puzhi +* @description 针对表【image】的数据库操作Mapper +* @createDate 2025-08-06 11:12:22 +* @Entity com.unisinsight.project.entity.Image +*/ +public interface ImageMapper extends BaseMapper { + +} + + + + diff --git a/nex-be/src/main/java/com/unisinsight/project/mapper/UserDeviceGroupMapper.java b/nex-be/src/main/java/com/unisinsight/project/mapper/UserDeviceGroupMapper.java new file mode 100644 index 0000000..3d2cd5c --- /dev/null +++ b/nex-be/src/main/java/com/unisinsight/project/mapper/UserDeviceGroupMapper.java @@ -0,0 +1,18 @@ +package com.unisinsight.project.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.unisinsight.project.entity.dao.UserDeviceGroup; + +/** +* @author rdpnr_puzhi +* @description 针对表【user_device_group】的数据库操作Mapper +* @createDate 2025-08-06 10:52:20 +* @Entity com.unisinsight.project.entity.UserDeviceGroup +*/ +public interface UserDeviceGroupMapper extends BaseMapper { + +} + + + + diff --git a/nex-be/src/main/java/com/unisinsight/project/mapper/UserMapper.java b/nex-be/src/main/java/com/unisinsight/project/mapper/UserMapper.java new file mode 100644 index 0000000..627d3b6 --- /dev/null +++ b/nex-be/src/main/java/com/unisinsight/project/mapper/UserMapper.java @@ -0,0 +1,18 @@ +package com.unisinsight.project.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.unisinsight.project.entity.dao.User; + +/** + * @author rdpnr_puzhi + * @description 针对表【user】的数据库操作Mapper + * @createDate 2025-08-06 11:12:08 + * @Entity com.unisinsight.project.entity.User + */ +public interface UserMapper extends BaseMapper { + +} + + + + diff --git a/nex-be/src/main/java/com/unisinsight/project/service/DeviceImageMappingService.java b/nex-be/src/main/java/com/unisinsight/project/service/DeviceImageMappingService.java new file mode 100644 index 0000000..28a8140 --- /dev/null +++ b/nex-be/src/main/java/com/unisinsight/project/service/DeviceImageMappingService.java @@ -0,0 +1,13 @@ +package com.unisinsight.project.service; + +import com.unisinsight.project.entity.dao.DeviceImageMapping; +import com.baomidou.mybatisplus.extension.service.IService; + +/** +* @author rdpnr_puzhi +* @description 针对表【device_image_mapping】的数据库操作Service +* @createDate 2025-08-06 11:07:16 +*/ +public interface DeviceImageMappingService extends IService { + +} diff --git a/nex-be/src/main/java/com/unisinsight/project/service/DeviceService.java b/nex-be/src/main/java/com/unisinsight/project/service/DeviceService.java new file mode 100644 index 0000000..b00dc08 --- /dev/null +++ b/nex-be/src/main/java/com/unisinsight/project/service/DeviceService.java @@ -0,0 +1,13 @@ +package com.unisinsight.project.service; + +import com.unisinsight.project.entity.dao.Device; +import com.baomidou.mybatisplus.extension.service.IService; + +/** +* @author rdpnr_puzhi +* @description 针对表【device】的数据库操作Service +* @createDate 2025-08-06 11:04:49 +*/ +public interface DeviceService extends IService { + +} diff --git a/nex-be/src/main/java/com/unisinsight/project/service/DeviceUserMappingService.java b/nex-be/src/main/java/com/unisinsight/project/service/DeviceUserMappingService.java new file mode 100644 index 0000000..95ad95a --- /dev/null +++ b/nex-be/src/main/java/com/unisinsight/project/service/DeviceUserMappingService.java @@ -0,0 +1,13 @@ +package com.unisinsight.project.service; + +import com.unisinsight.project.entity.dao.DeviceUserMapping; +import com.baomidou.mybatisplus.extension.service.IService; + +/** +* @author rdpnr_puzhi +* @description 针对表【device_user_mapping】的数据库操作Service +* @createDate 2025-08-06 11:07:39 +*/ +public interface DeviceUserMappingService extends IService { + +} diff --git a/nex-be/src/main/java/com/unisinsight/project/service/ImageService.java b/nex-be/src/main/java/com/unisinsight/project/service/ImageService.java new file mode 100644 index 0000000..5886c4b --- /dev/null +++ b/nex-be/src/main/java/com/unisinsight/project/service/ImageService.java @@ -0,0 +1,13 @@ +package com.unisinsight.project.service; + +import com.unisinsight.project.entity.dao.Image; +import com.baomidou.mybatisplus.extension.service.IService; + +/** +* @author rdpnr_puzhi +* @description 针对表【image】的数据库操作Service +* @createDate 2025-08-06 11:12:22 +*/ +public interface ImageService extends IService { + +} diff --git a/nex-be/src/main/java/com/unisinsight/project/service/UserDeviceGroupService.java b/nex-be/src/main/java/com/unisinsight/project/service/UserDeviceGroupService.java new file mode 100644 index 0000000..dd0b2a5 --- /dev/null +++ b/nex-be/src/main/java/com/unisinsight/project/service/UserDeviceGroupService.java @@ -0,0 +1,13 @@ +package com.unisinsight.project.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.unisinsight.project.entity.dao.UserDeviceGroup; + +/** +* @author rdpnr_puzhi +* @description 针对表【user_device_group】的数据库操作Service +* @createDate 2025-08-06 10:52:20 +*/ +public interface UserDeviceGroupService extends IService { + +} diff --git a/nex-be/src/main/java/com/unisinsight/project/service/UserService.java b/nex-be/src/main/java/com/unisinsight/project/service/UserService.java new file mode 100644 index 0000000..c712dae --- /dev/null +++ b/nex-be/src/main/java/com/unisinsight/project/service/UserService.java @@ -0,0 +1,24 @@ +package com.unisinsight.project.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.unisinsight.project.entity.dao.User; +import com.unisinsight.project.entity.req.DeleteIdReq; +import com.unisinsight.project.entity.req.UserReq; +import com.unisinsight.project.exception.Result; + +/** +* @author rdpnr_puzhi +* @description 针对表【user】的数据库操作Service +* @createDate 2025-08-06 11:12:08 +*/ +public interface UserService extends IService { + + + Result insert(UserReq userReq); + + Result update(UserReq userReq); + + Result delete(DeleteIdReq deleteIdReq); + + Result selectPageUser(UserReq userReq); +} diff --git a/nex-be/src/main/java/com/unisinsight/project/service/impl/DeviceImageMappingServiceImpl.java b/nex-be/src/main/java/com/unisinsight/project/service/impl/DeviceImageMappingServiceImpl.java new file mode 100644 index 0000000..1a5f9e4 --- /dev/null +++ b/nex-be/src/main/java/com/unisinsight/project/service/impl/DeviceImageMappingServiceImpl.java @@ -0,0 +1,22 @@ +package com.unisinsight.project.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.unisinsight.project.entity.dao.DeviceImageMapping; +import com.unisinsight.project.service.DeviceImageMappingService; +import com.unisinsight.project.mapper.DeviceImageMappingMapper; +import org.springframework.stereotype.Service; + +/** +* @author rdpnr_puzhi +* @description 针对表【device_image_mapping】的数据库操作Service实现 +* @createDate 2025-08-06 11:07:16 +*/ +@Service +public class DeviceImageMappingServiceImpl extends ServiceImpl + implements DeviceImageMappingService{ + +} + + + + diff --git a/nex-be/src/main/java/com/unisinsight/project/service/impl/DeviceServiceImpl.java b/nex-be/src/main/java/com/unisinsight/project/service/impl/DeviceServiceImpl.java new file mode 100644 index 0000000..3b5b38f --- /dev/null +++ b/nex-be/src/main/java/com/unisinsight/project/service/impl/DeviceServiceImpl.java @@ -0,0 +1,22 @@ +package com.unisinsight.project.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.unisinsight.project.entity.dao.Device; +import com.unisinsight.project.service.DeviceService; +import com.unisinsight.project.mapper.DeviceMapper; +import org.springframework.stereotype.Service; + +/** +* @author rdpnr_puzhi +* @description 针对表【device】的数据库操作Service实现 +* @createDate 2025-08-06 11:04:49 +*/ +@Service +public class DeviceServiceImpl extends ServiceImpl + implements DeviceService{ + +} + + + + diff --git a/nex-be/src/main/java/com/unisinsight/project/service/impl/DeviceUserMappingServiceImpl.java b/nex-be/src/main/java/com/unisinsight/project/service/impl/DeviceUserMappingServiceImpl.java new file mode 100644 index 0000000..f1b9064 --- /dev/null +++ b/nex-be/src/main/java/com/unisinsight/project/service/impl/DeviceUserMappingServiceImpl.java @@ -0,0 +1,22 @@ +package com.unisinsight.project.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.unisinsight.project.entity.dao.DeviceUserMapping; +import com.unisinsight.project.service.DeviceUserMappingService; +import com.unisinsight.project.mapper.DeviceUserMappingMapper; +import org.springframework.stereotype.Service; + +/** +* @author rdpnr_puzhi +* @description 针对表【device_user_mapping】的数据库操作Service实现 +* @createDate 2025-08-06 11:07:39 +*/ +@Service +public class DeviceUserMappingServiceImpl extends ServiceImpl + implements DeviceUserMappingService{ + +} + + + + diff --git a/nex-be/src/main/java/com/unisinsight/project/service/impl/ImageServiceImpl.java b/nex-be/src/main/java/com/unisinsight/project/service/impl/ImageServiceImpl.java new file mode 100644 index 0000000..6243c8c --- /dev/null +++ b/nex-be/src/main/java/com/unisinsight/project/service/impl/ImageServiceImpl.java @@ -0,0 +1,22 @@ +package com.unisinsight.project.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.unisinsight.project.entity.dao.Image; +import com.unisinsight.project.service.ImageService; +import com.unisinsight.project.mapper.ImageMapper; +import org.springframework.stereotype.Service; + +/** +* @author rdpnr_puzhi +* @description 针对表【image】的数据库操作Service实现 +* @createDate 2025-08-06 11:12:22 +*/ +@Service +public class ImageServiceImpl extends ServiceImpl + implements ImageService{ + +} + + + + diff --git a/nex-be/src/main/java/com/unisinsight/project/service/impl/UserDeviceGroupServiceImpl.java b/nex-be/src/main/java/com/unisinsight/project/service/impl/UserDeviceGroupServiceImpl.java new file mode 100644 index 0000000..e023b05 --- /dev/null +++ b/nex-be/src/main/java/com/unisinsight/project/service/impl/UserDeviceGroupServiceImpl.java @@ -0,0 +1,22 @@ +package com.unisinsight.project.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.unisinsight.project.entity.dao.UserDeviceGroup; +import com.unisinsight.project.mapper.UserDeviceGroupMapper; +import com.unisinsight.project.service.UserDeviceGroupService; +import org.springframework.stereotype.Service; + +/** +* @author rdpnr_puzhi +* @description 针对表【user_device_group】的数据库操作Service实现 +* @createDate 2025-08-06 10:52:20 +*/ +@Service +public class UserDeviceGroupServiceImpl extends ServiceImpl + implements UserDeviceGroupService{ + +} + + + + diff --git a/nex-be/src/main/java/com/unisinsight/project/service/impl/UserServiceImpl.java b/nex-be/src/main/java/com/unisinsight/project/service/impl/UserServiceImpl.java new file mode 100644 index 0000000..6e1c76a --- /dev/null +++ b/nex-be/src/main/java/com/unisinsight/project/service/impl/UserServiceImpl.java @@ -0,0 +1,98 @@ +package com.unisinsight.project.service.impl; + +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.json.JSONUtil; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.unisinsight.project.entity.dao.User; +import com.unisinsight.project.entity.req.DeleteIdReq; +import com.unisinsight.project.entity.req.UserReq; +import com.unisinsight.project.exception.BaseErrorCode; +import com.unisinsight.project.exception.Result; +import com.unisinsight.project.mapper.UserMapper; +import com.unisinsight.project.service.UserService; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; + +/** + * @author rdpnr_puzhi + * @description 针对表【user】的数据库操作Service实现 + * @createDate 2025-08-06 11:12:08 + */ +@Service +@Slf4j +public class UserServiceImpl extends ServiceImpl + implements UserService { + + @Resource + private UserMapper userMapper; + + @Override + public Result insert(UserReq userReq) { + User user = BeanUtil.copyProperties(userReq, User.class); + user.setCreateUser("admin"); + int insert = userMapper.insert(user); + log.info("用户新增insert:{}", insert); + if (insert == 1) { + return Result.successResult(); + } else { + return Result.errorResult(BaseErrorCode.HTTP_ERROR_CODE_500); + } + } + + @Override + public Result update(UserReq userReq) { + User user = BeanUtil.copyProperties(userReq, User.class); + user.setUpdateUser("admin"); + int updated = userMapper.updateById(user); + log.info("用户修改insert:{}", updated); + if (updated == 1) { + return Result.successResult(); + } else { + return Result.errorResult(BaseErrorCode.HTTP_ERROR_CODE_500); + } + } + + @Override + public Result delete(DeleteIdReq deleteIdReq) { + int deleted = userMapper.deleteById(deleteIdReq.getId()); + log.info("用户删除insert:{}", deleted); + if (deleted == 1) { + return Result.successResult(); + } else { + return Result.errorResult(BaseErrorCode.HTTP_ERROR_CODE_500); + } + } + + @Override + public Result selectPageUser(UserReq userReq) { + + Page page = new Page<>(userReq.getPageNum(), userReq.getPageSize()); + + QueryWrapper queryWrapper = new QueryWrapper<>(); + + if (StringUtils.isNoneBlank(userReq.getUserName())) { + queryWrapper.lambda().like(User::getUserName, userReq.getUserName()); + } + if (StringUtils.isNoneBlank(userReq.getIdentityNo())) { + queryWrapper.lambda().like(User::getIdentityNo, userReq.getIdentityNo()); + } + if (StringUtils.isNoneBlank(userReq.getCellPhone())) { + queryWrapper.lambda().like(User::getCellPhone, userReq.getCellPhone()); + } + + IPage userPage = userMapper.selectPage(page, queryWrapper); + log.info("分页查询用户返回:{}", JSONUtil.toJsonStr(userPage)); + + return Result.successResult(userPage); + } +} + + + + diff --git a/nex-be/src/main/java/com/unisinsight.project/util/BtTorrentUtil.java b/nex-be/src/main/java/com/unisinsight/project/util/BtTorrentUtil.java similarity index 97% rename from nex-be/src/main/java/com/unisinsight.project/util/BtTorrentUtil.java rename to nex-be/src/main/java/com/unisinsight/project/util/BtTorrentUtil.java index 7699a86..5955dd9 100644 --- a/nex-be/src/main/java/com/unisinsight.project/util/BtTorrentUtil.java +++ b/nex-be/src/main/java/com/unisinsight/project/util/BtTorrentUtil.java @@ -191,7 +191,7 @@ public class BtTorrentUtil { if (torrentInfo.getFiles() != null && !torrentInfo.getFiles().isEmpty()) { // 多文件模式 - java.util.List> fileList = new ArrayList<>(); + List> fileList = new ArrayList<>(); for (FileInfo file : torrentInfo.getFiles()) { java.util.Map fileMap = new java.util.HashMap<>(); fileMap.put("length", file.getLength()); @@ -271,9 +271,9 @@ public class BtTorrentUtil { // 处理文件列表 Object filesObj = infoMap.get("files"); - if (filesObj instanceof java.util.List) { - java.util.List> fileList = - (java.util.List>) filesObj; + if (filesObj instanceof List) { + List> fileList = + (List>) filesObj; List files = new ArrayList<>(); for (java.util.Map fileMap : fileList) { @@ -409,7 +409,7 @@ public class BtTorrentUtil { ); // 解析种子文件 - BtTorrentUtil.TorrentInfo info = BtTorrentUtil.parseTorrent("/path/to/output.torrent"); + TorrentInfo info = BtTorrentUtil.parseTorrent("/path/to/output.torrent"); System.out.println("种子名称: " + info.getName()); System.out.println("创建时间: " + new Date(info.getCreationDate() * 1000)); diff --git a/nex-be/src/main/resources/application.yml b/nex-be/src/main/resources/application.yml index befcef1..075d6d4 100644 --- a/nex-be/src/main/resources/application.yml +++ b/nex-be/src/main/resources/application.yml @@ -11,8 +11,31 @@ spring: multipart: max-file-size: 10MB max-request-size: 10MB + datasource: + driver-class-name: org.postgresql.Driver + url: jdbc:postgresql://10.100.51.86:5432/postgres?serverTimeZone=UTC + username: unis + password: unis@123 knife4j: production: false basic: - enable: false \ No newline at end of file + enable: false + + +mybatis-plus: + mapper-locations: classpath*:mappers/*.xml + typeAliasesPackage: com.unisinsight.project.entity + global-config: + db-config: + logic-delete-value: 1 + logic-not-delete-value: 0 + logic-delete-field: deleted + id-type: auto + field-strategy: 0 + db-column-underline: true + db-type: pgsql + configuration: + map-underscore-to-camel-case: true + cache-enabled: false + log-impl: org.apache.ibatis.logging.stdout.StdOutImpl diff --git a/nex-be/src/main/resources/mappers/DeviceImageMappingMapper.xml b/nex-be/src/main/resources/mappers/DeviceImageMappingMapper.xml new file mode 100644 index 0000000..63766b5 --- /dev/null +++ b/nex-be/src/main/resources/mappers/DeviceImageMappingMapper.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + id,device_id,device_group_id,image_id,restore_type,create_time, + create_user,update_time,update_user,description + + diff --git a/nex-be/src/main/resources/mappers/DeviceMapper.xml b/nex-be/src/main/resources/mappers/DeviceMapper.xml new file mode 100644 index 0000000..8284238 --- /dev/null +++ b/nex-be/src/main/resources/mappers/DeviceMapper.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + + + + + + + + + + id,device_id,device_name,device_group_id,device_group_name,device_type, + ip_addr,mac_addr,model,create_time,create_user, + update_time,update_user,deleted,description + + diff --git a/nex-be/src/main/resources/mappers/DeviceUserMappingMapper.xml b/nex-be/src/main/resources/mappers/DeviceUserMappingMapper.xml new file mode 100644 index 0000000..db161fa --- /dev/null +++ b/nex-be/src/main/resources/mappers/DeviceUserMappingMapper.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + id,device_id,device_group_id,user_group_id,user_id,create_time, + create_user,update_time,update_user,description + + diff --git a/nex-be/src/main/resources/mappers/ImageMapper.xml b/nex-be/src/main/resources/mappers/ImageMapper.xml new file mode 100644 index 0000000..5829efc --- /dev/null +++ b/nex-be/src/main/resources/mappers/ImageMapper.xml @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + + + + + + + + + id,image_name,image_type,image_status,image_version,os_version, + bt_path,storage_path,create_time,create_user,update_time, + update_user,deleted,description + + diff --git a/nex-be/src/main/resources/mappers/UserDeviceGroupMapper.xml b/nex-be/src/main/resources/mappers/UserDeviceGroupMapper.xml new file mode 100644 index 0000000..f992034 --- /dev/null +++ b/nex-be/src/main/resources/mappers/UserDeviceGroupMapper.xml @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + id,name,parent__id,parent__name,index,type, + create_time,create_user,update_time,update_user,path + + diff --git a/nex-be/src/main/resources/mappers/UserMapper.xml b/nex-be/src/main/resources/mappers/UserMapper.xml new file mode 100644 index 0000000..f783714 --- /dev/null +++ b/nex-be/src/main/resources/mappers/UserMapper.xml @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + id,user_group_id,user_name,password,birthday,cell_phone, + email,gender,identity_no,priority,user_type, + status,create_time,create_user,update_time,update_user, + deleted,description + +