浏览代码

模型初始化

luoshi 2 年之前
父节点
当前提交
554fea66be
共有 24 个文件被更改,包括 985 次插入1 次删除
  1. 1 1
      pom.xml
  2. 16 0
      src/main/java/com/qmth/ops/api/OpsApiApplication.java
  3. 10 0
      src/main/java/com/qmth/ops/api/constants/OpsApiConstants.java
  4. 36 0
      src/main/java/com/qmth/ops/api/controller/AdminAppController.java
  5. 36 0
      src/main/java/com/qmth/ops/api/controller/AdminUserController.java
  6. 11 0
      src/main/java/com/qmth/ops/api/controller/ExportController.java
  7. 31 0
      src/main/java/com/qmth/ops/api/security/AdminAuthorizationService.java
  8. 55 0
      src/main/java/com/qmth/ops/api/security/AdminSession.java
  9. 8 0
      src/main/java/com/qmth/ops/biz/dao/UserDao.java
  10. 74 0
      src/main/java/com/qmth/ops/biz/domain/App.java
  11. 81 0
      src/main/java/com/qmth/ops/biz/domain/BaselineItem.java
  12. 101 0
      src/main/java/com/qmth/ops/biz/domain/ConfigItem.java
  13. 20 0
      src/main/java/com/qmth/ops/biz/domain/ConfigMode.java
  14. 84 0
      src/main/java/com/qmth/ops/biz/domain/Env.java
  15. 20 0
      src/main/java/com/qmth/ops/biz/domain/EnvType.java
  16. 84 0
      src/main/java/com/qmth/ops/biz/domain/Module.java
  17. 6 0
      src/main/java/com/qmth/ops/biz/domain/Role.java
  18. 101 0
      src/main/java/com/qmth/ops/biz/domain/User.java
  19. 104 0
      src/main/java/com/qmth/ops/biz/domain/Version.java
  20. 36 0
      src/main/java/com/qmth/ops/biz/service/UserService.java
  21. 5 0
      src/main/java/com/qmth/ops/biz/utils/OpsUtils.java
  22. 60 0
      src/main/java/com/qmth/ops/biz/utils/VersionNumber.java
  23. 5 0
      src/main/resources/application.properties
  24. 0 0
      src/main/resources/script/init.sql

+ 1 - 1
pom.xml

@@ -7,7 +7,7 @@
     <artifactId>ops-api</artifactId>
     <packaging>jar</packaging>
     <version>1.0.0</version>
-    <name>solar-api</name>
+    <name>ops-api</name>
 
     <properties>
         <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

+ 16 - 0
src/main/java/com/qmth/ops/api/OpsApiApplication.java

@@ -0,0 +1,16 @@
+package com.qmth.ops.api;
+
+import org.mybatis.spring.annotation.MapperScan;
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.context.annotation.ComponentScan;
+
+@SpringBootApplication
+@ComponentScan("com.qmth.ops")
+@MapperScan("com.qmth.ops.biz")
+public class OpsApiApplication {
+
+    public static void main(String[] args) {
+        SpringApplication.run(OpsApiApplication.class, args);
+    }
+}

+ 10 - 0
src/main/java/com/qmth/ops/api/constants/OpsApiConstants.java

@@ -0,0 +1,10 @@
+package com.qmth.ops.api.constants;
+
+import com.qmth.boot.api.constant.ApiConstant;
+
+public interface OpsApiConstants {
+
+    String ADMIN_URI_PREFIX = ApiConstant.DEFAULT_URI_PREFIX + "/admin";
+
+    String EXPORT_URI_PREFIX = ApiConstant.DEFAULT_URI_PREFIX + "/export";
+}

+ 36 - 0
src/main/java/com/qmth/ops/api/controller/AdminAppController.java

