升级java17
This commit is contained in:
85
pom.xml
85
pom.xml
@@ -11,26 +11,25 @@
|
||||
<parent>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-parent</artifactId>
|
||||
<version>2.6.6</version>
|
||||
<version>3.3.9</version>
|
||||
</parent>
|
||||
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||
<java.version>1.8</java.version>
|
||||
<mybatisplus.version>3.3.1</mybatisplus.version>
|
||||
<mysql.version>8.0.28</mysql.version>
|
||||
<java.version>17</java.version>
|
||||
<mybatisplus.version>3.5.9</mybatisplus.version>
|
||||
<mysql.version>8.0.33</mysql.version>
|
||||
<mssql.version>4.0</mssql.version>
|
||||
<oracle.version>11.2.0.3</oracle.version>
|
||||
<druid.version>1.2.1</druid.version>
|
||||
<druid.version>1.2.18</druid.version>
|
||||
<quartz.version>2.3.0</quartz.version>
|
||||
<commons.lang.version>2.6</commons.lang.version>
|
||||
<commons.fileupload.version>1.2.2</commons.fileupload.version>
|
||||
<commons.io.version>2.5</commons.io.version>
|
||||
<commons.codec.version>1.10</commons.codec.version>
|
||||
<commons.configuration.version>1.10</commons.configuration.version>
|
||||
<shiro.version>1.9.0</shiro.version>
|
||||
<jwt.version>0.7.0</jwt.version>
|
||||
<kaptcha.version>0.0.9</kaptcha.version>
|
||||
<qiniu.version>7.2.23</qiniu.version>
|
||||
@@ -41,7 +40,7 @@
|
||||
<gson.version>2.10.1</gson.version>
|
||||
<fastjson.version>1.2.79</fastjson.version>
|
||||
<hutool.version>5.7.22</hutool.version>
|
||||
<lombok.version>1.18.4</lombok.version>
|
||||
<lombok.version>1.18.24</lombok.version>
|
||||
<expiringmap.varsion>0.5.10</expiringmap.varsion>
|
||||
<aspectjweaverversion>1.9.4</aspectjweaverversion>
|
||||
|
||||
@@ -56,6 +55,17 @@
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.google.guava</groupId>
|
||||
<artifactId>guava</artifactId>
|
||||
<version>32.0.1-android</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.plugin</groupId>
|
||||
<artifactId>spring-plugin-core</artifactId>
|
||||
<version>3.0.0</version>
|
||||
</dependency>
|
||||
<!--stripe支付-->
|
||||
<dependency>
|
||||
<groupId>com.stripe</groupId>
|
||||
@@ -136,7 +146,7 @@
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>mybatis-plus-boot-starter</artifactId>
|
||||
<artifactId>mybatis-plus-spring-boot3-starter</artifactId>
|
||||
<version>${mybatisplus.version}</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
@@ -145,7 +155,12 @@
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
<!--mybatis-plus分页插件使用必须依赖项-->
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>mybatis-plus-jsqlparser</artifactId>
|
||||
<version>${mybatisplus.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>mysql</groupId>
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
@@ -155,7 +170,7 @@
|
||||
<dependency>
|
||||
<groupId>org.redisson</groupId>
|
||||
<artifactId>redisson</artifactId>
|
||||
<version>3.12.5</version>
|
||||
<version>3.22.0</version>
|
||||
</dependency>
|
||||
|
||||
<!--阿里短信服务-->
|
||||
@@ -268,12 +283,6 @@
|
||||
<artifactId>postgresql</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!--集成 微信 登录 -->
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.httpcomponents</groupId>
|
||||
<artifactId>httpclient</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
@@ -316,15 +325,41 @@
|
||||
<artifactId>commons-configuration</artifactId>
|
||||
<version>${commons.configuration.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.shiro</groupId>
|
||||
<artifactId>shiro-spring</artifactId>
|
||||
<classifier>jakarta</classifier>
|
||||
<version>1.12.0</version>
|
||||
<!-- 排除仍使用了javax.servlet的依赖 -->
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.apache.shiro</groupId>
|
||||
<artifactId>shiro-core</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.apache.shiro</groupId>
|
||||
<artifactId>shiro-web</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<!-- 引入适配jakarta的依赖包 -->
|
||||
<dependency>
|
||||
<groupId>org.apache.shiro</groupId>
|
||||
<artifactId>shiro-core</artifactId>
|
||||
<version>${shiro.version}</version>
|
||||
<classifier>jakarta</classifier>
|
||||
<version>1.12.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.shiro</groupId>
|
||||
<artifactId>shiro-spring</artifactId>
|
||||
<version>${shiro.version}</version>
|
||||
<artifactId>shiro-web</artifactId>
|
||||
<classifier>jakarta</classifier>
|
||||
<version>1.12.0</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.apache.shiro</groupId>
|
||||
<artifactId>shiro-core</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.jsonwebtoken</groupId>
|
||||
@@ -336,21 +371,11 @@
|
||||
<artifactId>kaptcha</artifactId>
|
||||
<version>${kaptcha.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.springfox</groupId>
|
||||
<artifactId>springfox-swagger2</artifactId>
|
||||
<version>${swagger.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.aliyun</groupId>
|
||||
<artifactId>vod20170321</artifactId>
|
||||
<version>2.20.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.springfox</groupId>
|
||||
<artifactId>springfox-swagger-ui</artifactId>
|
||||
<version>${swagger.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.qiniu</groupId>
|
||||
<artifactId>qiniu-java-sdk</artifactId>
|
||||
@@ -446,7 +471,7 @@
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<configuration>
|
||||
<fork>true</fork>
|
||||
<!-- <fork>true</fork>-->
|
||||
</configuration>
|
||||
</plugin>
|
||||
<!-- 跳过单元测试 -->
|
||||
|
||||
@@ -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<String, Object> 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;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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<String, Object> getConfig ( int type ) {
|
||||
|
||||
Map<String, Object> conf = new HashMap<String, Object>();
|
||||
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]*?\\*/", "" );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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<String, Integer> 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<String, Integer>(){{
|
||||
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 );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
package com.baidu.ueditor.define;
|
||||
|
||||
public enum ActionState {
|
||||
UNKNOW_ERROR
|
||||
}
|
||||
@@ -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<Integer, String> info = new HashMap<Integer, String>(){{
|
||||
|
||||
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 );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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<String, String> infoMap = new HashMap<String, String>();
|
||||
|
||||
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<String> 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+"");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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<String, String> types = new HashMap<String, String>(){{
|
||||
|
||||
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();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
package com.baidu.ueditor.define;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class MIMEType {
|
||||
|
||||
public static final Map<String, String> types = new HashMap<String, String>(){{
|
||||
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 );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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<String, Long> intMap = new HashMap<String, Long>();
|
||||
private Map<String, String> infoMap = new HashMap<String, String>();
|
||||
private List<String> stateList = new ArrayList<String>();
|
||||
|
||||
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<String> 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 );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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();
|
||||
|
||||
}
|
||||
@@ -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<String, Object> 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<File> 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;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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<String> allowTypes = null;
|
||||
private long maxSize = -1;
|
||||
|
||||
private List<String> filters = null;
|
||||
|
||||
public ImageHunter ( Map<String, Object> 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;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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<String, Object> 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;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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<String, Object> 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<String> list = Arrays.asList(allowTypes);
|
||||
|
||||
return list.contains(type);
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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<String, Object> conf = null;
|
||||
|
||||
public Uploader(HttpServletRequest request, Map<String, Object> 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;
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -11,7 +11,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 {
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ 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地址
|
||||
|
||||
@@ -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;
|
||||
|
||||
98
src/main/java/com/peanut/common/utils/SmsUtil.java
Normal file
98
src/main/java/com/peanut/common/utils/SmsUtil.java
Normal file
@@ -0,0 +1,98 @@
|
||||
package com.peanut.common.utils;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import org.apache.http.client.methods.HttpPost;
|
||||
import org.apache.http.entity.StringEntity;
|
||||
import org.apache.http.impl.client.CloseableHttpClient;
|
||||
import org.apache.http.impl.client.HttpClients;
|
||||
import org.apache.http.util.EntityUtils;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.net.URLEncoder;
|
||||
|
||||
@Component
|
||||
public class SmsUtil {
|
||||
|
||||
@Value("${sms.domestic.url}")
|
||||
private String url;
|
||||
@Value("${sms.domestic.account}")
|
||||
private String account;
|
||||
@Value("${sms.domestic.pswd}")
|
||||
private String pswd;
|
||||
@Value("${sms.domestic.content}")
|
||||
private String content;
|
||||
@Value("${sms.abroad.url}")
|
||||
private String abroadUrl;
|
||||
@Value("${sms.abroad.account}")
|
||||
private String abroadAccount;
|
||||
@Value("${sms.abroad.pswd}")
|
||||
private String abroadPswd;
|
||||
@Value("${sms.abroad.content}")
|
||||
private String abroadContent;
|
||||
|
||||
public R sendSmsCode(String phone, String code) {
|
||||
try {
|
||||
CloseableHttpClient client = HttpClients.createDefault();
|
||||
HttpPost httpPost = new HttpPost(url);
|
||||
StringEntity entity = new StringEntity("" +
|
||||
"account="+account+
|
||||
"&pswd="+pswd+
|
||||
"&mobile="+phone+
|
||||
"&msg="+ URLEncoder.encode(content.replace("XXXXXX",code), "UTF-8")+
|
||||
"&needstatus=false");
|
||||
httpPost.setHeader("Content-Type", "application/x-www-form-urlencoded");
|
||||
httpPost.setEntity(entity);
|
||||
String returnString = EntityUtils.toString(client.execute(httpPost).getEntity());
|
||||
//20250416115415,0
|
||||
String[] res = returnString.split(",");
|
||||
if ("0".equals(res[1])){
|
||||
return R.ok();
|
||||
}else if ("104".equals(res[1])){
|
||||
return R.error("短信平台系统忙,请稍后重试。");
|
||||
}else if ("107".equals(res[1])){
|
||||
return R.error("错误的手机号码。");
|
||||
}else {
|
||||
return R.error("系统错误,请联系管理员");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return R.error("系统错误,请联系管理员");
|
||||
}
|
||||
}
|
||||
|
||||
public R sendSmsAbroad(String phone, String code){
|
||||
try {
|
||||
CloseableHttpClient client = HttpClients.createDefault();
|
||||
HttpPost httpPost = new HttpPost(abroadUrl);
|
||||
StringEntity entity = new StringEntity("" +
|
||||
"sp_id="+abroadAccount+
|
||||
"&password="+MD5Utils.getStrrMD5(abroadPswd)+
|
||||
"&mobile="+phone+
|
||||
"&content="+abroadContent.replace("XXXXXX",code));
|
||||
httpPost.setEntity(entity);
|
||||
httpPost.setHeader("Content-Type", "application/x-www-form-urlencoded");
|
||||
String responseBody = EntityUtils.toString(client.execute(httpPost).getEntity());
|
||||
System.out.println(responseBody);
|
||||
JSONObject object = JSONObject.parseObject(responseBody);
|
||||
if ("0".equals(object.get("code").toString())){
|
||||
return R.ok();
|
||||
}else if ("10000".equals(object.get("code").toString())){
|
||||
return R.error("短信平台系统忙,请稍后重试。");
|
||||
}else {
|
||||
if ("WL:CDQC".equals(object.get("data").toString())){
|
||||
return R.error("地区不支持。");
|
||||
}else if ("WL:CWHM".equals(object.get("data").toString())){
|
||||
return R.error("错误的手机号码。");
|
||||
}else {
|
||||
return R.error("系统错误,请联系管理员");
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return R.error("系统错误,请联系管理员");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
/**
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
package com.peanut.common.validator.group;
|
||||
|
||||
import javax.validation.GroupSequence;
|
||||
import jakarta.validation.GroupSequence;
|
||||
|
||||
/**
|
||||
* 定义校验顺序,如果AddGroup组失败,则UpdateGroup组不会再校验
|
||||
|
||||
@@ -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;
|
||||
|
||||
/**
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -14,7 +14,7 @@ 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配置
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -20,11 +21,12 @@ import org.springframework.context.annotation.Configuration;
|
||||
@Configuration
|
||||
public class MybatisPlusConfig {
|
||||
|
||||
/**
|
||||
* 分页插件
|
||||
*/
|
||||
@Bean
|
||||
public PaginationInterceptor paginationInterceptor() {
|
||||
return new PaginationInterceptor();
|
||||
public MybatisPlusInterceptor mybatisPlusInterceptor() {
|
||||
MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
|
||||
// 添加分页插件
|
||||
interceptor.addInnerInterceptor(new PaginationInnerInterceptor());
|
||||
return interceptor;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ 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;
|
||||
|
||||
@@ -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<ApiKey> security() {
|
||||
return newArrayList(
|
||||
new ApiKey("token", "token", "header")
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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 {
|
||||
}
|
||||
@@ -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 {
|
||||
|
||||
}
|
||||
@@ -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;//国际短信模版
|
||||
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -1,42 +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.context.annotation.Configuration;
|
||||
import org.springframework.web.method.support.HandlerMethodArgumentResolver;
|
||||
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* MVC配置
|
||||
*
|
||||
* @author Mark sunlightcs@gmail.com
|
||||
*/
|
||||
@Configuration
|
||||
public class WebMvcConfig implements WebMvcConfigurer {
|
||||
@Autowired
|
||||
private AuthorizationInterceptor authorizationInterceptor;
|
||||
@Autowired
|
||||
private LoginUserHandlerMethodArgumentResolver loginUserHandlerMethodArgumentResolver;
|
||||
|
||||
@Override
|
||||
public void addInterceptors(InterceptorRegistry registry) {
|
||||
registry.addInterceptor(authorizationInterceptor).addPathPatterns("/app/**");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addArgumentResolvers(List<HandlerMethodArgumentResolver> argumentResolvers) {
|
||||
argumentResolvers.add(loginUserHandlerMethodArgumentResolver);
|
||||
}
|
||||
}
|
||||
@@ -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<String, Object> map = new HashMap<>();
|
||||
// map.put("token", token);
|
||||
// map.put("expire", jwtUtils.getExpire());
|
||||
//
|
||||
// return R.ok(map);
|
||||
// }
|
||||
|
||||
}
|
||||
@@ -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();
|
||||
// }
|
||||
}
|
||||
@@ -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也能访问。。。");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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 + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -226,19 +226,14 @@ public class BookController {
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
//查询书籍是否加入书架
|
||||
Integer integer = bookShelfService.getBaseMapper().selectCount(new QueryWrapper<BookShelfEntity>()
|
||||
long integer = bookShelfService.getBaseMapper().selectCount(new QueryWrapper<BookShelfEntity>()
|
||||
.eq("book_id", id)
|
||||
.eq("user_id", userId));
|
||||
|
||||
boolean flag = false;
|
||||
|
||||
if (integer > 0) {
|
||||
flag = true;
|
||||
}
|
||||
|
||||
book.setAuthorName(authorName);
|
||||
book.setPublisherName(publisherName);
|
||||
book.setFlag(flag);
|
||||
@@ -908,7 +903,7 @@ public class BookController {
|
||||
for (BookEntity b:bookEntityPage.getRecords()){
|
||||
LambdaQueryWrapper<BookForumArticlesEntity> bookForumArticlesEntityLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
bookForumArticlesEntityLambdaQueryWrapper.eq(BookForumArticlesEntity::getBookid,b.getId());
|
||||
Integer integer = bookForumArticlesDao.selectCount(bookForumArticlesEntityLambdaQueryWrapper);
|
||||
Integer integer = bookForumArticlesDao.selectCount(bookForumArticlesEntityLambdaQueryWrapper).intValue();
|
||||
b.setForumNum(integer);
|
||||
}
|
||||
|
||||
|
||||
@@ -70,8 +70,7 @@ public class BookShelfController {
|
||||
public R save(@RequestBody BookShelfEntity bookShelf){
|
||||
|
||||
// 加入前判断数据库是否加入过 这本书
|
||||
Integer integer = bookShelfService.getBaseMapper().selectCount(new QueryWrapper<BookShelfEntity>()
|
||||
|
||||
long integer = bookShelfService.getBaseMapper().selectCount(new QueryWrapper<BookShelfEntity>()
|
||||
.eq("book_id", bookShelf.getBookId())
|
||||
.eq("user_id", bookShelf.getUserId()));
|
||||
System.out.println("bookShelf"+bookShelf);
|
||||
|
||||
@@ -45,7 +45,7 @@ public class BookTeachLikeAndCommentController {
|
||||
LambdaQueryWrapper<BookTeachLikeEntity> 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);
|
||||
}
|
||||
|
||||
|
||||
@@ -88,8 +88,8 @@ public class ExpressController {
|
||||
Page<ExpressOrder> expressOrderPage = new Page<>(currentPage, pageSize);
|
||||
QueryWrapper<ExpressOrder> expressOrderQueryWrapper = new QueryWrapper<>();
|
||||
|
||||
int totalDataSize = expressOrderService.count(expressOrderQueryWrapper);
|
||||
int totalPage = totalDataSize / pageSize + 1;
|
||||
long totalDataSize = expressOrderService.count(expressOrderQueryWrapper);
|
||||
int totalPage = Math.toIntExact(totalDataSize / pageSize + 1);
|
||||
Page<ExpressOrder> page = expressOrderService.page(expressOrderPage, expressOrderQueryWrapper);
|
||||
List<ExpressOrder> expressOrderList = page.getRecords();
|
||||
List<PrintTemplateVo> data = new ArrayList<>();
|
||||
|
||||
@@ -215,14 +215,10 @@ public class MyUserController {
|
||||
}
|
||||
i = sb.toString() + i;
|
||||
String code = i + "_"+System.currentTimeMillis();
|
||||
|
||||
//redis 缓存验证码
|
||||
redisTemplate.opsForValue().set("RegistCode"+phone,code,5, TimeUnit.MINUTES);
|
||||
|
||||
//发送
|
||||
userService.sendCodeForRegister(phone,code,areacode);
|
||||
|
||||
return R.ok();
|
||||
return userService.sendCodeForRegister(phone,code,areacode);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -601,34 +597,6 @@ public class MyUserController {
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 电子书购买
|
||||
*/
|
||||
@RequestMapping("/buyEbook")
|
||||
public R buyEbook(@RequestParam Map<String, Object> params){
|
||||
String msg = "";
|
||||
String bookId = (String) params.get("bookId");
|
||||
String userId = (String) params.get("userId");
|
||||
String couponId = (String) params.get("couponId");
|
||||
BookEntity book = this.bookService.getById(bookId);
|
||||
MyUserEntity user = this.userService.getById(userId);
|
||||
if(1 == book.getIsVip()){
|
||||
if(!"1".equals(user.getVip())){
|
||||
msg ="当前书籍为VIP书籍,请开通VIP后购买!";
|
||||
return R.ok().put("msg", msg).put("status","error");
|
||||
}
|
||||
}
|
||||
msg = userService.buyEbook(userId, bookId,couponId);
|
||||
|
||||
if (msg.equals("当前书籍以购买,请勿重复购买!")) {
|
||||
return R.ok().put("msg",msg).put("status","error");
|
||||
}else if (msg.equals("余额不足,请充值!")) {
|
||||
return R.ok().put("msg",msg).put("status","error");
|
||||
}else {
|
||||
return R.ok().put("msg",msg).put("status","success");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 花生币充扣
|
||||
*/
|
||||
|
||||
@@ -22,26 +22,19 @@ public interface MyUserService extends IService<MyUserEntity> {
|
||||
|
||||
PageUtils queryPage(Map<String, Object> params);
|
||||
|
||||
void sendCodeForRegister(String phone, String code,Integer areaCode) throws Exception;
|
||||
R sendCodeForRegister(String phone, String code,Integer areaCode) throws Exception;
|
||||
//电子书鉴权
|
||||
boolean bookAuthenticate(Integer bookId,Integer userId);
|
||||
|
||||
|
||||
//电子书针对听书鉴权
|
||||
boolean bookAuthen(Integer bookId,Integer userId);
|
||||
|
||||
List<BookForumArticlesEntity> getForumsLimit(Integer book_id, Integer limit);
|
||||
|
||||
|
||||
//会员开通 电话 开通 期限
|
||||
boolean openMember(Integer customerId,Integer openMonth);
|
||||
//充值花生币
|
||||
boolean rechargeHSPoint(MyUserEntity userEntity,Integer HSPoint);
|
||||
//电子书购买
|
||||
String buyEbook(String userId, String bookId,String couponId);
|
||||
|
||||
//第三方微信登录
|
||||
R getUserInfoByApp(UserAppAuthorEntity userAppAuthorEntity);
|
||||
|
||||
boolean checkUserBook(Integer userId,Integer bookId);
|
||||
|
||||
|
||||
@@ -57,7 +57,7 @@ public class BookForumArticlesServiceImpl extends ServiceImpl<BookForumArticlesD
|
||||
LambdaQueryWrapper<BookForumArticlesEntity> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(BookForumArticlesEntity::getDelflag,0);
|
||||
wrapper.eq(BookForumArticlesEntity::getBookid,book_id);
|
||||
int count = this.count(wrapper);
|
||||
int count = (int)this.count(wrapper);
|
||||
return count;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,7 +69,7 @@ public class BookForumCommenServiceImpl extends ServiceImpl<BookForumCommentDao,
|
||||
LambdaQueryWrapper<BookForumCommentEntity> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(BookForumCommentEntity::getBfaid,forum_id);
|
||||
wrapper.eq(BookForumCommentEntity::getDelflag,0);
|
||||
int count = this.count(wrapper);
|
||||
int count = (int)this.count(wrapper);
|
||||
return count;
|
||||
}
|
||||
|
||||
@@ -93,7 +93,7 @@ public class BookForumCommenServiceImpl extends ServiceImpl<BookForumCommentDao,
|
||||
LambdaQueryWrapper<BookForumCommentEntity> 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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -280,7 +280,7 @@ public class BuyOrderServiceImpl extends ServiceImpl<BuyOrderDao, BuyOrder> 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<BuyOrder> page = page(buyOrderPage, queryWrapper);
|
||||
List<BuyOrder> buyOrderList = page.getRecords();
|
||||
@@ -593,7 +593,7 @@ public class BuyOrderServiceImpl extends ServiceImpl<BuyOrderDao, BuyOrder> impl
|
||||
QueryWrapper<BuyOrderProduct> buyOrderProductQueryWrapper = new QueryWrapper<>();
|
||||
buyOrderProductQueryWrapper.eq("order_id", buyorder.getOrderId());
|
||||
buyOrderProductQueryWrapper.eq("express_order_id", 0);
|
||||
int count = buyOrderProductService.count(buyOrderProductQueryWrapper);
|
||||
long count = buyOrderProductService.count(buyOrderProductQueryWrapper);
|
||||
if (count == 0) {
|
||||
buyorder.setOrderStatus(Constants.ORDER_STATUS_SHIPPED);
|
||||
}
|
||||
|
||||
@@ -1,37 +1,23 @@
|
||||
package com.peanut.modules.book.service.impl;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.alipay.api.domain.Member;
|
||||
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.ObjectUtils;
|
||||
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.peanut.common.utils.*;
|
||||
import com.peanut.config.DelayQueueConfig;
|
||||
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 com.peanut.modules.mq.service.RabbitMqService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.beanutils.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.*;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
|
||||
import com.peanut.modules.common.dao.MyUserDao;
|
||||
|
||||
@Slf4j
|
||||
@@ -40,7 +26,7 @@ public class MyUserServiceImpl extends ServiceImpl<MyUserDao, MyUserEntity> impl
|
||||
|
||||
|
||||
@Autowired
|
||||
private SMSConfig smsConfig;
|
||||
private SmsUtil smsUtil;
|
||||
@Autowired
|
||||
private BookService bookService;
|
||||
@Autowired
|
||||
@@ -67,9 +53,13 @@ public class MyUserServiceImpl extends ServiceImpl<MyUserDao, MyUserEntity> impl
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendCodeForRegister(String phone, String code,Integer areaCode) throws Exception {
|
||||
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 {
|
||||
return smsUtil.sendSmsCode(phone,scode);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -254,120 +244,6 @@ public class MyUserServiceImpl extends ServiceImpl<MyUserDao, MyUserEntity> impl
|
||||
this.updateById(user);
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public String buyEbook(String userId, String bookId,String couponId) {
|
||||
|
||||
String authorName = "";
|
||||
|
||||
//避免重复购买
|
||||
TransactionDetailsEntity entity = transactionDetailsService.getBaseMapper().selectOne(new QueryWrapper<TransactionDetailsEntity>().eq("user_id", userId)
|
||||
.eq("relation_id", bookId));
|
||||
|
||||
if (entity != null) {
|
||||
return "余额不足,请充值!";
|
||||
}
|
||||
|
||||
|
||||
BigDecimal salePrice = new BigDecimal(0);
|
||||
|
||||
|
||||
// 查询书籍 价格
|
||||
BookEntity book = bookService.getById(Integer.valueOf(bookId));
|
||||
|
||||
// 是否为秒杀
|
||||
Integer isSale = book.getIsSale();
|
||||
if (isSale == 1) {
|
||||
salePrice = book.getSalePrice();
|
||||
}else {
|
||||
salePrice = book.getPrice();
|
||||
}
|
||||
|
||||
//查询用户
|
||||
MyUserEntity user = this.getById(Integer.valueOf(userId));
|
||||
Double peanutCoin = user.getPeanutCoin().doubleValue() - salePrice.doubleValue();
|
||||
if (peanutCoin < 0) {
|
||||
return "当前书籍已购买,请勿重复购买!";
|
||||
}
|
||||
user.setPeanutCoin(new BigDecimal(peanutCoin));
|
||||
this.updateById(user);
|
||||
|
||||
|
||||
TransactionDetailsEntity detailsEntity = new TransactionDetailsEntity();
|
||||
detailsEntity.setUserId(Integer.valueOf(userId));
|
||||
detailsEntity.setChangeAmount(salePrice.negate());
|
||||
detailsEntity.setUserBalance(user.getPeanutCoin());
|
||||
detailsEntity.setRemark("购买:"+book.getName());
|
||||
detailsEntity.setOrderType("购买电子书");
|
||||
detailsEntity.setRelationId(Integer.valueOf(bookId));
|
||||
detailsEntity.setUserName(user.getNickname());
|
||||
detailsEntity.setTel(user.getTel());
|
||||
transactionDetailsService.save(detailsEntity);
|
||||
|
||||
// 插入购买记录
|
||||
UserEbookBuyEntity userEbookBuyEntity = new UserEbookBuyEntity();
|
||||
userEbookBuyEntity.setUserId(Integer.valueOf(userId));
|
||||
userEbookBuyEntity.setBookId(Integer.valueOf(bookId));
|
||||
userEbookBuyEntity.setBookName(book.getName());
|
||||
String authorId = book.getAuthorId();
|
||||
|
||||
String[] authorIds = authorId.split(",");
|
||||
List<String> authorList = Arrays.asList(authorIds);
|
||||
List<AuthorEntity> authorEntities = authorService.getBaseMapper().selectList(new QueryWrapper<AuthorEntity>().in("id", authorList));
|
||||
|
||||
for (AuthorEntity authorEntity : authorEntities) {
|
||||
authorName += "," + authorEntity.getAuthorName();
|
||||
}
|
||||
|
||||
authorName = authorName.startsWith(",") ? authorName.substring(1) : authorName;
|
||||
|
||||
|
||||
userEbookBuyEntity.setAuthor(authorName);
|
||||
userEbookBuyEntity.setImage(book.getImages());
|
||||
userEbookBuyEntity.setPayStatus("支付成功");
|
||||
userEbookBuyEntity.setPayType("point");
|
||||
userEbookBuyEntity.setPayTime(new Date());
|
||||
userEbookBuyService.save(userEbookBuyEntity);
|
||||
return "购买成功!";
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 微信授权登录
|
||||
*
|
||||
* @param userAppAuthorEntity
|
||||
*/
|
||||
@Override
|
||||
public R getUserInfoByApp(UserAppAuthorEntity userAppAuthorEntity) {
|
||||
|
||||
// todo CommConfig WeiXinParam 表未建
|
||||
try {
|
||||
Member member = new Member();
|
||||
BeanUtils.copyProperties(userAppAuthorEntity, member);
|
||||
|
||||
CommConfig commConfig = new CommConfig();
|
||||
//调用微信授权
|
||||
// WeixinLoginUtils appWeiXinUserInfo1 = weixinLoginUtils1.getAppWeiXinUserInfo(commConfig.);
|
||||
WeixinLoginUtils weixinLoginUtils = new WeixinLoginUtils();
|
||||
StringBuilder stringBuilder = weixinLoginUtils.getAccessTokenBycode(commConfig.getUserAppID(), commConfig.getUserAppSecret(), userAppAuthorEntity.getCode());
|
||||
if (stringBuilder != null) {
|
||||
if (stringBuilder.toString().trim().contains("errcode")) {
|
||||
return R.error();
|
||||
}
|
||||
JSONObject object = JSONObject.parseObject(stringBuilder.toString().trim());
|
||||
String accessToken = object.getString("access_token"); //接口调用凭证
|
||||
String openID = object.getString("openid"); //授权用户唯一标识
|
||||
//获取微信用户基本信息
|
||||
WeiXinParam appWeiXinUserInfo = weixinLoginUtils.getAppWeiXinUserInfo(accessToken, openID, WeiXinParam.class);
|
||||
// TODO 业务逻辑
|
||||
|
||||
return R.ok().put("member",member);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return R.ok("sec");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkUserBook(Integer userId, Integer bookId) {
|
||||
@@ -378,37 +254,6 @@ public class MyUserServiceImpl extends ServiceImpl<MyUserDao, MyUserEntity> 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<MyUserEntity> wrapper = new LambdaQueryWrapper<>();
|
||||
|
||||
@@ -86,6 +86,6 @@ public class UserAddressServiceImpl extends ServiceImpl<UserAddressDao, UserAddr
|
||||
QueryWrapper<UserAddress> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("user_id", userId);
|
||||
queryWrapper.eq("is_default", 1);
|
||||
return this.count(queryWrapper);
|
||||
return (int)this.count(queryWrapper);
|
||||
}
|
||||
}
|
||||
@@ -4,8 +4,8 @@ import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableLogic;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.persistence.Temporal;
|
||||
import javax.persistence.TemporalType;
|
||||
import jakarta.persistence.Temporal;
|
||||
import jakarta.persistence.TemporalType;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@@ -51,10 +51,10 @@ public class BookAbroadController {
|
||||
List<BookAbroadComment> commentsTree = comments.stream()
|
||||
.filter((bookAbroadComment) -> bookAbroadComment.getPid() == 0)
|
||||
.map((comment)->{
|
||||
comment.setIsLike(bookAbroadCommentLikeService.count(new LambdaQueryWrapper<BookAbroadCommentLike>()
|
||||
comment.setIsLike((int) bookAbroadCommentLikeService.count(new LambdaQueryWrapper<BookAbroadCommentLike>()
|
||||
.eq(BookAbroadCommentLike::getCommentId,comment.getId())
|
||||
.eq(BookAbroadCommentLike::getUserId,ShiroUtils.getUId())));
|
||||
comment.setLikeCount(bookAbroadCommentLikeService.count(new LambdaQueryWrapper<BookAbroadCommentLike>()
|
||||
comment.setLikeCount((int)bookAbroadCommentLikeService.count(new LambdaQueryWrapper<BookAbroadCommentLike>()
|
||||
.eq(BookAbroadCommentLike::getCommentId,comment.getId())));
|
||||
comment.setUserEntity(userService.getOne(new LambdaQueryWrapper<MyUserEntity>()
|
||||
.select(MyUserEntity::getId,MyUserEntity::getName,MyUserEntity::getNickname,MyUserEntity::getAvatar)
|
||||
@@ -72,10 +72,10 @@ public class BookAbroadController {
|
||||
List<BookAbroadComment> children = all.stream().filter(bookAbroadComment -> {
|
||||
return root.getId().equals(bookAbroadComment.getPid());
|
||||
}).map(bookAbroadComment -> {
|
||||
bookAbroadComment.setIsLike(bookAbroadCommentLikeService.count(new LambdaQueryWrapper<BookAbroadCommentLike>()
|
||||
bookAbroadComment.setIsLike((int)bookAbroadCommentLikeService.count(new LambdaQueryWrapper<BookAbroadCommentLike>()
|
||||
.eq(BookAbroadCommentLike::getCommentId,bookAbroadComment.getId())
|
||||
.eq(BookAbroadCommentLike::getUserId,ShiroUtils.getUId())));
|
||||
bookAbroadComment.setLikeCount(bookAbroadCommentLikeService.count(new LambdaQueryWrapper<BookAbroadCommentLike>()
|
||||
bookAbroadComment.setLikeCount((int)bookAbroadCommentLikeService.count(new LambdaQueryWrapper<BookAbroadCommentLike>()
|
||||
.eq(BookAbroadCommentLike::getCommentId,bookAbroadComment.getId())));
|
||||
bookAbroadComment.setUserEntity(userService.getOne(new LambdaQueryWrapper<MyUserEntity>()
|
||||
.select(MyUserEntity::getId,MyUserEntity::getName,MyUserEntity::getNickname,MyUserEntity::getAvatar)
|
||||
@@ -94,7 +94,7 @@ public class BookAbroadController {
|
||||
//点赞
|
||||
@RequestMapping("/insertBookAbroadCommentLike")
|
||||
public R insertBookAbroadCommentLike(@RequestBody BookAbroadCommentLike commentLike){
|
||||
int count = bookAbroadCommentLikeService.count(new LambdaQueryWrapper<BookAbroadCommentLike>()
|
||||
long count = bookAbroadCommentLikeService.count(new LambdaQueryWrapper<BookAbroadCommentLike>()
|
||||
.eq(BookAbroadCommentLike::getCommentId,commentLike.getCommentId())
|
||||
.eq(BookAbroadCommentLike::getUserId,ShiroUtils.getUId()));
|
||||
if (count > 0) {
|
||||
|
||||
@@ -159,11 +159,11 @@ public class HomeController {
|
||||
wrapper.orderByAsc(BookAbroadToLable::getSort);
|
||||
List<Map<String,Object>> list = toLableService.listMaps(wrapper);
|
||||
for (Map<String, Object> map : list) {
|
||||
int readCount = bookReadRateService.count(new LambdaQueryWrapper<BookReadRateEntity>()
|
||||
long readCount = bookReadRateService.count(new LambdaQueryWrapper<BookReadRateEntity>()
|
||||
.eq(BookReadRateEntity::getBookId,map.get("bookId")));
|
||||
int buyCount = userEbookBuyService.count(new LambdaQueryWrapper<UserEbookBuyEntity>()
|
||||
long buyCount = userEbookBuyService.count(new LambdaQueryWrapper<UserEbookBuyEntity>()
|
||||
.eq(UserEbookBuyEntity::getBookId,map.get("bookId")));
|
||||
int listenCount = bookListeningService.count(new LambdaQueryWrapper<BookListeningEntity>()
|
||||
long listenCount = bookListeningService.count(new LambdaQueryWrapper<BookListeningEntity>()
|
||||
.eq(BookListeningEntity::getBookId,map.get("bookId")));
|
||||
map.put("readCount",readCount);
|
||||
map.put("buyCount",buyCount);
|
||||
@@ -178,7 +178,7 @@ public class HomeController {
|
||||
BookEntity bookEntity = bookService.getById(params.get("bookId").toString());
|
||||
bookEntity.setAuthor(authorService.getById(bookEntity.getAuthorId()));
|
||||
bookEntity.setIsBuy(false);
|
||||
int count = userEbookBuyService.count(new LambdaQueryWrapper<UserEbookBuyEntity>()
|
||||
long count = userEbookBuyService.count(new LambdaQueryWrapper<UserEbookBuyEntity>()
|
||||
.eq(UserEbookBuyEntity::getUserId,ShiroUtils.getUId())
|
||||
.eq(UserEbookBuyEntity::getBookId,params.get("bookId")));
|
||||
if (count > 0) {
|
||||
@@ -227,11 +227,11 @@ public class HomeController {
|
||||
//已读\已买人数
|
||||
@RequestMapping("/getBookReadCount")
|
||||
public R getBookReadCount(@RequestBody Map<String,Object> params){
|
||||
int readCount = bookReadRateService.count(new LambdaQueryWrapper<BookReadRateEntity>()
|
||||
long readCount = bookReadRateService.count(new LambdaQueryWrapper<BookReadRateEntity>()
|
||||
.eq(BookReadRateEntity::getBookId,params.get("bookId")));
|
||||
int buyCount = userEbookBuyService.count(new LambdaQueryWrapper<UserEbookBuyEntity>()
|
||||
long buyCount = userEbookBuyService.count(new LambdaQueryWrapper<UserEbookBuyEntity>()
|
||||
.eq(UserEbookBuyEntity::getBookId,params.get("bookId")));
|
||||
int listenCount = bookListeningService.count(new LambdaQueryWrapper<BookListeningEntity>()
|
||||
long listenCount = bookListeningService.count(new LambdaQueryWrapper<BookListeningEntity>()
|
||||
.eq(BookListeningEntity::getBookId,params.get("bookId")));
|
||||
return R.ok().put("readCount",readCount).put("buyCount",buyCount).put("listenCount",listenCount);
|
||||
}
|
||||
@@ -254,13 +254,13 @@ public class HomeController {
|
||||
@RequestMapping("/insertBookReadRate")
|
||||
public R insertBookReadRate(@RequestBody BookReadRateEntity bookReadRate){
|
||||
//计算百分比
|
||||
int count = bookChapterContentService.count(new LambdaQueryWrapper<BookChapterContentEntity>()
|
||||
long count = bookChapterContentService.count(new LambdaQueryWrapper<BookChapterContentEntity>()
|
||||
.eq(BookChapterContentEntity::getBookId,bookReadRate.getBookId())
|
||||
.eq(BookChapterContentEntity::getLanguage,bookReadRate.getLanguage()));
|
||||
if (count>0){
|
||||
BookChapterContentEntity bcc = bookChapterContentService.getById(bookReadRate.getContentId());
|
||||
if (bcc != null) {
|
||||
int pre = bcc.getNumber()*100/count;
|
||||
int pre = bcc.getNumber()*100/ (int) count;
|
||||
bookReadRate.setPrecent(pre);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ public class OrderController {
|
||||
@RequestMapping("/placeOrder")
|
||||
@Transactional
|
||||
public R createOrder(@RequestBody BuyOrder buyOrder){
|
||||
int count = userEbookBuyService.count(new LambdaQueryWrapper<UserEbookBuyEntity>()
|
||||
long count = userEbookBuyService.count(new LambdaQueryWrapper<UserEbookBuyEntity>()
|
||||
.eq(UserEbookBuyEntity::getUserId,ShiroUtils.getUId())
|
||||
.eq(UserEbookBuyEntity::getBookId,buyOrder.getAbroadBookId()));
|
||||
if (count>0){
|
||||
|
||||
@@ -84,11 +84,11 @@ public class VisitorController {
|
||||
wrapper.orderByAsc(BookAbroadToLable::getSort);
|
||||
List<Map<String,Object>> list = toLableService.listMaps(wrapper);
|
||||
for (Map<String, Object> map : list) {
|
||||
int readCount = bookReadRateService.count(new LambdaQueryWrapper<BookReadRateEntity>()
|
||||
long readCount = bookReadRateService.count(new LambdaQueryWrapper<BookReadRateEntity>()
|
||||
.eq(BookReadRateEntity::getBookId,map.get("bookId")));
|
||||
int buyCount = userEbookBuyService.count(new LambdaQueryWrapper<UserEbookBuyEntity>()
|
||||
long buyCount = userEbookBuyService.count(new LambdaQueryWrapper<UserEbookBuyEntity>()
|
||||
.eq(UserEbookBuyEntity::getBookId,map.get("bookId")));
|
||||
int listenCount = bookListeningService.count(new LambdaQueryWrapper<BookListeningEntity>()
|
||||
long listenCount = bookListeningService.count(new LambdaQueryWrapper<BookListeningEntity>()
|
||||
.eq(BookListeningEntity::getBookId,map.get("bookId")));
|
||||
map.put("readCount",readCount);
|
||||
map.put("buyCount",buyCount);
|
||||
|
||||
@@ -59,7 +59,7 @@ public class CouponController {
|
||||
Page<CouponEntity> couponPage = couponService.page(new Page<>(page, limit), wrapper);
|
||||
for (CouponEntity couponEntity : couponPage.getRecords()) {
|
||||
couponService.setRangeList(couponEntity);
|
||||
couponEntity.setGrantCount(couponHistoryService.count(new LambdaQueryWrapper<CouponHistory>()
|
||||
couponEntity.setGrantCount((int) couponHistoryService.count(new LambdaQueryWrapper<CouponHistory>()
|
||||
.eq(CouponHistory::getCouponId,couponEntity.getId())));
|
||||
}
|
||||
return R.ok().put("couponPage",couponPage);
|
||||
@@ -110,7 +110,7 @@ public class CouponController {
|
||||
public R getCouponInfo(@RequestBody Map<String,Object> params){
|
||||
CouponEntity couponEntity = couponService.getByIdSetRange(Integer.parseInt(params.get("id").toString()));
|
||||
couponService.setRangeList(couponEntity);
|
||||
couponEntity.setGrantCount(couponHistoryService.count(new LambdaQueryWrapper<CouponHistory>()
|
||||
couponEntity.setGrantCount((int) couponHistoryService.count(new LambdaQueryWrapper<CouponHistory>()
|
||||
.eq(CouponHistory::getCouponId,couponEntity.getId())));
|
||||
return R.ok().put("couponEntity",couponEntity);
|
||||
}
|
||||
@@ -136,7 +136,7 @@ public class CouponController {
|
||||
@Transactional
|
||||
public R delCoupon(@RequestBody Map<String,Object> params){
|
||||
int couponId = Integer.parseInt(params.get("id").toString());
|
||||
int count = couponHistoryService.count(new LambdaQueryWrapper<CouponHistory>()
|
||||
long count = couponHistoryService.count(new LambdaQueryWrapper<CouponHistory>()
|
||||
.eq(CouponHistory::getCouponId,couponId));
|
||||
if (count>0){
|
||||
return R.error("已有用户拥有优惠券");
|
||||
|
||||
@@ -85,7 +85,7 @@ public class ExpressController {
|
||||
Page<ExpressOrder> expressOrderPage = new Page<>(currentPage, pageSize);
|
||||
QueryWrapper<ExpressOrder> expressOrderQueryWrapper = new QueryWrapper<>();
|
||||
|
||||
int totalDataSize = expressOrderService.count(expressOrderQueryWrapper);
|
||||
int totalDataSize = (int) expressOrderService.count(expressOrderQueryWrapper);
|
||||
int totalPage = totalDataSize / pageSize + 1;
|
||||
Page<ExpressOrder> page = expressOrderService.page(expressOrderPage, expressOrderQueryWrapper);
|
||||
List<ExpressOrder> expressOrderList = page.getRecords();
|
||||
|
||||
@@ -80,8 +80,7 @@ public class UserController {
|
||||
//redis 缓存验证码
|
||||
redisTemplate.opsForValue().set("RegistCode"+phone,code,5, TimeUnit.MINUTES);
|
||||
//发送
|
||||
userService.sendCodeForRegister(phone,code,areacode);
|
||||
return R.ok();
|
||||
return userService.sendCodeForRegister(phone,code,areacode);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -23,7 +23,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.time.LocalDate;
|
||||
import java.time.Period;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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;
|
||||
|
||||
/**
|
||||
|
||||
@@ -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;
|
||||
|
||||
/**
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
package com.peanut.modules.common.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.peanut.common.utils.R;
|
||||
import com.peanut.modules.common.entity.MyUserEntity;
|
||||
|
||||
public interface MyUserService extends IService<MyUserEntity> {
|
||||
|
||||
void sendCodeForRegister(String phone, String code,Integer areaCode) throws Exception;
|
||||
R sendCodeForRegister(String phone, String code, Integer areaCode) throws Exception;
|
||||
|
||||
}
|
||||
|
||||
@@ -244,29 +244,29 @@ public class ClassEntityServiceImpl extends ServiceImpl<ClassEntityDao, ClassEnt
|
||||
ClassEntity classEntity = this.getBaseMapper().selectById(params.get("classId").toString());
|
||||
ClassModel classModel = classModelDao.selectById(classEntity.getModelId());
|
||||
//开班校验
|
||||
int monitorCount = classUserDao.selectCount(new LambdaQueryWrapper<ClassUser>()
|
||||
long monitorCount = classUserDao.selectCount(new LambdaQueryWrapper<ClassUser>()
|
||||
.eq(ClassUser::getClassId,classEntity.getId()).eq(ClassUser::getRole,"1"));
|
||||
if (monitorCount<1){
|
||||
return R.error("请先设置班长");
|
||||
}
|
||||
int dmonitorCount = classUserDao.selectCount(new LambdaQueryWrapper<ClassUser>()
|
||||
long dmonitorCount = classUserDao.selectCount(new LambdaQueryWrapper<ClassUser>()
|
||||
.eq(ClassUser::getClassId,classEntity.getId()).eq(ClassUser::getRole,"2"));
|
||||
if (dmonitorCount<1){
|
||||
return R.error("请先设置副班长");
|
||||
}
|
||||
int studyCount = classUserDao.selectCount(new LambdaQueryWrapper<ClassUser>()
|
||||
long studyCount = classUserDao.selectCount(new LambdaQueryWrapper<ClassUser>()
|
||||
.eq(ClassUser::getClassId,classEntity.getId()).eq(ClassUser::getRole,"3"));
|
||||
if (studyCount<1){
|
||||
return R.error("请先设置学习委员");
|
||||
}
|
||||
int commentCount = classUserDao.selectCount(new LambdaQueryWrapper<ClassUser>()
|
||||
long commentCount = classUserDao.selectCount(new LambdaQueryWrapper<ClassUser>()
|
||||
.eq(ClassUser::getClassId,classEntity.getId()).eq(ClassUser::getRole,"4"));
|
||||
if (commentCount<3){
|
||||
return R.error("请先设置3位评分员");
|
||||
}
|
||||
|
||||
if (classModel.getIsTask()==1){
|
||||
int taskCount = classTaskDao.selectCount(new LambdaQueryWrapper<ClassTask>()
|
||||
long taskCount = classTaskDao.selectCount(new LambdaQueryWrapper<ClassTask>()
|
||||
.eq(ClassTask::getClassId,classEntity.getId()).eq(ClassTask::getType,"0"));
|
||||
double allWeek = Math.ceil((classModel.getDays()-classModel.getExamDays())/7.0)-2;
|
||||
if (taskCount<allWeek){
|
||||
@@ -274,7 +274,7 @@ public class ClassEntityServiceImpl extends ServiceImpl<ClassEntityDao, ClassEnt
|
||||
}
|
||||
}
|
||||
|
||||
int studentCount = classUserDao.selectCount(new LambdaQueryWrapper<ClassUser>()
|
||||
long studentCount = classUserDao.selectCount(new LambdaQueryWrapper<ClassUser>()
|
||||
.eq(ClassUser::getClassId,classEntity.getId()).eq(ClassUser::getRole,"0"));
|
||||
if (studentCount<classEntity.getNumber()){
|
||||
return R.error("学生人数未满");
|
||||
@@ -286,12 +286,12 @@ public class ClassEntityServiceImpl extends ServiceImpl<ClassEntityDao, ClassEnt
|
||||
for (ClassCourse classCourse : classCourses) {
|
||||
CourseEntity course = courseDao.selectById(classCourse.getCourseId());
|
||||
int singleCount = classExamSubjectDao.selectCount(new LambdaQueryWrapper<ClassExamSubject>()
|
||||
.eq(ClassExamSubject::getCourseId,classCourse.getCourseId()).eq(ClassExamSubject::getType,"0"));
|
||||
.eq(ClassExamSubject::getCourseId,classCourse.getCourseId()).eq(ClassExamSubject::getType,"0")).intValue();
|
||||
if (singleCount<Integer.parseInt(classModel.getExamProportion().split(":")[0])){
|
||||
return R.error(course.getTitle()+"-单选题不足,请补充题库");
|
||||
}
|
||||
int multipleCount = classExamSubjectDao.selectCount(new LambdaQueryWrapper<ClassExamSubject>()
|
||||
.eq(ClassExamSubject::getCourseId,classCourse.getCourseId()).eq(ClassExamSubject::getType,"1"));
|
||||
.eq(ClassExamSubject::getCourseId,classCourse.getCourseId()).eq(ClassExamSubject::getType,"1")).intValue();
|
||||
if (multipleCount<Integer.parseInt(classModel.getExamProportion().split(":")[1])){
|
||||
return R.error(course.getTitle()+"-多选题不足,请补充题库");
|
||||
}
|
||||
@@ -313,7 +313,7 @@ public class ClassEntityServiceImpl extends ServiceImpl<ClassEntityDao, ClassEnt
|
||||
List<CourseCatalogueEntity> catalogues = courseCatalogueDao.selectList(new LambdaQueryWrapper<CourseCatalogueEntity>()
|
||||
.eq(CourseCatalogueEntity::getCourseId,classCourse.getCourseId()));
|
||||
for (CourseCatalogueEntity catalog:catalogues){
|
||||
int ucbCount = userCourseBuyDao.selectCount(new LambdaQueryWrapper<UserCourseBuyEntity>()
|
||||
long ucbCount = userCourseBuyDao.selectCount(new LambdaQueryWrapper<UserCourseBuyEntity>()
|
||||
.eq(UserCourseBuyEntity::getUserId,classUser.getUserId())
|
||||
.eq(UserCourseBuyEntity::getCatalogueId,catalog.getId()));
|
||||
if (ucbCount == 0){
|
||||
@@ -526,7 +526,7 @@ public class ClassEntityServiceImpl extends ServiceImpl<ClassEntityDao, ClassEnt
|
||||
@Override
|
||||
public R delClass(Map<String, Object> params) {
|
||||
ClassEntity classEntity = this.getBaseMapper().selectById(params.get("classId").toString());
|
||||
int count = classUserDao.selectCount(
|
||||
long count = classUserDao.selectCount(
|
||||
new LambdaQueryWrapper<ClassUser>()
|
||||
.eq(ClassUser::getClassId,classEntity.getId())
|
||||
.eq(ClassUser::getRole,0));
|
||||
@@ -584,7 +584,7 @@ public class ClassEntityServiceImpl extends ServiceImpl<ClassEntityDao, ClassEnt
|
||||
List<CourseCatalogueEntity> catalogues = courseCatalogueDao.selectList(new LambdaQueryWrapper<CourseCatalogueEntity>()
|
||||
.eq(CourseCatalogueEntity::getCourseId,course.getId()));
|
||||
for (CourseCatalogueEntity catalog:catalogues){
|
||||
int ucbCount = userCourseBuyDao.selectCount(new LambdaQueryWrapper<UserCourseBuyEntity>()
|
||||
long ucbCount = userCourseBuyDao.selectCount(new LambdaQueryWrapper<UserCourseBuyEntity>()
|
||||
.eq(UserCourseBuyEntity::getUserId,user.getId())
|
||||
.eq(UserCourseBuyEntity::getCatalogueId,catalog.getId()));
|
||||
if (ucbCount > 0){
|
||||
@@ -708,7 +708,7 @@ public class ClassEntityServiceImpl extends ServiceImpl<ClassEntityDao, ClassEnt
|
||||
List<CourseCatalogueEntity> catalogues = courseCatalogueDao.selectList(new LambdaQueryWrapper<CourseCatalogueEntity>()
|
||||
.eq(CourseCatalogueEntity::getCourseId,classCourse.getCourseId()));
|
||||
for (CourseCatalogueEntity catalog:catalogues){
|
||||
int ucbCount = userCourseBuyDao.selectCount(new LambdaQueryWrapper<UserCourseBuyEntity>()
|
||||
long ucbCount = userCourseBuyDao.selectCount(new LambdaQueryWrapper<UserCourseBuyEntity>()
|
||||
.eq(UserCourseBuyEntity::getUserId,user.getId())
|
||||
.eq(UserCourseBuyEntity::getCatalogueId,catalog.getId()));
|
||||
if (ucbCount == 0){
|
||||
@@ -738,7 +738,7 @@ public class ClassEntityServiceImpl extends ServiceImpl<ClassEntityDao, ClassEnt
|
||||
if (courseList.size() > 0){
|
||||
for (ClassCourse classCourse:courseList){
|
||||
//是否有拿过该课程证书
|
||||
int count = userCertificateDao.selectCount(new LambdaQueryWrapper<UserCertificate>()
|
||||
long count = userCertificateDao.selectCount(new LambdaQueryWrapper<UserCertificate>()
|
||||
.and(t->t.eq(UserCertificate::getType,"A").or().eq(UserCertificate::getType,"B"))
|
||||
.eq(UserCertificate::getCourseId,classCourse.getCourseId())
|
||||
.eq(UserCertificate::getUserId,ShiroUtils.getUId()));
|
||||
@@ -759,7 +759,7 @@ public class ClassEntityServiceImpl extends ServiceImpl<ClassEntityDao, ClassEnt
|
||||
}
|
||||
}
|
||||
//判断开班人数
|
||||
int count = classUserDao.selectCount(new LambdaQueryWrapper<ClassUser>()
|
||||
long count = classUserDao.selectCount(new LambdaQueryWrapper<ClassUser>()
|
||||
.eq(ClassUser::getClassId,classEntity.getId())
|
||||
.eq(ClassUser::getRole,"0"));
|
||||
if (count<classEntity.getNumber()){
|
||||
@@ -888,9 +888,9 @@ public class ClassEntityServiceImpl extends ServiceImpl<ClassEntityDao, ClassEnt
|
||||
wrapper.orderByDesc(ClassTask::getId);
|
||||
Page<ClassTask> classTaskPage = classTaskDao.selectPage(new Page<>(page, limit), wrapper);
|
||||
for (ClassTask classTask:classTaskPage.getRecords()){
|
||||
int alreadyReply = classTaskAndQuesReplyDao.selectCount(new LambdaQueryWrapper<ClassTaskAndQuesReply>()
|
||||
long alreadyReply = classTaskAndQuesReplyDao.selectCount(new LambdaQueryWrapper<ClassTaskAndQuesReply>()
|
||||
.eq(ClassTaskAndQuesReply::getRelationId,classTask.getId()));
|
||||
int userNoCount = classTaskAndQuesReplyDao.selectCount(new LambdaQueryWrapper<ClassTaskAndQuesReply>()
|
||||
long userNoCount = classTaskAndQuesReplyDao.selectCount(new LambdaQueryWrapper<ClassTaskAndQuesReply>()
|
||||
.eq(ClassTaskAndQuesReply::getRelationId,classTask.getId())
|
||||
.lt(ClassTaskAndQuesReply::getScoreSuccess,2)
|
||||
.notLike(ClassTaskAndQuesReply::getScoreInfo,"\""+ShiroUtils.getUId()+"\""));
|
||||
@@ -971,7 +971,7 @@ public class ClassEntityServiceImpl extends ServiceImpl<ClassEntityDao, ClassEnt
|
||||
public ClassTask getClassTaskInfoStudent(Map<String, Object> params) {
|
||||
ClassTask classTask = classTaskDao.selectById(params.get("taskId").toString());
|
||||
classTask.setCreateUser(myUserDao.selectById(classTask.getUserId().toString()));
|
||||
int count = classTaskAndQuesReplyDao.selectCount(new LambdaQueryWrapper<ClassTaskAndQuesReply>()
|
||||
long count = classTaskAndQuesReplyDao.selectCount(new LambdaQueryWrapper<ClassTaskAndQuesReply>()
|
||||
.eq(ClassTaskAndQuesReply::getRelationId,classTask.getId())
|
||||
.eq(ClassTaskAndQuesReply::getUserId,ShiroUtils.getUId()));
|
||||
if (count > 0) {
|
||||
@@ -1281,7 +1281,7 @@ public class ClassEntityServiceImpl extends ServiceImpl<ClassEntityDao, ClassEnt
|
||||
wrapper.leftJoin(ClassModel.class,ClassModel::getId,ClassCourse::getModelId);
|
||||
wrapper.eq(ClassModel::getId,classModel.getId());
|
||||
wrapper.ne(CourseCatalogueChapterEntity::getQuestions,"");
|
||||
int count = courseCatalogueChapterDao.selectCount(wrapper);
|
||||
long count = courseCatalogueChapterDao.selectCount(wrapper);
|
||||
BigDecimal totalScore = new BigDecimal(staticScore*count);
|
||||
questionScore = questionScore.divide(totalScore,2, RoundingMode.HALF_UP);
|
||||
questionScore = questionScore.multiply(new BigDecimal(classModel.getQuestionScore()));
|
||||
@@ -1297,7 +1297,7 @@ public class ClassEntityServiceImpl extends ServiceImpl<ClassEntityDao, ClassEnt
|
||||
MPJLambdaWrapper<ClassTask> wrapper = new MPJLambdaWrapper();
|
||||
wrapper.eq(ClassTask::getClassId,classEntity.getId());
|
||||
wrapper.eq(ClassTask::getType,"0");
|
||||
int count = classTaskDao.selectCount(wrapper);
|
||||
long count = classTaskDao.selectCount(wrapper);
|
||||
BigDecimal totalScore = new BigDecimal(staticScore*count);
|
||||
task0Score = task0Score.divide(totalScore,2, RoundingMode.HALF_UP);
|
||||
task0Score = task0Score.multiply(new BigDecimal(classModel.getTaskScore()));
|
||||
@@ -1313,7 +1313,7 @@ public class ClassEntityServiceImpl extends ServiceImpl<ClassEntityDao, ClassEnt
|
||||
MPJLambdaWrapper<ClassTask> wrapper = new MPJLambdaWrapper();
|
||||
wrapper.eq(ClassTask::getClassId,classEntity.getId());
|
||||
wrapper.eq(ClassTask::getType,"1");
|
||||
int count = classTaskDao.selectCount(wrapper);
|
||||
long count = classTaskDao.selectCount(wrapper);
|
||||
BigDecimal totalScore = new BigDecimal(staticScore*count);
|
||||
task1Score = task1Score.divide(totalScore,2, RoundingMode.HALF_UP);
|
||||
task1Score = task1Score.multiply(new BigDecimal(classModel.getMedicalcaseScore()));
|
||||
@@ -1402,17 +1402,17 @@ public class ClassEntityServiceImpl extends ServiceImpl<ClassEntityDao, ClassEnt
|
||||
return R.error("教学时间未完");
|
||||
}
|
||||
//结班限制
|
||||
int classExamUsers = classExamUserDao.selectCount(new LambdaQueryWrapper<ClassExamUser>()
|
||||
long classExamUsers = classExamUserDao.selectCount(new LambdaQueryWrapper<ClassExamUser>()
|
||||
.eq(ClassExamUser::getRelationId,classEntity.getId())
|
||||
.eq(ClassExamUser::getScoreSuccess,0));
|
||||
if (classExamUsers>0){
|
||||
return R.error("有学员正在考试,请稍后再试");
|
||||
}
|
||||
int taskReplys = classTaskAndQuesReplyDao.selectCount(new LambdaQueryWrapper<ClassTaskAndQuesReply>()
|
||||
long taskReplys = classTaskAndQuesReplyDao.selectCount(new LambdaQueryWrapper<ClassTaskAndQuesReply>()
|
||||
.eq(ClassTaskAndQuesReply::getClassId,classEntity.getId())
|
||||
.eq(ClassTaskAndQuesReply::getType,0)
|
||||
.ne(ClassTaskAndQuesReply::getScoreSuccess,2));
|
||||
int questionReplys = classTaskAndQuesReplyDao.selectCount(new LambdaQueryWrapper<ClassTaskAndQuesReply>()
|
||||
long questionReplys = classTaskAndQuesReplyDao.selectCount(new LambdaQueryWrapper<ClassTaskAndQuesReply>()
|
||||
.eq(ClassTaskAndQuesReply::getClassId,classEntity.getId())
|
||||
.eq(ClassTaskAndQuesReply::getType,1)
|
||||
.eq(ClassTaskAndQuesReply::getScoreSuccess,0));
|
||||
|
||||
@@ -79,7 +79,7 @@ public class CouponServiceImpl extends ServiceImpl<CouponDao, CouponEntity> impl
|
||||
public R insertCouponHistory(int couponId, int userId,int getType,String remark) {
|
||||
CouponEntity couponEntity = couponDao.selectById(couponId);
|
||||
if (couponEntity.getCurrentState()==0){
|
||||
int historyCount = couponHistoryDao.selectCount(new LambdaQueryWrapper<CouponHistory>()
|
||||
long historyCount = couponHistoryDao.selectCount(new LambdaQueryWrapper<CouponHistory>()
|
||||
.eq(CouponHistory::getCouponId,couponId));
|
||||
//是否超出总发行量
|
||||
if (historyCount<couponEntity.getTotalCirculation()){
|
||||
|
||||
@@ -92,14 +92,14 @@ public class CourseGuestbookServiceImpl extends ServiceImpl<CourseGuestbookDao,
|
||||
public int getUserSupportCount(int guestbookId) {
|
||||
LambdaQueryWrapper<CourseGuestbookSupport> 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<CourseGuestbookSupport> 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 {
|
||||
|
||||
@@ -1,14 +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.modules.app.config.SMSConfig;
|
||||
import com.peanut.modules.app.config.Sample;
|
||||
import com.peanut.common.utils.R;
|
||||
import com.peanut.common.utils.SmsUtil;
|
||||
import com.peanut.modules.common.dao.MyUserDao;
|
||||
import com.peanut.modules.common.entity.MyUserEntity;
|
||||
import com.peanut.modules.common.service.MyUserService;
|
||||
@@ -21,41 +15,15 @@ import org.springframework.stereotype.Service;
|
||||
public class MyUserServiceImpl extends ServiceImpl<MyUserDao, MyUserEntity> implements MyUserService {
|
||||
|
||||
@Autowired
|
||||
private SMSConfig smsConfig;
|
||||
private SmsUtil smsUtil;
|
||||
|
||||
@Override
|
||||
public void sendCodeForRegister(String phone, String code, Integer areaCode) throws Exception {
|
||||
public R sendCodeForRegister(String phone, String code, Integer areaCode){
|
||||
String scode = code.split("_")[0];
|
||||
sendCode(phone,scode,areaCode);
|
||||
}
|
||||
|
||||
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);
|
||||
if (areaCode!=null&&areaCode>0&&areaCode!=86){
|
||||
return smsUtil.sendSmsAbroad(""+areaCode+phone,scode);
|
||||
}else {
|
||||
return smsUtil.sendSmsCode(phone,scode);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -55,7 +55,7 @@ public class UserInviteRegisterServiceImpl extends ServiceImpl<UserInviteRegiste
|
||||
int index = random.nextInt(chars.length());
|
||||
inviteCode.append(chars.charAt(index));
|
||||
}
|
||||
int count = myUserDao.selectCount(new LambdaQueryWrapper<MyUserEntity>()
|
||||
long count = myUserDao.selectCount(new LambdaQueryWrapper<MyUserEntity>()
|
||||
.eq(MyUserEntity::getInviteCode,inviteCode.toString()));
|
||||
if (count > 0) {
|
||||
code = generateInviteCode();
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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")
|
||||
|
||||
@@ -66,7 +66,7 @@ public class BookAbroadController {
|
||||
public R updateBookAbroadLable(@RequestBody BookAbroadLable lable){
|
||||
BookAbroadLable oldLable = labelService.getById(lable.getId());
|
||||
if (oldLable.getIsLast()!=lable.getIsLast()) {
|
||||
int count = toLableService.count(new LambdaQueryWrapper<BookAbroadToLable>()
|
||||
long count = toLableService.count(new LambdaQueryWrapper<BookAbroadToLable>()
|
||||
.eq(BookAbroadToLable::getLableId,lable.getId()));
|
||||
if (count > 0){
|
||||
return R.error("存在绑定书籍,删除后再操作");
|
||||
@@ -83,7 +83,7 @@ public class BookAbroadController {
|
||||
if (oldLable.getIsLast()!=1){
|
||||
return R.error("不是最下级,禁止删除");
|
||||
}
|
||||
int count = toLableService.count(new LambdaQueryWrapper<BookAbroadToLable>()
|
||||
long count = toLableService.count(new LambdaQueryWrapper<BookAbroadToLable>()
|
||||
.eq(BookAbroadToLable::getLableId,params.get("id").toString()));
|
||||
if (count > 0){
|
||||
return R.error("存在绑定书籍,删除后再操作");
|
||||
@@ -99,7 +99,7 @@ public class BookAbroadController {
|
||||
if (oldLable.getIsLast()!=1){
|
||||
return R.error("不是最下级,禁止绑定");
|
||||
}
|
||||
int count = toLableService.count(new LambdaQueryWrapper<BookAbroadToLable>()
|
||||
long count = toLableService.count(new LambdaQueryWrapper<BookAbroadToLable>()
|
||||
.eq(BookAbroadToLable::getBookId,toLable.getBookId())
|
||||
.eq(BookAbroadToLable::getLableId,toLable.getLableId()));
|
||||
if (count > 0) {
|
||||
|
||||
@@ -59,7 +59,7 @@ public class BuyConfigController {
|
||||
|
||||
@RequestMapping("/delBookBuyConfig")
|
||||
public R delBookBuyConfig(@RequestBody Map<String, Object> params) {
|
||||
int count = buyOrderService.count(new LambdaQueryWrapper<BuyOrder>()
|
||||
long count = buyOrderService.count(new LambdaQueryWrapper<BuyOrder>()
|
||||
.eq(BuyOrder::getOrderStatus,3)
|
||||
.eq(BuyOrder::getProductId,params.get("id").toString()));
|
||||
if (count > 0) {
|
||||
|
||||
@@ -57,14 +57,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<CourseMedicineMarketEntity>().eq(CourseMedicineMarketEntity::getPid, courseMedicineMarketEntity.getId()));
|
||||
long integer = marketService.getBaseMapper().selectCount(new LambdaQueryWrapper<CourseMedicineMarketEntity>().eq(CourseMedicineMarketEntity::getPid, courseMedicineMarketEntity.getId()));
|
||||
if(integer>0){
|
||||
return R.error("请先清空子集再操作!");
|
||||
}
|
||||
}
|
||||
|
||||
if(courseMedicineMarketEntity.getIsLast()==0&&old.getIsLast()==1){
|
||||
Integer integer = toMarketService.getBaseMapper().selectCount(new LambdaQueryWrapper<CourseToMedicineMarketEntity>().eq(CourseToMedicineMarketEntity::getMedicineMarketId, courseMedicineMarketEntity.getId()));
|
||||
long integer = toMarketService.getBaseMapper().selectCount(new LambdaQueryWrapper<CourseToMedicineMarketEntity>().eq(CourseToMedicineMarketEntity::getMedicineMarketId, courseMedicineMarketEntity.getId()));
|
||||
if(integer>0){
|
||||
return R.error("请先清空绑定的课程后,再操作");
|
||||
}
|
||||
@@ -130,7 +130,7 @@ public class CourseMedicineMarketController {
|
||||
public R bindCourseAndMedicineMarket(@RequestBody Map<String,Integer> map){
|
||||
int marketId = map.get("marketId");
|
||||
int courseId = map.get("courseId");
|
||||
Integer integer = toMarketService.getBaseMapper().selectCount(new LambdaQueryWrapper<CourseToMedicineMarketEntity>().eq(CourseToMedicineMarketEntity::getMedicineMarketId, marketId).eq(CourseToMedicineMarketEntity::getCourseId, courseId));
|
||||
long integer = toMarketService.getBaseMapper().selectCount(new LambdaQueryWrapper<CourseToMedicineMarketEntity>().eq(CourseToMedicineMarketEntity::getMedicineMarketId, marketId).eq(CourseToMedicineMarketEntity::getCourseId, courseId));
|
||||
if(integer>0){
|
||||
return R.error("不可重复绑定");
|
||||
}
|
||||
|
||||
@@ -56,14 +56,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<CourseSociologyMarketEntity>().eq(CourseSociologyMarketEntity::getPid, courseSociologyMarketEntity.getId()));
|
||||
long integer = marketService.getBaseMapper().selectCount(new LambdaQueryWrapper<CourseSociologyMarketEntity>().eq(CourseSociologyMarketEntity::getPid, courseSociologyMarketEntity.getId()));
|
||||
if(integer>0){
|
||||
return R.error("请先清空子集再操作!");
|
||||
}
|
||||
}
|
||||
|
||||
if(courseSociologyMarketEntity.getIsLast()==0&&old.getIsLast()==1){
|
||||
Integer integer = toMarketService.getBaseMapper().selectCount(new LambdaQueryWrapper<CourseToSociologyMarketEntity>().eq(CourseToSociologyMarketEntity::getSociologyMarketId, courseSociologyMarketEntity.getId()));
|
||||
long integer = toMarketService.getBaseMapper().selectCount(new LambdaQueryWrapper<CourseToSociologyMarketEntity>().eq(CourseToSociologyMarketEntity::getSociologyMarketId, courseSociologyMarketEntity.getId()));
|
||||
if(integer>0){
|
||||
return R.error("请先清空绑定的课程后,再操作");
|
||||
}
|
||||
@@ -158,7 +158,7 @@ public class CourseSociologyMarketController {
|
||||
public R bindCourseAndSociologyMarket(@RequestBody Map<String,Integer> map){
|
||||
int marketId = map.get("marketId");
|
||||
int courseId = map.get("courseId");
|
||||
Integer integer = toMarketService.getBaseMapper().selectCount(new LambdaQueryWrapper<CourseToSociologyMarketEntity>().eq(CourseToSociologyMarketEntity::getSociologyMarketId, marketId).eq(CourseToSociologyMarketEntity::getCourseId, courseId));
|
||||
long integer = toMarketService.getBaseMapper().selectCount(new LambdaQueryWrapper<CourseToSociologyMarketEntity>().eq(CourseToSociologyMarketEntity::getSociologyMarketId, marketId).eq(CourseToSociologyMarketEntity::getCourseId, courseId));
|
||||
if(integer>0){
|
||||
return R.error("不可重复绑定");
|
||||
}
|
||||
|
||||
@@ -76,7 +76,7 @@ public class OfflineActivityController {
|
||||
|
||||
@RequestMapping("/updateOfflineActivity")
|
||||
public R updateOfflineActivity(@RequestBody OfflineActivity offlineActivity) {
|
||||
int count = toUserService.count(new LambdaQueryWrapper<OfflineActivityToUser>()
|
||||
long count = toUserService.count(new LambdaQueryWrapper<OfflineActivityToUser>()
|
||||
.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<String,Object> params) {
|
||||
int count = toUserService.count(new LambdaQueryWrapper<OfflineActivityToUser>()
|
||||
long count = toUserService.count(new LambdaQueryWrapper<OfflineActivityToUser>()
|
||||
.eq(OfflineActivityToUser::getActivityId,params.get("id").toString()));
|
||||
if (count > 0) {
|
||||
return R.error("已有人报名禁止删除");
|
||||
|
||||
@@ -18,7 +18,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.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
@@ -44,9 +44,9 @@ public class UserVipController {
|
||||
public R getVipProductForUser(@RequestBody Map<String, Object> params){
|
||||
int uid = Integer.parseInt(params.get("uid").toString());
|
||||
MyUserEntity userEntity = userService.getById(uid);
|
||||
Integer chaoCount = vipService.count(new LambdaQueryWrapper<UserVip>().eq(UserVip::getUserId, uid).eq(UserVip::getType, 1).gt(UserVip::getEndTime,new Date()).eq(UserVip::getState,0));
|
||||
Integer medicalCount = vipService.count(new LambdaQueryWrapper<UserVip>().eq(UserVip::getUserId, uid).eq(UserVip::getType, 2).gt(UserVip::getEndTime, new Date()).eq(UserVip::getState, 0));
|
||||
Integer sociologyCount = vipService.count(new LambdaQueryWrapper<UserVip>().eq(UserVip::getUserId, uid).eq(UserVip::getType, 3).gt(UserVip::getEndTime, new Date()).eq(UserVip::getState, 0));
|
||||
long chaoCount = vipService.count(new LambdaQueryWrapper<UserVip>().eq(UserVip::getUserId, uid).eq(UserVip::getType, 1).gt(UserVip::getEndTime,new Date()).eq(UserVip::getState,0));
|
||||
long medicalCount = vipService.count(new LambdaQueryWrapper<UserVip>().eq(UserVip::getUserId, uid).eq(UserVip::getType, 2).gt(UserVip::getEndTime, new Date()).eq(UserVip::getState, 0));
|
||||
long sociologyCount = vipService.count(new LambdaQueryWrapper<UserVip>().eq(UserVip::getUserId, uid).eq(UserVip::getType, 3).gt(UserVip::getEndTime, new Date()).eq(UserVip::getState, 0));
|
||||
//获取超v列表
|
||||
LambdaQueryWrapper<VipBuyConfigEntity> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.in(VipBuyConfigEntity::getType,userEntity.getVip().equals("1")||userEntity.getVip().equals("2")||userEntity.getVip().equals("3")? Collections.singletonList(1): Arrays.asList(1,2,3));
|
||||
|
||||
@@ -17,12 +17,9 @@ 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 javax.xml.ws.soap.Addressing;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Slf4j
|
||||
@Service("masterCourseCatalogueChapterVideoService")
|
||||
@@ -111,7 +108,7 @@ public class CourseCatalogueChapterVideoServiceImpl extends ServiceImpl<CourseCa
|
||||
GetVideoPlayAuthResponse p = SpdbUtil.getPlayAuth(video.getVideo());
|
||||
String playAuth = p.getBody().getPlayAuth();
|
||||
video.setPlayAuth(playAuth);
|
||||
Integer integer = videoM3u8Dao.selectCount(new LambdaQueryWrapper<VideoM3u8Entity>().eq(VideoM3u8Entity::getVid, video.getVideo()));
|
||||
long integer = videoM3u8Dao.selectCount(new LambdaQueryWrapper<VideoM3u8Entity>().eq(VideoM3u8Entity::getVid, video.getVideo()));
|
||||
if(integer>0){
|
||||
String s = playToken.generateToken();
|
||||
GetPlayInfoResponseBody urlBody = SpdbUtil.getUrl(video.getVideo());
|
||||
@@ -190,13 +187,13 @@ public class CourseCatalogueChapterVideoServiceImpl extends ServiceImpl<CourseCa
|
||||
return true;
|
||||
}
|
||||
if(u.getVip().equals("3")){
|
||||
Integer integer = courseToSociologyDao.selectCount(new LambdaQueryWrapper<CourseToSociologyEntity>().eq(CourseToSociologyEntity::getCourseId, courseId));
|
||||
long integer = courseToSociologyDao.selectCount(new LambdaQueryWrapper<CourseToSociologyEntity>().eq(CourseToSociologyEntity::getCourseId, courseId));
|
||||
if(integer>0){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if(u.getVip().equals("2")){
|
||||
Integer integer = courseToMedicineDao.selectCount(new LambdaQueryWrapper<CourseToMedicine>().eq(CourseToMedicine::getCourseId, courseId));
|
||||
long integer = courseToMedicineDao.selectCount(new LambdaQueryWrapper<CourseToMedicine>().eq(CourseToMedicine::getCourseId, courseId));
|
||||
if(integer>0){
|
||||
return true;
|
||||
}
|
||||
@@ -210,7 +207,7 @@ public class CourseCatalogueChapterVideoServiceImpl extends ServiceImpl<CourseCa
|
||||
wrapper.eq(UserCourseBuyEntity::getCatalogueId,courseCatalogueEntity.getId());
|
||||
wrapper.and(i -> 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);
|
||||
long integer = userCourseBuyDao.selectCount(wrapper);
|
||||
return integer>0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,19 +54,19 @@ public class CourseCatalogueServiceImpl extends ServiceImpl<CourseCatalogueDao,
|
||||
|
||||
@Override
|
||||
public R delCourseCatalogue(int id) {
|
||||
Integer integer = courseCatalogueChapterDao.selectCount(new LambdaQueryWrapper<CourseCatalogueChapterEntity>().eq(CourseCatalogueChapterEntity::getCatalogueId, id));
|
||||
long integer = courseCatalogueChapterDao.selectCount(new LambdaQueryWrapper<CourseCatalogueChapterEntity>().eq(CourseCatalogueChapterEntity::getCatalogueId, id));
|
||||
if(integer>0){
|
||||
return R.error(502,"删除失败,请先清空章节");
|
||||
}
|
||||
LambdaQueryWrapper<UserCourseBuyEntity> userCourseBuyEntityLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
userCourseBuyEntityLambdaQueryWrapper.eq(UserCourseBuyEntity::getCatalogueId,id);
|
||||
userCourseBuyEntityLambdaQueryWrapper.gt(UserCourseBuyEntity::getEndTime,new Date());
|
||||
Integer integer1 = userCourseBuyDao.selectCount(userCourseBuyEntityLambdaQueryWrapper);
|
||||
long integer1 = userCourseBuyDao.selectCount(userCourseBuyEntityLambdaQueryWrapper);
|
||||
if(integer1>0){
|
||||
return R.error(502,"删除失败,有人已购买此课程");
|
||||
}
|
||||
|
||||
Integer integer2 = shopProductCourseDao.selectCount(new LambdaQueryWrapper<ShopProductCourseEntity>().eq(ShopProductCourseEntity::getCatalogueId, id));
|
||||
long integer2 = shopProductCourseDao.selectCount(new LambdaQueryWrapper<ShopProductCourseEntity>().eq(ShopProductCourseEntity::getCatalogueId, id));
|
||||
if(integer2>0){
|
||||
return R.error(503,"删除失败,有商品已绑定此课程,请解绑或删除后再操作");
|
||||
}
|
||||
@@ -95,7 +95,7 @@ public class CourseCatalogueServiceImpl extends ServiceImpl<CourseCatalogueDao,
|
||||
if(byId.getFee().compareTo(BigDecimal.ZERO)==0||byId.getHalfFee().compareTo(BigDecimal.ZERO)==0){
|
||||
return R.error("价格异常");
|
||||
}
|
||||
Integer integer = shopProductCourseDao.selectCount(new LambdaQueryWrapper<ShopProductCourseEntity>()
|
||||
long integer = shopProductCourseDao.selectCount(new LambdaQueryWrapper<ShopProductCourseEntity>()
|
||||
.eq(ShopProductCourseEntity::getCatalogueId, byId.getId()));
|
||||
if(integer>1){
|
||||
return R.error("生成失败!已存在商品数量大于等于2,快捷生成商品不可用");
|
||||
|
||||
@@ -29,12 +29,12 @@ public class CourseMedicineServiceImpl extends ServiceImpl<CourseMedicineDao, Co
|
||||
@Override
|
||||
public R delCourseMedical(int id) {
|
||||
//查看下一级是否存在
|
||||
int count = this.count(new LambdaQueryWrapper<CourseMedicine>().eq(CourseMedicine::getPid, id));
|
||||
long count = this.count(new LambdaQueryWrapper<CourseMedicine>().eq(CourseMedicine::getPid, id));
|
||||
if(count>0){
|
||||
return R.error(501,"删除失败,请先删除子项目后再尝试");
|
||||
}
|
||||
//查看绑定关系是否存在
|
||||
Integer integer = toMedicalDao.selectCount(new LambdaQueryWrapper<CourseToMedicine>().eq(CourseToMedicine::getMedicalId, id));
|
||||
long integer = toMedicalDao.selectCount(new LambdaQueryWrapper<CourseToMedicine>().eq(CourseToMedicine::getMedicalId, id));
|
||||
if(integer>0){
|
||||
return R.error(502,"删除失败,请先解绑课程与国学标签的绑定关系");
|
||||
}
|
||||
@@ -52,7 +52,7 @@ public class CourseMedicineServiceImpl extends ServiceImpl<CourseMedicineDao, Co
|
||||
}
|
||||
}
|
||||
if(old.getIsLast()==1&& courseMedicine.getIsLast()==0){
|
||||
Integer integer = toMedicalDao.selectCount(new LambdaQueryWrapper<CourseToMedicine>().eq(CourseToMedicine::getMedicalId, courseMedicine.getId()));
|
||||
long integer = toMedicalDao.selectCount(new LambdaQueryWrapper<CourseToMedicine>().eq(CourseToMedicine::getMedicalId, courseMedicine.getId()));
|
||||
if(integer>0){
|
||||
return R.error(502,"更新失败,请先把此项与课程的关联关系清空后才可把此标签变成普通标签");
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
@@ -95,7 +94,7 @@ public class CourseServiceImpl extends ServiceImpl<CourseDao, CourseEntity> impl
|
||||
|
||||
@Override
|
||||
public R delCourse(int id) {
|
||||
Integer integer = courseCatalogueDao.selectCount(new LambdaQueryWrapper<CourseCatalogueEntity>().eq(CourseCatalogueEntity::getCourseId, id));
|
||||
long integer = courseCatalogueDao.selectCount(new LambdaQueryWrapper<CourseCatalogueEntity>().eq(CourseCatalogueEntity::getCourseId, id));
|
||||
if (integer>0){
|
||||
return R.error(501,"请先删除目录后再删除!");
|
||||
}
|
||||
|
||||
@@ -29,12 +29,12 @@ public class CourseSociologyServiceImpl extends ServiceImpl<CourseSociologyDao,
|
||||
@Override
|
||||
public R delCourseSociology(int id) {
|
||||
//查看下一级是否存在
|
||||
int count = this.count(new LambdaQueryWrapper<CourseSociologyEntity>().eq(CourseSociologyEntity::getPid, id));
|
||||
long count = this.count(new LambdaQueryWrapper<CourseSociologyEntity>().eq(CourseSociologyEntity::getPid, id));
|
||||
if(count>0){
|
||||
return R.error(501,"删除失败,请先删除子项目后再尝试");
|
||||
}
|
||||
//查看绑定关系是否存在
|
||||
Integer integer = courseToSociologyDao.selectCount(new LambdaQueryWrapper<CourseToSociologyEntity>().eq(CourseToSociologyEntity::getSociologyId, id));
|
||||
long integer = courseToSociologyDao.selectCount(new LambdaQueryWrapper<CourseToSociologyEntity>().eq(CourseToSociologyEntity::getSociologyId, id));
|
||||
if(integer>0){
|
||||
return R.error(502,"删除失败,请先解绑课程与国学标签的绑定关系");
|
||||
}
|
||||
|
||||
@@ -75,7 +75,7 @@ public class ShopProductServiceImpl extends ServiceImpl<ShopProductDao, ShopProd
|
||||
public void bindProductAndBookLabel(String[] productIds, Integer labelId) {
|
||||
for (String id:productIds){
|
||||
//check
|
||||
Integer integer = shopProductToBookLabelDao.selectCount(new LambdaQueryWrapper<ShopProductToBookLabel>().eq(ShopProductToBookLabel::getProductId, Integer.valueOf(id)).eq(ShopProductToBookLabel::getBookLabelId, labelId));
|
||||
long integer = shopProductToBookLabelDao.selectCount(new LambdaQueryWrapper<ShopProductToBookLabel>().eq(ShopProductToBookLabel::getProductId, Integer.valueOf(id)).eq(ShopProductToBookLabel::getBookLabelId, labelId));
|
||||
if(integer>0){
|
||||
continue;
|
||||
}
|
||||
@@ -94,7 +94,7 @@ public class ShopProductServiceImpl extends ServiceImpl<ShopProductDao, ShopProd
|
||||
@Override
|
||||
public void bindProductAndBookMarket(String[] productIds, Integer marketId) {
|
||||
for (String p:productIds){
|
||||
Integer integer = shopProductToBookMarketDao.selectCount(new LambdaQueryWrapper<ShopProductToBookMarket>().eq(ShopProductToBookMarket::getProductId, Integer.valueOf(p)).eq(ShopProductToBookMarket::getBookMarketId, marketId));
|
||||
long integer = shopProductToBookMarketDao.selectCount(new LambdaQueryWrapper<ShopProductToBookMarket>().eq(ShopProductToBookMarket::getProductId, Integer.valueOf(p)).eq(ShopProductToBookMarket::getBookMarketId, marketId));
|
||||
if(integer>0){
|
||||
continue;
|
||||
}
|
||||
@@ -113,7 +113,7 @@ public class ShopProductServiceImpl extends ServiceImpl<ShopProductDao, ShopProd
|
||||
@Override
|
||||
public void bindProductAndSociologyLabel(String[] productIds, Integer labelId) {
|
||||
for (String p : productIds){
|
||||
Integer integer = shopProductToSociologyLabelDao.selectCount(new LambdaQueryWrapper<ShopProductToSociologyLabel>().eq(ShopProductToSociologyLabel::getProductId, Integer.valueOf(p)).eq(ShopProductToSociologyLabel::getSociologyLabelId, labelId));
|
||||
long integer = shopProductToSociologyLabelDao.selectCount(new LambdaQueryWrapper<ShopProductToSociologyLabel>().eq(ShopProductToSociologyLabel::getProductId, Integer.valueOf(p)).eq(ShopProductToSociologyLabel::getSociologyLabelId, labelId));
|
||||
if(integer>0){
|
||||
continue;
|
||||
}
|
||||
@@ -132,7 +132,7 @@ public class ShopProductServiceImpl extends ServiceImpl<ShopProductDao, ShopProd
|
||||
@Override
|
||||
public void bindProductAndSociologyMarket(String[] productId, int marketId) {
|
||||
for (String p:productId){
|
||||
Integer integer = shopProductToSociologyMarketDao.selectCount(new LambdaQueryWrapper<ShopProductToSociologyMarket>().eq(ShopProductToSociologyMarket::getProductId, Integer.valueOf(p)).eq(ShopProductToSociologyMarket::getSociologyMarketId, marketId));
|
||||
long integer = shopProductToSociologyMarketDao.selectCount(new LambdaQueryWrapper<ShopProductToSociologyMarket>().eq(ShopProductToSociologyMarket::getProductId, Integer.valueOf(p)).eq(ShopProductToSociologyMarket::getSociologyMarketId, marketId));
|
||||
if(integer>0){
|
||||
continue;
|
||||
}
|
||||
@@ -152,7 +152,7 @@ public class ShopProductServiceImpl extends ServiceImpl<ShopProductDao, ShopProd
|
||||
@Override
|
||||
public void bindProductAndMedicineLabel(String[] productId, int labelId) {
|
||||
for (String p : productId){
|
||||
Integer integer = shopProductToMedicineLabelDao.selectCount(new LambdaQueryWrapper<ShopProductToMedicineLabel>().eq(ShopProductToMedicineLabel::getProductId, Integer.valueOf(p)).eq(ShopProductToMedicineLabel::getMedicineLabelId, labelId));
|
||||
long integer = shopProductToMedicineLabelDao.selectCount(new LambdaQueryWrapper<ShopProductToMedicineLabel>().eq(ShopProductToMedicineLabel::getProductId, Integer.valueOf(p)).eq(ShopProductToMedicineLabel::getMedicineLabelId, labelId));
|
||||
if(integer>0){
|
||||
continue;
|
||||
}
|
||||
@@ -171,7 +171,7 @@ public class ShopProductServiceImpl extends ServiceImpl<ShopProductDao, ShopProd
|
||||
@Override
|
||||
public void bindProductAndMedicineMarket(String[] productId, int marketId) {
|
||||
for (String p:productId){
|
||||
Integer integer = shopProductToMedicineMarketDao.selectCount(new LambdaQueryWrapper<ShopProductToMedicineMarket>().eq(ShopProductToMedicineMarket::getProductId, Integer.valueOf(p)).eq(ShopProductToMedicineMarket::getMedicineMarketId, marketId));
|
||||
long integer = shopProductToMedicineMarketDao.selectCount(new LambdaQueryWrapper<ShopProductToMedicineMarket>().eq(ShopProductToMedicineMarket::getProductId, Integer.valueOf(p)).eq(ShopProductToMedicineMarket::getMedicineMarketId, marketId));
|
||||
if(integer>0){
|
||||
continue;
|
||||
}
|
||||
@@ -210,7 +210,7 @@ public class ShopProductServiceImpl extends ServiceImpl<ShopProductDao, ShopProd
|
||||
|
||||
@Override
|
||||
public R bindProductAndBook(int productId, int bookId) {
|
||||
Integer integer = shopProductBookDao.selectCount(new LambdaQueryWrapper<ShopProductBookEntity>().eq(ShopProductBookEntity::getProductId, productId).eq(ShopProductBookEntity::getBookId, bookId));
|
||||
long integer = shopProductBookDao.selectCount(new LambdaQueryWrapper<ShopProductBookEntity>().eq(ShopProductBookEntity::getProductId, productId).eq(ShopProductBookEntity::getBookId, bookId));
|
||||
if(integer>0){
|
||||
return R.error("重复绑定");
|
||||
}
|
||||
@@ -260,7 +260,7 @@ public class ShopProductServiceImpl extends ServiceImpl<ShopProductDao, ShopProd
|
||||
|
||||
@Override
|
||||
public R bindProductAndCourse(ShopProductCourseEntity shopProductCourseEntity) {
|
||||
Integer integer = shopProductCourseDao.selectCount(new LambdaQueryWrapper<ShopProductCourseEntity>().eq(ShopProductCourseEntity::getProductId, shopProductCourseEntity.getProductId()).eq(ShopProductCourseEntity::getCourseId, shopProductCourseEntity.getCourseId()));
|
||||
long integer = shopProductCourseDao.selectCount(new LambdaQueryWrapper<ShopProductCourseEntity>().eq(ShopProductCourseEntity::getProductId, shopProductCourseEntity.getProductId()).eq(ShopProductCourseEntity::getCourseId, shopProductCourseEntity.getCourseId()));
|
||||
if(integer>0){
|
||||
return R.error("不可重复绑定");
|
||||
}
|
||||
@@ -283,7 +283,7 @@ public class ShopProductServiceImpl extends ServiceImpl<ShopProductDao, ShopProd
|
||||
LambdaQueryWrapper<BuyOrder> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(BuyOrder::getProductId,productId);
|
||||
wrapper.in(BuyOrder::getOrderType,Arrays.asList(0,1,2));
|
||||
Integer integer = buyOrderDao.selectCount(wrapper);
|
||||
long integer = buyOrderDao.selectCount(wrapper);
|
||||
if(integer>0){
|
||||
return R.error(505,"删除失败,有人下单,且订单未完成");
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ public class ShopStoreServiceImpl extends ServiceImpl<ShopStoreDao, ShopStore> i
|
||||
|
||||
@Override
|
||||
public R delStore(int id) {
|
||||
Integer integer = shopStoreToProductDao.selectCount(new LambdaQueryWrapper<ShopStoreToProductEntity>().eq(ShopStoreToProductEntity::getStoreId, id));
|
||||
long integer = shopStoreToProductDao.selectCount(new LambdaQueryWrapper<ShopStoreToProductEntity>().eq(ShopStoreToProductEntity::getStoreId, id));
|
||||
if(integer>0){
|
||||
return R.error("请先清空后,再操作");
|
||||
}
|
||||
|
||||
@@ -119,7 +119,7 @@ public class CourseMedicalServiceImpl extends ServiceImpl<CourseMedicineDao, Cou
|
||||
if (courseCatalogueEntities.size() > 0){
|
||||
for (CourseCatalogueEntity cc:courseCatalogueEntities){
|
||||
if ("0".equals(vip)||"3".equals(vip)){
|
||||
Integer i = userCourseBuyDao.selectCount(new LambdaQueryWrapper<UserCourseBuyEntity>()
|
||||
long i = userCourseBuyDao.selectCount(new LambdaQueryWrapper<UserCourseBuyEntity>()
|
||||
.eq(UserCourseBuyEntity::getCatalogueId, cc.getId())
|
||||
.eq(UserCourseBuyEntity::getUserId, ShiroUtils.getUId()));
|
||||
cc.setIsBuy(i>0?1:0);
|
||||
|
||||
@@ -86,7 +86,7 @@ public class CourseServiceImpl extends ServiceImpl<CourseDao, CourseEntity> impl
|
||||
|
||||
@Override
|
||||
public R addUserCourseStudying(UserCourseStudying userCourseStudying) {
|
||||
int isExist = studyingDao.selectCount(new LambdaQueryWrapper<UserCourseStudying>()
|
||||
long isExist = studyingDao.selectCount(new LambdaQueryWrapper<UserCourseStudying>()
|
||||
.eq(UserCourseStudying::getUserId,userCourseStudying.getUserId())
|
||||
.eq(UserCourseStudying::getCourseId,userCourseStudying.getCourseId()));
|
||||
if (isExist>0){
|
||||
@@ -209,7 +209,7 @@ public class CourseServiceImpl extends ServiceImpl<CourseDao, CourseEntity> impl
|
||||
List<CourseEntity> courseEntities = courseEntityPage.getRecords();
|
||||
if(courseEntities!=null&&courseEntities.size()>0){
|
||||
for (CourseEntity co:courseEntities){
|
||||
int i = studyingDao.selectCount(new LambdaQueryWrapper<UserCourseStudying>().eq(UserCourseStudying::getCourseId,co.getId()).eq(UserCourseStudying::getUserId,user.getId()));
|
||||
long i = studyingDao.selectCount(new LambdaQueryWrapper<UserCourseStudying>().eq(UserCourseStudying::getCourseId,co.getId()).eq(UserCourseStudying::getUserId,user.getId()));
|
||||
co.setIsStudying(i>0?1:0);
|
||||
MPJLambdaWrapper<CourseCatalogueEntity> catalogueWrapper = new MPJLambdaWrapper();
|
||||
catalogueWrapper.eq(CourseCatalogueEntity::getCourseId, co.getId());
|
||||
@@ -322,7 +322,7 @@ public class CourseServiceImpl extends ServiceImpl<CourseDao, CourseEntity> impl
|
||||
HashMap<String, String> userVip = new HashMap<>();
|
||||
userVip.put("vip",userEntity.getVip());
|
||||
if (userEntity.getVip().equals("3")){
|
||||
Integer integer = courseToSociologyDao.selectCount(new LambdaQueryWrapper<CourseToSociologyEntity>().eq(CourseToSociologyEntity::getCourseId, id));
|
||||
long integer = courseToSociologyDao.selectCount(new LambdaQueryWrapper<CourseToSociologyEntity>().eq(CourseToSociologyEntity::getCourseId, id));
|
||||
userVip.put("vipCan",integer>0?"1":"0");
|
||||
}
|
||||
flag.put("vip",userVip);
|
||||
|
||||
@@ -33,8 +33,8 @@ public class VipBuyConfigServiceImpl extends ServiceImpl<VipBuyConfigDao, VipBuy
|
||||
public R getVipProductForUser() {
|
||||
int uid = ShiroUtils.getUId();
|
||||
MyUserEntity userEntity = myUserDao.selectById(uid);
|
||||
Integer chaoCount = userVipDao.selectCount(new LambdaQueryWrapper<UserVip>().eq(UserVip::getUserId, uid).eq(UserVip::getType, 1).gt(UserVip::getEndTime,new Date()).eq(UserVip::getState,0));
|
||||
Integer medicalCount = userVipDao.selectCount(new LambdaQueryWrapper<UserVip>().eq(UserVip::getUserId, uid).eq(UserVip::getType, 2).gt(UserVip::getEndTime, new Date()).eq(UserVip::getState, 0));
|
||||
long chaoCount = userVipDao.selectCount(new LambdaQueryWrapper<UserVip>().eq(UserVip::getUserId, uid).eq(UserVip::getType, 1).gt(UserVip::getEndTime,new Date()).eq(UserVip::getState,0));
|
||||
long medicalCount = userVipDao.selectCount(new LambdaQueryWrapper<UserVip>().eq(UserVip::getUserId, uid).eq(UserVip::getType, 2).gt(UserVip::getEndTime, new Date()).eq(UserVip::getState, 0));
|
||||
//获取超v列表
|
||||
LambdaQueryWrapper<VipBuyConfigEntity> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.in(VipBuyConfigEntity::getType,userEntity.getVip().equals("1")||userEntity.getVip().equals("3")? Collections.singletonList(1): Arrays.asList(1,2));
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user