diff --git a/pom.xml b/pom.xml index b619a639..dde1866c 100644 --- a/pom.xml +++ b/pom.xml @@ -11,41 +11,37 @@ org.springframework.boot spring-boot-starter-parent - 2.6.6 + 3.3.9 UTF-8 UTF-8 - 1.8 - 3.3.1 - 8.0.28 + 17 + 3.5.9 + 8.0.33 4.0 11.2.0.3 - 1.2.1 + 1.2.18 2.3.0 2.6 1.2.2 2.5 1.10 1.10 - 1.9.0 - 0.7.0 0.0.9 7.2.23 3.10.2 4.4 - 2.7.0 2.9.9 2.8.5 1.2.79 5.7.22 - 1.18.4 + 1.18.24 0.5.10 1.9.4 - - + 1.0.0 /work/renren @@ -55,7 +51,53 @@ 123456 + + + + org.springframework.ai + spring-ai-bom + ${spring-ai.version} + pom + import + + + + + + org.springframework.ai + spring-ai-starter-model-openai + + + + + + + com.google.guava + guava + 32.0.1-android + + + org.springdoc + springdoc-openapi-starter-webmvc-ui + 2.6.0 + + + org.springframework.plugin + spring-plugin-core + 3.0.0 + + + + org.springframework + spring-core + + + commons-logging + commons-logging + + + ws.schild @@ -144,7 +186,7 @@ com.baomidou - mybatis-plus-boot-starter + mybatis-plus-spring-boot3-starter ${mybatisplus.version} @@ -153,7 +195,12 @@ - + + + com.baomidou + mybatis-plus-jsqlparser + ${mybatisplus.version} + mysql mysql-connector-java @@ -163,7 +210,7 @@ org.redisson redisson - 3.12.5 + 3.22.0 @@ -275,14 +322,6 @@ org.postgresql postgresql - - - - - org.apache.httpcomponents - httpclient - - com.alibaba druid-spring-boot-starter @@ -324,41 +363,63 @@ commons-configuration ${commons.configuration.version} + + org.apache.shiro + shiro-spring + jakarta + 1.12.0 + + + + org.apache.shiro + shiro-core + + + org.apache.shiro + shiro-web + + + + org.apache.shiro shiro-core - ${shiro.version} + jakarta + 1.12.0 org.apache.shiro - shiro-spring - ${shiro.version} + shiro-web + jakarta + 1.12.0 + + + org.apache.shiro + shiro-core + + + + + + com.auth0 + java-jwt + 4.4.0 io.jsonwebtoken jjwt - ${jwt.version} + 0.12.1 com.github.axet kaptcha ${kaptcha.version} - - io.springfox - springfox-swagger2 - ${swagger.version} - com.aliyun vod20170321 2.20.0 - - io.springfox - springfox-swagger-ui - ${swagger.version} - com.qiniu qiniu-java-sdk @@ -454,7 +515,7 @@ org.springframework.boot spring-boot-maven-plugin - true + @@ -544,6 +605,25 @@ com.e-iceblue https://repo.e-iceblue.cn/repository/maven-public/ + + spring-snapshots + Spring Snapshots + https://repo.spring.io/snapshot + + false + + + + Central Portal Snapshots + central-portal-snapshots + https://central.sonatype.com/repository/maven-snapshots/ + + false + + + true + + diff --git a/src/main/java/com/baidu/ueditor/ActionEnter.java b/src/main/java/com/baidu/ueditor/ActionEnter.java deleted file mode 100644 index 33a3dc7b..00000000 --- a/src/main/java/com/baidu/ueditor/ActionEnter.java +++ /dev/null @@ -1,127 +0,0 @@ -package com.baidu.ueditor; - -import java.util.Map; - -import javax.servlet.http.HttpServletRequest; - -import com.baidu.ueditor.define.ActionMap; -import com.baidu.ueditor.define.AppInfo; -import com.baidu.ueditor.define.BaseState; -import com.baidu.ueditor.define.State; -import com.baidu.ueditor.hunter.FileManager; -import com.baidu.ueditor.hunter.ImageHunter; -import com.baidu.ueditor.upload.Uploader; - -public class ActionEnter { - - private HttpServletRequest request = null; - - private String rootPath = null; - private String contextPath = null; - - private String actionType = null; - - private ConfigManager configManager = null; - - public ActionEnter ( HttpServletRequest request, String rootPath ) { - - this.request = request; - this.rootPath = rootPath; - this.actionType = request.getParameter( "action" ); - this.contextPath = request.getContextPath(); - this.configManager = ConfigManager.getInstance( this.rootPath, this.contextPath, request.getRequestURI() ); - - } - - public String exec () { - - String callbackName = this.request.getParameter("callback"); - - if ( callbackName != null ) { - - if ( !validCallbackName( callbackName ) ) { - return new BaseState( false, AppInfo.ILLEGAL ).toJSONString(); - } - - return callbackName+"("+this.invoke()+");"; - - } else { - return this.invoke(); - } - - } - - public String invoke() { - - if ( actionType == null || !ActionMap.mapping.containsKey( actionType ) ) { - return new BaseState( false, AppInfo.INVALID_ACTION ).toJSONString(); - } - - if ( this.configManager == null || !this.configManager.valid() ) { - return new BaseState( false, AppInfo.CONFIG_ERROR ).toJSONString(); - } - - State state = null; - - int actionCode = ActionMap.getType( this.actionType ); - - Map conf = null; - - switch ( actionCode ) { - - case ActionMap.CONFIG: - return this.configManager.getAllConfig().toString(); - - case ActionMap.UPLOAD_IMAGE: - case ActionMap.UPLOAD_SCRAWL: - case ActionMap.UPLOAD_VIDEO: - case ActionMap.UPLOAD_FILE: - conf = this.configManager.getConfig( actionCode ); - state = new Uploader( request, conf ).doExec(); - break; - - case ActionMap.CATCH_IMAGE: - conf = configManager.getConfig( actionCode ); - String[] list = this.request.getParameterValues( (String)conf.get( "fieldName" ) ); - state = new ImageHunter( conf ).capture( list ); - break; - - case ActionMap.LIST_IMAGE: - case ActionMap.LIST_FILE: - conf = configManager.getConfig( actionCode ); - int start = this.getStartIndex(); - state = new FileManager( conf ).listFile( start ); - break; - - } - - return state.toJSONString(); - - } - - public int getStartIndex () { - - String start = this.request.getParameter( "start" ); - - try { - return Integer.parseInt( start ); - } catch ( Exception e ) { - return 0; - } - - } - - /** - * callback参数验证 - */ - public boolean validCallbackName ( String name ) { - - if ( name.matches( "^[a-zA-Z_]+[\\w0-9_]*$" ) ) { - return true; - } - - return false; - - } - -} \ No newline at end of file diff --git a/src/main/java/com/baidu/ueditor/ConfigManager.java b/src/main/java/com/baidu/ueditor/ConfigManager.java deleted file mode 100644 index a444dd2a..00000000 --- a/src/main/java/com/baidu/ueditor/ConfigManager.java +++ /dev/null @@ -1,230 +0,0 @@ -package com.baidu.ueditor; - -import java.io.BufferedReader; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.io.InputStreamReader; -import java.io.UnsupportedEncodingException; -import java.net.URISyntaxException; -import java.util.HashMap; -import java.util.Map; - -import org.json.JSONArray; -import org.json.JSONObject; - -import com.baidu.ueditor.define.ActionMap; - -/** - * 配置管理器 - * @author hancong03@baidu.com - * - */ -public final class ConfigManager { - - private final String rootPath; - private final String originalPath; - private final String contextPath; - private static final String configFileName = "uedit-config.json"; - private String parentPath = null; - private JSONObject jsonConfig = null; - // 涂鸦上传filename定义 - private final static String SCRAWL_FILE_NAME = "scrawl"; - // 远程图片抓取filename定义 - private final static String REMOTE_FILE_NAME = "remote"; - - /* - * 通过一个给定的路径构建一个配置管理器, 该管理器要求地址路径所在目录下必须存在config.properties文件 - */ - private ConfigManager ( String rootPath, String contextPath, String uri ) throws FileNotFoundException, IOException { - - rootPath = rootPath.replace( "\\", "/" ); - - this.rootPath = rootPath; - this.contextPath = contextPath; - - if ( contextPath.length() > 0 ) { - this.originalPath = this.rootPath + uri.substring( contextPath.length() ); - } else { - this.originalPath = this.rootPath + uri; - } - - this.initEnv(); - - } - - /** - * 配置管理器构造工厂 - * @param rootPath 服务器根路径 - * @param contextPath 服务器所在项目路径 - * @param uri 当前访问的uri - * @return 配置管理器实例或者null - */ - public static ConfigManager getInstance ( String rootPath, String contextPath, String uri ) { - - try { - return new ConfigManager(rootPath, contextPath, uri); - } catch ( Exception e ) { - return null; - } - - } - - // 验证配置文件加载是否正确 - public boolean valid () { - return this.jsonConfig != null; - } - - public JSONObject getAllConfig () { - - return this.jsonConfig; - - } - - public Map getConfig ( int type ) { - - Map conf = new HashMap(); - String savePath = null; - - switch ( type ) { - - case ActionMap.UPLOAD_FILE: - conf.put( "isBase64", "false" ); - conf.put( "maxSize", this.jsonConfig.getLong( "fileMaxSize" ) ); - conf.put( "allowFiles", this.getArray( "fileAllowFiles" ) ); - conf.put( "fieldName", this.jsonConfig.getString( "fileFieldName" ) ); - savePath = this.jsonConfig.getString( "filePathFormat" ); - break; - - case ActionMap.UPLOAD_IMAGE: - conf.put( "isBase64", "false" ); - conf.put( "maxSize", this.jsonConfig.getLong( "imageMaxSize" ) ); - conf.put( "allowFiles", this.getArray( "imageAllowFiles" ) ); - conf.put( "fieldName", this.jsonConfig.getString( "imageFieldName" ) ); - savePath = this.jsonConfig.getString( "imagePathFormat" ); - break; - - case ActionMap.UPLOAD_VIDEO: - conf.put( "maxSize", this.jsonConfig.getLong( "videoMaxSize" ) ); - conf.put( "allowFiles", this.getArray( "videoAllowFiles" ) ); - conf.put( "fieldName", this.jsonConfig.getString( "videoFieldName" ) ); - savePath = this.jsonConfig.getString( "videoPathFormat" ); - break; - - case ActionMap.UPLOAD_SCRAWL: - conf.put( "filename", ConfigManager.SCRAWL_FILE_NAME ); - conf.put( "maxSize", this.jsonConfig.getLong( "scrawlMaxSize" ) ); - conf.put( "fieldName", this.jsonConfig.getString( "scrawlFieldName" ) ); - conf.put( "isBase64", "true" ); - savePath = this.jsonConfig.getString( "scrawlPathFormat" ); - break; - - case ActionMap.CATCH_IMAGE: - conf.put( "filename", ConfigManager.REMOTE_FILE_NAME ); - conf.put( "filter", this.getArray( "catcherLocalDomain" ) ); - conf.put( "maxSize", this.jsonConfig.getLong( "catcherMaxSize" ) ); - conf.put( "allowFiles", this.getArray( "catcherAllowFiles" ) ); - conf.put( "fieldName", this.jsonConfig.getString( "catcherFieldName" ) + "[]" ); - savePath = this.jsonConfig.getString( "catcherPathFormat" ); - break; - - case ActionMap.LIST_IMAGE: - conf.put( "allowFiles", this.getArray( "imageManagerAllowFiles" ) ); - conf.put( "dir", this.jsonConfig.getString( "imageManagerListPath" ) ); - conf.put( "count", this.jsonConfig.getInt( "imageManagerListSize" ) ); - break; - - case ActionMap.LIST_FILE: - conf.put( "allowFiles", this.getArray( "fileManagerAllowFiles" ) ); - conf.put( "dir", this.jsonConfig.getString( "fileManagerListPath" ) ); - conf.put( "count", this.jsonConfig.getInt( "fileManagerListSize" ) ); - break; - - } - - conf.put( "savePath", savePath ); - conf.put( "rootPath", this.rootPath ); - - return conf; - - } - - private void initEnv () throws FileNotFoundException, IOException { - - File file = new File( this.originalPath ); - - if ( !file.isAbsolute() ) { - file = new File( file.getAbsolutePath() ); - } - - this.parentPath = file.getParent(); - - String configContent = this.readFile( this.getConfigPath() ); - - try{ - JSONObject jsonConfig = new JSONObject( configContent ); - this.jsonConfig = jsonConfig; - } catch ( Exception e ) { - this.jsonConfig = null; - } - - } - - private String getConfigPath () { -// return this.parentPath + File.separator + ConfigManager.configFileName; - // 修改源码 - try{ - return this.getClass().getClassLoader().getResource("uedit-config.json").toURI().getPath(); - } catch (URISyntaxException e) { - e.printStackTrace(); - return null; - } - } - - private String[] getArray ( String key ) { - - JSONArray jsonArray = this.jsonConfig.getJSONArray( key ); - String[] result = new String[ jsonArray.length() ]; - - for ( int i = 0, len = jsonArray.length(); i < len; i++ ) { - result[i] = jsonArray.getString( i ); - } - - return result; - - } - - private String readFile ( String path ) throws IOException { - - StringBuilder builder = new StringBuilder(); - - try { - - InputStreamReader reader = new InputStreamReader( new FileInputStream( path ), "UTF-8" ); - BufferedReader bfReader = new BufferedReader( reader ); - - String tmpContent = null; - - while ( ( tmpContent = bfReader.readLine() ) != null ) { - builder.append( tmpContent ); - } - - bfReader.close(); - - } catch ( UnsupportedEncodingException e ) { - // 忽略 - } - - return this.filter( builder.toString() ); - - } - - // 过滤输入字符串, 剔除多行注释以及替换掉反斜杠 - private String filter ( String input ) { - - return input.replaceAll( "/\\*[\\s\\S]*?\\*/", "" ); - - } - -} diff --git a/src/main/java/com/baidu/ueditor/Encoder.java b/src/main/java/com/baidu/ueditor/Encoder.java deleted file mode 100644 index 00bce19b..00000000 --- a/src/main/java/com/baidu/ueditor/Encoder.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.baidu.ueditor; - -public class Encoder { - - public static String toUnicode ( String input ) { - - StringBuilder builder = new StringBuilder(); - char[] chars = input.toCharArray(); - - for ( char ch : chars ) { - - if ( ch < 256 ) { - builder.append( ch ); - } else { - builder.append( "\\u" + Integer.toHexString( ch& 0xffff ) ); - } - - } - - return builder.toString(); - - } - -} \ No newline at end of file diff --git a/src/main/java/com/baidu/ueditor/PathFormat.java b/src/main/java/com/baidu/ueditor/PathFormat.java deleted file mode 100644 index 080ea48f..00000000 --- a/src/main/java/com/baidu/ueditor/PathFormat.java +++ /dev/null @@ -1,157 +0,0 @@ -package com.baidu.ueditor; - -import java.text.SimpleDateFormat; -import java.util.Date; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -public class PathFormat { - - private static final String TIME = "time"; - private static final String FULL_YEAR = "yyyy"; - private static final String YEAR = "yy"; - private static final String MONTH = "mm"; - private static final String DAY = "dd"; - private static final String HOUR = "hh"; - private static final String MINUTE = "ii"; - private static final String SECOND = "ss"; - private static final String RAND = "rand"; - - private static Date currentDate = null; - - public static String parse ( String input ) { - - Pattern pattern = Pattern.compile( "\\{([^\\}]+)\\}", Pattern.CASE_INSENSITIVE ); - Matcher matcher = pattern.matcher(input); - - PathFormat.currentDate = new Date(); - - StringBuffer sb = new StringBuffer(); - - while ( matcher.find() ) { - - matcher.appendReplacement(sb, PathFormat.getString( matcher.group( 1 ) ) ); - - } - - matcher.appendTail(sb); - - return sb.toString(); - } - - /** - * 格式化路径, 把windows路径替换成标准路径 - * @param input 待格式化的路径 - * @return 格式化后的路径 - */ - public static String format ( String input ) { - - return input.replace( "\\", "/" ); - - } - - public static String parse ( String input, String filename ) { - - Pattern pattern = Pattern.compile( "\\{([^\\}]+)\\}", Pattern.CASE_INSENSITIVE ); - Matcher matcher = pattern.matcher(input); - String matchStr = null; - - PathFormat.currentDate = new Date(); - - StringBuffer sb = new StringBuffer(); - - while ( matcher.find() ) { - - matchStr = matcher.group( 1 ); - if ( matchStr.indexOf( "filename" ) != -1 ) { - filename = filename.replace( "$", "\\$" ).replaceAll( "[\\/:*?\"<>|]", "" ); - matcher.appendReplacement(sb, filename ); - } else { - matcher.appendReplacement(sb, PathFormat.getString( matchStr ) ); - } - - } - - matcher.appendTail(sb); - - return sb.toString(); - } - - private static String getString ( String pattern ) { - - pattern = pattern.toLowerCase(); - - // time 处理 - if ( pattern.indexOf( PathFormat.TIME ) != -1 ) { - return PathFormat.getTimestamp(); - } else if ( pattern.indexOf( PathFormat.FULL_YEAR ) != -1 ) { - return PathFormat.getFullYear(); - } else if ( pattern.indexOf( PathFormat.YEAR ) != -1 ) { - return PathFormat.getYear(); - } else if ( pattern.indexOf( PathFormat.MONTH ) != -1 ) { - return PathFormat.getMonth(); - } else if ( pattern.indexOf( PathFormat.DAY ) != -1 ) { - return PathFormat.getDay(); - } else if ( pattern.indexOf( PathFormat.HOUR ) != -1 ) { - return PathFormat.getHour(); - } else if ( pattern.indexOf( PathFormat.MINUTE ) != -1 ) { - return PathFormat.getMinute(); - } else if ( pattern.indexOf( PathFormat.SECOND ) != -1 ) { - return PathFormat.getSecond(); - } else if ( pattern.indexOf( PathFormat.RAND ) != -1 ) { - return PathFormat.getRandom( pattern ); - } - - return pattern; - - } - - private static String getTimestamp () { - return System.currentTimeMillis() + ""; - } - - private static String getFullYear () { - return new SimpleDateFormat( "yyyy" ).format( PathFormat.currentDate ); - } - - private static String getYear () { - return new SimpleDateFormat( "yy" ).format( PathFormat.currentDate ); - } - - private static String getMonth () { - return new SimpleDateFormat( "MM" ).format( PathFormat.currentDate ); - } - - private static String getDay () { - return new SimpleDateFormat( "dd" ).format( PathFormat.currentDate ); - } - - private static String getHour () { - return new SimpleDateFormat( "HH" ).format( PathFormat.currentDate ); - } - - private static String getMinute () { - return new SimpleDateFormat( "mm" ).format( PathFormat.currentDate ); - } - - private static String getSecond () { - return new SimpleDateFormat( "ss" ).format( PathFormat.currentDate ); - } - - private static String getRandom ( String pattern ) { - - int length = 0; - pattern = pattern.split( ":" )[ 1 ].trim(); - - length = Integer.parseInt( pattern ); - - return ( Math.random() + "" ).replace( ".", "" ).substring( 0, length ); - - } - - public static void main(String[] args) { - // TODO Auto-generated method stub - - } - -} diff --git a/src/main/java/com/baidu/ueditor/define/ActionMap.java b/src/main/java/com/baidu/ueditor/define/ActionMap.java deleted file mode 100644 index 88f4f324..00000000 --- a/src/main/java/com/baidu/ueditor/define/ActionMap.java +++ /dev/null @@ -1,42 +0,0 @@ -package com.baidu.ueditor.define; - -import java.util.Map; -import java.util.HashMap; - -/** - * 定义请求action类型 - * @author hancong03@baidu.com - * - */ -@SuppressWarnings("serial") -public final class ActionMap { - - public static final Map mapping; - // 获取配置请求 - public static final int CONFIG = 0; - public static final int UPLOAD_IMAGE = 1; - public static final int UPLOAD_SCRAWL = 2; - public static final int UPLOAD_VIDEO = 3; - public static final int UPLOAD_FILE = 4; - public static final int CATCH_IMAGE = 5; - public static final int LIST_FILE = 6; - public static final int LIST_IMAGE = 7; - - static { - mapping = new HashMap(){{ - put( "config", ActionMap.CONFIG ); - put( "uploadimage", ActionMap.UPLOAD_IMAGE ); - put( "uploadscrawl", ActionMap.UPLOAD_SCRAWL ); - put( "uploadvideo", ActionMap.UPLOAD_VIDEO ); - put( "uploadfile", ActionMap.UPLOAD_FILE ); - put( "catchimage", ActionMap.CATCH_IMAGE ); - put( "listfile", ActionMap.LIST_FILE ); - put( "listimage", ActionMap.LIST_IMAGE ); - }}; - } - - public static int getType ( String key ) { - return ActionMap.mapping.get( key ); - } - -} diff --git a/src/main/java/com/baidu/ueditor/define/ActionState.java b/src/main/java/com/baidu/ueditor/define/ActionState.java deleted file mode 100644 index b0fad34f..00000000 --- a/src/main/java/com/baidu/ueditor/define/ActionState.java +++ /dev/null @@ -1,5 +0,0 @@ -package com.baidu.ueditor.define; - -public enum ActionState { - UNKNOW_ERROR -} diff --git a/src/main/java/com/baidu/ueditor/define/AppInfo.java b/src/main/java/com/baidu/ueditor/define/AppInfo.java deleted file mode 100644 index b869f2aa..00000000 --- a/src/main/java/com/baidu/ueditor/define/AppInfo.java +++ /dev/null @@ -1,77 +0,0 @@ -package com.baidu.ueditor.define; - -import java.util.HashMap; -import java.util.Map; - -public final class AppInfo { - - public static final int SUCCESS = 0; - public static final int MAX_SIZE = 1; - public static final int PERMISSION_DENIED = 2; - public static final int FAILED_CREATE_FILE = 3; - public static final int IO_ERROR = 4; - public static final int NOT_MULTIPART_CONTENT = 5; - public static final int PARSE_REQUEST_ERROR = 6; - public static final int NOTFOUND_UPLOAD_DATA = 7; - public static final int NOT_ALLOW_FILE_TYPE = 8; - - public static final int INVALID_ACTION = 101; - public static final int CONFIG_ERROR = 102; - - public static final int PREVENT_HOST = 201; - public static final int CONNECTION_ERROR = 202; - public static final int REMOTE_FAIL = 203; - - public static final int NOT_DIRECTORY = 301; - public static final int NOT_EXIST = 302; - - public static final int ILLEGAL = 401; - - public static Map info = new HashMap(){{ - - put( AppInfo.SUCCESS, "SUCCESS" ); - - // 无效的Action - put( AppInfo.INVALID_ACTION, "\u65E0\u6548\u7684Action" ); - // 配置文件初始化失败 - put( AppInfo.CONFIG_ERROR, "\u914D\u7F6E\u6587\u4EF6\u521D\u59CB\u5316\u5931\u8D25" ); - // 抓取远程图片失败 - put( AppInfo.REMOTE_FAIL, "\u6293\u53D6\u8FDC\u7A0B\u56FE\u7247\u5931\u8D25" ); - - // 被阻止的远程主机 - put( AppInfo.PREVENT_HOST, "\u88AB\u963B\u6B62\u7684\u8FDC\u7A0B\u4E3B\u673A" ); - // 远程连接出错 - put( AppInfo.CONNECTION_ERROR, "\u8FDC\u7A0B\u8FDE\u63A5\u51FA\u9519" ); - - // "文件大小超出限制" - put( AppInfo.MAX_SIZE, "\u6587\u4ef6\u5927\u5c0f\u8d85\u51fa\u9650\u5236" ); - // 权限不足, 多指写权限 - put( AppInfo.PERMISSION_DENIED, "\u6743\u9650\u4E0D\u8DB3" ); - // 创建文件失败 - put( AppInfo.FAILED_CREATE_FILE, "\u521B\u5EFA\u6587\u4EF6\u5931\u8D25" ); - // IO错误 - put( AppInfo.IO_ERROR, "IO\u9519\u8BEF" ); - // 上传表单不是multipart/form-data类型 - put( AppInfo.NOT_MULTIPART_CONTENT, "\u4E0A\u4F20\u8868\u5355\u4E0D\u662Fmultipart/form-data\u7C7B\u578B" ); - // 解析上传表单错误 - put( AppInfo.PARSE_REQUEST_ERROR, "\u89E3\u6790\u4E0A\u4F20\u8868\u5355\u9519\u8BEF" ); - // 未找到上传数据 - put( AppInfo.NOTFOUND_UPLOAD_DATA, "\u672A\u627E\u5230\u4E0A\u4F20\u6570\u636E" ); - // 不允许的文件类型 - put( AppInfo.NOT_ALLOW_FILE_TYPE, "\u4E0D\u5141\u8BB8\u7684\u6587\u4EF6\u7C7B\u578B" ); - - // 指定路径不是目录 - put( AppInfo.NOT_DIRECTORY, "\u6307\u5B9A\u8DEF\u5F84\u4E0D\u662F\u76EE\u5F55" ); - // 指定路径并不存在 - put( AppInfo.NOT_EXIST, "\u6307\u5B9A\u8DEF\u5F84\u5E76\u4E0D\u5B58\u5728" ); - - // callback参数名不合法 - put( AppInfo.ILLEGAL, "Callback\u53C2\u6570\u540D\u4E0D\u5408\u6CD5" ); - - }}; - - public static String getStateInfo ( int key ) { - return AppInfo.info.get( key ); - } - -} diff --git a/src/main/java/com/baidu/ueditor/define/BaseState.java b/src/main/java/com/baidu/ueditor/define/BaseState.java deleted file mode 100644 index dcc881b1..00000000 --- a/src/main/java/com/baidu/ueditor/define/BaseState.java +++ /dev/null @@ -1,90 +0,0 @@ -package com.baidu.ueditor.define; - -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; - -import com.baidu.ueditor.Encoder; - -public class BaseState implements State { - - private boolean state = false; - private String info = null; - - private Map infoMap = new HashMap(); - - public BaseState () { - this.state = true; - } - - public BaseState ( boolean state ) { - this.setState( state ); - } - - public BaseState ( boolean state, String info ) { - this.setState( state ); - this.info = info; - } - - public BaseState ( boolean state, int infoCode ) { - this.setState( state ); - this.info = AppInfo.getStateInfo( infoCode ); - } - - public boolean isSuccess () { - return this.state; - } - - public void setState ( boolean state ) { - this.state = state; - } - - public void setInfo ( String info ) { - this.info = info; - } - - public void setInfo ( int infoCode ) { - this.info = AppInfo.getStateInfo( infoCode ); - } - - @Override - public String toJSONString() { - return this.toString(); - } - - public String toString () { - - String key = null; - String stateVal = this.isSuccess() ? AppInfo.getStateInfo( AppInfo.SUCCESS ) : this.info; - - StringBuilder builder = new StringBuilder(); - - builder.append( "{\"state\": \"" + stateVal + "\"" ); - - Iterator iterator = this.infoMap.keySet().iterator(); - - while ( iterator.hasNext() ) { - - key = iterator.next(); - - builder.append( ",\"" + key + "\": \"" + this.infoMap.get(key) + "\"" ); - - } - - builder.append( "}" ); - - return Encoder.toUnicode( builder.toString() ); - - } - - @Override - public void putInfo(String name, String val) { - this.infoMap.put(name, val); - } - - @Override - public void putInfo(String name, long val) { - this.putInfo(name, val+""); - } - -} diff --git a/src/main/java/com/baidu/ueditor/define/FileType.java b/src/main/java/com/baidu/ueditor/define/FileType.java deleted file mode 100644 index 9195b85b..00000000 --- a/src/main/java/com/baidu/ueditor/define/FileType.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.baidu.ueditor.define; - -import java.util.HashMap; -import java.util.Map; - -public class FileType { - - public static final String JPG = "JPG"; - - private static final Map types = new HashMap(){{ - - put( FileType.JPG, ".jpg" ); - - }}; - - public static String getSuffix ( String key ) { - return FileType.types.get( key ); - } - - /** - * 根据给定的文件名,获取其后缀信息 - * @param filename - * @return - */ - public static String getSuffixByFilename ( String filename ) { - - return filename.substring( filename.lastIndexOf( "." ) ).toLowerCase(); - - } - -} diff --git a/src/main/java/com/baidu/ueditor/define/MIMEType.java b/src/main/java/com/baidu/ueditor/define/MIMEType.java deleted file mode 100644 index 77c6cddf..00000000 --- a/src/main/java/com/baidu/ueditor/define/MIMEType.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.baidu.ueditor.define; - -import java.util.HashMap; -import java.util.Map; - -public class MIMEType { - - public static final Map types = new HashMap(){{ - put( "image/gif", ".gif" ); - put( "image/jpeg", ".jpg" ); - put( "image/jpg", ".jpg" ); - put( "image/png", ".png" ); - put( "image/bmp", ".bmp" ); - }}; - - public static String getSuffix ( String mime ) { - return MIMEType.types.get( mime ); - } - -} diff --git a/src/main/java/com/baidu/ueditor/define/MultiState.java b/src/main/java/com/baidu/ueditor/define/MultiState.java deleted file mode 100644 index 26caefb7..00000000 --- a/src/main/java/com/baidu/ueditor/define/MultiState.java +++ /dev/null @@ -1,112 +0,0 @@ -package com.baidu.ueditor.define; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; - -import com.baidu.ueditor.Encoder; - -/** - * 多状态集合状态 - * 其包含了多个状态的集合, 其本身自己也是一个状态 - * @author hancong03@baidu.com - * - */ -public class MultiState implements State { - - private boolean state = false; - private String info = null; - private Map intMap = new HashMap(); - private Map infoMap = new HashMap(); - private List stateList = new ArrayList(); - - public MultiState ( boolean state ) { - this.state = state; - } - - public MultiState ( boolean state, String info ) { - this.state = state; - this.info = info; - } - - public MultiState ( boolean state, int infoKey ) { - this.state = state; - this.info = AppInfo.getStateInfo( infoKey ); - } - - @Override - public boolean isSuccess() { - return this.state; - } - - public void addState ( State state ) { - stateList.add( state.toJSONString() ); - } - - /** - * 该方法调用无效果 - */ - @Override - public void putInfo(String name, String val) { - this.infoMap.put(name, val); - } - - @Override - public String toJSONString() { - - String stateVal = this.isSuccess() ? AppInfo.getStateInfo( AppInfo.SUCCESS ) : this.info; - - StringBuilder builder = new StringBuilder(); - - builder.append( "{\"state\": \"" + stateVal + "\"" ); - - // 数字转换 - Iterator iterator = this.intMap.keySet().iterator(); - - while ( iterator.hasNext() ) { - - stateVal = iterator.next(); - - builder.append( ",\""+ stateVal +"\": " + this.intMap.get( stateVal ) ); - - } - - iterator = this.infoMap.keySet().iterator(); - - while ( iterator.hasNext() ) { - - stateVal = iterator.next(); - - builder.append( ",\""+ stateVal +"\": \"" + this.infoMap.get( stateVal ) + "\"" ); - - } - - builder.append( ", list: [" ); - - - iterator = this.stateList.iterator(); - - while ( iterator.hasNext() ) { - - builder.append( iterator.next() + "," ); - - } - - if ( this.stateList.size() > 0 ) { - builder.deleteCharAt( builder.length() - 1 ); - } - - builder.append( " ]}" ); - - return Encoder.toUnicode( builder.toString() ); - - } - - @Override - public void putInfo(String name, long val) { - this.intMap.put( name, val ); - } - -} diff --git a/src/main/java/com/baidu/ueditor/define/State.java b/src/main/java/com/baidu/ueditor/define/State.java deleted file mode 100644 index 7addad6e..00000000 --- a/src/main/java/com/baidu/ueditor/define/State.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.baidu.ueditor.define; - -/** - * 处理状态接口 - * @author hancong03@baidu.com - * - */ -public interface State { - - public boolean isSuccess(); - - public void putInfo(String name, String val); - - public void putInfo(String name, long val); - - public String toJSONString(); - -} diff --git a/src/main/java/com/baidu/ueditor/hunter/FileManager.java b/src/main/java/com/baidu/ueditor/hunter/FileManager.java deleted file mode 100644 index 5a8c1a05..00000000 --- a/src/main/java/com/baidu/ueditor/hunter/FileManager.java +++ /dev/null @@ -1,112 +0,0 @@ -package com.baidu.ueditor.hunter; - -import java.io.File; -import java.util.Arrays; -import java.util.Collection; -import java.util.Map; - -import org.apache.commons.io.FileUtils; - -import com.baidu.ueditor.PathFormat; -import com.baidu.ueditor.define.AppInfo; -import com.baidu.ueditor.define.BaseState; -import com.baidu.ueditor.define.MultiState; -import com.baidu.ueditor.define.State; - -public class FileManager { - - private String dir = null; - private String rootPath = null; - private String[] allowFiles = null; - private int count = 0; - - public FileManager ( Map conf ) { - - this.rootPath = (String)conf.get( "rootPath" ); - this.dir = this.rootPath + (String)conf.get( "dir" ); - this.allowFiles = this.getAllowFiles( conf.get("allowFiles") ); - this.count = (Integer)conf.get( "count" ); - - } - - public State listFile ( int index ) { - - File dir = new File( this.dir ); - State state = null; - - if ( !dir.exists() ) { - return new BaseState( false, AppInfo.NOT_EXIST ); - } - - if ( !dir.isDirectory() ) { - return new BaseState( false, AppInfo.NOT_DIRECTORY ); - } - - Collection list = FileUtils.listFiles( dir, this.allowFiles, true ); - - if ( index < 0 || index > list.size() ) { - state = new MultiState( true ); - } else { - Object[] fileList = Arrays.copyOfRange( list.toArray(), index, index + this.count ); - state = this.getState( fileList ); - } - - state.putInfo( "start", index ); - state.putInfo( "total", list.size() ); - - return state; - - } - - private State getState ( Object[] files ) { - - MultiState state = new MultiState( true ); - BaseState fileState = null; - - File file = null; - - for ( Object obj : files ) { - if ( obj == null ) { - break; - } - file = (File)obj; - fileState = new BaseState( true ); - fileState.putInfo( "url", PathFormat.format( this.getPath( file ) ) ); - state.addState( fileState ); - } - - return state; - - } - - private String getPath ( File file ) { - - String path = file.getAbsolutePath(); - - return path.replace( this.rootPath, "/" ); - - } - - private String[] getAllowFiles ( Object fileExt ) { - - String[] exts = null; - String ext = null; - - if ( fileExt == null ) { - return new String[ 0 ]; - } - - exts = (String[])fileExt; - - for ( int i = 0, len = exts.length; i < len; i++ ) { - - ext = exts[ i ]; - exts[ i ] = ext.replace( ".", "" ); - - } - - return exts; - - } - -} diff --git a/src/main/java/com/baidu/ueditor/hunter/ImageHunter.java b/src/main/java/com/baidu/ueditor/hunter/ImageHunter.java deleted file mode 100644 index 265bfed4..00000000 --- a/src/main/java/com/baidu/ueditor/hunter/ImageHunter.java +++ /dev/null @@ -1,144 +0,0 @@ -package com.baidu.ueditor.hunter; - -import java.net.HttpURLConnection; -import java.net.InetAddress; -import java.net.URL; -import java.net.UnknownHostException; -import java.util.Arrays; -import java.util.List; -import java.util.Map; - -import com.baidu.ueditor.PathFormat; -import com.baidu.ueditor.define.AppInfo; -import com.baidu.ueditor.define.BaseState; -import com.baidu.ueditor.define.MIMEType; -import com.baidu.ueditor.define.MultiState; -import com.baidu.ueditor.define.State; -import com.baidu.ueditor.upload.StorageManager; - -/** - * 图片抓取器 - * @author hancong03@baidu.com - * - */ -public class ImageHunter { - - private String filename = null; - private String savePath = null; - private String rootPath = null; - private List allowTypes = null; - private long maxSize = -1; - - private List filters = null; - - public ImageHunter ( Map conf ) { - - this.filename = (String)conf.get( "filename" ); - this.savePath = (String)conf.get( "savePath" ); - this.rootPath = (String)conf.get( "rootPath" ); - this.maxSize = (Long)conf.get( "maxSize" ); - this.allowTypes = Arrays.asList( (String[])conf.get( "allowFiles" ) ); - this.filters = Arrays.asList( (String[])conf.get( "filter" ) ); - - } - - public State capture ( String[] list ) { - - MultiState state = new MultiState( true ); - - for ( String source : list ) { - state.addState( captureRemoteData( source ) ); - } - - return state; - - } - - public State captureRemoteData ( String urlStr ) { - - HttpURLConnection connection = null; - URL url = null; - String suffix = null; - - try { - url = new URL( urlStr ); - - if ( !validHost( url.getHost() ) ) { - return new BaseState( false, AppInfo.PREVENT_HOST ); - } - - connection = (HttpURLConnection) url.openConnection(); - - connection.setInstanceFollowRedirects( true ); - connection.setUseCaches( true ); - - if ( !validContentState( connection.getResponseCode() ) ) { - return new BaseState( false, AppInfo.CONNECTION_ERROR ); - } - - suffix = MIMEType.getSuffix( connection.getContentType() ); - - if ( !validFileType( suffix ) ) { - return new BaseState( false, AppInfo.NOT_ALLOW_FILE_TYPE ); - } - - if ( !validFileSize( connection.getContentLength() ) ) { - return new BaseState( false, AppInfo.MAX_SIZE ); - } - - String savePath = this.getPath( this.savePath, this.filename, suffix ); - String physicalPath = this.rootPath + savePath; - - State state = StorageManager.saveFileByInputStream( connection.getInputStream(), physicalPath ); - - if ( state.isSuccess() ) { - state.putInfo( "url", PathFormat.format( savePath ) ); - state.putInfo( "source", urlStr ); - } - - return state; - - } catch ( Exception e ) { - return new BaseState( false, AppInfo.REMOTE_FAIL ); - } - - } - - private String getPath ( String savePath, String filename, String suffix ) { - - return PathFormat.parse( savePath + suffix, filename ); - - } - - private boolean validHost ( String hostname ) { - try { - InetAddress ip = InetAddress.getByName(hostname); - - if (ip.isSiteLocalAddress()) { - return false; - } - } catch (UnknownHostException e) { - return false; - } - - return !filters.contains( hostname ); - - } - - private boolean validContentState ( int code ) { - - return HttpURLConnection.HTTP_OK == code; - - } - - private boolean validFileType ( String type ) { - - return this.allowTypes.contains( type ); - - } - - private boolean validFileSize ( int size ) { - return size < this.maxSize; - } - -} diff --git a/src/main/java/com/baidu/ueditor/upload/Base64Uploader.java b/src/main/java/com/baidu/ueditor/upload/Base64Uploader.java deleted file mode 100644 index 2f81076a..00000000 --- a/src/main/java/com/baidu/ueditor/upload/Base64Uploader.java +++ /dev/null @@ -1,52 +0,0 @@ -package com.baidu.ueditor.upload; - -import com.baidu.ueditor.PathFormat; -import com.baidu.ueditor.define.AppInfo; -import com.baidu.ueditor.define.BaseState; -import com.baidu.ueditor.define.FileType; -import com.baidu.ueditor.define.State; - -import java.util.Map; - -import org.apache.commons.codec.binary.Base64; - -public final class Base64Uploader { - - public static State save(String content, Map conf) { - - byte[] data = decode(content); - - long maxSize = ((Long) conf.get("maxSize")).longValue(); - - if (!validSize(data, maxSize)) { - return new BaseState(false, AppInfo.MAX_SIZE); - } - - String suffix = FileType.getSuffix("JPG"); - - String savePath = PathFormat.parse((String) conf.get("savePath"), - (String) conf.get("filename")); - - savePath = savePath + suffix; - String physicalPath = (String) conf.get("rootPath") + savePath; - - State storageState = StorageManager.saveBinaryFile(data, physicalPath); - - if (storageState.isSuccess()) { - storageState.putInfo("url", PathFormat.format(savePath)); - storageState.putInfo("type", suffix); - storageState.putInfo("original", ""); - } - - return storageState; - } - - private static byte[] decode(String content) { - return Base64.decodeBase64(content); - } - - private static boolean validSize(byte[] data, long length) { - return data.length <= length; - } - -} \ No newline at end of file diff --git a/src/main/java/com/baidu/ueditor/upload/BinaryUploader.java b/src/main/java/com/baidu/ueditor/upload/BinaryUploader.java deleted file mode 100644 index c69f9ddd..00000000 --- a/src/main/java/com/baidu/ueditor/upload/BinaryUploader.java +++ /dev/null @@ -1,98 +0,0 @@ -package com.baidu.ueditor.upload; - -import com.baidu.ueditor.PathFormat; -import com.baidu.ueditor.define.AppInfo; -import com.baidu.ueditor.define.BaseState; -import com.baidu.ueditor.define.FileType; -import com.baidu.ueditor.define.State; - -import java.io.IOException; -import java.io.InputStream; -import java.util.Arrays; -import java.util.List; -import java.util.Map; - -import javax.servlet.http.HttpServletRequest; - -import org.apache.commons.fileupload.FileItemIterator; -import org.apache.commons.fileupload.FileItemStream; -import org.apache.commons.fileupload.FileUploadException; -import org.apache.commons.fileupload.disk.DiskFileItemFactory; -import org.apache.commons.fileupload.servlet.ServletFileUpload; - -public class BinaryUploader { - - public static final State save(HttpServletRequest request, - Map conf) { - FileItemStream fileStream = null; - boolean isAjaxUpload = request.getHeader( "X_Requested_With" ) != null; - - if (!ServletFileUpload.isMultipartContent(request)) { - return new BaseState(false, AppInfo.NOT_MULTIPART_CONTENT); - } - - ServletFileUpload upload = new ServletFileUpload( - new DiskFileItemFactory()); - - if ( isAjaxUpload ) { - upload.setHeaderEncoding( "UTF-8" ); - } - - try { - FileItemIterator iterator = upload.getItemIterator(request); - - while (iterator.hasNext()) { - fileStream = iterator.next(); - - if (!fileStream.isFormField()) - break; - fileStream = null; - } - - if (fileStream == null) { - return new BaseState(false, AppInfo.NOTFOUND_UPLOAD_DATA); - } - - String savePath = (String) conf.get("savePath"); - String originFileName = fileStream.getName(); - String suffix = FileType.getSuffixByFilename(originFileName); - - originFileName = originFileName.substring(0, - originFileName.length() - suffix.length()); - savePath = savePath + suffix; - - long maxSize = ((Long) conf.get("maxSize")).longValue(); - - if (!validType(suffix, (String[]) conf.get("allowFiles"))) { - return new BaseState(false, AppInfo.NOT_ALLOW_FILE_TYPE); - } - - savePath = PathFormat.parse(savePath, originFileName); - - String physicalPath = (String) conf.get("rootPath") + savePath; - - InputStream is = fileStream.openStream(); - State storageState = StorageManager.saveFileByInputStream(is, - physicalPath, maxSize); - is.close(); - - if (storageState.isSuccess()) { - storageState.putInfo("url", PathFormat.format(savePath)); - storageState.putInfo("type", suffix); - storageState.putInfo("original", originFileName + suffix); - } - - return storageState; - } catch (FileUploadException e) { - return new BaseState(false, AppInfo.PARSE_REQUEST_ERROR); - } catch (IOException e) { - } - return new BaseState(false, AppInfo.IO_ERROR); - } - - private static boolean validType(String type, String[] allowTypes) { - List list = Arrays.asList(allowTypes); - - return list.contains(type); - } -} diff --git a/src/main/java/com/baidu/ueditor/upload/StorageManager.java b/src/main/java/com/baidu/ueditor/upload/StorageManager.java deleted file mode 100644 index 33911c64..00000000 --- a/src/main/java/com/baidu/ueditor/upload/StorageManager.java +++ /dev/null @@ -1,155 +0,0 @@ -package com.baidu.ueditor.upload; - -import com.baidu.ueditor.define.AppInfo; -import com.baidu.ueditor.define.BaseState; -import com.baidu.ueditor.define.State; - -import java.io.BufferedInputStream; -import java.io.BufferedOutputStream; -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; - -import org.apache.commons.io.FileUtils; - -public class StorageManager { - public static final int BUFFER_SIZE = 8192; - - public StorageManager() { - } - - public static State saveBinaryFile(byte[] data, String path) { - File file = new File(path); - - State state = valid(file); - - if (!state.isSuccess()) { - return state; - } - - try { - BufferedOutputStream bos = new BufferedOutputStream( - new FileOutputStream(file)); - bos.write(data); - bos.flush(); - bos.close(); - } catch (IOException ioe) { - return new BaseState(false, AppInfo.IO_ERROR); - } - - state = new BaseState(true, file.getAbsolutePath()); - state.putInfo( "size", data.length ); - state.putInfo( "title", file.getName() ); - return state; - } - - public static State saveFileByInputStream(InputStream is, String path, - long maxSize) { - State state = null; - - File tmpFile = getTmpFile(); - - byte[] dataBuf = new byte[ 2048 ]; - BufferedInputStream bis = new BufferedInputStream(is, StorageManager.BUFFER_SIZE); - - try { - BufferedOutputStream bos = new BufferedOutputStream( - new FileOutputStream(tmpFile), StorageManager.BUFFER_SIZE); - - int count = 0; - while ((count = bis.read(dataBuf)) != -1) { - bos.write(dataBuf, 0, count); - } - bos.flush(); - bos.close(); - - if (tmpFile.length() > maxSize) { - tmpFile.delete(); - return new BaseState(false, AppInfo.MAX_SIZE); - } - - state = saveTmpFile(tmpFile, path); - - if (!state.isSuccess()) { - tmpFile.delete(); - } - - return state; - - } catch (IOException e) { - } - return new BaseState(false, AppInfo.IO_ERROR); - } - - public static State saveFileByInputStream(InputStream is, String path) { - State state = null; - - File tmpFile = getTmpFile(); - - byte[] dataBuf = new byte[ 2048 ]; - BufferedInputStream bis = new BufferedInputStream(is, StorageManager.BUFFER_SIZE); - - try { - BufferedOutputStream bos = new BufferedOutputStream( - new FileOutputStream(tmpFile), StorageManager.BUFFER_SIZE); - - int count = 0; - while ((count = bis.read(dataBuf)) != -1) { - bos.write(dataBuf, 0, count); - } - bos.flush(); - bos.close(); - - state = saveTmpFile(tmpFile, path); - - if (!state.isSuccess()) { - tmpFile.delete(); - } - - return state; - } catch (IOException e) { - } - return new BaseState(false, AppInfo.IO_ERROR); - } - - private static File getTmpFile() { - File tmpDir = FileUtils.getTempDirectory(); - String tmpFileName = (Math.random() * 10000 + "").replace(".", ""); - return new File(tmpDir, tmpFileName); - } - - private static State saveTmpFile(File tmpFile, String path) { - State state = null; - File targetFile = new File(path); - - if (targetFile.canWrite()) { - return new BaseState(false, AppInfo.PERMISSION_DENIED); - } - try { - FileUtils.moveFile(tmpFile, targetFile); - } catch (IOException e) { - return new BaseState(false, AppInfo.IO_ERROR); - } - - state = new BaseState(true); - state.putInfo( "size", targetFile.length() ); - state.putInfo( "title", targetFile.getName() ); - - return state; - } - - private static State valid(File file) { - File parentPath = file.getParentFile(); - - if ((!parentPath.exists()) && (!parentPath.mkdirs())) { - return new BaseState(false, AppInfo.FAILED_CREATE_FILE); - } - - if (!parentPath.canWrite()) { - return new BaseState(false, AppInfo.PERMISSION_DENIED); - } - - return new BaseState(true); - } -} diff --git a/src/main/java/com/baidu/ueditor/upload/Uploader.java b/src/main/java/com/baidu/ueditor/upload/Uploader.java deleted file mode 100644 index 2312d1bc..00000000 --- a/src/main/java/com/baidu/ueditor/upload/Uploader.java +++ /dev/null @@ -1,29 +0,0 @@ -package com.baidu.ueditor.upload; - -import com.baidu.ueditor.define.State; -import java.util.Map; -import javax.servlet.http.HttpServletRequest; - -public class Uploader { - private HttpServletRequest request = null; - private Map conf = null; - - public Uploader(HttpServletRequest request, Map conf) { - this.request = request; - this.conf = conf; - } - - public final State doExec() { - String filedName = (String) this.conf.get("fieldName"); - State state = null; - - if ("true".equals(this.conf.get("isBase64"))) { - state = Base64Uploader.save(this.request.getParameter(filedName), - this.conf); - } else { - state = BinaryUploader.save(this.request, this.conf); - } - - return state; - } -} diff --git a/src/main/java/com/peanut/common/aspect/SysLogAspect.java b/src/main/java/com/peanut/common/aspect/SysLogAspect.java index 785be352..b044ca04 100644 --- a/src/main/java/com/peanut/common/aspect/SysLogAspect.java +++ b/src/main/java/com/peanut/common/aspect/SysLogAspect.java @@ -24,7 +24,7 @@ import org.aspectj.lang.reflect.MethodSignature; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; -import javax.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletRequest; import java.lang.reflect.Method; import java.util.Date; diff --git a/src/main/java/com/peanut/common/service/HlsDecryptService.java b/src/main/java/com/peanut/common/service/HlsDecryptService.java index 0fcb0642..5ba34d9e 100644 --- a/src/main/java/com/peanut/common/service/HlsDecryptService.java +++ b/src/main/java/com/peanut/common/service/HlsDecryptService.java @@ -3,20 +3,13 @@ package com.peanut.common.service; import com.aliyun.vod20170321.models.DecryptKMSDataKeyResponseBody; import com.aliyuncs.DefaultAcsClient; import com.aliyuncs.profile.DefaultProfile; -import com.peanut.common.utils.PlayToken; import com.peanut.common.utils.SpdbUtil; import com.sun.net.httpserver.Headers; import com.sun.net.httpserver.HttpExchange; import com.sun.net.httpserver.HttpHandler; import com.sun.net.httpserver.HttpServer; import com.sun.net.httpserver.spi.HttpServerProvider; -import lombok.extern.slf4j.Slf4j; import org.apache.commons.codec.binary.Base64; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.SpringApplication; -import org.springframework.stereotype.Service; - -import javax.annotation.PostConstruct; import java.io.IOException; import java.io.OutputStream; import java.net.HttpURLConnection; diff --git a/src/main/java/com/peanut/common/utils/FileDownloadUtil.java b/src/main/java/com/peanut/common/utils/FileDownloadUtil.java index 91b58c58..e74a0cf0 100644 --- a/src/main/java/com/peanut/common/utils/FileDownloadUtil.java +++ b/src/main/java/com/peanut/common/utils/FileDownloadUtil.java @@ -1,6 +1,6 @@ package com.peanut.common.utils; -import javax.servlet.http.HttpServletResponse; +import jakarta.servlet.http.HttpServletResponse; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; diff --git a/src/main/java/com/peanut/common/utils/HttpContextUtil.java b/src/main/java/com/peanut/common/utils/HttpContextUtil.java index 7a73ac84..0bea78e1 100644 --- a/src/main/java/com/peanut/common/utils/HttpContextUtil.java +++ b/src/main/java/com/peanut/common/utils/HttpContextUtil.java @@ -3,7 +3,7 @@ package com.peanut.common.utils; import org.springframework.web.context.request.RequestContextHolder; import org.springframework.web.context.request.ServletRequestAttributes; -import javax.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletRequest; import java.util.Objects; public class HttpContextUtil { diff --git a/src/main/java/com/peanut/common/utils/HttpContextUtils.java b/src/main/java/com/peanut/common/utils/HttpContextUtils.java index d9f4d7a1..a84c01be 100644 --- a/src/main/java/com/peanut/common/utils/HttpContextUtils.java +++ b/src/main/java/com/peanut/common/utils/HttpContextUtils.java @@ -10,8 +10,7 @@ package com.peanut.common.utils; import org.springframework.web.context.request.RequestContextHolder; import org.springframework.web.context.request.ServletRequestAttributes; - -import javax.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletRequest; public class HttpContextUtils { diff --git a/src/main/java/com/peanut/common/utils/IPUtils.java b/src/main/java/com/peanut/common/utils/IPUtils.java index 8dce45e9..f8704767 100644 --- a/src/main/java/com/peanut/common/utils/IPUtils.java +++ b/src/main/java/com/peanut/common/utils/IPUtils.java @@ -11,8 +11,7 @@ package com.peanut.common.utils; import com.alibaba.druid.util.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; - -import javax.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletRequest; /** * IP地址 diff --git a/src/main/java/com/peanut/common/utils/KdUtils.java b/src/main/java/com/peanut/common/utils/KdUtils.java index 252e1da0..f05dce14 100644 --- a/src/main/java/com/peanut/common/utils/KdUtils.java +++ b/src/main/java/com/peanut/common/utils/KdUtils.java @@ -1,7 +1,6 @@ package com.peanut.common.utils; -import com.sun.org.apache.xerces.internal.impl.dv.util.Base64; - +import cn.hutool.core.codec.Base64; import java.io.UnsupportedEncodingException; import java.net.URLEncoder; import java.security.MessageDigest; diff --git a/src/main/java/com/peanut/common/utils/UEditorUpload.java b/src/main/java/com/peanut/common/utils/UEditorUpload.java deleted file mode 100644 index 00cb103f..00000000 --- a/src/main/java/com/peanut/common/utils/UEditorUpload.java +++ /dev/null @@ -1,38 +0,0 @@ -package com.peanut.common.utils; - -import com.peanut.modules.app.entity.UEditorFile; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.stereotype.Component; -import org.springframework.util.ClassUtils; -import org.springframework.web.multipart.MultipartFile; - -import java.io.File; -import java.io.IOException; -import java.util.Date; - -@Component -public class UEditorUpload { - private Logger log = LoggerFactory.getLogger(UEditorUpload.class); - private String path = ClassUtils.getDefaultClassLoader().getResource("").getPath(); - - public UEditorFile uploadImage(MultipartFile file) throws IOException { - log.info("UEditor开始上传文件"); - String fileName = file.getOriginalFilename(); //获取文件名 - //Ueditor的config.json规定的返回路径格式 - String returnPath = "/image/upload/ueditor/"+new Date().getTime()+"/"+fileName; - File saveFile = new File(path+"static"+returnPath); - if (!saveFile.exists()){ - saveFile.mkdirs(); - } - file.transferTo(saveFile); //将临时文件移动到保存路径 - log.info("UEditor上传文件成功,保存路径:"+saveFile.getAbsolutePath()); - UEditorFile uEditorFile = new UEditorFile(); - uEditorFile.setState("SUCCESS"); - uEditorFile.setUrl(returnPath); //访问URL - uEditorFile.setTitle(fileName); - uEditorFile.setOriginal(fileName); - return uEditorFile; - } - -} diff --git a/src/main/java/com/peanut/common/validator/ValidatorUtils.java b/src/main/java/com/peanut/common/validator/ValidatorUtils.java index b4856f06..094dd20f 100644 --- a/src/main/java/com/peanut/common/validator/ValidatorUtils.java +++ b/src/main/java/com/peanut/common/validator/ValidatorUtils.java @@ -11,9 +11,9 @@ package com.peanut.common.validator; import com.peanut.common.exception.RRException; import com.peanut.common.utils.Constant; -import javax.validation.ConstraintViolation; -import javax.validation.Validation; -import javax.validation.Validator; +import jakarta.validation.ConstraintViolation; +import jakarta.validation.Validation; +import jakarta.validation.Validator; import java.util.Set; /** diff --git a/src/main/java/com/peanut/common/validator/group/Group.java b/src/main/java/com/peanut/common/validator/group/Group.java index e9d0b56e..225a269e 100644 --- a/src/main/java/com/peanut/common/validator/group/Group.java +++ b/src/main/java/com/peanut/common/validator/group/Group.java @@ -8,7 +8,7 @@ package com.peanut.common.validator.group; -import javax.validation.GroupSequence; +import jakarta.validation.GroupSequence; /** * 定义校验顺序,如果AddGroup组失败,则UpdateGroup组不会再校验 diff --git a/src/main/java/com/peanut/common/xss/XssFilter.java b/src/main/java/com/peanut/common/xss/XssFilter.java index 13eabac1..2041d6f8 100644 --- a/src/main/java/com/peanut/common/xss/XssFilter.java +++ b/src/main/java/com/peanut/common/xss/XssFilter.java @@ -8,8 +8,8 @@ package com.peanut.common.xss; -import javax.servlet.*; -import javax.servlet.http.HttpServletRequest; +import jakarta.servlet.*; +import jakarta.servlet.http.HttpServletRequest; import java.io.IOException; /** diff --git a/src/main/java/com/peanut/common/xss/XssHttpServletRequestWrapper.java b/src/main/java/com/peanut/common/xss/XssHttpServletRequestWrapper.java index 5d15d767..f799dfe7 100644 --- a/src/main/java/com/peanut/common/xss/XssHttpServletRequestWrapper.java +++ b/src/main/java/com/peanut/common/xss/XssHttpServletRequestWrapper.java @@ -13,10 +13,10 @@ import org.apache.commons.lang.StringUtils; import org.springframework.http.HttpHeaders; import org.springframework.http.MediaType; -import javax.servlet.ReadListener; -import javax.servlet.ServletInputStream; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletRequestWrapper; +import jakarta.servlet.ReadListener; +import jakarta.servlet.ServletInputStream; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletRequestWrapper; import java.io.ByteArrayInputStream; import java.io.IOException; import java.util.LinkedHashMap; diff --git a/src/main/java/com/peanut/config/FilterConfig.java b/src/main/java/com/peanut/config/FilterConfig.java index 90ec7cb4..65a4d358 100644 --- a/src/main/java/com/peanut/config/FilterConfig.java +++ b/src/main/java/com/peanut/config/FilterConfig.java @@ -13,8 +13,7 @@ import org.springframework.boot.web.servlet.FilterRegistrationBean; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.web.filter.DelegatingFilterProxy; - -import javax.servlet.DispatcherType; +import jakarta.servlet.DispatcherType; /** * Filter配置 diff --git a/src/main/java/com/peanut/config/MybatisPlusConfig.java b/src/main/java/com/peanut/config/MybatisPlusConfig.java index 85741f7e..ef40f3a0 100644 --- a/src/main/java/com/peanut/config/MybatisPlusConfig.java +++ b/src/main/java/com/peanut/config/MybatisPlusConfig.java @@ -8,7 +8,8 @@ package com.peanut.config; -import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor; +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; @@ -24,7 +25,10 @@ public class MybatisPlusConfig { * 分页插件 */ @Bean - public PaginationInterceptor paginationInterceptor() { - return new PaginationInterceptor(); + public MybatisPlusInterceptor mybatisPlusInterceptor() { + MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor(); + // 添加分页插件 + interceptor.addInnerInterceptor(new PaginationInnerInterceptor()); + return interceptor; } } diff --git a/src/main/java/com/peanut/config/ShiroConfig.java b/src/main/java/com/peanut/config/ShiroConfig.java index 0ba92ff8..3f3d7206 100644 --- a/src/main/java/com/peanut/config/ShiroConfig.java +++ b/src/main/java/com/peanut/config/ShiroConfig.java @@ -17,7 +17,7 @@ import org.apache.shiro.spring.web.ShiroFilterFactoryBean; import org.apache.shiro.web.mgt.DefaultWebSecurityManager; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; -import javax.servlet.Filter; +import jakarta.servlet.Filter; import java.util.HashMap; import java.util.LinkedHashMap; import java.util.Map; diff --git a/src/main/java/com/peanut/config/SwaggerConfig.java b/src/main/java/com/peanut/config/SwaggerConfig.java deleted file mode 100644 index 7ac80e2c..00000000 --- a/src/main/java/com/peanut/config/SwaggerConfig.java +++ /dev/null @@ -1,61 +0,0 @@ -/** - * Copyright (c) 2016-2019 人人开源 All rights reserved. - * - * https://www.renren.io - * - * 版权所有,侵权必究! - */ - -package com.peanut.config; - -import io.swagger.annotations.ApiOperation; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; -import springfox.documentation.builders.ApiInfoBuilder; -import springfox.documentation.builders.PathSelectors; -import springfox.documentation.builders.RequestHandlerSelectors; -import springfox.documentation.service.ApiInfo; -import springfox.documentation.service.ApiKey; -import springfox.documentation.spi.DocumentationType; -import springfox.documentation.spring.web.plugins.Docket; -import springfox.documentation.swagger2.annotations.EnableSwagger2; - -import java.util.List; - -import static com.google.common.collect.Lists.newArrayList; - -@Configuration -@EnableSwagger2 -public class SwaggerConfig implements WebMvcConfigurer { - - @Bean - public Docket createRestApi() { - return new Docket(DocumentationType.SWAGGER_2) - .apiInfo(apiInfo()) - .select() - //加了ApiOperation注解的类,才生成接口文档 - .apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class)) - //包下的类,才生成接口文档 - //.apis(RequestHandlerSelectors.basePackage("io.renren.controller")) - .paths(PathSelectors.any()) - .build() - .securitySchemes(security()); - } - - private ApiInfo apiInfo() { - return new ApiInfoBuilder() - .title("人人开源") - .description("renren-fast文档") - .termsOfServiceUrl("https://www.renren.io") - .version("3.0.0") - .build(); - } - - private List security() { - return newArrayList( - new ApiKey("token", "token", "header") - ); - } - -} \ No newline at end of file diff --git a/src/main/java/com/peanut/config/WebSocket.java b/src/main/java/com/peanut/config/WebSocket.java index fd764cf1..b9219a1c 100644 --- a/src/main/java/com/peanut/config/WebSocket.java +++ b/src/main/java/com/peanut/config/WebSocket.java @@ -3,11 +3,11 @@ package com.peanut.config; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Component; -import javax.websocket.OnClose; -import javax.websocket.OnMessage; -import javax.websocket.OnOpen; -import javax.websocket.Session; -import javax.websocket.server.ServerEndpoint; +import jakarta.websocket.OnClose; +import jakarta.websocket.OnMessage; +import jakarta.websocket.OnOpen; +import jakarta.websocket.Session; +import jakarta.websocket.server.ServerEndpoint; import java.util.concurrent.CopyOnWriteArraySet; diff --git a/src/main/java/com/peanut/modules/app/annotation/Login.java b/src/main/java/com/peanut/modules/app/annotation/Login.java deleted file mode 100644 index 9f0ccb6c..00000000 --- a/src/main/java/com/peanut/modules/app/annotation/Login.java +++ /dev/null @@ -1,22 +0,0 @@ -/** - * Copyright (c) 2016-2019 人人开源 All rights reserved. - * - * https://www.renren.io - * - * 版权所有,侵权必究! - */ - -package com.peanut.modules.app.annotation; - -import java.lang.annotation.*; - -/** - * app登录效验 - * - * @author Mark sunlightcs@gmail.com - */ -@Target(ElementType.METHOD) -@Retention(RetentionPolicy.RUNTIME) -@Documented -public @interface Login { -} diff --git a/src/main/java/com/peanut/modules/app/annotation/LoginUser.java b/src/main/java/com/peanut/modules/app/annotation/LoginUser.java deleted file mode 100644 index 6410b9d1..00000000 --- a/src/main/java/com/peanut/modules/app/annotation/LoginUser.java +++ /dev/null @@ -1,25 +0,0 @@ -/** - * Copyright (c) 2016-2019 人人开源 All rights reserved. - * - * https://www.renren.io - * - * 版权所有,侵权必究! - */ - -package com.peanut.modules.app.annotation; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * 登录用户信息 - * - * @author Mark sunlightcs@gmail.com - */ -@Target(ElementType.PARAMETER) -@Retention(RetentionPolicy.RUNTIME) -public @interface LoginUser { - -} diff --git a/src/main/java/com/peanut/modules/app/config/SMSConfig.java b/src/main/java/com/peanut/modules/app/config/SMSConfig.java deleted file mode 100644 index 42c9f362..00000000 --- a/src/main/java/com/peanut/modules/app/config/SMSConfig.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.peanut.modules.app.config; - -import lombok.Data; -import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.stereotype.Component; - -@ConfigurationProperties(prefix = "aliyun.sms") -@Component -@Data -public class SMSConfig { - - private String accessKeyId; - private String accessKeySecret; - private String singName; - private String templateCode; - private String sTemplateCode;//国际短信模版 - -} diff --git a/src/main/java/com/peanut/modules/app/config/Sample.java b/src/main/java/com/peanut/modules/app/config/Sample.java deleted file mode 100644 index 6fa7bdf1..00000000 --- a/src/main/java/com/peanut/modules/app/config/Sample.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.peanut.modules.app.config; - -import com.aliyun.teaopenapi.models.*; - - -public class Sample { - public static com.aliyun.dysmsapi20170525.Client createClient(String accessKeyId, String accessKeySecret) throws Exception { - Config config = new Config() - // 您的 AccessKey ID - .setAccessKeyId(accessKeyId) - // 您的 AccessKey Secret - .setAccessKeySecret(accessKeySecret); - // 访问的域名 - config.endpoint = "dysmsapi.aliyuncs.com"; - return new com.aliyun.dysmsapi20170525.Client(config); - } -} diff --git a/src/main/java/com/peanut/modules/app/config/WebMvcConfig.java b/src/main/java/com/peanut/modules/app/config/WebMvcConfig.java deleted file mode 100644 index 62e90718..00000000 --- a/src/main/java/com/peanut/modules/app/config/WebMvcConfig.java +++ /dev/null @@ -1,56 +0,0 @@ -/** - * Copyright (c) 2016-2019 人人开源 All rights reserved. - * - * https://www.renren.io - * - * 版权所有,侵权必究! - */ - -package com.peanut.modules.app.config; - -import com.peanut.modules.app.interceptor.AuthorizationInterceptor; -import com.peanut.modules.app.resolver.LoginUserHandlerMethodArgumentResolver; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Qualifier; -import org.springframework.context.annotation.Configuration; -import org.springframework.core.task.AsyncTaskExecutor; -import org.springframework.web.method.support.HandlerMethodArgumentResolver; -import org.springframework.web.servlet.config.annotation.AsyncSupportConfigurer; -import org.springframework.web.servlet.config.annotation.InterceptorRegistry; -import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; - -import java.util.List; -import java.util.concurrent.Executor; - -/** - * MVC配置 - * - * @author Mark sunlightcs@gmail.com - */ -@Configuration -public class WebMvcConfig implements WebMvcConfigurer { - @Autowired - private AuthorizationInterceptor authorizationInterceptor; - @Autowired - private LoginUserHandlerMethodArgumentResolver loginUserHandlerMethodArgumentResolver; - - @Autowired - @Qualifier("fluxTaskExecutor") - private AsyncTaskExecutor taskExecutor; - - @Override - public void configureAsyncSupport(AsyncSupportConfigurer configurer) { - configurer.setTaskExecutor(taskExecutor); - configurer.setDefaultTimeout(30_000); // 超时时间设为30秒 - } - @Override - public void addInterceptors(InterceptorRegistry registry) { - registry.addInterceptor(authorizationInterceptor).addPathPatterns("/app/**"); - } - - @Override - public void addArgumentResolvers(List argumentResolvers) { - argumentResolvers.add(loginUserHandlerMethodArgumentResolver); - } - -} \ No newline at end of file diff --git a/src/main/java/com/peanut/modules/app/controller/AppLoginController.java b/src/main/java/com/peanut/modules/app/controller/AppLoginController.java deleted file mode 100644 index eb3db18a..00000000 --- a/src/main/java/com/peanut/modules/app/controller/AppLoginController.java +++ /dev/null @@ -1,55 +0,0 @@ -/** - * Copyright (c) 2016-2019 人人开源 All rights reserved. - * - * https://www.renren.io - * - * 版权所有,侵权必究! - */ - -package com.peanut.modules.app.controller; - - -import com.peanut.modules.app.utils.JwtUtils; -import com.peanut.modules.book.service.MyUserService; -import io.swagger.annotations.Api; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -/** - * APP登录授权 - * - * @author Mark sunlightcs@gmail.com - */ -@RestController -@RequestMapping("/app") -@Api("APP登录接口") -public class AppLoginController { - @Autowired - private MyUserService userService; - @Autowired - private JwtUtils jwtUtils; - - /** - * 登录 - */ -// @PostMapping("login") -// @ApiOperation("登录") -// public R login(@RequestBody LoginForm form){ -// //表单校验 -// ValidatorUtils.validateEntity(form); -// -// //用户登录 -// long userId = userService.login(form); -// -// //生成token -// String token = jwtUtils.generateToken(userId); -// -// Map map = new HashMap<>(); -// map.put("token", token); -// map.put("expire", jwtUtils.getExpire()); -// -// return R.ok(map); -// } - -} diff --git a/src/main/java/com/peanut/modules/app/controller/AppRegisterController.java b/src/main/java/com/peanut/modules/app/controller/AppRegisterController.java deleted file mode 100644 index 8fda6a98..00000000 --- a/src/main/java/com/peanut/modules/app/controller/AppRegisterController.java +++ /dev/null @@ -1,45 +0,0 @@ -/** - * Copyright (c) 2016-2019 人人开源 All rights reserved. - * - * https://www.renren.io - * - * 版权所有,侵权必究! - */ - -package com.peanut.modules.app.controller; - - -import com.peanut.modules.book.service.MyUserService; -import io.swagger.annotations.Api; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -/** - * 注册 - * - * @author Mark sunlightcs@gmail.com - */ -@RestController -@RequestMapping("/app") -@Api("APP注册接口") -public class AppRegisterController { - @Autowired - private MyUserService userService; - -// @PostMapping("register") -// @ApiOperation("注册") -// public R register(@RequestBody RegisterForm form){ -// //表单校验 -// ValidatorUtils.validateEntity(form); -// -// UserEntity user = new UserEntity(); -// user.setMobile(form.getMobile()); -// user.setUsername(form.getMobile()); -// user.setPassword(DigestUtils.sha256Hex(form.getPassword())); -// user.setCreateTime(new Date()); -// userService.save(user); -// -// return R.ok(); -// } -} diff --git a/src/main/java/com/peanut/modules/app/controller/AppTestController.java b/src/main/java/com/peanut/modules/app/controller/AppTestController.java deleted file mode 100644 index 2ff214db..00000000 --- a/src/main/java/com/peanut/modules/app/controller/AppTestController.java +++ /dev/null @@ -1,53 +0,0 @@ -/** - * Copyright (c) 2016-2019 人人开源 All rights reserved. - * - * https://www.renren.io - * - * 版权所有,侵权必究! - */ - -package com.peanut.modules.app.controller; - - -import com.peanut.common.utils.R; -import com.peanut.modules.app.annotation.Login; -import com.peanut.modules.app.annotation.LoginUser; -import com.peanut.modules.common.entity.MyUserEntity; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestAttribute; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -/** - * APP测试接口 - * - * @author Mark sunlightcs@gmail.com - */ -@RestController -@RequestMapping("/app") -@Api("APP测试接口") -public class AppTestController { - - @Login - @GetMapping("userInfo") - @ApiOperation("获取用户信息") - public R userInfo(@LoginUser MyUserEntity user){ - return R.ok().put("user", user); - } - - @Login - @GetMapping("userId") - @ApiOperation("获取用户ID") - public R userInfo(@RequestAttribute("userId") Integer userId){ - return R.ok().put("userId", userId); - } - - @GetMapping("notToken") - @ApiOperation("忽略Token验证测试") - public R notToken(){ - return R.ok().put("msg", "无需token也能访问。。。"); - } - -} diff --git a/src/main/java/com/peanut/modules/app/controller/UeditorController.java b/src/main/java/com/peanut/modules/app/controller/UeditorController.java deleted file mode 100644 index 1f473c7c..00000000 --- a/src/main/java/com/peanut/modules/app/controller/UeditorController.java +++ /dev/null @@ -1,56 +0,0 @@ -package com.peanut.modules.app.controller; - -import com.alibaba.fastjson.JSONObject; -import com.baidu.ueditor.ActionEnter; -import com.peanut.common.utils.UEditorUpload; -import com.peanut.modules.app.entity.UEditorFile; -import com.peanut.modules.oss.service.OssService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.core.io.ResourceLoader; -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.*; -import org.springframework.web.multipart.MultipartFile; - -import javax.annotation.Resource; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import java.io.IOException; -import java.io.InputStream; -import java.util.Map; - -@Controller -@RequestMapping("/ueditor") -public class UeditorController { - - @Autowired - ResourceLoader resourceLoader; - @Autowired - UEditorUpload ueditorUpload; - - @RequestMapping("/config") - @ResponseBody - public String exec(HttpServletRequest request, - HttpServletResponse response, - @RequestParam(value = "action") String action, - @RequestParam(value = "upfile", required = false) MultipartFile upfile) throws Exception { - if (action.equals("config")) { - request.setCharacterEncoding("utf-8"); - response.setContentType("text/html"); - String rootPath = request.getSession().getServletContext().getRealPath("/"); - return new ActionEnter(request, rootPath).exec(); - } else if (action.equals("uploadimage")) { - UEditorFile uEditorFile = ueditorUpload.uploadImage(upfile); - String jsonString = JSONObject.toJSONString(uEditorFile); - - return jsonString; - } else if (action.equals("uploadfile")) { - UEditorFile uEditorFile = ueditorUpload.uploadImage(upfile); - String jsonString = JSONObject.toJSONString(uEditorFile); - - return jsonString; - } - return "无效Action"; - } - -} - diff --git a/src/main/java/com/peanut/modules/app/entity/UEditorFile.java b/src/main/java/com/peanut/modules/app/entity/UEditorFile.java deleted file mode 100644 index afed3002..00000000 --- a/src/main/java/com/peanut/modules/app/entity/UEditorFile.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.peanut.modules.app.entity; - -import lombok.Data; -import lombok.NoArgsConstructor; -import lombok.experimental.Accessors; - -@Data -@NoArgsConstructor -@Accessors(chain = true) -public class UEditorFile { - - private static final long serialVersionUID=1L; - - private String state; - - private String url; - - private String title; - - private String original; - - @Override - public String toString() { - return "{" + - "state='" + state + '\'' + - ", url='" + url + '\'' + - ", title='" + title + '\'' + - ", original='" + original + '\'' + - '}'; - } -} diff --git a/src/main/java/com/peanut/modules/app/form/LoginForm.java b/src/main/java/com/peanut/modules/app/form/LoginForm.java deleted file mode 100644 index 5af83f46..00000000 --- a/src/main/java/com/peanut/modules/app/form/LoginForm.java +++ /dev/null @@ -1,33 +0,0 @@ -/** - * Copyright (c) 2016-2019 人人开源 All rights reserved. - * - * https://www.renren.io - * - * 版权所有,侵权必究! - */ - -package com.peanut.modules.app.form; - -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; - -import javax.validation.constraints.NotBlank; - -/** - * 登录表单 - * - * @author Mark sunlightcs@gmail.com - */ -@Data -@ApiModel(value = "登录表单") -public class LoginForm { - @ApiModelProperty(value = "手机号") - @NotBlank(message="手机号不能为空") - private String mobile; - - @ApiModelProperty(value = "密码") - @NotBlank(message="密码不能为空") - private String password; - -} diff --git a/src/main/java/com/peanut/modules/app/form/RegisterForm.java b/src/main/java/com/peanut/modules/app/form/RegisterForm.java deleted file mode 100644 index ba9fd01b..00000000 --- a/src/main/java/com/peanut/modules/app/form/RegisterForm.java +++ /dev/null @@ -1,33 +0,0 @@ -/** - * Copyright (c) 2016-2019 人人开源 All rights reserved. - * - * https://www.renren.io - * - * 版权所有,侵权必究! - */ - -package com.peanut.modules.app.form; - -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; - -import javax.validation.constraints.NotBlank; - -/** - * 注册表单 - * - * @author Mark sunlightcs@gmail.com - */ -@Data -@ApiModel(value = "注册表单") -public class RegisterForm { - @ApiModelProperty(value = "手机号") - @NotBlank(message="手机号不能为空") - private String mobile; - - @ApiModelProperty(value = "密码") - @NotBlank(message="密码不能为空") - private String password; - -} diff --git a/src/main/java/com/peanut/modules/app/interceptor/AuthorizationInterceptor.java b/src/main/java/com/peanut/modules/app/interceptor/AuthorizationInterceptor.java deleted file mode 100644 index bee1cdcd..00000000 --- a/src/main/java/com/peanut/modules/app/interceptor/AuthorizationInterceptor.java +++ /dev/null @@ -1,72 +0,0 @@ -/** - * Copyright (c) 2016-2019 人人开源 All rights reserved. - * - * https://www.renren.io - * - * 版权所有,侵权必究! - */ - -package com.peanut.modules.app.interceptor; - - -import com.peanut.common.exception.RRException; -import com.peanut.modules.app.annotation.Login; -import com.peanut.modules.app.utils.JwtUtils; -import io.jsonwebtoken.Claims; -import org.apache.commons.lang.StringUtils; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.HttpStatus; -import org.springframework.stereotype.Component; -import org.springframework.web.method.HandlerMethod; -import org.springframework.web.servlet.handler.HandlerInterceptorAdapter; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -/** - * 权限(Token)验证 - * - * @author Mark sunlightcs@gmail.com - */ -@Component -public class AuthorizationInterceptor extends HandlerInterceptorAdapter { - @Autowired - private JwtUtils jwtUtils; - - public static final String USER_KEY = "userId"; - - @Override - public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { - Login annotation; - if(handler instanceof HandlerMethod) { - annotation = ((HandlerMethod) handler).getMethodAnnotation(Login.class); - }else{ - return true; - } - - if(annotation == null){ - return true; - } - - //获取用户凭证 - String token = request.getHeader(jwtUtils.getHeader()); - if(StringUtils.isBlank(token)){ - token = request.getParameter(jwtUtils.getHeader()); - } - - //凭证为空 - if(StringUtils.isBlank(token)){ - throw new RRException(jwtUtils.getHeader() + "不能为空", HttpStatus.UNAUTHORIZED.value()); - } - - Claims claims = jwtUtils.getClaimByToken(token); - if(claims == null || jwtUtils.isTokenExpired(claims.getExpiration())){ - throw new RRException(jwtUtils.getHeader() + "失效,请重新登录", HttpStatus.UNAUTHORIZED.value()); - } - - //设置userId到request里,后续根据userId,获取用户信息 - request.setAttribute(USER_KEY, Long.parseLong(claims.getSubject())); - - return true; - } -} diff --git a/src/main/java/com/peanut/modules/app/resolver/LoginUserHandlerMethodArgumentResolver.java b/src/main/java/com/peanut/modules/app/resolver/LoginUserHandlerMethodArgumentResolver.java deleted file mode 100644 index c1662fa7..00000000 --- a/src/main/java/com/peanut/modules/app/resolver/LoginUserHandlerMethodArgumentResolver.java +++ /dev/null @@ -1,53 +0,0 @@ -/** - * Copyright (c) 2016-2019 人人开源 All rights reserved. - * - * https://www.renren.io - * - * 版权所有,侵权必究! - */ - -package com.peanut.modules.app.resolver; - -import com.peanut.modules.app.annotation.LoginUser; -import com.peanut.modules.app.interceptor.AuthorizationInterceptor; -import com.peanut.modules.common.entity.MyUserEntity; -import com.peanut.modules.book.service.MyUserService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.core.MethodParameter; -import org.springframework.stereotype.Component; -import org.springframework.web.bind.support.WebDataBinderFactory; -import org.springframework.web.context.request.NativeWebRequest; -import org.springframework.web.context.request.RequestAttributes; -import org.springframework.web.method.support.HandlerMethodArgumentResolver; -import org.springframework.web.method.support.ModelAndViewContainer; - -/** - * 有@LoginUser注解的方法参数,注入当前登录用户 - * - * @author Mark sunlightcs@gmail.com - */ -@Component -public class LoginUserHandlerMethodArgumentResolver implements HandlerMethodArgumentResolver { - @Autowired - private MyUserService userService; - - @Override - public boolean supportsParameter(MethodParameter parameter) { - return parameter.getParameterType().isAssignableFrom(MyUserEntity.class) && parameter.hasParameterAnnotation(LoginUser.class); - } - - @Override - public Object resolveArgument(MethodParameter parameter, ModelAndViewContainer container, - NativeWebRequest request, WebDataBinderFactory factory) throws Exception { - //获取用户ID - Object object = request.getAttribute(AuthorizationInterceptor.USER_KEY, RequestAttributes.SCOPE_REQUEST); - if(object == null){ - return null; - } - - //获取用户信息 - MyUserEntity user = userService.getById((Long)object); - - return user; - } -} diff --git a/src/main/java/com/peanut/modules/app/utils/JwtUtils.java b/src/main/java/com/peanut/modules/app/utils/JwtUtils.java deleted file mode 100644 index 35a1f5e8..00000000 --- a/src/main/java/com/peanut/modules/app/utils/JwtUtils.java +++ /dev/null @@ -1,97 +0,0 @@ -/** - * Copyright (c) 2016-2019 人人开源 All rights reserved. - * - * https://www.renren.io - * - * 版权所有,侵权必究! - */ - -package com.peanut.modules.app.utils; - -import io.jsonwebtoken.Claims; -import io.jsonwebtoken.Jwts; -import io.jsonwebtoken.SignatureAlgorithm; -import lombok.extern.slf4j.Slf4j; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.stereotype.Component; - -import java.util.Date; - -/** - * jwt工具类 - * - * @author Mark sunlightcs@gmail.com - */ -@Slf4j -@ConfigurationProperties(prefix = "renren.jwt") -@Component -public class JwtUtils { - private Logger logger = LoggerFactory.getLogger(getClass()); - - private String secret; - private long expire; - private String header; - - /** - * 生成jwt token - */ - public String generateToken(long userId) { - Date nowDate = new Date(); - //过期时间 - Date expireDate = new Date(nowDate.getTime() + expire * 1000); - - return Jwts.builder() - .setHeaderParam("typ", "JWT") - .setSubject(userId+"") - .setIssuedAt(nowDate) - .setExpiration(expireDate) - .signWith(SignatureAlgorithm.HS512, secret) - .compact(); - } - - public Claims getClaimByToken(String token) { - try { - return Jwts.parser() - .setSigningKey(secret) - .parseClaimsJws(token) - .getBody(); - }catch (Exception e){ - logger.debug("validate is token error ", e); - return null; - } - } - - /** - * token是否过期 - * @return true:过期 - */ - public boolean isTokenExpired(Date expiration) { - return expiration.before(new Date()); - } - - public String getSecret() { - return secret; - } - - public void setSecret(String secret) { - this.secret = secret; - } - - public long getExpire() { - return expire; - } - - public void setExpire(long expire) { - this.expire = expire; - } - - public String getHeader() { - return header; - } - - public void setHeader(String header) { - this.header = header; - } -} diff --git a/src/main/java/com/peanut/modules/book/controller/BookController.java b/src/main/java/com/peanut/modules/book/controller/BookController.java index 9f22faa1..a62a1558 100644 --- a/src/main/java/com/peanut/modules/book/controller/BookController.java +++ b/src/main/java/com/peanut/modules/book/controller/BookController.java @@ -664,7 +664,7 @@ public class BookController { for (BookEntity b:bookEntityPage.getRecords()){ LambdaQueryWrapper bookForumArticlesEntityLambdaQueryWrapper = new LambdaQueryWrapper<>(); bookForumArticlesEntityLambdaQueryWrapper.eq(BookForumArticlesEntity::getBookid,b.getId()); - Integer integer = bookForumArticlesDao.selectCount(bookForumArticlesEntityLambdaQueryWrapper); + Integer integer = bookForumArticlesDao.selectCount(bookForumArticlesEntityLambdaQueryWrapper).intValue(); b.setForumNum(integer); } diff --git a/src/main/java/com/peanut/modules/book/controller/BookShelfController.java b/src/main/java/com/peanut/modules/book/controller/BookShelfController.java index 1cb76798..c18e14a3 100644 --- a/src/main/java/com/peanut/modules/book/controller/BookShelfController.java +++ b/src/main/java/com/peanut/modules/book/controller/BookShelfController.java @@ -73,7 +73,7 @@ public class BookShelfController { Integer integer = bookShelfService.getBaseMapper().selectCount(new QueryWrapper() .eq("book_id", bookShelf.getBookId()) - .eq("user_id", bookShelf.getUserId())); + .eq("user_id", bookShelf.getUserId())).intValue(); // System.out.println("bookShelf"+bookShelf); if (integer > 0){ return R.error(500,"当前书籍已加入书架"); diff --git a/src/main/java/com/peanut/modules/book/controller/BookTeachLikeAndCommentController.java b/src/main/java/com/peanut/modules/book/controller/BookTeachLikeAndCommentController.java index 8b90b0a7..b9ee6b78 100644 --- a/src/main/java/com/peanut/modules/book/controller/BookTeachLikeAndCommentController.java +++ b/src/main/java/com/peanut/modules/book/controller/BookTeachLikeAndCommentController.java @@ -45,7 +45,7 @@ public class BookTeachLikeAndCommentController { LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); wrapper.eq(BookTeachLikeEntity::getDelFlag,0); wrapper.eq(BookTeachLikeEntity::getTeachId,teachId); - int count = likeService.count(wrapper); + Long count = likeService.count(wrapper); return R.ok().put("count", count); } diff --git a/src/main/java/com/peanut/modules/book/controller/BuyOrderController.java b/src/main/java/com/peanut/modules/book/controller/BuyOrderController.java index a7225b94..c92e0427 100644 --- a/src/main/java/com/peanut/modules/book/controller/BuyOrderController.java +++ b/src/main/java/com/peanut/modules/book/controller/BuyOrderController.java @@ -38,7 +38,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.transaction.annotation.Transactional; import org.springframework.web.bind.annotation.*; -import javax.servlet.http.HttpServletResponse; +import jakarta.servlet.http.HttpServletResponse; import java.io.IOException; import java.io.OutputStream; import java.math.BigDecimal; diff --git a/src/main/java/com/peanut/modules/book/controller/ExpressController.java b/src/main/java/com/peanut/modules/book/controller/ExpressController.java index 9758c1b2..54ac0f83 100644 --- a/src/main/java/com/peanut/modules/book/controller/ExpressController.java +++ b/src/main/java/com/peanut/modules/book/controller/ExpressController.java @@ -17,7 +17,6 @@ import com.peanut.modules.book.vo.response.PrintTemplateVo; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; - import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; @@ -88,8 +87,8 @@ public class ExpressController { Page expressOrderPage = new Page<>(currentPage, pageSize); QueryWrapper expressOrderQueryWrapper = new QueryWrapper<>(); - int totalDataSize = expressOrderService.count(expressOrderQueryWrapper); - int totalPage = totalDataSize / pageSize + 1; + Long totalDataSize = expressOrderService.count(expressOrderQueryWrapper); + int totalPage = totalDataSize.intValue() / pageSize + 1; Page page = expressOrderService.page(expressOrderPage, expressOrderQueryWrapper); List expressOrderList = page.getRecords(); List data = new ArrayList<>(); diff --git a/src/main/java/com/peanut/modules/book/service/impl/BookForumArticlesServiceImpl.java b/src/main/java/com/peanut/modules/book/service/impl/BookForumArticlesServiceImpl.java index 0b8bb99c..560b5f42 100644 --- a/src/main/java/com/peanut/modules/book/service/impl/BookForumArticlesServiceImpl.java +++ b/src/main/java/com/peanut/modules/book/service/impl/BookForumArticlesServiceImpl.java @@ -57,7 +57,7 @@ public class BookForumArticlesServiceImpl extends ServiceImpl wrapper = new LambdaQueryWrapper<>(); wrapper.eq(BookForumArticlesEntity::getDelflag,0); wrapper.eq(BookForumArticlesEntity::getBookid,book_id); - int count = this.count(wrapper); - return count; + Long count = this.count(wrapper); + return count.intValue(); } } diff --git a/src/main/java/com/peanut/modules/book/service/impl/BookForumCommenServiceImpl.java b/src/main/java/com/peanut/modules/book/service/impl/BookForumCommenServiceImpl.java index 4656a07e..81c4eff9 100644 --- a/src/main/java/com/peanut/modules/book/service/impl/BookForumCommenServiceImpl.java +++ b/src/main/java/com/peanut/modules/book/service/impl/BookForumCommenServiceImpl.java @@ -69,8 +69,8 @@ public class BookForumCommenServiceImpl extends ServiceImpl wrapper = new LambdaQueryWrapper<>(); wrapper.eq(BookForumCommentEntity::getBfaid,forum_id); wrapper.eq(BookForumCommentEntity::getDelflag,0); - int count = this.count(wrapper); - return count; + Long count = this.count(wrapper); + return count.intValue(); } @@ -93,7 +93,7 @@ public class BookForumCommenServiceImpl extends ServiceImpl wrapper = new LambdaQueryWrapper<>(); wrapper.eq(BookForumCommentEntity::getPid,comment_id); wrapper.eq(BookForumCommentEntity::getDelflag,0); - Integer integer = this.getBaseMapper().selectCount(wrapper); + Integer integer = this.getBaseMapper().selectCount(wrapper).intValue(); return integer; } } diff --git a/src/main/java/com/peanut/modules/book/service/impl/BuyOrderServiceImpl.java b/src/main/java/com/peanut/modules/book/service/impl/BuyOrderServiceImpl.java index 569a41c7..1785f0cc 100644 --- a/src/main/java/com/peanut/modules/book/service/impl/BuyOrderServiceImpl.java +++ b/src/main/java/com/peanut/modules/book/service/impl/BuyOrderServiceImpl.java @@ -277,7 +277,7 @@ public class BuyOrderServiceImpl extends ServiceImpl impl queryWrapper.eq("user_id", userId); queryWrapper.eq("address_id", addressId); queryWrapper.eq("address_modified", 0); - Integer totalSize = count(queryWrapper); + Integer totalSize = (int)count(queryWrapper); Integer totalPage = totalSize / requestVo.getPageSize() + 1; Page page = page(buyOrderPage, queryWrapper); List buyOrderList = page.getRecords(); @@ -601,8 +601,7 @@ public class BuyOrderServiceImpl extends ServiceImpl impl QueryWrapper buyOrderProductQueryWrapper = new QueryWrapper<>(); buyOrderProductQueryWrapper.eq("order_id", buyorder.getOrderId()); buyOrderProductQueryWrapper.eq("express_order_id", 0); - int count = buyOrderProductService.count(buyOrderProductQueryWrapper); - if (count == 0) { + if (buyOrderProductService.count(buyOrderProductQueryWrapper) == 0) { buyorder.setOrderStatus(Constants.ORDER_STATUS_SHIPPED); } } diff --git a/src/main/java/com/peanut/modules/book/service/impl/MyUserServiceImpl.java b/src/main/java/com/peanut/modules/book/service/impl/MyUserServiceImpl.java index 87a990d1..5b1febf9 100644 --- a/src/main/java/com/peanut/modules/book/service/impl/MyUserServiceImpl.java +++ b/src/main/java/com/peanut/modules/book/service/impl/MyUserServiceImpl.java @@ -1,16 +1,8 @@ package com.peanut.modules.book.service.impl; -import com.aliyun.dysmsapi20170525.models.SendSmsRequest; -import com.aliyun.dysmsapi20170525.models.SendSmsResponse; -import com.aliyun.dysmsapi20170525.models.SendSmsResponseBody; -import com.aliyun.tea.TeaException; -import com.aliyun.teautil.Common; -import com.aliyun.teautil.models.RuntimeOptions; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.toolkit.StringUtils; import com.peanut.common.utils.*; -import com.peanut.modules.app.config.SMSConfig; -import com.peanut.modules.app.config.Sample; import com.peanut.modules.book.service.*; import com.peanut.modules.common.entity.*; import lombok.extern.slf4j.Slf4j; @@ -27,8 +19,6 @@ import com.peanut.modules.common.dao.MyUserDao; public class MyUserServiceImpl extends ServiceImpl implements MyUserService { - @Autowired - private SMSConfig smsConfig; @Autowired private SmsUtil smsUtil; @Autowired @@ -49,7 +39,6 @@ public class MyUserServiceImpl extends ServiceImpl impl @Override public R sendCodeForRegister(String phone, String code,Integer areaCode) throws Exception { String scode = code.split("_")[0]; -// sendCode(phone,scode,areaCode); if (areaCode!=null&&areaCode>0&&areaCode!=86){ return smsUtil.sendSmsAbroad(""+areaCode+phone,scode); }else { @@ -93,37 +82,6 @@ public class MyUserServiceImpl extends ServiceImpl impl return userEbookBuyEntity != null; } - private void sendCode(String phone, String code, Integer areaCode) throws Exception { - com.aliyun.dysmsapi20170525.Client client = Sample.createClient(smsConfig.getAccessKeyId(),smsConfig.getAccessKeySecret()); - String tem; - if(areaCode!=null&&areaCode>0&&areaCode!=86){ - tem = smsConfig.getSTemplateCode(); - phone = areaCode+phone; - }else{ - tem = smsConfig.getTemplateCode(); - } - SendSmsRequest sendSmsRequest = new SendSmsRequest() - .setSignName(smsConfig.getSingName()) - .setTemplateCode(tem) - .setPhoneNumbers(phone) - .setTemplateParam("{\"code\":\""+ code +"\"}"); - RuntimeOptions runtime = new RuntimeOptions(); - try { - // 复制代码运行请自行打印 API 的返回值 - SendSmsResponse sendSmsResponse = client.sendSmsWithOptions(sendSmsRequest, runtime); - SendSmsResponseBody body = sendSmsResponse.getBody(); -// System.out.println(body.getMessage()); - - } catch (TeaException error) { - // 如有需要,请打印 error - Common.assertAsString(error.message); - } catch (Exception _error) { - TeaException error = new TeaException(_error.getMessage(), _error); - // 如有需要,请打印 error - com.aliyun.teautil.Common.assertAsString(error.message); - } - } - @Override public boolean checkUserTelOrEmail(MyUserEntity user) { LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); diff --git a/src/main/java/com/peanut/modules/book/service/impl/UserAddressServiceImpl.java b/src/main/java/com/peanut/modules/book/service/impl/UserAddressServiceImpl.java index bd1120d0..066c4440 100644 --- a/src/main/java/com/peanut/modules/book/service/impl/UserAddressServiceImpl.java +++ b/src/main/java/com/peanut/modules/book/service/impl/UserAddressServiceImpl.java @@ -86,7 +86,8 @@ public class UserAddressServiceImpl extends ServiceImpl queryWrapper = new QueryWrapper<>(); queryWrapper.eq("user_id", userId); queryWrapper.eq("is_default", 1); - return this.count(queryWrapper); + Long count = this.count(queryWrapper); + return count.intValue(); } public void clearUserDefaultAddress(Integer userId) { diff --git a/src/main/java/com/peanut/modules/book/to/UserRecordDto.java b/src/main/java/com/peanut/modules/book/to/UserRecordDto.java deleted file mode 100644 index e94c537b..00000000 --- a/src/main/java/com/peanut/modules/book/to/UserRecordDto.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.peanut.modules.book.to; - -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableLogic; -import lombok.Data; - -import javax.persistence.Temporal; -import javax.persistence.TemporalType; -import java.io.Serializable; -import java.util.Date; -import java.util.List; - -@Data -public class UserRecordDto implements Serializable { - - - - private String[] images; - - - - -} diff --git a/src/main/java/com/peanut/modules/common/controller/ClassController.java b/src/main/java/com/peanut/modules/common/controller/ClassController.java index dc1c2404..4b58b118 100644 --- a/src/main/java/com/peanut/modules/common/controller/ClassController.java +++ b/src/main/java/com/peanut/modules/common/controller/ClassController.java @@ -3,33 +3,25 @@ package com.peanut.modules.common.controller; import cn.hutool.core.date.DateUtil; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import com.github.promeg.pinyinhelper.Pinyin; -import com.peanut.common.utils.DateUtils; import com.peanut.common.utils.R; import com.peanut.common.utils.ShiroUtils; -import com.peanut.modules.common.dao.ClassExamUserDao; import com.peanut.modules.common.entity.*; import com.peanut.modules.common.service.*; import com.peanut.modules.medical.service.CourseService; import lombok.extern.slf4j.Slf4j; -import org.apache.commons.lang.ArrayUtils; import org.apache.commons.lang.StringUtils; import org.apache.poi.ss.usermodel.Row; import org.apache.poi.ss.usermodel.Sheet; import org.apache.poi.xssf.usermodel.XSSFWorkbook; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.data.redis.core.StringRedisTemplate; import org.springframework.transaction.annotation.Transactional; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; - -import javax.imageio.ImageIO; -import javax.servlet.http.HttpServletResponse; +import jakarta.servlet.http.HttpServletResponse; import java.io.IOException; import java.io.OutputStream; import java.math.BigDecimal; -import java.net.URL; import java.net.URLEncoder; import java.util.HashSet; import java.util.List; @@ -267,7 +259,7 @@ public class ClassController { ClassEntity classEntity = classEntityService.getById(classTask.getClassId()); if (classEntity.getId()>168){ ClassModel classModel = classModelService.getById(classEntity.getModelId()); - int taskCount = classTaskService.count(new LambdaQueryWrapper() + Long taskCount = classTaskService.count(new LambdaQueryWrapper() .eq(ClassTask::getClassId,classEntity.getId()) .eq(ClassTask::getType,"2") .eq(ClassTask::getUserId,ShiroUtils.getUId())); diff --git a/src/main/java/com/peanut/modules/common/controller/CouponController.java b/src/main/java/com/peanut/modules/common/controller/CouponController.java index 935c6f11..53fe52e9 100644 --- a/src/main/java/com/peanut/modules/common/controller/CouponController.java +++ b/src/main/java/com/peanut/modules/common/controller/CouponController.java @@ -19,7 +19,6 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import java.util.List; import java.util.Map; -import java.util.Set; @Slf4j @RestController("commonCoupon") @@ -59,8 +58,9 @@ public class CouponController { Page couponPage = couponService.page(new Page<>(page, limit), wrapper); for (CouponEntity couponEntity : couponPage.getRecords()) { couponService.setRangeList(couponEntity); - couponEntity.setGrantCount(couponHistoryService.count(new LambdaQueryWrapper() - .eq(CouponHistory::getCouponId,couponEntity.getId()))); + Long count = couponHistoryService.count(new LambdaQueryWrapper() + .eq(CouponHistory::getCouponId,couponEntity.getId())); + couponEntity.setGrantCount(count.intValue()); } return R.ok().put("couponPage",couponPage); } @@ -110,8 +110,9 @@ public class CouponController { public R getCouponInfo(@RequestBody Map params){ CouponEntity couponEntity = couponService.getByIdSetRange(Integer.parseInt(params.get("id").toString())); couponService.setRangeList(couponEntity); - couponEntity.setGrantCount(couponHistoryService.count(new LambdaQueryWrapper() - .eq(CouponHistory::getCouponId,couponEntity.getId()))); + Long count = couponHistoryService.count(new LambdaQueryWrapper() + .eq(CouponHistory::getCouponId,couponEntity.getId())); + couponEntity.setGrantCount(count.intValue()); return R.ok().put("couponEntity",couponEntity); } @@ -136,7 +137,7 @@ public class CouponController { @Transactional public R delCoupon(@RequestBody Map params){ int couponId = Integer.parseInt(params.get("id").toString()); - int count = couponHistoryService.count(new LambdaQueryWrapper() + Long count = couponHistoryService.count(new LambdaQueryWrapper() .eq(CouponHistory::getCouponId,couponId)); if (count>0){ return R.error("已有用户拥有优惠券"); diff --git a/src/main/java/com/peanut/modules/common/controller/CourseRelearnController.java b/src/main/java/com/peanut/modules/common/controller/CourseRelearnController.java index 55d885da..958ca31c 100644 --- a/src/main/java/com/peanut/modules/common/controller/CourseRelearnController.java +++ b/src/main/java/com/peanut/modules/common/controller/CourseRelearnController.java @@ -9,7 +9,6 @@ import com.peanut.common.utils.ShiroUtils; import com.peanut.config.Constants; import com.peanut.config.DelayQueueConfig; import com.peanut.modules.book.service.TransactionDetailsService; -import com.peanut.modules.common.dao.CourseToMedicineDao; import com.peanut.modules.common.entity.*; import com.peanut.modules.common.service.*; import com.peanut.modules.common.service.JfTransactionDetailsService; @@ -27,8 +26,6 @@ import org.springframework.transaction.annotation.Transactional; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; - -import java.io.IOException; import java.math.BigDecimal; import java.math.RoundingMode; import java.util.ArrayList; @@ -102,10 +99,10 @@ public class CourseRelearnController { if (cc != null) { CourseEntity courseEntity = courseService.getById(cc.getCourseId()); if (courseEntity != null) { - int mCount = courseToMedicalService.count(new LambdaQueryWrapper().eq(CourseToMedicine::getCourseId,courseEntity.getId())); - int sCount = courseToSociologyService.count(new LambdaQueryWrapper().eq(CourseToSociologyEntity::getCourseId,courseEntity.getId())); - int pCount = courseToPsycheService.count(new LambdaQueryWrapper().eq(CourseToPsyche::getCourseId,courseEntity.getId())); - int tCount = courseToTaihumedService.count(new LambdaQueryWrapper().eq(CourseToTaihumed::getCourseId,courseEntity.getId())); + Long mCount = courseToMedicalService.count(new LambdaQueryWrapper().eq(CourseToMedicine::getCourseId,courseEntity.getId())); + Long sCount = courseToSociologyService.count(new LambdaQueryWrapper().eq(CourseToSociologyEntity::getCourseId,courseEntity.getId())); + Long pCount = courseToPsycheService.count(new LambdaQueryWrapper().eq(CourseToPsyche::getCourseId,courseEntity.getId())); + Long tCount = courseToTaihumedService.count(new LambdaQueryWrapper().eq(CourseToTaihumed::getCourseId,courseEntity.getId())); if (mCount>0||sCount > 0||pCount > 0||tCount > 0){ List list = userCourseBuyService.list(new MPJLambdaWrapper() .disableLogicDel()//查询出已删除数据 @@ -134,10 +131,10 @@ public class CourseRelearnController { if (cc != null) { CourseEntity courseEntity = courseService.getById(cc.getCourseId()); if (courseEntity != null){ - int mCount = courseToMedicalService.count(new LambdaQueryWrapper().eq(CourseToMedicine::getCourseId,courseEntity.getId())); - int sCount = courseToSociologyService.count(new LambdaQueryWrapper().eq(CourseToSociologyEntity::getCourseId,courseEntity.getId())); - int pCount = courseToPsycheService.count(new LambdaQueryWrapper().eq(CourseToPsyche::getCourseId,courseEntity.getId())); - int tCount = courseToTaihumedService.count(new LambdaQueryWrapper().eq(CourseToTaihumed::getCourseId,courseEntity.getId())); + Long mCount = courseToMedicalService.count(new LambdaQueryWrapper().eq(CourseToMedicine::getCourseId,courseEntity.getId())); + Long sCount = courseToSociologyService.count(new LambdaQueryWrapper().eq(CourseToSociologyEntity::getCourseId,courseEntity.getId())); + Long pCount = courseToPsycheService.count(new LambdaQueryWrapper().eq(CourseToPsyche::getCourseId,courseEntity.getId())); + Long tCount = courseToTaihumedService.count(new LambdaQueryWrapper().eq(CourseToTaihumed::getCourseId,courseEntity.getId())); if (mCount>0||sCount > 0||pCount > 0||tCount > 0){ MPJLambdaWrapper wrapper = new MPJLambdaWrapper<>(); wrapper.leftJoin(ShopProductCourseEntity.class,ShopProductCourseEntity::getProductId,ShopProduct::getProductId); diff --git a/src/main/java/com/peanut/modules/common/controller/ExpressController.java b/src/main/java/com/peanut/modules/common/controller/ExpressController.java index 4190852c..3514eda8 100644 --- a/src/main/java/com/peanut/modules/common/controller/ExpressController.java +++ b/src/main/java/com/peanut/modules/common/controller/ExpressController.java @@ -85,8 +85,8 @@ public class ExpressController { Page expressOrderPage = new Page<>(currentPage, pageSize); QueryWrapper expressOrderQueryWrapper = new QueryWrapper<>(); - int totalDataSize = expressOrderService.count(expressOrderQueryWrapper); - int totalPage = totalDataSize / pageSize + 1; + Long totalDataSize = expressOrderService.count(expressOrderQueryWrapper); + int totalPage = totalDataSize.intValue() / pageSize + 1; Page page = expressOrderService.page(expressOrderPage, expressOrderQueryWrapper); List expressOrderList = page.getRecords(); List data = new ArrayList<>(); diff --git a/src/main/java/com/peanut/modules/common/controller/TrainingClassController.java b/src/main/java/com/peanut/modules/common/controller/TrainingClassController.java index 72d79fe5..31dc7c62 100644 --- a/src/main/java/com/peanut/modules/common/controller/TrainingClassController.java +++ b/src/main/java/com/peanut/modules/common/controller/TrainingClassController.java @@ -21,7 +21,7 @@ import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; -import javax.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletRequest; import java.math.BigDecimal; import java.util.Date; import java.util.List; @@ -92,7 +92,7 @@ public class TrainingClassController { if (m!=null&m.containsKey("fee")){ trainingClass.setFinalFee(m.get("fee").toString()); } - int count = trainingToUserService.count(new LambdaQueryWrapper() + Long count = trainingToUserService.count(new LambdaQueryWrapper() .eq(TrainingToUser::getUserId, ShiroUtils.getUId()) .eq(TrainingToUser::getTrainingId,trainingClass.getId())); if (count > 0) { diff --git a/src/main/java/com/peanut/modules/common/controller/UserVipController.java b/src/main/java/com/peanut/modules/common/controller/UserVipController.java index 6e7cdbba..1859c022 100644 --- a/src/main/java/com/peanut/modules/common/controller/UserVipController.java +++ b/src/main/java/com/peanut/modules/common/controller/UserVipController.java @@ -24,8 +24,8 @@ import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; -import javax.servlet.http.HttpServletRequest; -import javax.transaction.Transactional; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.transaction.Transactional; import java.math.BigDecimal; import java.util.*; import java.util.stream.Collectors; diff --git a/src/main/java/com/peanut/modules/common/entity/PayWechatOrderEntity.java b/src/main/java/com/peanut/modules/common/entity/PayWechatOrderEntity.java index 66484e12..20ecb5f9 100644 --- a/src/main/java/com/peanut/modules/common/entity/PayWechatOrderEntity.java +++ b/src/main/java/com/peanut/modules/common/entity/PayWechatOrderEntity.java @@ -3,10 +3,6 @@ package com.peanut.modules.common.entity; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import lombok.Data; -import org.joda.time.DateTime; - -import javax.persistence.Column; -import javax.xml.soap.Text; import java.io.Serializable; import java.math.BigDecimal; import java.util.Date; diff --git a/src/main/java/com/peanut/modules/common/entity/UserAppAuthorEntity.java b/src/main/java/com/peanut/modules/common/entity/UserAppAuthorEntity.java index 8988a386..15a3cd6f 100644 --- a/src/main/java/com/peanut/modules/common/entity/UserAppAuthorEntity.java +++ b/src/main/java/com/peanut/modules/common/entity/UserAppAuthorEntity.java @@ -2,8 +2,8 @@ package com.peanut.modules.common.entity; import lombok.Data; -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; +import jakarta.validation.constraints.NotEmpty; +import jakarta.validation.constraints.NotNull; @Data public class UserAppAuthorEntity { diff --git a/src/main/java/com/peanut/modules/common/entity/UserFeedbackEntity.java b/src/main/java/com/peanut/modules/common/entity/UserFeedbackEntity.java index b4e1e616..754bb03c 100644 --- a/src/main/java/com/peanut/modules/common/entity/UserFeedbackEntity.java +++ b/src/main/java/com/peanut/modules/common/entity/UserFeedbackEntity.java @@ -5,8 +5,8 @@ import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import lombok.Data; -import javax.persistence.Temporal; -import javax.persistence.TemporalType; +import jakarta.persistence.Temporal; +import jakarta.persistence.TemporalType; import java.util.Date; /** diff --git a/src/main/java/com/peanut/modules/common/entity/UserFollowUpEntity.java b/src/main/java/com/peanut/modules/common/entity/UserFollowUpEntity.java index 1b9eb17a..72264ec1 100644 --- a/src/main/java/com/peanut/modules/common/entity/UserFollowUpEntity.java +++ b/src/main/java/com/peanut/modules/common/entity/UserFollowUpEntity.java @@ -6,8 +6,8 @@ import com.baomidou.mybatisplus.annotation.TableLogic; import com.baomidou.mybatisplus.annotation.TableName; import lombok.Data; -import javax.persistence.Temporal; -import javax.persistence.TemporalType; +import jakarta.persistence.Temporal; +import jakarta.persistence.TemporalType; import java.util.Date; /** diff --git a/src/main/java/com/peanut/modules/common/entity/UserRecord.java b/src/main/java/com/peanut/modules/common/entity/UserRecord.java index 6d36f0ff..f57cddf9 100644 --- a/src/main/java/com/peanut/modules/common/entity/UserRecord.java +++ b/src/main/java/com/peanut/modules/common/entity/UserRecord.java @@ -6,8 +6,8 @@ import com.baomidou.mybatisplus.annotation.TableLogic; import com.baomidou.mybatisplus.annotation.TableName; import lombok.Data; -import javax.persistence.Temporal; -import javax.persistence.TemporalType; +import jakarta.persistence.Temporal; +import jakarta.persistence.TemporalType; import java.util.Date; @Data diff --git a/src/main/java/com/peanut/modules/common/service/impl/ClassEntityServiceImpl.java b/src/main/java/com/peanut/modules/common/service/impl/ClassEntityServiceImpl.java index 24d4c6b1..4c2dddea 100644 --- a/src/main/java/com/peanut/modules/common/service/impl/ClassEntityServiceImpl.java +++ b/src/main/java/com/peanut/modules/common/service/impl/ClassEntityServiceImpl.java @@ -270,29 +270,29 @@ public class ClassEntityServiceImpl extends ServiceImpl() - .eq(ClassUser::getClassId,classEntity.getId()).eq(ClassUser::getRole,"1")); + .eq(ClassUser::getClassId,classEntity.getId()).eq(ClassUser::getRole,"1")).intValue(); if (monitorCount<1){ return R.error("请先设置班长"); } int dmonitorCount = classUserDao.selectCount(new LambdaQueryWrapper() - .eq(ClassUser::getClassId,classEntity.getId()).eq(ClassUser::getRole,"2")); + .eq(ClassUser::getClassId,classEntity.getId()).eq(ClassUser::getRole,"2")).intValue(); if (dmonitorCount<1){ return R.error("请先设置副班长"); } int studyCount = classUserDao.selectCount(new LambdaQueryWrapper() - .eq(ClassUser::getClassId,classEntity.getId()).eq(ClassUser::getRole,"3")); + .eq(ClassUser::getClassId,classEntity.getId()).eq(ClassUser::getRole,"3")).intValue(); if (studyCount<1){ return R.error("请先设置学习委员"); } int commentCount = classUserDao.selectCount(new LambdaQueryWrapper() - .eq(ClassUser::getClassId,classEntity.getId()).eq(ClassUser::getRole,"4")); + .eq(ClassUser::getClassId,classEntity.getId()).eq(ClassUser::getRole,"4")).intValue(); if (commentCount<3){ return R.error("请先设置3位评分员"); } if (classModel.getIsTask()==1){ int taskCount = classTaskDao.selectCount(new LambdaQueryWrapper() - .eq(ClassTask::getClassId,classEntity.getId()).eq(ClassTask::getType,"0")); + .eq(ClassTask::getClassId,classEntity.getId()).eq(ClassTask::getType,"0")).intValue(); double allWeek = Math.ceil((classModel.getDays())/7.0)-2; if (taskCount() - .eq(ClassUser::getClassId,classEntity.getId()).eq(ClassUser::getRole,"0")); + .eq(ClassUser::getClassId,classEntity.getId()).eq(ClassUser::getRole,"0")).intValue(); if (studentCount() - .eq(ClassExamSubject::getCourseId,classCourse.getCourseId()).eq(ClassExamSubject::getType,"0")); + .eq(ClassExamSubject::getCourseId,classCourse.getCourseId()).eq(ClassExamSubject::getType,"0")).intValue(); if (singleCount() - .eq(ClassExamSubject::getCourseId,classCourse.getCourseId()).eq(ClassExamSubject::getType,"1")); + .eq(ClassExamSubject::getCourseId,classCourse.getCourseId()).eq(ClassExamSubject::getType,"1")).intValue(); if (multipleCount() .eq(UserCourseBuyEntity::getUserId,classUser.getUserId()) - .eq(UserCourseBuyEntity::getCatalogueId,catalog.getId())); + .eq(UserCourseBuyEntity::getCatalogueId,catalog.getId())).intValue(); if (ucbCount == 0){ flag = true; CourseEntity c = courseDao.selectById(classCourse.getCourseId()); @@ -541,7 +541,7 @@ public class ClassEntityServiceImpl extends ServiceImpl() .eq(ClassUser::getClassId,classEntity.getId()) - .eq(ClassUser::getRole,0)); + .eq(ClassUser::getRole,0)).intValue(); if (count > 0){ return R.error("还有学员存在,删除失败。"); }else { @@ -599,7 +599,7 @@ public class ClassEntityServiceImpl extends ServiceImpl() .eq(UserCourseBuyEntity::getUserId,user.getId()) - .eq(UserCourseBuyEntity::getCatalogueId,catalog.getId())); + .eq(UserCourseBuyEntity::getCatalogueId,catalog.getId())).intValue(); if (ucbCount > 0){ sb.append(course.getTitle()+"-"+catalog.getTitle()+"已购买 ");//空格用来分割多门课程 }else { @@ -729,7 +729,7 @@ public class ClassEntityServiceImpl extends ServiceImpl() .eq(UserCourseBuyEntity::getUserId,user.getId()) - .eq(UserCourseBuyEntity::getCatalogueId,catalog.getId())); + .eq(UserCourseBuyEntity::getCatalogueId,catalog.getId())).intValue(); if (ucbCount == 0){ CourseEntity courseEntity = courseDao.selectById(classCourse.getCourseId()); if (StringUtils.isEmpty(msg)){ @@ -760,7 +760,7 @@ public class ClassEntityServiceImpl extends ServiceImpl() .and(t->t.eq(UserCertificate::getType,"A").or().eq(UserCertificate::getType,"B")) .eq(UserCertificate::getCourseId,classCourse.getCourseId()) - .eq(UserCertificate::getUserId,ShiroUtils.getUId())); + .eq(UserCertificate::getUserId,ShiroUtils.getUId())).intValue(); if (count>0){ return R.error("已获得相关课程证书"); } @@ -780,7 +780,7 @@ public class ClassEntityServiceImpl extends ServiceImpl() .eq(ClassUser::getClassId,classEntity.getId()) - .eq(ClassUser::getRole,"0")); + .eq(ClassUser::getRole,"0")).intValue(); if (count() .eq(ClassTaskAndQuesReply::getType,0) - .eq(ClassTaskAndQuesReply::getRelationId,classTask.getId())); + .eq(ClassTaskAndQuesReply::getRelationId,classTask.getId())).intValue(); int userNoCount = classTaskAndQuesReplyDao.selectCount(new LambdaQueryWrapper() .eq(ClassTaskAndQuesReply::getType,0) .eq(ClassTaskAndQuesReply::getRelationId,classTask.getId()) - .notLike(ClassTaskAndQuesReply::getScoreInfo,"\""+ShiroUtils.getUId()+"\"")); + .notLike(ClassTaskAndQuesReply::getScoreInfo,"\""+ShiroUtils.getUId()+"\"")).intValue(); Map result = new HashMap<>(); result.put("setGiveHomeWorkNumber",alreadyReply); result.put("userNoCount",userNoCount); @@ -1001,7 +1001,7 @@ public class ClassEntityServiceImpl extends ServiceImpl() .eq(ClassTaskAndQuesReply::getType,0) .eq(ClassTaskAndQuesReply::getRelationId,classTask.getId()) - .eq(ClassTaskAndQuesReply::getUserId,ShiroUtils.getUId())); + .eq(ClassTaskAndQuesReply::getUserId,ShiroUtils.getUId())).intValue(); if (count > 0) { classTask.setReply(true); }else { @@ -1016,7 +1016,7 @@ public class ClassEntityServiceImpl extends ServiceImpl() .eq(ClassTaskAndQuesReply::getType,classTaskAndQuesReply.getType()) .eq(ClassTaskAndQuesReply::getRelationId,classTaskAndQuesReply.getRelationId()) - .eq(ClassTaskAndQuesReply::getUserId,classTaskAndQuesReply.getUserId())); + .eq(ClassTaskAndQuesReply::getUserId,classTaskAndQuesReply.getUserId())).intValue(); if (c > 0) { return 2; } @@ -1161,14 +1161,14 @@ public class ClassEntityServiceImpl extends ServiceImpl() .eq(ClassTaskAndQuesReply::getType,0) .eq(ClassTaskAndQuesReply::getClassId,classEntity.getId()) - .notLike(ClassTaskAndQuesReply::getScoreInfo,"\""+ShiroUtils.getUId()+"\"")); + .notLike(ClassTaskAndQuesReply::getScoreInfo,"\""+ShiroUtils.getUId()+"\"")).intValue(); if (task0Replys > 0){ info += "任务"; } int quesReplys = classTaskAndQuesReplyDao.selectCount(new LambdaQueryWrapper() .eq(ClassTaskAndQuesReply::getType,1) .eq(ClassTaskAndQuesReply::getClassId,classEntity.getId()) - .notLike(ClassTaskAndQuesReply::getScoreInfo,"\""+ShiroUtils.getUId()+"\"")); + .notLike(ClassTaskAndQuesReply::getScoreInfo,"\""+ShiroUtils.getUId()+"\"")).intValue(); if (quesReplys > 0){ info += "思考题"; } @@ -1181,7 +1181,7 @@ public class ClassEntityServiceImpl extends ServiceImpl 0){ flag = true; } @@ -1192,7 +1192,7 @@ public class ClassEntityServiceImpl extends ServiceImpl() .eq(ClassTask::getClassId,cu.getClassId()) .eq(ClassTask::getType,2) - .notLike(ClassTask::getScoreInfo,"\""+ShiroUtils.getUId()+"\"")); + .notLike(ClassTask::getScoreInfo,"\""+ShiroUtils.getUId()+"\"")).intValue(); if (expReplys > 0){ info += "心得"; } @@ -1450,7 +1450,7 @@ public class ClassEntityServiceImpl extends ServiceImpl wrapper = new MPJLambdaWrapper(); wrapper.eq(ClassTask::getClassId,classEntity.getId()); wrapper.eq(ClassTask::getType,"0"); - int count = classTaskDao.selectCount(wrapper); + int count = classTaskDao.selectCount(wrapper).intValue(); BigDecimal totalScore = new BigDecimal(staticScore*count); task0Score = task0Score.divide(totalScore,2, RoundingMode.HALF_UP); task0Score = task0Score.multiply(new BigDecimal(classModel.getTaskScore())); @@ -1482,7 +1482,7 @@ public class ClassEntityServiceImpl extends ServiceImpl wrapper = new MPJLambdaWrapper(); wrapper.eq(ClassTask::getClassId,classEntity.getId()); wrapper.eq(ClassTask::getType,"1"); - int count = classTaskDao.selectCount(wrapper); + int count = classTaskDao.selectCount(wrapper).intValue(); BigDecimal totalScore = new BigDecimal(staticScore*count); task1Score = task1Score.divide(totalScore,2, RoundingMode.HALF_UP); task1Score = task1Score.multiply(new BigDecimal(classModel.getMedicalcaseScore())); @@ -1600,17 +1600,17 @@ public class ClassEntityServiceImpl extends ServiceImpl() .eq(ClassExamUser::getRelationId,classEntity.getId()) - .eq(ClassExamUser::getScoreSuccess,0)); + .eq(ClassExamUser::getScoreSuccess,0)).intValue(); if (classExamUsers>0){ return R.error("有学员正在考试,请稍后再试"); } int task0AndQuesReplys = classTaskAndQuesReplyDao.selectCount(new LambdaQueryWrapper() .eq(ClassTaskAndQuesReply::getClassId,classEntity.getId()) - .lt(ClassTaskAndQuesReply::getScoreSuccess,3)); + .lt(ClassTaskAndQuesReply::getScoreSuccess,3)).intValue(); int task1AndExpReplys = classTaskDao.selectCount(new LambdaQueryWrapper() .eq(ClassTask::getClassId,classEntity.getId()) .eq(ClassTask::getType,2) - .lt(ClassTask::getScoreSuccess,3)); + .lt(ClassTask::getScoreSuccess,3)).intValue(); if (task0AndQuesReplys>0||task1AndExpReplys>0){ return R.error("学员打分未完成,请完成打分后结班"); } diff --git a/src/main/java/com/peanut/modules/common/service/impl/CouponServiceImpl.java b/src/main/java/com/peanut/modules/common/service/impl/CouponServiceImpl.java index ddc296dc..b0ccac64 100644 --- a/src/main/java/com/peanut/modules/common/service/impl/CouponServiceImpl.java +++ b/src/main/java/com/peanut/modules/common/service/impl/CouponServiceImpl.java @@ -6,14 +6,11 @@ import com.github.yulichang.wrapper.MPJLambdaWrapper; import com.peanut.common.utils.DateUtils; import com.peanut.common.utils.R; import com.peanut.common.utils.ShiroUtils; -import com.peanut.config.DelayQueueConfig; import com.peanut.modules.common.dao.*; import com.peanut.modules.common.entity.*; import com.peanut.modules.common.service.CouponService; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang.StringUtils; -import org.springframework.amqp.core.MessagePostProcessor; -import org.springframework.amqp.rabbit.core.RabbitTemplate; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.math.BigDecimal; @@ -77,7 +74,7 @@ public class CouponServiceImpl extends ServiceImpl impl CouponEntity couponEntity = couponDao.selectById(couponId); if (couponEntity.getCurrentState()==0){ int historyCount = couponHistoryDao.selectCount(new LambdaQueryWrapper() - .eq(CouponHistory::getCouponId,couponId)); + .eq(CouponHistory::getCouponId,couponId)).intValue(); //是否超出总发行量 if (historyCount historyList = couponHistoryDao.selectList(new LambdaQueryWrapper() diff --git a/src/main/java/com/peanut/modules/common/service/impl/CourseGuestbookServiceImpl.java b/src/main/java/com/peanut/modules/common/service/impl/CourseGuestbookServiceImpl.java index a5870a48..4509d448 100644 --- a/src/main/java/com/peanut/modules/common/service/impl/CourseGuestbookServiceImpl.java +++ b/src/main/java/com/peanut/modules/common/service/impl/CourseGuestbookServiceImpl.java @@ -4,19 +4,16 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.github.yulichang.wrapper.MPJLambdaWrapper; -import com.peanut.common.utils.ShiroUtils; import com.peanut.modules.common.dao.CourseGuestbookDao; import com.peanut.modules.common.dao.CourseGuestbookSupportDao; import com.peanut.modules.common.dao.MyUserDao; import com.peanut.modules.common.entity.CourseGuestbook; import com.peanut.modules.common.entity.CourseGuestbookSupport; -import com.peanut.modules.common.entity.MyUserEntity; import com.peanut.modules.common.service.CourseGuestbookService; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; - import java.util.List; import java.util.Map; @@ -92,14 +89,14 @@ public class CourseGuestbookServiceImpl extends ServiceImpl wrapper = new LambdaQueryWrapper<>(); wrapper.eq(CourseGuestbookSupport::getGuestbookId,guestbookId); - return supportDao.selectCount(wrapper); + return supportDao.selectCount(wrapper).intValue(); } public boolean getUserSupport(int guestbookId,int userId) { LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); wrapper.eq(CourseGuestbookSupport::getGuestbookId,guestbookId); wrapper.eq(CourseGuestbookSupport::getUserId,userId); - int c = supportDao.selectCount(wrapper); + int c = supportDao.selectCount(wrapper).intValue(); if (c>0){ return true; }else { diff --git a/src/main/java/com/peanut/modules/common/service/impl/CoursePsycheServiceImpl.java b/src/main/java/com/peanut/modules/common/service/impl/CoursePsycheServiceImpl.java index 7e01d392..f8a2ec46 100644 --- a/src/main/java/com/peanut/modules/common/service/impl/CoursePsycheServiceImpl.java +++ b/src/main/java/com/peanut/modules/common/service/impl/CoursePsycheServiceImpl.java @@ -15,7 +15,6 @@ import com.peanut.modules.common.to.ParamTo; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; - import java.util.List; import java.util.stream.Collectors; @@ -86,7 +85,7 @@ public class CoursePsycheServiceImpl extends ServiceImpl().eq(CoursePsyche::getPid, id)); + Long count = this.count(new LambdaQueryWrapper().eq(CoursePsyche::getPid, id)); if(count>0){ return R.error(501,"删除失败,请先删除子项目后再尝试"); } diff --git a/src/main/java/com/peanut/modules/common/service/impl/MyUserServiceImpl.java b/src/main/java/com/peanut/modules/common/service/impl/MyUserServiceImpl.java index 3800ece4..9bd4bf32 100644 --- a/src/main/java/com/peanut/modules/common/service/impl/MyUserServiceImpl.java +++ b/src/main/java/com/peanut/modules/common/service/impl/MyUserServiceImpl.java @@ -1,16 +1,8 @@ package com.peanut.modules.common.service.impl; -import com.aliyun.dysmsapi20170525.models.SendSmsRequest; -import com.aliyun.dysmsapi20170525.models.SendSmsResponse; -import com.aliyun.dysmsapi20170525.models.SendSmsResponseBody; -import com.aliyun.tea.TeaException; -import com.aliyun.teautil.Common; -import com.aliyun.teautil.models.RuntimeOptions; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.peanut.common.utils.R; import com.peanut.common.utils.SmsUtil; -import com.peanut.modules.app.config.SMSConfig; -import com.peanut.modules.app.config.Sample; import com.peanut.modules.common.dao.MyUserDao; import com.peanut.modules.common.entity.MyUserEntity; import com.peanut.modules.common.service.MyUserService; @@ -22,15 +14,12 @@ import org.springframework.stereotype.Service; @Service("commonMyUserService") public class MyUserServiceImpl extends ServiceImpl implements MyUserService { - @Autowired - private SMSConfig smsConfig; @Autowired private SmsUtil smsUtil; @Override public R sendCodeForRegister(String phone, String code, Integer areaCode){ String scode = code.split("_")[0]; -// sendCode(phone,scode,areaCode); if (areaCode!=null&&areaCode>0&&areaCode!=86){ return smsUtil.sendSmsAbroad(""+areaCode+phone,scode); }else { @@ -38,36 +27,4 @@ public class MyUserServiceImpl extends ServiceImpl impl } } - private void sendCode(String phone, String code, Integer areaCode) throws Exception { - com.aliyun.dysmsapi20170525.Client client = Sample.createClient(smsConfig.getAccessKeyId(),smsConfig.getAccessKeySecret()); - String tem; - if(areaCode!=null&&areaCode>0&&areaCode!=86){ - tem = smsConfig.getSTemplateCode(); - phone = areaCode+phone; - }else{ - tem = smsConfig.getTemplateCode(); - } - SendSmsRequest sendSmsRequest = new SendSmsRequest() - .setSignName(smsConfig.getSingName()) - .setTemplateCode(tem) - .setPhoneNumbers(phone) - .setTemplateParam("{\"code\":\""+ code +"\"}"); - RuntimeOptions runtime = new RuntimeOptions(); - try { - // 复制代码运行请自行打印 API 的返回值 - SendSmsResponse sendSmsResponse = client.sendSmsWithOptions(sendSmsRequest, runtime); - SendSmsResponseBody body = sendSmsResponse.getBody(); -// System.out.println(body.getMessage()); - } catch (TeaException error) { - // 如有需要,请打印 error - Common.assertAsString(error.message); - } catch (Exception _error) { - TeaException error = new TeaException(_error.getMessage(), _error); - // 如有需要,请打印 error - com.aliyun.teautil.Common.assertAsString(error.message); - } - } - - - } diff --git a/src/main/java/com/peanut/modules/common/service/impl/TrainingClassServiceImpl.java b/src/main/java/com/peanut/modules/common/service/impl/TrainingClassServiceImpl.java index 951e3b7e..882d5b0f 100644 --- a/src/main/java/com/peanut/modules/common/service/impl/TrainingClassServiceImpl.java +++ b/src/main/java/com/peanut/modules/common/service/impl/TrainingClassServiceImpl.java @@ -39,7 +39,7 @@ public class TrainingClassServiceImpl extends ServiceImpl() + Long count = userVipService.count(new LambdaQueryWrapper() .eq(UserVip::getUserId,userId).eq(UserVip::getType,vipType).eq(UserVip::getState,0)); if (count>0){ fee = trainingClass.getVipFee(); @@ -113,7 +113,7 @@ public class TrainingClassServiceImpl extends ServiceImpl() + Long count = trainingToUserService.count(new LambdaQueryWrapper() .eq(TrainingToUser::getUserId,buyOrder.getUserId()) .eq(TrainingToUser::getTrainingId,buyOrder.getTrainingClassId())); if (count == 0){ diff --git a/src/main/java/com/peanut/modules/common/service/impl/UserInviteRegisterServiceImpl.java b/src/main/java/com/peanut/modules/common/service/impl/UserInviteRegisterServiceImpl.java index 7a645361..322793f2 100644 --- a/src/main/java/com/peanut/modules/common/service/impl/UserInviteRegisterServiceImpl.java +++ b/src/main/java/com/peanut/modules/common/service/impl/UserInviteRegisterServiceImpl.java @@ -57,7 +57,7 @@ public class UserInviteRegisterServiceImpl extends ServiceImpl() - .eq(MyUserEntity::getInviteCode,inviteCode.toString())); + .eq(MyUserEntity::getInviteCode,inviteCode.toString())).intValue(); if (count > 0) { code = generateInviteCode(); }else { diff --git a/src/main/java/com/peanut/modules/job/entity/ScheduleJobEntity.java b/src/main/java/com/peanut/modules/job/entity/ScheduleJobEntity.java index ec2eb567..a86d954b 100644 --- a/src/main/java/com/peanut/modules/job/entity/ScheduleJobEntity.java +++ b/src/main/java/com/peanut/modules/job/entity/ScheduleJobEntity.java @@ -13,7 +13,7 @@ import com.baomidou.mybatisplus.annotation.TableName; import com.fasterxml.jackson.annotation.JsonFormat; import lombok.Data; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; import java.io.Serializable; import java.util.Date; diff --git a/src/main/java/com/peanut/modules/job/service/impl/ScheduleJobServiceImpl.java b/src/main/java/com/peanut/modules/job/service/impl/ScheduleJobServiceImpl.java index 51e6ed11..c4aff040 100644 --- a/src/main/java/com/peanut/modules/job/service/impl/ScheduleJobServiceImpl.java +++ b/src/main/java/com/peanut/modules/job/service/impl/ScheduleJobServiceImpl.java @@ -25,7 +25,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import javax.annotation.PostConstruct; +import jakarta.annotation.PostConstruct; import java.util.*; @Service("scheduleJobService") diff --git a/src/main/java/com/peanut/modules/job/task/AiVipTask.java b/src/main/java/com/peanut/modules/job/task/AiVipTask.java index afc99ab3..ebb03934 100644 --- a/src/main/java/com/peanut/modules/job/task/AiVipTask.java +++ b/src/main/java/com/peanut/modules/job/task/AiVipTask.java @@ -30,7 +30,7 @@ public class AiVipTask implements ITask{ if (aiVipLog.getEndTime().getTime() params) { - int count = buyOrderService.count(new LambdaQueryWrapper() + Long count = buyOrderService.count(new LambdaQueryWrapper() .eq(BuyOrder::getOrderStatus,3) .eq(BuyOrder::getProductId,params.get("id").toString())); if (count > 0) { diff --git a/src/main/java/com/peanut/modules/master/controller/CourseMedicineMarketController.java b/src/main/java/com/peanut/modules/master/controller/CourseMedicineMarketController.java index 1bc06710..67c8b08c 100644 --- a/src/main/java/com/peanut/modules/master/controller/CourseMedicineMarketController.java +++ b/src/main/java/com/peanut/modules/master/controller/CourseMedicineMarketController.java @@ -3,7 +3,6 @@ package com.peanut.modules.master.controller; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.github.yulichang.wrapper.MPJLambdaWrapper; -import com.peanut.common.utils.ObjectUtils; import com.peanut.common.utils.R; import com.peanut.modules.common.entity.*; import com.peanut.modules.common.to.ParamTo; @@ -57,14 +56,14 @@ public class CourseMedicineMarketController { public R editSociologyMarket(@RequestBody CourseMedicineMarketEntity courseMedicineMarketEntity){ CourseMedicineMarketEntity old = marketService.getById(courseMedicineMarketEntity.getId()); if(courseMedicineMarketEntity.getIsLast()==1&&old.getIsLast()==0){//非终节点到终结点,要排除是否存在子集 - Integer integer = marketService.getBaseMapper().selectCount(new LambdaQueryWrapper().eq(CourseMedicineMarketEntity::getPid, courseMedicineMarketEntity.getId())); + Integer integer = marketService.getBaseMapper().selectCount(new LambdaQueryWrapper().eq(CourseMedicineMarketEntity::getPid, courseMedicineMarketEntity.getId())).intValue(); if(integer>0){ return R.error("请先清空子集再操作!"); } } if(courseMedicineMarketEntity.getIsLast()==0&&old.getIsLast()==1){ - Integer integer = toMarketService.getBaseMapper().selectCount(new LambdaQueryWrapper().eq(CourseToMedicineMarketEntity::getMedicineMarketId, courseMedicineMarketEntity.getId())); + Integer integer = toMarketService.getBaseMapper().selectCount(new LambdaQueryWrapper().eq(CourseToMedicineMarketEntity::getMedicineMarketId, courseMedicineMarketEntity.getId())).intValue(); if(integer>0){ return R.error("请先清空绑定的课程后,再操作"); } @@ -130,7 +129,7 @@ public class CourseMedicineMarketController { public R bindCourseAndMedicineMarket(@RequestBody Map map){ int marketId = map.get("marketId"); int courseId = map.get("courseId"); - Integer integer = toMarketService.getBaseMapper().selectCount(new LambdaQueryWrapper().eq(CourseToMedicineMarketEntity::getMedicineMarketId, marketId).eq(CourseToMedicineMarketEntity::getCourseId, courseId)); + Integer integer = toMarketService.getBaseMapper().selectCount(new LambdaQueryWrapper().eq(CourseToMedicineMarketEntity::getMedicineMarketId, marketId).eq(CourseToMedicineMarketEntity::getCourseId, courseId)).intValue(); if(integer>0){ return R.error("不可重复绑定"); } diff --git a/src/main/java/com/peanut/modules/master/controller/CoursePsycheMarketController.java b/src/main/java/com/peanut/modules/master/controller/CoursePsycheMarketController.java index 0b548f44..74abecb9 100644 --- a/src/main/java/com/peanut/modules/master/controller/CoursePsycheMarketController.java +++ b/src/main/java/com/peanut/modules/master/controller/CoursePsycheMarketController.java @@ -58,14 +58,14 @@ public class CoursePsycheMarketController { public R editPsycheMarket(@RequestBody CoursePsycheMarket coursePsycheMarket){ CoursePsycheMarket old = marketService.getById(coursePsycheMarket.getId()); if(coursePsycheMarket.getIsLast()==1&&old.getIsLast()==0){//非终节点到终结点,要排除是否存在子集 - Integer integer = marketService.getBaseMapper().selectCount(new LambdaQueryWrapper().eq(CoursePsycheMarket::getPid, coursePsycheMarket.getId())); + Integer integer = marketService.getBaseMapper().selectCount(new LambdaQueryWrapper().eq(CoursePsycheMarket::getPid, coursePsycheMarket.getId())).intValue(); if(integer>0){ return R.error("请先清空子集再操作!"); } } if(coursePsycheMarket.getIsLast()==0&&old.getIsLast()==1){ - Integer integer = toMarketService.getBaseMapper().selectCount(new LambdaQueryWrapper().eq(CourseToPsycheMarket::getPsycheMarketId, coursePsycheMarket.getId())); + Integer integer = toMarketService.getBaseMapper().selectCount(new LambdaQueryWrapper().eq(CourseToPsycheMarket::getPsycheMarketId, coursePsycheMarket.getId())).intValue(); if(integer>0){ return R.error("请先清空绑定的课程后,再操作"); } @@ -129,7 +129,7 @@ public class CoursePsycheMarketController { public R bindCourseAndPsycheMarket(@RequestBody Map map){ int marketId = map.get("marketId"); int courseId = map.get("courseId"); - Integer integer = toMarketService.getBaseMapper().selectCount(new LambdaQueryWrapper().eq(CourseToPsycheMarket::getPsycheMarketId, marketId).eq(CourseToPsycheMarket::getCourseId, courseId)); + Integer integer = toMarketService.getBaseMapper().selectCount(new LambdaQueryWrapper().eq(CourseToPsycheMarket::getPsycheMarketId, marketId).eq(CourseToPsycheMarket::getCourseId, courseId)).intValue(); if(integer>0){ return R.error("不可重复绑定"); } diff --git a/src/main/java/com/peanut/modules/master/controller/CourseSociologyMarketController.java b/src/main/java/com/peanut/modules/master/controller/CourseSociologyMarketController.java index 4c159367..7d6a2f9b 100644 --- a/src/main/java/com/peanut/modules/master/controller/CourseSociologyMarketController.java +++ b/src/main/java/com/peanut/modules/master/controller/CourseSociologyMarketController.java @@ -3,7 +3,6 @@ package com.peanut.modules.master.controller; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.github.yulichang.wrapper.MPJLambdaWrapper; -import com.peanut.common.utils.ObjectUtils; import com.peanut.common.utils.R; import com.peanut.modules.common.entity.*; import com.peanut.modules.common.to.ParamTo; @@ -14,7 +13,6 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; - import java.util.List; import java.util.Map; import java.util.stream.Collectors; @@ -56,14 +54,14 @@ public class CourseSociologyMarketController { public R editSociologyMarket(@RequestBody CourseSociologyMarketEntity courseSociologyMarketEntity){ CourseSociologyMarketEntity old = marketService.getById(courseSociologyMarketEntity.getId()); if(courseSociologyMarketEntity.getIsLast()==1&&old.getIsLast()==0){//非终节点到终结点,要排除是否存在子集 - Integer integer = marketService.getBaseMapper().selectCount(new LambdaQueryWrapper().eq(CourseSociologyMarketEntity::getPid, courseSociologyMarketEntity.getId())); + Integer integer = marketService.getBaseMapper().selectCount(new LambdaQueryWrapper().eq(CourseSociologyMarketEntity::getPid, courseSociologyMarketEntity.getId())).intValue(); if(integer>0){ return R.error("请先清空子集再操作!"); } } if(courseSociologyMarketEntity.getIsLast()==0&&old.getIsLast()==1){ - Integer integer = toMarketService.getBaseMapper().selectCount(new LambdaQueryWrapper().eq(CourseToSociologyMarketEntity::getSociologyMarketId, courseSociologyMarketEntity.getId())); + Integer integer = toMarketService.getBaseMapper().selectCount(new LambdaQueryWrapper().eq(CourseToSociologyMarketEntity::getSociologyMarketId, courseSociologyMarketEntity.getId())).intValue(); if(integer>0){ return R.error("请先清空绑定的课程后,再操作"); } @@ -158,7 +156,7 @@ public class CourseSociologyMarketController { public R bindCourseAndSociologyMarket(@RequestBody Map map){ int marketId = map.get("marketId"); int courseId = map.get("courseId"); - Integer integer = toMarketService.getBaseMapper().selectCount(new LambdaQueryWrapper().eq(CourseToSociologyMarketEntity::getSociologyMarketId, marketId).eq(CourseToSociologyMarketEntity::getCourseId, courseId)); + Integer integer = toMarketService.getBaseMapper().selectCount(new LambdaQueryWrapper().eq(CourseToSociologyMarketEntity::getSociologyMarketId, marketId).eq(CourseToSociologyMarketEntity::getCourseId, courseId)).intValue(); if(integer>0){ return R.error("不可重复绑定"); } diff --git a/src/main/java/com/peanut/modules/master/controller/CourseTaihumedController.java b/src/main/java/com/peanut/modules/master/controller/CourseTaihumedController.java index ef04ddbe..9b0afc2d 100644 --- a/src/main/java/com/peanut/modules/master/controller/CourseTaihumedController.java +++ b/src/main/java/com/peanut/modules/master/controller/CourseTaihumedController.java @@ -12,7 +12,6 @@ import com.peanut.modules.common.entity.CourseToTalent; import com.peanut.modules.common.service.CourseTaihumedService; import com.peanut.modules.common.service.CourseToTaihumedService; import com.peanut.modules.common.service.CourseToTalentService; -import com.peanut.modules.common.to.ParamTo; import com.peanut.modules.master.service.CourseService; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; @@ -20,7 +19,6 @@ import org.springframework.transaction.annotation.Transactional; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; - import java.util.List; import java.util.Map; import java.util.stream.Collectors; @@ -55,7 +53,7 @@ public class CourseTaihumedController { @RequestMapping("/delCourseTaihumed") public R delCourseTaihumed(@RequestBody Map params){ //查看下一级是否存在 - int count = courseTaihumedService.count(new LambdaQueryWrapper() + Long count = courseTaihumedService.count(new LambdaQueryWrapper() .eq(CourseTaihumed::getPid, params.get("id"))); if(count>0){ return R.error(501,"删除失败,请先删除子项目后再尝试"); @@ -86,7 +84,7 @@ public class CourseTaihumedController { } } if(old.getIsLast()==1&& courseTaihumed.getIsLast()==0){ - Integer integer = courseToTaihumedService.count(new LambdaQueryWrapper() + Long integer = courseToTaihumedService.count(new LambdaQueryWrapper() .eq(CourseToTaihumed::getTaihumedId, courseTaihumed.getId())); if(integer>0){ return R.error(502,"更新失败,请先把此项与课程的关联关系清空后才可把此标签变成普通标签"); diff --git a/src/main/java/com/peanut/modules/master/controller/OfflineActivityController.java b/src/main/java/com/peanut/modules/master/controller/OfflineActivityController.java index f3253ec4..5d1c7754 100644 --- a/src/main/java/com/peanut/modules/master/controller/OfflineActivityController.java +++ b/src/main/java/com/peanut/modules/master/controller/OfflineActivityController.java @@ -76,7 +76,7 @@ public class OfflineActivityController { @RequestMapping("/updateOfflineActivity") public R updateOfflineActivity(@RequestBody OfflineActivity offlineActivity) { - int count = toUserService.count(new LambdaQueryWrapper() + Long count = toUserService.count(new LambdaQueryWrapper() .eq(OfflineActivityToUser::getActivityId,offlineActivity.getId())); if (count > 0) { return R.error("已有人报名禁止修改"); @@ -87,7 +87,7 @@ public class OfflineActivityController { @RequestMapping("/delOfflineActivity") public R delOfflineActivity(@RequestBody Map params) { - int count = toUserService.count(new LambdaQueryWrapper() + Long count = toUserService.count(new LambdaQueryWrapper() .eq(OfflineActivityToUser::getActivityId,params.get("id").toString())); if (count > 0) { return R.error("已有人报名禁止删除"); diff --git a/src/main/java/com/peanut/modules/master/controller/TaihuTalentController.java b/src/main/java/com/peanut/modules/master/controller/TaihuTalentController.java index 83f95ced..888149be 100644 --- a/src/main/java/com/peanut/modules/master/controller/TaihuTalentController.java +++ b/src/main/java/com/peanut/modules/master/controller/TaihuTalentController.java @@ -76,7 +76,7 @@ public class TaihuTalentController { if(one != null){ return R.error(501,"绑定失败,绑定关系已将存在"); } - int count = courseToTalentService.count(new LambdaQueryWrapper() + Long count = courseToTalentService.count(new LambdaQueryWrapper() .eq(CourseToTalent::getCourseId, courseToTalent.getCourseId())); List ctts = courseToTaihumedService.list(new LambdaQueryWrapper() .eq(CourseToTaihumed::getCourseId,courseToTalent.getCourseId())); diff --git a/src/main/java/com/peanut/modules/master/controller/TrainingClassController.java b/src/main/java/com/peanut/modules/master/controller/TrainingClassController.java index d2c6d2ef..13ced114 100644 --- a/src/main/java/com/peanut/modules/master/controller/TrainingClassController.java +++ b/src/main/java/com/peanut/modules/master/controller/TrainingClassController.java @@ -20,7 +20,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; -import javax.servlet.http.HttpServletResponse; +import jakarta.servlet.http.HttpServletResponse; import java.io.IOException; import java.io.OutputStream; import java.net.URLEncoder; diff --git a/src/main/java/com/peanut/modules/master/controller/UserCertificateController.java b/src/main/java/com/peanut/modules/master/controller/UserCertificateController.java index 68c80025..c0207efc 100644 --- a/src/main/java/com/peanut/modules/master/controller/UserCertificateController.java +++ b/src/main/java/com/peanut/modules/master/controller/UserCertificateController.java @@ -22,7 +22,7 @@ import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; -import javax.servlet.http.HttpServletResponse; +import jakarta.servlet.http.HttpServletResponse; import java.io.IOException; import java.io.OutputStream; import java.net.URLEncoder; @@ -224,7 +224,7 @@ public class UserCertificateController { } } if(oldLabel.getIsLast()==1&& label.getIsLast()==0){ - Integer integer = userCertificateService.count(new LambdaQueryWrapper() + Long integer = userCertificateService.count(new LambdaQueryWrapper() .eq(UserCertificate::getLabelId, label.getId())); if(integer>0){ return R.error("更新失败,标签下存在证书"); @@ -238,13 +238,13 @@ public class UserCertificateController { @RequestMapping("/delUserCertificateLabel") public R delUserCertificateLabel(@RequestBody Map params) { //查看下一级是否存在 - int count = userCertificateLabelService.count(new LambdaQueryWrapper() + Long count = userCertificateLabelService.count(new LambdaQueryWrapper() .eq(UserCertificateLabel::getPid, params.get("id"))); if(count>0){ return R.error("删除失败,请先删除子项目后再尝试"); } //查看绑定关系是否存在 - Integer integer = userCertificateService.count(new LambdaQueryWrapper() + Long integer = userCertificateService.count(new LambdaQueryWrapper() .eq(UserCertificate::getLabelId, params.get("id"))); if(integer>0){ return R.error("删除失败,标签下存在证书"); diff --git a/src/main/java/com/peanut/modules/master/controller/UserContributionController.java b/src/main/java/com/peanut/modules/master/controller/UserContributionController.java index 139820c0..fe04b5fe 100644 --- a/src/main/java/com/peanut/modules/master/controller/UserContributionController.java +++ b/src/main/java/com/peanut/modules/master/controller/UserContributionController.java @@ -21,7 +21,7 @@ import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; -import javax.servlet.http.HttpServletResponse; +import jakarta.servlet.http.HttpServletResponse; import java.io.OutputStream; import java.math.BigDecimal; import java.net.URLEncoder; @@ -79,7 +79,7 @@ public class UserContributionController { @RequestMapping("/delUserContributionLabelList") public R delUserContributionLabelList(@RequestBody Map params) { SysDictDataEntity sysDictDataEntity = sysDictDataService.getById(params.get("id").toString()); - int count = contributionService.count(new LambdaQueryWrapper() + Long count = contributionService.count(new LambdaQueryWrapper() .eq(UserContribution::getType,sysDictDataEntity.getDictType())); if (count > 0){ return R.error("已存在湖分记录"); diff --git a/src/main/java/com/peanut/modules/master/controller/UserVipController.java b/src/main/java/com/peanut/modules/master/controller/UserVipController.java index 71bd519c..6b6f1b02 100644 --- a/src/main/java/com/peanut/modules/master/controller/UserVipController.java +++ b/src/main/java/com/peanut/modules/master/controller/UserVipController.java @@ -14,7 +14,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; -import javax.transaction.Transactional; +import jakarta.transaction.Transactional; import java.math.BigDecimal; import java.util.*; diff --git a/src/main/java/com/peanut/modules/master/service/impl/CourseCatalogueChapterVideoServiceImpl.java b/src/main/java/com/peanut/modules/master/service/impl/CourseCatalogueChapterVideoServiceImpl.java index c713f957..40bd70f6 100644 --- a/src/main/java/com/peanut/modules/master/service/impl/CourseCatalogueChapterVideoServiceImpl.java +++ b/src/main/java/com/peanut/modules/master/service/impl/CourseCatalogueChapterVideoServiceImpl.java @@ -19,7 +19,6 @@ import com.peanut.modules.master.service.CourseCatalogueChapterVideoService; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; - import java.util.*; @Slf4j @@ -109,7 +108,7 @@ public class CourseCatalogueChapterVideoServiceImpl extends ServiceImpl().eq(VideoM3u8Entity::getVid, video.getVideo())); + Integer integer = videoM3u8Dao.selectCount(new LambdaQueryWrapper().eq(VideoM3u8Entity::getVid, video.getVideo())).intValue(); if(integer>0){ String s = playToken.generateToken(); GetPlayInfoResponseBody urlBody = SpdbUtil.getUrl(video.getVideo()); @@ -206,7 +205,7 @@ public class CourseCatalogueChapterVideoServiceImpl extends ServiceImpl i.apply("end_time IS NULL OR end_time > {0}", new Date())); // wrapper.and(r->r.isNull(UserCourseBuyEntity::getEndTime).or().gt(UserCourseBuyEntity::getEndTime,new Date())); - Integer integer = userCourseBuyDao.selectCount(wrapper); + Integer integer = userCourseBuyDao.selectCount(wrapper).intValue(); return integer>0; } } diff --git a/src/main/java/com/peanut/modules/master/service/impl/CourseCatalogueServiceImpl.java b/src/main/java/com/peanut/modules/master/service/impl/CourseCatalogueServiceImpl.java index 862486b8..c8781718 100644 --- a/src/main/java/com/peanut/modules/master/service/impl/CourseCatalogueServiceImpl.java +++ b/src/main/java/com/peanut/modules/master/service/impl/CourseCatalogueServiceImpl.java @@ -11,7 +11,6 @@ import com.peanut.modules.master.service.CourseCatalogueService; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; - import java.math.BigDecimal; import java.util.Date; import java.util.List; @@ -54,19 +53,19 @@ public class CourseCatalogueServiceImpl extends ServiceImpl().eq(CourseCatalogueChapterEntity::getCatalogueId, id)); + Integer integer = courseCatalogueChapterDao.selectCount(new LambdaQueryWrapper().eq(CourseCatalogueChapterEntity::getCatalogueId, id)).intValue(); if(integer>0){ return R.error(502,"删除失败,请先清空章节"); } LambdaQueryWrapper userCourseBuyEntityLambdaQueryWrapper = new LambdaQueryWrapper<>(); userCourseBuyEntityLambdaQueryWrapper.eq(UserCourseBuyEntity::getCatalogueId,id); userCourseBuyEntityLambdaQueryWrapper.gt(UserCourseBuyEntity::getEndTime,new Date()); - Integer integer1 = userCourseBuyDao.selectCount(userCourseBuyEntityLambdaQueryWrapper); + Integer integer1 = userCourseBuyDao.selectCount(userCourseBuyEntityLambdaQueryWrapper).intValue(); if(integer1>0){ return R.error(502,"删除失败,有人已购买此课程"); } - Integer integer2 = shopProductCourseDao.selectCount(new LambdaQueryWrapper().eq(ShopProductCourseEntity::getCatalogueId, id)); + Integer integer2 = shopProductCourseDao.selectCount(new LambdaQueryWrapper().eq(ShopProductCourseEntity::getCatalogueId, id)).intValue(); if(integer2>0){ return R.error(503,"删除失败,有商品已绑定此课程,请解绑或删除后再操作"); } @@ -96,7 +95,7 @@ public class CourseCatalogueServiceImpl extends ServiceImpl() - .eq(ShopProductCourseEntity::getCatalogueId, byId.getId())); + .eq(ShopProductCourseEntity::getCatalogueId, byId.getId())).intValue(); if(integer>1){ return R.error("生成失败!已存在商品数量大于等于2,快捷生成商品不可用"); } diff --git a/src/main/java/com/peanut/modules/master/service/impl/CourseMedicineServiceImpl.java b/src/main/java/com/peanut/modules/master/service/impl/CourseMedicineServiceImpl.java index 7fcced9e..3325f9fa 100644 --- a/src/main/java/com/peanut/modules/master/service/impl/CourseMedicineServiceImpl.java +++ b/src/main/java/com/peanut/modules/master/service/impl/CourseMedicineServiceImpl.java @@ -13,7 +13,6 @@ import com.peanut.modules.master.service.CourseMedicalService; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; - import java.util.List; @Slf4j @@ -33,7 +32,7 @@ public class CourseMedicineServiceImpl extends ServiceImpl().eq(CourseMedicine::getPid, id)); + Long count = this.count(new LambdaQueryWrapper().eq(CourseMedicine::getPid, id)); if(count>0){ return R.error(501,"删除失败,请先删除子项目后再尝试"); } @@ -62,7 +61,7 @@ public class CourseMedicineServiceImpl extends ServiceImpl().eq(CourseToMedicine::getMedicalId, courseMedicine.getId())); + Integer integer = toMedicalDao.selectCount(new LambdaQueryWrapper().eq(CourseToMedicine::getMedicalId, courseMedicine.getId())).intValue(); if(integer>0){ return R.error(502,"更新失败,请先把此项与课程的关联关系清空后才可把此标签变成普通标签"); } diff --git a/src/main/java/com/peanut/modules/master/service/impl/CourseServiceImpl.java b/src/main/java/com/peanut/modules/master/service/impl/CourseServiceImpl.java index 5633e485..bbca3199 100644 --- a/src/main/java/com/peanut/modules/master/service/impl/CourseServiceImpl.java +++ b/src/main/java/com/peanut/modules/master/service/impl/CourseServiceImpl.java @@ -11,7 +11,6 @@ import com.peanut.modules.common.dao.*; import com.peanut.modules.common.entity.*; import com.peanut.modules.common.to.ParamTo; import com.peanut.modules.master.service.CourseService; -import io.swagger.models.auth.In; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -105,7 +104,7 @@ public class CourseServiceImpl extends ServiceImpl impl @Override public R delCourse(int id) { - Integer integer = courseCatalogueDao.selectCount(new LambdaQueryWrapper().eq(CourseCatalogueEntity::getCourseId, id)); + Integer integer = courseCatalogueDao.selectCount(new LambdaQueryWrapper().eq(CourseCatalogueEntity::getCourseId, id)).intValue(); if (integer>0){ return R.error(501,"请先删除目录后再删除!"); } diff --git a/src/main/java/com/peanut/modules/master/service/impl/CourseSociologyServiceImpl.java b/src/main/java/com/peanut/modules/master/service/impl/CourseSociologyServiceImpl.java index 2d4f0554..5e5c95be 100644 --- a/src/main/java/com/peanut/modules/master/service/impl/CourseSociologyServiceImpl.java +++ b/src/main/java/com/peanut/modules/master/service/impl/CourseSociologyServiceImpl.java @@ -13,7 +13,6 @@ import com.peanut.modules.master.service.CourseSociologyService; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; - import java.util.List; @Slf4j @@ -33,7 +32,7 @@ public class CourseSociologyServiceImpl extends ServiceImpl().eq(CourseSociologyEntity::getPid, id)); + Long count = this.count(new LambdaQueryWrapper().eq(CourseSociologyEntity::getPid, id)); if(count>0){ return R.error(501,"删除失败,请先删除子项目后再尝试"); } diff --git a/src/main/java/com/peanut/modules/master/service/impl/ShopProductServiceImpl.java b/src/main/java/com/peanut/modules/master/service/impl/ShopProductServiceImpl.java index 4480ff25..45a01ad4 100644 --- a/src/main/java/com/peanut/modules/master/service/impl/ShopProductServiceImpl.java +++ b/src/main/java/com/peanut/modules/master/service/impl/ShopProductServiceImpl.java @@ -83,7 +83,7 @@ public class ShopProductServiceImpl extends ServiceImpl().eq(ShopProductToBookLabel::getProductId, Integer.valueOf(id)).eq(ShopProductToBookLabel::getBookLabelId, labelId)); + Integer integer = shopProductToBookLabelDao.selectCount(new LambdaQueryWrapper().eq(ShopProductToBookLabel::getProductId, Integer.valueOf(id)).eq(ShopProductToBookLabel::getBookLabelId, labelId)).intValue(); if(integer>0){ continue; } @@ -102,7 +102,7 @@ public class ShopProductServiceImpl extends ServiceImpl().eq(ShopProductToBookMarket::getProductId, Integer.valueOf(p)).eq(ShopProductToBookMarket::getBookMarketId, marketId)); + Integer integer = shopProductToBookMarketDao.selectCount(new LambdaQueryWrapper().eq(ShopProductToBookMarket::getProductId, Integer.valueOf(p)).eq(ShopProductToBookMarket::getBookMarketId, marketId)).intValue(); if(integer>0){ continue; } @@ -121,7 +121,7 @@ public class ShopProductServiceImpl extends ServiceImpl().eq(ShopProductToSociologyLabel::getProductId, Integer.valueOf(p)).eq(ShopProductToSociologyLabel::getSociologyLabelId, labelId)); + Integer integer = shopProductToSociologyLabelDao.selectCount(new LambdaQueryWrapper().eq(ShopProductToSociologyLabel::getProductId, Integer.valueOf(p)).eq(ShopProductToSociologyLabel::getSociologyLabelId, labelId)).intValue(); if(integer>0){ continue; } @@ -140,7 +140,7 @@ public class ShopProductServiceImpl extends ServiceImpl().eq(ShopProductToSociologyMarket::getProductId, Integer.valueOf(p)).eq(ShopProductToSociologyMarket::getSociologyMarketId, marketId)); + Integer integer = shopProductToSociologyMarketDao.selectCount(new LambdaQueryWrapper().eq(ShopProductToSociologyMarket::getProductId, Integer.valueOf(p)).eq(ShopProductToSociologyMarket::getSociologyMarketId, marketId)).intValue(); if(integer>0){ continue; } @@ -160,7 +160,7 @@ public class ShopProductServiceImpl extends ServiceImpl().eq(ShopProductToPsycheLabel::getProductId, Integer.valueOf(p)).eq(ShopProductToPsycheLabel::getPsycheLabelId, labelId)); + Integer integer = shopProductToPsycheLabelDao.selectCount(new LambdaQueryWrapper().eq(ShopProductToPsycheLabel::getProductId, Integer.valueOf(p)).eq(ShopProductToPsycheLabel::getPsycheLabelId, labelId)).intValue(); if(integer>0){ continue; } @@ -179,7 +179,7 @@ public class ShopProductServiceImpl extends ServiceImpl().eq(ShopProductToPsycheMarket::getProductId, Integer.valueOf(p)).eq(ShopProductToPsycheMarket::getPsycheMarketId, marketId)); + Integer integer = shopProductToPsycheMarketDao.selectCount(new LambdaQueryWrapper().eq(ShopProductToPsycheMarket::getProductId, Integer.valueOf(p)).eq(ShopProductToPsycheMarket::getPsycheMarketId, marketId)).intValue(); if(integer>0){ continue; } @@ -198,7 +198,7 @@ public class ShopProductServiceImpl extends ServiceImpl().eq(ShopProductToMedicineLabel::getProductId, Integer.valueOf(p)).eq(ShopProductToMedicineLabel::getMedicineLabelId, labelId)); + Integer integer = shopProductToMedicineLabelDao.selectCount(new LambdaQueryWrapper().eq(ShopProductToMedicineLabel::getProductId, Integer.valueOf(p)).eq(ShopProductToMedicineLabel::getMedicineLabelId, labelId)).intValue(); if(integer>0){ continue; } @@ -217,7 +217,7 @@ public class ShopProductServiceImpl extends ServiceImpl().eq(ShopProductToMedicineMarket::getProductId, Integer.valueOf(p)).eq(ShopProductToMedicineMarket::getMedicineMarketId, marketId)); + Integer integer = shopProductToMedicineMarketDao.selectCount(new LambdaQueryWrapper().eq(ShopProductToMedicineMarket::getProductId, Integer.valueOf(p)).eq(ShopProductToMedicineMarket::getMedicineMarketId, marketId)).intValue(); if(integer>0){ continue; } @@ -256,7 +256,7 @@ public class ShopProductServiceImpl extends ServiceImpl().eq(ShopProductBookEntity::getProductId, productId).eq(ShopProductBookEntity::getBookId, bookId)); + Integer integer = shopProductBookDao.selectCount(new LambdaQueryWrapper().eq(ShopProductBookEntity::getProductId, productId).eq(ShopProductBookEntity::getBookId, bookId)).intValue(); if(integer>0){ return R.error("重复绑定"); } @@ -306,7 +306,7 @@ public class ShopProductServiceImpl extends ServiceImpl().eq(ShopProductCourseEntity::getProductId, shopProductCourseEntity.getProductId()).eq(ShopProductCourseEntity::getCourseId, shopProductCourseEntity.getCourseId())); + Integer integer = shopProductCourseDao.selectCount(new LambdaQueryWrapper().eq(ShopProductCourseEntity::getProductId, shopProductCourseEntity.getProductId()).eq(ShopProductCourseEntity::getCourseId, shopProductCourseEntity.getCourseId())).intValue(); if(integer>0){ return R.error("不可重复绑定"); } @@ -329,7 +329,7 @@ public class ShopProductServiceImpl extends ServiceImpl wrapper = new LambdaQueryWrapper<>(); wrapper.eq(BuyOrder::getProductId,productId); wrapper.in(BuyOrder::getOrderType,Arrays.asList(0,1,2)); - Integer integer = buyOrderDao.selectCount(wrapper); + Integer integer = buyOrderDao.selectCount(wrapper).intValue(); if(integer>0){ return R.error(505,"删除失败,有人下单,且订单未完成"); } diff --git a/src/main/java/com/peanut/modules/master/service/impl/ShopStoreServiceImpl.java b/src/main/java/com/peanut/modules/master/service/impl/ShopStoreServiceImpl.java index 37d415e6..732c86b1 100644 --- a/src/main/java/com/peanut/modules/master/service/impl/ShopStoreServiceImpl.java +++ b/src/main/java/com/peanut/modules/master/service/impl/ShopStoreServiceImpl.java @@ -20,7 +20,7 @@ public class ShopStoreServiceImpl extends ServiceImpl i @Override public R delStore(int id) { - Integer integer = shopStoreToProductDao.selectCount(new LambdaQueryWrapper().eq(ShopStoreToProductEntity::getStoreId, id)); + Integer integer = shopStoreToProductDao.selectCount(new LambdaQueryWrapper().eq(ShopStoreToProductEntity::getStoreId, id)).intValue(); if(integer>0){ return R.error("请先清空后,再操作"); } diff --git a/src/main/java/com/peanut/modules/master/service/impl/UserCourseBuyServiceImpl.java b/src/main/java/com/peanut/modules/master/service/impl/UserCourseBuyServiceImpl.java index 790db591..cc164a82 100644 --- a/src/main/java/com/peanut/modules/master/service/impl/UserCourseBuyServiceImpl.java +++ b/src/main/java/com/peanut/modules/master/service/impl/UserCourseBuyServiceImpl.java @@ -102,7 +102,7 @@ public class UserCourseBuyServiceImpl extends ServiceImpl() .eq(UserCourseBuyEntity::getCatalogueId, s) - .eq(UserCourseBuyEntity::getUserId, m.getId())); + .eq(UserCourseBuyEntity::getUserId, m.getId())).intValue(); if (check > 0) { AddCoursesFrag addCoursesFrag = new AddCoursesFrag(); addCoursesFrag.setUserId(m.getId()); diff --git a/src/main/java/com/peanut/modules/medical/service/impl/CourseMedicalServiceImpl.java b/src/main/java/com/peanut/modules/medical/service/impl/CourseMedicalServiceImpl.java index 7c0b9b12..7077bbd5 100644 --- a/src/main/java/com/peanut/modules/medical/service/impl/CourseMedicalServiceImpl.java +++ b/src/main/java/com/peanut/modules/medical/service/impl/CourseMedicalServiceImpl.java @@ -119,7 +119,7 @@ public class CourseMedicalServiceImpl extends ServiceImpl() .eq(UserCourseBuyEntity::getCatalogueId, cc.getId()) - .eq(UserCourseBuyEntity::getUserId, ShiroUtils.getUId())); + .eq(UserCourseBuyEntity::getUserId, ShiroUtils.getUId())).intValue(); cc.setIsBuy(i>0?1:0); }else { cc.setIsBuy(1); diff --git a/src/main/java/com/peanut/modules/medical/service/impl/CourseServiceImpl.java b/src/main/java/com/peanut/modules/medical/service/impl/CourseServiceImpl.java index 22aadee5..df9708c6 100644 --- a/src/main/java/com/peanut/modules/medical/service/impl/CourseServiceImpl.java +++ b/src/main/java/com/peanut/modules/medical/service/impl/CourseServiceImpl.java @@ -94,7 +94,7 @@ public class CourseServiceImpl extends ServiceImpl impl public R addUserCourseStudying(UserCourseStudying userCourseStudying) { int isExist = studyingDao.selectCount(new LambdaQueryWrapper() .eq(UserCourseStudying::getUserId,userCourseStudying.getUserId()) - .eq(UserCourseStudying::getCourseId,userCourseStudying.getCourseId())); + .eq(UserCourseStudying::getCourseId,userCourseStudying.getCourseId())).intValue(); if (isExist>0){ return R.error("已存在"); }else { @@ -209,7 +209,7 @@ public class CourseServiceImpl extends ServiceImpl impl for (CourseEntity co:courseEntities){ int i = studyingDao.selectCount(new LambdaQueryWrapper() .eq(UserCourseStudying::getCourseId,co.getId()) - .eq(UserCourseStudying::getUserId,ShiroUtils.getUId())); + .eq(UserCourseStudying::getUserId,ShiroUtils.getUId())).intValue(); co.setIsStudying(i>0?1:0); MPJLambdaWrapper catalogueWrapper = new MPJLambdaWrapper(); catalogueWrapper.eq(CourseCatalogueEntity::getCourseId, co.getId()); @@ -269,7 +269,7 @@ public class CourseServiceImpl extends ServiceImpl impl if (userVip == null) { int ucb = userCourseBuyDao.selectCount(new LambdaQueryWrapper() .eq(UserCourseBuyEntity::getUserId,param.get("userId")) - .eq(UserCourseBuyEntity::getCatalogueId,c.get("catalogueId"))); + .eq(UserCourseBuyEntity::getCatalogueId,c.get("catalogueId"))).intValue(); if (ucb == 0) { res.add(c); } diff --git a/src/main/java/com/peanut/modules/medical/service/impl/VipBuyConfigServiceImpl.java b/src/main/java/com/peanut/modules/medical/service/impl/VipBuyConfigServiceImpl.java index 0d530465..09f0a4d5 100644 --- a/src/main/java/com/peanut/modules/medical/service/impl/VipBuyConfigServiceImpl.java +++ b/src/main/java/com/peanut/modules/medical/service/impl/VipBuyConfigServiceImpl.java @@ -33,8 +33,8 @@ public class VipBuyConfigServiceImpl extends ServiceImpl().eq(UserVip::getUserId, uid).eq(UserVip::getType, 1).gt(UserVip::getEndTime,new Date()).eq(UserVip::getState,0)); - Integer medicalCount = userVipDao.selectCount(new LambdaQueryWrapper().eq(UserVip::getUserId, uid).eq(UserVip::getType, 2).gt(UserVip::getEndTime, new Date()).eq(UserVip::getState, 0)); + Integer chaoCount = userVipDao.selectCount(new LambdaQueryWrapper().eq(UserVip::getUserId, uid).eq(UserVip::getType, 1).gt(UserVip::getEndTime,new Date()).eq(UserVip::getState,0)).intValue(); + Integer medicalCount = userVipDao.selectCount(new LambdaQueryWrapper().eq(UserVip::getUserId, uid).eq(UserVip::getType, 2).gt(UserVip::getEndTime, new Date()).eq(UserVip::getState, 0)).intValue(); //获取超v列表 LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); wrapper.in(VipBuyConfigEntity::getType,userEntity.getVip().equals("1")||userEntity.getVip().equals("3")? Collections.singletonList(1): Arrays.asList(1,2)); diff --git a/src/main/java/com/peanut/modules/mq/Consumer/CommonConsumer.java b/src/main/java/com/peanut/modules/mq/Consumer/CommonConsumer.java index 9ffa55de..f51a895f 100644 --- a/src/main/java/com/peanut/modules/mq/Consumer/CommonConsumer.java +++ b/src/main/java/com/peanut/modules/mq/Consumer/CommonConsumer.java @@ -80,7 +80,7 @@ public class CommonConsumer { for (CourseCatalogueEntity catalog:catalogues){ int ucbCount = userCourseBuyDao.selectCount(new LambdaQueryWrapper() .eq(UserCourseBuyEntity::getUserId,user.getId()) - .eq(UserCourseBuyEntity::getCatalogueId,catalog.getId())); + .eq(UserCourseBuyEntity::getCatalogueId,catalog.getId())).intValue(); if (ucbCount == 0){ Map map = new HashMap<>(); map.put("classId",classEntity.getId()); diff --git a/src/main/java/com/peanut/modules/oss/cloud/CloudStorageConfig.java b/src/main/java/com/peanut/modules/oss/cloud/CloudStorageConfig.java index a044e762..5b3bfdcc 100644 --- a/src/main/java/com/peanut/modules/oss/cloud/CloudStorageConfig.java +++ b/src/main/java/com/peanut/modules/oss/cloud/CloudStorageConfig.java @@ -16,8 +16,8 @@ import lombok.Data; import org.hibernate.validator.constraints.Range; import org.hibernate.validator.constraints.URL; -import javax.validation.constraints.NotBlank; -import javax.validation.constraints.NotNull; +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; import java.io.Serializable; /** diff --git a/src/main/java/com/peanut/modules/oss/controller/OssController.java b/src/main/java/com/peanut/modules/oss/controller/OssController.java index 374a6458..024fd404 100644 --- a/src/main/java/com/peanut/modules/oss/controller/OssController.java +++ b/src/main/java/com/peanut/modules/oss/controller/OssController.java @@ -3,20 +3,15 @@ package com.peanut.modules.oss.controller; import com.peanut.common.utils.R; import com.peanut.modules.oss.service.OssService; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; -import java.util.UUID; - @Slf4j @RestController @RequestMapping("/oss/fileoss") @CrossOrigin -@Api("oss") public class OssController { @Autowired @@ -24,7 +19,6 @@ public class OssController { //上传头像的方法 @PostMapping - @ApiOperation("上传") public R uploadOssFile(MultipartFile file) { //获取上传文件 MultipartFile @@ -34,7 +28,6 @@ public class OssController { } @PostMapping("/uploadFileSchedule") - @ApiOperation("上传带进度条") public R uploadFileSchedule(@RequestParam("file") MultipartFile file,@RequestParam("uid") String uid) { String url = ossService.uploadFileSchedule(file,uid); return R.ok().put("url",url); diff --git a/src/main/java/com/peanut/modules/pay/IOSPay/model/dto/IapRequestDTO.java b/src/main/java/com/peanut/modules/pay/IOSPay/model/dto/IapRequestDTO.java index 0178aabf..f54bb03c 100644 --- a/src/main/java/com/peanut/modules/pay/IOSPay/model/dto/IapRequestDTO.java +++ b/src/main/java/com/peanut/modules/pay/IOSPay/model/dto/IapRequestDTO.java @@ -3,7 +3,7 @@ package com.peanut.modules.pay.IOSPay.model.dto; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.Data; -import javax.persistence.Column; +import jakarta.persistence.Column; import java.io.Serializable; @Data diff --git a/src/main/java/com/peanut/modules/pay/IOSPay/model/entities/IosPayOrderEntity.java b/src/main/java/com/peanut/modules/pay/IOSPay/model/entities/IosPayOrderEntity.java index 29bdc5d3..e7af9ac1 100644 --- a/src/main/java/com/peanut/modules/pay/IOSPay/model/entities/IosPayOrderEntity.java +++ b/src/main/java/com/peanut/modules/pay/IOSPay/model/entities/IosPayOrderEntity.java @@ -2,13 +2,6 @@ package com.peanut.modules.pay.IOSPay.model.entities; import com.baomidou.mybatisplus.annotation.*; import lombok.Data; -import lombok.Getter; -import lombok.Setter; -import lombok.Value; -import org.joda.time.DateTime; - -import javax.persistence.Column; -import javax.persistence.Id; import java.io.Serializable; import java.math.BigDecimal; import java.util.Date; diff --git a/src/main/java/com/peanut/modules/pay/alipay/controller/AliPayController.java b/src/main/java/com/peanut/modules/pay/alipay/controller/AliPayController.java index 5ef31b27..715db316 100644 --- a/src/main/java/com/peanut/modules/pay/alipay/controller/AliPayController.java +++ b/src/main/java/com/peanut/modules/pay/alipay/controller/AliPayController.java @@ -10,7 +10,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; -import javax.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletRequest; import java.util.Map; @@ -41,7 +41,6 @@ public class AliPayController { @RequestMapping( "/notify") public R notify_url(HttpServletRequest request) { Map parameterMap = request.getParameterMap(); - String jsonStr = JSONObject.toJSONString(parameterMap); String aliNotify = aliPayService.aliNotify(request); return R.ok().put("aliNotify",aliNotify); } diff --git a/src/main/java/com/peanut/modules/pay/alipay/service/AliPayService.java b/src/main/java/com/peanut/modules/pay/alipay/service/AliPayService.java index ed9a4700..eee1aac6 100644 --- a/src/main/java/com/peanut/modules/pay/alipay/service/AliPayService.java +++ b/src/main/java/com/peanut/modules/pay/alipay/service/AliPayService.java @@ -3,8 +3,7 @@ package com.peanut.modules.pay.alipay.service; import com.peanut.modules.pay.alipay.dto.AlipayDTO; -import com.peanut.modules.pay.alipay.dto.ReFundDTO; -import javax.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletRequest; import java.util.Map; diff --git a/src/main/java/com/peanut/modules/pay/alipay/service/impl/AliPayServiceImpl.java b/src/main/java/com/peanut/modules/pay/alipay/service/impl/AliPayServiceImpl.java index bd11fbca..f19e36fd 100644 --- a/src/main/java/com/peanut/modules/pay/alipay/service/impl/AliPayServiceImpl.java +++ b/src/main/java/com/peanut/modules/pay/alipay/service/impl/AliPayServiceImpl.java @@ -9,7 +9,6 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.github.yulichang.wrapper.MPJLambdaWrapper; import com.peanut.common.utils.CopyUtils; import com.peanut.common.utils.OrderUtils; -import com.peanut.common.utils.ShiroUtils; import com.peanut.modules.book.service.BookBuyConfigService; import com.peanut.modules.book.service.BuyOrderService; import com.peanut.modules.book.service.MyUserService; @@ -32,7 +31,7 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.interceptor.TransactionAspectSupport; -import javax.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletRequest; import java.math.BigDecimal; import java.util.*; import java.util.stream.Collectors; diff --git a/src/main/java/com/peanut/modules/pay/applePay/controller/ApplePayController.java b/src/main/java/com/peanut/modules/pay/applePay/controller/ApplePayController.java deleted file mode 100644 index 3d57ce5e..00000000 --- a/src/main/java/com/peanut/modules/pay/applePay/controller/ApplePayController.java +++ /dev/null @@ -1,150 +0,0 @@ -package com.peanut.modules.pay.applePay.controller; - - -import cn.hutool.crypto.SecureUtil; -import cn.hutool.json.JSONArray; -import cn.hutool.json.JSONObject; -import cn.hutool.json.JSONUtil; -import com.peanut.common.utils.R; -import com.peanut.modules.pay.applePay.service.ApplePayService; -import com.peanut.modules.pay.applePay.utils.ApplePayUtil; -import com.peanut.modules.pay.applePay.utils.IPayNotifyPo; -import com.peanut.modules.pay.IOSPay.Result; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import lombok.extern.slf4j.Slf4j; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.*; - -@Slf4j -@RestController -@Api(tags = {"苹果内购"}) -@RequestMapping(value = "/apple") -public class ApplePayController { - @Autowired - ApplePayService applePayService; - @Autowired - ApplePayUtil applePayUtil; - - /** - * @param :TransactionID订单号 - * @param :receipt订单加密收据 - * @Description: Ios客户端内购支付 - */ -// @PostMapping 文档显示都是post请求 - @RequestMapping("/applePay") - - public R doIosRequest(@RequestParam("receipt") String receipt, @RequestParam("TransactionID") String TransactionID) { - String verifyResult = applePayUtil.buyAppVerify(receipt, 0); - //苹果服务器没有返回验证结果 - if (verifyResult == null) { - return R.error(500,"服务器未接收到验证结果!"); -// return Result.failed(ResultCode.APPLE_NULL); - } else { - // -// return applePayService.getAppPay(verifyResult, TransactionID); - return R.ok(); -// return applePayService.doIosRequest(TransactionID,receipt,userId); - - } - } - - - /** - * IOS支付成功后通过APP回调服务器 - * - * @param iPayNotifyPo - * @return - */ - @ApiOperation("ios支付成功后验证结果") - @RequestMapping(value = "iPayNotify/", method = RequestMethod.POST) - @ResponseBody - public Result iPayNotify(@RequestBody IPayNotifyPo iPayNotifyPo) { - log.info("ios支付成功后验证结果[前端传递的ios支付参数:{}]", iPayNotifyPo.toString()); -// System.out.println("支付"); - String receipt = iPayNotifyPo.getTransactionReceipt(); - // 拿到收据的MD5 - String receiptMd5 = SecureUtil.md5(receipt); - // 查询数据库,看是否是己经验证过的该支付收据 -// boolean existsIOSReceipt = paymentService.isExistsIOSReceipt(receiptMd5); -// if (existsIOSReceipt) { -// return Result.error("该充值已完成"); -// } - - // 1.先线上测试 发送平台验证 - - - String verifyResult = ApplePayUtil.buyAppVerify(receipt, 0); - - - log.info("1,苹果返回的参数:{}]", verifyResult); - if (verifyResult == null) { - // 苹果服务器没有返回验证结果 - log.info("苹果服务器没有返回验证结果"); - return Result.error("订单没有找到"); - } else { - // 苹果验证有返回结果 - JSONObject job = JSONUtil.parseObj(verifyResult); - log.info("2,[苹果验证返回的json串:{}]", job.toString()); - String states = job.getStr("status"); - - if ("21007".equals(states)) { - log.debug("是沙盒环境,应沙盒测试,否则执行下面"); - // 是沙盒环境,应沙盒测试,否则执行下面 - // 2.再沙盒测试 发送平台验证 - verifyResult = ApplePayUtil.buyAppVerify(receipt, 0); - job = JSONUtil.parseObj(verifyResult); - log.debug("3,沙盒环境验证返回的json字符串=" + job.toString()); - states = job.getStr("status"); - } - if ("0".equals(states)) { // 前端所提供的收据是有效的 验证成功 - log.debug("前端所提供的收据是有效的 验证成功"); - String r_receipt = job.getStr("receipt"); - JSONObject returnJson = JSONUtil.parseObj(r_receipt); - String in_app = returnJson.getStr("in_app"); - - /** - * in_app说明: - * 验证票据返回的receipt里面的in_app字段,这个字段包含了所有你未完成交易的票据信息。也就是在上面说到的APP完成交易之后,这个票据信息,就会从in_app中消失。 - * 如果APP不完成交易,这个票据信息就会在in_app中一直保留。(这个情况可能仅限于你的商品类型为消耗型) - * - * 知道了事件的原委,就很好优化解决了,方案有2个 - * 1.对票据返回的in_app数据全部进行处理,没有充值的全部进行充值 - * 2.仅对最新的充值信息进行处理(我们采取的方案) - * - * 因为采用一方案: - * 如果用户仅进行了一次充值,该充值未到账,他不再进行充值了,那么会无法导致。 - * 如果他通过客服的途径已经进行了补充充值,那么他在下一次充值的时候依旧会把之前的产品票据带回,这时候有可能出现重复充值的情况 - * - * 以上说明是我在网上找到的,可以查看原文 - * https://www.cnblogs.com/widgetbox/p/8241333.html - */ - - JSONArray jsonArray = JSONUtil.parseArray(in_app); - if (jsonArray.size() > 0) { - int index = 0; - JSONObject o = JSONUtil.parseObj(jsonArray.get(index)); - String transaction_id = o.getStr("transaction_id"); // 订单号 - String product_id = o.getStr("product_id"); // 产品id,也就是支付金额 - String purchase_date_ms = o.getStr("purchase_date_ms"); // 支付时间 -// -// // 添加支付金额 -// Result iosChargeSuccess = paymentService.iosChargeSuccess(transaction_id, product_id, purchase_date_ms, receiptMd5, iPayNotifyPo.getMoneyId(), iPayNotifyPo.getUserId()); -// int i =0; -// int a = 0; -// if (iosChargeSuccess.getCode().equals(200)){ -// i = paymentService.updateCurrentState(iPayNotifyPo.getPayId(),iPayNotifyPo.getUserId(),a); -// }else { -// a = 1; -// i = paymentService.updateCurrentState(iPayNotifyPo.getPayId(),iPayNotifyPo.getUserId(),a); -// } -// -// return iosChargeSuccess; - } - } else { - return Result.error("收到数据有误"); - } - } - return Result.ok(); - } -} diff --git a/src/main/java/com/peanut/modules/pay/applePay/controller/IapController.java b/src/main/java/com/peanut/modules/pay/applePay/controller/IapController.java deleted file mode 100644 index 9a8b24a6..00000000 --- a/src/main/java/com/peanut/modules/pay/applePay/controller/IapController.java +++ /dev/null @@ -1,134 +0,0 @@ -package com.peanut.modules.pay.applePay.controller; - -import java.io.BufferedOutputStream; -import java.io.BufferedReader; -import java.io.InputStreamReader; -import java.net.URL; -import java.security.cert.CertificateException; -import java.security.cert.X509Certificate; - -import javax.net.ssl.HttpsURLConnection; -import javax.net.ssl.SSLContext; -import javax.net.ssl.TrustManager; -import javax.net.ssl.X509TrustManager; - -import lombok.extern.slf4j.Slf4j; -import org.apache.commons.lang.StringUtils; -import org.springframework.web.bind.annotation.RequestMapping; - -import com.alibaba.fastjson.JSONObject; -import org.springframework.web.bind.annotation.RestController; - -/** - * @author : - * @date : - * @Version: 1.0 - * @Desc : 苹果支付 参考地址:https://www.cnblogs.com/shoshana-kong/p/10991753.html - * sendHttpsCoon 方法里面包含了增加的业务逻辑 - * 本类引入多种的Json序列化工具,选择了Hutool - */ - - - -@Slf4j -@RestController -@RequestMapping("iap") -public class IapController { - - //购买凭证验证地址 - private static final String certificateUrl = "https://buy.itunes.apple.com/verifyReceipt"; - - //测试的购买凭证验证地址 - private static final String certificateUrlTest = "https://sandbox.itunes.apple.com/verifyReceipt"; - - /** - * 重写X509TrustManager - */ - private static TrustManager myX509TrustManager = new X509TrustManager() { - - @Override - public X509Certificate[] getAcceptedIssuers() { - return null; - } - - @Override - public void checkServerTrusted(X509Certificate[] chain, String authType) throws CertificateException { - - } - - @Override - public void checkClientTrusted(X509Certificate[] chain, String authType) throws CertificateException { - - } - }; - - /** - * 接收iOS端发过来的购买凭证 - * @param userId - * @param receipt - * @param chooseEnv - */ - @RequestMapping("/setIapCertificate") - public String setIapCertificate(String userId, String receiptData, boolean chooseEnv){ - if(StringUtils.isEmpty(userId) || StringUtils.isEmpty(receiptData)){ - return null; - - } - String url = null; - url = chooseEnv == true? certificateUrl:certificateUrlTest; - final String certificateCode = receiptData; - if(StringUtils.isNotEmpty(certificateCode)){ - return sendHttpsCoon(url, certificateCode); - }else{ - return null; - } - } - - /** - * 发送请求 - * @param url - * @param strings - * @return - */ - private String sendHttpsCoon(String url, String code){ - if(url.isEmpty()){ - return null; - } - try { - //设置SSLContext - SSLContext ssl = SSLContext.getInstance("SSL"); - ssl.init(null, new TrustManager[]{myX509TrustManager}, null); - - //打开连接 - HttpsURLConnection conn = (HttpsURLConnection) new URL(url).openConnection(); - //设置套接工厂 - conn.setSSLSocketFactory(ssl.getSocketFactory()); - //加入数据 - conn.setRequestMethod("POST"); - conn.setDoOutput(true); - conn.setRequestProperty("Content-type","application/json"); - - JSONObject obj = new JSONObject(); - obj.put("receipt-data", code); - - BufferedOutputStream buffOutStr = new BufferedOutputStream(conn.getOutputStream()); - buffOutStr.write(obj.toString().getBytes()); - buffOutStr.flush(); - buffOutStr.close(); - - //获取输入流 - BufferedReader reader = new BufferedReader(new InputStreamReader(conn.getInputStream())); - - String line = null; - StringBuffer sb = new StringBuffer(); - while((line = reader.readLine())!= null){ - sb.append(line); - } - return sb.toString(); - - } catch (Exception e) { - return null; - } - } -} - diff --git a/src/main/java/com/peanut/modules/pay/applePay/service/ApplePayService.java b/src/main/java/com/peanut/modules/pay/applePay/service/ApplePayService.java deleted file mode 100644 index 250332b5..00000000 --- a/src/main/java/com/peanut/modules/pay/applePay/service/ApplePayService.java +++ /dev/null @@ -1,35 +0,0 @@ -package com.peanut.modules.pay.applePay.service; - -import com.peanut.modules.pay.IOSPay.Result; -import org.springframework.stereotype.Service; - -@Service -public interface ApplePayService { - - /** - * 看是否是己经验证过的该支付收据 - * @param receiptMd5 - * @return - */ - - public boolean isExistsIOSReceipt(String receiptMd5); - - - int updateCurrentState(String payId, String userId, int a); - - /** - * IOS支付 - * @param transaction_id 订单号 - * @param product_id 产品id,也就是支付金额 - * @param purchase_date_ms 支付时间 - * @param receiptMd5 拿到收据的MD5 - * @param moneyId 金额id - */ - Result iosChargeSuccess(String transaction_id, String product_id, String purchase_date_ms, String receiptMd5, String moneyId, String userId); - - - -// R getAppPay(String verifyResult, String transactionID); - - -} diff --git a/src/main/java/com/peanut/modules/pay/applePay/service/impl/ApplePayServiceImpl.java b/src/main/java/com/peanut/modules/pay/applePay/service/impl/ApplePayServiceImpl.java deleted file mode 100644 index 7c1bd5fd..00000000 --- a/src/main/java/com/peanut/modules/pay/applePay/service/impl/ApplePayServiceImpl.java +++ /dev/null @@ -1,161 +0,0 @@ -package com.peanut.modules.pay.applePay.service.impl; - -import com.peanut.common.utils.DateUtils; -import com.peanut.modules.book.service.*; -import com.peanut.modules.pay.IOSPay.Result; -import com.peanut.modules.pay.applePay.service.ApplePayService; -import com.peanut.modules.pay.applePay.utils.*; -import lombok.AllArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.jdbc.core.JdbcTemplate; -import org.springframework.stereotype.Service; -import javax.annotation.Resource; -import java.math.BigDecimal; -import java.util.*; - - -@Service("ApplePayService") -@Slf4j -@AllArgsConstructor -public class ApplePayServiceImpl implements ApplePayService { - -// 日志记录,系统支付模块记录日志信息输出到sys-pay - private static final Logger logger = LoggerFactory.getLogger("sys-pay"); - - @Autowired - private MyUserService userService; - @Autowired - private BuyOrderService buyOrderService; - @Autowired - private TransactionDetailsService transactionDetailsService; - @Autowired - private ApplePayUtil applePayUtil; - @Autowired - private BookBuyConfigService bookBuyConfigService; - @Autowired - private PayPaymentOrderService payPaymentOrderService; - @Autowired - public static final String TRADE_TYPE_APP = "APP"; - @Autowired - private JdbcTemplate jdbcTemplate; - - @Override - public boolean isExistsIOSReceipt(String receiptMd5) { - return false; - } - - - @Resource - private TsBillMapper tsBillMapper; - /** - * 支付成功之后将当前订单的状态改为1 - * - * @param payId - * @param userId - * @param a - * @return - */ - @Override - public int updateCurrentState(String payId, String userId, int a) { - return 0; - } - - - /** - * IOS支付 - * @param transaction_id 订单号 - * @param product_id 产品id,也就是支付金额 - * @param purchase_date_ms 支付时间 - * @param receiptMd5 拿到收据的MD5 - * @param moneyId 金额id - */ - @Override - public Result iosChargeSuccess(String transaction_id, String product_id, String purchase_date_ms, String receiptMd5, String moneyId, String userId) { - /** - * IOS支付 - * @param transaction_id 订单号 - * @param product_id 产品id,也就是支付金额 - * @param purchase_date_ms 支付时间 - * @param receiptMd5 拿到收据的MD5 - * @param moneyId 金额id - */ - - try { - List> queryForList = jdbcTemplate.queryForList("SELECT id,showcoin_num,give_showcoin_num,rmb_price from tsm_payment_config_ios where product_id =? ", - moneyId); - - if (queryForList.size() > 0) { - String bill_content = "充值";//账单产生方式 - int bill_state = 1;// 充值 - int current_state = 1;// 支付成功 - int payment_method = 3;// IOS - String date = DateUtils.DATE_TIME_PATTERN;// 当前时间 - BigDecimal amountofmoney = new BigDecimal(queryForList.get(0).get("rmb_price").toString());// 金额 - String uuid = UUID.randomUUID().toString().replaceAll("-", ""); - // 生成消费订单 - //String sql = "insert into ts_bill (id,users_id,payment_config_id,bill_num,bill_content,bill_sumofmoney,bill_state,current_state,payment_method,receipt,createtdate) value(?,?,?,?,?,?,?,?,?,?,?);"; - //jdbcTemplate.update(sql, uuid,userId,moneyId,transaction_id,bill_content,amountofmoney,bill_state,current_state,payment_method,receiptMd5,date); - - String type = "1";// 加 - long showcoin_num = Long.parseLong(queryForList.get(0).get("showcoin_num").toString()) + Long.parseLong(queryForList.get(0).get("give_showcoin_num").toString()); - - - // 此操作为需求实际场景可根据用户产品需求更改 - //commonServiceI.updShowcoinNum(type, userId, showcoin_num); - - return Result.ok("支付成功"); - } else { - return Result.error("操作异常,所选金额不存在"); - } - } catch (Exception e) { - return Result.error("ios支付异常"); - } - - - } - -// @Override -// @Transactional -// public R getAppPay(String verifyResult, String transactionID) { -// log.info("##########################苹果支付验证!########################"); -// JSONObject jsonObject = JSONObject.parseObject(verifyResult); -// String status = jsonObject.getString("status"); -// //判断是否验证成功 -// if ("0".equals(status)) { -// //app端所提供的收据是有效的,验证成功 -// String receipt = jsonObject.getString("receipt"); -// JSONObject returnJson = JSONObject.parseObject(receipt); -// String in_app = returnJson.getString("in_app"); -// JSONObject in_appJson = JSONObject.parseObject(in_app.substring(1, in_app.length() - 1)); -// String transactionId = in_appJson.getString("transaction_id"); -// String in_app_ownership_type = in_appJson.getString("in_app_ownership_type"); -// //如果验证后的订单号与app端传来的订单号一致并且状态为已支付状态则处理自己的业务 -// if (transactionID.equals(transactionId) && "PURCHASED".equals(in_app_ownership_type)) { -// //===================处理自己的业务 ============================ -// BuyOrder order = this.buyOrderService.getOne(new QueryWrapper().eq("order_sn", transactionId )); -// PayWechatOrderEntity wechat = new PayWechatOrderEntity(); -// -// -// } -// return R.ok(); -// } -// return R.error("苹果内购验证失败"); -// } - - - - -} - - - - - - - - - - diff --git a/src/main/java/com/peanut/modules/pay/applePay/utils/AddIosOrderPM.java b/src/main/java/com/peanut/modules/pay/applePay/utils/AddIosOrderPM.java deleted file mode 100644 index 6a4f4c27..00000000 --- a/src/main/java/com/peanut/modules/pay/applePay/utils/AddIosOrderPM.java +++ /dev/null @@ -1,116 +0,0 @@ -package com.peanut.modules.pay.applePay.utils; - - -import io.swagger.annotations.ApiModel; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; - -import java.io.Serializable; - -//购买所需参数类 -@ApiModel(value = "支付数据字段对比") -@Data -@AllArgsConstructor //有参数的构造方法 -@NoArgsConstructor //无参构造方法 -public class AddIosOrderPM implements Serializable { - -// -// /** -// * ios支付所需参数 -// */ -// private String receipt; -// -// /** -// * 用户id -// */ -// private Integer userId; -// - - - - /** - * 交易编号 - * eg:1000000852134037 交易唯一标识符; - */ - private String transaction_id; - /** - * APP所有权类型 eg: PURCHASED为沙箱环境 - * eg:PURCHASED - */ - private String in_app_ownership_type; - /** - * 原来的交易编号 原始购买标识符 - * eg:1000000852108057 - */ - private String original_transaction_id; - /** - * 数量 - * eg:1 购买消耗品的数量 - */ - private String quantity; - /** - * 唯一标识符 - * eg:1e10a9ec617549f986765b8546eddd0a9f349f15 - */ - private String unique_identifier; - /** - * item_id - * eg:1578853844 - */ - private String item_id; - /** - * 处于介绍报价期 - * eg:false - */ - private String is_in_intro_offer_period; - /** - * 购买日期 - * eg:2021-08-02 03:57:56 America/Los_Angeles - */ - private String purchase_date_pst; - /** - * 原始购买日期 ms - * eg:1627900203000 - */ - private String original_purchase_date_ms; - /** - * 原始购买日期 - * eg:2021-08-02 03:30:03 America/Los_Angeles 太平洋时区 - */ - private String original_purchase_date_pst; - /** - * 是试用期 - * eg:false - */ - private String is_trial_period; - /** - * 原始购买日期 - * eg:2021-08-02 10:30:03 Etc/GMT 原始购买时间 ISO 8601日期格式 - */ - private String original_purchase_date; - /** - * 购买日期ms 时间日期 - */ - private String purchase_date_ms; - /** - * 产品id 购买产品唯一标识符 - * eg:2 - */ - private String product_id; - private String bvrs; - /** - * 购买日期 - * eg:2021-08-02 10:57:56 Etc/GMT 时间日期 - */ - private String purchase_date; - private String bid; - /** - * 唯一供应商标识符 - * eg:A1D7647F-019C-4D15-A23C-3A48CFBFF4E3 - */ - private String unique_vendor_identifier; - - - -} diff --git a/src/main/java/com/peanut/modules/pay/applePay/utils/ApplePayUtil.java b/src/main/java/com/peanut/modules/pay/applePay/utils/ApplePayUtil.java deleted file mode 100644 index 1e2b41dd..00000000 --- a/src/main/java/com/peanut/modules/pay/applePay/utils/ApplePayUtil.java +++ /dev/null @@ -1,159 +0,0 @@ -package com.peanut.modules.pay.applePay.utils; - -import org.springframework.beans.factory.annotation.Value; -import org.springframework.stereotype.Component; -import sun.misc.BASE64Decoder; - -import javax.net.ssl.*; -import java.io.BufferedOutputStream; -import java.io.BufferedReader; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.net.URL; -import java.security.cert.CertificateException; -import java.security.cert.X509Certificate; -import java.util.Locale; - -@Component -public class ApplePayUtil { - - - private static class TrustAnyTrustManager implements X509TrustManager { - - - @Override - public void checkClientTrusted(X509Certificate[] chain, String authType) throws CertificateException { - } - - @Override - public void checkServerTrusted(X509Certificate[] chain, String authType) throws CertificateException { - } - - @Override - public X509Certificate[] getAcceptedIssuers() { - return new X509Certificate[]{}; - } - } - - private static class TrustAnyHostnameVerifier implements HostnameVerifier { - @Override - public boolean verify(String hostname, SSLSession session) { - return true; - } - } - - private static String url_apple_pay = "https://buy.itunes.apple.com/verifyReceipt"; - - - - private static String test_url_apple_pay = "https://sandbox.itunes.apple.com/verifyReceipt"; - - - /** - * 苹果服务器验证 - * - * @param receipt 账单 - * @return null 或返回结果 - * @url 要验证的地址 沙盒 https://sandbox.itunes.apple.com/verifyReceipt - */ - public static String buyAppVerify(String receipt, int type) { - //环境判断 线上/开发环境用不同的请求链接 - try { - String url = null; - if (type == 0) { - url = test_url_apple_pay; //沙盒环境,测试 - } else { - url = url_apple_pay; //线上环境 - } - - //String url = EnvUtils.isOnline() ?url_verify : url_sandbox; - SSLContext sc = SSLContext.getInstance("SSL"); - sc.init(null, new TrustManager[]{new TrustAnyTrustManager()}, new java.security.SecureRandom()); - URL console = new URL(url); - HttpsURLConnection conn = (HttpsURLConnection) console.openConnection(); - conn.setSSLSocketFactory(sc.getSocketFactory()); - conn.setHostnameVerifier(new TrustAnyHostnameVerifier()); - conn.setRequestMethod("POST"); - conn.setRequestProperty("content-type", "text/json"); - conn.setRequestProperty("Proxy-Connection", "Keep-Alive"); - conn.setDoInput(true); - conn.setDoOutput(true); - //r如果有错误就注释 - conn.setConnectTimeout(3000); - BufferedOutputStream hurlBufOus = new BufferedOutputStream(conn.getOutputStream()); - //拼成固定的格式传给平台 - String str = String.format(Locale.CHINA, "{\"receipt-data\":\"" + receipt + "\"}"); - // 直接将receipt当参数发到苹果验证就行,不用拼格 - String str1 = String.format(Locale.CHINA, receipt); - hurlBufOus.write(str.getBytes()); - hurlBufOus.flush(); - - - InputStream is = conn.getInputStream(); - BufferedReader reader = new BufferedReader(new InputStreamReader(is)); - String line = null; - StringBuilder sb = new StringBuilder(); - while ((line = reader.readLine()) != null) { - sb.append(line); - } - return sb.toString(); - } catch (Exception ex) { - System.out.println("苹果服务器异常"); - ex.printStackTrace(); - } - return null; - - } - - - - - - - - - - - //视情况而定,苹果app进行支付,然后收到苹果的收据(一串很长的BASE64编码的字符串) - /** - * 用BASE64加密 - * - * @param str - * @return - */ - public static String getBASE64(String str) { - byte[] b = str.getBytes(); - String s = null; - if (b != null) { - s = new sun.misc.BASE64Encoder().encode(b); - } - return s; - } - - - /** - * 解密BASE64字窜 - * @param s - * @return - */ - public static String getFromBASE64(String s) { - byte[] b = null; - if (s != null) { - BASE64Decoder decoder = new BASE64Decoder(); - try { - b = decoder.decodeBuffer(s); - return new String(b); - } catch (Exception e) { - e.printStackTrace(); - } - } - return new String(b); - } - - - - - - - -} diff --git a/src/main/java/com/peanut/modules/pay/applePay/utils/IPayNotifyPo.java b/src/main/java/com/peanut/modules/pay/applePay/utils/IPayNotifyPo.java deleted file mode 100644 index 1d5cb353..00000000 --- a/src/main/java/com/peanut/modules/pay/applePay/utils/IPayNotifyPo.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.peanut.modules.pay.applePay.utils; - -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; - -@Data -public class IPayNotifyPo { - @ApiModelProperty("苹果支付凭证") - private String transactionReceipt; - - @ApiModelProperty("苹果支付单号") - private String payId; - - @ApiModelProperty("用户id") - private String userId; - - @ApiModelProperty("金额id") - private String moneyId; - - -} diff --git a/src/main/java/com/peanut/modules/pay/applePay/utils/TsBill.java b/src/main/java/com/peanut/modules/pay/applePay/utils/TsBill.java deleted file mode 100644 index 8e5a6717..00000000 --- a/src/main/java/com/peanut/modules/pay/applePay/utils/TsBill.java +++ /dev/null @@ -1,79 +0,0 @@ -package com.peanut.modules.pay.applePay.utils; - -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; -import lombok.experimental.Accessors; - -import java.io.Serializable; - -@Data -@AllArgsConstructor -@NoArgsConstructor -@Accessors(chain = true) -@ApiModel("订单号") -public class TsBill implements Serializable { - private static final long serialVersionUID = 1L; -// @ApiModelProperty("苹果支付凭证") -// private String transactionReceipt; -// -// @ApiModelProperty("苹果支付单号") -// private String payId; -// iOS端支付完成,苹果返回给iOS端的那个receiptData app返回的数据 -// @ApiModelProperty("用户id") -// private String userId; -// -// @ApiModelProperty("金额id") -// private String moneyId; -// @ApiModelProperty("") -// private String currentState; -// @ApiModelProperty("IOS内购商品Id") -// private String product_id; // IOS内购商品Id -// @ApiModelProperty("应用内购买的时间") -// private String purchase_date_pst; // 应用内购买的时间 -// @ApiModelProperty("购买的消费品数量") -// private String quantity; // 购买的消费品数量 -// @ApiModelProperty("交易的唯一标识符") -// private String transaction_id; // -// -// @ApiModelProperty("支付时间") -// private String purchase_date_ms; // -// @ApiModelProperty("拿到收据的MD5") -// private String receiptMd5; // -// @ApiModelProperty("拿到收据的MD5") -// private String BillNum; // - - - - @ApiModelProperty("主键ID") - private String id; - @ApiModelProperty("用户ID") - private String usersId; - @ApiModelProperty("充值配置ID") - private String paymentConfigId; - @ApiModelProperty("交易单号,根据当前的28位当前时间加上11位随机数字对上的") - private String billNum; - @ApiModelProperty("交易号") - private String tradeNo; - @ApiModelProperty("账单生成方式,比如充值,说说币之类的") - private String billContent; - @ApiModelProperty("账单对应的金额id") - private String billSumofmoney; - @ApiModelProperty("账单类型还是充值") - private Integer billState; - @ApiModelProperty(" 当前状态,0是支付失败,1是支付成功,10是待支付") - private Integer currentState; - @ApiModelProperty("支付方式,0是虚拟币,1是支付宝,2是微信,3是ios") - private Integer paymentMethod; - @ApiModelProperty("收据MD5,仅ios可用") - private String receipt; - @ApiModelProperty("创集时间") - private String createtdate; - @ApiModelProperty("修改时间") - private String updatedate; - - - -} diff --git a/src/main/java/com/peanut/modules/pay/applePay/utils/TsBillMapper.java b/src/main/java/com/peanut/modules/pay/applePay/utils/TsBillMapper.java deleted file mode 100644 index 13266c75..00000000 --- a/src/main/java/com/peanut/modules/pay/applePay/utils/TsBillMapper.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.peanut.modules.pay.applePay.utils; - -import com.baomidou.mybatisplus.core.mapper.BaseMapper; - -import org.apache.ibatis.annotations.Mapper; - -/** - * @author talkmate - */ -@Mapper -public interface TsBillMapper extends BaseMapper{ - -} diff --git a/src/main/java/com/peanut/modules/pay/weChatPay/controller/WeChatPayController.java b/src/main/java/com/peanut/modules/pay/weChatPay/controller/WeChatPayController.java index 0357af69..fcc04ab1 100644 --- a/src/main/java/com/peanut/modules/pay/weChatPay/controller/WeChatPayController.java +++ b/src/main/java/com/peanut/modules/pay/weChatPay/controller/WeChatPayController.java @@ -16,8 +16,8 @@ import org.springframework.context.annotation.Lazy; import org.springframework.transaction.annotation.Transactional; import org.springframework.web.bind.annotation.*; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; import java.util.*; @Slf4j diff --git a/src/main/java/com/peanut/modules/pay/weChatPay/service/WxpayService.java b/src/main/java/com/peanut/modules/pay/weChatPay/service/WxpayService.java index fb295502..662d2305 100644 --- a/src/main/java/com/peanut/modules/pay/weChatPay/service/WxpayService.java +++ b/src/main/java/com/peanut/modules/pay/weChatPay/service/WxpayService.java @@ -5,7 +5,7 @@ import com.peanut.modules.common.entity.PayWechatOrderEntity; import com.peanut.modules.pay.weChatPay.dto.WechatPaymentInfo; import org.springframework.stereotype.Service; -import javax.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletRequest; import java.util.Map; @Service diff --git a/src/main/java/com/peanut/modules/pay/weChatPay/service/impl/WxpayServiceImpl.java b/src/main/java/com/peanut/modules/pay/weChatPay/service/impl/WxpayServiceImpl.java index a7cd3840..d7f6d5ee 100644 --- a/src/main/java/com/peanut/modules/pay/weChatPay/service/impl/WxpayServiceImpl.java +++ b/src/main/java/com/peanut/modules/pay/weChatPay/service/impl/WxpayServiceImpl.java @@ -29,7 +29,7 @@ import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import javax.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletRequest; import java.math.BigDecimal; import java.util.*; import java.util.stream.Collectors; diff --git a/src/main/java/com/peanut/modules/pay/weChatPay/util/HttpUtils.java b/src/main/java/com/peanut/modules/pay/weChatPay/util/HttpUtils.java index e315712c..6f3ece1a 100644 --- a/src/main/java/com/peanut/modules/pay/weChatPay/util/HttpUtils.java +++ b/src/main/java/com/peanut/modules/pay/weChatPay/util/HttpUtils.java @@ -1,10 +1,6 @@ package com.peanut.modules.pay.weChatPay.util; -import org.junit.rules.Verifier; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import javax.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletRequest; import java.io.BufferedReader; import java.io.IOException; diff --git a/src/main/java/com/peanut/modules/pay/weChatPay/util/WechatPayValidator.java b/src/main/java/com/peanut/modules/pay/weChatPay/util/WechatPayValidator.java index 1d1eebd8..b0bcd2ae 100644 --- a/src/main/java/com/peanut/modules/pay/weChatPay/util/WechatPayValidator.java +++ b/src/main/java/com/peanut/modules/pay/weChatPay/util/WechatPayValidator.java @@ -9,7 +9,7 @@ import org.apache.http.HttpEntity; import org.apache.http.client.methods.CloseableHttpResponse; import org.apache.http.util.EntityUtils; -import javax.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletRequest; import java.io.IOException; import java.nio.charset.StandardCharsets; import java.time.DateTimeException; diff --git a/src/main/java/com/peanut/modules/pay/weChatPay/util/WechatPayValidatorForRequest.java b/src/main/java/com/peanut/modules/pay/weChatPay/util/WechatPayValidatorForRequest.java index a4df8551..98a82c10 100644 --- a/src/main/java/com/peanut/modules/pay/weChatPay/util/WechatPayValidatorForRequest.java +++ b/src/main/java/com/peanut/modules/pay/weChatPay/util/WechatPayValidatorForRequest.java @@ -5,7 +5,7 @@ import com.wechat.pay.contrib.apache.httpclient.auth.Verifier; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import javax.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletRequest; import java.io.IOException; import java.nio.charset.StandardCharsets; import java.time.DateTimeException; diff --git a/src/main/java/com/peanut/modules/psyche/controller/PsycheCourseController.java b/src/main/java/com/peanut/modules/psyche/controller/PsycheCourseController.java index 00f1d3cf..13322a2d 100644 --- a/src/main/java/com/peanut/modules/psyche/controller/PsycheCourseController.java +++ b/src/main/java/com/peanut/modules/psyche/controller/PsycheCourseController.java @@ -7,7 +7,6 @@ import com.peanut.common.utils.ShiroUtils; import com.peanut.modules.common.entity.*; import com.peanut.modules.common.service.UserCourseStudyingService; import com.peanut.modules.common.service.UserVipService; -import com.peanut.modules.master.service.CourseCatalogueService; import com.peanut.modules.master.service.CourseService; import com.peanut.modules.master.service.UserCourseBuyService; import lombok.extern.slf4j.Slf4j; @@ -15,7 +14,6 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; - import java.util.ArrayList; import java.util.List; import java.util.Map; @@ -48,7 +46,7 @@ public class PsycheCourseController { wrapper.orderByAsc(CourseEntity::getSort); List courseList = courseService.list(wrapper); for (CourseEntity c:courseList){ - int i = userCourseStudyingService.count(new LambdaQueryWrapper() + Long i = userCourseStudyingService.count(new LambdaQueryWrapper() .eq(UserCourseStudying::getCourseId,c.getId()) .eq(UserCourseStudying::getUserId,ShiroUtils.getUId())); c.setIsStudying(i>0?1:0); @@ -90,7 +88,7 @@ public class PsycheCourseController { List> list = courseService.listMaps(wrapper); for (Map courseEntity : list) { if (!userVipService.isPsycheVip(ShiroUtils.getUId())){ - int ucb = userCourseBuyService.count(new LambdaQueryWrapper() + Long ucb = userCourseBuyService.count(new LambdaQueryWrapper() .eq(UserCourseBuyEntity::getUserId,ShiroUtils.getUId()) .eq(UserCourseBuyEntity::getCatalogueId,courseEntity.get("catalogueId"))); if (ucb == 0) { @@ -117,7 +115,7 @@ public class PsycheCourseController { //加入收藏(加入正在学习) @RequestMapping("/addUserCourseStudying") public R addUserCourseStudying(@RequestBody Map map){ - int isExist = userCourseStudyingService.count(new LambdaQueryWrapper() + Long isExist = userCourseStudyingService.count(new LambdaQueryWrapper() .eq(UserCourseStudying::getUserId,ShiroUtils.getUId()) .eq(UserCourseStudying::getCourseId,map.get("courseId"))); if (isExist>0){ diff --git a/src/main/java/com/peanut/modules/sociology/controller/CourseController.java b/src/main/java/com/peanut/modules/sociology/controller/CourseController.java index 0a369e6f..eaea85dc 100644 --- a/src/main/java/com/peanut/modules/sociology/controller/CourseController.java +++ b/src/main/java/com/peanut/modules/sociology/controller/CourseController.java @@ -22,7 +22,6 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; - import java.util.HashMap; import java.util.List; import java.util.Map; @@ -113,7 +112,7 @@ public class CourseController { public R addUserCourseStudying(@RequestBody Map map){ int isExist = userCourseStudyingDao.selectCount(new LambdaQueryWrapper() .eq(UserCourseStudying::getUserId,ShiroUtils.getUId()) - .eq(UserCourseStudying::getCourseId,map.get("courseId"))); + .eq(UserCourseStudying::getCourseId,map.get("courseId"))).intValue(); if (isExist>0){ return R.error("已存在"); }else { diff --git a/src/main/java/com/peanut/modules/sociology/service/impl/CourseServiceImpl.java b/src/main/java/com/peanut/modules/sociology/service/impl/CourseServiceImpl.java index 5e32f206..d18b5166 100644 --- a/src/main/java/com/peanut/modules/sociology/service/impl/CourseServiceImpl.java +++ b/src/main/java/com/peanut/modules/sociology/service/impl/CourseServiceImpl.java @@ -71,7 +71,7 @@ public class CourseServiceImpl extends ServiceImpl impl wrapper.orderByAsc(CourseToSociologyEntity::getSort); Page courseEntityPage = this.getBaseMapper().selectJoinPage(new Page<>(param.getPage(), param.getLimit()),CourseEntity.class, wrapper); for (CourseEntity c:courseEntityPage.getRecords()){ - Integer integer = userCourseBuyDao.selectCount(new LambdaQueryWrapper().eq(UserCourseBuyEntity::getCourseId, c.getId()).eq(UserCourseBuyEntity::getUserId,uId).and(i -> i.apply("end_time IS NULL OR end_time > {0}", new Date()))); + Integer integer = userCourseBuyDao.selectCount(new LambdaQueryWrapper().eq(UserCourseBuyEntity::getCourseId, c.getId()).eq(UserCourseBuyEntity::getUserId,uId).and(i -> i.apply("end_time IS NULL OR end_time > {0}", new Date()))).intValue(); c.setIsBuy(integer>0?1:0); List courseCatalogueEntities = courseCatalogueDao.selectList(new LambdaQueryWrapper().eq(CourseCatalogueEntity::getCourseId, c.getId())); if (courseCatalogueEntities != null && courseCatalogueEntities.size() > 0){ @@ -80,7 +80,7 @@ public class CourseServiceImpl extends ServiceImpl impl if (userVip!=null){ cc.setIsBuy(1); }else { - Integer cou = userCourseBuyDao.selectCount(new LambdaQueryWrapper().eq(UserCourseBuyEntity::getCatalogueId, cc.getId()).eq(UserCourseBuyEntity::getUserId,uId).and(i -> i.apply("end_time IS NULL OR end_time > {0}", new Date()))); + Integer cou = userCourseBuyDao.selectCount(new LambdaQueryWrapper().eq(UserCourseBuyEntity::getCatalogueId, cc.getId()).eq(UserCourseBuyEntity::getUserId,uId).and(i -> i.apply("end_time IS NULL OR end_time > {0}", new Date()))).intValue(); cc.setIsBuy(cou>0?1:0); } } @@ -223,7 +223,7 @@ public class CourseServiceImpl extends ServiceImpl impl LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); wrapper.eq(UserCourseBuyEntity::getUserId,uId); wrapper.eq(UserCourseBuyEntity::getCatalogueId,catalogueId); - Integer integer = userCourseBuyDao.selectCount(wrapper); + Integer integer = userCourseBuyDao.selectCount(wrapper).intValue(); if(integer>0){ return R.error("您已拥有本门课程,无需领取"); } @@ -361,7 +361,7 @@ public class CourseServiceImpl extends ServiceImpl impl for (Map map:courseList){ int count = userCourseBuyDao.selectCount(new LambdaQueryWrapper() .eq(UserCourseBuyEntity::getUserId,param.get("userId")) - .eq(UserCourseBuyEntity::getCatalogueId,map.get("catalogueId"))); + .eq(UserCourseBuyEntity::getCatalogueId,map.get("catalogueId"))).intValue(); if (!userVipService.isSociologyVip((int)param.get("userId"))&&count==0){ courseEntities.add(map); } @@ -399,7 +399,7 @@ public class CourseServiceImpl extends ServiceImpl impl if(courseEntities!=null&&courseEntities.size()>0){ for (CourseEntity co:courseEntities){ //添加是否加入正在学习 - int i = studyingDao.selectCount(new LambdaQueryWrapper().eq(UserCourseStudying::getCourseId,co.getId()).eq(UserCourseStudying::getUserId,user.getId())); + int i = studyingDao.selectCount(new LambdaQueryWrapper().eq(UserCourseStudying::getCourseId,co.getId()).eq(UserCourseStudying::getUserId,user.getId())).intValue(); co.setIsStudying(i>0?1:0); List courseCatalogueEntities = courseCatalogueDao.selectList(new MPJLambdaWrapper().eq(CourseCatalogueEntity::getCourseId, co.getId()).orderByAsc(CourseCatalogueEntity::getSort)); if (courseCatalogueEntities.size() > 0) { diff --git a/src/main/java/com/peanut/modules/springai/ChatController.java b/src/main/java/com/peanut/modules/springai/ChatController.java new file mode 100644 index 00000000..f86a8347 --- /dev/null +++ b/src/main/java/com/peanut/modules/springai/ChatController.java @@ -0,0 +1,30 @@ +package com.peanut.modules.springai; + +import lombok.extern.slf4j.Slf4j; +import org.springframework.ai.chat.client.ChatClient; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import reactor.core.publisher.Flux; +import java.util.Map; + +@Slf4j +@RestController("commonChat") +@RequestMapping("common/chat") +public class ChatController { + + private final ChatClient chatClient; + + public ChatController(ChatClient.Builder chatClientBuilder) { + this.chatClient = chatClientBuilder.build(); + } + + @RequestMapping("/chat") + public Flux chat(@RequestBody Map parmas) { + return chatClient.prompt() + .user(parmas.get("message").toString()) + .stream() + .content(); + } + +} diff --git a/src/main/java/com/peanut/modules/sys/controller/SysLoginController.java b/src/main/java/com/peanut/modules/sys/controller/SysLoginController.java index 226170fd..d1114d03 100644 --- a/src/main/java/com/peanut/modules/sys/controller/SysLoginController.java +++ b/src/main/java/com/peanut/modules/sys/controller/SysLoginController.java @@ -24,8 +24,8 @@ import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RestController; import javax.imageio.ImageIO; -import javax.servlet.ServletOutputStream; -import javax.servlet.http.HttpServletResponse; +import jakarta.servlet.ServletOutputStream; +import jakarta.servlet.http.HttpServletResponse; import java.awt.image.BufferedImage; import java.io.IOException; import java.util.Map; diff --git a/src/main/java/com/peanut/modules/sys/controller/VisitorController.java b/src/main/java/com/peanut/modules/sys/controller/VisitorController.java index e2f59947..1f28c268 100644 --- a/src/main/java/com/peanut/modules/sys/controller/VisitorController.java +++ b/src/main/java/com/peanut/modules/sys/controller/VisitorController.java @@ -296,7 +296,7 @@ public class VisitorController { GetVideoPlayAuthResponse p = SpdbUtil.getPlayAuth(video.getVideo()); String playAuth = p.getBody().getPlayAuth(); video.setPlayAuth(playAuth); - Integer integer = videoM3u8Dao.selectCount(new LambdaQueryWrapper().eq(VideoM3u8Entity::getVid, video.getVideo())); + Integer integer = videoM3u8Dao.selectCount(new LambdaQueryWrapper().eq(VideoM3u8Entity::getVid, video.getVideo())).intValue(); if(integer>0){ String s = playToken.generateToken(); GetPlayInfoResponseBody urlBody = SpdbUtil.getUrl(video.getVideo()); diff --git a/src/main/java/com/peanut/modules/sys/entity/SysConfigEntity.java b/src/main/java/com/peanut/modules/sys/entity/SysConfigEntity.java index 07108067..86311478 100644 --- a/src/main/java/com/peanut/modules/sys/entity/SysConfigEntity.java +++ b/src/main/java/com/peanut/modules/sys/entity/SysConfigEntity.java @@ -12,7 +12,7 @@ import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import lombok.Data; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; /** * 系统配置信息 diff --git a/src/main/java/com/peanut/modules/sys/entity/SysRoleEntity.java b/src/main/java/com/peanut/modules/sys/entity/SysRoleEntity.java index e563b972..a26bb983 100644 --- a/src/main/java/com/peanut/modules/sys/entity/SysRoleEntity.java +++ b/src/main/java/com/peanut/modules/sys/entity/SysRoleEntity.java @@ -13,7 +13,7 @@ import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import lombok.Data; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; import java.io.Serializable; import java.util.Date; import java.util.List; diff --git a/src/main/java/com/peanut/modules/sys/entity/SysUserEntity.java b/src/main/java/com/peanut/modules/sys/entity/SysUserEntity.java index ecc420b0..ba2c9d0a 100644 --- a/src/main/java/com/peanut/modules/sys/entity/SysUserEntity.java +++ b/src/main/java/com/peanut/modules/sys/entity/SysUserEntity.java @@ -15,8 +15,8 @@ import com.peanut.common.validator.group.AddGroup; import com.peanut.common.validator.group.UpdateGroup; import lombok.Data; -import javax.validation.constraints.Email; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.Email; +import jakarta.validation.constraints.NotBlank; import java.io.Serializable; import java.util.Date; import java.util.List; diff --git a/src/main/java/com/peanut/modules/sys/oauth2/OAuth2Filter.java b/src/main/java/com/peanut/modules/sys/oauth2/OAuth2Filter.java index 1960e0de..51d7707d 100644 --- a/src/main/java/com/peanut/modules/sys/oauth2/OAuth2Filter.java +++ b/src/main/java/com/peanut/modules/sys/oauth2/OAuth2Filter.java @@ -17,11 +17,10 @@ import org.apache.shiro.authc.AuthenticationException; import org.apache.shiro.authc.AuthenticationToken; import org.apache.shiro.web.filter.authc.AuthenticatingFilter; import org.springframework.web.bind.annotation.RequestMethod; - -import javax.servlet.ServletRequest; -import javax.servlet.ServletResponse; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; +import jakarta.servlet.ServletRequest; +import jakarta.servlet.ServletResponse; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; import java.io.IOException; /** diff --git a/src/main/java/com/peanut/modules/sys/service/impl/SysUserTokenServiceImpl.java b/src/main/java/com/peanut/modules/sys/service/impl/SysUserTokenServiceImpl.java index b9d62259..8c6e9be5 100644 --- a/src/main/java/com/peanut/modules/sys/service/impl/SysUserTokenServiceImpl.java +++ b/src/main/java/com/peanut/modules/sys/service/impl/SysUserTokenServiceImpl.java @@ -18,7 +18,7 @@ import com.peanut.modules.sys.service.SysUserTokenService; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; -import javax.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletRequest; import java.util.Date; @Slf4j diff --git a/src/main/java/com/peanut/modules/taihumed/controller/AiRecordFolderController.java b/src/main/java/com/peanut/modules/taihumed/controller/AiRecordFolderController.java index 64d72ecc..598e0ae1 100644 --- a/src/main/java/com/peanut/modules/taihumed/controller/AiRecordFolderController.java +++ b/src/main/java/com/peanut/modules/taihumed/controller/AiRecordFolderController.java @@ -123,7 +123,7 @@ public class AiRecordFolderController { //删除病例夹 @RequestMapping("/delRecordFolder") public R delRecordFolder(@RequestBody Map params){ - int count = aiRecordFolderChatService.count(new LambdaQueryWrapper() + Long count = aiRecordFolderChatService.count(new LambdaQueryWrapper() .eq(AiRecordFolderChat::getFolderId,params.get("id").toString())); if (count > 0){ return R.error("存在患者记录,请清空后删除"); diff --git a/src/main/java/com/peanut/modules/taihumed/controller/AiVipController.java b/src/main/java/com/peanut/modules/taihumed/controller/AiVipController.java index bba80c24..26850c29 100644 --- a/src/main/java/com/peanut/modules/taihumed/controller/AiVipController.java +++ b/src/main/java/com/peanut/modules/taihumed/controller/AiVipController.java @@ -20,7 +20,7 @@ import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; -import javax.transaction.Transactional; +import jakarta.transaction.Transactional; import java.math.BigDecimal; import java.util.Date; import java.util.List; diff --git a/src/main/java/com/peanut/modules/taihumed/controller/CourseController.java b/src/main/java/com/peanut/modules/taihumed/controller/CourseController.java index 66cee0e7..98ba8255 100644 --- a/src/main/java/com/peanut/modules/taihumed/controller/CourseController.java +++ b/src/main/java/com/peanut/modules/taihumed/controller/CourseController.java @@ -16,11 +16,9 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; - import java.util.ArrayList; import java.util.List; import java.util.Map; -import java.util.stream.Collectors; @Slf4j @RestController("taihumedCourse") @@ -129,7 +127,7 @@ public class CourseController { wrapper.orderByAsc(CourseCatalogueEntity::getSort); List> list = courseService.listMaps(wrapper); for (Map courseEntity : list) { - int ucb = userCourseBuyService.count(new LambdaQueryWrapper() + Long ucb = userCourseBuyService.count(new LambdaQueryWrapper() .eq(UserCourseBuyEntity::getUserId,ShiroUtils.getUId()) .eq(UserCourseBuyEntity::getCatalogueId,courseEntity.get("catalogueId"))); if (ucb == 0) { diff --git a/src/main/java/com/peanut/modules/taihumed/controller/PrecisionMedicineController.java b/src/main/java/com/peanut/modules/taihumed/controller/PrecisionMedicineController.java index 809e1254..a28f839c 100644 --- a/src/main/java/com/peanut/modules/taihumed/controller/PrecisionMedicineController.java +++ b/src/main/java/com/peanut/modules/taihumed/controller/PrecisionMedicineController.java @@ -13,8 +13,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; - -import javax.servlet.http.HttpServletResponse; +import jakarta.servlet.http.HttpServletResponse; import java.io.IOException; import java.io.OutputStream; import java.net.URLEncoder; diff --git a/src/main/resources/application-dev.yml b/src/main/resources/application-dev.yml index c14e48a0..db70ddcf 100644 --- a/src/main/resources/application-dev.yml +++ b/src/main/resources/application-dev.yml @@ -1,17 +1,18 @@ spring: - redis: - open: false # 是否开启redis缓存 true开启 false关闭 - database: 0 - host: 47.93.127.115 - port: 6379 - password: Jgll2015 # 密码(默认为空) - timeout: 6000000ms # 连接超时时长(毫秒) - jedis: - pool: - max-active: 1000 # 连接池最大连接数(使用负值表示没有限制) - max-wait: -1ms # 连接池最大阻塞等待时间(使用负值表示没有限制) - max-idle: 10 # 连接池中的最大空闲连接 - min-idle: 5 # 连接池中的最小空闲连接 + data: + redis: +# open: false # 是否开启redis缓存 true开启 false关闭 + database: 0 + host: 47.93.127.115 + port: 6379 + password: Jgll2015 # 密码(默认为空) + timeout: 6000000ms # 连接超时时长(毫秒) + jedis: + pool: + max-active: 1000 # 连接池最大连接数(使用负值表示没有限制) + max-wait: -1ms # 连接池最大阻塞等待时间(使用负值表示没有限制) + max-idle: 10 # 连接池中的最大空闲连接 + min-idle: 5 # 连接池中的最小空闲连接 datasource: type: com.alibaba.druid.pool.DruidDataSource druid: @@ -31,7 +32,7 @@ spring: time-between-eviction-runs-millis: 60000 min-evictable-idle-time-millis: 300000 #Oracle需要打开注释 - #validation-query: SELECT 1 FROM DUAL + validation-query: SELECT 1 FROM DUAL test-while-idle: true test-on-borrow: false test-on-return: false diff --git a/src/main/resources/application-dev1.yml b/src/main/resources/application-dev1.yml index 88ed4942..ff0aa401 100644 --- a/src/main/resources/application-dev1.yml +++ b/src/main/resources/application-dev1.yml @@ -1,17 +1,18 @@ spring: - redis: - open: true # 是否开启redis缓存 true开启 false关闭 - database: 0 - host: 47.93.127.115 - port: 6379 - password: Jgll2015 # 密码(默认为空) - timeout: 6000000ms # 连接超时时长(毫秒) - jedis: - pool: - max-active: 1000 # 连接池最大连接数(使用负值表示没有限制) - max-wait: -1ms # 连接池最大阻塞等待时间(使用负值表示没有限制) - max-idle: 10 # 连接池中的最大空闲连接 - min-idle: 5 # 连接池中的最小空闲连接 + data: + redis: + open: true # 是否开启redis缓存 true开启 false关闭 + database: 0 + host: 47.93.127.115 + port: 6379 + password: Jgll2015 # 密码(默认为空) + timeout: 6000000ms # 连接超时时长(毫秒) + jedis: + pool: + max-active: 1000 # 连接池最大连接数(使用负值表示没有限制) + max-wait: -1ms # 连接池最大阻塞等待时间(使用负值表示没有限制) + max-idle: 10 # 连接池中的最大空闲连接 + min-idle: 5 # 连接池中的最小空闲连接 datasource: type: com.alibaba.druid.pool.DruidDataSource druid: diff --git a/src/main/resources/application-prod.yml b/src/main/resources/application-prod.yml index 1e09abc0..5718d8f6 100644 --- a/src/main/resources/application-prod.yml +++ b/src/main/resources/application-prod.yml @@ -1,17 +1,18 @@ spring: - redis: - open: false # 是否开启redis缓存 true开启 false关闭 - database: 0 - host: 59.110.212.44 - port: 6379 - password: Jgll2015 # 密码(默认为空) - timeout: 6000000ms # 连接超时时长(毫秒) - jedis: - pool: - max-active: 1000 # 连接池最大连接数(使用负值表示没有限制) - max-wait: -1ms # 连接池最大阻塞等待时间(使用负值表示没有限制) - max-idle: 10 # 连接池中的最大空闲连接 - min-idle: 5 # 连接池中的最小空闲连接 + data: + redis: + open: false # 是否开启redis缓存 true开启 false关闭 + database: 0 + host: 59.110.212.44 + port: 6379 + password: Jgll2015 # 密码(默认为空) + timeout: 6000000ms # 连接超时时长(毫秒) + jedis: + pool: + max-active: 1000 # 连接池最大连接数(使用负值表示没有限制) + max-wait: -1ms # 连接池最大阻塞等待时间(使用负值表示没有限制) + max-idle: 10 # 连接池中的最大空闲连接 + min-idle: 5 # 连接池中的最小空闲连接 datasource: type: com.alibaba.druid.pool.DruidDataSource druid: @@ -31,7 +32,7 @@ spring: time-between-eviction-runs-millis: 60000 min-evictable-idle-time-millis: 300000 #Oracle需要打开注释 - #validation-query: SELECT 1 FROM DUAL + validation-query: SELECT 1 FROM DUAL test-while-idle: true test-on-borrow: false test-on-return: false diff --git a/src/main/resources/application-test.yml b/src/main/resources/application-test.yml index 4b69d7a8..ec6113b9 100644 --- a/src/main/resources/application-test.yml +++ b/src/main/resources/application-test.yml @@ -1,17 +1,18 @@ spring: - redis: - open: false # 是否开启redis缓存 true开启 false关闭 - database: 0 - host: 47.93.127.115 - port: 6379 - password: Jgll2015 # 密码(默认为空) - timeout: 6000000ms # 连接超时时长(毫秒) - jedis: - pool: - max-active: 1000 # 连接池最大连接数(使用负值表示没有限制) - max-wait: -1ms # 连接池最大阻塞等待时间(使用负值表示没有限制) - max-idle: 10 # 连接池中的最大空闲连接 - min-idle: 5 # 连接池中的最小空闲连接 + data: + redis: + open: false # 是否开启redis缓存 true开启 false关闭 + database: 0 + host: 47.93.127.115 + port: 6379 + password: Jgll2015 # 密码(默认为空) + timeout: 6000000ms # 连接超时时长(毫秒) + jedis: + pool: + max-active: 1000 # 连接池最大连接数(使用负值表示没有限制) + max-wait: -1ms # 连接池最大阻塞等待时间(使用负值表示没有限制) + max-idle: 10 # 连接池中的最大空闲连接 + min-idle: 5 # 连接池中的最小空闲连接 datasource: type: com.alibaba.druid.pool.DruidDataSource druid: diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 1dd2aaf4..0a704428 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -39,6 +39,18 @@ spring: max-size: 50 main: allow-circular-references: true + ai: + openai: + api-key: sk-9b9babcc85414e999faac58411eb40d0 # 设置 DeepSeek API 的访问密钥,永远不要将密钥提交到代码仓库,建议通过环境变量注入。-收费 + base-url: https://api.deepseek.com # 指定 DeepSeek API 的基础地址,格式与OpenAI相同。 + chat: + options: + model: deepseek-chat # 选择要调用的 DeepSeek 模型名称,必须与 DeepSeek 支持的模型列表匹配(如 deepseek-chat、deepseek-coder 等),不同模型可能有不同的计费标准和能力。 + temperature: 0.7 # temperature 值越高,AI 回答越随机和创意;值越低,回答越确定和保守。 +# ollama: +# base-url: http://localhost:11434 +# chat: +# model: deepseek-r1:8b #mybatis mybatis-plus: diff --git a/src/test/java/com/VxApiTest.java b/src/test/java/com/VxApiTest.java deleted file mode 100644 index 19eac407..00000000 --- a/src/test/java/com/VxApiTest.java +++ /dev/null @@ -1,59 +0,0 @@ -package com; - -import com.peanut.common.utils.MD5Utils; -import com.peanut.modules.pay.weChatPay.config.WechatPayConfig; -import com.peanut.modules.pay.weChatPay.dto.WechatPaymentInfo; -import org.junit.Test; -import org.springframework.boot.test.context.SpringBootTest; - -import javax.annotation.Resource; -import java.math.BigDecimal; -import java.security.PrivateKey; -@SpringBootTest -public class VxApiTest { - - - @Resource - private WechatPayConfig wechatPayConfig; - - @Test - public void textgetPrivateKey(){ - //获取私钥路径 - String keyPemPath = wechatPayConfig.getKeyPemPath(); - //获取私钥 - PrivateKey privateKey = wechatPayConfig.getPrivateKey(keyPemPath); - //输出很长的字符串 如果有问题转json试试 - System.out.println(privateKey); - - } - - - @Test - public void getWxPayConfig(){ - String mchId =wechatPayConfig.getMchId(); - System.out.println(mchId); - } - - @Test - public void mytest(){ - WechatPaymentInfo wechatPaymentInfo = new WechatPaymentInfo(); - wechatPaymentInfo.setTotalAmount(new BigDecimal(56)); - wechatPaymentInfo.setOrderSn("testtest"); - System.out.println(wechatPaymentInfo.toString()); - } - - @Test - public void mmm(){ - String saltMD5 = MD5Utils.getSaltMD5("29698073wjl"); - System.out.println(saltMD5); - } - - @Test - public void mmmm(){ -// boolean saltverifyMD5 = MD5Utils.getSaltverifyMD5("29698073wjl", "15af9ed9b06a442b90b09e78d21a3635890e24196db1a61e"); - boolean saltverifyMD5 = MD5Utils.getSaltverifyMD5("29698073wjl", "f33643591f4e942d3918f582555719247f6e90131ea1dc0a"); - System.out.println(saltverifyMD5); - } - - -} diff --git a/src/test/java/com/peanut/JwtTest.java b/src/test/java/com/peanut/JwtTest.java index 44e4b1d3..a21039fc 100644 --- a/src/test/java/com/peanut/JwtTest.java +++ b/src/test/java/com/peanut/JwtTest.java @@ -1,9 +1,6 @@ package com.peanut; -import com.peanut.modules.app.utils.JwtUtils; -import org.junit.Test; import org.junit.runner.RunWith; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.junit4.SpringRunner; @@ -11,14 +8,6 @@ import org.springframework.test.context.junit4.SpringRunner; @RunWith(SpringRunner.class) @SpringBootTest public class JwtTest { - @Autowired - private JwtUtils jwtUtils; - @Test - public void test() { - String token = jwtUtils.generateToken(1); - - System.out.println(token); - } }