@@ -0,0 +1,36 @@
+package com.qmth.ops.api.controller;
+
+import com.qmth.boot.api.annotation.Aac;
+import com.qmth.boot.api.annotation.BOOL;
+import com.qmth.boot.core.exception.ParameterException;
+import com.qmth.ops.api.constants.OpsApiConstants;
+import com.qmth.ops.api.security.AdminSession;
+import com.qmth.ops.biz.domain.User;
+import com.qmth.ops.biz.service.UserService;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.annotation.Resource;
+
+@RestController
+@RequestMapping(OpsApiConstants.ADMIN_URI_PREFIX)
+@Aac(auth = BOOL.TRUE)
+public class AdminAppController {
+
+    @Resource
+    private UserService userService;
+
+    @PostMapping("/login")
+    @Aac(auth = BOOL.FALSE)
+    public AdminSession login(User request) {
+        User user = userService.findByLoginName(request.getLoginName());
+        if (user == null) {
+            throw new ParameterException("登录名错误");
+        }
+        if (!user.buildPassword(request.getPassword()).equals(user.getPassword())) {
+            throw new ParameterException("密码错误");
+        }
+        return new AdminSession(user);
+    }
+}

+ 36 - 0
src/main/java/com/qmth/ops/api/controller/AdminUserController.java

@@ -0,0 +1,36 @@
+package com.qmth.ops.api.controller;
+
+import com.qmth.boot.api.annotation.Aac;
+import com.qmth.boot.api.annotation.BOOL;
+import com.qmth.boot.core.exception.ParameterException;
+import com.qmth.ops.api.constants.OpsApiConstants;
+import com.qmth.ops.api.security.AdminSession;
+import com.qmth.ops.biz.domain.User;
+import com.qmth.ops.biz.service.UserService;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.annotation.Resource;
+
+@RestController
+@RequestMapping(OpsApiConstants.ADMIN_URI_PREFIX)
+@Aac(auth = BOOL.TRUE)
+public class AdminUserController {
+
+    @Resource
+    private UserService userService;
+
+    @PostMapping("/login")
+    @Aac(auth = BOOL.FALSE)
+    public AdminSession login(User request) {
+        User user = userService.findByLoginName(request.getLoginName());
+        if (user == null) {
+            throw new ParameterException("登录名错误");
+        }
+        if (!user.buildPassword(request.getPassword()).equals(user.getPassword())) {
+            throw new ParameterException("密码错误");
+        }
+        return new AdminSession(user);
+    }
+}

+ 11 - 0
src/main/java/com/qmth/ops/api/controller/ExportController.java

@@ -0,0 +1,11 @@
+package com.qmth.ops.api.controller;
+
+import com.qmth.ops.api.constants.OpsApiConstants;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+@RestController
+@RequestMapping(OpsApiConstants.EXPORT_URI_PREFIX)
+public class ExportController {
+
+}

+ 31 - 0
src/main/java/com/qmth/ops/api/security/AdminAuthorizationService.java

@@ -0,0 +1,31 @@
+package com.qmth.ops.api.security;
+
+import com.qmth.boot.core.security.annotation.AuthorizationComponent;
+import com.qmth.boot.core.security.service.AuthorizationService;
+import com.qmth.boot.tools.signature.SignatureType;
+import com.qmth.ops.api.constants.OpsApiConstants;
+import com.qmth.ops.biz.domain.User;
+import com.qmth.ops.biz.service.UserService;
+
+import javax.annotation.Resource;
+
+@AuthorizationComponent(prefix = OpsApiConstants.ADMIN_URI_PREFIX, type = SignatureType.TOKEN)
+public class AdminAuthorizationService implements AuthorizationService<AdminSession>, OpsApiConstants {
+
+    @Resource
+    private UserService userService;
+
+    @Override
+    public AdminSession findByIdentity(String identity, SignatureType signatureType, String path) {
+        User user = userService.findById(Long.parseLong(identity));
+        if (user != null) {
+            return new AdminSession(user);
+        }
+        return null;
+    }
+
+    @Override
+    public boolean hasPermission(AdminSession session, String path) {
+        return true;
+    }
+}

+ 55 - 0
src/main/java/com/qmth/ops/api/security/AdminSession.java

