diff --git a/README.md b/README.md index 3930987bad23d90ac3d24a008574d5231dc163d9..2df6a64a06b8f27cd20da9a283a97d8c070da29d 100644 --- a/README.md +++ b/README.md @@ -52,6 +52,10 @@ Oauth2 Client通常是要被保护的资源,例如app接口。配套的Oauth2 2. oauthserver v1.2.0添加了阿里大鱼的发送验证码功能,需要阿里大鱼的jar,安装方法:运行src/main/resources/jars/install.bat。 ## 更新日志 +### v1.2.4.beta(2018-08-18) +- 代码生成器bug修复; +- 重新生成实体类。 + ### v1.2.4.alpha(2018-08-11) - 代码生成器配置文件`code-gen.properties`; - 修复mysql建表语句bug; diff --git a/pom.xml b/pom.xml index 9aa474be891d2668b2a34eb2cfe74b74c2cb16e1..7a4e728e698b3fd80953bd7a2c779ce2646bcb79 100644 --- a/pom.xml +++ b/pom.xml @@ -179,7 +179,7 @@ com.google.code.gson gson - 2.8.0 + 2.8.5 com.alibaba @@ -225,8 +225,14 @@ tk.mybatis mapper-spring-boot-starter - 1.2.4 + 2.0.3 + + tk.mybatis + mapper-generator + 1.0.4 + + org.freemarker freemarker @@ -256,7 +262,7 @@ commons-io commons-io - 2.6 + 2.4 org.apache.commons @@ -266,7 +272,7 @@ commons-codec commons-codec - 1.11 + 1.10 @@ -284,6 +290,14 @@ bootstrap 4.1.2 + + + + com.qiniu + qiniu-java-sdk + [7.2.0, 7.2.99] + + @@ -348,29 +362,7 @@ org.mybatis.generator mybatis-generator-maven-plugin - 1.3.6 - - ${basedir}/src/main/resources/generator/generatorConfig.xml - true - true - - - - Generate MyBatis Artifacts - - generate - - - - - - - - org.postgresql - postgresql - 9.4-1206-jdbc42 - - + 1.3.7 diff --git a/src/main/java/com/simon/OauthserverApplication.java b/src/main/java/com/simon/OauthserverApplication.java index a5f4aab293356cc028ffe5dfdae97f35b5d3e4a6..a1d51bf04cfc8a48e37832596729de301840d4cb 100644 --- a/src/main/java/com/simon/OauthserverApplication.java +++ b/src/main/java/com/simon/OauthserverApplication.java @@ -1,6 +1,6 @@ package com.simon; -import org.mybatis.spring.annotation.MapperScan; +import tk.mybatis.spring.annotation.MapperScan; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; diff --git a/src/main/java/com/simon/common/code/CodeGenerator.java b/src/main/java/com/simon/common/code/CodeGenerator.java index d5f7496ae0809ec33590980e97e022fdf56fe9b4..50b4ab60f57051a62100e33a282d5fec544a6c6b 100644 --- a/src/main/java/com/simon/common/code/CodeGenerator.java +++ b/src/main/java/com/simon/common/code/CodeGenerator.java @@ -36,11 +36,11 @@ public class CodeGenerator { private static String JDBC_PASSWORD; private static String JDBC_DIVER_CLASS_NAME; - private static final String PROJECT_PATH = System.getProperty("user.dir");//项目在硬盘上的基础路径 - protected static final String TEMPLATE_FILE_PATH = PROJECT_PATH + "/src/main/resources/templates/code";//模板位置 + static final String PROJECT_PATH = System.getProperty("user.dir");//项目在硬盘上的基础路径 + static final String TEMPLATE_FILE_PATH = PROJECT_PATH + "/src/main/resources/templates/code";//模板位置 - private static String JAVA_PATH;//java文件路径 - private static String RESOURCES_PATH;//资源文件路径 + static String JAVA_PATH;//java文件路径 + static String RESOURCES_PATH;//资源文件路径 private static String PACKAGE_PATH_REPOSITORY; private static String PACKAGE_PATH_SERVICE;//生成的Service存放路径 @@ -49,8 +49,8 @@ public class CodeGenerator { private static String GEN_MODULES;//要生成的模块 - protected static String AUTHOR;//@author - protected static final String CREATE = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date());//@date + static String AUTHOR;//@author + static final String CREATE = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date());//@date private static Properties prop; static { @@ -94,14 +94,15 @@ public class CodeGenerator { //genCode("users", "news_info"); //genCodeByCustomModelName("输入表名","输入自定义Model名称"); -// genCodeByCustomModelName("news_info","NewsInfo"); + /*genCodeByCustomModelName("authorities", "Authority"); + genCodeByCustomModelName("news_info","NewsInfo"); genCodeByCustomModelName("users", "OauthUser"); -// genCodeByCustomModelName("veri_code", "VeriCode"); -// genCodeByCustomModelName("reset_pwd_info", "ResetPwdInfo"); -// genCodeByCustomModelName("qr_code", "QrCode"); - //genCodeByCustomModelName("log_login", "LogLogin"); -// genCodeByCustomModelName("news_tag", "NewsTag"); - + genCodeByCustomModelName("veri_code", "VeriCode"); + genCodeByCustomModelName("reset_pwd_info", "ResetPwdInfo"); + genCodeByCustomModelName("qr_code", "QrCode"); + genCodeByCustomModelName("log_login", "LogLogin"); + genCodeByCustomModelName("news_tag", "NewsTag");*/ + genCodeByCustomModelName("news_tag", "NewsTag"); } /** diff --git a/src/main/java/com/simon/common/code/FreeMarkerGeneratorUtil.java b/src/main/java/com/simon/common/code/FreeMarkerGeneratorUtil.java index 0c0088dfc732596352bbf6e016574f9981685840..8187c2e9426299534350677dcfd9f59281eb7177 100644 --- a/src/main/java/com/simon/common/code/FreeMarkerGeneratorUtil.java +++ b/src/main/java/com/simon/common/code/FreeMarkerGeneratorUtil.java @@ -49,12 +49,6 @@ public class FreeMarkerGeneratorUtil { return; } - //获取当前项目路径 - String path = FreeMarkerGeneratorUtil.class.getResource("/").getPath(); - path = StrUtil.sub(path, 1, path.indexOf("/target")); - - //log.info("当前项目路径为:{}", path); - String parentProjectPath = StrUtil.sub(path, 0, path.lastIndexOf("/")); //获取模板路径 String templatePath = CodeGenerator.TEMPLATE_FILE_PATH; //log.info("当前模板路径为:{}", templatePath); @@ -63,17 +57,17 @@ public class FreeMarkerGeneratorUtil { String entityDir = null; //根据实体包名创建目录 - File[] ls = FileUtil.ls(parentProjectPath); + File[] ls = FileUtil.ls(CodeGenerator.PROJECT_PATH); for (File f: ls) { String currModule = f.toString(); boolean matches = currModule.matches("(.*?pojo.*?)|(.*?domain.*?)|(.*?entity.*?)"); if (f.isDirectory()&&matches){ - entityDir = f.toString()+ "/src/test/java/" + basePackage.replace(".", "/"); + entityDir = f.toString()+ CodeGenerator.JAVA_PATH + "/" + basePackage.replace(".", "/"); break; } } if (StrUtil.isBlank(entityDir)){ - entityDir = path + "/src/test/java/" + basePackage.replace(".", "/"); + entityDir = CodeGenerator.PROJECT_PATH + CodeGenerator.JAVA_PATH + "/" + basePackage.replace(".", "/"); } if (!FileUtil.exist(entityDir)) { FileUtil.mkdir(entityDir); @@ -101,7 +95,7 @@ public class FreeMarkerGeneratorUtil { if(getDataBaseType(con) == 1){ sql = "SELECT TABLE_NAME,TABLE_COMMENT FROM information_schema.TABLES WHERE table_schema='" + con.getCatalog() + "' AND TABLE_NAME='" + tableName + "'"; }else if(getDataBaseType(con) == 2){ - sql = "select obj_description('public." + tableName + "'::regclass)"; + sql = "SELECT relname AS TABLE_NAME, CAST(obj_description(relfilenode, 'pg_class') AS VARCHAR) AS TABLE_COMMENT FROM pg_class C WHERE relname = '" + tableName + "'"; }else{ throw new Exception("暂不支持其他数据库"); } @@ -128,6 +122,8 @@ public class FreeMarkerGeneratorUtil { }else if(getDataBaseType(con) == 2){ log.info(con.getCatalog()); sql = "SELECT delta.table_name, delta.column_name, alb.column_comment, alb.column_type, delta.data_type, delta.column_default, delta.is_nullable FROM information_schema.COLUMNS AS delta, ( SELECT C .relname AS table_name, A.attname AS column_name, col_description ( A.attrelid, A.attnum ) AS column_comment, format_type ( A.atttypid, A.atttypmod ) AS column_type, A.attnotnull AS NOTNULL FROM pg_class AS C, pg_attribute AS A WHERE C.relname = '" + tableName + "' AND A.attrelid = C.oid AND A.attnum > 0 ) AS alb WHERE table_schema = 'public' AND delta.TABLE_NAME = '" + tableName + "' AND delta.COLUMN_NAME = alb.column_name"; + }else{ + throw new Exception("暂不支持其他数据库"); } @@ -160,10 +156,12 @@ public class FreeMarkerGeneratorUtil { if ("id".equals(name)) { if (propertyType.equalsIgnoreCase("Long")) { annotation = "@Id\n" + + " @KeySql(genId = SnowflakeGenId.class)\n" + " @GeneratedValue(generator = \"sequenceId\")\n" + " @GenericGenerator(name = \"sequenceId\", strategy = \"com.simon.common.utils.snowflake.SequenceId\")"; }else if(propertyType.equalsIgnoreCase("String")){ annotation = "@Id\n" + + " @KeySql(genId = UUIdGenId.class)\n" + " @GeneratedValue(generator = \"uuid\")\n" + " @GenericGenerator(name = \"uuid\", strategy = \"com.simon.common.utils.UuidGenerator\")"; }else if(propertyType.equalsIgnoreCase("Integer")){ diff --git a/src/main/java/com/simon/common/config/CustomUserDetailsService.java b/src/main/java/com/simon/common/config/CustomUserDetailsService.java index 2bd74a450a4fa27c6c6fcb26e9a33cb8cefc03c5..5d497ce75f132762081381e2e12c7f33a4405901 100644 --- a/src/main/java/com/simon/common/config/CustomUserDetailsService.java +++ b/src/main/java/com/simon/common/config/CustomUserDetailsService.java @@ -40,7 +40,12 @@ public class CustomUserDetailsService implements UserDetailsService { myUserDetailsRowMapper = (rs, i) -> new UserEntity(rs.getLong(1), rs.getString(2), rs.getString(3), rs.getBoolean(4), rs.getString("phone"), rs.getString("email")); - authorityRowMapper = (rs,i) -> new Authority(rs.getLong(1), rs.getString(2)); + authorityRowMapper = (rs,i) -> { + Authority authority = new Authority(); + authority.setUserId(rs.getLong(1)); + authority.setAuthority(rs.getString(2)); + return authority; + }; } @Override diff --git a/src/main/java/com/simon/common/handler/AuthSuccessHandler.java b/src/main/java/com/simon/common/handler/AuthSuccessHandler.java index 38bf753785b09b71c5884133b1c3044e3cba4c7a..6e0f5b1050868f0e9af60921222c5d10df0c6d66 100644 --- a/src/main/java/com/simon/common/handler/AuthSuccessHandler.java +++ b/src/main/java/com/simon/common/handler/AuthSuccessHandler.java @@ -36,7 +36,10 @@ public class AuthSuccessHandler extends SavedRequestAwareAuthenticationSuccessHa @Override public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) throws IOException, ServletException { UserEntity userDetails = (UserEntity) authentication.getPrincipal(); - LogLogin logLogin = new LogLogin(new Date(), IpUtil.getIpAddr(request), userDetails.getUsername()); + LogLogin logLogin = new LogLogin(); + logLogin.setCreateTime(new Date()); + logLogin.setIp(IpUtil.getIpAddr(request)); + logLogin.setUsername(userDetails.getUsername()); logLogin = logLoginRepository.save(logLogin); logger.info(JSON.toJSONString(logLogin)); logger.info("authentication.isAuthenticated()=" + authentication.isAuthenticated()); diff --git a/src/main/java/com/simon/common/plugins/qiniu/QiNiuConfig.java b/src/main/java/com/simon/common/plugins/qiniu/QiNiuConfig.java new file mode 100644 index 0000000000000000000000000000000000000000..02fac31b5d3d048ec37770ce51e28422678b0df2 --- /dev/null +++ b/src/main/java/com/simon/common/plugins/qiniu/QiNiuConfig.java @@ -0,0 +1,61 @@ +package com.simon.common.plugins.qiniu; + +import com.qiniu.common.Zone; +import lombok.Data; +import lombok.extern.slf4j.Slf4j; + +import java.util.Properties; + +/** + * 七牛云配置 + * + * @author simon + * @create 2018-08-15 10:44 + **/ +@Slf4j +@Data +public class QiNiuConfig { + private String accessKey; + private String secretKey; + private String bucket; + private Zone zone; + private String domainOfBucket; + private long expireInSeconds; + + private static QiNiuConfig instance = new QiNiuConfig(); + + private QiNiuConfig(){ + Properties prop = new Properties(); + try { + prop.load(QiNiuConfig.class.getResourceAsStream("/qiniu.properties")); + accessKey = prop.getProperty("qiniu.access-key"); + secretKey = prop.getProperty("qiniu.secret-key"); + bucket = prop.getProperty("qiniu.bucket"); + domainOfBucket = prop.getProperty("qiniu.domain-of-bucket"); + expireInSeconds = Long.parseLong(prop.getProperty("qiniu.expire-in-seconds")); + String zoneName = prop.getProperty("qiniu.zone"); + if(zoneName.equals("zone0")){ + zone = Zone.zone0(); + }else if(zoneName.equals("zone1")){ + zone = Zone.zone1(); + }else if(zoneName.equals("zone2")){ + zone = Zone.zone2(); + }else if(zoneName.equals("zoneNa0")){ + zone = Zone.zoneNa0(); + }else if(zoneName.equals("zoneAs0")){ + zone = Zone.zoneAs0(); + }else{ + throw new Exception("Zone对象配置错误!"); + } + } catch (Exception e) { + e.printStackTrace(); + } + } + + public static QiNiuConfig getInstance(){ + return instance; + } + public static void main(String[] args) { + System.out.println(QiNiuConfig.getInstance().getAccessKey()); + } +} diff --git a/src/main/java/com/simon/common/plugins/qiniu/QiNiuUtil.java b/src/main/java/com/simon/common/plugins/qiniu/QiNiuUtil.java new file mode 100644 index 0000000000000000000000000000000000000000..71e0c5fd75717b748698f9f0251ea188f6442a94 --- /dev/null +++ b/src/main/java/com/simon/common/plugins/qiniu/QiNiuUtil.java @@ -0,0 +1,191 @@ +package com.simon.common.plugins.qiniu; + +import com.google.gson.Gson; +import com.qiniu.common.QiniuException; +import com.qiniu.http.Response; +import com.qiniu.storage.Configuration; +import com.qiniu.storage.UploadManager; +import com.qiniu.storage.model.DefaultPutRet; +import com.qiniu.util.Auth; +import com.qiniu.util.UrlSafeBase64; +import lombok.extern.slf4j.Slf4j; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import org.springframework.web.multipart.MultipartFile; + +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.UnsupportedEncodingException; +import java.net.URLEncoder; + +/** + * 七牛上传下载工具类 + * + * @author simon + * @create 2018-08-15 11:21 + **/ +@Slf4j +public class QiNiuUtil { + /** + * 上传本地文件 + * @param localFilePath 本地文件完整路径 + * @param key 文件云端存储的名称 + * @param override 是否覆盖同名同位置文件 + * @return + */ + public static boolean upload(String localFilePath, String key, boolean override){ + //构造一个带指定Zone对象的配置类 + Configuration cfg = new Configuration(QiNiuConfig.getInstance().getZone()); + //...其他参数参考类注释 + UploadManager uploadManager = new UploadManager(cfg); + //...生成上传凭证,然后准备上传 + Auth auth = Auth.create(QiNiuConfig.getInstance().getAccessKey(), QiNiuConfig.getInstance().getSecretKey()); + String upToken; + if(override){ + upToken = auth.uploadToken(QiNiuConfig.getInstance().getBucket(), key);//覆盖上传凭证 + }else{ + upToken = auth.uploadToken(QiNiuConfig.getInstance().getBucket()); + } + try { + Response response = uploadManager.put(localFilePath, key, upToken); + //解析上传成功的结果 + DefaultPutRet putRet = new Gson().fromJson(response.bodyString(), DefaultPutRet.class); + System.out.println(putRet.key); + System.out.println(putRet.hash); + return true; + } catch (QiniuException ex) { + Response r = ex.response; + System.err.println(r.toString()); + try { + System.err.println(r.bodyString()); + } catch (QiniuException ex2) { + //ignore + return false; + } + return false; + } + } + + /** + * 上传Base64图片 + * @param l 图片没经过base64处理的原图字节大小,获取文件大小的时候,切记要通过文件流的方式获取。而不是通过图片标签然后转换后获取。 + * @param file64 图片base64字符串 + * @param key 文件云端存储的名称 + * @param override 是否覆盖同名同位置文件 + * @return + * @throws IOException + */ + public static boolean uploadBase64(int l, String file64, String key, boolean override) throws IOException{ + /*FileInputStream fis = null; + int l = (int) (new File(localFilePath).length()); + byte[] src = new byte[l]; + try { + fis = new FileInputStream(new File(localFilePath)); + fis.read(src); + }catch (FileNotFoundException e){ + e.printStackTrace(); + log.error(e.getMessage()); + log.error("图片文件读取失败"); + return false; + } + String file64 = Base64.encodeToString(src, 0);*/ + + Auth auth = getAuth(); + String upToken; + if(override){ + upToken = auth.uploadToken(QiNiuConfig.getInstance().getBucket(), key);//覆盖上传凭证 + }else{ + upToken = auth.uploadToken(QiNiuConfig.getInstance().getBucket()); + } + + String url = "http://upload.qiniup.com/putb64/" + l+"/key/"+ UrlSafeBase64.encodeToString(key); + //非华东空间需要根据注意事项 1 修改上传域名 + RequestBody rb = RequestBody.create(null, file64); + Request request = new Request.Builder(). + url(url). + addHeader("Content-Type", "application/octet-stream") + .addHeader("Authorization", "UpToken " + upToken) + .post(rb).build(); + //System.out.println(request.headers()); + OkHttpClient client = new OkHttpClient(); + okhttp3.Response response = client.newCall(request).execute(); + //System.out.println(response); + return response.isSuccessful(); + } + + /** + * 获取文件访问地址 + * @param fileName 文件云端存储的名称 + * @return + * @throws UnsupportedEncodingException + */ + public static String fileUrl(String fileName) throws UnsupportedEncodingException { + String encodedFileName = URLEncoder.encode(fileName, "utf-8"); + String publicUrl = String.format("%s/%s", QiNiuConfig.getInstance().getDomainOfBucket(), encodedFileName); + Auth auth = getAuth(); + long expireInSeconds = QiNiuConfig.getInstance().getExpireInSeconds(); + if(-1 == expireInSeconds){ + return auth.privateDownloadUrl(publicUrl); + } + return auth.privateDownloadUrl(publicUrl, expireInSeconds); + } + + /** + * 上传MultipartFile + * @param file + * @param key + * @param override + * @return + * @throws IOException + */ + public static boolean uploadMultipartFile(MultipartFile file, String key, boolean override) { + //构造一个带指定Zone对象的配置类 + Configuration cfg = new Configuration(QiNiuConfig.getInstance().getZone()); + //...其他参数参考类注释 + UploadManager uploadManager = new UploadManager(cfg); + + //把文件转化为字节数组 + InputStream is = null; + ByteArrayOutputStream bos = null; + + try { + is = file.getInputStream(); + bos = new ByteArrayOutputStream(); + byte[] b = new byte[1024]; + int len = -1; + while ((len = is.read(b)) != -1){ + bos.write(b, 0, len); + } + byte[] uploadBytes= bos.toByteArray(); + + Auth auth = getAuth(); + String upToken; + if(override){ + upToken = auth.uploadToken(QiNiuConfig.getInstance().getBucket(), key);//覆盖上传凭证 + }else{ + upToken = auth.uploadToken(QiNiuConfig.getInstance().getBucket()); + } + //默认上传接口回复对象 + DefaultPutRet putRet; + //进行上传操作,传入文件的字节数组,文件名,上传空间,得到回复对象 + Response response = uploadManager.put(uploadBytes, key, upToken); + putRet = new Gson().fromJson(response.bodyString(), DefaultPutRet.class); + System.out.println(putRet.key);//key 文件名 + System.out.println(putRet.hash);//hash 七牛返回的文件存储的地址,可以使用这个地址加七牛给你提供的前缀访问到这个视频。 + return true; + }catch (QiniuException e){ + e.printStackTrace(); + return false; + }catch (IOException e) { + e.printStackTrace(); + return false; + } + } + + public static Auth getAuth(){ + Auth auth = Auth.create(QiNiuConfig.getInstance().getAccessKey(), QiNiuConfig.getInstance().getSecretKey()); + return auth; + } +} diff --git a/src/main/java/com/simon/common/utils/SnowflakeGenId.java b/src/main/java/com/simon/common/utils/SnowflakeGenId.java new file mode 100644 index 0000000000000000000000000000000000000000..e358d0a1b08896343fdb4dc8963f1057ff0c6ded --- /dev/null +++ b/src/main/java/com/simon/common/utils/SnowflakeGenId.java @@ -0,0 +1,19 @@ +package com.simon.common.utils; + +import com.simon.common.utils.snowflake.Sequence; +import tk.mybatis.mapper.genid.GenId; + +/** + * 基于Twitter的Snowflake算法 + * + * @author simon + * @create 2018-08-17 22:18 + **/ + +public class SnowflakeGenId implements GenId { + private Sequence sequence = new Sequence(1, 1); + @Override + public Long genId(String table, String column) { + return sequence.nextId(); + } +} diff --git a/src/main/java/com/simon/common/utils/UUIdGenId.java b/src/main/java/com/simon/common/utils/UUIdGenId.java new file mode 100644 index 0000000000000000000000000000000000000000..e4a4aa314e1bc699f2a0788868f10296dedcc29e --- /dev/null +++ b/src/main/java/com/simon/common/utils/UUIdGenId.java @@ -0,0 +1,17 @@ +package com.simon.common.utils; + +import tk.mybatis.mapper.genid.GenId; + +/** + * uuid生成 + * + * @author simon + * @create 2018-08-17 13:23 + **/ + +public class UUIdGenId implements GenId { + @Override + public String genId(String table, String column) { + return UuidUtils.getUUID(); + } +} diff --git a/src/main/java/com/simon/mapper/NewsTagMapper.java b/src/main/java/com/simon/mapper/NewsTagMapper.java index 7dcf039f6539a61de390c5796bb7730f5565b2b3..91d6b9faab67b305288b3072eacbd35ad8e6262b 100644 --- a/src/main/java/com/simon/mapper/NewsTagMapper.java +++ b/src/main/java/com/simon/mapper/NewsTagMapper.java @@ -2,7 +2,6 @@ package com.simon.mapper; import com.simon.common.mapper.MyMapper; import com.simon.model.NewsTag; -import org.springframework.stereotype.Repository; public interface NewsTagMapper extends MyMapper { } \ No newline at end of file diff --git a/src/main/java/com/simon/model/Authority.java b/src/main/java/com/simon/model/Authority.java index 26e9a1605c450aeaa74d7be0fcd8bd9bbc91de84..05c4a7085262a00bdeb28855308b9e1be6db7b90 100644 --- a/src/main/java/com/simon/model/Authority.java +++ b/src/main/java/com/simon/model/Authority.java @@ -1,46 +1,33 @@ package com.simon.model; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; import org.springframework.security.core.GrantedAuthority; +import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.Id; import javax.persistence.Table; import java.io.Serializable; -@Table(name = "authorities") +/** +* @author SimonSun +* @create 2018-08-17 23:33:01 +**/ +@ApiModel(description = "Authority") +@Data @Entity +@Table(name="authorities") public class Authority implements GrantedAuthority, Serializable { - private static final long serialVersionUID = 6565100352773737675L; + private static final long serialVersionUID = 1L; + @Id + @ApiModelProperty(value = "user_id") + @Column(name = "user_id", nullable = false) private Long userId; + @ApiModelProperty(value = "authority") + @Column(name = "authority", nullable = false) private String authority; - - public Authority() { - } - - public Authority(String authority) { - this.authority = authority; - } - - public Authority(Long userId, String authority) { - this.userId = userId; - this.authority = authority; - } - - public Long getUserId() { - return userId; - } - - public void setUserId(Long userId) { - this.userId = userId; - } - - public String getAuthority() { - return authority; - } - - public void setAuthority(String authority) { - this.authority = authority == null ? null : authority.trim(); - } } \ No newline at end of file diff --git a/src/main/java/com/simon/model/LogLogin.java b/src/main/java/com/simon/model/LogLogin.java index 4a05f1c6fd5a36404cd959b9c842298c1589e1c2..0d8352620eacf1595146fb32cf4817e11089e8b5 100644 --- a/src/main/java/com/simon/model/LogLogin.java +++ b/src/main/java/com/simon/model/LogLogin.java @@ -1,89 +1,42 @@ package com.simon.model; +import com.simon.common.utils.SnowflakeGenId; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; import org.hibernate.annotations.GenericGenerator; +import tk.mybatis.mapper.annotation.KeySql; import javax.persistence.*; import java.io.Serializable; import java.util.Date; +/** +* @author SimonSun +* @create 2018-08-17 23:33:01 +**/ +@ApiModel(description = "LogLogin") +@Data @Entity -@Table(name = "log_login") -public class LogLogin implements Serializable { - private static final long serialVersionUID = -1797278390731325076L; +@Table(name="log_login") +public class LogLogin implements Serializable{ + private static final long serialVersionUID = 1L; + @Id + @KeySql(genId = SnowflakeGenId.class) @GeneratedValue(generator = "sequenceId") @GenericGenerator(name = "sequenceId", strategy = "com.simon.common.utils.snowflake.SequenceId") private Long id; + @ApiModelProperty(value = "create_time") @Column(name = "create_time") private Date createTime; + @ApiModelProperty(value = "ip") + @Column(name = "ip") private String ip; + @ApiModelProperty(value = "username") + @Column(name = "username") private String username; - - public LogLogin() { - } - - public LogLogin(Date createTime, String ip, String username) { - this.createTime = createTime; - this.ip = ip; - this.username = username; - } - - /** - * @return id - */ - public Long getId() { - return id; - } - - /** - * @param id - */ - public void setId(Long id) { - this.id = id; - } - - /** - * @return create_time - */ - public Date getCreateTime() { - return createTime; - } - - /** - * @param createTime - */ - public void setCreateTime(Date createTime) { - this.createTime = createTime; - } - - /** - * @return ip - */ - public String getIp() { - return ip; - } - - /** - * @param ip - */ - public void setIp(String ip) { - this.ip = ip; - } - - /** - * @return username - */ - public String getUsername() { - return username; - } - - /** - * @param username - */ - public void setUsername(String username) { - this.username = username; - } } \ No newline at end of file diff --git a/src/main/java/com/simon/model/NewsInfo.java b/src/main/java/com/simon/model/NewsInfo.java index dd982647a4fed473c4bd86b754597d029d2bf224..81cd7a351017768c95cfbc554beab7b61614c907 100644 --- a/src/main/java/com/simon/model/NewsInfo.java +++ b/src/main/java/com/simon/model/NewsInfo.java @@ -1,146 +1,58 @@ package com.simon.model; +import com.simon.common.utils.SnowflakeGenId; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; import org.hibernate.annotations.GenericGenerator; +import tk.mybatis.mapper.annotation.KeySql; import javax.persistence.*; import java.io.Serializable; import java.util.Date; +/** +* @author SimonSun +* @create 2018-08-17 23:33:01 +**/ +@ApiModel(description = "NewsInfo") +@Data @Entity -@Table(name = "news_info") -public class NewsInfo implements Serializable { - private static final long serialVersionUID = 3237531145721255719L; +@Table(name="news_info") +public class NewsInfo implements Serializable{ + private static final long serialVersionUID = 1L; + @Id + @KeySql(genId = SnowflakeGenId.class) @GeneratedValue(generator = "sequenceId") @GenericGenerator(name = "sequenceId", strategy = "com.simon.common.utils.snowflake.SequenceId") private Long id; + @ApiModelProperty(value = "title") + @Column(name = "title") private String title; + @ApiModelProperty(value = "user_id") @Column(name = "user_id") private Long userId; + @ApiModelProperty(value = "status") + @Column(name = "status") private Integer status; + @ApiModelProperty(value = "content") + @Column(name = "content") private String content; + @ApiModelProperty(value = "image_url") @Column(name = "image_url") private String imageUrl; + @ApiModelProperty(value = "publish_date") @Column(name = "publish_date") private Date publishDate; + @ApiModelProperty(value = "tags") + @Column(name = "tags") private String tags; - - /** - * @return id - */ - public Long getId() { - return id; - } - - /** - * @param id - */ - public void setId(Long id) { - this.id = id; - } - - /** - * @return title - */ - public String getTitle() { - return title; - } - - /** - * @param title - */ - public void setTitle(String title) { - this.title = title; - } - - /** - * @return user_id - */ - public Long getUserId() { - return userId; - } - - /** - * @param userId - */ - public void setUserId(Long userId) { - this.userId = userId; - } - - /** - * @return status - */ - public Integer getStatus() { - return status; - } - - /** - * @param status - */ - public void setStatus(Integer status) { - this.status = status; - } - - /** - * @return content - */ - public String getContent() { - return content; - } - - /** - * @param content - */ - public void setContent(String content) { - this.content = content; - } - - /** - * @return image_url - */ - public String getImageUrl() { - return imageUrl; - } - - /** - * @param imageUrl - */ - public void setImageUrl(String imageUrl) { - this.imageUrl = imageUrl; - } - - /** - * @return publish_date - */ - public Date getPublishDate() { - return publishDate; - } - - /** - * @param publishDate - */ - public void setPublishDate(Date publishDate) { - this.publishDate = publishDate; - } - - /** - * @return tags - */ - public String getTags() { - return tags; - } - - /** - * @param tags - */ - public void setTags(String tags) { - this.tags = tags; - } } \ No newline at end of file diff --git a/src/main/java/com/simon/model/NewsTag.java b/src/main/java/com/simon/model/NewsTag.java index 69a8dcf0359e3ef7f26dcb7e37d86de3124f0b7c..2ee8ee59cdc755e6d58ed789d32a766cd9b0bf83 100644 --- a/src/main/java/com/simon/model/NewsTag.java +++ b/src/main/java/com/simon/model/NewsTag.java @@ -1,64 +1,37 @@ package com.simon.model; +import com.simon.common.utils.SnowflakeGenId; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; import org.hibernate.annotations.GenericGenerator; +import tk.mybatis.mapper.annotation.KeySql; import javax.persistence.*; import java.io.Serializable; +/** +* @author SimonSun +* @create 2018-08-18 00:41:52 +**/ +@ApiModel(description = "NewsTag") +@Data @Entity -@Table(name = "news_tag") -public class NewsTag implements Serializable { - private static final long serialVersionUID = -6089611811346962418L; +@Table(name="news_tag") +public class NewsTag implements Serializable{ + private static final long serialVersionUID = 1L; + @Id + @KeySql(genId = SnowflakeGenId.class) @GeneratedValue(generator = "sequenceId") @GenericGenerator(name = "sequenceId", strategy = "com.simon.common.utils.snowflake.SequenceId") private Long id; + @ApiModelProperty(value = "news_info_id") @Column(name = "news_info_id") private Long newsInfoId; + @ApiModelProperty(value = "tag_id") @Column(name = "tag_id") private Long tagId; - - /** - * @return id - */ - public Long getId() { - return id; - } - - /** - * @param id - */ - public void setId(Long id) { - this.id = id; - } - - /** - * @return news_info_id - */ - public Long getNewsInfoId() { - return newsInfoId; - } - - /** - * @param newsInfoId - */ - public void setNewsInfoId(Long newsInfoId) { - this.newsInfoId = newsInfoId; - } - - /** - * @return tag_id - */ - public Long getTagId() { - return tagId; - } - - /** - * @param tagId - */ - public void setTagId(Long tagId) { - this.tagId = tagId; - } } \ No newline at end of file diff --git a/src/main/java/com/simon/model/OauthUser.java b/src/main/java/com/simon/model/OauthUser.java index 58550e7e1c86388f333b0f6e81f164765733e02f..f0cfca81b0a84ee946526284801cfafbb6c4d3be 100644 --- a/src/main/java/com/simon/model/OauthUser.java +++ b/src/main/java/com/simon/model/OauthUser.java @@ -1,225 +1,81 @@ package com.simon.model; +import com.simon.common.utils.SnowflakeGenId; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; import org.hibernate.annotations.GenericGenerator; +import tk.mybatis.mapper.annotation.KeySql; import javax.persistence.*; import java.io.Serializable; +/** +* @author SimonSun +* @create 2018-08-17 23:33:01 +**/ +@ApiModel(description = "OauthUser") +@Data @Entity -@Table(name = "users") -public class OauthUser implements Serializable { - private static final long serialVersionUID = 7928736608744438474L; +@Table(name="users") +public class OauthUser implements Serializable{ + private static final long serialVersionUID = 1L; + @Id + @KeySql(genId = SnowflakeGenId.class) @GeneratedValue(generator = "sequenceId") @GenericGenerator(name = "sequenceId", strategy = "com.simon.common.utils.snowflake.SequenceId") private Long id; + @ApiModelProperty(value = "username") + @Column(name = "username", nullable = false) private String username; + @ApiModelProperty(value = "password") + @Column(name = "password", nullable = false) private String password; + @ApiModelProperty(value = "enabled") + @Column(name = "enabled", nullable = false) private Boolean enabled; + @ApiModelProperty(value = "email") + @Column(name = "email") private String email; + @ApiModelProperty(value = "phone") + @Column(name = "phone") private String phone; + @ApiModelProperty(value = "enable") + @Column(name = "enable") + private Boolean enable; + + @ApiModelProperty(value = "address") + @Column(name = "address") private String address; + @ApiModelProperty(value = "age") + @Column(name = "age") private Integer age; + @ApiModelProperty(value = "birth") + @Column(name = "birth") private String birth; + @ApiModelProperty(value = "head_photo") @Column(name = "head_photo") private String headPhoto; + @ApiModelProperty(value = "person_brief") @Column(name = "person_brief") private String personBrief; + @ApiModelProperty(value = "sex") + @Column(name = "sex") private Boolean sex; + @ApiModelProperty(value = "visit_card") @Column(name = "visit_card") private String visitCard; - - /** - * @return id - */ - public Long getId() { - return id; - } - - /** - * @param id - */ - public void setId(Long id) { - this.id = id; - } - - /** - * @return username - */ - public String getUsername() { - return username; - } - - /** - * @param username - */ - public void setUsername(String username) { - this.username = username; - } - - /** - * @return password - */ - public String getPassword() { - return password; - } - - /** - * @param password - */ - public void setPassword(String password) { - this.password = password; - } - - /** - * @return enabled - */ - public Boolean getEnabled() { - return enabled; - } - - /** - * @param enabled - */ - public void setEnabled(Boolean enabled) { - this.enabled = enabled; - } - - /** - * @return email - */ - public String getEmail() { - return email; - } - - /** - * @param email - */ - public void setEmail(String email) { - this.email = email; - } - - /** - * @return phone - */ - public String getPhone() { - return phone; - } - - /** - * @param phone - */ - public void setPhone(String phone) { - this.phone = phone; - } - - /** - * @return address - */ - public String getAddress() { - return address; - } - - /** - * @param address - */ - public void setAddress(String address) { - this.address = address; - } - - /** - * @return age - */ - public Integer getAge() { - return age; - } - - /** - * @param age - */ - public void setAge(Integer age) { - this.age = age; - } - - /** - * @return birth - */ - public String getBirth() { - return birth; - } - - /** - * @param birth - */ - public void setBirth(String birth) { - this.birth = birth; - } - - /** - * @return head_photo - */ - public String getHeadPhoto() { - return headPhoto; - } - - /** - * @param headPhoto - */ - public void setHeadPhoto(String headPhoto) { - this.headPhoto = headPhoto; - } - - /** - * @return person_brief - */ - public String getPersonBrief() { - return personBrief; - } - - /** - * @param personBrief - */ - public void setPersonBrief(String personBrief) { - this.personBrief = personBrief; - } - - /** - * @return sex - */ - public Boolean getSex() { - return sex; - } - - /** - * @param sex - */ - public void setSex(Boolean sex) { - this.sex = sex; - } - - /** - * @return visit_card - */ - public String getVisitCard() { - return visitCard; - } - - /** - * @param visitCard - */ - public void setVisitCard(String visitCard) { - this.visitCard = visitCard; - } } \ No newline at end of file diff --git a/src/main/java/com/simon/model/QrCode.java b/src/main/java/com/simon/model/QrCode.java index e702d51435e360629d68534c062a2222545b9505..a8c9efc47f49096555efecdc972cb88b4b9f7de4 100644 --- a/src/main/java/com/simon/model/QrCode.java +++ b/src/main/java/com/simon/model/QrCode.java @@ -1,95 +1,45 @@ package com.simon.model; +import com.simon.common.utils.SnowflakeGenId; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; import org.hibernate.annotations.GenericGenerator; +import tk.mybatis.mapper.annotation.KeySql; import javax.persistence.*; import java.io.Serializable; +/** +* @author SimonSun +* @create 2018-08-17 23:33:01 +**/ +@ApiModel(description = "QrCode") +@Data @Entity -@Table(name = "qr_code") -public class QrCode implements Serializable { - private static final long serialVersionUID = 893695741308186957L; +@Table(name="qr_code") +public class QrCode implements Serializable{ + private static final long serialVersionUID = 1L; + @Id + @KeySql(genId = SnowflakeGenId.class) @GeneratedValue(generator = "sequenceId") @GenericGenerator(name = "sequenceId", strategy = "com.simon.common.utils.snowflake.SequenceId") private Long id; + @ApiModelProperty(value = "is_ok") @Column(name = "is_ok") private Boolean isOk; + @ApiModelProperty(value = "sid") + @Column(name = "sid") private String sid; + @ApiModelProperty(value = "token") + @Column(name = "token") private String token; + @ApiModelProperty(value = "username") + @Column(name = "username") private String username; - - /** - * @return id - */ - public Long getId() { - return id; - } - - /** - * @param id - */ - public void setId(Long id) { - this.id = id; - } - - /** - * @return is_ok - */ - public Boolean getIsOk() { - return isOk; - } - - /** - * @param isOk - */ - public void setIsOk(Boolean isOk) { - this.isOk = isOk; - } - - /** - * @return sid - */ - public String getSid() { - return sid; - } - - /** - * @param sid - */ - public void setSid(String sid) { - this.sid = sid; - } - - /** - * @return token - */ - public String getToken() { - return token; - } - - /** - * @param token - */ - public void setToken(String token) { - this.token = token; - } - - /** - * @return username - */ - public String getUsername() { - return username; - } - - /** - * @param username - */ - public void setUsername(String username) { - this.username = username; - } } \ No newline at end of file diff --git a/src/main/java/com/simon/model/ResetPwdInfo.java b/src/main/java/com/simon/model/ResetPwdInfo.java index 1c05d2585615d65cb2dbdb52a6ca6187497f0336..e3b948cc71c06f81567b6bf7b419a402dcd7d705 100644 --- a/src/main/java/com/simon/model/ResetPwdInfo.java +++ b/src/main/java/com/simon/model/ResetPwdInfo.java @@ -1,98 +1,46 @@ package com.simon.model; +import com.simon.common.utils.SnowflakeGenId; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; import org.hibernate.annotations.GenericGenerator; +import tk.mybatis.mapper.annotation.KeySql; import javax.persistence.*; import java.io.Serializable; import java.util.Date; +/** +* @author SimonSun +* @create 2018-08-17 23:33:01 +**/ +@ApiModel(description = "ResetPwdInfo") +@Data @Entity -@Table(name = "reset_pwd_info") -public class ResetPwdInfo implements Serializable { - private static final long serialVersionUID = 980999113275832311L; +@Table(name="reset_pwd_info") +public class ResetPwdInfo implements Serializable{ + private static final long serialVersionUID = 1L; + @Id + @KeySql(genId = SnowflakeGenId.class) @GeneratedValue(generator = "sequenceId") @GenericGenerator(name = "sequenceId", strategy = "com.simon.common.utils.snowflake.SequenceId") private Long id; + @ApiModelProperty(value = "expires_in") @Column(name = "expires_in") private Date expiresIn; + @ApiModelProperty(value = "secret_key") @Column(name = "secret_key") private String secretKey; + @ApiModelProperty(value = "user_id") @Column(name = "user_id") private Long userId; + @ApiModelProperty(value = "valid") + @Column(name = "valid", nullable = false) private Boolean valid; - - /** - * @return id - */ - public Long getId() { - return id; - } - - /** - * @param id - */ - public void setId(Long id) { - this.id = id; - } - - /** - * @return expires_in - */ - public Date getExpiresIn() { - return expiresIn; - } - - /** - * @param expiresIn - */ - public void setExpiresIn(Date expiresIn) { - this.expiresIn = expiresIn; - } - - /** - * @return secret_key - */ - public String getSecretKey() { - return secretKey; - } - - /** - * @param secretKey - */ - public void setSecretKey(String secretKey) { - this.secretKey = secretKey; - } - - /** - * @return user_id - */ - public Long getUserId() { - return userId; - } - - /** - * @param userId - */ - public void setUserId(Long userId) { - this.userId = userId; - } - - /** - * @return valid - */ - public Boolean getValid() { - return valid; - } - - /** - * @param valid - */ - public void setValid(Boolean valid) { - this.valid = valid; - } } \ No newline at end of file diff --git a/src/main/java/com/simon/model/VeriCode.java b/src/main/java/com/simon/model/VeriCode.java index a01e603e637c0c3f28bf3fb5bf2a4b82fd996c05..7666c499d056d9dc52975093919693536a7fc880 100644 --- a/src/main/java/com/simon/model/VeriCode.java +++ b/src/main/java/com/simon/model/VeriCode.java @@ -1,95 +1,45 @@ package com.simon.model; +import com.simon.common.utils.SnowflakeGenId; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; import org.hibernate.annotations.GenericGenerator; +import tk.mybatis.mapper.annotation.KeySql; import javax.persistence.*; import java.io.Serializable; +/** +* @author SimonSun +* @create 2018-08-17 23:33:01 +**/ +@ApiModel(description = "VeriCode") +@Data @Entity -@Table(name = "veri_code") -public class VeriCode implements Serializable { - private static final long serialVersionUID = -4954084806431911715L; +@Table(name="veri_code") +public class VeriCode implements Serializable{ + private static final long serialVersionUID = 1L; + @Id + @KeySql(genId = SnowflakeGenId.class) @GeneratedValue(generator = "sequenceId") @GenericGenerator(name = "sequenceId", strategy = "com.simon.common.utils.snowflake.SequenceId") private Long id; + @ApiModelProperty(value = "code") + @Column(name = "code") private Integer code; + @ApiModelProperty(value = "create_time") @Column(name = "create_time") private Long createTime; + @ApiModelProperty(value = "expires") + @Column(name = "expires") private Integer expires; + @ApiModelProperty(value = "phone") + @Column(name = "phone") private String phone; - - /** - * @return id - */ - public Long getId() { - return id; - } - - /** - * @param id - */ - public void setId(Long id) { - this.id = id; - } - - /** - * @return code - */ - public Integer getCode() { - return code; - } - - /** - * @param code - */ - public void setCode(Integer code) { - this.code = code; - } - - /** - * @return create_time - */ - public Long getCreateTime() { - return createTime; - } - - /** - * @param createTime - */ - public void setCreateTime(Long createTime) { - this.createTime = createTime; - } - - /** - * @return expires - */ - public Integer getExpires() { - return expires; - } - - /** - * @param expires - */ - public void setExpires(Integer expires) { - this.expires = expires; - } - - /** - * @return phone - */ - public String getPhone() { - return phone; - } - - /** - * @param phone - */ - public void setPhone(String phone) { - this.phone = phone; - } } \ No newline at end of file diff --git a/src/main/resources/code-gen.properties b/src/main/resources/code-gen.properties index 2809af24e2109a0683543fa6a3bc7825f873aee8..aadffc7c96d0f64bb7f0d3d31910ea02efb3e28d 100644 --- a/src/main/resources/code-gen.properties +++ b/src/main/resources/code-gen.properties @@ -1,15 +1,15 @@ # # MySQL -jdbc_url=jdbc:mysql://127.0.0.1:3306/thymelte?useUnicode=true&characterEncoding=utf-8&useSSL=false -jdbc_username=root -jdbc_password=19941017 -jdbc_driver_class_name=com.mysql.jdbc.Driver +#jdbc_url=jdbc:mysql://127.0.0.1:3306/thymelte?useUnicode=true&characterEncoding=utf-8&useSSL=false +#jdbc_username=root +#jdbc_password=19941017 +#jdbc_driver_class_name=com.mysql.jdbc.Driver # PostgreSQL -#jdbc_url=jdbc:postgresql://127.0.0.1:5432/thymelte?useUnicode=true&characterEncoding=UTF-8 -#jdbc_username=postgres -#jdbc_password=19961120 -#jdbc_driver_class_name=org.postgresql.Driver +jdbc_url=jdbc:postgresql://127.0.0.1:5432/thymelte?useUnicode=true&characterEncoding=UTF-8 +jdbc_username=postgres +jdbc_password=19961120 +jdbc_driver_class_name=org.postgresql.Driver # Oracle #jdbc_url=jdbc:oracle:thin:@localhost:1521:orcl @@ -20,12 +20,12 @@ jdbc_driver_class_name=com.mysql.jdbc.Driver # ߣɵĴ@authorע author=SimonSun # ɵjavaļ洢· -java_path=/src/test/java +java_path=/src/main/java # ɵԴļ洢· -resources_path=/src/test/resources +resources_path=/src/main/resources # ĿƣԼĿ޸ base_package=com.simon # Mapperӿڵȫ޶(ڶᵽĺļ̳нӿMapper) mapper_interface_reference=com.simon.common.mapper.MyMapper # Ҫɵģ飬ѡֵmodelAndMapper,repository,service,controllerָmodelAndMapper,repository,service -gen_modules=modelAndMapper,repository,service \ No newline at end of file +gen_modules=modelAndMapper \ No newline at end of file diff --git a/src/main/resources/generator/generatorConfig.xml b/src/main/resources/generator/generatorConfig.xml deleted file mode 100644 index 3e021c7cbc673bc92f6ea567b76eeb53efadd72c..0000000000000000000000000000000000000000 --- a/src/main/resources/generator/generatorConfig.xml +++ /dev/null @@ -1,141 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/main/resources/qiniu.properties b/src/main/resources/qiniu.properties new file mode 100644 index 0000000000000000000000000000000000000000..17978ea6a19dd129e76f31a8998b6a82b5c917c1 --- /dev/null +++ b/src/main/resources/qiniu.properties @@ -0,0 +1,10 @@ +# ţ +qiniu.access-key=accessKey +qiniu.secret-key=secretKey +qiniu.bucket=Ĵ洢ռ +# [{'zone0':''}, {'zone1':''},{'zone2':''},{'zoneNa0':''},{'zoneAs0':''}] +qiniu.zone=zone0 +qiniu.domain-of-bucket=Ĭ +# ӹʱ䣬λ룬36001Сʱ-1 +qiniu.expire-in-seconds=-1 + diff --git a/src/main/resources/templates/code/entity.ftl b/src/main/resources/templates/code/entity.ftl index 8f7a7fdd9fc617e4fe0333d8f438ef762e4c82bd..be446f4468af2e7868781c89ac14459f43765700 100644 --- a/src/main/resources/templates/code/entity.ftl +++ b/src/main/resources/templates/code/entity.ftl @@ -1,8 +1,11 @@ package ${entityPackage}; +import com.simon.common.utils.UUIdGenId; +import com.simon.common.utils.SnowflakeGenId; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import org.hibernate.annotations.GenericGenerator; +import tk.mybatis.mapper.annotation.KeySql; import lombok.Data; import javax.persistence.*; diff --git a/src/test/java/com/simon/OauthserverApplicationTests.java b/src/test/java/com/simon/OauthserverApplicationTests.java index 41b48bac888807df5e6ce062a689a6d6eaf6eba8..35cf44904eef8d630216630188c743c23a322583 100644 --- a/src/test/java/com/simon/OauthserverApplicationTests.java +++ b/src/test/java/com/simon/OauthserverApplicationTests.java @@ -1,5 +1,7 @@ package com.simon; +import com.simon.mapper.LogLoginMapper; +import com.simon.model.LogLogin; import lombok.extern.slf4j.Slf4j; import org.junit.Test; import org.junit.runner.RunWith; @@ -12,6 +14,8 @@ import java.sql.Connection; import java.sql.DatabaseMetaData; import java.sql.ResultSet; import java.sql.SQLException; +import java.util.Date; + @Slf4j @RunWith(SpringRunner.class) @@ -21,6 +25,9 @@ public class OauthserverApplicationTests { @Autowired private JdbcTemplate jdbcTemplate; + @Autowired + private LogLoginMapper logLoginMapper; + @Test public void contextLoads() { } @@ -91,4 +98,14 @@ public class OauthserverApplicationTests { //System.out.println(); } + + @Test + public void logLoginMapperTest(){ + LogLogin logLogin = new LogLogin(); + logLogin.setIp("127.0.0.1"); + logLogin.setCreateTime(new Date()); + logLogin.setUsername("simon"); + logLoginMapper.insert(logLogin); + System.out.println(logLogin.getId()); + } }