@@ -0,0 +1,55 @@
+package com.qmth.ops.api.security;
+
+import com.qmth.boot.core.security.model.AccessEntity;
+import com.qmth.boot.tools.models.ByteArray;
+import com.qmth.ops.biz.domain.Role;
+import com.qmth.ops.biz.domain.User;
+
+public class AdminSession implements AccessEntity {
+
+    private Role role;
+
+    private String session;
+
+    private String token;
+
+    public AdminSession(User user) {
+        this.role = user.getRole();
+        this.session = user.getId().toString();
+        this.token = ByteArray.fromString(user.getLoginName()).toBase64();
+    }
+
+    public Role getRole() {
+        return role;
+    }
+
+    public void setRole(Role role) {
+        this.role = role;
+    }
+
+    public String getSession() {
+        return session;
+    }
+
+    public void setSession(String session) {
+        this.session = session;
+    }
+
+    public String getToken() {
+        return token;
+    }
+
+    public void setToken(String token) {
+        this.token = token;
+    }
+
+    @Override
+    public String getIdentity() {
+        return session;
+    }
+
+    @Override
+    public String getSecret() {
+        return token;
+    }
+}

+ 8 - 0
src/main/java/com/qmth/ops/biz/dao/UserDao.java

@@ -0,0 +1,8 @@
+package com.qmth.ops.biz.dao;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.qmth.ops.biz.domain.User;
+
+public interface UserDao extends BaseMapper<User> {
+
+}

+ 74 - 0
src/main/java/com/qmth/ops/biz/domain/App.java

@@ -0,0 +1,74 @@
+package com.qmth.ops.biz.domain;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+
+import java.io.Serializable;
+
+@TableName("app")
+public class App implements Serializable {
+
+    private static final long serialVersionUID = -2874796175196184476L;
+
+    @TableId(type = IdType.AUTO)
+    private Long id;
+
+    private String code;
+
+    private String name;
+
+    private Long masterVersionId;
+
+    private Long createTime;
+
+    private Long updateTime;
+
+    public Long getId() {
+        return id;
+    }
+
+    public void setId(Long id) {
+        this.id = id;
+    }
+
+    public String getCode() {
+        return code;
+    }
+
+    public void setCode(String code) {
+        this.code = code;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public Long getMasterVersionId() {
+        return masterVersionId;
+    }
+
+    public void setMasterVersionId(Long masterVersionId) {
+        this.masterVersionId = masterVersionId;
+    }
+
+    public Long getCreateTime() {
+        return createTime;
+    }
+
+    public void setCreateTime(Long createTime) {
+        this.createTime = createTime;
+    }
+
+    public Long getUpdateTime() {
+        return updateTime;
+    }
+
+    public void setUpdateTime(Long updateTime) {
+        this.updateTime = updateTime;
+    }
+}

+ 81 - 0
src/main/java/com/qmth/ops/biz/domain/BaselineItem.java

@@ -0,0 +1,81 @@
+package com.qmth.ops.biz.domain;
+
+import com.baomidou.mybatisplus.annotation.TableName;
+
+import java.io.Serializable;
+
+@TableName("baseline_item")
+public class BaselineItem implements Serializable {
+
+    private static final long serialVersionUID = -3347199955021382356L;
+
+    private Long appId;
+
+    private Long versionId;
+
+    private Long moduleId;
+
+    private String key;
+
+    private String value;
+
+    private String comment;
+
+    private ConfigMode mode;
+
+    public Long getAppId() {
+        return appId;
+    }
+
+    public void setAppId(Long appId) {
+        this.appId = appId;
+    }
+
+    public Long getVersionId() {
+        return versionId;
+    }
+
+    public void setVersionId(Long versionId) {
+        this.versionId = versionId;
+    }
+
+    public Long getModuleId() {
+        return moduleId;
+    }
+
+    public void setModuleId(Long moduleId) {
+        this.moduleId = moduleId;
+    }
+
+    public String getKey() {
+        return key;
+    }
+
+    public void setKey(String key) {
+        this.key = key;
+    }
+
+    public String getValue() {
+        return value;
+    }
+
+    public void setValue(String value) {
+        this.value = value;
+    }
+
+    public String getComment() {
+        return comment;
+    }
+
+    public void setComment(String comment) {
+        this.comment = comment;
+    }
+
+    public ConfigMode getMode() {
+        return mode;
+    }
+
+    public void setMode(ConfigMode mode) {
+        this.mode = mode;
+    }
+}

+ 101 - 0
src/main/java/com/qmth/ops/biz/domain/ConfigItem.java

@@ -0,0 +1,101 @@
+package com.qmth.ops.biz.domain;
+
+import com.baomidou.mybatisplus.annotation.TableName;
+
+import java.io.Serializable;
+
+@TableName("config_item")
+public class ConfigItem implements Serializable {
+
+    private static final long serialVersionUID = 1390416370953446620L;
+
+    private Long appId;
+
+    private Long versionId;
+
+    private Long envId;
+
+    private Long moduleId;
+
+    private String key;
+
+    private String value;
+
+    private String comment;
+
+    private Long createTime;
+
+    private Long updateTime;
+
+    public Long getAppId() {
+        return appId;
+    }
+
+    public void setAppId(Long appId) {
+        this.appId = appId;
+    }
+
+    public Long getVersionId() {
+        return versionId;
+    }
+
+    public void setVersionId(Long versionId) {
+        this.versionId = versionId;
+    }
+
+    public Long getEnvId() {
+        return envId;
+    }
+
+    public void setEnvId(Long envId) {
+        this.envId = envId;
+    }
+
+    public Long getModuleId() {
+        return moduleId;
+    }
+
+    public void setModuleId(Long moduleId) {
+        this.moduleId = moduleId;
+    }
+
+    public String getKey() {
+        return key;
+    }
+
+    public void setKey(String key) {
+        this.key = key;
+    }
+
+    public String getValue() {
+        return value;
+    }
+
+    public void setValue(String value) {
+        this.value = value;
+    }
+
+    public String getComment() {
+        return comment;
+    }
+
+    public void setComment(String comment) {
+        this.comment = comment;
+    }
+
+    public Long getCreateTime() {
+        return createTime;
+    }
+
+    public void setCreateTime(Long createTime) {
+        this.createTime = createTime;
+    }
+
+    public Long getUpdateTime() {
+        return updateTime;
+    }
+
+    public void setUpdateTime(Long updateTime) {
+        this.updateTime = updateTime;
+    }
+}

+ 20 - 0
src/main/java/com/qmth/ops/biz/domain/ConfigMode.java

@@ -0,0 +1,20 @@
+package com.qmth.ops.biz.domain;
+
+public enum ConfigMode {
+
+    READONLY("只读"), MUTABLE("可变"), OVERRIDE("覆盖");
+
+    private String name;
+
+    private ConfigMode(String name) {
+        this.name = name;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public String getCode() {
+        return toString().toUpperCase();
+    }
+}

+ 84 - 0
src/main/java/com/qmth/ops/biz/domain/Env.java

@@ -0,0 +1,84 @@
+package com.qmth.ops.biz.domain;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+
+import java.io.Serializable;
+
+@TableName("env")
+public class Env implements Serializable {
+
+    private static final long serialVersionUID = -5166610925082766076L;
+
+    @TableId(type = IdType.AUTO)
+    private Long id;
+
+    private Long appId;
+
+    private String code;
+
+    private String name;
+
+    private EnvType type;
+
+    private Long createTime;
+
+    private Long updateTime;
+
+    public Long getId() {
+        return id;
+    }
+
+    public void setId(Long id) {
+        this.id = id;
+    }
+
+    public Long getAppId() {
+        return appId;
+    }
+
+    public void setAppId(Long appId) {
+        this.appId = appId;
+    }
+
+    public String getCode() {
+        return code;
+    }
+
+    public void setCode(String code) {
+        this.code = code;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public EnvType getType() {
+        return type;
+    }
+
+    public void setType(EnvType type) {
+        this.type = type;
+    }
+
+    public Long getCreateTime() {
+        return createTime;
+    }
+
+    public void setCreateTime(Long createTime) {
+        this.createTime = createTime;
+    }
+
+    public Long getUpdateTime() {
+        return updateTime;
+    }
+
+    public void setUpdateTime(Long updateTime) {
+        this.updateTime = updateTime;
+    }
+}

+ 20 - 0
src/main/java/com/qmth/ops/biz/domain/EnvType.java

@@ -0,0 +1,20 @@
+package com.qmth.ops.biz.domain;
+
+public enum EnvType {
+
+    TEST("测试环境"), PROD("生产环境");
+
+    private String name;
+
+    private EnvType(String name) {
+        this.name = name;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public String getCode() {
+        return toString().toUpperCase();
+    }
+}

+ 84 - 0
src/main/java/com/qmth/ops/biz/domain/Module.java

@@ -0,0 +1,84 @@
+package com.qmth.ops.biz.domain;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+
+import java.io.Serializable;
+
+@TableName("module")
+public class Module implements Serializable {
+
+    private static final long serialVersionUID = 996527384846258420L;
+
+    @TableId(type = IdType.AUTO)
+    private Long id;
+
+    private Long appId;
+
+    private String code;
+
+    private String name;
+
+    private Boolean enable;
+
+    private Long createTime;
+
+    private Long updateTime;
+
+    public Long getId() {
+        return id;
+    }
+
+    public void setId(Long id) {
+        this.id = id;
+    }
+
+    public Long getAppId() {
+        return appId;
+    }
+
+    public void setAppId(Long appId) {
+        this.appId = appId;
+    }
+
+    public String getCode() {
+        return code;
+    }
+
+    public void setCode(String code) {
+        this.code = code;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public Boolean getEnable() {
+        return enable;
+    }
+
+    public void setEnable(Boolean enable) {
+        this.enable = enable;
+    }
+
+    public Long getCreateTime() {
+        return createTime;
+    }
+
+    public void setCreateTime(Long createTime) {
+        this.createTime = createTime;
+    }
+
+    public Long getUpdateTime() {
+        return updateTime;
+    }
+
+    public void setUpdateTime(Long updateTime) {
+        this.updateTime = updateTime;
+    }
+}

+ 6 - 0
src/main/java/com/qmth/ops/biz/domain/Role.java

@@ -0,0 +1,6 @@
+package com.qmth.ops.biz.domain;
+
+public enum Role {
+
+    DEV, TEST, OPS, ADMIN;
+}

+ 101 - 0
src/main/java/com/qmth/ops/biz/domain/User.java

@@ -0,0 +1,101 @@
+package com.qmth.ops.biz.domain;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.qmth.boot.tools.models.ByteArray;
+
+import java.io.Serializable;
+
+@TableName("user")
+public class User implements Serializable {
+
+    private static final long serialVersionUID = 3084261544687496032L;
+
+    @TableId(type = IdType.AUTO)
+    private Long id;
+
+    private String loginName;
+
+    private String name;
+
+    private String password;
+
+    private Role role;
+
+    private String exportSecret;
+
+    private Long createTime;
+
+    private Long updateTime;
+
+    public Long getId() {
+        return id;
+    }
+
+    public void setId(Long id) {
+        this.id = id;
+    }
+
+    public String getLoginName() {
+        return loginName;
+    }
+
+    public void setLoginName(String loginName) {
+        this.loginName = loginName;
+    }
+
+    public String getPassword() {
+        return password;
+    }
+
+    public void setPassword(String password) {
+        this.password = password;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public Role getRole() {
+        return role;
+    }
+
+    public void setRole(Role role) {
+        this.role = role;
+    }
+
+    public String getExportSecret() {
+        return exportSecret;
+    }
+
+    public void setExportSecret(String exportSecret) {
+        this.exportSecret = exportSecret;
+    }
+
+    public Long getCreateTime() {
+        return createTime;
+    }
+
+    public void setCreateTime(Long createTime) {
+        this.createTime = createTime;
+    }
+
+    public Long getUpdateTime() {
+        return updateTime;
+    }
+
+    public void setUpdateTime(Long updateTime) {
+        this.updateTime = updateTime;
+    }
+
+    public String buildPassword(String input) {
+        return ByteArray.md5(ByteArray.md5(input).toHexString() + "\t" + createTime.toString()).toHexString()
+                .toLowerCase();
+    }
+
+}

+ 104 - 0
src/main/java/com/qmth/ops/biz/domain/Version.java

@@ -0,0 +1,104 @@
+package com.qmth.ops.biz.domain;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+
+import java.io.Serializable;
+
+@TableName("version")
+public class Version implements Serializable {
+
+    private static final long serialVersionUID = -5708139814911098509L;
+
+    @TableId(type = IdType.AUTO)
+    private Long id;
+
+    private Long appId;
+
+    private String name;
+
+    private Integer mainNumber;
+
+    private Integer middleNumber;
+
+    private Integer subNumber;
+
+    private Boolean archived;
+
+    private Long createTime;
+
+    private Long updateTime;
+
+    public Long getId() {
+        return id;
+    }
+
+    public void setId(Long id) {
+        this.id = id;
+    }
+
+    public Long getAppId() {
+        return appId;
+    }
+
+    public void setAppId(Long appId) {
+        this.appId = appId;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public Integer getMainNumber() {
+        return mainNumber;
+    }
+
+    public void setMainNumber(Integer mainNumber) {
+        this.mainNumber = mainNumber;
+    }
+
+    public Integer getMiddleNumber() {
+        return middleNumber;
+    }
+
+    public void setMiddleNumber(Integer middleNumber) {
+        this.middleNumber = middleNumber;
+    }
+
+    public Integer getSubNumber() {
+        return subNumber;
+    }
+
+    public void setSubNumber(Integer subNumber) {
+        this.subNumber = subNumber;
+    }
+
+    public Boolean getArchived() {
+        return archived;
+    }
+
+    public void setArchived(Boolean archived) {
+        this.archived = archived;
+    }
+
+    public Long getCreateTime() {
+        return createTime;
+    }
+
+    public void setCreateTime(Long createTime) {
+        this.createTime = createTime;
+    }
+
+    public Long getUpdateTime() {
+        return updateTime;
+    }
+
+    public void setUpdateTime(Long updateTime) {
+        this.updateTime = updateTime;
+    }
+}

+ 36 - 0
src/main/java/com/qmth/ops/biz/service/UserService.java

@@ -0,0 +1,36 @@
+package com.qmth.ops.biz.service;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.qmth.ops.biz.dao.UserDao;
+import com.qmth.ops.biz.domain.User;
+import org.apache.commons.lang3.RandomStringUtils;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+
+@Service
+public class UserService {
+
+    @Resource
+    private UserDao userDao;
+
+    public User findById(Long id) {
+        return userDao.selectById(id);
+    }
+
+    public User findByLoginName(String loginName) {
+        return userDao.selectOne(new LambdaQueryWrapper<User>().eq(User::getLoginName, loginName));
+    }
+
+    public User insert(User user) {
+        user.setExportSecret(RandomStringUtils.random(32, true, true));
+        user.setCreateTime(System.currentTimeMillis());
+        user.setUpdateTime(user.getCreateTime());
+        user.setPassword(user.buildPassword(user.getPassword()));
+        if (userDao.insert(user) > 0) {
+            return user;
+        } else {
+            return null;
+        }
+    }
+}

+ 5 - 0
src/main/java/com/qmth/ops/biz/utils/OpsUtils.java

@@ -0,0 +1,5 @@
+package com.qmth.ops.biz.utils;
+
+public class OpsUtils {
+
+}

+ 60 - 0
src/main/java/com/qmth/ops/biz/utils/VersionNumber.java

@@ -0,0 +1,60 @@
+package com.qmth.ops.biz.utils;
+
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+public class VersionNumber {
+
+    private static final Pattern PATTERN = Pattern.compile("^(\\d+)\\.(\\d+)\\.(\\d+)$");
+
+    private int main;
+
+    private int middle;
+
+    private int sub;
+
+    public static VersionNumber parse(String content) {
+        try {
+            Matcher m = PATTERN.matcher(content);
+            if (m.find()) {
+                VersionNumber number = new VersionNumber();
+                number.main = Integer.parseInt(m.group(1));
+                number.middle = Integer.parseInt(m.group(2));
+                number.sub = Integer.parseInt(m.group(3));
+                return number;
+            }
+            return null;
+        } catch (Exception e) {
+            return null;
+        }
+    }
+
+    public int getMain() {
+        return main;
+    }
+
+    public void setMain(int main) {
+        this.main = main;
+    }
+
+    public int getMiddle() {
+        return middle;
+    }
+
+    public void setMiddle(int middle) {
+        this.middle = middle;
+    }
+
+    public int getSub() {
+        return sub;
+    }
+
+    public void setSub(int sub) {
+        this.sub = sub;
+    }
+
+    public String toString() {
+        return main + "." + middle + "." + sub;
+    }
+
+}

+ 5 - 0
src/main/resources/application.properties

@@ -0,0 +1,5 @@
+server.port=8080
+
+com.qmth.datasource.url=jdbc:mysql://localhost:3306/test_ops
+com.qmth.datasource.username=root
+com.qmth.datasource.password=root

+ 0 - 0
src/main/resources/script/init.sql